1import{W as im,S as sm}from"./ImageUploader-528d6ef1.js";import{B as wd}from"./SelectSource.svelte_svelte_type_style_lang-0a285437.js";import{w as Vt,a as Td,c as qs,f as nm,h as Ed,S as Ad}from"./Index-26cfc80a.js";import"./Image-21c02477.js";/* empty css */import{u as fo,p as po}from"./index-a80d931b.js";import{_ as om}from"./__vite-browser-external-d8e3c0c7.js";import{I as mi}from"./IconButton-7294c90b.js";import{C as am}from"./Check-965babbe.js";import{C as lm}from"./Clear-2c7bae91.js";import{U as hm}from"./Undo-b088de14.js";import{U as cm}from"./ModifyUpload.svelte_svelte_type_style_lang-4ba51100.js";import{D as um}from"./DropdownArrow-bb2afb7e.js";import{I as Sd}from"./Image-eaba773f.js";import{U as dm,I as fm}from"./Upload-351cc897.js";import{W as pm}from"./SelectSource-f5281119.js";import{B as mm}from"./BlockLabel-f27805b1.js";import"./utils-572af92b.js";import"./Empty-28f63bf0.js";import"./ShareButton-7dae44e7.js";import"./DownloadLink-7ff36416.js";import"./file-url-bef2dc1b.js";import"./svelte/svelte.js";const{SvelteComponent:_m,append:mh,attr:vr,detach:gm,init:ym,insert:vm,noop:mo,safe_not_equal:bm,svg_element:_o}=window.__gradio__svelte__internal;function xm(i){let t,e,r;return{c(){t=_o("svg"),e=_o("path"),r=_o("path"),vr(e,"d","M28.828 3.172a4.094 4.094 0 0 0-5.656 0L4.05 22.292A6.954 6.954 0 0 0 2 27.242V30h2.756a6.952 6.952 0 0 0 4.95-2.05L28.828 8.829a3.999 3.999 0 0 0 0-5.657zM10.91 18.26l2.829 2.829l-2.122 2.121l-2.828-2.828zm-2.619 8.276A4.966 4.966 0 0 1 4.756 28H4v-.759a4.967 4.967 0 0 1 1.464-3.535l1.91-1.91l2.829 2.828zM27.415 7.414l-12.261 12.26l-2.829-2.828l12.262-12.26a2.047 2.047 0 0 1 2.828 0a2 2 0 0 1 0 2.828z"),vr(e,"fill","currentColor"),vr(r,"d","M6.5 15a3.5 3.5 0 0 1-2.475-5.974l3.5-3.5a1.502 1.502 0 0 0 0-2.121a1.537 1.537 0 0 0-2.121 0L3.415 5.394L2 3.98l1.99-1.988a3.585 3.585 0 0 1 4.95 0a3.504 3.504 0 0 1 0 4.949L5.439 10.44a1.502 1.502 0 0 0 0 2.121a1.537 1.537 0 0 0 2.122 0l4.024-4.024L13 9.95l-4.025 4.024A3.475 3.475 0 0 1 6.5 15z"),vr(r,"fill","currentColor"),vr(t,"width","100%"),vr(t,"height","100%"),vr(t,"viewBox","0 0 32 32")},m(s,n){vm(s,t,n),mh(t,e),mh(t,r)},p:mo,i:mo,o:mo,d(s){s&&gm(t)}}}let wm=class extends _m{constructor(t){super(),ym(this,t,null,xm,bm,{})}};const{SvelteComponent:Tm,append:Em,attr:$r,detach:Am,init:Sm,insert:Cm,noop:go,safe_not_equal:Im,svg_element:_h}=window.__gradio__svelte__internal;function Rm(i){let t,e;return{c(){t=_h("svg"),e=_h("path"),$r(e,"fill","currentColor"),$r(e,"d","M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10s10-4.47 10-10S17.53 2 12 2z"),$r(t,"xmlns","http://www.w3.org/2000/svg"),$r(t,"width","100%"),$r(t,"height","100%"),$r(t,"viewBox","0 0 24 24")},m(r,s){Cm(r,t,s),Em(t,e)},p:go,i:go,o:go,d(r){r&&Am(t)}}}let Pm=class extends Tm{constructor(t){super(),Sm(this,t,null,Rm,Im,{})}};const{SvelteComponent:Mm,append:Bm,attr:jr,detach:km,init:Dm,insert:Fm,noop:yo,safe_not_equal:Om,svg_element:gh}=window.__gradio__svelte__internal;function Nm(i){let t,e;return{c(){t=gh("svg"),e=gh("path"),jr(e,"fill","currentColor"),jr(e,"d","M17 23v-4H7q-.825 0-1.413-.588T5 17V7H1V5h4V1h2v16h16v2h-4v4h-2Zm0-8V7H9V5h8q.825 0 1.413.588T19 7v8h-2Z"),jr(t,"xmlns","http://www.w3.org/2000/svg"),jr(t,"width","100%"),jr(t,"height","100%"),jr(t,"viewBox","0 0 24 24")},m(r,s){Fm(r,t,s),Bm(t,e)},p:yo,i:yo,o:yo,d(r){r&&km(t)}}}let Lm=class extends Mm{constructor(t){super(),Dm(this,t,null,Nm,Om,{})}};const{SvelteComponent:Um,append:vo,attr:re,detach:Gm,init:Hm,insert:zm,noop:bo,safe_not_equal:Xm,svg_element:ds}=window.__gradio__svelte__internal;function Vm(i){let t,e,r,s;return{c(){t=ds("svg"),e=ds("g"),r=ds("path"),s=ds("path"),re(r,"fill","currentColor"),re(r,"d","m5.505 11.41l.53.53l-.53-.53ZM3 14.952h-.75H3ZM9.048 21v.75V21ZM11.41 5.505l-.53-.53l.53.53Zm1.831 12.34a.75.75 0 0 0 1.06-1.061l-1.06 1.06ZM7.216 9.697a.75.75 0 1 0-1.06 1.061l1.06-1.06Zm10.749 2.362l-5.905 5.905l1.06 1.06l5.905-5.904l-1.06-1.06Zm-11.93-.12l5.905-5.905l-1.06-1.06l-5.905 5.904l1.06 1.06Zm0 6.025c-.85-.85-1.433-1.436-1.812-1.933c-.367-.481-.473-.79-.473-1.08h-1.5c0 .749.312 1.375.78 1.99c.455.596 1.125 1.263 1.945 2.083l1.06-1.06Zm-1.06-7.086c-.82.82-1.49 1.488-1.945 2.084c-.468.614-.78 1.24-.78 1.99h1.5c0-.29.106-.6.473-1.08c.38-.498.962-1.083 1.812-1.933l-1.06-1.06Zm7.085 7.086c-.85.85-1.435 1.433-1.933 1.813c-.48.366-.79.472-1.08.472v1.5c.75 0 1.376-.312 1.99-.78c.596-.455 1.264-1.
1125 2.084-1.945l-1.06-1.06Zm-7.085 1.06c.82.82 1.487 1.49 2.084 1.945c.614.468 1.24.78 1.989.78v-1.5c-.29 0-.599-.106-1.08-.473c-.497-.38-1.083-.962-1.933-1.812l-1.06 1.06Zm12.99-12.99c.85.85 1.433 1.436 1.813 1.933c.366.481.472.79.472 1.08h1.5c0-.749-.312-1.375-.78-1.99c-.455-.596-1.125-1.263-1.945-2.083l-1.06 1.06Zm1.06 7.086c.82-.82 1.49-1.488 1.945-2.084c.468-.614.78-1.24.78-1.99h-1.5c0 .29-.106.6-.473 1.08c-.38.498-.962 1.083-1.812 1.933l1.06 1.06Zm0-8.146c-.82-.82-1.487-1.49-2.084-1.945c-.614-.468-1.24-.78-1.989-.78v1.5c.29 0 .599.106 1.08.473c.497.38 1.083.962 1.933 1.812l1.06-1.06Zm-7.085 1.06c.85-.85 1.435-1.433 1.933-1.812c.48-.367.79-.473 1.08-.473v-1.5c-.75 0-1.376.312-1.99.78c-.596.455-1.264 1.125-2.084 1.945l1.06 1.06Zm2.362 10.749L7.216 9.698l-1.06 1.061l7.085 7.085l1.06-1.06Z"),re(s,"stroke","currentColor"),re(s,"stroke-linecap","round"),re(s,"stroke-width","1.5"),re(s,"d","M9 21h12"),re(e,"fill","none"),re(t,"xmlns","http://www.w3.org/2000/svg"),re(t,"width","100%"),re(t,"height","100%"),re(t,"viewBox","0 0 24 24")},m(n,o){zm(n,t,o),vo(t,e),vo(e,r),vo(e,s)},p:bo,i:bo,o:bo,d(n){n&&Gm(t)}}}class Wm extends Um{constructor(t){super(),Hm(this,t,null,Vm,Xm,{})}}const{SvelteComponent:$m,append:jm,attr:Yr,detach:Ym,init:qm,insert:Zm,noop:xo,safe_not_equal:Km,svg_element:yh}=window.__gradio__svelte__internal;function Jm(i){let t,e;return{c(){t=yh("svg"),e=yh("path"),Yr(e,"fill","currentColor"),Yr(e,"d","M21.03 2.97a3.578 3.578 0 0 0-5.06 0L14 4.94l-.013-.013a1.75 1.75 0 0 0-2.475 0l-.585.586a1.75 1.75 0 0 0 0 2.475l.012.012l-6.78 6.78a2.25 2.25 0 0 0-.659 1.592v.687l-1.28 2.347c-.836 1.533.841 3.21 2.374 2.375l2.347-1.28h.688a2.25 2.25 0 0 0 1.59-.66L16 13.061l.012.012a1.75 1.75 0 0 0 2.475 0l.586-.585a1.75 1.75 0 0 0 0-2.475L19.061 10l1.97-1.97a3.578 3.578 0 0 0 0-5.06ZM12 9.061l2.94 2.94l-6.78 6.78a.75.75 0 0 1-.531.22H6.75a.75.75 0 0 0-.359.09l-2.515 1.373a.234.234 0 0 1-.159.032a.264.264 0 0 1-.138-.075a.264.264 0 0 1-.075-.138a.234.234 0 0 1 .033-.158l1.372-2.515A.75.75 0 0 0 5 17.25v-.878a.75.75 0 0 1 .22-.53L12 9.06Z"),Yr(t,"xmlns","http://www.w3.org/2000/svg"),Yr(t,"width","100%"),Yr(t,"height","100%"),Yr(t,"viewBox","0 0 24 24")},m(r,s){Zm(r,t,s),jm(t,e)},p:xo,i:xo,o:xo,d(r){r&&Ym(t)}}}class Qm extends $m{constructor(t){super(),qm(this,t,null,Jm,Km,{})}}const{SvelteComponent:t_,append:ki,attr:Nt,detach:e_,init:r_,insert:i_,noop:wo,safe_not_equal:s_,svg_element:qr}=window.__gradio__svelte__internal;function n_(i){let t,e,r,s,n,o;return{c(){t=qr("svg"),e=qr("g"),r=qr("path"),s=qr("circle"),n=qr("circle"),o=qr("path"),Nt(r,"d","M2 12.026c0 5.146 3.867 9.387 8.847 9.96c.735.085 1.447-.228 1.97-.753a1.68 1.68 0 0 0 0-2.372c-.523-.525-.95-1.307-.555-1.934c1.576-2.508 9.738 3.251 9.738-4.9C22 6.488 17.523 2 12 2S2 6.489 2 12.026Z"),Nt(s,"cx","17.5"),Nt(s,"cy","11.5"),Nt(s,"r",".75"),Nt(n,"cx","6.5"),Nt(n,"cy","11.5"),Nt(n,"r",".75"),Nt(o,"d","M10.335 7a.75.75 0 1 1-1.5 0a.75.75 0 0 1 1.5 0Zm4.915 0a.75.75 0 1 1-1.5 0a.75.75 0 0 1 1.5 0Z"),Nt(e,"fill","none"),Nt(e,"stroke","currentColor"),Nt(e,"stroke-width","1.5"),Nt(t,"xmlns","http://www.w3.org/2000/svg"),Nt(t,"width","100%"),Nt(t,"height","100%"),Nt(t,"viewBox","0 0 24 24")},m(a,l){i_(a,t,l),ki(t,e),ki(e,r),ki(e,s),ki(e,n),ki(e,o)},p:wo,i:wo,o:wo,d(a){a&&e_(t)}}}class o_ extends t_{constructor(t){super(),r_(this,t,null,n_,s_,{})}}const{SvelteComponent:a_,append:vh,attr:Yt,detach:l_,init:h_,insert:c_,noop:To,safe_not_equal:u_,set_style:d_,svg_element:Eo}=window.__gradio__svelte__internal;function f_(i){let t,e,r;return{c(){t=Eo("svg"),e=Eo("polyline"),r=Eo("path"),Yt(e,"points","1 4 1 10 7 10"),Yt(r,"d","M3.51 15a9 9 0 1 0 2.13-9.36L1 10"),Yt(t,"xmlns","http://www.w3.org/2000/svg"),Yt(t,"width","100%"),Yt(t,"height","100%"),Yt(t,"viewBox","0 0 24 24"),Yt(t,"fill","none"),Yt(t,"stroke","currentColor"),Yt(t,"stroke-width","2"),Yt(t,"stroke-linecap","round"),Yt(t,"stroke-linejoin","round"),Yt(t,"class","feather feather-rotate-ccw"),d_(t,"transform","rotateY(180deg)")},m(s,n){c_(s,t,n),vh(t,e),vh(t,r)},p:To,i:To,o:To,d(s){s&&l_(t)}}}class p_ extends a_{constructor(t){super(),h_(this,t,null,f_,u_,{})}}const{SvelteComponent:m_,attr:__,create_slot:g_,detach:y_,element:v_,get_all_dirty_from_scope:b_,get_slot_changes:x_,init:w_,insert:T_,safe_not_equal:E_,toggle_class:bh,transition_in:A_,transition_out:S_,update_slot_base:C_}=window.__gradio__svelte__internal;function I_(i){let t,e;const r=i[2].default,s=g_(r,i,i[1],null);return{c(){t=v_("div"),s&&s.c(),__(t,"class","svelte-1geikgz"),bh(t,"show_border",i[0])},m(n,o){T_(n,t,o),s&&s.m(t,null),e=!0},p(n,[o]){s&&s.p&&(!e||o&2)&&C_(s,r,n,n[1],e?x_(r,n[1],o,null):b_(n[1]),null),(!e||o&1)&&bh(t,"show_border",n[0])},i(n){e||(A_(s,n),e=!0)},o(n){S_(s,n),e=!1},d(n){n&&y_(t),s&&s.d(n)}}}function R_(i,t,e){let{$$slots:r={},$$scope:s}=t,{show_border:n=!1}=t;return i.$$set=o=>{"show_border"in o&&e(0,n=o.show_border),"$$scope"in o&&e(1,s=o.$$scope)},[n,s,r]}class xh extends m_{constructor(t){super(),w_(this,t,R_,I_,E_,{show_border:0})}}const{SvelteComponent:P_,append:M_,attr:B_,check_outros:Ul,component_subscribe:Ao,create_component:gn,create_slot:k_,destroy_component:yn,detach:Lr,element:D_,empty:as,ensure_array_like:vn,get_all_dirty_from_scope:F_,get_slot_changes:O_,group_outros:Gl,init:N_,insert:Ur,mount_component:bn,outro_and_destroy_block:Cd,safe_not_equal:L_,set_store_value:U_,space:wh,transition_in:Ae,transition_out:ze,update_keyed_each:Id,update_slot_base:G_}=window.__gradio__svelte__internal,{getContext:H_,setContext:z_}=window.__gradio__svelte__internal;function Th(i,t,e){const r=i.slice();return r[17]=t[e],r}function Eh(i,t,e){const r=i.slice();return r[20]=t[e],r}function Ah(i){let t=[],e=new Map,r,s,n=vn(i[3].options);const o=a=>a[20].id;for(let a=0;a<n.length;a+=1){let l=Eh(i,n,a),h=o(l);e.set(h,t[a]=Sh(h,l))}return{c(){for(let a=0;a<t.length;a+=1)t[a].c();r=as()},m(a,l){for(let h=0;h<t.length;h+=1)t[h]&&t[h].m(a,l);Ur(a,r,l),s=!0},p(a,l){l&541&&(n=vn(a[3].options),Gl(),t=Id(t,l,o,1,a,n,e,r.parentNode,Cd,Sh,r,Eh),Ul())},i(a){if(!s){for(let l=0;l<n.length;l+=1)Ae(t[l]);s=!0}},o(a){for(let l=0;l<t.length;l+=1)ze(t[l]);s=!1},d(a){a&&Lr(r);for(let l=0;l<t.length;l+=1)t[l].d(a)}}}function Sh(i,t){let e,r,s;function n(){return t[14](t[20])}return r=new mi({props:{highlight:t[2]===t[20].id&&t[20].id!=="brush_size",color:t[0]==="draw"&&t[20].id==="brush_size"?t[4]:void 0,Icon:t[20].icon,size:"large",padded:!1,label:t[20].label+" button",hasPopup:!0,transparent:!0}}),r.$on("click",n),{key:i,first:null,c(){e=as(),gn(r.$$.fragment),this.first=e},m(o,a){Ur(o,e,a),bn(r,o,a),s=!0},p(o,a){t=o;const l={};a&12&&(l.highlight=t[2]===t[20].id&&t[20].id!=="brush_size"),a&25&&(l.color=t[0]==="draw"&&t[20].id==="brush_size"?t[4]:void 0),a&8&&(l.Icon=t[20].icon),a&8&&(l.label=t[20].label+" button"),r.$set(l)},i(o){s||(Ae(r.$$.fragment,o),s=!0)},o(o){ze(r.$$.fragment,o),s=!1},d(o){o&&Lr(e),yn(r,o)}}}function X_(i){let t,e,r=i[3]&&Ah(i);return{c(){r&&r.c(),t=as()},m(s,n){r&&r.m(s,n),Ur(s,t,n),e=!0},p(s,n){s[3]?r?(r.p(s,n),n&8&&Ae(r,1)):(r=Ah(s),r.c(),Ae(r,1),r.m(t.parentNode,t)):r&&(Gl(),ze(r,1,1,()=>{r=null}),Ul())},i(s){e||(Ae(r),e=!0)},o(s){ze(r),e=!1},d(s){s&&Lr(t),r&&r.d(s)}}}function Ch(i,t){let e,r,s;function n(){return t[15](t[17])}return r=new mi({props:{disabled:t[17]==="bg"&&!!t[5].previous,highlight:t[0]===t[17],Icon:t[10][t[17]].icon,size:"large",padded:!1,label:t[10][t[17]].label+" button",transparent:!0}}),r.$on("click",n),{key:i,first:null,c(){e=as(),gn(r.$$.fragment),this.first=e},m(o,a){Ur(o,e,a),bn(r,o,a),s=!0},p(o,a){t=o;const l={};a&34&&(l.disabled=t[17]==="bg"&&!!t[5].previous),a&3&&(l.highlight=t[0]===t[17]),a&2&&(l.Icon=t[10][t[17]].icon),a&2&&(l.label=t[10][t[17]].label+" button"),r.$set(l)},i(o){s||(Ae(r.$$.fragment,o),s=!0)},o(o){ze(r.$$.fragment,o),s=!1},d(o){o&&Lr(e),yn(r,o)}}}function V_(i){let t=[],e=new Map,r,s,n=vn(i[1]);const o=a=>a[17];for(let a=0;a<n.length;a+=1){let l=Th(i,n,a),h=o(l);e.set(h,t[a]=Ch(h,l))}return{c(){for(let a=0;a<t.length;a+=1)t[a].c();r=as()},m(a,l){for(let h=0;h<t.length;h+=1)t[h]&&t[h].m(a,l);Ur(a,r,l),s=!0},p(a,l){l&1059&&(n=vn(a[1]),Gl(),t=Id(t,l,o,1,a,n,e,r.parentNode,Cd,Ch,r,Th),Ul())},i(a){if(!s){for(let l=0;l<n.length;l+=1)Ae(t[l]);s=!0}},o(a){for(let l=0;l<t.length;l+=1)ze(t[l]);s=!1},d(a){a&&Lr(r);for(let l=0;l<t.length;l+=1)t[l].d(a)}}}function W_(i){let t,e,r,s,n,o;const a=i[13].default,l=k_(a,i,i[16],null);return r=new xh({props:{show_border:!1,$$slots:{default:[X_]},$$scope:{ctx:i}}}),n=new xh({props:{show_border:!1,$$slots:{default:[V_]},$$scope:{ctx:i}}}),{c(){l&&l.c(),t=wh(),e=D_("div"),gn(r.$$.fragment),s=wh(),gn(n.$$.fragment),B_(e,"class","toolbar-wrap svelte-dybhw0")},m(h,c){l&&l.m(h,c),Ur(h,t,c),Ur(h,e,c),bn(r,e,null),M_(e,s),bn(n,e,null),o=!0},p(h,[c]){l&&l.p&&(!o||c&65536)&&G_(l,a,h,h[16],o?O_(a,h[16],c,null):F_(h[16]),null);const u={};c&65565&&(u.$$scope={dirty:c,ctx:h}),r.$set(u);const d={};c&65571&&(d.$$scope={dirty:c,ctx:h}),n.$set(d)},i(h){o||(Ae(l,h),Ae(r.$$.fragment,h),Ae(n.$$.fragment,h),o=!0)}
1,o(h){ze(l,h),ze(r.$$.fragment,h),ze(n.$$.fragment,h),o=!1},d(h){h&&(Lr(t),Lr(e)),l&&l.d(h),yn(r),yn(n)}}}const Yn=Symbol("tool");function $_(i,t,e){let r,s,n,o,{$$slots:a={},$$scope:l}=t;const{current_history:h,active_tool:c}=H_(Bi);Ao(i,h,b=>e(5,o=b)),Ao(i,c,b=>e(0,s=b));let{i18n:u}=t,d=[];const f={draw:null,erase:null,crop:null,bg:null};let p=Vt("#000000");Ao(i,p,b=>e(4,n=b));let g;const y={current_color:p,register_tool:(b,w)=>(e(1,d=[...d,b]),e(12,f[b]=w,f),()=>{e(1,d=d.filter(A=>A!==b))}),active_tool:{subscribe:c.subscribe},activate_subtool:(b,w)=>{e(2,g=b),w&&w()}};z_(Yn,y);const m={bg:{order:0,label:u("Image"),icon:Sd},crop:{order:1,label:u("Transform"),icon:Lm},draw:{order:2,label:u("Draw"),icon:wm},erase:{order:2,label:u("Erase"),icon:Wm}},v=b=>y.activate_subtool(b.id,b.cb),_=b=>U_(c,s=b,s);return i.$$set=b=>{"i18n"in b&&e(11,u=b.i18n),"$$scope"in b&&e(16,l=b.$$scope)},i.$$.update=()=>{i.$$.dirty&4097&&e(3,r=s&&f[s])},[s,d,g,r,n,o,h,c,p,y,m,u,f,a,v,_,l]}class j_ extends P_{constructor(t){super(),N_(this,t,$_,W_,L_,{i18n:11})}}function xn(i){"@babel/helpers - typeof";return xn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xn(i)}var Y_=/^\s+/,q_=/\s+$/;function X(i,t){if(i=i||"",t=t||{},i instanceof X)return i;if(!(this instanceof X))return new X(i,t);var e=Z_(i);this._originalInput=i,this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||e.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=e.ok}X.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),e,r,s,n,o,a;return e=t.r/255,r=t.g/255,s=t.b/255,e<=.03928?n=e/12.92:n=Math.pow((e+.055)/1.055,2.4),r<=.03928?o=r/12.92:o=Math.pow((r+.055)/1.055,2.4),s<=.03928?a=s/12.92:a=Math.pow((s+.055)/1.055,2.4),.2126*n+.7152*o+.0722*a},setAlpha:function(t){return this._a=Rd(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=Rh(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=Rh(this._r,this._g,this._b),e=Math.round(t.h*360),r=Math.round(t.s*100),s=Math.round(t.v*100);return this._a==1?"hsv("+e+", "+r+"%, "+s+"%)":"hsva("+e+", "+r+"%, "+s+"%, "+this._roundA+")"},toHsl:function(){var t=Ih(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=Ih(this._r,this._g,this._b),e=Math.round(t.h*360),r=Math.round(t.s*100),s=Math.round(t.l*100);return this._a==1?"hsl("+e+", "+r+"%, "+s+"%)":"hsla("+e+", "+r+"%, "+s+"%, "+this._roundA+")"},toHex:function(t){return Ph(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return tg(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(pt(this._r,255)*100)+"%",g:Math.round(pt(this._g,255)*100)+"%",b:Math.round(pt(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(pt(this._r,255)*100)+"%, "+Math.round(pt(this._g,255)*100)+"%, "+Math.round(pt(this._b,255)*100)+"%)":"rgba("+Math.round(pt(this._r,255)*100)+"%, "+Math.round(pt(this._g,255)*100)+"%, "+Math.round(pt(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:dg[Ph(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var e="#"+Mh(this._r,this._g,this._b,this._a),r=e,s=this._gradientType?"GradientType = 1, ":"";if(t){var n=X(t);r="#"+Mh(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+s+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,s=this._a<1&&this._a>=0,n=!e&&s&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return n?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(r=this.toRgbString()),t==="prgb"&&(r=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(r=this.toHexString()),t==="hex3"&&(r=this.toHexString(!0)),t==="hex4"&&(r=this.toHex8String(!0)),t==="hex8"&&(r=this.toHex8String()),t==="name"&&(r=this.toName()),t==="hsl"&&(r=this.toHslString()),t==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return X(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(sg,arguments)},brighten:function(){return this._applyModification(ng,arguments)},darken:function(){return this._applyModification(og,arguments)},desaturate:function(){return this._applyModification(eg,arguments)},saturate:function(){return this._applyModification(rg,arguments)},greyscale:function(){return this._applyModification(ig,arguments)},spin:function(){return this._applyModification(ag,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(cg,arguments)},complement:function(){return this._applyCombination(lg,arguments)},monochromatic:function(){return this._applyCombination(ug,arguments)},splitcomplement:function(){return this._applyCombination(hg,arguments)},triad:function(){return this._applyCombination(Bh,[3])},tetrad:function(){return this._applyCombination(Bh,[4])}};X.fromRatio=function(i,t){if(xn(i)=="object"){var e={};for(var r in i)i.hasOwnProperty(r)&&(r==="a"?e[r]=i[r]:e[r]=Gi(i[r]));i=e}return X(i,t)};function Z_(i){var t={r:0,g:0,b:0},e=1,r=null,s=null,n=null,o=!1,a=!1;return typeof i=="string"&&(i=_g(i)),xn(i)=="object"&&(Me(i.r)&&Me(i.g)&&Me(i.b)?(t=K_(i.r,i.g,i.b),o=!0,a=String(i.r).substr(-1)==="%"?"prgb":"rgb"):Me(i.h)&&Me(i.s)&&Me(i.v)?(r=Gi(i.s),s=Gi(i.v),t=Q_(i.h,r,s),o=!0,a="hsv"):Me(i.h)&&Me(i.s)&&Me(i.l)&&(r=Gi(i.s),n=Gi(i.l),t=J_(i.h,r,n),o=!0,a="hsl"),i.hasOwnProperty("a")&&(e=i.a)),e=Rd(e),{ok:o,format:i.format||a,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:e}}function K_(i,t,e){return{r:pt(i,255)*255,g:pt(t,255)*255,b:pt(e,255)*255}}function Ih(i,t,e){i=pt(i,255),t=pt(t,255),e=pt(e,255);var r=Math.max(i,t,e),s=Math.min(i,t,e),n,o,a=(r+s)/2;if(r==s)n=o=0;else{var l=r-s;switch(o=a>.5?l/(2-r-s):l/(r+s),r){case i:n=(t-e)/l+(t<e?6:0);break;case t:n=(e-i)/l+2;break;case e:n=(i-t)/l+4;break}n/=6}return{h:n,s:o,l:a}}function J_(i,t,e){var r,s,n;i=pt(i,360),t=pt(t,100),e=pt(e,100);function o(h,c,u){return u<0&&(u+=1),u>1&&(u-=1),u<1/6?h+(c-h)*6*u:u<1/2?c:u<2/3?h+(c-h)*(2/3-u)*6:h}if(t===0)r=s=n=e;else{var a=e<.5?e*(1+t):e+t-e*t,l=2*e-a;r=o(l,a,i+1/3),s=o(l,a,i),n=o(l,a,i-1/3)}return{r:r*255,g:s*255,b:n*255}}function Rh(i,t,e){i=pt(i,255),t=pt(t,255),e=pt(e,255);var r=Math.max(i,t,e),s=Math.min(i,t,e),n,o,a=r,l=r-s;if(o=r===0?0:l/r,r==s)n=0;else{switch(r){case i:n=(t-e)/l+(t<e?6:0);break;case t:n=(e-i)/l+2;break;case e:n=(i-t)/l+4;break}n/=6}return{h:n,s:o,v:a}}function Q_(i,t,e){i=pt(i,360)*6,t=pt(t,100),e=pt(e,100);var r=Math.floor(i),s=i-r,n=e*(1-t),o=e*(1-s*t),a=e*(1-(1-s)*t),l=r%6,h=[e,o,n,n,a,e][l],c=[a,e,e,o,n,n][l],u=[n,n,a,e,e,o][l];return{r:h*255,g:c*255,b:u*255}}function Ph(i,t,e,r){var s=[he(Math.round(i).toString(16)),he(Math.round(t).toString(16)),he(Math.round(e).toString(16))];return r&&s[0].charAt(0)==s[0].charAt(1)&&s[1].charAt(0)==s[1].charAt(1)&&s[2].charAt(0)==s[2].charAt(1)?s[0].charAt(0)+s[1].charAt(0)+s[2].charAt(0):s.join("")}function tg(i,t,e,r,s){var n=[he(Math.round(i).toString(16)),he(Math.round(t).toString(16)),he(Math.round(e).toString(16)),he(Pd(r))];return s&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)&&n[3].charAt(0)==n[3].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")}function Mh(i,t,e,r){var s=[he(Pd(r)),he(Math.round(i).toString(16)),he(Math.round(t).toString(16)),he(Math.round(e).toString(16))];return s.join("")}X.equals=function(i,t){return!i||!t?!1:X(i).toRgbString()==X(t).toRgbString()};X.random=function(){return X.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function eg(i,t){t=t===0?0:t||10;var e=X(i).toHsl();return e.s-=t/100,e.s=qn(e.s),X(e)}function rg(i,t){t=t===0?0:t||10;var e=X(i).toHsl();return e.s+=t/100,e.s=qn(e.s),X(e)}function ig(i){return X(i).desaturate(100)}function sg(i,t){t=t===0?0:t||10;var e=X(i).toHsl();return e.l+=t/100,e.l=qn(e.l),X(e)}function ng(i,t){t=t===0?0:t||10;var e=X(i).toRgb();return e.r=Math.max(0,Math.min(255,e.r-Math.round(255*-(t/100)))),e.g=M
vendor: 3,145 bytes, line 1
1ath.max(0,Math.min(255,e.g-Math.round(255*-(t/100)))),e.b=Math.max(0,Math.min(255,e.b-Math.round(255*-(t/100)))),X(e)}function og(i,t){t=t===0?0:t||10;var e=X(i).toHsl();return e.l-=t/100,e.l=qn(e.l),X(e)}function ag(i,t){var e=X(i).toHsl(),r=(e.h+t)%360;return e.h=r<0?360+r:r,X(e)}function lg(i){var t=X(i).toHsl();return t.h=(t.h+180)%360,X(t)}function Bh(i,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var e=X(i).toHsl(),r=[X(i)],s=360/t,n=1;n<t;n++)r.push(X({h:(e.h+n*s)%360,s:e.s,l:e.l}));return r}function hg(i){var t=X(i).toHsl(),e=t.h;return[X(i),X({h:(e+72)%360,s:t.s,l:t.l}),X({h:(e+216)%360,s:t.s,l:t.l})]}function cg(i,t,e){t=t||6,e=e||30;var r=X(i).toHsl(),s=360/e,n=[X(i)];for(r.h=(r.h-(s*t>>1)+720)%360;--t;)r.h=(r.h+s)%360,n.push(X(r));return n}function ug(i,t){t=t||6;for(var e=X(i).toHsv(),r=e.h,s=e.s,n=e.v,o=[],a=1/t;t--;)o.push(X({h:r,s,v:n})),n=(n+a)%1;return o}X.mix=function(i,t,e){e=e===0?0:e||50;var r=X(i).toRgb(),s=X(t).toRgb(),n=e/100,o={r:(s.r-r.r)*n+r.r,g:(s.g-r.g)*n+r.g,b:(s.b-r.b)*n+r.b,a:(s.a-r.a)*n+r.a};return X(o)};X.readability=function(i,t){var e=X(i),r=X(t);return(Math.max(e.getLuminance(),r.getLuminance())+.05)/(Math.min(e.getLuminance(),r.getLuminance())+.05)};X.isReadable=function(i,t,e){var r=X.readability(i,t),s,n;switch(n=!1,s=gg(e),s.level+s.size){case"AAsmall":case"AAAlarge":n=r>=4.5;break;case"AAlarge":n=r>=3;break;case"AAAsmall":n=r>=7;break}return n};X.mostReadable=function(i,t,e){var r=null,s=0,n,o,a,l;e=e||{},o=e.includeFallbackColors,a=e.level,l=e.size;for(var h=0;h<t.length;h++)n=X.readability(i,t[h]),n>s&&(s=n,r=X(t[h]));return X.isReadable(i,r,{level:a,size:l})||!o?r:(e.includeFallbackColors=!1,X.mostReadable(i,["#fff","#000"],e))};var Ea=X.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee9
10",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},dg=X.hexNames=fg(Ea);function fg(i){var t={};for(var e in i)i.hasOwnProperty(e)&&(t[i[e]]=e);return t}function Rd(i){return i=parseFloat(i),(isNaN(i)||i<0||i>1)&&(i=1),i}function pt(i,t){pg(i)&&(i="100%");var e=mg(i);return i=Math.min(t,Math.max(0,parseFloat(i))),e&&(i=parseInt(i*t,10)/100),Math.abs(i-t)<1e-6?1:i%t/parseFloat(t)}function qn(i){return Math.min(1,Math.max(0,i))}function zt(i){return parseInt(i,16)}function pg(i){return typeof i=="string"&&i.indexOf(".")!=-1&&parseFloat(i)===1}function mg(i){return typeof i=="string"&&i.indexOf("%")!=-1}function he(i){return i.length==1?"0"+i:""+i}function Gi(i){return i<=1&&(i=i*100+"%"),i}function Pd(i){return Math.round(parseFloat(i)*255).toString(16)}function kh(i){return zt(i)/255}var ne=function(){var i="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",e="(?:"+t+")|(?:"+i+")",r="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",s="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:new RegExp(e),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+s),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+s),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"
1+s),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Me(i){return!!ne.CSS_UNIT.exec(i)}function _g(i){i=i.replace(Y_,"").replace(q_,"").toLowerCase();var t=!1;if(Ea[i])i=Ea[i],t=!0;else if(i=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var e;return(e=ne.rgb.exec(i))?{r:e[1],g:e[2],b:e[3]}:(e=ne.rgba.exec(i))?{r:e[1],g:e[2],b:e[3],a:e[4]}:(e=ne.hsl.exec(i))?{h:e[1],s:e[2],l:e[3]}:(e=ne.hsla.exec(i))?{h:e[1],s:e[2],l:e[3],a:e[4]}:(e=ne.hsv.exec(i))?{h:e[1],s:e[2],v:e[3]}:(e=ne.hsva.exec(i))?{h:e[1],s:e[2],v:e[3],a:e[4]}:(e=ne.hex8.exec(i))?{r:zt(e[1]),g:zt(e[2]),b:zt(e[3]),a:kh(e[4]),format:t?"name":"hex8"}:(e=ne.hex6.exec(i))?{r:zt(e[1]),g:zt(e[2]),b:zt(e[3]),format:t?"name":"hex"}:(e=ne.hex4.exec(i))?{r:zt(e[1]+""+e[1]),g:zt(e[2]+""+e[2]),b:zt(e[3]+""+e[3]),a:kh(e[4]+""+e[4]),format:t?"name":"hex8"}:(e=ne.hex3.exec(i))?{r:zt(e[1]+""+e[1]),g:zt(e[2]+""+e[2]),b:zt(e[3]+""+e[3]),format:t?"name":"hex"}:!1}function gg(i){var t,e;return i=i||{level:"AA",size:"small"},t=(i.level||"AA").toUpperCase(),e=(i.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),e!=="small"&&e!=="large"&&(e="small"),{level:t,size:e}}var Vr=(i=>(i[i.WEBGL_LEGACY=0]="WEBGL_LEGACY",i[i.WEBGL=1]="WEBGL",i[i.WEBGL2=2]="WEBGL2",i))(Vr||{}),Md=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.WEBGL=1]="WEBGL",i[i.CANVAS=2]="CANVAS",i))(Md||{}),Aa=(i=>(i[i.COLOR=16384]="COLOR",i[i.DEPTH=256]="DEPTH",i[i.STENCIL=1024]="STENCIL",i))(Aa||{}),Z=(i=>(i[i.NORMAL=0]="NORMAL",i[i.ADD=1]="ADD",i[i.MULTIPLY=2]="MULTIPLY",i[i.SCREEN=3]="SCREEN",i[i.OVERLAY=4]="OVERLAY",i[i.DARKEN=5]="DARKEN",i[i.LIGHTEN=6]="LIGHTEN",i[i.COLOR_DODGE=7]="COLOR_DODGE",i[i.COLOR_BURN=8]="COLOR_BURN",i[i.HARD_LIGHT=9]="HARD_LIGHT",i[i.SOFT_LIGHT=10]="SOFT_LIGHT",i[i.DIFFERENCE=11]="DIFFERENCE",i[i.EXCLUSION=12]="EXCLUSION",i[i.HUE=13]="HUE",i[i.SATURATION=14]="SATURATION",i[i.COLOR=15]="COLOR",i[i.LUMINOSITY=16]="LUMINOSITY",i[i.NORMAL_NPM=17]="NORMAL_NPM",i[i.ADD_NPM=18]="ADD_NPM",i[i.SCREEN_NPM=19]="SCREEN_NPM",i[i.NONE=20]="NONE",i[i.SRC_OVER=0]="SRC_OVER",i[i.SRC_IN=21]="SRC_IN",i[i.SRC_OUT=22]="SRC_OUT",i[i.SRC_ATOP=23]="SRC_ATOP",i[i.DST_OVER=24]="DST_OVER",i[i.DST_IN=25]="DST_IN",i[i.DST_OUT=26]="DST_OUT",i[i.DST_ATOP=27]="DST_ATOP",i[i.ERASE=26]="ERASE",i[i.SUBTRACT=28]="SUBTRACT",i[i.XOR=29]="XOR",i))(Z||{}),we=(i=>(i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN",i))(we||{}),F=(i=>(i[i.RGBA=6408]="RGBA",i[i.RGB=6407]="RGB",i[i.RG=33319]="RG",i[i.RED=6403]="RED",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.ALPHA=6406]="ALPHA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i))(F||{}),_i=(i=>(i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i))(_i||{}),q=(i=>(i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.BYTE=5120]="BYTE",i[i.SHORT=5122]="SHORT",i[i.INT=5124]="INT",i[i.FLOAT=5126]="FLOAT",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.HALF_FLOAT=36193]="HALF_FLOAT",i))(q||{}),G=(i=>(i[i.FLOAT=0]="FLOAT",i[i.INT=1]="INT",i[i.UINT=2]="UINT",i))(G||{}),Ne=(i=>(i[i.NEAREST=0]="NEAREST",i[i.LINEAR=1]="LINEAR",i))(Ne||{}),nr=(i=>(i[i.CLAMP=33071]="CLAMP",i[i.REPEAT=10497]="REPEAT",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i))(nr||{}),Ie=(i=>(i[i.OFF=0]="OFF",i[i.POW2=1]="POW2",i[i.ON=2]="ON",i[i.ON_MANUAL=3]="ON_MANUAL",i))(Ie||{}),Ht=(i=>(i[i.NPM=0]="NPM",i[i.UNPACK=1]="UNPACK",i[i.PMA=2]="PMA",i[i.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",i[i.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",i[i.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",i))(Ht||{}),be=(i=>(i[i.NO=0]="NO",i[i.YES=1]="YES",i[i.AUTO=2]="AUTO",i[i.BLEND=0]="BLEND",i[i.CLEAR=1]="CLEAR",i[i.BLIT=2]="BLIT",i))(be||{}),Hl=(i=>
1(i[i.AUTO=0]="AUTO",i[i.MANUAL=1]="MANUAL",i))(Hl||{}),Jt=(i=>(i.LOW="lowp",i.MEDIUM="mediump",i.HIGH="highp",i))(Jt||{}),Et=(i=>(i[i.NONE=0]="NONE",i[i.SCISSOR=1]="SCISSOR",i[i.STENCIL=2]="STENCIL",i[i.SPRITE=3]="SPRITE",i[i.COLOR=4]="COLOR",i))(Et||{}),xt=(i=>(i[i.NONE=0]="NONE",i[i.LOW=2]="LOW",i[i.MEDIUM=4]="MEDIUM",i[i.HIGH=8]="HIGH",i))(xt||{}),Se=(i=>(i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",i))(Se||{});const yg={createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,t)=>fetch(i,t),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")},H={ADAPTER:yg,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var So=/iPhone/i,Dh=/iPod/i,Fh=/iPad/i,Oh=/\biOS-universal(?:.+)Mac\b/i,Co=/\bAndroid(?:.+)Mobile\b/i,Nh=/Android/i,Zr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,fs=/Silk/i,Be=/Windows Phone/i,Lh=/\bWindows(?:.+)ARM\b/i,Uh=/BlackBerry/i,Gh=/BB10/i,Hh=/Opera Mini/i,zh=/\b(CriOS|Chrome)(?:.+)Mobile/i,Xh=/Mobile(?:.+)Firefox\b/i,Vh=function(i){return typeof i<"u"&&i.platform==="MacIntel"&&typeof i.maxTouchPoints=="number"&&i.maxTouchPoints>1&&typeof MSStream>"u"};function vg(i){return function(t){return t.test(i)}}function Wh(i){var t={userAgent:"",platform:"",maxTouchPoints:0};!i&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof i=="string"?t.userAgent=i:i&&i.userAgent&&(t={userAgent:i.userAgent,platform:i.platform,maxTouchPoints:i.maxTouchPoints||0});var e=t.userAgent,r=e.split("[FBAN");typeof r[1]<"u"&&(e=r[0]),r=e.split("Twitter"),typeof r[1]<"u"&&(e=r[0]);var s=vg(e),n={apple:{phone:s(So)&&!s(Be),ipod:s(Dh),tablet:!s(So)&&(s(Fh)||Vh(t))&&!s(Be),universal:s(Oh),device:(s(So)||s(Dh)||s(Fh)||s(Oh)||Vh(t))&&!s(Be)},amazon:{phone:s(Zr),tablet:!s(Zr)&&s(fs),device:s(Zr)||s(fs)},android:{phone:!s(Be)&&s(Zr)||!s(Be)&&s(Co),tablet:!s(Be)&&!s(Zr)&&!s(Co)&&(s(fs)||s(Nh)),device:!s(Be)&&(s(Zr)||s(fs)||s(Co)||s(Nh))||s(/\bokhttp\b/i)},windows:{phone:s(Be),tablet:s(Lh),device:s(Be)||s(Lh)},other:{blackberry:s(Uh),blackberry10:s(Gh),opera:s(Hh),firefox:s(Xh),chrome:s(zh),device:s(Uh)||s(Gh)||s(Hh)||s(Xh)||s(zh)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const bg=Wh.default??Wh,Le=bg(globalThis.navigator);H.RETINA_PREFIX=/@([0-9\.]+)x/;H.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Bd={exports:{}};(function(i){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function s(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function n(l,h,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,u||l,d),p=e?e+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new r:delete l._events[h]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],c,u;if(this._eventsCount===0)return h;for(u in c=this._events)t.call(c,u)&&h.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=e?e+h:h,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(h){var c=e?e+h:h,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(h,c,u,d,f,p){var g=e?e+h:h;if(!this._events[g])return!1;var y=this._events[g],m=arguments.length,v,_;if(y.fn){switch(y.once&&this.removeListener(h,y.fn,void 0,!0),m){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,c),!0;case 3:return y.fn.call(y.context,c,u),!0;case 4:return y.fn.call(y.context,c,u,d),!0;case 5:return y.fn.call(y.context,c,u,d,f),!0;case 6:return y.fn.call(y.context,c,u,d,f,p),!0}for(_=1,v=new Array(m-1);_<m;_++)v[_-1]=arguments[_];
vendor: 5,224 bytes, line 1
1y.fn.apply(y.context,v)}else{var b=y.length,w;for(_=0;_<b;_++)switch(y[_].once&&this.removeListener(h,y[_].fn,void 0,!0),m){case 1:y[_].fn.call(y[_].context);break;case 2:y[_].fn.call(y[_].context,c);break;case 3:y[_].fn.call(y[_].context,c,u);break;case 4:y[_].fn.call(y[_].context,c,u,d);break;default:if(!v)for(w=1,v=new Array(m-1);w<m;w++)v[w-1]=arguments[w];y[_].fn.apply(y[_].context,v)}}return!0},a.prototype.on=function(h,c,u){return n(this,h,c,u,!1)},a.prototype.once=function(h,c,u){return n(this,h,c,u,!0)},a.prototype.removeListener=function(h,c,u,d){var f=e?e+h:h;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var g=0,y=[],m=p.length;g<m;g++)(p[g].fn!==c||d&&!p[g].once||u&&p[g].context!==u)&&y.push(p[g]);y.length?this._events[f]=y.length===1?y[0]:y:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=e?e+h:h,this._events[c]&&o(this,c)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,i.exports=a})(Bd);var xg=Bd.exports;const ls=Td(xg);var zl={exports:{}};zl.exports=Zn;zl.exports.default=Zn;function Zn(i,t,e){e=e||2;var r=t&&t.length,s=r?t[0]*e:i.length,n=kd(i,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,l,h,c,u,d,f;if(r&&(n=Sg(i,t,n,e)),i.length>80*e){a=h=i[0],l=c=i[1];for(var p=e;p<s;p+=e)u=i[p],d=i[p+1],u<a&&(a=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);f=Math.max(h-a,c-l),f=f!==0?32767/f:0}return Qi(n,o,e,a,l,f,0),o}function kd(i,t,e,r,s){var n,o;if(s===Ia(i,t,e,r)>0)for(n=t;n<e;n+=r)o=$h(n,i[n],i[n+1],o);else for(n=e-r;n>=t;n-=r)o=$h(n,i[n],i[n+1],o);return o&&Kn(o,o.next)&&(es(o),o=o.next),o}function Gr(i,t){if(!i)return i;t||(t=i);var e=i,r;do if(r=!1,!e.steiner&&(Kn(e,e.next)||_t(e.prev,e,e.next)===0)){if(es(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function Qi(i,t,e,r,s,n,o){if(i){!o&&n&&Mg(i,r,s,n);for(var a=i,l,h;i.prev!==i.next;){if(l=i.prev,h=i.next,n?Tg(i,r,s,n):wg(i)){t.push(l.i/e|0),t.push(i.i/e|0),t.push(h.i/e|0),es(i),i=h.next,a=h.next;continue}if(i=h,i===a){o?o===1?(i=Eg(Gr(i),t,e),Qi(i,t,e,r,s,n,2)):o===2&&Ag(i,t,e,r,s,n):Qi(Gr(i),t,e,r,s,n,1);break}}}}function wg(i){var t=i.prev,e=i,r=i.next;if(_t(t,e,r)>=0)return!1;for(var s=t.x,n=e.x,o=r.x,a=t.y,l=e.y,h=r.y,c=s<n?s<o?s:o:n<o?n:o,u=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,f=a>l?a>h?a:h:l>h?l:h,p=r.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&fi(s,a,n,l,o,h,p.x,p.y)&&_t(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Tg(i,t,e,r){var s=i.prev,n=i,o=i.next;if(_t(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,c=s.y,u=n.y,d=o.y,f=a<l?a<h?a:h:l<h?l:h,p=c<u?c<d?c:d:u<d?u:d,g=a>l?a>h?a:h:l>h?l:h,y=c>u?c>d?c:d:u>d?u:d,m=Sa(f,p,t,e,r),v=Sa(g,y,t,e,r),_=i.prevZ,b=i.nextZ;_&&_.z>=m&&b&&b.z<=v;){if(_.x>=f&&_.x<=g&&_.y>=p&&_.y<=y&&_!==s&&_!==o&&fi(a,c,l,u,h,d,_.x,_.y)&&_t(_.prev,_,_.next)>=0||(_=_.prevZ,b.x>=f&&b.x<=g&&b.y>=p&&b.y<=y&&b!==s&&b!==o&&fi(a,c,l,u,h,d,b.x,b.y)&&_t(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;_&&_.z>=m;){if(_.x>=f&&_.x<=g&&_.y>=p&&_.y<=y&&_!==s&&_!==o&&fi(a,c,l,u,h,d,_.x,_.y)&&_t(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;b&&b.z<=v;){if(b.x>=f&&b.x<=g&&b.y>=p&&b.y<=y&&b!==s&&b!==o&&fi(a,c,l,u,h,d,b.x,b.y)&&_t(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Eg(i,t,e){var r=i;do{var s=r.prev,n=r.next.next;!Kn(s,n)&&Dd(s,r,r.next,n)&&ts(s,n)&&ts(n,s)&&(t.push(s.i/e|0),t.push(r.i/e|0),t.push(n.i/e|0),es(r),es(r.next),r=i=n),r=r.next}while(r!==i);return Gr(r)}function Ag(i,t,e,r,s,n){var o=i;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Dg(o,a)){var l=Fd(o,a);o=Gr(o,o.next),l=Gr(l,l.next),Qi(o,t,e,r,s,n,0),Qi(l,t,e,r,s,n,0);return}a=a.next}o=o.next}while(o!==i)}function Sg(i,t,e,r){var s=[],n,o,a,l,h;for(n=0,o=t.length;n<o;n++)a=t[n]*r,l=n<o-1?t[n+1]*r:i.length,h=kd(i,a,l,r,!1),h===h.next&&(h.steiner=!0),s.push(kg(h));for(s.sort(Cg),n=0;n<s.length;n++)e=Ig(s[n],e);return e}function Cg(i,t){return i.x-t.x}function Ig(i,t){var e=Rg(i,t);if(!e)return t;var r=Fd(e,i);return Gr(r,r.next),Gr(e,e.next)}function Rg(i,t){var e=t,r=i.x,s=i.y,n=-1/0,o;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var a=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=r&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===r))return o}e=e.next}while(e!==t);if(!o)return null;var l=o,h=o.x,c=o.y,u=1/0,d;e=o;do r>=e.x&&e.x>=h&&r!==e.x&&fi(s<c?r:n,s,h,c,s<c?n:r,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(r-e.x),ts(e,i)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&Pg(o,e)))&&(o=e,u=d)),e=e.next;while(e!==l);return o}function Pg(i,t){return _t(i.prev,i,t.prev)<0&&_t(t.next,i,i.next)<0}function Mg(i,t,e,r){var s=i;do s.z===0&&(s.z=Sa(s.x,s.y,t,e,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i);s.prevZ.nextZ=null,s.prevZ=null,Bg(s)}function Bg(i){var t,e,r,s,n,o,a,l,h=1;do{for(e=i,i=null,n=null,o=0;e;){for(o++,r=e,a=0,t=0;t<h&&(a++,r=r.nextZ,!!r);t++);for(l=h;a>0||l>0&&r;)a!==0&&(l===0||!r||e.z<=r.z)?(s=e,e=e.nextZ,a--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:i=s,s.prevZ=n,n=s;e=r}n.nextZ=null,h*=2}while(o>1);return i}function Sa(i,t,e,r,s){return i=(i-e)*s|0,t=(t-r)*s|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|
vendor: 5,480 bytes, line 1
1i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function kg(i){var t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function fi(i,t,e,r,s,n,o,a){return(s-o)*(t-a)>=(i-o)*(n-a)&&(i-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(r-a)}function Dg(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!Fg(i,t)&&(ts(i,t)&&ts(t,i)&&Og(i,t)&&(_t(i.prev,i,t.prev)||_t(i,t.prev,t))||Kn(i,t)&&_t(i.prev,i,i.next)>0&&_t(t.prev,t,t.next)>0)}function _t(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Kn(i,t){return i.x===t.x&&i.y===t.y}function Dd(i,t,e,r){var s=ms(_t(i,t,e)),n=ms(_t(i,t,r)),o=ms(_t(e,r,i)),a=ms(_t(e,r,t));return!!(s!==n&&o!==a||s===0&&ps(i,e,t)||n===0&&ps(i,r,t)||o===0&&ps(e,i,r)||a===0&&ps(e,t,r))}function ps(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function ms(i){return i>0?1:i<0?-1:0}function Fg(i,t){var e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&Dd(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function ts(i,t){return _t(i.prev,i,i.next)<0?_t(i,t,i.next)>=0&&_t(i,i.prev,t)>=0:_t(i,t,i.prev)<0||_t(i,i.next,t)<0}function Og(i,t){var e=i,r=!1,s=(i.x+t.x)/2,n=(i.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==i);return r}function Fd(i,t){var e=new Ca(i.i,i.x,i.y),r=new Ca(t.i,t.x,t.y),s=i.next,n=t.prev;return i.next=t,t.prev=i,e.next=s,s.prev=e,r.next=e,e.prev=r,n.next=r,r.prev=n,r}function $h(i,t,e,r){var s=new Ca(i,t,e);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function es(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Ca(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Zn.deviation=function(i,t,e,r){var s=t&&t.length,n=s?t[0]*e:i.length,o=Math.abs(Ia(i,0,n,e));if(s)for(var a=0,l=t.length;a<l;a++){var h=t[a]*e,c=a<l-1?t[a+1]*e:i.length;o-=Math.abs(Ia(i,h,c,e))}var u=0;for(a=0;a<r.length;a+=3){var d=r[a]*e,f=r[a+1]*e,p=r[a+2]*e;u+=Math.abs((i[d]-i[p])*(i[f+1]-i[d+1])-(i[d]-i[f])*(i[p+1]-i[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function Ia(i,t,e,r){for(var s=0,n=t,o=e-r;n<e;n+=r)s+=(i[o]-i[n])*(i[n+1]+i[o+1]),o=n;return s}Zn.flatten=function(i){for(var t=i[0][0].length,e={vertices:[],holes:[],dimensions:t},r=0,s=0;s<i.length;s++){for(var n=0;n<i[s].length;n++)for(var o=0;o<t;o++)e.vertices.push(i[s][n][o]);s>0&&(r+=i[s-1].length,e.holes.push(r))}return e};var Ng=zl.exports;const Lg=Td(Ng);var wn={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */wn.exports;(function(i,t){(function(e){var r=t&&!t.nodeType&&t,s=i&&!i.nodeType&&i,n=typeof qs=="object"&&qs;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,l=36,h=1,c=26,u=38,d=700,f=72,p=128,g="-",y=/^xn--/,m=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},b=l-h,w=Math.floor,A=String.fromCharCode,x;function C(R){throw new RangeError(_[R])}function T(R,L){for(var Y=R.length,tt=[];Y--;)tt[Y]=L(R[Y]);return tt}function P(R,L){var Y=R.split("@"),tt="";Y.length>1&&(tt=Y[0]+"@",R=Y[1]),R=R.replace(v,".");var J=R.split("."),st=T(J,L).join(".");return tt+st}function M(R){for(var L=[],Y=0,tt=R.length,J,st;Y<tt;)J=R.charCodeAt(Y++),J>=55296&&J<=56319&&Y<tt?(st=R.charCodeAt(Y++),(st&64512)==56320?L.push(((J&1023)<<10)+(st&1023)+65536):(L.push(J),Y--)):L.push(J);return L}function B(R){return T(R,function(L){var Y="";return L>65535&&(L-=65536,Y+=A(L>>>10&1023|55296),L=56320|L&1023),Y+=A(L),Y}).join("")}function S(R){return R-48<10?R-22:R-65<26?R-65:R-97<26?R-97:l}function I(R,L){return R+22+75*(R<26)-((L!=0)<<5)}function k(R,L,Y){var tt=0;for(R=Y?w(R/d):R>>1,R+=w(R/L);R>b*c>>1;tt+=l)R=w(R/b);return w(tt+(b+1)*R/(R+u))}function V(R){var L=[],Y=R.length,tt,J=0,st=p,at=f,ht,yt,wt,D,ct,N,lt,Rt,jt;for(ht=R.lastIndexOf(g),ht<0&&(ht=0),yt=0;yt<ht;++yt)R.charCodeAt(yt)>=128&&C("not-basic"),L.push(R.charCodeAt(yt));for(wt=ht>0?ht+1:0;wt<Y;){for(D=J,ct=1,N=l;wt>=Y&&C("invalid-input"),lt=S(R.charCodeAt(wt++)),(lt>=l||lt>w((a-J)/ct))&&C("overflow"),J+=lt*ct,Rt=N<=at?h:N>=at+c?c:N-at,!(lt<Rt);N+=l)jt=l-Rt,ct>w(a/jt)&&C("overflow"),ct*=jt;tt=L.length+1,at=k(J-D,tt,D==0),w(J/tt)>a-st&&C("overflow"),st+=w(J/tt),J%=tt,L.splice(J++,0,st)}return B(L)}function O(R){var L,Y,tt,J,st,at,ht,yt,wt,D,ct,N=[],lt,Rt,jt,yr;for(R=M(R),lt=R.length,L=p,Y=0,st=f,at=0;at<lt;++at)ct=R[at],ct<128&&N.push(A(ct));for(tt=J=N.length,J&&N.push(g);tt<lt;){for(ht=a,at=0;at<lt;++at)ct=R[at],ct>=L&&ct<ht&&(ht=ct);for(Rt=tt+1,ht-L>w((a-Y)/Rt)&&C("overflow"),Y+=(ht-L)*Rt,L=ht,at=0;at<lt;++at)if(ct=R[at],ct<L&&++Y>a&&C("overflow"),ct==L){for(yt=Y,wt=l;D=wt<=st?h:wt>=st+c?c:wt-st,!(yt<D);wt+=l)yr=yt-D,jt=l-D,N.push(A(I(D+yr%jt,0))),yt=w(yr/jt);N.push(A(I(yt,0))),st=k(Y,Rt,tt==J),Y=0,++tt}++Y,++L}return N.join("")}function et(R){return P(R,function(L){return y.test(L)?V(L.slice(4).toLowerCase()):L})}function E(R){return P(R,function(L){return m.test(L)?"xn--"+O(L):L})}if(o={version:"1.4.1",ucs2:{decode:M,encode:B},decode:V,encode:O,toASCII:E,toUnicode:et},r&&s)if(i.exports==r)s.exports=o;else for(x in o)o.hasOwnProperty(x)&&(r[x]=o[x]);else e.punycode=o})(qs)}
1)(wn,wn.exports);var Ug=wn.exports,Gg=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),r=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var s=42;t[e]=s;for(e in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var n=Object.getOwnPropertySymbols(t);if(n.length!==1||n[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(t,e);if(o.value!==s||o.enumerable!==!0)return!1}return!0},jh=typeof Symbol<"u"&&Symbol,Hg=Gg,zg=function(){return typeof jh!="function"||typeof Symbol!="function"||typeof jh("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Hg()},Yh={foo:{}},Xg=Object,Vg=function(){return{__proto__:Yh}.foo===Yh.foo&&!({__proto__:null}instanceof Xg)},Wg="Function.prototype.bind called on incompatible ",$g=Object.prototype.toString,jg=Math.max,Yg="[object Function]",qh=function(t,e){for(var r=[],s=0;s<t.length;s+=1)r[s]=t[s];for(var n=0;n<e.length;n+=1)r[n+t.length]=e[n];return r},qg=function(t,e){for(var r=[],s=e||0,n=0;s<t.length;s+=1,n+=1)r[n]=t[s];return r},Zg=function(i,t){for(var e="",r=0;r<i.length;r+=1)e+=i[r],r+1<i.length&&(e+=t);return e},Kg=function(t){var e=this;if(typeof e!="function"||$g.apply(e)!==Yg)throw new TypeError(Wg+e);for(var r=qg(arguments,1),s,n=function(){if(this instanceof s){var c=e.apply(this,qh(r,arguments));return Object(c)===c?c:this}return e.apply(t,qh(r,arguments))},o=jg(0,e.length-r.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+Zg(a,",")+"){ return binder.apply(this,arguments); }")(n),e.prototype){var h=function(){};h.prototype=e.prototype,s.prototype=new h,h.prototype=null}return s},Jg=Kg,Xl=Function.prototype.bind||Jg,Qg=Function.prototype.call,t0=Object.prototype.hasOwnProperty,e0=Xl,r0=e0.call(Qg,t0),it,Ti=SyntaxError,Od=Function,gi=TypeError,Io=function(i){try{return Od('"use strict"; return ('+i+").constructor;")()}catch{}},kr=Object.getOwnPropertyDescriptor;if(kr)try{kr({},"")}catch{kr=null}var Ro=function(){throw new gi},i0=kr?function(){try{return arguments.callee,Ro}catch{try{return kr(arguments,"callee").get}catch{return Ro}}}():Ro,Kr=zg(),s0=Vg(),Ct=Object.getPrototypeOf||(s0?function(i){return i.__proto__}:null),ni={},n0=typeof Uint8Array>"u"||!Ct?it:Ct(Uint8Array),Dr={"%AggregateError%":typeof AggregateError>"u"?it:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?it:ArrayBuffer,"%ArrayIteratorPrototype%":Kr&&Ct?Ct([][Symbol.iterator]()):it,"%AsyncFromSyncIteratorPrototype%":it,"%AsyncFunction%":ni,"%AsyncGenerator%":ni,"%AsyncGeneratorFunction%":ni,"%AsyncIteratorPrototype%":ni,"%Atomics%":typeof Atomics>"u"?it:Atomics,"%BigInt%":typeof BigInt>"u"?it:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?it:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?it:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?it:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?it:Float32Array,"%Float64Array%":typeof Float64Array>"u"?it:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?it:FinalizationRegistry,"%Function%":Od,"%GeneratorFunction%":ni,"%Int8Array%":typeof Int8Array>"u"?it:Int8Array,"%Int16Array%":typeof Int16Array>"u"?it:Int16Array,"%Int32Array%":typeof Int32Array>
vendor: 4,536 bytes, line 1
1"u"?it:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Kr&&Ct?Ct(Ct([][Symbol.iterator]())):it,"%JSON%":typeof JSON=="object"?JSON:it,"%Map%":typeof Map>"u"?it:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Kr||!Ct?it:Ct(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?it:Promise,"%Proxy%":typeof Proxy>"u"?it:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?it:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?it:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Kr||!Ct?it:Ct(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?it:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Kr&&Ct?Ct(""[Symbol.iterator]()):it,"%Symbol%":Kr?Symbol:it,"%SyntaxError%":Ti,"%ThrowTypeError%":i0,"%TypedArray%":n0,"%TypeError%":gi,"%Uint8Array%":typeof Uint8Array>"u"?it:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?it:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?it:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?it:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?it:WeakMap,"%WeakRef%":typeof WeakRef>"u"?it:WeakRef,"%WeakSet%":typeof WeakSet>"u"?it:WeakSet};if(Ct)try{null.error}catch(i){var o0=Ct(Ct(i));Dr["%Error.prototype%"]=o0}var a0=function i(t){var e;if(t==="%AsyncFunction%")e=Io("async function () {}");else if(t==="%GeneratorFunction%")e=Io("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=Io("async function* () {}");else if(t==="%AsyncGenerator%"){var r=i("%AsyncGeneratorFunction%");r&&(e=r.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=i("%AsyncGenerator%");s&&Ct&&(e=Ct(s.prototype))}return Dr[t]=e,e},Zh={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},hs=Xl,Tn=r0,l0=hs.call(Function.call,Array.prototype.concat),h0=hs.call(Function.apply,Array.prototype.splice),Kh=hs.call(Function.call,String.prototype.replace),En=hs.call(Function.call,String.prototype.slice),c0=
1hs.call(Function.call,RegExp.prototype.exec),u0=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,d0=/\\(\\)?/g,f0=function(t){var e=En(t,0,1),r=En(t,-1);if(e==="%"&&r!=="%")throw new Ti("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&e!=="%")throw new Ti("invalid intrinsic syntax, expected opening `%`");var s=[];return Kh(t,u0,function(n,o,a,l){s[s.length]=a?Kh(l,d0,"$1"):o||n}),s},p0=function(t,e){var r=t,s;if(Tn(Zh,r)&&(s=Zh[r],r="%"+s[0]+"%"),Tn(Dr,r)){var n=Dr[r];if(n===ni&&(n=a0(r)),typeof n>"u"&&!e)throw new gi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:r,value:n}}throw new Ti("intrinsic "+t+" does not exist!")},Wr=function(t,e){if(typeof t!="string"||t.length===0)throw new gi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new gi('"allowMissing" argument must be a boolean');if(c0(/^%?[^%]*%?$/,t)===null)throw new Ti("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=f0(t),s=r.length>0?r[0]:"",n=p0("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],h0(r,l0([0,1],h)));for(var c=1,u=!0;c<r.length;c+=1){var d=r[c],f=En(d,0,1),p=En(d,-1);if((f==='"'||f==="'"||f==="`"||p==='"'||p==="'"||p==="`")&&f!==p)throw new Ti("property names with quotes must have matching quotes");if((d==="constructor"||!u)&&(l=!0),s+="."+d,o="%"+s+"%",Tn(Dr,o))a=Dr[o];else if(a!=null){if(!(d in a)){if(!e)throw new gi("base intrinsic for "+t+" exists, but the property is not available.");return}if(kr&&c+1>=r.length){var g=kr(a,d);u=!!g,u&&"get"in g&&!("originalValue"in g.get)?a=g.get:a=a[d]}else u=Tn(a,d),a=a[d];u&&!l&&(Dr[o]=a)}}return a},Nd={exports:{}},m0=Wr,Ra=m0("%Object.defineProperty%",!0),Pa=function(){if(Ra)try{return Ra({},"a",{value:1}),!0}catch{return!1}return!1};Pa.hasArrayLengthDefineBug=function(){if(!Pa())return null;try{return Ra([],"length",{value:1}).length!==1}catch{return!0}};var Ld=Pa,_0=Wr,Zs=_0("%Object.getOwnPropertyDescriptor%",!0);if(Zs)try{Zs([],"length")}catch{Zs=null}var Ud=Zs,g0=Ld(),Vl=Wr,Yi=g0&&Vl("%Object.defineProperty%",!0);if(Yi)try{Yi({},"a",{value:1})}catch{Yi=!1}var y0=Vl("%SyntaxError%"),Jr=Vl("%TypeError%"),Jh=Ud,v0=function(t,e,r){if(!t||typeof t!="object"&&typeof t!="function")throw new Jr("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new Jr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Jr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Jr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Jr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Jr("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,n=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!Jh&&Jh(t,e);if(Yi)Yi(t,e,{configurable:o===null&&l?l.configurable:!o,enumerable:s===null&&l?l.enumerable:!s,value:r,writable:n===null&&l?l.writable:!n});else if(a||!s&&!n&&!o)t[e]=r;else throw new y0("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Gd=Wr,Qh=v0,b0=Ld(),tc=Ud,ec=Gd("%TypeError%"),x0=Gd("%Math.floor%"),w0=function(t,e){if(typeof t!="function")throw new ec("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||x0(e)!==e)throw new ec("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],s=!0,n=!0;if("length"in t&&tc){var o=tc(t,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(n=!1)}return(s||n||!r)&&(b0?Qh(t,"length",e,!0,!0):Qh(t,"length",e)),t};(function(i){var t=Xl,e=Wr,r=w0,s=e("%TypeError%"),n=e("%Function.prototype.apply%"),o=e("%Function.prototype.call%"),a=e("%Reflect.apply%",!0)||t.call(o,n),l=e("%Object.defineProperty%",!0),h=e("%Math.max%");if(l)try{l({},"a",{value:1})}catch{l=null}i.exports=function(d){if(typeof d!="function")throw new s("a function is required");var f=a(t,o,arguments);return r(f,1+h(0,d.length-(arguments.length-1)),!0)};var c=function(){return a(t,n,arguments)};l?l(i.exports,"apply",{value:c}):i.exports.apply=c})(Nd);var T0=Nd.exports,Hd=Wr,zd=T0,E0=zd(Hd("String.prototype.indexOf")),A0=function(t,e){var r=Hd(t,!!e);return typeof r=="function"&&E0(t,".prototype.")>-1?zd(r):r};const S0=nm(om);var Wl=typeof Map=="function"&&Map.prototype,Po=Object.getOwnPropertyDescriptor&&Wl?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,An=Wl&&Po&&typeof Po.get=="function"?Po.get:null,rc=Wl&&Map.prototype.forEach,$l=typeof Set=="function"&&Set.prototype,Mo=Object.getOwnPropertyDescriptor&&$l?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Sn=$l&&Mo&&typeof Mo.get=="function"?Mo.get:null,ic=$l&&Set.prototype.forEach,C0=typeof WeakMap=="function"&&WeakMap.prototype,qi=C0?WeakMap.prototype.has:null,I0=typeof WeakSet=="function"&&WeakSet.prototype,Zi=I0?WeakSet.prototype.has:null,R0=typeof WeakRef=="function"&&WeakRef.prototype,sc=R0?WeakRef.prototype.deref:null,P0=Boolean.prototype.valueOf,M0=Object.prototype.toString,B0=Function.prototype.toString,k0=String.prototype.match,jl=String.prototype.slice,er=String.prototype.replace,D0=String.prototype.toUpperCase,nc=String.prototype.toLowerCase,Xd=RegExp.prototype.test,oc=Array.prototype.concat,xe=Array.prototype.join,F0=Array.prototype.slice,ac=Math.floor,Ma=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Bo=Object.getOwnPropertySymbols,Ba=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Ei=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Ot=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Ei||"symbol")?Symbol.toStringTag:null,Vd=Object.prototype.propertyIsEnumerable,lc=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(i){return i.__proto__}:null);function hc(i,t){if(i===1/0||i===-1/0||i!==i||i&&i>
vendor: 10,069 bytes, lines 1-4
1-1e3&&i<1e3||Xd.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof i=="number"){var r=i<0?-ac(-i):ac(i);if(r!==i){var s=String(r),n=jl.call(t,s.length+1);return er.call(s,e,"$&_")+"."+er.call(er.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return er.call(t,e,"$&_")}var ka=S0,cc=ka.custom,uc=$d(cc)?cc:null,O0=function i(t,e,r,s){var n=e||{};if(Je(n,"quoteStyle")&&n.quoteStyle!=="single"&&n.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Je(n,"maxStringLength")&&(typeof n.maxStringLength=="number"?n.maxStringLength<0&&n.maxStringLength!==1/0:n.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=Je(n,"customInspect")?n.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Je(n,"indent")&&n.indent!==null&&n.indent!==" "&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Je(n,"numericSeparator")&&typeof n.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=n.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return Yd(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?hc(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?hc(t,h):h}var c=typeof n.depth>"u"?5:n.depth;if(typeof r>"u"&&(r=0),r>=c&&c>0&&typeof t=="object")return Da(t)?"[Array]":"[Object]";var u=ty(n,r);if(typeof s>"u")s=[];else if(jd(s,t)>=0)return"[Circular]";function d(S,I,k){if(I&&(s=F0.call(s),s.push(I)),k){var V={depth:n.depth};return Je(n,"quoteStyle")&&(V.quoteStyle=n.quoteStyle),i(S,V,r+1,s)}return i(S,n,r+1,s)}if(typeof t=="function"&&!dc(t)){var f=W0(t),p=_s(t,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(p.length>0?" { "+xe.call(p,", ")+" }":"")}if($d(t)){var g=Ei?er.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Ba.call(t);return typeof t=="object"&&!Ei?Di(g):g}if(K0(t)){for(var y="<"+nc.call(String(t.nodeName)),m=t.attributes||[],v=0;v<m.length;v++)y+=" "+m[v].name+"="+Wd(N0(m[v].value),"double",n);return y+=">",t.childNodes&&t.childNodes.length&&(y+="..."),y+="</"+nc.call(String(t.nodeName))+">",y}if(Da(t)){if(t.length===0)return"[]";var _=_s(t,d);return u&&!Q0(_)?"["+Fa(_,u)+"]":"[ "+xe.call(_,", ")+" ]"}if(U0(t)){var b=_s(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!Vd.call(t,"cause")?"{ ["+String(t)+"] "+xe.call(oc.call("[cause]: "+d(t.cause),b),", ")+" }":b.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+xe.call(b,", ")+" }"}if(typeof t=="object"&&o){if(uc&&typeof t[uc]=="function"&&ka)return ka(t,{depth:c-r});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if($0(t)){var w=[];return rc&&rc.call(t,function(S,I){w.push(d(I,t,!0)+" => "+d(S,t))}),fc("Map",An.call(t),w,u)}if(q0(t)){var A=[];return ic&&ic.call(t,function(S){A.push(d(S,t))}),fc("Set",Sn.call(t),A,u)}if(j0(t))return ko("WeakMap");if(Z0(t))return ko("WeakSet");if(Y0(t))return ko("WeakRef");if(H0(t))return Di(d(Number(t)));if(X0(t))return Di(d(Ma.call(t)));if(z0(t))return Di(P0.call(t));if(G0(t))return Di(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(t===qs)return"{ [object globalThis] }";if(!L0(t)&&!dc(t)){var x=_s(t,d),C=lc?lc(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",P=!C&&Ot&&Object(t)===t&&Ot in t?jl.call(_r(t),8,-1):T?"Object":"",M=C||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",B=M+(P||T?"["+xe.call(oc.call([],P||[],T||[]),": ")+"] ":"");return x.length===0?B+"{}":u?B+"{"+Fa(x,u)+"}":B+"{ "+xe.call(x,", ")+" }"}return String(t)};function Wd(i,t,e){var r=(e.quoteStyle||t)==="double"?'"':"'";return r+i+r}function N0(i){return er.call(String(i),/"/g,""")}function Da(i){return _r(i)==="[object Array]"&&(!Ot||!(typeof i=="object"&&Ot in i))}function L0(i){return _r(i)==="[object Date]"&&(!Ot||!(typeof i=="object"&&Ot in i))}function dc(i){return _r(i)==="[object RegExp]"&&(!Ot||!(typeof i=="object"&&Ot in i))}function U0(i){return _r(i)==="[object Error]"&&(!Ot||!(typeof i=="object"&&Ot in i))}function G0(i){return _r(i)==="[object String]"&&(!Ot||!(typeof i=="object"&&Ot in i))}function H0(i){return _r(i)==="[object Number]"&&(!Ot||!(typeof i=="object"&&Ot in i))}function z0(i){return _r(i)==="[object Boolean]"&&(!Ot||!(typeof i=="object"&&Ot in i))}function $d(i){if(Ei)return i&&typeof i=="object"&&i instanceof Symbol;if(typeof i=="symbol")return!0;if(!i||typeof i!="object"||!Ba)return!1;try{return Ba.call(i),!0}catch{}return!1}function X0(i){if(!i||typeof i!="object"||!Ma)return!1;try{return Ma.call(i),!0}catch{}return!1}var V0=Object.prototype.hasOwnProperty||function(i){return i in this};function Je(i,t){return V0.call(i,t)}function _r(i){return M0.call(i)}function W0(i){if(i.name)return i.name;var t=k0.call(B0.call(i),/^function\s*([\w$]+)/);return t?t[1]:null}function jd(i,t){if(i.indexOf)return i.indexOf(t);for(var e=0,r=i.length;e<r;e++)if(i[e]===t)return e;return-1}function $0(i){if(!An||!i||typeof i!="object")return!1;try{An.call(i);try{Sn.call(i)}catch{return!0}return i instanceof Map}catch{}return!1}function j0(i){if(!qi||!i||typeof i!="object")return!1;try{qi.call(i,qi);try{Zi.call(i,Zi)}catch{return!0}return i instanceof WeakMap}catch{}return!1}function Y0(i){if(!sc||!i||typeof i!="object")return!1;try{return sc.call(i),!0}catch{}return!1}function q0(i){if(!Sn||!i||typeof i!="object")return!1;try{Sn.call(i);try{An.call(i)}catch{return!0}return i instanceof Set}catch{}return!1}function Z0(i){if(!Zi||!i||typeof i!="object")return!1;try{Zi.call(i,Zi);try{qi.call(i,qi)}catch{return!0}return i instanceof WeakSet}catch{}return!1}function K0(i){return!i||typeof i!="object"?!1:typeof HTMLElement<"u"&&i instanceof HTMLElement?!0:typeof i.nodeName=="string"&&typeof i.getAttribute=="function"}function Yd(i,t){if(i.length>t.maxStringLength){var e=i.length-t.maxStringLength,r="... "+e+" more character"+(e>1?"s":"");return Yd(jl.call(i,0,t.maxStringLength),t)+r}var s=er.call(er.call(i,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,J0);return Wd(s,"single",t)}function J0(i){var t=i.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+D0.call(t.toString(16))}function Di(i){return"Object("+i+")"}function ko(i){return i+" { ? }"}function fc(i,t,e,r){var s=r?Fa(e,r):xe.call(e,", ");return i+" ("+t+") {"+s+"}"}function Q0(i){for(var t=0;t<i.length;t++)if(jd(i[t],` 2`)>=0)return!1;return!0}function ty(i,t){var e;if(i.indent===" ")e=" ";else if(typeof i.indent=="number"&&i.indent>0)e=xe.call(Array(i.indent+1)," ");else return null;return{base:e,prev:xe.call(Array(t+1),e)}}function Fa(i,t){if(i.length===0)return"";var e=` 3`+t.prev+t.base;return e+xe.call(i,","+e)+` 4`+t.prev}function _s(i,t){var e=Da(i),r=[];if(e){r.length=i.length;for(var s=0;s<i.length;s++)r[s]=Je(i,s)?t(i[s],i):""}var n=typeof Bo=="function"?Bo(i):[],o;if(Ei){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var l in i)Je(i,l)&&(e&&String(Number(l))===l&&l<i.length||Ei&&o["$"+l]instanceof Symbol||(Xd.call(/[^\w$]/,l)?r.push(t(l,i)+": "+t(i[l],i)):r.push(l+": "+t(i[l],i))));if(typeof Bo=="function")for(var h=0;h<n.length;h++)Vd.call(i,n[h])&&r.push("["+t(n[h])+"]: "+t(i[n[h]],i));return r}var Yl=Wr,Pi=A0,ey=O0,ry=Yl("%TypeError%"),gs=Yl("%WeakMap%",!0),ys=Yl("%Map%",!0),iy=Pi("WeakMap.prototype.get",!0),sy=Pi("WeakMap.prototype.set",!0),ny=Pi("WeakMap.prototype.has",!0),oy=Pi("Map.prototype.get",!0),ay=Pi("Map.prototype.set",!0),ly=Pi("Map.prototype.has",!0),ql=function(i,t){for(var e=i,r;(r=e.next)!==null;e=r)if(r.key===t)return e.next=r.next,r.next=i.next,i.next=r,r},hy=function(i,t){var e=ql(i,t);return e&&e.value},cy=function(i,t,e){var r=ql(i,t);r?r.value=e:i.next={key:t,next:i.next,value:e}},uy=function(i,t){return!!ql(i,t)},dy=function(){var t,e,r,s={assert:function(n){if(!s.has(n))throw new ry("Side channel does not contain "+ey(n))},get:function(n){if(gs&&n&&(typeof n=="object"||typeof n=="function")){if(t)return iy(t,n)}else if(ys){if(e)return oy(e,n)}else if(r)return hy(r,n)},has:function(n){if(gs&&n&&(typeof n=="object"||typeof n=="function")){if(t)return ny(t,n)}else if(ys){if(e)return ly(e,n)}else if(r)return uy(r,n);return!1},set:function(n,o){gs&&n&&(typeof n=="object"||typeof n=="function")?(t||(t=new gs),sy(t,n,o)):ys?(e||(e=new ys),ay(e,n,o)):(r||(r={key:{},next:null}),cy(r,n,o))}};return s},fy=String.prototype.replace,py=/%20/g,Do={RFC1738:"RFC1738",RFC3986:"RFC3986"},Zl={default:Do.RFC3986,formatters:{RFC1738:function(i){return fy.call(i,py,"+")},RFC3986:function(i){return String(i)}},RFC1738:Do.RFC1738,RFC3986:Do.RFC3986},my=Zl,Fo=Object.prototype.hasOwnProperty,Pr=Array.isArray,fe=function(){for(var i=[],t=0;t<256;++t)i.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return i}(),_y=function(t){for(;t.length>1;){var e=t.pop(),r=e.obj[e.prop];if(Pr(r)){for(var s=[],n=0;n<r.length;++n)typeof r[n]<"u"&&s.push(r[n]);e.obj[e.prop]=s}}},qd=function(t,e){for(var r=e&&e.plainObjects?Object.create(null):{},s=0;s<t.length;++s)typeof t[s]<"u"&&(r[s]=t[s]);return r},gy=function i(t,e,r){if(!e)return t;if(typeof e!="object"){if(Pr(t))t.push(e);else if(t&&typeof t=="object")(r&&(r.plainObjects||r.allowPrototypes)||!Fo.call(Object.prototype,e))&&(t[e]=!0);else return[t,e];return t}if(!t||typeof t!="object")return[t].concat(e);var s=t;return Pr(t)&&!Pr(e)&&(s=qd(t,r)),Pr(t)&&Pr(e)?(e.forEach(function(n,o){if(Fo.call(t,o)){var a=t[o];a&&typeof a=="object"&&n&&typeof n=="object"?t[o]=i(a,n,r):t.push(n)}else t[o]=n}),t):Object.keys(e).reduce(function(n,o){var a=e[o];return Fo.call(n,o)?n[o]=i(n[o],a,r):n[o]=a,n},s)},yy=function(t,e){return Object.keys(e).reduce(function(r,s){return r[s]=e[s],r},t)},vy=function(i,t,e){var r=i.replace(/\+/g," ");
4if(e==="iso-8859-1")return r.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(r)}catch{return r}},by=function(t,e,r,s,n){if(t.length===0)return t;var o=t;if(typeof t=="symbol"?o=Symbol.prototype.toString.call(t):typeof t!="string"&&(o=String(t)),r==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(c){return"%26%23"+parseInt(c.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;++l){var h=o.charCodeAt(l);if(h===45||h===46||h===95||h===126||h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||n===my.RFC1738&&(h===40||h===41)){a+=o.charAt(l);continue}if(h<128){a=a+fe[h];continue}if(h<2048){a=a+(fe[192|h>>6]+fe[128|h&63]);continue}if(h<55296||h>=57344){a=a+(fe[224|h>>12]+fe[128|h>>6&63]+fe[128|h&63]);continue}l+=1,h=65536+((h&1023)<<10|o.charCodeAt(l)&1023),a+=fe[240|h>>18]+fe[128|h>>12&63]+fe[128|h>>6&63]+fe[128|h&63]}return a},xy=function(t){for(var e=[{obj:{o:t},prop:"o"}],r=[],s=0;s<e.length;++s)for(var n=e[s],o=n.obj[n.prop],a=Object.keys(o),l=0;l<a.length;++l){var h=a[l],c=o[h];typeof c=="object"&&c!==null&&r.indexOf(c)===-1&&(e.push({obj:o,prop:h}),r.push(c))}return _y(e),t},wy=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},Ty=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},Ey=function(t,e){return[].concat(t,e)},Ay=function(t,e){if(Pr(t)){for(var r=[],s=0;s<t.length;s+=1)r.push(e(t[s]));return r}return e(t)},Zd={arrayToObject:qd,assign:yy,combine:Ey,compact:xy,decode:vy,encode:by,isBuffer:Ty,isRegExp:wy,maybeMap:Ay,merge:gy},Kd=dy,Ks=Zd,Ki=Zl,Sy=Object.prototype.hasOwnProperty,pc={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},Oe=Array.isArray,Cy=Array.prototype.push,Jd=function(i,t){Cy.apply(i,Oe(t)?t:[t])},Iy=Date.prototype.toISOString,mc=Ki.default,Mt={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:Ks.encode,encodeValuesOnly:!1,format:mc,formatter:Ki.formatters[mc],indices:!1,serializeDate:function(t){return Iy.call(t)},skipNulls:!1,strictNullHandling:!1},Ry=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},Oo={},Py=function i(t,e,r,s,n,o,a,l,h,c,u,d,f,p,g,y){for(var m=t,v=y,_=0,b=!1;(v=v.get(Oo))!==void 0&&!b;){var w=v.get(t);if(_+=1,typeof w<"u"){if(w===_)throw new RangeError("Cyclic object value");b=!0}typeof v.get(Oo)>"u"&&(_=0)}if(typeof l=="function"?m=l(e,m):m instanceof Date?m=u(m):r==="comma"&&Oe(m)&&(m=Ks.maybeMap(m,function(V){return V instanceof Date?u(V):V})),m===null){if(n)return a&&!p?a(e,Mt.encoder,g,"key",d):e;m=""}if(Ry(m)||Ks.isBuffer(m)){if(a){var A=p?e:a(e,Mt.encoder,g,"key",d);return[f(A)+"="+f(a(m,Mt.encoder,g,"value",d))]}return[f(e)+"="+f(String(m))]}var x=[];if(typeof m>"u")return x;var C;if(r==="comma"&&Oe(m))p&&a&&(m=Ks.maybeMap(m,a)),C=[{value:m.length>0?m.join(",")||null:void 0}];else if(Oe(l))C=l;else{var T=Object.keys(m);C=h?T.sort(h):T}for(var P=s&&Oe(m)&&m.length===1?e+"[]":e,M=0;M<C.length;++M){var B=C[M],S=typeof B=="object"&&typeof B.value<"u"?B.value:m[B];if(!(o&&S===null)){var I=Oe(m)?typeof r=="function"?r(P,B):P:P+(c?"."+B:"["+B+"]");y.set(t,_);var k=Kd();k.set(Oo,y),Jd(x,i(S,I,r,s,n,o,r==="comma"&&p&&Oe(m)?null:a,l,h,c,u,d,f,p,g,k))}}return x},My=function(t){if(!t)return Mt;if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");var e=t.charset||Mt.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=Ki.default;if(typeof t.format<"u"){if(!Sy.call(Ki.formatters,t.format))throw new TypeError("Unknown format option provided.");r=t.format}var s=Ki.formatters[r],n=Mt.filter;return(typeof t.filter=="function"||Oe(t.filter))&&(n=t.filter),{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:Mt.addQueryPrefix,allowDots:typeof t.allowDots>"u"?Mt.allowDots:!!t.allowDots,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Mt.charsetSentinel,delimiter:typeof t.delimiter>"u"?Mt.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:Mt.encode,encoder:typeof t.encoder=="function"?t.encoder:Mt.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:Mt.encodeValuesOnly,filter:n,format:r,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:
4Mt.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:Mt.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Mt.strictNullHandling}},By=function(i,t){var e=i,r=My(t),s,n;typeof r.filter=="function"?(n=r.filter,e=n("",e)):Oe(r.filter)&&(n=r.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a;t&&t.arrayFormat in pc?a=t.arrayFormat:t&&"indices"in t?a=t.indices?"indices":"repeat":a="indices";var l=pc[a];if(t&&"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var h=l==="comma"&&t&&t.commaRoundTrip;s||(s=Object.keys(e)),r.sort&&s.sort(r.sort);for(var c=Kd(),u=0;u<s.length;++u){var d=s[u];r.skipNulls&&e[d]===null||Jd(o,Py(e[d],d,l,h,r.strictNullHandling,r.skipNulls,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,c))}var f=o.join(r.delimiter),p=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?p+="utf8=%26%2310003%3B&":p+="utf8=%E2%9C%93&"),f.length>0?p+f:""},Ai=Zd,Oa=Object.prototype.hasOwnProperty,ky=Array.isArray,St={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:Ai.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Dy=function(i){return i.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},Qd=function(i,t){return i&&typeof i=="string"&&t.comma&&i.indexOf(",")>-1?i.split(","):i},Fy="utf8=%26%2310003%3B",Oy="utf8=%E2%9C%93",Ny=function(t,e){var r={__proto__:null},s=e.ignoreQueryPrefix?t.replace(/^\?/,""):t,n=e.parameterLimit===1/0?void 0:e.parameterLimit,o=s.split(e.delimiter,n),a=-1,l,h=e.charset;if(e.charsetSentinel)for(l=0;l<o.length;++l)o[l].indexOf("utf8=")===0&&(o[l]===Oy?h="utf-8":o[l]===Fy&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var c=o[l],u=c.indexOf("]="),d=u===-1?c.indexOf("="):u+1,f,p;d===-1?(f=e.decoder(c,St.decoder,h,"key"),p=e.strictNullHandling?null:""):(f=e.decoder(c.slice(0,d),St.decoder,h,"key"),p=Ai.maybeMap(Qd(c.slice(d+1),e),function(g){return e.decoder(g,St.decoder,h,"value")})),p&&e.interpretNumericEntities&&h==="iso-8859-1"&&(p=Dy(p)),c.indexOf("[]=")>-1&&(p=ky(p)?[p]:p),Oa.call(r,f)?r[f]=Ai.combine(r[f],p):r[f]=p}return r},Ly=function(i,t,e,r){for(var s=r?t:Qd(t,e),n=i.length-1;n>=0;--n){var o,a=i[n];if(a==="[]"&&e.parseArrays)o=[].concat(s);else{o=e.plainObjects?Object.create(null):{};var l=a.charAt(0)==="["&&a.charAt(a.length-1)==="]"?a.slice(1,-1):a,h=parseInt(l,10);!e.parseArrays&&l===""?o={0:s}:!isNaN(h)&&a!==l&&String(h)===l&&h>=0&&e.parseArrays&&h<=e.arrayLimit?(o=[],o[h]=s):l!=="__proto__"&&(o[l]=s)}s=o}return s},Uy=function(t,e,r,s){if(t){var n=r.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=r.depth>0&&o.exec(n),h=l?n.slice(0,l.index):n,c=[];if(h){if(!r.plainObjects&&Oa.call(Object.prototype,h)&&!r.allowPrototypes)return;c.push(h)}for(var u=0;r.depth>0&&(l=a.exec(n))!==null&&u<r.depth;){if(u+=1,!r.plainObjects&&Oa.call(Object.prototype,l[1].slice(1,-1))&&!r.allowPrototypes)return;c.push(l[1])}return l&&c.push("["+n.slice(l.index)+"]"),Ly(c,e,r,s)}},Gy=function(t){if(!t)return St;if(t.decoder!==null&&t.decoder!==void 0&&typeof t.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=typeof t.charset>"u"?St.charset:t.charset;return{allowDots:typeof t.allowDots>"u"?St.allowDots:!!t.allowDots,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:St.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:St.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:St.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:St.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:St.comma,decoder:typeof t.decoder=="function"?t.decoder:St.decoder,delimiter:typeof t.delimiter=="string"||Ai.isRegExp(t.delimiter)?t.delimiter:St.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:St.depth,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:St.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:St.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:St.plainObjects,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:St.strictNullHandling}},Hy=function(i,t){var e=Gy(t);if(i===""||i===null||typeof i>"u")return e.plainObjects?Object.create(null):{};for(var r=typeof i=="string"?Ny(i,e):i,s=e.plainObjects?Object.create(null):{},n=Object.keys(r),o=0;o<n.length;++o){var a=n[o],l=Uy(a,r[a],e,typeof i=="string");s=Ai.merge(s,l,e)}return e.allowSparse===!0?s:Ai.compact(s)},zy=By,Xy=Hy,Vy=Zl,Wy={formats:Vy,parse:Xy,stringify:zy},$y=Ug;function Xe(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}
vendor: 6,141 bytes, lines 4-5
4var jy=/^([a-z0-9.+-]+:)/i,Yy=/:[0-9]*$/,qy=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,Zy=["<",">",'"',"`"," ","\r",` 5`," "],Ky=["{","}","|","\\","^","`"].concat(Zy),Na=["'"].concat(Ky),_c=["%","/","?",";","#"].concat(Na),gc=["/","?","#"],Jy=255,yc=/^[+a-z0-9A-Z_-]{0,63}$/,Qy=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,t1={javascript:!0,"javascript:":!0},La={javascript:!0,"javascript:":!0},yi={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},Ua=Wy;function e1(i,t,e){if(i&&typeof i=="object"&&i instanceof Xe)return i;var r=new Xe;return r.parse(i,t,e),r}Xe.prototype.parse=function(i,t,e){if(typeof i!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof i);var r=i.indexOf("?"),s=r!==-1&&r<i.indexOf("#")?"?":"#",n=i.split(s),o=/\\/g;n[0]=n[0].replace(o,"/"),i=n.join(s);var a=i;if(a=a.trim(),!e&&i.split("#").length===1){var l=qy.exec(a);if(l)return this.path=a,this.href=a,this.pathname=l[1],l[2]?(this.search=l[2],t?this.query=Ua.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var h=jy.exec(a);if(h){h=h[0];var c=h.toLowerCase();this.protocol=c,a=a.substr(h.length)}if(e||h||a.match(/^\/\/[^@/]+@[^@/]+/)){var u=a.substr(0,2)==="//";u&&!(h&&La[h])&&(a=a.substr(2),this.slashes=!0)}if(!La[h]&&(u||h&&!yi[h])){for(var d=-1,f=0;f<gc.length;f++){var p=a.indexOf(gc[f]);p!==-1&&(d===-1||p<d)&&(d=p)}var g,y;d===-1?y=a.lastIndexOf("@"):y=a.lastIndexOf("@",d),y!==-1&&(g=a.slice(0,y),a=a.slice(y+1),this.auth=decodeURIComponent(g)),d=-1;for(var f=0;f<_c.length;f++){var p=a.indexOf(_c[f]);p!==-1&&(d===-1||p<d)&&(d=p)}d===-1&&(d=a.length),this.host=a.slice(0,d),a=a.slice(d),this.parseHost(),this.hostname=this.hostname||"";var m=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!m)for(var v=this.hostname.split(/\./),f=0,_=v.length;f<_;f++){var b=v[f];if(b&&!b.match(yc)){for(var w="",A=0,x=b.length;A<x;A++)b.charCodeAt(A)>127?w+="x":w+=b[A];if(!w.match(yc)){var C=v.slice(0,f),T=v.slice(f+1),P=b.match(Qy);P&&(C.push(P[1]),T.unshift(P[2])),T.length&&(a="/"+T.join(".")+a),this.hostname=C.join(".");break}}}this.hostname.length>Jy?this.hostname="":this.hostname=this.hostname.toLowerCase(),m||(this.hostname=$y.toASCII(this.hostname));var M=this.port?":"+this.port:"",B=this.hostname||"";this.host=B+M,this.href+=this.host,m&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!t1[c])for(var f=0,_=Na.length;f<_;f++){var S=Na[f];if(a.indexOf(S)!==-1){var I=encodeURIComponent(S);I===S&&(I=escape(S)),a=a.split(S).join(I)}}var k=a.indexOf("#");k!==-1&&(this.hash=a.substr(k),a=a.slice(0,k));var V=a.indexOf("?");if(V!==-1?(this.search=a.substr(V),this.query=a.substr(V+1),t&&(this.query=Ua.parse(this.query)),a=a.slice(0,V)):t&&(this.search="",this.query={}),a&&(this.pathname=a),yi[c]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var M=this.pathname||"",O=this.search||"";this.path=M+O}return this.href=this.format(),this};Xe.prototype.format=function(){var i=this.auth||"";i&&(i=encodeURIComponent(i),i=i.replace(/%3A/i,":"),i+="@");var t=this.protocol||"",e=this.pathname||"",r=this.hash||"",s=!1,n="";this.host?s=i+this.host:this.hostname&&(s=i+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(n=Ua.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||yi[t])&&s!==!1?(s="//"+(s||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):s||(s=""),r&&r.charAt(0)!=="#"&&(r="#"+r),o&&o.charAt(0)!=="?"&&(o="?"+o),e=e.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),o=o.replace("#","%23"),t+s+e+o+r};Xe.prototype.resolve=function(i){return this.resolveObject(e1(i,!1,!0)).format()};Xe.prototype.resolveObject=function(i){if(typeof i=="string"){var t=new Xe;t.parse(i,!1,!0),i=t}for(var e=new Xe,r=Object.keys(this),s=0;s<r.length;s++){var n=r[s];e[n]=this[n]}if(e.hash=i.hash,i.href==="")return e.href=e.format(),e;if(i.slashes&&!i.protocol){for(var o=Object.keys(i),a=0;a<o.length;a++){var l=o[a];l!=="protocol"&&(e[l]=i[l])}return yi[e.protocol]&&e.hostname&&!e.pathname&&(e.pathname="/",e.path=e.pathname),e.href=e.format(),e}if(i.protocol&&i.protocol!==e.protocol){if(!yi[i.protocol]){for(var h=Object.keys(i),c=0;c<h.length;c++){var u=h[c];e[u]=i[u]}return e.href=e.format(),e}if(e.protocol=i.protocol,!i.host&&!La[i.protocol]){for(var _=(i.pathname||"").split("/");_.length&&!(i.host=_.shift()););i.host||(i.host=""),i.hostname||(i.hostname=""),_[0]!==""&&_.unshift(""),_.length<2&&_.unshift(""),e.pathname=_.join("/")}else e.pathname=i.pathname;if(e.search=i.search,e.query=i.query,e.host=i.host||"",e.auth=i.auth,e.hostname=i.hostname||i.host,e.port=i.port,e.pathname||e.search){var d=e.pathname||"",f=e.search||"";e.path=d+f}return e.slashes=e.slashes||i.slashes,e.href=e.format(),e}var p=e.pathname&&e.pathname.charAt(0)==="/",g=i.host||i.pathname&&i.pathname.charAt(0)==="/",y=g||p||e.host&&i.pathname,m=y,v=e.pathname&&e.pathname.split("/")||[],_=i.pathname&&i.pathname.split("/")||[],b=e.protocol&&!yi[e.protocol];if(b&&(e.hostname="",e.port=null,e.host&&(v[0]===""?v[0]=e.host:v.unshift(e.host)),e.host="",i.protocol&&(i.hostname=null,i.port=null,i.host&&(_[0]===""?_[0]=i.host:_.unshift(i.host)),i.host=null),y=y&&(_[0]===""||v[0]==="")),g)e.host=i.host||i.host===""?i.host:e.host,e.hostname=i.hostname||i.hostname===""?i.hostname:e.hostname,e.search=i.search,e.query=i.query,v=_;else if(_.length)v||(v=[]),v.pop(),v=v.concat(_),e.search=i.search,e.query=i.query;else if(i.search!=null){if(b){e.host=v.shift(),e.hostname=e.host;var w=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;w&&(e.auth=w.shift(),e.hostname=w.shift(),e.host=e.hostname)}return e.search=i.search,e.query=i.query,(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!v.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;
vendor: 5,639 bytes, lines 5-10
5for(var A=v.slice(-1)[0],x=(e.host||i.host||v.length>1)&&(A==="."||A==="..")||A==="",C=0,T=v.length;T>=0;T--)A=v[T],A==="."?v.splice(T,1):A===".."?(v.splice(T,1),C++):C&&(v.splice(T,1),C--);if(!y&&!m)for(;C--;C)v.unshift("..");y&&v[0]!==""&&(!v[0]||v[0].charAt(0)!=="/")&&v.unshift(""),x&&v.join("/").substr(-1)!=="/"&&v.push("");var P=v[0]===""||v[0]&&v[0].charAt(0)==="/";if(b){e.hostname=P?"":v.length?v.shift():"",e.host=e.hostname;var w=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;w&&(e.auth=w.shift(),e.hostname=w.shift(),e.host=e.hostname)}return y=y||e.host&&v.length,y&&!P&&v.unshift(""),v.length>0?e.pathname=v.join("/"):(e.pathname=null,e.path=null),(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.auth=i.auth||e.auth,e.slashes=e.slashes||i.slashes,e.href=e.format(),e};Xe.prototype.parseHost=function(){var i=this.host,t=Yy.exec(i);t&&(t=t[0],t!==":"&&(this.port=t.substr(1)),i=i.substr(0,i.length-t.length)),i&&(this.hostname=i)};const vc={};function rt(i,t,e=3){if(vc[t])return;let r=new Error().stack;typeof r>"u"?console.warn("PixiJS Deprecation Warning: ",`${t} 6Deprecated since v${i}`):(r=r.split(` 7`).splice(e).join(` 8`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t} 9Deprecated since v${i}`),console.warn(r),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t} 10Deprecated since v${i}`),console.warn(r))),vc[t]=!0}function ie(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function Fi(i){return i.split("?")[0].split("#")[0]}function r1(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function i1(i,t,e){return i.replace(new RegExp(r1(t),"g"),e)}function s1(i,t){let e="",r=0,s=-1,n=0,o=-1;for(let a=0;a<=i.length;++a){if(a<i.length)o=i.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(e.length<2||r!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",r=0):(e=e.slice(0,l),r=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",r=0,s=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",r=2)}else e.length>0?e+=`/${i.slice(s+1,a)}`:e=i.slice(s+1,a),r=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const At={toPosix(i){return i1(i,"\\","/")},isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},isBlobUrl(i){return i.startsWith("blob:")},hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){ie(i),i=this.toPosix(i);const t=/^file:\/\/\//.exec(i);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(i);return e?e[0]:""},toAbsolute(i,t,e){if(ie(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const r=Fi(this.toPosix(t??H.ADAPTER.getBaseUrl())),s=Fi(this.toPosix(e??this.rootname(r)));return i=this.toPosix(i),i.startsWith("/")?At.join(s,i.slice(1)):this.isAbsolute(i)?i:this.join(r,i)},normalize(i){if(ie(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let t="";const e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));const r=i.endsWith("/");return i=s1(i,!1),i.length>0&&r&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return ie(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){if(i.length===0)return".";let t;for(let e=0;e<i.length;++e){const r=i[e];if(ie(r),r.length>0)if(t===void 0)t=r;else{const s=i[e-1]??"";this.extname(s)?t+=`/../${r}`:t+=`/${r}`}}return t===void 0?".":this.normalize(t)},dirname(i){if(ie(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let r=-1,s=!0;const n=this.getProtocol(i),o=i;i=i.slice(n.length);for(let a=i.length-1;a>=1;--a)if(t=i.charCodeAt(a),t===47){if(!s){r=a;break}}else s=!1;return r===-1?e?"/":this.isUrl(o)?n+i:n:e&&r===1?"//":n+i.slice(0,r)},rootname(i){ie(i),i=this.toPosix(i);let t="";if(i.startsWith("/")?t="/":t=this.getProtocol(i),this.isUrl(i)){const e=i.indexOf("/",t.length);e!==-1?t=i.slice(0,e):t=i,t.endsWith("/")||(t+="/")}return t},basename(i,t){ie(i),t&&ie(t),i=Fi(this.toPosix(i));let e=0,r=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";let o=t.length-1,a=-1;for(n=i.length-1;n>=0;--n){const l=i.charCodeAt(n);if(l===47){if(!s){e=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(r=n):(o=-1,r=a))}return e===r?r=a:r===-1&&(r=i.length),i.slice(e,r)}for(n=i.length-1;n>=0;--n)if(i.charCodeAt(n)===47){if(!s){e=n+1;break}}else r===-1&&(s=!1,r=n+1);return r===-1?"":i.slice(e,r)},extname(i){ie(i),i=Fi(this.toPosix(i));let t=-1,e=0,r=-1,s=!0,n=0;for(let o=i.length-1;o>=0;--o){const a=i.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}r===-1&&(s=!1,r=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||r===-1||n===0||n===1&&t===r-1&&t===e+1?"":i.slice(t,r)},parse(i){ie(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=Fi(this.toPosix(i));let e=i.charCodeAt(0);const r=this.isAbsolute(i);let s;t.root=this.rootname(i),r||this.hasProtocol(i)?s=1:s=0;let n=-1,o=0,a=-1,l=!0,h=i.length-1,c=0;for(;h>=s;--h){if(e=i.charCodeAt(h),e===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),e===46?n===-1?n=h:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&r?t.base
vendor: 5,631 bytes, line 10
10=t.name=i.slice(1,a):t.base=t.name=i.slice(o,a)):(o===0&&r?(t.name=i.slice(1,n),t.base=i.slice(1,a)):(t.name=i.slice(o,n),t.base=i.slice(o,a)),t.ext=i.slice(n,a)),t.dir=this.dirname(i),t},sep:"/",delimiter:":"};let No;async function n1(){return No??(No=(async()=>{const i=document.createElement("canvas").getContext("webgl");if(!i)return Ht.UNPACK;const t=await new Promise(n=>{const o=document.createElement("video");o.onloadeddata=()=>n(o),o.onerror=()=>n(null),o.autoplay=!1,o.crossOrigin="anonymous",o.preload="auto",o.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",o.load()});if(!t)return Ht.UNPACK;const e=i.createTexture();i.bindTexture(i.TEXTURE_2D,e);const r=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,r),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return i.readPixels(0,0,1,1,i.RGBA,i.UNSIGNED_BYTE,s),i.deleteFramebuffer(r),i.deleteTexture(e),i.getExtension("WEBGL_lose_context")?.loseContext(),s[0]<=s[3]?Ht.PMA:Ht.UNPACK})()),No}let Lo;function o1(){return typeof Lo>"u"&&(Lo=function(){const i={stencil:!0,failIfMajorPerformanceCaveat:H.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!H.ADAPTER.getWebGLRenderingContext())return!1;const t=H.ADAPTER.createCanvas();let e=t.getContext("webgl",i)||t.getContext("experimental-webgl",i);const r=!!e?.getContextAttributes()?.stencil;if(e){const s=e.getExtension("WEBGL_lose_context");s&&s.loseContext()}return e=null,r}catch{return!1}}()),Lo}var a1={grad:.9,turn:360,rad:360/(2*Math.PI)},ke=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},It=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},Qt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},tf=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},bc=function(i){return{r:Qt(i.r,0,255),g:Qt(i.g,0,255),b:Qt(i.b,0,255),a:Qt(i.a)}},Uo=function(i){return{r:It(i.r),g:It(i.g),b:It(i.b),a:It(i.a,3)}},l1=/^#([0-9a-f]{3,8})$/i,vs=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},ef=function(i){var t=i.r,e=i.g,r=i.b,s=i.a,n=Math.max(t,e,r),o=n-Math.min(t,e,r),a=o?n===t?(e-r)/o:n===e?2+(r-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},rf=function(i){var t=i.h,e=i.s,r=i.v,s=i.a;t=t/360*6,e/=100,r/=100;var n=Math.floor(t),o=r*(1-e),a=r*(1-(t-n)*e),l=r*(1-(1-t+n)*e),h=n%6;return{r:255*[r,a,o,o,l,r][h],g:255*[l,r,r,a,o,o][h],b:255*[o,o,l,r,r,a][h],a:s}},xc=function(i){return{h:tf(i.h),s:Qt(i.s,0,100),l:Qt(i.l,0,100),a:Qt(i.a)}},wc=function(i){return{h:It(i.h),s:It(i.s),l:It(i.l),a:It(i.a,3)}},Tc=function(i){return rf((e=(t=i).s,{h:t.h,s:(e*=((r=t.l)<50?r:100-r)/100)>0?2*e/(r+e)*100:0,v:r+e,a:t.a}));var t,e,r},Ji=function(i){return{h:(t=ef(i)).h,s:(s=(200-(e=t.s))*(r=t.v)/100)>0&&s<200?e*r/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,r,s},h1=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,c1=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,u1=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,d1=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ga={string:[[function(i){var t=l1.exec(i);return t?(i=t[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:i.length===4?It(parseInt(i[3]+i[3],16)/255,2):1}:i.length===6||i.length===8?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:i.length===8?It(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=u1.exec(i)||d1.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:bc({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(i){var t=h1.exec(i)||c1.exec(i);if(!t)return null;var e,r,s=xc({h:(e=t[1],r=t[2],r===void 0&&(r="deg"),Number(e)*(a1[r]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Tc(s)},"hsl"]],object:[[function(i){var t=i.r,e=i.g,r=i.b,s=i.a,n=s===void 0?1:s;return ke(t)&&ke(e)&&ke(r)?bc({r:Number(t),g:Number(e),b:Number(r),a:Number(n)}):null},"rgb"],[function(i){var t=i.h,e=i.s,r=i.l,s=i.a,n=s===void 0?1:s;if(!ke(t)||!ke(e)||!ke(r))return null;var o=xc({h:Number(t),s:Number(e),l:Number(r),a:Number(n)});return Tc(o)},"hsl"],[function(i){var t=i.h,e=i.s,r=i.v,s=i.a,n=s===void 0?1:s;if(!ke(t)||!ke(e)||!ke(r))return null;var o=function(a){return{h:tf(a.h),s:Qt(a.s,0,100),v:Qt(a.v,0,100),a:Qt(a.a)}}({h:Number(t),s:Number(e),v:Number(r),a:Number(n)});
vendor: 5,236 bytes, line 10
10return rf(o)},"hsv"]]},Ec=function(i,t){for(var e=0;e<t.length;e++){var r=t[e][0](i);if(r)return[r,t[e][1]]}return[null,void 0]},f1=function(i){return typeof i=="string"?Ec(i.trim(),Ga.string):typeof i=="object"&&i!==null?Ec(i,Ga.object):[null,void 0]},Go=function(i,t){var e=Ji(i);return{h:e.h,s:Qt(e.s+100*t,0,100),l:e.l,a:e.a}},Ho=function(i){return(299*i.r+587*i.g+114*i.b)/1e3/255},Ac=function(i,t){var e=Ji(i);return{h:e.h,s:e.s,l:Qt(e.l+100*t,0,100),a:e.a}},Ha=function(){function i(t){this.parsed=f1(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return i.prototype.isValid=function(){return this.parsed!==null},i.prototype.brightness=function(){return It(Ho(this.rgba),2)},i.prototype.isDark=function(){return Ho(this.rgba)<.5},i.prototype.isLight=function(){return Ho(this.rgba)>=.5},i.prototype.toHex=function(){return t=Uo(this.rgba),e=t.r,r=t.g,s=t.b,o=(n=t.a)<1?vs(It(255*n)):"","#"+vs(e)+vs(r)+vs(s)+o;var t,e,r,s,n,o},i.prototype.toRgb=function(){return Uo(this.rgba)},i.prototype.toRgbString=function(){return t=Uo(this.rgba),e=t.r,r=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+r+", "+s+", "+n+")":"rgb("+e+", "+r+", "+s+")";var t,e,r,s,n},i.prototype.toHsl=function(){return wc(Ji(this.rgba))},i.prototype.toHslString=function(){return t=wc(Ji(this.rgba)),e=t.h,r=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+r+"%, "+s+"%, "+n+")":"hsl("+e+", "+r+"%, "+s+"%)";var t,e,r,s,n},i.prototype.toHsv=function(){return t=ef(this.rgba),{h:It(t.h),s:It(t.s),v:It(t.v),a:It(t.a,3)};var t},i.prototype.invert=function(){return _e({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},i.prototype.saturate=function(t){return t===void 0&&(t=.1),_e(Go(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),_e(Go(this.rgba,-t))},i.prototype.grayscale=function(){return _e(Go(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),_e(Ac(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),_e(Ac(this.rgba,-t))},i.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},i.prototype.alpha=function(t){return typeof t=="number"?_e({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):It(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=Ji(this.rgba);return typeof t=="number"?_e({h:t,s:e.s,l:e.l,a:e.a}):It(e.h)},i.prototype.isEqual=function(t){return this.toHex()===_e(t).toHex()},i}(),_e=function(i){return i instanceof Ha?i:new Ha(i)},Sc=[],p1=function(i){i.forEach(function(t){Sc.indexOf(t)<0&&(t(Ha,Ga),Sc.push(t))})};function m1(i,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",s
vendor: 5,408 bytes, line 10
10andybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var s in e)r[e[s]]=s;var n={};i.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=r[this.toHex()];if(h)return h;if(o?.closest){var c=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in e)n[f]=new i(e[f]).toRgb();for(var p in e){var g=(a=c,l=n[p],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));g<u&&(u=g,d=p)}return d}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new i(l).toRgb():null},"name"])}p1([m1]);const oi=class Js{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof Js)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,e){const r=typeof t;if(r!==typeof e)return!1;if(r==="number"||r==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,r,s]=this._components;return{r:t,g:e,b:r,a:s}}toRgb(){const[t,e,r]=this._components;return{r:t,g:e,b:r}}toRgbaString(){const[t,e,r]=this.toUint8RgbArray();return`rgba(${t},${e},${r},${this.alpha})`}toUint8RgbArray(t){const[e,r,s]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(r*255),t[2]=Math.round(s*255),t}toRgbArray(t){t=t??[];const[e,r,s]=this._components;return t[0]=e,t[1]=r,t[2]=s,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,r,s,n]=Js.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=r,this._components[2]*=s,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let r=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return e&&(r=r*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(r<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,r,s]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(r*t)/t,this._components[2]=Math.round(s*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,r,s,n]=this._components;return t[0]=e,t[1]=r,t[2]=s,t[3]=n,t}normalize(t){let e,r,s,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,r=(o>>8&255)/255,s=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,r,s,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,r,s,n=255]=t,e/=255,r/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=Js.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=_e(t);o.isValid()&&({r:e,g:r,b:s,a:n}=o.rgba,e/=255,r/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=r,this._components[2]=s,this._components[3]=n,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,e,r]=this._components;this._int=(t*255<<16)+(e*255<<8)+(r*255|0)}_clamp(t,e=0,r=1){return typeof t=="number"?Math.min(Math.max(t,e),r):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),r)}),t)}};oi.shared=new oi,oi.temp=new oi,oi.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let ut=oi;function _1(i){return rt("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),ut.shared.setValue(i).toHex()}function g1(i){return rt("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),ut.shared.setValue(i).toNumber()}function y1(){const i=[],t=[];for(let r=0;r<32;r++)i[r]=r,t[r]=r;i[Z.NORMAL_NPM]=Z.NORMAL,i[Z.ADD_NPM]=Z.ADD,i[Z.SCREEN_NPM]=Z.SCREEN,t[Z.NORMAL]=Z.NORMAL_NPM,t[Z.ADD]=Z.ADD_NPM,t[Z.SCREEN]=Z.SCREEN_NPM;const e=[];return e.push(t),e.push(i),e}const sf=y1();function nf(i,t){return sf[t?1:0][i]}function v1(i,t=null){const e=i*6;
10if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let r=0,s=0;r<e;r+=6,s+=4)t[r+0]=s+0,t[r+1]=s+1,t[r+2]=s+2,t[r+3]=s+0,t[r+4]=s+2,t[r+5]=s+3;return t}function of(i){if(i.BYTES_PER_ELEMENT===4)return i instanceof Float32Array?"Float32Array":i instanceof Uint32Array?"Uint32Array":"Int32Array";if(i.BYTES_PER_ELEMENT===2){if(i instanceof Uint16Array)return"Uint16Array"}else if(i.BYTES_PER_ELEMENT===1&&i instanceof Uint8Array)return"Uint8Array";return null}function Cn(i){return i+=i===0?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function Cc(i){return!(i&i-1)&&!!i}function Ic(i){let t=(i>65535?1:0)<<4;i>>>=t;let e=(i>255?1:0)<<3;return i>>>=e,t|=e,e=(i>15?1:0)<<2,i>>>=e,t|=e,e=(i>3?1:0)<<1,i>>>=e,t|=e,t|i>>1}function vi(i,t,e){const r=i.length;let s;if(t>=r||e===0)return;e=t+e>r?r-t:e;const n=r-e;for(s=t;s<n;++s)i[s]=i[s+e];i.length=n}function rr(i){return i===0?0:i<0?-1:1}let b1=0;function Hr(){return++b1}const za=class{constructor(i,t,e,r){this.left=i,this.top=t,this.right=e,this.bottom=r}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};za.EMPTY=new za(0,0,0,0);let Rc=za;const Pc={},ge=Object.create(null),We=Object.create(null);class x1{constructor(t,e,r){this._canvas=H.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=r||H.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function Mc(i,t,e){for(let r=0,s=4*e*t;r<t;++r,s+=4)if(i[s+3]!==0)return!1;return!0}function Bc(i,t,e,r,s){const n=4*t;for(let o=r,a=r*n+4*e;o<=s;++o,a+=n)if(i[a+3]!==0)return!1;return!0}function w1(i){const{width:t,height:e}=i,r=i.getContext("2d",{willReadFrequently:!0});if(r===null)throw new TypeError("Failed to get canvas 2D context");const s=r.getImageData(0,0,t,e).data;let n=0,o=0,a=t-1,l=e-1;for(;o<e&&Mc(s,t,o);)++o;if(o===e)return Rc.EMPTY;for(;Mc(s,t,l);)--l;for(;Bc(s,t,n,o,l);)++n;for(;Bc(s,t,a,o,l);)--a;return++a,++l,new Rc(n,o,a,l)}function T1(i){const t=w1(i),{width:e,height:r}=t;let s=null;if(!t.isEmpty()){const n=i.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");s=n.getImageData(t.left,t.top,e,r)}return{width:e,height:r,data:s}}function E1(i,t=globalThis.location){if(i.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(i,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function Ve(i,t=1){const e=H.RETINA_PREFIX?.exec(i);return e?parseFloat(e[1]):t}var U=(i=>(i.Renderer="renderer",i.Application="application",i.RendererSystem="renderer-webgl-system",i.RendererPlugin="renderer-webgl-plugin",i.CanvasRendererSystem="renderer-canvas-system",i.CanvasRendererPlugin="renderer-canvas-plugin",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i))(U||{});const Xa=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={...typeof i.extension!="object"?{type:i.extension}:i.extension,ref:i}}if(typeof i=="object")i={...i};else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},kc=(i,t)=>Xa(i).priority??t,$={_addHandlers:{},_removeHandlers:{},_queue:{}
10,remove(...i){return i.map(Xa).forEach(t=>{t.type.forEach(e=>this._removeHandlers[e]?.(t))}),this},add(...i){return i.map(Xa).forEach(t=>{t.type.forEach(e=>{const r=this._addHandlers,s=this._queue;r[e]?r[e](t):(s[e]=s[e]||[],s[e].push(t))})}),this},handle(i,t,e){const r=this._addHandlers,s=this._removeHandlers;if(r[i]||s[i])throw new Error(`Extension type ${i} already has a handler`);r[i]=t,s[i]=e;const n=this._queue;return n[i]&&(n[i].forEach(o=>t(o)),delete n[i]),this},handleByMap(i,t){return this.handle(i,e=>{t[e.name]=e.ref},e=>{delete t[e.name]})},handleByList(i,t,e=-1){return this.handle(i,r=>{t.includes(r.ref)||(t.push(r.ref),t.sort((s,n)=>kc(n,e)-kc(s,e)))},r=>{const s=t.indexOf(r.ref);s!==-1&&t.splice(s,1)})}};class Va{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const A1=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` 11`);function S1(i){let t="";for(let e=0;e<i;++e)e>0&&(t+=` 12else `),e<i-1&&(t+=`if(test == ${e}.0){}`);return t}function C1(i,t){if(i===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);for(;;){const r=A1.replace(/%forloop%/gi,S1(i));if(t.shaderSource(e,r),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))i=i/2|0;else break}return i}const zo=0,Xo=1,Vo=2,Wo=3,$o=4,jo=5;class Re{constructor(){this.data=0,this.blendMode=Z.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<zo)}set blend(t){!!(this.data&1<<zo)!==t&&(this.data^=1<<zo)}get offsets(){return!!(this.data&1<<Xo)}set offsets(t){!!(this.data&1<<Xo)!==t&&(this.data^=1<<Xo)}get culling(){return!!(this.data&1<<Vo)}set culling(t){!!(this.data&1<<Vo)!==t&&(this.data^=1<<Vo)}get depthTest(){return!!(this.data&1<<Wo)}set depthTest(t){!!(this.data&1<<Wo)!==t&&(this.data^=1<<Wo)}get depthMask(){return!!(this.data&1<<jo)}set depthMask(t){!!(this.data&1<<jo)!==t&&(this.data^=1<<jo)}get clockwiseFrontFace(){return!!(this.data&1<<$o)}set clockwiseFrontFace(t){!!(this.data&1<<$o)!==t&&(this.data^=1<<$o)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==Z.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Re;return t.depthTest=!1,t.blend=!0,t}}Re.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const Wa=[];function af(i,t){if(!i)return null;let e="";if(typeof i=="string"){const r=/\.(\w{3,4})(?:$|\?|#)/i.exec(i);r&&(e=r[1].toLowerCase())}for(let r=Wa.length-1;r>=0;--r){const s=Wa[r];if(s.test&&s.test(i,e))return new s(i,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class ce{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,r,s,n,o,a,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:h,items:c}=this;this._aliasCount++;for(let u=0,d=c.length;u<d;u++)c[u][h](t,e,r,s,n,o,a,l);return c===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(ce.prototype,{dispatch:{value:ce.prototype.emit},run:{value:ce.prototype.emit}});class rs{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new ce("setRealSize"),this.onUpdate=new ce("update"),this.onError=ne
vendor: 23,660 bytes, lines 12-26
12w ce("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,r){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class Jn extends rs{constructor(t,e){const{width:r,height:s}=e||{};if(!r||!s)throw new Error("BufferResource width or height invalid");super(r,s),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,r){const s=t.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Ht.UNPACK);const n=e.realWidth,o=e.realHeight;return r.width===n&&r.height===o?s.texSubImage2D(e.target,0,0,0,n,o,e.format,r.type,this.data):(r.width=n,r.height=o,s.texImage2D(e.target,0,r.internalFormat,n,o,0,e.format,r.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const I1={scaleMode:Ne.NEAREST,alphaMode:Ht.NPM},$a=class ai extends ls{constructor(t=null,e=null){super(),e=Object.assign({},ai.defaultOptions,e);const{alphaMode:r,mipmap:s,anisotropicLevel:n,scaleMode:o,width:a,height:l,wrapMode:h,format:c,type:u,target:d,resolution:f,resourceOptions:p}=e;t&&!(t instanceof rs)&&(t=af(t,p),t.internal=!0),this.resolution=f||H.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=h,this._scaleMode=o,this.format=c,this.type=u,this.target=d,this.alphaMode=r,this.uid=Hr(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=a>0&&l>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(t)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,e){let r;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,r=!0),e!==void 0&&e!==this.mipmap&&(this.mipmap=e,r=!0),r&&this.dirtyStyleId++,this}setSize(t,e,r){return r=r||this.resolution,this.setRealSize(t*r,e*r,r)}setRealSize(t,e,r){return this.resolution=r||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=Cc(this.realWidth)&&Cc(this.realHeight)}setResolution(t){const e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete We[this.cacheId],delete ge[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),ai.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,e,r=H.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else{if(!t._pixiId){const a=e?.pixiIdPrefix||"pixiid";t._pixiId=`${a}_${Hr()}`}n=t._pixiId}let o=We[n];if(s&&r&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new ai(t,e),o.cacheId=n,ai.addToCache(o,n)),o}static fromBuffer(t,e,r,s){t=t||new Float32Array(e*r*4);const n=new Jn(t,{width:e,height:r,...s?.resourceOptions});let o,a;return t instanceof Float32Array?(o=F.RGBA,a=q.FLOAT):t instanceof Int32Array?(o=F.RGBA_INTEGER,a=q.INT):t instanceof Uint32Array?(o=F.RGBA_INTEGER,a=q.UNSIGNED_INT):t instanceof Int16Array?(o=F.RGBA_INTEGER,a=q.SHORT):t instanceof Uint16Array?(o=F.RGBA_INTEGER,a=q.UNSIGNED_SHORT):t instanceof Int8Array?(o=F.RGBA,a=q.BYTE):(o=F.RGBA,a=q.UNSIGNED_BYTE),n.internal=!0,new ai(n,Object.assign({},I1,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),We[e]&&We[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),We[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=We[t];if(e){const r=e.textureCacheIds.indexOf(t);return r>-1&&e.textureCacheIds.splice(r,1),delete We[t],e}}else if(t?.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete We[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};$a.defaultOptions={mipmap:Ie.POW2,anisotropicLevel:0,scaleMode:Ne.LINEAR,wrapMode:nr.CLAMP,alphaMode:Ht.UNPACK,target:_i.TEXTURE_2D,format:F.RGBA,type:q.UNSIGNED_BYTE},$a._globalBatch=0;let Q=$a;class ja{constructor(){this.texArray=null,this.blend=0,this.type=we.TRIANGLES,this.start=0,this.size=0,this.data=null}}let R1=0;class vt{constructor(t,e=!0,r=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=r,this.static=e,this.id=R1++,this.disposeRunner=new ce("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?Se.ELEMENT_ARRAY_BUFFER:Se.ARRAY_BUFFER}get index(){return this.type===Se.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new vt(t)}}class In{constructor(t,e=0,r=!1,s=q.FLOAT,n,o,a,l=1){this.buffer=t,this.size=e,this.normalized=r,this.type=s,this.stride=n,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(t,e,r,s,n){return new In(t,e,r,s,n)}}const P1={Float32Array,Uint32Array,Int32Array,Uint8Array};function M1(i,t){let e=0,r=0;const s={};for(let l=0;l<i.length;l++)r+=t[l],e+=i[l].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let l=0;l<i.length;l++){const h=t[l],c=i[l],u=of(c);s[u]||(s[u]=new P1[u](n)),o=s[u];for(let d=0;d<c.length;d++){const f=(d/h|0)*r+a,p=d%h;o[f+p]=c[d]}a+=h}return new Float32Array(n)}const Dc={5126:4,5123:2,5121:1};let B1=0;const k1={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class lr{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=B1++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new ce("disposeGeometry"),this.refCount=0}addAttribute(t,e,r=0,s=!1,n,o,a,l=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof vt||(e instanceof Array&&(e=new Float32Array(e)),e=new vt(e));const h=t.split("|");if(h.length>1){for(let u=0;u<h.length;u++)this.addAttribute(h[u],e,r,s,n);return this}let c=this.buffers.indexOf(e);return c===-1&&(this.buffers.push(e),c=this.buffers.length-1),this.attributes[t]=new In(c,r,s,n,o,a,l),this.instanced=this.instanced||l,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof vt||(t instanceof Array&&(t=new Uint16Array(t)),t=new vt(t)),t.type=Se.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],r=new vt;let s;for(s in this.attributes){const n=this.attributes[s],o=this.buffers[n.buffer];t.push(o.data),e.push(n.size*Dc[n.type]/4),n.buffer=0}for(r.data=M1(t,e),s=0;s<this.buffers.length;s++)this.buffers[s]!==this.indexBuffer&&this.buffers[s].destroy();return this.buffers=[r],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new lr;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new vt(this.buffers[e].data.slice(0));for(const e in this.attributes){const r=this.attributes[e];t.attributes[e]=new In(r.buffer,r.size,r.normalized,r.type,r.stride,r.start,r.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=Se.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new lr,r=[],s=[],n=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)s[l]=s[l]||0,s[l]+=o.buffers[l].data.length,n[l]=0}for(let a=0;a<o.buffers.length;a++)r[a]=new k1[of(o.buffers[a].data)](s[a]),e.buffers[a]=new vt(r[a]);for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)r[l].set(o.buffers[l].data,n[l]),n[l]+=o.buffers[l].data.length}if(e.attributes=o.attributes,o.indexBuffer){e.indexBuffer=e.buffers[o.buffers.indexOf(o.indexBuffer)],e.indexBuffer.type=Se.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,c=0;for(let u=0;u<o.buffers.length;u++)if(o.buffers[u]!==o.indexBuffer){c=u;break}for(const u in o.attributes){const d=o.attributes[u];(d.buffer|0)===c&&(l+=d.size*Dc[d.type]/4)}for(let u=0;u<t.length;u++){const d=t[u].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+h]+=a;a+=t[u].buffers[c].data.length/l,h+=d.length}}return e}}class lf extends lr{constructor(t=!1){super(),this._buffer=new vt(null,t,!1),this._indexBuffer=new vt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,q.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,q.FLOAT).addAttribute("aColor",this._buffer,4,!0,q.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,q.FLOAT).addIndex(this._indexBuffer)}}const Rn=Math.PI*2,D1=180/Math.PI,F1=Math.PI/180;var Pt=(i=>(i[i.POLY=0]="POLY",i[i.RECT=1]="RECT",i[i.CIRC=2]="CIRC",i[i.ELIP=3]="ELIP",i[i.RREC=4]="RREC",i))(Pt||{});class ot{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new ot(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}}ot.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const bs=[new ot,new ot,new ot,new ot];class K{constructor(t=0,e=0,r=0,s=0){this.x=Number(t),this.y=Number(e),this.width=Number(r),this.height=Number(s),this.type=Pt.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new K(0,0,0,0)}clone(){return new K(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const C=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=C)return!1;const T=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>T}const r=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=r||o<=n)return!1;const a=bs[0].set(t.left,t.top),l=bs[1].set(t.left,t.bottom),h=bs[2].set(t.right,t.top),c=bs[3].set(t.right,t.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(l,l),e.apply(h,h),e.apply(c,c),Math.max(a.x,l.x,h.x,c.x)<=r||Math.min(a.x,l.x,h.x,c.x)>=s||Math.max(a.y,l.y,h.y,c.y)<=n||Math.min(a.y,l.y,h.y,c.y)>=o))return!1;const d=u*(l.y-a.y),f=u*(a.x-l.x),p=d*r+f*n,g=d*s+f*n,y=d*r+f*o,m=d*s+f*o;if(Math.max(p,g,y,m)<=d*a.x+f*a.y||Math.min(p,g,y,m)>=d*c.x+f*c.y)return!1;const v=u*(a.y-h.y),_=u*(h.x-a.x),b=v*r+_*n,w=v*s+_*n,A=v*r+_*o,x=v*s+_*o;return!(Math.max(b,w,A,x)<=v*a.x+_*a.y||Math.min(b,w,A,x)>=v*c.x+_*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),r=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(r-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const r=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=r-this.x,this.height=s-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),r=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=r-e,this.y=s,this.height=n-s,this}}K.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Qn{constructor(t=0,e=0,r=0){this.x=t,this.y=e,this.radius=r,this.type=Pt.CIRC}clone(){return new Qn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const r=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=r}getBounds(){return new K(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}Qn.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class to{constructor(t=0,e=0,r=0,s=0){this.x=t,this.y=e,this.width=r,this.height=s,this.type=Pt.ELIP}clone(){return new to(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let r=(t-this.x)/this.width,s=(e-this.y)/this.height;return r*=r,s*=s,r+s<=1}getBounds(){return new K(this.x-this.width,this.y-this.height,this.width,this.height)}}to.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Fr{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const r=[];for(let s=0,n=e.length;s<n;s++)r.push(e[s].x,e[s].y);e=r}this.points=e,this.type=Pt.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Fr(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let r=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],l=this.points[n*2+1],h=this.points[o*2],c=this.points[o*2+1];l>e!=c>e&&t<(h-a)*((e-l)/(c-l))+a&&(r=!r)}return r}}Fr.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((i,t)=>`${i}, ${t}`,"")}]`};class eo{constructor(t=0,e=0,r=0,s=0,n=20){this.x=t,this.y=e,this.width=r,this.height=s,this.radius=n,this.type=Pt.RREC}clone(){return new eo(this.x,this.y,this.width,this.height,this.radius)}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const r=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+r&&e<=this.y+this.height-r||t>=this.x+r&&t<=this.x+this.width-r)return!0;let s=t-(this.x+r),n=e-(this.y+r);const o=r*r;if(s*s+n*n<=o||(s=t-(this.x+this.width-r),s*s+n*n<=o)||(n=e-(this.y+this.height-r),s*s+n*n<=o)||(s=t-(this.x+r),s*s+n*n<=o))return!0}return!1}}eo.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class dt{constructor(t=1,e=0,r=0,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=r,this.d=s,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,r,s,n,o){return this.a=t,this.b=e,this.c=r,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const r=e||this.array;return t?(r[0]=this.a,r[1]=this.b,r[2]=0,r[3]=this.c,r[4]=this.d,r[5]=0,r[6]=this.tx,r[7]=this.ty,r[8]=1):(r[0]=this.a,r[1]=this.c,r[2]=this.tx,r[3]=this.b,r[4]=this.d,r[5]=this.ty,r[6]=0,r[7]=0,r[8]=1),r}apply(t,e){e=e||new ot;const r=t.x,s=t.y;return e.x=this.a*r+this.c*s+this.tx,e.y=this.b*r+this.d*s+this.ty,e}applyInverse(t,e){e=e||new ot;const r=1/(this.a*this.d+this.c*-this.b),s=t.x,n=t.y;return e.x=this.d*r*s+-this.c*r*n+(this.ty*this.c-this.tx*this.d)*r,e.y=this.a*r*n+-this.b*r*s+(-this.ty*this.a+this.tx*this.b)*r,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),r=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*r,this.b=s*r+this.b*e,this.c=n*e-this.d*r,this.d=n*r+this.d*e,this.tx=o*e-this.ty*r,this.ty=o*r+this.ty*e,this}append(t){const e=this.a,r=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*r+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*r+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*r+t.ty*n+this.ty,this}setTransform(t,e,r,s,n,o,a,l,h){return this.a=Math.cos(a+h)*n,this.b=Math.sin(a+h)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(r*this.a+s*this.c),this.ty=e-(r*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const r=this.a,s=this.c;this.a=r*t.a+this.b*t.c,this.b=r*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,r=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),l=Math.atan2(r,e),h=Math.abs(a+l);return h<1e-5||Math.abs(Rn-h)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=l),t.scale.x=Math.sqrt(e*e+r*r),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(o.x*e+o.y*s),t.position.y=this.ty+(o.x*r+o.y*n),t}invert(){const t=this.a,e=this.b,r=this.c,s=this.d,n=this.tx,o=t*s-e*r;return this.a=s/o,this.b=-e/o,this.c=-r/o,this.d=t/o,this.tx=(r*this.ty-s*n)/o,this.ty=-(t*this.ty-e*n)/o,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new dt;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}static get IDENTITY(){return new dt}static get TEMP_MATRIX(){return new dt}}dt.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const Tr=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Er=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Ar=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Sr=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Ya=[],hf=[],xs=Math.sign;function O1(){for(let i=0;i<16;i++){const t=[];Ya.push(t);for(let e=0;e<16;e++){const r=xs(Tr[i]*Tr[e]+Ar[i]*Er[e]),s=xs(Er[i]*Tr[e]+Sr[i]*Er[e]),n=xs(Tr[i]*Ar[e]+Ar[i]*Sr[e]),o=xs(Er[i]*Ar[e]+Sr[i]*Sr[e]);for(let a=0;a<16;a++)if(Tr[a]===r&&Er[a]===s&&Ar[a]===n&&Sr[a]===o){t.push(a);break}}}for(let i=0;i<16;i++){const t=new dt;t.set(Tr[i],Er[i],Ar[i],Sr[i],0,0),hf.push(t)}}O1();const mt={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:i=>Tr[i],uY:i=>Er[i],vX:i=>Ar[i],vY:i=>Sr[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>Ya[i][t],sub:(i,t)=>Ya[i][mt.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?mt.S:mt.N:Math.abs(t)*2<=Math.abs(i)?i>0?mt.E:mt.W:t>0?i>0?mt.SE:mt.SW:i>0?mt.NE:mt.NW,matrixAppendRotationInv:(i,t,e=0,r=0)=>{const s=hf[mt.inv(t)];s.tx=e,s.ty=r,i.append(s)}};class Ue{constructor(t,e,r=0,s=0){this._x=r,this._y=s,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new Ue(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}Ue.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const qa=class{constructor(){this.worldTransform=new dt,this.localTransform=new dt,this.position=new Ue(this.onChange,this,0,0),this.scale=new Ue(this.onChange,this,1,1),this.pivot=new Ue(this.onChange,this,0,0),this.skew=new Ue(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const i=this.localTransform;this._localID!==this._currentLocalID&&(i.a=this._cx*this.scale.x,i.b=this._sx*this.scale.x,i.c=this._cy*this.scale.y,i.d=this._sy*this.scale.y,i.tx=this.position.x-(this.pivot.x*i.a+this.pivot.y*i.c),i.ty=this.position.y-(this.pivot.x*i.b+this.pivot.y*i.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(i){const t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==i._worldID){const e=i.worldTransform,r=this.worldTransform;r.a=t.a*e.a+t.b*e.c,r.b=t.a*e.b+t.b*e.d,r.c=t.c*e.a+t.d*e.c,r.d=t.c*e.b+t.d*e.d,r.tx=t.tx*e.a+t.ty*e.c+e.tx,r.ty=t.tx*e.b+t.ty*e.d+e.ty,this._parentID=i._worldID,this._worldID++}}setFromMatrix(i){i.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(i){this._rotation!==i&&(this._rotation=i,this.updateSkew())}};qa.IDENTITY=new qa;let Kl=qa;Kl.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var N1=`varying vec2 vTextureCoord; 13 14uniform sampler2D uSampler; 15 16void main(void){ 17 gl_FragColor *= texture2D(uSampler, vTextureCoord); 18}`,L1=`attribute vec2 aVertexPosition; 19attribute vec2 aTextureCoord; 20 21uniform mat3 projectionMatrix; 22 23varying vec2 vTextureCoord; 24 25void main(void){ 26 gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0
26)).xy, 0.0, 1.0); 27 vTextureCoord = aTextureCoord; 28} 29`;function Fc(i,t,e){const r=i.createShader(t);return i.shaderSource(r,e),i.compileShader(r),r}function Yo(i){const t=new Array(i);for(let e=0;e<t.length;e++)t[e]=!1;return t}function cf(i,t){switch(i){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Yo(2*t);case"bvec3":return Yo(3*t);case"bvec4":return Yo(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const bi=[{test:i=>i.type==="float"&&i.size===1&&!i.isArray,code:i=>` 30 if(uv["${i}"] !== ud["${i}"].value) 31 { 32 ud["${i}"].value = uv["${i}"] 33 gl.uniform1f(ud["${i}"].location, uv["${i}"]) 34 } 35 `},{test:(i,t)=>(i.type==="sampler2D"||i.type==="samplerCube"||i.type==="sampler2DArray")&&i.size===1&&!i.isArray&&(t==null||t.castToBaseTexture!==void 0),code:i=>`t = syncData.textureCount++; 36 37 renderer.texture.bind(uv["${i}"], t); 38 39 if(ud["${i}"].value !== t) 40 { 41 ud["${i}"].value = t; 42 gl.uniform1i(ud["${i}"].location, t); 43; // eslint-disable-line max-len 44 }`},{test:(i,t)=>i.type==="mat3"&&i.size===1&&!i.isArray&&t.a!==void 0,code:i=>` 45 gl.uniformMatrix3fv(ud["${i}"].location, false, uv["${i}"].toArray(true)); 46 `,codeUbo:i=>` 47 var ${i}_matrix = uv.${i}.toArray(true); 48 49 data[offset] = ${i}_matrix[0]; 50 data[offset+1] = ${i}_matrix[1]; 51 data[offset+2] = ${i}_matrix[2]; 52 53 data[offset + 4] = ${i}_matrix[3]; 54 data[offset + 5] = ${i}_matrix[4]; 55 data[offset + 6] = ${i}_matrix[5]; 56 57 data[offset + 8] = ${i}_matrix[6]; 58 data[offset + 9] = ${i}_matrix[7]; 59 data[offset + 10] = ${i}_matrix[8]; 60 `},{test:(i,t)=>i.type==="vec2"&&i.size===1&&!i.isArray&&t.x!==void 0,code:i=>` 61 cv = ud["${i}"].value; 62 v = uv["${i}"]; 63 64 if(cv[0] !== v.x || cv[1] !== v.y) 65 { 66 cv[0] = v.x; 67 cv[1] = v.y; 68 gl.uniform2f(ud["${i}"].location, v.x, v.y); 69 }`,codeUbo:i=>` 70 v = uv.${i}; 71 72 data[offset] = v.x; 73 data[offset+1] = v.y; 74 `},{test:i=>i.type==="vec2"&&i.size===1&&!i.isArray,code:i=>` 75 cv = ud["${i}"].value; 76 v = uv["${i}"]; 77 78 if(cv[0] !== v[0] || cv[1] !== v[1]) 79 { 80 cv[0] = v[0]; 81 cv[1] = v[1]; 82 gl.uniform2f(ud["${i}"].location, v[0], v[1]); 83 } 84 `},{test:(i,t)=>i.type==="vec4"&&i.size===1&&!i.isArray&&t.width!==void 0,code:i=>` 85 cv = ud["${i}"].value; 86 v = uv["${i}"]; 87 88 if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) 89 { 90 cv[0] = v.x; 91 cv[1] = v.y; 92 cv[2] = v.width; 93 cv[3] = v.height; 94 gl.uniform4f(ud["${i}"].location, v.x, v.y, v.width, v.height) 95 }`,codeUbo:i=>` 96 v = uv.${i}; 97 98 data[offset] = v.x; 99 data[offset+1] = v.y; 100 data[offset+2] = v.width; 101 data[offset+3] = v.height; 102 `},{test:(i,t)=>i.type==="vec4"&&i.size===1&&!i.isArray&&t.red!==void 0,code:i=>` 103 cv = ud["${i}"].value; 104 v = uv["${i}"]; 105 106 if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) 107 { 108 cv[0] = v.red; 109 cv[1] = v.green; 110 cv[2] = v.blue; 111 cv[3] = v.alpha; 112 gl.uniform4f(ud["${i}"].location, v.red, v.green, v.blue, v.alpha) 113 }`,codeUbo:i=>` 114 v = uv.${i}; 115 116 data[offset] = v.red; 117 data[offset+1] = v.green; 118 data[offset+2] = v.blue; 119 data[offset+3] = v.alpha; 120 `},{test:(i,t)=>i.type==="vec3"&&i.size===1&&!i.isArray&&t.red!==void 0,code:i=>` 121 cv = ud["${i}"].value; 122 v = uv["${i}"]; 123 124 if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a) 125 { 126 cv[0] = v.red; 127 cv[1] = v.green; 128 cv[2] = v.blue; 129 130 gl.uniform3f(ud["${i}"].location, v.red, v.green, v.blue) 131 }`,codeUbo:i=>` 132 v = uv.${i}; 133 134 data[offset] = v.red; 135 data[offset+1] = v.green; 136 data[offset+2] = v.blue; 137 `},{test:i=>i.type==="vec4"&&i.size===1&&!i.isArray,code:i=>` 138 cv = ud["${i}"].value; 139 v = uv["${i}"]; 140 141 if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 142 { 143 cv[0] = v[0]; 144 cv[1] = v[1]; 145 cv[2] = v[2]; 146 cv[3] = v[3]; 147 148 gl.uniform4f(ud["${i}"].location, v[0], v[1], v[2], v[3]) 149 }`}],U1={float:` 150 if (cv !== v) 151 { 152 cu.value = v; 153 gl.uniform1f(location, v); 154 }`,vec2:` 155 if (cv[0] !== v[0] || cv[1] !== v[1]) 156 { 157 cv[0] = v[0]; 158 cv[1] = v[1]; 159 160 gl.uniform2f(location, v[0], v[1]) 161 }`,vec3:` 162 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) 163 { 164 cv[0] = v[0]; 165 cv[1] = v[1]; 166 cv[2] = v[2]; 167 168 gl.uniform3f(location, v[0], v[1], v[2]) 169 }`,vec4:` 170 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 171 { 172 cv[0] = v[0]; 173 cv[1] = v[1]; 174 cv[2] = v[2]; 175 cv[3] = v[3]; 176 177 gl.uniform4f(location, v[0], v[1], v[2], v[3]); 178 }`,int:` 179 if (cv !== v) 180 { 181 cu.value = v; 182 183 gl.uniform1i(location, v); 184 }`,ivec2:` 185 if (cv[0] !== v[0] || cv[1] !== v[1]) 186 { 187 cv[0] = v[0]; 188 cv[1] = v[1]; 189 190 gl.uniform2i(location, v[0], v[1]); 191 }`,ivec3:` 192 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) 193 { 194 cv[0] = v[0]; 195 cv[1] = v[1]; 196 cv[2] = v[2]; 197 198 gl.uniform3i(location, v[0], v[1], v[2]); 199 }`,ivec4:` 200 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 201 { 202 cv[0] = v[0]; 203 cv[1] = v[1]; 204 cv[2] = v[2]; 205 cv[3] = v[3]; 206 207 gl.uniform4i(location, v[0], v[1], v[2], v[3]); 208 }`,uint:` 209 if (cv !== v) 210 { 211 cu.value = v; 212 213 gl.uniform1ui(location, v); 214 }`,uvec2:` 215 if (cv[0] !== v[0] || cv[1] !== v[1]) 216 { 217 cv[0] = v[0]; 218 cv[1] = v[1]; 219 220 gl.uniform2ui(location, v[0], v[1]); 221 }`,uvec3:` 222 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) 223 { 224 cv[0] = v[0]; 225 cv[1] = v[1]; 226 cv[2] = v[2]; 227 228 gl.uniform3ui(location, v[0], v[1], v[2]); 229 }`,uvec4:` 230 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 231 { 232 cv[0] = v[0]; 233 cv[1] = v[1]; 234 cv[2] = v[2]; 235 cv[3] = v[3]; 236 237 gl.uniform4ui(location, v[0], v[1], v[2], v[3]); 238 }`,bool:` 239 if (cv !== v) 240 { 241 cu.value = v; 242 gl.uniform1i(location, v); 243 }`,bvec2:` 244 if (cv[0] != v[0] || cv[1] != v[1]) 245 { 246 cv[0] = v[0]; 247 cv[1] = v[1]; 248 249 gl.uniform2i(location, v[0], v[1]); 250 }`,bvec3:` 251 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) 252 { 253 cv[0] = v[0]; 254 cv[1] = v[1]; 255 cv[2] = v[2]; 256 257 gl.uniform3i(location, v[0], v[1], v[2]); 258 }`,bvec4:` 259 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 260 { 261 cv[0] = v[0]; 262 cv[1] = v[1]; 263 cv[2] = v[2]; 264 cv[3] = v[3]; 265 266 gl.uniform4i(location, v[0], v[1], v[2], v[3]); 267 }`,mat2:"gl.uniformMatrix2fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",sampler2D:` 268 if (cv !== v) 269 { 270 cu.value = v; 271 272 gl.uniform1i(location, v); 273 }`,samplerCube:` 274 if (cv !== v) 275 { 276 cu.value = v; 277 278 gl.uniform1i(location, v); 279 }`,sampler2DArray:` 280 if (cv !== v) 281 { 282 cu.value = v; 283 284 gl.uniform1i(location, v); 285 }`},G1={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};function H1(i,t){const e=[` 286 var v = null; 287 var cv = null; 288 var cu = null; 289 var t = 0; 290 var gl = renderer.gl; 291 `];for(const r in i.uniforms){const s=t[r];
vendor: 7,792 bytes, lines 291-339
291if(!s){i.uniforms[r]?.group===!0&&(i.uniforms[r].ubo?e.push(` 292 renderer.shader.syncUniformBufferGroup(uv.${r}, '${r}'); 293 `):e.push(` 294 renderer.shader.syncUniformGroup(uv.${r}, syncData); 295 `));continue}const n=i.uniforms[r];let o=!1;for(let a=0;a<bi.length;a++)if(bi[a].test(s,n)){e.push(bi[a].code(r,n)),o=!0;break}if(!o){const a=(s.size===1&&!s.isArray?U1:G1)[s.type].replace("location",`ud["${r}"].location`);e.push(` 296 cu = ud["${r}"]; 297 cv = cu.value; 298 v = uv["${r}"]; 299 ${a};`)}}return new Function("ud","uv","renderer","syncData",e.join(` 300`))}const uf={};let ws=uf;function z1(){if(ws===uf||ws?.isContextLost()){const i=H.ADAPTER.createCanvas();let t;H.PREFER_ENV>=Vr.WEBGL2&&(t=i.getContext("webgl2",{})),t||(t=i.getContext("webgl",{})||i.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),ws=t}return ws}let Ts;function X1(){if(!Ts){Ts=Jt.MEDIUM;const i=z1();if(i&&i.getShaderPrecisionFormat){const t=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT);t&&(Ts=t.precision?Jt.HIGH:Jt.MEDIUM)}}return Ts}function Oc(i,t){const e=i.getShaderSource(t).split(` 301`).map((h,c)=>`${c}: ${h}`),r=i.getShaderInfoLog(t),s=r.split(` 302`),n={},o=s.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!n[h]?(n[h]=!0,!0):!1),a=[""];o.forEach(h=>{e[h-1]=`%c${e[h-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=e.join(` 303`);a[0]=l,console.error(r),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function V1(i,t,e,r){i.getProgramParameter(t,i.LINK_STATUS)||(i.getShaderParameter(e,i.COMPILE_STATUS)||Oc(i,e),i.getShaderParameter(r,i.COMPILE_STATUS)||Oc(i,r),console.error("PixiJS Error: Could not initialize shader."),i.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",i.getProgramInfoLog(t)))}const W1={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function df(i){return W1[i]}let Es=null;const Nc={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function ff(i,t){if(!Es){const e=Object.keys(Nc);Es={};for(let r=0;r<e.length;++r){const s=e[r];Es[i[s]]=Nc[s]}}return Es[t]}function Lc(i,t,e){if(i.substring(0,9)!=="precision"){let r=t;return t===Jt.HIGH&&e!==Jt.HIGH&&(r=Jt.MEDIUM),`precision ${r} float; 304${i}`}else if(e!==Jt.HIGH&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}let Oi;function $1(){if(typeof Oi=="boolean")return Oi;try{Oi=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Oi=!1}return Oi}let j1=0;const As={},Za=class li{constructor(t,e,r="pixi-shader",s={}){this.extra={},this.id=j1++,this.vertexSrc=t||li.defaultVertexSrc,this.fragmentSrc=e||li.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=s,this.vertexSrc.substring(0,8)!=="#version"&&(r=r.replace(/\s+/g,"-"),As[r]?(As[r]++,r+=`-${As[r]}`):As[r]=1,this.vertexSrc=`#define SHADER_NAME ${r} 305${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${r} 306${this.fragmentSrc}`,this.vertexSrc=Lc(this.vertexSrc,li.defaultVertexPrecision,Jt.HIGH),this.fragmentSrc=Lc(this.fragmentSrc,li.defaultFragmentPrecision,X1())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return L1}static get defaultFragmentSrc(){return N1}static from(t,e,r){const s=t+e;let n=Pc[s];return n||(Pc[s]=n=new li(t,e,r)),n}};Za.defaultVertexPrecision=Jt.HIGH,Za.defaultFragmentPrecision=Le.apple.device?Jt.HIGH:Jt.MEDIUM;let Ge=Za,Y1=0;class ue{constructor(t,e,r){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=Y1++,this.static=!!e,this.ubo=!!r,t instanceof vt?(this.buffer=t,this.buffer.type=Se.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new vt(new Float32Array(1)),this.buffer.type=Se.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,r){if(!this.ubo)this.uniforms[t]=new ue(e,r);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,e,r){return new ue(t,e,r)}static uboFrom(t,e){return new ue(t,e??!0,!0)}}class Ce{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof ue?this.uniformGroup=e:this.uniformGroup=new ue(e):this.uniformGroup=new ue({}),this.disposeRunner=new ce("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const r in e.uniforms){const s=e.uniforms[r];if(s.group===!0&&this.checkUniformExists(t,s))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,r){const s=Ge.from(t,e);return new Ce(s,r)}}class q1{constructor(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},!e.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!e.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const r=new Int32Array(t);for(let n=0;n<t;n++)r[n]=n;this.defaultGroupCache[t]=ue.from({uSamplers:r},!0);let s=this.fragTemplate;s=s.replace(/%count%/gi,`${t}`),s=s.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new Ge(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new dt,default:this.defaultGroupCache[t]};return new Ce(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=` 307`,e+=` 308`;for(let r=0;r<t;r++)r>0&&(e+=` 309else `),r<t-1&&(e+=`if(vTextureId < ${r}.5)`),e+=` 310{`,e+=` 311 color = texture2D(uSamplers[${r}], vTextureCoord);`,e+=` 312}`;return e+=` 313`,e+=` 314`,e}}class Ka{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}function Z1(){return!Le.apple.device}function K1(i){let t=!0;const e=H.ADAPTER.getNavigator();if(Le.tablet||Le.phone){if(Le.apple.device){const r=e.userAgent.match(/OS (\d+)_(\d+)?/);r&&parseInt(r[1],10)<11&&(t=!1)}if(Le.android.device){const r=e.userAgent.match(/Android\s([0-9.]*)/);r&&parseInt(r[1],10)<7&&(t=!1)}}return t?i:4}class ro{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var J1=`varying vec2 vTextureCoord; 315varying vec4 vColor; 316varying float vTextureId; 317uniform sampler2D uSamplers[%count%]; 318 319void main(void){ 320 vec4 color; 321 %forloop% 322 gl_FragColor = color * vColor; 323} 324`,Q1=`precision highp float; 325attribute vec2 aVertexPosition; 326attribute vec2 aTextureCoord; 327attribute vec4 aColor; 328attribute float aTextureId; 329 330uniform mat3 projectionMatrix; 331uniform mat3 translationMatrix; 332uniform vec4 tint; 333 334varying vec2 vTextureCoord; 335varying vec4 vColor; 336varying float vTextureId; 337 338void main(void){ 339 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
339)).xy, 0.0, 1.0); 340 341 vTextureCoord = aTextureCoord; 342 vTextureId = aTextureId; 343 vColor = aColor * tint; 344} 345`;const Hi=class oe extends ro{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=lf,this.vertexSize=6,this.state=Re.for2d(),this.size=oe.defaultBatchSize*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),t.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??K1(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??Z1(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return rt("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Q1}static get defaultFragmentTemplate(){return J1}setShaderGenerator({vertex:t=oe.defaultVertexSrc,fragment:e=oe.defaultFragmentTemplate}={}){this.shaderGenerator=new q1(t,e)}contextChange(){const t=this.renderer.gl;H.PREFER_ENV===Vr.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),oe.defaultMaxTextures),this.maxTextures=C1(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:e}=oe,r=this.size/4,s=Math.floor(r/this.maxTextures)+1;for(;t.length<r;)t.push(new ja);for(;e.length<s;)e.push(new Ka);for(let n=0;n<this.maxTextures;n++)this._tempBoundTextures[n]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:e}=this,r=oe._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++Q._globalBatch,l=0,h=r[0],c=0;s.copyBoundTextures(n,e);for(let u=0;u<this._bufferSize;++u){const d=t[u];t[u]=null,d._batchEnabled!==a&&(h.count>=e&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,c,u),c=u,h=r[++l],++a),d._batchEnabled=a,d.touched=o,h.elements[h.count++]=d)}h.count>0&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,c,this._bufferSize),++l,++a);for(let u=0;u<n.length;u++)n[u]=null;Q._globalBatch=a}buildDrawCalls(t,e,r){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,l=oe._drawCallPool;let h=this._dcIndex,c=this._aIndex,u=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=t;for(let f=e;f<r;++f){const p=s[f],g=p._texture.baseTexture,y=sf[g.alphaMode?1:0][p.blendMode];s[f]=null,e<f&&d.blend!==y&&(d.size=u-d.start,e=f,d=l[++h],d.texArray=t,d.start=u),this.packInterleavedGeometry(p,n,o,c,u),c+=p.vertexData.length/2*a,u+=p.indices.length,d.blend=y}e<r&&(d.size=u-d.start,++h),this._dcIndex=h,this._aIndex=c,this._iIndex=u}bindAndClearTexArray(t){const e=this.renderer.texture;for(let r=0;r<t.count;r++)e.bind(t.elements[r],t.ids[r]),t.elements[r]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:r}=this;oe.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(r),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(r),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:r}=this.renderer,s=oe._drawCallPool;let n=null;for(let o=0;o<t;o++){const{texArray:a,type:l,size:h,start:c,blend:u}=s[o];n!==a&&(n=a,this.bindAndClearTexArray(a)),this.state.blendMode=u,r.set(this.state),e.drawElements(l,h,e.UNSIGNED_SHORT,c*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),oe.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(t){const e=Cn(Math.ceil(t/8)),r=Ic(e),s=e*8;this._aBuffers.length<=r&&(this._iBuffers.length=r+1);let n=this._aBuffers[s];return n||(this._aBuffers[s]=n=new Va(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=Cn(Math.ceil(t/12)),r=Ic(e),s=e*12;this._iBuffers.length<=r&&(this._iBuffers.length=r+1);let n=this._iBuffers[r];return n||(this._iBuffers[r]=n=new Uint16Array(s)),n}packInterleavedGeometry(t,e,r,s,n){const{uint32View:o,float32View:a}=e,l=s/this.vertexSize,h=t.uvs,c=t.indices,u=t.vertexData,d=t._texture.baseTexture._batchLocation,f=Math.min(t.worldAlpha,1),p=ut.shared.setValue(t._tintRGB).toPremultiplied(f,t._texture.baseTexture.alphaMode>0);for(let g=0;g<u.length;g+=2)a[s++]=u[g],a[s++]=u[g+1],a[s++]=h[g],a[s++]=h[g+1],o[s++]=p,a[s++]=d;for(let g=0;g<c.length;g++)r[n++]=l+c[g]}};Hi.defaultBatchSize=4096,Hi.extension={name:"batch",type:U.RendererPlugin},Hi._drawCallPool=[],Hi._textureArrayPool=[];let Cr=Hi;$.add(Cr);var tv=`varying vec2 vTextureCoord; 346 347uniform sampler2D uSampler; 348 349void main(void){ 350 gl_FragColor = texture2D(uSampler, vTextureCoord); 351} 352`,ev=`attribute vec2 aVertexPosition; 353 354uniform mat3 projectionMatrix; 355 356varying vec2 vTextureCoord; 357 358uniform vec4 inputSize; 359uniform vec4 outputFrame; 360 361vec4 filterVertexPosition( void ) 362{ 363 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 364
365 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 366} 367 368vec2 filterTextureCoord( void ) 369{ 370 return aVertexPosition * (outputFrame.zw * inputSize.zw); 371} 372 373void main(void) 374{ 375 gl_Position = filterVertexPosition(); 376 vTextureCoord = filterTextureCoord(); 377} 378`;const Ja=class zi extends Ce{constructor(t,e,r){const s=Ge.from(t||zi.defaultVertexSrc,e||zi.defaultFragmentSrc);super(s,r),this.padding=0,this.resolution=zi.defaultResolution,this.multisample=zi.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Re}apply(t,e,r,s,n){t.applyFilter(this,e,r,s)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return ev}static get defaultFragmentSrc(){return tv}};Ja.defaultResolution=1,Ja.defaultMultisample=xt.NONE;let kt=Ja;class Pn{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new ut(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:r,backgroundAlpha:s}=t,n=r??e;n!==void 0&&(this.color=n),this.alpha=s}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}Pn.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Pn.extension={type:[U.RendererSystem,U.CanvasRendererSystem],name:"background"};$.add(Pn);class pf{constructor(t){this.renderer=t,this.emptyRenderer=new ro(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:r}=this.renderer.texture;for(let s=e-1;s>=0;--s)t[s]=r[s]||null,t[s]&&(t[s]._batchLocation=s)}boundArray(t,e,r,s){const{elements:n,ids:o,count:a}=t;let l=0;for(let h=0;h<a;h++){const c=n[h],u=c._batchLocation;if(u>=0&&u<s&&e[u]===c){o[h]=u;continue}for(;l<s;){const d=e[l];if(d&&d._batchEnabled===r&&d._batchLocation===l){l++;continue}o[h]=l,c._batchLocation=l,e[l]=c;break}}}destroy(){this.renderer=null}}pf.extension={type:U.RendererSystem,name:"batch"};$.add(pf);let Uc=0;class Mn{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=Uc++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,r=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:r,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=Uc++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;e.addEventListener!==void 0&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let r;if(H.PREFER_ENV>=Vr.WEBGL2&&(r=t.getContext("webgl2",e)),r)this.webGLVersion=2;else if(this.webGLVersion=1,r=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!r)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=r,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),r="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;r&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=r||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=s,s||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}Mn.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},Mn.extension={type:U.RendererSystem,name:"context"};$.add(Mn);class Qa{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new ce("disposeFramebuffer"),this.multisample=xt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new Q(null,{scaleMode:Ne.NEAREST,resolution:1,mipmap:Ie.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new Q(null,{scaleMode:Ne.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Ie.OFF,format:F.DEPTH_COMPONENT,type:q.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let r=0;r<this.colorTextures.length;r++){const s=this.colorTextures[r],n=s.resolution;s.setSize(t/n,e/n)}if(this.depthTexture){const r=this.depthTexture.resolution;this.depthTexture.setSize(t/r,e/r)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class mf extends Q{constructor(t={}){if(typeof t=="number"){const e=arguments[0],r=arguments[1],s=arguments[2],n=arguments[3];t={width:e,height:r,scaleMode:s,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=xt.NONE),super(null,t),this.mipmap=Ie.OFF,this.valid=!0,this._clear=new ut([0,0,0,0]),this.framebuffer=new Qa(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.he
vendor: 18,295 bytes, line 378
378ight)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class hr extends rs{constructor(t){const e=t,r=e.naturalWidth||e.videoWidth||e.width,s=e.naturalHeight||e.videoHeight||e.height;super(r,s),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,r){r===void 0&&!e.startsWith("data:")?t.crossOrigin=E1(e):r!==!1&&(t.crossOrigin=typeof r=="string"?r:"anonymous")}upload(t,e,r,s){const n=t.gl,o=e.realWidth,a=e.realHeight;if(s=s||this.source,typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement){if(!s.complete||s.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement&&s.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Ht.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&r.width===o&&r.height===a?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,r.type,s):(r.width=o,r.height=a,n.texImage2D(e.target,0,r.internalFormat,e.format,r.type,s)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,r=t.naturalHeight||t.videoHeight||t.height;this.resize(e,r),super.update()}dispose(){this.source=null}}class _f extends hr{constructor(t,e){if(e=e||{},typeof t=="string"){const r=new Image;hr.crossOrigin(r,t,e.crossorigin),r.src=t,t=r}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??H.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,r)=>{const s=this.source;this.url=s.src;const n=()=>{this.destroyed||(s.onload=null,s.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};s.complete&&s.src?n():(s.onload=n,s.onerror=o=>{r(o),this.onError.emit(o)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,r=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:r?"cors":"no-cors"}).then(s=>s.blob()).then(s=>e(s,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Ht.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,r){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,r);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,r,this.bitmap),!this.preserveBitmap){let s=!0;const n=e._glTextures;for(const o in n){const a=n[o];if(a!==r&&a.dirtyId!==e.dirtyId){s=!1;break}}s&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class Jl{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,r){const s=e.width,n=e.height;if(r){const o=t.width/2/s,a=t.height/2/n,l=t.x/s+o,h=t.y/n+a;r=mt.add(r,mt.NW),this.x0=l+o*mt.uX(r),this.y0=h+a*mt.uY(r),r=mt.add(r,2),this.x1=l+o*mt.uX(r),this.y1=h+a*mt.uY(r),r=mt.add(r,2),this.x2=l+o*mt.uX(r),this.y2=h+a*mt.uY(r),r=mt.add(r,2),this.x3=l+o*mt.uX(r),this.y3=h+a*mt.uY(r)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Jl.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const Gc=new Jl;function Ss(i){i.destroy=function(){},i.on=function(){},i.once=function(){},i.emit=function(){}}class W extends ls{constructor(t,e,r,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new K(0,0,1,1)),t instanceof W&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=Gc,this.uvMatrix=null,this.orig=r||e,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=o?new ot(o.x,o.y):new ot(0,0),this.defaultBorders=a,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:e}=this.baseTexture;e?.url&&ge[e.url]&&W.removeFromCache(e.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,W.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),r=new W(this.baseTexture,!this.noFrame&&t,e,this.trim?.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(r._frame=t),r}updateUvs(){this._uvs===Gc&&(this._uvs=new Jl),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},r=H.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof Q){if(!t.cacheId){const a=e?.pixiIdPrefix||"pixiid";t.cacheId=`${a}-${Hr()}`,Q.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=e?.pixiIdPrefix||"pixiid";t._pixiId=`${a}_${Hr()}`}n=t._pixiId}let o=ge[n];if(s&&r&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof Q)?(e.resolution||(e.resolution=Ve(t)),o=new W(new Q(t,e)),o.baseTexture.cacheId=n,Q.addToCache(o.baseTexture,n),W.addToCache(o,n)):!o&&t instanceof Q&&(o=new W(t),W.addToCache(o,n)),o}static fromURL(t,e){const r=Object.assign({autoLoad:!1},e?.resourceOptions),s=W.from(t,Object.assign({resourceOptions:r},e),!1),n=s.baseTexture.resource;return s.baseTexture.valid?Promise.resolve(s):n.load().then(()=>Promise.resolve(s))}static fromBuffer(t,e,r,s){return new W(Q.fromBuffer(t,e,r,s))}static fromLoader(t,e,r,s){const n=new Q(t,Object.assign({scaleMode:Q.defaultOptions.scaleMode,resolution:Ve(e)},s)),{resource:o}=n;o instanceof _f&&(o.url=e);const a=new W(n);return r||(r=e),Q.addToCache(a.baseTexture,r),W.addToCache(a,r),r!==e&&(Q.addToCache(a.baseTexture,e),W.addToCache(a,e)),a.baseTexture.valid?Promise.resolve(a):new Promise(l=>{a.baseTexture.once("loaded",()=>l(a))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),ge[e]&&ge[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),ge[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=ge[t];if(e){const r=e.textureCacheIds.indexOf(t);return r>-1&&e.textureCacheIds.splice(r,1),delete ge[t],e}}else if(t?.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)ge[t.textureCacheIds[e]]===t&&delete ge[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:r,width:s,height:n}=t,o=e+s>this.baseTexture.width,a=r+n>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${e} + ${s} = ${e+s} > ${this.baseTexture.width}`,c=`Y: ${r} + ${n} = ${r+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${c}`)}this.valid=s&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return W._EMPTY||(W._EMPTY=new W(new Q),Ss(W._EMPTY),Ss(W._EMPTY.baseTexture)),W._EMPTY}static get WHITE(){if(!W._WHITE){const t=H.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),W._WHITE=new W(Q.from(t)),Ss(W._WHITE),Ss(W._WHITE.baseTexture)}return W._WHITE}}class Ft extends W{constructor(t,e){super(t,e),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e,r=!0){const s=this.baseTexture.resolution,n=Math.round(t*s)/s,o=Math.round(e*s)/s;this.valid=n>0&&o>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=o,r&&this.baseTexture.resize(n,o),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new Ft(new mf(t))}}class gf{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,r=xt.NONE){const s=new mf(Object.assign({width:t,height:e,resolution:1,multisample:r},this.textureOptions));return new Ft(s)}getOptimalTexture(t,e,r=1,s=xt.NONE){let n;t=Math.max(Math.ceil(t*r-1e-6),1),e=Math.max(Math.ceil(e*r-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=Cn(t),e=Cn(e),n=((t&65535)<<16|e&65535)>>>0,s>1&&(n+=s*4294967296)):n=s>1?-s:-1,this.texturePool[n]||(this.texturePool[n]=[]);let o=this.texturePool[n].pop();return o||(o=this.createTexture(t,e,s)),o.filterPoolKey=n,o.setResolution(r),o}getFilterTexture(t,e,r){const s=this.getOptimalTexture(t.width,t.height,e||t.resolution,r||xt.NONE);return s.filterFrame=t.filterFrame,s}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const e in this.texturePool){const r=this.texturePool[e];if(r)for(let s=0;s<r.length;s++)r[s].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const r=this.texturePool[e];if(r)for(let s=0;s<r.length;s++)r[s].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}gf.SCREEN_KEY=-1;class rv extends lr{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class yf extends lr{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new vt(this.vertices),this.uvBuffer=new vt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let r=0,s=0;return this.uvs[0]=r,this.uvs[1]=s,this.uvs[2]=r+e.width/t.width,this.uvs[3]=s,this.uvs[4]=r+e.width/t.width,this.uvs[5]=s+e.height/t.height,this.uvs[6]=r,this.uvs[7]=s+e.height/t.height,r=e.x,s=e.y,this.vertices[0]=r,this.vertices[1]=s,this.vertices[2]=r+e.width,this.vertices[3]=s,this.vertices[4]=r+e.width,this.vertices[5]=s+e.height,this.vertices[6]=r,this.vertices[7]=s+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class iv{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=xt.NONE,this.sourceFrame=new K,this.destinationFrame=new K,this.bindingSourceFrame=new K,this.bindingDestinationFrame=new K,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Cs=[new ot,new ot,new ot,new ot],qo=new dt;class vf{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new gf,this.statePool=[],this.quad=new rv,this.quadUv=new yf,this.tempRect=new K,this.activeState={},this.globalUniforms=new ue({outputFrame:new K,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const r=this.renderer,s=this.defaultFilterStack,n=this.statePool.pop()||new iv,o=r.renderTexture;let a,l;if(o.current){const y=o.current;a=y.resolution,l=y.multisample}else a=r.resolution,l=r.multisample;let h=e[0].resolution||a,c=e[0].multisample??l,u=e[0].padding,d=e[0].autoFit,f=e[0].legacy??!0;for(let y=1;y<e.length;y++){const m=e[y];h=Math.min(h,m.resolution||a),c=Math.min(c,m.multisample??l),u=this.useMaxPadding?Math.max(u,m.padding):u+m.padding,d=d&&m.autoFit,f=f||(m.legacy??!0)}s.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),s.push(n),n.resolution=h,n.multisample=c,n.legacy=f,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(u);const p=this.tempRect.copyFrom(o.sourceFrame);r.projection.transform&&this.transformAABB(qo.copyFrom(r.projection.transform).invert(),p),d?(n.sourceFrame.fit(p),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(p)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,o.current?o.current.resolution:r.resolution,o.sourceFrame,o.destinationFrame,r.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,h,c),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const g=this.tempRect;g.x=0,g.y=0,g.width=n.sourceFrame.width,g.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(o.sourceFrame),n.bindingDestinationFrame.copyFrom(o.destinationFrame),n.transform=r.projection.transform,r.projection.transform=null,o.bind(n.renderTexture,n.sourceFrame,g),r.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),r=e.filters;this.activeState=e;const s=this.globalUniforms.uniforms;s.outputFrame=e.sourceFrame,s.resolution=e.resolution;const n=s.inputSize,o=s.inputPixel,a=s.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],o[0]=Math.round(n[0]*e.resolution),o[1]=Math.round(n[1]*e.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=e.sourceFrame.width*n[2]-.5*o[2],a[3]=e.sourceFrame.height*n[3]-.5*o[3],e.legacy){const h=s.filterArea;h[0]=e.destinationFrame.width,h[1]=e.destinationFrame.height,h[2]=e.sourceFrame.x,h[3]=e.sourceFrame.y,s.filterClamp=s.inputClamp}this.globalUniforms.update();const l=t[t.length-1];if(this.renderer.framebuffer.blit(),r.length===1)r[0].apply(this,e.renderTexture,l.renderTexture,be.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let h=e.renderTexture,c=this.getOptimalFilterTexture(h.width,h.height,e.resolution);c.filterFrame=h.filterFrame;let u=0;for(u=0;u<r.length-1;++u){u===1&&e.multisample>1&&(c=this.getOptimalFilterTexture(h.width,h.height,e.resolution),c.filterFrame=h.filterFrame),r[u].apply(this,h,c,be.CLEAR,e);const d=h;h=c,c=d}r[u].apply(this,h,l.renderTexture,be.BLEND,e),u>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(c)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=be.CLEAR){const{renderTexture:r,state:s}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t?.filterFrame){const o=this.tempRect;o.x=0,o.y=0,o.width=t.filterFrame.width,o.height=t.filterFrame.height,r.bind(t,t.filterFrame,o)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?r.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=s.stateId&1||this.forceClear;(e===be.CLEAR||e===be.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,r,s){const n=this.renderer;n.state.set(t.state),this.bindAndClear(r,s),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(we.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(we.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:r,destinationFrame:s}=this.activeState,{orig:n}=e._texture,o=t.set(s.width,0,0,s.height,r.x,r.y),a=e.worldTransform.copyTo(dt.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/n.width,1/n.height),o.translate(e.anchor.x,e.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,r=1,s=xt.NONE){return this.texturePool.getOptimalTexture(t,e,r,s)}getFilterTexture(t,e,r){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const s=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,r||xt.NONE);return s.filterFrame=t.filterFrame,s}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}
vendor: 5,275 bytes, line 378
378resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const r=Cs[0],s=Cs[1],n=Cs[2],o=Cs[3];r.set(e.left,e.top),s.set(e.left,e.bottom),n.set(e.right,e.top),o.set(e.right,e.bottom),t.apply(r,r),t.apply(s,s),t.apply(n,n),t.apply(o,o);const a=Math.min(r.x,s.x,n.x,o.x),l=Math.min(r.y,s.y,n.y,o.y),h=Math.max(r.x,s.x,n.x,o.x),c=Math.max(r.y,s.y,n.y,o.y);e.x=a,e.y=l,e.width=h-a,e.height=c-l}roundFrame(t,e,r,s,n){if(!(t.width<=0||t.height<=0||r.width<=0||r.height<=0)){if(n){const{a:o,b:a,c:l,d:h}=n;if((Math.abs(a)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(h)>1e-4))return}n=n?qo.copyFrom(n):qo.identity(),n.translate(-r.x,-r.y).scale(s.width/r.width,s.height/r.height).translate(s.x,s.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}vf.extension={type:U.RendererSystem,name:"filter"};$.add(vf);class sv{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=xt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const nv=new K;class bf{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Qa(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new K,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,r=this.renderer.context.extensions.depthTexture;H.PREFER_ENV===Vr.WEBGL_LEGACY&&(e=null,r=null),e?t.drawBuffers=s=>e.drawBuffersWEBGL(s):(this.hasMRT=!1,t.drawBuffers=()=>{}),r||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,r=0){const{gl:s}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==r&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=r),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,r)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let o=0;o<t.colorTextures.length;o++){const a=t.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const o=e.width>>r,a=e.height>>r,l=o/e.width;this.setViewport(e.x*l,e.y*l,o,a)}else{const o=t.width>>r,a=t.height>>r;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,s.bindFramebuffer(s.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,r,s){const n=this.viewport;t=Math.round(t),e=Math.round(e),r=Math.round(r),s=Math.round(s),(n.width!==r||n.height!==s||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=r,n.height=s,this.gl.viewport(t,e,r,s))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,e,r,s,n=Aa.COLOR|Aa.DEPTH){const{gl:o}=this;o.clearColor(t,e,r,s),o.clear(n)}initFramebuffer(t){const{gl:e}=this,r=new sv(e.createFramebuffer());return r.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=r,this.managedFramebuffers.push(t),t.disposeRunner.add(this),r}resizeFramebuffer(t){const{gl:e}=this,r=t.glFramebuffers[this.CONTEXT_UID];if(r.stencil){e.bindRenderbuffer(e.RENDERBUFFER,r.stencil);let o;this.renderer.context.webGLVersion===1?o=e.DEPTH_STENCIL:t.depth&&t.stencil?o=e.DEPTH24_STENCIL8:t.depth?o=e.DEPTH_COMPONENT24:o=e.STENCIL_INDEX8,r.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,r.multisample,o,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,o,t.width,t.height)}const s=t.colorTextures;let n=s.length;e.drawBuffers||(n=Math.min(n,1));for(let o=0;o<n;o++){const a=s[o],l=a.parentTextureArray||a;this.renderer.texture.bind(l,0),o===0&&r.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,r.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,r.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:r}=this,s=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let o=n.length;r.drawBuffers||(o=Math.min(o,1)),s.multisample>1&&this.canMultisampleFramebuffer(t)?s.msaaBuffer=s.msaaBuffer||r.createRenderbuffer():s.msaaBuffer&&(r.deleteRenderbuffer(s.msaaBuffer),s.msaaBuffer=null,s.blitFramebuffer&&(s.blitFramebuffer.dispose(),s.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=n[l],c=h.parentTextureArray||h;this.renderer.texture.bind(c,0),l===0&&s.msaaBuffer?(r.bindRenderbuffer(r.RENDERBUFFER,s.msaaBuffer),r.renderbufferStorageMultisample(r.RENDERBUFFER,s.multisample,c._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,s.msaaBuffer)):(r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+l,h.target,c._glTextures[this.CONTEXT_UID].texture,e),a.push(r.COLOR_ATTACHMENT0+l))}
vendor: 2,294 bytes, line 378
378if(a.length>1&&r.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const l=t.depthTexture;this.renderer.texture.bind(l,0),r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||r.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=r.DEPTH_STENCIL_ATTACHMENT,h=r.DEPTH_STENCIL):t.depth&&t.stencil?(l=r.DEPTH_STENCIL_ATTACHMENT,h=r.DEPTH24_STENCIL8):t.depth?(l=r.DEPTH_ATTACHMENT,h=r.DEPTH_COMPONENT24):(l=r.STENCIL_ATTACHMENT,h=r.STENCIL_INDEX8),r.bindRenderbuffer(r.RENDERBUFFER,s.stencil),s.msaaBuffer?r.renderbufferStorageMultisample(r.RENDERBUFFER,s.multisample,h,t.width,t.height):r.renderbufferStorage(r.RENDERBUFFER,h,t.width,t.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,l,r.RENDERBUFFER,s.stencil)}else s.stencil&&(r.deleteRenderbuffer(s.stencil),s.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let r=xt.NONE;if(t<=1||e===null)return r;for(let s=0;s<e.length;s++)if(e[s]<=t){r=e[s];break}return r===1&&(r=xt.NONE),r}blit(t,e,r){const{current:s,renderer:n,gl:o,CONTEXT_UID:a}=this;if(n.context.webGLVersion!==2||!s)return;const l=s.glFramebuffers[a];if(!l)return;if(!t){if(!l.msaaBuffer)return;const c=s.colorTextures[0];if(!c)return;l.blitFramebuffer||(l.blitFramebuffer=new Qa(s.width,s.height),l.blitFramebuffer.addColorTexture(0,c)),t=l.blitFramebuffer,t.colorTextures[0]!==c&&(t.colorTextures[0]=c,t.dirtyId++,t.dirtyFormat++),(t.width!==s.width||t.height!==s.height)&&(t.width=s.width,t.height=s.height,t.dirtyId++,t.dirtySize++)}e||(e=nv,e.width=s.width,e.height=s.height),r||(r=e);const h=e.width===r.width&&e.height===r.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,r.left,r.top,r.right,r.bottom,o.COLOR_BUFFER_BIT,h?o.NEAREST:o.LINEAR),o.bindFramebuffer(o.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const r=t.glFramebuffers[this.CONTEXT_UID],s=this.gl;if(!r)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>
vendor: 7,861 bytes, lines 378-395
378=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(s.deleteFramebuffer(r.framebuffer),r.msaaBuffer&&s.deleteRenderbuffer(r.msaaBuffer),r.stencil&&s.deleteRenderbuffer(r.stencil)),r.blitFramebuffer&&this.disposeFramebuffer(r.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let r=0;r<e.length;r++)this.disposeFramebuffer(e[r],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const r=t.width,s=t.height,n=this.gl,o=e.stencil=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,o);let a,l;this.renderer.context.webGLVersion===1?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH_STENCIL):t.depth?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH24_STENCIL8):(a=n.STENCIL_ATTACHMENT,l=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,l,r,s):n.renderbufferStorage(n.RENDERBUFFER,l,r,s),n.framebufferRenderbuffer(n.FRAMEBUFFER,a,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new K}destroy(){this.renderer=null}}bf.extension={type:U.RendererSystem,name:"framebuffer"};$.add(bf);const Zo={5126:4,5123:2,5121:1};class xf{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){let r=this.renderer.context.extensions.vertexArrayObject;H.PREFER_ENV===Vr.WEBGL_LEGACY&&(r=null),r?(t.createVertexArray=()=>r.createVertexArrayOES(),t.bindVertexArray=s=>r.bindVertexArrayOES(s),t.deleteVertexArray=s=>r.deleteVertexArrayOES(s)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const r=t.getExtension("ANGLE_instanced_arrays");r?(t.vertexAttribDivisor=(s,n)=>r.vertexAttribDivisorANGLE(s,n),t.drawElementsInstanced=(s,n,o,a,l)=>r.drawElementsInstancedANGLE(s,n,o,a,l),t.drawArraysInstanced=(s,n,o,a)=>r.drawArraysInstancedANGLE(s,n,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:r}=this;let s=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;s||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=s={},n=!0);const o=s[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==o&&(this._activeVao=o,this.hasVao?r.bindVertexArray(o):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let r=0;r<t.buffers.length;r++){const s=t.buffers[r];e.update(s)}}checkCompatibility(t,e){const r=t.attributes,s=e.attributeData;for(const n in s)if(!r[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const r=t.attributes,s=e.attributeData,n=["g",t.id];for(const o in r)s[o]&&n.push(o,s[o].location);return n.join("-")}initGeometryVao(t,e,r=!0){const s=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,a=e.program;a.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const l=this.getSignature(t,a),h=t.glVertexArrayObjects[this.CONTEXT_UID];let c=h[l];if(c)return h[a.id]=c,c;const u=t.buffers,d=t.attributes,f={},p={};for(const g in u)f[g]=0,p[g]=0;for(const g in d)!d[g].size&&a.attributeData[g]?d[g].size=a.attributeData[g].size:d[g].size||console.warn(`PIXI Geometry attribute '${g}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[g].buffer]+=d[g].size*Zo[d[g].type];for(const g in d){const y=d[g],m=y.size;y.stride===void 0&&(f[y.buffer]===m*Zo[y.type]?y.stride=0:y.stride=f[y.buffer]),y.start===void 0&&(y.start=p[y.buffer],p[y.buffer]+=m*Zo[y.type])}c=s.createVertexArray(),s.bindVertexArray(c);for(let g=0;g<u.length;g++){const y=u[g];o.bind(y),r&&y._glBuffers[n].refCount++}return this.activateVao(t,a),h[a.id]=c,h[l]=c,s.bindVertexArray(null),o.unbind(Se.ARRAY_BUFFER),c}disposeGeometry(t,e){if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const r=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,n=t.buffers,o=this.renderer?.buffer;if(t.disposeRunner.remove(this),!!r){if(o)for(let a=0;a<n.length;a++){const l=n[a]._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&o.dispose(n[a],e))}if(!e){for(const a in r)if(a[0]==="g"){const l=r[a];this._activeVao===l&&this.unbind(),s.deleteVertexArray(l)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let r=0;r<e.length;r++)this.disposeGeometry(this.managedGeometries[e[r]],t)}activateVao(t,e){const r=this.gl,s=this.CONTEXT_UID,n=this.renderer.buffer,o=t.buffers,a=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let l=null;for(const h in a){const c=a[h],u=o[c.buffer],d=u._glBuffers[s];if(e.attributeData[h]){l!==d&&(n.bind(u),l=d);const f=e.attributeData[h].location;if(r.enableVertexAttribArray(f),r.vertexAttribPointer(f,c.size,c.type||r.FLOAT,c.normalized,c.stride,c.start),c.instance)if(this.hasInstance)r.vertexAttribDivisor(f,c.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,r,s){const{gl:n}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,l=a===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,l,(r||0)*a,s||1):n.drawElements(t,e||o.indexBuffer.data.length,l,(r||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?n.drawArraysInstanced(t,r,e||o.getSize(),s||1):n.drawArrays(t,r,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}xf.extension={type:U.RendererSystem,name:"geometry"};$.add(xf);const Hc=new dt;class wf{constructor(t,e){this._texture=t,this.mapCoord=new dt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){e===void 0&&(e=t);const r=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],o=t[s+1];e[s]=n*r.a+o*r.c+r.tx,e[s+1]=n*r.b+o*r.d+r.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const r=e._uvs;this.mapCoord.set(r.x1-r.x0,r.y1-r.y0,r.x3-r.x0,r.y3-r.y0,r.x0,r.y0);const s=e.orig,n=e.trim;n&&(Hc.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Hc));const o=e.baseTexture,a=this.uClampFrame,l=this.clampMargin/o.resolution,h=this.clampOffset;return a[0]=(e._frame.x+l+h)/o.width,a[1]=(e._frame.y+l+h)/o.height,a[2]=(e._frame.x+e._frame.width-l+h)/o.width,a[3]=(e._frame.y+e._frame.height-l+h)/o.height,this.uClampOffset[0]=h/o.realWidth,this.uClampOffset[1]=h/o.realHeight,this.isSimple=e._frame.width===o.width&&e._frame.height===o.height&&e.rotate===0,!0}}var ov=`varying vec2 vMaskCoord; 379varying vec2 vTextureCoord; 380 381uniform sampler2D uSampler; 382uniform sampler2D mask; 383uniform float alpha; 384uniform float npmAlpha; 385uniform vec4 maskClamp; 386 387void main(void) 388{ 389 float clip = step(3.5, 390 step(maskClamp.x, vMaskCoord.x) + 391 step(maskClamp.y, vMaskCoord.y) + 392 step(vMaskCoord.x, maskClamp.z) + 393 step(vMaskCoord.y, maskClamp.w)); 394 395 vec4 original = texture2D(uSampler, vTextureCoord);
396 vec4 masky = texture2D(mask, vMaskCoord); 397 float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a); 398 399 original *= (alphaMul * masky.r * alpha * clip); 400 401 gl_FragColor = original; 402} 403`,av=`attribute vec2 aVertexPosition; 404attribute vec2 aTextureCoord; 405 406uniform mat3 projectionMatrix; 407uniform mat3 otherMatrix; 408 409varying vec2 vMaskCoord; 410varying vec2 vTextureCoord; 411 412void main(void) 413{ 414 gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); 415 416 vTextureCoord = aTextureCoord; 417 vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy; 418} 419`;class lv extends kt{constructor(t,e,r){let s=null;typeof t!="string"&&e===void 0&&r===void 0&&(s=t,t=void 0,e=void 0,r=void 0),super(t||av,e||ov,r),this.maskSprite=s,this.maskMatrix=new dt}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,r,s){const n=this._maskSprite,o=n._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new wf(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,t.applyFilter(this,e,r,s))}}class hv{constructor(t=null){this.type=Et.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=kt.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=Et.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class Tf{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let r=e;if(!r.isMaskData){const n=this.maskDataPool.pop()||new hv;n.pooled=!0,n.maskObject=e,r=n}const s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(r.copyCountersOrReset(s),r._colorMask=s?s._colorMask:15,r.autoDetect&&this.detect(r),r._target=t,r.type!==Et.SPRITE&&this.maskStack.push(r),r.enabled)switch(r.type){case Et.SCISSOR:this.renderer.scissor.push(r);break;case Et.STENCIL:this.renderer.stencil.push(r);break;case Et.SPRITE:r.copyCountersOrReset(null),this.pushSpriteMask(r);break;case Et.COLOR:this.pushColorMask(r);break}r.type===Et.SPRITE&&this.maskStack.push(r)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case Et.SCISSOR:this.renderer.scissor.pop(e);break;case Et.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case Et.SPRITE:this.popSpriteMask(e);break;case Et.COLOR:this.popColorMask(e);break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){const r=this.maskStack[this.maskStack.length-1];r.type===Et.SPRITE&&r._filters&&(r._filters[0].maskSprite=r.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=Et.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=Et.SCISSOR:t.type=Et.STENCIL:t.type=Et.COLOR}pushSpriteMask(t){const{maskObject:e}=t,r=t._target;let s=t._filters;s||(s=this.alphaMaskPool[this.alphaMaskIndex],s||(s=this.alphaMaskPool[this.alphaMaskIndex]=[new lv])),s[0].resolution=t.resolution,s[0].multisample=t.multisample,s[0].maskSprite=e;const n=r.filterArea;r.filterArea=e.getBounds(!0),this.renderer.filter.push(r,s),r.filterArea=n,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,r=t._colorMask=e&t.colorMask;r!==e&&this.renderer.gl.colorMask((r&1)!==0,(r&2)!==0,(r&4)!==0,(r&8)!==0)}popColorMask(t){const e=t._colorMask,r=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;r!==e&&this.renderer.gl.colorMask((r&1)!==0,(r&2)!==0,(r&4)!==0,(r&8)!==0)}destroy(){this.renderer=null}}Tf.extension={type:U.RendererSystem,name:"mask"};$.add(Tf);class Ef{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,r=this.getStackLength();this.maskStack=t;const s=this.getStackLength();s!==r&&(s===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}
vendor: 30,751 bytes, lines 419-489
419const zc=new dt,Xc=[],Af=class Qs extends Ef{constructor(t){super(t),this.glConst=H.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:r}=t,{renderer:s}=this,n=s.renderTexture,o=r.getBounds(!0,Xc.pop()??new K);this.roundFrameToPixels(o,n.current?n.current.resolution:s.resolution,n.sourceFrame,n.destinationFrame,s.projection.transform),e&&o.fit(e),t._scissorRectLocal=o}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:r,c:s,d:n}=t;return(Math.abs(r)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(n)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||Qs.isMatrixRotated(e.worldTransform)||Qs.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const r=t._scissorRectLocal;return r.width>0&&r.height>0}roundFrameToPixels(t,e,r,s,n){Qs.isMatrixRotated(n)||(n=n?zc.copyFrom(n):zc.identity(),n.translate(-r.x,-r.y).scale(s.width/r.width,s.height/r.height).translate(s.x,s.y),this.renderer.filter.transformAABB(n,t),t.fit(s),t.x=Math.round(t.x*e),t.y=Math.round(t.y*e),t.width=Math.round(t.width*e),t.height=Math.round(t.height*e))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&Xc.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;this.renderer.renderTexture.current?e=t.y:e=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};Af.extension={type:U.RendererSystem,name:"scissor"};let cv=Af;$.add(cv);class Sf extends Ef{constructor(t){super(t),this.glConst=H.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const e=t.maskObject,{gl:r}=this.renderer,s=t._stencilCounter;s===0&&(this.renderer.framebuffer.forceStencil(),r.clearStencil(0),r.clear(r.STENCIL_BUFFER_BIT),r.enable(r.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,r.colorMask(!1,!1,!1,!1)),r.stencilFunc(r.EQUAL,s,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,r.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}pop(t){const e=this.renderer.gl;if(this.getStackLength()===0)e.disable(e.STENCIL_TEST);else{const r=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,s=r?r._colorMask:15;s!==0&&(r._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,s!==0&&(r._colorMask=s,e.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}Sf.extension={type:U.RendererSystem,name:"stencil"};$.add(Sf);class Cf{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return rt("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return rt("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return rt("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events}}})}init(){const t=this.rendererPlugins;for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}Cf.extension={type:[U.RendererSystem,U.CanvasRendererSystem],name:"_plugin"};$.add(Cf);class If{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new dt,this.transform=null}update(t,e,r,s){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,r,s),this.transform&&this.projectionMatrix.append(this.transform);const n=this.renderer;n.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,n.globalUniforms.update(),n.shader.shader&&n.shader.syncUniformGroup(n.shader.shader.uniforms.globals)}calculateProjection(t,e,r,s){const n=this.projectionMatrix,o=s?-1:1;n.identity(),n.a=1/e.width*2,n.d=o*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-o-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}If.extension={type:U.RendererSystem,name:"projection"};$.add(If);const uv=new Kl,Vc=new K;class Rf{constructor(t){this.renderer=t,this._tempMatrix=new dt}generateTexture(t,e){const{region:r,...s}=e||{},n=r?.copyTo(Vc)||t.getLocalBounds(Vc,!0),o=s.resolution||this.renderer.resolution;n.width=Math.max(n.width,1/o),n.height=Math.max(n.height,1/o),s.width=n.width,s.height=n.height,s.resolution=o,s.multisample??(s.multisample=this.renderer.multisample);const a=Ft.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=uv,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}Rf.extension={type:[U.RendererSystem,U.CanvasRendererSystem],name:"textureGenerator"};$.add(Rf);const br=new K,Ni=new K;class Pf{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new K,this.destinationFrame=new K,this.viewportFrame=new K}contextChange(){const t=this.renderer?.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,r){const s=this.renderer;this.current=t;let n,o,a;t?(n=t.baseTexture,a=n.resolution,e||(br.width=t.frame.width,br.height=t.frame.height,e=br),r||(Ni.x=t.frame.x,Ni.y=t.frame.y,Ni.width=e.width,Ni.height=e.height,r=Ni),o=n.framebuffer):(a=s.resolution,e||(br.width=s._view.screen.width,br.height=s._view.screen.height,e=br),r||(r=br,r.width=e.width,r.height=e.height));const l=this.viewportFrame;l.x=r.x*a,l.y=r.y*a,l.width=r.width*a,l.height=r.height*a,t||(l.y=s.view.height-(l.y+l.height)),l.ceil(),this.renderer.framebuffer.bind(o,l),this.renderer.projection.update(r,e,a,!o),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(r)}clear(t,e){const r=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,s=ut.shared.setValue(t||r);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&s.premultiply(s.alpha);const n=this.destinationFrame,o=this.current?this.current.baseTexture:this.renderer._view.screen,a=n.width!==o.width||n.height!==o.height;if(a){let{x:l,y:h,width:c,height:u}=this.viewportFrame;l=Math.round(l),h=Math.round(h),c=Math.round(c),u=Math.round(u),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,c,u)}this.renderer.framebuffer.clear(s.red,s.green,s.blue,s.alpha,e),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}Pf.extension={type:U.RendererSystem,name:"renderTexture"};$.add(Pf);class dv{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function fv(i,t){const e={},r=t.getProgramParameter(i,t.ACTIVE_ATTRIBUTES);for(let s=0;s<r;s++){const n=t.getActiveAttrib(i,s);if(n.name.startsWith("gl_"))continue;const o=ff(t,n.type),a={type:o,name:n.name,size:df(o),location:t.getAttribLocation(i,n.name)};e[n.name]=a}return e}function pv(i,t){const e={},r=t.getProgramParameter(i,t.ACTIVE_UNIFORMS);for(let s=0;s<r;s++){const n=t.getActiveUniform(i,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=ff(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:cf(l,n.size)}}return e}function mv(i,t){const e=Fc(i,i.VERTEX_SHADER,t.vertexSrc),r=Fc(i,i.FRAGMENT_SHADER,t.fragmentSrc),s=i.createProgram();i.attachShader(s,e),i.attachShader(s,r);const n=t.extra?.transformFeedbackVaryings;if(n&&(typeof i.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):i.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?i.SEPARATE_ATTRIBS:i.INTERLEAVED_ATTRIBS)),i.linkProgram(s),i.getProgramParameter(s,i.LINK_STATUS)||V1(i,s,e,r),t.attributeData=fv(s,i),t.uniformData=pv(s,i),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const a=Object.keys(t.attributeData);a.sort((l,h)=>l>h?1:-1);for(let l=0;l<a.length;l++)t.attributeData[a[l]].location=l,i.bindAttribLocation(s,l,a[l]);i.linkProgram(s)}i.deleteShader(e),i.deleteShader(r);const o={};for(const a in t.uniformData){const l=t.uniformData[a];o[a]={location:i.getUniformLocation(s,a),value:cf(l.type,l.size)}}return new dv(s,o)}function _v(i,t,e,r,s){e.buffer.update(s)}const gv={float:` 420 data[offset] = v; 421 `,vec2:` 422 data[offset] = v[0]; 423 data[offset+1] = v[1]; 424 `,vec3:` 425 data[offset] = v[0]; 426 data[offset+1] = v[1]; 427 data[offset+2] = v[2]; 428 429 `,vec4:` 430 data[offset] = v[0]; 431 data[offset+1] = v[1]; 432 data[offset+2] = v[2]; 433 data[offset+3] = v[3]; 434 `,mat2:` 435 data[offset] = v[0]; 436 data[offset+1] = v[1]; 437 438 data[offset+4] = v[2]; 439 data[offset+5] = v[3]; 440 `,mat3:` 441 data[offset] = v[0]; 442 data[offset+1] = v[1]; 443 data[offset+2] = v[2]; 444 445 data[offset + 4] = v[3]; 446 data[offset + 5] = v[4]; 447 data[offset + 6] = v[5]; 448 449 data[offset + 8] = v[6]; 450 data[offset + 9] = v[7]; 451 data[offset + 10] = v[8]; 452 `,mat4:` 453 for(var i = 0; i < 16; i++) 454 { 455 data[offset + i] = v[i]; 456 } 457 `},Mf={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:16*2,mat3:16*3,mat4:16*4};function yv(i){const t=i.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,r=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(e=Mf[o.data.type],o.data.size>1&&(e=Math.max(e,16)*o.data.size),o.dataLen=e,r%e!==0&&r<16){const a=r%e%16;r+=a,s+=a}r+e>16?(s=Math.ceil(s/16)*16,o.offset=s,s+=e,r=e):(o.offset=s,r+=e,s+=e)}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}function vv(i,t){const e=[];for(const r in i)t[r]&&e.push(t[r]);return e.sort((r,s)=>r.index-s.index),e}function bv(i,t){if(!i.autoManage)return{size:0,syncFunc:_v};const e=vv(i.uniforms,t),{uboElements:r,size:s}=yv(e),n=[` 458 var v = null; 459 var v2 = null; 460 var cv = null; 461 var t = 0; 462 var gl = renderer.gl 463 var index = 0; 464 var data = buffer.data; 465 `];for(let o=0;o<r.length;o++){const a=r[o],l=i.uniforms[a.data.name],h=a.data.name;let c=!1;for(let u=0;u<bi.length;u++){const d=bi[u];if(d.codeUbo&&d.test(a.data,l)){n.push(`offset = ${a.offset/4};`,bi[u].codeUbo(a.data.name,l)),c=!0;break}}if(!c)if(a.data.size>1){const u=df(a.data.type),d=Math.max(Mf[a.data.type]/16,1),f=u/d,p=(4-f%4)%4;n.push(` 466 cv = ud.${h}.value; 467 v = uv.${h}; 468 offset = ${a.offset/4}; 469 470 t = 0; 471 472 for(var i=0; i < ${a.data.size*d}; i++) 473 { 474 for(var j = 0; j < ${f}; j++) 475 { 476 data[offset++] = v[t++]; 477 } 478 offset += ${p}; 479 } 480 481 `)}else{const u=gv[a.data.type];n.push(` 482 cv = ud.${h}.value; 483 v = uv.${h}; 484 offset = ${a.offset/4}; 485 ${u}; 486 `)}}return n.push(` 487 renderer.buffer.update(buffer); 488 `),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(` 489`))}}let xv=0;const Is={textureCount:0,uboCount:0};class Bf{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=xv++}systemCheck(){if(!$1())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const r=t.program,s=r.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==r&&(this.program=r,this.gl.useProgram(s.program)),e||(Is.textureCount=0,Is.uboCount=0,this.syncUniformGroup(t.uniformGroup,Is)),s}setUniforms(t){const e=this.shader.program,r=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(r.uniformData,t,this.renderer)}syncUniformGroup(t,e){const r=this.getGlProgram();(!t.static||t.dirtyId!==r.uniformDirtyGroups[t.id])&&(r.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,r,e))}syncUniforms(t,e,r){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,r)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=H1(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const r=this.getGlProgram();if(!t.static||t.dirtyId!==0||!r.uniformGroups[t.id]){t.dirtyId=0;const s=r.uniformGroups[t.id]||this.createSyncBufferGroup(t,r,e);t.buffer.update(),s(r.uniformData,t.uniforms,this.renderer,Is,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,r.uniformBufferBindings[e])}createSyncBufferGroup(t,e,r){const{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,r);e.uniformBufferBindings[r]=this.shader.uniformBindCount,s.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(t,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=bv(t,this.shader.program.uniformData)),t.autoManage){const l=new Float32Array(a.size/4);t.buffer.update(l)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,r){const s=t.uniforms,n=[`${r}-`];for(const o in s)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,r=t.program,s=mv(e,r);return r.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}Bf.extension={type:U.RendererSystem,name:"shader"};$.add(Bf);class Bn{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.3.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}Bn.defaultOptions={hello:!1},Bn.extension={type:[U.RendererSystem,U.CanvasRendererSystem],name:"startup"};$.add(Bn);function wv(i,t=[]){return t[Z.NORMAL]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.ADD]=[i.ONE,i.ONE],t[Z.MULTIPLY]=[i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.SCREEN]=[i.ONE,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.OVERLAY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.DARKEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.LIGHTEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.COLOR_DODGE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.COLOR_BURN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.HARD_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.SOFT_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.DIFFERENCE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.EXCLUSION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.HUE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.SATURATION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.COLOR]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.LUMINOSITY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.NONE]=[0,0],t[Z.NORMAL_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.ADD_NPM]=[i.SRC_ALPHA,i.ONE,i.ONE,i.ONE],t[Z.SCREEN_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[Z.SRC_IN]=[i.DST_ALPHA,i.ZERO],t[Z.SRC_OUT]=[i.ONE_MINUS_DST_ALPHA,i.ZERO],t[Z.SRC_ATOP]=[i.DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[Z.DST_OVER]=[i.ONE_MINUS_DST_ALPHA,i.ONE],t[Z.DST_IN]=[i.ZERO,i.SRC_ALPHA],t[Z.DST_OUT]=[i.ZERO,i.ONE_MINUS_SRC_ALPHA],t[Z.DST_ATOP]=[i.ONE_MINUS_DST_ALPHA,i.SRC_ALPHA],t[Z.XOR]=[i.ONE_MINUS_DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[Z.SUBTRACT]=[i.ONE,i.ONE,i.ONE,i.ONE,i.FUNC_REVERSE_SUBTRACT,i.FUNC_ADD],t}const Tv=0,Ev=1,Av=2,Sv=3,Cv=4,Iv=5,kf=class tl{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=Z.NONE,this._blendEq=!1,this.map=[],this.map[Tv]=this.setBlend,this.map[Ev]=this.setOffset,this.map[Av]=this.setCullFace,this.map[Sv]=this.setDepthTest,this.map[Cv]=this.setFrontFace,this.map[Iv]=this.setDepthMask,this.checks=[],this.defaultState=new Re,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=wv(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,r=0;for(;e;)e&1&&this.map[r].call(this,!!(t.data&1<<r)),e=e>>1,r++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(tl.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(tl.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const e=this.blendModes[t],r=this.gl;e.length===2?r.blendFunc(e[0],e[1]):r.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,r.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,r.blendEquationSeparate(r.FUNC_ADD,r.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){const r=this.checks.indexOf(t);e&&r===-1?this.checks.push(t):!e&&r!==-1&&this.checks.splice(r,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};kf.extension={type:U.RendererSystem,name:"state"};let Rv=kf;$.add(Rv);class Pv extends ls{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(s=>t.systems[s]),r=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(const s of r)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new ce(e)})}addSystem(t,e){const r=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=r,this._systemsHash[e]=r;for(const s in this.runners)this.runners[s].add(r);return this}emitWithCustomOptions(t,e){const r=Object.keys(this._systemsHash);t.items.forEach(s=>{const n=r.find(o=>this._systemsHash[o]===s);s[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const Xi=class tn{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=tn.defaultMaxIdle,this.checkCountMax=tn.defaultCheckCountMax,this.mode=tn.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Hl.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let r=!1;for(let s=0;s<e.length;s++){const n=e[s];n.resource&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[s]=null,r=!0)}if(r){let s=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[s++]=e[n]);e.length=s}}unload(t){const e=this.renderer.texture,r=t._texture;r&&!r.framebuffer&&e.destroyTexture(r);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};Xi.defaultMode=Hl.AUTO,Xi.defaultMaxIdle=60*60,Xi.defaultCheckCountMax=60*10,Xi.extension={type:U.RendererSystem,name:"textureGC"};let Ir=Xi;$.add(Ir);class Ko{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=q.UNSIGNED_BYTE,this.internalFormat=F.RGBA,this.samplerType=0}}function Mv(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[i.RGB]:G.FLOAT,[i.RGBA]:G.FLOAT,[i.ALPHA]:G.FLOAT,[i.LUMINANCE]:G.FLOAT,[i.LUMINANCE_ALPHA]:G.FLOAT,[i.R8]:G.FLOAT,[i.R8_SNORM]:G.FLOAT,[i.RG8]:G.FLOAT,[i.RG8_SNORM]:G.FLOAT,[i.RGB8]:G.FLOAT,[i.RGB8_SNORM]:G.FLOAT,[i.RGB565]:G.FLOAT,[i.RGBA4]:G.FLOAT,[i.RGB5_A1]:G.FLOAT,[i.RGBA8]:G.FLOAT,[i.RGBA8_SNORM]:G.FLOAT,[i.RGB10_A2]:G.FLOAT,[i.RGB10_A2UI]:G.FLOAT,[i.SRGB8]:G.FLOAT,[i.SRGB8_ALPHA8]:G.FLOAT,[i.R16F]:G.FLOAT,[i.RG16F]:G.FLOAT,[i.RGB16F]:G.FLOAT,[i.RGBA16F]:G.FLOAT,[i.R32F]:G.FLOAT,[i.RG32F]:G.FLOAT,[i.RGB32F]:G.FLOAT,[i.RGBA32F]:G.FLOAT,[i.R11F_G11F_B10F]:G.FLOAT,[i.RGB9_E5]:G.FLOAT,[i.R8I]:G.INT,[i.R8UI]:G.UINT,[i.R16I]:G.INT,[i.R16UI]:G.UINT,[i.R32I]:G.INT,[i.R32UI]:G.UINT,[i.RG8I]:G.INT,[i.RG8UI]:G.UINT,[i.RG16I]:G.INT,[i.RG16UI]:G.UINT,[i.RG32I]:G.INT,[i.RG32UI]:G.UINT,[i.RGB8I]:G.INT,[i.RGB8UI]:G.UINT,[i.RGB16I]:G.INT,[i.RGB16UI]:G.UINT,[i.RGB32I]:G.INT,[i.RGB32UI]:G.UINT,[i.RGBA8I]:G.INT,[i.RGBA8UI]:G.UINT,[i.RGBA16I]:G.INT,[i.RGBA16UI]:G.UINT,[i.RGBA32I]:G.INT,[i.RGBA32UI]:G.UINT,[i.DEPTH_COMPONENT16]:G.FLOAT,[i.DEPTH_COMPONENT24]:G.FLOAT,[i.DEPTH_COMPONENT32F]:G.FLOAT,[i.DEPTH_STENCIL]:G.FLOAT,[i.DEPTH24_STENCIL8]:G.FLOAT,[i.DEPTH32F_STENCIL8]:G.FLOAT}:t={[i.RGB]:G.FLOAT,[i.RGBA]:G.FLOAT,[i.ALPHA]:G.FLOAT,[i.LUMINANCE]:G.FLOAT,[i.LUMINANCE_ALPHA]:G.FLOAT,[i.DEPTH_STENCIL]:G.FLOAT},t}function Bv(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[q.UNSIGNED_BYTE]:{[F.RGBA]:i.RGBA8,[F.RGB]:i.RGB8,[F.RG]:i.RG8,[F.RED]:i.R8,[F.RGBA_INTEGER]:i.RGBA8UI,[F.RGB_INTEGER]:i.RGB8UI,[F.RG_INTEGER]:i.RG8UI,[F.RED_INTEGER]:i.R8UI,[F.ALPHA]:i.ALPHA,[F.LUMINANCE]:i.LUMINANCE,[F.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[q.BYTE]:{[F.RGBA]:i.RGBA8_SNORM,[F.RGB]:i.RGB8_SNORM,[F.RG]:i.RG8_SNORM,[F.RED]:i.R8_SNORM,[F.RGBA_INTEGER]:i.RGBA8I,[F.RGB_INTEGER]:i.RGB8I,[F.RG_INTEGER]:i.RG8I,[F.RED_INTEGER]:i.R8I},[q.UNSIGNED_SHORT]:{[F.RGBA_INTEGER]:i.RGBA16UI,[F.RGB_INTEGER]:i.RGB16UI,[F.RG_INTEGER]:i.RG16UI,[F.RED_INTEGER]:i.R16UI,[F.DEPTH_COMPONENT]:i.DEPTH_COMPONENT16},[q.SHORT]:{[F.RGBA_INTEGER]:i.RGBA16I,[F.RGB_INTEGER]:i.RGB16I,[F.RG_INTEGER]:i.RG16I,[F.RED_INTEGER]:i.R16I},[q.UNSIGNED_INT]:{[F.RGBA_INTEGER]:i.RGBA32UI,[F.RGB_INTEGER]:i.RGB32UI,[F.RG_INTEGER]:i.RG32UI,[F.RED_INTEGER]:i.R32UI,[F.DEPTH_COMPONENT]:i.DEPTH_COMPONENT24},[q.INT]:{[F.RGBA_INTEGER]:i.RGBA32I,[F.RGB_INTEGER]:i.RGB32I,[F.RG_INTEGER]:i.RG32I,[F.RED_INTEGER]:i.R32I},[q.FLOAT]:{[F.RGBA]:i.RGBA32F,[F.RGB]:i.RGB32F,[F.RG]:i.RG32F,[F.RED]:i.R32F,[F.DEPTH_COMPONENT]:i.DEPTH_COMPONENT32F},[q.HALF_FLOAT]:{[F.RGBA]:i.RGBA16F,[F.RGB]:i.RGB16F,[F.RG]:i.RG16F,[F.RED]:i.R16F},[q.UNSIGNED_SHORT_5_6_5]:{[F.RGB]:i.RGB565},[q.UNSIGNED_SHORT_4_4_4_4]:{[F.RGBA]:i.RGBA4},[q.UNSIGNED_SHORT_5_5_5_1]:{[F.RGBA]:i.RGB5_A1},[q.UNSIGNED_INT_2_10_10_10_REV]:{[F.RGBA]:i.RGB10_A2,[F.RGBA_INTEGER]:i.RGB10_A2UI},[q.UNSIGNED_INT_10F_11F_11F_REV]:{[F.RGB]:i.R11F_G11F_B10F},[q.UNSIGNED_INT_5_9_9_9_REV]:{[F.RGB]:i.RGB9_E5},[q.UNSIGNED_INT_24_8]:{[F.DEPTH_STENCIL]:i.DEPTH24_STENCIL8},[q.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[F.DEPTH_STENCIL]:i.DEPTH32F_STENCIL8}}:t={[q.UNSIGNED_BYTE]:{[F.RGBA]:i.RGBA,[F.RGB]:i.RGB,[F.ALPHA]:i.ALPHA,[F.LUMINANCE]:i.LUMINANCE,[F.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[q.UNSIGNED_SHORT_5_6_5]:{[F.RGB]:i.RGB},[q.UNSIGNED_SHORT_4_4_4_4]:{[F.RGBA]:i.RGBA},[q.UNSIGNED_SHORT_5_5_5_1]:{[F.RGBA]:i.RGBA}},t}class Df{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new Q,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=Bv(t),this.samplerTypes=Mv(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};const r=new Ko(t.createTexture());t.bindTexture(t.TEXTURE_2D,r.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=r,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Ko(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){const{gl:r}=this;if(t=t?.castToBaseTexture(),t?.valid&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,r.activeTexture(r.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(r.TEXTURE_2D,this.emptyTextures[r.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:r}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<r.length;s++)r[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<r.length;s++)r[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),r[s]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:r,CONTEXT_UID:s}=this;if(r)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[s].samplerType!==G.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new Ko(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){e.internalFormat=this.internalFormats[t.type]?.[t.format]??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??G.FLOAT,this.webGLVersion===2&&t.type===q.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const r=this.renderer;if(this.initTextureType(t,e),t.resource?.upload(r,t,e))e.samplerType!==G.FLOAT&&(this.hasIntegerTextures=!0);else{const s=t.realWidth,n=t.realHeight,o=r.gl;(e.width!==s||e.height!==n||e.dirtyId<0)&&(e.width=s,e.height=n,o.texImage2D(t.target,0,e.internalFormat,s,n,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:r}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),r.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const s=this.managedTextures.indexOf(t);s!==-1&&vi(this.managedTextures,s,1)}}updateTextureStyle(t){const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===Ie.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=nr.CLAMP:e.wrapMode=t.wrapMode,t.resource?.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const r=this.gl;if(e.mipmap&&t.mipmap!==Ie.ON_MANUAL&&r.generateMipmap(t.target),r.texParameteri(t.target,r.TEXTURE_WRAP_S,e.wrapMode),r.texParameteri(t.target,r.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){r.texParameteri(t.target,r.TEXTURE_MIN_FILTER,t.scaleMode===Ne.LINEAR?r.LINEAR_MIPMAP_LINEAR:r.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===Ne.LINEAR){const n=Math.min(t.anisotropicLevel,r.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));r.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else r.texParameteri(t.target,r.TEXTURE_MIN_FILTER,t.scaleMode===Ne.LINEAR?r.LINEAR:r.NEAREST);r.texParameteri(t.target,r.TEXTURE_MAG_FILTER,t.scaleMode===Ne.LINEAR?r.LINEAR:r.NEAREST)}destroy(){this.renderer=null}}Df.extension={type:U.RendererSystem,name:"texture"};$.add(Df);class Ff{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:r}=this,s=t._glTransformFeedbacks[r]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:r,renderer:s}=this;e&&s.shader.bind(e),r.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:r,CONTEXT_UID:s}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[s]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];a&&(r.buffer.update(a),a._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const r=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;
489t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&n.dispose(a,e))}r&&(e||s.deleteTransformFeedback(r),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Ff.extension={type:U.RendererSystem,name:"transformFeedback"};$.add(Ff);class kn{constructor(t){this.renderer=t}init(t){this.screen=new K(0,0,t.width,t.height),this.element=t.view||H.ADAPTER.createCanvas(),this.resolution=t.resolution||H.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const r=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=r,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${r}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",r,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){t&&this.element.parentNode?.removeChild(this.element),this.renderer=null,this.element=null,this.screen=null}}kn.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},kn.extension={type:[U.RendererSystem,U.CanvasRendererSystem],name:"_view"};$.add(kn);H.PREFER_ENV=Vr.WEBGL2;H.STRICT_TEXTURE_CACHE=!1;H.RENDER_OPTIONS={...Mn.defaultOptions,...Pn.defaultOptions,...kn.defaultOptions,...Bn.defaultOptions};Object.defineProperties(H,{WRAP_MODE:{get(){return Q.defaultOptions.wrapMode},set(i){rt("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),Q.defaultOptions.wrapMode=i}},SCALE_MODE:{get(){return Q.defaultOptions.scaleMode},set(i){rt("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),Q.defaultOptions.scaleMode=i}},MIPMAP_TEXTURES:{get(){return Q.defaultOptions.mipmap},set(i){rt("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),Q.defaultOptions.mipmap=i}},ANISOTROPIC_LEVEL:{get(){return Q.defaultOptions.anisotropicLevel},set(i){rt("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),Q.defaultOptions.anisotropicLevel=i}},FILTER_RESOLUTION:{get(){return rt("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),kt.defaultResolution},set(i){kt.defaultResolution=i}},FILTER_MULTISAMPLE:{get(){return rt("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),kt.defaultMultisample},set(i){kt.defaultMultisample=i}},SPRITE_MAX_TEXTURES:{get(){return Cr.defaultMaxTextures},set(i){rt("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Cr.defaultMaxTextures=i}},SPRITE_BATCH_SIZE:{get(){return Cr.defaultBatchSize},set(i){rt("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Cr.defaultBatchSize=i}},CAN_UPLOAD_SAME_BUFFER:{get(){return Cr.canUploadSameBuffer},set(i){rt("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Cr.canUploadSameBuffer=i}},GC_MODE:{get(){return Ir.defaultMode},set(i){rt("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Ir.defaultMode=i}},GC_MAX_IDLE:{get(){return Ir.defaultMaxIdle},set(i){rt("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Ir.defaultMaxIdle=i}},GC_MAX_CHECK_COUNT:{get(){return Ir.defaultCheckCountMax},set(i){rt("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Ir.defaultCheckCountMax=i}},PRECISION_VERTEX:{get(){return Ge.defaultVertexPrecision},set(i){rt("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Ge.defaultVertexPrecision=i}},PRECISION_FRAGMENT:{get(){return Ge.defaultFragmentPrecision},set(i){rt("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Ge.defaultFragmentPrecision=i}}});var zr=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(zr||{});class Jo{constructor(t,e=null,r=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=r,this.once=s}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.
vendor: 4,087 bytes, lines 489-498
489next,t.next=this}destroy(t=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Of=class Xt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Jo(null,null,1/0),this.deltaMS=1/Xt.targetFPMS,this.elapsedMS=1/Xt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,r=zr.NORMAL){return this._addListener(new Jo(t,e,r))}addOnce(t,e,r=zr.NORMAL){return this._addListener(new Jo(t,e,r,!0))}_addListener(t){let e=this._head.next,r=this._head;if(!e)t.connect(r);else{for(;e;){if(t.priority>e.priority){t.connect(r);break}r=e,e=e.next}t.previous||t.connect(r)}return this._startIfPossible(),this}remove(t,e){let r=this._head.next;for(;r;)r.match(t,e)?r=r.destroy():r=r.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Xt.targetFPMS;const r=this._head;let s=r.next;for(;s;)s=s.emit(this.deltaTime);r.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),r=Math.min(Math.max(0,e)/1e3,Xt.targetFPMS);this._maxElapsedMS=1/r}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!Xt._shared){const t=Xt._shared=new Xt;t.autoStart=!0,t._protected=!0}return Xt._shared}static get system(){if(!Xt._system){const t=Xt._system=new Xt;t.autoStart=!0,t._protected=!0}return Xt._system}};Of.targetFPMS=.06;let $t=Of;Object.defineProperties(H,{TARGET_FPMS:{get(){return $t.targetFPMS},set(i){rt("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),$t.targetFPMS=i}}});class Nf{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,zr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?$t.shared:new $t,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Nf.extension=U.Application;$.add(Nf);const Lf=[];$.handleByList(U.Renderer,Lf);function kv(i){for(const t of Lf)if(t.test(i))return new t(i);throw new Error("Unable to auto-detect a suitable renderer.")}var Dv=`attribute vec2 aVertexPosition; 490attribute vec2 aTextureCoord; 491 492uniform mat3 projectionMatrix; 493 494varying vec2 vTextureCoord; 495 496void main(void) 497{ 498 gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0
498)).xy, 0.0, 1.0); 499 vTextureCoord = aTextureCoord; 500}`,Fv=`attribute vec2 aVertexPosition; 501 502uniform mat3 projectionMatrix; 503 504varying vec2 vTextureCoord; 505 506uniform vec4 inputSize; 507uniform vec4 outputFrame; 508 509vec4 filterVertexPosition( void ) 510{ 511 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 512 513 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 514} 515 516vec2 filterTextureCoord( void ) 517{ 518 return aVertexPosition * (outputFrame.zw * inputSize.zw); 519} 520 521void main(void) 522{ 523 gl_Position = filterVertexPosition(); 524 vTextureCoord = filterTextureCoord(); 525} 526`;const Ov=Dv,Uf=Fv;class Gf{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const r=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,r)}else{const r=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,r)}e>=xt.HIGH?this.multisample=xt.HIGH:e>=xt.MEDIUM?this.multisample=xt.MEDIUM:e>=xt.LOW?this.multisample=xt.LOW:this.multisample=xt.NONE}destroy(){}}Gf.extension={type:U.RendererSystem,name:"_multisample"};$.add(Gf);class Nv{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Hf{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:r}=this,s=t._glBuffers[r]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:r,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,r.bindBufferBase(r.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,r){const{gl:s,CONTEXT_UID:n}=this;r=r||0;const o=t._glBuffers[n]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,o.buffer,r*256,256)}update(t){const{gl:e,CONTEXT_UID:r}=this,s=t._glBuffers[r]||this.createGLBuffer(t);if(t._updateID!==s.updateID)if(s.updateID=t._updateID,e.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const r=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),r&&(e||s.deleteBuffer(r.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let r=0;r<e.length;r++)this.dispose(this.managedBuffers[e[r]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:r}=this;return t._glBuffers[e]=new Nv(r.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Hf.extension={type:U.RendererSystem,name:"buffer"};$.add(Hf);class zf{constructor(t){this.renderer=t}render(t,e){const r=this.renderer;let s,n,o,a;if(e&&(s=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,r.runners.prerender.emit(),r.emit("prerender"),r.projection.transform=o,!r.context.isLost){if(s||(this.lastObjectRendered=t),!a){const l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}r.renderTexture.bind(s),r.batch.currentRenderer.start(),(n??r.background.clearBeforeRender)&&r.renderTexture.clear(),t.render(r),r.batch.currentRenderer.flush(),s&&(e.blit&&r.framebuffer.blit(),s.baseTexture.update()),r.runners.postrender.emit(),r.projection.transform=null,r.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}zf.extension={type:U.RendererSystem,name:"objectRenderer"};$.add(zf);const en=class el extends Pv{constructor(t){super(),this.type=Md.WEBGL,t=Object.assign({},H.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new ue({projectionMatrix:new dt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:el.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};
vendor: 4,569 bytes, line 526
526this.setup(e),"useContextAlpha"in t&&(rt("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=el.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t?.forceCanvas?!1:o1()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return rt("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return rt("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return rt("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return rt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){rt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return rt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){rt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return rt("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};en.extension={type:U.Renderer,priority:1},en.__plugins={},en.__systems={};let Ql=en;$.handleByMap(U.RendererPlugin,Ql.__plugins);$.handleByMap(U.RendererSystem,Ql.__systems);$.add(Ql);class Xf extends rs{constructor(t,e){const{width:r,height:s}=e||{};super(r,s),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const o=new Q;this.items.push(o),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let r=0;r<this.length;r++)t[r]&&(t[r].castToBaseTexture?this.addBaseTextureAt(t[r].castToBaseTexture(),r):t[r]instanceof rs?this.addResourceAt(t[r],r):this.addResourceAt(af(t[r],e),r))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{const{realWidth:e,realHeight:r}=this.items[0];return this.resize(e,r),this.update(),Promise.resolve(this)}),this._load}}class Lv extends Xf{constructor(t,e){const{width:r,height:s}=e||{};let n,o;Array.isArray(t)?(n=t,o=t.length):o=t,super(o,{width:r,height:s}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);
vendor: 19,327 bytes, line 526
526else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=_i.TEXTURE_2D_ARRAY}upload(t,e,r){const{length:s,itemDirtyIds:n,items:o}=this,{gl:a}=t;r.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,r.internalFormat,this._width,this._height,s,0,e.format,r.type,null);for(let l=0;l<s;l++){const h=o[l];n[l]<h.dirtyId&&(n[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,e.format,r.type,h.resource.source))}return!0}}class Uv extends hr{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Vf=class Vi extends Xf{constructor(t,e){const{width:r,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==Vi.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:r,height:s});for(let a=0;a<Vi.SIDES;a++)this.items[a].target=_i.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,t&&this.initFromArray(t,e),n!==!1&&this.load()}bind(t){super.bind(t),t.target=_i.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,r){if(r===void 0&&(r=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=_i.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,r){const s=this.itemDirtyIds;for(let n=0;n<Vi.SIDES;n++){const o=this.items[n];(s[n]<o.dirtyId||r.dirtyId<e.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(t,o,r),s[n]=o.dirtyId):s[n]<-1&&(t.gl.texImage2D(o.target,0,r.internalFormat,e.realWidth,e.realHeight,0,e.format,r.type,null),s[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Vi.SIDES}};Vf.SIDES=6;let Gv=Vf;class pi extends hr{constructor(t,e){e=e||{};let r,s,n;typeof t=="string"?(r=pi.EMPTY,s=t,n=!0):(r=t,s=null,n=!1),super(r),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??n,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const r=await H.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await r.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Ht.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(r){if(this.destroyed)return;e(r),this.onError.emit(r)}}),this._load)}upload(t,e,r){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,r)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return pi._EMPTY=pi._EMPTY??H.ADAPTER.createCanvas(0,0),pi._EMPTY}}const rl=class rn extends hr{constructor(t,e){e=e||{},super(H.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},rn.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const t=new Image;hr.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,r=t.height;if(!e||!r)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,n=r*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/r*e,n=this._overrideHeight||this._overrideWidth/e*r),s=Math.round(s),n=Math.round(n);const o=this.source;o.width=s,o.height=n,o._pixiId=`canvas_${Hr()}`,o.getContext("2d").drawImage(t,0,0,e,r,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=rn.SVG_SIZE.exec(t),r={};return e&&(r[e[1]]=Math.round(parseFloat(e[3])),r[e[5]]=Math.round(parseFloat(e[7]))),r}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&rn.SVG_XML.test(t)}};rl.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,rl.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let il=rl;const sl=class nl extends hr{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const r=document.createElement("video");e.autoLoad!==!1&&r.setAttribute("preload","auto"),e.playsinline!==!1&&(r.setAttribute("webkit-playsinline",""),r.setAttribute("playsinline","")),e.muted===!0&&(r.setAttribute("muted",""),r.muted=!0),e.loop===!0&&r.setAttribute("loop",""),e.autoPlay!==!1&&r.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const s=t[0].src||t[0];hr.crossOrigin(r,s,e.crossorigin);for(let n=0;n<t.length;++n){const o=document.createElement("source");let{src:a,mime:l}=t[n];if(a=a||t[n],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),c=h.slice(h.lastIndexOf(".")+1);l=l||nl.MIME_TYPES[c]||`video/${c}`}o.src=a,l&&(o.type=l),r.appendChild(o)}t=r}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const e=$t.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,r)=>{this.valid?e(this):(this._resolve=e,this._reject=r,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&($t.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||($t.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&($t.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||nl.TYPES.includes(e)}};sl.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],sl.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Wf=sl;Wa.push(pi,_f,Uv,Wf,il,Jn,Gv,Lv);class Dn{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?K.EMPTY:(t=t||new K(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:r,b:s,c:n,d:o,tx:a,ty:l}=t,h=r*e.x+n*e.y+a,c=s*e.x+o*e.y+l;this.minX=Math.min(this.minX,h),this.maxX=Math.max(this.maxX,h),this.minY=Math.min(this.minY,c),this.maxY=Math.max(this.maxY,c)}addQuad(t){let e=this.minX,r=this.minY,s=this.maxX,n=this.maxY,o=t[0],a=t[1];e=o<e?o:e,r=a<r?a:r,s=o>s?o:s,n=a>n?a:n,o=t[2],a=t[3],e=o<e?o:e,r=a<r?a:r,s=o>s?o:s,n=a>n?a:n,o=t[4],a=t[5],e=o<e?o:e,r=a<r?a:r,s=o>s?o:s,n=a>n?a:n,o=t[6],a=t[7],e=o<e?o:e,r=a<r?a:r,s=o>s?o:s,n=a>n?a:n,this.minX=e,this.minY=r,this.maxX=s,this.maxY=n}addFrame(t,e,r,s,n){this.addFrameMatrix(t.worldTransform,e,r,s,n)}addFrameMatrix(t,e,r,s,n){const o=t.a,a=t.b,l=t.c,h=t.d,c=t.tx,u=t.ty;let d=this.minX,f=this.minY,p=this.maxX,g=this.maxY,y=o*e+l*r+c,m=a*e+h*r+u;d=y<d?y:d,f=m<f?m:f,p=y>p?y:p,g=m>g?m:g,y=o*s+l*r+c,m=a*s+h*r+u,d=y<d?y:d,f=m<f?m:f,p=y>p?y:p,g=m>g?m:g,y=o*e+l*n+c,m=a*e+h*n+u,d=y<d?y:d,f=m<f?m:f,p=y>p?y:p,g=m>g?m:g,y=o*s+l*n+c,m=a*s+h*n+u,d=y<d?y:d,f=m<f?m:f,p=y>p?y:p,g=m>g?m:g,this.minX=d,this.minY=f,this.maxX=p,this.maxY=g}addVertexData(t,e,r){let s=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let l=e;l<r;l+=2){const h=t[l],c=t[l+1];s=h<s?h:s,n=c<n?c:n,o=h>o?h:o,a=c>a?c:a}this.minX=s,this.minY=n,this.maxX=o,this.maxY=a}addVertices(t,e,r,s){this.addVerticesMatrix(t.worldTransform,e,r,s)}addVerticesMatrix(t,e,r,s,n=0,o=n){const a=t.a,l=t.b,h=t.c,c=t.d,u=t.tx,d=t.ty;let f=this.minX,p=this.minY,g=this.maxX,y=this.maxY;for(let m=r;m<s;m+=2){const v=e[m],_=e[m+1],b=a*v+h*_+u,w=c*_+l*v+d;f=Math.min(f,b-n),g=Math.max(g,b+n),p=Math.min(p,w-o),y=Math.max(y,w+o)}this.minX=f,this.minY=p,this.maxX=g,this.maxY=y}addBounds(t){const e=this.minX,r=this.minY,s=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<r?t.minY:r,this.maxX=t.maxX>s?t.maxX:s,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const r=t.minX>e.minX?t.minX:e.minX,s=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(r<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=r<a?r:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>c?o:c}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const r=t.minX>e.x?t.minX:e.x,s=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,o=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(r<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=r<a?r:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>c?o:c}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,r,s,n,o){t-=n,e-=o,r+=n,s+=o,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>r?this.maxX:r,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>s?this.maxY:s}}class gt extends ls{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Kl,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new Dn,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const e=Object.keys(t);for(let r=0;r<e.length;++r){const s=e[r];Object.defineProperty(gt.prototype,s,Object.getOwnPropertyDescriptor(t,s))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new K),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new K),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Dn);const e=this.transform,r=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=r?.worldAlpha??1,this.transform=this._tempDisplayObjectParent.transform;const s=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,t);return this.parent=r,this.transform=e,this._bounds=s,this._bounds.updateID+=this._boundsID-n,o}toGlobal(t,e,r=!1){return r||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,r,s){return e&&(t=e.toGlobal(t,r,s)),s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,r)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){this.parent?.removeChild(this)}setTransform(t=0,e=0,r=1,s=1,n=0,o=0,a=0,l=0,h=0){return this.position.x=t,this.position.y=e,this.scale.x=r||1,this.scale.y=s||1,this.rotation=n,this.skew.x=o,this.skew.y=a,this.pivot.x=l,this.pivot.y=h,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new Hv),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*D1}set angle(t){this.transform.rotation=t*F1}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex=t,this.parent&&(this.parent.sortDirty=!0)}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount--,e._maskRefCount===0&&(e.renderable=!0,e.isMask=!1))}if(this._mask=t,this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount===0&&(e.renderable=!1,e.isMask=!0),e._maskRefCount++)}}}}class Hv extends gt{constructor(){super(...arguments),this.sortDirty=null}}gt.prototype.displayObjectUpdateTransform=gt.prototype.updateTransform;const zv=new dt;function Xv(i,t){return i.zIndex===t.zIndex?i._lastSortedIndex-t._lastSortedIndex:i.zIndex-t.zIndex}const $f=class ol extends gt{constructor(){super(),this.children=[],this.sortableChildren=ol.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit
vendor: 19,565 bytes, lines 526-568
526("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const r=this.getChildIndex(t),s=this.getChildIndex(e);this.children[r]=e,this.children[s]=t,this.onChildrenChange(r<s?r:s)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const r=this.getChildIndex(t);vi(this.children,r,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],r=this.children.indexOf(e);if(r===-1)return null;e.parent=null,e.transform._parentID=-1,vi(this.children,r,1),this._boundsID++,this.onChildrenChange(r),e.emit("removed",this),this.emit("childRemoved",e,this,r)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,vi(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const r=t,s=e,n=s-r;let o;if(n>0&&n<=s){o=this.children.splice(r,n);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let a=0;a<o.length;++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,r=this.children.length;e<r;++e){const s=this.children[e];s._lastSortedIndex=e,!t&&s.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(Xv),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t<e;++t){const r=this.children[t];r.visible&&r.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const r=e._mask.isMaskData?e._mask.maskObject:e._mask;r?(r.calculateBounds(),this._bounds.addBoundsMask(e._bounds,r._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const r=super.getLocalBounds(t);if(!e)for(let s=0,n=this.children.length;s<n;++s){const o=this.children[s];o.visible&&o.updateTransform()}return r}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let r,s;this.cullArea?(r=this.cullArea,s=this.worldTransform):this._render!==ol.prototype._render&&(r=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=zv.copyFrom(s),s.prepend(n)):s=n),r&&e.intersects(r,s))this._render(t);else if(this.cullArea)return;for(let o=0,a=this.children.length;o<a;++o){const l=this.children[o],h=l.cullable;l.cullable=h||!this.cullArea,l.render(t),l.cullable=h}}render(t){if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||this.filters?.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let e=0,r=this.children.length;e<r;++e)this.children[e].render(t)}}renderAdvanced(t){const e=this.filters,r=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let n=0;n<e.length;n++)e[n].enabled&&this._enabledFilters.push(e[n])}const s=e&&this._enabledFilters?.length||r&&(!r.isMaskData||r.enabled&&(r.autoDetect||r.type!==Et.NONE));if(s&&t.batch.flush(),e&&this._enabledFilters?.length&&t.filter.push(this,this._enabledFilters),r&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let n=0,o=this.children.length;n<o;++n)this.children[n].render(t)}s&&t.batch.flush(),r&&t.mask.pop(this),e&&this._enabledFilters?.length&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t?.children,r=this.removeChildren(0,this.children.length);if(e)for(let s=0;s<r.length;++s)r[s].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}};$f.defaultSortableChildren=!1;let Dt=$f;Dt.prototype.containerUpdateTransform=Dt.prototype.updateTransform;Object.defineProperties(H,{SORTABLE_CHILDREN:{get(){return Dt.defaultSortableChildren},set(i){rt("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),Dt.defaultSortableChildren=i}}});const Li=new ot,Vv=new Uint16Array([0,1,2,0,2,3]);class Lt extends Dt{constructor(t){super(),this._anchor=new Ue(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new ut(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=Z.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||W.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=Vv,this.pluginName="batch",this.isSprite=!0,this._roundPixels=H.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=rr(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=rr(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,r=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this.vertexData,c=t.trim,u=t.orig,d=this._anchor;let f=0,p=0,g=0,y=0;if(c?(p=c.x-d._x*u.width,f=p+c.width,y=c.y-d._y*u.height,g=y+c.height):(p=-d._x*u.width,f=p+u.width,y=-d._y*u.height,g=y+u.height),h[0]=r*p+n*y+a,h[1]=o*y+s*p+l,h[2]=r*f+n*y+a,h[3]=o*y+s*f+l,h[4]=r*f+n*g+a,h[5]=o*g+s*f+l,h[6]=r*p+n*g+a,h[7]=o*g+s*p+l,this._roundPixels){const m=H.RESOLUTION;for(let v=0;v<h.length;++v)h[v]=Math.round(h[v]*m)/m}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,r=t.orig,s=this._anchor,n=this.transform.worldTransform,o=n.a,a=n.b,l=n.c,h=n.d,c=n.tx,u=n.ty,d=-s._x*r.width,f=d+r.width,p=-s._y*r.height,g=p+r.height;if(e[0]=o*d+l*p+c,e[1]=h*p+a*d+u,e[2]=o*f+l*p+c,e[3]=h*p+a*f+u,e[4]=o*f+l*g+c,e[5]=h*g+a*f+u,e[6]=o*d+l*g+c,e[7]=h*g+a*d+u,this._roundPixels){const y=H.RESOLUTION;for(let m=0;m<e.length;++m)e[m]=Math.round(e[m]*y)/y}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new Dn),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new K),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Li);const e=this._texture.orig.width,r=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return Li.x>=s&&Li.x<s+e&&(n=-r*this.anchor.y,Li.y>=n&&Li.y<n+r)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t?.texture){const e=typeof t=="boolean"?t:t?.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const r=t instanceof W?t:W.from(t,e);return new Lt(r)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=rr(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=rr(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||W.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const jf=new dt;gt.prototype._cacheAsBitmap=!1;gt.prototype._cacheData=null;gt.prototype._cacheAsBitmapResolution=null;gt.prototype._cacheAsBitmapMultisample=null;class Wv{constructor(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}Object.defineProperties(gt.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(i){i!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=i,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(i){i!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=i,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(i){if(this._cacheAsBitmap===i)return;this._cacheAsBitmap=i;let t;i?(this._cacheData||(this._cacheData=new Wv),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}});gt.prototype._renderCached=function(i){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(i),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(i))};gt.prototype._initCachedDisplayObject=function(i){if(this._cacheData?.sprite)return;const t=this.alpha;this.alpha=1,i.batch.flush();const e=this.getLocalBounds(new K,!0);if(this.filters?.length){const d=this.filters[0].padding;e.pad(d)}const r=this.cacheAsBitmapResolution||i.resolution;e.ceil(r),e.width=Math.max(e.width,1/r),e.height=Math.max(e.height,1/r);const s=i.renderTexture.current,n=i.renderTexture.sourceFrame.clone(),o=i.renderTexture.destinationFrame.clone(),a=i.projection.transform,l=Ft.create({width:e.width,height:e.height,resolution:r,multisample:this.cacheAsBitmapMultisample??i.multisample}),h=`cacheAsBitmap_${Hr()}`;this._cacheData.textureCacheId=h,Q.addToCache(l.baseTexture,h),W.addToCache(l,h);const c=this.transform.localTransform.copyTo(jf).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,i.render(this,{renderTexture:l,clear:!0,transform:c,skipUpdateTransform:!1}),i.framebuffer.blit(),i.projection.transform=a,i.renderTexture.bind(s,n,o),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const u=new Lt(l);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(e.x/e.width),u.anchor.y=-(e.y/e.height),u.alpha=t,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=u.containsPoint.bind(u)};gt.prototype._renderCachedCanvas=function(i){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(i),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(i))};gt.prototype._initCachedDisplayObjectCanvas=function(i){if(this._cacheData?.sprite)return;const t=this.getLocalBounds(new K,!0),e=this.alpha;this.alpha=1;const r=i.canvasContext.activeContext,s=i._projTransform,n=this.cacheAsBitmapResolution||i.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const o=Ft.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${Hr()}`;this._cacheData.textureCacheId=a,Q.addToCache(o.baseTexture,a),W.addToCache(o,a);const l=jf;this.transform.localTransform.copyTo(l),l.invert(),l.tx-=t.x,l.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,i.render(this,{renderTexture:o,clear:!0,transform:l,skipUpdateTransform:!1}),i.canvasContext.activeContext=r,i._projTransform=s,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=e;const h=new Lt(o);h.transform.worldTransform=this.transform.worldTransform,h.anchor.x=-(t.x/t.width),h.anchor.y=-(t.y/t.height),h.alpha=e,h._bounds=this._bounds,this._cacheData.sprite=h,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=i._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=h.containsPoint.bind(h)};gt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID};gt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)};gt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,Q.removeFromCache(this._cacheData.textureCacheId),W.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null};gt.prototype._cacheAsBitmapDestroy=function(i){this.cacheAsBitmap=!1,this.destroy(i)};gt.prototype.name=null;Dt.prototype.getChildByName=function(i,t){for(let e=0,r=this.children.length;e<r;e++)if(this.children[e].name===i)return this.children[e];if(t)for(let e=0,r=this.children.length;e<r;e++){const s=this.children[e];if(!s.getChildByName)continue;const n=s.getChildByName(i,!0);if(n)return n}return null};gt.prototype.getGlobalPosition=function(i=new ot,t=!1){return this.parent?this.parent.toGlobal(this.position,i,t):(i.x=this.position.x,i.y=this.position.y),i};var $v=`varying vec2 vTextureCoord; 527 528uniform sampler2D uSampler; 529uniform float uAlpha; 530 531void main(void) 532{ 533 gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha; 534} 535`;class jv extends kt{constructor(t=1){super(Ov,$v,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const Yv={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},qv=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(` 536`);function Zv(i){const t=Yv[i],e=t.length;let r=qv,s="";const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<i;a++){let l=n.replace("%index%",a.toString());o=a,a>=e&&(o=i-a-1),l=l.replace("%value%",t[o].toString()),s+=l,s+=` 537`}return r=r.replace("%blur%",s),r=r.replace("%size%",i.toString()),r}const Kv=` 538 attribute vec2 aVertexPosition; 539 540 uniform mat3 projectionMatrix; 541 542 uniform float strength; 543 544 varying vec2 vBlurTexCoords[%size%]; 545 546 uniform vec4 inputSize; 547 uniform vec4 outputFrame; 548 549 vec4 filterVertexPosition( void ) 550 { 551 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 552 553 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 554 } 555 556 vec2 filterTextureCoord( void ) 557 { 558 return aVertexPosition * (outputFrame.zw * inputSize.zw); 559 } 560 561 void main(void) 562 { 563 gl_Position = filterVertexPosition(); 564 565 vec2 textureCoord = filterTextureCoord(); 566 %blur% 567 }`;function Jv(i,t){const e=Math.ceil(i/2);let r=Kv,s="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<i;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),s+=a,s+=` 568`}return r=r.replace("%blur%",s),r=r.replace("%size%",i.toString()),r}class al extends kt{constructor(t,e=8,r=4,s=kt.defaultResolution,n=5){const o=Jv(n,t),a=Zv(n);super(o,a),this.horizontal=t,this.resolution=s,this._quality=0,this.qual
vendor: 9,154 bytes, lines 568-654
568ity=r,this.blur=e}apply(t,e,r,s){if(r?this.horizontal?this.uniforms.strength=1/r.width*(r.width/e.width):this.uniforms.strength=1/r.height*(r.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,r,s);else{const n=t.getFilterTexture(),o=t.renderer;let a=e,l=n;this.state.blend=!1,t.applyFilter(this,a,l,be.CLEAR);for(let h=1;h<this.passes-1;h++){t.bindAndClear(a,be.BLIT),this.uniforms.uSampler=l;const c=l;l=a,a=c,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,l,r,s),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class Qv extends kt{constructor(t=8,e=4,r=kt.defaultResolution,s=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new al(!0,t,e,r,s),this.blurYFilter=new al(!1,t,e,r,s),this.resolution=r,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,r,s){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=t.getFilterTexture();this.blurXFilter.apply(t,e,a,be.CLEAR),this.blurYFilter.apply(t,a,r,s),t.returnFilterTexture(a)}else o?this.blurYFilter.apply(t,e,r,s):this.blurXFilter.apply(t,e,r,s)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var tb=`varying vec2 vTextureCoord; 569uniform sampler2D uSampler; 570uniform float m[20]; 571uniform float uAlpha; 572 573void main(void) 574{ 575 vec4 c = texture2D(uSampler, vTextureCoord); 576 577 if (uAlpha == 0.0) { 578 gl_FragColor = c; 579 return; 580 } 581 582 // Un-premultiply alpha before applying the color matrix. See issue #3539. 583 if (c.a > 0.0) { 584 c.rgb /= c.a; 585 } 586 587 vec4 result; 588 589 result.r = (m[0] * c.r); 590 result.r += (m[1] * c.g); 591 result.r += (m[2] * c.b); 592 result.r += (m[3] * c.a); 593 result.r += m[4]; 594 595 result.g = (m[5] * c.r); 596 result.g += (m[6] * c.g); 597 result.g += (m[7] * c.b); 598 result.g += (m[8] * c.a); 599 result.g += m[9]; 600 601 result.b = (m[10] * c.r); 602 result.b += (m[11] * c.g); 603 result.b += (m[12] * c.b); 604 result.b += (m[13] * c.a); 605 result.b += m[14]; 606 607 result.a = (m[15] * c.r); 608 result.a += (m[16] * c.g); 609 result.a += (m[17] * c.b); 610 result.a += (m[18] * c.a); 611 result.a += m[19]; 612 613 vec3 rgb = mix(c.rgb, result.rgb, uAlpha); 614 615 // Premultiply alpha again. 616 rgb *= result.a; 617 618 gl_FragColor = vec4(rgb, result.a); 619} 620`;class ll extends kt{constructor(){const t={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};super(Uf,tb,t),this.alpha=1}_loadMatrix(t,e=!1){let r=t;e&&(this._multiply(r,this.uniforms.m,t),r=this._colorMatrix(r)),this.uniforms.m=r}_multiply(t,e,r){return t[0]=e[0]*r[0]+e[1]*r[5]+e[2]*r[10]+e[3]*r[15],t[1]=e[0]*r[1]+e[1]*r[6]+e[2]*r[11]+e[3]*r[16],t[2]=e[0]*r[2]+e[1]*r[7]+e[2]*r[12]+e[3]*r[17],t[3]=e[0]*r[3]+e[1]*r[8]+e[2]*r[13]+e[3]*r[18],t[4]=e[0]*r[4]+e[1]*r[9]+e[2]*r[14]+e[3]*r[19]+e[4],t[5]=e[5]*r[0]+e[6]*r[5]+e[7]*r[10]+e[8]*r[15],t[6]=e[5]*r[1]+e[6]*r[6]+e[7]*r[11]+e[8]*r[16],t[7]=e[5]*r[2]+e[6]*r[7]+e[7]*r[12]+e[8]*r[17],t[8]=e[5]*r[3]+e[6]*r[8]+e[7]*r[13]+e[8]*r[18],t[9]=e[5]*r[4]+e[6]*r[9]+e[7]*r[14]+e[8]*r[19]+e[9],t[10]=e[10]*r[0]+e[11]*r[5]+e[12]*r[10]+e[13]*r[15],t[11]=e[10]*r[1]+e[11]*r[6]+e[12]*r[11]+e[13]*r[16],t[12]=e[10]*r[2]+e[11]*r[7]+e[12]*r[12]+e[13]*r[17],t[13]=e[10]*r[3]+e[11]*r[8]+e[12]*r[13]+e[13]*r[18],t[14]=e[10]*r[4]+e[11]*r[9]+e[12]*r[14]+e[13]*r[19]+e[14],t[15]=e[15]*r[0]+e[16]*r[5]+e[17]*r[10]+e[18]*r[15],t[16]=e[15]*r[1]+e[16]*r[6]+e[17]*r[11]+e[18]*r[16],t[17]=e[15]*r[2]+e[16]*r[7]+e[17]*r[12]+e[18]*r[17],t[18]=e[15]*r[3]+e[16]*r[8]+e[17]*r[13]+e[18]*r[18],t[19]=e[15]*r[4]+e[16]*r[9]+e[17]*r[14]+e[18]*r[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const r=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(r,e)}tint(t,e){const[r,s,n]=ut.shared.setValue(t).toArray(),o=[r,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const r=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(r,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const r=Math.cos(t),s=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),l=r+(1-r)*o,h=o*(1-r)-a*s,c=o*(1-r)+a*s,u=o*(1-r)+a*s,d=r+o*(1-r),f=o*(1-r)-a*s,p=o*(1-r)-a*s,g=o*(1-r)+a*s,y=r+o*(1-r),m=[l,h,c,0,0,u,d,f,0,0,p,g,y,0,0,0,0,0,1,0];this._loadMatrix(m,e)}contrast(t,e){const r=(t||0)+1,s=-.5*(r-1),n=[r,0,0,0,s,0,r,0,0,s,0,0,r,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const r=t*2/3+1,s=(r-1)*-.5,n=[r,s,s,0,0,s,r,s,0,0,s,s,r,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,r,s,n){t=t||.2,e=e||.15,r=r||16770432,s=s||3375104;const o=ut.shared,[a,l,h]=o.setValue(r).toArray(),[c,u,d]=o.setValue(s).toArray(),f=[.3,.59,.11,0,0,a,l,h,t,0,c,u,d,e,0,a-c,l-u,h-d,0,0];this._loadMatrix(f,n)}night(t,e){t=t||.1;const r=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(r,e)}predator(t,e){const r=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(r,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}ll.prototype.grayscale=ll.prototype.greyscale;var eb=`varying vec2 vFilterCoord; 621varying vec2 vTextureCoord; 622 623uniform vec2 scale; 624uniform mat2 rotation; 625uniform sampler2D uSampler; 626uniform sampler2D mapSampler; 627 628uniform highp vec4 inputSize; 629uniform vec4 inputClamp; 630 631void main(void) 632{ 633 vec4 map = texture2D(mapSampler, vFilterCoord); 634 635 map -= 0.5; 636 map.xy = scale * inputSize.zw * (rotation * map.xy); 637 638 gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw)); 639} 640`,rb=`attribute vec2 aVertexPosition; 641 642uniform mat3 projectionMatrix; 643uniform mat3 filterMatrix; 644 645varying vec2 vTextureCoord; 646varying vec2 vFilterCoord; 647 648uniform vec4 inputSize; 649uniform vec4 outputFrame; 650 651vec4 filterVertexPosition( void ) 652{ 653 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 654
655 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 656} 657 658vec2 filterTextureCoord( void ) 659{ 660 return aVertexPosition * (outputFrame.zw * inputSize.zw); 661} 662 663void main(void) 664{ 665 gl_Position = filterVertexPosition(); 666 vTextureCoord = filterTextureCoord(); 667 vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy; 668} 669`;class ib extends kt{constructor(t,e){const r=new dt;t.renderable=!1,super(rb,eb,{mapSampler:t._texture,filterMatrix:r,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=r,e==null&&(e=20),this.scale=new ot(e,e)}apply(t,e,r,s){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,o=Math.sqrt(n.a*n.a+n.b*n.b),a=Math.sqrt(n.c*n.c+n.d*n.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=n.a/o,this.uniforms.rotation[1]=n.b/o,this.uniforms.rotation[2]=n.c/a,this.uniforms.rotation[3]=n.d/a),t.applyFilter(this,e,r,s)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var sb=`varying vec2 v_rgbNW; 670varying vec2 v_rgbNE; 671varying vec2 v_rgbSW; 672varying vec2 v_rgbSE; 673varying vec2 v_rgbM; 674 675varying vec2 vFragCoord; 676uniform sampler2D uSampler; 677uniform highp vec4 inputSize; 678 679 680/** 681 Basic FXAA implementation based on the code on geeks3d.com with the 682 modification that the texture2DLod stuff was removed since it's 683 unsupported by WebGL. 684 685 -- 686 687 From: 688 https://github.com/mitsuhiko/webgl-meincraft 689 690 Copyright (c) 2011 by Armin Ronacher. 691 692 Some rights reserved. 693 694 Redistribution and use in source and binary forms, with or without 695 modification, are permitted provided that the following conditions are 696 met: 697 698 * Redistributions of source code must retain the above copyright 699 notice, this list of conditions and the following disclaimer. 700 701 * Redistributions in binary form must reproduce the above 702 copyright notice, this list of conditions and the following 703 disclaimer in the documentation and/or other materials provided 704 with the distribution. 705 706 * The names of the contributors may not be used to endorse or 707 promote products derived from this software without specific 708 prior written permission. 709 710 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 711 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 712 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 713 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 714 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 715 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 716 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 717 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 718 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 719 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 720 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 721 */ 722 723#ifndef FXAA_REDUCE_MIN 724#define FXAA_REDUCE_MIN (1.0/ 128.0) 725#endif 726#ifndef FXAA_REDUCE_MUL 727#define FXAA_REDUCE_MUL (1.0 / 8.0) 728#endif 729#ifndef FXAA_SPAN_MAX 730#define FXAA_SPAN_MAX 8.0 731#endif 732 733//optimized version for mobile, where dependent 734//texture reads can be a bottleneck 735vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP, 736 vec2 v_rgbNW, vec2 v_rgbNE, 737 vec2 v_rgbSW, vec2 v_rgbSE, 738 vec2 v_rgbM) { 739 vec4 color; 740 vec3 rgbNW = texture2D(tex, v_rgbNW).xyz; 741 vec3 rgbNE = texture2D(tex, v_rgbNE).xyz; 742 vec3 rgbSW = texture2D(tex, v_rgbSW).xyz; 743 vec3 rgbSE = texture2D(tex, v_rgbSE).xyz; 744 vec4 texColor = texture2D(tex, v_rgbM); 745 vec3 rgbM = texColor.xyz; 746 vec3 luma = vec3(0.299, 0.587, 0.114); 747 float lumaNW = dot(rgbNW, luma); 748 float lumaNE = dot(rgbNE, luma); 749 float lumaSW = dot(rgbSW, luma); 750 float lumaSE = dot(rgbSE, luma); 751 float lumaM = dot(rgbM, luma); 752 float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); 753 float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); 754 755 mediump vec2 dir; 756 dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); 757 dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); 758
759 float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * 760 (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); 761 762 float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); 763 dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), 764 max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), 765 dir * rcpDirMin)) * inverseVP; 766 767 vec3 rgbA = 0.5 * ( 768 texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz + 769 texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz); 770 vec3 rgbB = rgbA * 0.5 + 0.25 * ( 771 texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz + 772 texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz); 773 774 float lumaB = dot(rgbB, luma); 775 if ((lumaB < lumaMin) || (lumaB > lumaMax)) 776 color = vec4(rgbA, texColor.a); 777 else 778 color = vec4(rgbB, texColor.a); 779 return color; 780} 781 782void main() { 783 784 vec4 color; 785 786 color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); 787 788 gl_FragColor = color; 789} 790`,nb=` 791attribute vec2 aVertexPosition; 792 793uniform mat3 projectionMatrix; 794 795varying vec2 v_rgbNW; 796varying vec2 v_rgbNE; 797varying vec2 v_rgbSW; 798varying vec2 v_rgbSE; 799varying vec2 v_rgbM; 800 801varying vec2 vFragCoord; 802 803uniform vec4 inputSize; 804uniform vec4 outputFrame; 805 806vec4 filterVertexPosition( void ) 807{ 808 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 809 810 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 811} 812 813void texcoords(vec2 fragCoord, vec2 inverseVP, 814 out vec2 v_rgbNW, out vec2 v_rgbNE, 815 out vec2 v_rgbSW, out vec2 v_rgbSE, 816 out vec2 v_rgbM) { 817 v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP; 818 v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP; 819 v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP; 820 v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP; 821 v_rgbM = vec2(fragCoord * inverseVP); 822} 823 824void main(void) { 825 826 gl_Position = filterVertexPosition(); 827 828 vFragCoord = aVertexPosition * outputFrame.zw; 829 830 texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); 831} 832`;class ob extends kt{constructor(){super(nb,sb)}}var ab=`precision highp float; 833 834varying vec2 vTextureCoord; 835varying vec4 vColor; 836 837uniform float uNoise; 838uniform float uSeed; 839uniform sampler2D uSampler; 840 841float rand(vec2 co) 842{ 843 return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); 844} 845 846void main() 847{ 848 vec4 color = texture2D(uSampler, vTextureCoord); 849 float randomValue = rand(gl_FragCoord.xy * uSeed); 850 float diff = (randomValue - 0.5) * uNoise; 851 852 // Un-premultiply alpha before applying the color matrix. See issue #3539. 853 if (color.a > 0.0) { 854 color.rgb /= color.a; 855 } 856 857 color.r += diff; 858 color.g += diff; 859 color.b += diff; 860 861 // Premultiply alpha again. 862 color.rgb *= color.a; 863 864 gl_FragColor = color; 865} 866`;class lb extends kt{constructor(t=.5,e=Math.random()){super(Uf,ab,{uNoise:0,uSeed:0}),this.noise=t,this.seed=e}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}const Wc={AlphaFilter:jv,BlurFilter:Qv,BlurFilterPass:al,ColorMatrixFilter:ll,DisplacementFilter:ib,FXAAFilter:ob,NoiseFilter:lb};Object.entries(Wc).forEach(([i,t])=>{Object.defineProperty(Wc,i,{get(){return rt("7.1.0",`filters.${i} has moved to ${i}`),t}})});class hb{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||($t.system.add(this.tickerUpdate,this,zr.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&($t.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}
vendor: 4,289 bytes, line 866
866tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const tr=new hb;class cs{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=cs.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ot,this.page=new ot,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,r){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,r,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class Fn extends cs{constructor(){super(...arguments),this.client=new ot,this.movement=new ot,this.offset=new ot,this.global=new ot,this.screen=new ot}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,r){return t.worldTransform.applyInverse(r||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,r,s,n,o,a,l,h,c,u,d,f,p,g){throw new Error("Method not implemented.")}}class ae extends Fn{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class xi extends Fn{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}xi.DOM_DELTA_PIXEL=0,xi.DOM_DELTA_LINE=1,xi.DOM_DELTA_PAGE=2;const cb=2048,ub=new ot,Qo=new ot;class db{constructor(t){this.dispatch=new ls,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((r,s)=>r.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let r=0,s=e.length;r<s;r++)e[r].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}
vendor: 10,543 bytes, line 866
866hitTest(t,e){tr.pauseUpdate=!0;const r=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[r](this.rootTarget,this.rootTarget.eventMode,ub.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const r=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=r.length-1;s<n;s++)if(t.currentTarget=r[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let s=r.length-2;s>=0;s--)if(t.currentTarget=r[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,r=this._allInteractiveElements){if(r.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=r.length-1;n>=0;n--)s.forEach(o=>{t.currentTarget=r[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let r=0;r<cb&&t!==this.rootTarget;r++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,r,s,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(tr.pauseUpdate=!1),t.interactiveChildren&&t.children){const c=t.children;for(let u=c.length-1;u>=0;u--){const d=c[u],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,r,s,n,o||n(t,r));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const l=this._isInteractive(e),h=t.isInteractive();return l&&h&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,r)&&s(t,r)?h?[t]:[]:null}hitTestRecursive(t,e,r,s,n){if(this._interactivePrune(t)||n(t,r))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(tr.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let h=l.length-1;h>=0;h--){const c=l[h],u=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,r,s,n);if(u){if(u.length>0&&!u[u.length-1].parent)continue;const d=t.isInteractive();return(u.length>0||d)&&u.push(t),u}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&s(t,r)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,Qo),!t.hitArea.contains(Qo.x,Qo.y)))return!0;if(t._mask){const r=t._mask.isMaskData?t._mask.maskObject:t._mask;if(r&&!r.containsPoint?.(e))return!0}return!1}hitTestFn(t,e){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){e=e??t.type;const r=`on${e}`;t.currentTarget[r]?.(t);const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const s=e.button===2;this.dispatchEvent(e,s?"rightdown":"mousedown")}const r=this.trackingData(t.pointerId);r.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){if(!(t instanceof ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const r=e.pointerType==="mouse"||e.pointerType==="pen",s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.overTargets);if(s.overTargets?.length>0&&n!==e.target){const l=t.type==="mousemove"?"mouseout":"pointerout",h=this.createPointerEvent(t,l,n);if(this.dispatchEvent(h,"pointerout"),r&&this.dispatchEvent(h,"mouseout"),!e.composedPath().includes(n)){const c=this.createPointerEvent(t,"pointerleave",n);for(c.eventPhase=c.AT_TARGET;c.target&&!e.composedPath().includes(c.target);)c.currentTarget=c.target,this.notifyTarget(c),r&&this.notifyTarget(c,"mouseleave"),c.target=c.target.parent;this.freeEvent(c)}this.freeEvent(h)}if(n!==e.target){const l=t.type==="mousemove"?"mouseover":"pointerover",h=this.clonePointerEvent(e,l);this.dispatchEvent(h,"pointerover"),r&&this.dispatchEvent(h,"mouseover");let c=n?.parent;for(;c&&c!==this.rootTarget.parent&&c!==e.target;)c=c.parent;if(!c||c===this.rootTarget.parent){const u=this.clonePointerEvent(e,"pointerenter");for(u.eventPhase=u.AT_TARGET;u.target&&u.target!==n&&u.target!==this.rootTarget.parent;)u.currentTarget=u.target,this.notifyTarget(u),r&&this.notifyTarget(u,"mouseenter"),u.target=u.target.parent;this.freeEvent(u)}this.freeEvent(h)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(e,"pointermove"),a&&o.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),a&&o.push("globaltouchmove")),r&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&o.push("globalmousemove"),this.cursor=e.target?.cursor),o.length>0&&this.all(e,o),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){if(!(t instanceof ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),r=this.createPointerEvent(t),s=r.pointerType==="mouse"||r.pointerType==="pen";this.dispatchEvent(r,"pointerover"),s&&this.dispatchEvent(r,"mouseover"),r.pointerType==="mouse"&&(this.cursor=r.target?.cursor);const n=this.clonePointerEvent(r,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=r.composedPath(),this.freeEvent(r),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const r=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),r&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",s);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),r&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),r=this.createPointerEvent(t);if(this.dispatchEvent(r,"pointerup"),r.pointerType==="touch")this.dispatchEvent(r,"touchend");else if(r.pointerType==="mouse"||r.pointerType==="pen"){const a=r.button===2;this.dispatchEvent(r,a?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let o=n;if(n&&!r.composedPath().includes(n)){let a=n;for(;a&&!r.composedPath().includes(a);){if(r.currentTarget=a,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch")this.notifyTarget(r,"touchendoutside");else if(r.pointerType==="mouse"||r.pointerType==="pen"){const l=r.button===2;this.notifyTarget(r,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(r,"click");a.target=o,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=s.clicksByButton[t.button];if(l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,a.detail=l.clickCount,a.pointerType==="mouse"){const h=a.button===2;this.dispatchEvent(a,h?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(r)}mapPointerUpOutside(t){if(!(t instanceof ae)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),r=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(r){let n=r;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof xi)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let r=1;r<t.length&&t[r].parent===e;r++)e=t[r];return e}createPointerEvent(t,e,r){const s=this.allocateEvent(ae);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=r??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(xi);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const r=this.allocateEvent(ae);return r.nativeEvent=t.nativeEvent,r.originalEvent=t.originalEvent,this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.target=t.target,r.path=t.composedPath().slice(),r.type=e??r.type,r}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof ae&&e instanceof ae&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.t
vendor: 17,793 bytes, line 866
866iltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof Fn&&e instanceof Fn&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const r=t.currentTarget._events[e];if(r&&t.currentTarget.isInteractive())if("fn"in r)r.once&&t.currentTarget.removeListener(e,r.fn,void 0,!0),r.fn.call(r.context,t);else for(let s=0,n=r.length;s<n&&!t.propagationImmediatelyStopped;s++)r[s].once&&t.currentTarget.removeListener(e,r[s].fn,void 0,!0),r[s].fn.call(r[s].context,t)}}const fb=1,pb={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},hl=class cl{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new db(null),tr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new ae(null),this.rootWheelEvent=new xi(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...cl.defaultEventFeatures},{set:(e,r,s)=>(r==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[r]=s,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{view:e,resolution:r}=this.renderer;this.setTargetElement(e),this.resolution=r,cl._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const r=this.cursorStyles[t];if(r)switch(typeof r){case"string":e&&(this.domElement.style.cursor=r);break;case"function":r(t);break;case"object":e&&Object.assign(this.domElement.style,r);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let r=0,s=e.length;r<s;r++){const n=e[r],o=this.bootstrapEvent(this.rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,tr.pointerMoved();const e=this.normalizeToPointerData(t);for(let r=0,s=e.length;r<s;r++){const n=this.bootstrapEvent(this.rootPointerEvent,e[r]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const r=e!==this.domElement?"outside":"",s=this.normalizeToPointerData(t);for(let n=0,o=s.length;n<o;n++){const a=this.bootstrapEvent(this.rootPointerEvent,s[n]);a.type+=r,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let r=0,s=e.length;r<s;r++){const n=this.bootstrapEvent(this.rootPointerEvent,e[r]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,tr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;tr.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;tr.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,e,r){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(r-s.top)*(this.domElement.height/s.height)*n}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let r=0,s=t.changedTouches.length;r<s;r++){const n=t.changedTouches[r];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const r=t;typeof r.isPrimary>"u"&&(r.isPrimary=!0),typeof r.width>"u"&&(r.width=1),typeof r.height>"u"&&(r.height=1),typeof r.tiltX>"u"&&(r.tiltX=0),typeof r.tiltY>"u"&&(r.tiltY=0),typeof r.pointerType>"u"&&(r.pointerType="mouse"),typeof r.pointerId>"u"&&(r.pointerId=fb),typeof r.pressure>"u"&&(r.pressure=.5),typeof r.twist>"u"&&(r.twist=0),typeof r.tangentialPressure>"u"&&(r.tangentialPressure=0),r.isNormalized=!0,e.push(r)}else e.push(t);return e}normalizeWheelEvent(t){const e=this.rootWheelEvent;return this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=pb[t.type]||t.type),t}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};hl.extension={name:"events",type:[U.RendererSystem,U.CanvasRendererSystem]},hl.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let ul=hl;$.add(ul);function $c(i){return i==="dynamic"||i==="static"}const mb={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??$c(ul.defaultEventMode)},set interactive(i){rt("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=i,this.eventMode=i?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??ul.defaultEventMode},set eventMode(i){this._internalInteractive=$c(i),this._internalEventMode=i},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(i,t,e){const r=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;i=r?`${i}capture`:i,t=typeof t=="function"?t:t.handleEvent,this.on(i,t,s)},removeEventListener(i,t,e){const r=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;i=r?`${i}capture`:i,t=typeof t=="function"?t:t.handleEvent,this.off(i,t,s)},dispatchEvent(i){if(!(i instanceof cs))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return i.defaultPrevented=!1,i.path=null,i.target=this,i.manager.dispatchEvent(i),!i.defaultPrevented}};gt.mixin(mb);const _b={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};gt.mixin(_b);const gb=9,Rs=100,yb=0,vb=0,jc=2,Yc=1,bb=-1e3,xb=-1e3,wb=2;class Yf{constructor(t){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(Le.tablet||Le.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${Rs}px`,e.style.height=`${Rs}px`,e.style.position="absolute",e.style.top=`${yb}px`,e.style.left=`${vb}px`,e.style.zIndex=jc.toString(),this.div=e,this.renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const t=document.createElement("button");t.style.width=`${Yc}px`,t.style.height=`${Yc}px`,t.style.position="absolute",t.style.top=`${bb}px`,t.style.left=`${xb}px`,t.style.zIndex=wb.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),this.renderer.view.parentNode?.appendChild(this.div))}deactivate(){!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),this.div.parentNode?.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const e=t.children;if(e)for(let r=0;r<e.length;r++)this.updateAccessibleObjects(e[r])}update(){const t=performance.now();if(Le.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:r,width:s,height:n}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:l}=this.renderer,h=s/o*l,c=n/a*l;let u=this.div;u.style.left=`${e}px`,u.style.top=`${r}px`,u.style.width=`${o}px`,u.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const f=this.children[d];if(f.renderId!==this.renderId)f._accessibleActive=!1,vi(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{u=f._accessibleDiv;let p=f.hitArea;const g=f.worldTransform;f.hitArea?(u.style.left=`${(g.tx+p.x*g.a)*h}px`,u.style.top=`${(g.ty+p.y*g.d)*c}px`,u.style.width=`${p.width*g.a*h}px`,u.style.height=`${p.height*g.d*c}px`):(p=f.getBounds(),this.capHitArea(p),u.style.left=`${p.x*h}px`,u.style.top=`${p.y*c}px`,u.style.width=`${p.width*h}px`,u.style.height=`${p.height*c}px`,u.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(u.title=f.accessibleTitle),u.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&u.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==u.title||f.tabIndex!==u.tabIndex)&&(u.title=f.accessibleTitle,u.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(u))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:r}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>r&&(t.height=r-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${Rs}px`,e.style.height=`${Rs}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=jc.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.t
vendor: 4,377 bytes, line 866
866itle=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:r}=t.target,s=this.renderer.events.rootBoundary,n=Object.assign(new cs(s),{target:r});s.rootTarget=this.renderer.lastObjectRendered,e.forEach(o=>s.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===gb&&this.activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}Yf.extension={name:"accessibility",type:[U.RendererPlugin,U.CanvasRendererPlugin]};$.add(Yf);const qf=class dl{constructor(t){this.stage=new Dt,t=Object.assign({forceCanvas:!1},t),this.renderer=kv(t),dl._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){return this.renderer?.view}get screen(){return this.renderer?.screen}destroy(t,e){const r=dl._plugins.slice(0);r.reverse(),r.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};qf._plugins=[];let Zf=qf;$.handleByList(U.Application,Zf._plugins);class Kf{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let e,r;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,r=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,r=n}this.renderer.resize(e,r),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Kf.extension=U.Application;$.add(Kf);const qc={loader:U.LoadParser,resolver:U.ResolveParser,cache:U.CacheParser,detection:U.DetectionParser};$.handle(U.Asset,i=>{const t=i.ref;Object.entries(qc).filter(([e])=>!!t[e]).forEach(([e,r])=>$.add(Object.assign(t[e],{extension:t[e].extension??r})))},i=>{const t=i.ref;Object.keys(qc).filter(e=>!!t[e]).forEach(e=>$.remove(t[e]))});class Tb{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let r=0;r<e;r++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}function Mi(i,t){if(Array.isArray(t)){for(const e of t)if(i.startsWith(`data:${e}`))return!0;return!1}return i.startsWith(`data:${t}`)}function gr(i,t){const e=i.split("?")[0],r=At.extname(e).toLowerCase();return Array.isArray(t)?t.includes(r):r===t}const le=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(r=>typeof r=="string"||e?t(r):r):i),fl=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i};function Jf(i,t,e,r,s){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];
866e<t.length-1?Jf(i.replace(r[e],a),t,e+1,r,s):s.push(i.replace(r[e],a))}}function Eb(i){const t=/\{(.*?)\}/g,e=i.match(t),r=[];if(e){const s=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),Jf(i,s,0,e,r)}else r.push(i);return r}const On=i=>!Array.isArray(i);class Ab{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const r=le(t);let s;for(let a=0;a<this.parsers.length;a++){const l=this.parsers[a];if(l.test(e)){s=l.getCacheableAssets(r,e);break}}s||(s={},r.forEach(a=>{s[a]=e}));const n=Object.keys(s),o={cacheKeys:n,keys:r};if(r.forEach(a=>{this._cacheMap.set(a,o)}),n.forEach(a=>{this._cache.has(a)&&this._cache.get(a)!==e&&console.warn("[Cache] already has key:",a),this._cache.set(a,s[a])}),e instanceof W){const a=e;r.forEach(l=>{a.baseTexture!==W.EMPTY.baseTexture&&Q.addToCache(a.baseTexture,l),W.addToCache(a,l)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(r=>{this._cache.delete(r)}),e.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const Mr=new Ab;class Sb{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,r)=>(this._parsersValidated=!1,t[e]=r,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const r={promise:null,parser:null};return r.promise=(async()=>{let s=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let o=0;o<this.parsers.length;o++){const a=this.parsers[o];if(a.load&&a.test?.(t,e,this)){n=a;break}}if(!n)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(t,e,this),r.parser=n;for(let o=0;o<this.parsers.length;o++){const a=this.parsers[o];a.parse&&a.parse&&await a.testParse?.(s,e,this)&&(s=await a.parse(s,e,this)||s,r.parser=a)}return s})(),r}async load(t,e){this._parsersValidated||this._validateParsers();let r=0;const s={},n=On(t),o=le(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const c=At.toAbsolute(h.src);if(!s[h.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,h)),s[h.src]=await this.promiseCache[c].promise,e&&e(++r/a)}catch(u){throw delete this.promiseCache[c],delete s[h.src],new Error(`[Loader.load] Failed to load ${c}. 867${u}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=le(t,r=>({alias:[r],src:r})).map(async r=>{const s=At.toAbsolute(r.src),n=this.promiseCache[s];if(n){const o=await n.promise;delete this.promiseCache[s],n.parser?.unload?.(o,r,this)}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(t[e.name]&&console.warn(`[Assets] loadParser name conflict "${e.name}"`),{...t,[e.name]:e}),{})}}var de=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(de||{});const Cb=".json",Ib="application/json",Rb={extension:{type:U.LoadParser,priority:de.Low},name:"loadJson",test(i){return Mi(i,Ib)||gr(i,Cb)},async load(i){return await(await H.ADAPTER.fetch(i)).json()}};$.add(Rb);const Pb=".txt",Mb="text/plain",Bb={name:"loadTxt",extension:{type:U.LoadParser,priority:de.Low},test(i){return Mi(i,Mb)||gr(i,Pb)},async load(i){return await(await H.ADAPTER.fetch(i)).text()}};$.add(Bb);const kb=["normal","bold","100","200","300","400","500","600","700","800","900"],Db=[".ttf",".otf",".woff",".woff2"],Fb=["font/ttf","font/otf","font/woff","font/woff2"],Ob=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Nb(i){const t=At.extname(i),e=At.basename(i,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let r=e.length>0;for(const n of e)if(!n.match(Ob)){r=!1;break}let s=e.join(" ");return r||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const Lb=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Ub(i){return Lb.test(i)?i:encodeURI(i)}const Gb={extension:{type:U.LoadParser,priority:de.Low},name:"loadWebFont",test(i){return Mi(i,Fb)||gr(i,Db)},async load(i,t){const e=H.ADAPTER.getFontFaceSet();if(e){const r=[],s=t.data?.family??Nb(i),n=t.data?.weights?.filter(a=>
867kb.includes(a))??["normal"],o=t.data??{};for(let a=0;a<n.length;a++){const l=n[a],h=new FontFace(s,`url(${Ub(i)})`,{...o,weight:l});await h.load(),e.add(h),r.push(h)}return r.length===1?r[0]:r}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(i){(Array.isArray(i)?i:[i]).forEach(t=>H.ADAPTER.getFontFaceSet().delete(t))}};$.add(Gb);let Zc=0,ta;const Hb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=",zb={id:"checkImageBitmap",code:` 868 async function checkImageBitmap() 869 { 870 try 871 { 872 if (typeof createImageBitmap !== 'function') return false; 873 874 const response = await fetch('${Hb}'); 875 const imageBlob = await response.blob(); 876 const imageBitmap = await createImageBitmap(imageBlob); 877 878 return imageBitmap.width === 1 && imageBitmap.height === 1; 879 } 880 catch (e) 881 { 882 return false; 883 } 884 } 885 checkImageBitmap().then((result) => { self.postMessage(result); }); 886 `},Xb={id:"loadImageBitmap",code:` 887 async function loadImageBitmap(url) 888 { 889 const response = await fetch(url); 890 891 if (!response.ok) 892 { 893 throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \` 894 + \`\${response.status} \${response.statusText}\`); 895 } 896 897 const imageBlob = await response.blob(); 898 const imageBitmap = await createImageBitmap(imageBlob); 899 900 return imageBitmap; 901 } 902 self.onmessage = async (event) => 903 { 904 try 905 { 906 const imageBitmap = await loadImageBitmap(event.data.data[0]); 907 908 self.postMessage({ 909 data: imageBitmap, 910 uuid: event.data.uuid, 911 id: event.data.id, 912 }, [imageBitmap]); 913 } 914 catch(e) 915 { 916 self.postMessage({ 917 error: e, 918 uuid: event.data.uuid, 919 id: event.data.id, 920 }); 921 } 922 };`};let ea;class Vb{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const e=URL.createObjectURL(new Blob([zb.code],{type:"application/javascript"})),r=new Worker(e);r.addEventListener("message",s=>{r.terminate(),URL.revokeObjectURL(e),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){ta===void 0&&(ta=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<ta&&(ea||(ea=URL.createObjectURL(new Blob([Xb.code],{type:"application/javascript"}))),this._createdWorkers++,t=new Worker(ea),t.addEventListener("message",e=>{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const r=new Promise((s,n)=>{this.queue.push({id:t,arguments:e,resolve:s,reject:n})});return this.next(),r}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),r=e.id;this.resolveHash[Zc]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Zc++,id:r})}}const Kc=new Vb;function us(i,t,e){i.resource.internal=!0;const r=new W(i),s=()=>{delete t.promiseCache[e],Mr.has(e)&&Mr.remove(e)};return r.baseTexture.once("destroyed",()=>{e in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),s())}),r.once("destroyed",()=>{i.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),s())}),r}const Wb=[".jpeg",".jpg",".png",".webp",".avif"],$b=["image/jpeg","image/png","image/webp","image/avif"];async function jb(i){const t=await H.ADAPTER.fetch(i);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const io={name:"loadTextures",extension:{type:U.LoadParser,priority:de.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(i){return Mi(i,$b)||gr(i,Wb)},async load(i,t,e){const r=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;r?this.config.preferWorkers&&await Kc.isImageBitmapSupported()?s=await Kc.loadImageBitmap(i):s=await jb(i):s=await new Promise((a,l)=>{const h=new Image;
922h.crossOrigin=this.config.crossOrigin,h.src=i,h.complete?a(h):(h.onload=()=>a(h),h.onerror=c=>l(c))});const n={...t.data};n.resolution??(n.resolution=Ve(i)),r&&n.resourceOptions?.ownsImageBitmap===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const o=new Q(s,n);return o.resource.src=i,us(o,e,i)},unload(i){i.destroy(!0)}};$.add(io);const Yb=".svg",qb="image/svg+xml",Zb={extension:{type:U.LoadParser,priority:de.High},name:"loadSVG",test(i){return Mi(i,qb)||gr(i,Yb)},async testParse(i){return il.test(i)},async parse(i,t,e){const r=new il(i,t?.data?.resourceOptions);await r.load();const s=new Q(r,{resolution:Ve(i),...t?.data});return s.resource.src=t.src,us(s,e,t.src)},async load(i,t){return(await H.ADAPTER.fetch(i)).text()},unload:io.unload};$.add(Zb);const Kb=[".mp4",".m4v",".webm",".ogv"],Jb=["video/mp4","video/webm","video/ogg"],Qb={name:"loadVideo",extension:{type:U.LoadParser,priority:de.High},config:{defaultAutoPlay:!0},test(i){return Mi(i,Jb)||gr(i,Kb)},async load(i,t,e){let r;const s=await(await H.ADAPTER.fetch(i)).blob(),n=URL.createObjectURL(s);try{const o={autoPlay:this.config.defaultAutoPlay,...t?.data?.resourceOptions},a=new Wf(n,o);await a.load();const l=new Q(a,{alphaMode:await n1(),resolution:Ve(i),...t?.data});l.resource.src=i,r=us(l,e,i),r.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(o){throw URL.revokeObjectURL(n),o}return r},unload(i){i.destroy(!0)}};$.add(Qb);class tx{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(r=>`${encodeURIComponent(r)}=${encodeURIComponent(e[r])}`).join("&")}}getAlias(t){const{alias:e,name:r,src:s,srcs:n}=t;return le(e||r||s||n,o=>typeof o=="string"?o:Array.isArray(o)?o.map(a=>a?.src??a?.srcs??a):o?.src||o?.srcs?o.src??o.srcs:o,!0)}addManifest(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const r=[];Array.isArray(e)?e.forEach(s=>{const n=s.src??s.srcs,o=s.alias??s.name;let a;if(typeof o=="string"){const l=this._createBundleAssetId(t,o);r.push(l),a=[o,l]}else{const l=o.map(h=>this._createBundleAssetId(t,h));r.push(...l),a=[...o,...l]}this.add({...s,alias:a,src:n})}):Object.keys(e).forEach(s=>{const n=[s,this._createBundleAssetId(t,s)];if(typeof e[s]=="string")this.add({alias:n,src:e[s]});else if(Array.isArray(e[s]))this.add({alias:n,src:e[s]});else{const o=e[s],a=o.src??o.srcs;this.add({...o,alias:n,src:Array.isArray(a)?a:[a]})}r.push(...n)}),this._bundles[t]=r}add(t,e,r,s,n){const o=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(rt("7.2.0",`Assets.add now uses an object instead of individual parameters. 923Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:t,src:e,data:r,format:s,loadParser:n})):Array.isArray(t)?o.push(...t):o.push(t);let a;a=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)}
923,le(o).forEach(l=>{const{src:h,srcs:c}=l;let{data:u,format:d,loadParser:f}=l;const p=le(h||c).map(m=>typeof m=="string"?Eb(m):Array.isArray(m)?m:[m]),g=this.getAlias(l);Array.isArray(g)?g.forEach(a):a(g);const y=[];p.forEach(m=>{m.forEach(v=>{let _={};if(typeof v!="object"){_.src=v;for(let b=0;b<this._parsers.length;b++){const w=this._parsers[b];if(w.test(v)){_=w.parse(v);break}}}else u=v.data??u,d=v.format??d,f=v.loadParser??f,_={..._,...v};if(!g)throw new Error(`[Resolver] alias is undefined for this asset: ${_.src}`);_=this.buildResolvedAsset(_,{aliases:g,data:u,format:d,loadParser:f}),y.push(_)})}),g.forEach(m=>{this._assetMap[m]=y})})}resolveBundle(t){const e=On(t);t=le(t);const r={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(s,l)]=h}r[s]=a}}),e?r[t[0]]:r}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const r={};for(const s in e)r[s]=e[s].src;return r}return e.src}resolve(t){const e=On(t);t=le(t);const r={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=n[0],a=this._getPreferredOrder(n);a?.priority.forEach(l=>{a.params[l].forEach(h=>{const c=n.filter(u=>u[l]?u[l]===h:!1);c.length&&(n=c)})}),this._resolverHash[s]=n[0]??o}else this._resolverHash[s]=this.buildResolvedAsset({alias:[s],src:s},{});r[s]=this._resolverHash[s]}),e?r[t[0]]:r}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const r=t[0],s=this._preferredOrder.find(n=>n.params.format.includes(r.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}buildResolvedAsset(t,e){const{aliases:r,data:s,loadParser:n,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=At.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=r??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.format=o??At.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class ex{constructor(){this._detections=[],this._initialized=!1,this.resolver=new tx,this.loader=new Sb,this.cache=Mr,this._backgroundLoader=new Tb(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Asset.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let n=t.manifest;typeof n=="string"&&(n=await this.load(n)),this.resolver.addManifest(n)}const e=t.texturePreference?.resolution??1,r=typeof e=="number"?[e]:e,s=await this._detectFormats({preferredFormats:t.texturePreference?.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:r}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,r,s,n){this.resolver.add(t,e,r,s,n)}async load(t,e){this._initialized||await this.init();const r=On(t),s=le(t).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(h=>!this.resolver.hasKey(h))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(s),o=await this._mapLoadToResolve(n,e);return r?o[s[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let r=!1;typeof t=="string"&&(r=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},o=Object.keys(s);let a=0,l=0;const h=()=>{e?.(++a/l)},c=o.map(u=>{const d=s[u];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(f=>{n[u]=f})});return await Promise.all(c),r?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(r=>{this._backgroundLoader.add(Object.values(r))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Mr.get(t);const e={};for(let r=0;r<t.length;r++)e[r]=Mr.get(t[r]);return e}async _mapLoadToResolve(t,e){const r=Object.values(t),s=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(r,e);this._backgroundLoader.active=!0;const o={};return r.forEach((a,l)=>{const h=n[a.src],c=[a.src];a.alias&&c.push(...a.alias),o[s[l]]=h,Mr.set(c,h)}),o}async unload(t){this._initialized||await this.init();const e=le(t).map(s=>
923typeof s!="string"?s.src:s),r=this.resolver.resolve(e);await this._unloadFromResolved(r)}async unloadBundle(t){this._initialized||await this.init(),t=le(t);const e=this.resolver.resolveBundle(t),r=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(r)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(r=>{Mr.remove(r.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const r of t.detections)t.skipDetections||await r.test()?e=await r.add(e):t.skipDetections||(e=await r.remove(e));return e=e.filter((r,s)=>e.indexOf(r)===s),e}get detections(){return this._detections}get preferWorkers(){return io.config.preferWorkers}set preferWorkers(t){rt("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:t})}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(r=>r in t).forEach(r=>{e.config[r]=t[r]})})}}const Ps=new ex;$.handleByList(U.LoadParser,Ps.loader.parsers).handleByList(U.ResolveParser,Ps.resolver.parsers).handleByList(U.CacheParser,Ps.cache.parsers).handleByList(U.DetectionParser,Ps.detections);const rx={extension:U.CacheParser,test:i=>Array.isArray(i)&&i.every(t=>t instanceof W),getCacheableAssets:(i,t)=>{const e={};return i.forEach(r=>{t.forEach((s,n)=>{e[r+(n===0?"":n+1)]=s})}),e}};$.add(rx);async function Qf(i){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=i});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(i)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const ix={extension:{type:U.DetectionParser,priority:1},test:async()=>Qf("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")};$.add(ix);const sx={extension:{type:U.DetectionParser,priority:0},test:async()=>Qf("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async i=>[...i,"webp"],remove:async i=>i.filter(t=>t!=="webp")};$.add(sx);const Jc=["png","jpg","jpeg"],nx={extension:{type:U.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...Jc],remove:async i=>i.filter(t=>!Jc.includes(t))};$.add(nx);const ox="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function th(i){return ox?!1:document.createElement("video").canPlayType(i)!==""}const ax={extension:{type:U.DetectionParser,priority:0},test:async()=>th("video/webm"),add:async i=>[...i,"webm"],remove:async i=>i.filter(t=>t!=="webm")};$.add(ax);const lx={extension:{type:U.DetectionParser,priority:0},test:async()=>th("video/mp4"),add:async i=>[...i,"mp4","m4v"],remove:async i=>i.filter(t=>t!=="mp4"&&t!=="m4v")};$.add(lx);const hx={extension:{type:U.DetectionParser,priority:0},test:async()=>th("video/ogg"),add:async i=>[...i,"ogv"],remove:async i=>i.filter(t=>t!=="ogv")};$.add(hx);const cx={extension:U.ResolveParser,test:io.test,parse:i=>({resolution:parseFloat(H.RETINA_PREFIX.exec(i)?.[1]??"1"),format:At.extname(i).slice(1),src:i})};$.add(cx);var Wt=(i=>(i[i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",i[i.COMPRESSED_R11_
923EAC=37488]="COMPRESSED_R11_EAC",i[i.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",i[i.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",i[i.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",i[i.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",i[i.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",i[i.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",i[i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",i[i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",i[i.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",i[i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",i))(Wt||{});const Nn={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35986:1,34798:1,37808:1};let Fe,hi;function Qc(){hi={s3tc:Fe.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Fe.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:Fe.getExtension("WEBGL_compressed_texture_etc"),etc1:Fe.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:Fe.getExtension("WEBGL_compressed_texture_pvrtc")||Fe.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:Fe.getExtension("WEBGL_compressed_texture_atc"),astc:Fe.getExtension("WEBGL_compressed_texture_astc")}}const ux={extension:{type:U.DetectionParser,priority:2},test:async()=>{const i=H.ADAPTER.createCanvas().getContext("webgl");return i?(Fe=i,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async i=>{hi||Qc();const t=[];for(const e in hi)hi[e]&&t.push(e);return[...t,...i]},remove:async i=>(hi||Qc(),i.filter(t=>!(t in hi)))};$.add(ux);class dx extends Jn{constructor(t,e={width:1,height:1,autoLoad:!0}){let r,s;typeof t=="string"?(r=t,s=new Uint8Array):(r=null,s=t),super(s,e),this.origin=r,this.buffer=s?new Va(s):null,this._load=null,this.loaded=!1,this.origin!==null&&e.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new Va(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Or extends dx{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=Or._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Or._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,r){const s=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;s.pixelStorei(s.UNPACK_ALIGNMENT,4);for(let n=0,o=this.levels;n<o;n++){const{levelID:a,levelWidth:l,levelHeight:h,levelBuffer:c}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,a,this.format,l,h,0,c)}return!0}onBlobLoaded(){this._levelBuffers=Or._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t>=36196)return"etc1";if(t>=35986&&t<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")}static _createLevelBuffers(t,e,r,s,n,o,a){const l=new Array(r);let h=t.byteOffset,c=o,u=a,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*Nn[e];for(let g=0;g<r;g++)l[g]={levelID:g,levelWidth:r>1?c:d,levelHeight:r>1?u:f,levelBuffer:new Uint8Array(t.buffer,h,p)},h+=p,c=c>>1||1,u=u>>1||1,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*Nn[e];return l}}const ra=4,Ms=124,fx=32,tu=20,px=542327876,Bs={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},mx={SIZE:0,FLAGS:1,FOURCC:2,RGB_BITCOUNT:3,R_BIT_MASK:4,G_BIT_MASK:5,B_BIT_MASK:6,A_BIT_MASK:7},ks={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},_x=1,gx=2,yx=4,vx=64,bx=512,xx=131072,wx=827611204,Tx=861165636,Ex=894720068,Ax=808540228,Sx=4,Cx={[wx]:Wt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Tx]:Wt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Ex]:Wt.COMPRESSED_RGBA_S3TC_DXT5_EXT},Ix={70:Wt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Wt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Wt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Wt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Wt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Wt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Wt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Wt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Wt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT};function Rx(i){const t=new Uint32Array(i);if(t[0]!==px)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(i,0,Ms/Uint32Array.BYTES_PER_ELEMENT),r=e[Bs.HEIGHT],s=e[Bs.WIDTH],n=e[Bs.MIPMAP_COUNT],o=new Uint32Array(i,Bs.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,fx/Uint32Array.BYTES_PER_ELEMENT),a=o[_x];if(a&yx){const l=o[mx.FOURCC];if(l!==Ax){const v=Cx[l],_=ra+Ms,b=new Uint8Array(i,_);return[new Or(b,{format:v,width:s,height:r,levels:n})]}const h=ra+Ms,c=new Uint32Array(t.buffer,h,tu/Uint32Array.BYTES_PER_ELEMENT),u=c[ks.DXGI_FORMAT],d=c[ks.RESOURCE_DIMENSION],f=c[ks.MISC_FLAG],p=c[
923ks.ARRAY_SIZE],g=Ix[u];if(g===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${u}`);if(f===Sx)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const y=new Array,m=ra+Ms+tu;if(p===1)y.push(new Uint8Array(i,m));else{const v=Nn[g];let _=0,b=s,w=r;for(let x=0;x<n;x++){const C=Math.max(1,b+3&-4),T=Math.max(1,w+3&-4),P=C*T*v;_+=P,b=b>>>1,w=w>>>1}let A=m;for(let x=0;x<p;x++)y.push(new Uint8Array(i,A,_)),A+=_}return y.map(v=>new Or(v,{format:g,width:s,height:r,levels:n}))}throw a&vx?new Error("DDSParser does not support uncompressed texture data."):a&bx?new Error("DDSParser does not supported YUV uncompressed texture data."):a&xx?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&gx?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const eu=[171,75,84,88,32,49,49,187,13,10,26,10],Px=67305985,se={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},pl=64,ru={[q.UNSIGNED_BYTE]:1,[q.UNSIGNED_SHORT]:2,[q.INT]:4,[q.UNSIGNED_INT]:4,[q.FLOAT]:4,[q.HALF_FLOAT]:8},Mx={[F.RGBA]:4,[F.RGB]:3,[F.RG]:2,[F.RED]:1,[F.LUMINANCE]:1,[F.LUMINANCE_ALPHA]:2,[F.ALPHA]:1},Bx={[q.UNSIGNED_SHORT_4_4_4_4]:2,[q.UNSIGNED_SHORT_5_5_5_1]:2,[q.UNSIGNED_SHORT_5_6_5]:2};function kx(i,t,e=!1){const r=new DataView(t);if(!Dx(i,r))return null;const s=r.getUint32(se.ENDIANNESS,!0)===Px,n=r.getUint32(se.GL_TYPE,s),o=r.getUint32(se.GL_FORMAT,s),a=r.getUint32(se.GL_INTERNAL_FORMAT,s),l=r.getUint32(se.PIXEL_WIDTH,s),h=r.getUint32(se.PIXEL_HEIGHT,s)||1,c=r.getUint32(se.PIXEL_DEPTH,s)||1,u=r.getUint32(se.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=r.getUint32(se.NUMBER_OF_FACES,s),f=r.getUint32(se.NUMBER_OF_MIPMAP_LEVELS,s),p=r.getUint32(se.BYTES_OF_KEY_VALUE_DATA,s);if(h===0||c!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(u!==1)throw new Error("WebGL does not support array textures");const g=4,y=4,m=l+3&-4,v=h+3&-4,_=new Array(u);let b=l*h;n===0&&(b=m*v);let w;if(n!==0?ru[n]?w=ru[n]*Mx[o]:w=Bx[n]:w=Nn[a],w===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const A=e?Ox(r,p,s):null;let x=b*w,C=l,T=h,P=m,M=v,B=pl+p;for(let S=0;S<f;S++){const I=r.getUint32(B,s);let k=B+4;for(let V=0;V<u;V++){let O=_[V];O||(O=_[V]=new Array(f)),O[S]={levelID:S,levelWidth:f>1||n!==0?C:P,levelHeight:f>1||n!==0?T:M,levelBuffer:new Uint8Array(t,k,x)},k+=x}B+=I+4,B=B%4!==0?B+4-B%4:B,C=C>>1||1,T=T>>1||1,P=C+g-1&~(g-1),M=T+y-1&~(y-1),x=P*M*w}return n!==0?{uncompressed:_.map(S=>{let I=S[0].levelBuffer,k=!1;return n===q.FLOAT?I=new Float32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4):n===q.UNSIGNED_INT?(k=!0,I=new Uint32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4)):n===q.INT&&(k=!0,I=new Int32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4)),{resource:new Jn(I,{width:S[0].levelWidth,height:S[0].levelHeight}),type:n,format:k?Fx(o):o}}),kvData:A}:{compressed:_.map(S=>new Or(null,{format:a,width:l,height:h,levels:f,levelBuffers:S})),kvData:A}}function Dx(i,t){for(let e=0;e<eu.length;e++)if(t.getUint8(e)!==eu[e])return console.error(`${i} is not a valid *.ktx file!`),!1;return!0}function Fx(i){switch(i){case F.RGBA:return F.RGBA_INTEGER;case F.RGB:return F.RGB_INTEGER;case F.RG:return F.RG_INTEGER;case F.RED:return F.RED_INTEGER;default:return i}}function Ox(i,t,e){const r=new Map;let s=0;for(;s<t;){const n=i.getUint32(pl+s,e),o=pl+s+4,a=3-(n+3)%4;if(n===0||n>t-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<n&&i.getUint8(o+l)!==0;l++);if(l===-1){console.error("KTXLoader: Failed to find null byte terminating
923kvData key");break}const h=new TextDecoder().decode(new Uint8Array(i.buffer,o,l)),c=new DataView(i.buffer,o+l+1,n-l-1);r.set(h,c),s+=4+n+a}return r}const Nx={extension:{type:U.LoadParser,priority:de.High},name:"loadDDS",test(i){return gr(i,".dds")},async load(i,t,e){const r=await(await H.ADAPTER.fetch(i)).arrayBuffer(),s=Rx(r).map(n=>{const o=new Q(n,{mipmap:Ie.OFF,alphaMode:Ht.NO_PREMULTIPLIED_ALPHA,resolution:Ve(i),...t.data});return us(o,e,i)});return s.length===1?s[0]:s},unload(i){Array.isArray(i)?i.forEach(t=>t.destroy(!0)):i.destroy(!0)}};$.add(Nx);const Lx={extension:{type:U.LoadParser,priority:de.High},name:"loadKTX",test(i){return gr(i,".ktx")},async load(i,t,e){const r=await(await H.ADAPTER.fetch(i)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=kx(i,r),a=s??n,l={mipmap:Ie.OFF,alphaMode:Ht.NO_PREMULTIPLIED_ALPHA,resolution:Ve(i),...t.data},h=a.map(c=>{a===n&&Object.assign(l,{type:c.type,format:c.format});const u=c.resource??c,d=new Q(u,l);return d.ktxKeyValueData=o,us(d,e,i)});return h.length===1?h[0]:h},unload(i){Array.isArray(i)?i.forEach(t=>t.destroy(!0)):i.destroy(!0)}};$.add(Lx);const Ux={extension:U.ResolveParser,test:i=>{const t=At.extname(i).slice(1);return["basis","ktx","dds"].includes(t)},parse:i=>{const t=At.extname(i).slice(1);if(t==="ktx"){const e=[".s3tc.ktx",".s3tc_sRGB.ktx",".etc.ktx",".etc1.ktx",".pvrt.ktx",".atc.ktx",".astc.ktx"];if(e.some(r=>i.endsWith(r)))return{resolution:parseFloat(H.RETINA_PREFIX.exec(i)?.[1]??"1"),format:e.find(r=>i.endsWith(r)),src:i}}return{resolution:parseFloat(H.RETINA_PREFIX.exec(i)?.[1]??"1"),format:t,src:i}}};$.add(Ux);const Ds=new K,Gx=4,tp=class Wi{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){const t=this.renderer?.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(t,e,r,s){const n=new Image;return n.src=await this.base64(t,e,r,s),n}async base64(t,e,r,s){const n=this.canvas(t,s);if(n.toBlob!==void 0)return new Promise((o,a)=>{n.toBlob(l=>{if(!l){a(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>o(h.result),h.onerror=a,h.readAsDataURL(l)},e,r)});if(n.toDataURL!==void 0)return n.toDataURL(e,r);if(n.convertToBlob!==void 0){const o=await n.convertToBlob({type:e,quality:r});return new Promise((a,l)=>{const h=new FileReader;h.onload=()=>a(h.result),h.onerror=l,h.readAsDataURL(o)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const{pixels:r,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);o&&Wi._flipY(r,s,n),a&&Wi._unpremultiplyAlpha(r);const l=new x1(s,n,1),h=new ImageData(new Uint8ClampedArray(r.buffer),s,n);return l.context.putImageData(h,0,0),l.canvas}pixels(t,e){const{pixels:r,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);return o&&Wi._flipY(r,s,n),a&&Wi._unpremultiplyAlpha(r),r}_rawPixels(t,e){const r=this.renderer;if(!r)throw new Error("The Extract has already been destroyed");let s,n=!1,o=!1,a,l=!1;t&&(t instanceof Ft?a=t:(a=r.generateTexture(t,{region:e,resolution:r.resolution,multisample:r.multisample}),l=!0,e&&(Ds.width=e.width,Ds.height=e.height,e=Ds)));const h=r.gl;if(a){if(s=a.baseTexture.resolution,e=e??a.frame,n=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===F.RGBA,!l){r.renderTexture.bind(a);const f=a.framebuffer.glFramebuffers[r.CONTEXT_UID];f.blitFramebuffer&&r.framebuffer.bind(f.blitFramebuffer)}}else s=r.resolution,e||(e=Ds,e.width=r.width/s,e.height=r.height/s),n=!0,o=this._rendererPremultipliedAlpha,r.renderTexture.bind();const c=Math.max(Math.round(e.width*s),1),u=Math.max(Math.round(e.height*s),1),d=new Uint8Array(Gx*c*u);return h.readPixels(Math.round(e.x*s),Math.round(e.y*s),c,u,h.RGBA,h.UNSIGNED_BYTE,d),l&&a?.destroy(!0),{pixels:d,width:c,height:u,flipY:n,premultipliedAlpha:o}}destroy(){this.renderer=null}static _flipY(t,e,r){const s=e<<2,n=r>>1,o=new Uint8Array(s);for(let a=0;a<n;a++){const l=a*s,h=(r-a-1)*s;o.set(t.subarray(l,l+s)),t.copyWithin(l,h,h+s),t.set(o,h)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let r=0;r<e;r+=4){const s=t[r+3];if(s!==0){const n=255.001/s;t[r]=t[r]*n+.5,t[r+1]=t[r+1]*n+.5,t[r+2]=t[r+2]*n+.5}}}};tp.extension={name:"extract",type:U.RendererSystem};let Hx=tp;$.add(Hx);const Ln={build(i){const t=i.points;let e,r,s,n,o,a;if(i.type===Pt.CIRC){const p=i.shape;e=p.x,r=p.y,o=a=p.radius,s=n=0}else if(i.type===Pt.ELIP){const p=i.shape;e=p.x,r=p.y,o=p.width,a=p.height,s=n=0}else{const p=i.shape,g=p.width/2,y=p.height/2;e=p.x+g,r=p.y+y,o=a=Math.max(0,Math.min(p.radius,Math.min(g,y))),s=g-o,n=y-a}if(!(o>=0&&a>=0&&s>=0&&n>=0)){t.length=0;return}const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(s?4:0)+(n?4:0);if(t.length=h,h===0)return;if(l===0){t.length=8,t[0]=t[6]=e+s,t[1]=t[3]=r+n,t[2]=t[4]=e-s,t[5]=t[7]=r-n;return}let c=0,u=l*4+(s?2:0)+2,d=u,f=h;{const p=s+o,g=n,y=e+p,m=e-p,v=r+g;if(t[c++]=y,t[c++]=v,t[--u]=v,t[--u]=m,n){const _=r-g;t[d++]=m,t[d++]=_,t[--f]=_,t[--f]=y}}for(let p=1;p<l;p++){const g=Math.PI/2*(p/l),y=s+Math.cos(g)*o,m=n+Math.sin(g)*a,v=e+y,_=e-y,b=r+m,w=r-m;t[c++]=v,t[c++]=b,t[--u]=b,t[--u]=_,t[d++]=_,t[d++]=w,t[--f]=w,t[--f]=v}{const p=s,g=n+a,y=e+p,m=e-p,v=r+g,_=r-g;t[c++]=y,t[c++]=v,t[--f]=_,t[--f]=y,s&&(t[c++]=m,t[c++]=v,t[--f]=_,t[--f]=m)}},triangulate(i,t){const e=i.points,r=t.points,s=t.indices;if(e.length===0)return;let n=r.length/2;const o=n;let a,l;if(i.type!==Pt.RREC){const c=i.shape;a=c.x,l=c.y}else{const c=i.shape;a=c.x+c.width/2,l=c.y+c.height/2}const h=i.matrix;r.push(i.matrix?h.a*a+h.c*l+h.tx:a,i.matrix?h.b*a+h.d*l+h.ty:l),n++,r.push(e[0],e[1]);for(let c=2;c<e.length;c+=2)r.push(e[c],e[c+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function iu(i,t=!1){const e=i.length;if(e<6)return;let r=0;for(let s=0,n=i[e-2],o=i[e-1];s<e;s+=2){const a=i[s],l=i[s+1];r+=(a-n)*(l+o),n=a,o=l}if(!t&&r>0||t&&r<=0){const s=e/2;for(let n=s+s%2;n<e;n+=2){const o=e-n-2,a=e-n-1,l=n,h=n+1;[i[o],i[l]]=[i[l],i[o]],[i[a],i[h]]=[i[h],i[a]]}}}const ep={build(i){i.points=i.shape.points.slice()},triangulate(i,t){let e=i.points;const r=i.holes,s=t.points,n=t.indices;if(e.length>=6){iu(e,!1);const o=[];for(let h=0;h<r.length;h++){const c=r[h];iu(c.points,!0),o.push(e.length/2),e=e.concat(c.points)}const a=Lg(e,o,2);if(!a)return;const l=s.length/2;for(let h=0;h<a.length;h+=3)n.push(a[h]+l),n.push(a[h+1]+l),n.push(a[h+2]+l);for(let h=0;h<e.length;h++)s.push(e[h])}}},zx={build(i){const t=i.shape,e=t.x,r=t.y,s=t.width,n=t.height,o=i.points;o.length=0,s>=0&&n>=0&&o.push(e,r,e+s,r,e+s,r+n,e,r+n)},triangulate(i,t){const e=i.points,r=t.points;if(e.length===0)return;const s=r.length/2;r.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},Xx={build(i){Ln.build(i)}
923,triangulate(i,t){Ln.triangulate(i,t)}};var Kt=(i=>(i.MITER="miter",i.BEVEL="bevel",i.ROUND="round",i))(Kt||{}),ir=(i=>(i.BUTT="butt",i.ROUND="round",i.SQUARE="square",i))(ir||{});const Si={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(i,t=20){if(!this.adaptive||!i||isNaN(i))return t;let e=Math.ceil(i/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class su{static curveTo(t,e,r,s,n,o){const a=o[o.length-2],l=o[o.length-1]-e,h=a-t,c=s-e,u=r-t,d=Math.abs(l*u-h*c);if(d<1e-8||n===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const f=l*l+h*h,p=c*c+u*u,g=l*c+h*u,y=n*Math.sqrt(f)/d,m=n*Math.sqrt(p)/d,v=y*g/f,_=m*g/p,b=y*u+m*h,w=y*c+m*l,A=h*(m+v),x=l*(m+v),C=u*(y+_),T=c*(y+_),P=Math.atan2(x-w,A-b),M=Math.atan2(T-w,C-b);return{cx:b+t,cy:w+e,radius:n,startAngle:P,endAngle:M,anticlockwise:h*c>u*l}}static arc(t,e,r,s,n,o,a,l,h){const c=a-o,u=Si._segmentsCount(Math.abs(c)*n,Math.ceil(Math.abs(c)/Rn)*40),d=c/(u*2),f=d*2,p=Math.cos(d),g=Math.sin(d),y=u-1,m=y%1/y;for(let v=0;v<=y;++v){const _=v+m*v,b=d+o+f*_,w=Math.cos(b),A=-Math.sin(b);h.push((p*w+g*A)*n+r,(p*-A+g*w)*n+s)}}}class Vx{constructor(){this.reset()}begin(t,e,r){this.reset(),this.style=t,this.start=e,this.attribStart=r}end(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class eh{static curveLength(t,e,r,s,n,o,a,l){let h=0,c=0,u=0,d=0,f=0,p=0,g=0,y=0,m=0,v=0,_=0,b=t,w=e;for(let A=1;A<=10;++A)c=A/10,u=c*c,d=u*c,f=1-c,p=f*f,g=p*f,y=g*t+3*p*c*r+3*f*u*n+d*a,m=g*e+3*p*c*s+3*f*u*o+d*l,v=b-y,_=w-m,b=y,w=m,h+=Math.sqrt(v*v+_*_);return h}static curveTo(t,e,r,s,n,o,a){const l=a[a.length-2],h=a[a.length-1];a.length-=2;const c=Si._segmentsCount(eh.curveLength(l,h,t,e,r,s,n,o));let u=0,d=0,f=0,p=0,g=0;a.push(l,h);for(let y=1,m=0;y<=c;++y)m=y/c,u=1-m,d=u*u,f=d*u,p=m*m,g=p*m,a.push(f*l+3*d*m*t+3*u*p*r+g*n,f*h+3*d*m*e+3*u*p*s+g*o)}}function nu(i,t,e,r,s,n,o,a){const l=i-e*s,h=t-r*s,c=i+e*n,u=t+r*n;let d,f;o?(d=r,f=-e):(d=-r,f=e);const p=l+d,g=h+f,y=c+d,m=u+f;return a.push(p,g,y,m),2}function xr(i,t,e,r,s,n,o,a){const l=e-i,h=r-t;
923let c=Math.atan2(l,h),u=Math.atan2(s-i,n-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),g=Math.sqrt(l*l+h*h),y=(15*p*Math.sqrt(g)/Math.PI>>0)+1,m=f/y;if(d+=m,a){o.push(i,t,e,r);for(let v=1,_=d;v<y;v++,_+=m)o.push(i,t,i+Math.sin(_)*g,t+Math.cos(_)*g);o.push(i,t,s,n)}else{o.push(e,r,i,t);for(let v=1,_=d;v<y;v++,_+=m)o.push(i+Math.sin(_)*g,t+Math.cos(_)*g,i,t);o.push(s,n,i,t)}return y*2}function Wx(i,t){const e=i.shape;let r=i.points||e.points.slice();const s=t.closePointEps;if(r.length===0)return;const n=i.lineStyle,o=new ot(r[0],r[1]),a=new ot(r[r.length-2],r[r.length-1]),l=e.type!==Pt.POLY||e.closeStroke,h=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;if(l){r=r.slice(),h&&(r.pop(),r.pop(),a.set(r[r.length-2],r[r.length-1]));const O=(o.x+a.x)*.5,et=(a.y+o.y)*.5;r.unshift(O,et),r.push(O,et)}const c=t.points,u=r.length/2;let d=r.length;const f=c.length/2,p=n.width/2,g=p*p,y=n.miterLimit*n.miterLimit;let m=r[0],v=r[1],_=r[2],b=r[3],w=0,A=0,x=-(v-b),C=m-_,T=0,P=0,M=Math.sqrt(x*x+C*C);x/=M,C/=M,x*=p,C*=p;const B=n.alignment,S=(1-B)*2,I=B*2;l||(n.cap===ir.ROUND?d+=xr(m-x*(S-I)*.5,v-C*(S-I)*.5,m-x*S,v-C*S,m+x*I,v+C*I,c,!0)+2:n.cap===ir.SQUARE&&(d+=nu(m,v,x,C,S,I,!0,c))),c.push(m-x*S,v-C*S,m+x*I,v+C*I);for(let O=1;O<u-1;++O){m=r[(O-1)*2],v=r[(O-1)*2+1],_=r[O*2],b=r[O*2+1],w=r[(O+1)*2],A=r[(O+1)*2+1],x=-(v-b),C=m-_,M=Math.sqrt(x*x+C*C),x/=M,C/=M,x*=p,C*=p,T=-(b-A),P=_-w,M=Math.sqrt(T*T+P*P),T/=M,P/=M,T*=p,P*=p;const et=_-m,E=v-b,R=_-w,L=A-b,Y=et*R+E*L,tt=E*R-L*et,J=tt<0;if(Math.abs(tt)<.001*Math.abs(Y)){c.push(_-x*S,b-C*S,_+x*I,b+C*I),Y>=0&&(n.join===Kt.ROUND?d+=xr(_,b,_-x*S,b-C*S,_-T*S,b-P*S,c,!1)+4:d+=2,c.push(_-T*I,b-P*I,_+T*S,b+P*S));continue}const st=(-x+m)*(-C+b)-(-x+_)*(-C+v),at=(-T+w)*(-P+b)-(-T+_)*(-P+A),ht=(et*at-R*st)/tt,yt=(L*st-E*at)/tt,wt=(ht-_)*(ht-_)+(yt-b)*(yt-b),D=_+(ht-_)*S,ct=b+(yt-b)*S,N=_-(ht-_)*I,lt=b-(yt-b)*I,Rt=Math.min(et*et+E*E,R*R+L*L),jt=J?S:I,yr=Rt+jt*jt*g,z=wt<=yr;let Tt=n.join;if(Tt===Kt.MITER&&wt/g>y&&(Tt=Kt.BEVEL),z)switch(Tt){case Kt.MITER:{c.push(D,ct,N,lt);break}case Kt.BEVEL:{J?c.push(D,ct,_+x*I,b+C*I,D,ct,_+T*I,b+P*I):c.push(_-x*S,b-C*S,N,lt,_-T*S,b-P*S,N,lt),d+=2;break}case Kt.ROUND:{J?(c.push(D,ct,_+x*I,b+C*I),d+=xr(_,b,_+x*I,b+C*I,_+T*I,b+P*I,c,!0)+4,c.push(D,ct,_+T*I,b+P*I)):(c.push(_-x*S,b-C*S,N,lt),d+=xr(_,b,_-x*S,b-C*S,_-T*S,b-P*S,c,!1)+4,c.push(_-T*S,b-P*S,N,lt));break}}else{switch(c.push(_-x*S,b-C*S,_+x*I,b+C*I),Tt){case Kt.MITER:{J?c.push(N,lt,N,lt):c.push(D,ct,D,ct),d+=2;break}case Kt.ROUND:{J?d+=xr(_,b,_+x*I,b+C*I,_+T*I,b+P*I,c,!0)+2:d+=xr(_,b,_-x*S,b-C*S,_-T*S,b-P*S,c,!1)+2;break}}c.push(_-T*S,b-P*S,_+T*I,b+P*I),d+=2}}m=r[(u-2)*2],v=r[(u-2)*2+1],_=r[(u-1)*2],b=r[(u-1)*2+1],x=-(v-b),C=m-_,M=Math.sqrt(x*x+C*C),x/=M,C/=M,x*=p,C*=p,c.push(_-x*S,b-C*S,_+x*I,b+C*I),l||(n.cap===ir.ROUND?d+=xr(_-x*(S-I)*.5,b-C*(S-I)*.5,_-x*S,b-C*S,_+x*I,b+C*I,c,!1)+2:n.cap===ir.SQUARE&&(d+=nu(_,b,x,C,S,I,!1,c)));const k=t.indices,V=Si.epsilon*Si.epsilon;for(let O=f;O<d+f-2;++O)m=c[O*2],v=c[O*2+1],_=c[(O+1)*2],b=c[(O+1)*2+1],w=c[(O+2)*2],A=c[(O+2)*2+1],!(Math.abs(m*(b-A)+_*(A-v)+w*(v-b))<V)&&k.push(O,O+1,O+2)}function $x(i,t){let e=0;const r=i.shape,s=i.points||r.points,n=r.type!==Pt.POLY||r.closeStroke;if(s.length===0)return;const o=t.points,a=t.indices,l=s.length/2,h=o.length/2;let c=h;for(o.push(s[0],s[1]),e=1;e<l;e++)o.push(s[e*2],s[e*2+1]),a.push(c,c+1),c++;n&&a.push(c,h)}function ou(i,t){i.lineStyle.native?$x(i,t):Wx(i,t)}class rh{static curveLength(t,e,r,s,n,o){const a=t-2*r+n,l=e-2*s+o,h=2*r-2*t,c=2*s-2*e,u=4*(a*a+l*l),d=4*(a*h+l*c),f=h*h+c*c,p=2*Math.sqrt(u+d+f),g=Math.sqrt(u),y=2*u*g,m=2*Math.sqrt(f),v=d/g;return(y*p+g*d*(p-m)+(4*f*u-d*d)*Math.log((2*g+v+p)/(v+m)))/(4*y)}static curveTo(t,e,r,s,n){const o=n[n.length-2],a=n[n.length-1],l=Si._segmentsCount(rh.curveLength(o,a,t,e,r,s));let h=0,c=0;for(let u=1;u<=l;++u){const d=u/l;h=o+(t-o)*d,c=a+(e-a)*d,n.push(h+(t+(r-t)*d-h)*d,c+(e+(s-e)*d-c)*d)}}}const ia={[Pt.POLY]:ep,[Pt.CIRC]:Ln,[Pt.ELIP]:Ln,[Pt.RECT]:zx,[Pt.RREC]:Xx},au=[],Fs=[];class Un{constructor(t,e=null,r=null,s=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=r,this.fillStyle=e,this.matrix=s,this.type=t.type}clone(){return new Un(this.shape,this.fillStyle,this.lineStyle,this.matrix
923)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const Qr=new ot,rp=class ip extends lf{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new Dn,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),Fs.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),au.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,r=null,s=null){const n=new Un(t,e,r,s);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const r=new Un(t,null,null,e),s=this.graphicsData[this.graphicsData.length-1];return r.lineStyle=s.lineStyle,s.holes.push(r),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const e=this.graphicsData;for(let r=0;r<e.length;++r){const s=e[r];if(s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(t,Qr):Qr.copyFrom(t),s.shape.contains(Qr.x,Qr.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(Qr.x,Qr.y)){n=!0;break}}if(!n)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let r=null,s=null;this.batches.length>0&&(r=this.batches[this.batches.length-1],s=r.style);for(let l=this.shapeIndex;l<e.length;l++){this.shapeIndex++;const h=e[l],c=h.fillStyle,u=h.lineStyle;ia[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(c.visible||u.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const f=d===0?c:u;if(!f.visible)continue;const p=f.texture.baseTexture,g=this.indices.length,y=this.points.length/2;p.wrapMode=nr.REPEAT,d===0?this.processFill(h):this.processLine(h);const m=this.points.length/2-y;m!==0&&(r&&!this._compareStyles(s,f)&&(r.end(g,y),r=null),r||(r=au.pop()||new Vx,r.begin(f,g,y),this.batches.push(r),s=f),this.addUvs(this.points,t,f.texture,y,m,f.matrix))}}const n=this.indices.length,o=this.points.length/2;if(r&&r.end(n,o),this.batches.length===0){this.batchable=!0;return}const a=o>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&a===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=a?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const r=this.graphicsData[t],s=r.fillStyle,n=r.lineStyle;if(s&&!s.texture.baseTexture.valid||n&&!n.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,r=t.length;e<r;e++){const s=t[e];for(let n=0;n<s.size;n++){const o=s.start+n;this.indicesUint16[o]=this.indicesUint16[o]-s.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<ip.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++Q._globalBatch;for(let u=0;u<this.drawCalls.length;u++)this.drawCalls[u].texArray.clear(),Fs.push(this.drawCalls[u]);this.drawCalls.length=0;const e=this.colors,r=this.textureIds;let s=Fs.pop();s||(s=new ja,s.texArray=new Ka),s.texArray.count=0,s.start=0,s.size=0,s.type=we.TRIANGLES;let n=0,o=null,a=0,l=!1,h=we.TRIANGLES,c=0;this.drawCalls.push(s);for(let u=0;u<this.batches.length;u++){const d=this.batches[u],f=8,p=d.style,g=p.texture.baseTexture;l!==!!p.native&&(l=!!p.native,h=l?we.LINES:we.TRIANGLES,o=null,n=f,t++),o!==g&&(o=g,g._batchEnabled!==t&&(n===f&&(t++,n=0,s.size>0&&(s=Fs.pop(),s||(s=new ja,s.texArray=new Ka),this.drawCalls.push(s)),s.start=c,s.size=0,s.texArray.count=0,s.type=h),g.touched=1,g._batchEnabled=t,g._batchLocation=n,g.wrapMode=nr.REPEAT,s.texArray.elements[s.texArray.count++
923]=g,n++)),s.size+=d.size,c+=d.size,a=g._batchLocation,this.addColors(e,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(r,a,d.attribSize,d.attribStart)}Q._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,r=this.colors,s=this.textureIds,n=new ArrayBuffer(t.length*3*4),o=new Float32Array(n),a=new Uint32Array(n);let l=0;for(let h=0;h<t.length/2;h++)o[l++]=t[h*2],o[l++]=t[h*2+1],o[l++]=e[h*2],o[l++]=e[h*2+1],a[l++]=r[h],o[l++]=s[h];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?ep.triangulate(t,this):ia[t.type].triangulate(t,this)}processLine(t){ou(t,this);for(let e=0;e<t.holes.length;e++)ou(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const r=t[e];ia[r.type].build(r),r.matrix&&this.transformPoints(r.points,r.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let r=0;r<t.length/2;r++){const s=t[r*2],n=t[r*2+1];t[r*2]=e.a*s+e.c*n+e.tx,t[r*2+1]=e.b*s+e.d*n+e.ty}}addColors(t,e,r,s,n=0){const o=ut.shared.setValue(e).toLittleEndianNumber(),a=ut.shared.setValue(o).toPremultiplied(r);t.length=Math.max(t.length,n+s);for(let l=0;l<s;l++)t[n+l]=a}addTextureIds(t,e,r,s=0){t.length=Math.max(t.length,s+r);for(let n=0;n<r;n++)t[s+n]=e}addUvs(t,e,r,s,n,o=null){let a=0;const l=e.length,h=r.frame;for(;a<n;){let u=t[(s+a)*2],d=t[(s+a)*2+1];if(o){const f=o.a*u+o.c*d+o.tx;d=o.b*u+o.d*d+o.ty,u=f}a++,e.push(u/h.width,d/h.height)}const c=r.baseTexture;(h.width<c.width||h.height<c.height)&&this.adjustUvs(e,r,l,n)}adjustUvs(t,e,r,s){const n=e.baseTexture,o=1e-6,a=r+s*2,l=e.frame,h=l.width/n.width,c=l.height/n.height;let u=l.x/l.width,d=l.y/l.height,f=Math.floor(t[r]+o),p=Math.floor(t[r+1]+o);for(let g=r+2;g<a;g+=2)f=Math.min(f,Math.floor(t[g]+o)),p=Math.min(p,Math.floor(t[g+1]+o));u-=f,d-=p;for(let g=r;g<a;g+=2)t[g]=(t[g]+u)*h,t[g+1]=(t[g+1]+d)*c}};rp.BATCHABLE_SIZE=100;let jx=rp;class so{constructor(){this.color=16777215,this.alpha=1,this.texture=W.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new so;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=W.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class ih extends so{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=ir.BUTT,this.join=Kt.MITER,this.miterLimit=10}clone(){const t=new ih;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=ir.BUTT,this.join=Kt.MITER,this.miterLimit=10}}const sa={},ml=class sn extends Dt{constructor(t=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new so,this._lineStyle=new ih,this._matrix=null,this._holeMode=!1,this.state=Re.for2d(),this._geometry=t||new jx,this._geometry.refCount++,this._transformID=-1,this._tintColor=new ut(16777215),this.blendMode=Z.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new sn(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,r,s=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:r,alignment:s,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:W.WHITE,color:t?.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:ir.BUTT,join:Kt.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const r=t.width>0&&t.alpha>0;return r?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:r},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new Fr,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Fr,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const r=this.currentPath.points,s=r[r.length-2],n=r[r.length-1];return(s!==t||n!==e)&&r.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,r,s){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),rh.curveTo(t,e,r,s,n),this}bezierCurveTo(t,e,r,s,n,o){return this._initCurve(),eh.curveTo(t,e,r,s,n,o,this.currentPath.points),this}arcTo(t,e,r,s,n){this._initCurve(t,e);const o=this.currentPath.points,a=su.curveTo(t,e,r,s,n,o);if(a){const{cx:l,cy:h,radius:c,startAngle:u,endAngle:d,anticlockwise:f}=a;this.arc(l,h,c,u,d,f)}return this}arc(t,e,r,s,n,o=!1){if(s===n)return this;if(!o&&n<=s?n+=Rn:o&&s<=n&&(s+=Rn),n-s===0)return this;const a=t+Math.cos(s)*r,l=e+Math.sin(s)*r,h=this._geometry.closePointEps;let c=this.currentPath?this.currentPath.points:null;if(c){const u=Math.abs(c[c.length-2]-a),d=Math.abs(c[c.length-1]-l);u<h&&d<h||c.push(a,l)}else this.moveTo(a,l),c=this.currentPath.points;return su.arc(a,l,t,e,r,s,n,o,c),this}beginFill(t=0,e){return this.beginTextureFill({texture:W.WHITE,color:t,alpha:e})}normalizeColor(t){const e=ut.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:W.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const r=t.alpha>0;return r?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:r},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,r,s){return this.drawShape(new K(t,e,r,s))}drawRoundedRect(t,e,r,s,n){return this.drawShape(new eo(t,e,r,s,n))}drawCircle(t,e,r){return this.drawShape(new Qn(t,e,r))}drawEllipse(t,e,r,s){return this.drawShape(new to(t,e,r,s))}drawPolygon(...t){let e,r=!0;const s=t[0];s.points?(r=s.closeStroke,e=s.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new Fr(e);return n.closeStroke=r,this.drawShape(n),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}
923isFastRect(){const t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Pt.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,r=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=r,this.vertexData=new Float32Array(t.points);for(let s=0;s<r;s++){const n=t.batches[s],o=n.style.color,a=new Float32Array(this.vertexData.buffer,n.attribStart*4*2,n.attribSize*2),l=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),h=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),c={vertexData:a,blendMode:e,indices:h,uvs:l,_batchRGB:ut.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=c}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,r=this.batches.length;e<r;e++){const s=this.batches[e];s.worldAlpha=this.worldAlpha*s.alpha,t.plugins[this.pluginName].render(s)}}}_renderDirect(t){const e=this._resolveDirectShader(t),r=this._geometry,s=this.worldAlpha,n=e.uniforms,o=r.drawCalls;n.translationMatrix=this.transform.worldTransform,ut.shared.setValue(this._tintColor).premultiply(s).toArray(n.tint),t.shader.bind(e),t.geometry.bind(r,e),t.state.set(this.state);for(let a=0,l=o.length;a<l;a++)this._renderDrawCallDirect(t,r.drawCalls[a])}_renderDrawCallDirect(t,e){const{texArray:r,type:s,size:n,start:o}=e,a=r.count;for(let l=0;l<a;l++)t.texture.bind(r.elements[l],l);t.geometry.draw(s,n,o)}_resolveDirectShader(t){let e=this.shader;const r=this.pluginName;if(!e){if(!sa[r]){const{maxTextures:s}=t.plugins[r],n=new Int32Array(s);for(let l=0;l<s;l++)n[l]=l;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new dt,default:ue.from({uSamplers:n},!0)},a=t.plugins[r]._shader.program;sa[r]=new Ce(a,o)}e=sa[r]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:r,maxX:s,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,r,s,n)}containsPoint(t){return this.worldTransform.applyInverse(t,sn._TEMP_POINT),this._geometry.containsPoint(sn._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=ut.shared.setValue(this._tintColor).multiply(e._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const e=this.transform.worldTransform,r=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this._geometry.points,c=this.vertexData;let u=0;for(let d=0;d<h.length;d+=2){const f=h[d],p=h[d+1];c[u++]=r*f+n*p+a,c[u++]=o*p+s*f+l}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,
923super.destroy(t)}};ml.curves=Si,ml._TEMP_POINT=new ot;let Xr=ml;class Yx{constructor(t,e){this.uvBuffer=t,this.uvMatrix=e,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const e=this.uvBuffer.data;(!this.data||this.data.length!==e.length)&&(this.data=new Float32Array(e.length)),this.uvMatrix.multiplyUvs(e,this.data),this._updateID++}}const na=new ot,lu=new Fr,sp=class np extends Dt{constructor(t,e,r,s=we.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=r||Re.for2d(),this.drawMode=s,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=H.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const e=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===we.TRIANGLES&&e.length<np.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const e=this.shader;e.alpha=this.worldAlpha,e.update&&e.update(),t.batch.flush(),e.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(e),t.state.set(this.state),t.geometry.bind(this.geometry,e),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const e=this.geometry,r=this.shader;r.uvMatrix&&(r.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=r._tintRGB,this._texture=r.texture;const s=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[s]),t.plugins[s].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,r=t._updateID;if(r===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const s=this.transform.worldTransform,n=s.a,o=s.b,a=s.c,l=s.d,h=s.tx,c=s.ty,u=this.vertexData;for(let d=0;d<u.length/2;d++){const f=e[d*2],p=e[d*2+1];u[d*2]=n*f+a*p+h,u[d*2+1]=o*f+l*p+c}if(this._roundPixels){const d=H.RESOLUTION;for(let f=0;f<u.length;++f)u[f]=Math.round(u[f]*d)/d}this.vertexDirty=r}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new Yx(t,e.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,na);const e=this.geometry.getBuffer("aVertexPosition").data,r=lu.points,s=this.geometry.getIndex().data,n=s.length,o=this.drawMode===4?3:1;for(let a=0;a+2<n;a+=o){const l=s[a]*2,h=s[a+1]*2,c=s[a+2]*2;if(r[0]=e[l],r[1]=e[l+1],r[2]=e[h],r[3]=e[h+1],r[4]=e[c],r[5]=e[c+1],lu.contains(na.x,na.y))return!0}return!1}destroy(t){super.destroy(t),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};sp.BATCHABLE_SIZE=100;let hu=sp;class qx extends lr{constructor(t,e,r){super();const s=new vt(t),n=new vt(e,!0),o=new vt(r,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,q.FLOAT).addAttribute("aTextureCoord",n,2,!1,q.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var Zx=`varying vec2 vTextureCoord; 924uniform vec4 uColor; 925 926uniform sampler2D uSampler; 927 928void main(void) 929{ 930 gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; 931} 932`,Kx=`attribute vec2 aVertexPosition; 933attribute vec2 aTextureCoord; 934 935uniform mat3 projectionMatrix; 936uniform mat3 translationMatrix; 937uniform mat3 uTextureMatrix; 938 939varying vec2 vTextureCoord; 940 941void main(void) 942{ 943 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
943)).xy, 0.0, 1.0); 944 945 vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; 946} 947`;class cu extends Ce{constructor(t,e){const r={uSampler:t,alpha:1,uTextureMatrix:dt.IDENTITY,uColor:new Float32Array([1,1,1,1])};e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e),e.uniforms&&Object.assign(r,e.uniforms),super(e.program||Ge.from(Kx,Zx),r),this._colorDirty=!1,this.uvMatrix=new wf(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new ut(e.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=e.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this.tint&&(this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}get tintValue(){return this._tintColor.toNumber()}update(){if(this._colorDirty){this._colorDirty=!1;const t=this.texture.baseTexture.alphaMode;ut.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class uu{constructor(t,e,r){this.geometry=new lr,this.indexBuffer=null,this.size=r,this.dynamicProperties=[],this.staticProperties=[];for(let s=0;s<t.length;++s){let n=t[s];n={attributeName:n.attributeName,size:n.size,uploadFunction:n.uploadFunction,type:n.type||q.FLOAT,offset:n.offset},e[s]?this.dynamicProperties.push(n):this.staticProperties.push(n)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const t=this.geometry;let e=0;this.indexBuffer=new vt(v1(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];a.offset=e,e+=a.size,this.dynamicStride+=a.size}const r=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(r),this.dynamicDataUint32=new Uint32Array(r),this.dynamicBuffer=new vt(this.dynamicData,!1,!1);let s=0;this.staticStride=0;for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];a.offset=s,s+=a.size,this.staticStride+=a.size}const n=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(n),this.staticDataUint32=new Uint32Array(n),this.staticBuffer=new vt(this.staticData,!0,!1);for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];t.addAttribute(a.attributeName,this.dynamicBuffer,0,a.type===q.UNSIGNED_BYTE,a.type,this.dynamicStride*4,a.offset*4)}for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];t.addAttribute(a.attributeName,this.staticBuffer,0,a.type===q.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(t,e,r){for(let s=0;s<this.dynamicProperties.length;s++){const n=this.dynamicProperties[s];n.uploadFunction(t,e,r,n.type===q.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,n.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,r){for(let s=0;s<this.staticProperties.length;s++){const n=this.staticProperties[s];n.uploadFunction(t,e,r,n.type===q.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,n.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var Jx=`varying vec2 vTextureCoord; 948varying vec4 vColor; 949 950uniform sampler2D uSampler; 951 952void main(void){ 953 vec4 color = texture2D(uSampler, vTextureCoord) * vColor; 954 gl_FragColor = color; 955}`,Qx=`attribute vec2 aVertexPosition; 956attribute vec2 aTextureCoord; 957attribute vec4 aColor; 958 959attribute vec2 aPositionCoord; 960attribute float aRotation; 961 962uniform mat3 translationMatrix; 963uniform vec4 uColor; 964 965varying vec2 vTextureCoord; 966varying vec4 vColor; 967 968void main(void){ 969 float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation); 970 float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation); 971 972 vec2 v = vec2(x, y); 973 v = v + aPositionCoord; 974 975 gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0); 976 977 vTextureCoord = aTextureCoord; 978 vColor = aColor * uColor; 979} 980`;class op extends ro{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new dt,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:q.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=Ce.from(Qx,Jx,{}),this.state=Re.for2d()}render(t){const e=t.children,r=t._maxSize,s=t._batchSize,n=this.renderer;let o=e.length;if(o===0)return;o>r&&!t.autoResize&&(o=r);let a=t._buffers;a||(a=t._buffers=this.generateBuffers(t));const l=e[0]._texture.baseTexture,h=l.alphaMode>0;this.state.blendMode=nf(t.blendMode,h),n.state.set(this.state);const c=n.gl,u=t.worldTransform.copyTo(this.tempMatrix);
vendor: 7,196 bytes, lines 980-981
980u.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=u.toArray(!0),this.shader.uniforms.uColor=ut.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,h).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=l,this.renderer.shader.bind(this.shader);let d=!1;for(let f=0,p=0;f<o;f+=s,p+=1){let g=o-f;g>s&&(g=s),p>=a.length&&a.push(this._generateOneMoreBuffer(t));const y=a[p];y.uploadDynamic(e,f,g);const m=t._bufferUpdateIDs[p]||0;d=d||y._updateID<m,d&&(y._updateID=t._updateID,y.uploadStatic(e,f,g)),n.geometry.bind(y.geometry),c.drawElements(c.TRIANGLES,g*6,c.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],r=t._maxSize,s=t._batchSize,n=t._properties;for(let o=0;o<r;o+=s)e.push(new uu(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,r=t._properties;return new uu(this.properties,r,e)}uploadVertices(t,e,r,s,n,o){let a=0,l=0,h=0,c=0;for(let u=0;u<r;++u){const d=t[e+u],f=d._texture,p=d.scale.x,g=d.scale.y,y=f.trim,m=f.orig;y?(l=y.x-d.anchor.x*m.width,a=l+y.width,c=y.y-d.anchor.y*m.height,h=c+y.height):(a=m.width*(1-d.anchor.x),l=m.width*-d.anchor.x,h=m.height*(1-d.anchor.y),c=m.height*-d.anchor.y),s[o]=l*p,s[o+1]=c*g,s[o+n]=a*p,s[o+n+1]=c*g,s[o+n*2]=a*p,s[o+n*2+1]=h*g,s[o+n*3]=l*p,s[o+n*3+1]=h*g,o+=n*4}}uploadPosition(t,e,r,s,n,o){for(let a=0;a<r;a++){const l=t[e+a].position;s[o]=l.x,s[o+1]=l.y,s[o+n]=l.x,s[o+n+1]=l.y,s[o+n*2]=l.x,s[o+n*2+1]=l.y,s[o+n*3]=l.x,s[o+n*3+1]=l.y,o+=n*4}}uploadRotation(t,e,r,s,n,o){for(let a=0;a<r;a++){const l=t[e+a].rotation;s[o]=l,s[o+n]=l,s[o+n*2]=l,s[o+n*3]=l,o+=n*4}}uploadUvs(t,e,r,s,n,o){for(let a=0;a<r;++a){const l=t[e+a]._texture._uvs;l?(s[o]=l.x0,s[o+1]=l.y0,s[o+n]=l.x1,s[o+n+1]=l.y1,s[o+n*2]=l.x2,s[o+n*2+1]=l.y2,s[o+n*3]=l.x3,s[o+n*3+1]=l.y3,o+=n*4):(s[o]=0,s[o+1]=0,s[o+n]=0,s[o+n+1]=0,s[o+n*2]=0,s[o+n*2+1]=0,s[o+n*3]=0,s[o+n*3+1]=0,o+=n*4)}}uploadTint(t,e,r,s,n,o){for(let a=0;a<r;++a){const l=t[e+a],h=ut.shared.setValue(l._tintRGB).toPremultiplied(l.alpha,l.texture.baseTexture.alphaMode>0);s[o]=h,s[o+n]=h,s[o+n*2]=h,s[o+n*3]=h,o+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}op.extension={name:"particle",type:U.RendererPlugin};$.add(op);var no=(i=>(i[i.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",i[i.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",i))(no||{});const Os={willReadFrequently:!0},ye=class j{static get experimentalLetterSpacingSupported(){let t=j._experimentalLetterSpacingSupported;if(t!==void 0){const e=H.ADAPTER.getCanvasRenderingContext2D().prototype;t=j._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,r,s,n,o,a,l,h){this.text=t,this.style=e,this.width=r,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}static measureText(t,e,r,s=j._canvas){r=r??e.wordWrap;const n=e.toFontString(),o=j.measureFont(n);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=s.getContext("2d",Os);a.font=n;const l=(r?j.wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let c=0;for(let p=0;p<l.length;p++){const g=j._measureText(l[p],e.letterSpacing,a);h[p]=g,c=Math.max(c,g)}let u=c+e.strokeThickness;e.dropShadow&&(u+=e.dropShadowDistance);const d=e.lineHeight||o.fontSize+e.strokeThickness;let f=Math.max(d,o.fontSize+e.strokeThickness*2)+e.leading+(l.length-1)*(d+e.leading);return e.dropShadow&&(f+=e.dropShadowDistance),new j(t,e,u,f,l,h,d+e.leading,c,o)}static _measureText(t,e,r){let s=!1;j.experimentalLetterSpacingSupported&&(j.experimentalLetterSpacing?(r.letterSpacing=`${e}px`,r.textLetterSpacing=`${e}px`,s=!0):(r.letterSpacing="0px",r.textLetterSpacing="0px"));let n=r.measureText(t).width;return n>0&&(s?n-=e:n+=(j.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,r=j._canvas){const s=r.getContext("2d",Os);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:c}=e,u=j.collapseSpaces(c),d=j.collapseNewlines(c);let f=!u;const p=e.wordWrapWidth+h,g=j.tokenize(t);for(let y=0;y<g.length;y++){let m=g[y];if(j.isNewline(m)){if(!d){a+=j.addLine(o),f=!u,o="",n=0;continue}m=" "}if(u){const _=j.isBreakingSpace(m),b=j.isBreakingSpace(o[o.length-1]);if(_&&b)continue}const v=j.getFromCache(m,h,l,s);if(v>p)if(o!==""&&(a+=j.addLine(o),o="",n=0),j.canBreakWords(m,e.breakWords)){const _=j.wordWrapSplit(m);for(let b=0;b<_.length;b++){let w=_[b],A=w,x=1;for(;_[b+x];){const T=_[b+x];if(!j.canBreakChars(A,T,m,b,e.breakWords))w+=T;else break;A=T,x++}b+=x-1;const C=j.getFromCache(w,h,l,s);C+n>p&&(a+=j.addLine(o),f=!1,o="",n=0),o+=w,n+=C}}else{o.length>0&&(a+=j.addLine(o),o="",n=0);const _=y===g.length-1;a+=j.addLine(m,!_),f=!1,o="",n=0}else v+n>p&&(f=!1,a+=j.addLine(o),o="",n=0),(o.length>0||!j.isBreakingSpace(m)||f)&&(o+=m,n+=v)}return a+=j.addLine(o,!1),a}static addLine(t,e=!0){return t=j.trimRight(t),t=e?`${t} 981`:t,t}static getFromCache(t,e,r,s){let n=r[t];return typeof n!="number"&&(n=j._measureText(t,e,s)+e,r[t]=n),n}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const r=t[e];if(!j.isBreakingSpace(r))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:j._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:j._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let r="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){const n=t[s],o=t[s+1];if(j.isBreakingSpace(n,o)||j.isNewline(n)){r!==""&&(e.push(r),r=""),e.push(n);continue}r+=n}return r!==""&&e.push(r),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,r,s,n){return!0}static wordWrapSplit(t){return j.graphemeSegmenter(t)}static measureFont(t){if(j._fonts[t])return j._fonts[t];const e={ascent:0,descent:0,fontSize:0},r=j._canvas,s=j._context;s.font=t;const n=j.METRICS_STRING+j.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(j.BASELINE_SYMBOL).width);const l=Math.ceil(j.HEIGHT_MULTIPLIER*a);if(a=a*j.BASELINE_MULTIPLIER|0,o===0||l===0)return j._fonts[t]=e,e;r.width=o,r.height=l,s.fillStyle="#f00",s.fillRect(0,0,o,l),s.font=t,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,a);const h=s.getImageData(0,0,o,l).data,c=h.length,u=o*4;let d=0,f=0,p=!1;for(d=0;d<a;++d){for(let g=0;g<u;g+=4)if(h[f+g]!==255){p=!0;break}if(!p)f+=u;else break}for(e.ascent=a-d,f=c-u,p=!1,d=l;d>a;--d){for(let g=0;g<u;g+=4)if(h[f+g]!==255){p=!0;break}if(!p)f-=u;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,j._fonts[t]=e,e}static clearMetrics(t=""){t?delete j._fonts[t]:j._fonts={}}static get _canvas(){if(!j.__canvas){let t;try{const e=new OffscreenCanvas(0,0);if(e.getContext("2d",Os)?.measureText)return j.__canvas=e,e;t=H.ADAPTER.createCanvas()}catch{t=H.ADAPTER.createCanvas()}t.width=t.height=10,j.__canvas=t}return j.__canvas}static get _context(){return j.__context||(j.__context=j._canvas.getContext("2d",Os)),j.__context}};ye.METRICS_STRING="|ÉqÅ",ye.BASELINE_SYMBOL="M",ye.BASELINE_MULTIPLIER=1.4,ye.HEIGHT_MULTIPLIER=2,ye.graphemeSegmenter=(()=>
vendor: 9,995 bytes, line 981
981{if(typeof Intl?.Segmenter=="function"){const i=new Intl.Segmenter;return t=>[...i.segment(t)].map(e=>e.segment)}return i=>[...i]})(),ye.experimentalLetterSpacing=!1,ye._fonts={},ye._newlines=[10,13],ye._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Qe=ye;const tw=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],ap=class $i{constructor(t){this.styleID=0,this.reset(),aa(this,t,t)}clone(){const t={};return aa(t,this,$i.defaultStyle),new $i(t)}reset(){aa(this,$i.defaultStyle,$i.defaultStyle)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const e=oa(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const e=oa(t);this._fill!==e&&(this._fill=e,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){ew(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const e=oa(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let r=e.length-1;r>=0;r--){let s=e[r].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!tw.includes(s)&&(s=`"${s}"`),e[r]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};ap.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:no.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let cr=ap;function oa(i){const t=ut.shared,e=r=>{const s=t.setValue(r);return s.alpha===1?s.toHex():s.toRgbaString()};return Array.isArray(i)?i.map(e):e(i)}function ew(i,t){if(!Array.isArray(i)||!Array.isArray(t)||i.length!==t.length)return!1;for(let e=0;e<i.length;++e)if(i[e]!==t[e])return!1;return!0}function aa(i,t,e){for(const r in e)Array.isArray(t[r])?i[r]=t[r].slice():i[r]=t[r]}const rw={texture:!0,children:!1,baseTexture:!0},lp=class _l extends Lt{constructor(t,e,r){let s=!1;r||(r=H.ADAPTER.createCanvas(),s=!0),r.width=3,r.height=3;const n=W.from(r);n.orig=new K,n.trim=new K,super(n),this._ownCanvas=s,this.canvas=r,this.context=r.getContext("2d",{willReadFrequently:!0}),this._resolution=_l.defaultResolution??H.RESOLUTION,this._autoResolution=_l.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=e,this.localStyleID=-1}static get experimentalLetterSpacing(){return Qe.experimentalLetterSpacing}static set experimentalLetterSpacing(t){rt("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Qe.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const r=this.context,s=Qe.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=s.width,o=s.height,a=s.lines,l=s.lineHeight,h=s.lineWidths,c=s.maxLineWidth,u=s.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,n)+e.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,o)+e.padding*2)*this._resolution),r.scale(this._resolution,this._resolution),r.clearRect(0,0,this.canvas.width,this.canvas.height),r.font=this._font,r.lineWidth=e.strokeThickness,r.textBaseline=e.textBaseline,r.lineJoin=e.lineJoin,r.miterLimit=e.miterLimit;let d,f;const p=e.dropShadow?2:1;for(let g=0;g<p;++g){const y=e.dropShadow&&g===0,m=y?Math.ceil(Math.max(1,o)+e.padding*2):0,v=m*this._resolution;if(y){r.fillStyle="black",r.strokeStyle="black";const b=e.dropShadowColor,w=e.dropShadowBlur*this._resolution,A=e.dropShadowDistance*this._resolution;r.shadowColor=ut.shared.setValue(b).setAlpha(e.dropShadowAlpha).toRgbaString(),r.shadowBlur=w,r.shadowOffsetX=Math.cos(e.dropShadowAngle)*A,r.shadowOffsetY=Math.sin(e.dropShadowAngle)*A+v}else r.fillStyle=this._generateFillStyle(e,a,s),r.strokeStyle=e.stroke,r.shadowColor="black",r.shadowBlur=0,r.shadowOffsetX=0,r.shadowOffsetY=0;let _=(l-u.fontSize)/2;l-u.fontSize<0&&(_=0);for(let b=0;b<a.length;b++)d=e.strokeThickness/2,f=e.strokeThickness/2+b*l+u.ascent+_,e.align==="right"?d+=c-h[b]:e.align==="center"&&(d+=(c-h[b])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[b],d+e.padding,f+e.padding-m,!0),e.fill&&this.drawLetterSpacing(a[b],d+e.padding,f+e.padding-m)}this.updateTexture()}drawLetterSpacing(t,e,r,s=!1){const n=this._style.letterSpacing;let o=!1;if(Qe.experimentalLetterSpacingSupported&&(Qe.experimentalLetterSpacing?(this.context.letterSpacing=`${n}px`,this.context.textLetterSpacing=`${n}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),n===0||o){s?this.context.strokeText(t,e,r):this.context.fillText(t,e,r);return}let a=e;const l=Qe.graphemeSegmenter(t);let h=this.context.measureText(t).width,c=0;for(let u=0;u<l.length;++u){const d=l[u];s?this.context.strokeText(d,a,r):this.context.fillText(d,a,r);let f="";for(let p=u+1;p<l.length;++p)f+=l[p];c=this.context.measureText(f).width,a+=h-c+n,h=c}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=T1(t);o.data&&(t.width=o.width,t.height=o.height,this.context.putImageData(o.data,0,0))}const e=this._texture,r=this._style,s=r.trim?0:r.padding,n=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-s,e.trim.y=-s,e.orig.width=e._frame.width-s*2,e.orig.height=e._frame.height-s*2,this._onTextureUpdate(),n.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,r){const s=t.fill;if(Array.isArray(s)){if(s.length===1)return s[0]}else return s;let n;const o=t.dropShadow?t.dropShadowDistance:0,a=t.padding||0,l=this.canvas.width/this._resolution-o-a*2,h=this.canvas.height/this._resolution-o-a*2,c=s.slice(),u=t.fillGradientStops.slice();if(!u.length){const d=c.length+1;for(let f=1;f<d;++f)u.push(f/d)}if(c.unshift(s[0]),u.unshift(0),c.push(s[s.length-1]),u.push(1),t.fillGradientType===no.L
981INEAR_VERTICAL){n=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=r.fontProperties.fontSize+t.strokeThickness;for(let f=0;f<e.length;f++){const p=r.lineHeight*(f-1)+d,g=r.lineHeight*f;let y=g;f>0&&p>g&&(y=(g+p)/2);const m=g+d,v=r.lineHeight*(f+1);let _=m;f+1<e.length&&v<m&&(_=(m+v)/2);const b=(_-y)/h;for(let w=0;w<c.length;w++){let A=0;typeof u[w]=="number"?A=u[w]:A=w/c.length;let x=Math.min(1,Math.max(0,y/h+A*b));x=Number(x.toFixed(5)),n.addColorStop(x,c[w])}}}else{n=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=c.length+1;let f=1;for(let p=0;p<c.length;p++){let g;typeof u[p]=="number"?g=u[p]:g=f/d,n.addColorStop(g,c[p]),f++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},rw,t),super.destroy(t),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this.updateText(!0);const e=rr(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const e=rr(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof cr?this._style=t:this._style=new cr(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};lp.defaultAutoResolution=!0;let hp=lp;class iw{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function sw(i,t){let e=!1;if(i?._textures?.length){for(let r=0;r<i._textures.length;r++)if(i._textures[r]instanceof W){const s=i._textures[r].baseTexture;t.includes(s)||(t.push(s),e=!0)}}return e}function nw(i,t){if(i.baseTexture instanceof Q){const e=i.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function ow(i,t){if(i._texture&&i._texture instanceof W){const e=i._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function aw(i,t){return t instanceof hp?(t.updateText(!0),!0):!1}function lw(i,t){if(t instanceof cr){const e=t.toFontString();return Qe.measureFont(e),!0}return!1}function hw(i,t){if(i instanceof hp){t.includes(i.style)||t.push(i.style),t.includes(i)||t.push(i);const e=i._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function cw(i,t){return i instanceof cr?(t.includes(i)||t.push(i),!0):!1}const cp=class up{constructor(t){this.limiter=new iw(up.uploadsPerFrame),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(hw),this.registerFindHook(cw),this.registerFindHook(sw),this.registerFindHook(nw),this.registerFindHook(ow),this.registerUploadHook(aw),this.registerUploadHook(lw)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,$t.system.addOnce(this.tick,this,zr.UTILITY))):e()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed){for(let r=0,s=this.uploadHooks.length;r<s;r++)if(this.uploadHooks[r](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)$t.system.addOnce(this.tick,this,zr.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,r=t.length;e<r;e++)t[e]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let e=0,r=this.addHooks.length;e<r&&!this.addHooks[e](t,this.queue);e++);if(t instanceof Dt)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&$t.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};cp.uploadsPerFrame=4;let gl=cp;Object.defineProperties(H,{UPLOADS_PER_FRAME:{get(){return gl.uploadsPerFrame},set(i){rt("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),gl.uploadsPerFrame=i}}});function dp(i,t){return t instanceof Q?(t._glTextures[i.CONTEXT_UID]||i.texture.bind(t),!0):!1}function uw(i,t){if(!(t instanceof Xr))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:r}=e;for(let s=0;s<r.length;s++){const{texture:n}=r[s].style;n&&dp(i,n.baseTexture)}return e.batchable||i.geometry.bind(e,t._resolveDirectShader(i)),!0}function dw(i,t){return i instanceof Xr?(t.push(i),!0):!1}class fp extends gl{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(dw),this.registerUploadHook(dp),this.registerUploadHook(uw)}}fp.extension={name:"prepare",type:U.RendererSystem};$.add(fp);var fw=`#version 300 es 982#define SHADER_NAME Tiling-Sprite-100 983 984precision lowp float; 985 986in vec2 vTextureCoord; 987 988out vec4 fragmentColor; 989 990uniform sampler2D uSampler; 991uniform vec4 uColor; 992uniform mat3 uMapCoord; 993uniform vec4 uClampFrame; 994uniform vec2 uClampOffset; 995 996void main(void) 997{ 998 vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord); 999 coord = (uMapCoord * vec3(coord, 1.0)).xy;
1000 vec2 unclamped = coord; 1001 coord = clamp(coord, uClampFrame.xy, uClampFrame.zw); 1002 1003 vec4 texSample = texture(uSampler, coord, unclamped == coord ? 0.0f : -32.0f);// lod-bias very negative to force lod 0 1004 1005 fragmentColor = texSample * uColor; 1006} 1007`,pw=`#version 300 es 1008#define SHADER_NAME Tiling-Sprite-300 1009 1010precision lowp float; 1011 1012in vec2 aVertexPosition; 1013in vec2 aTextureCoord; 1014 1015uniform mat3 projectionMatrix; 1016uniform mat3 translationMatrix; 1017uniform mat3 uTransform; 1018 1019out vec2 vTextureCoord; 1020 1021void main(void) 1022{ 1023 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); 1024 1025 vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy; 1026} 1027`,mw=`#version 100 1028#ifdef GL_EXT_shader_texture_lod 1029 #extension GL_EXT_shader_texture_lod : enable 1030#endif 1031#define SHADER_NAME Tiling-Sprite-100 1032 1033precision lowp float; 1034 1035varying vec2 vTextureCoord; 1036 1037uniform sampler2D uSampler; 1038uniform vec4 uColor; 1039uniform mat3 uMapCoord; 1040uniform vec4 uClampFrame; 1041uniform vec2 uClampOffset; 1042 1043void main(void) 1044{ 1045 vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord); 1046 coord = (uMapCoord * vec3(coord, 1.0)).xy; 1047 vec2 unclamped = coord; 1048 coord = clamp(coord, uClampFrame.xy, uClampFrame.zw); 1049 1050 #ifdef GL_EXT_shader_texture_lod 1051 vec4 texSample = unclamped == coord 1052 ? texture2D(uSampler, coord) 1053 : texture2DLodEXT(uSampler, coord, 0); 1054 #else 1055 vec4 texSample = texture2D(uSampler, coord); 1056 #endif 1057 1058 gl_FragColor = texSample * uColor; 1059} 1060`,du=`#version 100 1061#define SHADER_NAME Tiling-Sprite-100 1062 1063precision lowp float; 1064 1065attribute vec2 aVertexPosition; 1066attribute vec2 aTextureCoord; 1067 1068uniform mat3 projectionMatrix; 1069uniform mat3 translationMatrix; 1070uniform mat3 uTransform; 1071 1072varying vec2 vTextureCoord; 1073 1074void main(void) 1075{ 1076 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
1076)).xy, 0.0, 1.0); 1077 1078 vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy; 1079} 1080`,_w=`#version 100 1081#define SHADER_NAME Tiling-Sprite-Simple-100 1082 1083precision lowp float; 1084 1085varying vec2 vTextureCoord; 1086 1087uniform sampler2D uSampler; 1088uniform vec4 uColor; 1089 1090void main(void) 1091{ 1092 vec4 texSample = texture2D(uSampler, vTextureCoord); 1093 gl_FragColor = texSample * uColor; 1094} 1095`;const Ns=new dt;class pp extends ro{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new yf,this.state=Re.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=Ce.from(du,_w,e),this.shader=t.context.webGLVersion>1?Ce.from(pw,fw,e):Ce.from(du,mw,e)}render(t){const e=this.renderer,r=this.quad;let s=r.vertices;s[0]=s[6]=t._width*-t.anchor.x,s[1]=s[3]=t._height*-t.anchor.y,s[2]=s[4]=t._width*(1-t.anchor.x),s[5]=s[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,o=t.uvRespectAnchor?t.anchor.y:0;s=r.uvs,s[0]=s[6]=-n,s[1]=s[3]=-o,s[2]=s[4]=1-n,s[5]=s[7]=1-o,r.invalidate();const a=t._texture,l=a.baseTexture,h=l.alphaMode>0,c=t.tileTransform.localTransform,u=t.uvMatrix;let d=l.isPowerOfTwo&&a.frame.width===l.width&&a.frame.height===l.height;d&&(l._glTextures[e.CONTEXT_UID]?d=l.wrapMode!==nr.CLAMP:l.wrapMode===nr.CLAMP&&(l.wrapMode=nr.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,g=a.height,y=t._width,m=t._height;Ns.set(c.a*p/y,c.b*p/m,c.c*g/y,c.d*g/m,c.tx/y,c.ty/m),Ns.invert(),d?Ns.prepend(u.mapCoord):(f.uniforms.uMapCoord=u.mapCoord.toArray(!0),f.uniforms.uClampFrame=u.uClampFrame,f.uniforms.uClampOffset=u.uClampOffset),f.uniforms.uTransform=Ns.toArray(!0),f.uniforms.uColor=ut.shared.setValue(t.tint).premultiply(t.worldAlpha,h).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),f.uniforms.uSampler=a,e.shader.bind(f),e.geometry.bind(r),this.state.blendMode=nf(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}pp.extension={name:"tilingSprite",type:U.RendererPlugin};$.add(pp);const mp=class ji{constructor(t,e,r=null){this.linkedSheets=[],this._texture=t instanceof W?t:null,this.baseTexture=t instanceof Q?t:this._texture.baseTexture,this.textures={},this.animations={},this.data=e;const s=this.baseTexture.resource;this.resolution=this._updateResolution(r||(s?s.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:e}=this.data.meta;let r=Ve(t,null);return r===null&&(r=parseFloat(e??"1")),r!==1&&this.baseTexture.setResolution(r),r}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=ji.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const r=ji.BATCH_SIZE;for(;e-t<r&&e<this._frameKeys.length;){const s=this._frameKeys[e],n=this._frames[s],o=n.frame;if(o){let a=null,l=null;const h=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,c=new K(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?a=new K(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):a=new K(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(l=new K(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[s]=new W(this.baseTexture,a,c,l,n.rotated?2:0,n.anchor,n.borders),W.addToCache(this.textures[s],s.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let r=0;r<t[e].length;r++){const s=t[e][r];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*ji.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*ji.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){for(const e in this.textures)this.textures[e].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(this._texture?.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};mp.BATCH_SIZE=1e3;let fu=mp;const gw=["jpg","png","jpeg","avif","webp"];function _p(i,t,e){const r={};if(i.forEach(s=>{r[s]=t}
1095),Object.keys(t.textures).forEach(s=>{r[s]=t.textures[s]}),!e){const s=At.dirname(i[0]);t.linkedSheets.forEach((n,o)=>{const a=_p([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(r,a)})}return r}const yw={extension:U.Asset,cache:{test:i=>i instanceof fu,getCacheableAssets:(i,t)=>_p(i,t,!1)},resolver:{test:i=>{const t=i.split("?")[0].split("."),e=t.pop(),r=t.pop();return e==="json"&&gw.includes(r)},parse:i=>{const t=i.split(".");return{resolution:parseFloat(H.RETINA_PREFIX.exec(i)?.[1]??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",extension:{type:U.LoadParser,priority:de.Normal},async testParse(i,t){return At.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){let r=At.dirname(t.src);r&&r.lastIndexOf("/")!==r.length-1&&(r+="/");let s=r+i.meta.image;s=fl(s,t.src);const n=(await e.load([s]))[s],o=new fu(n.baseTexture,i,t.src);await o.parse();const a=i?.meta?.related_multi_packs;if(Array.isArray(a)){const l=[];for(const c of a){if(typeof c!="string")continue;let u=r+c;t.data?.ignoreMultiPack||(u=fl(u,t.src),l.push(e.load({src:u,data:{ignoreMultiPack:!0}})))}const h=await Promise.all(l);o.linkedSheets=h,h.forEach(c=>{c.linkedSheets=[o].concat(o.linkedSheets.filter(u=>u!==c))})}return o},unload(i){i.destroy(!0)}}};$.add(yw);class Gn{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class nn{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),r={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const o=e[n].match(/^[a-z]+/gm)[0],a=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const h in a){const c=a[h].split("="),u=c[0],d=c[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;l[u]=p}r[o].push(l)}const s=new Gn;return r.info.forEach(n=>s.info.push({face:n.face,size:parseInt(n.size,10)})),r.common.forEach(n=>s.common.push({lineHeight:parseInt(n.lineHeight,10)})),r.page.forEach(n=>s.page.push({id:parseInt(n.id,10),file:n.file})),r.char.forEach(n=>s.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),r.kerning.forEach(n=>s.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),r.distanceField.forEach(n=>s.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),s}}class yl{static test(t){const e=t;return typeof t!="string"&&"getElementsByTagName"in t&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new Gn,r=t.getElementsByTagName("info"),s=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),l=t.getElementsByTagName("distanceField");for(let h=0;h<r.length;h++)e.info.push({face:r[h].getAttribute("face"),size:parseInt(r[h].getAttribute("size"),10)});for(let h=0;h<s.length;h++)e.common.push({lineHeight:parseInt(s[h].getAttribute("lineHeight"),10)});for(let h=0;h<n.length;h++)e.page.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});for(let h=0;h<o.length;h++){const c=o[h];e.char.push({id:parseInt(c.getAttribute("id"),10),page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xoffset:parseInt(c.getAttribute("xoffset"),10),yoffset:parseInt(c.getAttribute("yoffset"),10),xadvance:parseInt(c.getAttribute("xadvance"),10)})}for(let h=0;h<a.length;h++)e.kerning.push({first:parseInt(a[h].getAttribute("first"),10),second:parseInt(a[h].getAttribute("second"),10),amount:parseInt(a[h].getAttribute("amount"),10)});for(let h=0;h<l.length;h++)e.distanceField.push({fieldType:l[h].getAttribute("fieldType"),distanceRange:parseInt(l[h].getAttribute("distanceRange"),10)});return e}}class vl{static test(t){return typeof t=="string"&&t.includes("<font>")?yl.test(H.ADAPTER.parseXML(t)):!1}static parse(t){return yl.parse(H.ADAPTER.parseXML(t))}}const la=[nn,yl,vl];function vw(i){for(let t=0;t<la.length;t++)if(la[t].test(i))return la[t];return null}function bw(i,t,e,r,s,n){const o=e.fill;if(Array.isArray(o)){if(o.length===1)return o[0]}else return o;let a;const l=e.dropShadow?e.dropShadowDistance:0,h=e.padding||0,c=i.width/r-l-h*2,u=i.height/r-l-h*2,d=o.slice(),f=e.fillGradientStops.slice();if(!f.length){const p=d.length+1;for(let g=1;g<p;++g)f.push(g/p)}
1095if(d.unshift(o[0]),f.unshift(0),d.push(o[o.length-1]),f.push(1),e.fillGradientType===no.LINEAR_VERTICAL){a=t.createLinearGradient(c/2,h,c/2,u+h);let p=0;const g=(n.fontProperties.fontSize+e.strokeThickness)/u;for(let y=0;y<s.length;y++){const m=n.lineHeight*y;for(let v=0;v<d.length;v++){let _=0;typeof f[v]=="number"?_=f[v]:_=v/d.length;const b=m/u+_*g;let w=Math.max(p,b);w=Math.min(w,1),a.addColorStop(w,d[v]),p=w}}}else{a=t.createLinearGradient(h,u/2,c+h,u/2);const p=d.length+1;let g=1;for(let y=0;y<d.length;y++){let m;typeof f[y]=="number"?m=f[y]:m=g/p,a.addColorStop(m,d[y]),g++}}return a}function xw(i,t,e,r,s,n,o){const a=e.text,l=e.fontProperties;t.translate(r,s),t.scale(n,n);const h=o.strokeThickness/2,c=-(o.strokeThickness/2);if(t.font=o.toFontString(),t.lineWidth=o.strokeThickness,t.textBaseline=o.textBaseline,t.lineJoin=o.lineJoin,t.miterLimit=o.miterLimit,t.fillStyle=bw(i,t,o,n,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const u=o.dropShadowColor,d=o.dropShadowBlur*n,f=o.dropShadowDistance*n;t.shadowColor=ut.shared.setValue(u).setAlpha(o.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(o.dropShadowAngle)*f,t.shadowOffsetY=Math.sin(o.dropShadowAngle)*f}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;o.stroke&&o.strokeThickness&&t.strokeText(a,h,c+e.lineHeight-l.descent),o.fill&&t.fillText(a,h,c+e.lineHeight-l.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function on(i){return i.codePointAt?i.codePointAt(0):i.charCodeAt(0)}function gp(i){return Array.from?Array.from(i):i.split("")}function ww(i){typeof i=="string"&&(i=[i]);const t=[];for(let e=0,r=i.length;e<r;e++){const s=i[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);const n=s[0].charCodeAt(0),o=s[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...gp(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const Ye=class ve{constructor(t,e,r){const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,l=Ve(o.file),h={};this._ownsTextures=r,this.font=s.face,this.size=s.size,this.lineHeight=n.lineHeight/l,this.chars={},this.pageTextures=h;for(let c=0;c<t.page.length;c++){const{id:u,file:d}=t.page[c];h[u]=e instanceof Array?e[c]:e[d],a?.fieldType&&a.fieldType!=="none"&&(h[u].baseTexture.alphaMode=Ht.NO_PREMULTIPLIED_ALPHA,h[u].baseTexture.mipmap=Ie.OFF)}for(let c=0;c<t.char.length;c++){const{id:u,page:d}=t.char[c];let{x:f,y:p,width:g,height:y,xoffset:m,yoffset:v,xadvance:_}=t.char[c];f/=l,p/=l,g/=l,y/=l,m/=l,v/=l,_/=l;const b=new K(f+h[d].frame.x/l,p+h[d].frame.y/l,g,y);this.chars[u]={xOffset:m,yOffset:v,xAdvance:_,kerning:{},texture:new W(h[d].baseTexture,b),page:d}}for(let c=0;c<t.kerning.length;c++){let{first:u,second:d,amount:f}=t.kerning[c];u/=l,d/=l,f/=l,this.chars[d]&&(this.chars[d].kerning[u]=f)}this.distanceFieldRange=a?.distanceRange,this.distanceFieldType=a?.fieldType?.toLowerCase()??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,r){let s;if(t instanceof Gn)s=t;else{const o=vw(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof W&&(e=[e]);const n=new ve(s,e,r);return ve.available[n.font]=n,n}static uninstall(t){const e=ve.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete ve.available[t]}static from(t,e,r){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:s,padding:n,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},ve.defaultOptions,r),c=ww(s),u=e instanceof cr?e:new cr(e),d=a,f=new Gn;f.info[0]={face:u.fontFamily,size:u.fontSize},f.common[0]={lineHeight:u.fontSize};let p=0,g=0,y,m,v,_=0;const b=[];for(let A=0;A<c.length;A++){y||(y=H.ADAPTER.createCanvas(),y.width=a,y.height=l,m=y.getContext("2d"),v=new Q(y,{resolution:o,...h}
1095),b.push(new W(v)),f.page.push({id:b.length-1,file:""}));const x=c[A],C=Qe.measureText(x,u,!1,y),T=C.width,P=Math.ceil(C.height),M=Math.ceil((u.fontStyle==="italic"?2:1)*T);if(g>=l-P*o){if(g===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${x}')`);--A,y=null,m=null,v=null,g=0,p=0,_=0;continue}if(_=Math.max(P+C.fontProperties.descent,_),M*o+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${x}')`);--A,g+=_*o,g=Math.ceil(g),p=0,_=0;continue}xw(y,m,C,p,g,o,u);const B=on(C.text);f.char.push({id:B,page:b.length-1,x:p/o,y:g/o,width:M,height:P,xoffset:0,yoffset:0,xadvance:T-(u.dropShadow?u.dropShadowDistance:0)-(u.stroke?u.strokeThickness:0)}),p+=(M+2*n)*o,p=Math.ceil(p)}if(!r?.skipKerning)for(let A=0,x=c.length;A<x;A++){const C=c[A];for(let T=0;T<x;T++){const P=c[T],M=m.measureText(C).width,B=m.measureText(P).width,S=m.measureText(C+P).width-(M+B);S&&f.kerning.push({first:on(C),second:on(P),amount:S})}}const w=new ve(f,b,!0);return ve.available[t]!==void 0&&ve.uninstall(t),ve.available[t]=w,w}};Ye.ALPHA=[["a","z"],["A","Z"]," "],Ye.NUMERIC=[["0","9"]],Ye.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Ye.ASCII=[[" ","~"]],Ye.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Ye.ALPHANUMERIC},Ye.available={};let qe=Ye;var Tw=`// Pixi texture info\r 1096varying vec2 vTextureCoord;\r 1097uniform sampler2D uSampler;\r 1098\r 1099// Tint\r 1100uniform vec4 uColor;\r 1101\r 1102// on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r 1103uniform float uFWidth;\r 1104\r 1105void main(void) {\r 1106\r 1107 // To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r 1108 vec4 texColor = texture2D(uSampler, vTextureCoord);\r 1109\r 1110 // MSDF\r 1111 float median = texColor.r + texColor.g + texColor.b -\r 1112 min(texColor.r, min(texColor.g, texColor.b)) -\r 1113 max(texColor.r, max(texColor.g, texColor.b));\r 1114 // SDF\r 1115 median = min(median, texColor.a);\r 1116\r 1117 float screenPxDistance = uFWidth * (median - 0.5);\r 1118 float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r 1119 if (median < 0.01) {\r 1120 alpha = 0.0;\r 1121 } else if (median > 0.99) {\r 1122 alpha = 1.0;\r 1123 }\r 1124\r 1125 // Gamma correction for coverage-like alpha\r 1126 float luma = dot(uColor.rgb, vec3(0.299, 0.587, 0.114));\r 1127 float gamma = mix(1.0, 1.0 / 2.2, luma);\r 1128 float coverage = pow(uColor.a * alpha, gamma); \r 1129\r 1130 // NPM Textures, NPM outputs\r 1131 gl_FragColor = vec4(uColor.rgb, coverage);\r 1132}\r 1133`,Ew=`// Mesh material default fragment\r 1134attribute vec2 aVertexPosition;\r 1135attribute vec2 aTextureCoord;\r 1136\r 1137uniform mat3 projectionMatrix;\r 1138uniform mat3 translationMatrix;\r 1139uniform mat3 uTextureMatrix;\r 1140\r 1141varying vec2 vTextureCoord;\r 1142\r 1143void main(void)\r 1144{\r 1145 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
1145)).xy, 0.0, 1.0);\r 1146\r 1147 vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r 1148}\r 1149`;const pu=[],mu=[],_u=[],Aw=class yp extends Dt{constructor(t,e={}){super();const{align:r,tint:s,maxWidth:n,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},yp.styleDefaults,e);if(!qe.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=r,this._tintColor=new ut(s),this._font=void 0,this._fontName=a,this._fontSize=l,this.text=t,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=o,this._anchor=new Ue(()=>{this.dirty=!0},this,0,0),this._roundPixels=H.ROUND_PIXELS,this.dirty=!0,this._resolution=H.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){const t=qe.available[this._fontName],e=this.fontSize,r=e/t.size,s=new ot,n=[],o=[],a=[],l=this._text.replace(/(?:\r\n|\r)/g,` 1150`)||" ",h=gp(l),c=this._maxWidth*t.size/e,u=t.distanceFieldType==="none"?pu:mu;let d=null,f=0,p=0,g=0,y=-1,m=0,v=0,_=0,b=0;for(let M=0;M<h.length;M++){const B=h[M],S=on(B);if(/(?:\s)/.test(B)&&(y=M,m=f,b++),B==="\r"||B===` 1151`){o.push(f),a.push(-1),p=Math.max(p,f),++g,++v,s.x=0,s.y+=t.lineHeight,d=null,b=0;continue}const I=t.chars[S];if(!I)continue;d&&I.kerning[d]&&(s.x+=I.kerning[d]);const k=_u.pop()||{texture:W.EMPTY,line:0,charCode:0,prevSpaces:0,position:new ot};k.texture=I.texture,k.line=g,k.charCode=S,k.position.x=Math.round(s.x+I.xOffset+this._letterSpacing/2),k.position.y=Math.round(s.y+I.yOffset),k.prevSpaces=b,n.push(k),f=k.position.x+Math.max(I.xAdvance-I.xOffset,I.texture.orig.width),s.x+=I.xAdvance+this._letterSpacing,_=Math.max(_,I.yOffset+I.texture.height),d=S,y!==-1&&c>0&&s.x>c&&(++v,vi(n,1+y-v,1+M-y),M=y,y=-1,o.push(m),a.push(n.length>0?n[n.length-1].prevSpaces:0),p=Math.max(p,m),g++,s.x=0,s.y+=t.lineHeight,d=null,b=0)}const w=h[h.length-1];w!=="\r"&&w!==` 1152`&&(/(?:\s)/.test(w)&&(f=m),o.push(f),p=Math.max(p,f),a.push(-1));const A=[];for(let M=0;M<=g;M++){let B=0;this._align==="right"?B=p-o[M]:this._align==="center"?B=(p-o[M])/2:this._align==="justify"&&(B=a[M]<0?0:(p-o[M])/a[M]),A.push(B)}const x=n.length,C={},T=[],P=this._activePagesMeshData;u.push(...P);for(let M=0;M<x;M++){const B=n[M].texture,S=B.baseTexture.uid;if(!C[S]){let I=u.pop();if(!I){const V=new qx;let O,et;t.distanceFieldType==="none"?(O=new cu(W.EMPTY),et=Z.NORMAL):(O=new cu(W.EMPTY,{program:Ge.from(Ew,Tw),uniforms:{uFWidth:0}}),et=Z.NORMAL_NPM);const E=new hu(V,O);E.blendMode=et,I={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:E,vertices:null,uvs:null,indices:null}}I.index=0,I.indexCount=0,I.vertexCount=0,I.uvsCount=0,I.total=0;const{_textureCache:k}=this;k[S]=k[S]||new W(B.baseTexture),I.mesh.texture=k[S],I.mesh.tint=this._tintColor.value,T.push(I),C[S]=I}C[S].total++}for(let M=0;M<P.length;M++)T.includes(P[M])||this.removeChild(P[M].mesh);for(let M=0;M<T.length;M++)T[M].mesh.parent!==this&&this.addChild(T[M].mesh);this._activePagesMeshData=T;for(const M in C){const B=C[M],S=B.total;if(!(B.indices?.length>6*S)||B.vertices.length<hu.BATCHABLE_SIZE*2)B.vertices=new Float32Array(4*2*S),B.uvs=new Float32Array(4*2*S),B.indices=new Uint16Array(6*S);else{const I=B.total,k=B.vertices;for(let V=I*4*2;V<k.length;V++)k[V]=0}B.mesh.size=6*S}for(let M=0;M<x;M++){const B=n[M];let S=B.position.x+A[B.line]*(this._align==="justify"?B.prevSpaces:1);this._roundPixels&&(S=Math.round(S));const I=S*r,k=B.position.y*r,V=B.texture,O=C[V.baseTexture.uid],et=V.frame,E=V._uvs,R=O.index++;O.indices[R*6+0]=0+R*4,O.indices[R*6+1]=1+R*4,O.indices[R*6+2]=2+R*4,O.indices[R*6+3]=0+R*4,O.indices[R*6+4]=2+R*4,O.indices[R*6+5]=3+R*4,O.vertices[R*8+0]=I,O.vertices[R*8+1]=k,O.vertices[R*8+2]=I+et.width*r,O.vertices[R*8+3]=k,O.vertices[R*8+4]=I+et.width*r,O.vertices[R*8+5]=k+et.height*r,O.vertices[R*8+6]=I,O.vertices[R*8+7]=k+et.height*r,O.uvs[R*8+0]=E.x0,O.uvs[R*8+1]=E.y0,O.uvs[R*8+2]=E.x1,O.uvs[R*8+3]=E.y1,O.uvs[R*8+4]=E.x2,O.uvs[R*8+5]=E.y2,O.uvs[R*8+6]=E.x3,O.uvs[R*8+7]=E.y3}this._textWidth=p*r,this._textHeight=(s.y+t.lineHeight)*r;for(const M in C){const B=C[M];if(this.anchor.x!==0||this.anchor.y!==0){let V=0;const O=this._textWidth*this.anchor.x,et=this._textHeight*this.anchor.y;for(let E=0;E<B.total;E++)B.vertices[V++]-=O,B.vertices[V++]-=et,B.vertices[V++]-=O,B.vertices[V++]-=et,B.vertices[V++]-=O,B.vertices[V++]-=et,B.vertices[V++]-=O,B.vertices[V++]-=et}this._maxLineHeight=_*r;const S=B.mesh.geometry.getBuffer("aVertexPosition"),I=B.mesh.geometry.getBuffer("aTextureCoord"),k=B.mesh.geometry.getIndex();S.data=B.vertices,I.data=B.uvs,k.data=B.indices,S.update(),I.update(),k.update()}for(let M=0;M<n.length;M++)_u.push(n[M]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:e,distanceFieldType:r,size:s}=qe.available[this._fontName];if(r!=="none"){const{a:n,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(n*n+o*o),c=Math.sqrt(a*a+l*l),u=(Math.abs(h)+Math.abs(c))/2,d=this.fontSize/s,f=t._view.resolution;for(const p of this._activePagesMeshData)p.mesh.shader.uniforms.uFWidth=u*e*d*f}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=qe.available[this._fontName];if(!t)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==t&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(t){if(this.tint!==t){this._tintColor.setValue(t);for(let e=0;e<this._activePagesMeshData.length;e++)this._activePagesMeshData[e].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!qe.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??qe.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}
1152set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:e}=this,r=qe.available[this._fontName].distanceFieldType==="none"?pu:mu;r.push(...this._activePagesMeshData);for(const s of this._activePagesMeshData)this.removeChild(s.mesh);this._activePagesMeshData=[],r.filter(s=>e[s.mesh.texture.baseTexture.uid]).forEach(s=>{s.mesh.texture=W.EMPTY});for(const s in e)e[s].destroy(),delete e[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};Aw.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const Sw=[".xml",".fnt"],Cw={extension:{type:U.LoadParser,priority:de.Normal},name:"loadBitmapFont",test(i){return Sw.includes(At.extname(i).toLowerCase())},async testParse(i){return nn.test(i)||vl.test(i)},async parse(i,t,e){const r=nn.test(i)?nn.parse(i):vl.parse(i),{src:s}=t,{page:n}=r,o=[];for(let h=0;h<n.length;++h){const c=n[h].file;let u=At.join(At.dirname(s),c);u=fl(u,s),o.push(u)}const a=await e.load(o),l=o.map(h=>a[h]);return qe.install(r,l,!0)},async load(i,t){return(await H.ADAPTER.fetch(i)).text()},unload(i){i.destroy()}};$.add(Cw);const bl=class ci extends cr{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new ci(Object.keys(ci.defaultOptions).reduce((e,r)=>({...e,[r]:t[r]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(t=>{URL.revokeObjectURL(t.src),t.refs--,t.refs===0&&(t.fontFace&&document.fonts.delete(t.fontFace),delete ci.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:r}=ci;if(r[t]){const s=r[t];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return H.ADAPTER.fetch(t).then(s=>s.blob()).then(async s=>new Promise((n,o)=>{const a=URL.createObjectURL(s),l=new FileReader;l.onload=()=>n([a,l.result]),l.onerror=o,l.readAsDataURL(s)})).then(async([s,n])=>{const o=Object.assign({family:At.basename(t,At.extname(t)),weight:"normal",style:"normal",display:"auto",src:s,dataSrc:n,refs:1,originalUrl:t,fontFace:null},e);r[t]=o,this._fonts.push(o),this.styleID++;const a=new FontFace(o.family,`url(${o.src})`,{weight:o.weight,style:o.style,display:o.display});o.fontFace=a,await a.load(),document.fonts.add(a),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...t){const e=t.filter(r=>!this._overrides.includes(r));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter(r=>this._overrides.includes(r));e.length>0&&(this._overrides=this._overrides.filter(r=>!e.includes(r)),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((t,e)=>`${t} 1153 @font-face { 1154 font-family: "${e.family}"; 1155 src: url('${e.dataSrc}');
1156 font-weight: ${e.weight}; 1157 font-style: ${e.style}; 1158 font-display: ${e.display}; 1159 }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=g1(t)),typeof t=="number"?_1(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,r=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),s=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${r}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,ci.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(e=>setTimeout(e,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=H.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};bl.availableFonts={},bl.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let ha=bl;const Ls=class ui extends Lt{constructor(t="",e={}){super(W.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const r=new Image,s=W.from(r,{scaleMode:H.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new K,s.trim=new K,this.texture=s;const n="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(n,"svg"),l=document.createElementNS(n,"foreignObject"),h=document.createElementNS(o,"div"),c=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=ui.defaultMaxWidth,this.maxHeight=ui.defaultMaxHeight,this._domElement=h,this._styleElement=c,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(c),this._foreignObject.appendChild(h),this._image=r,this._loadImage=new Image,this._autoResolution=ui.defaultAutoResolution,this._resolution=ui.defaultResolution??H.RESOLUTION,this.text=t,this.style=e}measureText(t){const{text:e,style:r,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:r.toCSS(s)}),this._styleElement.textContent=r.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=n;(o>this.maxWidth||a>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const l=Math.min(this.maxWidth,Math.ceil(o)),h=Math.min(this.maxHeight,Math.ceil(a));return this._svgRoot.setAttribute("width",l.toString()),this._svgRoot.setAttribute("height",h.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),r!==this._style&&(Object.assign(this._domElement,{style:this._style?.toCSS(s)}),this._styleElement.textContent=this._style?.toGlobalCSS()),{width:l+r.padding*2,height:h+r.padding*2}}async updateText(t=!0){const{style:e,_image:r,_loadImage:s}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:o}=this.measureText();r.width=s.width=Math.ceil(Math.max(1,n)),r.height=s.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{s.onload=async()=>
1159{if(a<this._updateID){l();return}await e.onBeforeDraw(),r.src=s.src,s.onload=null,s.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:r,resolution:s}=this,{padding:n}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=r.width/s,e.trim.height=e._frame.height=r.height/s,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(r.width,r.height,s),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},ui.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&this._style?.cleanFonts(),this._style=e,this._svgRoot?.remove(),this._svgRoot=e,this._domElement?.remove(),this._domElement=e,this._foreignObject?.remove(),this._foreignObject=e,this._styleElement?.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=rr(this.scale.x)||1;this.scale.x=e*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const e=rr(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof ha?(this.ownsStyle=!1,this._style=t):t instanceof cr?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=ha.from(t)):(this.ownsStyle=!0,this._style=new ha(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," ")}};Ls.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Ls.defaultMaxWidth=2024,Ls.defaultMaxHeight=2024,Ls.defaultAutoResolution=!0;function Iw(i,t,e,r){const s=window.devicePixelRatio||1,n=new Zf({width:t,height:e,antialias:r,backgroundAlpha:0,eventMode:"static"}),o=n.view;n.stage.sortableChildren=!0,o.style.maxWidth=`${t/s}px`,o.style.maxHeight=`${e/s}px`,o.style.width="100%",o.style.height="100%",i.appendChild(n.view);const a=new Dt;a.zIndex=0;const l=new Dt;l.zIndex=1,l.sortableChildren=!0;const h=new Dt;h.zIndex=1;const c=new Dt;c.zIndex=0,h.addChild(a),h.addChild(l),n.stage.addChild(h),n.stage.addChild(c);const u=new Xr;let d=Ft.create({width:t,height:e});const f=new Lt(d);h.mask=f,n.render();function p(m,v){a.removeChildren(),u.beginFill(16777215,1),u.drawRect(0,0,m,v),u.endFill(),d=Ft.create({width:m,height:v}),n.renderer.render(u,{renderTexture:d});const _=new Lt(d);h.mask=_}function g(m,v){n.renderer.resize(m,v),o.style.maxWidth=`${m/s}px`,o.style.maxHeight=`${v/s}px`,p(m,v)}async function y(m,v,[_,b]){const w=await ca(n.renderer,a,v,_,b),A=await Promise.all(m.map(C=>ca(n.renderer,C.composite,v,_,b))),x=await ca(n.renderer,h,v,_,b);return{background:w,layers:A,composite:x}}return{layer_container:l,renderer:n.renderer,destroy:()=>n.destroy(!0),view:n.view,background_container:a,mask_container:h,resize:g,get_blobs:y}}function vp(i){const t=new Xr;return t.eventMode="none",t.zIndex=i,t}function Gt(i,t,e){return i<t?t:i>e?e:i}function ca(i,t,e,r,s){return new Promise(n=>{const o=i.extract.canvas(t,new K(0,0,r,s));let a=document.createElement("canvas");a.width=e.width,a.height=e.height;let l=a.getContext("2d");if(!l)throw n(null),new Error("Could not create canvas context");l.drawImage(o,e.x,e.y,e.width,e.height,0,0,e.width,e.height),a.toBlob?.(h=>{h||n(null),n(h)})})}function ua(i,t,e,r=new ut("black"),s){const n=new ut(r);i.beginFill(n),i.drawCircle(t,e,s),i.endFill()}function Rw(i,t){let e=[];const r=t.x-i.x,s=t.y-i.y,n=Math.sqrt(r*r+s*s),o=Math.ceil(n/2),a=r/o,l=s/o;for(let h=0;h<o;h++){const c=i.x+h*a,u=i.y+h*l;e.push({x:c,y:u})}return e}function Pw(i,t,e,r){const s=[];let n,o,a,l=!1,h=0;return{drawing:!1,start:function({x:c,y:u,size:d,color:f=new ut("black"),opacity:p,set_initial_texture:g=!0}){g&&(a=Ft.create({width:e.draw_texture.width,height:e.draw_texture.height}),i.render(e.composite,{renderTexture:a})),n={x:c,y:u,size:d,color:f,opacity:p},s.push({x:c,y:u}),o=vp(h++),ua(o,c,u,f,d),i.render(o,{renderTexture:r==="draw"?e.draw_texture:e.erase_texture,clear:!1}),this.drawing=!0},continue:function({x:c,y:u}){const d=s[s.length-1],f=Rw(d,{x:c,y:u});for(let p=0;p<f.length;p++){const{x:g,y}=f[p];ua(o,g,y,n.color,n.size),s.push({x:g,y})}i.render(o,{renderTexture:r==="draw"?e.draw_texture:e.erase_texture,clear:!1}),o.clear()},stop:function(){const c=Ft.create({width:e.draw_texture.width,height:e.draw_texture.height});i.render(e.composite,{renderTexture:c}),i.render(new Lt(c),{renderTexture:e.draw_texture});const u=new Xr().beginFill(0,0).drawRect(0,0,e.erase_texture.width,e.erase_texture.height).endFill();i.render(u,{renderTexture:e.erase_texture,clear:!0}),l=!0,this.drawing=!1},execute:function(){if(!l){for(let c=1;c<s.length;c++){const{x:u,y:d}=s[c];ua(o,u,d,n.color,n.size)}i.render(o,{renderTexture:r==="draw"?e.draw_texture:e.erase_texture,clear:!1}),this.stop()}},undo:function(){const c=new Xr().beginFill(0,0).drawRect(0,0,e.erase_texture.width,e.erase_texture.height).endFill();i.render(new Lt(a),{renderTexture:e.draw_texture}),i.render(c,{renderTexture:e.erase_texture,clear:!0}),this.stop(),l=!1}}}function sh(i,t){const e=r=>{i&&!i.contains(r.target)&&!r.defaultPrevented&&t(r)};return document.addEventListener("mousedown",e,!0),{destroy(){document.removeEventListener("mousedown",e,!0)}}}const{SvelteComponent:Mw,append:gu,attr:Us,binding_callbacks:yu,detach:da,element:Gs,init:Bw,insert:fa,listen:Hs,noop:vu,run_all:kw,safe_not_equal:Dw,set_style:pe,space:Fw}=window.__gradio__svelte__internal,{tick:Ow}=window.__gradio__svelte__internal;function Nw(i){let t,e,r=`translate(${i[1][0]}px,${i[1][1]}px)`,s,n,o,a=`translateX(${i[3]}px)`,l,h;return{c(){t=Gs("div"),e=Gs("div"),s=Fw(),n=Gs("div"),o=Gs("div"),Us(e,"class","marker svelte-90y9cx"),pe(e,"transform",r),pe(e,"background",i[0]),Us(t,"class","color-gradient svelte-90y9cx"),pe(t,"--hue",i[2]),Us(o,"class","marker svelte-90y9cx"),pe(o,"background","hsl("+i[2]+", 100%, 50%)"),pe(o,"transform",a),Us(n,"class","hue-slider svelte-90y9cx")},m(c,u){fa(c,t,u),gu(t,e),i[10](t),fa(c,s,u),fa(c,n,u),gu(n,o),i[11](n),l||(h=[Hs(window,"mousemove",i[8]),Hs(window,"mouseup",i[9]),Hs(t,"mousedown",i[7]),Hs(n,"mousedown",i[6])],l=!0)},p(c,[u]){u&2&&r!==(r=`translate(${c[1][0]}px,${c[1][1]}px)`)&&pe(e,"transform",r),u&1&&pe(e,"background",c[0]),u&4&&pe(t,"--hue",c[2]),u&4&&pe(o,"background","hsl("+c[2]+", 100%, 50%)"),u&8&&a!==(a=`translateX(${c[3]}px)`)&&pe(o,"transform",a)},i:vu,o:vu,d(c){c&&(da(t),da(s),da(n)),i[10](null),i[11](null),l=!1,kw(h)}}}function bu(i){const t=i.s,e=i.v;let r=t*e;const s=i.h/60;let n=r*(1-Math.abs(s%2-1));const o=e-r;r=r+o,n=n+o;const a=Math.floor(s)%6,l=[r,n,o,o,n,r][a],h=[n,r,r,n,o,o][a],c=[o,o,n,r,r,n][a];return`rgba(${l*255}, ${h*255}, ${c*255}, ${i.a})`}function Lw(i,t,e){let{color:r="rgb(255, 255, 255)"}=t,s=[0,0],n=null,o=!1,a=[0,0],l=0,h=0,c=null,u=!1;function d(x){c=x.currentTarget.getBoundingClientRect(),u=!0,f(x.clientX)}function f(x){if(!c)return;const C=Gt(x-c.left,0,c.width);e(3,h=C);const T=C/c.width*360;e(2,l=T),e(0,r=bu({h:T,s:a[0],v:a[1],a:1}))}function p(x,C){if(!n)return;const T=Gt(x-n.left,0,n.width),P=Gt(C-n.top,0,n.height);e(1,s=[T,P]);const M={h:l*1,s:T/n.width,v:1-P/n.height,a:1};a=[M.s,M.v],e(0,r=bu(M))}function g(x){o=!0,n=x.currentTarget.getBoundingClientRect(),p(x.clientX,x.clientY)}function y(x){o&&p(x.clientX,x.clientY),u&&f(x.clientX)}function m(){o&&(o=!1),u&&(u=!1)}async function v(x){if(o||u||(await Ow(),!x))return;n||(n=_.getBoundingClientRect()),c||(c=b.getBoundingClientRect());
1159const C=X(x).toHsv(),T=C.s*n.width,P=(1-C.v)*n.height;e(1,s=[T,P]),a=[C.s,C.v],e(2,l=C.h),e(3,h=C.h/360*c.width)}let _,b;function w(x){yu[x?"unshift":"push"](()=>{_=x,e(4,_)})}function A(x){yu[x?"unshift":"push"](()=>{b=x,e(5,b)})}return i.$$set=x=>{"color"in x&&e(0,r=x.color)},i.$$.update=()=>{i.$$.dirty&1&&v(r)},[r,s,l,h,_,b,d,g,y,m,w,A]}class Uw extends Mw{constructor(t){super(),Bw(this,t,Lw,Nw,Dw,{color:0})}}const{SvelteComponent:Gw,append:xu,attr:is,destroy_each:bp,detach:ss,element:ns,ensure_array_like:Hn,init:Hw,insert:os,listen:nh,noop:wu,safe_not_equal:zw,set_style:zn,space:xp,toggle_class:Te}=window.__gradio__svelte__internal,{createEventDispatcher:Xw}=window.__gradio__svelte__internal;function Tu(i,t,e){const r=i.slice();return r[14]=t[e],r[16]=e,r}function Eu(i,t,e){const r=i.slice();return r[14]=t[e],r[16]=e,r}function Au(i){let t,e,r,s,n,o=Hn(i[1]),a=[];for(let l=0;l<o.length;l+=1)a[l]=Su(Eu(i,o,l));return{c(){t=ns("div");for(let l=0;l<a.length;l+=1)a[l].c();e=xp(),r=ns("button"),is(r,"class","color colorpicker svelte-1nrqo0k"),Te(r,"hidden",!i[0]),is(t,"class","swatch svelte-1nrqo0k")},m(l,h){os(l,t,h);for(let c=0;c<a.length;c+=1)a[c]&&a[c].m(t,null);xu(t,e),xu(t,r),s||(n=nh(r,"click",i[5]),s=!0)},p(l,h){if(h&22){o=Hn(l[1]);let c;for(c=0;c<o.length;c+=1){const u=Eu(l,o,c);a[c]?a[c].p(u,h):(a[c]=Su(u),a[c].c(),a[c].m(t,e))}for(;c<a.length;c+=1)a[c].d(1);a.length=o.length}h&1&&Te(r,"hidden",!l[0])},d(l){l&&ss(t),bp(a,l),s=!1,n()}}}function Su(i){let t,e,r;function s(){return i[10](i[16],i[14])}return{c(){t=ns("button"),is(t,"class","color svelte-1nrqo0k"),zn(t,"background-color",i[14]),Te(t,"empty",i[14]===null),Te(t,"selected",`edit-${i[16]}`===i[2])},m(n,o){os(n,t,o),e||(r=nh(t,"click",s),e=!0)},p(n,o){i=n,o&2&&zn(t,"background-color",i[14]),o&2&&Te(t,"empty",i[14]===null),o&4&&Te(t,"selected",`edit-${i[16]}`===i[2])},d(n){n&&ss(t),e=!1,r()}}}function Cu(i){let t,e,r;function s(){return i[11](i[16],i[14])}return{c(){t=ns("button"),is(t,"class","color svelte-1nrqo0k"),zn(t,"background-color",i[14]),Te(t,"empty",i[14]===null),Te(t,"selected",`select-${i[16]}`===i[2])},m(n,o){os(n,t,o),e||(r=nh(t,"click",s),e=!0)},p(n,o){i=n,o&8&&zn(t,"background-color",i[14]),o&8&&Te(t,"empty",i[14]===null),o&4&&Te(t,"selected",`select-${i[16]}`===i[2])},d(n){n&&ss(t),e=!1,r()}}}function Vw(i){let t,e,r=i[1]&&Au(i),s=Hn(i[3]),n=[];for(let o=0;o<s.length;o+=1)n[o]=Cu(Tu(i,s,o));return{c(){r&&r.c(),t=xp(),e=ns("menu");for(let o=0;o<n.length;o+=1)n[o].c();is(e,"class","swatch svelte-1nrqo0k")},m(o,a){r&&r.m(o,a),os(o,t,a),os(o,e,a);for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(e,null)},p(o,[a]){if(o[1]?r?r.p(o,a):(r=Au(o),r.c(),r.m(t.parentNode,t)):r&&(r.d(1),r=null),a&28){s=Hn(o[3]);let l;for(l=0;l<s.length;l+=1){const h=Tu(o,s,l);n[l]?n[l].p(h,a):(n[l]=Cu(h),n[l].c(),n[l].m(e,null))}for(;l<n.length;l+=1)n[l].d(1);n.length=s.length}},i:wu,o:wu,d(o){o&&(ss(t),ss(e)),r&&r.d(o),bp(n,o)}}}function Ww(i,t,e){let r,{selected_color:s}=t,{colors:n}=t,{user_colors:o=[]}=t,{show_empty:a=!1}=t,{current_mode:l="hex"}=t,{color_picker:h=!1}=t;const c=Xw();function u(m,v){return v==="hex"?X(m).toHexString():v==="rgb"?X(m).toRgbString():X(m).toHslString()}let d=`select-${n.findIndex(m=>u(m,l)===u(s,l))}`;function f(m,v){e(2,d=`${m}-${v.index}`),c(m,v)}function p(){c("select",{index:null,color:s}),e(0,h=!h)}const g=(m,v)=>f("edit",{index:m,color:v}),y=(m,v)=>f("select",{index:m,color:v});return i.$$set=m=>{"selected_color"in m&&e(6,s=m.selected_color),"colors"in m&&e(7,n=m.colors),"user_colors"in m&&e(1,o=m.user_colors),"show_empty"in m&&e(8,a=m.show_empty),"current_mode"in m&&e(9,l=m.current_mode),"color_picker"in m&&e(0,h=m.color_picker)},i.$$.update=()=>{i.$$.dirty&384&&e(3,r=a?n:n.filter(m=>m))},[h,o,d,r,f,p,s,n,a,l,g,y]}class $w extends Gw{constructor(t){super(),Hw(this,t,Ww,Vw,zw,{selected_color:6,colors:7,user_colors:1,show_empty:8,current_mode:9,color_picker:0})}}const{SvelteComponent:jw,append:De,attr:Ze,create_component:Yw,destroy_component:qw,destroy_each:Zw,detach:wp,element:Ke,ensure_array_like:Iu,init:Kw,insert:Tp,listen:an,mount_component:Jw,run_all:Qw,safe_not_equal:tT,set_style:Ru,space:pa,toggle_class:Pu,transition_in:Ep,transition_out:Ap}=window.__gradio__svelte__internal,{createEventDispatcher:eT}=window.__gradio__svelte__internal;function Mu(i,t,e){const r=i.slice();return r[11]=t[e][0],r[12]=t[e][1],r}function rT(i){let t,e;return t=new Qm({}),{c(){Yw(t.$$.fragment)},m(r,s){Jw(t,r,s),e=!0},i(r){e||(Ep(t.$$.fragment,r),e=!0)},o(r){Ap(t.$$.fragment,r),e=!1},d(r){qw(t,r)}}}function Bu(i){let t,e,r;function s(){return i[8](i[12])}return{c(){t=Ke("button"),t.textContent=`${i[11]}`,Ze(t,"class","button svelte-w84deg"),Pu(t,"active",i[1]===i[12])},m(n,o){Tp(n,t,o),e||(r=an(t,"click",s),e=!0)},p(n,o){i=n,o&10&&Pu(t,"active",i[1]===i[12])},d(n){n&&wp(t),e=!1,r()}}}function iT(i){let t,e,r,s,n,o,a,l,h,c,u,d,f,p=i[5]&&rT(),g=Iu(i[3]),y=[];for(let m=0;m<g.length;m+=1)y[m]=Bu(Mu(i,g,m));return{c(){t=Ke("div"),e=Ke("button"),r=pa(),s=Ke("div"),n=Ke("div"),o=Ke("input"),a=pa(),l=Ke("button"),p&&p.c(),h=pa(),c=Ke("div");for(let m=0;m<y.length;m+=1)y[m].c();Ze(e,"class","swatch svelte-w84deg"),Ru(e,"background",i[0]),Ze(o,"type","text"),o.value=i[2],Ze(o,"class","svelte-w84deg"),Ze(l,"class","eyedropper svelte-w84deg"),Ze(n,"class","input-wrap svelte-w84deg"),Ze(c,"class","buttons svelte-w84deg"),Ze(t,"class","input svelte-w84deg")},m(m,v){Tp(m,t,v),De(t,e),De(t,r),De(t,s),De(s,n),De(n,o),De(n,a),De(n,l),p&&p.m(l,null),De(s,h),De(s,
1159c);for(let _=0;_<y.length;_+=1)y[_]&&y[_].m(c,null);u=!0,d||(f=[an(e,"click",i[6]),an(o,"change",i[7]),an(l,"click",i[4])],d=!0)},p(m,[v]){if(v&1&&Ru(e,"background",m[0]),(!u||v&4&&o.value!==m[2])&&(o.value=m[2]),v&10){g=Iu(m[3]);let _;for(_=0;_<g.length;_+=1){const b=Mu(m,g,_);y[_]?y[_].p(b,v):(y[_]=Bu(b),y[_].c(),y[_].m(c,null))}for(;_<y.length;_+=1)y[_].d(1);y.length=g.length}},i(m){u||(Ep(p),u=!0)},o(m){Ap(p),u=!1},d(m){m&&wp(t),p&&p.d(),Zw(y,m),d=!1,Qw(f)}}}function sT(i,t,e){let r,{color:s}=t,{current_mode:n="hex"}=t;const o=eT(),a=[["Hex","hex"],["RGB","rgb"],["HSL","hsl"]];function l(p,g){return g==="hex"?X(p).toHexString():g==="rgb"?X(p).toRgbString():X(p).toHslString()}function h(){new EyeDropper().open().then(g=>{e(0,s=g.sRGBHex)})}const c=!!window.EyeDropper;function u(){o("selected",r),o("close")}const d=p=>e(0,s=p.currentTarget.value),f=p=>e(1,n=p);return i.$$set=p=>{"color"in p&&e(0,s=p.color),"current_mode"in p&&e(1,n=p.current_mode)},i.$$.update=()=>{i.$$.dirty&3&&e(2,r=l(s,n)),i.$$.dirty&4&&r&&o("selected",r)},[s,n,r,a,h,c,u,d,f]}class nT extends jw{constructor(t){super(),Kw(this,t,sT,iT,tT,{color:0,current_mode:1})}}const{SvelteComponent:oT,action_destroyer:aT,add_flush_callback:xl,add_iframe_resize_listener:lT,add_render_callback:ku,append:hT,attr:cT,bind:wl,binding_callbacks:Xn,check_outros:Sp,create_component:Tl,destroy_component:El,detach:oh,element:uT,empty:dT,group_outros:Cp,init:fT,insert:ah,listen:pT,mount_component:Al,run_all:mT,safe_not_equal:_T,space:Ip,toggle_class:$e,transition_in:He,transition_out:Nr}=window.__gradio__svelte__internal,{createEventDispatcher:gT}=window.__gradio__svelte__internal;function Du(i){let t,e,r=i[9]&&Fu(i);return{c(){r&&r.c(),t=dT()},m(s,n){r&&r.m(s,n),ah(s,t,n),e=!0},p(s,n){s[9]?r?(r.p(s,n),n&512&&He(r,1)):(r=Fu(s),r.c(),He(r,1),r.m(t.parentNode,t)):r&&(Cp(),Nr(r,1,1,()=>{r=null}),Sp())},i(s){e||(He(r),e=!0)},o(s){Nr(r),e=!1},d(s){s&&oh(t),r&&r.d(s)}}}function Fu(i){let t,e,r,s,n,o;function a(u){i[16](u)}let l={};i[0]!==void 0&&(l.color=i[0]),t=new Uw({props:l}),Xn.push(()=>wl(t,"color",a));function h(u){i[17](u)}let c={color:i[0]};return i[10]!==void 0&&(c.current_mode=i[10]),s=new nT({props:c}),Xn.push(()=>wl(s,"current_mode",h)),s.$on("close",i[18]),s.$on("selected",i[19]),{c(){Tl(t.$$.fragment),r=Ip(),Tl(s.$$.fragment)},m(u,d){Al(t,u,d),ah(u,r,d),Al(s,u,d),o=!0},p(u,d){const f={};!e&&d&1&&(e=!0,f.color=u[0],xl(()=>e=!1)),t.$set(f);const p={};d&1&&(p.color=u[0]),!n&&d&1024&&(n=!0,p.current_mode=u[10],xl(()=>n=!1)),s.$set(p)},i(u){o||(He(t.$$.fragment,u),He(s.$$.fragment,u),o=!0)},o(u){Nr(t.$$.fragment,u),Nr(s.$$.fragment,u),o=!1},d(u){u&&oh(r),El(t,u),El(s,u)}}}function yT(i){let t,e,r,s,n,o,a,l;ku(i[15]);let h=i[3]==="defaults"&&Du(i);function c(d){i[20](d)}let u={colors:i[2],user_colors:i[3]==="defaults"?i[1]:null,selected_color:i[0],current_mode:i[10]};return i[9]!==void 0&&(u.color_picker=i[9]),r=new $w({props:u}),Xn.push(()=>wl(r,"color_picker",c)),r.$on("select",i[21]),r.$on("edit",i[22]),{c(){t=uT("div"),h&&h.c(),e=Ip(),Tl(r.$$.fragment),cT(t,"class","wrap svelte-1pyj3ft"),ku(()=>i[25].call(t)),$e(t,"padded",!i[9]),$e(t,"right",i[11]),$e(t,"top",i[12]),$e(t,"bottom",!i[12])},m(d,f){ah(d,t,f),h&&h.m(t,null),hT(t,e),Al(r,t,null),i[24](t),n=lT(t,i[25].bind(t)),o=!0,a||(l=[pT(window,"resize",i[15]),aT(sh.call(null,t,i[23]))],a=!0)},p(d,[f]){d[3]==="defaults"?h?(h.p(d,f),f&8&&He(h,1)):(h=Du(d),h.c(),He(h,1),h.m(t,e)):h&&(Cp(),Nr(h,1,1,()=>{h=null}),Sp());const p={};f&4&&(p.colors=d[2]),f&10&&(p.user_colors=d[3]==="defaults"?d[1]:null),f&1&&(p.selected_color=d[0]),f&1024&&(p.current_mode=d[10]),!s&&f&512&&(s=!0,p.color_picker=d[9],xl(()=>s=!1)),r.$set(p),(!o||f&512)&&$e(t,"padded",!d[9]),(!o||f&2048)&&$e(t,"right",d[11]),(!o||f&4096)&&$e(t,"top",d[12]),(!o||f&4096)&&$e(t,"bottom",!d[12])},i(d){o||(He(h),He(r.$$.fragment,d),o=!0)},o(d){Nr(h),Nr(r.$$.fragment,d),o=!1},d(d){d&&oh(t),h&&h.d(),El(r),i[24](null),n(),a=!1,mT(l)}}}function vT(i,t,e){let{colors:r}=t,{selected_color:s}=t,{color_mode:n=void 0}=t,{recent_colors:o=[]}=t,a=!1,l="hex",h=null;const c=gT();function u({index:k,color:V},O){O==="user"&&!V&&(h=k,e(9,a=!0)),V&&(e(0,s=V),O==="core"&&e(9,a=!1))}function d(k){h!==null&&e(1,o[h]=k,o)}let f=0,p=0,g=0,y=0,m,v=!1,_=!1;function b(){e(5,p=window.innerHeight),e(4,f=window.innerWidth)}function w(k){s=k,e(0,s)}function A(k){l=k,e(10,l)}const x=()=>e(9,a=!1),C=({detail:k})=>e(0,s=k);function T(k){a=k,e(9,a)}const P=({detail:k})=>u(k,"core"),M=({detail:k})=>u(k,"user"),B=()=>c("click_outside");function S(k){Xn[k?"unshift":"push"](()=>{m=k,e(8,m)})}
1159function I(){g=this.clientWidth,y=this.clientHeight,e(6,g),e(7,y)}return i.$$set=k=>{"colors"in k&&e(2,r=k.colors),"selected_color"in k&&e(0,s=k.selected_color),"color_mode"in k&&e(3,n=k.color_mode),"recent_colors"in k&&e(1,o=k.recent_colors)},i.$$.update=()=>{if(i.$$.dirty&1&&d(s),i.$$.dirty&496&&m&&(f||p||y||g)){const k=m.getBoundingClientRect();e(11,v=k.width+30>f/2),e(12,_=k.y<80)}},[s,o,r,n,f,p,g,y,m,a,l,v,_,c,u,b,w,A,x,C,T,P,M,B,S,I]}class bT extends oT{constructor(t){super(),fT(this,t,vT,yT,_T,{colors:2,selected_color:0,color_mode:3,recent_colors:1})}}const{SvelteComponent:xT,action_destroyer:wT,add_iframe_resize_listener:TT,add_render_callback:Ou,append:ET,attr:wr,binding_callbacks:AT,detach:ST,element:Nu,init:CT,insert:IT,listen:ma,noop:Lu,run_all:RT,safe_not_equal:PT,set_input_value:Uu,to_number:MT,toggle_class:ti}=window.__gradio__svelte__internal,{createEventDispatcher:BT}=window.__gradio__svelte__internal;function kT(i){let t,e,r,s,n;return Ou(i[11]),{c(){t=Nu("div"),e=Nu("input"),wr(e,"type","range"),wr(e,"min",i[1]),wr(e,"max",i[2]),wr(e,"step",1),wr(t,"class","wrap svelte-b3dw9m"),Ou(()=>i[15].call(t)),ti(t,"right",i[8]),ti(t,"top",i[9]),ti(t,"bottom",!i[9])},m(o,a){IT(o,t,a),ET(t,e),Uu(e,i[0]),i[14](t),r=TT(t,i[15].bind(t)),s||(n=[ma(window,"resize",i[11]),ma(e,"change",i[12]),ma(e,"input",i[12]),wT(sh.call(null,t,i[13]))],s=!0)},p(o,[a]){a&2&&wr(e,"min",o[1]),a&4&&wr(e,"max",o[2]),a&1&&Uu(e,o[0]),a&256&&ti(t,"right",o[8]),a&512&&ti(t,"top",o[9]),a&512&&ti(t,"bottom",!o[9])},i:Lu,o:Lu,d(o){o&&ST(t),i[14](null),r(),s=!1,RT(n)}}}function DT(i,t,e){let{selected_size:r}=t,{min:s}=t,{max:n}=t;const o=BT();let a=0,l=0,h=0,c=0,u,d=!1,f=!1;function p(){e(4,l=window.innerHeight),e(3,a=window.innerWidth)}function g(){r=MT(this.value),e(0,r)}const y=()=>o("click_outside");function m(_){AT[_?"unshift":"push"](()=>{u=_,e(7,u)})}function v(){h=this.clientWidth,c=this.clientHeight,e(5,h),e(6,c)}return i.$$set=_=>{"selected_size"in _&&e(0,r=_.selected_size),"min"in _&&e(1,s=_.min),"max"in _&&e(2,n=_.max)},i.$$.update=()=>{if(i.$$.dirty&248&&u&&(a||l||c||h)){const _=u.getBoundingClientRect();e(8,d=_.width+30>a/2),e(9,f=_.y<80)}},[r,s,n,a,l,h,c,u,d,f,o,p,g,y,m,v]}class FT extends xT{constructor(t){super(),CT(this,t,DT,kT,PT,{selected_size:0,min:1,max:2})}}const{SvelteComponent:OT,add_flush_callback:Sl,attr:NT,bind:Cl,binding_callbacks:Il,check_outros:LT,component_subscribe:ei,create_component:Rp,destroy_component:Pp,detach:ln,element:Mp,empty:UT,group_outros:GT,init:HT,insert:hn,listen:zT,mount_component:Bp,safe_not_equal:XT,set_style:qt,space:VT,transition_in:Vn,transition_out:Wn}=window.__gradio__svelte__internal,{getContext:Gu,onMount:WT,tick:QS}=window.__gradio__svelte__internal;function $T(i){let t,e,r;function s(o){i[26](o)}let n={max:i[5][0]/10,min:1};return i[3]!==void 0&&(n.selected_size=i[3]),t=new FT({props:n}),Il.push(()=>Cl(t,"selected_size",s)),t.$on("click_outside",i[27]),{c(){Rp(t.$$.fragment)},m(o,a){Bp(t,o,a),r=!0},p(o,a){const l={};a[0]&32&&(l.max=o[5][0]/10),!e&&a[0]&8&&(e=!0,l.selected_size=o[3],Sl(()=>e=!1)),t.$set(l)},i(o){r||(Vn(t.$$.fragment,o),r=!0)},o(o){Wn(t.$$.fragment,o),r=!1},d(o){Pp(t,o)}}}function jT(i){let t,e,r,s,n;function o(h){i[23](h)}function a(h){i[24](h)}let l={colors:i[11],color_mode:i[1]};return i[2]!==void 0&&(l.selected_color=i[2]),i[8]!==void 0&&(l.recent_colors=i[8]),e=new bT({props:l}),Il.push(()=>Cl(e,"selected_color",o)),Il.push(()=>Cl(e,"recent_colors",a)),e.$on("click_outside",i[25]),{c(){t=Mp("div"),Rp(e.$$.fragment)},m(h,c){hn(h,t,c),Bp(e,t,null),n=!0},p(h,c){const u={};c[0]&2&&(u.color_mode=h[1]),!r&&c[0]&4&&(r=!0,u.selected_color=h[2],Sl(()=>r=!1)),!s&&c[0]&256&&(s=!0,u.recent_colors=h[8],Sl(()=>s=!1)),e.$set(u)},i(h){n||(Vn(e.$$.fragment,h),n=!0)},o(h){Wn(e.$$.fragment,h),n=!1},d(h){h&&ln(t),Pp(e)}}}function YT(i){let t,e=`translate(${i[9].x}px, ${i[9].y}px)`,r=`${i[4].child_top-i[4].parent_top-i[10]/2}px`,s=`${i[4].child_left-i[4].parent_left-i[10]/2}px`,n=`${i[10]}px`,o=`${i[10]}px`,a,l,h,c,u,d,f;const p=[jT,$T],g=[];function y(m,v){return m[6]==="color"&&m[0]?0:m[6]==="size"?1:-1}return~(l=y(i))&&(h=g[l]=p[l](i)),{c(){t=Mp("span"),a=VT(),h&&h.c(),c=UT(),NT(t,"class","svelte-btgkrd"),qt(t,"transform",e),qt(t,"top",r),qt(t,"left",s
1159),qt(t,"width",n),qt(t,"height",o),qt(t,"opacity",i[7]?1:0)},m(m,v){hn(m,t,v),hn(m,a,v),~l&&g[l].m(m,v),hn(m,c,v),u=!0,d||(f=zT(window,"keydown",i[22]),d=!0)},p(m,v){v[0]&512&&e!==(e=`translate(${m[9].x}px, ${m[9].y}px)`)&&qt(t,"transform",e),v[0]&1040&&r!==(r=`${m[4].child_top-m[4].parent_top-m[10]/2}px`)&&qt(t,"top",r),v[0]&1040&&s!==(s=`${m[4].child_left-m[4].parent_left-m[10]/2}px`)&&qt(t,"left",s),v[0]&1024&&n!==(n=`${m[10]}px`)&&qt(t,"width",n),v[0]&1024&&o!==(o=`${m[10]}px`)&&qt(t,"height",o),v[0]&128&&qt(t,"opacity",m[7]?1:0);let _=l;l=y(m),l===_?~l&&g[l].p(m,v):(h&&(GT(),Wn(g[_],1,1,()=>{g[_]=null}),LT()),~l?(h=g[l],h?h.p(m,v):(h=g[l]=p[l](m),h.c()),Vn(h,1),h.m(c.parentNode,c)):h=null)},i(m){u||(Vn(h),u=!0)},o(m){Wn(h),u=!1},d(m){m&&(ln(t),ln(a),ln(c)),~l&&g[l].d(m),d=!1,f()}}}function qT(i,t,e){let r,s,n,o,a,l,h,{default_size:c}=t,{default_color:u=void 0}=t,{colors:d=void 0}=t,{color_mode:f=void 0}=t,{mode:p}=t;const g=d?d.map(J).filter((N,lt)=>lt<5):[];let y=u==="auto"?g[0]:u?J(u):"black";const m={color:{icon:o_,label:"Color",order:0,id:"brush_color",cb(){e(6,_="color")}},size:{icon:Pm,label:"Size",order:1,id:"brush_size",cb(){e(6,_="size")}}};let v,_=null;const{pixi:b,dimensions:w,current_layer:A,command_manager:x,register_context:C,editor_box:T,crop:P}=Gu(Bi);ei(i,b,N=>e(31,a=N)),ei(i,w,N=>e(5,n=N)),ei(i,A,N=>e(33,h=N)),ei(i,T,N=>e(4,s=N)),ei(i,P,N=>e(32,l=N));const{active_tool:M,register_tool:B,current_color:S}=Gu(Yn);ei(i,M,N=>e(21,o=N));let I=!1,k;function V(N,lt){const Rt=Gt(Math.min(N,lt),500,1e3);return Math.round(Rt*2/100)}let O=c==="auto"?V(...n):c;function et(N){o===p&&(I=!0,!(!a||!h)&&(k=Pw(a.renderer,a.layer_container,h,p),k.start({x:N.screen.x,y:N.screen.y,color:y||void 0,size:O,opacity:1})))}function E(N){!a||!h||o===p&&(k.stop(),x.execute(k),I=!1)}function R(N){if(o!==p)return;I&&k.continue({x:N.screen.x,y:N.screen.y});const lt=l[0]*n[0],Rt=l[1]*n[1];lt>N.screen.x||Rt>N.screen.y||N.screen.x>lt+l[2]*n[0]||N.screen.y>Rt+l[3]*n[1]?(e(7,L=!1),document.body.style.cursor="auto"):(e(7,L=!0),document.body.style.cursor="none"),L&&e(9,st={x:N.clientX-s.child_left,y:N.clientY-s.child_top})}let L=!1;async function Y(N){a?.layer_container[N]("pointerdown",et),a?.layer_container[N]("pointerup",E),a?.layer_container[N]("pointermove",R),a?.layer_container[N]("pointerenter",lt=>{o===p&&(e(7,L=!0),document.body.style.cursor="none")}),a?.layer_container[N]("pointerleave",()=>(e(7,L=!1),document.body.style.cursor="auto"))}C(p,{init_fn:()=>{Y("on")},reset_fn:()=>{Y("off")}}),WT(()=>{const N=B(p,{default:null,options:v});return()=>{N(),Y("off")}});let tt=[null,null,null];function J(N){return X(N).toRgbString()}let st={x:0,y:0};const at=({key:N})=>N==="Escape"&&e(6,_=null);function ht(N){y=N,e(2,y)}function yt(N){tt=N,e(8,tt)}const wt=()=>e(6,_=null);function D(N){O=N,e(3,O)}const ct=()=>e(6,_=null);return i.$$set=N=>{"default_size"in N&&e(18,c=N.default_size),"default_color"in N&&e(19,u=N.default_color),"colors"in N&&e(0,d=N.colors),"color_mode"in N&&e(1,f=N.color_mode),"mode"in N&&e(20,p=N.mode)},i.$$.update=()=>{i.$$.dirty[0]&1048576&&(v=p==="draw"?Object.values(m):[m.size]),i.$$.dirty[0]&1048580&&p==="draw"&&S.set(y),i.$$.dirty[0]&3145728&&o!==p&&e(6,_=null),i.$$.dirty[0]&56&&e(10,r=O/n[0]*s.child_width*2)},[d,f,y,O,s,n,_,L,tt,st,r,g,b,w,A,T,P,M,c,u,p,o,at,ht,yt,wt,D,ct]}class kp extends OT{constructor(t){super(),HT(this,t,qT,YT,XT,{default_size:18,default_color:19,colors:0,color_mode:1,mode:20},null,[-1,-1])}}function Hu(i,t,e,r=0){let s,n;const o=new Xr;let a,l,h,c,u=Ed(r,{stiffness:.1,damping:.5}),d=r;u.subscribe(y=>{l&&(d=y,f(h,c,l,!0))});function f(y,m,v,_){o.clear(),_&&(o.beginFill(16777215,d),o.drawRect(0,0,y,m),o.endFill()),o.beginFill(16777215,1),o.drawRect(...v),o.endFill(),i.render(o,{renderTexture:s})}let p=!0,g=!1;return{start:(y,m,v,_=!0)=>{p=!1,s=Ft.create({width:y,height:m}),f(y,m,v,!0),n=new Lt(s),t.mask=n,h=y,c=m,_&&(a=JSON.parse(JSON.stringify(v)))},continue:y=>{l=JSON.parse(JSON.stringify(y)),d===.2?f(h,c,l,!0):u.set(.2)},undo(){this.start(h,c,a,!1),e.set([a[0]/h,a[1]/c,a[2]/h,a[3]/c]),p=!0},stop(){return g=!0,d},execute(){p?(this.start(h,c,l,!1),e.set([l[0]/h,l[1]/c,l[2]/h,l[3]/c]),p=!0):(g||u.set(0),e.set([l[0]/h,l[1]/c,l[2]/h,l[3]/c]),p=!0)}}}function Dp(i,t,e,r,s,n){let o=i,a=t;(e.includes("t")||e.includes("b")||e=="c")&&(o=t*r),(e.includes("l")||e.includes("r")||e=="c")&&(a=i/r),a=a||o/r,o=o||a*r,o>s&&(o=s,a=o/r),a>n&&(a=n,o=a*r);let l=0,h=0;return e.includes("r")?l=i-o:e.includes("l")?l=0:l=(i-o)/2,e.includes("b")?h=t-a:e.includes("t")?h=0:h=(t-a)/2,{new_width:o,new_height:a,x_offset:l,
1159y_offset:h}}const{SvelteComponent:ZT,append:KT,attr:zs,binding_callbacks:JT,detach:QT,element:zu,init:tE,insert:eE,listen:_a,noop:Xu,run_all:rE,safe_not_equal:iE,set_style:Vu}=window.__gradio__svelte__internal,{tick:sE,createEventDispatcher:nE}=window.__gradio__svelte__internal;function oE(i){let t,e,r,s,n,o;return{c(){t=zu("div"),e=zu("div"),zs(e,"class",r="handle "+i[0]+" "+i[1]+" svelte-29tqs9"),zs(t,"class",s="hitbox "+i[1]+" svelte-29tqs9"),Vu(t,"transform",i[3])},m(a,l){eE(a,t,l),KT(t,e),i[12](e),n||(o=[_a(window,"mousemove",i[5]),_a(window,"mouseup",i[6]),_a(t,"mousedown",i[4])],n=!0)},p(a,[l]){l&3&&r!==(r="handle "+a[0]+" "+a[1]+" svelte-29tqs9")&&zs(e,"class",r),l&2&&s!==(s="hitbox "+a[1]+" svelte-29tqs9")&&zs(t,"class",s),l&8&&Vu(t,"transform",a[3])},i:Xu,o:Xu,d(a){a&&QT(t),i[12](null),n=!1,rE(o)}}}function aE(i,t,e){let r,{type:s="corner"}=t,{location:n}=t,{x1:o=0}=t,{y1:a=0}=t,{x2:l=0}=t,{y2:h=0}=t,c,u=0,d=0,f=!1;const p=nE();let{dragging:g=!1}=t,y;function m(A){c=y.getBoundingClientRect(),f=!0,e(11,g=!0),["tl","bl","l"].includes(n)&&(d=A.clientX-c.right),["tl","tr","t"].includes(n)&&(u=A.clientY-c.bottom),["tr","r","br"].includes(n)&&(d=A.clientX-c.left),["br","b","bl"].includes(n)&&(u=A.clientY-c.top)}function v(A){if(!f)return;const x=A.clientY-u,C=A.clientY-u,T=A.clientX-d,P=A.clientX-d;["tl","bl","l"].includes(n)&&e(7,o=T),["tl","tr","t"].includes(n)&&e(8,a=x),["tr","r","br"].includes(n)&&e(9,l=P),["br","b","bl"].includes(n)&&e(10,h=C)}async function _(A){await sE(),f=!1,e(11,g=!1)}function b(A,x,C,T,P){let M,B,S,I;return c&&(["tl","l","bl"].includes(A)&&(B=x),["tl","t","tr"].includes(A)&&(M=T),["tr","r","br"].includes(A)&&(S=C),["br","b","bl"].includes(A)&&(I=P)),p("change",{top:M,bottom:I,left:B,right:S}),""}function w(A){JT[A?"unshift":"push"](()=>{y=A,e(2,y)})}return i.$$set=A=>{"type"in A&&e(0,s=A.type),"location"in A&&e(1,n=A.location),"x1"in A&&e(7,o=A.x1),"y1"in A&&e(8,a=A.y1),"x2"in A&&e(9,l=A.x2),"y2"in A&&e(10,h=A.y2),"dragging"in A&&e(11,g=A.dragging)},i.$$.update=()=>{i.$$.dirty&1922&&e(3,r=b(n,o,l,a,h))},[s,n,y,r,m,v,_,o,a,l,h,g,w]}class lE extends ZT{constructor(t){super(),tE(this,t,aE,oE,iE,{type:0,location:1,x1:7,y1:8,x2:9,y2:10,dragging:11})}}const{SvelteComponent:hE,add_flush_callback:cE,append:ga,attr:cn,bind:uE,binding_callbacks:dE,check_outros:fE,create_component:pE,destroy_component:mE,destroy_each:Wu,detach:Fp,element:un,ensure_array_like:ya,group_outros:_E,init:gE,insert:Op,listen:va,mount_component:yE,noop:Np,run_all:vE,safe_not_equal:bE,set_style:je,space:xE,subscribe:wE,toggle_class:$u,transition_in:dn,transition_out:Rl}=window.__gradio__svelte__internal,{createEventDispatcher:TE}=window.__gradio__svelte__internal;function EE(i,t,e){const r=i.slice();return r[30]=t[e],r}function ju(i,t,e){const r=i.slice();return r[33]=t[e],r}function Yu(i){let t,e,r;function s(a){i[20](a)}function n(...a){return i[21](i[33],...a)}let o={location:i[33]};return i[1]!==void 0&&(o.dragging=i[1]),t=new lE({props:o}),dE.push(()=>uE(t,"dragging",s)),t.$on("change",n),{c(){pE(t.$$.fragment)},m(a,l){yE(t,a,l),r=!0},p(a,l){i=a;const h={};!e&&l[0]&2&&(e=!0,h.dragging=i[1],cE(()=>e=!1)),t.$set(h)},i(a){r||(dn(t.$$.fragment,a),r=!0)},o(a){Rl(t.$$.fragment,a),r=!1},d(a){mE(t,a)}}}function AE(i){let t;return{c(){t=un("div"),cn(t,"class","svelte-ae5ytx")},m(e,r){Op(e,t,r)},p:Np,d(e){e&&Fp(t)}}}function SE(i){let t,e,r,s,n=`${i[3]}px`,o=`${i[2]}px`,a=`${i[4]}px`,l=`${i[5]}px`,h,c,u,d=ya(i[7]),f=[];for(let m=0;m<d.length;m+=1)f[m]=Yu(ju(i,d,m));const p=m=>Rl(f[m],1,1,()=>{f[m]=null});let g=ya({length:25}),y=[];for(let m=0;m<g.length;m+=1)y[m]=AE(EE(i,g,m));return{c(){t=un("div"),e=un("div");for(let m=0;m<f.length;m+=1)f[m].c();r=xE(),s=un("div");for(let m=0;m<y.length;m+=1)y[m].c();cn(s,"class","grid svelte-ae5ytx"),$u(s,"finished",i[6]),cn(e,"class","box svelte-ae5ytx"),je(e,"width",n),je(e,"height",o),je(e,"top",a),je(e,"left",l),cn(t,"class","wrap svelte-ae5ytx")},m(m,v){Op(m,t,v),ga(t,e);for(let _=0;_<f.length;_+=1)f[_]&&f[_].m(e,null);ga(e,r),ga(e,s);for(let _=0;_<y.length;_+=1)y[_]&&y[_].m(s,null);h=!0,c||(u=[va(window,"mousemove",i[11]),va(window,"mouseup",i[10]),va(s,"mousedown",i[9])],c=!0)},p(m,v){if(v[0]&386){d=ya(m[7]);let _;for(_=0;_<d.length;_+=1){const b=ju(m,d,_);f[_]?(f[_].p(b,v),dn(f[_],1)):(f[_]=Yu(b),f[_].c(),dn(f[_],1),f[_].m(e,r))}for(_E(),_=d.length;_<f.length;_+=1)p(_);fE()}(!h||v[0]&64)&&$u(s,"finished",m[6]),v[0]&8&&n!==(n=`${m[3]}px`)&&je(e,"width",n),v[0]&4&&o!==(o=`${m[2]}px`)&&je(e,"height",o),v[0]&16&&a!==(a=`${m[4]}px`)&&je(e,"top",a),v[0]&32&&l!==(l=`${m[5]}px`)&&je(e,"left",l)},i(m){if(!h){for(let v=0;v<d.length;v+=1)dn(f[v]);h=!0}},o(m){f=f.filter(Boolean);for(let v=0;v<f.length;v+=1)Rl(f[v]);h=!1},d(m){m&&Fp(t),Wu(f,m),Wu(y,m),c=!1,vE(u)}}}function CE(i,t,e){let r,s=Np,n=()=>(s(),s=wE(o,E=>e(19,r=E)),o);i.$$.on_destroy.push(()=>s());let{editor_box:o}=t;n();let{crop_constraint:a}=t;const l=TE();let h=r.child_height,c=r.child_width,u=r.child_top-r.parent_top,d=r.child_left-r.parent_left,f=r.child_right-r.parent_left,p=0,g=!1,{w_p:y}=t,{h_p:m}=t,{l_p:v}=t,{t_p:_}=t;const b=["tl","br","tr","bl","t","b","l","r"];let w,A,x=!1;function C(){A&&clearTimeout(A),e(17,A=setTimeout(()=>{x&&(l("crop_end",{x:v,y:_,width:y,height:m}),x=!1),e(6,w=!0),e(18,S=!1)},1e3))}
1159function T({top:E,bottom:R,left:L,right:Y},tt){e(4,u=Gt(E?E-r.parent_top:u,r.child_top-r.parent_top,r.child_bottom-r.parent_top)),e(5,d=Gt(L?L-r.parent_left:d,r.child_left-r.parent_left,r.child_right-r.parent_left)),f=Gt(Y?Y-r.parent_left:f,r.child_left-r.parent_left,r.child_right-r.parent_left),p=Gt(R?R-r.parent_top:p,r.child_top-r.parent_top,r.child_bottom-r.parent_top),e(3,c=Gt(Y?Y-d-r.parent_left:c,0,f-d)),e(3,c=Gt(L?f-L+r.parent_left:c,0,f-d)),e(2,h=Gt(R?R-u-r.parent_top:h,0,p-u)),e(2,h=Gt(E?p-E+r.parent_top:h,0,p-u));const J={tl:"br",tr:"bl",bl:"tr",br:"tl",t:"b",b:"t",l:"r",r:"l",c:"c"};if(a){const st=["t","b"].includes(tt)?r.child_width:f-d,at=["l","r"].includes(tt)?r.child_height:p-u;let ht=Dp(c,h,J[tt],a,st,at);e(3,c=ht.new_width),e(2,h=ht.new_height),e(5,d=d+ht.x_offset),e(4,u=u+ht.y_offset),f=d+c,p=u+h}e(12,y=c/r.child_width),e(13,m=h/r.child_height),e(14,v=(d-r.child_left+r.parent_left)/r.child_width),e(15,_=(u-r.child_top+r.parent_top)/r.child_height),l(x?"crop_continue":"crop_start",{x:v,y:_,width:y,height:m}),x=!0}function P(){e(3,c=y*r.child_width),e(2,h=m*r.child_height),e(5,d=v*r.child_width+(r.child_left-r.parent_left)),e(4,u=_*r.child_height+(r.child_top-r.parent_top)),f=d+c,p=u+h}let M=0,B=0,S=!1;function I(E){e(18,S=!0),M=E.clientX,B=E.clientY,w&&(e(6,w=!1),l("crop_start",{x:v,y:_,width:y,height:m}))}function k(E){S&&e(18,S=!1)}function V(E){if(!S)return;const R=E.clientX-M,L=E.clientY-B;e(5,d=Gt(d+R,r.child_left-r.parent_left,r.child_right-r.parent_left-c)),e(4,u=Gt(u+L,r.child_top-r.parent_top,r.child_bottom-r.parent_top-h)),f=d+c,p=u+h,e(14,v=(d-r.child_left+r.parent_left)/r.child_width),e(15,_=(u-r.child_top+r.parent_top)/r.child_height),M=E.clientX,B=E.clientY,l("crop_continue",{x:v,y:_,width:y,height:m}),x=!0}function O(E){g=E,e(1,g)}const et=(E,{detail:R})=>T(R,E);return i.$$set=E=>{"editor_box"in E&&n(e(0,o=E.editor_box)),"crop_constraint"in E&&e(16,a=E.crop_constraint),"w_p"in E&&e(12,y=E.w_p),"h_p"in E&&e(13,m=E.h_p),"l_p"in E&&e(14,v=E.l_p),"t_p"in E&&e(15,_=E.t_p)},i.$$.update=()=>{i.$$.dirty[0]&393218&&(g||S?(clearTimeout(A),e(6,w=!1)):C()),i.$$.dirty[0]&524288&&r&&P()},[o,g,h,c,u,d,w,b,T,I,k,V,y,m,v,_,a,A,S,r,O,et]}class IE extends hE{constructor(t){super(),gE(this,t,CE,SE,bE,{editor_box:0,crop_constraint:16,w_p:12,h_p:13,l_p:14,t_p:15},null,[-1,-1])}}const{SvelteComponent:RE,check_outros:PE,component_subscribe:ri,create_component:ME,destroy_component:BE,detach:kE,empty:DE,group_outros:FE,init:OE,insert:NE,mount_component:LE,safe_not_equal:UE,transition_in:fn,transition_out:Pl}=window.__gradio__svelte__internal,{getContext:qu,onDestroy:tC,onMount:GE,tick:eC}=window.__gradio__svelte__internal;function Zu(i){let t,e;return t=new IE({props:{crop_constraint:i[0],w_p:i[1],h_p:i[2],l_p:i[3],t_p:i[4],editor_box:i[9]}}),t.$on("crop_start",i[20]),t.$on("crop_continue",i[21]),t.$on("crop_end",i[22]),{c(){ME(t.$$.fragment)},m(r,s){LE(t,r,s),e=!0},p(r,s){const n={};s[0]&1&&(n.crop_constraint=r[0]),s[0]&2&&(n.w_p=r[1]),s[0]&4&&(n.h_p=r[2]),s[0]&8&&(n.l_p=r[3]),s[0]&16&&(n.t_p=r[4]),t.$set(n)},i(r){e||(fn(t.$$.fragment,r),e=!0)},o(r){Pl(t.$$.fragment,r),e=!1},d(r){BE(t,r)}}}function HE(i){let t,e,r=i[5]==="crop"&&i[6]&&Zu(i);return{c(){r&&r.c(),t=DE()},m(s,n){r&&r.m(s,n),NE(s,t,n),e=!0},p(s,n){s[5]==="crop"&&s[6]?r?(r.p(s,n),n[0]&96&&fn(r,1)):(r=Zu(s),r.c(),fn(r,1),r.m(t.parentNode,t)):r&&(FE(),Pl(r,1,1,()=>{r=null}),PE())},i(s){e||(fn(r),e=!0)},o(s){Pl(r),e=!1},d(s){s&&kE(t),r&&r.d(s)}}}function zE(i,t,e){let r,s,n,o,a,l;const{active_tool:h,register_tool:c}=qu(Yn);ri(i,h,E=>e(5,l=E));const{dimensions:u,editor_box:d,pixi:f,crop:p,command_manager:g,current_history:y}=qu(Bi);ri(i,u,E=>e(18,n=E)),ri(i,d,E=>e(16,r=E)),ri(i,f,E=>e(19,o=E)),ri(i,p,E=>e(17,s=E)),ri(i,y,E=>e(27,a=E));let m,{crop_constraint:v}=t,_=null,b=1,w=1,A=0,x=0,C=0,T=!1,P=null;async function M(){if(P||a.previous)return;const{new_height:E,new_width:R,x_offset:L,y_offset:Y}=Dp(r.child_width,r.child_height,"c",_,r.child_width,r.child_height);e(1,b=R/r.child_width),e(2,w=E/r.child_height),e(3,A=L/r.child_width),e(4,x=Y/r.child_height),P=Hu(o.renderer,o.mask_container,p,.2),P.start(...n,k),P.continue([A*n[0],x*n[1],b*n[0],w*n[1]]),P.stop(),P.execute(),P=null,C=0}function B(E,{x:R,y:L,width:Y,height:tt}){if(o){if(E==="start")m&&(C=m.stop(),m=null),m=Hu(o?.renderer,o.mask_container,p,C),m.start(...n,k);else if(E==="continue"){if(!m)return;m.continue([R*n[0],L*n[1],Y*n[0],tt*n[1]])}else if(E==="stop"){if(!m)return;g.execute(m)}e(15,T=!0)}}let S=!1;function I(){if(S||!r.child_height)return;const E=r.child_height,R=r.child_width,L=r.child_top-r.parent_top,Y=r.child_left-r.parent_left;e(1,b=R/r.child_width),e(2,w=E/r.child_height),e(3,A=(Y-r.child_left+r.parent_left)/r.child_width),e(4,x=(L-r.child_top+r.parent_top)/r.child_height),e(6,S=!0)}let k;GE(()=>c("crop",{default:"crop",options:[]}));const V=({detail:E})=>B("start",E),O=({detail:E})=>B("continue",E),et=({detail:E})=>B("stop",E);return i.$$set=E=>{"crop_constraint"in E&&e(14,v=E.crop_constraint)},i.$$.update=()=>{if(i.$$.dirty[0]&16384)if(typeof v=="string"){const[E,R]=v.split(":");e(0,_=parseInt(E)/parseInt(R))}else Array.isArray(v)&&e(0,_=v[0]/v[1]);i.$$.dirty[0]&557089&&!T&&_&&o&&l&&requestAnimationFrame(()=>{M()}),i.$$.dirty[0]&131072&&(e(3,A=s[0]),e(4,x=s[1]),e(1,b=s[2]),e(2,w=s[3])),i.$$.dirty[0]&262174&&(k=[A*n[0],x*n[1],b*n[0],w*n[1]]),i.$$.dirty[0]&65536&&r&&I()},[_,b,w,A,x,l,S,h,u,d,f,p,y,B,v,T,r,s,n,o,V,O,et]}class XE extends RE{constructor(t){super(),OE(this,t,zE,HE,UE,{crop_constraint:14},null,[-1,-1])}}function VE(i,t,e,r){let s;return{async start(){i.removeChildren();const n=await createImageBitmap(e),o=W.from(n);return s=new Lt(o),[s.width,s.height]},async execute(){r(s.width,s.height),s.zIndex=0,i.addChild(s)}
1159,undo(){i.removeChildAt(0)}}}function WE(i,t,e,r,s,n){let o;return{start(){i.removeChildren();const a=vp(1),l=Ft.create({width:r,height:s});return a.beginFill(new ut(e)),a.drawRect(0,0,r,s),a.endFill(),t.render(a,{renderTexture:l}),o=new Lt(l),[o.width,o.height]},async execute(){n(o.width,o.height),o.zIndex=1,i.addChild(o)},undo(){i.removeChildren()}}}const{SvelteComponent:$E,append:Lp,attr:Ml,binding_callbacks:jE,bubble:ba,check_outros:Up,component_subscribe:Xs,create_component:Gp,destroy_component:Hp,detach:lh,element:Bl,empty:YE,group_outros:zp,init:qE,insert:hh,listen:ZE,mount_component:Xp,safe_not_equal:KE,set_store_value:Ku,set_style:ii,space:JE,transition_in:sr,transition_out:wi}=window.__gradio__svelte__internal,{getContext:Ju,onMount:QE,tick:tA}=window.__gradio__svelte__internal;function Qu(i){let t,e,r,s,n={hidden:!0,filetype:"image/*",root:i[0],disable_click:!i[1].includes("upload"),format:"blob"};e=new cm({props:n}),i[17](e),e.$on("load",i[12]),e.$on("error",i[18]);let o=i[4]==="webcam"&&td(i);return{c(){t=Bl("div"),Gp(e.$$.fragment),r=JE(),o&&o.c(),Ml(t,"class","upload-container")},m(a,l){hh(a,t,l),Xp(e,t,null),Lp(t,r),o&&o.m(t,null),s=!0},p(a,l){const h={};l[0]&1&&(h.root=a[0]),l[0]&2&&(h.disable_click=!a[1].includes("upload")),e.$set(h),a[4]==="webcam"?o?(o.p(a,l),l[0]&16&&sr(o,1)):(o=td(a),o.c(),sr(o,1),o.m(t,null)):o&&(zp(),wi(o,1,1,()=>{o=null}),Up())},i(a){s||(sr(e.$$.fragment,a),sr(o),s=!0)},o(a){wi(e.$$.fragment,a),wi(o),s=!1},d(a){a&&lh(t),i[17](null),Hp(e),o&&o.d()}}}function td(i){let t,e,r,s=`${i[7].child_width}px`,n=`${i[7].child_height}px`,o=`${i[7].child_top-i[7].parent_top}px`,a;return r=new im({props:{root:i[0],mirror_webcam:i[2],streaming:!1,mode:"image",include_audio:!1,i18n:i[3]}}),r.$on("capture",i[12]),r.$on("error",i[19]),r.$on("drag",i[20]),{c(){t=Bl("div"),e=Bl("div"),Gp(r.$$.fragment),Ml(e,"class","modal-inner svelte-16d2e0q"),Ml(t,"class","modal svelte-16d2e0q"),ii(t,"max-width",s),ii(t,"max-height",n),ii(t,"top",o)},m(l,h){hh(l,t,h),Lp(t,e),Xp(r,e,null),a=!0},p(l,h){const c={};h[0]&1&&(c.root=l[0]),h[0]&4&&(c.mirror_webcam=l[2]),h[0]&8&&(c.i18n=l[3]),r.$set(c),h[0]&128&&s!==(s=`${l[7].child_width}px`)&&ii(t,"max-width",s),h[0]&128&&n!==(n=`${l[7].child_height}px`)&&ii(t,"max-height",n),h[0]&128&&o!==(o=`${l[7].child_top-l[7].parent_top}px`)&&ii(t,"top",o)},i(l){a||(sr(r.$$.fragment,l),a=!0)},o(l){wi(r.$$.fragment,l),a=!1},d(l){l&&lh(t),Hp(r)}}}function eA(i){let t,e,r,s,n=i[6]==="bg"&&Qu(i);return{c(){n&&n.c(),t=YE()},m(o,a){n&&n.m(o,a),hh(o,t,a),e=!0,r||(s=ZE(window,"keydown",i[13]),r=!0)},p(o,a){o[6]==="bg"?n?(n.p(o,a),a[0]&64&&sr(n,1)):(n=Qu(o),n.c(),sr(n,1),n.m(t.parentNode,t)):n&&(zp(),wi(n,1,1,()=>{n=null}),Up())},i(o){e||(sr(n),e=!0)},o(o){wi(n),e=!1},d(o){o&&lh(t),n&&n.d(o),r=!1,s()}}}function rA(i,t,e){let r,s,n,o,a,{background_file:l}=t,{root:h}=t,{sources:c=["upload","webcam","clipboard"]}=t,{mirror_webcam:u=!0}=t,{i18n:d}=t;const{active_tool:f,register_tool:p}=Ju(Yn);Xs(i,f,E=>e(6,o=E));const{pixi:g,dimensions:y,register_context:m,reset:v,editor_box:_}=Ju(Bi);Xs(i,g,E=>e(24,n=E)),Xs(i,y,E=>e(23,s=E)),Xs(i,_,E=>e(7,a=E));let b=null,w;const A={upload:{icon:dm,label:"Upload",order:0,id:"bg_upload",cb(){x.open_file_upload()}},webcam:{icon:pm,label:"Webcam",order:1,id:"bg_webcam",cb(){e(4,b="webcam")}},clipboard:{icon:fm,label:"Paste",order:2,id:"bg_clipboard",cb(){C()}}};let x;async function C(){const E=await navigator.clipboard.read();for(let R=0;R<E.length;R++){const L=E[R].types.find(Y=>Y.startsWith("image/"));if(L){const Y=await E[R].getType(L);e(16,w=Y||null)}}}function T(E){const R=E.detail;e(16,w=R),e(4,b=null)}let P=!0;async function M(){if(n&&w){const E=VE(n.background_container,n.renderer,w,n.resize);Ku(y,s=await E.start(),s),P&&v(!1,s),E.execute(),P=!0,await tA(),e(14,I=!0)}}async function B(E){if(!E||!E.url)return;P=!1;const L=await(await fetch(E.url)).blob();e(16,w=L)}function S(E){E.key==="Escape"&&e(4,b=null)}let{bg:I=!1}=t;m("bg",{init_fn:()=>{if(!n)return;const E=WE(n.background_container,n.renderer,"black",...s,n.resize);Ku(y,s=E.start(),s),E.execute()},reset_fn:()=>{}}),QE(()=>p("bg",{default:"bg_upload",options:r||[]}));function k(E){jE[E?"unshift":"push"](()=>{x=E,e(5,x)})}function V(E){ba.call(this,i,E)}function O(E){ba.call(this,i,E)}function et(E){ba.call(this,i,E)}return i.$$set=E=>
1159{"background_file"in E&&e(15,l=E.background_file),"root"in E&&e(0,h=E.root),"sources"in E&&e(1,c=E.sources),"mirror_webcam"in E&&e(2,u=E.mirror_webcam),"i18n"in E&&e(3,d=E.i18n),"bg"in E&&e(14,I=E.bg)},i.$$.update=()=>{i.$$.dirty[0]&2&&(r=c.map(E=>A[E]).sort((E,R)=>E.order-R.order)),i.$$.dirty[0]&65536&&w&&M(),i.$$.dirty[0]&32768&&B(l)},[h,c,u,d,b,x,o,a,f,g,y,_,T,S,I,l,w,k,V,O,et]}class iA extends $E{constructor(t){super(),qE(this,t,rA,eA,KE,{background_file:15,root:0,sources:1,mirror_webcam:2,i18n:3,bg:14},null,[-1,-1])}}function kl(i){return{command:i||null,next:null,previous:null,push:function(t){const e=kl(t);e.previous=this,this.next=e}}}function sA(){let i=kl();const t=Vt(!1),e=Vt(!1),r=Vt(i);return{undo:function(){i.previous&&(i.command?.undo(),i=i.previous),t.set(!!i.previous),e.set(!!i.next),r.set(i)},redo:function(){i.next&&(i.next.command?.execute(),i=i.next),t.set(!!i.previous),e.set(!!i.next),r.set(i)},execute:function(s){s.execute(),i.push(s),i=i.next,t.set(!!i.previous),e.set(!!i.next),r.set(i)},can_undo:t,can_redo:e,current_history:r,reset:function(){i=kl(),t.set(!1),e.set(!1),r.set(i)}}}const nA=` 1160precision highp float; 1161 1162uniform sampler2D uDrawingTexture; 1163uniform sampler2D uEraserTexture; 1164 1165varying vec2 vTextureCoord; 1166 1167void main(void) { 1168 vec4 drawingColor = texture2D(uDrawingTexture,vTextureCoord); 1169 vec4 eraserColor = texture2D(uEraserTexture, vTextureCoord); 1170 1171 // Use the alpha of the eraser to determine how much to "erase" from the drawing 1172 float alpha = 1.0 - eraserColor.a; 1173 gl_FragColor = vec4(drawingColor.rgb * alpha, drawingColor.a * alpha); 1174}`;function ed(i,t){if(t<0||t>=i.length-1)throw new Error("Index out of bounds");[i[t],i[t+1]]=[i[t+1],i[t]]}function oA(){let i=[],t=0;return{add_layer:function(e,r,s,n){const o=new Dt;t++,o.zIndex=t;const a=Ft.create({width:s,height:n}),l=new Lt(a);o.addChild(l),l.zIndex=t;const h={draw_texture:Ft.create({width:s,height:n}),erase_texture:Ft.create({width:s,height:n}),composite:l},c=new kt(void 0,nA,{uEraserTexture:h.erase_texture,uDrawingTexture:h.draw_texture});return l.filters=[c],e.addChild(o),i.push(h),[h,i]},swap_layers:function(e,r){return r==="up"?ed(i,e):ed(i,e-1),i[e]},change_active_layer:function(e){return i[e]},reset(){i.forEach(e=>{e.draw_texture.destroy(!0),e.erase_texture.destroy(!0),e.composite.destroy(!0)}),i=[],t=0},async add_layer_from_blob(e,r,s){const n=await createImageBitmap(s),o=W.from(n),a=new Lt(o);a.zIndex=0;const[l,h]=this.add_layer(e,r,a.width,a.height);return r.render(a,{renderTexture:l.draw_texture}),[l,h]},get_layers(){return i}}}const{SvelteComponent:aA,append:Vs,attr:Dl,check_outros:lA,create_component:pn,destroy_component:mn,detach:Vp,element:Fl,group_outros:hA,init:cA,insert:Wp,mount_component:_n,safe_not_equal:uA,space:xa,transition_in:Rr,transition_out:di}=window.__gradio__svelte__internal,{createEventDispatcher:dA}=window.__gradio__svelte__internal;function rd(i){let t,e,r;return e=new mi({props:{disabled:!i[2],Icon:am,label:"Save changes",background:"var(--color-green-500)",color:"#fff"}}),e.$on("click",i[8]),{c(){t=Fl("div"),pn(e.$$.fragment),Dl(t,"class","row-wrap save svelte-4lttvb")},m(s,n){Wp(s,t,n),_n(e,t,null),r=!0},p(s,n){const o={};n&4&&(o.disabled=!s[2]),e.$set(o)},i(s){r||(Rr(e.$$.fragment,s),r=!0)},o(s){di(e.$$.fragment,s),r=!1},d(s){s&&Vp(t),mn(e)}}}function fA(i){let t,e,r,s,n,o,a,l,h;r=new mi({props:{disabled:!i[0],Icon:hm,label:"Undo"}}),r.$on("click",i[5]),n=new mi({props:{disabled:!i[1],Icon:p_,label:"Redo"}}),n.$on("click",i[6]),a=new mi({props:{Icon:lm,label:"Clear canvas"}}),a.$on("click",i[7]);let c=i[3]&&rd(i);return{c(){t=Fl("div"),e=Fl("div"),pn(r.$$.fragment),s=xa(),pn(n.$$.fragment),o=xa(),pn(a.$$.fragment),l=xa(),c&&c.c(),Dl(e,"class","row-wrap svelte-4lttvb"),Dl(t,"class","controls-wrap svelte-4lttvb")},m(u,d){Wp(u,t,d),Vs(t,e),_n(r,e,null),Vs(e,s),_n(n,e,null),Vs(e,o),_n(a,e,null),Vs(t,l),c&&c.m(t,null),h=!0},p(u,[d]){const f={};d&1&&(f.disabled=!u[0]),r.$set(f);const p={};d&2&&(p.disabled=!u[1]),n.$set(p),u[3]?c?(c.p(u,d),d&8&&Rr(c,1)):(c=rd(u),c.c(),Rr(c,1),c.m(t,null)):c&&(hA(),di(c,1,1,()=>{c=null}),lA())}
1174,i(u){h||(Rr(r.$$.fragment,u),Rr(n.$$.fragment,u),Rr(a.$$.fragment,u),Rr(c),h=!0)},o(u){di(r.$$.fragment,u),di(n.$$.fragment,u),di(a.$$.fragment,u),di(c),h=!1},d(u){u&&Vp(t),mn(r),mn(n),mn(a),c&&c.d()}}}function pA(i,t,e){let{can_undo:r=!1}=t,{can_redo:s=!1}=t,{can_save:n=!1}=t,{changeable:o=!1}=t;const a=dA(),l=d=>{a("undo"),d.stopPropagation()},h=d=>{a("redo"),d.stopPropagation()},c=d=>{a("remove_image"),d.stopPropagation()},u=d=>{a("save"),d.stopPropagation()};return i.$$set=d=>{"can_undo"in d&&e(0,r=d.can_undo),"can_redo"in d&&e(1,s=d.can_redo),"can_save"in d&&e(2,n=d.can_save),"changeable"in d&&e(3,o=d.changeable)},[r,s,n,o,a,l,h,c,u]}class mA extends aA{constructor(t){super(),cA(this,t,pA,fA,uA,{can_undo:0,can_redo:1,can_save:2,changeable:3})}}const{SvelteComponent:_A,append:si,attr:Ui,binding_callbacks:id,component_subscribe:Zt,create_component:gA,create_slot:yA,destroy_component:vA,detach:bA,element:Ws,get_all_dirty_from_scope:xA,get_slot_changes:wA,init:TA,insert:EA,listen:AA,mount_component:SA,safe_not_equal:CA,set_store_value:sd,set_style:me,space:wa,toggle_class:nd,transition_in:od,transition_out:ad,update_slot_base:IA}=window.__gradio__svelte__internal,{onMount:RA,setContext:PA,createEventDispatcher:MA,tick:BA}=window.__gradio__svelte__internal;function kA(i){let t,e,r,s,n,o=`translate(${i[6].x}px, ${i[6].y}px)`,a,l,h,c=`${i[7][2]*i[9].child_width}px`,u=`${i[7][3]*i[9].child_height}px`,d=`${i[7][1]*i[9].child_height+(i[9].child_top-i[9].parent_top)}px`,f=`${i[7][0]*i[9].child_width+(i[9].child_left-i[9].parent_left)}px`,p,g,y;e=new mA({props:{can_undo:i[10],can_redo:i[11],can_save:i[8]!==i[5],changeable:i[1]}}),e.$on("undo",i[17].undo),e.$on("redo",i[17].redo),e.$on("remove_image",i[2]),e.$on("save",i[26]);const m=i[36].default,v=yA(m,i,i[35],null);return{c(){t=Ws("div"),gA(e.$$.fragment),r=wa(),s=Ws("div"),n=Ws("div"),a=wa(),v&&v.c(),l=wa(),h=Ws("div"),Ui(n,"class","stage-wrap svelte-h1irw9"),nd(n,"bg",!i[0]),me(n,"transform",o),Ui(s,"class","wrap svelte-h1irw9"),Ui(h,"class","border svelte-h1irw9"),me(h,"width",c),me(h,"height",u),me(h,"top",d),me(h,"left",f),Ui(t,"data-testid","image"),Ui(t,"class","image-container svelte-h1irw9")},m(_,b){EA(_,t,b),SA(e,t,null),si(t,r),si(t,s),si(s,n),i[38](n),i[39](s),si(t,a),v&&v.m(t,null),si(t,l),si(t,h),p=!0,g||(y=AA(window,"scroll",i[37]),g=!0)},p(_,b){const w={};b[0]&1024&&(w.can_undo=_[10]),b[0]&2048&&(w.can_redo=_[11]),b[0]&288&&(w.can_save=_[8]!==_[5]),b[0]&2&&(w.changeable=_[1]),e.$set(w),(!p||b[0]&1)&&nd(n,"bg",!_[0]),b[0]&64&&o!==(o=`translate(${_[6].x}px, ${_[6].y}px)`)&&me(n,"transform",o),v&&v.p&&(!p||b[1]&16)&&IA(v,m,_,_[35],p?wA(m,_[35],b,null):xA(_[35]),null),b[0]&640&&c!==(c=`${_[7][2]*_[9].child_width}px`)&&me(h,"width",c),b[0]&640&&u!==(u=`${_[7][3]*_[9].child_height}px`)&&me(h,"height",u),b[0]&640&&d!==(d=`${_[7][1]*_[9].child_height+(_[9].child_top-_[9].parent_top)}px`)&&me(h,"top",d),b[0]&640&&f!==(f=`${_[7][0]*_[9].child_width+(_[9].child_left-_[9].parent_left)}px`)&&me(h,"left",f)},i(_){p||(od(e.$$.fragment,_),od(v,_),p=!0)},o(_){ad(e.$$.fragment,_),ad(v,_),p=!1},d(_){_&&bA(t),vA(e),i[38](null),i[39](null),v&&v.d(_),g=!1,y()}}}const Bi=Symbol("editor");function DA(i,t,e){let r,s,n,o,a,l,h,c,u,d,f,p,{$$slots:g={},$$scope:y}=t,{antialias:m=!0}=t,{crop_size:v=[800,600]}=t,{changeable:_=!1}=t,{history:b}=t,{bg:w=!1}=t,{sources:A}=t;const x=MA();let{crop_constraint:C=!1}=t,T=Vt(v);Zt(i,T,z=>e(43,l=z));let P=Vt({parent_width:0,parent_height:0,parent_top:0,parent_left:0,parent_right:0,parent_bottom:0,child_width:0,child_height:0,child_top:0,child_left:0,child_right:0,child_bottom:0});Zt(i,P,z=>e(9,d=z));const M=Vt([0,0,1,1]);Zt(i,M,z=>e(7,u=z));const B=Ed({x:0,y:0},{stiffness:.1,damping:.5});Zt(i,B,z=>e(6,c=z));const S=Vt(null);Zt(i,S,z=>e(42,a=z));const I=sA(),{can_redo:k,can_undo:V,current_history:O}=I;Zt(i,k,z=>e(11,p=z)),Zt(i,V,z=>e(10,f=z)),Zt(i,O,z=>e(5,s=z));const et=Vt("bg");Zt(i,et,z=>e(34,r=z));const E=Vt({});Zt(i,E,z=>e(40,n=z));const R=Vt({});Zt(i,R,z=>e(44,h=z));const L=Vt([]);Zt(i,L,z=>e(41,o=z));const Y=["bg","layers","crop","draw","erase"],tt=PA(Bi,{pixi:S,current_layer:Vt(null),dimensions:T,editor_box:P,active_tool:et,crop:M,position_spring:
1174B,command_manager:I,current_history:O,register_context:(z,{reset_fn:Tt,init_fn:Ut})=>{L.update(nt=>[...nt,z]),R.update(nt=>({...nt,[z]:Ut})),E.update(nt=>({...nt,[z]:Tt}))},reset:(z,Tt)=>{e(0,w=!1);const Ut=o.sort((nt,Pe)=>Y.indexOf(nt)-Y.indexOf(Pe));for(const nt of Ut)nt in n&&typeof n[nt]=="function"&&n[nt]?.();for(const nt of Ut){if(nt in h&&typeof h[nt]=="function"){if(nt==="bg"&&!z)continue;h[nt]?.(Tt)}I.reset(),a?.resize?.(...Tt)}}});let J,st;function at(z,Tt){if(!z||!Tt)return;const{width:Ut,height:nt,top:Pe,left:ao,right:lo,bottom:ho}=st.getBoundingClientRect(),{width:co,height:uo,top:Qp,left:tm,right:em,bottom:rm}=Tt.getBoundingClientRect();P.set({child_width:co,child_height:uo,child_left:tm,child_right:em,child_top:Qp,child_bottom:rm,parent_width:Ut,parent_height:nt,parent_left:ao,parent_right:lo,parent_top:Pe,parent_bottom:ho})}function ht(){requestAnimationFrame(()=>{BA().then(z=>sd(et,r="crop",r))})}function yt(){if(!d)return;const[z,Tt,Ut,nt]=u,Pe=z*d.child_width,ao=Tt*d.child_height,lo=Ut*d.child_width,ho=nt*d.child_height,co=.5*d.child_width-Pe-lo/2,uo=.5*d.child_height-ao-ho/2;B.set({x:co,y:uo})}async function wt(){if(!a||!a.get_layers)return{background:null,layers:[],composite:null};const[z,Tt,Ut,nt]=u;return a?.get_blobs(a.get_layers(),new K(z*l[0],Tt*l[1],Ut*l[0],nt*l[1]),l)}function D(){tt.reset(!0,l),A.length?lt("bg"):lt("draw")}RA(()=>{const z=Iw(J,...v,m);function Tt(nt,Pe){z.resize(nt,Pe),T.set([nt,Pe])}S.set({...z,resize:Tt});const Ut=new ResizeObserver(nt=>{for(const Pe of nt)at(st,J)});Ut.observe(st),Ut.observe(J);for(const nt of o)nt in h&&typeof h[nt]=="function"&&h[nt]?.(l);return Tt(...l),()=>{a?.destroy(),Ut.disconnect();for(const nt of o)nt in n&&n[nt]?.()}});let ct=s;function N(){e(8,ct=s),x("save")}function lt(z){sd(et,r=z,r)}const Rt=()=>at(st,J);function jt(z){id[z?"unshift":"push"](()=>{J=z,e(3,J)})}function yr(z){id[z?"unshift":"push"](()=>{st=z,e(4,st)})}return i.$$set=z=>{"antialias"in z&&e(28,m=z.antialias),"crop_size"in z&&e(29,v=z.crop_size),"changeable"in z&&e(1,_=z.changeable),"history"in z&&e(27,b=z.history),"bg"in z&&e(0,w=z.bg),"sources"in z&&e(30,A=z.sources),"crop_constraint"in z&&e(31,C=z.crop_constraint),"$$scope"in z&&e(35,y=z.$$scope)},i.$$.update=()=>{i.$$.dirty[0]&32|i.$$.dirty[1]&8&&e(27,b=!!s.previous||r!=="bg"),i.$$.dirty[0]&134217729|i.$$.dirty[1]&1&&C&&w&&!b&&ht(),i.$$.dirty[0]&128&&u&&yt(),i.$$.dirty[0]&88&&c&&at(st,J)},[w,_,D,J,st,s,c,u,ct,d,f,p,T,P,M,B,S,I,k,V,O,et,E,R,L,at,N,b,m,v,A,C,wt,lt,r,y,g,Rt,jt,yr]}class FA extends _A{constructor(t){super(),TA(this,t,DA,kA,CA,{antialias:28,crop_size:29,changeable:1,history:27,bg:0,sources:30,crop_constraint:31,get_blobs:32,handle_remove:2,set_tool:33},null,[-1,-1])}get get_blobs(){return this.$$.ctx[32]}get handle_remove(){return this.$$.ctx[2]}get set_tool(){return this.$$.ctx[33]}}const{SvelteComponent:OA,action_destroyer:NA,append:Ee,attr:Br,component_subscribe:Ta,create_component:LA,destroy_block:UA,destroy_component:GA,detach:ch,element:or,ensure_array_like:ld,init:HA,insert:uh,is_function:zA,listen:dh,mount_component:XA,run_all:VA,safe_not_equal:WA,set_data:$A,set_store_value:$s,space:$p,text:Ol,toggle_class:$n,transition_in:jA,transition_out:YA,update_keyed_each:qA}=window.__gradio__svelte__internal,{createEventDispatcher:rC,getContext:ZA,onMount:KA,tick:hd}=window.__gradio__svelte__internal;function cd(i,t,e){const r=i.slice();return r[16]=t[e],r[18]=e,r}function ud(i){let t,e=[],r=new Map,s,n,o,a,l,h=ld(i[1]);const c=u=>u[18];for(let u=0;u<h.length;u+=1){let d=cd(i,h,u),f=c(d);r.set(f,e[u]=dd(f,d))}return{c(){t=or("ul");for(let u=0;u<e.length;u+=1)e[u].c();s=$p(),n=or("li"),o=or("button"),o.textContent="+",Br(o,"aria-label","Add Layer"),Br(o,"class","svelte-g7pfx4")},m(u,d){uh(u,t,d);for(let f=0;f<e.length;f+=1)e[f]&&e[f].m(t,null);Ee(t,s),Ee(t,n),Ee(n,o),a||(l=dh(o,"click",i[7]),a=!0)},p(u,d){d&70&&(h=ld(u[1]),e=qA(e,d,c,1,u,h,r,t,UA,dd,s,cd))},d(u){u&&ch(t);for(let d=0;d<e.length;d+=1)e[d].d();a=!1,l()}}}function dd(i,t){let e,r,s,n=t[18]+1+"",o,a,l;function h(){return t[10](t[18])}return{key:i,first:null,c(){e=or("li"),r=or("button"),s=Ol("Layer "),o=Ol(n),Br(r,"class","svelte-g7pfx4"),$n(r,"selected_layer",t[2]===t[16]),this.first=e},m(c,u){uh(c,e,u),Ee(e,r),Ee(r,s),Ee(r,o),a||(l=dh(r,"click",h),a=!0)},p(c,u){t=c,u&2&&n!==(n=t[18]+1+"")&&$A(o,n),u&6&&$n(r,"selected_layer",t[2]===t[16])},d(c){c&&ch(e),a=!1,l()}}}function JA(i){let t,e,r,s,n,o,a,l,h,c;n=new um({});let u=i[0]&&ud(i);return{c(){t=or("div"),e=or("button"),r=Ol("Layers"),s=or("span"),LA(n.$$.fragment),o=$p(),u&&u.c(),Br(s,"class","layer-toggle svelte-g7pfx4"),Br(e,"aria-label","Show Layers"),Br(e,"class","svelte-g7pfx4"),Br(t,"class","layer-wrap svelte-g7pfx4"),$n(t,"closed",!i[0])},m(d,f){uh(d,t,f),Ee(t,e),Ee(e,r),Ee(e,s),XA(n,s,null),Ee(t,o),u&&u.m(t,null),l=!0,h||(c=[dh(e,"click",i[9]),NA(a=sh.c
1174all(null,t,i[11]))],h=!0)},p(d,[f]){d[0]?u?u.p(d,f):(u=ud(d),u.c(),u.m(t,null)):u&&(u.d(1),u=null),a&&zA(a.update)&&f&1&&a.update.call(null,d[11]),(!l||f&1)&&$n(t,"closed",!d[0])},i(d){l||(jA(n.$$.fragment,d),l=!0)},o(d){YA(n.$$.fragment,d),l=!1},d(d){d&&ch(t),GA(n),u&&u.d(),h=!1,VA(c)}}}function QA(i){return i!==null}function tS(i,t,e){let r,s,n,o=!1,{layer_files:a=[]}=t;const{pixi:l,current_layer:h,dimensions:c,register_context:u}=ZA(Bi);Ta(i,l,_=>e(12,r=_)),Ta(i,h,_=>e(2,s=_)),Ta(i,c,_=>e(13,n=_));const d=oA();let f=[];u("layers",{init_fn:()=>{p()},reset_fn:()=>{d.reset()}});async function p(){if(!r)return;const[_,b]=d.add_layer(r.layer_container,r.renderer,...n);$s(h,s=_,s),e(1,f=b)}async function g(_){if(await hd(),!_||_.length==0||!r)return;const b=await Promise.all(_.map(x=>!x||!x.url?null:fetch(x.url))),w=await Promise.all(b.map(x=>x?x.blob():null));d.reset();let A=null;for(const x of w.filter(QA))A=await d.add_layer_from_blob(r.layer_container,r.renderer,x);A&&($s(h,s=A[0],s),e(1,f=A[1]))}KA(async()=>{await hd(),r&&$s(l,r={...r,get_layers:d.get_layers},r)});const y=()=>e(0,o=!o),m=_=>$s(h,s=d.change_active_layer(_),s),v=()=>e(0,o=!1);return i.$$set=_=>{"layer_files"in _&&e(8,a=_.layer_files)},i.$$.update=()=>{i.$$.dirty&256&&g(a)},[o,f,s,l,h,c,d,p,a,y,m,v]}class eS extends OA{constructor(t){super(),HA(this,t,tS,JA,WA,{layer_files:8})}}const{SvelteComponent:rS,add_flush_callback:Nl,append:fd,attr:jp,bind:Ll,binding_callbacks:jn,bubble:iS,check_outros:js,create_component:ur,destroy_component:dr,detach:te,element:oo,empty:Yp,group_outros:Ys,init:sS,insert:ee,mount_component:fr,safe_not_equal:nS,space:ar,transition_in:bt,transition_out:Bt}=window.__gradio__svelte__internal;function pd(i){let t,e,r;function s(o){i[16](o)}let n={i18n:i[3],root:i[4],sources:i[2],background_file:i[8]?.background||null};return i[11]!==void 0&&(n.bg=i[11]),t=new iA({props:n}),jn.push(()=>Ll(t,"bg",s)),{c(){ur(t.$$.fragment)},m(o,a){fr(t,o,a),r=!0},p(o,a){const l={};a&8&&(l.i18n=o[3]),a&16&&(l.root=o[4]),a&4&&(l.sources=o[2]),a&256&&(l.background_file=o[8]?.background||null),!e&&a&2048&&(e=!0,l.bg=o[11],Nl(()=>e=!1)),t.$set(l)},i(o){r||(bt(t.$$.fragment,o),r=!0)},o(o){Bt(t.$$.fragment,o),r=!1},d(o){dr(t,o)}}}function md(i){let t,e;return t=new XE({props:{crop_constraint:i[13]}}),{c(){ur(t.$$.fragment)},m(r,s){fr(t,r,s),e=!0},p(r,s){const n={};s&8192&&(n.crop_constraint=r[13]),t.$set(n)},i(r){e||(bt(t.$$.fragment,r),e=!0)},o(r){Bt(t.$$.fragment,r),e=!1},d(r){dr(t,r)}}}function _d(i){let t,e;return t=new kp({props:{color_mode:i[0].color_mode,default_color:i[0].default_color,default_size:i[0].default_size,colors:i[0].colors,mode:"draw"}}),{c(){ur(t.$$.fragment)},m(r,s){fr(t,r,s),e=!0},p(r,s){const n={};s&1&&(n.color_mode=r[0].color_mode),s&1&&(n.default_color=r[0].default_color),s&1&&(n.default_size=r[0].default_size),s&1&&(n.colors=r[0].colors),t.$set(n)},i(r){e||(bt(t.$$.fragment,r),e=!0)},o(r){Bt(t.$$.fragment,r),e=!1},d(r){dr(t,r)}}}function gd(i){let t,e;return t=new kp({props:{default_size:i[1].default_size,mode:"erase"}}),{c(){ur(t.$$.fragment)},m(r,s){fr(t,r,s),e=!0},p(r,s){const n={};s&2&&(n.default_size=r[1].default_size),t.$set(n)},i(r){e||(bt(t.$$.fragment,r),e=!0)},o(r){Bt(t.$$.fragment,r),e=!1},d(r){dr(t,r)}}}function oS(i){let t,e=i[9].includes("crop"),r,s,n,o,a=i[2]&&i[2].length&&pd(i),l=e&&md(i),h=i[0]&&_d(i),c=i[0]&&i[1]&&gd(i);return{c(){a&&a.c(),t=ar(),l&&l.c(),r=ar(),h&&h.c(),s=ar(),c&&c.c(),n=Yp()},m(u,d){a&&a.m(u,d),ee(u,t,d),l&&l.m(u,d),ee(u,r,d),h&&h.m(u,d),ee(u,s,d),c&&c.m(u,d),ee(u,n,d),o=!0},p(u,d){u[2]&&u[2].length?a?(a.p(u,d),d&4&&bt(a,1)):(a=pd(u),a.c(),bt(a,1),a.m(t.parentNode,t)):a&&(Ys(),Bt(a,1,1,()=>{a=null}),js()),d&512&&(e=u[9].includes("crop")),e?l?(l.p(u,d),d&512&&bt(l,1)):(l=md(u),l.c(),bt(l,1),l.m(r.parentNode,r)):l&&(Ys(),Bt(l,1,1,()=>{l=null}),js()),u[0]?h?(h.p(u,d),d&1&&bt(h,1)):(h=_d(u),h.c(),bt(h,1),h.m(s.parentNode,s)):h&&(Ys(),Bt(h,1,1,()=>{h=null}),js()),u[0]&&u[1]?c?(c.p(u,d),d&3&&bt(c,1)):(c=gd(u),c.c(),bt(c,1),c.m(n.parentNode,n)):c&&(Ys(),Bt(c,1,1,()=>{c=null}),js())},i(u){o||(bt(a),bt(l),bt(h),bt(c),o=!0)},o(u){Bt(a),Bt(l),Bt(h),Bt(c),o=!1},d(u){u&&(te(t),te(r),te(s),te(n)),a&&a.d(u),l&&l.d(u),h&&h.d(u),c&&c.d(u)}}}function yd(i){let t,e,r,s=i[2]&&i[2].length&&vd(),n=i[2]&&i[2].length&&i[0]&&bd(),o=i[0]&&xd();return{c(){t=oo("div"),s&&s.c(),e=ar(),n&&n.c(),r=ar(),o&&o.c(),jp(t,"class","empty wrap svelte-1dewo5e")},m(a,l){ee(a,t,l),s&&s.m(t,null),fd(t,e),n&&n.m(t,null),fd(t,r),o&&o.m(t,null)},p(a,l){a[2]&&a[2].length?s||(s=vd(),s.c(),s.m(t,e)):s&&(s.d(1),s=null),a[2]&&a[2].length&&a[0]?n||(n=bd(),n.c(),n.m(t,r)):n&&(n.d(1),n=null),a[0]?o||(o=xd(),o.c(),o.m(t,null)):o&&(o.d(1),o=null)},d(a){a&&te(t),s&&s.d(),n&&n.d(),o&&o.d()}}}function vd(i){let t;return{c(){t=oo("div"),t.textContent="Upload an image"},m(e,r){ee(e,t,r)},d(e){e&&te(t)}}}function bd(i){let t;return{c(){t=oo("div"),t.textContent="or",jp(t,"class","or svelte-1dewo5e")},m(e,r){ee(e,t,r)},d(e){e&&te(t)}}}function xd(i){let t;return{c(){t=oo("div"),t.textContent="select the draw tool to start"},m(e,r){ee(e,t,r)},d(e){e&&te(t)}}}function aS(i){let t,e,r,s,n,o;t=new j_({props:{i18n:i[3],$$slots:{default:[oS]},$$scope:{ctx:i}}}
1174),r=new eS({props:{layer_files:i[8]?.layers||null}});let a=!i[11]&&!i[12]&&yd(i);return{c(){ur(t.$$.fragment),e=ar(),ur(r.$$.fragment),s=ar(),a&&a.c(),n=Yp()},m(l,h){fr(t,l,h),ee(l,e,h),fr(r,l,h),ee(l,s,h),a&&a.m(l,h),ee(l,n,h),o=!0},p(l,h){const c={};h&8&&(c.i18n=l[3]),h&4205343&&(c.$$scope={dirty:h,ctx:l}),t.$set(c);const u={};h&256&&(u.layer_files=l[8]?.layers||null),r.$set(u),!l[11]&&!l[12]?a?a.p(l,h):(a=yd(l),a.c(),a.m(n.parentNode,n)):a&&(a.d(1),a=null)},i(l){o||(bt(t.$$.fragment,l),bt(r.$$.fragment,l),o=!0)},o(l){Bt(t.$$.fragment,l),Bt(r.$$.fragment,l),o=!1},d(l){l&&(te(e),te(s),te(n)),dr(t,l),dr(r,l),a&&a.d(l)}}}function lS(i){let t,e,r,s,n,o;t=new mm({props:{show_label:i[6],Icon:Sd,label:i[5]||i[3]("image.image")}});function a(c){i[18](c)}function l(c){i[19](c)}let h={changeable:i[7],sources:i[2],crop_constraint:!!i[13],$$slots:{default:[aS]},$$scope:{ctx:i}};return i[12]!==void 0&&(h.history=i[12]),i[11]!==void 0&&(h.bg=i[11]),r=new FA({props:h}),i[17](r),jn.push(()=>Ll(r,"history",a)),jn.push(()=>Ll(r,"bg",l)),r.$on("save",i[20]),{c(){ur(t.$$.fragment),e=ar(),ur(r.$$.fragment)},m(c,u){fr(t,c,u),ee(c,e,u),fr(r,c,u),o=!0},p(c,[u]){const d={};u&64&&(d.show_label=c[6]),u&40&&(d.label=c[5]||c[3]("image.image")),t.$set(d);const f={};u&128&&(f.changeable=c[7]),u&4&&(f.sources=c[2]),u&8192&&(f.crop_constraint=!!c[13]),u&4209439&&(f.$$scope={dirty:u,ctx:c}),!s&&u&4096&&(s=!0,f.history=c[12],Nl(()=>s=!1)),!n&&u&2048&&(n=!0,f.bg=c[11],Nl(()=>n=!1)),r.$set(f)},i(c){o||(bt(t.$$.fragment,c),bt(r.$$.fragment,c),o=!0)},o(c){Bt(t.$$.fragment,c),Bt(r.$$.fragment,c),o=!1},d(c){c&&te(e),dr(t,c),i[17](null),dr(r,c)}}}function hS(i){return!!i}function cS(i){return!!i}function uS(i,t,e){let r,{brush:s}=t,{eraser:n}=t,{sources:o}=t,{crop_size:a=null}=t,{i18n:l}=t,{root:h}=t,{label:c=void 0}=t,{show_label:u}=t,{changeable:d=!1}=t,{value:f={background:null,layers:[],composite:null}}=t,{transforms:p=["crop"]}=t,g;async function y(){const T=await g.get_blobs(),P=T.background?fo(await po([new File([T.background],"background.png")]),h):Promise.resolve(null),M=T.layers.filter(hS).map(async(V,O)=>fo(await po([new File([V],`layer_${O}.png`)]),h)),B=T.composite?fo(await po([new File([T.composite],"composite.png")]),h):Promise.resolve(null),[S,I,...k]=await Promise.all([P,B,...M]);return{background:Array.isArray(S)?S[0]:S,layers:k.flatMap(V=>Array.isArray(V)?V:[V]).filter(cS),composite:Array.isArray(I)?I[0]:I}}function m(T){g&&T==null&&g.handle_remove()}let v=!1,_=!1;function b(T){v=T,e(11,v)}function w(T){jn[T?"unshift":"push"](()=>{g=T,e(10,g)})}function A(T){_=T,e(12,_)}function x(T){v=T,e(11,v)}function C(T){iS.call(this,i,T)}return i.$$set=T=>{"brush"in T&&e(0,s=T.brush),"eraser"in T&&e(1,n=T.eraser),"sources"in T&&e(2,o=T.sources),"crop_size"in T&&e(14,a=T.crop_size),"i18n"in T&&e(3,l=T.i18n),"root"in T&&e(4,h=T.root),"label"in T&&e(5,c=T.label),"show_label"in T&&e(6,u=T.show_label),"changeable"in T&&e(7,d=T.changeable),"value"in T&&e(8,f=T.value),"transforms"in T&&e(9,p=T.transforms)},i.$$.update=()=>{i.$$.dirty&256&&m(f),i.$$.dirty&16384&&e(13,r=a),i.$$.dirty&1028&&g&&g.set_tool&&(o&&o.length?g.set_tool("bg"):g.set_tool("draw"))},[s,n,o,l,h,c,u,d,f,p,g,v,_,r,a,y,b,w,A,x,C]}class dS extends rS{constructor(t){super(),sS(this,t,uS,lS,nS,{brush:0,eraser:1,sources:2,crop_size:14,i18n:3,root:4,label:5,show_label:6,changeable:7,value:8,transforms:9,get_data:15})}get get_data(){return this.$$.ctx[15]}}const{SvelteComponent:fS,assign:qp,binding_callbacks:pS,bubble:mS,check_outros:_S,create_component:Ci,destroy_component:Ii,detach:fh,empty:gS,flush:ft,get_spread_object:Zp,get_spread_update:Kp,group_outros:yS,init:vS,insert:ph,mount_component:Ri,safe_not_equal:bS,space:Jp,transition_in:pr,transition_out:mr}=window.__gradio__svelte__internal;function xS(i){let t,e;return t=new wd({props:{visible:i[3],variant:i[4]===null?"dashed":"solid",border_mode:i[25]?"focus":"base",padding:!1,elem_id:i[1],elem_classes:i[2],height:i[9]||void 0,width:i[10],allow_overflow:!1,container:i[12],scale:i[13],min_width:i[14],$$slots:{default:[TS]},$$scope:{ctx:i}}}),{c(){Ci(t.$$.fragment)},m(r,s){Ri(t,r,s),e=!0},p(r,s){const n={};s[0]&8&&(n.visible=r[3]),s[0]&16&&(n.variant=r[4]===null?"dashed":"solid"),s[0]&33554432&&(n.border_mode=r[25]?"focus":"base"),s[0]&2&&(n.elem_id=r[1]),s[0]&4&&(n.elem_classes=r[2]),s[0]&512&&(n.height=r[9]||void 0),s[0]&1024&&(n.width=r[10]),s[0]&4096&&(n.container=r[12]),s[0]&8192&&(n.scale=r[13]),s[0]&16384&&(n.min_width=r[14]),s[0]&66912625|s[1]&4096&&(n.$$scope={dirty:s,ctx:r}),t.$set(n)},i(r){e||(pr(t.$$.fragment,r),e=!0)},o(r){mr(t.$$.fragment,r),e=!1},d(r){Ii(t,r)}}}function wS(i){let t,e;return t=new wd({props:{visible:i[3],variant:"solid",border_mode:i[25]?"focus":"base",padding:!1,elem_id:i[1],elem_classes:i[2],height:i[9]||void 0,width:i[10],allow_overflow:!1,container:i[12],scale:i[13],min_width:i[14],$$slots:{default:[ES]},$$scope:{ctx:i}}}),{c(){Ci(t.$$.fragment)},m(r,s){Ri(t,r,s),e=!0},p(r,s){const n={};s[0]&8&&(n.visible=r[3]),s[0]&33554432&&(n.border_mode=r[25]?"focus":"base"),s[0]&2&&(n.elem_id=r[1]),s[0]&4&&(n.elem_classes=r[2]),s[0]&512&&(n.height=r[9]||void 0),s[0]&1024&&(n.width=r[10]),s[0]&4096&&(n.container=r[12]),s[0]&8192&&(n.scale=r[13]),s[0]&16384&&(n.min_width=r[14]),s[0]&8423665|s[1]&4096&&(n.$$scope={dirty:s,ctx:r}),t.$set(n)},i(r){e||(pr(t.$$.fragment,r),e=!0)},o(r){mr(t.$$.fragment,r),e=!1},d(r){Ii(t,r)}}}function TS(i){let t,e,r,s;const n=[{autoscroll:i[23].autoscroll},{i18n:i[23].i18n},i[0]];let o={};for(let l=0;l<n.length;l+=1)o=qp(o,n[l]);t=new Ad({props:o});let a={crop_size:i[20],value:i[4],root:i[8],sources:i[16],label:i[5],show_label:i[6],brush:i[18],eraser:i[19],changeable:i[22].includes("change"),i18n:i[23].i18n,transforms:i[21]};return r=new dS({props:a}),i[31](r),r.$on("save",i[32]),r.$on("edit",i[33]),r.$on("clear",i[34]),r.$on("stream",i[35
1174]),r.$on("drag",i[36]),r.$on("upload",i[37]),r.$on("select",i[38]),r.$on("share",i[39]),r.$on("error",i[40]),r.$on("error",i[41]),{c(){Ci(t.$$.fragment),e=Jp(),Ci(r.$$.fragment)},m(l,h){Ri(t,l,h),ph(l,e,h),Ri(r,l,h),s=!0},p(l,h){const c=h[0]&8388609?Kp(n,[h[0]&8388608&&{autoscroll:l[23].autoscroll},h[0]&8388608&&{i18n:l[23].i18n},h[0]&1&&Zp(l[0])]):{};t.$set(c);const u={};h[0]&1048576&&(u.crop_size=l[20]),h[0]&16&&(u.value=l[4]),h[0]&256&&(u.root=l[8]),h[0]&65536&&(u.sources=l[16]),h[0]&32&&(u.label=l[5]),h[0]&64&&(u.show_label=l[6]),h[0]&262144&&(u.brush=l[18]),h[0]&524288&&(u.eraser=l[19]),h[0]&4194304&&(u.changeable=l[22].includes("change")),h[0]&8388608&&(u.i18n=l[23].i18n),h[0]&2097152&&(u.transforms=l[21]),r.$set(u)},i(l){s||(pr(t.$$.fragment,l),pr(r.$$.fragment,l),s=!0)},o(l){mr(t.$$.fragment,l),mr(r.$$.fragment,l),s=!1},d(l){l&&fh(e),Ii(t,l),i[31](null),Ii(r,l)}}}function ES(i){let t,e,r,s;const n=[{autoscroll:i[23].autoscroll},{i18n:i[23].i18n},i[0]];let o={};for(let a=0;a<n.length;a+=1)o=qp(o,n[a]);return t=new Ad({props:o}),r=new sm({props:{value:i[4]?.composite||null,label:i[5],show_label:i[6],show_download_button:i[7],selectable:i[11],show_share_button:i[15],i18n:i[23].i18n}}),r.$on("select",i[28]),r.$on("share",i[29]),r.$on("error",i[30]),{c(){Ci(t.$$.fragment),e=Jp(),Ci(r.$$.fragment)},m(a,l){Ri(t,a,l),ph(a,e,l),Ri(r,a,l),s=!0},p(a,l){const h=l[0]&8388609?Kp(n,[l[0]&8388608&&{autoscroll:a[23].autoscroll},l[0]&8388608&&{i18n:a[23].i18n},l[0]&1&&Zp(a[0])]):{};t.$set(h);const c={};l[0]&16&&(c.value=a[4]?.composite||null),l[0]&32&&(c.label=a[5]),l[0]&64&&(c.show_label=a[6]),l[0]&128&&(c.show_download_button=a[7]),l[0]&2048&&(c.selectable=a[11]),l[0]&32768&&(c.show_share_button=a[15]),l[0]&8388608&&(c.i18n=a[23].i18n),r.$set(c)},i(a){s||(pr(t.$$.fragment,a),pr(r.$$.fragment,a),s=!0)},o(a){mr(t.$$.fragment,a),mr(r.$$.fragment,a),s=!1},d(a){a&&fh(e),Ii(t,a),Ii(r,a)}}}function AS(i){let t,e,r,s;const n=[wS,xS],o=[];function a(l,h){return l[17]?1:0}return t=a(i),e=o[t]=n[t](i),{c(){e.c(),r=gS()},m(l,h){o[t].m(l,h),ph(l,r,h),s=!0},p(l,h){let c=t;t=a(l),t===c?o[t].p(l,h):(yS(),mr(o[c],1,1,()=>{o[c]=null}),_S(),e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),pr(e,1),e.m(r.parentNode,r))},i(l){s||(pr(e),s=!0)},o(l){mr(e),s=!1},d(l){l&&fh(r),o[t].d(l)}}}function SS(i,t,e){let{elem_id:r=""}=t,{elem_classes:s=[]}=t,{visible:n=!0}=t,{value:o={background:null,layers:[],composite:null}}=t,{label:a}=t,{show_label:l}=t,{show_download_button:h}=t,{root:c}=t,{height:u}=t,{width:d}=t,{_selectable:f=!1}=t,{container:p=!0}=t,{scale:g=null}=t,{min_width:y=void 0}=t,{loading_status:m}=t,{show_share_button:v=!1}=t,{sources:_=["upload","clipboard","webcam"]}=t,{interactive:b}=t,{brush:w}=t,{eraser:A}=t,{crop_size:x=null}=t,{transforms:C=["crop"]}=t,{attached_events:T=[]}=t,{gradio:P}=t,M;async function B(){e(0,m={status:"pending"});const D=await M.get_data();return e(0,m={status:"complete"}),D}let S;function I(){o&&(o.background||o.layers?.length||o.composite)&&P.dispatch("change")}function k(){P.dispatch("change"),P.dispatch("input")}const V=({detail:D})=>P.dispatch("select",D),O=({detail:D})=>P.dispatch("share",D),et=({detail:D})=>P.dispatch("error",D);function E(D){pS[D?"unshift":"push"](()=>{M=D,e(24,M)})}const R=D=>k(),L=()=>P.dispatch("edit"),Y=()=>P.dispatch("clear"),tt=()=>P.dispatch("stream"),J=({detail:D})=>e(25,S=D),st=()=>P.dispatch("upload"),at=({detail:D})=>P.dispatch("select",D),ht=({detail:D})=>P.dispatch("share",D),yt=({detail:D})=>{e(0,m=m||{}),e(0,m.status="error",m),P.dispatch("error",D)};function wt(D){mS.call(this,i,D)}return i.$$set=D=>{"elem_id"in D&&e(1,r=D.elem_id),"elem_classes"in D&&e(2,s=D.elem_classes),"visible"in D&&e(3,n=D.visible),"value"in D&&e(4,o=D.value),"label"in D&&e(5,a=D.label),"show_label"in D&&e(6,l=D.show_label),"show_download_button"in D&&e(7,h=D.show_download_button),"root"in D&&e(8,c=D.root),"height"in D&&e(9,u=D.height),"width"in D&&e(10,d=D.width),"_selectable"in D&&e(11,f=D._selectable),"container"in D&&e(12,p=D.container),"scale"in D&&e(13,g=D.scale),"min_width"in D&&e(14,y=D.min_width),"loading_status"in D&&e(0,m=D.loading_status),"show_share_button"in D&&e(15,v=D.show_share_button),"s
1174ources"in D&&e(16,_=D.sources),"interactive"in D&&e(17,b=D.interactive),"brush"in D&&e(18,w=D.brush),"eraser"in D&&e(19,A=D.eraser),"crop_size"in D&&e(20,x=D.crop_size),"transforms"in D&&e(21,C=D.transforms),"attached_events"in D&&e(22,T=D.attached_events),"gradio"in D&&e(23,P=D.gradio)},i.$$.update=()=>{i.$$.dirty[0]&16&&o&&I()},[m,r,s,n,o,a,l,h,c,u,d,f,p,g,y,v,_,b,w,A,x,C,T,P,M,S,k,B,V,O,et,E,R,L,Y,tt,J,st,at,ht,yt,wt]}class iC extends fS{constructor(t){super(),vS(this,t,SS,AS,bS,{elem_id:1,elem_classes:2,visible:3,value:4,label:5,show_label:6,show_download_button:7,root:8,height:9,width:10,_selectable:11,container:12,scale:13,min_width:14,loading_status:0,show_share_button:15,sources:16,interactive:17,brush:18,eraser:19,crop_size:20,transforms:21,attached_events:22,gradio:23,get_value:27},null,[-1,-1])}get elem_id(){return this.$$.ctx[1]}set elem_id(t){this.$$set({elem_id:t}),ft()}get elem_classes(){return this.$$.ctx[2]}set elem_classes(t){this.$$set({elem_classes:t}),ft()}get visible(){return this.$$.ctx[3]}set visible(t){this.$$set({visible:t}),ft()}get value(){return this.$$.ctx[4]}set value(t){this.$$set({value:t}),ft()}get label(){return this.$$.ctx[5]}set label(t){this.$$set({label:t}),ft()}get show_label(){return this.$$.ctx[6]}set show_label(t){this.$$set({show_label:t}),ft()}get show_download_button(){return this.$$.ctx[7]}set show_download_button(t){this.$$set({show_download_button:t}),ft()}get root(){return this.$$.ctx[8]}set root(t){this.$$set({root:t}),ft()}get height(){return this.$$.ctx[9]}set height(t){this.$$set({height:t}),ft()}get width(){return this.$$.ctx[10]}set width(t){this.$$set({width:t}),ft()}get _selectable(){return this.$$.ctx[11]}set _selectable(t){this.$$set({_selectable:t}),ft()}get container(){return this.$$.ctx[12]}set container(t){this.$$set({container:t}),ft()}get scale(){return this.$$.ctx[13]}set scale(t){this.$$set({scale:t}),ft()}get min_width(){return this.$$.ctx[14]}set min_width(t){this.$$set({min_width:t}),ft()}get loading_status(){return this.$$.ctx[0]}set loading_status(t){this.$$set({loading_status:t}),ft()}get show_share_button(){return this.$$.ctx[15]}set show_share_button(t){this.$$set({show_share_button:t}),ft()}get sources(){return this.$$.ctx[16]}set sources(t){this.$$set({sources:t}),ft()}get interactive(){return this.$$.ctx[17]}set interactive(t){this.$$set({interactive:t}),ft()}get brush(){return this.$$.ctx[18]}set brush(t){this.$$set({brush:t}),ft()}get eraser(){return this.$$.ctx[19]}set eraser(t){this.$$set({eraser:t}),ft()}get crop_size(){return this.$$.ctx[20]}set crop_size(t){this.$$set({crop_size:t}),ft()}get transforms(){return this.$$.ctx[21]}set transforms(t){this.$$set({transforms:t}),ft()}get attached_events(){return this.$$.ctx[22]}set attached_events(t){this.$$set({attached_events:t}),ft()}get gradio(){return this.$$.ctx[23]}set gradio(t){this.$$set({gradio:t}),ft()}get get_value(){return this.$$.ctx[27]}}export{iC as default}; 1175//# sourceMappingURL=Index-f1ffe7dc.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.