1import z_ from"./ImagePreview-BpvYwBpC.js";import{W as X_}from"./ImageUploader-Dh2I3hM7.js";import{B as gf}from"./Button-BIUaXfcG.js";import{I as Bi,s as yf,S as vf}from"./Index-DB1XLvMK.js";import"./Image-CJc3fwmN.js";/* empty css */import{w as jt,g as bf,c as vn,h as V_,b as Ko}from"./index-BQPjLIsY.js";import{_ as W_}from"./__vite-browser-external-D7Ct-6yo.js";import{C as j_}from"./Check-CZUQOzJl.js";import{U as Y_}from"./Undo-CpmTQw3B.js";/* empty css *//* empty css */import{I as Ph}from"./Image-Bsh8Umrh.js";import{I as q_}from"./Upload-Cp8Go_XF.js";import{W as Z_}from"./SelectSource-C3FIO9My.js";import{U as K_}from"./Upload-1-QDTAlg.js";import{B as J_}from"./BlockLabel-BlSr62f_.js";import"./Blocks-CyfcXtBq.js";import"./Empty-BgF7sXBn.js";import"./ShareButton-DRfMJDgB.js";import"./Download-DVtk-Jv3.js";import"./Minimize-X5PPawdt.js";import"./utils-Gtzs_Zla.js";import"./DownloadLink-CHpWw1Ex.js";import"./file-url-SIRImsEF.js";import"./svelte/svelte.js";import"./DropdownArrow-B_jYsAai.js";const{SvelteComponent:Q_,append:rc,attr:Nr,detach:tm,init:em,insert:rm,noop:Jo,safe_not_equal:im,svg_element:Qo}=window.__gradio__svelte__internal;function sm(r){let t,e,i;return{c(){t=Qo("svg"),e=Qo("path"),i=Qo("path"),Nr(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"),Nr(e,"fill","currentColor"),Nr(i,"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"),Nr(i,"fill","currentColor"),Nr(t,"width","100%"),Nr(t,"height","100%"),Nr(t,"viewBox","0 0 32 32")},m(s,n){rm(s,t,n),rc(t,e),rc(t,i)},p:Jo,i:Jo,o:Jo,d(s){s&&tm(t)}}}let nm=class extends Q_{constructor(t){super(),em(this,t,null,sm,im,{})}};const{SvelteComponent:om,append:am,attr:ci,detach:lm,init:hm,insert:cm,noop:ta,safe_not_equal:um,svg_element:ic}=window.__gradio__svelte__internal;function dm(r){let t,e;return{c(){t=ic("svg"),e=ic("path"),ci(e,"fill","currentColor"),ci(e,"d","M2.753 2.933a.75.75 0 0 1 .814-.68l3.043.272c2.157.205 4.224.452 5.922.732c1.66.273 3.073.594 3.844.983c.197.1.412.233.578.415c.176.192.352.506.28.9c-.067.356-.304.59-.487.729a3.001 3.001 0 0 1-.695.369c-1.02.404-2.952.79-5.984 1.169c-1.442.18-2.489.357-3.214.522c.205.045.43.089.674.132c.992.174 2.241.323 3.568.437a31.21 31.21 0 0 1 3.016.398c.46.087.893.186 1.261.296c.352.105.707.236.971.412c.13.086.304.225.42.437a.988.988 0 0 1 .063.141A1.75 1.75 0 0 0 14.5 12.25v.158c-.758.154-1.743.302-2.986.444c-2.124.243-3.409.55-4.117.859c-.296.128-.442.236-.508.3c.026.037.073.094.156.17c.15.138.369.29.65.45c.56.316 1.282.61 1.979.838l2.637.814a.75.75 0 1 1-.443 1.433l-2.655-.819c-.754-.247-1.58-.578-2.257-.96a5.082 5.082 0 0 1-.924-.65c-.255-.233-.513-.544-.62-.935c-.12-.441-.016-.88.274-1.244c.261-.328.656-.574 1.113-.773c.92-.4 2.387-.727 4.545-.974c1.366-.156 2.354-.313 3.041-.462a16.007 16.007 0 0 0-.552-.114a29.716 29.716 0 0 0-2.865-.378c-1.352-.116-2.649-.27-3.7-.454c-.524-.092-1-.194-1.395-.307c-.376-.106-.75-.241-1.021-.426a1.186 1.186 0 0 1-.43-.49a.934.934 0 0 1 .059-.873c.13-.213.32-.352.472-.442a3.23 3.23 0 0 1 .559-.251c.807-.287 2.222-.562 4.37-.83c2.695-.338 4.377-.666 5.295-.962c-.638-.21-1.623-.427-2.89-.635c-1.65-.273-3.679-.515-5.816-.718l-3.038-.272a.75.75 0 0 1-.68-.814M17 12.25a.75.75 0 0 0-1.5 0v4.19l-.72-.72a.75.75 0 1 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0l2-2a.75.75 0 1 0-1.06-1.06l-.72.72z"),ci(t,"xmlns","http://www.w3.org/2000/svg"),ci(t,"width","100%"),ci(t,"height","100%"),ci(t,"viewBox","0 0 24 24")},m(i,s){cm(i,t,s),am(t,e)},p:ta,i:ta,o:ta,d(i){i&&lm(t)}}}class fm extends om{constructor(t){super(),hm(this,t,null,dm,um,{})}}const{SvelteComponent:pm,append:_m,attr:ui,detach:mm,init:gm,insert:ym,noop:ea,safe_not_equal:vm,svg_element:sc}=window.__gradio__svelte__internal;function bm(r){let t,e;return{c(){t=sc("svg"),e=sc("path"),ui(e,"fill","currentColor"),ui(e,"d","M17 23v-4H7q-.825 0-1.413-.588T5 17V7H1V5h4V1h2v16h16v2h-4v4h-2Zm0-8V7H9V5h8q.825 0 1.413.588T19 7v8h-2Z"),ui(t,"xmlns","http://www.w3.org/2000/svg"),ui(t,"width","100%"),ui(t,"height","100%"),ui(t,"viewBox","0 0 24 24")},m(i,s){ym(i,t,s),_m(t,e)},p:ea,i:ea,o:ea,d(i){i&&mm(t)}}}let xm=class extends pm{constructor(t){super(),gm(this,t,null,bm,vm,{})}};const{SvelteComponent:wm,append:ra,attr:fe,detach:Tm,init:Em,insert:Am,noop:ia,safe_not_equal:Sm,svg_element:Os}=window.__gradio__svelte__internal;function Cm(r){let t,e,i,s;return{c(){t=Os("svg"),e=Os("g"),i=Os("path"),s=Os("path"),fe(i,"fill","currentColor"),fe(i,"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"),fe(s,"stroke","currentColor"),fe(s,"stroke-linecap","round"),fe(s,"stroke-width","1.5"),fe(s,"d","M9 21h12"),fe(e,"fill","none"),fe(t,"xmlns","http://www.w3.org/2000/svg"),fe(t,"width","100%"),fe(t,"height","100%"),fe(t,"viewBox","0 0 24 24")},m(n,o){Am(n,t,o),ra(t,e),ra(e,i),ra(e,s)},p:ia,i:ia,o:ia,d(n){n&&Tm(t)}}}class Im extends wm{constructor(t){super(),Em(this,t,null,Cm,Sm,{})}}const{SvelteComponent:Rm,append:Pm,attr:di,detach:Mm,init:km,insert:Bm,noop:sa,safe_not_equal:Dm,svg_element:nc}=window.__gradio__svelte__internal;function Fm(r){let t,e;return{c(){t=nc("svg"),e=nc("path"),di(e,"fill","currentColor"),di(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"),di(t,"xmlns","http://www.w3.org/2000/svg"),di(t,"width","100%"),di(t,"height","100%"),di(t,"viewBox","0 0 24 24")},m(i,s){Bm(i,t,s),Pm(t,e)},p:sa,i:sa,o:sa,d(i){i&&Mm(t)}}}class Om extends Rm{constructor(t){super(),km(this,t,null,Fm,Dm,{})}}const{SvelteComponent:Nm,append:oc,attr:se,detach:Lm,init:Um,insert:Gm,noop:na,safe_not_equal:Hm,svg_element:oa}=window.__gradio__svelte__internal;function $m(r){let t,e,i;return{c(){t=oa("svg"),e=oa("path"),i=oa("path"),se(e,"d","M1.35327 10.9495L6.77663 15.158C7.12221 15.4229 7.50051 15.5553 7.91154 15.5553C8.32258 15.5553 8.70126 15.4229 9.0476 15.158L14.471 10.9495"),se(e,"stroke","currentColor"),se(e,"stroke-width","1.5"),se(e,"stroke-linecap","round"),se(i,"d","M7.23461 11.4324C7.23406 11.432 7.2335 11.4316 7.23295 11.4312L1.81496 7.2268C1.81471 7.22661 1.81446 7.22641 1.8142 7.22621C1.52269 6.99826 1.39429 6.73321 1.39429 6.37014C1.39429 6.00782 1.52236 5.74301 1.81325 5.51507C1.8136 5.5148 1.81394 5.51453 1.81428 5.51426L7.2331 1.30812C7.45645 1.13785 7.67632 1.06653 7.91159 1.06653C8.14692 1.06653 8.36622 1.13787 8.58861 1.30787C8.58915 1.30828 8.58969 1.30869 8.59023 1.30911L14.0082 5.51462C14.0085 5.51485 14.0088 5.51507 14.0091 5.51529C14.3008 5.74345 14.4289 6.00823 14.4289 6.37014C14.4289 6.73356 14.3006 6.99862 14.01 7.22634C14.0096 7.22662 14.0093 7.22689 14.0089 7.22717L8.59007 11.4322C8.36672 11.6024 8.14686 11.6738 7.91159 11.6738C7.67628 11.6738 7.45699 11.6024 7.23461 11.4324Z"),se(i,"stroke","currentColor"),se(i,"stroke-width","1.5"),se(t,"width","100%"),se(t,"height","100%"),se(t,"viewBox","0 0 17 17"),se(t,"fill","none"),se(t,"xmlns","http://www.w3.org/2000/svg")},m(s,n){Gm(s,t,n),oc(t,e),oc(t,i)},p:na,i:na,o:na,d(s){s&&Lm(t)}}}class zm extends Nm{constructor(t){super(),Um(this,t,null,$m,Hm,{})}}const{SvelteComponent:Xm,append:is,attr:Vt,detach:Vm,init:Wm,insert:jm,noop:aa,safe_not_equal:Ym,svg_element:fi}=window.__gradio__svelte__internal;function qm(r){let t,e,i,s,n,o;return{c(){t=fi("svg"),e=fi("g"),i=fi("path"),s=fi("circle"),n=fi("circle"),o=fi("path"),Vt(i,"d","M2 12.026c0 5.146 3.867 9.387 8.847 9.96c.735.085 1.447-.228 1.97-.753a1.
168 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"),Vt(s,"cx","17.5"),Vt(s,"cy","11.5"),Vt(s,"r",".75"),Vt(n,"cx","6.5"),Vt(n,"cy","11.5"),Vt(n,"r",".75"),Vt(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"),Vt(e,"fill","none"),Vt(e,"stroke","currentColor"),Vt(e,"stroke-width","1.5"),Vt(t,"xmlns","http://www.w3.org/2000/svg"),Vt(t,"width","100%"),Vt(t,"height","100%"),Vt(t,"viewBox","0 0 24 24")},m(a,l){jm(a,t,l),is(t,e),is(e,i),is(e,s),is(e,n),is(e,o)},p:aa,i:aa,o:aa,d(a){a&&Vm(t)}}}class Zm extends Xm{constructor(t){super(),Wm(this,t,null,qm,Ym,{})}}const{SvelteComponent:Km,append:ac,attr:ne,detach:Jm,init:Qm,insert:tg,noop:la,safe_not_equal:eg,set_style:rg,svg_element:ha}=window.__gradio__svelte__internal;function ig(r){let t,e,i;return{c(){t=ha("svg"),e=ha("polyline"),i=ha("path"),ne(e,"points","1 4 1 10 7 10"),ne(i,"d","M3.51 15a9 9 0 1 0 2.13-9.36L1 10"),ne(t,"xmlns","http://www.w3.org/2000/svg"),ne(t,"width","100%"),ne(t,"height","100%"),ne(t,"viewBox","0 0 24 24"),ne(t,"fill","none"),ne(t,"stroke","currentColor"),ne(t,"stroke-width","2"),ne(t,"stroke-linecap","round"),ne(t,"stroke-linejoin","round"),ne(t,"class","feather feather-rotate-ccw"),rg(t,"transform","rotateY(180deg)")},m(s,n){tg(s,t,n),ac(t,e),ac(t,i)},p:la,i:la,o:la,d(s){s&&Jm(t)}}}class sg extends Km{constructor(t){super(),Qm(this,t,null,ig,eg,{})}}const{SvelteComponent:ng,append:ar,attr:Et,detach:og,init:ag,insert:lg,noop:ca,safe_not_equal:hg,svg_element:lr,text:cg}=window.__gradio__svelte__internal;function ug(r){let t,e,i,s,n,o,a,l,h;return{c(){t=lr("svg"),e=lr("defs"),i=lr("style"),s=cg(`.cls-1 { 2 fill: none; 3 }`),n=lr("rect"),o=lr("rect"),a=lr("path"),l=lr("rect"),h=lr("rect"),Et(n,"x","12"),Et(n,"y","12"),Et(n,"width","2"),Et(n,"height","12"),Et(o,"x","18"),Et(o,"y","12"),Et(o,"width","2"),Et(o,"height","12"),Et(a,"d","M4,6V8H6V28a2,2,0,0,0,2,2H24a2,2,0,0,0,2-2V8h2V6ZM8,28V8H24V28Z"),Et(l,"x","12"),Et(l,"y","2"),Et(l,"width","8"),Et(l,"height","2"),Et(h,"id","_Transparent_Rectangle_"),Et(h,"data-name","<Transparent Rectangle>"),Et(h,"class","cls-1"),Et(h,"width","32"),Et(h,"height","32"),Et(t,"id","icon"),Et(t,"xmlns","http://www.w3.org/2000/svg"),Et(t,"viewBox","0 0 32 32"),Et(t,"fill","currentColor")},m(c,u){lg(c,t,u),ar(t,e),ar(e,i),ar(i,s),ar(t,n),ar(t,o),ar(t,a),ar(t,l),ar(t,h)},p:ca,i:ca,o:ca,d(c){c&&og(t)}}}class dg extends ng{constructor(t){super(),ag(this,t,null,ug,hg,{})}}const{SvelteComponent:fg,attr:pg,create_slot:_g,detach:mg,element:gg,flush:yg,get_all_dirty_from_scope:vg,get_slot_changes:bg,init:xg,insert:wg,safe_not_equal:Tg,toggle_class:lc,transition_in:Eg,transition_out:Ag,update_slot_base:Sg}=window.__gradio__svelte__internal;function Cg(r){let t,e;const i=r[2].default,s=_g(i,r,r[1],null);return{c(){t=gg("div"),s&&s.c(),pg(t,"class","svelte-1ua59x3"),lc(t,"show_border",r[0])},m(n,o){wg(n,t,o),s&&s.m(t,null),e=!0},p(n,[o]){s&&s.p&&(!e||o&2)&&Sg(s,i,n,n[1],e?bg(i,n[1],o,null):vg(n[1]),null),(!e||o&1)&&lc(t,"show_border",n[0])},i(n){e||(Eg(s,n),e=!0)},o(n){Ag(s,n),e=!1},d(n){n&&mg(t),s&&s.d(n)}}}function Ig(r,t,e){let{$$slots:i={},$$scope:s}=t,{show_border:n=!1}=t;return r.$$set=o=>{"show_border"in o&&e(0,n=o.show_border),"$$scope"in o&&e(1,s=o.$$scope)},[n,s,i]}class Rg extends fg{constructor(t){super(),xg(this,t,Ig,Cg,Tg,{show_border:0})}get show_border(){return this.$$.ctx[0]}set show_border(t){this.$$set({show_border:t}),yg()}}const{SvelteComponent:Pg,add_iframe_resize_listener:Mg,add_render_callback:kg,attr:Bg,binding_callbacks:Dg,check_outros:Fg,component_subscribe:ua,create_component:xf,create_slot:Og,destroy_component:wf,detach:Vn,element:Ng,empty:Tf,ensure_array_like:hc,flush:Lg,get_all_dirty_from_scope:Ug,get_slot_changes:Gg,group_outros:Hg,init:$g,insert:Wn,mount_component:Ef,outro_and_destroy_block:zg,safe_not_equal:Xg,set_store_value:cc,space:Vg,transition_in:jn,transition_out:Yn,update_keyed_each:Wg,update_slot_base:jg}=window.__gradio__svelte__internal,{getContext:Yg,setContext:qg}=window.__gradio__svelte__internal;function uc(r,t,e){const i=r.slice();return i[21]=t[e],i}function dc(r,t){let e,i,s;function n(...o){return t[12](t[21],...o)}return i=new Bi({props:{highlight:t[3]===t[21],Icon:t[7][t[21]].icon,size:"medium",padded:!1,label:t[7][t[21]].label+" button",transparent:!0,offset:t[21]==="draw"?-2:t[21]==="erase"?-6:0}}),i.$on("click",n),{key:r,first:null,c(){e=Tf(),xf(i.$$.fragment),this.first=e},m(o,a){Wn(o,e,a),Ef(i,o,a),s=!0},p(o,a){t=o;const l={};a&10&&(l.highlight=t[3]===t[21]),a&2&&(l.Icon=t[7][t[21]].icon),a&2&&(l.label=t[7][t[21]].label+" button"),a&2&&(l.offset=t[21]==="draw"?-2:t[21]==="erase"?-6:0),i.$set(l)},i(o){s||(jn(i.$$.fragment,o),s=!0)},o(o){Yn(i.$$.fragment,o),s=!1},d(o){o&&Vn(e),wf(i,o)}}}function Zg(r){let t=[],e=new Map,i,s,n=hc(r[1]);const o=a=>a[21];for(let a=0;a<n.length;a+=1){let l=uc(r,n,a),h=o(l);e.set(h,t[a]=dc(h,l))}return{c(){for(let a=0;a<t.length;a+=1)t[a].c();i=Tf()},m(a,l){for(let h=0;h<t.length;h+=1)t[h]&&t[h].m(a,l);Wn(a,i,l),s=!0},p(a,l){l&394&&(n=hc(a[1]),Hg(),t=Wg(t,l,o,1,a,n,e,i.parentNode,zg,dc,i,uc),Fg())},i(a){if(!s){for(let l=0;l<n.length;l+=1)jn(t[l]);s=!0}},o(a){for(let l=0;l<t.length;l+=1)Yn(t[l]);s=!1},d(a){a&&Vn(i);for(let l=0;l<t.length;l+=1)t[l].d(a)}}}function Kg(r){let t,e,i,s,n;const o=r[11].default,a=Og(o,r,r[15],null);return i=new Rg({props:{show_border:!1,$$slots:{default:[Zg]},$$scope:{ctx:r}}}),{c(){a&&a.c(),t=Vg(),e=Ng("div"),xf(i.$$.fragment),Bg(e,"class","toolbar-wrap svelte-k9d7m2"),kg(()=>r[13].call(e))}
3,m(l,h){a&&a.m(l,h),Wn(l,t,h),Wn(l,e,h),Ef(i,e,null),s=Mg(e,r[13].bind(e)),r[14](e),n=!0},p(l,[h]){a&&a.p&&(!n||h&32768)&&jg(a,o,l,l[15],n?Gg(o,l[15],h,null):Ug(l[15]),null);const c={};h&32778&&(c.$$scope={dirty:h,ctx:l}),i.$set(c)},i(l){n||(jn(a,l),jn(i.$$.fragment,l),n=!0)},o(l){Yn(a,l),Yn(i.$$.fragment,l),n=!1},d(l){l&&(Vn(t),Vn(e)),a&&a.d(l),wf(i),s(),r[14](null)}}}const So=Symbol("tool");function Jg(r,t,e){let i,s,n,{$$slots:o={},$$scope:a}=t;const{active_tool:l,toolbar_box:h,editor_box:c}=Yg(es);ua(r,l,E=>e(3,i=E)),ua(r,h,E=>e(17,s=E)),ua(r,c,E=>e(10,n=E));let{i18n:u}=t,d=[];const f={},m={current_color:jt("#000000"),register_tool:(E,C)=>(e(1,d=[...d,E]),C?.cb&&(f[E]=C.cb),()=>{e(1,d=d.filter(M=>M!==E))}),active_tool:{subscribe:l.subscribe,set:l.set}};qg(So,m);const g={crop:{order:1,label:u("Transform"),icon:xm},draw:{order:2,label:u("Draw"),icon:nm},erase:{order:2,label:u("Erase"),icon:Im},bg:{order:0,label:u("Background"),icon:Ph}};let _,v;function y(){v&&cc(h,s=v.getBoundingClientRect(),s)}function b(E,C){E.stopPropagation(),cc(l,i=C,i),f[C]&&f[C]()}const x=(E,C)=>b(C,E);function w(){_=this.clientWidth,e(0,_)}function T(E){Dg[E?"unshift":"push"](()=>{v=E,e(2,v)})}return r.$$set=E=>{"i18n"in E&&e(9,u=E.i18n),"$$scope"in E&&e(15,a=E.$$scope)},r.$$.update=()=>{r.$$.dirty&1025&&y()},[_,d,v,i,l,h,c,g,b,u,n,o,x,w,T,a]}class Qg extends Pg{constructor(t){super(),$g(this,t,Jg,Kg,Xg,{i18n:9})}get i18n(){return this.$$.ctx[9]}set i18n(t){this.$$set({i18n:t}),Lg()}}function qn(r){"@babel/helpers - typeof";return qn=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},qn(r)}var t0=/^\s+/,e0=/\s+$/;function W(r,t){if(r=r||"",t=t||{},r instanceof W)return r;if(!(this instanceof W))return new W(r,t);var e=r0(r);this._originalInput=r,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}W.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,i,s,n,o,a;return e=t.r/255,i=t.g/255,s=t.b/255,e<=.03928?n=e/12.92:n=Math.pow((e+.055)/1.055,2.4),i<=.03928?o=i/12.92:o=Math.pow((i+.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=Af(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=pc(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=pc(this._r,this._g,this._b),e=Math.round(t.h*360),i=Math.round(t.s*100),s=Math.round(t.v*100);return this._a==1?"hsv("+e+", "+i+"%, "+s+"%)":"hsva("+e+", "+i+"%, "+s+"%, "+this._roundA+")"},toHsl:function(){var t=fc(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=fc(this._r,this._g,this._b),e=Math.round(t.h*360),i=Math.round(t.s*100),s=Math.round(t.l*100);return this._a==1?"hsl("+e+", "+i+"%, "+s+"%)":"hsla("+e+", "+i+"%, "+s+"%, "+this._roundA+")"},toHex:function(t){return _c(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return o0(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(vt(this._r,255)*100)+"%",g:Math.round(vt(this._g,255)*100)+"%",b:Math.round(vt(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(vt(this._r,255)*100)+"%, "+Math.round(vt(this._g,255)*100)+"%, "+Math.round(vt(this._b,255)*100)+"%)":"rgba("+Math.round(vt(this._r,255)*100)+"%, "+Math.round(vt(this._g,255)*100)+"%, "+Math.round(vt(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:y0[_c(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var e="#"+mc(this._r,this._g,this._b,this._a),i=e,s=this._gradientType?"GradientType = 1, ":"";if(t){var n=W(t);i="#"+mc(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+s+"startColorstr="+e+",endColorstr="+i+")"},toString:function(t){var e=!!t;t=t||this._format;var i=!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"&&(i=this.toRgbString()),t==="prgb"&&(i=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(i=this.toHexString()),t==="hex3"&&(i=this.toHexString(!0)),t==="hex4"&&(i=this.toHex8String(!0)),t==="hex8"&&(i=this.toHex8String()),t==="name"&&(i=this.toName()),t==="hsl"&&(i=this.toHslString()),t==="hsv"&&(i=this.toHsvString()),i||this.toHexString())},clone:function(){return W(this.toString())},_applyModification:function(t,e){var i=t.apply(null,[this].concat([].slice.call(e)));return this._r=i._r,this._g=i._g,this._b=i._b,this.setAlpha(i._a),this},lighten:function(){return this._applyModification(c0,arguments)},brighten:function(){return this._applyModification(u0,arguments)},darken:function(){return this._applyModification(d0,arguments)},desaturate:function(){return this._applyModification(a0,arguments)},saturate:function(){return this._applyModification(l0,arguments)},greyscale:function(){return this._applyModification(h0,arguments)},spin:function(){return this._applyModification(f0,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(m0,arguments)},complement:function(){return this._applyCombination(p0,arguments)},monochromatic:function(){return this._applyCombination(g0,arguments)},splitcomplement:function(){return this._applyCombination(_0,arguments)},triad:function(){return this._applyCombination(gc,[3])},tetrad:function(){return this._applyCombination(gc,[4])}};W.fromRatio=function(r,t){if(qn(r)=="object"){var e={};for(var i in r)r.hasOwnProperty(i)&&(i==="a"?e[i]=r[i]:e[i]=ds(r[i]));r=e}return W(r,t)};function r0(r){var t={r:0,g:0,b:0},e=1,i=null,s=null,n=null,o=!1,a=!1;return typeof r=="string"&&(r=w0(r)),qn(r)=="object"&&(Ve(r.r)&&Ve(r.g)&&Ve(r.b)?(t=i0(r.r,r.g,r.b),o=!0,a=String(r.r).substr(-1)==="%"?"prgb":"rgb"):Ve(r.h)&&Ve(r.s)&&Ve(r.v)?(i=ds(r.s),s=ds(r.v),t=n0(r.h,i,s),o=!0,a="hsv"):Ve(r.h)&&Ve(r.s)&&Ve(r.l)&&(i=ds(r.s),n=ds(r.l),t=s0(r.h,i,n),o=!0,a="hsl"),r.hasOwnProperty("a")&&(e=r.a)),e=Af(e),{ok:o,format:r.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 i0(r,t,e){return{r:vt(r,255)*255,g:vt(t,255)*255,b:vt(e,255)*255}}function fc(r,t,e){r=vt(r,255),t=vt(t,255),e=vt(e,255);var i=Math.max(r,t,e),s=Math.min(r,t,e),n,o,a=(i+s)/2;if(i==s)n=o=0;else{var l=i-s;switch(o=a>.5?l/(2-i-s):l/(i+s),i){case r:n=(t-e)/l+(t<e?6:0);break;case t:n=(e-r)/l+2;break;case e:n=(r-t)/l+4;break}n/=6}return{h:n,s:o,l:a}}function s0(r,t,e){var i,s,n;r=vt(r,360),t=vt(t,100),e=vt(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)i=s=n=e;else{var a=e<.5?e*(1+t):e+t-e*t,l=2*e-a;i=o(l,a,r+1/3),s=o(l,a,r),n=o(l,a,r-1/3)}return{r:i*255,g:s*255,b:n*255}}function pc(r,t,e){r=vt(r,255),t=vt(t,255),e=vt(e,255);var i=Math.max(r,t,e),s=Math.min(r,t,e),n,o,a=i,l=i-s;if(o=i===0?0:l/i,i==s)n=0;else{switch(i){case r:n=(t-e)/l+(t<e?6:0);break;case t:n=(e-r)/l+2;break;case e:n=(r-t)/l+4;break}n/=6}return{h:n,s:o,v:a}}function n0(r,t,e){r=vt(r,360)*6,t=vt(t,100),e=vt(e,100);var i=Math.floor(r),s=r-i,n=e*(1-t),o=e*(1-s*t),a=e*(1-(1-s)*t),l=i%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 _c(r,t,e,i){var s=[we(Math.round(r).toString(16)),we(Math.round(t).toString(16)),we(Math.round(e).toString(16))];return i&&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 o0(r,t,e,i,s){var n=[we(Math.round(r).toString(16)),we(Math.round(t).toString(16)),we(Math.round(e).toString(16)),we(Sf(i))];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 mc(r,t,e,i){var s=[we(Sf(i)),we(Math.round(r).toString(16)),we(Math.round(t).toString(16)),we(Math.round(e).toString(16))];return s.join("")}W.equals=function(r,t){return!r||!t?!1:W(r).toRgbString()==W(t).toRgbString()};W.random=function(){return W.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function a0(r,t){t=t===0?0:t||10;var e=W(r).toHsl();return e.s-=t/100,e.s=Co(e.s),W(e)}function l0(r,t){t=t===0?0:t||10;var e=W(r).toHsl();return e.s+=t/100,e.s=Co(e.s),W(e)}function h0(r){return W(r).desaturate(100)}function c0(r,t){t=t===0?0:t||10;var e=W(r).toHsl();return e.l+=t/100,e.l=Co(e.l),W(e)}function u0(r,t){t=t===0?0:t||10;var e=W(r).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 3
3ath.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)))),W(e)}function d0(r,t){t=t===0?0:t||10;var e=W(r).toHsl();return e.l-=t/100,e.l=Co(e.l),W(e)}function f0(r,t){var e=W(r).toHsl(),i=(e.h+t)%360;return e.h=i<0?360+i:i,W(e)}function p0(r){var t=W(r).toHsl();return t.h=(t.h+180)%360,W(t)}function gc(r,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var e=W(r).toHsl(),i=[W(r)],s=360/t,n=1;n<t;n++)i.push(W({h:(e.h+n*s)%360,s:e.s,l:e.l}));return i}function _0(r){var t=W(r).toHsl(),e=t.h;return[W(r),W({h:(e+72)%360,s:t.s,l:t.l}),W({h:(e+216)%360,s:t.s,l:t.l})]}function m0(r,t,e){t=t||6,e=e||30;var i=W(r).toHsl(),s=360/e,n=[W(r)];for(i.h=(i.h-(s*t>>1)+720)%360;--t;)i.h=(i.h+s)%360,n.push(W(i));return n}function g0(r,t){t=t||6;for(var e=W(r).toHsv(),i=e.h,s=e.s,n=e.v,o=[],a=1/t;t--;)o.push(W({h:i,s,v:n})),n=(n+a)%1;return o}W.mix=function(r,t,e){e=e===0?0:e||50;var i=W(r).toRgb(),s=W(t).toRgb(),n=e/100,o={r:(s.r-i.r)*n+i.r,g:(s.g-i.g)*n+i.g,b:(s.b-i.b)*n+i.b,a:(s.a-i.a)*n+i.a};return W(o)};W.readability=function(r,t){var e=W(r),i=W(t);return(Math.max(e.getLuminance(),i.getLuminance())+.05)/(Math.min(e.getLuminance(),i.getLuminance())+.05)};W.isReadable=function(r,t,e){var i=W.readability(r,t),s,n;switch(n=!1,s=T0(e),s.level+s.size){case"AAsmall":case"AAAlarge":n=i>=4.5;break;case"AAlarge":n=i>=3;break;case"AAAsmall":n=i>=7;break}return n};W.mostReadable=function(r,t,e){var i=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=W.readability(r,t[h]),n>s&&(s=n,i=W(t[h]));return W.isReadable(r,i,{level:a,size:l})||!o?i:(e.includeFallbackColors=!1,W.mostReadable(r,["#fff","#000"],e))};var bl=W.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
30",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"},y0=W.hexNames=v0(bl);function v0(r){var t={};for(var e in r)r.hasOwnProperty(e)&&(t[r[e]]=e);return t}function Af(r){return r=parseFloat(r),(isNaN(r)||r<0||r>1)&&(r=1),r}function vt(r,t){b0(r)&&(r="100%");var e=x0(r);return r=Math.min(t,Math.max(0,parseFloat(r))),e&&(r=parseInt(r*t,10)/100),Math.abs(r-t)<1e-6?1:r%t/parseFloat(t)}function Co(r){return Math.min(1,Math.max(0,r))}function Jt(r){return parseInt(r,16)}function b0(r){return typeof r=="string"&&r.indexOf(".")!=-1&&parseFloat(r)===1}function x0(r){return typeof r=="string"&&r.indexOf("%")!=-1}function we(r){return r.length==1?"0"+r:""+r}function ds(r){return r<=1&&(r=r*100+"%"),r}function Sf(r){return Math.round(parseFloat(r)*255).toString(16)}function yc(r){return Jt(r)/255}var ge=function(){var r="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",e="(?:"+t+")|(?:"+r+")",i="[\\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"+i),rgba:new RegExp("rgba"+s),hsl:new RegExp("hsl"+i),hsla:new RegExp("hsla"+s),hsv:new RegExp("hsv"+i),hsva:new RegExp("hsva"
3+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 Ve(r){return!!ge.CSS_UNIT.exec(r)}function w0(r){r=r.replace(t0,"").replace(e0,"").toLowerCase();var t=!1;if(bl[r])r=bl[r],t=!0;else if(r=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var e;return(e=ge.rgb.exec(r))?{r:e[1],g:e[2],b:e[3]}:(e=ge.rgba.exec(r))?{r:e[1],g:e[2],b:e[3],a:e[4]}:(e=ge.hsl.exec(r))?{h:e[1],s:e[2],l:e[3]}:(e=ge.hsla.exec(r))?{h:e[1],s:e[2],l:e[3],a:e[4]}:(e=ge.hsv.exec(r))?{h:e[1],s:e[2],v:e[3]}:(e=ge.hsva.exec(r))?{h:e[1],s:e[2],v:e[3],a:e[4]}:(e=ge.hex8.exec(r))?{r:Jt(e[1]),g:Jt(e[2]),b:Jt(e[3]),a:yc(e[4]),format:t?"name":"hex8"}:(e=ge.hex6.exec(r))?{r:Jt(e[1]),g:Jt(e[2]),b:Jt(e[3]),format:t?"name":"hex"}:(e=ge.hex4.exec(r))?{r:Jt(e[1]+""+e[1]),g:Jt(e[2]+""+e[2]),b:Jt(e[3]+""+e[3]),a:yc(e[4]+""+e[4]),format:t?"name":"hex8"}:(e=ge.hex3.exec(r))?{r:Jt(e[1]+""+e[1]),g:Jt(e[2]+""+e[2]),b:Jt(e[3]+""+e[3]),format:t?"name":"hex"}:!1}function T0(r){var t,e;return r=r||{level:"AA",size:"small"},t=(r.level||"AA").toUpperCase(),e=(r.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),e!=="small"&&e!=="large"&&(e="small"),{level:t,size:e}}var li=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(li||{}),Cf=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Cf||{}),xl=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(xl||{}),Q=(r=>(r[r.NORMAL=0]="NORMAL",r[r.ADD=1]="ADD",r[r.MULTIPLY=2]="MULTIPLY",r[r.SCREEN=3]="SCREEN",r[r.OVERLAY=4]="OVERLAY",r[r.DARKEN=5]="DARKEN",r[r.LIGHTEN=6]="LIGHTEN",r[r.COLOR_DODGE=7]="COLOR_DODGE",r[r.COLOR_BURN=8]="COLOR_BURN",r[r.HARD_LIGHT=9]="HARD_LIGHT",r[r.SOFT_LIGHT=10]="SOFT_LIGHT",r[r.DIFFERENCE=11]="DIFFERENCE",r[r.EXCLUSION=12]="EXCLUSION",r[r.HUE=13]="HUE",r[r.SATURATION=14]="SATURATION",r[r.COLOR=15]="COLOR",r[r.LUMINOSITY=16]="LUMINOSITY",r[r.NORMAL_NPM=17]="NORMAL_NPM",r[r.ADD_NPM=18]="ADD_NPM",r[r.SCREEN_NPM=19]="SCREEN_NPM",r[r.NONE=20]="NONE",r[r.SRC_OVER=0]="SRC_OVER",r[r.SRC_IN=21]="SRC_IN",r[r.SRC_OUT=22]="SRC_OUT",r[r.SRC_ATOP=23]="SRC_ATOP",r[r.DST_OVER=24]="DST_OVER",r[r.DST_IN=25]="DST_IN",r[r.DST_OUT=26]="DST_OUT",r[r.DST_ATOP=27]="DST_ATOP",r[r.ERASE=26]="ERASE",r[r.SUBTRACT=28]="SUBTRACT",r[r.XOR=29]="XOR",r))(Q||{}),Ge=(r=>(r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN",r))(Ge||{}),N=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(N||{}),Di=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(Di||{}),K=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(K||{}),X=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(X||{}),Je=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(Je||{}),Tr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Tr||{}),ze=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(ze||{}),Zt=(r=>(r[r.NPM=0]="NPM",r[r.UNPACK=1]="UNPACK",r[r.PMA=2]="PMA",r[r.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",r[r.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",r[r.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",r))(Zt||{}),Oe=(r=>(r[r.NO=0]="NO",r[r.YES=1]="YES",r[r.AUTO=2]="AUTO",r[r.BLEND=0]="BLEND",r[r.CLEAR=1]="CLEAR",r[r.BLIT=2]="BLIT",r))(Oe||{}),Mh=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(Mh||{}),he=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(he||{}),It=(r=>(r[r.NONE=0]="NONE",r[r.SCISSOR=1]="SCISSOR",r[r.STENCIL=2]="STENCIL",r[r.SPRITE=3]="SPRITE",r[r.COLOR=4]="COLOR",r))(It||{}),Ct=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Ct||{}),He=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(He||{});const E0={createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")},V={ADAPTER:E0,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var da=/iPhone/i,vc=/iPod/i,bc=/iPad/i,xc=/\biOS-universal(?:.+)Mac\b/i,fa=/\bAndroid(?:.+)Mobile\b/i,wc=/Android/i,pi=/(?:SD4930UR|\bSilk(?:.
vendor: 5,234 bytes, line 3
3+)Mobile\b)/i,Ns=/Silk/i,We=/Windows Phone/i,Tc=/\bWindows(?:.+)ARM\b/i,Ec=/BlackBerry/i,Ac=/BB10/i,Sc=/Opera Mini/i,Cc=/\b(CriOS|Chrome)(?:.+)Mobile/i,Ic=/Mobile(?:.+)Firefox\b/i,Rc=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function A0(r){return function(t){return t.test(r)}}function Pc(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var s=A0(e),n={apple:{phone:s(da)&&!s(We),ipod:s(vc),tablet:!s(da)&&(s(bc)||Rc(t))&&!s(We),universal:s(xc),device:(s(da)||s(vc)||s(bc)||s(xc)||Rc(t))&&!s(We)},amazon:{phone:s(pi),tablet:!s(pi)&&s(Ns),device:s(pi)||s(Ns)},android:{phone:!s(We)&&s(pi)||!s(We)&&s(fa),tablet:!s(We)&&!s(pi)&&!s(fa)&&(s(Ns)||s(wc)),device:!s(We)&&(s(pi)||s(Ns)||s(fa)||s(wc))||s(/\bokhttp\b/i)},windows:{phone:s(We),tablet:s(Tc),device:s(We)||s(Tc)},other:{blackberry:s(Ec),blackberry10:s(Ac),opera:s(Sc),firefox:s(Ic),chrome:s(Cc),device:s(Ec)||s(Ac)||s(Sc)||s(Ic)||s(Cc)},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 S0=Pc.default??Pc,Qe=S0(globalThis.navigator);V.RETINA_PREFIX=/@([0-9\.]+)x/;V.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var If={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__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 i:delete l._events[h]}function a(){this._events=new i,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 m=e?e+h:h;if(!this._events[m])return!1;var g=this._events[m],_=arguments.length,v,y;if(g.fn){switch(g.once&&this.removeListener(h,g.fn,void 0,!0),_){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,u),!0;case 4:return g.fn.call(g.context,c,u,d),!0;case 5:return g.fn.call(g.context,c,u,d,f),!0;case 6:return g.fn.call(g.context,c,u,d,f,p),!0}for(y=1,v=new Array(_-1);y<_;y++)v[y-1]=arguments[y];g.fn.apply(g.context,v)}else{var b=g.length,x;for(y=0;y<b;y++)switch(g[y].once&&this.removeListener(h,g[y].fn,void 0,!0),_){case 1:g[y].fn.call(g[y].context);break;case 2:g[y].fn.call(g[y].context,c);break;case 3:g[y].fn.call(g[y].context,c,u);break;case 4:g[y].fn.call(g[y].context,c,u,d);break;default:if(!v)for(x=1,v=new Array(_-1);x<_;x++)v[x-1]=arguments[x];g[y].fn.apply(g[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 m=0,g=[],_=p.length;m<_;m++)(p[m].fn!==c||d&&!p[m].once||u&&p[m].context!==u)&&g.push(p[m]);g.length?this._events[f]=g.length===1?g[0]:g: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 i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(If);var C0=If.exports;const ks=bf(C0);var kh={exports:{}};kh.exports=Io;kh.exports.default=Io;function Io(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=Rf(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,l,h,c,u,d,f;if(i&&(n=k0(r,t,n,e)),r.length>80*e){a=h=r[0],l=c=r[1];for(var p=e;p<s;p+=e)u=r[p],d=r[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 Cs(n,o,e,a,l,f,0),o}function Rf(r,t,e,i,s){var n,o;if(s===El(r,t,e,i)>0)for(n=t;n<e;n+=i)o=Mc(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=Mc(n,r[n],r[n+1],o);return o&&Ro(o,o.next)&&(Rs(o),o=o.next),o}function si(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(Ro(e,e.next)||xt(e.prev,e,e.next)===0)){if(Rs(e),e=t=e.prev,e===e.next)break;
vendor: 4,917 bytes, line 3
3i=!0}else e=e.next;while(i||e!==t);return t}function Cs(r,t,e,i,s,n,o){if(r){!o&&n&&N0(r,i,s,n);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,n?R0(r,i,s,n):I0(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),Rs(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=P0(si(r),t,e),Cs(r,t,e,i,s,n,2)):o===2&&M0(r,t,e,i,s,n):Cs(si(r),t,e,i,s,n,1);break}}}}function I0(r){var t=r.prev,e=r,i=r.next;if(xt(t,e,i)>=0)return!1;for(var s=t.x,n=e.x,o=i.x,a=t.y,l=e.y,h=i.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=i.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&Mi(s,a,n,l,o,h,p.x,p.y)&&xt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function R0(r,t,e,i){var s=r.prev,n=r,o=r.next;if(xt(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,m=a>l?a>h?a:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,_=wl(f,p,t,e,i),v=wl(m,g,t,e,i),y=r.prevZ,b=r.nextZ;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=f&&y.x<=m&&y.y>=p&&y.y<=g&&y!==s&&y!==o&&Mi(a,c,l,u,h,d,y.x,y.y)&&xt(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==s&&b!==o&&Mi(a,c,l,u,h,d,b.x,b.y)&&xt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=f&&y.x<=m&&y.y>=p&&y.y<=g&&y!==s&&y!==o&&Mi(a,c,l,u,h,d,y.x,y.y)&&xt(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==s&&b!==o&&Mi(a,c,l,u,h,d,b.x,b.y)&&xt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function P0(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!Ro(s,n)&&Pf(s,i,i.next,n)&&Is(s,n)&&Is(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),Rs(i),Rs(i.next),i=r=n),i=i.next}while(i!==r);return si(i)}function M0(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&G0(o,a)){var l=Mf(o,a);o=si(o,o.next),l=si(l,l.next),Cs(o,t,e,i,s,n,0),Cs(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function k0(r,t,e,i){var s=[],n,o,a,l,h;for(n=0,o=t.length;n<o;n++)a=t[n]*i,l=n<o-1?t[n+1]*i:r.length,h=Rf(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(U0(h));for(s.sort(B0),n=0;n<s.length;n++)e=D0(s[n],e);return e}function B0(r,t){return r.x-t.x}function D0(r,t){var e=F0(r,t);if(!e)return t;var i=Mf(e,r);return si(i,i.next),si(e,e.next)}function F0(r,t){var e=t,i=r.x,s=r.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<=i&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===i))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 i>=e.x&&e.x>=h&&i!==e.x&&Mi(s<c?i:n,s,h,c,s<c?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),Is(e,r)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&O0(o,e)))&&(o=e,u=d)),e=e.next;while(e!==l);return o}function O0(r,t){return xt(r.prev,r,t.prev)<0&&xt(t.next,r,r.next)<0}function N0(r,t,e,i){var s=r;do s.z===0&&(s.z=wl(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,L0(s)}function L0(r){var t,e,i,s,n,o,a,l,h=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,i=e,a=0,t=0;t<h&&(a++,i=i.nextZ,!!i);t++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}n.nextZ=null,h*=2}while(o>1);return r}function wl(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function U0(r){var t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function Mi(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function G0(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!H0(r,t)&&(Is(r,t)&&Is(t,r)&&$0(r,t)&&(xt(r.prev,r,t.prev)||xt(r,t.prev,t))||Ro(r,t)&&xt(r.prev,r,r.next)>0&&xt(t.prev,t,t.next)>0)}function xt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Ro(r,t){return r.x===t.x&&r.y===t.y}function Pf(r,t,e,i){var s=Us(xt(r,t,e)),n=Us(xt(r,t,i)),o=Us(xt(e,i,r)),a=Us(xt(e,i,t));return!!(s!==n&&o!==a||s===0&&Ls(r,e,t)||n===0&&Ls(r,i,t)||o===0&&Ls(e,r,i)||a===0&&Ls(e,t,i))}function Ls(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Us(r){return r>0?1:r<0?-1:0}function H0(r,t){var e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&Pf(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Is(r,t){return xt(r.prev,r,r.next)<0?xt(r,t,r.next)>=0&&xt(r,r.prev,t)>=0:xt(r,t,r.prev)<0||xt(r,r.next,t)<0}function $0(r,t){var e=r,i=!1,s=(r.x+t.x)/2,n=(r.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&&(i=!i),e=e.next;while(e!==r);return i}function Mf(r,t){var e=new Tl(r.i,r.x,r.y),i=new Tl(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function Mc(r,t,e,i){var s=new Tl(r,t,e);
3return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Rs(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Tl(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Io.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(El(r,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:r.length;o-=Math.abs(El(r,h,c,e))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,f=i[a+1]*e,p=i[a+2]*e;u+=Math.abs((r[d]-r[p])*(r[f+1]-r[d+1])-(r[d]-r[f])*(r[p+1]-r[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function El(r,t,e,i){for(var s=0,n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}Io.flatten=function(r){for(var t=r[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,s=0;s<r.length;s++){for(var n=0;n<r[s].length;n++)for(var o=0;o<t;o++)e.vertices.push(r[s][n][o]);s>0&&(i+=r[s-1].length,e.holes.push(i))}return e};var z0=kh.exports;const X0=bf(z0);var Zn={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */Zn.exports;(function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof vn=="object"&&vn;(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,m="-",g=/^xn--/,_=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,y={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,x=Math.floor,w=String.fromCharCode,T;function E(A){throw new RangeError(y[A])}function C(A,L){for(var I=A.length,B=[];I--;)B[I]=L(A[I]);return B}function M(A,L){var I=A.split("@"),B="";I.length>1&&(B=I[0]+"@",A=I[1]),A=A.replace(v,".");var J=A.split("."),it=C(J,L).join(".");return B+it}function k(A){for(var L=[],I=0,B=A.length,J,it;I<B;)J=A.charCodeAt(I++),J>=55296&&J<=56319&&I<B?(it=A.charCodeAt(I++),(it&64512)==56320?L.push(((J&1023)<<10)+(it&1023)+65536):(L.push(J),I--)):L.push(J);return L}function P(A){return C(A,function(L){var I="";return L>65535&&(L-=65536,I+=w(L>>>10&1023|55296),L=56320|L&1023),I+=w(L),I}).join("")}function S(A){return A-48<10?A-22:A-65<26?A-65:A-97<26?A-97:l}function R(A,L){return A+22+75*(A<26)-((L!=0)<<5)}function H(A,L,I){var B=0;for(A=I?x(A/d):A>>1,A+=x(A/L);A>b*c>>1;B+=l)A=x(A/b);return x(B+(b+1)*A/(A+u))}function j(A){var L=[],I=A.length,B,J=0,it=p,ht=f,lt,yt,Tt,mt,st,F,ot,U,ut;for(lt=A.lastIndexOf(m),lt<0&&(lt=0),yt=0;yt<lt;++yt)A.charCodeAt(yt)>=128&&E("not-basic"),L.push(A.charCodeAt(yt));for(Tt=lt>0?lt+1:0;Tt<I;){for(mt=J,st=1,F=l;Tt>=I&&E("invalid-input"),ot=S(A.charCodeAt(Tt++)),(ot>=l||ot>x((a-J)/st))&&E("overflow"),J+=ot*st,U=F<=ht?h:F>=ht+c?c:F-ht,!(ot<U);F+=l)ut=l-U,st>x(a/ut)&&E("overflow"),st*=ut;B=L.length+1,ht=H(J-mt,B,mt==0),x(J/B)>a-it&&E("overflow"),it+=x(J/B),J%=B,L.splice(J++,0,it)}return P(L)}function D(A){var L,I,B,J,it,ht,lt,yt,Tt,mt,st,F=[],ot,U,ut,pt;for(A=k(A),ot=A.length,L=p,I=0,it=f,ht=0;ht<ot;++ht)st=A[ht],st<128&&F.push(w(st));for(B=J=F.length,J&&F.push(m);B<ot;){for(lt=a,ht=0;ht<ot;++ht)st=A[ht],st>=L&&st<lt&&(lt=st);for(U=B+1,lt-L>x((a-I)/U)&&E("overflow"),I+=(lt-L)*U,L=lt,ht=0;ht<ot;++ht)if(st=A[ht],st<L&&++I>a&&E("overflow"),st==L){for(yt=I,Tt=l;mt=Tt<=it?h:Tt>=it+c?c:Tt-it,!(yt<mt);Tt+=l)pt=yt-mt,ut=l-mt,F.push(w(R(mt+pt%ut,0))),yt=x(pt/ut);F.push(w(R(yt,0))),it=H(I,U,B==J),I=0,++B}++I,++L}return F.join("")}function tt(A){return M(A,function(L){return g.test(L)?j(L.slice(4).toLowerCase()):L})}function G(A){return M(A,function(L){return _.test(L)?"xn--"+D(L):L})}if(o={version:"1.4.1",ucs2:{decode:k,encode:P},decode:j,encode:D,toASCII:G,toUnicode:tt},i&&s)if(r.exports==i)s.exports=o;else for(T in o)o.hasOwnProperty(T)&&(i[T]=o[T]);else e.punycode=o})(vn)})(Zn,Zn.exports);var V0=Zn.exports,W0=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),i=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[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},kc=typeof Symbol<"u"&&Symbol,j0=W0,Y0=function(){return typeof kc!="function"||typeof Symbol!="function"||typeof kc("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:j0()},Bc={foo:{}},q0=Object,Z0=function(){return{__proto__:Bc}.foo===Bc.foo&&!({__proto__:null}instanceof q0)},K0="Function.prototype.bind called on incompatible ",J0=Object.prototype.toString,Q0=Math.max,t1="[object Function]",Dc=function(t,e){for(var i=[],s=0;s<t.length;s+=1)i[s]=t[s];for(var n=0;n<e.length;n+=1)i[n+t.length]=e[n];return i},e1=function(t,e){for(var i=[],s=e,n=0;s<t.length;s+=1,n+=1)i[n]=t[s];return i},r1=function(r,t){for(var e="",i=0;i<r.length;i+=1)e+=r[i],i+1<r.length&&(e+=t);return e},i1=function(t){var e=this;if(typeof e!="function"||J0.apply(e)!==t1)throw new TypeError(K0+e);
3for(var i=e1(arguments,1),s,n=function(){if(this instanceof s){var c=e.apply(this,Dc(i,arguments));return Object(c)===c?c:this}return e.apply(t,Dc(i,arguments))},o=Q0(0,e.length-i.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+r1(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},s1=i1,Bh=Function.prototype.bind||s1,n1=Function.prototype.call,o1=Object.prototype.hasOwnProperty,a1=Bh,l1=a1.call(n1,o1),at,Xi=SyntaxError,kf=Function,Fi=TypeError,pa=function(r){try{return kf('"use strict"; return ('+r+").constructor;")()}catch{}},Qr=Object.getOwnPropertyDescriptor;if(Qr)try{Qr({},"")}catch{Qr=null}var _a=function(){throw new Fi},h1=Qr?function(){try{return arguments.callee,_a}catch{try{return Qr(arguments,"callee").get}catch{return _a}}}():_a,_i=Y0(),c1=Z0(),Mt=Object.getPrototypeOf||(c1?function(r){return r.__proto__}:null),Ti={},u1=typeof Uint8Array>"u"||!Mt?at:Mt(Uint8Array),ti={"%AggregateError%":typeof AggregateError>"u"?at:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?at:ArrayBuffer,"%ArrayIteratorPrototype%":_i&&Mt?Mt([][Symbol.iterator]()):at,"%AsyncFromSyncIteratorPrototype%":at,"%AsyncFunction%":Ti,"%AsyncGenerator%":Ti,"%AsyncGeneratorFunction%":Ti,"%AsyncIteratorPrototype%":Ti,"%Atomics%":typeof Atomics>"u"?at:Atomics,"%BigInt%":typeof BigInt>"u"?at:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?at:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?at:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?at:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?at:Float32Array,"%Float64Array%":typeof Float64Array>"u"?at:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?at:FinalizationRegistry,"%Function%":kf,"%GeneratorFunction%":Ti,"%Int8Array%":typeof Int8Array>"u"?at:Int8Array,"%Int16Array%":typeof Int16Array>"u"?at:Int16Array,"%Int32Array%":typeof Int32Array>
vendor: 6,421 bytes, line 3
3"u"?at:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":_i&&Mt?Mt(Mt([][Symbol.iterator]())):at,"%JSON%":typeof JSON=="object"?JSON:at,"%Map%":typeof Map>"u"?at:Map,"%MapIteratorPrototype%":typeof Map>"u"||!_i||!Mt?at:Mt(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?at:Promise,"%Proxy%":typeof Proxy>"u"?at:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?at:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?at:Set,"%SetIteratorPrototype%":typeof Set>"u"||!_i||!Mt?at:Mt(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?at:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":_i&&Mt?Mt(""[Symbol.iterator]()):at,"%Symbol%":_i?Symbol:at,"%SyntaxError%":Xi,"%ThrowTypeError%":h1,"%TypedArray%":u1,"%TypeError%":Fi,"%Uint8Array%":typeof Uint8Array>"u"?at:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?at:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?at:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?at:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?at:WeakMap,"%WeakRef%":typeof WeakRef>"u"?at:WeakRef,"%WeakSet%":typeof WeakSet>"u"?at:WeakSet};if(Mt)try{null.error}catch(r){var d1=Mt(Mt(r));ti["%Error.prototype%"]=d1}var f1=function r(t){var e;if(t==="%AsyncFunction%")e=pa("async function () {}");else if(t==="%GeneratorFunction%")e=pa("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=pa("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&Mt&&(e=Mt(s.prototype))}return ti[t]=e,e},Fc={"%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"]},Bs=Bh,Kn=l1,p1=Bs.call(Function.call,Array.prototype.concat),_1=Bs.call(Function.apply,Array.prototype.splice),Oc=Bs.call(Function.call,String.prototype.replace),Jn=Bs.call(Function.call,String.prototype.slice),m1=Bs.call(Function.call,RegExp.prototype.exec),g1=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,y1=/\\(\\)?/g,v1=function(t){var e=Jn(t,0,1),i=Jn(t,-1);if(e==="%"&&i!=="%")throw new Xi("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new Xi("invalid intrinsic syntax, expected opening `%`");var s=[];return Oc(t,g1,function(n,o,a,l){s[s.length]=a?Oc(l,y1,"$1"):o||n}),s},b1=function(t,e){var i=t,s;if(Kn(Fc,i)&&(s=Fc[i],i="%"+s[0]+"%"),Kn(ti,i)){var n=ti[i];if(n===Ti&&(n=f1(i)),typeof n>"u"&&!e)throw new Fi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new Xi("intrinsic "+t+" does not exist!")},hi=function(t,e){if(typeof t!="string"||t.length===0)throw new Fi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new Fi('"allowMissing" argument must be a boolean');if(m1(/^%?[^%]*%?$/,t)===null)throw new Xi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=v1(t),s=i.length>0?i[0]:"",n=b1("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],_1(i,p1([0,1],h)));for(var c=1,u=!0;c<i.length;c+=1){var d=i[c],f=Jn(d,0,1),p=Jn(d,-1);if((f==='"'||f==="'"||f==="`"||p==='"'||p==="'"||p==="`")&&f!==p)throw new Xi("property names with quotes must have matching quotes");if((d==="constructor"||!u)&&(l=!0),s+="."+d,o="%"+s+"%",Kn(ti,o))a=ti[o];else if(a!=null){if(!(d in a)){if(!e)throw new Fi("base intrinsic for "+t+" exists, but the property is not available.");return}if(Qr&&c+1>=i.length){var m=Qr(a,d);u=!!m,u&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else u=Kn(a,d),a=a[d];u&&!l&&(ti[o]=a)}}return a},Bf={exports:{}},x1=hi,Al=x1("%Object.defineProperty%",!0),Sl=function(){if(Al)try{return Al({},"a",{value:1}),!0}catch{return!1}return!1};
3Sl.hasArrayLengthDefineBug=function(){if(!Sl())return null;try{return Al([],"length",{value:1}).length!==1}catch{return!0}};var Df=Sl,w1=hi,bn=w1("%Object.getOwnPropertyDescriptor%",!0);if(bn)try{bn([],"length")}catch{bn=null}var Ff=bn,T1=Df(),Dh=hi,bs=T1&&Dh("%Object.defineProperty%",!0);if(bs)try{bs({},"a",{value:1})}catch{bs=!1}var E1=Dh("%SyntaxError%"),mi=Dh("%TypeError%"),Nc=Ff,A1=function(t,e,i){if(!t||typeof t!="object"&&typeof t!="function")throw new mi("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new mi("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new mi("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new mi("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new mi("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new mi("`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=!!Nc&&Nc(t,e);if(bs)bs(t,e,{configurable:o===null&&l?l.configurable:!o,enumerable:s===null&&l?l.enumerable:!s,value:i,writable:n===null&&l?l.writable:!n});else if(a||!s&&!n&&!o)t[e]=i;else throw new E1("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Of=hi,Lc=A1,S1=Df(),Uc=Ff,Gc=Of("%TypeError%"),C1=Of("%Math.floor%"),I1=function(t,e){if(typeof t!="function")throw new Gc("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||C1(e)!==e)throw new Gc("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],s=!0,n=!0;if("length"in t&&Uc){var o=Uc(t,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(n=!1)}return(s||n||!i)&&(S1?Lc(t,"length",e,!0,!0):Lc(t,"length",e)),t};(function(r){var t=Bh,e=hi,i=I1,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}r.exports=function(d){if(typeof d!="function")throw new s("a function is required");var f=a(t,o,arguments);return i(f,1+h(0,d.length-(arguments.length-1)),!0)};var c=function(){return a(t,n,arguments)};l?l(r.exports,"apply",{value:c}):r.exports.apply=c})(Bf);var R1=Bf.exports,Nf=hi,Lf=R1,P1=Lf(Nf("String.prototype.indexOf")),M1=function(t,e){var i=Nf(t,!!e);return typeof i=="function"&&P1(t,".prototype.")>-1?Lf(i):i};const k1=V_(W_);var Fh=typeof Map=="function"&&Map.prototype,ma=Object.getOwnPropertyDescriptor&&Fh?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Qn=Fh&&ma&&typeof ma.get=="function"?ma.get:null,Hc=Fh&&Map.prototype.forEach,Oh=typeof Set=="function"&&Set.prototype,ga=Object.getOwnPropertyDescriptor&&Oh?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,to=Oh&&ga&&typeof ga.get=="function"?ga.get:null,$c=Oh&&Set.prototype.forEach,B1=typeof WeakMap=="function"&&WeakMap.prototype,xs=B1?WeakMap.prototype.has:null,D1=typeof WeakSet=="function"&&WeakSet.prototype,ws=D1?WeakSet.prototype.has:null,F1=typeof WeakRef=="function"&&WeakRef.prototype,zc=F1?WeakRef.prototype.deref:null,O1=Boolean.prototype.valueOf,N1=Object.prototype.toString,L1=Function.prototype.toString,U1=String.prototype.match,Nh=String.prototype.slice,vr=String.prototype.replace,G1=String.prototype.toUpperCase,Xc=String.prototype.toLowerCase,Uf=RegExp.prototype.test,Vc=Array.prototype.concat,Ne=Array.prototype.join,H1=Array.prototype.slice,Wc=Math.floor,Cl=typeof BigInt=="function"?BigInt.prototype.valueOf:null,ya=Object.getOwnPropertySymbols,Il=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Vi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",zt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Vi||!0)?Symbol.toStringTag:null,Gf=Object.prototype.propertyIsEnumerable,jc=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Yc(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||Uf.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-Wc(-r):Wc(r);if(i!==r){var s=String(i),n=Nh.call(t,s.length+1);return vr.call(s,e,"$&_")+"."+vr.call(vr.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return vr.call(t,e,"$&_")}var Rl=k1,qc=Rl.custom,Zc=$f(qc)?qc:null,$1=function r(t,e,i,s){var n=e||{};if(_r(n,"quoteStyle")&&n.quoteStyle!=="single"&&n.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(_r(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=_r(n,"customInspect")?n.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");
vendor: 10,583 bytes, lines 3-6
3if(_r(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(_r(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 Xf(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?Yc(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?Yc(t,h):h}var c=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=c&&c>0&&typeof t=="object")return Pl(t)?"[Array]":"[Object]";var u=oy(n,i);if(typeof s>"u")s=[];else if(zf(s,t)>=0)return"[Circular]";function d(S,R,H){if(R&&(s=H1.call(s),s.push(R)),H){var j={depth:n.depth};return _r(n,"quoteStyle")&&(j.quoteStyle=n.quoteStyle),r(S,j,i+1,s)}return r(S,n,i+1,s)}if(typeof t=="function"&&!Kc(t)){var f=K1(t),p=Gs(t,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(p.length>0?" { "+Ne.call(p,", ")+" }":"")}if($f(t)){var m=Vi?vr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Il.call(t);return typeof t=="object"&&!Vi?ss(m):m}if(iy(t)){for(var g="<"+Xc.call(String(t.nodeName)),_=t.attributes||[],v=0;v<_.length;v++)g+=" "+_[v].name+"="+Hf(z1(_[v].value),"double",n);return g+=">",t.childNodes&&t.childNodes.length&&(g+="..."),g+="</"+Xc.call(String(t.nodeName))+">",g}if(Pl(t)){if(t.length===0)return"[]";var y=Gs(t,d);return u&&!ny(y)?"["+Ml(y,u)+"]":"[ "+Ne.call(y,", ")+" ]"}if(V1(t)){var b=Gs(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!Gf.call(t,"cause")?"{ ["+String(t)+"] "+Ne.call(Vc.call("[cause]: "+d(t.cause),b),", ")+" }":b.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+Ne.call(b,", ")+" }"}if(typeof t=="object"&&o){if(Zc&&typeof t[Zc]=="function"&&Rl)return Rl(t,{depth:c-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(J1(t)){var x=[];return Hc&&Hc.call(t,function(S,R){x.push(d(R,t,!0)+" => "+d(S,t))}),Jc("Map",Qn.call(t),x,u)}if(ey(t)){var w=[];return $c&&$c.call(t,function(S){w.push(d(S,t))}),Jc("Set",to.call(t),w,u)}if(Q1(t))return va("WeakMap");if(ry(t))return va("WeakSet");if(ty(t))return va("WeakRef");if(j1(t))return ss(d(Number(t)));if(q1(t))return ss(d(Cl.call(t)));if(Y1(t))return ss(O1.call(t));if(W1(t))return ss(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(t===vn)return"{ [object globalThis] }";if(!X1(t)&&!Kc(t)){var T=Gs(t,d),E=jc?jc(t)===Object.prototype:t instanceof Object||t.constructor===Object,C=t instanceof Object?"":"null prototype",M=!E&&zt&&Object(t)===t&&zt in t?Nh.call(Br(t),8,-1):C?"Object":"",k=E||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",P=k+(M||C?"["+Ne.call(Vc.call([],M||[],C||[]),": ")+"] ":"");return T.length===0?P+"{}":u?P+"{"+Ml(T,u)+"}":P+"{ "+Ne.call(T,", ")+" }"}return String(t)};function Hf(r,t,e){var i=(e.quoteStyle||t)==="double"?'"':"'";return i+r+i}function z1(r){return vr.call(String(r),/"/g,""")}function Pl(r){return Br(r)==="[object Array]"&&(!zt||!(typeof r=="object"&&zt in r))}function X1(r){return Br(r)==="[object Date]"&&(!zt||!(typeof r=="object"&&zt in r))}function Kc(r){return Br(r)==="[object RegExp]"&&(!zt||!(typeof r=="object"&&zt in r))}function V1(r){return Br(r)==="[object Error]"&&(!zt||!(typeof r=="object"&&zt in r))}function W1(r){return Br(r)==="[object String]"&&(!zt||!(typeof r=="object"&&zt in r))}function j1(r){return Br(r)==="[object Number]"&&(!zt||!(typeof r=="object"&&zt in r))}function Y1(r){return Br(r)==="[object Boolean]"&&(!zt||!(typeof r=="object"&&zt in r))}function $f(r){if(Vi)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Il)return!1;try{return Il.call(r),!0}catch{}return!1}function q1(r){if(!r||typeof r!="object"||!Cl)return!1;try{return Cl.call(r),!0}catch{}return!1}var Z1=Object.prototype.hasOwnProperty||function(r){return r in this};function _r(r,t){return Z1.call(r,t)}function Br(r){return N1.call(r)}function K1(r){if(r.name)return r.name;var t=U1.call(L1.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function zf(r,t){if(r.indexOf)return r.indexOf(t);for(var e=0,i=r.length;e<i;e++)if(r[e]===t)return e;return-1}function J1(r){if(!Qn||!r||typeof r!="object")return!1;try{Qn.call(r);try{to.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function Q1(r){if(!xs||!r||typeof r!="object")return!1;try{xs.call(r,xs);try{ws.call(r,ws)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function ty(r){if(!zc||!r||typeof r!="object")return!1;try{return zc.call(r),!0}catch{}return!1}function ey(r){if(!to||!r||typeof r!="object")return!1;try{to.call(r);try{Qn.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function ry(r){if(!ws||!r||typeof r!="object")return!1;try{ws.call(r,ws);try{xs.call(r,xs)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function iy(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Xf(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return Xf(Nh.call(r,0,t.maxStringLength),t)+i}var s=vr.call(vr.call(r,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,sy);return Hf(s,"single",t)}function sy(r){var t=r.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+G1.call(t.toString(16))}function ss(r){return"Object("+r+")"}function va(r){return r+" { ? }"}function Jc(r,t,e,i){var s=i?Ml(e,i):Ne.call(e,", ");return r+" ("+t+") {"+s+"}"}function ny(r){for(var t=0;t<r.length;t++)if(zf(r[t],` 4`)>=0)return!1;return!0}function oy(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=Ne.call(Array(r.indent+1)," ");else return null;return{base:e,prev:Ne.call(Array(t+1),e)}}function Ml(r,t){if(r.length===0)return"";var e=` 5`+t.prev+t.base;return e+Ne.call(r,","+e)+` 6`+t.prev}function Gs(r,t){var e=Pl(r),i=[];if(e){i.length=r.length;for(var s=0;s<r.length;s++)i[s]=_r(r,s)?t(r[s],r):""}var n=typeof ya=="function"?ya(r):[],o;if(Vi){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var l in r)_r(r,l)&&(e&&String(Number(l))===l&&l<r.length||Vi&&o["$"+l]instanceof Symbol||(Uf.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof ya=="function")for(var h=0;h<n.length;h++)Gf.call(r,n[h])&&i.push("["+t(n[h])+"]: "+t(r[n[h]],r));return i}var Lh=hi,Qi=M1,ay=$1,ly=Lh("%TypeError%"),Hs=Lh("%WeakMap%",!0),$s=Lh("%Map%",!0),hy=Qi("WeakMap.prototype.get",!0),cy=Qi("WeakMap.prototype.set",!0),uy=Qi("WeakMap.prototype.has",!0),dy=Qi("Map.prototype.get",!0),fy=Qi("Map.prototype.set",!0),py=Qi("Map.prototype.has",!0),Uh=function(r,t){for(var e=r,i;(i=e.next)!==null;e=i)if(i.key===t)return e.next=i.next,i.next=r.next,r.next=i,i},_y=function(r,t){var e=Uh(r,t);return e&&e.value},my=function(r,t,e){var i=Uh(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},gy=function(r,t){return!!Uh(r,t)},yy=function(){var t,e,i,s={assert:function(n){if(!s.has(n))throw new ly("Side channel does not contain "+ay(n))},get:function(n){if(Hs&&n&&(typeof n=="object"||typeof n=="function")){if(t)return hy(t,n)}else if($s){if(e)return dy(e,n)}else if(i)return _y(i,n)},has:function(n){if(Hs&&n&&(typeof n=="object"||typeof n=="function")){if(t)return uy(t,n)}else if($s){if(e)return py(e,n)}else if(i)return gy(i,n);return!1},set:function(n,o){Hs&&n&&(typeof n=="object"||typeof n=="function")?(t||(t=new Hs),cy(t,n,o)):$s?(e||(e=new $s),fy(e,n,o)):(i||(i={key:{},next:null}),my(i,n,o))}};return s},vy=String.prototype.replace,by=/%20/g,ba={RFC1738:"RFC1738",RFC3986:"RFC3986"},Gh={default:ba.RFC3986,formatters:{RFC1738:function(r){return vy.call(r,by,"+")},RFC3986:function(r){return String(r)}},RFC1738:ba.RFC1738,RFC3986:ba.RFC3986},xy=Gh,xa=Object.prototype.hasOwnProperty,Zr=Array.isArray,Se=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),wy=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(Zr(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},Vf=function(t,e){for(var i=e&&e.plainObjects?Object.create(null):{},s=0;s<t.length;++s)typeof t[s]<"u"&&(i[s]=t[s]);return i},Ty=function r(t,e,i){if(!e)return t;if(typeof e!="object"){if(Zr(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!xa.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 Zr(t)&&!Zr(e)&&(s=Vf(t,i)),Zr(t)&&Zr(e)?(e.forEach(function(n,o){if(xa.call(t,o)){var a=t[o];a&&typeof a=="object"&&n&&typeof n=="object"?t[o]=r(a,n,i):t.push(n)}else t[o]=n}),t):Object.keys(e).reduce(function(n,o){var a=e[o];return xa.call(n,o)?n[o]=r(n[o],a,i):n[o]=a,n},s)},Ey=function(t,e){return Object.keys(e).reduce(function(i,s){return i[s]=e[s],i},t)},Ay=function(r,t,e){var i=r.replace(/\+/g," ");if(e==="iso-8859-1")return i.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(i)}catch{return i}},Sy=function(t,e,i,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)),i==="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===xy.RFC1738&&(h===40||h===41)){a+=o.charAt(l);continue}if(h<128){a=a+Se[h];continue}if(h<2048){a=a+(Se[192|h>>6]+Se[128|h&63]);continue}if(h<55296||h>=57344){a=a+(Se[224|h>>12]+Se[128|h>>6&63]+Se[128|h&63]);continue}l+=1,h=65536+((h&1023)<<10|o.charCodeAt(l)&1023),a+=Se[240|h>>18]+Se[128|h>>12&63]+Se[128|h>>6&63]+Se[128|h&63]}return a},Cy=function(t){for(var e=[{obj:{o:t},prop:"o"}],i=[],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&&i.indexOf(c)===-1&&(e.push({obj:o,prop:h}),i.push(c))}return wy(e),t},Iy=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},Ry=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},Py=function(t,e){return[].concat(t,e)},My=function(t,e){if(Zr(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)}
6,Wf={arrayToObject:Vf,assign:Ey,combine:Py,compact:Cy,decode:Ay,encode:Sy,isBuffer:Ry,isRegExp:Iy,maybeMap:My,merge:Ty},jf=yy,xn=Wf,Ts=Gh,ky=Object.prototype.hasOwnProperty,Qc={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},Ke=Array.isArray,By=Array.prototype.push,Yf=function(r,t){By.apply(r,Ke(t)?t:[t])},Dy=Date.prototype.toISOString,tu=Ts.default,Ut={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:xn.encode,encodeValuesOnly:!1,format:tu,formatter:Ts.formatters[tu],indices:!1,serializeDate:function(t){return Dy.call(t)},skipNulls:!1,strictNullHandling:!1},Fy=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},wa={},Oy=function r(t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,g){for(var _=t,v=g,y=0,b=!1;(v=v.get(wa))!==void 0&&!b;){var x=v.get(t);if(y+=1,typeof x<"u"){if(x===y)throw new RangeError("Cyclic object value");b=!0}typeof v.get(wa)>"u"&&(y=0)}if(typeof l=="function"?_=l(e,_):_ instanceof Date?_=u(_):i==="comma"&&Ke(_)&&(_=xn.maybeMap(_,function(j){return j instanceof Date?u(j):j})),_===null){if(n)return a&&!p?a(e,Ut.encoder,m,"key",d):e;_=""}if(Fy(_)||xn.isBuffer(_)){if(a){var w=p?e:a(e,Ut.encoder,m,"key",d);return[f(w)+"="+f(a(_,Ut.encoder,m,"value",d))]}return[f(e)+"="+f(String(_))]}var T=[];if(typeof _>"u")return T;var E;if(i==="comma"&&Ke(_))p&&a&&(_=xn.maybeMap(_,a)),E=[{value:_.length>0?_.join(",")||null:void 0}];else if(Ke(l))E=l;else{var C=Object.keys(_);E=h?C.sort(h):C}for(var M=s&&Ke(_)&&_.length===1?e+"[]":e,k=0;k<E.length;++k){var P=E[k],S=typeof P=="object"&&typeof P.value<"u"?P.value:_[P];if(!(o&&S===null)){var R=Ke(_)?typeof i=="function"?i(M,P):M:M+(c?"."+P:"["+P+"]");g.set(t,y);var H=jf();H.set(wa,g),Yf(T,r(S,R,i,s,n,o,i==="comma"&&p&&Ke(_)?null:a,l,h,c,u,d,f,p,m,H))}}return T},Ny=function(t){if(!t)return Ut;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||Ut.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 i=Ts.default;if(typeof t.format<"u"){if(!ky.call(Ts.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=Ts.formatters[i],n=Ut.filter;return(typeof t.filter=="function"||Ke(t.filter))&&(n=t.filter),{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:Ut.addQueryPrefix,allowDots:typeof t.allowDots>"u"?Ut.allowDots:!!t.allowDots,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Ut.charsetSentinel,delimiter:typeof t.delimiter>"u"?Ut.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:Ut.encode,encoder:typeof t.encoder=="function"?t.encoder:Ut.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:Ut.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:Ut.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:Ut.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Ut.strictNullHandling}},Ly=function(r,t){var e=r,i=Ny(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):Ke(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a;t&&t.arrayFormat in Qc?a=t.arrayFormat:t&&"indices"in t?a=t.indices?"indices":"repeat":a="indices";var l=Qc[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)),i.sort&&s.sort(i.sort);for(var c=jf(),u=0;u<s.length;++u){var d=s[u];i.skipNulls&&e[d]===null||Yf(o,Oy(e[d],d,l,h,i.strictNullHandling,i.skipNulls,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,c))}var f=o.join(i.delimiter),p=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?p+="utf8=%26%2310003%3B&":p+="utf8=%E2%9C%93&"),f.length>0?p+f:""},Wi=Wf,kl=Object.prototype.hasOwnProperty,Uy=Array.isArray,Pt={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:Wi.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Gy=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},qf=function(r,t){return r&&typeof r=="string"&&t.comma&&r.indexOf(",")>-1?r.split(","):r},Hy="utf8=%26%2310003%3B",$y="utf8=%E2%9C%93",zy=function(t,e){var i={__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]===$y?h="utf-8":o[l]===Hy&&(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,Pt.decoder,h,"key"),p=e.strictNullHandling?null:""):(f=e.decoder(c.slice(0,d),Pt.decoder,h,"key"),p=Wi.maybeMap(qf(c.slice(d+1),e),function(m){return e.decoder(m,Pt.decoder,h,"value")})),p&&e.interpretNumericEntities&&h==="iso-8859-1"&&(p=Gy(p)),c.indexOf("[]=")>
vendor: 5,482 bytes, lines 6-7
6-1&&(p=Uy(p)?[p]:p),kl.call(i,f)?i[f]=Wi.combine(i[f],p):i[f]=p}return i},Xy=function(r,t,e,i){for(var s=i?t:qf(t,e),n=r.length-1;n>=0;--n){var o,a=r[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},Vy=function(t,e,i,s){if(t){var n=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=i.depth>0&&o.exec(n),h=l?n.slice(0,l.index):n,c=[];if(h){if(!i.plainObjects&&kl.call(Object.prototype,h)&&!i.allowPrototypes)return;c.push(h)}for(var u=0;i.depth>0&&(l=a.exec(n))!==null&&u<i.depth;){if(u+=1,!i.plainObjects&&kl.call(Object.prototype,l[1].slice(1,-1))&&!i.allowPrototypes)return;c.push(l[1])}return l&&c.push("["+n.slice(l.index)+"]"),Xy(c,e,i,s)}},Wy=function(t){if(!t)return Pt;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"?Pt.charset:t.charset;return{allowDots:typeof t.allowDots>"u"?Pt.allowDots:!!t.allowDots,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:Pt.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:Pt.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:Pt.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Pt.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:Pt.comma,decoder:typeof t.decoder=="function"?t.decoder:Pt.decoder,delimiter:typeof t.delimiter=="string"||Wi.isRegExp(t.delimiter)?t.delimiter:Pt.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:Pt.depth,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:Pt.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:Pt.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:Pt.plainObjects,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Pt.strictNullHandling}},jy=function(r,t){var e=Wy(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?Object.create(null):{};for(var i=typeof r=="string"?zy(r,e):r,s=e.plainObjects?Object.create(null):{},n=Object.keys(i),o=0;o<n.length;++o){var a=n[o],l=Vy(a,i[a],e,typeof r=="string");s=Wi.merge(s,l,e)}return e.allowSparse===!0?s:Wi.compact(s)},Yy=Ly,qy=jy,Zy=Gh,Ky={formats:Zy,parse:qy,stringify:Yy},Jy=V0;function nr(){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}var Qy=/^([a-z0-9.+-]+:)/i,tv=/:[0-9]*$/,ev=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,rv=["<",">",'"',"`"," ","\r",` 7`," "],iv=["{","}","|","\\","^","`"].concat(rv),Bl=["'"].concat(iv),eu=["%","/","?",";","#"].concat(Bl),ru=["/","?","#"],sv=255,iu=/^[+a-z0-9A-Z_-]{0,63}$/,nv=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,ov={javascript:!0,"javascript:":!0},Dl={javascript:!0,"javascript:":!0},Oi={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},Fl=Ky;function av(r,t,e){if(r&&typeof r=="object"&&r instanceof nr)return r;var i=new nr;return i.parse(r,t,e),i}nr.prototype.parse=function(r,t,e){if(typeof r!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof r);var i=r.indexOf("?"),s=i!==-1&&i<r.indexOf("#")?"?":"#",n=r.split(s),o=/\\/g;n[0]=n[0].replace(o,"/"),r=n.join(s);var a=r;if(a=a.trim(),!e&&r.split("#").length===1){var l=ev.exec(a);if(l)return this.path=a,this.href=a,this.pathname=l[1],l[2]?(this.search=l[2],t?this.query=Fl.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var h=Qy.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&&Dl[h])&&(a=a.substr(2),this.slashes=!0)}if(!Dl[h]&&(u||h&&!Oi[h])){for(var d=-1,f=0;f<ru.length;f++){var p=a.indexOf(ru[f]);p!==-1&&(d===-1||p<d)&&(d=p)}var m,g;d===-1?g=a.lastIndexOf("@"):g=a.lastIndexOf("@",d),g!==-1&&(m=a.slice(0,g),a=a.slice(g+1),this.auth=decodeURIComponent(m)),d=-1;for(var f=0;f<eu.length;f++){var p=a.indexOf(eu[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 _=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!_)for(var v=this.hostname.split(/\./),f=0,y=v.length;f<y;f++){var b=v[f];if(b&&!b.match(iu)){for(var x="",w=0,T=b.length;w<T;w++)b.charCodeAt(w)>127?x+="x":x+=b[w];if(!x.match(iu)){var E=v.slice(0,f),C=v.slice(f+1),M=b.match(nv);M&&(E.push(M[1]),C.unshift(M[2])),C.length&&(a="/"+C.join(".")+a),this.hostname=E.join(".");break}}}this.hostname.length>sv?this.hostname="":this.hostname=this.hostname.toLowerCase(),_||(this.hostname=Jy.toASCII(this.hostname));var k=this.port?":"+this.port:"",P=this.hostname||"";this.host=P+k,this.href+=this.host,_&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(
vendor: 6,420 bytes, lines 7-12
7a="/"+a))}if(!ov[c])for(var f=0,y=Bl.length;f<y;f++){var S=Bl[f];if(a.indexOf(S)!==-1){var R=encodeURIComponent(S);R===S&&(R=escape(S)),a=a.split(S).join(R)}}var H=a.indexOf("#");H!==-1&&(this.hash=a.substr(H),a=a.slice(0,H));var j=a.indexOf("?");if(j!==-1?(this.search=a.substr(j),this.query=a.substr(j+1),t&&(this.query=Fl.parse(this.query)),a=a.slice(0,j)):t&&(this.search="",this.query={}),a&&(this.pathname=a),Oi[c]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var k=this.pathname||"",D=this.search||"";this.path=k+D}return this.href=this.format(),this};nr.prototype.format=function(){var r=this.auth||"";r&&(r=encodeURIComponent(r),r=r.replace(/%3A/i,":"),r+="@");var t=this.protocol||"",e=this.pathname||"",i=this.hash||"",s=!1,n="";this.host?s=r+this.host:this.hostname&&(s=r+(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=Fl.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||Oi[t])&&s!==!1?(s="//"+(s||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):s||(s=""),i&&i.charAt(0)!=="#"&&(i="#"+i),o&&o.charAt(0)!=="?"&&(o="?"+o),e=e.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),o=o.replace("#","%23"),t+s+e+o+i};nr.prototype.resolve=function(r){return this.resolveObject(av(r,!1,!0)).format()};nr.prototype.resolveObject=function(r){if(typeof r=="string"){var t=new nr;t.parse(r,!1,!0),r=t}for(var e=new nr,i=Object.keys(this),s=0;s<i.length;s++){var n=i[s];e[n]=this[n]}if(e.hash=r.hash,r.href==="")return e.href=e.format(),e;if(r.slashes&&!r.protocol){for(var o=Object.keys(r),a=0;a<o.length;a++){var l=o[a];l!=="protocol"&&(e[l]=r[l])}return Oi[e.protocol]&&e.hostname&&!e.pathname&&(e.pathname="/",e.path=e.pathname),e.href=e.format(),e}if(r.protocol&&r.protocol!==e.protocol){if(!Oi[r.protocol]){for(var h=Object.keys(r),c=0;c<h.length;c++){var u=h[c];e[u]=r[u]}return e.href=e.format(),e}if(e.protocol=r.protocol,!r.host&&!Dl[r.protocol]){for(var y=(r.pathname||"").split("/");y.length&&!(r.host=y.shift()););r.host||(r.host=""),r.hostname||(r.hostname=""),y[0]!==""&&y.unshift(""),y.length<2&&y.unshift(""),e.pathname=y.join("/")}else e.pathname=r.pathname;if(e.search=r.search,e.query=r.query,e.host=r.host||"",e.auth=r.auth,e.hostname=r.hostname||r.host,e.port=r.port,e.pathname||e.search){var d=e.pathname||"",f=e.search||"";e.path=d+f}return e.slashes=e.slashes||r.slashes,e.href=e.format(),e}var p=e.pathname&&e.pathname.charAt(0)==="/",m=r.host||r.pathname&&r.pathname.charAt(0)==="/",g=m||p||e.host&&r.pathname,_=g,v=e.pathname&&e.pathname.split("/")||[],y=r.pathname&&r.pathname.split("/")||[],b=e.protocol&&!Oi[e.protocol];if(b&&(e.hostname="",e.port=null,e.host&&(v[0]===""?v[0]=e.host:v.unshift(e.host)),e.host="",r.protocol&&(r.hostname=null,r.port=null,r.host&&(y[0]===""?y[0]=r.host:y.unshift(r.host)),r.host=null),g=g&&(y[0]===""||v[0]==="")),m)e.host=r.host||r.host===""?r.host:e.host,e.hostname=r.hostname||r.hostname===""?r.hostname:e.hostname,e.search=r.search,e.query=r.query,v=y;else if(y.length)v||(v=[]),v.pop(),v=v.concat(y),e.search=r.search,e.query=r.query;else if(r.search!=null){if(b){e.host=v.shift(),e.hostname=e.host;var x=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;x&&(e.auth=x.shift(),e.hostname=x.shift(),e.host=e.hostname)}return e.search=r.search,e.query=r.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;for(var w=v.slice(-1)[0],T=(e.host||r.host||v.length>1)&&(w==="."||w==="..")||w==="",E=0,C=v.length;C>=0;C--)w=v[C],w==="."?v.splice(C,1):w===".."?(v.splice(C,1),E++):E&&(v.splice(C,1),E--);if(!g&&!_)for(;E--;E)v.unshift("..");g&&v[0]!==""&&(!v[0]||v[0].charAt(0)!=="/")&&v.unshift(""),T&&v.join("/").substr(-1)!=="/"&&v.push("");var M=v[0]===""||v[0]&&v[0].charAt(0)==="/";if(b){e.hostname=M?"":v.length?v.shift():"",e.host=e.hostname;var x=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;x&&(e.auth=x.shift(),e.hostname=x.shift(),e.host=e.hostname)}return g=g||e.host&&v.length,g&&!M&&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=r.auth||e.auth,e.slashes=e.slashes||r.slashes,e.href=e.format(),e};nr.prototype.parseHost=function(){var r=this.host,t=tv.exec(r);t&&(t=t[0],t!==":"&&(this.port=t.substr(1)),r=r.substr(0,r.length-t.length)),r&&(this.hostname=r)};const su={};function nt(r,t,e=3){if(su[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t} 8Deprecated since v${r}`):(i=i.split(` 9`).splice(e).join(` 10`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t} 11Deprecated since v${r}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t} 12Deprecated since v${r}`),console.warn(i))),su[t]=!0}function pe(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function ns(r){return r.split("?")[0].split("#")[0]}function lv(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hv(r,t,e){return r.replace(new RegExp(lv(t),"g"),e)}function cv(r,t){let e="",i=0,s=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.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||i!==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="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=a,n=0;continue}}}else e.length>0?e+=`/${r.slice(s+1,a)}`:e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const Rt={toPosix(r){return hv(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")}
vendor: 5,683 bytes, line 12
12,hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){pe(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(pe(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=ns(this.toPosix(t??V.ADAPTER.getBaseUrl())),s=ns(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?Rt.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(pe(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const i=r.endsWith("/");return r=cv(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return pe(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let t;for(let e=0;e<r.length;++e){const i=r[e];if(pe(i),i.length>0)if(t===void 0)t=i;else{const s=r[e-1]??"";this.extname(s)?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(pe(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!s){i=a;break}}else s=!1;return i===-1?e?"/":this.isUrl(o)?n+r:n:e&&i===1?"//":n+r.slice(0,i)},rootname(r){pe(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){pe(r),t&&pe(t),r=ns(this.toPosix(r));let e=0,i=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const l=r.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&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){e=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(e,i)},extname(r){pe(r),r=ns(this.toPosix(r));let t=-1,e=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}i===-1&&(s=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){pe(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=ns(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let s;t.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let n=-1,o=0,a=-1,l=!0,h=r.length-1,c=0;for(;h>=s;--h){if(e=r.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&&i?t.base=t.name=r.slice(1,a):t.base=t.name=r.slice(o,a)):(o===0&&i?(t.name=r.slice(1,n),t.base=r.slice(1,a)):(t.name=r.slice(o,n),t.base=r.slice(o,a)),t.ext=r.slice(n,a)),t.dir=this.dirname(r),t},sep:"/",delimiter:":"};let Ta;async function uv(){return Ta??(Ta=(async()=>{const r=document.createElement("canvas").getContext("webgl");if(!r)return Zt.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 Zt.UNPACK;const e=r.createTexture();r.bindTexture(r.TEXTURE_2D,e);const i=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,s),r.deleteFramebuffer(i),r.deleteTexture(e),r.getExtension("WEBGL_lose_context")?.loseContext(),s[0]<=s[3]?Zt.PMA:Zt.UNPACK})()),Ta}let Ea;function dv(){return typeof Ea>"u"&&(Ea=function(){const r={stencil:!0,failIfMajorPerformanceCaveat:V.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!V.ADAPTER.getWebGLRenderingContext())return!1;const t=V.ADAPTER.createCanvas();let e=t.getContext("webgl",r)||t.getContext("experimental-webgl",r);const i=!!e?.getContextAttributes()?.stencil;if(e){const s=e.getExtension("WEBGL_lose_context");s&&s.loseContext()}return e=null,i}catch{return!1}}()),Ea}var fv={grad:.9,turn:360,rad:360/(2*Math.PI)},je=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},kt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},ce=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},Zf=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},nu=function(r){return{r:ce(r.r,0,255),g:ce(r.g,0,255),b:ce(r.b,0,255),a:ce(r.a)}},Aa=function(r){return{r:kt(r.r),g:kt(r.g),b:kt(r.b),a:kt(r.a,3)}}
vendor: 5,314 bytes, line 12
12,pv=/^#([0-9a-f]{3,8})$/i,zs=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},Kf=function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-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}},Jf=function(r){var t=r.h,e=r.s,i=r.v,s=r.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),l=i*(1-(1-t+n)*e),h=n%6;return{r:255*[i,a,o,o,l,i][h],g:255*[l,i,i,a,o,o][h],b:255*[o,o,l,i,i,a][h],a:s}},ou=function(r){return{h:Zf(r.h),s:ce(r.s,0,100),l:ce(r.l,0,100),a:ce(r.a)}},au=function(r){return{h:kt(r.h),s:kt(r.s),l:kt(r.l),a:kt(r.a,3)}},lu=function(r){return Jf((e=(t=r).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},Es=function(r){return{h:(t=Kf(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},_v=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,mv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,gv=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,yv=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ol={string:[[function(r){var t=pv.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?kt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?kt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=gv.exec(r)||yv.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:nu({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(r){var t=_v.exec(r)||mv.exec(r);if(!t)return null;var e,i,s=ou({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(fv[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return lu(s)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return je(t)&&je(e)&&je(i)?nu({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!je(t)||!je(e)||!je(i))return null;var o=ou({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return lu(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!je(t)||!je(e)||!je(i))return null;var o=function(a){return{h:Zf(a.h),s:ce(a.s,0,100),v:ce(a.v,0,100),a:ce(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Jf(o)},"hsv"]]},hu=function(r,t){for(var e=0;e<t.length;e++){var i=t[e][0](r);if(i)return[i,t[e][1]]}return[null,void 0]},vv=function(r){return typeof r=="string"?hu(r.trim(),Ol.string):typeof r=="object"&&r!==null?hu(r,Ol.object):[null,void 0]},Sa=function(r,t){var e=Es(r);return{h:e.h,s:ce(e.s+100*t,0,100),l:e.l,a:e.a}},Ca=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},cu=function(r,t){var e=Es(r);return{h:e.h,s:e.s,l:ce(e.l+100*t,0,100),a:e.a}},Nl=function(){function r(t){this.parsed=vv(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return kt(Ca(this.rgba),2)},r.prototype.isDark=function(){return Ca(this.rgba)<.5},r.prototype.isLight=function(){return Ca(this.rgba)>=.5},r.prototype.toHex=function(){return t=Aa(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?zs(kt(255*n)):"","#"+zs(e)+zs(i)+zs(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return Aa(this.rgba)},r.prototype.toRgbString=function(){return t=Aa(this.rgba),e=t.r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},r.prototype.toHsl=function(){return au(Es(this.rgba))},r.prototype.toHslString=function(){return t=au(Es(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=Kf(this.rgba),{h:kt(t.h),s:kt(t.s),v:kt(t.v),a:kt(t.a,3)};var t},r.prototype.invert=function(){return ke({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),ke(Sa(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),ke(Sa(this.rgba,-t))},r.prototype.grayscale=function(){return ke(Sa(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),ke(cu(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),ke(cu(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?ke({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):kt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=Es(this.rgba);return typeof t=="number"?ke({h:t,s:e.s,l:e.l,a:e.a}):kt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===ke(t).toHex()},r}(),ke=function(r){return r instanceof Nl?r:new Nl(r)},uu=[],bv=function(r){r.forEach(function(t){uu.indexOf(t)<0&&(t(Nl,Ol),uu.push(t))})};
vendor: 4,443 bytes, line 12
12function xv(r,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",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var s in e)i[e[s]]=s;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=i[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 r(e[f]).toRgb();for(var p in e){var m=(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));m<u&&(u=m,d=p)}return d}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new r(l).toRgb():null},"name"])}bv([xv]);const Ei=class wn{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 wn)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 i=typeof t;if(i!==typeof e)return!1;
vendor: 4,962 bytes, line 12
12if(i==="number"||i==="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,i,s]=this._components;return{r:t,g:e,b:i,a:s}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,s]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toRgbArray(t){t=t??[];const[e,i,s]=this._components;return t[0]=e,t[1]=i,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,i,s,n]=wn.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,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 i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<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,i,s]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(s*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}normalize(t){let e,i,s,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(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,i,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,i,s,n=255]=t,e/=255,i/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=wn.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=ke(t);o.isValid()&&({r:e,g:i,b:s,a:n}=o.rgba,e/=255,i/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,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,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}};Ei.shared=new Ei,Ei.temp=new Ei,Ei.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let ft=Ei;function wv(r){return nt("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),ft.shared.setValue(r).toHex()}function Tv(r){return nt("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),ft.shared.setValue(r).toNumber()}function Ev(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[Q.NORMAL_NPM]=Q.NORMAL,r[Q.ADD_NPM]=Q.ADD,r[Q.SCREEN_NPM]=Q.SCREEN,t[Q.NORMAL]=Q.NORMAL_NPM,t[Q.ADD]=Q.ADD_NPM,t[Q.SCREEN]=Q.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const Qf=Ev();function tp(r,t){return Qf[t?1:0][r]}function Av(r,t=null){const e=r*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}function ep(r){if(r.BYTES_PER_ELEMENT===4)return r instanceof Float32Array?"Float32Array":r instanceof Uint32Array?"Uint32Array":"Int32Array";if(r.BYTES_PER_ELEMENT===2){if(r instanceof Uint16Array)return"Uint16Array"}else if(r.BYTES_PER_ELEMENT===1&&r instanceof Uint8Array)return"Uint8Array";return null}function eo(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function du(r){return!(r&r-1)&&!!r}function fu(r){let t=(r>65535?1:0)<<4;r>>>=t;let e=(r>255?1:0)<<3;return r>>>=e,t|=e,e=(r>15?1:0)<<2,r>>>=e,t|=e,e=(r>3?1:0)<<1,r>>>=e,t|=e,t|r>>1}function Ni(r,t,e){const i=r.length;let s;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(s=t;s<n;++s)r[s]=r[s+e];r.length=n}function br(r){return r===0?0:r<0?-1:1}let Sv=0;function ni(){return++Sv}const Ll=class{constructor(r,t,e,i){this.left=r,this.top=t,this.right=e,this.bottom=i}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};
12Ll.EMPTY=new Ll(0,0,0,0);let pu=Ll;const _u={},Be=Object.create(null),hr=Object.create(null);class Cv{constructor(t,e,i){this._canvas=V.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||V.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 mu(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function gu(r,t,e,i,s){const n=4*t;for(let o=i,a=i*n+4*e;o<=s;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function Iv(r){const{width:t,height:e}=r,i=r.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const s=i.getImageData(0,0,t,e).data;let n=0,o=0,a=t-1,l=e-1;for(;o<e&&mu(s,t,o);)++o;if(o===e)return pu.EMPTY;for(;mu(s,t,l);)--l;for(;gu(s,t,n,o,l);)++n;for(;gu(s,t,a,o,l);)--a;return++a,++l,new pu(n,o,a,l)}function Rv(r){const t=Iv(r),{width:e,height:i}=t;let s=null;if(!t.isEmpty()){const n=r.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");s=n.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:s}}function Pv(r,t=globalThis.location){if(r.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function or(r,t=1){const e=V.RETINA_PREFIX?.exec(r);return e?parseFloat(e[1]):t}var $=(r=>(r.Renderer="renderer",r.Application="application",r.RendererSystem="renderer-webgl-system",r.RendererPlugin="renderer-webgl-plugin",r.CanvasRendererSystem="renderer-canvas-system",r.CanvasRendererPlugin="renderer-canvas-plugin",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r))($||{});const Ul=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},yu=(r,t)=>Ul(r).priority??t,q={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Ul).forEach(t=>{t.type.forEach(e=>this._removeHandlers[e]?.(t))}),this},add(...r){return r.map(Ul).forEach(t=>{t.type.forEach(e=>{const i=this._addHandlers,s=this._queue;i[e]?i[e](t):(s[e]=s[e]||[],s[e].push(t))})}),this},handle(r,t,e){const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=t,s[r]=e;const n=this._queue;return n[r]&&(n[r].forEach(o=>t(o)),delete n[r]),this},handleByMap(r,t){return this.handle(r,e=>{t[e.name]=e.ref},e=>{delete t[e.name]})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>yu(n,e)-yu(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class Gl{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 Mv=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` 13`);function kv(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=` 14else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function Bv(r,t){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);for(;;){const i=Mv.replace(/%forloop%/gi,kv(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const Ia=0,Ra=1,Pa=2,Ma=3,ka=4,Ba=5;class Xe{constructor(){this.data=0,this.blendMode=Q.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Ia)}set blend(t){!!(this.data&1<<Ia)!==t&&(this.data^=1<<Ia)}get offsets(){return!!(this.data&1<<Ra)}set offsets(t){!!(this.data&1<<Ra)!==t&&(this.data^=1<<Ra)}
vendor: 26,046 bytes, lines 14-28
14get culling(){return!!(this.data&1<<Pa)}set culling(t){!!(this.data&1<<Pa)!==t&&(this.data^=1<<Pa)}get depthTest(){return!!(this.data&1<<Ma)}set depthTest(t){!!(this.data&1<<Ma)!==t&&(this.data^=1<<Ma)}get depthMask(){return!!(this.data&1<<Ba)}set depthMask(t){!!(this.data&1<<Ba)!==t&&(this.data^=1<<Ba)}get clockwiseFrontFace(){return!!(this.data&1<<ka)}set clockwiseFrontFace(t){!!(this.data&1<<ka)!==t&&(this.data^=1<<ka)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==Q.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Xe;return t.depthTest=!1,t.blend=!0,t}}Xe.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const Hl=[];function rp(r,t){if(!r)return null;let e="";if(typeof r=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(r);i&&(e=i[1].toLowerCase())}for(let i=Hl.length-1;i>=0;--i){const s=Hl[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class Te{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,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,i,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(Te.prototype,{dispatch:{value:Te.prototype.emit},run:{value:Te.prototype.emit}});class Ps{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new Te("setRealSize"),this.onUpdate=new Te("update"),this.onError=new Te("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,i){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 Po extends Ps{constructor(t,e){const{width:i,height:s}=e||{};if(!i||!s)throw new Error("BufferResource width or height invalid");super(i,s),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const s=t.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Zt.UNPACK);const n=e.realWidth,o=e.realHeight;return i.width===n&&i.height===o?s.texSubImage2D(e.target,0,0,0,n,o,e.format,i.type,this.data):(i.width=n,i.height=o,s.texImage2D(e.target,0,i.internalFormat,n,o,0,e.format,i.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 Dv={scaleMode:Je.NEAREST,alphaMode:Zt.NPM},$l=class Ai extends ks{constructor(t=null,e=null){super(),e=Object.assign({},Ai.defaultOptions,e);const{alphaMode:i,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 Ps)&&(t=rp(t,p),t.internal=!0),this.resolution=f||V.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=i,this.uid=ni(),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 i;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),e!==void 0&&e!==this.mipmap&&(this.mipmap=e,i=!0),i&&this.dirtyStyleId++,this}setSize(t,e,i){return i=i||this.resolution,this.setRealSize(t*i,e*i,i)}setRealSize(t,e,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=du(this.realWidth)&&du(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 hr[this.cacheId],delete Be[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,i=V.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}_${ni()}`}n=t._pixiId}let o=hr[n];if(s&&i&&!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,i,s){t=t||new Float32Array(e*i*4);const n=new Po(t,{width:e,height:i,...s?.resourceOptions});let o,a;return t instanceof Float32Array?(o=N.RGBA,a=K.FLOAT):t instanceof Int32Array?(o=N.RGBA_INTEGER,a=K.INT):t instanceof Uint32Array?(o=N.RGBA_INTEGER,a=K.UNSIGNED_INT):t instanceof Int16Array?(o=N.RGBA_INTEGER,a=K.SHORT):t instanceof Uint16Array?(o=N.RGBA_INTEGER,a=K.UNSIGNED_SHORT):t instanceof Int8Array?(o=N.RGBA,a=K.BYTE):(o=N.RGBA,a=K.UNSIGNED_BYTE),n.internal=!0,new Ai(n,Object.assign({},Dv,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),hr[e]&&hr[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),hr[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=hr[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete hr[t],e}}else if(t?.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete hr[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};$l.defaultOptions={mipmap:ze.POW2,anisotropicLevel:0,scaleMode:Je.LINEAR,wrapMode:Tr.CLAMP,alphaMode:Zt.UNPACK,target:Di.TEXTURE_2D,format:N.RGBA,type:K.UNSIGNED_BYTE},$l._globalBatch=0;let rt=$l;class zl{constructor(){this.texArray=null,this.blend=0,this.type=Ge.TRIANGLES,this.start=0,this.size=0,this.data=null}}let Fv=0;class St{constructor(t,e=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=e,this.id=Fv++,this.disposeRunner=new Te("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?He.ELEMENT_ARRAY_BUFFER:He.ARRAY_BUFFER}get index(){return this.type===He.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new St(t)}}class ro{constructor(t,e=0,i=!1,s=K.FLOAT,n,o,a,l=1){this.buffer=t,this.size=e,this.normalized=i,this.type=s,this.stride=n,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(t,e,i,s,n){return new ro(t,e,i,s,n)}}const Ov={Float32Array,Uint32Array,Int32Array,Uint8Array};function Nv(r,t){let e=0,i=0;const s={};for(let l=0;l<r.length;l++)i+=t[l],e+=r[l].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let l=0;l<r.length;l++){const h=t[l],c=r[l],u=ep(c);s[u]||(s[u]=new Ov[u](n)),o=s[u];for(let d=0;d<c.length;d++){const f=(d/h|0)*i+a,p=d%h;o[f+p]=c[d]}a+=h}return new Float32Array(n)}const vu={5126:4,5123:2,5121:1};let Lv=0;const Uv={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class Ar{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=Lv++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new Te("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,s=!1,n,o,a,l=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof St||(e instanceof Array&&(e=new Float32Array(e)),e=new St(e));const h=t.split("|");if(h.length>1){for(let u=0;u<h.length;u++)this.addAttribute(h[u],e,i,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 ro(c,i,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 St||(t instanceof Array&&(t=new Uint16Array(t)),t=new St(t)),t.type=He.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=[],i=new St;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*vu[n.type]/4),n.buffer=0}for(i.data=Nv(t,e),s=0;s<this.buffers.length;s++)this.buffers[s]!==this.indexBuffer&&this.buffers[s].destroy();return this.buffers=[i],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 Ar;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new St(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new ro(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=He.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new Ar,i=[],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++)i[a]=new Uv[ep(o.buffers[a].data)](s[a]),e.buffers[a]=new St(i[a]);for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)i[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=He.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*vu[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 ip extends Ar{constructor(t=!1){super(),this._buffer=new St(null,t,!1),this._indexBuffer=new St(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,K.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,K.FLOAT).addAttribute("aColor",this._buffer,4,!0,K.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,K.FLOAT).addIndex(this._indexBuffer)}}const io=Math.PI*2,Gv=180/Math.PI,Hv=Math.PI/180;var Ft=(r=>(r[r.POLY=0]="POLY",r[r.RECT=1]="RECT",r[r.CIRC=2]="CIRC",r[r.ELIP=3]="ELIP",r[r.RREC=4]="RREC",r))(Ft||{});class ct{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new ct(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}}ct.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Xs=[new ct,new ct,new ct,new ct];class et{constructor(t=0,e=0,i=0,s=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s),this.type=Ft.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 et(0,0,0,0)}clone(){return new et(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 E=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=E)return!1;const C=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>C}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=Xs[0].set(t.left,t.top),l=Xs[1].set(t.left,t.bottom),h=Xs[2].set(t.right,t.top),c=Xs[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)<=i||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*i+f*n,m=d*s+f*n,g=d*i+f*o,_=d*s+f*o;if(Math.max(p,m,g,_)<=d*a.x+f*a.y||Math.min(p,m,g,_)>=d*c.x+f*c.y)return!1;const v=u*(a.y-h.y),y=u*(h.x-a.x),b=v*i+y*n,x=v*s+y*n,w=v*i+y*o,T=v*s+y*o;return!(Math.max(b,x,w,T)<=v*a.x+y*a.y||Math.min(b,x,w,T)>=v*c.x+y*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),i=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(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=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=i-this.x,this.height=s-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=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=i-e,this.y=s,this.height=n-s,this}}et.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Mo{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Ft.CIRC}clone(){return new Mo(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}getBounds(){return new et(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}Mo.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class ko{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=Ft.ELIP}clone(){return new ko(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,s=(e-this.y)/this.height;return i*=i,s*=s,i+s<=1}getBounds(){return new et(this.x-this.width,this.y-this.height,this.width,this.height)}}ko.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class ei{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.type=Ft.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new ei(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!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&&(i=!i)}return i}}ei.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class Bo{constructor(t=0,e=0,i=0,s=0,n=20){this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n,this.type=Ft.RREC}clone(){return new Bo(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 i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let s=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=t-(this.x+this.width-i),s*s+n*n<=o)||(n=e-(this.y+this.height-i),s*s+n*n<=o)||(s=t-(this.x+i),s*s+n*n<=o))return!0}return!1}}Bo.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class gt{constructor(t=1,e=0,i=0,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,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,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new ct;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new ct;const i=1/(this.a*this.d+this.c*-this.b),s=t.x,n=t.y;return e.x=this.d*i*s+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,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),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}setTransform(t,e,i,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-(i*this.a+s*this.c),this.ty=e-(i*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 i=this.a,s=this.c;this.a=i*t.a+this.b*t.c,this.b=i*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,i=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),l=Math.atan2(i,e),h=Math.abs(a+l);return h<1e-5||Math.abs(io-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+i*i),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*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,o=t*s-e*i;return this.a=s/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*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 gt;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 gt}static get TEMP_MATRIX(){return new gt}}gt.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 zr=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Xr=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Vr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Wr=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Xl=[],sp=[],Vs=Math.sign;function $v(){for(let r=0;r<16;r++){const t=[];Xl.push(t);for(let e=0;e<16;e++){const i=Vs(zr[r]*zr[e]+Vr[r]*Xr[e]),s=Vs(Xr[r]*zr[e]+Wr[r]*Xr[e]),n=Vs(zr[r]*Vr[e]+Vr[r]*Wr[e]),o=Vs(Xr[r]*Vr[e]+Wr[r]*Wr[e]);for(let a=0;a<16;a++)if(zr[a]===i&&Xr[a]===s&&Vr[a]===n&&Wr[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new gt;t.set(zr[r],Xr[r],Vr[r],Wr[r],0,0),sp.push(t)}}$v();const bt={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:r=>zr[r],uY:r=>Xr[r],vX:r=>Vr[r],vY:r=>Wr[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Xl[r][t],sub:(r,t)=>Xl[r][bt.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?bt.S:bt.N:Math.abs(t)*2<=Math.abs(r)?r>0?bt.E:bt.W:t>0?r>0?bt.SE:bt.SW:r>0?bt.NE:bt.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=sp[bt.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class tr{constructor(t,e,i=0,s=0){this._x=i,this._y=s,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new tr(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))}}tr.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Vl=class{constructor(){this.worldTransform=new gt,this.localTransform=new gt,this.position=new tr(this.onChange,this,0,0),this.scale=new tr(this.onChange,this,1,1),this.pivot=new tr(this.onChange,this,0,0),this.skew=new tr(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 r=this.localTransform;this._localID!==this._currentLocalID&&(r.a=this._cx*this.scale.x,r.b=this._sx*this.scale.x,r.c=this._cy*this.scale.y,r.d=this._sy*this.scale.y,r.tx=this.position.x-(this.pivot.x*r.a+this.pivot.y*r.c),r.ty=this.position.y-(this.pivot.x*r.b+this.pivot.y*r.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(r){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!==r._worldID){const e=r.worldTransform,i=this.worldTransform;i.a=t.a*e.a+t.b*e.c,i.b=t.a*e.b+t.b*e.d,i.c=t.c*e.a+t.d*e.c,i.d=t.c*e.b+t.d*e.d,i.tx=t.tx*e.a+t.ty*e.c+e.tx,i.ty=t.tx*e.b+t.ty*e.d+e.ty,this._parentID=r._worldID,this._worldID++}}setFromMatrix(r){r.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(r){this._rotation!==r&&(this._rotation=r,this.updateSkew())}};Vl.IDENTITY=new Vl;let Hh=Vl;Hh.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 zv=`varying vec2 vTextureCoord; 15 16uniform sampler2D uSampler; 17 18void main(void){ 19 gl_FragColor *= texture2D(uSampler, vTextureCoord); 20}`,Xv=`attribute vec2 aVertexPosition; 21attribute vec2 aTextureCoord; 22 23uniform mat3 projectionMatrix; 24 25varying vec2 vTextureCoord; 26 27void main(void){ 28 gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0
28)).xy, 0.0, 1.0); 29 vTextureCoord = aTextureCoord; 30} 31`;function bu(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function Da(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function np(r,t){switch(r){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 Da(2*t);case"bvec3":return Da(3*t);case"bvec4":return Da(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 Li=[{test:r=>r.type==="float"&&r.size===1&&!r.isArray,code:r=>` 32 if(uv["${r}"] !== ud["${r}"].value) 33 { 34 ud["${r}"].value = uv["${r}"] 35 gl.uniform1f(ud["${r}"].location, uv["${r}"]) 36 } 37 `},{test:(r,t)=>(r.type==="sampler2D"||r.type==="samplerCube"||r.type==="sampler2DArray")&&r.size===1&&!r.isArray&&(t==null||t.castToBaseTexture!==void 0),code:r=>`t = syncData.textureCount++; 38 39 renderer.texture.bind(uv["${r}"], t); 40 41 if(ud["${r}"].value !== t) 42 { 43 ud["${r}"].value = t; 44 gl.uniform1i(ud["${r}"].location, t); 45; // eslint-disable-line max-len 46 }`},{test:(r,t)=>r.type==="mat3"&&r.size===1&&!r.isArray&&t.a!==void 0,code:r=>` 47 gl.uniformMatrix3fv(ud["${r}"].location, false, uv["${r}"].toArray(true)); 48 `,codeUbo:r=>` 49 var ${r}_matrix = uv.${r}.toArray(true); 50 51 data[offset] = ${r}_matrix[0]; 52 data[offset+1] = ${r}_matrix[1]; 53 data[offset+2] = ${r}_matrix[2]; 54 55 data[offset + 4] = ${r}_matrix[3]; 56 data[offset + 5] = ${r}_matrix[4]; 57 data[offset + 6] = ${r}_matrix[5]; 58 59 data[offset + 8] = ${r}_matrix[6]; 60 data[offset + 9] = ${r}_matrix[7]; 61 data[offset + 10] = ${r}_matrix[8]; 62 `},{test:(r,t)=>r.type==="vec2"&&r.size===1&&!r.isArray&&t.x!==void 0,code:r=>` 63 cv = ud["${r}"].value; 64 v = uv["${r}"]; 65 66 if(cv[0] !== v.x || cv[1] !== v.y) 67 { 68 cv[0] = v.x; 69 cv[1] = v.y; 70 gl.uniform2f(ud["${r}"].location, v.x, v.y); 71 }`,codeUbo:r=>` 72 v = uv.${r}; 73 74 data[offset] = v.x; 75 data[offset+1] = v.y; 76 `},{test:r=>r.type==="vec2"&&r.size===1&&!r.isArray,code:r=>` 77 cv = ud["${r}"].value; 78 v = uv["${r}"]; 79 80 if(cv[0] !== v[0] || cv[1] !== v[1]) 81 { 82 cv[0] = v[0]; 83 cv[1] = v[1]; 84 gl.uniform2f(ud["${r}"].location, v[0], v[1]); 85 } 86 `},{test:(r,t)=>r.type==="vec4"&&r.size===1&&!r.isArray&&t.width!==void 0,code:r=>` 87 cv = ud["${r}"].value; 88 v = uv["${r}"]; 89 90 if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) 91 { 92 cv[0] = v.x; 93 cv[1] = v.y; 94 cv[2] = v.width; 95 cv[3] = v.height; 96 gl.uniform4f(ud["${r}"].location, v.x, v.y, v.width, v.height) 97 }`,codeUbo:r=>` 98 v = uv.${r}; 99 100 data[offset] = v.x; 101 data[offset+1] = v.y; 102 data[offset+2] = v.width; 103 data[offset+3] = v.height; 104 `},{test:(r,t)=>r.type==="vec4"&&r.size===1&&!r.isArray&&t.red!==void 0,code:r=>` 105 cv = ud["${r}"].value; 106 v = uv["${r}"]; 107 108 if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) 109 { 110 cv[0] = v.red; 111 cv[1] = v.green; 112 cv[2] = v.blue; 113 cv[3] = v.alpha; 114 gl.uniform4f(ud["${r}"].location, v.red, v.green, v.blue, v.alpha) 115 }`,codeUbo:r=>` 116 v = uv.${r}; 117 118 data[offset] = v.red; 119 data[offset+1] = v.green; 120 data[offset+2] = v.blue; 121 data[offset+3] = v.alpha; 122 `},{test:(r,t)=>r.type==="vec3"&&r.size===1&&!r.isArray&&t.red!==void 0,code:r=>` 123 cv = ud["${r}"].value; 124 v = uv["${r}"]; 125 126 if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a) 127 { 128 cv[0] = v.red; 129 cv[1] = v.green; 130 cv[2] = v.blue; 131 132 gl.uniform3f(ud["${r}"].location, v.red, v.green, v.blue) 133 }`,codeUbo:r=>` 134 v = uv.${r}; 135 136 data[offset] = v.red; 137 data[offset+1] = v.green; 138 data[offset+2] = v.blue; 139 `},{test:r=>r.type==="vec4"&&r.size===1&&!r.isArray,code:r=>` 140 cv = ud["${r}"].value; 141 v = uv["${r}"]; 142 143 if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 144 { 145 cv[0] = v[0]; 146 cv[1] = v[1]; 147 cv[2] = v[2]; 148 cv[3] = v[3]; 149 150 gl.uniform4f(ud["${r}"].location, v[0], v[1], v[2], v[3]) 151 }`}],Vv={float:` 152 if (cv !== v) 153 { 154 cu.value = v; 155 gl.uniform1f(location, v); 156 }`,vec2:` 157 if (cv[0] !== v[0] || cv[1] !== v[1]) 158 { 159 cv[0] = v[0]; 160 cv[1] = v[1]; 161 162 gl.uniform2f(location, v[0], v[1]) 163 }`,vec3:` 164 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) 165 { 166 cv[0] = v[0]; 167 cv[1] = v[1]; 168 cv[2] = v[2]; 169 170 gl.uniform3f(location, v[0], v[1], v[2]) 171 }`,vec4:` 172 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 173 { 174 cv[0] = v[0]; 175 cv[1] = v[1]; 176 cv[2] = v[2]; 177 cv[3] = v[3]; 178 179 gl.uniform4f(location, v[0], v[1], v[2], v[3]); 180 }`,int:` 181 if (cv !== v) 182 { 183 cu.value = v; 184 185 gl.uniform1i(location, v); 186 }`,ivec2:` 187 if (cv[0] !== v[0] || cv[1] !== v[1]) 188 { 189 cv[0] = v[0]; 190 cv[1] = v[1]; 191 192 gl.uniform2i(location, v[0], v[1]); 193 }`,ivec3:` 194 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) 195 { 196 cv[0] = v[0]; 197 cv[1] = v[1]; 198 cv[2] = v[2]; 199 200 gl.uniform3i(location, v[0], v[1], v[2]); 201 }`,ivec4:` 202 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 203 { 204 cv[0] = v[0]; 205 cv[1] = v[1]; 206 cv[2] = v[2]; 207 cv[3] = v[3]; 208 209 gl.uniform4i(location, v[0], v[1], v[2], v[3]); 210 }`,uint:` 211 if (cv !== v) 212 { 213 cu.value = v; 214 215 gl.uniform1ui(location, v); 216 }`,uvec2:` 217 if (cv[0] !== v[0] || cv[1] !== v[1]) 218 { 219 cv[0] = v[0]; 220 cv[1] = v[1]; 221 222 gl.uniform2ui(location, v[0], v[1]); 223 }`,uvec3:` 224 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) 225 { 226 cv[0] = v[0]; 227 cv[1] = v[1]; 228 cv[2] = v[2]; 229 230 gl.uniform3ui(location, v[0], v[1], v[2]); 231 }`,uvec4:` 232 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 233 { 234 cv[0] = v[0]; 235 cv[1] = v[1]; 236 cv[2] = v[2]; 237 cv[3] = v[3]; 238 239 gl.uniform4ui(location, v[0], v[1], v[2], v[3]); 240 }`,bool:` 241 if (cv !== v) 242 { 243 cu.value = v; 244 gl.uniform1i(location, v); 245 }`,bvec2:` 246 if (cv[0] != v[0] || cv[1] != v[1]) 247 { 248 cv[0] = v[0]; 249 cv[1] = v[1]; 250 251 gl.uniform2i(location, v[0], v[1]); 252 }`,bvec3:` 253 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) 254 { 255 cv[0] = v[0]; 256 cv[1] = v[1]; 257 cv[2] = v[2]; 258 259 gl.uniform3i(location, v[0], v[1], v[2]); 260 }`,bvec4:` 261 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 262 { 263 cv[0] = v[0]; 264 cv[1] = v[1]; 265 cv[2] = v[2]; 266 cv[3] = v[3]; 267 268 gl.uniform4i(location, v[0], v[1], v[2], v[3]); 269 }`,mat2:"gl.uniformMatrix2fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",sampler2D:` 270 if (cv !== v) 271 { 272 cu.value = v; 273 274 gl.uniform1i(location, v); 275 }`,samplerCube:` 276 if (cv !== v) 277 { 278 cu.value = v; 279 280 gl.uniform1i(location, v); 281 }`,sampler2DArray:` 282 if (cv !== v) 283 { 284 cu.value = v; 285 286 gl.uniform1i(location, v); 287 }`},Wv={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 jv(r,t){const e=[` 288 var v = null; 289 var cv = null; 290 var cu = null; 291 var t = 0; 292 var gl = renderer.gl; 293 `];for(const i in r.uniforms){const s=t[i];if(!s){r.uniforms[i]?.group===!0&&(r.uniforms[i].ubo?e.push(` 294 renderer.shader.syncUniformBufferGroup(uv.${i}, '${i}'); 295 `):e.push(` 296 renderer.shader.syncUniformGroup(uv.${i}, syncData); 297 `));continue}const n=r.uniforms[i];let o=!1;for(let a=0;a<Li.length;a++)if(Li[a].test(s,n)){e.push(Li[a].code(i,n)),o=!0;break}if(!o){const a=(s.size===1&&!s.isArray?Vv:Wv)[s.type].replace("location",`ud["${i}"].location`);e.push(` 298 cu = ud["${i}"]; 299 cv = cu.value; 300 v = uv["${i}"]; 301 ${a};`)}}return new Function("ud","uv","renderer","syncData",e.join(` 302`))}const op={};let Ws=op;function Yv(){if(Ws===op||Ws?.isContextLost()){const r=V.ADAPTER.createCanvas();let t;V.PREFER_ENV>=li.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Ws=t}return Ws}let js;function qv(){if(!js){js=he.MEDIUM;const r=Yv();if(r&&r.getShaderPrecisionFormat){const t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);t&&(js=t.precision?he.HIGH:he.MEDIUM)}}return js}function xu(r,t){const e=r.getShaderSource(t).split(` 303`).map((h,c)=>`${c}: ${h}`),i=r.getShaderInfoLog(t),s=i.split(` 304`),n={},o=s.map(h=>
vendor: 6,481 bytes, lines 304-341
304parseFloat(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(` 305`);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Zv(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||xu(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||xu(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const Kv={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 ap(r){return Kv[r]}let Ys=null;const wu={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 lp(r,t){if(!Ys){const e=Object.keys(wu);Ys={};for(let i=0;i<e.length;++i){const s=e[i];Ys[r[s]]=wu[s]}}return Ys[t]}function Tu(r,t,e){if(r.substring(0,9)!=="precision"){let i=t;return t===he.HIGH&&e!==he.HIGH&&(i=he.MEDIUM),`precision ${i} float; 306${r}`}else if(e!==he.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let os;function Jv(){if(typeof os=="boolean")return os;try{os=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{os=!1}return os}let Qv=0;const qs={},Wl=class Si{constructor(t,e,i="pixi-shader",s={}){this.extra={},this.id=Qv++,this.vertexSrc=t||Si.defaultVertexSrc,this.fragmentSrc=e||Si.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=s,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),qs[i]?(qs[i]++,i+=`-${qs[i]}`):qs[i]=1,this.vertexSrc=`#define SHADER_NAME ${i} 307${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i} 308${this.fragmentSrc}`,this.vertexSrc=Tu(this.vertexSrc,Si.defaultVertexPrecision,he.HIGH),this.fragmentSrc=Tu(this.fragmentSrc,Si.defaultFragmentPrecision,qv())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return Xv}static get defaultFragmentSrc(){return zv}static from(t,e,i){const s=t+e;let n=_u[s];return n||(_u[s]=n=new Si(t,e,i)),n}};Wl.defaultVertexPrecision=he.HIGH,Wl.defaultFragmentPrecision=Qe.apple.device?he.HIGH:he.MEDIUM;let er=Wl,tb=0;class Ee{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=tb++,this.static=!!e,this.ubo=!!i,t instanceof St?(this.buffer=t,this.buffer.type=He.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new St(new Float32Array(1)),this.buffer.type=He.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,i){if(!this.ubo)this.uniforms[t]=new Ee(e,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,e,i){return new Ee(t,e,i)}static uboFrom(t,e){return new Ee(t,e??!0,!0)}}class $e{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof Ee?this.uniformGroup=e:this.uniformGroup=new Ee(e):this.uniformGroup=new Ee({}),this.disposeRunner=new Te("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const s=e.uniforms[i];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,i){const s=er.from(t,e);return new $e(s,i)}}class eb{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 i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=n;this.defaultGroupCache[t]=Ee.from({uSamplers:i},!0);let s=this.fragTemplate;s=s.replace(/%count%/gi,`${t}`),s=s.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new er(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new gt,default:this.defaultGroupCache[t]};return new $e(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=` 309`,e+=` 310`;for(let i=0;i<t;i++)i>0&&(e+=` 311else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=` 312{`,e+=` 313 color = texture2D(uSamplers[${i}], vTextureCoord);`,e+=` 314}`;return e+=` 315`,e+=` 316`,e}}class jl{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 rb(){return!Qe.apple.device}function ib(r){let t=!0;const e=V.ADAPTER.getNavigator();if(Qe.tablet||Qe.phone){if(Qe.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(Qe.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?r:4}class Do{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var sb=`varying vec2 vTextureCoord; 317varying vec4 vColor; 318varying float vTextureId; 319uniform sampler2D uSamplers[%count%]; 320 321void main(void){ 322 vec4 color; 323 %forloop% 324 gl_FragColor = color * vColor; 325} 326`,nb=`precision highp float; 327attribute vec2 aVertexPosition; 328attribute vec2 aTextureCoord; 329attribute vec4 aColor; 330attribute float aTextureId; 331 332uniform mat3 projectionMatrix; 333uniform mat3 translationMatrix; 334uniform vec4 tint; 335 336varying vec2 vTextureCoord; 337varying vec4 vColor; 338varying float vTextureId; 339 340void main(void){ 341 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
341)).xy, 0.0, 1.0); 342 343 vTextureCoord = aTextureCoord; 344 vTextureId = aTextureId; 345 vColor = aColor * tint; 346} 347`;const fs=class ye extends Do{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=ip,this.vertexSize=6,this.state=Xe.for2d(),this.size=ye.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??ib(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??rb(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return nt("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return nb}static get defaultFragmentTemplate(){return sb}setShaderGenerator({vertex:t=ye.defaultVertexSrc,fragment:e=ye.defaultFragmentTemplate}={}){this.shaderGenerator=new eb(t,e)}contextChange(){const t=this.renderer.gl;V.PREFER_ENV===li.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),ye.defaultMaxTextures),this.maxTextures=Bv(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}=ye,i=this.size/4,s=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new zl);for(;e.length<s;)e.push(new jl);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,i=ye._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++rt._globalBatch,l=0,h=i[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=i[++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;rt._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,l=ye._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<i;++f){const p=s[f],m=p._texture.baseTexture,g=Qf[m.alphaMode?1:0][p.blendMode];s[f]=null,e<f&&d.blend!==g&&(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=g}e<i&&(d.size=u-d.start,++h),this._dcIndex=h,this._aIndex=c,this._iIndex=u}bindAndClearTexArray(t){const e=this.renderer.texture;for(let i=0;i<t.count;i++)e.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:i}=this;ye.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),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(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:i}=this.renderer,s=ye._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,i.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),ye.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=eo(Math.ceil(t/8)),i=fu(e),s=e*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._aBuffers[s];return n||(this._aBuffers[s]=n=new Gl(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=eo(Math.ceil(t/12)),i=fu(e),s=e*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._iBuffers[i];return n||(this._iBuffers[i]=n=new Uint16Array(s)),n}packInterleavedGeometry(t,e,i,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=ft.shared.setValue(t._tintRGB).toPremultiplied(f,t._texture.baseTexture.alphaMode>0);for(let m=0;m<u.length;m+=2)a[s++]=u[m],a[s++]=u[m+1],a[s++]=h[m],a[s++]=h[m+1],o[s++]=p,a[s++]=d;for(let m=0;m<c.length;m++)i[n++]=l+c[m]}};fs.defaultBatchSize=4096,fs.extension={name:"batch",type:$.RendererPlugin},fs._drawCallPool=[],fs._textureArrayPool=[];let jr=fs;q.add(jr);var ob=`varying vec2 vTextureCoord; 348 349uniform sampler2D uSampler; 350 351void main(void){ 352 gl_FragColor = texture2D(uSampler, vTextureCoord); 353} 354`,ab=`attribute vec2 aVertexPosition; 355 356uniform mat3 projectionMatrix; 357 358varying vec2 vTextureCoord; 359 360uniform vec4 inputSize; 361uniform vec4 outputFrame; 362 363vec4 filterVertexPosition( void ) 364{ 365 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 366
367 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 368} 369 370vec2 filterTextureCoord( void ) 371{ 372 return aVertexPosition * (outputFrame.zw * inputSize.zw); 373} 374 375void main(void) 376{ 377 gl_Position = filterVertexPosition(); 378 vTextureCoord = filterTextureCoord(); 379} 380`;const Yl=class ps extends $e{constructor(t,e,i){const s=er.from(t||ps.defaultVertexSrc,e||ps.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=ps.defaultResolution,this.multisample=ps.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Xe}apply(t,e,i,s,n){t.applyFilter(this,e,i,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 ab}static get defaultFragmentSrc(){return ob}};Yl.defaultResolution=1,Yl.defaultMultisample=Ct.NONE;let Gt=Yl;class so{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new ft(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:s}=t,n=i??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(){}}so.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},so.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"background"};q.add(so);class hp{constructor(t){this.renderer=t,this.emptyRenderer=new Do(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:i}=this.renderer.texture;for(let s=e-1;s>=0;--s)t[s]=i[s]||null,t[s]&&(t[s]._batchLocation=s)}boundArray(t,e,i,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===i&&d._batchLocation===l){l++;continue}o[h]=l,c._batchLocation=l,e[l]=c;break}}}destroy(){this.renderer=null}}hp.extension={type:$.RendererSystem,name:"batch"};q.add(hp);let Eu=0;class no{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=Eu++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:i,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=Eu++,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 i;if(V.PREFER_ENV>=li.WEBGL2&&(i=t.getContext("webgl2",e)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,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(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=i||!!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")}}no.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},no.extension={type:$.RendererSystem,name:"context"};q.add(no);class ql{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 Te("disposeFramebuffer"),this.multisample=Ct.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new rt(null,{scaleMode:Je.NEAREST,resolution:1,mipmap:ze.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new rt(null,{scaleMode:Je.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:ze.OFF,format:N.DEPTH_COMPONENT,type:K.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 i=0;i<this.colorTextures.length;i++){const s=this.colorTextures[i],n=s.resolution;s.setSize(t/n,e/n)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class cp extends rt{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],s=arguments[2],n=arguments[3];t={width:e,height:i,scaleMode:s,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=Ct.NONE),super(null,t),this.mipmap=ze.OFF,this.valid=!0,this._clear=new ft([0,0,0,0]),this.framebuffer=new ql(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,315 bytes, line 380
380ight)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Sr extends Ps{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.width,s=e.naturalHeight||e.videoHeight||e.height;super(i,s),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=Pv(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,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===Zt.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&i.width===o&&i.height===a?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,i.type,s):(i.width=o,i.height=a,n.texImage2D(e.target,0,i.internalFormat,e.format,i.type,s)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class up extends Sr{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;Sr.crossOrigin(i,t,e.crossorigin),i.src=t,t=i}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??V.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,i)=>{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=>{i(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,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(s=>s.blob()).then(s=>e(s,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Zt.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,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let s=!0;const n=e._glTextures;for(const o in n){const a=n[o];if(a!==i&&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 $h{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,i){const s=e.width,n=e.height;if(i){const o=t.width/2/s,a=t.height/2/n,l=t.x/s+o,h=t.y/n+a;i=bt.add(i,bt.NW),this.x0=l+o*bt.uX(i),this.y0=h+a*bt.uY(i),i=bt.add(i,2),this.x1=l+o*bt.uX(i),this.y1=h+a*bt.uY(i),i=bt.add(i,2),this.x2=l+o*bt.uX(i),this.y2=h+a*bt.uY(i),i=bt.add(i,2),this.x3=l+o*bt.uX(i),this.y3=h+a*bt.uY(i)}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}}$h.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 Au=new $h;function Zs(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class Y extends ks{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new et(0,0,1,1)),t instanceof Y&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=Au,this.uvMatrix=null,this.orig=i||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 ct(o.x,o.y):new ct(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&&Be[e.url]&&Y.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,Y.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(),i=new Y(this.baseTexture,!this.noFrame&&t,e,this.trim?.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===Au&&(this._uvs=new $h),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=V.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof rt){if(!t.cacheId){const a=e?.pixiIdPrefix||"pixiid";t.cacheId=`${a}-${ni()}`,rt.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=e?.pixiIdPrefix||"pixiid";t._pixiId=`${a}_${ni()}`}n=t._pixiId}let o=Be[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof rt)?(e.resolution||(e.resolution=or(t)),o=new Y(new rt(t,e)),o.baseTexture.cacheId=n,rt.addToCache(o.baseTexture,n),Y.addToCache(o,n)):!o&&t instanceof rt&&(o=new Y(t),Y.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e?.resourceOptions),s=Y.from(t,Object.assign({resourceOptions:i},e),!1),n=s.baseTexture.resource;return s.baseTexture.valid?Promise.resolve(s):n.load().then(()=>Promise.resolve(s))}static fromBuffer(t,e,i,s){return new Y(rt.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new rt(t,Object.assign({scaleMode:rt.defaultOptions.scaleMode,resolution:or(e)},s)),{resource:o}=n;o instanceof up&&(o.url=e);const a=new Y(n);return i||(i=e),rt.addToCache(a.baseTexture,i),Y.addToCache(a,i),i!==e&&(rt.addToCache(a.baseTexture,e),Y.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),Be[e]&&Be[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),Be[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Be[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Be[t],e}}else if(t?.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)Be[t.textureCacheIds[e]]===t&&delete Be[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:i,width:s,height:n}=t,o=e+s>this.baseTexture.width,a=i+n>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${e} + ${s} = ${e+s} > ${this.baseTexture.width}`,c=`Y: ${i} + ${n} = ${i+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 Y._EMPTY||(Y._EMPTY=new Y(new rt),Zs(Y._EMPTY),Zs(Y._EMPTY.baseTexture)),Y._EMPTY}static get WHITE(){if(!Y._WHITE){const t=V.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),Y._WHITE=new Y(rt.from(t)),Zs(Y._WHITE),Zs(Y._WHITE.baseTexture)}return Y._WHITE}}class $t extends Y{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,i=!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,i&&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 $t(new cp(t))}}class dp{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=Ct.NONE){const s=new cp(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new $t(s)}getOptimalTexture(t,e,i=1,s=Ct.NONE){let n;t=Math.max(Math.ceil(t*i-1e-6),1),e=Math.max(Math.ceil(e*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=eo(t),e=eo(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(i),o}getFilterTexture(t,e,i){const s=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||Ct.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 i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[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 i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}dp.SCREEN_KEY=-1;class lb extends Ar{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class fp extends Ar{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 St(this.vertices),this.uvBuffer=new St(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,s=0;return this.uvs[0]=i,this.uvs[1]=s,this.uvs[2]=i+e.width/t.width,this.uvs[3]=s,this.uvs[4]=i+e.width/t.width,this.uvs[5]=s+e.height/t.height,this.uvs[6]=i,this.uvs[7]=s+e.height/t.height,i=e.x,s=e.y,this.vertices[0]=i,this.vertices[1]=s,this.vertices[2]=i+e.width,this.vertices[3]=s,this.vertices[4]=i+e.width,this.vertices[5]=s+e.height,this.vertices[6]=i,this.vertices[7]=s+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class hb{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=Ct.NONE,this.sourceFrame=new et,this.destinationFrame=new et,this.bindingSourceFrame=new et,this.bindingDestinationFrame=new et,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Ks=[new ct,new ct,new ct,new ct],Fa=new gt;class pp{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new dp,this.statePool=[],this.quad=new lb,this.quadUv=new fp,this.tempRect=new et,this.activeState={},this.globalUniforms=new Ee({outputFrame:new et,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 i=this.renderer,s=this.defaultFilterStack,n=this.statePool.pop()||new hb,o=i.renderTexture;let a,l;if(o.current){const g=o.current;a=g.resolution,l=g.multisample}else a=i.resolution,l=i.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 g=1;g<e.length;g++){const _=e[g];h=Math.min(h,_.resolution||a),c=Math.min(c,_.multisample??l),u=this.useMaxPadding?Math.max(u,_.padding):u+_.padding,d=d&&_.autoFit,f=f||(_.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);i.projection.transform&&this.transformAABB(Fa.copyFrom(i.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:i.resolution,o.sourceFrame,o.destinationFrame,i.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 m=this.tempRect;m.x=0,m.y=0,m.width=n.sourceFrame.width,m.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(o.sourceFrame),n.bindingDestinationFrame.copyFrom(o.destinationFrame),n.transform=i.projection.transform,i.projection.transform=null,o.bind(n.renderTexture,n.sourceFrame,m),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=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(),i.length===1)i[0].apply(this,e.renderTexture,l.renderTexture,Oe.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<i.length-1;++u){u===1&&e.multisample>1&&(c=this.getOptimalFilterTexture(h.width,h.height,e.resolution),c.filterFrame=h.filterFrame),i[u].apply(this,h,c,Oe.CLEAR,e);const d=h;h=c,c=d}i[u].apply(this,h,l.renderTexture,Oe.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=Oe.CLEAR){const{renderTexture:i,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,i.bind(t,t.filterFrame,o)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=s.stateId&1||this.forceClear;(e===Oe.CLEAR||e===Oe.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,s){const n=this.renderer;n.state.set(t.state),this.bindAndClear(i,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(Ge.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(Ge.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:s}=this.activeState,{orig:n}=e._texture,o=t.set(s.width,0,0,s.height,i.x,i.y),a=e.worldTransform.copyTo(gt.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,i=1,s=Ct.NONE){return this.texturePool.getOptimalTexture(t,e,i,s)}getFilterTexture(t,e,i){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,i||Ct.NONE);return s.filterFrame=t.filterFrame,s}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}
vendor: 5,277 bytes, line 380
380resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=Ks[0],s=Ks[1],n=Ks[2],o=Ks[3];i.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(i,i),t.apply(s,s),t.apply(n,n),t.apply(o,o);const a=Math.min(i.x,s.x,n.x,o.x),l=Math.min(i.y,s.y,n.y,o.y),h=Math.max(i.x,s.x,n.x,o.x),c=Math.max(i.y,s.y,n.y,o.y);e.x=a,e.y=l,e.width=h-a,e.height=c-l}roundFrame(t,e,i,s,n){if(!(t.width<=0||t.height<=0||i.width<=0||i.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?Fa.copyFrom(n):Fa.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}pp.extension={type:$.RendererSystem,name:"filter"};q.add(pp);class cb{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Ct.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const ub=new et;class _p{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new ql(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 et,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;V.PREFER_ENV===li.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=s=>e.drawBuffersWEBGL(s):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,i=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!==i&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=i),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):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>>i,a=e.height>>i,l=o/e.width;this.setViewport(e.x*l,e.y*l,o,a)}else{const o=t.width>>i,a=t.height>>i;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,i,s){const n=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),s=Math.round(s),(n.width!==i||n.height!==s||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=i,n.height=s,this.gl.viewport(t,e,i,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,i,s,n=xl.COLOR|xl.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,s),o.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new cb(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){e.bindRenderbuffer(e.RENDERBUFFER,i.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,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.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&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.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:i}=this,s=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let o=n.length;i.drawBuffers||(o=Math.min(o,1)),s.multisample>1&&this.canMultisampleFramebuffer(t)?s.msaaBuffer=s.msaaBuffer||i.createRenderbuffer():s.msaaBuffer&&(i.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?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,c._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,s.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,c._glTextures[this.CONTEXT_UID].texture,e),a.push(i.COLOR_ATTACHMENT0+l))}
vendor: 2,294 bytes, line 380
380if(a.length>1&&i.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const l=t.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH_STENCIL):t.depth&&t.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH24_STENCIL8):t.depth?(l=i.DEPTH_ATTACHMENT,h=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,h=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,h,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,h,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,s.stencil)}else s.stencil&&(i.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 i=Ct.NONE;if(t<=1||e===null)return i;for(let s=0;s<e.length;s++)if(e[s]<=t){i=e[s];break}return i===1&&(i=Ct.NONE),i}blit(t,e,i){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 ql(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=ub,e.width=s.width,e.height=s.height),i||(i=e);const h=e.width===i.width&&e.height===i.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.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 i=t.glFramebuffers[this.CONTEXT_UID],s=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>
vendor: 7,862 bytes, lines 380-397
380=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(s.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&s.deleteRenderbuffer(i.msaaBuffer),i.stencil&&s.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],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 i=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,i,s):n.renderbufferStorage(n.RENDERBUFFER,l,i,s),n.framebufferRenderbuffer(n.FRAMEBUFFER,a,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new et}destroy(){this.renderer=null}}_p.extension={type:$.RendererSystem,name:"framebuffer"};q.add(_p);const Oa={5126:4,5123:2,5121:1};class mp{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 i=this.renderer.context.extensions.vertexArrayObject;V.PREFER_ENV===li.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=s=>i.bindVertexArrayOES(s),t.deleteVertexArray=s=>i.deleteVertexArrayOES(s)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n),t.drawElementsInstanced=(s,n,o,a,l)=>i.drawElementsInstancedANGLE(s,n,o,a,l),t.drawArraysInstanced=(s,n,o,a)=>i.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:i}=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?i.bindVertexArray(o):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.update(s)}}checkCompatibility(t,e){const i=t.attributes,s=e.attributeData;for(const n in s)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,s=e.attributeData,n=["g",t.id];for(const o in i)s[o]&&n.push(o,s[o].location);return n.join("-")}initGeometryVao(t,e,i=!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 m in u)f[m]=0,p[m]=0;for(const m in d)!d[m].size&&a.attributeData[m]?d[m].size=a.attributeData[m].size:d[m].size||console.warn(`PIXI Geometry attribute '${m}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[m].buffer]+=d[m].size*Oa[d[m].type];for(const m in d){const g=d[m],_=g.size;g.stride===void 0&&(f[g.buffer]===_*Oa[g.type]?g.stride=0:g.stride=f[g.buffer]),g.start===void 0&&(g.start=p[g.buffer],p[g.buffer]+=_*Oa[g.type])}c=s.createVertexArray(),s.bindVertexArray(c);for(let m=0;m<u.length;m++){const g=u[m];o.bind(g),i&&g._glBuffers[n].refCount++}return this.activateVao(t,a),h[a.id]=c,h[l]=c,s.bindVertexArray(null),o.unbind(He.ARRAY_BUFFER),c}disposeGeometry(t,e){if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,n=t.buffers,o=this.renderer?.buffer;if(t.disposeRunner.remove(this),!!i){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 i)if(a[0]==="g"){const l=i[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 i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=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(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,c.size,c.type||i.FLOAT,c.normalized,c.stride,c.start),c.instance)if(this.hasInstance)i.vertexAttribDivisor(f,c.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,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,(i||0)*a,s||1):n.drawElements(t,e||o.indexBuffer.data.length,l,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?n.drawArraysInstanced(t,i,e||o.getSize(),s||1):n.drawArrays(t,i,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}mp.extension={type:$.RendererSystem,name:"geometry"};q.add(mp);const Su=new gt;class gp{constructor(t,e){this._texture=t,this.mapCoord=new gt,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 i=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],o=t[s+1];e[s]=n*i.a+o*i.c+i.tx,e[s+1]=n*i.b+o*i.d+i.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 i=e._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const s=e.orig,n=e.trim;n&&(Su.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Su));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 db=`varying vec2 vMaskCoord; 381varying vec2 vTextureCoord; 382 383uniform sampler2D uSampler; 384uniform sampler2D mask; 385uniform float alpha; 386uniform float npmAlpha; 387uniform vec4 maskClamp; 388 389void main(void) 390{ 391 float clip = step(3.5, 392 step(maskClamp.x, vMaskCoord.x) + 393 step(maskClamp.y, vMaskCoord.y) + 394 step(vMaskCoord.x, maskClamp.z) + 395 step(vMaskCoord.y, maskClamp.w)); 396 397 vec4 original = texture2D(uSampler, vTextureCoord);
398 vec4 masky = texture2D(mask, vMaskCoord); 399 float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a); 400 401 original *= (alphaMul * masky.r * alpha * clip); 402 403 gl_FragColor = original; 404} 405`,fb=`attribute vec2 aVertexPosition; 406attribute vec2 aTextureCoord; 407 408uniform mat3 projectionMatrix; 409uniform mat3 otherMatrix; 410 411varying vec2 vMaskCoord; 412varying vec2 vTextureCoord; 413 414void main(void) 415{ 416 gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); 417 418 vTextureCoord = aTextureCoord; 419 vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy; 420} 421`;class pb extends Gt{constructor(t,e,i){let s=null;typeof t!="string"&&e===void 0&&i===void 0&&(s=t,t=void 0,e=void 0,i=void 0),super(t||fb,e||db,i),this.maskSprite=s,this.maskMatrix=new gt}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,s){const n=this._maskSprite,o=n._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new gp(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,i,s))}}class _b{constructor(t=null){this.type=It.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Gt.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=It.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 yp{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 i=e;if(!i.isMaskData){const n=this.maskDataPool.pop()||new _b;n.pooled=!0,n.maskObject=e,i=n}const s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(s),i._colorMask=s?s._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==It.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case It.SCISSOR:this.renderer.scissor.push(i);break;case It.STENCIL:this.renderer.stencil.push(i);break;case It.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case It.COLOR:this.pushColorMask(i);break}i.type===It.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case It.SCISSOR:this.renderer.scissor.pop(e);break;case It.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case It.SPRITE:this.popSpriteMask(e);break;case It.COLOR:this.popColorMask(e);break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===It.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=It.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=It.SCISSOR:t.type=It.STENCIL:t.type=It.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let s=t._filters;s||(s=this.alphaMaskPool[this.alphaMaskIndex],s||(s=this.alphaMaskPool[this.alphaMaskIndex]=[new pb])),s[0].resolution=t.resolution,s[0].multisample=t.multisample,s[0].maskSprite=e;const n=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,s),i.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,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}yp.extension={type:$.RendererSystem,name:"mask"};q.add(yp);class vp{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,i=this.getStackLength();this.maskStack=t;const s=this.getStackLength();s!==i&&(s===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const Cu=new gt,Iu=[],bp=class Tn extends vp{constructor(t){super(t),this.glConst=V.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}
vendor: 30,533 bytes, lines 421-491
421calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:i}=t,{renderer:s}=this,n=s.renderTexture,o=i.getBounds(!0,Iu.pop()??new et);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:i,c:s,d:n}=t;return(Math.abs(i)>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()||Tn.isMatrixRotated(e.worldTransform)||Tn.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,e,i,s,n){Tn.isMatrixRotated(n)||(n=n?Cu.copyFrom(n):Cu.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.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&&Iu.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)}};bp.extension={type:$.RendererSystem,name:"scissor"};let mb=bp;q.add(mb);class xp extends vp{constructor(t){super(t),this.glConst=V.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:i}=this.renderer,s=t._stencilCounter;s===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,s,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,i.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 i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,s=i?i._colorMask:15;s!==0&&(i._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&&(i._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)}}xp.extension={type:$.RendererSystem,name:"stencil"};q.add(xp);class wp{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return nt("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return nt("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return nt("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}}wp.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"_plugin"};q.add(wp);class Tp{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new gt,this.transform=null}update(t,e,i,s){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,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,i,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}}Tp.extension={type:$.RendererSystem,name:"projection"};q.add(Tp);const gb=new Hh,Ru=new et;class Ep{constructor(t){this.renderer=t,this._tempMatrix=new gt}generateTexture(t,e){const{region:i,...s}=e||{},n=i?.copyTo(Ru)||t.getLocalBounds(Ru,!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=$t.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=gb,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}Ep.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"textureGenerator"};q.add(Ep);const Lr=new et,as=new et;class Ap{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new et,this.destinationFrame=new et,this.viewportFrame=new et}contextChange(){const t=this.renderer?.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,i){const s=this.renderer;this.current=t;let n,o,a;t?(n=t.baseTexture,a=n.resolution,e||(Lr.width=t.frame.width,Lr.height=t.frame.height,e=Lr),i||(as.x=t.frame.x,as.y=t.frame.y,as.width=e.width,as.height=e.height,i=as),o=n.framebuffer):(a=s.resolution,e||(Lr.width=s._view.screen.width,Lr.height=s._view.screen.height,e=Lr),i||(i=Lr,i.width=e.width,i.height=e.height));const l=this.viewportFrame;l.x=i.x*a,l.y=i.y*a,l.width=i.width*a,l.height=i.height*a,t||(l.y=s.view.height-(l.y+l.height)),l.ceil(),this.renderer.framebuffer.bind(o,l),this.renderer.projection.update(i,e,a,!o),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(i)}clear(t,e){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,s=ft.shared.setValue(t||i);(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}}Ap.extension={type:$.RendererSystem,name:"renderTexture"};q.add(Ap);class yb{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 vb(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){const n=t.getActiveAttrib(r,s);if(n.name.startsWith("gl_"))continue;const o=lp(t,n.type),a={type:o,name:n.name,size:ap(o),location:t.getAttribLocation(r,n.name)};e[n.name]=a}return e}function bb(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let s=0;s<i;s++){const n=t.getActiveUniform(r,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=lp(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:np(l,n.size)}}return e}function xb(r,t){const e=bu(r,r.VERTEX_SHADER,t.vertexSrc),i=bu(r,r.FRAGMENT_SHADER,t.fragmentSrc),s=r.createProgram();r.attachShader(s,e),r.attachShader(s,i);const n=t.extra?.transformFeedbackVaryings;if(n&&(typeof r.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||Zv(r,s,e,i),t.attributeData=vb(s,r),t.uniformData=bb(s,r),!/^[ \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,r.bindAttribLocation(s,l,a[l]);r.linkProgram(s)}r.deleteShader(e),r.deleteShader(i);const o={};for(const a in t.uniformData){const l=t.uniformData[a];o[a]={location:r.getUniformLocation(s,a),value:np(l.type,l.size)}}return new yb(s,o)}function wb(r,t,e,i,s){e.buffer.update(s)}const Tb={float:` 422 data[offset] = v; 423 `,vec2:` 424 data[offset] = v[0]; 425 data[offset+1] = v[1]; 426 `,vec3:` 427 data[offset] = v[0]; 428 data[offset+1] = v[1]; 429 data[offset+2] = v[2]; 430 431 `,vec4:` 432 data[offset] = v[0]; 433 data[offset+1] = v[1]; 434 data[offset+2] = v[2]; 435 data[offset+3] = v[3]; 436 `,mat2:` 437 data[offset] = v[0]; 438 data[offset+1] = v[1]; 439 440 data[offset+4] = v[2]; 441 data[offset+5] = v[3]; 442 `,mat3:` 443 data[offset] = v[0]; 444 data[offset+1] = v[1]; 445 data[offset+2] = v[2]; 446 447 data[offset + 4] = v[3]; 448 data[offset + 5] = v[4]; 449 data[offset + 6] = v[5]; 450 451 data[offset + 8] = v[6]; 452 data[offset + 9] = v[7]; 453 data[offset + 10] = v[8]; 454 `,mat4:` 455 for(var i = 0; i < 16; i++) 456 { 457 data[offset + i] = v[i]; 458 } 459 `},Sp={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 Eb(r){const t=r.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,i=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(e=Sp[o.data.type],o.data.size>1&&(e=Math.max(e,16)*o.data.size),o.dataLen=e,i%e!==0&&i<16){const a=i%e%16;i+=a,s+=a}i+e>16?(s=Math.ceil(s/16)*16,o.offset=s,s+=e,i=e):(o.offset=s,i+=e,s+=e)}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}function Ab(r,t){const e=[];for(const i in r)t[i]&&e.push(t[i]);return e.sort((i,s)=>i.index-s.index),e}function Sb(r,t){if(!r.autoManage)return{size:0,syncFunc:wb};const e=Ab(r.uniforms,t),{uboElements:i,size:s}=Eb(e),n=[` 460 var v = null; 461 var v2 = null; 462 var cv = null; 463 var t = 0; 464 var gl = renderer.gl 465 var index = 0; 466 var data = buffer.data; 467 `];for(let o=0;o<i.length;o++){const a=i[o],l=r.uniforms[a.data.name],h=a.data.name;let c=!1;for(let u=0;u<Li.length;u++){const d=Li[u];if(d.codeUbo&&d.test(a.data,l)){n.push(`offset = ${a.offset/4};`,Li[u].codeUbo(a.data.name,l)),c=!0;break}}if(!c)if(a.data.size>1){const u=ap(a.data.type),d=Math.max(Sp[a.data.type]/16,1),f=u/d,p=(4-f%4)%4;n.push(` 468 cv = ud.${h}.value; 469 v = uv.${h}; 470 offset = ${a.offset/4}; 471 472 t = 0; 473 474 for(var i=0; i < ${a.data.size*d}; i++) 475 { 476 for(var j = 0; j < ${f}; j++) 477 { 478 data[offset++] = v[t++]; 479 } 480 offset += ${p}; 481 } 482 483 `)}else{const u=Tb[a.data.type];n.push(` 484 cv = ud.${h}.value; 485 v = uv.${h}; 486 offset = ${a.offset/4}; 487 ${u}; 488 `)}}return n.push(` 489 renderer.buffer.update(buffer); 490 `),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(` 491`))}}let Cb=0;const Js={textureCount:0,uboCount:0};class Cp{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=Cb++}systemCheck(){if(!Jv())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 i=t.program,s=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(s.program)),e||(Js.textureCount=0,Js.uboCount=0,this.syncUniformGroup(t.uniformGroup,Js)),s}setUniforms(t){const e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=jv(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const s=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),s(i.uniformData,t.uniforms,this.renderer,Js,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=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]=Sb(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,i){const s=t.uniforms,n=[`${i}-`];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,i=t.program,s=xb(e,i);return i.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}}Cp.extension={type:$.RendererSystem,name:"shader"};q.add(Cp);class oo{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(){}}oo.defaultOptions={hello:!1},oo.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"startup"};q.add(oo);function Ib(r,t=[]){return t[Q.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.ADD]=[r.ONE,r.ONE],t[Q.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.NONE]=[0,0],t[Q.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[Q.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Q.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[Q.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[Q.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[Q.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[Q.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[Q.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[Q.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[Q.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[Q.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const Rb=0,Pb=1,Mb=2,kb=3,Bb=4,Db=5,Ip=class Zl{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=Q.NONE,this._blendEq=!1,this.map=[],this.map[Rb]=this.setBlend,this.map[Pb]=this.setOffset,this.map[Mb]=this.setCullFace,this.map[kb]=this.setDepthTest,this.map[Bb]=this.setFrontFace,this.map[Db]=this.setDepthMask,this.checks=[],this.defaultState=new Xe,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=Ib(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;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(Zl.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Zl.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],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.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 i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};Ip.extension={type:$.RendererSystem,name:"state"};let Fb=Ip;q.add(Fb);class Ob extends ks{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(s=>t.systems[s]),i=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(const s of i)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Te(e)})}addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach(s=>{const n=i.find(o=>this._systemsHash[o]===s);s[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const _s=class En{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=En.defaultMaxIdle,this.checkCountMax=En.defaultCheckCountMax,this.mode=En.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Mh.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let i=!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,i=!0)}if(i){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,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};_s.defaultMode=Mh.AUTO,_s.defaultMaxIdle=60*60,_s.defaultCheckCountMax=60*10,_s.extension={type:$.RendererSystem,name:"textureGC"};let Yr=_s;q.add(Yr);class Na{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=K.UNSIGNED_BYTE,this.internalFormat=N.RGBA,this.samplerType=0}}function Nb(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:X.FLOAT,[r.RGBA]:X.FLOAT,[r.ALPHA]:X.FLOAT,[r.LUMINANCE]:X.FLOAT,[r.LUMINANCE_ALPHA]:X.FLOAT,[r.R8]:X.FLOAT,[r.R8_SNORM]:X.FLOAT,[r.RG8]:X.FLOAT,[r.RG8_SNORM]:X.FLOAT,[r.RGB8]:X.FLOAT,[r.RGB8_SNORM]:X.FLOAT,[r.RGB565]:X.FLOAT,[r.RGBA4]:X.FLOAT,[r.RGB5_A1]:X.FLOAT,[r.RGBA8]:X.FLOAT,[r.RGBA8_SNORM]:X.FLOAT,[r.RGB10_A2]:X.FLOAT,[r.RGB10_A2UI]:X.FLOAT,[r.SRGB8]:X.FLOAT,[r.SRGB8_ALPHA8]:X.FLOAT,[r.R16F]:X.FLOAT,[r.RG16F]:X.FLOAT,[r.RGB16F]:X.FLOAT,[r.RGBA16F]:X.FLOAT,[r.R32F]:X.FLOAT,[r.RG32F]:X.FLOAT,[r.RGB32F]:X.FLOAT,[r.RGBA32F]:X.FLOAT,[r.R11F_G11F_B10F]:X.FLOAT,[r.RGB9_E5]:X.FLOAT,[r.R8I]:X.INT,[r.R8UI]:X.UINT,[r.R16I]:X.INT,[r.R16UI]:X.UINT,[r.R32I]:X.INT,[r.R32UI]:X.UINT,[r.RG8I]:X.INT,[r.RG8UI]:X.UINT,[r.RG16I]:X.INT,[r.RG16UI]:X.UINT,[r.RG32I]:X.INT,[r.RG32UI]:X.UINT,[r.RGB8I]:X.INT,[r.RGB8UI]:X.UINT,[r.RGB16I]:X.INT,[r.RGB16UI]:X.UINT,[r.RGB32I]:X.INT,[r.RGB32UI]:X.UINT,[r.RGBA8I]:X.INT,[r.RGBA8UI]:X.UINT,[r.RGBA16I]:X.INT,[r.RGBA16UI]:X.UINT,[r.RGBA32I]:X.INT,[r.RGBA32UI]:X.UINT,[r.DEPTH_COMPONENT16]:X.FLOAT,[r.DEPTH_COMPONENT24]:X.FLOAT,[r.DEPTH_COMPONENT32F]:X.FLOAT,[r.DEPTH_STENCIL]:X.FLOAT,[r.DEPTH24_STENCIL8]:X.FLOAT,[r.DEPTH32F_STENCIL8]:X.FLOAT}:t={[r.RGB]:X.FLOAT,[r.RGBA]:X.FLOAT,[r.ALPHA]:X.FLOAT,[r.LUMINANCE]:X.FLOAT,[r.LUMINANCE_ALPHA]:X.FLOAT,[r.DEPTH_STENCIL]:X.FLOAT},t}function Lb(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[K.UNSIGNED_BYTE]:{[N.RGBA]:r.RGBA8,[N.RGB]:r.RGB8,[N.RG]:r.RG8,[N.RED]:r.R8,[N.RGBA_INTEGER]:r.RGBA8UI,[N.RGB_INTEGER]:r.RGB8UI,[N.RG_INTEGER]:r.RG8UI,[N.RED_INTEGER]:r.R8UI,[N.ALPHA]:r.ALPHA,[N.LUMINANCE]:r.LUMINANCE,[N.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[K.BYTE]:{[N.RGBA]:r.RGBA8_SNORM,[N.RGB]:r.RGB8_SNORM,[N.RG]:r.RG8_SNORM,[N.RED]:r.R8_SNORM,[N.RGBA_INTEGER]:r.RGBA8I,[N.RGB_INTEGER]:r.RGB8I,[N.RG_INTEGER]:r.RG8I,[N.RED_INTEGER]:r.R8I},[K.UNSIGNED_SHORT]:{[N.RGBA_INTEGER]:r.RGBA16UI,[N.RGB_INTEGER]:r.RGB16UI,[N.RG_INTEGER]:r.RG16UI,[N.RED_INTEGER]:r.R16UI,[N.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[K.SHORT]:{[N.RGBA_INTEGER]:r.RGBA16I,[N.RGB_INTEGER]:r.RGB16I,[N.RG_INTEGER]:r.RG16I,[N.RED_INTEGER]:r.R16I},[K.UNSIGNED_INT]:{[N.RGBA_INTEGER]:r.RGBA32UI,[N.RGB_INTEGER]:r.RGB32UI,[N.RG_INTEGER]:r.RG32UI,[N.RED_INTEGER]:r.R32UI,[N.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[K.INT]:{[N.RGBA_INTEGER]:r.RGBA32I,[N.RGB_INTEGER]:r.RGB32I,[N.RG_INTEGER]:r.RG32I,[N.RED_INTEGER]:r.R32I},[K.FLOAT]:{[N.RGBA]:r.RGBA32F,[N.RGB]:r.RGB32F,[N.RG]:r.RG32F,[N.RED]:r.R32F,[N.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[K.HALF_FLOAT]:{[N.RGBA]:r.RGBA16F,[N.RGB]:r.RGB16F,[N.RG]:r.RG16F,[N.RED]:r.R16F},[K.UNSIGNED_SHORT_5_6_5]:{[N.RGB]:r.RGB565},[K.UNSIGNED_SHORT_4_4_4_4]:{[N.RGBA]:r.RGBA4},[K.UNSIGNED_SHORT_5_5_5_1]:{[N.RGBA]:r.RGB5_A1},[K.UNSIGNED_INT_2_10_10_10_REV]:{[N.RGBA]:r.RGB10_A2,[N.RGBA_INTEGER]:r.RGB10_A2UI},[K.UNSIGNED_INT_10F_11F_11F_REV]:{[N.RGB]:r.R11F_G11F_B10F},[K.UNSIGNED_INT_5_9_9_9_REV]:{[N.RGB]:r.RGB9_E5},[K.UNSIGNED_INT_24_8]:{[N.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[K.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[N.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[K.UNSIGNED_BYTE]:{[N.RGBA]:r.RGBA,[N.RGB]:r.RGB,[N.ALPHA]:r.ALPHA,[N.LUMINANCE]:r.LUMINANCE,[N.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[K.UNSIGNED_SHORT_5_6_5]:{[N.RGB]:r.RGB},[K.UNSIGNED_SHORT_4_4_4_4]:{[N.RGBA]:r.RGBA},[K.UNSIGNED_SHORT_5_5_5_1]:{[N.RGBA]:r.RGBA}},t}class Rp{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new rt,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=Lb(t),this.samplerTypes=Nb(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 i=new Na(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.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]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Na(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:i}=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,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.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:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[s].samplerType!==X.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new Na(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]??X.FLOAT,this.webGLVersion===2&&t.type===K.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 i=this.renderer;if(this.initTextureType(t,e),t.resource?.upload(i,t,e))e.samplerType!==X.FLOAT&&(this.hasIntegerTextures=!0);else{const s=t.realWidth,n=t.realHeight,o=i.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:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.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&&Ni(this.managedTextures,s,1)}}updateTextureStyle(t){const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===ze.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Tr.CLAMP:e.wrapMode=t.wrapMode,t.resource?.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const i=this.gl;if(e.mipmap&&t.mipmap!==ze.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Je.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===Je.LINEAR){const n=Math.min(t.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Je.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===Je.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Rp.extension={type:$.RendererSystem,name:"texture"};q.add(Rp);class Pp{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:i}=this,s=t._glTransformFeedbacks[i]||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:i,renderer:s}=this;e&&s.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,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&&(i.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 i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;
491t.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))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Pp.extension={type:$.RendererSystem,name:"transformFeedback"};q.add(Pp);class ao{constructor(t){this.renderer=t}init(t){this.screen=new et(0,0,t.width,t.height),this.element=t.view||V.ADAPTER.createCanvas(),this.resolution=t.resolution||V.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 i=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",i,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}}ao.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},ao.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"_view"};q.add(ao);V.PREFER_ENV=li.WEBGL2;V.STRICT_TEXTURE_CACHE=!1;V.RENDER_OPTIONS={...no.defaultOptions,...so.defaultOptions,...ao.defaultOptions,...oo.defaultOptions};Object.defineProperties(V,{WRAP_MODE:{get(){return rt.defaultOptions.wrapMode},set(r){nt("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),rt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return rt.defaultOptions.scaleMode},set(r){nt("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),rt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return rt.defaultOptions.mipmap},set(r){nt("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),rt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return rt.defaultOptions.anisotropicLevel},set(r){nt("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),rt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return nt("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Gt.defaultResolution},set(r){Gt.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return nt("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Gt.defaultMultisample},set(r){Gt.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return jr.defaultMaxTextures},set(r){nt("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),jr.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return jr.defaultBatchSize},set(r){nt("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),jr.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return jr.canUploadSameBuffer},set(r){nt("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),jr.canUploadSameBuffer=r}},GC_MODE:{get(){return Yr.defaultMode},set(r){nt("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Yr.defaultMode=r}},GC_MAX_IDLE:{get(){return Yr.defaultMaxIdle},set(r){nt("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Yr.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return Yr.defaultCheckCountMax},set(r){nt("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Yr.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return er.defaultVertexPrecision},set(r){nt("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),er.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return er.defaultFragmentPrecision},set(r){nt("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),er.defaultFragmentPrecision=r}}});var oi=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(oi||{});class La{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,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 491-500
491next,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 Mp=class Qt{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 La(null,null,1/0),this.deltaMS=1/Qt.targetFPMS,this.elapsedMS=1/Qt.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,i=oi.NORMAL){return this._addListener(new La(t,e,i))}addOnce(t,e,i=oi.NORMAL){return this._addListener(new La(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.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*Qt.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this.deltaTime);i.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),i=Math.min(Math.max(0,e)/1e3,Qt.targetFPMS);this._maxElapsedMS=1/i}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(!Qt._shared){const t=Qt._shared=new Qt;t.autoStart=!0,t._protected=!0}return Qt._shared}static get system(){if(!Qt._system){const t=Qt._system=new Qt;t.autoStart=!0,t._protected=!0}return Qt._system}};Mp.targetFPMS=.06;let ie=Mp;Object.defineProperties(V,{TARGET_FPMS:{get(){return ie.targetFPMS},set(r){nt("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),ie.targetFPMS=r}}});class kp{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,oi.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?ie.shared:new ie,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}kp.extension=$.Application;q.add(kp);const Bp=[];q.handleByList($.Renderer,Bp);function Ub(r){for(const t of Bp)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var Gb=`attribute vec2 aVertexPosition; 492attribute vec2 aTextureCoord; 493 494uniform mat3 projectionMatrix; 495 496varying vec2 vTextureCoord; 497 498void main(void) 499{ 500 gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0
500)).xy, 0.0, 1.0); 501 vTextureCoord = aTextureCoord; 502}`,Hb=`attribute vec2 aVertexPosition; 503 504uniform mat3 projectionMatrix; 505 506varying vec2 vTextureCoord; 507 508uniform vec4 inputSize; 509uniform vec4 outputFrame; 510 511vec4 filterVertexPosition( void ) 512{ 513 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 514 515 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 516} 517 518vec2 filterTextureCoord( void ) 519{ 520 return aVertexPosition * (outputFrame.zw * inputSize.zw); 521} 522 523void main(void) 524{ 525 gl_Position = filterVertexPosition(); 526 vTextureCoord = filterTextureCoord(); 527} 528`;const $b=Gb,Dp=Hb;class Fp{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=Ct.HIGH?this.multisample=Ct.HIGH:e>=Ct.MEDIUM?this.multisample=Ct.MEDIUM:e>=Ct.LOW?this.multisample=Ct.LOW:this.multisample=Ct.NONE}destroy(){}}Fp.extension={type:$.RendererSystem,name:"_multisample"};q.add(Fp);class zb{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Op{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:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,i){const{gl:s,CONTEXT_UID:n}=this;i=i||0;const o=t._glBuffers[n]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,o.buffer,i*256,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||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 i=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),i&&(e||s.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new zb(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Op.extension={type:$.RendererSystem,name:"buffer"};q.add(Op);class Np{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let s,n,o,a;if(e&&(s=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(s||(this.lastObjectRendered=t),!a){const l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(s),i.batch.currentRenderer.start(),(n??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),s&&(e.blit&&i.framebuffer.blit(),s.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Np.extension={type:$.RendererSystem,name:"objectRenderer"};q.add(Np);const An=class Kl extends Ob{constructor(t){super(),this.type=Cf.WEBGL,t=Object.assign({},V.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new Ee({projectionMatrix:new gt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Kl.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};
528this.setup(e),"useContextAlpha"in t&&(nt("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=Kl.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t?.forceCanvas?!1:dv()}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 nt("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return nt("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return nt("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return nt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){nt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return nt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){nt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return nt("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)}};An.extension={type:$.Renderer,priority:1},An.__plugins={},An.__systems={};let zh=An;
vendor: 5,917 bytes, line 528
528q.handleByMap($.RendererPlugin,zh.__plugins);q.handleByMap($.RendererSystem,zh.__systems);q.add(zh);class Lp extends Ps{constructor(t,e){const{width:i,height:s}=e||{};super(i,s),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const o=new rt;this.items.push(o),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof Ps?this.addResourceAt(t[i],i):this.addResourceAt(rp(t[i],e),i))}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:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}}class Xb extends Lp{constructor(t,e){const{width:i,height:s}=e||{};let n,o;Array.isArray(t)?(n=t,o=t.length):o=t,super(o,{width:i,height:s}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=Di.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:s,itemDirtyIds:n,items:o}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,e.format,i.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,i.type,h.resource.source))}return!0}}class Vb extends Sr{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Up=class ms extends Lp{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==ms.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<ms.SIDES;a++)this.items[a].target=Di.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=Di.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=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=Di.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,i){const s=this.itemDirtyIds;for(let n=0;n<ms.SIDES;n++){const o=this.items[n];(s[n]<o.dirtyId||i.dirtyId<e.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(t,o,i),s[n]=o.dirtyId):s[n]<-1&&(t.gl.texImage2D(o.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),s[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===ms.SIDES}};Up.SIDES=6;let Wb=Up;class ki extends Sr{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=ki.EMPTY,s=t,n=!0):(i=t,s=null,n=!1),super(i),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 i=await V.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Zt.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(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 ki._EMPTY=ki._EMPTY??V.ADAPTER.createCanvas(0,0),ki._EMPTY}}const Jl=class Sn extends Sr{constructor(t,e){e=e||{},super(V.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)},Sn.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;Sr.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>
vendor: 17,053 bytes, line 528
528{if(!this._resolve)return;const e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,n=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*e,n=this._overrideHeight||this._overrideWidth/e*i),s=Math.round(s),n=Math.round(n);const o=this.source;o.width=s,o.height=n,o._pixiId=`canvas_${ni()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=Sn.SVG_SIZE.exec(t),i={};return e&&(i[e[1]]=Math.round(parseFloat(e[3])),i[e[5]]=Math.round(parseFloat(e[7]))),i}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"&&Sn.SVG_XML.test(t)}};Jl.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Jl.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Ql=Jl;const th=class eh extends Sr{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const s=t[0].src||t[0];Sr.crossOrigin(i,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||eh.MIME_TYPES[c]||`video/${c}`}o.src=a,l&&(o.type=l),i.appendChild(o)}t=i}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=ie.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,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,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&&(ie.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||(ie.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ie.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||eh.TYPES.includes(e)}};th.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],th.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Gp=th;Hl.push(ki,up,Vb,Gp,Ql,Po,Wb,Xb);class lo{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?et.EMPTY:(t=t||new et(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:i,b:s,c:n,d:o,tx:a,ty:l}=t,h=i*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,i=this.minY,s=this.maxX,n=this.maxY,o=t[0],a=t[1];e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[2],a=t[3],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[4],a=t[5],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[6],a=t[7],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,this.minX=e,this.minY=i,this.maxX=s,this.maxY=n}addFrame(t,e,i,s,n){this.addFrameMatrix(t.worldTransform,e,i,s,n)}addFrameMatrix(t,e,i,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,m=this.maxY,g=o*e+l*i+c,_=a*e+h*i+u;d=g<d?g:d,f=_<f?_:f,p=g>p?g:p,m=_>m?_:m,g=o*s+l*i+c,_=a*s+h*i+u,d=g<d?g:d,f=_<f?_:f,p=g>p?g:p,m=_>m?_:m,g=o*e+l*n+c,_=a*e+h*n+u,d=g<d?g:d,f=_<f?_:f,p=g>p?g:p,m=_>m?_:m,g=o*s+l*n+c,_=a*s+h*n+u,d=g<d?g:d,f=_<f?_:f,p=g>p?g:p,m=_>m?_:m,this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}addVertexData(t,e,i){let s=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let l=e;l<i;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,i,s){this.addVerticesMatrix(t.worldTransform,e,i,s)}addVerticesMatrix(t,e,i,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,m=this.maxX,g=this.maxY;for(let _=i;_<s;_+=2){const v=e[_],y=e[_+1],b=a*v+h*y+u,x=c*y+l*v+d;f=Math.min(f,b-n),m=Math.max(m,b+n),p=Math.min(p,x-o),g=Math.max(g,x+o)}this.minX=f,this.minY=p,this.maxX=m,this.maxY=g}addBounds(t){const e=this.minX,i=this.minY,s=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>s?t.maxX:s,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const i=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(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i: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 i=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(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i: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,i,s,n,o){t-=n,e-=o,i+=n,s+=o,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>s?this.maxY:s}}class wt extends ks{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Hh,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 lo,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 i=0;i<e.length;++i){const s=e[i];Object.defineProperty(wt.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 et),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new et),t=this._localBoundsRect),this._localBounds||(this._localBounds=new lo);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=i?.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=i,this.transform=e,this._bounds=s,this._bounds.updateID+=this._boundsID-n,o}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,s){return e&&(t=e.toGlobal(t,i,s)),s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}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,i=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=i||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 jb),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*Gv}set angle(t){this.transform.rotation=t*Hv}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 jb extends wt{constructor(){super(...arguments),this.sortDirty=null}}wt.prototype.displayObjectUpdateTransform=wt.prototype.updateTransform;const Yb=new gt;function qb(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const Hp=class rh extends wt{constructor(){super(),this.children=[],this.sortableChildren=rh.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("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 i=this.getChildIndex(t),s=this.getChildIndex(e);this.children[i]=e,this.children[s]=t,this.onChildrenChange(i<s?i: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 i=this.getChildIndex(t);Ni(this.children,i,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],i=this.children.indexOf(e);if(i===-1)return null;e.parent=null,e.transform._parentID=-1,Ni(this.children,i,1),this._boundsID++,this.onChildrenChange(i),e.emit("removed",this),this.emit("childRemoved",e,this,i)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,Ni(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 i=t,s=e,n=s-i;let o;if(n>0&&n<=s){o=this.children.splice(i,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;
vendor: 17,648 bytes, lines 528-570
528++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,i=this.children.length;e<i;++e){const s=this.children[e];s._lastSortedIndex=e,!t&&s.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(qb),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 i=this.children[t];i.visible&&i.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 i=e._mask.isMaskData?e._mask.maskObject:e._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(e._bounds,i._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 i=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 i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,s;this.cullArea?(i=this.cullArea,s=this.worldTransform):this._render!==rh.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=Yb.copyFrom(s),s.prepend(n)):s=n),i&&e.intersects(i,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,i=this.children.length;e<i;++e)this.children[e].render(t)}}renderAdvanced(t){const e=this.filters,i=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||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==It.NONE));if(s&&t.batch.flush(),e&&this._enabledFilters?.length&&t.filter.push(this,this._enabledFilters),i&&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(),i&&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,i=this.removeChildren(0,this.children.length);if(e)for(let s=0;s<i.length;++s)i[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}};Hp.defaultSortableChildren=!1;let Ht=Hp;Ht.prototype.containerUpdateTransform=Ht.prototype.updateTransform;Object.defineProperties(V,{SORTABLE_CHILDREN:{get(){return Ht.defaultSortableChildren},set(r){nt("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),Ht.defaultSortableChildren=r}}});const ls=new ct,Zb=new Uint16Array([0,1,2,0,2,3]);class Wt extends Ht{constructor(t){super(),this._anchor=new tr(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 ft(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=Q.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||Y.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=Zb,this.pluginName="batch",this.isSprite=!0,this._roundPixels=V.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=br(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=br(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,i=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,m=0,g=0;if(c?(p=c.x-d._x*u.width,f=p+c.width,g=c.y-d._y*u.height,m=g+c.height):(p=-d._x*u.width,f=p+u.width,g=-d._y*u.height,m=g+u.height),h[0]=i*p+n*g+a,h[1]=o*g+s*p+l,h[2]=i*f+n*g+a,h[3]=o*g+s*f+l,h[4]=i*f+n*m+a,h[5]=o*m+s*f+l,h[6]=i*p+n*m+a,h[7]=o*m+s*p+l,this._roundPixels){const _=V.RESOLUTION;for(let v=0;v<h.length;++v)h[v]=Math.round(h[v]*_)/_}}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,i=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*i.width,f=d+i.width,p=-s._y*i.height,m=p+i.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*m+c,e[5]=h*m+a*f+u,e[6]=o*d+l*m+c,e[7]=h*m+a*d+u,this._roundPixels){const g=V.RESOLUTION;for(let _=0;_<e.length;++_)e[_]=Math.round(e[_]*g)/g}}_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 lo),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 et),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,ls);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return ls.x>=s&&ls.x<s+e&&(n=-i*this.anchor.y,ls.y>=n&&ls.y<n+i)}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 i=t instanceof Y?t:Y.from(t,e);return new Wt(i)}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=br(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=br(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||Y.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const $p=new gt;wt.prototype._cacheAsBitmap=!1;wt.prototype._cacheData=null;wt.prototype._cacheAsBitmapResolution=null;wt.prototype._cacheAsBitmapMultisample=null;class Kb{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(wt.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(r){r!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=r,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(r){r!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=r,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(r){if(this._cacheAsBitmap===r)return;this._cacheAsBitmap=r;let t;r?(this._cacheData||(this._cacheData=new Kb),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)}}});wt.prototype._renderCached=function(r){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(r),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(r))};wt.prototype._initCachedDisplayObject=function(r){if(this._cacheData?.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new et,!0);if(this.filters?.length){const d=this.filters[0].padding;e.pad(d)}const i=this.cacheAsBitmapResolution||r.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const s=r.renderTexture.current,n=r.renderTexture.sourceFrame.clone(),o=r.renderTexture.destinationFrame.clone(),a=r.projection.transform,l=$t.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${ni()}`;this._cacheData.textureCacheId=h,rt.addToCache(l.baseTexture,h),Y.addToCache(l,h);const c=this.transform.localTransform.copyTo($p).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:l,clear:!0,transform:c,skipUpdateTransform:!1}),r.framebuffer.blit(),r.projection.transform=a,r.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 Wt(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)};wt.prototype._renderCachedCanvas=function(r){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(r),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(r))};wt.prototype._initCachedDisplayObjectCanvas=function(r){if(this._cacheData?.sprite)return;const t=this.getLocalBounds(new et,!0),e=this.alpha;this.alpha=1;const i=r.canvasContext.activeContext,s=r._projTransform,n=this.cacheAsBitmapResolution||r.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const o=$t.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${ni()}`;this._cacheData.textureCacheId=a,rt.addToCache(o.baseTexture,a),Y.addToCache(o,a);const l=$p;this.transform.localTransform.copyTo(l),l.invert(),l.tx-=t.x,l.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,{renderTexture:o,clear:!0,transform:l,skipUpdateTransform:!1}),r.canvasContext.activeContext=i,r._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 Wt(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=r._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=h.containsPoint.bind(h)};wt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID};wt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)};wt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,rt.removeFromCache(this._cacheData.textureCacheId),Y.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null};wt.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)};wt.prototype.name=null;Ht.prototype.getChildByName=function(r,t){for(let e=0,i=this.children.length;e<i;e++)if(this.children[e].name===r)return this.children[e];if(t)for(let e=0,i=this.children.length;e<i;e++){const s=this.children[e];if(!s.getChildByName)continue;const n=s.getChildByName(r,!0);if(n)return n}return null};wt.prototype.getGlobalPosition=function(r=new ct,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var Jb=`varying vec2 vTextureCoord; 529 530uniform sampler2D uSampler; 531uniform float uAlpha; 532 533void main(void) 534{ 535 gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha; 536} 537`;class Qb extends Gt{constructor(t=1){super($b,Jb,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const tx={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]},ex=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(` 538`);function rx(r){const t=tx[r],e=t.length;let i=ex,s="";const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<r;a++){let l=n.replace("%index%",a.toString());o=a,a>=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),s+=l,s+=` 539`}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const ix=` 540 attribute vec2 aVertexPosition; 541 542 uniform mat3 projectionMatrix; 543 544 uniform float strength; 545 546 varying vec2 vBlurTexCoords[%size%]; 547 548 uniform vec4 inputSize; 549 uniform vec4 outputFrame; 550 551 vec4 filterVertexPosition( void ) 552 { 553 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 554 555 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 556 } 557 558 vec2 filterTextureCoord( void ) 559 { 560 return aVertexPosition * (outputFrame.zw * inputSize.zw); 561 } 562 563 void main(void) 564 { 565 gl_Position = filterVertexPosition(); 566 567 vec2 textureCoord = filterTextureCoord(); 568 %blur% 569 }`;function sx(r,t){const e=Math.ceil(r/2);let i=ix,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<r;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),s+=a,s+=` 570`}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}class ih extends Gt{constructor(t,e=8,i=4,s=Gt.defaultResolution,n=5){const o=sx(n,t),a=rx(n);super(o,a),this.horizontal=t,this.resolution=s,this._quality=0,this.qual
vendor: 11,735 bytes, lines 570-716
570ity=i,this.blur=e}apply(t,e,i,s){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/e.width):this.uniforms.strength=1/i.height*(i.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,i,s);else{const n=t.getFilterTexture(),o=t.renderer;let a=e,l=n;this.state.blend=!1,t.applyFilter(this,a,l,Oe.CLEAR);for(let h=1;h<this.passes-1;h++){t.bindAndClear(a,Oe.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,i,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 nx extends Gt{constructor(t=8,e=4,i=Gt.defaultResolution,s=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new ih(!0,t,e,i,s),this.blurYFilter=new ih(!1,t,e,i,s),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,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,Oe.CLEAR),this.blurYFilter.apply(t,a,i,s),t.returnFilterTexture(a)}else o?this.blurYFilter.apply(t,e,i,s):this.blurXFilter.apply(t,e,i,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 ox=`varying vec2 vTextureCoord; 571uniform sampler2D uSampler; 572uniform float m[20]; 573uniform float uAlpha; 574 575void main(void) 576{ 577 vec4 c = texture2D(uSampler, vTextureCoord); 578 579 if (uAlpha == 0.0) { 580 gl_FragColor = c; 581 return; 582 } 583 584 // Un-premultiply alpha before applying the color matrix. See issue #3539. 585 if (c.a > 0.0) { 586 c.rgb /= c.a; 587 } 588 589 vec4 result; 590 591 result.r = (m[0] * c.r); 592 result.r += (m[1] * c.g); 593 result.r += (m[2] * c.b); 594 result.r += (m[3] * c.a); 595 result.r += m[4]; 596 597 result.g = (m[5] * c.r); 598 result.g += (m[6] * c.g); 599 result.g += (m[7] * c.b); 600 result.g += (m[8] * c.a); 601 result.g += m[9]; 602 603 result.b = (m[10] * c.r); 604 result.b += (m[11] * c.g); 605 result.b += (m[12] * c.b); 606 result.b += (m[13] * c.a); 607 result.b += m[14]; 608 609 result.a = (m[15] * c.r); 610 result.a += (m[16] * c.g); 611 result.a += (m[17] * c.b); 612 result.a += (m[18] * c.a); 613 result.a += m[19]; 614 615 vec3 rgb = mix(c.rgb, result.rgb, uAlpha); 616 617 // Premultiply alpha again. 618 rgb *= result.a; 619 620 gl_FragColor = vec4(rgb, result.a); 621} 622`;class sh extends Gt{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(Dp,ox,t),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[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 i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,s,n]=ft.shared.setValue(t).toArray(),o=[i,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 i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,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 i=Math.cos(t),s=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),l=i+(1-i)*o,h=o*(1-i)-a*s,c=o*(1-i)+a*s,u=o*(1-i)+a*s,d=i+o*(1-i),f=o*(1-i)-a*s,p=o*(1-i)-a*s,m=o*(1-i)+a*s,g=i+o*(1-i),_=[l,h,c,0,0,u,d,f,0,0,p,m,g,0,0,0,0,0,1,0];this._loadMatrix(_,e)}contrast(t,e){const i=(t||0)+1,s=-.5*(i-1),n=[i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,s=(i-1)*-.5,n=[i,s,s,0,0,s,i,s,0,0,s,s,i,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,i,s,n){t=t||.2,e=e||.15,i=i||16770432,s=s||3375104;const o=ft.shared,[a,l,h]=o.setValue(i).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 i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[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(i,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}}sh.prototype.grayscale=sh.prototype.greyscale;var ax=`varying vec2 vFilterCoord; 623varying vec2 vTextureCoord; 624 625uniform vec2 scale; 626uniform mat2 rotation; 627uniform sampler2D uSampler; 628uniform sampler2D mapSampler; 629 630uniform highp vec4 inputSize; 631uniform vec4 inputClamp; 632 633void main(void) 634{ 635 vec4 map = texture2D(mapSampler, vFilterCoord); 636 637 map -= 0.5; 638 map.xy = scale * inputSize.zw * (rotation * map.xy); 639 640 gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw)); 641} 642`,lx=`attribute vec2 aVertexPosition; 643 644uniform mat3 projectionMatrix; 645uniform mat3 filterMatrix; 646 647varying vec2 vTextureCoord; 648varying vec2 vFilterCoord; 649 650uniform vec4 inputSize; 651uniform vec4 outputFrame; 652 653vec4 filterVertexPosition( void ) 654{ 655 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 656 657 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 658} 659 660vec2 filterTextureCoord( void ) 661{ 662 return aVertexPosition * (outputFrame.zw * inputSize.zw); 663} 664 665void main(void) 666{ 667 gl_Position = filterVertexPosition(); 668 vTextureCoord = filterTextureCoord(); 669 vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy; 670} 671`;class hx extends Gt{constructor(t,e){const i=new gt;t.renderable=!1,super(lx,ax,{mapSampler:t._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=i,e==null&&(e=20),this.scale=new ct(e,e)}apply(t,e,i,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,i,s)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var cx=`varying vec2 v_rgbNW; 672varying vec2 v_rgbNE; 673varying vec2 v_rgbSW; 674varying vec2 v_rgbSE; 675varying vec2 v_rgbM; 676 677varying vec2 vFragCoord; 678uniform sampler2D uSampler; 679uniform highp vec4 inputSize; 680 681 682/** 683 Basic FXAA implementation based on the code on geeks3d.com with the 684 modification that the texture2DLod stuff was removed since it's 685 unsupported by WebGL. 686 687 -- 688 689 From: 690 https://github.com/mitsuhiko/webgl-meincraft 691 692 Copyright (c) 2011 by Armin Ronacher. 693 694 Some rights reserved. 695 696 Redistribution and use in source and binary forms, with or without 697 modification, are permitted provided that the following conditions are 698 met: 699 700 * Redistributions of source code must retain the above copyright 701 notice, this list of conditions and the following disclaimer. 702 703 * Redistributions in binary form must reproduce the above 704 copyright notice, this list of conditions and the following 705 disclaimer in the documentation and/or other materials provided 706 with the distribution. 707 708 * The names of the contributors may not be used to endorse or 709 promote products derived from this software without specific 710 prior written permission. 711 712 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 713 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 714 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 715 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 716 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
717 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 718 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 719 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 720 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 721 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 722 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 723 */ 724 725#ifndef FXAA_REDUCE_MIN 726#define FXAA_REDUCE_MIN (1.0/ 128.0) 727#endif 728#ifndef FXAA_REDUCE_MUL 729#define FXAA_REDUCE_MUL (1.0 / 8.0) 730#endif 731#ifndef FXAA_SPAN_MAX 732#define FXAA_SPAN_MAX 8.0 733#endif 734 735//optimized version for mobile, where dependent 736//texture reads can be a bottleneck 737vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP, 738 vec2 v_rgbNW, vec2 v_rgbNE, 739 vec2 v_rgbSW, vec2 v_rgbSE, 740 vec2 v_rgbM) { 741 vec4 color; 742 vec3 rgbNW = texture2D(tex, v_rgbNW).xyz; 743 vec3 rgbNE = texture2D(tex, v_rgbNE).xyz; 744 vec3 rgbSW = texture2D(tex, v_rgbSW).xyz; 745 vec3 rgbSE = texture2D(tex, v_rgbSE).xyz; 746 vec4 texColor = texture2D(tex, v_rgbM); 747 vec3 rgbM = texColor.xyz; 748 vec3 luma = vec3(0.299, 0.587, 0.114); 749 float lumaNW = dot(rgbNW, luma); 750 float lumaNE = dot(rgbNE, luma); 751 float lumaSW = dot(rgbSW, luma); 752 float lumaSE = dot(rgbSE, luma); 753 float lumaM = dot(rgbM, luma); 754 float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); 755 float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); 756 757 mediump vec2 dir; 758 dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); 759 dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); 760 761 float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * 762 (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); 763 764 float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); 765 dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), 766 max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), 767 dir * rcpDirMin)) * inverseVP; 768 769 vec3 rgbA = 0.5 * ( 770 texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz + 771 texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz); 772 vec3 rgbB = rgbA * 0.5 + 0.25 * ( 773 texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz + 774 texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz); 775 776 float lumaB = dot(rgbB, luma); 777 if ((lumaB < lumaMin) || (lumaB > lumaMax)) 778 color = vec4(rgbA, texColor.a); 779 else 780 color = vec4(rgbB, texColor.a); 781 return color; 782} 783 784void main() { 785 786 vec4 color; 787 788 color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); 789 790 gl_FragColor = color; 791} 792`,ux=` 793attribute vec2 aVertexPosition; 794 795uniform mat3 projectionMatrix; 796 797varying vec2 v_rgbNW; 798varying vec2 v_rgbNE; 799varying vec2 v_rgbSW; 800varying vec2 v_rgbSE; 801varying vec2 v_rgbM; 802 803varying vec2 vFragCoord; 804 805uniform vec4 inputSize; 806uniform vec4 outputFrame; 807 808vec4 filterVertexPosition( void ) 809{ 810 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 811 812 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 813} 814 815void texcoords(vec2 fragCoord, vec2 inverseVP, 816 out vec2 v_rgbNW, out vec2 v_rgbNE, 817 out vec2 v_rgbSW, out vec2 v_rgbSE, 818 out vec2 v_rgbM) { 819 v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP; 820 v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP; 821 v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP; 822 v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP; 823 v_rgbM = vec2(fragCoord * inverseVP); 824} 825 826void main(void) { 827 828 gl_Position = filterVertexPosition(); 829 830 vFragCoord = aVertexPosition * outputFrame.zw; 831 832 texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); 833} 834`;class dx extends Gt{constructor(){super(ux,cx)}}var fx=`precision highp float; 835 836varying vec2 vTextureCoord; 837varying vec4 vColor; 838 839uniform float uNoise; 840uniform float uSeed; 841uniform sampler2D uSampler; 842 843float rand(vec2 co) 844{ 845 return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); 846} 847 848void main() 849{ 850 vec4 color = texture2D(uSampler, vTextureCoord); 851 float randomValue = rand(gl_FragCoord.xy * uSeed); 852 float diff = (randomValue - 0.5) * uNoise; 853 854 // Un-premultiply alpha before applying the color matrix. See issue #3539. 855 if (color.a > 0.0) { 856 color.rgb /= color.a; 857 } 858 859 color.r += diff; 860 color.g += diff; 861 color.b += diff; 862 863 // Premultiply alpha again. 864 color.rgb *= color.a; 865 866 gl_FragColor = color; 867} 868`;class px extends Gt{constructor(t=.5,e=Math.random()){super(Dp,fx,{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 Pu={AlphaFilter:Qb,BlurFilter:nx,BlurFilterPass:ih,ColorMatrixFilter:sh,DisplacementFilter:hx,FXAAFilter:dx,NoiseFilter:px};Object.entries(Pu).forEach(([r,t])=>{Object.defineProperty(Pu,r,{get(){return nt("7.1.0",`filters.${r} has moved to ${r}`),t}})});class _x{constructor(){this.interactionFrequency=10,this._deltaT
vendor: 4,913 bytes, line 868
868ime=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||(ie.system.add(this.tickerUpdate,this,oi.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(ie.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}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const yr=new _x;class Ds{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Ds.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ct,this.page=new ct,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,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,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 ho extends Ds{constructor(){super(...arguments),this.client=new ct,this.movement=new ct,this.offset=new ct,this.global=new ct,this.screen=new ct}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,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,s,n,o,a,l,h,c,u,d,f,p,m){throw new Error("Method not implemented.")}}class ve extends ho{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 Ui extends ho{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Ui.DOM_DELTA_PIXEL=0,Ui.DOM_DELTA_LINE=1,Ui.DOM_DELTA_PAGE=2;const mx=2048,gx=new ct,Ua=new ct;class yx{constructor(t){this.dispatch=new ks,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((i,s)=>i.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.prop
vendor: 10,784 bytes, line 868
868agate(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 i=0,s=e.length;i<s;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){yr.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,gx.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[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=i.length-2;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)s.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<mx&&t!==this.rootTarget;i++){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,i,s,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(yr.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,i,s,n,o||n(t,i));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,i)&&s(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(yr.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,i,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,i)?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,Ua),!t.hitArea.contains(Ua.x,Ua.y)))return!0;if(t._mask){const i=t._mask.isMaskData?t._mask.maskObject:t._mask;if(i&&!i.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 i=`on${e}`;t.currentTarget[i]?.(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 ve)){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 i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){if(!(t instanceof ve)){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 i=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"),i&&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),i&&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"),i&&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),i&&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")),i&&(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 ve)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=i.target?.cursor);const n=this.clonePointerEvent(i,"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=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof ve)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&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),i&&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 ve)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let o=n;if(n&&!i.composedPath().includes(n)){let a=n;for(;a&&!i.composedPath().includes(a);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"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(i)}mapPointerUpOutside(t){if(!(t instanceof ve)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;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 Ui)){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 i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const s=this.allocateEvent(ve);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=i??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(Ui);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 i=this.allocateEvent(ve);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof ve&&e instanceof ve&&(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: 8,059 bytes, line 868
868iltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof ho&&e instanceof ho&&(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 i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}const vx=1,bx={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},nh=class oh{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new yx(null),yr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new ve(null),this.rootWheelEvent=new Ui(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...oh.defaultEventFeatures},{set:(e,i,s)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[i]=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:i}=this.renderer;this.setTargetElement(e),this.resolution=i,oh._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 i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);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 i=0,s=e.length;i<s;i++){const n=e[i],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,yr.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);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 i=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+=i,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 i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);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,yr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;yr.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;yr.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,i){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=(i-s.top)*(this.domElement.height/s.height)*n}normalizeToPointerData(t){const e=[];
868if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const n=t.changedTouches[i];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 i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=vx),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}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=bx[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}};nh.extension={name:"events",type:[$.RendererSystem,$.CanvasRendererSystem]},nh.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let ah=nh;q.add(ah);function Mu(r){return r==="dynamic"||r==="static"}const xx={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??Mu(ah.defaultEventMode)},set interactive(r){nt("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=r,this.eventMode=r?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??ah.defaultEventMode},set eventMode(r){this._internalInteractive=Mu(r),this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.on(r,t,s)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,s)},dispatchEvent(r){if(!(r instanceof Ds))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};wt.mixin(xx);const wx={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};wt.mixin(wx);const Tx=9,Qs=100,Ex=0,Ax=0,ku=2,Bu=1,Sx=-1e3,Cx=-1e3,Ix=2;class zp{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,(Qe.tablet||Qe.ph
vendor: 4,455 bytes, line 868
868one)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${Qs}px`,e.style.height=`${Qs}px`,e.style.position="absolute",e.style.top=`${Ex}px`,e.style.left=`${Ax}px`,e.style.zIndex=ku.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=`${Bu}px`,t.style.height=`${Bu}px`,t.style.position="absolute",t.style.top=`${Sx}px`,t.style.left=`${Cx}px`,t.style.zIndex=Ix.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 i=0;i<e.length;i++)this.updateAccessibleObjects(e[i])}update(){const t=performance.now();if(Qe.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:i,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=`${i}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,Ni(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 m=f.worldTransform;f.hitArea?(u.style.left=`${(m.tx+p.x*m.a)*h}px`,u.style.top=`${(m.ty+p.y*m.d)*c}px`,u.style.width=`${p.width*m.a*h}px`,u.style.height=`${p.height*m.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:i}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${Qs}px`,e.style.height=`${Qs}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=ku.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: 1,684 bytes, line 868
868itle=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:i}=t.target,s=this.renderer.events.rootBoundary,n=Object.assign(new Ds(s),{target:i});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===Tx&&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}}zp.extension={name:"accessibility",type:[$.RendererPlugin,$.CanvasRendererPlugin]};q.add(zp);const Xp=class lh{constructor(t){this.stage=new Ht,t=Object.assign({forceCanvas:!1},t),this.renderer=Ub(t),lh._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 i=lh._plugins.slice(0);
868i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Xp._plugins=[];let Vp=Xp;q.handleByList($.Application,Vp._plugins);class Wp{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,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),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}}Wp.extension=$.Application;q.add(Wp);const Du={loader:$.LoadParser,resolver:$.ResolveParser,cache:$.CacheParser,detection:$.DetectionParser};q.handle($.Asset,r=>{const t=r.ref;Object.entries(Du).filter(([e])=>!!t[e]).forEach(([e,i])=>q.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys(Du).filter(e=>!!t[e]).forEach(e=>q.remove(t[e]))});class Rx{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 i=0;i<e;i++)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 ts(r,t){if(Array.isArray(t)){for(const e of t)if(r.startsWith(`data:${e}`))return!0;return!1}return r.startsWith(`data:${t}`)}function Dr(r,t){const e=r.split("?")[0],i=Rt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const be=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),hh=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function jp(r,t,e,i,s){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?jp(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function Px(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const s=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),jp(r,s,0,e,i)}else i.push(r);return i}const co=r=>!Array.isArray(r);class Mx{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 i=be(t);let s;for(let a=0;a<this.parsers.length;a++){const l=this.parsers[a];if(l.test(e)){s=l.getCacheableAssets(i,e);break}}s||(s={},i.forEach(a=>{s[a]=e}));const n=Object.keys(s),o={cacheKeys:n,keys:i};if(i.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 Y){const a=e;i.forEach(l=>{a.baseTexture!==Y.EMPTY.baseTexture&&rt.addToCache(a.baseTexture,l),Y.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(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const Kr=new Mx;class kx{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.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),i.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,i.parser=a)}return s})(),i}
vendor: 9,569 bytes, lines 868-924
868async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const s={},n=co(t),o=be(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const c=Rt.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(++i/a)}catch(u){throw delete this.promiseCache[c],delete s[h.src],new Error(`[Loader.load] Failed to load ${c}. 869${u}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=be(t,i=>({alias:[i],src:i})).map(async i=>{const s=Rt.toAbsolute(i.src),n=this.promiseCache[s];if(n){const o=await n.promise;delete this.promiseCache[s],n.parser?.unload?.(o,i,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 Ae=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Ae||{});const Bx=".json",Dx="application/json",Fx={extension:{type:$.LoadParser,priority:Ae.Low},name:"loadJson",test(r){return ts(r,Dx)||Dr(r,Bx)},async load(r){return await(await V.ADAPTER.fetch(r)).json()}};q.add(Fx);const Ox=".txt",Nx="text/plain",Lx={name:"loadTxt",extension:{type:$.LoadParser,priority:Ae.Low},test(r){return ts(r,Nx)||Dr(r,Ox)},async load(r){return await(await V.ADAPTER.fetch(r)).text()}};q.add(Lx);const Ux=["normal","bold","100","200","300","400","500","600","700","800","900"],Gx=[".ttf",".otf",".woff",".woff2"],Hx=["font/ttf","font/otf","font/woff","font/woff2"],$x=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function zx(r){const t=Rt.extname(r),e=Rt.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match($x)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const Xx=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Vx(r){return Xx.test(r)?r:encodeURI(r)}const Wx={extension:{type:$.LoadParser,priority:Ae.Low},name:"loadWebFont",test(r){return ts(r,Hx)||Dr(r,Gx)},async load(r,t){const e=V.ADAPTER.getFontFaceSet();if(e){const i=[],s=t.data?.family??zx(r),n=t.data?.weights?.filter(a=>Ux.includes(a))??["normal"],o=t.data??{};for(let a=0;a<n.length;a++){const l=n[a],h=new FontFace(s,`url(${Vx(r)})`,{...o,weight:l});await h.load(),e.add(h),i.push(h)}return i.length===1?i[0]:i}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(r){(Array.isArray(r)?r:[r]).forEach(t=>V.ADAPTER.getFontFaceSet().delete(t))}};q.add(Wx);let Fu=0,Ga;const jx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=",Yx={id:"checkImageBitmap",code:` 870 async function checkImageBitmap() 871 { 872 try 873 { 874 if (typeof createImageBitmap !== 'function') return false; 875 876 const response = await fetch('${jx}'); 877 const imageBlob = await response.blob(); 878 const imageBitmap = await createImageBitmap(imageBlob); 879 880 return imageBitmap.width === 1 && imageBitmap.height === 1; 881 } 882 catch (e) 883 { 884 return false; 885 } 886 } 887 checkImageBitmap().then((result) => { self.postMessage(result); }); 888 `},qx={id:"loadImageBitmap",code:` 889 async function loadImageBitmap(url) 890 { 891 const response = await fetch(url); 892 893 if (!response.ok) 894 { 895 throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \` 896 + \`\${response.status} \${response.statusText}\`); 897 } 898 899 const imageBlob = await response.blob(); 900 const imageBitmap = await createImageBitmap(imageBlob); 901 902 return imageBitmap; 903 } 904 self.onmessage = async (event) => 905 { 906 try 907 { 908 const imageBitmap = await loadImageBitmap(event.data.data[0]); 909 910 self.postMessage({ 911 data: imageBitmap, 912 uuid: event.data.uuid, 913 id: event.data.id, 914 }, [imageBitmap]); 915 } 916 catch(e) 917 { 918 self.postMessage({ 919 error: e, 920 uuid: event.data.uuid, 921 id: event.data.id, 922 }); 923 } 924 };`};let Ha;class Zx{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([Yx.code],{type:"application/javascript"})),i=new Worker(e);i.addEventListener("message",s=>{i.terminate(),URL.revokeObjectURL(e),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Ga===void 0&&(Ga=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Ga&&(Ha||(Ha=URL.createObjectURL(new Blob([qx.code],{type:"application/javascript"}))),this._createdWorkers++,t=new Worker(Ha),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 i=new Promise((s,n)=>{this.queue.push({id:t,arguments:e,resolve:s,reject:n})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),i=e.id;this.resolveHash[Fu]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Fu++,id:i})}}const Ou=new Zx;function Fs(r,t,e){r.resource.internal=!0;const i=new Y(r),s=()=>{delete t.promiseCache[e],Kr.has(e)&&Kr.remove(e)};return i.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())}),i.once("destroyed",()=>{r.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),s())}),i}const Kx=[".jpeg",".jpg",".png",".webp",".avif"],Jx=["image/jpeg","image/png","image/webp","image/avif"];async function Qx(r){const t=await V.ADAPTER.fetch(r);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const Fo={name:"loadTextures",extension:{type:$.LoadParser,priority:Ae.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return ts(r,Jx)||Dr(r,Kx)},async load(r,t,e){const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await Ou.isImageBitmapSupported()?s=await Ou.loadImageBitmap(r):s=await Qx(r):s=await new Promise((a,l)=>{const h=new Image;h.crossOrigin=this.config.crossOrigin,h.src=r,h.complete?a(h):(h.onload=()=>a(h),h.onerror=c=>l(c))});const n={...t.data};n.resolution??(n.resolution=or(r)),i&&n.resourceOptions?.ownsImageBitmap===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const o=new rt(s,n);return o.resource.src=r,Fs(o,e,r)},unload(r){r.destroy(!0)}};q.add(Fo);const tw=".svg",ew="image/svg+xml",rw={extension:{type:$.LoadParser,priority:Ae.High},name:"loadSVG",test(r){return ts(r,ew)||Dr(r,tw)},async testParse(r){return Ql.test(r)},async parse(r,t,e){const i=new Ql(r,t?.data?.resourceOptions);await i.load();const s=new rt(i,{resolution:or(r),...t?.data});return s.resource.src=t.src,Fs(s,e,t.src)},async load(r,t){return(await V.ADAPTER.fetch(r)).text()},unload:Fo.unload};q.add(rw);const iw=[".mp4",".m4v",".webm",".ogv"],sw=["video/mp4","video/webm","video/ogg"],nw={name:"loadVideo",extension:{type:$.LoadParser,priority:Ae.High},config:{defaultAutoPlay:!0},test(r){return ts(r,sw)||Dr(r,iw)},async load(r,t,e){let i;const s=await(await V.ADAPTER.fetch(r)).blob(),n=URL.createObjectURL(s);try{const o={autoPlay:this.config.defaultAutoPlay,...t?.data?.resourceOptions},a=new Gp(n,o);await a.load();const l=new rt(a,{alphaMode:await uv(),resolution:or(r),...t?.data});l.resource.src=r,i=Fs(l,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(o){throw URL.revokeObjectURL(n),o}return i},unload(r){r.destroy(!0)}};q.add(nw);class ow{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")}
924prefer(...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(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,name:i,src:s,srcs:n}=t;return be(e||i||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 i=[];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);i.push(l),a=[o,l]}else{const l=o.map(h=>this._createBundleAssetId(t,h));i.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]})}i.push(...n)}),this._bundles[t]=i}add(t,e,i,s,n){const o=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(nt("7.2.0",`Assets.add now uses an object instead of individual parameters. 925Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:t,src:e,data:i,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`)},be(o).forEach(l=>{const{src:h,srcs:c}=l;let{data:u,format:d,loadParser:f}=l;const p=be(h||c).map(_=>typeof _=="string"?Px(_):Array.isArray(_)?_:[_]),m=this.getAlias(l);Array.isArray(m)?m.forEach(a):a(m);const g=[];p.forEach(_=>{_.forEach(v=>{let y={};if(typeof v!="object"){y.src=v;for(let b=0;b<this._parsers.length;b++){const x=this._parsers[b];if(x.test(v)){y=x.parse(v);break}}}else u=v.data??u,d=v.format??d,f=v.loadParser??f,y={...y,...v};if(!m)throw new Error(`[Resolver] alias is undefined for this asset: ${y.src}`);y=this.buildResolvedAsset(y,{aliases:m,data:u,format:d,loadParser:f}),g.push(y)})}),m.forEach(_=>{this._assetMap[_]=g})})}resolveBundle(t){const e=co(t);t=be(t);const i={};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}i[s]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const s in e)i[s]=e[s].src;return i}return e.src}resolve(t){const e=co(t);t=be(t);const i={};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},{});i[s]=this._resolverHash[s]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],s=this._preferredOrder.find(n=>n.params.format.includes(i.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:i,data:s,loadParser:n,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=Rt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.format=o??Rt.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class aw{constructor(){this._detections=[],this._initialized=!1,this.resolver=new ow,this.loader=new kx,this.cache=Kr,this._backgroundLoader=new Rx(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,i=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:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,i,s,n){this.resolver.add(t,e,i,s,n)}async load(t,e){this._initialized||await this.init();const i=co(t),s=be(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 i?o[s[0]]:o}
925addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!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),i?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(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Kr.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=Kr.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=Object.values(t),s=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const o={};return i.forEach((a,l)=>{const h=n[a.src],c=[a.src];a.alias&&c.push(...a.alias),o[s[l]]=h,Kr.set(c,h)}),o}async unload(t){this._initialized||await this.init();const e=be(t).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=be(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{Kr.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,s)=>e.indexOf(i)===s),e}get detections(){return this._detections}get preferWorkers(){return Fo.config.preferWorkers}set preferWorkers(t){nt("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(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const tn=new aw;q.handleByList($.LoadParser,tn.loader.parsers).handleByList($.ResolveParser,tn.resolver.parsers).handleByList($.CacheParser,tn.cache.parsers).handleByList($.DetectionParser,tn.detections);const lw={extension:$.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof Y),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};q.add(lw);async function Yp(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const hw={extension:{type:$.DetectionParser,priority:1},test:async()=>Yp("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};q.add(hw);const cw={extension:{type:$.DetectionParser,priority:0},test:async()=>Yp("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};q.add(cw);const Nu=["png","jpg","jpeg"],uw={extension:{type:$.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Nu],remove:async r=>r.filter(t=>!Nu.includes(t))};q.add(uw);const dw="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Xh(r){return dw?!1:document.createElement("video").canPlayType(r)!==""}const fw={extension:{type:$.DetectionParser,priority:0},test:async()=>Xh("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};q.add(fw);const pw={extension:{type:$.DetectionParser,priority:0},test:async()=>Xh("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};q.add(pw);const _w={extension:{type:$.DetectionParser,priority:0},test:async()=>Xh("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};q.add(_w);const mw={extension:$.ResolveParser,test:Fo.test,parse:r=>({resolution:parseFloat(V.RETINA_PREFIX.exec(r)?.[1]??"1"),format:Rt.extname(r).slice(1),src:r})};q.add(mw);var te=(r=>(r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_R11_
925EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",r[r.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",r[r.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r))(te||{});const uo={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 Ze,Ci;function Lu(){Ci={s3tc:Ze.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Ze.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:Ze.getExtension("WEBGL_compressed_texture_etc"),etc1:Ze.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:Ze.getExtension("WEBGL_compressed_texture_pvrtc")||Ze.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:Ze.getExtension("WEBGL_compressed_texture_atc"),astc:Ze.getExtension("WEBGL_compressed_texture_astc")}}const gw={extension:{type:$.DetectionParser,priority:2},test:async()=>{const r=V.ADAPTER.createCanvas().getContext("webgl");return r?(Ze=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{Ci||Lu();const t=[];for(const e in Ci)Ci[e]&&t.push(e);return[...t,...r]},remove:async r=>(Ci||Lu(),r.filter(t=>!(t in Ci)))};q.add(gw);class yw extends Po{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,s;typeof t=="string"?(i=t,s=new Uint8Array):(i=null,s=t),super(s,e),this.origin=i,this.buffer=s?new Gl(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 Gl(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class ri extends yw{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=ri._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||ri._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){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=ri._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,i,s,n,o,a){const l=new Array(i);let h=t.byteOffset,c=o,u=a,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*uo[e];for(let m=0;m<i;m++)l[m]={levelID:m,levelWidth:i>1?c:d,levelHeight:i>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*uo[e];return l}}const $a=4,en=124,vw=32,Uu=20,bw=542327876,rn={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},xw={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},sn={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},ww=1,Tw=2,Ew=4,Aw=64,Sw=512,Cw=131072,Iw=827611204,Rw=861165636,Pw=894720068,Mw=808540228,kw=4,Bw={[Iw]:te.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Rw]:te.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Pw]:te.COMPRESSED_RGBA_S3TC_DXT5_EXT},Dw={70:te.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:te.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:te.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:te.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:te.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:te.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:te.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:te.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:te.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT};function Fw(r){const t=new Uint32Array(r);if(t[0]!==bw)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,en/Uint32Array.BYTES_PER_ELEMENT),i=e[rn.HEIGHT],s=e[rn.WIDTH],n=e[rn.MIPMAP_COUNT],o=new Uint32Array(r,rn.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,vw/Uint32Array.BYTES_PER_ELEMENT),a=o[ww];if(a&Ew){const l=o[xw.FOURCC];if(l!==Mw){const v=Bw[l],y=$a+en,b=new Uint8Array(r,y);return[new ri(b,{format:v,width:s,height:i,levels:n})]}const h=$a+en,c=new Uint32Array(t.buffer,h,Uu/Uint32Array.BYTES_PER_ELEMENT),u=c[sn.DXGI_FORMAT],d=c[sn.RESOURCE_DIMENSION],f=c[sn.MISC_FLAG],p=c[sn.ARRAY_SIZE],m=Dw[u];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${u}`);if(f===kw)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const g=new Array,_=$a+en+Uu;if(p===1)g.push(new Uint8Array(r,_));else{const v=uo[m];let y=0,b=s,x=i;for(let T=0;T<n;T++){const E=Math.max(1,b+3&-4),C=Math.max(1,x+3&-4),M=E*C*v;y+=M,b=b>>>1,x=x>>>1}let w=_;for(let T=0;T<p;T++)g.push(new Uint8Array(r,w,y)),w+=y}return g.map(v=>new ri(v,{format:m,width:s,height:i,levels:n}))}throw a&Aw?new Error("DDSParser does not support uncompressed texture data."):a&Sw?new Error("DDSParser does not supported YUV uncompressed texture data."):a&Cw?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&Tw?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 Gu=[171,75,84,88,32,49,49,187,13,10,26,10],Ow=67305985,_e={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},ch=64,Hu={[K.UNSIGNED_BYTE]:1,[K.UNSIGNED_SHORT]:2,[K.INT]:4,[K.UNSIGNED_INT]:4,[K.FLOAT]:4,[K.HALF_FLOAT]:8},Nw={[N.RGBA]:4,[N.RGB]:3,[N.RG]:2,[N.RED]:1,[N.LUMINANCE]:1,[N.LUMINANCE_ALPHA]:2,[N.ALPHA]:1},Lw={[K.UNSIGNED_SHORT_4_4_4_4]:2,[K.UNSIGNED_SHORT_5_5_5_1]:2,[K.UNSIGNED_SHORT_5_6_5]:2};function Uw(r,t,e=!1){const i=new DataView(t);
925if(!Gw(r,i))return null;const s=i.getUint32(_e.ENDIANNESS,!0)===Ow,n=i.getUint32(_e.GL_TYPE,s),o=i.getUint32(_e.GL_FORMAT,s),a=i.getUint32(_e.GL_INTERNAL_FORMAT,s),l=i.getUint32(_e.PIXEL_WIDTH,s),h=i.getUint32(_e.PIXEL_HEIGHT,s)||1,c=i.getUint32(_e.PIXEL_DEPTH,s)||1,u=i.getUint32(_e.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(_e.NUMBER_OF_FACES,s),f=i.getUint32(_e.NUMBER_OF_MIPMAP_LEVELS,s),p=i.getUint32(_e.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 m=4,g=4,_=l+3&-4,v=h+3&-4,y=new Array(u);let b=l*h;n===0&&(b=_*v);let x;if(n!==0?Hu[n]?x=Hu[n]*Nw[o]:x=Lw[n]:x=uo[a],x===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const w=e?$w(i,p,s):null;let T=b*x,E=l,C=h,M=_,k=v,P=ch+p;for(let S=0;S<f;S++){const R=i.getUint32(P,s);let H=P+4;for(let j=0;j<u;j++){let D=y[j];D||(D=y[j]=new Array(f)),D[S]={levelID:S,levelWidth:f>1||n!==0?E:M,levelHeight:f>1||n!==0?C:k,levelBuffer:new Uint8Array(t,H,T)},H+=T}P+=R+4,P=P%4!==0?P+4-P%4:P,E=E>>1||1,C=C>>1||1,M=E+m-1&~(m-1),k=C+g-1&~(g-1),T=M*k*x}return n!==0?{uncompressed:y.map(S=>{let R=S[0].levelBuffer,H=!1;return n===K.FLOAT?R=new Float32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4):n===K.UNSIGNED_INT?(H=!0,R=new Uint32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4)):n===K.INT&&(H=!0,R=new Int32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4)),{resource:new Po(R,{width:S[0].levelWidth,height:S[0].levelHeight}),type:n,format:H?Hw(o):o}}),kvData:w}:{compressed:y.map(S=>new ri(null,{format:a,width:l,height:h,levels:f,levelBuffers:S})),kvData:w}}function Gw(r,t){for(let e=0;e<Gu.length;e++)if(t.getUint8(e)!==Gu[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function Hw(r){switch(r){case N.RGBA:return N.RGBA_INTEGER;case N.RGB:return N.RGB_INTEGER;case N.RG:return N.RG_INTEGER;case N.RED:return N.RED_INTEGER;default:return r}}function $w(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(ch+s,e),o=ch+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&&r.getUint8(o+l)!==0;l++);if(l===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const h=new TextDecoder().decode(new Uint8Array(r.buffer,o,l)),c=new DataView(r.buffer,o+l+1,n-l-1);i.set(h,c),s+=4+n+a}return i}const zw={extension:{type:$.LoadParser,priority:Ae.High},name:"loadDDS",test(r){return Dr(r,".dds")},async load(r,t,e){const i=await(await V.ADAPTER.fetch(r)).arrayBuffer(),s=Fw(i).map(n=>{const o=new rt(n,{mipmap:ze.OFF,alphaMode:Zt.NO_PREMULTIPLIED_ALPHA,resolution:or(r),...t.data});return Fs(o,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};q.add(zw);const Xw={extension:{type:$.LoadParser,priority:Ae.High},name:"loadKTX",test(r){return Dr(r,".ktx")},async load(r,t,e){const i=await(await V.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=Uw(r,i),a=s??n,l={mipmap:ze.OFF,alphaMode:Zt.NO_PREMULTIPLIED_ALPHA,resolution:or(r),...t.data},h=a.map(c=>{a===n&&Object.assign(l,{type:c.type,format:c.format});const u=c.resource??c,d=new rt(u,l);return d.ktxKeyValueData=o,Fs(d,e,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};q.add(Xw);const Vw={extension:$.ResolveParser,test:r=>{const t=Rt.extname(r).slice(1);return["basis","ktx","dds"].includes(t)},parse:r=>{const t=Rt.extname(r).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(i=>r.endsWith(i)))return{resolution:parseFloat(V.RETINA_PREFIX.exec(r)?.[1]??"1"),format:e.find(i=>r.endsWith(i)),src:r}}return{resolution:parseFloat(V.RETINA_PREFIX.exec(r)?.[1]??"1"),format:t,src:r}}};q.add(Vw);
925const nn=new et,Ww=4,qp=class gs{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,i,s){const n=new Image;return n.src=await this.base64(t,e,i,s),n}async base64(t,e,i,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,i)});if(n.toDataURL!==void 0)return n.toDataURL(e,i);if(n.convertToBlob!==void 0){const o=await n.convertToBlob({type:e,quality:i});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:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);o&&gs._flipY(i,s,n),a&&gs._unpremultiplyAlpha(i);const l=new Cv(s,n,1),h=new ImageData(new Uint8ClampedArray(i.buffer),s,n);return l.context.putImageData(h,0,0),l.canvas}pixels(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);return o&&gs._flipY(i,s,n),a&&gs._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let s,n=!1,o=!1,a,l=!1;t&&(t instanceof $t?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(nn.width=e.width,nn.height=e.height,e=nn)));const h=i.gl;if(a){if(s=a.baseTexture.resolution,e=e??a.frame,n=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===N.RGBA,!l){i.renderTexture.bind(a);const f=a.framebuffer.glFramebuffers[i.CONTEXT_UID];f.blitFramebuffer&&i.framebuffer.bind(f.blitFramebuffer)}}else s=i.resolution,e||(e=nn,e.width=i.width/s,e.height=i.height/s),n=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const c=Math.max(Math.round(e.width*s),1),u=Math.max(Math.round(e.height*s),1),d=new Uint8Array(Ww*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,i){const s=e<<2,n=i>>1,o=new Uint8Array(s);for(let a=0;a<n;a++){const l=a*s,h=(i-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 i=0;i<e;i+=4){const s=t[i+3];if(s!==0){const n=255.001/s;t[i]=t[i]*n+.5,t[i+1]=t[i+1]*n+.5,t[i+2]=t[i+2]*n+.5}}}};qp.extension={name:"extract",type:$.RendererSystem};let jw=qp;q.add(jw);const fo={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===Ft.CIRC){const p=r.shape;e=p.x,i=p.y,o=a=p.radius,s=n=0}else if(r.type===Ft.ELIP){const p=r.shape;e=p.x,i=p.y,o=p.width,a=p.height,s=n=0}else{const p=r.shape,m=p.width/2,g=p.height/2;e=p.x+m,i=p.y+g,o=a=Math.max(0,Math.min(p.radius,Math.min(m,g))),s=m-o,n=g-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]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n;return}let c=0,u=l*4+(s?2:0)+2,d=u,f=h;{const p=s+o,m=n,g=e+p,_=e-p,v=i+m;if(t[c++]=g,t[c++]=v,t[--u]=v,t[--u]=_,n){const y=i-m;t[d++]=_,t[d++]=y,t[--f]=y,t[--f]=g}}for(let p=1;p<l;p++){const m=Math.PI/2*(p/l),g=s+Math.cos(m)*o,_=n+Math.sin(m)*a,v=e+g,y=e-g,b=i+_,x=i-_;t[c++]=v,t[c++]=b,t[--u]=b,t[--u]=y,t[d++]=y,t[d++]=x,t[--f]=x,t[--f]=v}{const p=s,m=n+a,g=e+p,_=e-p,v=i+m,y=i-m;t[c++]=g,t[c++]=v,t[--f]=y,t[--f]=g,s&&(t[c++]=_,t[c++]=v,t[--f]=y,t[--f]=_)}},triangulate(r,t){const e=r.points,i=t.points,s=t.indices;if(e.length===0)return;let n=i.length/2;const o=n;let a,l;if(r.type!==Ft.RREC){const c=r.shape;a=c.x,l=c.y}else{const c=r.shape;a=c.x+c.width/2,l=c.y+c.height/2}const h=r.matrix;i.push(r.matrix?h.a*a+h.c*l+h.tx:a,r.matrix?h.b*a+h.d*l+h.ty:l),n++,i.push(e[0],e[1]);for(let c=2;c<e.length;c+=2)i.push(e[c],e[c+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function $u(r,t=!1){const e=r.length;if(e<6)return;let i=0;for(let s=0,n=r[e-2],o=r[e-1];s<e;s+=2){const a=r[s],l=r[s+1];i+=(a-n)*(l+o),n=a,o=l}if(!t&&i>0||t&&i<=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;[r[o],r[l]]=[r[l],r[o]],[r[a],r[h]]=[r[h],r[a]]}}}const Zp={build(r){r.points=r.shape.points.slice()},triangulate(r,t){let e=r.points;const i=r.holes,s=t.points,n=t.indices;if(e.length>=6){$u(e,!1);const o=[];for(let h=0;h<i.length;h++){const c=i[h];$u(c.points,!0),o.push(e.length/2),e=e.concat(c.points)}const a=X0(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])}}},Yw={build(r){const t=r.shape,e=t.x,i=t.y,s=t.width,n=t.height,o=r.points;o.length=0,s>=0&&n>=0&&o.push(e,i,e+s,i,e+s,i+n,e,i+n)},triangulate(r,t){const e=r.points,i=t.points;if(e.length===0)return;const s=i.length/2;i.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)}},qw={build(r){fo.build(r)},triangulate(r,t){fo.triangulate(r,t)}};var le=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(le||{}),xr=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(xr||{});const ji={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(r,t=20){if(!this.adaptive||!r||isNaN(r))return t;let e=Math.ceil(r/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class zu{static curveTo(t,e,i,s,n,o){const a=o[o.length-2],l=o[o.length-1]-e,h=a-t,c=s-e,u=i-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,m=l*c+h*u,g=n*Math.sqrt(f)/d,_=n*Math.sqrt(p)/d,v=g*m/f,y=_*m/p,b=g*u+_*h,x=g*c+_*l,w=h*(_+v),T=l*(_+v),E=u*(g+y),C=c*(g+y),M=Math.atan2(T-x,w-b),k=Math.atan2(C-x,E-b);
925return{cx:b+t,cy:x+e,radius:n,startAngle:M,endAngle:k,anticlockwise:h*c>u*l}}static arc(t,e,i,s,n,o,a,l,h){const c=a-o,u=ji._segmentsCount(Math.abs(c)*n,Math.ceil(Math.abs(c)/io)*40),d=c/(u*2),f=d*2,p=Math.cos(d),m=Math.sin(d),g=u-1,_=g%1/g;for(let v=0;v<=g;++v){const y=v+_*v,b=d+o+f*y,x=Math.cos(b),w=-Math.sin(b);h.push((p*x+m*w)*n+i,(p*-w+m*x)*n+s)}}}class Zw{constructor(){this.reset()}begin(t,e,i){this.reset(),this.style=t,this.start=e,this.attribStart=i}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 Vh{static curveLength(t,e,i,s,n,o,a,l){let h=0,c=0,u=0,d=0,f=0,p=0,m=0,g=0,_=0,v=0,y=0,b=t,x=e;for(let w=1;w<=10;++w)c=w/10,u=c*c,d=u*c,f=1-c,p=f*f,m=p*f,g=m*t+3*p*c*i+3*f*u*n+d*a,_=m*e+3*p*c*s+3*f*u*o+d*l,v=b-g,y=x-_,b=g,x=_,h+=Math.sqrt(v*v+y*y);return h}static curveTo(t,e,i,s,n,o,a){const l=a[a.length-2],h=a[a.length-1];a.length-=2;const c=ji._segmentsCount(Vh.curveLength(l,h,t,e,i,s,n,o));let u=0,d=0,f=0,p=0,m=0;a.push(l,h);for(let g=1,_=0;g<=c;++g)_=g/c,u=1-_,d=u*u,f=d*u,p=_*_,m=p*_,a.push(f*l+3*d*_*t+3*u*p*i+m*n,f*h+3*d*_*e+3*u*p*s+m*o)}}function Xu(r,t,e,i,s,n,o,a){const l=r-e*s,h=t-i*s,c=r+e*n,u=t+i*n;let d,f;o?(d=i,f=-e):(d=-i,f=e);const p=l+d,m=h+f,g=c+d,_=u+f;return a.push(p,m,g,_),2}function Ur(r,t,e,i,s,n,o,a){const l=e-r,h=i-t;
925let c=Math.atan2(l,h),u=Math.atan2(s-r,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),m=Math.sqrt(l*l+h*h),g=(15*p*Math.sqrt(m)/Math.PI>>0)+1,_=f/g;if(d+=_,a){o.push(r,t,e,i);for(let v=1,y=d;v<g;v++,y+=_)o.push(r,t,r+Math.sin(y)*m,t+Math.cos(y)*m);o.push(r,t,s,n)}else{o.push(e,i,r,t);for(let v=1,y=d;v<g;v++,y+=_)o.push(r+Math.sin(y)*m,t+Math.cos(y)*m,r,t);o.push(s,n,r,t)}return g*2}function Kw(r,t){const e=r.shape;let i=r.points||e.points.slice();const s=t.closePointEps;if(i.length===0)return;const n=r.lineStyle,o=new ct(i[0],i[1]),a=new ct(i[i.length-2],i[i.length-1]),l=e.type!==Ft.POLY||e.closeStroke,h=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;if(l){i=i.slice(),h&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const D=(o.x+a.x)*.5,tt=(a.y+o.y)*.5;i.unshift(D,tt),i.push(D,tt)}const c=t.points,u=i.length/2;let d=i.length;const f=c.length/2,p=n.width/2,m=p*p,g=n.miterLimit*n.miterLimit;let _=i[0],v=i[1],y=i[2],b=i[3],x=0,w=0,T=-(v-b),E=_-y,C=0,M=0,k=Math.sqrt(T*T+E*E);T/=k,E/=k,T*=p,E*=p;const P=n.alignment,S=(1-P)*2,R=P*2;l||(n.cap===xr.ROUND?d+=Ur(_-T*(S-R)*.5,v-E*(S-R)*.5,_-T*S,v-E*S,_+T*R,v+E*R,c,!0)+2:n.cap===xr.SQUARE&&(d+=Xu(_,v,T,E,S,R,!0,c))),c.push(_-T*S,v-E*S,_+T*R,v+E*R);for(let D=1;D<u-1;++D){_=i[(D-1)*2],v=i[(D-1)*2+1],y=i[D*2],b=i[D*2+1],x=i[(D+1)*2],w=i[(D+1)*2+1],T=-(v-b),E=_-y,k=Math.sqrt(T*T+E*E),T/=k,E/=k,T*=p,E*=p,C=-(b-w),M=y-x,k=Math.sqrt(C*C+M*M),C/=k,M/=k,C*=p,M*=p;const tt=y-_,G=v-b,A=y-x,L=w-b,I=tt*A+G*L,B=G*A-L*tt,J=B<0;if(Math.abs(B)<.001*Math.abs(I)){c.push(y-T*S,b-E*S,y+T*R,b+E*R),I>=0&&(n.join===le.ROUND?d+=Ur(y,b,y-T*S,b-E*S,y-C*S,b-M*S,c,!1)+4:d+=2,c.push(y-C*R,b-M*R,y+C*S,b+M*S));continue}const it=(-T+_)*(-E+b)-(-T+y)*(-E+v),ht=(-C+x)*(-M+b)-(-C+y)*(-M+w),lt=(tt*ht-A*it)/B,yt=(L*it-G*ht)/B,Tt=(lt-y)*(lt-y)+(yt-b)*(yt-b),mt=y+(lt-y)*S,st=b+(yt-b)*S,F=y-(lt-y)*R,ot=b-(yt-b)*R,U=Math.min(tt*tt+G*G,A*A+L*L),ut=J?S:R,pt=U+ut*ut*m,Lt=Tt<=pt;let Kt=n.join;if(Kt===le.MITER&&Tt/m>g&&(Kt=le.BEVEL),Lt)switch(Kt){case le.MITER:{c.push(mt,st,F,ot);break}case le.BEVEL:{J?c.push(mt,st,y+T*R,b+E*R,mt,st,y+C*R,b+M*R):c.push(y-T*S,b-E*S,F,ot,y-C*S,b-M*S,F,ot),d+=2;break}case le.ROUND:{J?(c.push(mt,st,y+T*R,b+E*R),d+=Ur(y,b,y+T*R,b+E*R,y+C*R,b+M*R,c,!0)+4,c.push(mt,st,y+C*R,b+M*R)):(c.push(y-T*S,b-E*S,F,ot),d+=Ur(y,b,y-T*S,b-E*S,y-C*S,b-M*S,c,!1)+4,c.push(y-C*S,b-M*S,F,ot));break}}else{switch(c.push(y-T*S,b-E*S,y+T*R,b+E*R),Kt){case le.MITER:{J?c.push(F,ot,F,ot):c.push(mt,st,mt,st),d+=2;break}case le.ROUND:{J?d+=Ur(y,b,y+T*R,b+E*R,y+C*R,b+M*R,c,!0)+2:d+=Ur(y,b,y-T*S,b-E*S,y-C*S,b-M*S,c,!1)+2;break}}c.push(y-C*S,b-M*S,y+C*R,b+M*R),d+=2}}_=i[(u-2)*2],v=i[(u-2)*2+1],y=i[(u-1)*2],b=i[(u-1)*2+1],T=-(v-b),E=_-y,k=Math.sqrt(T*T+E*E),T/=k,E/=k,T*=p,E*=p,c.push(y-T*S,b-E*S,y+T*R,b+E*R),l||(n.cap===xr.ROUND?d+=Ur(y-T*(S-R)*.5,b-E*(S-R)*.5,y-T*S,b-E*S,y+T*R,b+E*R,c,!1)+2:n.cap===xr.SQUARE&&(d+=Xu(y,b,T,E,S,R,!1,c)));const H=t.indices,j=ji.epsilon*ji.epsilon;for(let D=f;D<d+f-2;++D)_=c[D*2],v=c[D*2+1],y=c[(D+1)*2],b=c[(D+1)*2+1],x=c[(D+2)*2],w=c[(D+2)*2+1],!(Math.abs(_*(b-w)+y*(w-v)+x*(v-b))<j)&&H.push(D,D+1,D+2)}function Jw(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==Ft.POLY||i.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 Vu(r,t){r.lineStyle.native?Jw(r,t):Kw(r,t)}class Wh{static curveLength(t,e,i,s,n,o){const a=t-2*i+n,l=e-2*s+o,h=2*i-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),m=Math.sqrt(u),g=2*u*m,_=2*Math.sqrt(f),v=d/m;return(g*p+m*d*(p-_)+(4*f*u-d*d)*Math.log((2*m+v+p)/(v+_)))/(4*g)}static curveTo(t,e,i,s,n){const o=n[n.length-2],a=n[n.length-1],l=ji._segmentsCount(Wh.curveLength(o,a,t,e,i,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+(i-t)*d-h)*d,c+(e+(s-e)*d-c)*d)}}}const za={[Ft.POLY]:Zp,[Ft.CIRC]:fo,[Ft.ELIP]:fo,[Ft.RECT]:Yw,[Ft.RREC]:qw},Wu=[],on=[];class po{constructor(t,e=null,i=null,s=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=s,this.type=t.type}clone(){return new po(this.shape,this.fillStyle,this.lineStyle,this.matrix
925)}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 gi=new ct,Kp=class Jp extends ip{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 lo,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(),on.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),Wu.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,i=null,s=null){const n=new po(t,e,i,s);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new po(t,null,null,e),s=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=s.lineStyle,s.holes.push(i),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 i=0;i<e.length;++i){const s=e[i];if(s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(t,gi):gi.copyFrom(t),s.shape.contains(gi.x,gi.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(gi.x,gi.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 i=null,s=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],s=i.style);for(let l=this.shapeIndex;l<e.length;l++){this.shapeIndex++;const h=e[l],c=h.fillStyle,u=h.lineStyle;za[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,m=this.indices.length,g=this.points.length/2;p.wrapMode=Tr.REPEAT,d===0?this.processFill(h):this.processLine(h);const _=this.points.length/2-g;_!==0&&(i&&!this._compareStyles(s,f)&&(i.end(m,g),i=null),i||(i=Wu.pop()||new Zw,i.begin(f,m,g),this.batches.push(i),s=f),this.addUvs(this.points,t,f.texture,g,_,f.matrix))}}const n=this.indices.length,o=this.points.length/2;if(i&&i.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 i=this.graphicsData[t],s=i.fillStyle,n=i.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,i=t.length;e<i;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<Jp.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++rt._globalBatch;for(let u=0;u<this.drawCalls.length;u++)this.drawCalls[u].texArray.clear(),on.push(this.drawCalls[u]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=on.pop();s||(s=new zl,s.texArray=new jl),s.texArray.count=0,s.start=0,s.size=0,s.type=Ge.TRIANGLES;let n=0,o=null,a=0,l=!1,h=Ge.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,m=p.texture.baseTexture;l!==!!p.native&&(l=!!p.native,h=l?Ge.LINES:Ge.TRIANGLES,o=null,n=f,t++),o!==m&&(o=m,m._batchEnabled!==t&&(n===f&&(t++,n=0,s.size>0&&(s=on.pop(),s||(s=new zl,s.texArray=new jl),this.drawCalls.push(s)),s.start=c,s.size=0,s.texArray.count=0,s.type=h),m.touched=1,m._batchEnabled=t,m._batchLocation=n,m.
925wrapMode=Tr.REPEAT,s.texArray.elements[s.texArray.count++]=m,n++)),s.size+=d.size,c+=d.size,a=m._batchLocation,this.addColors(e,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}rt._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=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++]=i[h],o[l++]=s[h];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?Zp.triangulate(t,this):za[t.type].triangulate(t,this)}processLine(t){Vu(t,this);for(let e=0;e<t.holes.length;e++)Vu(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];za[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.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 i=0;i<t.length/2;i++){const s=t[i*2],n=t[i*2+1];t[i*2]=e.a*s+e.c*n+e.tx,t[i*2+1]=e.b*s+e.d*n+e.ty}}addColors(t,e,i,s,n=0){const o=ft.shared.setValue(e).toLittleEndianNumber(),a=ft.shared.setValue(o).toPremultiplied(i);t.length=Math.max(t.length,n+s);for(let l=0;l<s;l++)t[n+l]=a}addTextureIds(t,e,i,s=0){t.length=Math.max(t.length,s+i);for(let n=0;n<i;n++)t[s+n]=e}addUvs(t,e,i,s,n,o=null){let a=0;const l=e.length,h=i.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=i.baseTexture;(h.width<c.width||h.height<c.height)&&this.adjustUvs(e,i,l,n)}adjustUvs(t,e,i,s){const n=e.baseTexture,o=1e-6,a=i+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[i]+o),p=Math.floor(t[i+1]+o);for(let m=i+2;m<a;m+=2)f=Math.min(f,Math.floor(t[m]+o)),p=Math.min(p,Math.floor(t[m+1]+o));u-=f,d-=p;for(let m=i;m<a;m+=2)t[m]=(t[m]+u)*h,t[m+1]=(t[m+1]+d)*c}};Kp.BATCHABLE_SIZE=100;let Qw=Kp;class Oo{constructor(){this.color=16777215,this.alpha=1,this.texture=Y.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Oo;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=Y.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class jh extends Oo{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=xr.BUTT,this.join=le.MITER,this.miterLimit=10}clone(){const t=new jh;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=xr.BUTT,this.join=le.MITER,this.miterLimit=10}}const Xa={},uh=class Cn extends Ht{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 Oo,this._lineStyle=new jh,this._matrix=null,this._holeMode=!1,this.state=Xe.for2d(),this._geometry=t||new Qw,this._geometry.refCount++,this._transformID=-1,this._tintColor=new ft(16777215),this.blendMode=Q.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new Cn(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,i,s=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:s,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:Y.WHITE,color:t?.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:xr.BUTT,join:le.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();
925const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},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 ei,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new ei,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 i=this.currentPath.points,s=i[i.length-2],n=i[i.length-1];return(s!==t||n!==e)&&i.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,i,s){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),Wh.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o){return this._initCurve(),Vh.curveTo(t,e,i,s,n,o,this.currentPath.points),this}arcTo(t,e,i,s,n){this._initCurve(t,e);const o=this.currentPath.points,a=zu.curveTo(t,e,i,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,i,s,n,o=!1){if(s===n)return this;if(!o&&n<=s?n+=io:o&&s<=n&&(s+=io),n-s===0)return this;const a=t+Math.cos(s)*i,l=e+Math.sin(s)*i,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 zu.arc(a,l,t,e,i,s,n,o,c),this}beginFill(t=0,e){return this.beginTextureFill({texture:Y.WHITE,color:t,alpha:e})}normalizeColor(t){const e=ft.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:Y.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,s){return this.drawShape(new et(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new Bo(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new Mo(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new ko(t,e,i,s))}drawPolygon(...t){let e,i=!0;const s=t[0];s.points?(i=s.closeStroke,e=s.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new ei(e);return n.closeStroke=i,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}isFastRect(){const t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Ft.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,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let s=0;s<i;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:ft.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,i=this.batches.length;e<i;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),i=this._geometry,s=this.worldAlpha,n=e.uniforms,o=i.drawCalls;n.translationMatrix=this.transform.worldTransform,ft.shared.setValue(this._tintColor).premultiply(s).toArray(n.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let a=0,l=o.length;a<l;a++)this._renderDrawCallDirect(t,i.drawCalls[a])}_renderDrawCallDirect(t,e){const{texArray:i,type:s,size:n,start:o}=e,a=i.count;for(let l=0;l<a;l++)t.texture.bind(i.elements[l],l);t.geometry.draw(s,n,o)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!Xa[i]){const{maxTextures:s}=t.plugins[i],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 gt,default:Ee.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;Xa[i]=new $e(a,o)}e=Xa[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:s,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,i,s,n)}containsPoint(t){return this.worldTransform.applyInverse(t,Cn._TEMP_POINT),this._geometry.containsPoint(Cn._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=ft.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,i=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++]=i*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,
925super.destroy(t)}};uh.curves=ji,uh._TEMP_POINT=new ct;let ai=uh;class tT{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 Va=new ct,ju=new ei,Qp=class t_ extends Ht{constructor(t,e,i,s=Ge.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||Xe.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=V.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===Ge.TRIANGLES&&e.length<t_.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,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.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,i=t._updateID;if(i===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=V.RESOLUTION;for(let f=0;f<u.length;++f)u[f]=Math.round(u[f]*d)/d}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new tT(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,Va);const e=this.geometry.getBuffer("aVertexPosition").data,i=ju.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(i[0]=e[l],i[1]=e[l+1],i[2]=e[h],i[3]=e[h+1],i[4]=e[c],i[5]=e[c+1],ju.contains(Va.x,Va.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}};Qp.BATCHABLE_SIZE=100;let Yu=Qp;class eT extends Ar{constructor(t,e,i){super();
925const s=new St(t),n=new St(e,!0),o=new St(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,K.FLOAT).addAttribute("aTextureCoord",n,2,!1,K.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var rT=`varying vec2 vTextureCoord; 926uniform vec4 uColor; 927 928uniform sampler2D uSampler; 929 930void main(void) 931{ 932 gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; 933} 934`,iT=`attribute vec2 aVertexPosition; 935attribute vec2 aTextureCoord; 936 937uniform mat3 projectionMatrix; 938uniform mat3 translationMatrix; 939uniform mat3 uTextureMatrix; 940 941varying vec2 vTextureCoord; 942 943void main(void) 944{ 945 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); 946 947 vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; 948} 949`;class qu extends $e{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:gt.IDENTITY,uColor:new Float32Array([1,1,1,1])};e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e),e.uniforms&&Object.assign(i,e.uniforms),super(e.program||er.from(iT,rT),i),this._colorDirty=!1,this.uvMatrix=new gp(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new ft(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;ft.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class Zu{constructor(t,e,i){this.geometry=new Ar,this.indexBuffer=null,this.size=i,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||K.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 St(Av(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 i=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(i),this.dynamicDataUint32=new Uint32Array(i),this.dynamicBuffer=new St(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 St(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===K.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===K.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(t,e,i){for(let s=0;s<this.dynamicProperties.length;s++){const n=this.dynamicProperties[s];n.uploadFunction(t,e,i,n.type===K.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,n.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,i){for(let s=0;s<this.staticProperties.length;s++){const n=this.staticProperties[s];
vendor: 5,030 bytes, lines 949-982
949n.uploadFunction(t,e,i,n.type===K.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 sT=`varying vec2 vTextureCoord; 950varying vec4 vColor; 951 952uniform sampler2D uSampler; 953 954void main(void){ 955 vec4 color = texture2D(uSampler, vTextureCoord) * vColor; 956 gl_FragColor = color; 957}`,nT=`attribute vec2 aVertexPosition; 958attribute vec2 aTextureCoord; 959attribute vec4 aColor; 960 961attribute vec2 aPositionCoord; 962attribute float aRotation; 963 964uniform mat3 translationMatrix; 965uniform vec4 uColor; 966 967varying vec2 vTextureCoord; 968varying vec4 vColor; 969 970void main(void){ 971 float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation); 972 float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation); 973 974 vec2 v = vec2(x, y); 975 v = v + aPositionCoord; 976 977 gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0); 978 979 vTextureCoord = aTextureCoord; 980 vColor = aColor * uColor; 981} 982`;class e_ extends Do{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new gt,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:K.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=$e.from(nT,sT,{}),this.state=Xe.for2d()}render(t){const e=t.children,i=t._maxSize,s=t._batchSize,n=this.renderer;let o=e.length;if(o===0)return;o>i&&!t.autoResize&&(o=i);let a=t._buffers;a||(a=t._buffers=this.generateBuffers(t));const l=e[0]._texture.baseTexture,h=l.alphaMode>0;this.state.blendMode=tp(t.blendMode,h),n.state.set(this.state);const c=n.gl,u=t.worldTransform.copyTo(this.tempMatrix);u.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=u.toArray(!0),this.shader.uniforms.uColor=ft.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 m=o-f;m>s&&(m=s),p>=a.length&&a.push(this._generateOneMoreBuffer(t));const g=a[p];g.uploadDynamic(e,f,m);const _=t._bufferUpdateIDs[p]||0;d=d||g._updateID<_,d&&(g._updateID=t._updateID,g.uploadStatic(e,f,m)),n.geometry.bind(g.geometry),c.drawElements(c.TRIANGLES,m*6,c.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],i=t._maxSize,s=t._batchSize,n=t._properties;for(let o=0;o<i;o+=s)e.push(new Zu(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new Zu(this.properties,i,e)}uploadVertices(t,e,i,s,n,o){let a=0,l=0,h=0,c=0;for(let u=0;u<i;++u){const d=t[e+u],f=d._texture,p=d.scale.x,m=d.scale.y,g=f.trim,_=f.orig;g?(l=g.x-d.anchor.x*_.width,a=l+g.width,c=g.y-d.anchor.y*_.height,h=c+g.height):(a=_.width*(1-d.anchor.x),l=_.width*-d.anchor.x,h=_.height*(1-d.anchor.y),c=_.height*-d.anchor.y),s[o]=l*p,s[o+1]=c*m,s[o+n]=a*p,s[o+n+1]=c*m,s[o+n*2]=a*p,s[o+n*2+1]=h*m,s[o+n*3]=l*p,s[o+n*3+1]=h*m,o+=n*4}}uploadPosition(t,e,i,s,n,o){for(let a=0;a<i;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,i,s,n,o){for(let a=0;a<i;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,i,s,n,o){for(let a=0;a<i;++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,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a],h=ft.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}}e_.extension={name:"particle",type:$.RendererPlugin};q.add(e_);var No=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(No||{});const an={willReadFrequently:!0},De=class Z{static get experimentalLetterSpacingSupported(){let t=Z._experimentalLetterSpacingSupported;if(t!==void 0){const e=V.ADAPTER.getCanvasRenderingContext2D().prototype;t=Z._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,s,n,o,a,l,h){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}
vendor: 9,422 bytes, lines 982-983
982static measureText(t,e,i,s=Z._canvas){i=i??e.wordWrap;const n=e.toFontString(),o=Z.measureFont(n);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=s.getContext("2d",an);a.font=n;const l=(i?Z.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 m=Z._measureText(l[p],e.letterSpacing,a);h[p]=m,c=Math.max(c,m)}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 Z(t,e,u,f,l,h,d+e.leading,c,o)}static _measureText(t,e,i){let s=!1;Z.experimentalLetterSpacingSupported&&(Z.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(s?n-=e:n+=(Z.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=Z._canvas){const s=i.getContext("2d",an);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:c}=e,u=Z.collapseSpaces(c),d=Z.collapseNewlines(c);let f=!u;const p=e.wordWrapWidth+h,m=Z.tokenize(t);for(let g=0;g<m.length;g++){let _=m[g];if(Z.isNewline(_)){if(!d){a+=Z.addLine(o),f=!u,o="",n=0;continue}_=" "}if(u){const y=Z.isBreakingSpace(_),b=Z.isBreakingSpace(o[o.length-1]);if(y&&b)continue}const v=Z.getFromCache(_,h,l,s);if(v>p)if(o!==""&&(a+=Z.addLine(o),o="",n=0),Z.canBreakWords(_,e.breakWords)){const y=Z.wordWrapSplit(_);for(let b=0;b<y.length;b++){let x=y[b],w=x,T=1;for(;y[b+T];){const C=y[b+T];if(!Z.canBreakChars(w,C,_,b,e.breakWords))x+=C;else break;w=C,T++}b+=T-1;const E=Z.getFromCache(x,h,l,s);E+n>p&&(a+=Z.addLine(o),f=!1,o="",n=0),o+=x,n+=E}}else{o.length>0&&(a+=Z.addLine(o),o="",n=0);const y=g===m.length-1;a+=Z.addLine(_,!y),f=!1,o="",n=0}else v+n>p&&(f=!1,a+=Z.addLine(o),o="",n=0),(o.length>0||!Z.isBreakingSpace(_)||f)&&(o+=_,n+=v)}return a+=Z.addLine(o,!1),a}static addLine(t,e=!0){return t=Z.trimRight(t),t=e?`${t} 983`:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=Z._measureText(t,e,s)+e,i[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 i=t[e];if(!Z.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:Z._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:Z._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){const n=t[s],o=t[s+1];if(Z.isBreakingSpace(n,o)||Z.isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return Z.graphemeSegmenter(t)}static measureFont(t){if(Z._fonts[t])return Z._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=Z._canvas,s=Z._context;s.font=t;const n=Z.METRICS_STRING+Z.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(Z.BASELINE_SYMBOL).width);const l=Math.ceil(Z.HEIGHT_MULTIPLIER*a);if(a=a*Z.BASELINE_MULTIPLIER|0,o===0||l===0)return Z._fonts[t]=e,e;i.width=o,i.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 m=0;m<u;m+=4)if(h[f+m]!==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 m=0;m<u;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f-=u;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,Z._fonts[t]=e,e}static clearMetrics(t=""){t?delete Z._fonts[t]:Z._fonts={}}static get _canvas(){if(!Z.__canvas){let t;try{const e=new OffscreenCanvas(0,0);if(e.getContext("2d",an)?.measureText)return Z.__canvas=e,e;t=V.ADAPTER.createCanvas()}catch{t=V.ADAPTER.createCanvas()}t.width=t.height=10,Z.__canvas=t}return Z.__canvas}static get _context(){return Z.__context||(Z.__context=Z._canvas.getContext("2d",an)),Z.__context}};De.METRICS_STRING="|ÉqÅ",De.BASELINE_SYMBOL="M",De.BASELINE_MULTIPLIER=1.4,De.HEIGHT_MULTIPLIER=2,De.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){const r=new Intl.Segmenter;return t=>[...r.segment(t)].map(e=>e.segment)}return r=>[...r]})(),De.experimentalLetterSpacing=!1,De._fonts={},De._newlines=[10,13],De._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let mr=De;const oT=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],r_=class ys{constructor(t){this.styleID=0,this.reset(),ja(this,t,t)}clone(){const t={};return ja(t,this,ys.defaultStyle),new ys(t)}reset(){ja(this,ys.defaultStyle,ys.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=Wa(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=Wa(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){aT(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=Wa(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 i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!oT.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};r_.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=r_;function Wa(r){const t=ft.shared,e=i=>{const s=t.setValue(i);
983return s.alpha===1?s.toHex():s.toRgbaString()};return Array.isArray(r)?r.map(e):e(r)}function aT(r,t){if(!Array.isArray(r)||!Array.isArray(t)||r.length!==t.length)return!1;for(let e=0;e<r.length;++e)if(r[e]!==t[e])return!1;return!0}function ja(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const lT={texture:!0,children:!1,baseTexture:!0},i_=class dh extends Wt{constructor(t,e,i){let s=!1;i||(i=V.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=Y.from(i);n.orig=new et,n.trim=new et,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=dh.defaultResolution??V.RESOLUTION,this._autoResolution=dh.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 mr.experimentalLetterSpacing}static set experimentalLetterSpacing(t){nt("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),mr.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 i=this.context,s=mr.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),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;let d,f;const p=e.dropShadow?2:1;for(let m=0;m<p;++m){const g=e.dropShadow&&m===0,_=g?Math.ceil(Math.max(1,o)+e.padding*2):0,v=_*this._resolution;if(g){i.fillStyle="black",i.strokeStyle="black";const b=e.dropShadowColor,x=e.dropShadowBlur*this._resolution,w=e.dropShadowDistance*this._resolution;i.shadowColor=ft.shared.setValue(b).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=x,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*w,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*w+v}else i.fillStyle=this._generateFillStyle(e,a,s),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let y=(l-u.fontSize)/2;l-u.fontSize<0&&(y=0);for(let b=0;b<a.length;b++)d=e.strokeThickness/2,f=e.strokeThickness/2+b*l+u.ascent+y,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-_,!0),e.fill&&this.drawLetterSpacing(a[b],d+e.padding,f+e.padding-_)}this.updateTexture()}drawLetterSpacing(t,e,i,s=!1){const n=this._style.letterSpacing;let o=!1;if(mr.experimentalLetterSpacingSupported&&(mr.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,i):this.context.fillText(t,e,i);return}let a=e;const l=mr.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,i):this.context.fillText(d,a,i);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=Rv(t);o.data&&(t.width=o.width,t.height=o.height,this.context.putImageData(o.data,0,0))}const e=this._texture,i=this._style,s=i.trim?0:i.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,i){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.LINEAR_VERTICAL){n=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=i.fontProperties.fontSize+t.strokeThickness;for(let f=0;f<e.length;f++){const p=i.lineHeight*(f-1)+d,m=i.lineHeight*f;let g=m;f>0&&p>m&&(g=(m+p)/2);const _=m+d,v=i.lineHeight*(f+1);let y=_;f+1<e.length&&v<_&&(y=(_+v)/2);const b=(y-g)/h;for(let x=0;x<c.length;x++){let w=0;typeof u[x]=="number"?w=u[x]:w=x/c.length;let T=Math.min(1,Math.max(0,g/h+w*b));T=Number(T.toFixed(5)),n.addColorStop(T,c[x])}}}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 m;typeof u[p]=="number"?m=u[p]:m=f/d,n.addColorStop(m,c[p]),f++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},lT,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=br(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=br(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)}};i_.defaultAutoResolution=!0;let s_=i_;class hT{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function cT(r,t){let e=!1;if(r?._textures?.length){for(let i=0;i<r._textures.length;i++)if(r._textures[i]instanceof Y){const s=r._textures[i].baseTexture;t.includes(s)||(t.push(s),e=!0)}}return e}function uT(r,t){if(r.baseTexture instanceof rt){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function dT(r,t){if(r._texture&&r._texture instanceof Y){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function fT(r,t){return t instanceof s_?(t.updateText(!0),!0):!1}function pT(r,t){if(t instanceof Cr){const e=t.toFontString();return mr.measureFont(e),!0}return!1}function _T(r,t){if(r instanceof s_){t.includes(r.style)||t.push(r.style),t.includes(r)||t.push(r);const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function mT(r,t){return r instanceof Cr?(t.includes(r)||t.push(r),!0):!1}const n_=class o_{constructor(t){this.limiter=new hT(o_.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(_T),this.registerFindHook(mT),this.registerFindHook(cT),this.registerFindHook(uT),this.registerFindHook(dT),this.registerUploadHook(fT),this.registerUploadHook(pT)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,ie.system.addOnce(this.tick,this,oi.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 i=0,s=this.uploadHooks.length;i<s;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)ie.system.addOnce(this.tick,this,oi.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,i=t.length;e<i;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,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof Ht)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&ie.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}};n_.uploadsPerFrame=4;let fh=n_;Object.defineProperties(V,{UPLOADS_PER_FRAME:{get(){return fh.uploadsPerFrame},set(r){nt("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),fh.uploadsPerFrame=r}}});function a_(r,t){return t instanceof rt?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function gT(r,t){if(!(t instanceof ai))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let s=0;s<i.length;s++){const{texture:n}=i[s].style;n&&a_(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function yT(r,t){return r instanceof ai?(t.push(r),!0):!1}class l_ extends fh{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(yT),this.registerUploadHook(a_),this.registerUploadHook(gT)}}l_.extension={name:"prepare",type:$.RendererSystem};q.add(l_);var vT=`#version 300 es 984#define SHADER_NAME Tiling-Sprite-100 985 986precision lowp float; 987 988in vec2 vTextureCoord; 989 990out vec4 fragmentColor; 991 992uniform sampler2D uSampler; 993uniform vec4 uColor; 994uniform mat3 uMapCoord; 995uniform vec4 uClampFrame; 996uniform vec2 uClampOffset; 997 998void main(void) 999{ 1000 vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord); 1001 coord = (uMapCoord * vec3(coord, 1.0)).xy;
1002 vec2 unclamped = coord; 1003 coord = clamp(coord, uClampFrame.xy, uClampFrame.zw); 1004 1005 vec4 texSample = texture(uSampler, coord, unclamped == coord ? 0.0f : -32.0f);// lod-bias very negative to force lod 0 1006 1007 fragmentColor = texSample * uColor; 1008} 1009`,bT=`#version 300 es 1010#define SHADER_NAME Tiling-Sprite-300 1011 1012precision lowp float; 1013 1014in vec2 aVertexPosition; 1015in vec2 aTextureCoord; 1016 1017uniform mat3 projectionMatrix; 1018uniform mat3 translationMatrix; 1019uniform mat3 uTransform; 1020 1021out vec2 vTextureCoord; 1022 1023void main(void) 1024{ 1025 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); 1026 1027 vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy; 1028} 1029`,xT=`#version 100 1030#ifdef GL_EXT_shader_texture_lod 1031 #extension GL_EXT_shader_texture_lod : enable 1032#endif 1033#define SHADER_NAME Tiling-Sprite-100 1034 1035precision lowp float; 1036 1037varying vec2 vTextureCoord; 1038 1039uniform sampler2D uSampler; 1040uniform vec4 uColor; 1041uniform mat3 uMapCoord; 1042uniform vec4 uClampFrame; 1043uniform vec2 uClampOffset; 1044 1045void main(void) 1046{ 1047 vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord); 1048 coord = (uMapCoord * vec3(coord, 1.0)).xy; 1049 vec2 unclamped = coord; 1050 coord = clamp(coord, uClampFrame.xy, uClampFrame.zw); 1051 1052 #ifdef GL_EXT_shader_texture_lod 1053 vec4 texSample = unclamped == coord 1054 ? texture2D(uSampler, coord) 1055 : texture2DLodEXT(uSampler, coord, 0); 1056 #else 1057 vec4 texSample = texture2D(uSampler, coord); 1058 #endif 1059 1060 gl_FragColor = texSample * uColor; 1061} 1062`,Ku=`#version 100 1063#define SHADER_NAME Tiling-Sprite-100 1064 1065precision lowp float; 1066 1067attribute vec2 aVertexPosition; 1068attribute vec2 aTextureCoord; 1069 1070uniform mat3 projectionMatrix; 1071uniform mat3 translationMatrix; 1072uniform mat3 uTransform; 1073 1074varying vec2 vTextureCoord; 1075 1076void main(void) 1077{ 1078 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
1078)).xy, 0.0, 1.0); 1079 1080 vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy; 1081} 1082`,wT=`#version 100 1083#define SHADER_NAME Tiling-Sprite-Simple-100 1084 1085precision lowp float; 1086 1087varying vec2 vTextureCoord; 1088 1089uniform sampler2D uSampler; 1090uniform vec4 uColor; 1091 1092void main(void) 1093{ 1094 vec4 texSample = texture2D(uSampler, vTextureCoord); 1095 gl_FragColor = texSample * uColor; 1096} 1097`;const ln=new gt;class h_ extends Do{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new fp,this.state=Xe.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=$e.from(Ku,wT,e),this.shader=t.context.webGLVersion>1?$e.from(bT,vT,e):$e.from(Ku,xT,e)}render(t){const e=this.renderer,i=this.quad;let s=i.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=i.uvs,s[0]=s[6]=-n,s[1]=s[3]=-o,s[2]=s[4]=1-n,s[5]=s[7]=1-o,i.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!==Tr.CLAMP:l.wrapMode===Tr.CLAMP&&(l.wrapMode=Tr.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,m=a.height,g=t._width,_=t._height;ln.set(c.a*p/g,c.b*p/_,c.c*m/g,c.d*m/_,c.tx/g,c.ty/_),ln.invert(),d?ln.prepend(u.mapCoord):(f.uniforms.uMapCoord=u.mapCoord.toArray(!0),f.uniforms.uClampFrame=u.uClampFrame,f.uniforms.uClampOffset=u.uClampOffset),f.uniforms.uTransform=ln.toArray(!0),f.uniforms.uColor=ft.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(i),this.state.blendMode=tp(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}h_.extension={name:"tilingSprite",type:$.RendererPlugin};q.add(h_);const c_=class vs{constructor(t,e,i=null){this.linkedSheets=[],this._texture=t instanceof Y?t:null,this.baseTexture=t instanceof rt?t:this._texture.baseTexture,this.textures={},this.animations={},this.data=e;const s=this.baseTexture.resource;this.resolution=this._updateResolution(i||(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 i=or(t,null);return i===null&&(i=parseFloat(e??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=vs.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=vs.BATCH_SIZE;for(;e-t<i&&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 et(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?a=new et(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 et(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 et(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 Y(this.baseTexture,a,c,l,n.rotated?2:0,n.anchor,n.borders),Y.addToCache(this.textures[s],s.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];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*vs.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*vs.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=[]}};c_.BATCH_SIZE=1e3;let Ju=c_;const TT=["jpg","png","jpeg","avif","webp"];function u_(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}
1097),Object.keys(t.textures).forEach(s=>{i[s]=t.textures[s]}),!e){const s=Rt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=u_([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const ET={extension:$.Asset,cache:{test:r=>r instanceof Ju,getCacheableAssets:(r,t)=>u_(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&TT.includes(i)},parse:r=>{const t=r.split(".");return{resolution:parseFloat(V.RETINA_PREFIX.exec(r)?.[1]??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:$.LoadParser,priority:Ae.Normal},async testParse(r,t){return Rt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){let i=Rt.dirname(t.src);i&&i.lastIndexOf("/")!==i.length-1&&(i+="/");let s=i+r.meta.image;s=hh(s,t.src);const n=(await e.load([s]))[s],o=new Ju(n.baseTexture,r,t.src);await o.parse();const a=r?.meta?.related_multi_packs;if(Array.isArray(a)){const l=[];for(const c of a){if(typeof c!="string")continue;let u=i+c;t.data?.ignoreMultiPack||(u=hh(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(r){r.destroy(!0)}}};q.add(ET);class _o{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class In{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={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}i[o].push(l)}const s=new _o;return i.info.forEach(n=>s.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>s.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>s.page.push({id:parseInt(n.id,10),file:n.file})),i.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)})),i.kerning.forEach(n=>s.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>s.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),s}}class ph{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 _o,i=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<i.length;h++)e.info.push({face:i[h].getAttribute("face"),size:parseInt(i[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 _h{static test(t){return typeof t=="string"&&t.includes("<font>")?ph.test(V.ADAPTER.parseXML(t)):!1}static parse(t){return ph.parse(V.ADAPTER.parseXML(t))}}const Ya=[In,ph,_h];function AT(r){for(let t=0;t<Ya.length;t++)if(Ya[t].test(r))return Ya[t];return null}function ST(r,t,e,i,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=r.width/i-l-h
1097*2,u=r.height/i-l-h*2,d=o.slice(),f=e.fillGradientStops.slice();if(!f.length){const p=d.length+1;for(let m=1;m<p;++m)f.push(m/p)}if(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 m=(n.fontProperties.fontSize+e.strokeThickness)/u;for(let g=0;g<s.length;g++){const _=n.lineHeight*g;for(let v=0;v<d.length;v++){let y=0;typeof f[v]=="number"?y=f[v]:y=v/d.length;const b=_/u+y*m;let x=Math.max(p,b);x=Math.min(x,1),a.addColorStop(x,d[v]),p=x}}}else{a=t.createLinearGradient(h,u/2,c+h,u/2);const p=d.length+1;let m=1;for(let g=0;g<d.length;g++){let _;typeof f[g]=="number"?_=f[g]:_=m/p,a.addColorStop(_,d[g]),m++}}return a}function CT(r,t,e,i,s,n,o){const a=e.text,l=e.fontProperties;t.translate(i,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=ST(r,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=ft.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 Rn(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function d_(r){return Array.from?Array.from(r):r.split("")}function IT(r){typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const s=r[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(...d_(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const ur=class Fe{constructor(t,e,i){const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,l=or(o.file),h={};this._ownsTextures=i,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=Zt.NO_PREMULTIPLIED_ALPHA,h[u].baseTexture.mipmap=ze.OFF)}for(let c=0;c<t.char.length;c++){const{id:u,page:d}=t.char[c];let{x:f,y:p,width:m,height:g,xoffset:_,yoffset:v,xadvance:y}=t.char[c];f/=l,p/=l,m/=l,g/=l,_/=l,v/=l,y/=l;const b=new et(f+h[d].frame.x/l,p+h[d].frame.y/l,m,g);this.chars[u]={xOffset:_,yOffset:v,xAdvance:y,kerning:{},texture:new Y(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,i){let s;if(t instanceof _o)s=t;else{const o=AT(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof Y&&(e=[e]);const n=new Fe(s,e,i);return Fe.available[n.font]=n,n}static uninstall(t){const e=Fe.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete Fe.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:s,padding:n,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},Fe.defaultOptions,i),c=IT(s),u=e instanceof Cr?e:new Cr(e),d=a,f=new _o;f.info[0]={face:u.fontFamily,size:u.fontSize},f.common[0]={lineHeight:u.fontSize};let p=0,m=0,g,_,v,y=0;const b=[];for(let w=0;w<c.length;w++){g||(g=V.ADAPTER.createCanvas(),g.width=a,g.height=l,_=g.getContext("2d"),v=new rt(g,{resolution:o,...h}
1097),b.push(new Y(v)),f.page.push({id:b.length-1,file:""}));const T=c[w],E=mr.measureText(T,u,!1,g),C=E.width,M=Math.ceil(E.height),k=Math.ceil((u.fontStyle==="italic"?2:1)*C);if(m>=l-M*o){if(m===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${T}')`);--w,g=null,_=null,v=null,m=0,p=0,y=0;continue}if(y=Math.max(M+E.fontProperties.descent,y),k*o+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${T}')`);--w,m+=y*o,m=Math.ceil(m),p=0,y=0;continue}CT(g,_,E,p,m,o,u);const P=Rn(E.text);f.char.push({id:P,page:b.length-1,x:p/o,y:m/o,width:k,height:M,xoffset:0,yoffset:0,xadvance:C-(u.dropShadow?u.dropShadowDistance:0)-(u.stroke?u.strokeThickness:0)}),p+=(k+2*n)*o,p=Math.ceil(p)}if(!i?.skipKerning)for(let w=0,T=c.length;w<T;w++){const E=c[w];for(let C=0;C<T;C++){const M=c[C],k=_.measureText(E).width,P=_.measureText(M).width,S=_.measureText(E+M).width-(k+P);S&&f.kerning.push({first:Rn(E),second:Rn(M),amount:S})}}const x=new Fe(f,b,!0);return Fe.available[t]!==void 0&&Fe.uninstall(t),Fe.available[t]=x,x}};ur.ALPHA=[["a","z"],["A","Z"]," "],ur.NUMERIC=[["0","9"]],ur.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],ur.ASCII=[[" ","~"]],ur.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:ur.ALPHANUMERIC},ur.available={};let dr=ur;var RT=`// Pixi texture info\r 1098varying vec2 vTextureCoord;\r 1099uniform sampler2D uSampler;\r 1100\r 1101// Tint\r 1102uniform vec4 uColor;\r 1103\r 1104// on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r 1105uniform float uFWidth;\r 1106\r 1107void main(void) {\r 1108\r 1109 // To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r 1110 vec4 texColor = texture2D(uSampler, vTextureCoord);\r 1111\r 1112 // MSDF\r 1113 float median = texColor.r + texColor.g + texColor.b -\r 1114 min(texColor.r, min(texColor.g, texColor.b)) -\r 1115 max(texColor.r, max(texColor.g, texColor.b));\r 1116 // SDF\r 1117 median = min(median, texColor.a);\r 1118\r 1119 float screenPxDistance = uFWidth * (median - 0.5);\r 1120 float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r 1121 if (median < 0.01) {\r 1122 alpha = 0.0;\r 1123 } else if (median > 0.99) {\r 1124 alpha = 1.0;\r 1125 }\r 1126\r 1127 // Gamma correction for coverage-like alpha\r 1128 float luma = dot(uColor.rgb, vec3(0.299, 0.587, 0.114));\r 1129 float gamma = mix(1.0, 1.0 / 2.2, luma);\r 1130 float coverage = pow(uColor.a * alpha, gamma); \r 1131\r 1132 // NPM Textures, NPM outputs\r 1133 gl_FragColor = vec4(uColor.rgb, coverage);\r 1134}\r 1135`,PT=`// Mesh material default fragment\r 1136attribute vec2 aVertexPosition;\r 1137attribute vec2 aTextureCoord;\r 1138\r 1139uniform mat3 projectionMatrix;\r 1140uniform mat3 translationMatrix;\r 1141uniform mat3 uTextureMatrix;\r 1142\r 1143varying vec2 vTextureCoord;\r 1144\r 1145void main(void)\r 1146{\r 1147 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
1147)).xy, 0.0, 1.0);\r 1148\r 1149 vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r 1150}\r 1151`;const Qu=[],td=[],ed=[],MT=class f_ extends Ht{constructor(t,e={}){super();const{align:i,tint:s,maxWidth:n,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},f_.styleDefaults,e);if(!dr.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new ft(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 tr(()=>{this.dirty=!0},this,0,0),this._roundPixels=V.ROUND_PIXELS,this.dirty=!0,this._resolution=V.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){const t=dr.available[this._fontName],e=this.fontSize,i=e/t.size,s=new ct,n=[],o=[],a=[],l=this._text.replace(/(?:\r\n|\r)/g,` 1152`)||" ",h=d_(l),c=this._maxWidth*t.size/e,u=t.distanceFieldType==="none"?Qu:td;let d=null,f=0,p=0,m=0,g=-1,_=0,v=0,y=0,b=0;for(let k=0;k<h.length;k++){const P=h[k],S=Rn(P);if(/(?:\s)/.test(P)&&(g=k,_=f,b++),P==="\r"||P===` 1153`){o.push(f),a.push(-1),p=Math.max(p,f),++m,++v,s.x=0,s.y+=t.lineHeight,d=null,b=0;continue}const R=t.chars[S];if(!R)continue;d&&R.kerning[d]&&(s.x+=R.kerning[d]);const H=ed.pop()||{texture:Y.EMPTY,line:0,charCode:0,prevSpaces:0,position:new ct};H.texture=R.texture,H.line=m,H.charCode=S,H.position.x=Math.round(s.x+R.xOffset+this._letterSpacing/2),H.position.y=Math.round(s.y+R.yOffset),H.prevSpaces=b,n.push(H),f=H.position.x+Math.max(R.xAdvance-R.xOffset,R.texture.orig.width),s.x+=R.xAdvance+this._letterSpacing,y=Math.max(y,R.yOffset+R.texture.height),d=S,g!==-1&&c>0&&s.x>c&&(++v,Ni(n,1+g-v,1+k-g),k=g,g=-1,o.push(_),a.push(n.length>0?n[n.length-1].prevSpaces:0),p=Math.max(p,_),m++,s.x=0,s.y+=t.lineHeight,d=null,b=0)}const x=h[h.length-1];x!=="\r"&&x!==` 1154`&&(/(?:\s)/.test(x)&&(f=_),o.push(f),p=Math.max(p,f),a.push(-1));const w=[];for(let k=0;k<=m;k++){let P=0;this._align==="right"?P=p-o[k]:this._align==="center"?P=(p-o[k])/2:this._align==="justify"&&(P=a[k]<0?0:(p-o[k])/a[k]),w.push(P)}const T=n.length,E={},C=[],M=this._activePagesMeshData;u.push(...M);for(let k=0;k<T;k++){const P=n[k].texture,S=P.baseTexture.uid;if(!E[S]){let R=u.pop();if(!R){const j=new eT;let D,tt;t.distanceFieldType==="none"?(D=new qu(Y.EMPTY),tt=Q.NORMAL):(D=new qu(Y.EMPTY,{program:er.from(PT,RT),uniforms:{uFWidth:0}}),tt=Q.NORMAL_NPM);const G=new Yu(j,D);G.blendMode=tt,R={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:G,vertices:null,uvs:null,indices:null}}R.index=0,R.indexCount=0,R.vertexCount=0,R.uvsCount=0,R.total=0;const{_textureCache:H}=this;H[S]=H[S]||new Y(P.baseTexture),R.mesh.texture=H[S],R.mesh.tint=this._tintColor.value,C.push(R),E[S]=R}E[S].total++}for(let k=0;k<M.length;k++)C.includes(M[k])||this.removeChild(M[k].mesh);for(let k=0;k<C.length;k++)C[k].mesh.parent!==this&&this.addChild(C[k].mesh);this._activePagesMeshData=C;for(const k in E){const P=E[k],S=P.total;if(!(P.indices?.length>6*S)||P.vertices.length<Yu.BATCHABLE_SIZE*2)P.vertices=new Float32Array(4*2*S),P.uvs=new Float32Array(4*2*S),P.indices=new Uint16Array(6*S);else{const R=P.total,H=P.vertices;for(let j=R*4*2;j<H.length;j++)H[j]=0}P.mesh.size=6*S}for(let k=0;k<T;k++){const P=n[k];let S=P.position.x+w[P.line]*(this._align==="justify"?P.prevSpaces:1);this._roundPixels&&(S=Math.round(S));const R=S*i,H=P.position.y*i,j=P.texture,D=E[j.baseTexture.uid],tt=j.frame,G=j._uvs,A=D.index++;D.indices[A*6+0]=0+A*4,D.indices[A*6+1]=1+A*4,D.indices[A*6+2]=2+A*4,D.indices[A*6+3]=0+A*4,D.indices[A*6+4]=2+A*4,D.indices[A*6+5]=3+A*4,D.vertices[A*8+0]=R,D.vertices[A*8+1]=H,D.vertices[A*8+2]=R+tt.width*i,D.vertices[A*8+3]=H,D.vertices[A*8+4]=R+tt.width*i,D.vertices[A*8+5]=H+tt.height*i,D.vertices[A*8+6]=R,D.vertices[A*8+7]=H+tt.height*i,D.uvs[A*8+0]=G.x0,D.uvs[A*8+1]=G.y0,D.uvs[A*8+2]=G.x1,D.uvs[A*8+3]=G.y1,D.uvs[A*8+4]=G.x2,D.uvs[A*8+5]=G.y2,D.uvs[A*8+6]=G.x3,D.uvs[A*8+7]=G.y3}this._textWidth=p*i,this._textHeight=(s.y+t.lineHeight)*i;for(const k in E){const P=E[k];if(this.anchor.x!==0||this.anchor.y!==0){let j=0;const D=this._textWidth*this.anchor.x,tt=this._textHeight*this.anchor.y;for(let G=0;G<P.total;G++)P.vertices[j++]-=D,P.vertices[j++]-=tt,P.vertices[j++]-=D,P.vertices[j++]-=tt,P.vertices[j++]-=D,P.vertices[j++]-=tt,P.vertices[j++]-=D,P.vertices[j++]-=tt}this._maxLineHeight=y*i;const S=P.mesh.geometry.getBuffer("aVertexPosition"),R=P.mesh.geometry.getBuffer("aTextureCoord"),H=P.mesh.geometry.getIndex();S.data=P.vertices,R.data=P.uvs,H.data=P.indices,S.update(),R.update(),H.update()}for(let k=0;k<n.length;k++)ed.push(n[k]);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:i,size:s}=dr.available[this._fontName];if(i!=="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=dr.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(!dr.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??dr.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}
1154set 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,i=dr.available[this._fontName].distanceFieldType==="none"?Qu:td;i.push(...this._activePagesMeshData);for(const s of this._activePagesMeshData)this.removeChild(s.mesh);this._activePagesMeshData=[],i.filter(s=>e[s.mesh.texture.baseTexture.uid]).forEach(s=>{s.mesh.texture=Y.EMPTY});for(const s in e)e[s].destroy(),delete e[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};MT.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const kT=[".xml",".fnt"],BT={extension:{type:$.LoadParser,priority:Ae.Normal},name:"loadBitmapFont",test(r){return kT.includes(Rt.extname(r).toLowerCase())},async testParse(r){return In.test(r)||_h.test(r)},async parse(r,t,e){const i=In.test(r)?In.parse(r):_h.parse(r),{src:s}=t,{page:n}=i,o=[];for(let h=0;h<n.length;++h){const c=n[h].file;let u=Rt.join(Rt.dirname(s),c);u=hh(u,s),o.push(u)}const a=await e.load(o),l=o.map(h=>a[h]);return dr.install(i,l,!0)},async load(r,t){return(await V.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};q.add(BT);const mh=class Ii extends Cr{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new Ii(Object.keys(Ii.defaultOptions).reduce((e,i)=>({...e,[i]:t[i]}),{}))}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 Ii.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=Ii;if(i[t]){const s=i[t];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return V.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:Rt.basename(t,Rt.extname(t)),weight:"normal",style:"normal",display:"auto",src:s,dataSrc:n,refs:1,originalUrl:t,fontFace:null},e);i[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(i=>!this._overrides.includes(i));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter(i=>this._overrides.includes(i));e.length>0&&(this._overrides=this._overrides.filter(i=>!e.includes(i)),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} 1155 @font-face { 1156 font-family: "${e.family}"; 1157 src: url('${e.dataSrc}');
1158 font-weight: ${e.weight}; 1159 font-style: ${e.style}; 1160 font-display: ${e.display}; 1161 }`,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=Tv(t)),typeof t=="number"?wv(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=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=`${i}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,Ii.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}=V.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}};mh.availableFonts={},mh.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 qa=mh;const hn=class Ri extends Wt{constructor(t="",e={}){super(Y.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,s=Y.from(i,{scaleMode:V.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new et,s.trim=new et,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=Ri.defaultMaxWidth,this.maxHeight=Ri.defaultMaxHeight,this._domElement=h,this._styleElement=c,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(c),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=Ri.defaultAutoResolution,this._resolution=Ri.defaultResolution??V.RESOLUTION,this.text=t,this.style=e}measureText(t){const{text:e,style:i,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(s)}),this._styleElement.textContent=i.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),i!==this._style&&(Object.assign(this._domElement,{style:this._style?.toCSS(s)}),this._styleElement.textContent=this._style?.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_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();i.width=s.width=Math.ceil(Math.max(1,n)),i.height=s.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{s.onload=async()=>
1161{if(a<this._updateID){l();return}await e.onBeforeDraw(),i.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:i,resolution:s}=this,{padding:n}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/s,e.trim.height=e._frame.height=i.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(i.width,i.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({},Ri.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=br(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=br(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 qa?(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=qa.from(t)):(this.ownsStyle=!0,this._style=new qa(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," ")}};hn.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},hn.defaultMaxWidth=2024,hn.defaultMaxHeight=2024,hn.defaultAutoResolution=!0;const DT=` 1162precision highp float; 1163 1164uniform sampler2D uDrawingTexture; 1165uniform sampler2D uEraserTexture; 1166 1167varying vec2 vTextureCoord; 1168 1169void main(void) { 1170 vec4 drawingColor = texture2D(uDrawingTexture,vTextureCoord); 1171 vec4 eraserColor = texture2D(uEraserTexture, vTextureCoord); 1172 1173 // Use the alpha of the eraser to determine how much to "erase" from the drawing 1174 float alpha = 1.0 - eraserColor.a; 1175 gl_FragColor = vec4(drawingColor.rgb * alpha, drawingColor.a * alpha); 1176}`;function rd(r,t){if(t<0||t>=r.length-1)throw new Error("Index out of bounds");[r[t],r[t+1]]=[r[t+1],r[t]]}function FT(){let r=[],t=0;return{add_layer:function(e,i,s,n){const o=new Ht;t++,o.zIndex=t;const a=$t.create({width:s,height:n}),l=new Wt(a);o.addChild(l),l.zIndex=t;const h={draw_texture:$t.create({width:s,height:n}),erase_texture:$t.create({width:s,height:n}),composite:l},c=new Gt(void 0,DT,{uEraserTexture:h.erase_texture,uDrawingTexture:h.draw_texture});return l.filters=[c],e.addChild(o),r.push(h),[h,r]},swap_layers:function(e,i){return i==="up"?rd(r,e):rd(r,e-1),r[e]},change_active_layer:function(e){return r[e]},reset(){r.forEach(e=>{e.draw_texture.destroy(!0),e.erase_texture.destroy(!0),e.composite.destroy(!0)}),r=[],t=0},async add_layer_from_blob(e,i,s,n){const o=await createImageBitmap(s),a=Y.from(o),[l,h]=OT(a.width,a.height,n.width,n.height),c=new Wt(a);c.zIndex=0,c.width=l,c.height=h;const[u,d]=this.add_layer(e,i,n.width,n.height);return i.render(c,{renderTexture:u.draw_texture}),[u,d]},get_layers(){return r}}}function OT(r,t,e,i){if(r<=e&&t<=i)return[r,t];const s=r/t,n=e/i;let o,a;return s>n?(o=e,a=e/s):(a=i,o=i*s),[o,a]}function NT({target:r,dimensions:[t,e],antialias:i}){const s=window.devicePixelRatio||1,n=new Vp({width:t,height:e,antialias:i,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%",r.appendChild(n.view);const a=new Ht;a.zIndex=0;const l=new Ht;l.zIndex=1,l.sortableChildren=!0;const h=new Ht;h.zIndex=1;const c=new Ht;c.zIndex=0,h.addChild(a),h.addChild(l),n.stage.addChild(h),n.stage.addChild(c);const u=new ai;let d=$t.create({width:t,height:e});const f=new Wt(d);h.mask=f,n.render();function p(_,v){a.removeChildren(),u.beginFill(16777215,1),u.drawRect(0,0,_,v),u.endFill(),d=$t.create({width:_,height:v}),n.renderer.render(u,{renderTexture:d});const y=new Wt(d);h.mask=y}function m(_,v){n.renderer.resize(_,v),o.style.maxWidth=`${_/s}px`,o.style.maxHeight=`${v/s}px`,p(_,v)}async function g(_,v,[y,b]){const x=await Za(n.renderer,a,v,y,b),w=await Promise.all(_.map(E=>
1176Za(n.renderer,E.composite,v,y,b))),T=await Za(n.renderer,h,v,y,b);return{background:x,layers:w,composite:T}}return{layer_container:l,renderer:n.renderer,destroy:()=>n.destroy(!0),view:n.view,background_container:a,mask_container:h,resize:m,get_blobs:g}}function p_(r){const t=new ai;return t.eventMode="none",t.zIndex=r,t}function Yt(r,t,e){return r<t?t:r>e?e:r}function Za(r,t,e,i,s){return new Promise(n=>{const o=r.extract.canvas(t,new et(0,0,i,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 gh(r){return{command:r||null,next:null,previous:null,push:function(t){const e=gh(t);e.previous=this,this.next=e}}}function LT(){let r=gh();const t=jt(!1),e=jt(!1),i=jt(r);return{undo:function(){r.previous&&(r.command?.undo(),r=r.previous),t.set(!!r.previous),e.set(!!r.next),i.set(r)},redo:function(){r.next&&(r.next.command?.execute(),r=r.next),t.set(!!r.previous),e.set(!!r.next),i.set(r)},execute:function(s){s.execute(),r.push(s),r=r.next,t.set(!!r.previous),e.set(!!r.next),i.set(r)},can_undo:t,can_redo:e,current_history:i,reset:function(){r=gh(),t.set(!1),e.set(!1),i.set(r)}}}function Ka(r,t,e,i=new ft("black"),s){const n=new ft(i);r.beginFill(n),r.drawCircle(t,e,s),r.endFill()}function UT(r,t){let e=[];const i=t.x-r.x,s=t.y-r.y,n=Math.sqrt(i*i+s*s),o=Math.ceil(n/2),a=i/o,l=s/o;for(let h=0;h<o;h++){const c=r.x+h*a,u=r.y+h*l;e.push({x:c,y:u})}return e}function GT(r,t,e,i){const s=[];let n,o,a,l=!1,h=0;return{drawing:!1,start:function({x:c,y:u,size:d,color:f=new ft("black"),opacity:p,set_initial_texture:m=!0}){m&&(a=$t.create({width:e.draw_texture.width,height:e.draw_texture.height}),r.render(e.composite,{renderTexture:a})),n={x:c,y:u,size:d,color:f,opacity:p},s.push({x:c,y:u}),o=p_(h++),Ka(o,c,u,f,d),r.render(o,{renderTexture:i==="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=UT(d,{x:c,y:u});for(let p=0;p<f.length;p++){const{x:m,y:g}=f[p];Ka(o,m,g,n.color,n.size),s.push({x:m,y:g})}r.render(o,{renderTexture:i==="draw"?e.draw_texture:e.erase_texture,clear:!1}),o.clear()},stop:function(){const c=$t.create({width:e.draw_texture.width,height:e.draw_texture.height});r.render(e.composite,{renderTexture:c}),r.render(new Wt(c),{renderTexture:e.draw_texture});const u=new ai().beginFill(0,0).drawRect(0,0,e.erase_texture.width,e.erase_texture.height).endFill();r.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];Ka(o,u,d,n.color,n.size)}r.render(o,{renderTexture:i==="draw"?e.draw_texture:e.erase_texture,clear:!1}),this.stop()}},undo:function(){const c=new ai().beginFill(0,0).drawRect(0,0,e.erase_texture.width,e.erase_texture.height).endFill();r.render(new Wt(a),{renderTexture:e.draw_texture}),r.render(c,{renderTexture:e.erase_texture,clear:!0}),this.stop(),l=!1}}}function Yh(r,t){const e=i=>{r&&!r.contains(i.target)&&!i.defaultPrevented&&t(i)};return document.addEventListener("mousedown",e,!0),{destroy(){document.removeEventListener("mousedown",e,!0)}}}const{SvelteComponent:HT,append:id,attr:cn,binding_callbacks:sd,detach:Ja,element:un,flush:$T,init:zT,insert:Qa,listen:dn,noop:nd,run_all:XT,safe_not_equal:VT,set_style:Ce,space:WT}=window.__gradio__svelte__internal,{tick:jT}=window.__gradio__svelte__internal;function YT(r){let t,e,i=`translate(${r[1][0]}px,${r[1][1]}px)`,s,n,o,a=`translateX(${r[3]}px)`,l,h;
1176return{c(){t=un("div"),e=un("div"),s=WT(),n=un("div"),o=un("div"),cn(e,"class","marker svelte-90y9cx"),Ce(e,"transform",i),Ce(e,"background",r[0]),cn(t,"class","color-gradient svelte-90y9cx"),Ce(t,"--hue",r[2]),cn(o,"class","marker svelte-90y9cx"),Ce(o,"background","hsl("+r[2]+", 100%, 50%)"),Ce(o,"transform",a),cn(n,"class","hue-slider svelte-90y9cx")},m(c,u){Qa(c,t,u),id(t,e),r[10](t),Qa(c,s,u),Qa(c,n,u),id(n,o),r[11](n),l||(h=[dn(window,"mousemove",r[8]),dn(window,"mouseup",r[9]),dn(t,"mousedown",r[7]),dn(n,"mousedown",r[6])],l=!0)},p(c,[u]){u&2&&i!==(i=`translate(${c[1][0]}px,${c[1][1]}px)`)&&Ce(e,"transform",i),u&1&&Ce(e,"background",c[0]),u&4&&Ce(t,"--hue",c[2]),u&4&&Ce(o,"background","hsl("+c[2]+", 100%, 50%)"),u&8&&a!==(a=`translateX(${c[3]}px)`)&&Ce(o,"transform",a)},i:nd,o:nd,d(c){c&&(Ja(t),Ja(s),Ja(n)),r[10](null),r[11](null),l=!1,XT(h)}}}function od(r){const t=r.s,e=r.v;let i=t*e;const s=r.h/60;let n=i*(1-Math.abs(s%2-1));const o=e-i;i=i+o,n=n+o;const a=Math.floor(s)%6,l=[i,n,o,o,n,i][a],h=[n,i,i,n,o,o][a],c=[o,o,n,i,i,n][a];return`rgba(${l*255}, ${h*255}, ${c*255}, ${r.a})`}function qT(r,t,e){let{color:i="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(T){c=T.currentTarget.getBoundingClientRect(),u=!0,f(T.clientX)}function f(T){if(!c)return;const E=Yt(T-c.left,0,c.width);e(3,h=E);const C=E/c.width*360;e(2,l=C),e(0,i=od({h:C,s:a[0],v:a[1],a:1}))}function p(T,E){if(!n)return;const C=Yt(T-n.left,0,n.width),M=Yt(E-n.top,0,n.height);e(1,s=[C,M]);const k={h:l*1,s:C/n.width,v:1-M/n.height,a:1};a=[k.s,k.v],e(0,i=od(k))}function m(T){o=!0,n=T.currentTarget.getBoundingClientRect(),p(T.clientX,T.clientY)}function g(T){o&&p(T.clientX,T.clientY),u&&f(T.clientX)}function _(){o&&(o=!1),u&&(u=!1)}async function v(T){if(o||u||(await jT(),!T))return;n||(n=y.getBoundingClientRect()),c||(c=b.getBoundingClientRect());const E=W(T).toHsv(),C=E.s*n.width,M=(1-E.v)*n.height;e(1,s=[C,M]),a=[E.s,E.v],e(2,l=E.h),e(3,h=E.h/360*c.width)}let y,b;function x(T){sd[T?"unshift":"push"](()=>{y=T,e(4,y)})}function w(T){sd[T?"unshift":"push"](()=>{b=T,e(5,b)})}return r.$$set=T=>{"color"in T&&e(0,i=T.color)},r.$$.update=()=>{r.$$.dirty&1&&v(i)},[i,s,l,h,y,b,d,m,g,_,x,w]}class ZT extends HT{constructor(t){super(),zT(this,t,qT,YT,VT,{color:0})}get color(){return this.$$.ctx[0]}set color(t){this.$$set({color:t}),$T()}}const{SvelteComponent:KT,append:Jr,attr:Er,create_component:JT,destroy_component:QT,destroy_each:__,detach:Yi,element:rr,ensure_array_like:mo,flush:yi,init:tE,insert:qi,listen:qh,mount_component:eE,safe_not_equal:rE,set_style:go,space:Pn,toggle_class:ue,transition_in:iE,transition_out:sE}=window.__gradio__svelte__internal,{createEventDispatcher:nE}=window.__gradio__svelte__internal;function ad(r,t,e){const i=r.slice();return i[14]=t[e],i[16]=e,i}function ld(r,t,e){const i=r.slice();return i[14]=t[e],i[16]=e,i}function hd(r){let t;return{c(){t=rr("span"),Er(t,"class","svelte-287ern"),ue(t,"lg",r[1])},m(e,i){qi(e,t,i)},p(e,i){i&2&&ue(t,"lg",e[1])},d(e){e&&Yi(t)}}}function cd(r){let t,e,i,s,n,o=mo(r[1]),a=[];for(let l=0;l<o.length;l+=1)a[l]=ud(ld(r,o,l));return{c(){t=rr("div");for(let l=0;l<a.length;l+=1)a[l].c();e=Pn(),i=rr("button"),Er(i,"class","color colorpicker svelte-287ern"),ue(i,"hidden",!r[0]),Er(t,"class","swatch svelte-287ern")},m(l,h){qi(l,t,h);for(let c=0;c<a.length;c+=1)a[c]&&a[c].m(t,null);Jr(t,e),Jr(t,i),s||(n=qh(i,"click",r[5]),s=!0)},p(l,h){if(h&22){o=mo(l[1]);let c;for(c=0;c<o.length;c+=1){const u=ld(l,o,c);a[c]?a[c].p(u,h):(a[c]=ud(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&&ue(i,"hidden",!l[0])},d(l){l&&Yi(t),__(a,l),s=!1,n()}}}function ud(r){let t,e,i;function s(){return r[10](r[16],r[14])}return{c(){t=rr("button"),Er(t,"class","color svelte-287ern"),go(t,"background-color",r[14]),ue(t,"empty",r[14]===null),ue(t,"selected",`edit-${r[16]}`===r[2])},m(n,o){qi(n,t,o),e||(i=qh(t,"click",s),e=!0)},p(n,o){r=n,o&2&&go(t,"background-color",r[14]),o&2&&ue(t,"empty",r[14]===null),o&4&&ue(t,"selected",`edit-${r[16]}`===r[2])},d(n){n&&Yi(t),e=!1,i()}}}function dd(r){let t,e,i;function s(){return r[11](r[16],r[14])}return{c(){t=rr("button"),Er(t,"class","color svelte-287ern"),go(t,"background-color",r[14]),ue(t,"empty",r[14]===null),ue(t,"selected",`select-${r[16]}`===r[2])},m(n,o){qi(n,t,o),e||(i=qh(t,"click",s),e=!0)},p(n,o){r=n,o&8&&go(t,"background-color",r[14]),o&8&&ue(t,"empty",r[14]===null),o&4&&ue(t,"selected",`select-${r[16]}`===r[2])},d(n){n&&Yi(t),e=!1,i()}}}function oE(r){let t,e,i,s,n,o,a,l,h,c=!r[0]&&hd(r);s=new Zm({});let u=r[1]&&cd(r),d=mo(r[3]),f=[];for(let p=0;p<d.length;p+=1)f[p]=dd(ad(r,d,p));return{c(){c&&c.c(),t=Pn(),e=rr("div"),i=rr("span"),JT(s.$$.fragment),n=Pn(),o=rr("div"),u&&u.c(),a=Pn(),l=rr("menu");for(let p=0;p<f.length;p+=1)f[p].c();Er(i,"class","icon-wrap svelte-287ern"),Er(l,"class","swatch svelte-287ern"),Er(e,"class","swatch-wrap svelte-287ern")},m(p,m){c&&c.m(p,m),qi(p,t,m),qi(p,e,m),Jr(e,i),eE(s,i,null),Jr(e,n),Jr(e,o),u&&u.m(o,null),Jr(o,a),Jr(o,l);for(let g=0;g<f.length;g+=1)f[g]&&f[g].m(l,null);h=!0}
1176,p(p,[m]){if(p[0]?c&&(c.d(1),c=null):c?c.p(p,m):(c=hd(p),c.c(),c.m(t.parentNode,t)),p[1]?u?u.p(p,m):(u=cd(p),u.c(),u.m(o,a)):u&&(u.d(1),u=null),m&28){d=mo(p[3]);let g;for(g=0;g<d.length;g+=1){const _=ad(p,d,g);f[g]?f[g].p(_,m):(f[g]=dd(_),f[g].c(),f[g].m(l,null))}for(;g<f.length;g+=1)f[g].d(1);f.length=d.length}},i(p){h||(iE(s.$$.fragment,p),h=!0)},o(p){sE(s.$$.fragment,p),h=!1},d(p){p&&(Yi(t),Yi(e)),c&&c.d(p),QT(s),u&&u.d(),__(f,p)}}}function aE(r,t,e){let i,{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=nE();function u(_,v){return v==="hex"?W(_).toHexString():v==="rgb"?W(_).toRgbString():W(_).toHslString()}let d=`select-${n.findIndex(_=>u(_,l)===u(s,l))}`;function f(_,v){e(2,d=`${_}-${v.index}`),c(_,v)}function p(){c("select",{index:null,color:s}),e(0,h=!h)}const m=(_,v)=>f("edit",{index:_,color:v}),g=(_,v)=>f("select",{index:_,color:v});return r.$$set=_=>{"selected_color"in _&&e(6,s=_.selected_color),"colors"in _&&e(7,n=_.colors),"user_colors"in _&&e(1,o=_.user_colors),"show_empty"in _&&e(8,a=_.show_empty),"current_mode"in _&&e(9,l=_.current_mode),"color_picker"in _&&e(0,h=_.color_picker)},r.$$.update=()=>{r.$$.dirty&384&&e(3,i=a?n:n.filter(_=>_))},[h,o,d,i,f,p,s,n,a,l,m,g]}class lE extends KT{constructor(t){super(),tE(this,t,aE,oE,rE,{selected_color:6,colors:7,user_colors:1,show_empty:8,current_mode:9,color_picker:0})}get selected_color(){return this.$$.ctx[6]}set selected_color(t){this.$$set({selected_color:t}),yi()}get colors(){return this.$$.ctx[7]}set colors(t){this.$$set({colors:t}),yi()}get user_colors(){return this.$$.ctx[1]}set user_colors(t){this.$$set({user_colors:t}),yi()}get show_empty(){return this.$$.ctx[8]}set show_empty(t){this.$$set({show_empty:t}),yi()}get current_mode(){return this.$$.ctx[9]}set current_mode(t){this.$$set({current_mode:t}),yi()}get color_picker(){return this.$$.ctx[0]}set color_picker(t){this.$$set({color_picker:t}),yi()}}const{SvelteComponent:hE,append:Ye,attr:fr,create_component:cE,destroy_component:uE,destroy_each:dE,detach:m_,element:pr,ensure_array_like:fd,flush:pd,init:fE,insert:g_,listen:Mn,mount_component:pE,run_all:_E,safe_not_equal:mE,set_style:_d,space:tl,toggle_class:md,transition_in:y_,transition_out:v_}=window.__gradio__svelte__internal,{createEventDispatcher:gE}=window.__gradio__svelte__internal;function gd(r,t,e){const i=r.slice();return i[11]=t[e][0],i[12]=t[e][1],i}function yE(r){let t,e;return t=new Om({}),{c(){cE(t.$$.fragment)},m(i,s){pE(t,i,s),e=!0},i(i){e||(y_(t.$$.fragment,i),e=!0)},o(i){v_(t.$$.fragment,i),e=!1},d(i){uE(t,i)}}}function yd(r){let t,e,i;function s(){return r[8](r[12])}return{c(){t=pr("button"),t.textContent=`${r[11]}`,fr(t,"class","button svelte-w84deg"),md(t,"active",r[1]===r[12])},m(n,o){g_(n,t,o),e||(i=Mn(t,"click",s),e=!0)},p(n,o){r=n,o&10&&md(t,"active",r[1]===r[12])},d(n){n&&m_(t),e=!1,i()}}}function vE(r){let t,e,i,s,n,o,a,l,h,c,u,d,f,p=r[5]&&yE(),m=fd(r[3]),g=[];for(let _=0;_<m.length;_+=1)g[_]=yd(gd(r,m,_));return{c(){t=pr("div"),e=pr("button"),i=tl(),s=pr("div"),n=pr("div"),o=pr("input"),a=tl(),l=pr("button"),p&&p.c(),h=tl(),c=pr("div");for(let _=0;_<g.length;_+=1)g[_].c();fr(e,"class","swatch svelte-w84deg"),_d(e,"background",r[0]),fr(o,"type","text"),o.value=r[2],fr(o,"class","svelte-w84deg"),fr(l,"class","eyedropper svelte-w84deg"),fr(n,"class","input-wrap svelte-w84deg"),fr(c,"class","buttons svelte-w84deg"),fr(t,"class","input svelte-w84deg")},m(_,v){g_(_,t,v),Ye(t,e),Ye(t,i),Ye(t,s),Ye(s,n),Ye(n,o),Ye(n,a),Ye(n,l),p&&p.m(l,null),Ye(s,h),Ye(s,c);for(let y=0;y<g.length;y+=1)g[y]&&g[y].m(c,null);u=!0,d||(f=[Mn(e,"click",r[6]),Mn(o,"change",r[7]),Mn(l,"click",r[4])],d=!0)},p(_,[v]){if(v&1&&_d(e,"background",_[0]),(!u||v&4&&o.value!==_[2])&&(o.value=_[2]),v&10){m=fd(_[3]);let y;for(y=0;y<m.length;y+=1){const b=gd(_,m,y);g[y]?g[y].p(b,v):(g[y]=yd(b),g[y].c(),g[y].m(c,null))}for(;y<g.length;y+=1)g[y].d(1);g.length=m.length}},i(_){u||(y_(p),u=!0)},o(_){v_(p),u=!1},d(_){_&&m_(t),p&&p.d(),dE(g,_),d=!1,_E(f)}}}function bE(r,t,e){let i,{color:s}=t,{current_mode:n="hex"}=t;const o=gE(),a=[["Hex","hex"],["RGB","rgb"],["HSL","hsl"]];function l(p,m){return m==="hex"?W(p).toHexString():m==="rgb"?W(p).toRgbString():W(p).toHslString()}function h(){new EyeDropper().open().then(m=>{e(0,s=m.sRGBHex)})}const c=!!window.EyeDropper;function u(){o("selected",i),o("close")}const d=p=>e(0,s=p.currentTarget.value),f=p=>e(1,n=p);return r.$$set=p=>{"color"in p&&e(0,s=p.color),"current_mode"in p&&e(1,n=p.current_mode)},r.$$.update=()=>{r.$$.dirty&3&&e(2,i=l(s,n)),r.$$.dirty&4&&i&&o("selected",i)},[s,n,i,a,h,c,u,d,f]}class xE extends hE{constructor(t){super(),fE(this,t,bE,vE,mE,{color:0,current_mode:1})}get color(){return this.$$.ctx[0]}set color(t){this.$$set({color:t}),pd()}get current_mode(){return this.$$.ctx[1]}set current_mode(t){this.$$set({current_mode:t}),pd()}}const{SvelteComponent:wE,action_destroyer:TE,add_iframe_resize_listener:EE,add_render_callback:vd,append:el,attr:qe,binding_callbacks:AE,create_component:SE,destroy_component:CE,detach:IE,element:rl,flush:il,init:RE,insert:PE,listen:sl,mount_component:ME,run_all:kE,safe_not_equal:BE,set_input_value:bd,space:DE,to_number:FE,toggle_class:vi,transition_in:OE,transition_out:NE}=window.__gradio__svelte__internal,{createEventDispatcher:LE}=window.__gradio__svelte__internal;function UE(r){let t,e,i,s,n,o,a,l,h;return vd(r[11]),i=new fm({}),{c(){t=rl("div"),e=rl("span"),SE(i.$$.fragment),s=DE(),n=rl("input"),qe(e,"class","svelte-12m4nbd"),qe(n,"type","range"),qe(n,"min",r[1]),qe(n,"max",r[2]),qe(n,"step",1),qe(n,"class","svelte-12m4nbd"),qe(t,"class","wrap svelte-12m4nbd"),vd(()=>r[15].call(t)),vi(t,"right",r[8]),vi(t,"top",r[9]),vi(t,"bottom",!r[9])},m(c,u){PE(c,t,u),el(t,e),ME(i,e,null),el(t,s),el(t,n),bd(n,r[0]),r[14](t),o=EE(t,r[15].bind(t)),a=!0,l||(h=[sl(window,"resize",r[11]),sl(n,"change",r[12]),sl(n,"input",r[12]),TE(Yh.call(null,t,r[13]))],l=!0)},p(c,[u]){(!a||u&2)&&qe(n,"min",c[1]),(!a||u&4)&&qe(n,"max",c[2]),u&1&&bd(n,c[0]),(!a||u&256)&&vi(t,"right",c[8]),(!a||u&512)&&vi(t,"top",c[9]),(!a||u&512)&&vi(t,"bottom",!c[9])},i(c){a||(OE(i.$$.fragment,c),a=!0)},o(c){NE(i.$$.fragment,c),a=!1},d(c){c&&IE(t),CE(i),r[14](null),o(),l=!1,kE(h)}}}function GE(r,t,e){let{selected_size:i}=t,{min:s}=t,{max:n}=t;const o=LE();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 m(){i=FE(this.value),e(0,i)}const g=()=>o("click_outside");function _(y){AE[y?"unshift":"push"](()=>{u=y,e(7,u)})}
1176function v(){h=this.clientWidth,c=this.clientHeight,e(5,h),e(6,c)}return r.$$set=y=>{"selected_size"in y&&e(0,i=y.selected_size),"min"in y&&e(1,s=y.min),"max"in y&&e(2,n=y.max)},r.$$.update=()=>{if(r.$$.dirty&248&&u&&(a||l||c||h)){const y=u.getBoundingClientRect();e(8,d=y.width+30>a/2),e(9,f=y.y<80)}},[i,s,n,a,l,h,c,u,d,f,o,p,m,g,_,v]}class HE extends wE{constructor(t){super(),RE(this,t,GE,UE,BE,{selected_size:0,min:1,max:2})}get selected_size(){return this.$$.ctx[0]}set selected_size(t){this.$$set({selected_size:t}),il()}get min(){return this.$$.ctx[1]}set min(t){this.$$set({min:t}),il()}get max(){return this.$$.ctx[2]}set max(t){this.$$set({max:t}),il()}}const{SvelteComponent:$E,action_destroyer:zE,add_flush_callback:yo,add_iframe_resize_listener:XE,add_render_callback:xd,append:nl,attr:b_,bind:vo,binding_callbacks:Ms,check_outros:yh,create_component:bo,destroy_component:xo,detach:Lo,element:x_,empty:VE,flush:me,group_outros:vh,init:WE,insert:Uo,listen:jE,mount_component:wo,run_all:YE,safe_not_equal:qE,space:kn,toggle_class:Ie,transition_in:ee,transition_out:Le}=window.__gradio__svelte__internal,{createEventDispatcher:ZE}=window.__gradio__svelte__internal;function wd(r){let t,e,i=r[7]&&Td(r);return{c(){i&&i.c(),t=VE()},m(s,n){i&&i.m(s,n),Uo(s,t,n),e=!0},p(s,n){s[7]?i?(i.p(s,n),n[0]&128&&ee(i,1)):(i=Td(s),i.c(),ee(i,1),i.m(t.parentNode,t)):i&&(vh(),Le(i,1,1,()=>{i=null}),yh())},i(s){e||(ee(i),e=!0)},o(s){Le(i),e=!1},d(s){s&&Lo(t),i&&i.d(s)}}}function Td(r){let t,e,i,s,n,o;function a(u){r[23](u)}let l={};r[0]!==void 0&&(l.color=r[0]),t=new ZT({props:l}),Ms.push(()=>vo(t,"color",a));function h(u){r[24](u)}let c={color:r[0]};return r[13]!==void 0&&(c.current_mode=r[13]),s=new xE({props:c}),Ms.push(()=>vo(s,"current_mode",h)),s.$on("close",r[25]),s.$on("selected",r[26]),{c(){bo(t.$$.fragment),i=kn(),bo(s.$$.fragment)},m(u,d){wo(t,u,d),Uo(u,i,d),wo(s,u,d),o=!0},p(u,d){const f={};!e&&d[0]&1&&(e=!0,f.color=u[0],yo(()=>e=!1)),t.$set(f);const p={};d[0]&1&&(p.color=u[0]),!n&&d[0]&8192&&(n=!0,p.current_mode=u[13],yo(()=>n=!1)),s.$set(p)},i(u){o||(ee(t.$$.fragment,u),ee(s.$$.fragment,u),o=!0)},o(u){Le(t.$$.fragment,u),Le(s.$$.fragment,u),o=!1},d(u){u&&Lo(i),xo(t,u),xo(s,u)}}}function Ed(r){let t,e,i;function s(o){r[27](o)}let n={colors:r[3],user_colors:r[4]==="defaults"?r[1]:null,selected_color:r[0],current_mode:r[13]};return r[7]!==void 0&&(n.color_picker=r[7]),t=new lE({props:n}),Ms.push(()=>vo(t,"color_picker",s)),t.$on("select",r[28]),t.$on("edit",r[29]),{c(){bo(t.$$.fragment)},m(o,a){wo(t,o,a),i=!0},p(o,a){const l={};a[0]&8&&(l.colors=o[3]),a[0]&18&&(l.user_colors=o[4]==="defaults"?o[1]:null),a[0]&1&&(l.selected_color=o[0]),a[0]&8192&&(l.current_mode=o[13]),!e&&a[0]&128&&(e=!0,l.color_picker=o[7],yo(()=>e=!1)),t.$set(l)},i(o){i||(ee(t.$$.fragment,o),i=!0)},o(o){Le(t.$$.fragment,o),i=!1},d(o){xo(t,o)}}}function Ad(r){let t;return{c(){t=x_("div"),b_(t,"class","sep svelte-gtuiq3")},m(e,i){Uo(e,t,i)},d(e){e&&Lo(t)}}}function KE(r){let t,e,i,s,n,o,a,l,h,c;xd(r[22]);let u=r[4]==="defaults"&&wd(r),d=r[6]&&Ed(r),f=(r[7]||r[6])&&Ad();function p(g){r[30](g)}let m={max:r[5][0]/10,min:1};return r[2]!==void 0&&(m.selected_size=r[2]),n=new HE({props:m}),Ms.push(()=>vo(n,"selected_size",p)),{c(){t=x_("div"),u&&u.c(),e=kn(),d&&d.c(),i=kn(),f&&f.c(),s=kn(),bo(n.$$.fragment),b_(t,"class","wrap svelte-gtuiq3"),xd(()=>
1176r[33].call(t)),Ie(t,"padded",!r[7]),Ie(t,"anchor_default",r[14]==="default"),Ie(t,"anchor_center",r[14]==="center"),Ie(t,"anchor_top",r[14]==="top"),Ie(t,"anchor",`${r[15]}px`)},m(g,_){Uo(g,t,_),u&&u.m(t,null),nl(t,e),d&&d.m(t,null),nl(t,i),f&&f.m(t,null),nl(t,s),wo(n,t,null),r[32](t),a=XE(t,r[33].bind(t)),l=!0,h||(c=[jE(window,"resize",r[22]),zE(Yh.call(null,t,r[31]))],h=!0)},p(g,_){g[4]==="defaults"?u?(u.p(g,_),_[0]&16&&ee(u,1)):(u=wd(g),u.c(),ee(u,1),u.m(t,e)):u&&(vh(),Le(u,1,1,()=>{u=null}),yh()),g[6]?d?(d.p(g,_),_[0]&64&&ee(d,1)):(d=Ed(g),d.c(),ee(d,1),d.m(t,i)):d&&(vh(),Le(d,1,1,()=>{d=null}),yh()),g[7]||g[6]?f||(f=Ad(),f.c(),f.m(t,s)):f&&(f.d(1),f=null);const v={};_[0]&32&&(v.max=g[5][0]/10),!o&&_[0]&4&&(o=!0,v.selected_size=g[2],yo(()=>o=!1)),n.$set(v),(!l||_[0]&128)&&Ie(t,"padded",!g[7]),(!l||_[0]&16384)&&Ie(t,"anchor_default",g[14]==="default"),(!l||_[0]&16384)&&Ie(t,"anchor_center",g[14]==="center"),(!l||_[0]&16384)&&Ie(t,"anchor_top",g[14]==="top"),(!l||_[0]&32768)&&Ie(t,"anchor",`${g[15]}px`)},i(g){l||(ee(u),ee(d),ee(n.$$.fragment,g),l=!0)},o(g){Le(u),Le(d),Le(n.$$.fragment,g),l=!1},d(g){g&&Lo(t),u&&u.d(),d&&d.d(),f&&f.d(),xo(n),r[32](null),a(),h=!1,YE(c)}}}function JE(r,t,e){let{colors:i}=t,{selected_color:s}=t,{color_mode:n=void 0}=t,{recent_colors:o=[]}=t,{selected_size:a}=t,{dimensions:l}=t,{parent_width:h}=t,{parent_height:c}=t,{parent_left:u}=t,{toolbar_box:d}=t,{show_swatch:f}=t,p=!1,m="hex",g=null;const _=ZE();function v({index:B,color:J},it){it==="user"&&!J&&(g=B,e(7,p=!0)),J&&(e(0,s=J),it==="core"&&e(7,p=!1))}function y(B){g!==null&&e(1,o[g]=B,o)}let b=0,x=0,w=0,T=0,E,C="default",M=0;function k(){e(9,x=window.innerHeight),e(8,b=window.innerWidth)}function P(B){s=B,e(0,s)}function S(B){m=B,e(13,m)}const R=()=>e(7,p=!1),H=({detail:B})=>e(0,s=B);function j(B){p=B,e(7,p)}const D=({detail:B})=>v(B,"core"),tt=({detail:B})=>v(B,"user");function G(B){a=B,e(2,a)}const A=()=>_("click_outside");function L(B){Ms[B?"unshift":"push"](()=>{E=B,e(12,E)})}function I(){w=this.clientWidth,T=this.clientHeight,e(10,w),e(11,T)}return r.$$set=B=>{"colors"in B&&e(3,i=B.colors),"selected_color"in B&&e(0,s=B.selected_color),"color_mode"in B&&e(4,n=B.color_mode),"recent_colors"in B&&e(1,o=B.recent_colors),"selected_size"in B&&e(2,a=B.selected_size),"dimensions"in B&&e(5,l=B.dimensions),"parent_width"in B&&e(18,h=B.parent_width),"parent_height"in B&&e(19,c=B.parent_height),"parent_left"in B&&e(20,u=B.parent_left),"toolbar_box"in B&&e(21,d=B.toolbar_box),"show_swatch"in B&&e(6,f=B.show_swatch)},r.$$.update=()=>{if(r.$$.dirty[0]&1&&y(s),r.$$.dirty[0]&3940224&&E&&(b||x||T||w)){const B=E.getBoundingClientRect();B.width>h||(h>B.width+230*2+25?(e(14,C="default"),e(15,M=d.right-u+24)):e(14,C="center")),B.height+50>c&&e(14,C="top")}},[s,o,a,i,n,l,f,p,b,x,w,T,E,m,C,M,_,v,h,c,u,d,k,P,S,R,H,j,D,tt,G,A,L,I]}class QE extends $E{constructor(t){super(),WE(this,t,JE,KE,qE,{colors:3,selected_color:0,color_mode:4,recent_colors:1,selected_size:2,dimensions:5,parent_width:18,parent_height:19,parent_left:20,toolbar_box:21,show_swatch:6},null,[-1,-1])}get colors(){return this.$$.ctx[3]}set colors(t){this.$$set({colors:t}),me()}get selected_color(){return this.$$.ctx[0]}set selected_color(t){this.$$set({selected_color:t}),me()}get color_mode(){return this.$$.ctx[4]}set color_mode(t){this.$$set({color_mode:t}),me()}get recent_colors(){return this.$$.ctx[1]}set recent_colors(t){this.$$set({recent_colors:t}),me()}get selected_size(){return this.$$.ctx[2]}set selected_size(t){this.$$set({selected_size:t}),me()}get dimensions(){return this.$$.ctx[5]}set dimensions(t){this.$$set({dimensions:t}),me()}get parent_width(){return this.$$.ctx[18]}set parent_width(t){this.$$set({parent_width:t}),me()}get parent_height(){return this.$$.ctx[19]}set parent_height(t){this.$$set({parent_height:t}),me()}get parent_left(){return this.$$.ctx[20]}set parent_left(t){this.$$set({parent_left:t}),me()}get toolbar_box(){return this.$$.ctx[21]}set toolbar_box(t){this.$$set({toolbar_box:t}),me()}get show_swatch(){return this.$$.ctx[6]}set show_swatch(t){this.$$set({show_swatch:t}),me()}}const{SvelteComponent:tA,add_flush_callback:ol,attr:eA,bind:al,b
1176inding_callbacks:ll,check_outros:rA,component_subscribe:Gr,create_component:iA,destroy_component:sA,detach:Bn,element:w_,empty:nA,flush:hs,group_outros:oA,init:aA,insert:Dn,listen:lA,mount_component:hA,safe_not_equal:cA,set_style:oe,space:uA,transition_in:Fn,transition_out:bh}=window.__gradio__svelte__internal,{getContext:Sd,onMount:dA,tick:RC}=window.__gradio__svelte__internal;function Cd(r){let t,e,i,s,n,o;function a(u){r[25](u)}function l(u){r[26](u)}function h(u){r[27](u)}let c={show_swatch:r[1]==="draw",colors:r[4],color_mode:r[0],dimensions:r[6],parent_width:r[5].parent_width,parent_height:r[5].parent_height,parent_left:r[5].parent_left,toolbar_box:r[12]};return r[3]!==void 0&&(c.selected_color=r[3]),r[9]!==void 0&&(c.recent_colors=r[9]),r[2]!==void 0&&(c.selected_size=r[2]),e=new QE({props:c}),ll.push(()=>al(e,"selected_color",a)),ll.push(()=>al(e,"recent_colors",l)),ll.push(()=>al(e,"selected_size",h)),e.$on("click_outside",r[28]),{c(){t=w_("div"),iA(e.$$.fragment)},m(u,d){Dn(u,t,d),hA(e,t,null),o=!0},p(u,d){const f={};d[0]&2&&(f.show_swatch=u[1]==="draw"),d[0]&16&&(f.colors=u[4]),d[0]&1&&(f.color_mode=u[0]),d[0]&64&&(f.dimensions=u[6]),d[0]&32&&(f.parent_width=u[5].parent_width),d[0]&32&&(f.parent_height=u[5].parent_height),d[0]&32&&(f.parent_left=u[5].parent_left),d[0]&4096&&(f.toolbar_box=u[12]),!i&&d[0]&8&&(i=!0,f.selected_color=u[3],ol(()=>i=!1)),!s&&d[0]&512&&(s=!0,f.recent_colors=u[9],ol(()=>s=!1)),!n&&d[0]&4&&(n=!0,f.selected_size=u[2],ol(()=>n=!1)),e.$set(f)},i(u){o||(Fn(e.$$.fragment,u),o=!0)},o(u){bh(e.$$.fragment,u),o=!1},d(u){u&&Bn(t),sA(e)}}}function fA(r){let t,e=`translate(${r[10].x}px, ${r[10].y}px)`,i=`${r[5].child_top-r[5].parent_top-r[11]/2}px`,s=`${r[5].child_left-r[5].parent_left-r[11]/2}px`,n=`${r[11]}px`,o=`${r[11]}px`,a,l,h,c,u,d=r[7]&&Cd(r);return{c(){t=w_("span"),a=uA(),d&&d.c(),l=nA(),eA(t,"class","svelte-btgkrd"),oe(t,"transform",e),oe(t,"top",i),oe(t,"left",s),oe(t,"width",n),oe(t,"height",o),oe(t,"opacity",r[8]?1:0)},m(f,p){Dn(f,t,p),Dn(f,a,p),d&&d.m(f,p),Dn(f,l,p),h=!0,c||(u=lA(window,"keydown",r[24]),c=!0)},p(f,p){p[0]&1024&&e!==(e=`translate(${f[10].x}px, ${f[10].y}px)`)&&oe(t,"transform",e),p[0]&2080&&i!==(i=`${f[5].child_top-f[5].parent_top-f[11]/2}px`)&&oe(t,"top",i),p[0]&2080&&s!==(s=`${f[5].child_left-f[5].parent_left-f[11]/2}px`)&&oe(t,"left",s),p[0]&2048&&n!==(n=`${f[11]}
1176px`)&&oe(t,"width",n),p[0]&2048&&o!==(o=`${f[11]}px`)&&oe(t,"height",o),p[0]&256&&oe(t,"opacity",f[8]?1:0),f[7]?d?(d.p(f,p),p[0]&128&&Fn(d,1)):(d=Cd(f),d.c(),Fn(d,1),d.m(l.parentNode,l)):d&&(oA(),bh(d,1,1,()=>{d=null}),rA())},i(f){h||(Fn(d),h=!0)},o(f){bh(d),h=!1},d(f){f&&(Bn(t),Bn(a),Bn(l)),d&&d.d(f),c=!1,u()}}}function pA(r,t,e){let i,s,n,o,a,l,h,c,u,d,{default_size:f}=t,{default_color:p=void 0}=t,{colors:m=void 0}=t,{color_mode:g=void 0}=t,{mode:_}=t,v=!1;const{pixi:y,dimensions:b,current_layer:x,command_manager:w,register_context:T,editor_box:E,crop:C,toolbar_box:M}=Sd(es);Gr(r,y,U=>e(31,l=U)),Gr(r,b,U=>e(6,a=U)),Gr(r,x,U=>e(34,u=U)),Gr(r,E,U=>e(5,o=U)),Gr(r,C,U=>e(33,c=U)),Gr(r,M,U=>e(12,d=U));const{active_tool:k,register_tool:P,current_color:S}=Sd(So);Gr(r,k,U=>e(32,h=U));let R=!1,H;function j(U,ut){const pt=Yt(Math.min(U,ut),500,1e3);return Math.round(pt*2/100)}let D=f==="auto"?j(...a):f;function tt(U){h===_&&(R=!0,!(!l||!u)&&(H=GT(l.renderer,l.layer_container,u,_),H.start({x:U.screen.x,y:U.screen.y,color:s||void 0,size:D,opacity:1})))}function G(U){!l||!u||h===_&&(H.stop(),w.execute(H),R=!1)}function A(U){if(h!==_)return;R&&H.continue({x:U.screen.x,y:U.screen.y});const ut=c[0]*a[0],pt=c[1]*a[1];ut>U.screen.x||pt>U.screen.y||U.screen.x>ut+c[2]*a[0]||U.screen.y>pt+c[3]*a[1]?(e(8,L=!1),document.body.style.cursor="auto"):(e(8,L=!0),document.body.style.cursor="none"),L&&e(10,lt={x:U.clientX-o.child_left,y:U.clientY-o.child_top})}let L=!1;async function I(U){l?.layer_container[U]("pointerdown",tt),l?.layer_container[U]("pointerup",G),l?.layer_container[U]("pointermove",A),l?.layer_container[U]("pointerenter",ut=>{h===_&&(e(8,L=!0),document.body.style.cursor="none")}),l?.layer_container[U]("pointerleave",()=>(e(8,L=!1),document.body.style.cursor="auto"))}T(_,{init_fn:()=>{I("on")},reset_fn:()=>{I("off")}});const B=yt(),J=P(_,{cb:B});dA(()=>()=>{J(),I("off")});let it=[null,null,null];function ht(U){return W(U).toRgbString()}let lt={x:0,y:0};function yt(){let U=null;return function(pt){const Lt=()=>{if(U&&clearTimeout(U),pt!==void 0){e(7,v=pt);return}e(7,v=!v)};U&&clearTimeout(U),U=setTimeout(Lt,100)}}const Tt=({key:U})=>U==="Escape"&&B(!1);function mt(U){s=U,e(3,s),e(22,p),e(4,i),e(23,m)}function st(U){it=U,e(9,it)}function F(U){D=U,e(2,D)}const ot=()=>B();return r.$$set=U=>{"default_size"in U&&e(21,f=U.default_size),"default_color"in U&&e(22,p=U.default_color),"colors"in U&&e(23,m=U.colors),"color_mode"in U&&e(0,g=U.color_mode),"mode"in U&&e(1,_=U.mode)},r.$$.update=()=>{r.$$.dirty[0]&8388608&&e(4,i=m?m.map(ht).filter((U,ut)=>ut<4):[]),r.$$.dirty[0]&4194320&&e(3,s=p==="auto"?i[0]:p?ht(p):"black"),r.$$.dirty[0]&10&&_==="draw"&&S.set(s),r.$$.dirty[0]&100&&e(11,n=D/a[0]*o.child_width*2)},[g,_,D,s,i,o,a,v,L,it,lt,n,d,y,b,x,E,C,M,k,B,f,p,m,Tt,mt,st,F,ot]}class T_ extends tA{constructor(t){super(),aA(this,t,pA,fA,cA,{default_size:21,default_color:22,colors:23,color_mode:0,mode:1},null,[-1,-1])}get default_size(){return this.$$.ctx[21]}set default_size(t){this.$$set({default_size:t}),hs()}get default_color(){return this.$$.ctx[22]}set default_color(t){this.$$set({default_color:t}),hs()}get colors(){return this.$$.ctx[23]}set colors(t){this.$$set({colors:t}),hs()}get color_mode(){return this.$$.ctx[0]}set color_mode(t){this.$$set({color_mode:t}),hs()}get mode(){return this.$$.ctx[1]}set mode(t){this.$$set({mode:t}),hs()}}function Id(r,t,e,i=0){let s,n;const o=new ai;let a,l,h,c,u=yf(i,{stiffness:.1,damping:.5}),d=i;u.subscribe(g=>{l&&(d=g,f(h,c,l,!0))});function f(g,_,v,y){o.clear(),y&&(o.beginFill(16777215,d),o.drawRect(0,0,g,_),o.endFill()),o.beginFill(16777215,1),o.drawRect(...v),o.endFill(),r.render(o,{renderTexture:s})}let p=!0,m=!1;return{start:(g,_,v,y=!0,b=!0)=>{p=!1,s=$t.create({width:g,height:_}),f(g,_,v,y),n=new Wt(s),t.mask=n,h=g,c=_,b&&(a=JSON.parse(JSON.stringify(v)))},continue:(g,_=!0)=>{l=JSON.parse(JSON.stringify(g)),d===.2?f(h,c,l,_):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 m=!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):(m||u.set(0),e.set([l[0]/h,l[1]/c,l[2]/h,l[3]/c]),p=!0)}}}function E_(r,t,e,i,s,n){let o=r,a=t;(e.includes("t")||e.includes("b")||e=="c")&&(o=t*i),(e.includes("l")||e.includes("r")||e=="c")&&(a=r/i),a=a||o/i,o=o||a*i,o>s&&(o=s,a=o/i),a>n&&(a=n,o=a*i);let l=0,h=0;return e.includes("r")?l=r-o:e.includes("l")?l=0:l=(r-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,
1176y_offset:h}}const{SvelteComponent:_A,append:mA,attr:fn,binding_callbacks:gA,detach:yA,element:Rd,flush:Hr,init:vA,insert:bA,listen:hl,noop:Pd,run_all:xA,safe_not_equal:wA,set_style:Md}=window.__gradio__svelte__internal,{tick:TA,createEventDispatcher:EA}=window.__gradio__svelte__internal;function AA(r){let t,e,i,s,n,o;return{c(){t=Rd("div"),e=Rd("div"),fn(e,"class",i="handle "+r[0]+" "+r[1]+" svelte-1x33xzn"),fn(t,"class",s="hitbox "+r[1]+" svelte-1x33xzn"),Md(t,"transform",r[3])},m(a,l){bA(a,t,l),mA(t,e),r[12](e),n||(o=[hl(window,"mousemove",r[5]),hl(window,"mouseup",r[6]),hl(t,"mousedown",r[4])],n=!0)},p(a,[l]){l&3&&i!==(i="handle "+a[0]+" "+a[1]+" svelte-1x33xzn")&&fn(e,"class",i),l&2&&s!==(s="hitbox "+a[1]+" svelte-1x33xzn")&&fn(t,"class",s),l&8&&Md(t,"transform",a[3])},i:Pd,o:Pd,d(a){a&&yA(t),r[12](null),n=!1,xA(o)}}}function SA(r,t,e){let i,{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=EA();let{dragging:m=!1}=t,g;function _(w){c=g.getBoundingClientRect(),f=!0,e(11,m=!0),["tl","bl","l"].includes(n)&&(d=w.clientX-c.right),["tl","tr","t"].includes(n)&&(u=w.clientY-c.bottom),["tr","r","br"].includes(n)&&(d=w.clientX-c.left),["br","b","bl"].includes(n)&&(u=w.clientY-c.top)}function v(w){if(!f)return;const T=w.clientY-u,E=w.clientY-u,C=w.clientX-d,M=w.clientX-d;["tl","bl","l"].includes(n)&&e(7,o=C),["tl","tr","t"].includes(n)&&e(8,a=T),["tr","r","br"].includes(n)&&e(9,l=M),["br","b","bl"].includes(n)&&e(10,h=E)}async function y(w){await TA(),f=!1,e(11,m=!1)}function b(w,T,E,C,M){let k,P,S,R;return c&&(["tl","l","bl"].includes(w)&&(P=T),["tl","t","tr"].includes(w)&&(k=C),["tr","r","br"].includes(w)&&(S=E),["br","b","bl"].includes(w)&&(R=M)),p("change",{top:k,bottom:R,left:P,right:S}),""}function x(w){gA[w?"unshift":"push"](()=>{g=w,e(2,g)})}return r.$$set=w=>{"type"in w&&e(0,s=w.type),"location"in w&&e(1,n=w.location),"x1"in w&&e(7,o=w.x1),"y1"in w&&e(8,a=w.y1),"x2"in w&&e(9,l=w.x2),"y2"in w&&e(10,h=w.y2),"dragging"in w&&e(11,m=w.dragging)},r.$$.update=()=>{r.$$.dirty&1922&&e(3,i=b(n,o,l,a,h))},[s,n,g,i,_,v,y,o,a,l,h,m,x]}class CA extends _A{constructor(t){super(),vA(this,t,SA,AA,wA,{type:0,location:1,x1:7,y1:8,x2:9,y2:10,dragging:11})}get type(){return this.$$.ctx[0]}set type(t){this.$$set({type:t}),Hr()}get location(){return this.$$.ctx[1]}set location(t){this.$$set({location:t}),Hr()}get x1(){return this.$$.ctx[7]}set x1(t){this.$$set({x1:t}),Hr()}get y1(){return this.$$.ctx[8]}set y1(t){this.$$set({y1:t}),Hr()}get x2(){return this.$$.ctx[9]}set x2(t){this.$$set({x2:t}),Hr()}get y2(){return this.$$.ctx[10]}set y2(t){this.$$set({y2:t}),Hr()}get dragging(){return this.$$.ctx[11]}set dragging(t){this.$$set({dragging:t}),Hr()}}const{SvelteComponent:IA,add_flush_callback:RA,append:cl,attr:On,bind:PA,binding_callbacks:MA,check_outros:kA,create_component:BA,destroy_component:DA,destroy_each:kd,detach:A_,element:Nn,ensure_array_like:ul,flush:bi,group_outros:FA,init:OA,insert:S_,listen:dl,mount_component:NA,noop:C_,run_all:LA,safe_not_equal:UA,set_style:cr,space:GA,subscribe:HA,toggle_class:Bd,transition_in:Ln,transition_out:xh}=window.__gradio__svelte__internal,{createEventDispatcher:$A}=window.__gradio__svelte__internal;function zA(r,t,e){const i=r.slice();return i[30]=t[e],i}function Dd(r,t,e){const i=r.slice();return i[33]=t[e],i}function Fd(r){let t,e,i;function s(a){r[20](a)}function n(...a){return r[21](r[33],...a)}let o={location:r[33]};return r[1]!==void 0&&(o.dragging=r[1]),t=new CA({props:o}),MA.push(()=>PA(t,"dragging",s)),t.$on("change",n),{c(){BA(t.$$.fragment)},m(a,l){NA(t,a,l),i=!0},p(a,l){r=a;const h={};!e&&l[0]&2&&(e=!0,h.dragging=r[1],RA(()=>e=!1)),t.$set(h)},i(a){i||(Ln(t.$$.fragment,a),i=!0)},o(a){xh(t.$$.fragment,a),i=!1},d(a){DA(t,a)}}}function XA(r){let t;return{c(){t=Nn("div"),On(t,"class","svelte-12y7ld0")},m(e,i){S_(e,t,i)},p:C_,d(e){e&&A_(t)}}}function VA(r){let t,e,i,s,n=`${r[3]}px`,o=`${r[2]}px`,a=`${r[4]}px`,l=`${r[5]}px`,h,c,u,d=ul(r[7]),f=[];for(let _=0;_<d.length;_+=1)f[_]=Fd(Dd(r,d,_));const p=_=>xh(f[_],1,1,()=>{f[_]=null});let m=ul({length:25}
1176),g=[];for(let _=0;_<m.length;_+=1)g[_]=XA(zA(r,m,_));return{c(){t=Nn("div"),e=Nn("div");for(let _=0;_<f.length;_+=1)f[_].c();i=GA(),s=Nn("div");for(let _=0;_<g.length;_+=1)g[_].c();On(s,"class","grid svelte-12y7ld0"),Bd(s,"finished",r[6]),On(e,"class","box svelte-12y7ld0"),cr(e,"width",n),cr(e,"height",o),cr(e,"top",a),cr(e,"left",l),On(t,"class","wrap svelte-12y7ld0")},m(_,v){S_(_,t,v),cl(t,e);for(let y=0;y<f.length;y+=1)f[y]&&f[y].m(e,null);cl(e,i),cl(e,s);for(let y=0;y<g.length;y+=1)g[y]&&g[y].m(s,null);h=!0,c||(u=[dl(window,"mousemove",r[11]),dl(window,"mouseup",r[10]),dl(s,"mousedown",r[9])],c=!0)},p(_,v){if(v[0]&386){d=ul(_[7]);let y;for(y=0;y<d.length;y+=1){const b=Dd(_,d,y);f[y]?(f[y].p(b,v),Ln(f[y],1)):(f[y]=Fd(b),f[y].c(),Ln(f[y],1),f[y].m(e,i))}for(FA(),y=d.length;y<f.length;y+=1)p(y);kA()}(!h||v[0]&64)&&Bd(s,"finished",_[6]),v[0]&8&&n!==(n=`${_[3]}px`)&&cr(e,"width",n),v[0]&4&&o!==(o=`${_[2]}px`)&&cr(e,"height",o),v[0]&16&&a!==(a=`${_[4]}px`)&&cr(e,"top",a),v[0]&32&&l!==(l=`${_[5]}px`)&&cr(e,"left",l)},i(_){if(!h){for(let v=0;v<d.length;v+=1)Ln(f[v]);h=!0}},o(_){f=f.filter(Boolean);for(let v=0;v<f.length;v+=1)xh(f[v]);h=!1},d(_){_&&A_(t),kd(f,_),kd(g,_),c=!1,LA(u)}}}function WA(r,t,e){let i,s=C_,n=()=>(s(),s=HA(o,G=>e(19,i=G)),o);r.$$.on_destroy.push(()=>s());let{editor_box:o}=t;n();let{crop_constraint:a}=t;const l=$A();let h=i.child_height,c=i.child_width,u=i.child_top-i.parent_top,d=i.child_left-i.parent_left,f=i.child_right-i.parent_left,p=0,m=!1,{w_p:g}=t,{h_p:_}=t,{l_p:v}=t,{t_p:y}=t;const b=["tl","br","tr","bl","t","b","l","r"];let x,w,T=!1;function E(){w&&clearTimeout(w),e(17,w=setTimeout(()=>{T&&(l("crop_end",{x:v,y,width:g,height:_}),T=!1),e(6,x=!0),e(18,S=!1)},1e3))}function C({top:G,bottom:A,left:L,right:I},B){e(4,u=Yt(G?G-i.parent_top:u,i.child_top-i.parent_top,i.child_bottom-i.parent_top)),e(5,d=Yt(L?L-i.parent_left:d,i.child_left-i.parent_left,i.child_right-i.parent_left)),f=Yt(I?I-i.parent_left:f,i.child_left-i.parent_left,i.child_right-i.parent_left),p=Yt(A?A-i.parent_top:p,i.child_top-i.parent_top,i.child_bottom-i.parent_top),e(3,c=Yt(I?I-d-i.parent_left:c,0,f-d)),e(3,c=Yt(L?f-L+i.parent_left:c,0,f-d)),e(2,h=Yt(A?A-u-i.parent_top:h,0,p-u)),e(2,h=Yt(G?p-G+i.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 it=["t","b"].includes(B)?i.child_width:f-d,ht=["l","r"].includes(B)?i.child_height:p-u;let lt=E_(c,h,J[B],a,it,ht);e(3,c=lt.new_width),e(2,h=lt.new_height),e(5,d=d+lt.x_offset),e(4,u=u+lt.y_offset),f=d+c,p=u+h}e(12,g=c/i.child_width),e(13,_=h/i.child_height),e(14,v=(d-i.child_left+i.parent_left)/i.child_width),e(15,y=(u-i.child_top+i.parent_top)/i.child_height),l(T?"crop_continue":"crop_start",{x:v,y,width:g,height:_}),T=!0}function M(){e(3,c=g*i.child_width),e(2,h=_*i.child_height),e(5,d=v*i.child_width+(i.child_left-i.parent_left)),e(4,u=y*i.child_height+(i.child_top-i.parent_top)),f=d+c,p=u+h}let k=0,P=0,S=!1;function R(G){e(18,S=!0),k=G.clientX,P=G.clientY,x&&(e(6,x=!1),l("crop_start",{x:v,y,width:g,height:_}))}function H(G){S&&e(18,S=!1)}function j(G){if(!S)return;const A=G.clientX-k,L=G.clientY-P;e(5,d=Yt(d+A,i.child_left-i.parent_left,i.child_right-i.parent_left-c)),e(4,u=Yt(u+L,i.child_top-i.parent_top,i.child_bottom-i.parent_top-h)),f=d+c,p=u+h,e(14,v=(d-i.child_left+i.parent_left)/i.child_width),e(15,y=(u-i.child_top+i.parent_top)/i.child_height),k=G.clientX,P=G.clientY,l("crop_continue",{x:v,y,width:g,height:_}),T=!0}function D(G){m=G,e(1,m)}const tt=(G,{detail:A})=>C(A,G);return r.$$set=G=>{"editor_box"in G&&n(e(0,o=G.editor_box)),"crop_constraint"in G&&e(16,a=G.crop_constraint),"w_p"in G&&e(12,g=G.w_p),"h_p"in G&&e(13,_=G.h_p),"l_p"in G&&e(14,v=G.l_p),"t_p"in G&&e(15,y=G.t_p)},r.$$.update=()=>{r.$$.dirty[0]&393218&&(m||S?(clearTimeout(w),e(6,x=!1)):E()),r.$$.dirty[0]&524288&&i&&M()},[o,m,h,c,u,d,x,b,C,R,H,j,g,_,v,y,a,w,S,i,D,tt]}class jA extends IA{constructor(t){super(),OA(this,t,WA,VA,UA,{editor_box:0,crop_constraint:16,w_p:12,h_p:13,l_p:14,t_p:15},null,[-1,-1])}get editor_box(){return this.$$.ctx[0]}set editor_box(t){this.$$set({editor_box:t}),bi()}get crop_constraint(){return this.$$.ctx[16]}set crop_constraint(t){this.$$set({crop_constraint:t}),bi()}get w_p(){return this.$$.ctx[12]}set w_p(t){this.$$set({w_p:t}),bi()}get h_p(){return this.$$.ctx[13]}set h_p(t){this.$$set({h_p:t}),bi()}get l_p(){return this.$$.ctx[14]}set l_p(t){this.$$set({l_p:t}),bi()}get t_p(){return this.$$.ctx[15]}set t_p(t){this.$$set({t_p:t}),bi()}}const{SvelteComponent:YA,check_outros:qA,component_subscribe:xi,create_component:ZA,destroy_component:KA,detach:JA,empty:QA,flush:t2,group_outros:e2,init:r2,insert:i2,mount_component:s2,safe_not_equal:n2,transition_in:Un,transition_out:wh}=window.__gradio__svelte__internal,{getContext:Od,onDestroy:o2,onMount:PC,tick:MC}=window.__gradio__svelte__internal;function Nd(r){let t,e;return t=new jA({props:{crop_constraint:r[0],w_p:r[1],h_p:r[2],l_p:r[3],t_p:r[4],editor_box:r[9]}}),t.$on("crop_start",r[20]),t.$on("crop_continue",r[21]),t.$on("crop_end",r[22]),{c(){ZA(t.$$.fragment)},m(i,s){s2(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.crop_constraint=i[0]),s[0]&2&&(n.w_p=i[1]),s[0]&4&&(n.h_p=i[2]),s[0]&8&&(n.l_p=i[3]),s[0]&16&&(n.t_p=i[4]),t.$set(n)},i(i){e||(Un(t.$$.fragment,i),e=!0)},o(i){wh(t.$$.fragment,i),e=!1},d(i){KA(t,i)}}}function a2(r){let t,e,i=r[5]==="crop"&&r[6]&&Nd(r);return{c(){i&&i.c(),t=QA()},m(s,n){i&&i.m(s,n),i2(s,t,n),e=!0}
1176,p(s,n){s[5]==="crop"&&s[6]?i?(i.p(s,n),n[0]&96&&Un(i,1)):(i=Nd(s),i.c(),Un(i,1),i.m(t.parentNode,t)):i&&(e2(),wh(i,1,1,()=>{i=null}),qA())},i(s){e||(Un(i),e=!0)},o(s){wh(i),e=!1},d(s){s&&JA(t),i&&i.d(s)}}}function l2(r,t,e){let i,s,n,o,a,l;const{active_tool:h,register_tool:c}=Od(So);xi(r,h,A=>e(5,l=A));const{dimensions:u,editor_box:d,pixi:f,crop:p,command_manager:m,current_history:g}=Od(es);xi(r,u,A=>e(18,n=A)),xi(r,d,A=>e(16,i=A)),xi(r,f,A=>e(19,o=A)),xi(r,p,A=>e(17,s=A)),xi(r,g,A=>e(27,a=A));let _,{crop_constraint:v}=t,y=null,b=1,x=1,w=0,T=0,E=0,C=!1,M=null;async function k(){if(M||a.previous)return;const{new_height:A,new_width:L,x_offset:I,y_offset:B}=E_(i.child_width,i.child_height,"c",y,i.child_width,i.child_height);e(1,b=L/i.child_width),e(2,x=A/i.child_height),e(3,w=I/i.child_width),e(4,T=B/i.child_height),M=Id(o.renderer,o.mask_container,p,.2),M.start(...n,H,!1),M.continue([w*n[0],T*n[1],b*n[0],x*n[1]],!1),M.stop(),M.execute(),M=null,E=0}function P(A,{x:L,y:I,width:B,height:J}){if(o){if(A==="start")_&&(E=_.stop(),_=null),_=Id(o?.renderer,o.mask_container,p,E),_.start(...n,H);else if(A==="continue"){if(!_)return;_.continue([L*n[0],I*n[1],B*n[0],J*n[1]])}else if(A==="stop"){if(!_)return;m.execute(_)}e(15,C=!0)}}let S=!1;function R(){if(S||!i.child_height)return;const A=i.child_height,L=i.child_width,I=i.child_top-i.parent_top,B=i.child_left-i.parent_left;e(1,b=L/i.child_width),e(2,x=A/i.child_height),e(3,w=(B-i.child_left+i.parent_left)/i.child_width),e(4,T=(I-i.child_top+i.parent_top)/i.child_height),e(6,S=!0)}let H;const j=c("crop");o2(j);const D=({detail:A})=>P("start",A),tt=({detail:A})=>P("continue",A),G=({detail:A})=>P("stop",A);return r.$$set=A=>{"crop_constraint"in A&&e(14,v=A.crop_constraint)},r.$$.update=()=>{if(r.$$.dirty[0]&16384)if(typeof v=="string"){const[A,L]=v.split(":");e(0,y=parseInt(A)/parseInt(L))}else Array.isArray(v)&&e(0,y=v[0]/v[1]);r.$$.dirty[0]&557089&&!C&&y&&o&&l&&requestAnimationFrame(()=>{k()}),r.$$.dirty[0]&131072&&(e(3,w=s[0]),e(4,T=s[1]),e(1,b=s[2]),e(2,x=s[3])),r.$$.dirty[0]&262174&&(H=[w*n[0],T*n[1],b*n[0],x*n[1]]),r.$$.dirty[0]&65536&&i&&R()},[y,b,x,w,T,l,S,h,u,d,f,p,g,P,v,C,i,s,n,o,D,tt,G]}class h2 extends YA{constructor(t){super(),r2(this,t,l2,a2,n2,{crop_constraint:14},null,[-1,-1])}get crop_constraint(){return this.$$.ctx[14]}set crop_constraint(t){this.$$set({crop_constraint:t}),t2()}}function c2(r,t,e,i){let s;return{async start(){r.removeChildren();const n=await createImageBitmap(e),o=Y.from(n);return s=new Wt(o),[s.width,s.height]},async execute(){i(s.width,s.height),s.zIndex=0,r.addChild(s)},undo(){r.removeChildAt(0)}}}function u2(r,t,e,i,s,n){let o;return{start(){r.removeChildren();const a=p_(1),l=$t.create({width:i,height:s});return a.beginFill(new ft(e)),a.drawRect(0,0,i,s),a.endFill(),t.render(a,{renderTexture:l}),o=new Wt(l),[o.width,o.height]},async execute(){n(o.width,o.height),o.zIndex=1,r.addChild(o)},undo(){r.removeChildren()}}}const{SvelteComponent:d2,add_flush_callback:f2,append:Gn,attr:As,bind:p2,binding_callbacks:I_,bubble:fl,check_outros:Th,component_subscribe:pn,create_component:Zh,destroy_component:Kh,detach:Gi,element:Ss,empty:R_,ensure_array_like:Ld,flush:Re,group_outros:Eh,init:_2,insert:Hi,is_function:m2,listen:g2,mount_component:Jh,outro_and_destroy_block:y2,safe_not_equal:v2,set_store_value:cs,set_style:gr,space:pl,toggle_class:Ud,transition_in:Ue,transition_out:wr,update_keyed_each:b2}=window.__gradio__svelte__internal,{getContext:Gd,onMount:kC,tick:x2,createEventDispatcher:w2}=window.__gradio__svelte__internal;function Hd(r,t,e){const i=r.slice();return i[36]=t[e].icon,i[37]=t[e].label,i[38]=t[e].id,i[39]=t[e].cb,i}function $d(r){let t,e=[],i=new Map,s,n,o,a,l,h,c,u=`${r[12].child_height+(r[12].child_top-r[12].parent_top)}px`,d,f=Ld(r[10]);const p=v=>v[38];for(let v=0;v<f.length;v+=1){let y=Hd(r,f,v),b=p(y);i.set(b,e[v]=zd(b,y))}function m(v){r[22](v)}let g={hidden:r[2]||r[1]==="webcam"||r[11]!=="bg",filetype:"image/*",root:r[3],disable_click:!r[4].includes("upload"),format:"blob",upload:r[7],stream_handler:r[8]};r[0]!==void 0&&(g.dragging=r[0]),l=new K_({props:g}),r[21](l),I_.push(()=>
1176p2(l,"dragging",m)),l.$on("load",r[17]),l.$on("error",r[23]);let _=r[1]==="webcam"&&Xd(r);return{c(){t=Ss("div");for(let v=0;v<e.length;v+=1)e[v].c();s=pl(),n=Ss("span"),o=pl(),a=Ss("div"),Zh(l.$$.fragment),c=pl(),_&&_.c(),As(n,"class","sep svelte-ip7ypz"),As(t,"class","source-wrap svelte-ip7ypz"),As(a,"class","upload-container svelte-ip7ypz"),Ud(a,"click-disabled",!!r[2]||r[1]==="webcam"||r[11]!=="bg"),gr(a,"height",u)},m(v,y){Hi(v,t,y);for(let b=0;b<e.length;b+=1)e[b]&&e[b].m(t,null);Gn(t,s),Gn(t,n),Hi(v,o,y),Hi(v,a,y),Jh(l,a,null),Gn(a,c),_&&_.m(a,null),d=!0},p(v,y){y[0]&1024&&(f=Ld(v[10]),Eh(),e=b2(e,y,p,1,v,f,i,t,y2,zd,s,Hd),Th());const b={};y[0]&2054&&(b.hidden=v[2]||v[1]==="webcam"||v[11]!=="bg"),y[0]&8&&(b.root=v[3]),y[0]&16&&(b.disable_click=!v[4].includes("upload")),y[0]&128&&(b.upload=v[7]),y[0]&256&&(b.stream_handler=v[8]),!h&&y[0]&1&&(h=!0,b.dragging=v[0],f2(()=>h=!1)),l.$set(b),v[1]==="webcam"?_?(_.p(v,y),y[0]&2&&Ue(_,1)):(_=Xd(v),_.c(),Ue(_,1),_.m(a,null)):_&&(Eh(),wr(_,1,1,()=>{_=null}),Th()),(!d||y[0]&2054)&&Ud(a,"click-disabled",!!v[2]||v[1]==="webcam"||v[11]!=="bg"),y[0]&4096&&u!==(u=`${v[12].child_height+(v[12].child_top-v[12].parent_top)}px`)&&gr(a,"height",u)},i(v){if(!d){for(let y=0;y<f.length;y+=1)Ue(e[y]);Ue(l.$$.fragment,v),Ue(_),d=!0}},o(v){for(let y=0;y<e.length;y+=1)wr(e[y]);wr(l.$$.fragment,v),wr(_),d=!1},d(v){v&&(Gi(t),Gi(o),Gi(a));for(let y=0;y<e.length;y+=1)e[y].d();r[21](null),Kh(l),_&&_.d()}}}function zd(r,t){let e,i,s;return i=new Bi({props:{Icon:t[36],size:"medium",padded:!1,label:t[37]+" button",hasPopup:!0,transparent:!0}}),i.$on("click",function(){m2(t[39])&&t[39].apply(this,arguments)}),{key:r,first:null,c(){e=R_(),Zh(i.$$.fragment),this.first=e},m(n,o){Hi(n,e,o),Jh(i,n,o),s=!0},p(n,o){t=n;const a={};o[0]&1024&&(a.Icon=t[36]),o[0]&1024&&(a.label=t[37]+" button"),i.$set(a)},i(n){s||(Ue(i.$$.fragment,n),s=!0)},o(n){wr(i.$$.fragment,n),s=!1},d(n){n&&Gi(e),Kh(i,n)}}}function Xd(r){let t,e,i,s=`${r[12].child_width}px`,n=`${r[12].child_height}px`,o=`${r[12].child_top-r[12].parent_top}px`,a;return i=new X_({props:{upload:r[7],root:r[3],mirror_webcam:r[5],streaming:!1,mode:"image",include_audio:!1,i18n:r[6]}}),i.$on("capture",r[17]),i.$on("error",r[24]),i.$on("drag",r[25]),{c(){t=Ss("div"),e=Ss("div"),Zh(i.$$.fragment),As(e,"class","modal-inner svelte-ip7ypz"),As(t,"class","modal svelte-ip7ypz"),gr(t,"max-width",s),gr(t,"max-height",n),gr(t,"top",o)},m(l,h){Hi(l,t,h),Gn(t,e),Jh(i,e,null),a=!0},p(l,h){const c={};h[0]&128&&(c.upload=l[7]),h[0]&8&&(c.root=l[3]),h[0]&32&&(c.mirror_webcam=l[5]),h[0]&64&&(c.i18n=l[6]),i.$set(c),h[0]&4096&&s!==(s=`${l[12].child_width}px`)&&gr(t,"max-width",s),h[0]&4096&&n!==(n=`${l[12].child_height}px`)&&gr(t,"max-height",n),h[0]&4096&&o!==(o=`${l[12].child_top-l[12].parent_top}px`)&&gr(t,"top",o)},i(l){a||(Ue(i.$$.fragment,l),a=!0)},o(l){wr(i.$$.fragment,l),a=!1},d(l){l&&Gi(t),Kh(i)}}}function T2(r){let t,e,i,s,n=r[4].length&&$d(r);return{c(){n&&n.c(),t=R_()},m(o,a){n&&n.m(o,a),Hi(o,t,a),e=!0,i||(s=g2(window,"keydown",r[18]),i=!0)},p(o,a){o[4].length?n?(n.p(o,a),a[0]&16&&Ue(n,1)):(n=$d(o),n.c(),Ue(n,1),n.m(t.parentNode,t)):n&&(Eh(),wr(n,1,1,()=>{n=null}),Th())},i(o){e||(Ue(n),e=!0)},o(o){wr(n),e=!1},d(o){o&&Gi(t),n&&n.d(o),i=!1,s()}}}function E2(r,t,e){let i,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,{upload:f}=t,{stream_handler:p}=t,{dragging:m}=t;const{active_tool:g}=Gd(So);pn(r,g,I=>e(11,o=I));const{pixi:_,dimensions:v,register_context:y,reset:b,editor_box:x}=Gd(es);pn(r,_,I=>e(28,n=I)),pn(r,v,I=>e(27,s=I)),pn(r,x,I=>e(12,a=I));let{active_mode:w=null}=t,T;w2();const E={upload:{icon:Ph,label:"Upload",order:0,id:"bg_upload",cb(){C.open_file_upload(),cs(g,o="bg",o)}},webcam:{icon:Z_,label:"Webcam",order:1,id:"bg_webcam",cb(){e(1,w="webcam"),cs(g,o="bg",o)}},clipboard:{icon:q_,label:"Paste",order:2,id:"bg_clipboard",cb(){M(),cs(g,o=null,o)}}};let C;async function M(){const I=await navigator.clipboard.read();for(let B=0;B<I.length;B++){const J=I[B].types.find(it=>it.startsWith("image/"));if(J){const it=await I[B].getType(J);e(20,T=it||null)}}}function k(I){const B=I.detail;e(20,T=B),e(1,w=null)}let P=!0;async function S(){if(n&&T){const I=c2(n.background_container,n.renderer,T,n.resize);cs(v,s=await I.start(),s),P&&b(!1,s),I.execute(),P=!0,await x2(),e(2,j=!0)}}async function R(I){if(!I||!I.url)return;P=!1;const J=await(await fetch(I.url)).blob();e(20,T=J)}function H(I){I.key==="Escape"&&e(1,w=null)}let{bg:j=!1}=t;y("bg",{init_fn:()=>
1176{if(!n)return;const I=u2(n.background_container,n.renderer,"black",...s,n.resize);cs(v,s=I.start(),s),I.execute()},reset_fn:()=>{}});function D(I){I_[I?"unshift":"push"](()=>{C=I,e(9,C)})}function tt(I){m=I,e(0,m)}function G(I){fl.call(this,r,I)}function A(I){fl.call(this,r,I)}function L(I){fl.call(this,r,I)}return r.$$set=I=>{"background_file"in I&&e(19,l=I.background_file),"root"in I&&e(3,h=I.root),"sources"in I&&e(4,c=I.sources),"mirror_webcam"in I&&e(5,u=I.mirror_webcam),"i18n"in I&&e(6,d=I.i18n),"upload"in I&&e(7,f=I.upload),"stream_handler"in I&&e(8,p=I.stream_handler),"dragging"in I&&e(0,m=I.dragging),"active_mode"in I&&e(1,w=I.active_mode),"bg"in I&&e(2,j=I.bg)},r.$$.update=()=>{r.$$.dirty[0]&16&&e(10,i=c.map(I=>E[I]).sort((I,B)=>I.order-B.order)),r.$$.dirty[0]&1048576&&T&&S(),r.$$.dirty[0]&524288&&R(l)},[m,w,j,h,c,u,d,f,p,C,i,o,a,g,_,v,x,k,H,l,T,D,tt,G,A,L]}class A2 extends d2{constructor(t){super(),_2(this,t,E2,T2,v2,{background_file:19,root:3,sources:4,mirror_webcam:5,i18n:6,upload:7,stream_handler:8,dragging:0,active_mode:1,bg:2},null,[-1,-1])}get background_file(){return this.$$.ctx[19]}set background_file(t){this.$$set({background_file:t}),Re()}get root(){return this.$$.ctx[3]}set root(t){this.$$set({root:t}),Re()}get sources(){return this.$$.ctx[4]}set sources(t){this.$$set({sources:t}),Re()}get mirror_webcam(){return this.$$.ctx[5]}set mirror_webcam(t){this.$$set({mirror_webcam:t}),Re()}get i18n(){return this.$$.ctx[6]}set i18n(t){this.$$set({i18n:t}),Re()}get upload(){return this.$$.ctx[7]}set upload(t){this.$$set({upload:t}),Re()}get stream_handler(){return this.$$.ctx[8]}set stream_handler(t){this.$$set({stream_handler:t}),Re()}get dragging(){return this.$$.ctx[0]}set dragging(t){this.$$set({dragging:t}),Re()}get active_mode(){return this.$$.ctx[1]}set active_mode(t){this.$$set({active_mode:t}),Re()}get bg(){return this.$$.ctx[2]}set bg(t){this.$$set({bg:t}),Re()}}const{SvelteComponent:S2,append:_n,attr:Ah,check_outros:C2,create_component:Hn,destroy_component:$n,detach:P_,element:Sh,flush:mn,group_outros:I2,init:R2,insert:M_,mount_component:zn,safe_not_equal:P2,space:_l,transition_in:qr,transition_out:Pi}=window.__gradio__svelte__internal,{createEventDispatcher:M2}=window.__gradio__svelte__internal;function Vd(r){let t,e,i;return e=new Bi({props:{disabled:!r[2],Icon:j_,label:"Save changes",background:"var(--color-green-500)",color:"#fff"}}),e.$on("click",r[8]),{c(){t=Sh("div"),Hn(e.$$.fragment),Ah(t,"class","row-wrap save svelte-4lttvb")},m(s,n){M_(s,t,n),zn(e,t,null),i=!0},p(s,n){const o={};n&4&&(o.disabled=!s[2]),e.$set(o)},i(s){i||(qr(e.$$.fragment,s),i=!0)},o(s){Pi(e.$$.fragment,s),i=!1},d(s){s&&P_(t),$n(e)}}}function k2(r){let t,e,i,s,n,o,a,l,h;i=new Bi({props:{disabled:!r[0],Icon:Y_,label:"Undo"}}),i.$on("click",r[5]),n=new Bi({props:{disabled:!r[1],Icon:sg,label:"Redo"}}),n.$on("click",r[6]),a=new Bi({props:{Icon:dg,label:"Clear canvas"}}),a.$on("click",r[7]);let c=r[3]&&Vd(r);return{c(){t=Sh("div"),e=Sh("div"),Hn(i.$$.fragment),s=_l(),Hn(n.$$.fragment),o=_l(),Hn(a.$$.fragment),l=_l(),c&&c.c(),Ah(e,"class","row-wrap svelte-4lttvb"),Ah(t,"class","controls-wrap svelte-4lttvb")},m(u,d){M_(u,t,d),_n(t,e),zn(i,e,null),_n(e,s),zn(n,e,null),_n(e,o),zn(a,e,null),_n(t,l),c&&c.m(t,null),h=!0},p(u,[d]){const f={};d&1&&(f.disabled=!u[0]),i.$set(f);const p={};d&2&&(p.disabled=!u[1]),n.$set(p),u[3]?c?(c.p(u,d),d&8&&qr(c,1)):(c=Vd(u),c.c(),qr(c,1),c.m(t,null)):c&&(I2(),Pi(c,
11761,1,()=>{c=null}),C2())},i(u){h||(qr(i.$$.fragment,u),qr(n.$$.fragment,u),qr(a.$$.fragment,u),qr(c),h=!0)},o(u){Pi(i.$$.fragment,u),Pi(n.$$.fragment,u),Pi(a.$$.fragment,u),Pi(c),h=!1},d(u){u&&P_(t),$n(i),$n(n),$n(a),c&&c.d()}}}function B2(r,t,e){let{can_undo:i=!1}=t,{can_redo:s=!1}=t,{can_save:n=!1}=t,{changeable:o=!1}=t;const a=M2(),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 r.$$set=d=>{"can_undo"in d&&e(0,i=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)},[i,s,n,o,a,l,h,c,u]}class D2 extends S2{constructor(t){super(),R2(this,t,B2,k2,P2,{can_undo:0,can_redo:1,can_save:2,changeable:3})}get can_undo(){return this.$$.ctx[0]}set can_undo(t){this.$$set({can_undo:t}),mn()}get can_redo(){return this.$$.ctx[1]}set can_redo(t){this.$$set({can_redo:t}),mn()}get can_save(){return this.$$.ctx[2]}set can_save(t){this.$$set({can_save:t}),mn()}get changeable(){return this.$$.ctx[3]}set changeable(t){this.$$set({changeable:t}),mn()}}const{SvelteComponent:F2,append:$r,attr:wi,binding_callbacks:Wd,component_subscribe:ae,create_component:O2,create_slot:N2,destroy_component:L2,detach:U2,element:us,flush:Pe,get_all_dirty_from_scope:G2,get_slot_changes:H2,globals:$2,init:z2,insert:X2,listen:V2,mount_component:W2,safe_not_equal:j2,set_store_value:jd,set_style:Me,space:ml,toggle_class:gn,transition_in:Yd,transition_out:qd,update_slot_base:Y2}=window.__gradio__svelte__internal,{window:q2}=$2,{onMount:Z2,setContext:K2,createEventDispatcher:J2,tick:Q2}=window.__gradio__svelte__internal;function tS(r){let t,e,i,s,n,o=`translate(${r[8].x}px, ${r[8].y}px)`,a,l,h,c,u=`${r[9][2]*r[10].child_width+1}px`,d=`${r[9][3]*r[10].child_height+1}px`,f=`${r[9][1]*r[10].child_height+(r[10].child_top-r[10].parent_top)-.5}px`,p=`${r[9][0]*r[10].child_width+(r[10].child_left-r[10].parent_left)-.5}px`,m,g,_;e=new D2({props:{can_undo:r[12],can_redo:r[13],can_save:r[11]!==r[7],changeable:r[2]}}),e.$on("undo",r[19].undo),e.$on("redo",r[19].redo),e.$on("remove_image",r[3]),e.$on("save",r[28]);const v=r[39].default,y=N2(v,r,r[38],null);return{c(){t=us("div"),O2(e.$$.fragment),i=ml(),s=us("div"),n=us("div"),a=ml(),l=us("div"),y&&y.c(),h=ml(),c=us("div"),wi(n,"class","stage-wrap svelte-1mn8392"),gn(n,"bg",!r[1]),Me(n,"transform",o),wi(s,"class","wrap svelte-1mn8392"),wi(l,"class","tools-wrap svelte-1mn8392"),wi(c,"class","canvas svelte-1mn8392"),gn(c,"no-border",!r[1]&&r[6]==="bg"&&!r[0]),Me(c,"width",u),Me(c,"height",d),Me(c,"top",f),Me(c,"left",p),wi(t,"data-testid","image"),wi(t,"class","image-container svelte-1mn8392")},m(b,x){X2(b,t,x),W2(e,t,null),$r(t,i),$r(t,s),$r(s,n),r[41](n),r[42](s),$r(t,a),$r(t,l),y&&y.m(l,null),$r(t,h),$r(t,c),m=!0,g||(_=V2(q2,"scroll",r[40]),g=!0)},p(b,x){const w={};x[0]&4096&&(w.can_undo=b[12]),x[0]&8192&&(w.can_redo=b[13]),x[0]&2176&&(w.can_save=b[11]!==b[7]),x[0]&4&&(w.changeable=b[2]),e.$set(w),(!m||x[0]&2)&&gn(n,"bg",!b[1]),x[0]&256&&o!==(o=`translate(${b[8].x}px, ${b[8].y}px)`)&&Me(n,"transform",o),y&&y.p&&(!m||x[1]&128)&&Y2(y,v,b,b[38],m?H2(v,b[38],x,null):G2(b[38]),null),(!m||x[0]&67)&&gn(c,"no-border",!b[1]&&b[6]==="bg"&&!b[0]),x[0]&1536&&u!==(u=`${b[9][2]*b[10].child_width+1}px`)&&Me(c,"width",u),x[0]&1536&&d!==(d=`${b[9][3]*b[10].child_height+1}px`)&&Me(c,"height",d),x[0]&1536&&f!==(f=`${b[9][1]*b[10].child_height+(b[10].child_top-b[10].parent_top)-.5}px`)&&Me(c,"top",f),x[0]&1536&&p!==(p=`${b[9][0]*b[10].child_width+(b[10].child_left-b[10].parent_left)-.5}px`)&&Me(c,"left",p)},i(b){m||(Yd(e.$$.fragment,b),Yd(y,b),m=!0)},o(b){qd(e.$$.fragment,b),qd(y,b),m=!1},d(b){b&&U2(t),L2(e),r[41](null),r[42](null),y&&y.d(b),g=!1,_()}}}const es=Symbol("editor");function eS(r,t,e){let i,s,n,o,a,l,h,c,u,d,f,p,m,{$$slots:g={},$$scope:_}=t,{antialias:v=!0}=t,{crop_size:y}=t,{changeable:b=!1}=t,{history:x}=t,{bg:w=!1}=t,{sources:T}=t;const E=J2();let{crop_constraint:C=!1}=t,{canvas_size:M}=t,{parent_height:k}=t,S=jt(M||[800,600]);ae(r,S,z=>e(47,h=z));let{height:R=0}=t,H=jt({parent_width:0,parent_height:k,parent_top:0,parent_left:0,parent_right:0,parent_bottom:0,child_width:0,child_height:k,child_top:0,child_left:0,child_right:0,child_bottom:0});ae(r,H,z=>e(10,f=z));const j=jt([0,0,1,1]);ae(r,j,z=>e(9,d=z));const D=yf({x:0,y:0},{stiffness:.1,damping:.5});ae(r,D,z=>e(8,u=z));const tt=jt(null);ae(r,tt,z=>e(46,l=z));const G=LT(),{can_redo:A,can_undo:L,current_history:I}=G;ae(r,A,z=>e(13,m=z)),ae(r,L,z=>e(12,p=z)),ae(r,I,z=>e(7,n=z));const B=typeof window<"u",J=jt("bg");ae(r,J,z=>e(6,s=z));const it=jt({});ae(r,it,z=>e(44,o=z));const ht=jt({});ae(r,ht,z=>e(48,c=z));const lt=jt([]);ae(r,lt,z=>e(45,a=z));const yt=jt(B?new DOMRect:{}),Tt=["bg","layers","crop","draw","erase"],mt=K2(es,{pixi:tt,current_layer:jt(null),dimensions:S,editor_box:H,toolbar_box:yt,active_tool:J,crop:j,position_spring:D,command_manager:G,current_history:I,register_context:(z,{reset_fn:O,init_fn:Xt})=>{lt.update(_t=>[..._t,z]),ht.update(_t=>({..._t,[z]:Xt})),it.update(_t=>({..._t,[z]:O}))},reset:(z,O)=>
1176{e(1,w=!1);const Xt=a.sort((_t,Bt)=>Tt.indexOf(_t)-Tt.indexOf(Bt));for(const _t of Xt)_t in o&&typeof o[_t]=="function"&&o[_t]?.();for(const _t of Xt){if(_t in c&&typeof c[_t]=="function"){if(_t==="bg"&&!z)continue;c[_t]?.(O)}G.reset(),l?.resize?.(...O)}}});let st,F;function ot(z,O){if(!z||!O)return;const{width:Xt,height:_t,top:Bt,left:Or,right:jo,bottom:Yo}=F.getBoundingClientRect(),{width:qo,height:Zo,top:U_,left:G_,right:H_,bottom:$_}=O.getBoundingClientRect();H.set({child_width:qo,child_height:Zo,child_left:G_,child_right:H_,child_top:U_,child_bottom:$_,parent_width:Xt,parent_height:_t,parent_left:Or,parent_right:jo,parent_top:Bt,parent_bottom:Yo})}function U(){requestAnimationFrame(()=>{Q2().then(z=>jd(J,s="crop",s))})}function ut(){if(!f)return;const[z,O,Xt,_t]=d,Bt=z*f.child_width,Or=O*f.child_height,jo=Xt*f.child_width,Yo=_t*f.child_height,qo=.5*f.child_width-Bt-jo/2,Zo=.5*f.child_height-Or-Yo/2;D.set({x:qo,y:Zo})}async function pt(){if(!l||!l.get_layers)return{background:null,layers:[],composite:null};const[z,O,Xt,_t]=d;return l?.get_blobs(l.get_layers(),new et(Math.round(z*h[0]),Math.round(O*h[1]),Math.round(Xt*h[0]),Math.round(_t*h[1])),h)}function Lt(){mt.reset(!0,i||h),T.length?Fr("bg"):Fr("draw"),E("clear")}Z2(()=>{const O=NT({target:st,dimensions:M||y||[800,600],antialias:v});function Xt(Bt,Or){O.resize(Bt,Or),S.set([Bt,Or])}tt.set({...O,resize:Xt});const _t=new ResizeObserver(Bt=>{for(const Or of Bt)ot(F,st)});_t.observe(F),_t.observe(st);for(const Bt of a)Bt in c&&typeof c[Bt]=="function"&&c[Bt]?.(h);return Xt(...h),()=>{l?.destroy(),_t.disconnect();for(const Bt of a)Bt in o&&o[Bt]?.()}});let Kt=n;function de(){e(11,Kt=n),E("save")}function Fr(z){jd(J,s=z,s)}const Xo=()=>ot(F,st);function Vo(z){Wd[z?"unshift":"push"](()=>{st=z,e(4,st)})}function Wo(z){Wd[z?"unshift":"push"](()=>{F=z,e(5,F)})}return r.$$set=z=>{"antialias"in z&&e(30,v=z.antialias),"crop_size"in z&&e(31,y=z.crop_size),"changeable"in z&&e(2,b=z.changeable),"history"in z&&e(0,x=z.history),"bg"in z&&e(1,w=z.bg),"sources"in z&&e(32,T=z.sources),"crop_constraint"in z&&e(33,C=z.crop_constraint),"canvas_size"in z&&e(34,M=z.canvas_size),"parent_height"in z&&e(35,k=z.parent_height),"height"in z&&e(29,R=z.height),"$$scope"in z&&e(38,_=z.$$scope)},r.$$.update=()=>{r.$$.dirty[1]&8&&(i=M),r.$$.dirty[0]&1024&&e(29,R=f.child_height),r.$$.dirty[0]&128&&(n.previous,E("change")),r.$$.dirty[0]&192&&e(0,x=!!n.previous||s!=="bg"),r.$$.dirty[0]&3|r.$$.dirty[1]&4&&C&&w&&!x&&U(),r.$$.dirty[0]&512&&d&&ut(),r.$$.dirty[0]&304&&u&&ot(F,st)},[x,w,b,Lt,st,F,s,n,u,d,f,Kt,p,m,S,H,j,D,tt,G,A,L,I,J,it,ht,lt,ot,de,R,v,y,T,C,M,k,pt,Fr,_,g,Xo,Vo,Wo]}class rS extends F2{constructor(t){super(),z2(this,t,eS,tS,j2,{antialias:30,crop_size:31,changeable:2,history:0,bg:1,sources:32,crop_constraint:33,canvas_size:34,parent_height:35,height:29,get_blobs:36,handle_remove:3,set_tool:37},null,[-1,-1])}get antialias(){return this.$$.ctx[30]}set antialias(t){this.$$set({antialias:t}),Pe()}get crop_size(){return this.$$.ctx[31]}set crop_size(t){this.$$set({crop_size:t}),Pe()}get changeable(){return this.$$.ctx[2]}set changeable(t){this.$$set({changeable:t}),Pe()}get history(){return this.$$.ctx[0]}set history(t){this.$$set({history:t}),Pe()}get bg(){return this.$$.ctx[1]}set bg(t){this.$$set({bg:t}),Pe()}get sources(){return this.$$.ctx[32]}set sources(t){this.$$set({sources:t}),Pe()}get crop_constraint(){return this.$$.ctx[33]}set crop_constraint(t){this.$$set({crop_constraint:t}),Pe()}get canvas_size(){return this.$$.ctx[34]}set canvas_size(t){this.$$set({canvas_size:t}),Pe()}get parent_height(){return this.$$.ctx[35]}set parent_height(t){this.$$set({parent_height:t}),Pe()}get height(){return this.$$.ctx[29]}set height(t){this.$$set({height:t}),Pe()}get get_blobs(){return this.$$.ctx[36]}get handle_remove(){return this.$$.ctx[3]}get set_tool(){return this.$$.ctx[37]}}const{SvelteComponent:iS,action_destroyer:sS,append:re,attr:xe,check_outros:nS,component_subscribe:gl,create_component:oS,destroy_block:aS,destroy_component:lS,detach:Go,element:ir,empty:hS,ensure_array_like:Zd,flush:Kd,group_outros:cS,init:uS,insert:Ho,is_function:dS,listen:Qh,mount_component:fS,run_all:pS,safe_not_equal:_S,set_data:k_,set_store_value:yn,space:Ch,text:To,toggle_class:Eo,transition_in:Xn,transition_out:Ih,update_keyed_each:mS}=window.__gradio__svelte__internal,{getContext:gS,onMount:yS,tick:Jd}=window.__gradio__svelte__internal;function Qd(r,t,e){const i=r.slice();return i[19]=t[e],i[21]=e,i}function tf(r){let t,e,i,s,n,o=r[2].findIndex(r[11])+1+"",a,l,h,c,u,d,f,p;s=new zm({});let m=r[1]&&ef(r);return{c(){t=ir("div"),e=ir("button"),i=ir("span"),oS(s.$$.fragment),n=To(" Layer "),a=To(o),l=Ch(),m&&m.c(),h=Ch(),c=ir("span"),xe(i,"class","icon svelte-wbw3z5"),xe(e,"aria-label","Show Layers"),xe(e,"class","svelte-wbw3z5"),xe(c,"class","sep svelte-wbw3z5"),xe(t,"class","layer-wrap svelte-wbw3z5"),Eo(t,"closed",!r[1])},m(g,_){Ho(g,t,_),re(t,e),re(e,i),fS(s,i,null),re(e,n),re(e,a),re(t,l),m&&m.m(t,null),re(t,h),re(t,c),d=!0,f||(p=[Qh(e,"click",r[12]),sS(u=Yh.call(null,t,r[14]))],f=!0)},p(g,_){(!d||_&12)&&o!==(o=g[2].findIndex(g[11])+1+"")&&k_(a,o),g[1]?m?m.p(g,_):(m=ef(g),m.c(),m.m(t,h)):m&&(m.d(1),m=null),u&&dS(u.update)&&_&2&&u.update.call(null,g[14]),(!d||_&2)&&Eo(t,"closed",!g[1])},i(g){d||(Xn(s.$$.fragment,g),d=!0)},o(g){Ih(s.$$.fragment,g),d=!1},d(g){g&&Go(t),lS(s),m&&m.d(),f=!1,pS(p)}}}function ef(r){let t,e=[],i=new Map,s,n,o,a,l,h=Zd(r[2]);const c=u=>u[21];for(let u=0;u<h.length;u+=1){let d=Qd(r,h,u),f=c(d);i.set(f,e[u]=rf(f,d))}return{c(){t=ir("ul");for(let u=0;u<e.length;u+=1)e[u].c();s=Ch(),n=ir("li"),o=ir("button"),o.textContent="+",xe(o,"aria-label","Add Layer"),xe(o,"class","svelte-wbw3z5"),xe(n,"class","svelte-wbw3z5"),xe(t,"class","svelte-wbw3z5")},m(u,d){Ho(u,t,d);for(let f=0;f<e.length;f+=1)e[f]&&e[f].m(t,null);re(t,s),re(t,n),re(n,o),a||(l=Qh(o,"click",r[8]),a=!0)},p(u,d){d&140&&(h=Zd(u[2]),e=mS(e,d,c,1,u,h,i,t,aS,rf,s,Qd))},d(u){u&&Go(t);for(let d=0;d<e.length;d+=1)e[d].d();a=!1,l()}}}function rf(r,t){let e,i,s,n=t[21]+1+"",o,a,l;function h(){return t[13](t[21])}return{key:r,first:null,c(){e=ir("li"),i=ir("button"),s=To("Layer "),o=To(n),xe(i,"class","svelte-wbw3z5"),Eo(i,"selected_layer",t[3]===t[19]),xe(e,"class","svelte-wbw3z5"),this.first=e}
1176,m(c,u){Ho(c,e,u),re(e,i),re(i,s),re(i,o),a||(l=Qh(i,"click",h),a=!0)},p(c,u){t=c,u&4&&n!==(n=t[21]+1+"")&&k_(o,n),u&12&&Eo(i,"selected_layer",t[3]===t[19])},d(c){c&&Go(e),a=!1,l()}}}function vS(r){let t,e,i=r[0]&&tf(r);return{c(){i&&i.c(),t=hS()},m(s,n){i&&i.m(s,n),Ho(s,t,n),e=!0},p(s,[n]){s[0]?i?(i.p(s,n),n&1&&Xn(i,1)):(i=tf(s),i.c(),Xn(i,1),i.m(t.parentNode,t)):i&&(cS(),Ih(i,1,1,()=>{i=null}),nS())},i(s){e||(Xn(i),e=!0)},o(s){Ih(i),e=!1},d(s){s&&Go(t),i&&i.d(s)}}}function bS(r){return r!==null}function xS(r,t,e){let i,s,n,o=!1,{layer_files:a=[]}=t,{enable_layers:l=!0}=t;const{pixi:h,current_layer:c,dimensions:u,register_context:d}=gS(es);gl(r,h,w=>e(15,i=w)),gl(r,c,w=>e(3,s=w)),gl(r,u,w=>e(10,n=w));const f=FT();let p=[];d("layers",{init_fn:()=>{g()},reset_fn:()=>{f.reset()}});async function m(){p.some(T=>T.composite.texture?.width!=n[0]||T.composite.texture?.height!=n[1])&&(f.reset(),!a||a.length==0?g():_(a))}async function g(){if(!i)return;const[w,T]=f.add_layer(i.layer_container,i.renderer,...n);yn(c,s=w,s),e(2,p=T)}async function _(w){if(await Jd(),!w||w.length==0){f.reset(),g();return}if(!i)return;const T=await Promise.all(w.map(M=>!M||!M.url?null:fetch(M.url))),E=await Promise.all(T.map(M=>M?M.blob():null));f.reset();let C=null;for(const M of E.filter(bS))C=await f.add_layer_from_blob(i.layer_container,i.renderer,M,i.view);C&&(yn(c,s=C[0],s),e(2,p=C[1]))}yS(async()=>{await Jd(),i&&yn(h,i={...i,get_layers:f.get_layers},i)});const v=w=>w===s,y=()=>e(1,o=!o),b=w=>yn(c,s=f.change_active_layer(w),s),x=()=>e(1,o=!1);return r.$$set=w=>{"layer_files"in w&&e(9,a=w.layer_files),"enable_layers"in w&&e(0,l=w.enable_layers)},r.$$.update=()=>{r.$$.dirty&1024&&m(),r.$$.dirty&512&&_(a)},[l,o,p,s,h,c,u,f,g,a,n,v,y,b,x]}class wS extends iS{constructor(t){super(),uS(this,t,xS,vS,_S,{layer_files:9,enable_layers:0})}get layer_files(){return this.$$.ctx[9]}set layer_files(t){this.$$set({layer_files:t}),Kd()}get enable_layers(){return this.$$.ctx[0]}set enable_layers(t){this.$$set({enable_layers:t}),Kd()}}const TS=/^(#\s*)(.+)$/m;function ES(r){const t=r.trim(),e=t.match(TS);if(!e)return[!1,t||!1];const[i,,s]=e,n=s.trim();if(t===i)return[n,!1];const o=e.index!==void 0?e.index+i.length:0,l=t.substring(o).trim()||!1;return[n,l]}const{SvelteComponent:AS,add_flush_callback:$i,append:Ao,attr:$o,bind:zi,binding_callbacks:ii,bubble:SS,check_outros:yl,create_component:Ir,destroy_component:Rr,detach:Ot,element:rs,empty:zo,flush:At,group_outros:vl,init:CS,insert:Nt,mount_component:Pr,noop:IS,safe_not_equal:RS,set_data:B_,set_style:sf,space:sr,text:D_,transition_in:Dt,transition_out:qt}=window.__gradio__svelte__internal,{createEventDispatcher:PS}=window.__gradio__svelte__internal;function nf(r){let t,e;return t=new h2({props:{crop_constraint:r[26]}}),{c(){Ir(t.$$.fragment)},m(i,s){Pr(t,i,s),e=!0},p(i,s){const n={};s[0]&67108864&&(n.crop_constraint=i[26]),t.$set(n)},i(i){e||(Dt(t.$$.fragment,i),e=!0)},o(i){qt(t.$$.fragment,i),e=!1},d(i){Rr(t,i)}}}function of(r){let t,e;return t=new T_({props:{color_mode:r[1].color_mode,default_color:r[1].default_color,default_size:r[1].default_size,colors:r[1].colors,mode:"draw"}}),{c(){Ir(t.$$.fragment)},m(i,s){Pr(t,i,s),e=!0},p(i,s){const n={};s[0]&2&&(n.color_mode=i[1].color_mode),s[0]&2&&(n.default_color=i[1].default_color),s[0]&2&&(n.default_size=i[1].default_size),s[0]&2&&(n.colors=i[1].colors),t.$set(n)},i(i){e||(Dt(t.$$.fragment,i),e=!0)},o(i){qt(t.$$.fragment,i),e=!1},d(i){Rr(t,i)}}}function af(r){let t,e;return t=new T_({props:{default_size:r[2].default_size,mode:"erase"}}),{c(){Ir(t.$$.fragment)},m(i,s){Pr(t,i,s),e=!0},p(i,s){const n={};s[0]&4&&(n.default_size=i[2].default_size),t.$set(n)},i(i){e||(Dt(t.$$.fragment,i),e=!0)},o(i){qt(t.$$.fragment,i),e=!1},d(i){Rr(t,i)}}}function MS(r){let t,e,i,s,n,o,a,l=r[11].includes("crop"),h,c,u,d;t=new wS({props:{layer_files:r[10]?.layers||null,enable_layers:r[12]}});function f(b){r[33](b)}function p(b){r[34](b)}function m(b){r[35](b)}let g={i18n:r[5],root:r[6],sources:r[3],upload:r[15],stream_handler:r[16],background_file:r[10]?.background||r[10]?.composite||null};r[0]!==void 0&&(g.dragging=r[0]),r[20]!==void 0&&(g.bg=r[20]),r[22]!==void 0&&(g.active_mode=r[22]),i=new A2({props:g}),ii.push(()=>zi(i,"dragging",f)),ii.push(()=>zi(i,"bg",p)),ii.push(()=>zi(i,"active_mode",m));let _=l&&nf(r),v=r[1]&&of(r),y=r[1]&&r[2]&&af(r);return{c(){Ir(t.$$.fragment),e=sr(),Ir(i.$$.fragment),a=sr(),_&&_.c(),h=sr(),v&&v.c(),c=sr(),y&&y.c(),u=zo()},m(b,x){Pr(t,b,x),Nt(b,e,x),Pr(i,b,x),Nt(b,a,x),_&&_.m(b,x),Nt(b,h,x),v&&v.m(b,x),Nt(b,c,x),y&&y.m(b,x),Nt(b,u,x),d=!0},p(b,x){const w={};x[0]&1024&&(w.layer_files=b[10]?.layers||null),x[0]&4096&&(w.enable_layers=b[12]),t.$set(w);const T={};x[0]&32&&(T.i18n=b[5]),x[0]&64&&(T.root=b[6]),x[0]&8&&(T.sources=b[3]),x[0]&32768&&(T.upload=b[15]),x[0]&65536&&(T.stream_handler=b[16]),x[0]&1024&&(T.background_file=b[10]?.background||b[10]?.composite||null),!s&&x[0]&1&&(s=!0,T.dragging=b[0],$i(()=>s=!1)),!n&&x[0]&1048576&&(n=!0,T.bg=b[20],$i(()=>n=!1)),!o&&x[0]&4194304&&(o=!0,T.active_mode=b[22],$i(()=>o=!1)),i.$set(T),x[0]&2048&&(l=b[11].includes("crop")),l?_?(_.p(b,x),x[0]&2048&&Dt(_,1)):(_=nf(b),_.c(),Dt(_,1),_.m(h.parentNode,h)):_&&(vl(),qt(_,1,1,()=>{_=null}),yl()),b[1]?v?(v.p(b,x),x[0]&2&&Dt(v,1)):(v=of(b),v.c(),Dt(v,1),v.m(c.parentNode,c)):v&&(vl(),qt(v,1,1,()=>{v=null}),yl()),b[1]&&b[2]?y?(y.p(b,x),x[0]&6&&Dt(y,1)):(y=af(b),y.c(),Dt(y,1),y.m(u.parentNode,u)):y&&(vl(),qt(y,1,1,()=>{y=null}),yl())},i(b){d||(Dt(t.$$.fragment,b),Dt(i.$$.fragment,b),Dt(_),Dt(v),Dt(y),d=!0)},o(b){qt(t.$$.fragment,b),qt(i.$$.fragment,b),qt(_),qt(v),qt(y),d=!1},d(b){b&&(Ot(e),Ot(a),Ot(h),Ot(c),Ot(u)),Rr(t,b),Rr(i,b),_&&_.d(b),v&&v.d(b),y&&y.d(b)}}}function lf(r){let t,e,i,s=r[3]&&r[3].length&&hf(r),n=r[3]&&r[3].length&&r[1]&&!r[17]&&df(),o=r[1]&&!r[17]&&ff();return{c(){t=rs("div"),s&&s.c(),e=sr(),n&&n.c(),i=sr(),o&&o.c(),$o(t,"class","empty wrap svelte-1jsrluz"),sf(t,"height",`${r[23]}px`)},m(a,l){Nt(a,t,l),s&&s.m(t,null),Ao(t,e),n&&n.m(t,null),Ao(t,i),o&&o.m(t,null)},p(a,l){a[3]&&a[3].length?s?s.p(a,l):(s=hf(a),s.c(),s.m(t,e)):s&&(s.d(1),s=null),a[3]&&a[3].length&&a[1]&&!a[17]?n||(n=df(),n.c(),n.m(t,i)):n&&(n.d(1),n=null),a[1]&&!a[17]?o||(o=ff(),o.c(),o.m(t,null)):o&&(o.d(1),o=null),l[0]&8388608&&sf(t,"height",`${a[23]}px`)},d(a){a&&Ot(t),s&&s.d(),n&&n.d(),o&&o.d()}}}function hf(r){let t;function e(n,o){return n[25]||n[24]?BS:kS}let i=e(r),s=i(r);return{c(){s.c(),t=zo()},m(n,o){s.m(n,o),Nt(n,t,o)},p(n,o){i===(i=e(n))&&s?s.p(n,o):(s.d(1),s=i(n),s&&(s.c(),s.m(t.parentNode,t)))},d(n){n&&Ot(t),s.d(n)}}}function kS(r){let t;return{c(){t=rs("div"),t.textContent="Upload an image"},m(e,i){Nt(e,t,i)},p:IS,d(e){e&&Ot(t)}}}function BS(r){let t,e,i=r[25]&&cf(r),s=r[24]&&uf(r);return{c(){i&&i.c(),t=sr(),s&&s.c(),e=zo()},m(n,o){i&&i.m(n,o),Nt(n,t,o),s&&s.m(n,o),Nt(n,e,o)},p(n,o){n[25]?i?i.p(n,o):(i=cf(n),i.c(),i.m(t.parentNode,t)):i&&(i.d(1),i=null),n[24]?s?s.p(n,o):(s=uf(n),s.c(),s.m(e.parentNode,e)):s&&(s.d(1),s=null)},d(n){n&&(Ot(t),Ot(e)),i&&i.d(n),s&&s.d(n)}}}function cf(r){let t,e;return{c(){t=rs("h2"),e=D_(r[25]),$o(t,"class","svelte-1jsrluz")},m(i,s){Nt(i,t,s),Ao(t,e)},p(i,s){s[0]&33554432&&B_(e,i[25])},d(i){i&&Ot(t)}}}function uf(r){let t,e;return{c(){t=rs("p"),e=D_(r[24]),$o(t,"class","svelte-1jsrluz")},m(i,s){Nt(i,t,s),Ao(t,e)},p(i,s){s[0]&16777216&&B_(e,i[24])},d(i){i&&Ot(t)}}}function df(r){let t;return{c(){t=rs("div"),t.textContent="or",$o(t,"class","or svelte-1jsrluz")},m(e,i){Nt(e,t,i)},d(e){e&&Ot(t)}}}function ff(r){let t;return{c(){t=rs("div"),t.textContent="select the draw tool to start"},m(e,i){Nt(e,t,i)},d(e){e&&Ot(t)}}}function DS(r){let t,e,i,s;t=new Qg({props:{i18n:r[5],$$slots:{default:[MS]},$$scope:{ctx:r}}});let n=!r[20]&&!r[21]&&r[22]!=="webcam"&&r[13]!=="error"&&lf(r);return{c(){Ir(t.$$.fragment),e=sr(),n&&n.c(),i=zo()},m(o,a){Pr(t,o,a),Nt(o,e,a),n&&n.m(o,a),Nt(o,i,a),s=!0},p(o,a){const l={};a[0]&32&&(l.i18n=o[5]),a[0]&72457327|a[1]&16384&&(l.$$scope={dirty:a,ctx:o}),t.$set(l),!o[20]&&!o[21]&&o[22]!=="webcam"&&o[13]!=="error"?n?n.p(o,a):(n=lf(o),n.c(),n.m(i.parentNode,i)):n&&(n.d(1),n=null)},i(o){s||(Dt(t.$$.fragment,o),s=!0)},o(o){qt(t.$$.fragment,o),s=!1},d(o){o&&(Ot(e),Ot(i)),Rr(t,o),n&&n.d(o)}}}function FS(r){let t,e,i,s,n,o,a;t=new J_({props:{show_label:r[8],Icon:Ph,label:r[7]||r[5]("image.image")}});function l(d){r[37](d)}function h(d){r[38](d)}function c(d){r[39](d)}let u={canvas_size:r[14],crop_size:Array.isArray(r[4])?r[4]:void 0,parent_height:r[18],changeable:r[9],sources:r[3],crop_constraint:!!r[26],$$slots:{default:[DS]},$$scope:{ctx:r}};return r[23]!==void 0&&(u.height=r[23]),r[21]!==void 0&&(u.history=r[21]),r[20]!==void 0&&(u.bg=r[20]),i=new rS({props:u}),r[36](i),ii.push(()=>zi(i,"height",l)),ii.push(()=>zi(i,"history",h)),ii.push(()=>zi(i,"bg",c)),i.$on("save",r[40]),i.$on("change",r[28]),i.$on("clear",r[41]),{c(){Ir(t.$$.fragment),e=sr(),Ir(i.$$.fragment)}
1176,m(d,f){Pr(t,d,f),Nt(d,e,f),Pr(i,d,f),a=!0},p(d,f){const p={};f[0]&256&&(p.show_label=d[8]),f[0]&160&&(p.label=d[7]||d[5]("image.image")),t.$set(p);const m={};f[0]&16384&&(m.canvas_size=d[14]),f[0]&16&&(m.crop_size=Array.isArray(d[4])?d[4]:void 0),f[0]&262144&&(m.parent_height=d[18]),f[0]&512&&(m.changeable=d[9]),f[0]&8&&(m.sources=d[3]),f[0]&67108864&&(m.crop_constraint=!!d[26]),f[0]&133413999|f[1]&16384&&(m.$$scope={dirty:f,ctx:d}),!s&&f[0]&8388608&&(s=!0,m.height=d[23],$i(()=>s=!1)),!n&&f[0]&2097152&&(n=!0,m.history=d[21],$i(()=>n=!1)),!o&&f[0]&1048576&&(o=!0,m.bg=d[20],$i(()=>o=!1)),i.$set(m)},i(d){a||(Dt(t.$$.fragment,d),Dt(i.$$.fragment,d),a=!0)},o(d){qt(t.$$.fragment,d),qt(i.$$.fragment,d),a=!1},d(d){d&&Ot(e),Rr(t,d),r[36](null),Rr(i,d)}}}function OS(r){return!!r}function NS(r){return!!r}function pf(){return new Promise(r=>setTimeout(()=>r(),30))}function LS(r,t,e){let i,s,n,{brush:o}=t,{eraser:a}=t,{sources:l}=t,{crop_size:h=null}=t,{i18n:c}=t,{root:u}=t,{label:d=void 0}=t,{show_label:f}=t,{changeable:p=!1}=t,{value:m={background:null,layers:[],composite:null}}=t,{transforms:g=["crop"]}=t,{layers:_}=t,{accept_blobs:v}=t,{status:y="complete"}=t,{canvas_size:b}=t,{realtime:x}=t,{upload:w}=t,{stream_handler:T}=t,{dragging:E}=t,{placeholder:C=void 0}=t,{height:M=400}=t;const k=PS();let P;async function S(){const F=await P.get_blobs(),ot=F.background?w(await Ko([new File([F.background],"background.png")]),u):Promise.resolve(null),U=F.layers.filter(OS).map(async(de,Fr)=>w(await Ko([new File([de],`layer_${Fr}.png`)]),u)),ut=F.composite?w(await Ko([new File([F.composite],"composite.png")]),u):Promise.resolve(null),[pt,Lt,...Kt]=await Promise.all([ot,ut,...U]);return{background:Array.isArray(pt)?pt[0]:pt,layers:Kt.flatMap(de=>Array.isArray(de)?de:[de]).filter(NS),composite:Array.isArray(Lt)?Lt[0]:Lt}}function R(F){P&&F==null&&P.handle_remove()}let H=!1,j=!1,{image_id:D=null}=t,tt=!1,G=!1;async function A(F){if(!x)return;if(tt){G=!0;return}tt=!0,await pf();const ot=await P.get_blobs(),U=[];let ut=Math.random().toString(36).substring(2);ot.background&&U.push([ut,"background",new File([ot.background],"background.png"),null]),ot.composite&&U.push([ut,"composite",new File([ot.composite],"composite.png"),null]),ot.layers.forEach((pt,Lt)=>{pt&&U.push([ut,"layer",new File([pt],`layer_${Lt}.png`),Lt])}),await Promise.all(U.map(async([pt,Lt,Kt,de])=>v({binary:!0,data:{file:Kt,id:pt,type:Lt,index:de}}))),e(29,D=ut),k("change"),await pf(),tt=!1,G&&(G=!1,tt=!1,A())}let L=null,I=M-100;function B(F){E=F,e(0,E)}function J(F){H=F,e(20,H)}function it(F){L=F,e(22,L)}function ht(F){ii[F?"unshift":"push"](()=>{P=F,e(19,P)})}function lt(F){I=F,e(23,I)}function yt(F){j=F,e(21,j)}function Tt(F){H=F,e(20,H)}function mt(F){SS.call(this,r,F)}const st=()=>k("clear");return r.$$set=F=>{"brush"in F&&e(1,o=F.brush),"eraser"in F&&e(2,a=F.eraser),"sources"in F&&e(3,l=F.sources),"crop_size"in F&&e(4,h=F.crop_size),"i18n"in F&&e(5,c=F.i18n),"root"in F&&e(6,u=F.root),"label"in F&&e(7,d=F.label),"show_label"in F&&e(8,f=F.show_label),"changeable"in F&&e(9,p=F.changeable),"value"in F&&e(10,m=F.value),"transforms"in F&&e(11,g=F.transforms),"layers"in F&&e(12,_=F.layers),"accept_blobs"in F&&e(30,v=F.accept_blobs),"status"in F&&e(13,y=F.status),"canvas_size"in F&&e(14,b=F.canvas_size),"realtime"in F&&e(31,x=F.realtime),"upload"in F&&e(15,w=F.upload),"stream_handler"in F&&e(16,T=F.stream_handler),"dragging"in F&&e(0,E=F.dragging),"placeholder"in F&&e(17,C=F.placeholder),"height"in F&&e(18,M=F.height),"image_id"in F&&e(29,D=F.image_id)},r.$$.update=()=>{r.$$.dirty[0]&1048576&&H&&k("upload"),r.$$.dirty[0]&1024&&R(m),r.$$.dirty[0]&16&&e(26,i=h),r.$$.dirty[0]&524296&&P&&P.set_tool&&(l&&l.length?P.set_tool("bg"):P.set_tool("draw")),r.$$.dirty[0]&131072&&e(25,[s,n]=C?ES(C):[!1,!1],s,(e(24,n),e(17,C)))},[E,o,a,l,h,c,u,d,f,p,m,g,_,y,b,w,T,C,M,P,H,j,L,I,n,s,i,k,A,D,v,x,S,B,J,it,ht,lt,yt,Tt,mt,st]}class US extends AS{constructor(t){super(),CS(this,t,LS,FS,RS,{brush:1,eraser:2,sources:3,crop_size:4,i18n:5,root:6,label:7,show_label:8,changeable:9,value:10,transforms:11,layers:12,accept_blobs:30,status:13,canvas_size:14,realtime:31,upload:15,stream_handler:16,dragging:0,placeholder:17,height:18,get_data:32,image_id:29},null,[-1,-1])}get brush(){return this.$$.ctx[1]}set brush(t){this.$$set({brush:t}),At()}get eraser(){return this.$$.ctx[2]}set eraser(t){this.$$set({eraser:t}),At()}get sources(){return this.$$.ctx[3]}set sources(t){this.$$set({sources:t}),At()}get crop_size(){return this.$$.ctx[4]}set crop_size(t){this.$$set({crop_size:t}),At()}get i18n(){return this.$$.ctx[5]}set i18n(t){this.$$set({i18n:t}),At()}get root(){return this.$$.ctx[6]}set root(t){this.$$set({root:t}),At()}get label(){return this.$$.ctx[7]}set label(t){this.$$set({label:t}),At()}get show_label(){return this.$$.ctx[8]}set show_label(t){this.$$set({show_label:t}),At()}get changeable(){return this.$$.ctx[9]}set changeable(t){this.$$set({changeable:t}),At()}get value(){return this.$$.ctx[10]}set value(t){this.$$set({value:t}),At()}get transforms(){return this.$$.ctx[11]}set transforms(t){this.$$set({transforms:t}),At()}get layers(){return this.$$.ctx[12]}set layers(t){this.$$set({layers:t}),At()}get accept_blobs(){return this.$$.ctx[30]}set accept_blobs(t){this.$$set({accept_blobs:t}),At()}get status(){return this.$$.ctx[13]}set status(t){this.$$set({status:t}),At()}get canvas_size(){return this.$$.ctx[14]}set canvas_size(t){this.$$set({canvas_size:t}),At()}get realtime(){return this.$$.ctx[31]}set realtime(t){this.$$set({realtime:t}),At()}get upload(){return this.$$.ctx[15]}set upload(t){this.$$set({upload:t}),At()}get stream_handler(){return this.$$.ctx[16]}set stream_handler(t){this.$$set({stream_handler:t}),At()}get dragging(){return this.$$.ctx[0]}set dragging(t){this.$$set({dragging:t}),At()}get placeholder(){return this.$$.ctx[17]}set placeholder(t){this.$$set({placeholder:t}),At()}get height(){return this.$$.ctx[18]}set height(t){this.$$set({height:t}),At()}get get_data(){return this.$$.ctx[32]}get image_id(){return this.$$.ctx[29]}set image_id(t){this.$$set({image_id:t}),At()}}const{SvelteComponent:GS,add_flush_callback:_f,assign:F_,bind:mf,binding_callbacks:Rh,bubble:HS,check_outros:$S,create_component:Zi,destroy_component:Ki,detach:tc,empty:zS,flush:dt,get_spread_object:O_,get_spread_update:N_,group_outros:XS,init:VS,insert:ec,mount_component:Ji,not_equal:WS,space:L_,transition_in:Mr,transition_out:kr}=window.__gradio__svelte__internal,{tick:jS}=window.__gradio__svelte__internal;function YS(r){let t,e;return t=new gf({props:{visible:r[3],variant:r[32]?"solid":"dashed",border_mode:r[31]?"focus":"base",padding:!1,elem_id:r[1],elem_classes:r[2],height:r[9]||void 0,width:r[10],allow_overflow:!1,container:r[12],scale:r[13],min_width:r[14],$$slots:{default:[ZS]},$$scope:{ctx:r}}}),{c(){Zi(t.$$.fragment)},m(i,s){Ji(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.visible=i[3]),s[1]&2&&(n.variant=i[32]?"solid":"dashed"),s[1]&1&&(n.border_mode=i[31]?"focus":"base"),s[0]&2&&(n.elem_id=i[1]),s[0]&4&&(n.elem_classes=i[2]),s[0]&512&&(n.height=i[9]||void 0),s[0]&1024&&(n.width=i[10]),s[0]&4096&&(n.container=i[12]),s[0]&8192&&(n.scale=i[13]),s[0]&16384&&(n.min_width=i[14]),s[0]&2013070193|s[1]&134217729&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(Mr(t.$$.fragment,i),e=!0)},o(i){kr(t.$$.fragment,i),e=!1},d(i){Ki(t,i)}}}function qS(r){let t,e;return t=new gf({props:{visible:r[3],variant:"solid",border_mode:r[31]?"focus":"base",padding:!1,elem_id:r[1],elem_classes:r[2],height:r[9]||void 0,width:r[10],allow_overflow:!1,container:r[12],scale:r[13],min_width:r[14],$$slots:{default:[KS]},$$scope:{ctx:r}}}),{c(){Zi(t.$$.fragment)},m(i,s){Ji(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.visible=i[3]),s[1]&1&&(n.border_mode=i[31]?"focus":"base"),s[0]&2&&(n.elem_id=i[1]),s[0]&4&&(n.elem_classes=i[2]),s[0]&512&&(n.height=i[9]||void 0),s[0]&1024&&(n.width=i[10]),s[0]&4096&&(n.container=i[12]),s[0]&8192&&(n.scale=i[13]),s[0]&16384&&(n.min_width=i[14]),s[0]&402688241|s[1]&134217728&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(Mr(t.$$.fragment,i),e=!0)},o(i){kr(t.$$.fragment,i),e=!1},d(i){Ki(t,i)}}}function ZS(r){let t,e,i,s,n,o;const a=[{autoscroll:r[28].autoscroll},{i18n:r[28].i18n},r[0]];let l={};for(let d=0;d<a.length;d+=1)l=F_(l,a[d]);t=new vf({props:l}),t.$on("clear_status",r[41]);function h(d){r[42](d)}function c(d){r[43](d)}let u={canvas_size:r[26],crop_size:r[21],value:r[4],root:r[8],sources:r[16],label:r[5],show_label:r[6],height:r[9],brush:r[19],eraser:r[20],changeable:r[24].includes("apply"),realtime:r[24].includes("change"),i18n:r[28].i18n,transforms:r[22],accept_blobs:r[25].accept_blobs,layers:r[23],status:r[0]?.status,upload:r[28].client.upload,stream_handler:r[28].
1176client.stream,placeholder:r[18]};return r[31]!==void 0&&(u.dragging=r[31]),r[30]!==void 0&&(u.image_id=r[30]),i=new US({props:u}),Rh.push(()=>mf(i,"dragging",h)),Rh.push(()=>mf(i,"image_id",c)),r[44](i),i.$on("change",r[45]),i.$on("save",r[46]),i.$on("edit",r[47]),i.$on("clear",r[48]),i.$on("drag",r[49]),i.$on("upload",r[50]),i.$on("share",r[51]),i.$on("error",r[52]),i.$on("error",r[53]),{c(){Zi(t.$$.fragment),e=L_(),Zi(i.$$.fragment)},m(d,f){Ji(t,d,f),ec(d,e,f),Ji(i,d,f),o=!0},p(d,f){const p=f[0]&268435457?N_(a,[f[0]&268435456&&{autoscroll:d[28].autoscroll},f[0]&268435456&&{i18n:d[28].i18n},f[0]&1&&O_(d[0])]):{};t.$set(p);const m={};f[0]&67108864&&(m.canvas_size=d[26]),f[0]&2097152&&(m.crop_size=d[21]),f[0]&16&&(m.value=d[4]),f[0]&256&&(m.root=d[8]),f[0]&65536&&(m.sources=d[16]),f[0]&32&&(m.label=d[5]),f[0]&64&&(m.show_label=d[6]),f[0]&512&&(m.height=d[9]),f[0]&524288&&(m.brush=d[19]),f[0]&1048576&&(m.eraser=d[20]),f[0]&16777216&&(m.changeable=d[24].includes("apply")),f[0]&16777216&&(m.realtime=d[24].includes("change")),f[0]&268435456&&(m.i18n=d[28].i18n),f[0]&4194304&&(m.transforms=d[22]),f[0]&33554432&&(m.accept_blobs=d[25].accept_blobs),f[0]&8388608&&(m.layers=d[23]),f[0]&1&&(m.status=d[0]?.status),f[0]&268435456&&(m.upload=d[28].client.upload),f[0]&268435456&&(m.stream_handler=d[28].client.stream),f[0]&262144&&(m.placeholder=d[18]),!s&&f[1]&1&&(s=!0,m.dragging=d[31],_f(()=>s=!1)),!n&&f[0]&1073741824&&(n=!0,m.image_id=d[30],_f(()=>n=!1)),i.$set(m)},i(d){o||(Mr(t.$$.fragment,d),Mr(i.$$.fragment,d),o=!0)},o(d){kr(t.$$.fragment,d),kr(i.$$.fragment,d),o=!1},d(d){d&&tc(e),Ki(t,d),r[44](null),Ki(i,d)}}}function KS(r){let t,e,i,s;const n=[{autoscroll:r[28].autoscroll},{i18n:r[28].i18n},r[0]];let o={};for(let a=0;a<n.length;a+=1)o=F_(o,n[a]);return t=new vf({props:o}),t.$on("clear_status",r[37]),i=new z_({props:{value:r[4]?.composite||null,label:r[5],show_label:r[6],show_download_button:r[7],selectable:r[11],show_share_button:r[15],i18n:r[28].i18n,show_fullscreen_button:r[27]}}),i.$on("select",r[38]),i.$on("share",r[39]),i.$on("error",r[40]),{c(){Zi(t.$$.fragment),e=L_(),Zi(i.$$.fragment)},m(a,l){Ji(t,a,l),ec(a,e,l),Ji(i,a,l),s=!0},p(a,l){const h=l[0]&268435457?N_(n,[l[0]&268435456&&{autoscroll:a[28].autoscroll},l[0]&268435456&&{i18n:a[28].i18n},l[0]&1&&O_(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]&268435456&&(c.i18n=a[28].i18n),l[0]&134217728&&(c.show_fullscreen_button=a[27]),i.$set(c)},i(a){s||(Mr(t.$$.fragment,a),Mr(i.$$.fragment,a),s=!0)},o(a){kr(t.$$.fragment,a),kr(i.$$.fragment,a),s=!1},d(a){a&&tc(e),Ki(t,a),Ki(i,a)}}}function JS(r){let t,e,i,s;const n=[qS,YS],o=[];function a(l,h){return l[17]?1:0}return t=a(r),e=o[t]=n[t](r),{c(){e.c(),i=zS()},m(l,h){o[t].m(l,h),ec(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?o[t].p(l,h):(XS(),kr(o[c],1,1,()=>{o[c]=null}),$S(),e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),Mr(e,1),e.m(i.parentNode,i))},i(l){s||(Mr(e),s=!0)},o(l){kr(e),s=!1},d(l){l&&tc(i),o[t].d(l)}}}function QS(r,t,e){let i,{elem_id:s=""}=t,{elem_classes:n=[]}=t,{visible:o=!0}=t,{value:a={background:null,layers:[],composite:null}}=t,{label:l}=t,{show_label:h}=t,{show_download_button:c}=t,{root:u}=t,{value_is_output:d=!1}=t,{height:f=400}=t,{width:p}=t,{_selectable:m=!1}=t,{container:g=!0}=t,{scale:_=null}=t,{min_width:v=void 0}=t,{loading_status:y}=t,{show_share_button:b=!1}=t,{sources:x=["upload","clipboard","webcam"]}=t,{interactive:w}=t,{placeholder:T}=t,{brush:E}=t,{eraser:C}=t,{crop_size:M=null}=t,{transforms:k=["crop"]}=t,{layers:P=!0}=t,{attached_events:S=[]}=t,{server:R}=t,{canvas_size:H}=t,{show_fullscreen_button:j=!0}=t,{gradio:D}=t,tt,G=null;async function A(){if(G){const Xt={id:G};return e(30,G=null),Xt}return await tt.get_data()}let L;const B=typeof window<"u"?window.requestAnimationFrame:()=>{};function J(){return new Promise(O=>{B(()=>B(()=>O()))})}async function it(){await J(),a&&(a.background||a.layers?.length||a.composite)&&D.dispatch("change")}function ht(){D.dispatch("apply")}function lt(){D.dispatch("change"),d||(D.dispatch("input"),jS().then(O=>e(35,d=!1)))}const yt=()=>D.dispatch("clear_status",y),Tt=({detail:O})=>D.dispatch("select",O),mt=({detail:O})=>D.dispatch("share",O),st=({detail:O})=>D.dispatch("error",O),F=()=>D.dispatch("clear_status",y);function ot(O){L=O,e(31,L)}function U(O){G=O,e(30,G)}function ut(O){Rh[O?"unshift":"push"](()=>{tt=O,e(29,tt)})}const pt=()=>lt(),Lt=O=>ht(),Kt=()=>D.dispatch("edit"),de=()=>D.dispatch("clear"),Fr=({detail:O})=>e(31,L=O),Xo=()=>D.dispatch("upload"),Vo=({detail:O})=>D.dispatch("share",O),Wo=({detail:O})=>{e(0,y=y||{}),e(0,y.status="error",y),D.dispatch("error",O)};function z(O){HS.call(this,r,O)}return r.$$set=O=>{"elem_id"in O&&e(1,s=O.elem_id),"elem_classes"in O&&e(2,n=O.elem_classes),"visible"in O&&e(3,o=O.visible),"value"in O&&e(4,a=O.value),"label"in O&&e(5,l=O.label),"show_label"in O&&e(6,h=O.show_label),"show_download_button"in O&&e(7,c=O.show_download_button),"root"in O&&e(8,u=O.root),"value_is_output"in O&&e(35,d=O.value_is_output),"height"in O&&e(9,f=O.height),"width"in O&&e(10,p=O.width),"_selectable"in O&&e(11,m=O._selectable),"container"in O&&e(12,g=O.container),"scale"in O&&e(13,_=O.scale),"min_width"in O&&e(14,v=O.min_width),"loading_status"in O&&e(0,y=O.loading_status),"show_share_button"in O&&e(15,b=O.show_share_button),"s
1176ources"in O&&e(16,x=O.sources),"interactive"in O&&e(17,w=O.interactive),"placeholder"in O&&e(18,T=O.placeholder),"brush"in O&&e(19,E=O.brush),"eraser"in O&&e(20,C=O.eraser),"crop_size"in O&&e(21,M=O.crop_size),"transforms"in O&&e(22,k=O.transforms),"layers"in O&&e(23,P=O.layers),"attached_events"in O&&e(24,S=O.attached_events),"server"in O&&e(25,R=O.server),"canvas_size"in O&&e(26,H=O.canvas_size),"show_fullscreen_button"in O&&e(27,j=O.show_fullscreen_button),"gradio"in O&&e(28,D=O.gradio)},r.$$.update=()=>{r.$$.dirty[0]&16&&a&&it(),r.$$.dirty[0]&16&&e(32,i=a?.background||a?.layers?.length||a?.composite)},[y,s,n,o,a,l,h,c,u,f,p,m,g,_,v,b,x,w,T,E,C,M,k,P,S,R,H,j,D,tt,G,L,i,ht,lt,d,A,yt,Tt,mt,st,F,ot,U,ut,pt,Lt,Kt,de,Fr,Xo,Vo,Wo,z]}class BC extends GS{constructor(t){super(),VS(this,t,QS,JS,WS,{elem_id:1,elem_classes:2,visible:3,value:4,label:5,show_label:6,show_download_button:7,root:8,value_is_output:35,height:9,width:10,_selectable:11,container:12,scale:13,min_width:14,loading_status:0,show_share_button:15,sources:16,interactive:17,placeholder:18,brush:19,eraser:20,crop_size:21,transforms:22,layers:23,attached_events:24,server:25,canvas_size:26,show_fullscreen_button:27,gradio:28,get_value:36},null,[-1,-1])}get elem_id(){return this.$$.ctx[1]}set elem_id(t){this.$$set({elem_id:t}),dt()}get elem_classes(){return this.$$.ctx[2]}set elem_classes(t){this.$$set({elem_classes:t}),dt()}get visible(){return this.$$.ctx[3]}set visible(t){this.$$set({visible:t}),dt()}get value(){return this.$$.ctx[4]}set value(t){this.$$set({value:t}),dt()}get label(){return this.$$.ctx[5]}set label(t){this.$$set({label:t}),dt()}get show_label(){return this.$$.ctx[6]}set show_label(t){this.$$set({show_label:t}),dt()}get show_download_button(){return this.$$.ctx[7]}set show_download_button(t){this.$$set({show_download_button:t}),dt()}get root(){return this.$$.ctx[8]}set root(t){this.$$set({root:t}),dt()}get value_is_output(){return this.$$.ctx[35]}set value_is_output(t){this.$$set({value_is_output:t}),dt()}get height(){return this.$$.ctx[9]}set height(t){this.$$set({height:t}),dt()}get width(){return this.$$.ctx[10]}set width(t){this.$$set({width:t}),dt()}get _selectable(){return this.$$.ctx[11]}set _selectable(t){this.$$set({_selectable:t}),dt()}get container(){return this.$$.ctx[12]}set container(t){this.$$set({container:t}),dt()}get scale(){return this.$$.ctx[13]}set scale(t){this.$$set({scale:t}),dt()}get min_width(){return this.$$.ctx[14]}set min_width(t){this.$$set({min_width:t}),dt()}get loading_status(){return this.$$.ctx[0]}set loading_status(t){this.$$set({loading_status:t}),dt()}get show_share_button(){return this.$$.ctx[15]}set show_share_button(t){this.$$set({show_share_button:t}),dt()}get sources(){return this.$$.ctx[16]}set sources(t){this.$$set({sources:t}),dt()}get interactive(){return this.$$.ctx[17]}set interactive(t){this.$$set({interactive:t}),dt()}get placeholder(){return this.$$.ctx[18]}set placeholder(t){this.$$set({placeholder:t}),dt()}get brush(){return this.$$.ctx[19]}set brush(t){this.$$set({brush:t}),dt()}get eraser(){return this.$$.ctx[20]}set eraser(t){this.$$set({eraser:t}),dt()}get crop_size(){return this.$$.ctx[21]}set crop_size(t){this.$$set({crop_size:t}),dt()}get transforms(){return this.$$.ctx[22]}set transforms(t){this.$$set({transforms:t}),dt()}get layers(){return this.$$.ctx[23]}set layers(t){this.$$set({layers:t}),dt()}get attached_events(){return this.$$.ctx[24]}set attached_events(t){this.$$set({attached_events:t}),dt()}get server(){return this.$$.ctx[25]}set server(t){this.$$set({server:t}),dt()}get canvas_size(){return this.$$.ctx[26]}set canvas_size(t){this.$$set({canvas_size:t}),dt()}get show_fullscreen_button(){return this.$$.ctx[27]}set show_fullscreen_button(t){this.$$set({show_fullscreen_button:t}),dt()}get gradio(){return this.$$.ctx[28]}set gradio(t){this.$$set({gradio:t}),dt()}get get_value(){return this.$$.ctx[36]}}export{BC as default}; 1177//# sourceMappingURL=Index-Ds0AjFoZ.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.