import k_ from"./ImagePreview-DuKw1rWw.js";import{W as D_}from"./ImageUploader-Cq2e6XvI.js";import{B as lf}from"./Block-DZqtZLFP.js";import"./MarkdownCode.svelte_svelte_type_style_lang-3tofWDHK.js";import"./IconButtonWrapper.svelte_svelte_type_style_lang-BOpxTcdu.js";import{s as hf,S as cf}from"./index-B1gfMDT9.js";import"./StreamingBar.svelte_svelte_type_style_lang-CDNxkBIr.js";import{w as Nt,g as uf,h as bn,o as Wo,e as jo}from"./index-C7PS0jJm.js";/* empty css */import"./Image-CsmDAdIf.js";/* empty css */import{r as F_}from"./___vite-browser-external_commonjs-proxy-CdaBSatl.js";import{I as xn}from"./IconButton-B-aAVSzy.js";import{C as O_}from"./Check-BiRlaMNo.js";import{T as N_}from"./Trash-RbZEwH-j.js";import{U as L_}from"./Undo-DCjBnnSO.js";import{I as U_}from"./IconButtonWrapper-Cg16aIPK.js";import{t as Ci,E as G_}from"./tinycolor-DhRrpXkc.js";/* empty css *//* empty css */import{I as Ah}from"./FullscreenButton-CqFNG1Hv.js";import{I as H_}from"./Upload-DXgDHKDd.js";import{W as z_}from"./SelectSource-B90qmKix.js";import{U as $_}from"./Upload-DeO6qHmq.js";import{B as X_}from"./BlockLabel-DqHge3FF.js";import"./utils-BsGrhMNe.js";import"./Empty-CxRQfWXb.js";import"./ShareButton-CKIdzpwI.js";import"./Community-Dw1micSV.js";import"./Download-DVtk-Jv3.js";import"./utils-Gtzs_Zla.js";import"./DownloadLink-IzUam-rM.js";import"./context-TgWPFwN2.js";import"./file-url-DgijyRSD.js";import"./prism-python-qapVsvY8.js";import"./svelte/svelte.js";import"./Minimize-OAHZO2Ge.js";import"./Clear-By3xiIwg.js";import"./DropdownArrow-dYuMZY9s.js";import"./Square-oAGqOwsh.js";import"./index-CvpmwOJi.js";import"./StreamingBar-BU9S4hA7.js";import"./__vite-browser-external-D7Ct-6yo.js";const{SvelteComponent:V_,append:Kh,attr:Hi,detach:W_,init:j_,insert:Y_,noop:Yo,safe_not_equal:q_,svg_element:qo}=window.__gradio__svelte__internal;function Z_(r){let t,e,i;return{c(){t=qo("svg"),e=qo("path"),i=qo("path"),Hi(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"),Hi(e,"fill","currentColor"),Hi(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"),Hi(i,"fill","currentColor"),Hi(t,"width","100%"),Hi(t,"height","100%"),Hi(t,"viewBox","0 0 32 32")},m(s,n){Y_(s,t,n),Kh(t,e),Kh(t,i)},p:Yo,i:Yo,o:Yo,d(s){s&&W_(t)}}}let K_=class extends V_{constructor(t){super(),j_(this,t,null,Z_,q_,{})}};const{SvelteComponent:J_,append:Q_,attr:_r,detach:tm,init:em,insert:im,noop:Zo,safe_not_equal:rm,svg_element:Jh}=window.__gradio__svelte__internal;function sm(r){let t,e;return{c(){t=Jh("svg"),e=Jh("path"),_r(e,"fill","currentColor"),_r(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"),_r(t,"xmlns","http://www.w3.org/2000/svg"),_r(t,"width","100%"),_r(t,"height","100%"),_r(t,"viewBox","0 0 24 24")},m(i,s){im(i,t,s),Q_(t,e)},p:Zo,i:Zo,o:Zo,d(i){i&&tm(t)}}}class nm extends J_{constructor(t){super(),em(this,t,null,sm,rm,{})}}const{SvelteComponent:om,append:am,attr:mr,detach:lm,init:hm,insert:cm,noop:Ko,safe_not_equal:um,svg_element:Qh}=window.__gradio__svelte__internal;function dm(r){let t,e;return{c(){t=Qh("svg"),e=Qh("path"),mr(e,"fill","currentColor"),mr(e,"d","M17 23v-4H7q-.825 0-1.413-.588T5 17V7H1V5h4V1h2v16h16v2h-4v4h-2Zm0-8V7H9V5h8q.825 0 1.413.588T19 7v8h-2Z"),mr(t,"xmlns","http://www.w3.org/2000/svg"),mr(t,"width","100%"),mr(t,"height","100%"),mr(t,"viewBox","0 0 24 24")},m(i,s){cm(i,t,s),am(t,e)},p:Ko,i:Ko,o:Ko,d(i){i&&lm(t)}}}let fm=class extends om{constructor(t){super(),hm(this,t,null,dm,um,{})}};const{SvelteComponent:pm,append:Jo,attr:ve,detach:_m,init:mm,insert:gm,noop:Qo,safe_not_equal:ym,svg_element:Us}=window.__gradio__svelte__internal;function vm(r){let t,e,i,s;return{c(){t=Us("svg"),e=Us("g"),i=Us("path"),s=Us("path"),ve(i,"fill","currentColor"),ve(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.125 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"),ve(s,"stroke","currentColor"),ve(s,"stroke-linecap","round"),ve(s,"stroke-width","1.5"),ve(s,"d","M9 21h12"),ve(e,"fill","none"),ve(t,"xmlns","http://www.w3.org/2000/svg"),ve(t,"width","100%"),ve(t,"height","100%"),ve(t,"viewBox","0 0 24 24")},m(n,o){gm(n,t,o),Jo(t,e),Jo(e,i),Jo(e,s)},p:Qo,i:Qo,o:Qo,d(n){n&&_m(t)}}}class bm extends pm{constructor(t){super(),mm(this,t,null,vm,ym,{})}}const{SvelteComponent:xm,append:tc,attr:ae,detach:wm,init:Tm,insert:Em,noop:ta,safe_not_equal:Am,svg_element:ea}=window.__gradio__svelte__internal;function Sm(r){let t,e,i;return{c(){t=ea("svg"),e=ea("path"),i=ea("path"),ae(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"),ae(e,"stroke","currentColor"),ae(e,"stroke-width","1.5"),ae(e,"stroke-linecap","round"),ae(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"),ae(i,"stroke","currentColor"),ae(i,"stroke-width","1.5"),ae(t,"width","100%"),ae(t,"height","100%"),ae(t,"viewBox","0 0 17 17"),ae(t,"fill","none"),ae(t,"xmlns","http://www.w3.org/2000/svg")},m(s,n){Em(s,t,n),tc(t,e),tc(t,i)},p:ta,i:ta,o:ta,d(s){s&&wm(t)}}}class Cm extends xm{constructor(t){super(),Tm(this,t,null,Sm,Am,{})}}const{SvelteComponent:Im,append:ns,attr:$t,detach:Rm,init:Pm,insert:Mm,noop:ia,safe_not_equal:Bm,svg_element:gr}=window.__gradio__svelte__internal;function km(r){let t,e,i,s,n,o;return{c(){t=gr("svg"),e=gr("g"),i=gr("path"),s=gr("circle"),n=gr("circle"),o=gr("path"),$t(i,"d","M2 12.026c0 5.146 3.867 9.387 8.847 9.96c.735.085 1.447-.228 1.97-.753a1.68 1.68 0 0 0 0-2.372c-.523-.525-.95-1.307-.555-1.934c1.576-2.508 9.738 3.251 9.738-4.9C22 6.488 17.523 2 12 2S2 6.489 2 12.026Z"),$t(s,"cx","17.5"),$t(s,"cy","11.5"),$t(s,"r",".75"),$t(n,"cx","6.5"),$t(n,"cy","11.5"),$t(n,"r",".75"),$t(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"),$t(e,"fill","none"),$t(e,"stroke","currentColor"),$t(e,"stroke-width","1.5"),$t(t,"xmlns","http://www.w3.org/2000/svg"),$t(t,"width","100%"),$t(t,"height","100%"),$t(t,"viewBox","0 0 24 24")},m(a,l){Mm(a,t,l),ns(t,e),ns(e,i),ns(e,s),ns(e,n),ns(e,o)},p:ia,i:ia,o:ia,d(a){a&&Rm(t)}}}class Dm extends Im{constructor(t){super(),Pm(this,t,null,km,Bm,{})}}const{SvelteComponent:Fm,append:ec,attr:le,detach:Om,init:Nm,insert:Lm,noop:ra,safe_not_equal:Um,set_style:Gm,svg_element:sa}=window.__gradio__svelte__internal;function Hm(r){let t,e,i;return{c(){t=sa("svg"),e=sa("polyline"),i=sa("path"),le(e,"points","1 4 1 10 7 10"),le(i,"d","M3.51 15a9 9 0 1 0 2.13-9.36L1 10"),le(t,"xmlns","http://www.w3.org/2000/svg"),le(t,"width","100%"),le(t,"height","100%"),le(t,"viewBox","0 0 24 24"),le(t,"fill","none"),le(t,"stroke","currentColor"),le(t,"stroke-width","2"),le(t,"stroke-linecap","round"),le(t,"stroke-linejoin","round"),le(t,"class","feather feather-rotate-ccw"),Gm(t,"transform","rotateY(180deg)")},m(s,n){Lm(s,t,n),ec(t,e),ec(t,i)},p:ra,i:ra,o:ra,d(s){s&&Om(t)}}}class zm extends Fm{constructor(t){super(),Nm(this,t,null,Hm,Um,{})}}const{SvelteComponent:$m,attr:Xm,create_slot:Vm,detach:Wm,element:jm,flush:Ym,get_all_dirty_from_scope:qm,get_slot_changes:Zm,init:Km,insert:Jm,safe_not_equal:Qm,toggle_class:ic,transition_in:tg,transition_out:eg,update_slot_base:ig}=window.__gradio__svelte__internal;function rg(r){let t,e;const i=r[2].default,s=Vm(i,r,r[1],null);return{c(){t=jm("div"),s&&s.c(),Xm(t,"class","svelte-1ua59x3"),ic(t,"show_border",r[0])},m(n,o){Jm(n,t,o),s&&s.m(t,null),e=!0},p(n,[o]){s&&s.p&&(!e||o&2)&&ig(s,i,n,n[1],e?Zm(i,n[1],o,null):qm(n[1]),null),(!e||o&1)&&ic(t,"show_border",n[0])},i(n){e||(tg(s,n),e=!0)},o(n){eg(s,n),e=!1},d(n){n&&Wm(t),s&&s.d(n)}}}function sg(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 ng extends $m{constructor(t){super(),Km(this,t,sg,rg,Qm,{show_border:0})}get show_border(){return this.$$.ctx[0]}set show_border(t){this.$$set({show_border:t}),Ym()}}function gl(r){return{command:r||null,next:null,previous:null,push:function(t){const e=gl(t);e.previous=this,this.next=e}}}function og(){let r=gl();const t=Nt(!1),e=Nt(!1),i=Nt(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)},hydrate:function(s){setTimeout(()=>{for(;s.next;)this.execute(s.next.command),s=s.next},1e3)},can_undo:t,can_redo:e,current_history:i,reset:function(){r=gl(),t.set(!1),e.set(!1),i.set(r)}}}const{SvelteComponent:ag,append:yl,attr:Ke,bubble:lg,create_component:hg,destroy_component:cg,detach:df,element:vl,flush:Jt,init:ug,insert:ff,listen:dg,mount_component:fg,safe_not_equal:pg,set_data:_g,set_style:yr,space:mg,text:gg,toggle_class:jt,transition_in:yg,transition_out:vg}=window.__gradio__svelte__internal;function rc(r){let t,e;return{c(){t=vl("span"),e=gg(r[1]),Ke(t,"class","svelte-rk35yg")},m(i,s){ff(i,t,s),yl(t,e)},p(i,s){s&2&&_g(e,i[1])},d(i){i&&df(t)}}}function bg(r){let t,e,i,s,n,o,a,l=r[2]&&rc(r);return s=new r[0]({}),{c(){t=vl("button"),l&&l.c(),e=mg(),i=vl("div"),hg(s.$$.fragment),Ke(i,"class","svelte-rk35yg"),jt(i,"small",r[4]==="small"),jt(i,"large",r[4]==="large"),jt(i,"medium",r[4]==="medium"),t.disabled=r[7],Ke(t,"aria-label",r[1]),Ke(t,"aria-haspopup",r[8]),Ke(t,"title",r[1]),Ke(t,"class","svelte-rk35yg"),jt(t,"pending",r[3]),jt(t,"padded",r[5]),jt(t,"highlight",r[6]),jt(t,"transparent",r[9]),yr(t,"color",!r[7]&&r[12]?r[12]:"var(--block-label-text-color)"),yr(t,"--bg-color",r[7]?"auto":r[10]),yr(t,"margin-left",r[11]+"px")},m(h,c){ff(h,t,c),l&&l.m(t,null),yl(t,e),yl(t,i),fg(s,i,null),n=!0,o||(a=dg(t,"click",r[14]),o=!0)},p(h,[c]){h[2]?l?l.p(h,c):(l=rc(h),l.c(),l.m(t,e)):l&&(l.d(1),l=null),(!n||c&16)&&jt(i,"small",h[4]==="small"),(!n||c&16)&&jt(i,"large",h[4]==="large"),(!n||c&16)&&jt(i,"medium",h[4]==="medium"),(!n||c&128)&&(t.disabled=h[7]),(!n||c&2)&&Ke(t,"aria-label",h[1]),(!n||c&256)&&Ke(t,"aria-haspopup",h[8]),(!n||c&2)&&Ke(t,"title",h[1]),(!n||c&8)&&jt(t,"pending",h[3]),(!n||c&32)&&jt(t,"padded",h[5]),(!n||c&64)&&jt(t,"highlight",h[6]),(!n||c&512)&&jt(t,"transparent",h[9]),c&4224&&yr(t,"color",!h[7]&&h[12]?h[12]:"var(--block-label-text-color)"),c&1152&&yr(t,"--bg-color",h[7]?"auto":h[10]),c&2048&&yr(t,"margin-left",h[11]+"px")},i(h){n||(yg(s.$$.fragment,h),n=!0)},o(h){vg(s.$$.fragment,h),n=!1},d(h){h&&df(t),l&&l.d(),cg(s),o=!1,a()}}}function xg(r,t,e){let i,{Icon:s}=t,{label:n=""}=t,{show_label:o=!1}=t,{pending:a=!1}=t,{size:l="small"}=t,{padded:h=!0}=t,{highlight:c=!1}=t,{disabled:u=!1}=t,{hasPopup:d=!1}=t,{color:f="var(--block-label-text-color)"}=t,{transparent:p=!1}=t,{background:m="var(--background-fill-primary)"}=t,{offset:g=0}=t;function _(v){lg.call(this,r,v)}return r.$$set=v=>{"Icon"in v&&e(0,s=v.Icon),"label"in v&&e(1,n=v.label),"show_label"in v&&e(2,o=v.show_label),"pending"in v&&e(3,a=v.pending),"size"in v&&e(4,l=v.size),"padded"in v&&e(5,h=v.padded),"highlight"in v&&e(6,c=v.highlight),"disabled"in v&&e(7,u=v.disabled),"hasPopup"in v&&e(8,d=v.hasPopup),"color"in v&&e(13,f=v.color),"transparent"in v&&e(9,p=v.transparent),"background"in v&&e(10,m=v.background),"offset"in v&&e(11,g=v.offset)},r.$$.update=()=>{r.$$.dirty&8256&&e(12,i=c?"var(--color-accent)":f)},[s,n,o,a,l,h,c,u,d,p,m,g,i,f,_]}class pf extends ag{constructor(t){super(),ug(this,t,xg,bg,pg,{Icon:0,label:1,show_label:2,pending:3,size:4,padded:5,highlight:6,disabled:7,hasPopup:8,color:13,transparent:9,background:10,offset:11})}get Icon(){return this.$$.ctx[0]}set Icon(t){this.$$set({Icon:t}),Jt()}get label(){return this.$$.ctx[1]}set label(t){this.$$set({label:t}),Jt()}get show_label(){return this.$$.ctx[2]}set show_label(t){this.$$set({show_label:t}),Jt()}get pending(){return this.$$.ctx[3]}set pending(t){this.$$set({pending:t}),Jt()}get size(){return this.$$.ctx[4]}set size(t){this.$$set({size:t}),Jt()}get padded(){return this.$$.ctx[5]}set padded(t){this.$$set({padded:t}),Jt()}get highlight(){return this.$$.ctx[6]}set highlight(t){this.$$set({highlight:t}),Jt()}get disabled(){return this.$$.ctx[7]}set disabled(t){this.$$set({disabled:t}),Jt()}get hasPopup(){return this.$$.ctx[8]}set hasPopup(t){this.$$set({hasPopup:t}),Jt()}get color(){return this.$$.ctx[13]}set color(t){this.$$set({color:t}),Jt()}get transparent(){return this.$$.ctx[9]}set transparent(t){this.$$set({transparent:t}),Jt()}get background(){return this.$$.ctx[10]}set background(t){this.$$set({background:t}),Jt()}get offset(){return this.$$.ctx[11]}set offset(t){this.$$set({offset:t}),Jt()}}const{SvelteComponent:wg,add_iframe_resize_listener:Tg,add_render_callback:Eg,attr:Ag,binding_callbacks:Sg,check_outros:Cg,component_subscribe:na,create_component:_f,create_slot:Ig,destroy_component:mf,detach:Vn,element:Rg,empty:gf,ensure_array_like:sc,flush:Pg,get_all_dirty_from_scope:Mg,get_slot_changes:Bg,group_outros:kg,init:Dg,insert:Wn,mount_component:yf,outro_and_destroy_block:Fg,safe_not_equal:Og,set_store_value:nc,space:Ng,transition_in:jn,transition_out:Yn,update_keyed_each:Lg,update_slot_base:Ug}=window.__gradio__svelte__internal,{getContext:Gg,setContext:Hg}=window.__gradio__svelte__internal;function oc(r,t,e){const i=r.slice();return i[21]=t[e],i}function ac(r,t){let e,i,s;function n(...o){return t[12](t[21],...o)}return i=new pf({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=gf(),_f(i.$$.fragment),this.first=e},m(o,a){Wn(o,e,a),yf(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),mf(i,o)}}}function zg(r){let t=[],e=new Map,i,s,n=sc(r[1]);const o=a=>a[21];for(let a=0;ar[13].call(e))},m(l,h){a&&a.m(l,h),Wn(l,t,h),Wn(l,e,h),yf(i,e,null),s=Tg(e,r[13].bind(e)),r[14](e),n=!0},p(l,[h]){a&&a.p&&(!n||h&32768)&&Ug(a,o,l,l[15],n?Bg(o,l[15],h,null):Mg(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),mf(i),s(),r[14](null)}}}const Ao=Symbol("tool");function Xg(r,t,e){let i,s,n,{$$slots:o={},$$scope:a}=t;const{active_tool:l,toolbar_box:h,editor_box:c}=Gg(rs);na(r,l,T=>e(3,i=T)),na(r,h,T=>e(17,s=T)),na(r,c,T=>e(10,n=T));let{i18n:u}=t,d=[];const f={},m={current_color:Nt("#000000"),register_tool:(T,I)=>(e(1,d=[...d,T]),I?.cb&&(f[T]=I.cb),()=>{e(1,d=d.filter(B=>B!==T))}),active_tool:{subscribe:l.subscribe,set:l.set}};Hg(Ao,m);const g={crop:{order:1,label:u("Transform"),icon:fm},draw:{order:2,label:u("Draw"),icon:K_},erase:{order:2,label:u("Erase"),icon:bm},bg:{order:0,label:u("Background"),icon:Ah}};let _,v;function y(){v&&nc(h,s=v.getBoundingClientRect(),s)}function b(T,I){T.stopPropagation(),nc(l,i=I,i),f[I]&&f[I]()}const x=(T,I)=>b(I,T);function S(){_=this.clientWidth,e(0,_)}function w(T){Sg[T?"unshift":"push"](()=>{v=T,e(2,v)})}return r.$$set=T=>{"i18n"in T&&e(9,u=T.i18n),"$$scope"in T&&e(15,a=T.$$scope)},r.$$.update=()=>{r.$$.dirty&1025&&y()},[_,d,v,i,l,h,c,g,b,u,n,o,x,S,w,a]}class Vg extends wg{constructor(t){super(),Dg(this,t,Xg,$g,Og,{i18n:9})}get i18n(){return this.$$.ctx[9]}set i18n(t){this.$$set({i18n:t}),Pg()}}var fr=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(fr||{}),vf=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(vf||{}),bl=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(bl||{}),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||{}),He=(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))(He||{}),O=(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))(O||{}),Lr=(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))(Lr||{}),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||{}),W=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(W||{}),ti=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(ti||{}),Ii=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Ii||{}),Xe=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(Xe||{}),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||{}),Ne=(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))(Ne||{}),Sh=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(Sh||{}),pe=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(pe||{}),Ct=(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))(Ct||{}),At=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(At||{}),ze=(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))(ze||{});const Wg={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")},j={ADAPTER:Wg,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var oa=/iPhone/i,lc=/iPod/i,hc=/iPad/i,cc=/\biOS-universal(?:.+)Mac\b/i,aa=/\bAndroid(?:.+)Mobile\b/i,uc=/Android/i,vr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Gs=/Silk/i,je=/Windows Phone/i,dc=/\bWindows(?:.+)ARM\b/i,fc=/BlackBerry/i,pc=/BB10/i,_c=/Opera Mini/i,mc=/\b(CriOS|Chrome)(?:.+)Mobile/i,gc=/Mobile(?:.+)Firefox\b/i,yc=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function jg(r){return function(t){return t.test(r)}}function vc(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=jg(e),n={apple:{phone:s(oa)&&!s(je),ipod:s(lc),tablet:!s(oa)&&(s(hc)||yc(t))&&!s(je),universal:s(cc),device:(s(oa)||s(lc)||s(hc)||s(cc)||yc(t))&&!s(je)},amazon:{phone:s(vr),tablet:!s(vr)&&s(Gs),device:s(vr)||s(Gs)},android:{phone:!s(je)&&s(vr)||!s(je)&&s(aa),tablet:!s(je)&&!s(vr)&&!s(aa)&&(s(Gs)||s(uc)),device:!s(je)&&(s(vr)||s(Gs)||s(aa)||s(uc))||s(/\bokhttp\b/i)},windows:{phone:s(je),tablet:s(dc),device:s(je)||s(dc)},other:{blackberry:s(fc),blackberry10:s(pc),opera:s(_c),firefox:s(gc),chrome:s(mc),device:s(fc)||s(pc)||s(_c)||s(gc)||s(mc)},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 Yg=vc.default??vc,ei=Yg(globalThis.navigator);j.RETINA_PREFIX=/@([0-9\.]+)x/;j.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var bf={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);d80*e){a=h=r[0],l=c=r[1];for(var p=e;ph&&(h=u),d>c&&(c=d);f=Math.max(h-a,c-l),f=f!==0?32767/f:0}return Ps(n,o,e,a,l,f,0),o}function xf(r,t,e,i,s){var n,o;if(s===Tl(r,t,e,i)>0)for(n=t;n=t;n-=i)o=bc(n,r[n],r[n+1],o);return o&&Co(o,o.next)&&(Bs(o),o=o.next),o}function hr(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(Co(e,e.next)||xt(e.prev,e,e.next)===0)){if(Bs(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Ps(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?Kg(r,i,s,n):Zg(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),Bs(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=Jg(hr(r),t,e),Ps(r,t,e,i,s,n,2)):o===2&&Qg(r,t,e,i,s,n):Ps(hr(r),t,e,i,s,n,1);break}}}}function Zg(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=sn?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&&Or(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 Kg(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=al?a>h?a:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,_=xl(f,p,t,e,i),v=xl(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&&Or(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&&Or(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&&Or(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&&Or(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 Jg(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!Co(s,n)&&wf(s,i,i.next,n)&&Ms(s,n)&&Ms(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),Bs(i),Bs(i.next),i=r=n),i=i.next}while(i!==r);return hr(i)}function Qg(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&l0(o,a)){var l=Tf(o,a);o=hr(o,o.next),l=hr(l,l.next),Ps(o,t,e,i,s,n,0),Ps(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function t0(r,t,e,i){var s=[],n,o,a,l,h;for(n=0,o=t.length;n=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.x&&e.x>=h&&i!==e.x&&Or(so.x||e.x===o.x&&s0(o,e)))&&(o=e,u=d)),e=e.next;while(e!==l);return o}function s0(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=xl(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,o0(s)}function o0(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;t0||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 xl(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 a0(r){var t=r,e=r;do(t.x=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function l0(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!h0(r,t)&&(Ms(r,t)&&Ms(t,r)&&c0(r,t)&&(xt(r.prev,r,t.prev)||xt(r,t.prev,t))||Co(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 Co(r,t){return r.x===t.x&&r.y===t.y}function wf(r,t,e,i){var s=zs(xt(r,t,e)),n=zs(xt(r,t,i)),o=zs(xt(e,i,r)),a=zs(xt(e,i,t));return!!(s!==n&&o!==a||s===0&&Hs(r,e,t)||n===0&&Hs(r,i,t)||o===0&&Hs(e,r,i)||a===0&&Hs(e,t,i))}function Hs(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 zs(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&&wf(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Ms(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 c0(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 Tf(r,t){var e=new wl(r.i,r.x,r.y),i=new wl(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 bc(r,t,e,i){var s=new wl(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Bs(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 wl(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}So.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(Tl(r,0,n,e));if(s)for(var a=0,l=t.length;a0&&(i+=r[s-1].length,e.holes.push(i))}return e};var u0=Ch.exports;const d0=uf(u0);var qn={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */qn.exports;(function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof bn=="object"&&bn;(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,S=String.fromCharCode,w;function T(A){throw new RangeError(y[A])}function I(A,L){for(var V=A.length,D=[];V--;)D[V]=L(A[V]);return D}function B(A,L){var V=A.split("@"),D="";V.length>1&&(D=V[0]+"@",A=V[1]),A=A.replace(v,".");var R=A.split("."),et=I(R,L).join(".");return D+et}function P(A){for(var L=[],V=0,D=A.length,R,et;V=55296&&R<=56319&&V65535&&(L-=65536,V+=S(L>>>10&1023|55296),L=56320|L&1023),V+=S(L),V}).join("")}function E(A){return A-48<10?A-22:A-65<26?A-65:A-97<26?A-97:l}function C(A,L){return A+22+75*(A<26)-((L!=0)<<5)}function G(A,L,V){var D=0;for(A=V?x(A/d):A>>1,A+=x(A/L);A>b*c>>1;D+=l)A=x(A/b);return x(D+(b+1)*A/(A+u))}function X(A){var L=[],V=A.length,D,R=0,et=p,tt=f,st,ft,vt,pt,ot,ut,lt,mt,U;for(st=A.lastIndexOf(m),st<0&&(st=0),ft=0;ft=128&&T("not-basic"),L.push(A.charCodeAt(ft));for(vt=st>0?st+1:0;vt=V&&T("invalid-input"),lt=E(A.charCodeAt(vt++)),(lt>=l||lt>x((a-R)/ot))&&T("overflow"),R+=lt*ot,mt=ut<=tt?h:ut>=tt+c?c:ut-tt,!(ltx(a/U)&&T("overflow"),ot*=U;D=L.length+1,tt=G(R-pt,D,pt==0),x(R/D)>a-et&&T("overflow"),et+=x(R/D),R%=D,L.splice(R++,0,et)}return M(L)}function N(A){var L,V,D,R,et,tt,st,ft,vt,pt,ot,ut=[],lt,mt,U,Et;for(A=P(A),lt=A.length,L=p,V=0,et=f,tt=0;tt=L&&otx((a-V)/mt)&&T("overflow"),V+=(st-L)*mt,L=st,tt=0;tta&&T("overflow"),ot==L){for(ft=V,vt=l;pt=vt<=et?h:vt>=et+c?c:vt-et,!(ft"u"||!Pt?at:Pt(Uint8Array),or={"%AggregateError%":typeof AggregateError>"u"?at:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?at:ArrayBuffer,"%ArrayIteratorPrototype%":br&&Pt?Pt([][Symbol.iterator]()):at,"%AsyncFromSyncIteratorPrototype%":at,"%AsyncFunction%":Rr,"%AsyncGenerator%":Rr,"%AsyncGeneratorFunction%":Rr,"%AsyncIteratorPrototype%":Rr,"%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%":Ef,"%GeneratorFunction%":Rr,"%Int8Array%":typeof Int8Array>"u"?at:Int8Array,"%Int16Array%":typeof Int16Array>"u"?at:Int16Array,"%Int32Array%":typeof Int32Array>"u"?at:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":br&&Pt?Pt(Pt([][Symbol.iterator]())):at,"%JSON%":typeof JSON=="object"?JSON:at,"%Map%":typeof Map>"u"?at:Map,"%MapIteratorPrototype%":typeof Map>"u"||!br||!Pt?at:Pt(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"||!br||!Pt?at:Pt(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?at:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":br&&Pt?Pt(""[Symbol.iterator]()):at,"%Symbol%":br?Symbol:at,"%SyntaxError%":Wr,"%ThrowTypeError%":M0,"%TypedArray%":k0,"%TypeError%":Ur,"%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(Pt)try{null.error}catch(r){var D0=Pt(Pt(r));or["%Error.prototype%"]=D0}var F0=function r(t){var e;if(t==="%AsyncFunction%")e=la("async function () {}");else if(t==="%GeneratorFunction%")e=la("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=la("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&Pt&&(e=Pt(s.prototype))}return or[t]=e,e},Ec={"%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"]},Os=Ih,Zn=P0,O0=Os.call(Function.call,Array.prototype.concat),N0=Os.call(Function.apply,Array.prototype.splice),Ac=Os.call(Function.call,String.prototype.replace),Kn=Os.call(Function.call,String.prototype.slice),L0=Os.call(Function.call,RegExp.prototype.exec),U0=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,G0=/\\(\\)?/g,H0=function(t){var e=Kn(t,0,1),i=Kn(t,-1);if(e==="%"&&i!=="%")throw new Wr("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new Wr("invalid intrinsic syntax, expected opening `%`");var s=[];return Ac(t,U0,function(n,o,a,l){s[s.length]=a?Ac(l,G0,"$1"):o||n}),s},z0=function(t,e){var i=t,s;if(Zn(Ec,i)&&(s=Ec[i],i="%"+s[0]+"%"),Zn(or,i)){var n=or[i];if(n===Rr&&(n=F0(i)),typeof n>"u"&&!e)throw new Ur("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new Wr("intrinsic "+t+" does not exist!")},pr=function(t,e){if(typeof t!="string"||t.length===0)throw new Ur("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new Ur('"allowMissing" argument must be a boolean');if(L0(/^%?[^%]*%?$/,t)===null)throw new Wr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=H0(t),s=i.length>0?i[0]:"",n=z0("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],N0(i,O0([0,1],h)));for(var c=1,u=!0;c=i.length){var m=nr(a,d);u=!!m,u&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else u=Zn(a,d),a=a[d];u&&!l&&(or[o]=a)}}return a},Af={exports:{}},$0=pr,El=$0("%Object.defineProperty%",!0),Al=function(){if(El)try{return El({},"a",{value:1}),!0}catch{return!1}return!1};Al.hasArrayLengthDefineBug=function(){if(!Al())return null;try{return El([],"length",{value:1}).length!==1}catch{return!0}};var Sf=Al,X0=pr,wn=X0("%Object.getOwnPropertyDescriptor%",!0);if(wn)try{wn([],"length")}catch{wn=null}var Cf=wn,V0=Sf(),Rh=pr,bs=V0&&Rh("%Object.defineProperty%",!0);if(bs)try{bs({},"a",{value:1})}catch{bs=!1}var W0=Rh("%SyntaxError%"),xr=Rh("%TypeError%"),Sc=Cf,j0=function(t,e,i){if(!t||typeof t!="object"&&typeof t!="function")throw new xr("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new xr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new xr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new xr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new xr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new xr("`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=!!Sc&&Sc(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 W0("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},If=pr,Cc=j0,Y0=Sf(),Ic=Cf,Rc=If("%TypeError%"),q0=If("%Math.floor%"),Z0=function(t,e){if(typeof t!="function")throw new Rc("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||q0(e)!==e)throw new Rc("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],s=!0,n=!0;if("length"in t&&Ic){var o=Ic(t,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(n=!1)}return(s||n||!i)&&(Y0?Cc(t,"length",e,!0,!0):Cc(t,"length",e)),t};(function(r){var t=Ih,e=pr,i=Z0,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})(Af);var K0=Af.exports,Rf=pr,Pf=K0,J0=Pf(Rf("String.prototype.indexOf")),Q0=function(t,e){var i=Rf(t,!!e);return typeof i=="function"&&J0(t,".prototype.")>-1?Pf(i):i},Ph=typeof Map=="function"&&Map.prototype,ca=Object.getOwnPropertyDescriptor&&Ph?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Jn=Ph&&ca&&typeof ca.get=="function"?ca.get:null,Pc=Ph&&Map.prototype.forEach,Mh=typeof Set=="function"&&Set.prototype,ua=Object.getOwnPropertyDescriptor&&Mh?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Qn=Mh&&ua&&typeof ua.get=="function"?ua.get:null,Mc=Mh&&Set.prototype.forEach,t1=typeof WeakMap=="function"&&WeakMap.prototype,xs=t1?WeakMap.prototype.has:null,e1=typeof WeakSet=="function"&&WeakSet.prototype,ws=e1?WeakSet.prototype.has:null,i1=typeof WeakRef=="function"&&WeakRef.prototype,Bc=i1?WeakRef.prototype.deref:null,r1=Boolean.prototype.valueOf,s1=Object.prototype.toString,n1=Function.prototype.toString,o1=String.prototype.match,Bh=String.prototype.slice,wi=String.prototype.replace,a1=String.prototype.toUpperCase,kc=String.prototype.toLowerCase,Mf=RegExp.prototype.test,Dc=Array.prototype.concat,Le=Array.prototype.join,l1=Array.prototype.slice,Fc=Math.floor,Sl=typeof BigInt=="function"?BigInt.prototype.valueOf:null,da=Object.getOwnPropertySymbols,Cl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,jr=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Ht=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===jr||!0)?Symbol.toStringTag:null,Bf=Object.prototype.propertyIsEnumerable,Oc=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Nc(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||Mf.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-Fc(-r):Fc(r);if(i!==r){var s=String(i),n=Bh.call(t,s.length+1);return wi.call(s,e,"$&_")+"."+wi.call(wi.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return wi.call(t,e,"$&_")}var Il=F_,Lc=Il.custom,Uc=Df(Lc)?Lc:null,h1=function r(t,e,i,s){var n=e||{};if(gi(n,"quoteStyle")&&n.quoteStyle!=="single"&&n.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(gi(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=gi(n,"customInspect")?n.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(gi(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(gi(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 Of(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?Nc(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?Nc(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 Rl(t)?"[Array]":"[Object]";var u=C1(n,i);if(typeof s>"u")s=[];else if(Ff(s,t)>=0)return"[Circular]";function d(E,C,G){if(C&&(s=l1.call(s),s.push(C)),G){var X={depth:n.depth};return gi(n,"quoteStyle")&&(X.quoteStyle=n.quoteStyle),r(E,X,i+1,s)}return r(E,n,i+1,s)}if(typeof t=="function"&&!Gc(t)){var f=y1(t),p=$s(t,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(p.length>0?" { "+Le.call(p,", ")+" }":"")}if(Df(t)){var m=jr?wi.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Cl.call(t);return typeof t=="object"&&!jr?os(m):m}if(E1(t)){for(var g="<"+kc.call(String(t.nodeName)),_=t.attributes||[],v=0;v<_.length;v++)g+=" "+_[v].name+"="+kf(c1(_[v].value),"double",n);return g+=">",t.childNodes&&t.childNodes.length&&(g+="..."),g+="",g}if(Rl(t)){if(t.length===0)return"[]";var y=$s(t,d);return u&&!S1(y)?"["+Pl(y,u)+"]":"[ "+Le.call(y,", ")+" ]"}if(d1(t)){var b=$s(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!Bf.call(t,"cause")?"{ ["+String(t)+"] "+Le.call(Dc.call("[cause]: "+d(t.cause),b),", ")+" }":b.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+Le.call(b,", ")+" }"}if(typeof t=="object"&&o){if(Uc&&typeof t[Uc]=="function"&&Il)return Il(t,{depth:c-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(v1(t)){var x=[];return Pc&&Pc.call(t,function(E,C){x.push(d(C,t,!0)+" => "+d(E,t))}),Hc("Map",Jn.call(t),x,u)}if(w1(t)){var S=[];return Mc&&Mc.call(t,function(E){S.push(d(E,t))}),Hc("Set",Qn.call(t),S,u)}if(b1(t))return fa("WeakMap");if(T1(t))return fa("WeakSet");if(x1(t))return fa("WeakRef");if(p1(t))return os(d(Number(t)));if(m1(t))return os(d(Sl.call(t)));if(_1(t))return os(r1.call(t));if(f1(t))return os(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(t===bn)return"{ [object globalThis] }";if(!u1(t)&&!Gc(t)){var w=$s(t,d),T=Oc?Oc(t)===Object.prototype:t instanceof Object||t.constructor===Object,I=t instanceof Object?"":"null prototype",B=!T&&Ht&&Object(t)===t&&Ht in t?Bh.call(Li(t),8,-1):I?"Object":"",P=T||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",M=P+(B||I?"["+Le.call(Dc.call([],B||[],I||[]),": ")+"] ":"");return w.length===0?M+"{}":u?M+"{"+Pl(w,u)+"}":M+"{ "+Le.call(w,", ")+" }"}return String(t)};function kf(r,t,e){var i=(e.quoteStyle||t)==="double"?'"':"'";return i+r+i}function c1(r){return wi.call(String(r),/"/g,""")}function Rl(r){return Li(r)==="[object Array]"&&(!Ht||!(typeof r=="object"&&Ht in r))}function u1(r){return Li(r)==="[object Date]"&&(!Ht||!(typeof r=="object"&&Ht in r))}function Gc(r){return Li(r)==="[object RegExp]"&&(!Ht||!(typeof r=="object"&&Ht in r))}function d1(r){return Li(r)==="[object Error]"&&(!Ht||!(typeof r=="object"&&Ht in r))}function f1(r){return Li(r)==="[object String]"&&(!Ht||!(typeof r=="object"&&Ht in r))}function p1(r){return Li(r)==="[object Number]"&&(!Ht||!(typeof r=="object"&&Ht in r))}function _1(r){return Li(r)==="[object Boolean]"&&(!Ht||!(typeof r=="object"&&Ht in r))}function Df(r){if(jr)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Cl)return!1;try{return Cl.call(r),!0}catch{}return!1}function m1(r){if(!r||typeof r!="object"||!Sl)return!1;try{return Sl.call(r),!0}catch{}return!1}var g1=Object.prototype.hasOwnProperty||function(r){return r in this};function gi(r,t){return g1.call(r,t)}function Li(r){return s1.call(r)}function y1(r){if(r.name)return r.name;var t=o1.call(n1.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Ff(r,t){if(r.indexOf)return r.indexOf(t);for(var e=0,i=r.length;et.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return Of(Bh.call(r,0,t.maxStringLength),t)+i}var s=wi.call(wi.call(r,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,A1);return kf(s,"single",t)}function A1(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":"")+a1.call(t.toString(16))}function os(r){return"Object("+r+")"}function fa(r){return r+" { ? }"}function Hc(r,t,e,i){var s=i?Pl(e,i):Le.call(e,", ");return r+" ("+t+") {"+s+"}"}function S1(r){for(var t=0;t=0)return!1;return!0}function C1(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=Le.call(Array(r.indent+1)," ");else return null;return{base:e,prev:Le.call(Array(t+1),e)}}function Pl(r,t){if(r.length===0)return"";var e=` `+t.prev+t.base;return e+Le.call(r,","+e)+` `+t.prev}function $s(r,t){var e=Rl(r),i=[];if(e){i.length=r.length;for(var s=0;s1;){var e=t.pop(),i=e.obj[e.prop];if(Qi(i)){for(var s=[],n=0;n=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||n===z1.RFC1738&&(h===40||h===41)){a+=o.charAt(l);continue}if(h<128){a=a+Pe[h];continue}if(h<2048){a=a+(Pe[192|h>>6]+Pe[128|h&63]);continue}if(h<55296||h>=57344){a=a+(Pe[224|h>>12]+Pe[128|h>>6&63]+Pe[128|h&63]);continue}l+=1,h=65536+((h&1023)<<10|o.charCodeAt(l)&1023),a+=Pe[240|h>>18]+Pe[128|h>>12&63]+Pe[128|h>>6&63]+Pe[128|h&63]}return a},Y1=function(t){for(var e=[{obj:{o:t},prop:"o"}],i=[],s=0;s"u"&&(y=0)}if(typeof l=="function"?_=l(e,_):_ instanceof Date?_=u(_):i==="comma"&&Qe(_)&&(_=Tn.maybeMap(_,function(X){return X instanceof Date?u(X):X})),_===null){if(n)return a&&!p?a(e,Ot.encoder,m,"key",d):e;_=""}if(iy(_)||Tn.isBuffer(_)){if(a){var S=p?e:a(e,Ot.encoder,m,"key",d);return[f(S)+"="+f(a(_,Ot.encoder,m,"value",d))]}return[f(e)+"="+f(String(_))]}var w=[];if(typeof _>"u")return w;var T;if(i==="comma"&&Qe(_))p&&a&&(_=Tn.maybeMap(_,a)),T=[{value:_.length>0?_.join(",")||null:void 0}];else if(Qe(l))T=l;else{var I=Object.keys(_);T=h?I.sort(h):I}for(var B=s&&Qe(_)&&_.length===1?e+"[]":e,P=0;P"u"?Ot.allowDots:!!t.allowDots,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Ot.charsetSentinel,delimiter:typeof t.delimiter>"u"?Ot.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:Ot.encode,encoder:typeof t.encoder=="function"?t.encoder:Ot.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:Ot.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:Ot.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:Ot.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Ot.strictNullHandling}},ny=function(r,t){var e=r,i=sy(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):Qe(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a;t&&t.arrayFormat in zc?a=t.arrayFormat:t&&"indices"in t?a=t.indices?"indices":"repeat":a="indices";var l=zc[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=Uf(),u=0;u0?p+f:""},Yr=Lf,Ml=Object.prototype.hasOwnProperty,oy=Array.isArray,Rt={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:Yr.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},ay=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},Hf=function(r,t){return r&&typeof r=="string"&&t.comma&&r.indexOf(",")>-1?r.split(","):r},ly="utf8=%26%2310003%3B",hy="utf8=%E2%9C%93",cy=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-1&&(p=oy(p)?[p]:p),Ml.call(i,f)?i[f]=Yr.combine(i[f],p):i[f]=p}return i},uy=function(r,t,e,i){for(var s=i?t:Hf(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},dy=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&&Ml.call(Object.prototype,h)&&!i.allowPrototypes)return;c.push(h)}for(var u=0;i.depth>0&&(l=a.exec(n))!==null&&u"u"?Rt.charset:t.charset;return{allowDots:typeof t.allowDots>"u"?Rt.allowDots:!!t.allowDots,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:Rt.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:Rt.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:Rt.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Rt.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:Rt.comma,decoder:typeof t.decoder=="function"?t.decoder:Rt.decoder,delimiter:typeof t.delimiter=="string"||Yr.isRegExp(t.delimiter)?t.delimiter:Rt.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:Rt.depth,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:Rt.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:Rt.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:Rt.plainObjects,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Rt.strictNullHandling}},py=function(r,t){var e=fy(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?Object.create(null):{};for(var i=typeof r=="string"?cy(r,e):r,s=e.plainObjects?Object.create(null):{},n=Object.keys(i),o=0;o",'"',"`"," ","\r",` `," "],Ey=["{","}","|","\\","^","`"].concat(Ty),Bl=["'"].concat(Ey),Xc=["%","/","?",";","#"].concat(Bl),Vc=["/","?","#"],Ay=255,Wc=/^[+a-z0-9A-Z_-]{0,63}$/,Sy=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Cy={javascript:!0,"javascript:":!0},kl={javascript:!0,"javascript:":!0},Gr={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},Dl=yy;function Iy(r,t,e){if(r&&typeof r=="object"&&r instanceof ai)return r;var i=new ai;return i.parse(r,t,e),i}ai.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&&i127?x+="x":x+=b[S];if(!x.match(Wc)){var T=v.slice(0,f),I=v.slice(f+1),B=b.match(Sy);B&&(T.push(B[1]),I.unshift(B[2])),I.length&&(a="/"+I.join(".")+a),this.hostname=T.join(".");break}}}this.hostname.length>Ay?this.hostname="":this.hostname=this.hostname.toLowerCase(),_||(this.hostname=vy.toASCII(this.hostname));var P=this.port?":"+this.port:"",M=this.hostname||"";this.host=M+P,this.href+=this.host,_&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!Cy[c])for(var f=0,y=Bl.length;f0?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 S=v.slice(-1)[0],w=(e.host||r.host||v.length>1)&&(S==="."||S==="..")||S==="",T=0,I=v.length;I>=0;I--)S=v[I],S==="."?v.splice(I,1):S===".."?(v.splice(I,1),T++):T&&(v.splice(I,1),T--);if(!g&&!_)for(;T--;T)v.unshift("..");g&&v[0]!==""&&(!v[0]||v[0].charAt(0)!=="/")&&v.unshift(""),w&&v.join("/").substr(-1)!=="/"&&v.push("");var B=v[0]===""||v[0]&&v[0].charAt(0)==="/";if(b){e.hostname=B?"":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&&!B&&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};ai.prototype.parseHost=function(){var r=this.host,t=xy.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 jc={};function nt(r,t,e=3){if(jc[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t} Deprecated since v${r}`):(i=i.split(` `).splice(e).join(` `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t} Deprecated since v${r}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t} Deprecated since v${r}`),console.warn(i))),jc[t]=!0}function be(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function as(r){return r.split("?")[0].split("#")[0]}function Ry(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Py(r,t,e){return r.replace(new RegExp(Ry(t),"g"),e)}function My(r,t){let e="",i=0,s=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a2){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 It={toPosix(r){return Py(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:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){be(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(be(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=as(this.toPosix(t??j.ADAPTER.getBaseUrl())),s=as(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?It.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(be(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=My(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return be(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let t;for(let e=0;e0)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(be(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){be(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){be(r),t&&be(t),r=as(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){be(r),r=as(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){be(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=as(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 ga;async function By(){return ga??(ga=(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})()),ga}let ya;function ky(){return typeof ya>"u"&&(ya=function(){const r={stencil:!0,failIfMajorPerformanceCaveat:j.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!j.ADAPTER.getWebGLRenderingContext())return!1;const t=j.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}}()),ya}var Dy={grad:.9,turn:360,rad:360/(2*Math.PI)},Ye=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},Mt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},_e=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},Yc=function(r){return{r:_e(r.r,0,255),g:_e(r.g,0,255),b:_e(r.b,0,255),a:_e(r.a)}},va=function(r){return{r:Mt(r.r),g:Mt(r.g),b:Mt(r.b),a:Mt(r.a,3)}},Fy=/^#([0-9a-f]{3,8})$/i,Ws=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},$f=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}},Xf=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}},qc=function(r){return{h:zf(r.h),s:_e(r.s,0,100),l:_e(r.l,0,100),a:_e(r.a)}},Zc=function(r){return{h:Mt(r.h),s:Mt(r.s),l:Mt(r.l),a:Mt(r.a,3)}},Kc=function(r){return Xf((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=$f(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},Oy=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ny=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ly=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Uy=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Fl={string:[[function(r){var t=Fy.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?Mt(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?Mt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=Ly.exec(r)||Uy.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:Yc({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=Oy.exec(r)||Ny.exec(r);if(!t)return null;var e,i,s=qc({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Dy[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Kc(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 Ye(t)&&Ye(e)&&Ye(i)?Yc({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(!Ye(t)||!Ye(e)||!Ye(i))return null;var o=qc({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Kc(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!Ye(t)||!Ye(e)||!Ye(i))return null;var o=function(a){return{h:zf(a.h),s:_e(a.s,0,100),v:_e(a.v,0,100),a:_e(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Xf(o)},"hsv"]]},Jc=function(r,t){for(var e=0;e=.5},r.prototype.toHex=function(){return t=va(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?Ws(Mt(255*n)):"","#"+Ws(e)+Ws(i)+Ws(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return va(this.rgba)},r.prototype.toRgbString=function(){return t=va(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 Zc(Es(this.rgba))},r.prototype.toHslString=function(){return t=Zc(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=$f(this.rgba),{h:Mt(t.h),s:Mt(t.s),v:Mt(t.v),a:Mt(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(ba(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),ke(ba(this.rgba,-t))},r.prototype.grayscale=function(){return ke(ba(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),ke(Qc(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),ke(Qc(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}):Mt(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}):Mt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===ke(t).toHex()},r}(),ke=function(r){return r instanceof Ol?r:new Ol(r)},tu=[],Hy=function(r){r.forEach(function(t){tu.indexOf(t)<0&&(t(Ol,Fl),tu.push(t))})};function zy(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));ms===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]=En.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=En.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)}};Pr.shared=new Pr,Pr.temp=new Pr,Pr.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let dt=Pr;function $y(r){return nt("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),dt.shared.setValue(r).toHex()}function Xy(r){return nt("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),dt.shared.setValue(r).toNumber()}function Vy(){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 Vf=Vy();function Wf(r,t){return Vf[t?1:0][r]}function Wy(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>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function eu(r){return!(r&r-1)&&!!r}function iu(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 Hr(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(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 Ll=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},au=(r,t)=>Ll(r).priority??t,q={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Ll).forEach(t=>{t.type.forEach(e=>this._removeHandlers[e]?.(t))}),this},add(...r){return r.map(Ll).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)=>au(n,e)-au(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class Ul{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 Jy=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` `);function Qy(r){let t="";for(let e=0;e0&&(t+=` else `),e=0;--i){const s=Gl[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class Se{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;u0&&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(Se.prototype,{dispatch:{value:Se.prototype.emit},run:{value:Se.prototype.emit}});class ks{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new Se("setRealSize"),this.onUpdate=new Se("update"),this.onError=new Se("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 Io extends ks{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 ev={scaleMode:ti.NEAREST,alphaMode:Zt.NPM},Hl=class Mr extends Fs{constructor(t=null,e=null){super(),e=Object.assign({},Mr.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 ks)&&(t=Yf(t,p),t.internal=!0),this.resolution=f||j.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=cr(),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=eu(this.realWidth)&&eu(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 hi[this.cacheId],delete De[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),Mr.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=j.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}_${cr()}`}n=t._pixiId}let o=hi[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new Mr(t,e),o.cacheId=n,Mr.addToCache(o,n)),o}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new Io(t,{width:e,height:i,...s?.resourceOptions});let o,a;return t instanceof Float32Array?(o=O.RGBA,a=K.FLOAT):t instanceof Int32Array?(o=O.RGBA_INTEGER,a=K.INT):t instanceof Uint32Array?(o=O.RGBA_INTEGER,a=K.UNSIGNED_INT):t instanceof Int16Array?(o=O.RGBA_INTEGER,a=K.SHORT):t instanceof Uint16Array?(o=O.RGBA_INTEGER,a=K.UNSIGNED_SHORT):t instanceof Int8Array?(o=O.RGBA,a=K.BYTE):(o=O.RGBA,a=K.UNSIGNED_BYTE),n.internal=!0,new Mr(n,Object.assign({},ev,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),hi[e]&&hi[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),hi[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=hi[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete hi[t],e}}else if(t?.textureCacheIds){for(let e=0;e1){for(let u=0;u(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))(kt||{});class ht{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new ht(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}}ht.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const js=[new ht,new ht,new ht,new ht];class it{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=kt.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 it(0,0,0,0)}clone(){return new it(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.y&&et.right?t.right:this.right)<=T)return!1;const I=this.yt.bottom?t.bottom:this.bottom)>I}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=js[0].set(t.left,t.top),l=js[1].set(t.left,t.bottom),h=js[2].set(t.right,t.top),c=js[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,S=v*i+y*o,w=v*s+y*o;return!(Math.max(b,x,S,w)<=v*a.x+y*a.y||Math.min(b,x,S,w)>=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}}it.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Ro{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=kt.CIRC}clone(){return new Ro(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 it(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}Ro.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class Po{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=kt.ELIP}clone(){return new Po(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 it(this.x-this.width,this.y-this.height,this.width,this.height)}}Po.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class ar{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;se!=c>e&&t<(h-a)*((e-l)/(c-l))+a&&(i=!i)}return i}}ar.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class Mo{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=kt.RREC}clone(){return new Mo(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}}Mo.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class yt{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 ht;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 ht;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 yt;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 yt}static get TEMP_MATRIX(){return new yt}}yt.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 ji=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Yi=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],qi=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Zi=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],$l=[],Zf=[],Ys=Math.sign;function hv(){for(let r=0;r<16;r++){const t=[];$l.push(t);for(let e=0;e<16;e++){const i=Ys(ji[r]*ji[e]+qi[r]*Yi[e]),s=Ys(Yi[r]*ji[e]+Zi[r]*Yi[e]),n=Ys(ji[r]*qi[e]+qi[r]*Zi[e]),o=Ys(Yi[r]*qi[e]+Zi[r]*Zi[e]);for(let a=0;a<16;a++)if(ji[a]===i&&Yi[a]===s&&qi[a]===n&&Zi[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new yt;t.set(ji[r],Yi[r],qi[r],Zi[r],0,0),Zf.push(t)}}hv();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=>ji[r],uY:r=>Yi[r],vX:r=>qi[r],vY:r=>Zi[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>$l[r][t],sub:(r,t)=>$l[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=Zf[bt.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class ii{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 ii(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))}}ii.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Xl=class{constructor(){this.worldTransform=new yt,this.localTransform=new yt,this.position=new ii(this.onChange,this,0,0),this.scale=new ii(this.onChange,this,1,1),this.pivot=new ii(this.onChange,this,0,0),this.skew=new ii(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())}};Xl.IDENTITY=new Xl;let Oh=Xl;Oh.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 cv=`varying vec2 vTextureCoord; uniform sampler2D uSampler; void main(void){ gl_FragColor *= texture2D(uSampler, vTextureCoord); }`,uv=`attribute vec2 aVertexPosition; attribute vec2 aTextureCoord; uniform mat3 projectionMatrix; varying vec2 vTextureCoord; void main(void){ gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); vTextureCoord = aTextureCoord; } `;function hu(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function Ia(r){const t=new Array(r);for(let e=0;er.type==="float"&&r.size===1&&!r.isArray,code:r=>` if(uv["${r}"] !== ud["${r}"].value) { ud["${r}"].value = uv["${r}"] gl.uniform1f(ud["${r}"].location, uv["${r}"]) } `},{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++; renderer.texture.bind(uv["${r}"], t); if(ud["${r}"].value !== t) { ud["${r}"].value = t; gl.uniform1i(ud["${r}"].location, t); ; // eslint-disable-line max-len }`},{test:(r,t)=>r.type==="mat3"&&r.size===1&&!r.isArray&&t.a!==void 0,code:r=>` gl.uniformMatrix3fv(ud["${r}"].location, false, uv["${r}"].toArray(true)); `,codeUbo:r=>` var ${r}_matrix = uv.${r}.toArray(true); data[offset] = ${r}_matrix[0]; data[offset+1] = ${r}_matrix[1]; data[offset+2] = ${r}_matrix[2]; data[offset + 4] = ${r}_matrix[3]; data[offset + 5] = ${r}_matrix[4]; data[offset + 6] = ${r}_matrix[5]; data[offset + 8] = ${r}_matrix[6]; data[offset + 9] = ${r}_matrix[7]; data[offset + 10] = ${r}_matrix[8]; `},{test:(r,t)=>r.type==="vec2"&&r.size===1&&!r.isArray&&t.x!==void 0,code:r=>` cv = ud["${r}"].value; v = uv["${r}"]; if(cv[0] !== v.x || cv[1] !== v.y) { cv[0] = v.x; cv[1] = v.y; gl.uniform2f(ud["${r}"].location, v.x, v.y); }`,codeUbo:r=>` v = uv.${r}; data[offset] = v.x; data[offset+1] = v.y; `},{test:r=>r.type==="vec2"&&r.size===1&&!r.isArray,code:r=>` cv = ud["${r}"].value; v = uv["${r}"]; if(cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2f(ud["${r}"].location, v[0], v[1]); } `},{test:(r,t)=>r.type==="vec4"&&r.size===1&&!r.isArray&&t.width!==void 0,code:r=>` cv = ud["${r}"].value; v = uv["${r}"]; if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) { cv[0] = v.x; cv[1] = v.y; cv[2] = v.width; cv[3] = v.height; gl.uniform4f(ud["${r}"].location, v.x, v.y, v.width, v.height) }`,codeUbo:r=>` v = uv.${r}; data[offset] = v.x; data[offset+1] = v.y; data[offset+2] = v.width; data[offset+3] = v.height; `},{test:(r,t)=>r.type==="vec4"&&r.size===1&&!r.isArray&&t.red!==void 0,code:r=>` cv = ud["${r}"].value; v = uv["${r}"]; if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) { cv[0] = v.red; cv[1] = v.green; cv[2] = v.blue; cv[3] = v.alpha; gl.uniform4f(ud["${r}"].location, v.red, v.green, v.blue, v.alpha) }`,codeUbo:r=>` v = uv.${r}; data[offset] = v.red; data[offset+1] = v.green; data[offset+2] = v.blue; data[offset+3] = v.alpha; `},{test:(r,t)=>r.type==="vec3"&&r.size===1&&!r.isArray&&t.red!==void 0,code:r=>` cv = ud["${r}"].value; v = uv["${r}"]; if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a) { cv[0] = v.red; cv[1] = v.green; cv[2] = v.blue; gl.uniform3f(ud["${r}"].location, v.red, v.green, v.blue) }`,codeUbo:r=>` v = uv.${r}; data[offset] = v.red; data[offset+1] = v.green; data[offset+2] = v.blue; `},{test:r=>r.type==="vec4"&&r.size===1&&!r.isArray,code:r=>` cv = ud["${r}"].value; v = uv["${r}"]; if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4f(ud["${r}"].location, v[0], v[1], v[2], v[3]) }`}],dv={float:` if (cv !== v) { cu.value = v; gl.uniform1f(location, v); }`,vec2:` if (cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2f(location, v[0], v[1]) }`,vec3:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3f(location, v[0], v[1], v[2]) }`,vec4:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4f(location, v[0], v[1], v[2], v[3]); }`,int:` if (cv !== v) { cu.value = v; gl.uniform1i(location, v); }`,ivec2:` if (cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2i(location, v[0], v[1]); }`,ivec3:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3i(location, v[0], v[1], v[2]); }`,ivec4:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4i(location, v[0], v[1], v[2], v[3]); }`,uint:` if (cv !== v) { cu.value = v; gl.uniform1ui(location, v); }`,uvec2:` if (cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2ui(location, v[0], v[1]); }`,uvec3:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3ui(location, v[0], v[1], v[2]); }`,uvec4:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4ui(location, v[0], v[1], v[2], v[3]); }`,bool:` if (cv !== v) { cu.value = v; gl.uniform1i(location, v); }`,bvec2:` if (cv[0] != v[0] || cv[1] != v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2i(location, v[0], v[1]); }`,bvec3:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3i(location, v[0], v[1], v[2]); }`,bvec4:` if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4i(location, v[0], v[1], v[2], v[3]); }`,mat2:"gl.uniformMatrix2fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",sampler2D:` if (cv !== v) { cu.value = v; gl.uniform1i(location, v); }`,samplerCube:` if (cv !== v) { cu.value = v; gl.uniform1i(location, v); }`,sampler2DArray:` if (cv !== v) { cu.value = v; gl.uniform1i(location, v); }`},fv={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 pv(r,t){const e=[` var v = null; var cv = null; var cu = null; var t = 0; var gl = renderer.gl; `];for(const i in r.uniforms){const s=t[i];if(!s){r.uniforms[i]?.group===!0&&(r.uniforms[i].ubo?e.push(` renderer.shader.syncUniformBufferGroup(uv.${i}, '${i}'); `):e.push(` renderer.shader.syncUniformGroup(uv.${i}, syncData); `));continue}const n=r.uniforms[i];let o=!1;for(let a=0;a=fr.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),qs=t}return qs}let Zs;function mv(){if(!Zs){Zs=pe.MEDIUM;const r=_v();if(r&&r.getShaderPrecisionFormat){const t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);t&&(Zs=t.precision?pe.HIGH:pe.MEDIUM)}}return Zs}function cu(r,t){const e=r.getShaderSource(t).split(` `).map((h,c)=>`${c}: ${h}`),i=r.getShaderInfoLog(t),s=i.split(` `),n={},o=s.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!n[h]?(n[h]=!0,!0):!1),a=[""];o.forEach(h=>{e[h-1]=`%c${e[h-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=e.join(` `);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function gv(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||cu(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||cu(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const yv={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 Qf(r){return yv[r]}let Ks=null;const uu={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 tp(r,t){if(!Ks){const e=Object.keys(uu);Ks={};for(let i=0;i0&&(e+=` else `),ithis.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=Te._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=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;u0);for(let m=0;m=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=0&&u=fr.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")}}so.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},so.extension={type:$.RendererSystem,name:"context"};q.add(so);class Yl{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 Se("disposeFramebuffer"),this.multisample=At.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new rt(null,{scaleMode:ti.NEAREST,resolution:1,mipmap:Xe.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new rt(null,{scaleMode:ti.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Xe.OFF,format:O.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{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 Nh{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}}Nh.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 pu=new Nh;function Qs(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class Y extends Fs{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new it(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=pu,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 ht(o.x,o.y):new ht(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&&De[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===pu&&(this._uvs=new Nh),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=j.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}-${cr()}`,rt.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=e?.pixiIdPrefix||"pixiid";t._pixiId=`${a}_${cr()}`}n=t._pixiId}let o=De[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=li(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:li(e)},s)),{resource:o}=n;o instanceof rp&&(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),De[e]&&De[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),De[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=De[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete De[t],e}}else if(t?.textureCacheIds){for(let e=0;ethis.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),Qs(Y._EMPTY),Qs(Y._EMPTY.baseTexture)),Y._EMPTY}static get WHITE(){if(!Y._WHITE){const t=j.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)),Qs(Y._WHITE),Qs(Y._WHITE.baseTexture)}return Y._WHITE}}class Gt 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 Gt(new ip(t))}}class sp{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=At.NONE){const s=new ip(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new Gt(s)}getOptimalTexture(t,e,i=1,s=At.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=to(t),e=to(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||At.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;s0&&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;s1&&(c=this.getOptimalFilterTexture(h.width,h.height,e.resolution),c.filterFrame=h.filterFrame),i[u].apply(this,h,c,Ne.CLEAR,e);const d=h;h=c,c=d}i[u].apply(this,h,l.renderTexture,Ne.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=Ne.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===Ne.CLEAR||e===Ne.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(He.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(He.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(yt.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=At.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||At.NONE);return s.filterFrame=t.filterFrame,s}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=tn[0],s=tn[1],n=tn[2],o=tn[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?Ra.copyFrom(n):Ra.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)}}}op.extension={type:$.RendererSystem,name:"filter"};q.add(op);class Mv{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=At.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const Bv=new it;class ap{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Yl(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 it,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;j.PREFER_ENV===fr.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>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=bl.COLOR|bl.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,s),o.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new Mv(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;o1&&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;l1&&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=At.NONE;if(t<=1||e===null)return i;for(let s=0;s=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;ii.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"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;s0?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}}cp.extension={type:$.RendererSystem,name:"mask"};q.add(cp);class up{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 mu=new yt,gu=[],dp=class An extends up{constructor(t){super(t),this.glConst=j.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:i}=t,{renderer:s}=this,n=s.renderTexture,o=i.getBounds(!0,gu.pop()??new it);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()||An.isMatrixRotated(e.worldTransform)||An.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){An.isMatrixRotated(n)||(n=n?mu.copyFrom(n):mu.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&&gu.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)}};dp.extension={type:$.RendererSystem,name:"scissor"};let Nv=dp;q.add(Nv);class fp extends up{constructor(t){super(t),this.glConst=j.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)}}fp.extension={type:$.RendererSystem,name:"stencil"};q.add(fp);class pp{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}}pp.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"_plugin"};q.add(pp);class _p{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new yt,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}}_p.extension={type:$.RendererSystem,name:"projection"};q.add(_p);const Lv=new Oh,yu=new it;class mp{constructor(t){this.renderer=t,this._tempMatrix=new yt}generateTexture(t,e){const{region:i,...s}=e||{},n=i?.copyTo(yu)||t.getLocalBounds(yu,!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=Gt.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=Lv,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}mp.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"textureGenerator"};q.add(mp);const zi=new it,hs=new it;class gp{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new it,this.destinationFrame=new it,this.viewportFrame=new it}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||(zi.width=t.frame.width,zi.height=t.frame.height,e=zi),i||(hs.x=t.frame.x,hs.y=t.frame.y,hs.width=e.width,hs.height=e.height,i=hs),o=n.framebuffer):(a=s.resolution,e||(zi.width=s._view.screen.width,zi.height=s._view.screen.height,e=zi),i||(i=zi,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=dt.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}}gp.extension={type:$.RendererSystem,name:"renderTexture"};q.add(gp);class Uv{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 Gv(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let s=0;sl>h?1:-1);for(let l=0;l({data:n,offset:0,dataLen:0,dirty:0}));let e=0,i=0,s=0;for(let n=0;n1&&(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 Wv(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 jv(r,t){if(!r.autoManage)return{size:0,syncFunc:$v};const e=Wv(r.uniforms,t),{uboElements:i,size:s}=Vv(e),n=[` var v = null; var v2 = null; var cv = null; var t = 0; var gl = renderer.gl var index = 0; var data = buffer.data; `];for(let o=0;o1){const u=Qf(a.data.type),d=Math.max(yp[a.data.type]/16,1),f=u/d,p=(4-f%4)%4;n.push(` cv = ud.${h}.value; v = uv.${h}; offset = ${a.offset/4}; t = 0; for(var i=0; i < ${a.data.size*d}; i++) { for(var j = 0; j < ${f}; j++) { data[offset++] = v[t++]; } offset += ${p}; } `)}else{const u=Xv[a.data.type];n.push(` cv = ud.${h}.value; v = uv.${h}; offset = ${a.offset/4}; ${u}; `)}}return n.push(` renderer.buffer.update(buffer); `),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(` `))}}let Yv=0;const en={textureCount:0,uboCount:0};class vp{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=Yv++}systemCheck(){if(!vv())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||(en.textureCount=0,en.uboCount=0,this.syncUniformGroup(t.uniformGroup,en)),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]=pv(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,en,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]=jv(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=zv(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}}vp.extension={type:$.RendererSystem,name:"shader"};q.add(vp);class no{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(){}}no.defaultOptions={hello:!1},no.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"startup"};q.add(no);function qv(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 Zv=0,Kv=1,Jv=2,Qv=3,tb=4,eb=5,bp=class ql{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=Q.NONE,this._blendEq=!1,this.map=[],this.map[Zv]=this.setBlend,this.map[Kv]=this.setOffset,this.map[Jv]=this.setCullFace,this.map[Qv]=this.setDepthTest,this.map[tb]=this.setFrontFace,this.map[eb]=this.setDepthMask,this.checks=[],this.defaultState=new Ve,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=qv(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<>1,i++;this.stateId=t.data}for(let e=0;et.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 Se(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 Sn{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Sn.defaultMaxIdle,this.checkCountMax=Sn.defaultCheckCountMax,this.mode=Sn.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Sh.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;sthis.maxIdle&&(t.destroyTexture(n,!0),e[s]=null,i=!0)}if(i){let s=0;for(let n=0;n=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};_s.defaultMode=Sh.AUTO,_s.defaultMaxIdle=60*60,_s.defaultCheckCountMax=60*10,_s.extension={type:$.RendererSystem,name:"textureGC"};let Ji=_s;q.add(Ji);class Ma{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=O.RGBA,this.samplerType=0}}function sb(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:W.FLOAT,[r.RGBA]:W.FLOAT,[r.ALPHA]:W.FLOAT,[r.LUMINANCE]:W.FLOAT,[r.LUMINANCE_ALPHA]:W.FLOAT,[r.R8]:W.FLOAT,[r.R8_SNORM]:W.FLOAT,[r.RG8]:W.FLOAT,[r.RG8_SNORM]:W.FLOAT,[r.RGB8]:W.FLOAT,[r.RGB8_SNORM]:W.FLOAT,[r.RGB565]:W.FLOAT,[r.RGBA4]:W.FLOAT,[r.RGB5_A1]:W.FLOAT,[r.RGBA8]:W.FLOAT,[r.RGBA8_SNORM]:W.FLOAT,[r.RGB10_A2]:W.FLOAT,[r.RGB10_A2UI]:W.FLOAT,[r.SRGB8]:W.FLOAT,[r.SRGB8_ALPHA8]:W.FLOAT,[r.R16F]:W.FLOAT,[r.RG16F]:W.FLOAT,[r.RGB16F]:W.FLOAT,[r.RGBA16F]:W.FLOAT,[r.R32F]:W.FLOAT,[r.RG32F]:W.FLOAT,[r.RGB32F]:W.FLOAT,[r.RGBA32F]:W.FLOAT,[r.R11F_G11F_B10F]:W.FLOAT,[r.RGB9_E5]:W.FLOAT,[r.R8I]:W.INT,[r.R8UI]:W.UINT,[r.R16I]:W.INT,[r.R16UI]:W.UINT,[r.R32I]:W.INT,[r.R32UI]:W.UINT,[r.RG8I]:W.INT,[r.RG8UI]:W.UINT,[r.RG16I]:W.INT,[r.RG16UI]:W.UINT,[r.RG32I]:W.INT,[r.RG32UI]:W.UINT,[r.RGB8I]:W.INT,[r.RGB8UI]:W.UINT,[r.RGB16I]:W.INT,[r.RGB16UI]:W.UINT,[r.RGB32I]:W.INT,[r.RGB32UI]:W.UINT,[r.RGBA8I]:W.INT,[r.RGBA8UI]:W.UINT,[r.RGBA16I]:W.INT,[r.RGBA16UI]:W.UINT,[r.RGBA32I]:W.INT,[r.RGBA32UI]:W.UINT,[r.DEPTH_COMPONENT16]:W.FLOAT,[r.DEPTH_COMPONENT24]:W.FLOAT,[r.DEPTH_COMPONENT32F]:W.FLOAT,[r.DEPTH_STENCIL]:W.FLOAT,[r.DEPTH24_STENCIL8]:W.FLOAT,[r.DEPTH32F_STENCIL8]:W.FLOAT}:t={[r.RGB]:W.FLOAT,[r.RGBA]:W.FLOAT,[r.ALPHA]:W.FLOAT,[r.LUMINANCE]:W.FLOAT,[r.LUMINANCE_ALPHA]:W.FLOAT,[r.DEPTH_STENCIL]:W.FLOAT},t}function nb(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[K.UNSIGNED_BYTE]:{[O.RGBA]:r.RGBA8,[O.RGB]:r.RGB8,[O.RG]:r.RG8,[O.RED]:r.R8,[O.RGBA_INTEGER]:r.RGBA8UI,[O.RGB_INTEGER]:r.RGB8UI,[O.RG_INTEGER]:r.RG8UI,[O.RED_INTEGER]:r.R8UI,[O.ALPHA]:r.ALPHA,[O.LUMINANCE]:r.LUMINANCE,[O.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[K.BYTE]:{[O.RGBA]:r.RGBA8_SNORM,[O.RGB]:r.RGB8_SNORM,[O.RG]:r.RG8_SNORM,[O.RED]:r.R8_SNORM,[O.RGBA_INTEGER]:r.RGBA8I,[O.RGB_INTEGER]:r.RGB8I,[O.RG_INTEGER]:r.RG8I,[O.RED_INTEGER]:r.R8I},[K.UNSIGNED_SHORT]:{[O.RGBA_INTEGER]:r.RGBA16UI,[O.RGB_INTEGER]:r.RGB16UI,[O.RG_INTEGER]:r.RG16UI,[O.RED_INTEGER]:r.R16UI,[O.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[K.SHORT]:{[O.RGBA_INTEGER]:r.RGBA16I,[O.RGB_INTEGER]:r.RGB16I,[O.RG_INTEGER]:r.RG16I,[O.RED_INTEGER]:r.R16I},[K.UNSIGNED_INT]:{[O.RGBA_INTEGER]:r.RGBA32UI,[O.RGB_INTEGER]:r.RGB32UI,[O.RG_INTEGER]:r.RG32UI,[O.RED_INTEGER]:r.R32UI,[O.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[K.INT]:{[O.RGBA_INTEGER]:r.RGBA32I,[O.RGB_INTEGER]:r.RGB32I,[O.RG_INTEGER]:r.RG32I,[O.RED_INTEGER]:r.R32I},[K.FLOAT]:{[O.RGBA]:r.RGBA32F,[O.RGB]:r.RGB32F,[O.RG]:r.RG32F,[O.RED]:r.R32F,[O.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[K.HALF_FLOAT]:{[O.RGBA]:r.RGBA16F,[O.RGB]:r.RGB16F,[O.RG]:r.RG16F,[O.RED]:r.R16F},[K.UNSIGNED_SHORT_5_6_5]:{[O.RGB]:r.RGB565},[K.UNSIGNED_SHORT_4_4_4_4]:{[O.RGBA]:r.RGBA4},[K.UNSIGNED_SHORT_5_5_5_1]:{[O.RGBA]:r.RGB5_A1},[K.UNSIGNED_INT_2_10_10_10_REV]:{[O.RGBA]:r.RGB10_A2,[O.RGBA_INTEGER]:r.RGB10_A2UI},[K.UNSIGNED_INT_10F_11F_11F_REV]:{[O.RGB]:r.R11F_G11F_B10F},[K.UNSIGNED_INT_5_9_9_9_REV]:{[O.RGB]:r.RGB9_E5},[K.UNSIGNED_INT_24_8]:{[O.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[K.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[O.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[K.UNSIGNED_BYTE]:{[O.RGBA]:r.RGBA,[O.RGB]:r.RGB,[O.ALPHA]:r.ALPHA,[O.LUMINANCE]:r.LUMINANCE,[O.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[K.UNSIGNED_SHORT_5_6_5]:{[O.RGB]:r.RGB},[K.UNSIGNED_SHORT_4_4_4_4]:{[O.RGBA]:r.RGBA},[K.UNSIGNED_SHORT_5_5_5_1]:{[O.RGBA]:r.RGBA}},t}class xp{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=nb(t),this.samplerTypes=sb(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s=0;--n){const o=e[n];o&&o._glTextures[s].samplerType!==W.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new Ma(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]??W.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!==W.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&&Hr(this.managedTextures,s,1)}}updateTextureStyle(t){const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===Xe.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Ii.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!==Xe.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===ti.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===ti.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===ti.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===ti.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}xp.extension={type:$.RendererSystem,name:"texture"};q.add(xp);class wp{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(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))(ur||{});class Ba{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.next,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 Tp=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 Ba(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=ur.NORMAL){return this._addListener(new Ba(t,e,i))}addOnce(t,e,i=ur.NORMAL){return this._addListener(new Ba(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._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?se.shared:new se,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Ep.extension=$.Application;q.add(Ep);const Ap=[];q.handleByList($.Renderer,Ap);function ob(r){for(const t of Ap)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var ab=`attribute vec2 aVertexPosition; attribute vec2 aTextureCoord; uniform mat3 projectionMatrix; varying vec2 vTextureCoord; void main(void) { gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); vTextureCoord = aTextureCoord; }`,lb=`attribute vec2 aVertexPosition; uniform mat3 projectionMatrix; varying vec2 vTextureCoord; uniform vec4 inputSize; uniform vec4 outputFrame; vec4 filterVertexPosition( void ) { vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); } vec2 filterTextureCoord( void ) { return aVertexPosition * (outputFrame.zw * inputSize.zw); } void main(void) { gl_Position = filterVertexPosition(); vTextureCoord = filterTextureCoord(); } `;const hb=ab,Sp=lb;class Cp{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>=At.HIGH?this.multisample=At.HIGH:e>=At.MEDIUM?this.multisample=At.MEDIUM:e>=At.LOW?this.multisample=At.LOW:this.multisample=At.NONE}destroy(){}}Cp.extension={type:$.RendererSystem,name:"_multisample"};q.add(Cp);class cb{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Ip{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;ie.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 ub extends Pp{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=Lr.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;l0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=Lr.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{if(this.url===null){t(this);return}try{const i=await j.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 Nr._EMPTY=Nr._EMPTY??j.ADAPTER.createCanvas(0,0),Nr._EMPTY}}const Kl=class In extends Mi{constructor(t,e){e=e||{},super(j.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)},In.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;Mi.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,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_${cr()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=In.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"&&In.SVG_XML.test(t)}};Kl.SVG_XML=/^(<\?xml[^?]+\?>)?\s*()]*-->)?\s*\]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Jl=Kl;const Ql=class th extends Mi{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];Mi.crossOrigin(i,s,e.crossorigin);for(let n=0;n{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&&(se.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||(se.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(se.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||th.TYPES.includes(e)}};Ql.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Ql.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Bp=Ql;Gl.push(Nr,rp,db,Bp,Jl,Io,fb,ub);class ao{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?it.EMPTY:(t=t||new it(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=os?o:s,n=a>n?a:n,o=t[2],a=t[3],e=os?o:s,n=a>n?a:n,o=t[4],a=t[5],e=os?o:s,n=a>n?a:n,o=t[6],a=t[7],e=os?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=gp?g:p,m=_>m?_:m,g=o*s+l*i+c,_=a*s+h*i+u,d=gp?g:p,m=_>m?_:m,g=o*e+l*n+c,_=a*e+h*n+u,d=gp?g:p,m=_>m?_:m,g=o*s+l*n+c,_=a*s+h*n+u,d=gp?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;lo?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?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.maxXh?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.maxXh?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.minXi?this.maxX:i,this.minY=this.minYs?this.maxY:s}}class wt extends Fs{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Oh,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 ao,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;i1)for(let e=0;ethis.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=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);Hr(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;e0&&n<=s){o=this.children.splice(i,n);for(let a=0;a1&&this.children.sort(mb),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;t0&&e.height>0))return;let i,s;this.cullArea?(i=this.cullArea,s=this.worldTransform):this._render!==eh.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=_b.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=s&&cs.x=n&&cs.y=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),s+=l,s+=` `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const Eb=` attribute vec2 aVertexPosition; uniform mat3 projectionMatrix; uniform float strength; varying vec2 vBlurTexCoords[%size%]; uniform vec4 inputSize; uniform vec4 outputFrame; vec4 filterVertexPosition( void ) { vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); } vec2 filterTextureCoord( void ) { return aVertexPosition * (outputFrame.zw * inputSize.zw); } void main(void) { gl_Position = filterVertexPosition(); vec2 textureCoord = filterTextureCoord(); %blur% }`;function Ab(r,t){const e=Math.ceil(r/2);let i=Eb,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 0.0) { c.rgb /= c.a; } vec4 result; result.r = (m[0] * c.r); result.r += (m[1] * c.g); result.r += (m[2] * c.b); result.r += (m[3] * c.a); result.r += m[4]; result.g = (m[5] * c.r); result.g += (m[6] * c.g); result.g += (m[7] * c.b); result.g += (m[8] * c.a); result.g += m[9]; result.b = (m[10] * c.r); result.b += (m[11] * c.g); result.b += (m[12] * c.b); result.b += (m[13] * c.a); result.b += m[14]; result.a = (m[15] * c.r); result.a += (m[16] * c.g); result.a += (m[17] * c.b); result.a += (m[18] * c.a); result.a += m[19]; vec3 rgb = mix(c.rgb, result.rgb, uAlpha); // Premultiply alpha again. rgb *= result.a; gl_FragColor = vec4(rgb, result.a); } `;class rh extends Lt{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(Sp,Cb,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]=dt.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=dt.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}}rh.prototype.grayscale=rh.prototype.greyscale;var Ib=`varying vec2 vFilterCoord; varying vec2 vTextureCoord; uniform vec2 scale; uniform mat2 rotation; uniform sampler2D uSampler; uniform sampler2D mapSampler; uniform highp vec4 inputSize; uniform vec4 inputClamp; void main(void) { vec4 map = texture2D(mapSampler, vFilterCoord); map -= 0.5; map.xy = scale * inputSize.zw * (rotation * map.xy); gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw)); } `,Rb=`attribute vec2 aVertexPosition; uniform mat3 projectionMatrix; uniform mat3 filterMatrix; varying vec2 vTextureCoord; varying vec2 vFilterCoord; uniform vec4 inputSize; uniform vec4 outputFrame; vec4 filterVertexPosition( void ) { vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); } vec2 filterTextureCoord( void ) { return aVertexPosition * (outputFrame.zw * inputSize.zw); } void main(void) { gl_Position = filterVertexPosition(); vTextureCoord = filterTextureCoord(); vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy; } `;class Pb extends Lt{constructor(t,e){const i=new yt;t.renderable=!1,super(Rb,Ib,{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 ht(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 Mb=`varying vec2 v_rgbNW; varying vec2 v_rgbNE; varying vec2 v_rgbSW; varying vec2 v_rgbSE; varying vec2 v_rgbM; varying vec2 vFragCoord; uniform sampler2D uSampler; uniform highp vec4 inputSize; /** Basic FXAA implementation based on the code on geeks3d.com with the modification that the texture2DLod stuff was removed since it's unsupported by WebGL. -- From: https://github.com/mitsuhiko/webgl-meincraft Copyright (c) 2011 by Armin Ronacher. Some rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef FXAA_REDUCE_MIN #define FXAA_REDUCE_MIN (1.0/ 128.0) #endif #ifndef FXAA_REDUCE_MUL #define FXAA_REDUCE_MUL (1.0 / 8.0) #endif #ifndef FXAA_SPAN_MAX #define FXAA_SPAN_MAX 8.0 #endif //optimized version for mobile, where dependent //texture reads can be a bottleneck vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP, vec2 v_rgbNW, vec2 v_rgbNE, vec2 v_rgbSW, vec2 v_rgbSE, vec2 v_rgbM) { vec4 color; vec3 rgbNW = texture2D(tex, v_rgbNW).xyz; vec3 rgbNE = texture2D(tex, v_rgbNE).xyz; vec3 rgbSW = texture2D(tex, v_rgbSW).xyz; vec3 rgbSE = texture2D(tex, v_rgbSE).xyz; vec4 texColor = texture2D(tex, v_rgbM); vec3 rgbM = texColor.xyz; vec3 luma = vec3(0.299, 0.587, 0.114); float lumaNW = dot(rgbNW, luma); float lumaNE = dot(rgbNE, luma); float lumaSW = dot(rgbSW, luma); float lumaSE = dot(rgbSE, luma); float lumaM = dot(rgbM, luma); float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); mediump vec2 dir; dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * inverseVP; vec3 rgbA = 0.5 * ( texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz + texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz); vec3 rgbB = rgbA * 0.5 + 0.25 * ( texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz + texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz); float lumaB = dot(rgbB, luma); if ((lumaB < lumaMin) || (lumaB > lumaMax)) color = vec4(rgbA, texColor.a); else color = vec4(rgbB, texColor.a); return color; } void main() { vec4 color; color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); gl_FragColor = color; } `,Bb=` attribute vec2 aVertexPosition; uniform mat3 projectionMatrix; varying vec2 v_rgbNW; varying vec2 v_rgbNE; varying vec2 v_rgbSW; varying vec2 v_rgbSE; varying vec2 v_rgbM; varying vec2 vFragCoord; uniform vec4 inputSize; uniform vec4 outputFrame; vec4 filterVertexPosition( void ) { vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); } void texcoords(vec2 fragCoord, vec2 inverseVP, out vec2 v_rgbNW, out vec2 v_rgbNE, out vec2 v_rgbSW, out vec2 v_rgbSE, out vec2 v_rgbM) { v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP; v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP; v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP; v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP; v_rgbM = vec2(fragCoord * inverseVP); } void main(void) { gl_Position = filterVertexPosition(); vFragCoord = aVertexPosition * outputFrame.zw; texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); } `;class kb extends Lt{constructor(){super(Bb,Mb)}}var Db=`precision highp float; varying vec2 vTextureCoord; varying vec4 vColor; uniform float uNoise; uniform float uSeed; uniform sampler2D uSampler; float rand(vec2 co) { return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); } void main() { vec4 color = texture2D(uSampler, vTextureCoord); float randomValue = rand(gl_FragCoord.xy * uSeed); float diff = (randomValue - 0.5) * uNoise; // Un-premultiply alpha before applying the color matrix. See issue #3539. if (color.a > 0.0) { color.rgb /= color.a; } color.r += diff; color.g += diff; color.b += diff; // Premultiply alpha again. color.rgb *= color.a; gl_FragColor = color; } `;class Fb extends Lt{constructor(t=.5,e=Math.random()){super(Sp,Db,{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 vu={AlphaFilter:bb,BlurFilter:Sb,BlurFilterPass:ih,ColorMatrixFilter:rh,DisplacementFilter:Pb,FXAAFilter:kb,NoiseFilter:Fb};Object.entries(vu).forEach(([r,t])=>{Object.defineProperty(vu,r,{get(){return nt("7.1.0",`filters.${r} has moved to ${r}`),t}})});class Ob{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||(se.system.add(this.tickerUpdate,this,ur.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(se.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._deltaTimei.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i=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=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")&&(xi.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,ka),!t.hitArea.contains(ka.x,ka.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 Ee)){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 Ee)){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 Ee)){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 Ee)){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 Ee)){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 Ee)){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 $r)){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(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,nh._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;i0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",s=this.normalizeToPointerData(t);for(let n=0,o=s.length;n"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=Gb),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=Hb[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}};sh.extension={name:"events",type:[$.RendererSystem,$.CanvasRendererSystem]},sh.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let oh=sh;q.add(oh);function bu(r){return r==="dynamic"||r==="static"}const zb={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??bu(oh.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??oh.defaultEventMode},set eventMode(r){this._internalInteractive=bu(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 Ns))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(zb);const $b={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};wt.mixin($b);const Xb=9,rn=100,Vb=0,Wb=0,xu=2,wu=1,jb=-1e3,Yb=-1e3,qb=2;class Fp{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,(ei.tablet||ei.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${rn}px`,e.style.height=`${rn}px`,e.style.position="absolute",e.style.top=`${Vb}px`,e.style.left=`${Wb}px`,e.style.zIndex=xu.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=`${wu}px`,t.style.height=`${wu}px`,t.style.position="absolute",t.style.top=`${jb}px`,t.style.left=`${Yb}px`,t.style.zIndex=qb.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 title : ${t.title}
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=`${rn}px`,e.style.height=`${rn}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=xu.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.title=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 Ns(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===Xb&&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}}Fp.extension={name:"accessibility",type:[$.RendererPlugin,$.CanvasRendererPlugin]};q.add(Fp);const Op=class ah{constructor(t){this.stage=new Ut,t=Object.assign({forceCanvas:!1},t),this.renderer=ob(t),ah._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=ah._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Op._plugins=[];let Np=Op;q.handleByList($.Application,Np._plugins);class Lp{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}}Lp.extension=$.Application;q.add(Lp);const Tu={loader:$.LoadParser,resolver:$.ResolveParser,cache:$.CacheParser,detection:$.DetectionParser};q.handle($.Asset,r=>{const t=r.ref;Object.entries(Tu).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(Tu).filter(e=>!!t[e]).forEach(e=>q.remove(t[e]))});class Zb{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(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),lh=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Up(r,t,e,i,s){const n=t[e];for(let o=0;o{const o=n.substring(1,n.length-1).split(",");s.push(o)}),Up(r,s,0,e,i)}else i.push(r);return i}const ho=r=>!Array.isArray(r);class Jb{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=Ae(t);let s;for(let a=0;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 tr=new Jb;class Qb{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({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const c=It.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}. ${u}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=Ae(t,i=>({alias:[i],src:i})).map(async i=>{const s=It.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 Ie=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Ie||{});const tx=".json",ex="application/json",ix={extension:{type:$.LoadParser,priority:Ie.Low},name:"loadJson",test(r){return is(r,ex)||Ui(r,tx)},async load(r){return await(await j.ADAPTER.fetch(r)).json()}};q.add(ix);const rx=".txt",sx="text/plain",nx={name:"loadTxt",extension:{type:$.LoadParser,priority:Ie.Low},test(r){return is(r,sx)||Ui(r,rx)},async load(r){return await(await j.ADAPTER.fetch(r)).text()}};q.add(nx);const ox=["normal","bold","100","200","300","400","500","600","700","800","900"],ax=[".ttf",".otf",".woff",".woff2"],lx=["font/ttf","font/otf","font/woff","font/woff2"],hx=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function cx(r){const t=It.extname(r),e=It.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(hx)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const ux=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function dx(r){return ux.test(r)?r:encodeURI(r)}const fx={extension:{type:$.LoadParser,priority:Ie.Low},name:"loadWebFont",test(r){return is(r,lx)||Ui(r,ax)},async load(r,t){const e=j.ADAPTER.getFontFaceSet();if(e){const i=[],s=t.data?.family??cx(r),n=t.data?.weights?.filter(a=>ox.includes(a))??["normal"],o=t.data??{};for(let a=0;aj.ADAPTER.getFontFaceSet().delete(t))}};q.add(fx);let Eu=0,Da;const px="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=",_x={id:"checkImageBitmap",code:` async function checkImageBitmap() { try { if (typeof createImageBitmap !== 'function') return false; const response = await fetch('${px}'); const imageBlob = await response.blob(); const imageBitmap = await createImageBitmap(imageBlob); return imageBitmap.width === 1 && imageBitmap.height === 1; } catch (e) { return false; } } checkImageBitmap().then((result) => { self.postMessage(result); }); `},mx={id:"loadImageBitmap",code:` async function loadImageBitmap(url) { const response = await fetch(url); if (!response.ok) { throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \` + \`\${response.status} \${response.statusText}\`); } const imageBlob = await response.blob(); const imageBitmap = await createImageBitmap(imageBlob); return imageBitmap; } self.onmessage = async (event) => { try { const imageBitmap = await loadImageBitmap(event.data.data[0]); self.postMessage({ data: imageBitmap, uuid: event.data.uuid, id: event.data.id, }, [imageBitmap]); } catch(e) { self.postMessage({ error: e, uuid: event.data.uuid, id: event.data.id, }); } };`};let Fa;class gx{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([_x.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(){Da===void 0&&(Da=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers{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[Eu]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Eu++,id:i})}}const Au=new gx;function Ls(r,t,e){r.resource.internal=!0;const i=new Y(r),s=()=>{delete t.promiseCache[e],tr.has(e)&&tr.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 yx=[".jpeg",".jpg",".png",".webp",".avif"],vx=["image/jpeg","image/png","image/webp","image/avif"];async function bx(r){const t=await j.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 ko={name:"loadTextures",extension:{type:$.LoadParser,priority:Ie.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return is(r,vx)||Ui(r,yx)},async load(r,t,e){const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await Au.isImageBitmapSupported()?s=await Au.loadImageBitmap(r):s=await bx(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=li(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,Ls(o,e,r)},unload(r){r.destroy(!0)}};q.add(ko);const xx=".svg",wx="image/svg+xml",Tx={extension:{type:$.LoadParser,priority:Ie.High},name:"loadSVG",test(r){return is(r,wx)||Ui(r,xx)},async testParse(r){return Jl.test(r)},async parse(r,t,e){const i=new Jl(r,t?.data?.resourceOptions);await i.load();const s=new rt(i,{resolution:li(r),...t?.data});return s.resource.src=t.src,Ls(s,e,t.src)},async load(r,t){return(await j.ADAPTER.fetch(r)).text()},unload:ko.unload};q.add(Tx);const Ex=[".mp4",".m4v",".webm",".ogv"],Ax=["video/mp4","video/webm","video/ogg"],Sx={name:"loadVideo",extension:{type:$.LoadParser,priority:Ie.High},config:{defaultAutoPlay:!0},test(r){return is(r,Ax)||Ui(r,Ex)},async load(r,t,e){let i;const s=await(await j.ADAPTER.fetch(r)).blob(),n=URL.createObjectURL(s);try{const o={autoPlay:this.config.defaultAutoPlay,...t?.data?.resourceOptions},a=new Bp(n,o);await a.load();const l=new rt(a,{alphaMode:await By(),resolution:li(r),...t?.data});l.resource.src=r,i=Ls(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(Sx);class Cx{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,name:i,src:s,srcs:n}=t;return Ae(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. Please 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`)},Ae(o).forEach(l=>{const{src:h,srcs:c}=l;let{data:u,format:d,loadParser:f}=l;const p=Ae(h||c).map(_=>typeof _=="string"?Kb(_):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._assetMap[_]=g})})}resolveBundle(t){const e=ho(t);t=Ae(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=ho(t);t=Ae(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;en.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=It.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??It.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class Ix{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Cx,this.loader=new Qb,this.cache=tr,this._backgroundLoader=new Zb(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=ho(t),s=Ae(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}addBundle(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 tr.get(t);const e={};for(let i=0;i{const h=n[a.src],c=[a.src];a.alias&&c.push(...a.alias),o[s[l]]=h,tr.set(c,h)}),o}async unload(t){this._initialized||await this.init();const e=Ae(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=Ae(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=>{tr.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 ko.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 sn=new Ix;q.handleByList($.LoadParser,sn.loader.parsers).handleByList($.ResolveParser,sn.resolver.parsers).handleByList($.CacheParser,sn.cache.parsers).handleByList($.DetectionParser,sn.detections);const Rx={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(Rx);async function Gp(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 Px={extension:{type:$.DetectionParser,priority:1},test:async()=>Gp("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};q.add(Px);const Mx={extension:{type:$.DetectionParser,priority:0},test:async()=>Gp("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};q.add(Mx);const Su=["png","jpg","jpeg"],Bx={extension:{type:$.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Su],remove:async r=>r.filter(t=>!Su.includes(t))};q.add(Bx);const kx="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Uh(r){return kx?!1:document.createElement("video").canPlayType(r)!==""}const Dx={extension:{type:$.DetectionParser,priority:0},test:async()=>Uh("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};q.add(Dx);const Fx={extension:{type:$.DetectionParser,priority:0},test:async()=>Uh("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};q.add(Fx);const Ox={extension:{type:$.DetectionParser,priority:0},test:async()=>Uh("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};q.add(Ox);const Nx={extension:$.ResolveParser,test:ko.test,parse:r=>({resolution:parseFloat(j.RETINA_PREFIX.exec(r)?.[1]??"1"),format:It.extname(r).slice(1),src:r})};q.add(Nx);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_EAC=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 co={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 Je,kr;function Cu(){kr={s3tc:Je.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Je.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:Je.getExtension("WEBGL_compressed_texture_etc"),etc1:Je.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:Je.getExtension("WEBGL_compressed_texture_pvrtc")||Je.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:Je.getExtension("WEBGL_compressed_texture_atc"),astc:Je.getExtension("WEBGL_compressed_texture_astc")}}const Lx={extension:{type:$.DetectionParser,priority:2},test:async()=>{const r=j.ADAPTER.createCanvas().getContext("webgl");return r?(Je=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{kr||Cu();const t=[];for(const e in kr)kr[e]&&t.push(e);return[...t,...r]},remove:async r=>(kr||Cu(),r.filter(t=>!(t in kr)))};q.add(Lx);class Ux extends Io{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 Ul(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 Ul(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class lr extends Ux{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=lr._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||lr._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=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*co[e];for(let m=0;m1?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*co[e];return l}}const Oa=4,nn=124,Gx=32,Iu=20,Hx=542327876,on={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},zx={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},an={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},$x=1,Xx=2,Vx=4,Wx=64,jx=512,Yx=131072,qx=827611204,Zx=861165636,Kx=894720068,Jx=808540228,Qx=4,tw={[qx]:te.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Zx]:te.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Kx]:te.COMPRESSED_RGBA_S3TC_DXT5_EXT},ew={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 iw(r){const t=new Uint32Array(r);if(t[0]!==Hx)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,nn/Uint32Array.BYTES_PER_ELEMENT),i=e[on.HEIGHT],s=e[on.WIDTH],n=e[on.MIPMAP_COUNT],o=new Uint32Array(r,on.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,Gx/Uint32Array.BYTES_PER_ELEMENT),a=o[$x];if(a&Vx){const l=o[zx.FOURCC];if(l!==Jx){const v=tw[l],y=Oa+nn,b=new Uint8Array(r,y);return[new lr(b,{format:v,width:s,height:i,levels:n})]}const h=Oa+nn,c=new Uint32Array(t.buffer,h,Iu/Uint32Array.BYTES_PER_ELEMENT),u=c[an.DXGI_FORMAT],d=c[an.RESOURCE_DIMENSION],f=c[an.MISC_FLAG],p=c[an.ARRAY_SIZE],m=ew[u];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${u}`);if(f===Qx)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,_=Oa+nn+Iu;if(p===1)g.push(new Uint8Array(r,_));else{const v=co[m];let y=0,b=s,x=i;for(let w=0;w>>1,x=x>>>1}let S=_;for(let w=0;wnew lr(v,{format:m,width:s,height:i,levels:n}))}throw a&Wx?new Error("DDSParser does not support uncompressed texture data."):a&jx?new Error("DDSParser does not supported YUV uncompressed texture data."):a&Yx?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&Xx?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 Ru=[171,75,84,88,32,49,49,187,13,10,26,10],rw=67305985,xe={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},hh=64,Pu={[K.UNSIGNED_BYTE]:1,[K.UNSIGNED_SHORT]:2,[K.INT]:4,[K.UNSIGNED_INT]:4,[K.FLOAT]:4,[K.HALF_FLOAT]:8},sw={[O.RGBA]:4,[O.RGB]:3,[O.RG]:2,[O.RED]:1,[O.LUMINANCE]:1,[O.LUMINANCE_ALPHA]:2,[O.ALPHA]:1},nw={[K.UNSIGNED_SHORT_4_4_4_4]:2,[K.UNSIGNED_SHORT_5_5_5_1]:2,[K.UNSIGNED_SHORT_5_6_5]:2};function ow(r,t,e=!1){const i=new DataView(t);if(!aw(r,i))return null;const s=i.getUint32(xe.ENDIANNESS,!0)===rw,n=i.getUint32(xe.GL_TYPE,s),o=i.getUint32(xe.GL_FORMAT,s),a=i.getUint32(xe.GL_INTERNAL_FORMAT,s),l=i.getUint32(xe.PIXEL_WIDTH,s),h=i.getUint32(xe.PIXEL_HEIGHT,s)||1,c=i.getUint32(xe.PIXEL_DEPTH,s)||1,u=i.getUint32(xe.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(xe.NUMBER_OF_FACES,s),f=i.getUint32(xe.NUMBER_OF_MIPMAP_LEVELS,s),p=i.getUint32(xe.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?Pu[n]?x=Pu[n]*sw[o]:x=nw[n]:x=co[a],x===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const S=e?hw(i,p,s):null;let w=b*x,T=l,I=h,B=_,P=v,M=hh+p;for(let E=0;E1||n!==0?T:B,levelHeight:f>1||n!==0?I:P,levelBuffer:new Uint8Array(t,G,w)},G+=w}M+=C+4,M=M%4!==0?M+4-M%4:M,T=T>>1||1,I=I>>1||1,B=T+m-1&~(m-1),P=I+g-1&~(g-1),w=B*P*x}return n!==0?{uncompressed:y.map(E=>{let C=E[0].levelBuffer,G=!1;return n===K.FLOAT?C=new Float32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4):n===K.UNSIGNED_INT?(G=!0,C=new Uint32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4)):n===K.INT&&(G=!0,C=new Int32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4)),{resource:new Io(C,{width:E[0].levelWidth,height:E[0].levelHeight}),type:n,format:G?lw(o):o}}),kvData:S}:{compressed:y.map(E=>new lr(null,{format:a,width:l,height:h,levels:f,levelBuffers:E})),kvData:S}}function aw(r,t){for(let e=0;et-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l{const o=new rt(n,{mipmap:Xe.OFF,alphaMode:Zt.NO_PREMULTIPLIED_ALPHA,resolution:li(r),...t.data});return Ls(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(cw);const uw={extension:{type:$.LoadParser,priority:Ie.High},name:"loadKTX",test(r){return Ui(r,".ktx")},async load(r,t,e){const i=await(await j.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=ow(r,i),a=s??n,l={mipmap:Xe.OFF,alphaMode:Zt.NO_PREMULTIPLIED_ALPHA,resolution:li(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,Ls(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(uw);const dw={extension:$.ResolveParser,test:r=>{const t=It.extname(r).slice(1);return["basis","ktx","dds"].includes(t)},parse:r=>{const t=It.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(j.RETINA_PREFIX.exec(r)?.[1]??"1"),format:e.find(i=>r.endsWith(i)),src:r}}return{resolution:parseFloat(j.RETINA_PREFIX.exec(r)?.[1]??"1"),format:t,src:r}}};q.add(dw);const ln=new it,fw=4,Hp=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 Yy(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 Gt?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(ln.width=e.width,ln.height=e.height,e=ln)));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===O.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=ln,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(fw*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=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;p0||t&&i<=0){const s=e/2;for(let n=s+s%2;n=6){Mu(e,!1);const o=[];for(let h=0;h=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)}},mw={build(r){uo.build(r)},triangulate(r,t){uo.triangulate(r,t)}};var fe=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(fe||{}),Ei=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(Ei||{});const qr={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 ethis.maxSegments&&(e=this.maxSegments),e}};class Bu{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,S=h*(_+v),w=l*(_+v),T=u*(g+y),I=c*(g+y),B=Math.atan2(w-x,S-b),P=Math.atan2(I-x,T-b);return{cx:b+t,cy:x+e,radius:n,startAngle:B,endAngle:P,anticlockwise:h*c>u*l}}static arc(t,e,i,s,n,o,a,l,h){const c=a-o,u=qr._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),S=-Math.sin(b);h.push((p*x+m*S)*n+i,(p*-S+m*x)*n+s)}}}class gw{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 Gh{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 S=1;S<=10;++S)c=S/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=qr._segmentsCount(Gh.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 ku(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 $i(r,t,e,i,s,n,o,a){const l=e-r,h=i-t;let c=Math.atan2(l,h),u=Math.atan2(s-r,n-t);a&&cu&&(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=0&&(n.join===fe.ROUND?d+=$i(y,b,y-w*E,b-T*E,y-I*E,b-B*E,c,!1)+4:d+=2,c.push(y-I*C,b-B*C,y+I*E,b+B*E));continue}const et=(-w+_)*(-T+b)-(-w+y)*(-T+v),tt=(-I+x)*(-B+b)-(-I+y)*(-B+S),st=(J*tt-A*et)/D,ft=(L*et-H*tt)/D,vt=(st-y)*(st-y)+(ft-b)*(ft-b),pt=y+(st-y)*E,ot=b+(ft-b)*E,ut=y-(st-y)*C,lt=b-(ft-b)*C,mt=Math.min(J*J+H*H,A*A+L*L),U=R?E:C,Et=mt+U*U*m,zt=vt<=Et;let F=n.join;if(F===fe.MITER&&vt/m>g&&(F=fe.BEVEL),zt)switch(F){case fe.MITER:{c.push(pt,ot,ut,lt);break}case fe.BEVEL:{R?c.push(pt,ot,y+w*C,b+T*C,pt,ot,y+I*C,b+B*C):c.push(y-w*E,b-T*E,ut,lt,y-I*E,b-B*E,ut,lt),d+=2;break}case fe.ROUND:{R?(c.push(pt,ot,y+w*C,b+T*C),d+=$i(y,b,y+w*C,b+T*C,y+I*C,b+B*C,c,!0)+4,c.push(pt,ot,y+I*C,b+B*C)):(c.push(y-w*E,b-T*E,ut,lt),d+=$i(y,b,y-w*E,b-T*E,y-I*E,b-B*E,c,!1)+4,c.push(y-I*E,b-B*E,ut,lt));break}}else{switch(c.push(y-w*E,b-T*E,y+w*C,b+T*C),F){case fe.MITER:{R?c.push(ut,lt,ut,lt):c.push(pt,ot,pt,ot),d+=2;break}case fe.ROUND:{R?d+=$i(y,b,y+w*C,b+T*C,y+I*C,b+B*C,c,!0)+2:d+=$i(y,b,y-w*E,b-T*E,y-I*E,b-B*E,c,!1)+2;break}}c.push(y-I*E,b-B*E,y+I*C,b+B*C),d+=2}}_=i[(u-2)*2],v=i[(u-2)*2+1],y=i[(u-1)*2],b=i[(u-1)*2+1],w=-(v-b),T=_-y,P=Math.sqrt(w*w+T*T),w/=P,T/=P,w*=p,T*=p,c.push(y-w*E,b-T*E,y+w*C,b+T*C),l||(n.cap===Ei.ROUND?d+=$i(y-w*(E-C)*.5,b-T*(E-C)*.5,y-w*E,b-T*E,y+w*C,b+T*C,c,!1)+2:n.cap===Ei.SQUARE&&(d+=ku(y,b,w,T,E,C,!1,c)));const G=t.indices,X=qr.epsilon*qr.epsilon;for(let N=f;N0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,s=null){const n=new fo(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 fo(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;t0&&(i=this.batches[this.batches.length-1],s=i.style);for(let l=this.shapeIndex;l65535;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;t65535*2)return!1;const t=this.batches;for(let e=0;e0&&(s=hn.pop(),s||(s=new zl,s.texArray=new Wl),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.wrapMode=Ii.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;h0&&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 ar,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new ar,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),Hh.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o){return this._initCurve(),Gh.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=Bu.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);u0;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 it(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new Mo(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new Ro(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new Po(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 ar(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===kt.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;si&&!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=Wf(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=dt.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;fs&&(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;o0);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}}jp.extension={name:"particle",type:$.RendererPlugin};q.add(jp);var Fo=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(Fo||{});const cn={willReadFrequently:!0},Fe=class Z{static get experimentalLetterSpacingSupported(){let t=Z._experimentalLetterSpacingSupported;if(t!==void 0){const e=j.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}static 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",cn);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;p0&&(s?n-=e:n+=(Z.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=Z._canvas){const s=i.getContext("2d",cn);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;gp)if(o!==""&&(a+=Z.addLine(o),o="",n=0),Z.canBreakWords(_,e.breakWords)){const y=Z.wordWrapSplit(_);for(let b=0;bp&&(a+=Z.addLine(o),f=!1,o="",n=0),o+=x,n+=T}}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} `: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;sa;--d){for(let m=0;m{if(typeof Intl?.Segmenter=="function"){const r=new Intl.Segmenter;return t=>[...r.segment(t)].map(e=>e.segment)}return r=>[...r]})(),Fe.experimentalLetterSpacing=!1,Fe._fonts={},Fe._newlines=[10,13],Fe._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let yi=Fe;const Cw=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Yp=class ys{constructor(t){this.styleID=0,this.reset(),Ha(this,t,t)}clone(){const t={};return Ha(t,this,ys.defaultStyle),new ys(t)}reset(){Ha(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=Ga(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=Ga(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){Iw(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=Ga(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)&&!Cw.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};Yp.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Fo.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 Bi=Yp;function Ga(r){const t=dt.shared,e=i=>{const s=t.setValue(i);return s.alpha===1?s.toHex():s.toRgbaString()};return Array.isArray(r)?r.map(e):e(r)}function Iw(r,t){if(!Array.isArray(r)||!Array.isArray(t)||r.length!==t.length)return!1;for(let e=0;e0&&p>m&&(g=(m+p)/2);const _=m+d,v=i.lineHeight*(f+1);let y=_;f+10}}function Mw(r,t){let e=!1;if(r?._textures?.length){for(let i=0;i{this.queue&&this.prepareItems()},this.registerFindHook(Ow),this.registerFindHook(Nw),this.registerFindHook(Mw),this.registerFindHook(Bw),this.registerFindHook(kw),this.registerUploadHook(Dw),this.registerUploadHook(Fw)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,se.system.addOnce(this.tick,this,ur.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=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&se.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}};Kp.uploadsPerFrame=4;let dh=Kp;Object.defineProperties(j,{UPLOADS_PER_FRAME:{get(){return dh.uploadsPerFrame},set(r){nt("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),dh.uploadsPerFrame=r}}});function Qp(r,t){return t instanceof rt?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function Lw(r,t){if(!(t instanceof dr))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let s=0;s1?$e.from(Hw,Gw,e):$e.from(Gu,zw,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!==Ii.CLAMP:l.wrapMode===Ii.CLAMP&&(l.wrapMode=Ii.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,m=a.height,g=t._width,_=t._height;un.set(c.a*p/g,c.b*p/_,c.c*m/g,c.d*m/_,c.tx/g,c.ty/_),un.invert(),d?un.prepend(u.mapCoord):(f.uniforms.uMapCoord=u.mapCoord.toArray(!0),f.uniforms.uClampFrame=u.uClampFrame,f.uniforms.uClampOffset=u.uClampOffset),f.uniforms.uTransform=un.toArray(!0),f.uniforms.uColor=dt.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=Wf(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}e_.extension={name:"tilingSprite",type:$.RendererPlugin};q.add(e_);const i_=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=li(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{this._batchIndex*vs.BATCH_SIZE{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[s]=t.textures[s]}),!e){const s=It.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=r_([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const Vw={extension:$.Asset,cache:{test:r=>r instanceof Hu,getCacheableAssets:(r,t)=>r_(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&Xw.includes(i)},parse:r=>{const t=r.split(".");return{resolution:parseFloat(j.RETINA_PREFIX.exec(r)?.[1]??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:$.LoadParser,priority:Ie.Normal},async testParse(r,t){return It.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){let i=It.dirname(t.src);i&&i.lastIndexOf("/")!==i.length-1&&(i+="/");let s=i+r.meta.image;s=lh(s,t.src);const n=(await e.load([s]))[s],o=new Hu(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=lh(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(Vw);class po{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Pn{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 po;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 fh{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 po,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")?fh.test(j.ADAPTER.parseXML(t)):!1}static parse(t){return fh.parse(j.ADAPTER.parseXML(t))}}const za=[Pn,fh,ph];function Ww(r){for(let t=0;t=l-B*o){if(m===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${w}')`);--S,g=null,_=null,v=null,m=0,p=0,y=0;continue}if(y=Math.max(B+T.fontProperties.descent,y),P*o+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${w}')`);--S,m+=y*o,m=Math.ceil(m),p=0,y=0;continue}Yw(g,_,T,p,m,o,u);const M=Mn(T.text);f.char.push({id:M,page:b.length-1,x:p/o,y:m/o,width:P,height:B,xoffset:0,yoffset:0,xadvance:I-(u.dropShadow?u.dropShadowDistance:0)-(u.stroke?u.strokeThickness:0)}),p+=(P+2*n)*o,p=Math.ceil(p)}if(!i?.skipKerning)for(let S=0,w=c.length;S 0.99) {\r alpha = 1.0;\r }\r \r // Gamma correction for coverage-like alpha\r float luma = dot(uColor.rgb, vec3(0.299, 0.587, 0.114));\r float gamma = mix(1.0, 1.0 / 2.2, luma);\r float coverage = pow(uColor.a * alpha, gamma); \r \r // NPM Textures, NPM outputs\r gl_FragColor = vec4(uColor.rgb, coverage);\r }\r `,Kw=`// Mesh material default fragment\r attribute vec2 aVertexPosition;\r attribute vec2 aTextureCoord;\r \r uniform mat3 projectionMatrix;\r uniform mat3 translationMatrix;\r uniform mat3 uTextureMatrix;\r \r varying vec2 vTextureCoord;\r \r void main(void)\r {\r gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\r \r vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r }\r `;const zu=[],$u=[],Xu=[],Jw=class n_ extends Ut{constructor(t,e={}){super();const{align:i,tint:s,maxWidth:n,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},n_.styleDefaults,e);if(!pi.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new dt(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 ii(()=>{this.dirty=!0},this,0,0),this._roundPixels=j.ROUND_PIXELS,this.dirty=!0,this._resolution=j.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){const t=pi.available[this._fontName],e=this.fontSize,i=e/t.size,s=new ht,n=[],o=[],a=[],l=this._text.replace(/(?:\r\n|\r)/g,` `)||" ",h=s_(l),c=this._maxWidth*t.size/e,u=t.distanceFieldType==="none"?zu:$u;let d=null,f=0,p=0,m=0,g=-1,_=0,v=0,y=0,b=0;for(let P=0;P0&&s.x>c&&(++v,Hr(n,1+g-v,1+P-g),P=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!==` `&&(/(?:\s)/.test(x)&&(f=_),o.push(f),p=Math.max(p,f),a.push(-1));const S=[];for(let P=0;P<=m;P++){let M=0;this._align==="right"?M=p-o[P]:this._align==="center"?M=(p-o[P])/2:this._align==="justify"&&(M=a[P]<0?0:(p-o[P])/a[P]),S.push(M)}const w=n.length,T={},I=[],B=this._activePagesMeshData;u.push(...B);for(let P=0;P6*E)||M.vertices.lengthe[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)}};Jw.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const Qw=[".xml",".fnt"],tT={extension:{type:$.LoadParser,priority:Ie.Normal},name:"loadBitmapFont",test(r){return Qw.includes(It.extname(r).toLowerCase())},async testParse(r){return Pn.test(r)||ph.test(r)},async parse(r,t,e){const i=Pn.test(r)?Pn.parse(r):ph.parse(r),{src:s}=t,{page:n}=i,o=[];for(let h=0;ha[h]);return pi.install(i,l,!0)},async load(r,t){return(await j.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};q.add(tT);const _h=class Dr extends Bi{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new Dr(Object.keys(Dr.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 Dr.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=Dr;if(i[t]){const s=i[t];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return j.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:It.basename(t,It.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} @font-face { font-family: "${e.family}"; src: url('${e.dataSrc}'); font-weight: ${e.weight}; font-style: ${e.style}; font-display: ${e.display}; }`,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=Xy(t)),typeof t=="number"?$y(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,Dr.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}=j.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}};_h.availableFonts={},_h.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 $a=_h;const dn=class Fr extends Xt{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:j.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new it,s.trim=new it,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=Fr.defaultMaxWidth,this.maxHeight=Fr.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=Fr.defaultAutoResolution,this._resolution=Fr.defaultResolution??j.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()=>{if(a/gi,"

").replace(/
/gi,"
").replace(/ /gi," ")}};dn.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},dn.defaultMaxWidth=2024,dn.defaultMaxHeight=2024,dn.defaultAutoResolution=!0;const eT=` precision highp float; uniform sampler2D uDrawingTexture; uniform sampler2D uEraserTexture; varying vec2 vTextureCoord; void main(void) { vec4 drawingColor = texture2D(uDrawingTexture,vTextureCoord); vec4 eraserColor = texture2D(uEraserTexture, vTextureCoord); // Use the alpha of the eraser to determine how much to "erase" from the drawing float alpha = 1.0 - eraserColor.a; gl_FragColor = vec4(drawingColor.rgb * alpha, drawingColor.a * alpha); }`;function Vu(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 iT(){let r=[],t=0;return{add_layer:function(e,i,s,n,o){let a,l,h=this;return{execute:function(){a=new Ut,t++,a.zIndex=t;const c=Gt.create({width:s,height:n}),u=new Xt(c);a.addChild(u),u.zIndex=t;const d={draw_texture:Gt.create({width:s,height:n}),erase_texture:Gt.create({width:s,height:n}),composite:u},f=new Lt(void 0,eT,{uEraserTexture:d.erase_texture,uDrawingTexture:d.draw_texture});u.filters=[f],e.addChild(a),r.push(d),h.layers.update(p=>[...p,d]),h.active_layer.set(d),l=Wo(h.layers).length-1,o&&i.render(o,{renderTexture:d.draw_texture})},undo:function(){e.removeChild(a),r=Wo(h.layers),r=r.filter((u,d)=>d!==l),h.layers.set(r);const c=r[l-1]||r[0]||null;h.active_layer.set(c)}}},swap_layers:function(e,i){return i==="up"?Vu(r,e):Vu(r,e-1),r[e]},change_active_layer:function(e){return this.active_layer.set(Wo(this.layers)[e]),r[e]},reset(){r.forEach(e=>{e.draw_texture.destroy(!0),e.erase_texture.destroy(!0),e.composite.destroy(!0)}),r=[],t=0,this.active_layer.set(null),this.layers.set([])},async add_layer_from_blob(e,i,s,n){const o=await createImageBitmap(s),a=Y.from(o),[l,h]=rT(a.width,a.height,n.width,n.height),c=new Xt(a);return c.zIndex=0,c.width=l,c.height=h,this.add_layer(e,i,n.width,n.height,c)},get_layers(){return r},layers:Nt([]),active_layer:Nt(null)}}function rT(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 sT({target:r,dimensions:[t,e],antialias:i}){const s=window.devicePixelRatio||1,n=new Np({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 Ut;a.zIndex=0;const l=new Ut;l.zIndex=1,l.sortableChildren=!0;const h=new Ut;h.zIndex=1;const c=new Ut;c.zIndex=0,h.addChild(a),h.addChild(l),n.stage.addChild(h),n.stage.addChild(c);const u=new dr;let d=Gt.create({width:t,height:e});const f=new Xt(d);h.mask=f,n.render();function p(_,v){a.removeChildren(),u.beginFill(16777215,1),u.drawRect(0,0,_,v),u.endFill(),d=Gt.create({width:_,height:v}),n.renderer.render(u,{renderTexture:d});const y=new Xt(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 Xa(n.renderer,a,v,y,b),S=await Promise.all(_.map(T=>Xa(n.renderer,T.composite,v,y,b))),w=await Xa(n.renderer,h,v,y,b);return{background:x,layers:S,composite:w}}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 o_(r){const t=new dr;return t.eventMode="none",t.zIndex=r,t}function Yt(r,t,e){return re?e:r}function Xa(r,t,e,i,s){return new Promise(n=>{const o=r.extract.canvas(t,new it(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 Va(r,t,e,i=new dt("black"),s){const n=new dt(i);r.beginFill(n),r.drawCircle(t,e,s),r.endFill()}function nT(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{r&&!r.contains(i.target)&&!i.defaultPrevented&&t(i)};return document.addEventListener("mousedown",e,!0),{destroy(){document.removeEventListener("mousedown",e,!0)}}}const{SvelteComponent:aT,append:Wu,attr:fn,binding_callbacks:ju,detach:Wa,element:pn,flush:lT,init:hT,insert:ja,listen:_n,noop:Yu,run_all:cT,safe_not_equal:uT,set_style:Me,space:dT}=window.__gradio__svelte__internal,{tick:fT}=window.__gradio__svelte__internal;function pT(r){let t,e,i=`translate(${r[1][0]}px,${r[1][1]}px)`,s,n,o,a=`translateX(${r[3]}px)`,l,h;return{c(){t=pn("div"),e=pn("div"),s=dT(),n=pn("div"),o=pn("div"),fn(e,"class","marker svelte-90y9cx"),Me(e,"transform",i),Me(e,"background",r[0]),fn(t,"class","color-gradient svelte-90y9cx"),Me(t,"--hue",r[2]),fn(o,"class","marker svelte-90y9cx"),Me(o,"background","hsl("+r[2]+", 100%, 50%)"),Me(o,"transform",a),fn(n,"class","hue-slider svelte-90y9cx")},m(c,u){ja(c,t,u),Wu(t,e),r[10](t),ja(c,s,u),ja(c,n,u),Wu(n,o),r[11](n),l||(h=[_n(window,"mousemove",r[8]),_n(window,"mouseup",r[9]),_n(t,"mousedown",r[7]),_n(n,"mousedown",r[6])],l=!0)},p(c,[u]){u&2&&i!==(i=`translate(${c[1][0]}px,${c[1][1]}px)`)&&Me(e,"transform",i),u&1&&Me(e,"background",c[0]),u&4&&Me(t,"--hue",c[2]),u&4&&Me(o,"background","hsl("+c[2]+", 100%, 50%)"),u&8&&a!==(a=`translateX(${c[3]}px)`)&&Me(o,"transform",a)},i:Yu,o:Yu,d(c){c&&(Wa(t),Wa(s),Wa(n)),r[10](null),r[11](null),l=!1,cT(h)}}}function qu(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 _T(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(w){c=w.currentTarget.getBoundingClientRect(),u=!0,f(w.clientX)}function f(w){if(!c)return;const T=Yt(w-c.left,0,c.width);e(3,h=T);const I=T/c.width*360;e(2,l=I),e(0,i=qu({h:I,s:a[0],v:a[1],a:1}))}function p(w,T){if(!n)return;const I=Yt(w-n.left,0,n.width),B=Yt(T-n.top,0,n.height);e(1,s=[I,B]);const P={h:l*1,s:I/n.width,v:1-B/n.height,a:1};a=[P.s,P.v],e(0,i=qu(P))}function m(w){o=!0,n=w.currentTarget.getBoundingClientRect(),p(w.clientX,w.clientY)}function g(w){o&&p(w.clientX,w.clientY),u&&f(w.clientX)}function _(){o&&(o=!1),u&&(u=!1)}async function v(w){if(o||u||(await fT(),!w))return;n||(n=y.getBoundingClientRect()),c||(c=b.getBoundingClientRect());const T=Ci(w).toHsv(),I=T.s*n.width,B=(1-T.v)*n.height;e(1,s=[I,B]),a=[T.s,T.v],e(2,l=T.h),e(3,h=T.h/360*c.width)}let y,b;function x(w){ju[w?"unshift":"push"](()=>{y=w,e(4,y)})}function S(w){ju[w?"unshift":"push"](()=>{b=w,e(5,b)})}return r.$$set=w=>{"color"in w&&e(0,i=w.color)},r.$$.update=()=>{r.$$.dirty&1&&v(i)},[i,s,l,h,y,b,d,m,g,_,x,S]}class mT extends aT{constructor(t){super(),hT(this,t,_T,pT,uT,{color:0})}get color(){return this.$$.ctx[0]}set color(t){this.$$set({color:t}),lT()}}const{SvelteComponent:gT,append:er,attr:Ri,create_component:yT,destroy_component:vT,destroy_each:a_,detach:Zr,element:si,ensure_array_like:_o,flush:Tr,init:bT,insert:Kr,listen:Xh,mount_component:xT,safe_not_equal:wT,set_style:mo,space:Bn,toggle_class:me,transition_in:TT,transition_out:ET}=window.__gradio__svelte__internal,{createEventDispatcher:AT}=window.__gradio__svelte__internal;function Zu(r,t,e){const i=r.slice();return i[14]=t[e],i[16]=e,i}function Ku(r,t,e){const i=r.slice();return i[14]=t[e],i[16]=e,i}function Ju(r){let t;return{c(){t=si("span"),Ri(t,"class","svelte-287ern"),me(t,"lg",r[1])},m(e,i){Kr(e,t,i)},p(e,i){i&2&&me(t,"lg",e[1])},d(e){e&&Zr(t)}}}function Qu(r){let t,e,i,s,n,o=_o(r[1]),a=[];for(let l=0;lu(_,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 IT extends gT{constructor(t){super(),bT(this,t,CT,ST,wT,{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}),Tr()}get colors(){return this.$$.ctx[7]}set colors(t){this.$$set({colors:t}),Tr()}get user_colors(){return this.$$.ctx[1]}set user_colors(t){this.$$set({user_colors:t}),Tr()}get show_empty(){return this.$$.ctx[8]}set show_empty(t){this.$$set({show_empty:t}),Tr()}get current_mode(){return this.$$.ctx[9]}set current_mode(t){this.$$set({current_mode:t}),Tr()}get color_picker(){return this.$$.ctx[0]}set color_picker(t){this.$$set({color_picker:t}),Tr()}}const{SvelteComponent:RT,append:qe,attr:_i,create_component:PT,destroy_component:MT,destroy_each:BT,detach:l_,element:mi,ensure_array_like:id,flush:rd,init:kT,insert:h_,listen:kn,mount_component:DT,run_all:FT,safe_not_equal:OT,set_style:sd,space:Ya,toggle_class:nd,transition_in:c_,transition_out:u_}=window.__gradio__svelte__internal,{createEventDispatcher:NT}=window.__gradio__svelte__internal;function od(r,t,e){const i=r.slice();return i[11]=t[e][0],i[12]=t[e][1],i}function LT(r){let t,e;return t=new G_({}),{c(){PT(t.$$.fragment)},m(i,s){DT(t,i,s),e=!0},i(i){e||(c_(t.$$.fragment,i),e=!0)},o(i){u_(t.$$.fragment,i),e=!1},d(i){MT(t,i)}}}function ad(r){let t,e,i;function s(){return r[8](r[12])}return{c(){t=mi("button"),t.textContent=`${r[11]}`,_i(t,"class","button svelte-w84deg"),nd(t,"active",r[1]===r[12])},m(n,o){h_(n,t,o),e||(i=kn(t,"click",s),e=!0)},p(n,o){r=n,o&10&&nd(t,"active",r[1]===r[12])},d(n){n&&l_(t),e=!1,i()}}}function UT(r){let t,e,i,s,n,o,a,l,h,c,u,d,f,p=r[5]&<(),m=id(r[3]),g=[];for(let _=0;_{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 HT extends RT{constructor(t){super(),kT(this,t,GT,UT,OT,{color:0,current_mode:1})}get color(){return this.$$.ctx[0]}set color(t){this.$$set({color:t}),rd()}get current_mode(){return this.$$.ctx[1]}set current_mode(t){this.$$set({current_mode:t}),rd()}}const{SvelteComponent:zT,action_destroyer:$T,add_iframe_resize_listener:XT,add_render_callback:ld,append:qa,attr:Ze,binding_callbacks:VT,create_component:WT,destroy_component:jT,detach:YT,element:Za,flush:Ka,init:qT,insert:ZT,listen:Ja,mount_component:KT,run_all:JT,safe_not_equal:QT,set_input_value:hd,space:tE,to_number:eE,toggle_class:Er,transition_in:iE,transition_out:rE}=window.__gradio__svelte__internal,{createEventDispatcher:sE}=window.__gradio__svelte__internal;function nE(r){let t,e,i,s,n,o,a,l,h;return ld(r[11]),i=new nm({}),{c(){t=Za("div"),e=Za("span"),WT(i.$$.fragment),s=tE(),n=Za("input"),Ze(e,"class","svelte-12m4nbd"),Ze(n,"type","range"),Ze(n,"min",r[1]),Ze(n,"max",r[2]),Ze(n,"step",1),Ze(n,"class","svelte-12m4nbd"),Ze(t,"class","wrap svelte-12m4nbd"),ld(()=>r[15].call(t)),Er(t,"right",r[8]),Er(t,"top",r[9]),Er(t,"bottom",!r[9])},m(c,u){ZT(c,t,u),qa(t,e),KT(i,e,null),qa(t,s),qa(t,n),hd(n,r[0]),r[14](t),o=XT(t,r[15].bind(t)),a=!0,l||(h=[Ja(window,"resize",r[11]),Ja(n,"change",r[12]),Ja(n,"input",r[12]),$T($h.call(null,t,r[13]))],l=!0)},p(c,[u]){(!a||u&2)&&Ze(n,"min",c[1]),(!a||u&4)&&Ze(n,"max",c[2]),u&1&&hd(n,c[0]),(!a||u&256)&&Er(t,"right",c[8]),(!a||u&512)&&Er(t,"top",c[9]),(!a||u&512)&&Er(t,"bottom",!c[9])},i(c){a||(iE(i.$$.fragment,c),a=!0)},o(c){rE(i.$$.fragment,c),a=!1},d(c){c&&YT(t),jT(i),r[14](null),o(),l=!1,JT(h)}}}function oE(r,t,e){let{selected_size:i}=t,{min:s}=t,{max:n}=t;const o=sE();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=eE(this.value),e(0,i)}const g=()=>o("click_outside");function _(y){VT[y?"unshift":"push"](()=>{u=y,e(7,u)})}function 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 aE extends zT{constructor(t){super(),qT(this,t,oE,nE,QT,{selected_size:0,min:1,max:2})}get selected_size(){return this.$$.ctx[0]}set selected_size(t){this.$$set({selected_size:t}),Ka()}get min(){return this.$$.ctx[1]}set min(t){this.$$set({min:t}),Ka()}get max(){return this.$$.ctx[2]}set max(t){this.$$set({max:t}),Ka()}}const{SvelteComponent:lE,action_destroyer:hE,add_flush_callback:go,add_iframe_resize_listener:cE,add_render_callback:cd,append:Qa,attr:d_,bind:yo,binding_callbacks:Ds,check_outros:mh,create_component:vo,destroy_component:bo,detach:Oo,element:f_,empty:uE,flush:we,group_outros:gh,init:dE,insert:No,listen:fE,mount_component:xo,run_all:pE,safe_not_equal:_E,space:Dn,toggle_class:Be,transition_in:ee,transition_out:Ue}=window.__gradio__svelte__internal,{createEventDispatcher:mE}=window.__gradio__svelte__internal;function ud(r){let t,e,i=r[7]&&dd(r);return{c(){i&&i.c(),t=uE()},m(s,n){i&&i.m(s,n),No(s,t,n),e=!0},p(s,n){s[7]?i?(i.p(s,n),n[0]&128&&ee(i,1)):(i=dd(s),i.c(),ee(i,1),i.m(t.parentNode,t)):i&&(gh(),Ue(i,1,1,()=>{i=null}),mh())},i(s){e||(ee(i),e=!0)},o(s){Ue(i),e=!1},d(s){s&&Oo(t),i&&i.d(s)}}}function dd(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 mT({props:l}),Ds.push(()=>yo(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 HT({props:c}),Ds.push(()=>yo(s,"current_mode",h)),s.$on("close",r[25]),s.$on("selected",r[26]),{c(){vo(t.$$.fragment),i=Dn(),vo(s.$$.fragment)},m(u,d){xo(t,u,d),No(u,i,d),xo(s,u,d),o=!0},p(u,d){const f={};!e&&d[0]&1&&(e=!0,f.color=u[0],go(()=>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],go(()=>n=!1)),s.$set(p)},i(u){o||(ee(t.$$.fragment,u),ee(s.$$.fragment,u),o=!0)},o(u){Ue(t.$$.fragment,u),Ue(s.$$.fragment,u),o=!1},d(u){u&&Oo(i),bo(t,u),bo(s,u)}}}function fd(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 IT({props:n}),Ds.push(()=>yo(t,"color_picker",s)),t.$on("select",r[28]),t.$on("edit",r[29]),{c(){vo(t.$$.fragment)},m(o,a){xo(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],go(()=>e=!1)),t.$set(l)},i(o){i||(ee(t.$$.fragment,o),i=!0)},o(o){Ue(t.$$.fragment,o),i=!1},d(o){bo(t,o)}}}function pd(r){let t;return{c(){t=f_("div"),d_(t,"class","sep svelte-gtuiq3")},m(e,i){No(e,t,i)},d(e){e&&Oo(t)}}}function gE(r){let t,e,i,s,n,o,a,l,h,c;cd(r[22]);let u=r[4]==="defaults"&&ud(r),d=r[6]&&fd(r),f=(r[7]||r[6])&&pd();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 aE({props:m}),Ds.push(()=>yo(n,"selected_size",p)),{c(){t=f_("div"),u&&u.c(),e=Dn(),d&&d.c(),i=Dn(),f&&f.c(),s=Dn(),vo(n.$$.fragment),d_(t,"class","wrap svelte-gtuiq3"),cd(()=>r[33].call(t)),Be(t,"padded",!r[7]),Be(t,"anchor_default",r[14]==="default"),Be(t,"anchor_center",r[14]==="center"),Be(t,"anchor_top",r[14]==="top"),Be(t,"anchor",`${r[15]}px`)},m(g,_){No(g,t,_),u&&u.m(t,null),Qa(t,e),d&&d.m(t,null),Qa(t,i),f&&f.m(t,null),Qa(t,s),xo(n,t,null),r[32](t),a=cE(t,r[33].bind(t)),l=!0,h||(c=[fE(window,"resize",r[22]),hE($h.call(null,t,r[31]))],h=!0)},p(g,_){g[4]==="defaults"?u?(u.p(g,_),_[0]&16&&ee(u,1)):(u=ud(g),u.c(),ee(u,1),u.m(t,e)):u&&(gh(),Ue(u,1,1,()=>{u=null}),mh()),g[6]?d?(d.p(g,_),_[0]&64&&ee(d,1)):(d=fd(g),d.c(),ee(d,1),d.m(t,i)):d&&(gh(),Ue(d,1,1,()=>{d=null}),mh()),g[7]||g[6]?f||(f=pd(),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],go(()=>o=!1)),n.$set(v),(!l||_[0]&128)&&Be(t,"padded",!g[7]),(!l||_[0]&16384)&&Be(t,"anchor_default",g[14]==="default"),(!l||_[0]&16384)&&Be(t,"anchor_center",g[14]==="center"),(!l||_[0]&16384)&&Be(t,"anchor_top",g[14]==="top"),(!l||_[0]&32768)&&Be(t,"anchor",`${g[15]}px`)},i(g){l||(ee(u),ee(d),ee(n.$$.fragment,g),l=!0)},o(g){Ue(u),Ue(d),Ue(n.$$.fragment,g),l=!1},d(g){g&&Oo(t),u&&u.d(),d&&d.d(),f&&f.d(),bo(n),r[32](null),a(),h=!1,pE(c)}}}function yE(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 _=mE();function v({index:D,color:R},et){et==="user"&&!R&&(g=D,e(7,p=!0)),R&&(e(0,s=R),et==="core"&&e(7,p=!1))}function y(D){g!==null&&e(1,o[g]=D,o)}let b=0,x=0,S=0,w=0,T,I="default",B=0;function P(){e(9,x=window.innerHeight),e(8,b=window.innerWidth)}function M(D){s=D,e(0,s)}function E(D){m=D,e(13,m)}const C=()=>e(7,p=!1),G=({detail:D})=>e(0,s=D);function X(D){p=D,e(7,p)}const N=({detail:D})=>v(D,"core"),J=({detail:D})=>v(D,"user");function H(D){a=D,e(2,a)}const A=()=>_("click_outside");function L(D){Ds[D?"unshift":"push"](()=>{T=D,e(12,T)})}function V(){S=this.clientWidth,w=this.clientHeight,e(10,S),e(11,w)}return r.$$set=D=>{"colors"in D&&e(3,i=D.colors),"selected_color"in D&&e(0,s=D.selected_color),"color_mode"in D&&e(4,n=D.color_mode),"recent_colors"in D&&e(1,o=D.recent_colors),"selected_size"in D&&e(2,a=D.selected_size),"dimensions"in D&&e(5,l=D.dimensions),"parent_width"in D&&e(18,h=D.parent_width),"parent_height"in D&&e(19,c=D.parent_height),"parent_left"in D&&e(20,u=D.parent_left),"toolbar_box"in D&&e(21,d=D.toolbar_box),"show_swatch"in D&&e(6,f=D.show_swatch)},r.$$.update=()=>{if(r.$$.dirty[0]&1&&y(s),r.$$.dirty[0]&3940224&&T&&(b||x||w||S)){const D=T.getBoundingClientRect();D.width>h||(h>D.width+230*2+25?(e(14,I="default"),e(15,B=d.right-u+24)):e(14,I="center")),D.height+50>c&&e(14,I="top")}},[s,o,a,i,n,l,f,p,b,x,S,w,T,m,I,B,_,v,h,c,u,d,P,M,E,C,G,X,N,J,H,A,L,V]}class vE extends lE{constructor(t){super(),dE(this,t,yE,gE,_E,{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}),we()}get selected_color(){return this.$$.ctx[0]}set selected_color(t){this.$$set({selected_color:t}),we()}get color_mode(){return this.$$.ctx[4]}set color_mode(t){this.$$set({color_mode:t}),we()}get recent_colors(){return this.$$.ctx[1]}set recent_colors(t){this.$$set({recent_colors:t}),we()}get selected_size(){return this.$$.ctx[2]}set selected_size(t){this.$$set({selected_size:t}),we()}get dimensions(){return this.$$.ctx[5]}set dimensions(t){this.$$set({dimensions:t}),we()}get parent_width(){return this.$$.ctx[18]}set parent_width(t){this.$$set({parent_width:t}),we()}get parent_height(){return this.$$.ctx[19]}set parent_height(t){this.$$set({parent_height:t}),we()}get parent_left(){return this.$$.ctx[20]}set parent_left(t){this.$$set({parent_left:t}),we()}get toolbar_box(){return this.$$.ctx[21]}set toolbar_box(t){this.$$set({toolbar_box:t}),we()}get show_swatch(){return this.$$.ctx[6]}set show_swatch(t){this.$$set({show_swatch:t}),we()}}const{SvelteComponent:bE,add_flush_callback:tl,attr:xE,bind:el,binding_callbacks:il,check_outros:wE,component_subscribe:Xi,create_component:TE,destroy_component:EE,detach:Fn,element:p_,empty:AE,flush:us,group_outros:SE,init:CE,insert:On,listen:IE,mount_component:RE,safe_not_equal:PE,set_style:he,space:ME,transition_in:Nn,transition_out:yh}=window.__gradio__svelte__internal,{getContext:_d,onMount:BE,tick:cC}=window.__gradio__svelte__internal;function md(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[6],color_mode:r[0],dimensions:r[5],parent_width:r[4].parent_width,parent_height:r[4].parent_height,parent_left:r[4].parent_left,toolbar_box:r[12]};return r[2]!==void 0&&(c.selected_color=r[2]),r[9]!==void 0&&(c.recent_colors=r[9]),r[3]!==void 0&&(c.selected_size=r[3]),e=new vE({props:c}),il.push(()=>el(e,"selected_color",a)),il.push(()=>el(e,"recent_colors",l)),il.push(()=>el(e,"selected_size",h)),e.$on("click_outside",r[28]),{c(){t=p_("div"),TE(e.$$.fragment)},m(u,d){On(u,t,d),RE(e,t,null),o=!0},p(u,d){const f={};d[0]&2&&(f.show_swatch=u[1]==="draw"),d[0]&64&&(f.colors=u[6]),d[0]&1&&(f.color_mode=u[0]),d[0]&32&&(f.dimensions=u[5]),d[0]&16&&(f.parent_width=u[4].parent_width),d[0]&16&&(f.parent_height=u[4].parent_height),d[0]&16&&(f.parent_left=u[4].parent_left),d[0]&4096&&(f.toolbar_box=u[12]),!i&&d[0]&4&&(i=!0,f.selected_color=u[2],tl(()=>i=!1)),!s&&d[0]&512&&(s=!0,f.recent_colors=u[9],tl(()=>s=!1)),!n&&d[0]&8&&(n=!0,f.selected_size=u[3],tl(()=>n=!1)),e.$set(f)},i(u){o||(Nn(e.$$.fragment,u),o=!0)},o(u){yh(e.$$.fragment,u),o=!1},d(u){u&&Fn(t),EE(e)}}}function kE(r){let t,e=`translate(${r[10].x}px, ${r[10].y}px)`,i=`${r[4].child_top-r[4].parent_top-r[11]/2}px`,s=`${r[4].child_left-r[4].parent_left-r[11]/2}px`,n=`${r[11]}px`,o=`${r[11]}px`,a,l,h,c,u,d=r[7]&&md(r);return{c(){t=p_("span"),a=ME(),d&&d.c(),l=AE(),xE(t,"class","svelte-btgkrd"),he(t,"transform",e),he(t,"top",i),he(t,"left",s),he(t,"width",n),he(t,"height",o),he(t,"opacity",r[8]?1:0)},m(f,p){On(f,t,p),On(f,a,p),d&&d.m(f,p),On(f,l,p),h=!0,c||(u=IE(window,"keydown",r[24]),c=!0)},p(f,p){p[0]&1024&&e!==(e=`translate(${f[10].x}px, ${f[10].y}px)`)&&he(t,"transform",e),p[0]&2064&&i!==(i=`${f[4].child_top-f[4].parent_top-f[11]/2}px`)&&he(t,"top",i),p[0]&2064&&s!==(s=`${f[4].child_left-f[4].parent_left-f[11]/2}px`)&&he(t,"left",s),p[0]&2048&&n!==(n=`${f[11]}px`)&&he(t,"width",n),p[0]&2048&&o!==(o=`${f[11]}px`)&&he(t,"height",o),p[0]&256&&he(t,"opacity",f[8]?1:0),f[7]?d?(d.p(f,p),p[0]&128&&Nn(d,1)):(d=md(f),d.c(),Nn(d,1),d.m(l.parentNode,l)):d&&(SE(),yh(d,1,1,()=>{d=null}),wE())},i(f){h||(Nn(d),h=!0)},o(f){yh(d),h=!1},d(f){f&&(Fn(t),Fn(a),Fn(l)),d&&d.d(f),c=!1,u()}}}function DE(r,t,e){let i,s,n,o,a,l,h,c,{default_size:u}=t,{default_color:d=void 0}=t,{colors:f=void 0}=t,{color_mode:p=void 0}=t,{mode:m}=t,g=[],_=[];f&&JSON.stringify(_)!==JSON.stringify(f)&&(g=f.map(st).filter((U,Et)=>Et<4),_=g);let v=st(d||"#000000"),y=!1;const{pixi:b,dimensions:x,current_layer:S,command_manager:w,register_context:T,editor_box:I,crop:B,toolbar_box:P}=_d(rs);Xi(r,b,U=>e(32,o=U)),Xi(r,x,U=>e(5,n=U)),Xi(r,S,U=>e(35,h=U)),Xi(r,I,U=>e(4,s=U)),Xi(r,B,U=>e(34,l=U)),Xi(r,P,U=>e(12,c=U));const{active_tool:M,register_tool:E,current_color:C}=_d(Ao);Xi(r,M,U=>e(33,a=U));let G=!1,X;function N(U,Et){const zt=Yt(Math.min(U,Et),500,1e3);return Math.round(zt*2/100)}let J=u==="auto"?N(...n):u;function H(U){a===m&&(G=!0,!(!o||!h)&&(X=oT(o.renderer,o.layer_container,h,m),X.start({x:U.screen.x,y:U.screen.y,color:v||void 0,size:J,opacity:1})))}function A(U){!o||!h||a===m&&(X.stop(),w.execute(X),G=!1)}function L(U){if(a!==m)return;G&&X.continue({x:U.screen.x,y:U.screen.y});const Et=l[0]*n[0],zt=l[1]*n[1];Et>U.screen.x||zt>U.screen.y||U.screen.x>Et+l[2]*n[0]||U.screen.y>zt+l[3]*n[1]?(e(8,V=!1),document.body.style.cursor="auto"):(e(8,V=!0),document.body.style.cursor="none"),V&&e(10,ft={x:U.clientX-s.child_left,y:U.clientY-s.child_top})}let V=!1;async function D(U){o?.layer_container[U]("pointerdown",H),o?.layer_container[U]("pointerup",A),o?.layer_container[U]("pointermove",L),o?.layer_container[U]("pointerenter",Et=>{a===m&&(e(8,V=!0),document.body.style.cursor="none")}),o?.layer_container[U]("pointerleave",()=>(e(8,V=!1),document.body.style.cursor="auto"))}T(m,{init_fn:()=>{D("on")},reset_fn:()=>{D("off")}});const R=vt(),et=E(m,{cb:R});BE(()=>()=>{et(),D("off")});let tt=[null,null,null];function st(U){return Ci(U).toRgbString()}let ft={x:0,y:0};function vt(){let U=null;return function(zt){const F=()=>{if(U&&clearTimeout(U),zt!==void 0){e(7,y=zt);return}e(7,y=!y)};U&&clearTimeout(U),U=setTimeout(F,100)}}const pt=({key:U})=>U==="Escape"&&R(!1);function ot(U){v=U,e(2,v)}function ut(U){tt=U,e(9,tt)}function lt(U){J=U,e(3,J)}const mt=()=>R();return r.$$set=U=>{"default_size"in U&&e(21,u=U.default_size),"default_color"in U&&e(22,d=U.default_color),"colors"in U&&e(23,f=U.colors),"color_mode"in U&&e(0,p=U.color_mode),"mode"in U&&e(1,m=U.mode)},r.$$.update=()=>{r.$$.dirty[0]&6&&m==="draw"&&C.set(v),r.$$.dirty[0]&6&&m==="draw"&&C.set(v),r.$$.dirty[0]&56&&e(11,i=J/n[0]*s.child_width*2)},[p,m,v,J,s,n,g,y,V,tt,ft,i,c,b,x,S,I,B,P,M,R,u,d,f,pt,ot,ut,lt,mt]}class __ extends bE{constructor(t){super(),CE(this,t,DE,kE,PE,{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}),us()}get default_color(){return this.$$.ctx[22]}set default_color(t){this.$$set({default_color:t}),us()}get colors(){return this.$$.ctx[23]}set colors(t){this.$$set({colors:t}),us()}get color_mode(){return this.$$.ctx[0]}set color_mode(t){this.$$set({color_mode:t}),us()}get mode(){return this.$$.ctx[1]}set mode(t){this.$$set({mode:t}),us()}}function gd(r,t,e,i=0){let s,n;const o=new dr;let a,l,h,c,u=hf(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=Gt.create({width:g,height:_}),f(g,_,v,y),n=new Xt(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,{hard:!0}),e.set([l[0]/h,l[1]/c,l[2]/h,l[3]/c]),p=!0)}}}function m_(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,y_offset:h}}const{SvelteComponent:FE,append:OE,attr:mn,binding_callbacks:NE,detach:LE,element:yd,flush:Vi,init:UE,insert:GE,listen:rl,noop:vd,run_all:HE,safe_not_equal:zE,set_style:bd}=window.__gradio__svelte__internal,{tick:$E,createEventDispatcher:XE}=window.__gradio__svelte__internal;function VE(r){let t,e,i,s,n,o;return{c(){t=yd("div"),e=yd("div"),mn(e,"class",i="handle "+r[0]+" "+r[1]+" svelte-1x33xzn"),mn(t,"class",s="hitbox "+r[1]+" svelte-1x33xzn"),bd(t,"transform",r[3])},m(a,l){GE(a,t,l),OE(t,e),r[12](e),n||(o=[rl(window,"mousemove",r[5]),rl(window,"mouseup",r[6]),rl(t,"mousedown",r[4])],n=!0)},p(a,[l]){l&3&&i!==(i="handle "+a[0]+" "+a[1]+" svelte-1x33xzn")&&mn(e,"class",i),l&2&&s!==(s="hitbox "+a[1]+" svelte-1x33xzn")&&mn(t,"class",s),l&8&&bd(t,"transform",a[3])},i:vd,o:vd,d(a){a&&LE(t),r[12](null),n=!1,HE(o)}}}function WE(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=XE();let{dragging:m=!1}=t,g;function _(S){c=g.getBoundingClientRect(),f=!0,e(11,m=!0),["tl","bl","l"].includes(n)&&(d=S.clientX-c.right),["tl","tr","t"].includes(n)&&(u=S.clientY-c.bottom),["tr","r","br"].includes(n)&&(d=S.clientX-c.left),["br","b","bl"].includes(n)&&(u=S.clientY-c.top)}function v(S){if(!f)return;const w=S.clientY-u,T=S.clientY-u,I=S.clientX-d,B=S.clientX-d;["tl","bl","l"].includes(n)&&e(7,o=I),["tl","tr","t"].includes(n)&&e(8,a=w),["tr","r","br"].includes(n)&&e(9,l=B),["br","b","bl"].includes(n)&&e(10,h=T)}async function y(S){await $E(),f=!1,e(11,m=!1)}function b(S,w,T,I,B){let P,M,E,C;return c&&(["tl","l","bl"].includes(S)&&(M=w),["tl","t","tr"].includes(S)&&(P=I),["tr","r","br"].includes(S)&&(E=T),["br","b","bl"].includes(S)&&(C=B)),p("change",{top:P,bottom:C,left:M,right:E}),""}function x(S){NE[S?"unshift":"push"](()=>{g=S,e(2,g)})}return r.$$set=S=>{"type"in S&&e(0,s=S.type),"location"in S&&e(1,n=S.location),"x1"in S&&e(7,o=S.x1),"y1"in S&&e(8,a=S.y1),"x2"in S&&e(9,l=S.x2),"y2"in S&&e(10,h=S.y2),"dragging"in S&&e(11,m=S.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 jE extends FE{constructor(t){super(),UE(this,t,WE,VE,zE,{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}),Vi()}get location(){return this.$$.ctx[1]}set location(t){this.$$set({location:t}),Vi()}get x1(){return this.$$.ctx[7]}set x1(t){this.$$set({x1:t}),Vi()}get y1(){return this.$$.ctx[8]}set y1(t){this.$$set({y1:t}),Vi()}get x2(){return this.$$.ctx[9]}set x2(t){this.$$set({x2:t}),Vi()}get y2(){return this.$$.ctx[10]}set y2(t){this.$$set({y2:t}),Vi()}get dragging(){return this.$$.ctx[11]}set dragging(t){this.$$set({dragging:t}),Vi()}}const{SvelteComponent:YE,add_flush_callback:qE,append:sl,attr:Ln,bind:ZE,binding_callbacks:KE,check_outros:JE,create_component:QE,destroy_component:tA,destroy_each:xd,detach:g_,element:Un,ensure_array_like:nl,flush:Ar,group_outros:eA,init:iA,insert:y_,listen:ol,mount_component:rA,noop:v_,run_all:sA,safe_not_equal:nA,set_style:ci,space:oA,subscribe:aA,toggle_class:wd,transition_in:Gn,transition_out:vh}=window.__gradio__svelte__internal,{createEventDispatcher:lA}=window.__gradio__svelte__internal;function hA(r,t,e){const i=r.slice();return i[30]=t[e],i}function Td(r,t,e){const i=r.slice();return i[33]=t[e],i}function Ed(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 jE({props:o}),KE.push(()=>ZE(t,"dragging",s)),t.$on("change",n),{c(){QE(t.$$.fragment)},m(a,l){rA(t,a,l),i=!0},p(a,l){r=a;const h={};!e&&l[0]&2&&(e=!0,h.dragging=r[1],qE(()=>e=!1)),t.$set(h)},i(a){i||(Gn(t.$$.fragment,a),i=!0)},o(a){vh(t.$$.fragment,a),i=!1},d(a){tA(t,a)}}}function cA(r){let t;return{c(){t=Un("div"),Ln(t,"class","svelte-12y7ld0")},m(e,i){y_(e,t,i)},p:v_,d(e){e&&g_(t)}}}function uA(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=nl(r[7]),f=[];for(let _=0;_vh(f[_],1,1,()=>{f[_]=null});let m=nl({length:25}),g=[];for(let _=0;_(s(),s=aA(o,H=>e(19,i=H)),o);r.$$.on_destroy.push(()=>s());let{editor_box:o}=t;n();let{crop_constraint:a}=t;const l=lA();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,S,w=!1;function T(){S&&clearTimeout(S),e(17,S=setTimeout(()=>{w&&(l("crop_end",{x:v,y,width:g,height:_}),w=!1),e(6,x=!0),e(18,E=!1)},1e3))}function I({top:H,bottom:A,left:L,right:V},D){e(4,u=Yt(H?H-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(V?V-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(V?V-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(H?p-H+i.parent_top:h,0,p-u));const R={tl:"br",tr:"bl",bl:"tr",br:"tl",t:"b",b:"t",l:"r",r:"l",c:"c"};if(a){const et=["t","b"].includes(D)?i.child_width:f-d,tt=["l","r"].includes(D)?i.child_height:p-u;let st=m_(c,h,R[D],a,et,tt);e(3,c=st.new_width),e(2,h=st.new_height),e(5,d=d+st.x_offset),e(4,u=u+st.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(w?"crop_continue":"crop_start",{x:v,y,width:g,height:_}),w=!0}function B(){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 P=0,M=0,E=!1;function C(H){e(18,E=!0),P=H.clientX,M=H.clientY,x&&(e(6,x=!1),l("crop_start",{x:v,y,width:g,height:_}))}function G(H){E&&e(18,E=!1)}function X(H){if(!E)return;const A=H.clientX-P,L=H.clientY-M;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),P=H.clientX,M=H.clientY,l("crop_continue",{x:v,y,width:g,height:_}),w=!0}function N(H){m=H,e(1,m)}const J=(H,{detail:A})=>I(A,H);return r.$$set=H=>{"editor_box"in H&&n(e(0,o=H.editor_box)),"crop_constraint"in H&&e(16,a=H.crop_constraint),"w_p"in H&&e(12,g=H.w_p),"h_p"in H&&e(13,_=H.h_p),"l_p"in H&&e(14,v=H.l_p),"t_p"in H&&e(15,y=H.t_p)},r.$$.update=()=>{r.$$.dirty[0]&393218&&(m||E?(clearTimeout(S),e(6,x=!1)):T()),r.$$.dirty[0]&524288&&i&&B()},[o,m,h,c,u,d,x,b,I,C,G,X,g,_,v,y,a,S,E,i,N,J]}class fA extends YE{constructor(t){super(),iA(this,t,dA,uA,nA,{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}),Ar()}get crop_constraint(){return this.$$.ctx[16]}set crop_constraint(t){this.$$set({crop_constraint:t}),Ar()}get w_p(){return this.$$.ctx[12]}set w_p(t){this.$$set({w_p:t}),Ar()}get h_p(){return this.$$.ctx[13]}set h_p(t){this.$$set({h_p:t}),Ar()}get l_p(){return this.$$.ctx[14]}set l_p(t){this.$$set({l_p:t}),Ar()}get t_p(){return this.$$.ctx[15]}set t_p(t){this.$$set({t_p:t}),Ar()}}const{SvelteComponent:pA,check_outros:_A,component_subscribe:Sr,create_component:mA,destroy_component:gA,detach:yA,empty:vA,flush:bA,group_outros:xA,init:wA,insert:TA,mount_component:EA,safe_not_equal:AA,transition_in:Hn,transition_out:bh}=window.__gradio__svelte__internal,{getContext:Ad,onDestroy:SA,onMount:uC,tick:dC}=window.__gradio__svelte__internal;function Sd(r){let t,e;return t=new fA({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(){mA(t.$$.fragment)},m(i,s){EA(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||(Hn(t.$$.fragment,i),e=!0)},o(i){bh(t.$$.fragment,i),e=!1},d(i){gA(t,i)}}}function CA(r){let t,e,i=r[5]==="crop"&&r[6]&&Sd(r);return{c(){i&&i.c(),t=vA()},m(s,n){i&&i.m(s,n),TA(s,t,n),e=!0},p(s,n){s[5]==="crop"&&s[6]?i?(i.p(s,n),n[0]&96&&Hn(i,1)):(i=Sd(s),i.c(),Hn(i,1),i.m(t.parentNode,t)):i&&(xA(),bh(i,1,1,()=>{i=null}),_A())},i(s){e||(Hn(i),e=!0)},o(s){bh(i),e=!1},d(s){s&&yA(t),i&&i.d(s)}}}function IA(r,t,e){let i,s,n,o,a,l;const{active_tool:h,register_tool:c}=Ad(Ao);Sr(r,h,A=>e(5,l=A));const{dimensions:u,editor_box:d,pixi:f,crop:p,command_manager:m,current_history:g}=Ad(rs);Sr(r,u,A=>e(18,n=A)),Sr(r,d,A=>e(16,i=A)),Sr(r,f,A=>e(19,o=A)),Sr(r,p,A=>e(17,s=A)),Sr(r,g,A=>e(27,a=A));let _,{crop_constraint:v}=t,y=null,b=1,x=1,S=0,w=0,T=0,I=!1,B=null;async function P(){if(B||a.previous)return;const{new_height:A,new_width:L,x_offset:V,y_offset:D}=m_(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,S=V/i.child_width),e(4,w=D/i.child_height),B=gd(o.renderer,o.background_container,p,.2),B.start(...n,G,!1),B.continue([S*n[0],w*n[1],b*n[0],x*n[1]],!1),B.stop(),B.execute(),B=null,T=0}function M(A,{x:L,y:V,width:D,height:R}){if(o){if(A==="start")_&&(T=_.stop(),_=null),_=gd(o?.renderer,o.background_container,p,T),_.start(...n,G);else if(A==="continue"){if(!_)return;_.continue([L*n[0],V*n[1],D*n[0],R*n[1]])}else if(A==="stop"){if(!_)return;m.execute(_)}e(15,I=!0)}}let E=!1;function C(){if(E||!i.child_height)return;const A=i.child_height,L=i.child_width,V=i.child_top-i.parent_top,D=i.child_left-i.parent_left;e(1,b=L/i.child_width),e(2,x=A/i.child_height),e(3,S=(D-i.child_left+i.parent_left)/i.child_width),e(4,w=(V-i.child_top+i.parent_top)/i.child_height),e(6,E=!0)}let G;const X=c("crop");SA(X);const N=({detail:A})=>M("start",A),J=({detail:A})=>M("continue",A),H=({detail:A})=>M("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&&!I&&y&&o&&l&&requestAnimationFrame(()=>{P()}),r.$$.dirty[0]&131072&&(e(3,S=s[0]),e(4,w=s[1]),e(1,b=s[2]),e(2,x=s[3])),r.$$.dirty[0]&262174&&(G=[S*n[0],w*n[1],b*n[0],x*n[1]]),r.$$.dirty[0]&65536&&i&&C()},[y,b,x,S,w,l,E,h,u,d,f,p,g,M,v,I,i,s,n,o,N,J,H]}class RA extends pA{constructor(t){super(),wA(this,t,IA,CA,AA,{crop_constraint:14},null,[-1,-1])}get crop_constraint(){return this.$$.ctx[14]}set crop_constraint(t){this.$$set({crop_constraint:t}),bA()}}function Cd(r,t,e,i){const s=r/t,n=e/i;let o,a;r<=e&&t<=i?(o=r,a=t):s>n?(o=e,a=e/s):(a=i,o=i*s);const l=Math.round((e-o)/2),h=Math.round((i-a)/2);return{width:Math.round(o),height:Math.round(a),x:l,y:h}}function PA(r,t,e,i,s,n){let o;return{async start(){r.removeChildren();const a=await createImageBitmap(e),l=Y.from(a);if(o=new Xt(l),n||(s=[o.width,o.height]),n){const[c,u]=s,{width:d,height:f,x:p,y:m}=Cd(o.width,o.height,c,u);return o.width=d,o.height=f,o.x=p,o.y=m,s}const h=Cd(o.width,o.height,s[0],s[1]);return o.width=h.width,o.height=h.height,o.x=0,o.y=0,[h.width,h.height]},async execute(){i(n?s[0]:o.width,n?s[1]:o.height),o.zIndex=0,r.addChild(o)},undo(){r.removeChildAt(0)}}}function MA(r,t,e,i,s,n){let o;return{start(){r.removeChildren();const a=o_(1),l=Gt.create({width:i,height:s});return a.beginFill(new dt(e)),a.drawRect(0,0,i,s),a.endFill(),t.render(a,{renderTexture:l}),o=new Xt(l),[o.width,o.height]},async execute(){n(o.width,o.height),o.zIndex=1,r.addChild(o)},undo(){r.removeChildren()}}}const{SvelteComponent:BA,add_flush_callback:kA,append:zn,attr:As,bind:DA,binding_callbacks:b_,bubble:al,check_outros:xh,component_subscribe:gn,create_component:Vh,destroy_component:Wh,detach:Xr,element:Ss,empty:x_,ensure_array_like:Id,flush:ce,group_outros:wh,init:FA,insert:Vr,is_function:OA,listen:NA,mount_component:jh,outro_and_destroy_block:LA,safe_not_equal:UA,set_store_value:ds,set_style:vi,space:ll,toggle_class:Rd,transition_in:Ge,transition_out:Ai,update_keyed_each:GA}=window.__gradio__svelte__internal,{getContext:Pd,onMount:fC,tick:HA,createEventDispatcher:zA}=window.__gradio__svelte__internal;function Md(r,t,e){const i=r.slice();return i[38]=t[e].icon,i[39]=t[e].label,i[40]=t[e].id,i[41]=t[e].cb,i}function Bd(r){let t,e=[],i=new Map,s,n,o,a,l,h,c,u=`${Math.max(r[12].child_height+(r[12].child_top-r[12].parent_top),100)}px`,d,f=Id(r[10]);const p=v=>v[40];for(let v=0;vDA(l,"dragging",m)),l.$on("load",r[17]),l.$on("error",r[25]);let _=r[1]==="webcam"&&Dd(r);return{c(){t=Ss("div");for(let v=0;vh=!1)),l.$set(b),v[1]==="webcam"?_?(_.p(v,y),y[0]&2&&Ge(_,1)):(_=Dd(v),_.c(),Ge(_,1),_.m(a,null)):_&&(wh(),Ai(_,1,1,()=>{_=null}),xh()),(!d||y[0]&2054)&&Rd(a,"click-disabled",!!v[2]||v[1]==="webcam"||v[11]!=="bg"),y[0]&4096&&u!==(u=`${Math.max(v[12].child_height+(v[12].child_top-v[12].parent_top),100)}px`)&&vi(a,"height",u)},i(v){if(!d){for(let y=0;y{n=null}),xh())},i(o){e||(Ge(n),e=!0)},o(o){Ai(n),e=!1},d(o){o&&Xr(t),n&&n.d(o),i=!1,s()}}}function XA(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,{canvas_size:g}=t,{fixed_canvas:_=!1}=t;const{active_tool:v}=Pd(Ao);gn(r,v,R=>e(11,o=R));const{pixi:y,dimensions:b,register_context:x,reset:S,editor_box:w}=Pd(rs);gn(r,y,R=>e(30,n=R)),gn(r,b,R=>e(29,s=R)),gn(r,w,R=>e(12,a=R));let{active_mode:T=null}=t,I;zA();const B={upload:{icon:Ah,label:"Upload",order:0,id:"bg_upload",cb(){P.open_file_upload(),ds(v,o="bg",o)}},webcam:{icon:z_,label:"Webcam",order:1,id:"bg_webcam",cb(){e(1,T="webcam"),ds(v,o="bg",o)}},clipboard:{icon:H_,label:"Paste",order:2,id:"bg_clipboard",cb(){M(),ds(v,o=null,o)}}};let P;async function M(){const R=await navigator.clipboard.read();for(let et=0;etst.startsWith("image/"));if(tt){const st=await R[et].getType(tt);e(22,I=st||null)}}}function E(R){const et=R.detail;e(22,I=et),e(1,T=null)}let C=!0;async function G(){if(n&&I){const R=PA(n.background_container,n.renderer,I,n.resize,g,_);ds(b,s=await R.start(),s),C&&S(!1,s),R.execute(),C=!0,await HA(),e(2,J=!0)}}async function X(R){if(!R||!R.url)return;C=!1;const tt=await(await fetch(R.url)).blob();e(22,I=tt)}function N(R){R.key==="Escape"&&e(1,T=null)}let{bg:J=!1}=t;x("bg",{init_fn:()=>{if(!n)return;const R=MA(n.background_container,n.renderer,"black",...s,n.resize);ds(b,s=R.start(),s),R.execute()},reset_fn:()=>{}});function H(R){b_[R?"unshift":"push"](()=>{P=R,e(9,P)})}function A(R){m=R,e(0,m)}function L(R){al.call(this,r,R)}function V(R){al.call(this,r,R)}function D(R){al.call(this,r,R)}return r.$$set=R=>{"background_file"in R&&e(19,l=R.background_file),"root"in R&&e(3,h=R.root),"sources"in R&&e(4,c=R.sources),"mirror_webcam"in R&&e(5,u=R.mirror_webcam),"i18n"in R&&e(6,d=R.i18n),"upload"in R&&e(7,f=R.upload),"stream_handler"in R&&e(8,p=R.stream_handler),"dragging"in R&&e(0,m=R.dragging),"canvas_size"in R&&e(20,g=R.canvas_size),"fixed_canvas"in R&&e(21,_=R.fixed_canvas),"active_mode"in R&&e(1,T=R.active_mode),"bg"in R&&e(2,J=R.bg)},r.$$.update=()=>{r.$$.dirty[0]&16&&e(10,i=c.map(R=>B[R]).sort((R,et)=>R.order-et.order)),r.$$.dirty[0]&4194304&&I&&G(),r.$$.dirty[0]&524288&&X(l)},[m,T,J,h,c,u,d,f,p,P,i,o,a,v,y,b,w,E,N,l,g,_,I,H,A,L,V,D]}class VA extends BA{constructor(t){super(),FA(this,t,XA,$A,UA,{background_file:19,root:3,sources:4,mirror_webcam:5,i18n:6,upload:7,stream_handler:8,dragging:0,canvas_size:20,fixed_canvas:21,active_mode:1,bg:2},null,[-1,-1])}get background_file(){return this.$$.ctx[19]}set background_file(t){this.$$set({background_file:t}),ce()}get root(){return this.$$.ctx[3]}set root(t){this.$$set({root:t}),ce()}get sources(){return this.$$.ctx[4]}set sources(t){this.$$set({sources:t}),ce()}get mirror_webcam(){return this.$$.ctx[5]}set mirror_webcam(t){this.$$set({mirror_webcam:t}),ce()}get i18n(){return this.$$.ctx[6]}set i18n(t){this.$$set({i18n:t}),ce()}get upload(){return this.$$.ctx[7]}set upload(t){this.$$set({upload:t}),ce()}get stream_handler(){return this.$$.ctx[8]}set stream_handler(t){this.$$set({stream_handler:t}),ce()}get dragging(){return this.$$.ctx[0]}set dragging(t){this.$$set({dragging:t}),ce()}get canvas_size(){return this.$$.ctx[20]}set canvas_size(t){this.$$set({canvas_size:t}),ce()}get fixed_canvas(){return this.$$.ctx[21]}set fixed_canvas(t){this.$$set({fixed_canvas:t}),ce()}get active_mode(){return this.$$.ctx[1]}set active_mode(t){this.$$set({active_mode:t}),ce()}get bg(){return this.$$.ctx[2]}set bg(t){this.$$set({bg:t}),ce()}}const{SvelteComponent:WA,check_outros:jA,create_component:Cs,destroy_component:Is,detach:hl,flush:yn,group_outros:YA,init:qA,insert:cl,mount_component:Rs,safe_not_equal:ZA,space:ul,transition_in:bi,transition_out:ir}=window.__gradio__svelte__internal,{createEventDispatcher:KA}=window.__gradio__svelte__internal;function Fd(r){let t,e;return t=new xn({props:{disabled:!r[2],Icon:O_,label:"Save changes",background:"var(--color-green-500)",color:"#fff"}}),t.$on("click",r[5]),{c(){Cs(t.$$.fragment)},m(i,s){Rs(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.disabled=!i[2]),t.$set(n)},i(i){e||(bi(t.$$.fragment,i),e=!0)},o(i){ir(t.$$.fragment,i),e=!1},d(i){Is(t,i)}}}function JA(r){let t,e,i,s,n,o,a,l=r[3]&&Fd(r);return e=new xn({props:{disabled:!r[0],Icon:L_,label:"Undo"}}),e.$on("click",r[6]),s=new xn({props:{disabled:!r[1],Icon:zm,label:"Redo"}}),s.$on("click",r[7]),o=new xn({props:{Icon:N_,label:"Clear canvas"}}),o.$on("click",r[8]),{c(){l&&l.c(),t=ul(),Cs(e.$$.fragment),i=ul(),Cs(s.$$.fragment),n=ul(),Cs(o.$$.fragment)},m(h,c){l&&l.m(h,c),cl(h,t,c),Rs(e,h,c),cl(h,i,c),Rs(s,h,c),cl(h,n,c),Rs(o,h,c),a=!0},p(h,c){h[3]?l?(l.p(h,c),c&8&&bi(l,1)):(l=Fd(h),l.c(),bi(l,1),l.m(t.parentNode,t)):l&&(YA(),ir(l,1,1,()=>{l=null}),jA());const u={};c&1&&(u.disabled=!h[0]),e.$set(u);const d={};c&2&&(d.disabled=!h[1]),s.$set(d)},i(h){a||(bi(l),bi(e.$$.fragment,h),bi(s.$$.fragment,h),bi(o.$$.fragment,h),a=!0)},o(h){ir(l),ir(e.$$.fragment,h),ir(s.$$.fragment,h),ir(o.$$.fragment,h),a=!1},d(h){h&&(hl(t),hl(i),hl(n)),l&&l.d(h),Is(e,h),Is(s,h),Is(o,h)}}}function QA(r){let t,e;return t=new U_({props:{$$slots:{default:[JA]},$$scope:{ctx:r}}}),{c(){Cs(t.$$.fragment)},m(i,s){Rs(t,i,s),e=!0},p(i,[s]){const n={};s&527&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(bi(t.$$.fragment,i),e=!0)},o(i){ir(t.$$.fragment,i),e=!1},d(i){Is(t,i)}}}function t2(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=KA(),l=d=>{a("save"),d.stopPropagation()},h=d=>{a("undo"),d.stopPropagation()},c=d=>{a("redo"),d.stopPropagation()},u=d=>{a("remove_image"),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 e2 extends WA{constructor(t){super(),qA(this,t,t2,QA,ZA,{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}),yn()}get can_redo(){return this.$$.ctx[1]}set can_redo(t){this.$$set({can_redo:t}),yn()}get can_save(){return this.$$.ctx[2]}set can_save(t){this.$$set({can_save:t}),yn()}get changeable(){return this.$$.ctx[3]}set changeable(t){this.$$set({changeable:t}),yn()}}const{SvelteComponent:i2,append:ui,attr:Wi,binding_callbacks:Od,component_subscribe:ue,create_component:r2,create_slot:s2,destroy_component:n2,detach:o2,element:Cr,flush:de,get_all_dirty_from_scope:a2,get_slot_changes:l2,globals:h2,init:c2,insert:u2,listen:d2,mount_component:f2,safe_not_equal:p2,set_store_value:Nd,set_style:di,space:dl,toggle_class:vn,transition_in:Ld,transition_out:Ud,update_slot_base:_2}=window.__gradio__svelte__internal,{window:m2}=h2,{onMount:g2,setContext:y2,createEventDispatcher:v2,tick:Gd}=window.__gradio__svelte__internal;function b2(r){let t,e,i,s,n,o,a,l,h,c,u=`${r[8].child_width+1}px`,d=`${r[8].child_height+1}px`,f=`${r[8].child_top-r[8].parent_top-.5}px`,p=`${r[8].child_left-r[8].parent_left-.5}px`,m,g,_;e=new e2({props:{can_undo:r[10],can_redo:r[11],can_save:r[9]!==r[7],changeable:r[2]}}),e.$on("undo",r[17].undo),e.$on("redo",r[17].redo),e.$on("remove_image",r[3]),e.$on("save",r[26]);const v=r[41].default,y=s2(v,r,r[40],null);return{c(){t=Cr("div"),r2(e.$$.fragment),i=dl(),s=Cr("div"),n=Cr("div"),o=Cr("div"),a=dl(),l=Cr("div"),y&&y.c(),h=dl(),c=Cr("div"),Wi(o,"class","stage-wrap svelte-t4g8ka"),vn(o,"bg",!r[1]),Wi(n,"class","wrap svelte-t4g8ka"),Wi(l,"class","tools-wrap svelte-t4g8ka"),Wi(c,"class","canvas svelte-t4g8ka"),vn(c,"no-border",!r[1]&&r[6]==="bg"&&!r[0]),di(c,"width",u),di(c,"height",d),di(c,"top",f),di(c,"left",p),Wi(s,"class","container svelte-t4g8ka"),Wi(t,"data-testid","image"),Wi(t,"class","image-container svelte-t4g8ka")},m(b,x){u2(b,t,x),f2(e,t,null),ui(t,i),ui(t,s),ui(s,n),ui(n,o),r[43](o),r[44](n),ui(s,a),ui(s,l),y&&y.m(l,null),ui(s,h),ui(s,c),m=!0,g||(_=d2(m2,"scroll",r[42]),g=!0)},p(b,x){const S={};x[0]&1024&&(S.can_undo=b[10]),x[0]&2048&&(S.can_redo=b[11]),x[0]&640&&(S.can_save=b[9]!==b[7]),x[0]&4&&(S.changeable=b[2]),e.$set(S),(!m||x[0]&2)&&vn(o,"bg",!b[1]),y&&y.p&&(!m||x[1]&512)&&_2(y,v,b,b[40],m?l2(v,b[40],x,null):a2(b[40]),null),(!m||x[0]&67)&&vn(c,"no-border",!b[1]&&b[6]==="bg"&&!b[0]),x[0]&256&&u!==(u=`${b[8].child_width+1}px`)&&di(c,"width",u),x[0]&256&&d!==(d=`${b[8].child_height+1}px`)&&di(c,"height",d),x[0]&256&&f!==(f=`${b[8].child_top-b[8].parent_top-.5}px`)&&di(c,"top",f),x[0]&256&&p!==(p=`${b[8].child_left-b[8].parent_left-.5}px`)&&di(c,"left",p)},i(b){m||(Ld(e.$$.fragment,b),Ld(y,b),m=!0)},o(b){Ud(e.$$.fragment,b),Ud(y,b),m=!1},d(b){b&&o2(t),n2(e),r[43](null),r[44](null),y&&y.d(b),g=!1,_()}}}const rs=Symbol("editor");function w_(r){return r.previous?w_(r.previous):r}function x2(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:S=!1}=t,{sources:w}=t;const T=v2();let{crop_constraint:I=!1}=t,{canvas_size:B}=t,{parent_height:P}=t,{full_history:M=null}=t,C=Nt(B||[800,600]);ue(r,C,z=>e(49,h=z));let{height:G=0}=t,X=Nt({parent_width:0,parent_height:P,parent_top:0,parent_left:0,parent_right:0,parent_bottom:0,child_width:0,child_height:P,child_top:0,child_left:0,child_right:0,child_bottom:0});ue(r,X,z=>e(8,f=z));let{canvas_height:N=void 0}=t;const J=Nt([0,0,1,1]);ue(r,J,z=>e(39,d=z));const H=hf({x:0,y:0},{stiffness:.1,damping:.5});ue(r,H,z=>e(38,u=z));const A=Nt(null);ue(r,A,z=>e(48,l=z));const L=og(),{can_redo:V,can_undo:D,current_history:R}=L;ue(r,V,z=>e(11,m=z)),ue(r,D,z=>e(10,p=z)),ue(r,R,z=>e(7,n=z));const et=typeof window<"u",tt=Nt("bg");ue(r,tt,z=>e(6,s=z));const st=Nt({});ue(r,st,z=>e(46,o=z));const ft=Nt({});ue(r,ft,z=>e(50,c=z));const vt=Nt([]);ue(r,vt,z=>e(47,a=z));const pt=Nt(et?new DOMRect:{}),ot=["bg","layers","crop","draw","erase"],ut=y2(rs,{pixi:A,current_layer:Nt(null),dimensions:C,editor_box:X,toolbar_box:pt,active_tool:tt,crop:J,position_spring:H,command_manager:L,current_history:R,register_context:(z,{reset_fn:Wt,init_fn:Kt})=>{vt.update(_t=>[..._t,z]),ft.update(_t=>({..._t,[z]:Kt})),st.update(_t=>({..._t,[z]:Wt}))},reset:(z,Wt)=>{e(1,S=!1);const Kt=a.sort((_t,St)=>ot.indexOf(_t)-ot.indexOf(St));for(const _t of Kt)_t in o&&typeof o[_t]=="function"&&o[_t]?.();for(const _t of Kt){if(_t in c&&typeof c[_t]=="function"){if(_t==="bg"&&!z)continue;c[_t]?.(Wt)}L.reset(),l?.resize?.(...Wt)}}});let lt,mt;function U(z,Wt){if(!z||!Wt)return;const{width:Kt,height:_t,top:St,left:We,right:zo,bottom:$o}=mt.getBoundingClientRect(),{width:Xo,height:k,top:Vo,left:P_,right:M_,bottom:B_}=Wt.getBoundingClientRect();X.set({child_width:Xo,child_height:k,child_left:P_,child_right:M_,child_top:Vo,child_bottom:B_,parent_width:Kt,parent_height:_t,parent_left:We,parent_right:zo,parent_top:St,parent_bottom:$o})}function Et(){requestAnimationFrame(()=>{Gd().then(z=>Nd(tt,s="crop",s))})}function zt(){if(!f)return;const z=0,Wt=0,Kt=f.child_width,_t=f.child_height,St=.5*f.child_width-z-Kt/2,We=.5*f.child_height-Wt-_t/2;H.set({x:St,y:We})}async function F(){return!l||!l.get_layers?{background:null,layers:[],composite:null}:l?.get_blobs(l.get_layers(),new it(Math.round(0),Math.round(0),Math.round(1*h[0]),Math.round(1*h[1])),h)}function ge(){ut.reset(!0,i||h),w.length?Vt("bg"):Vt("draw"),T("clear");let z=B||y||[800,600];ut.reset(!0,z)}g2(()=>{const Wt=sT({target:lt,dimensions:B||y||[800,600],antialias:v});function Kt(St,We){Wt.resize(St,We),C.set([St,We])}A.set({...Wt,resize:Kt});const _t=new ResizeObserver(St=>{for(const We of St)U(mt,lt)});_t.observe(mt),_t.observe(lt);for(const St of a)St in c&&typeof c[St]=="function"&&c[St]?.(h);return Kt(...h),Gd().then(()=>{M&&L.hydrate(M)}),()=>{l?.destroy(),_t.disconnect();for(const St of a)St in o&&o[St]?.()}});let ye=n;function Re(){e(9,ye=n),T("save")}function Vt(z){Nd(tt,s=z,s)}const ne=()=>U(mt,lt);function Gi(z){Od[z?"unshift":"push"](()=>{lt=z,e(4,lt)})}function oe(z){Od[z?"unshift":"push"](()=>{mt=z,e(5,mt)})}return r.$$set=z=>{"antialias"in z&&e(29,v=z.antialias),"crop_size"in z&&e(30,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,S=z.bg),"sources"in z&&e(31,w=z.sources),"crop_constraint"in z&&e(32,I=z.crop_constraint),"canvas_size"in z&&e(33,B=z.canvas_size),"parent_height"in z&&e(34,P=z.parent_height),"full_history"in z&&e(35,M=z.full_history),"height"in z&&e(27,G=z.height),"canvas_height"in z&&e(28,N=z.canvas_height),"$$scope"in z&&e(40,_=z.$$scope)},r.$$.update=()=>{r.$$.dirty[1]&4&&(i=B),r.$$.dirty[0]&256&&e(27,G=f.child_height),r.$$.dirty[0]&256&&e(28,N=f.child_height+1),r.$$.dirty[0]&128&&(n.previous,T("change")),r.$$.dirty[0]&128&&T("history",w_(n)),r.$$.dirty[0]&192&&e(0,x=!!n.previous||s!=="bg"),r.$$.dirty[0]&3|r.$$.dirty[1]&2&&I&&S&&!x&&Et(),r.$$.dirty[1]&256&&d&&zt(),r.$$.dirty[0]&48|r.$$.dirty[1]&128&&u&&U(mt,lt)},[x,S,b,ge,lt,mt,s,n,f,ye,p,m,C,X,J,H,A,L,V,D,R,tt,st,ft,vt,U,Re,G,N,v,y,w,I,B,P,M,F,Vt,u,d,_,g,ne,Gi,oe]}class w2 extends i2{constructor(t){super(),c2(this,t,x2,b2,p2,{antialias:29,crop_size:30,changeable:2,history:0,bg:1,sources:31,crop_constraint:32,canvas_size:33,parent_height:34,full_history:35,height:27,canvas_height:28,get_blobs:36,handle_remove:3,set_tool:37},null,[-1,-1])}get antialias(){return this.$$.ctx[29]}set antialias(t){this.$$set({antialias:t}),de()}get crop_size(){return this.$$.ctx[30]}set crop_size(t){this.$$set({crop_size:t}),de()}get changeable(){return this.$$.ctx[2]}set changeable(t){this.$$set({changeable:t}),de()}get history(){return this.$$.ctx[0]}set history(t){this.$$set({history:t}),de()}get bg(){return this.$$.ctx[1]}set bg(t){this.$$set({bg:t}),de()}get sources(){return this.$$.ctx[31]}set sources(t){this.$$set({sources:t}),de()}get crop_constraint(){return this.$$.ctx[32]}set crop_constraint(t){this.$$set({crop_constraint:t}),de()}get canvas_size(){return this.$$.ctx[33]}set canvas_size(t){this.$$set({canvas_size:t}),de()}get parent_height(){return this.$$.ctx[34]}set parent_height(t){this.$$set({parent_height:t}),de()}get full_history(){return this.$$.ctx[35]}set full_history(t){this.$$set({full_history:t}),de()}get height(){return this.$$.ctx[27]}set height(t){this.$$set({height:t}),de()}get canvas_height(){return this.$$.ctx[28]}set canvas_height(t){this.$$set({canvas_height:t}),de()}get get_blobs(){return this.$$.ctx[36]}get handle_remove(){return this.$$.ctx[3]}get set_tool(){return this.$$.ctx[37]}}const{SvelteComponent:T2,action_destroyer:E2,append:ie,attr:re,check_outros:A2,component_subscribe:Ir,create_component:S2,destroy_block:C2,destroy_component:I2,detach:Lo,element:ni,empty:R2,ensure_array_like:Hd,flush:zd,group_outros:P2,init:M2,insert:Uo,is_function:B2,listen:Yh,mount_component:k2,run_all:D2,safe_not_equal:F2,set_data:T_,set_store_value:$d,space:Th,text:wo,toggle_class:To,transition_in:$n,transition_out:Eh,update_keyed_each:O2}=window.__gradio__svelte__internal,{getContext:N2,onMount:L2,tick:Xd}=window.__gradio__svelte__internal;function Vd(r,t,e){const i=r.slice();return i[26]=t[e],i[28]=e,i}function Wd(r){let t,e,i,s,n,o=r[2].findIndex(r[15])+1+"",a,l,h,c,u,d,f,p;s=new Cm({});let m=r[1]&&jd(r);return{c(){t=ni("div"),e=ni("button"),i=ni("span"),S2(s.$$.fragment),n=wo(" Layer "),a=wo(o),l=Th(),m&&m.c(),h=Th(),c=ni("span"),re(i,"class","icon svelte-wbw3z5"),re(e,"aria-label","Show Layers"),re(e,"class","svelte-wbw3z5"),re(c,"class","sep svelte-wbw3z5"),re(t,"class","layer-wrap svelte-wbw3z5"),To(t,"closed",!r[1])},m(g,_){Uo(g,t,_),ie(t,e),ie(e,i),k2(s,i,null),ie(e,n),ie(e,a),ie(t,l),m&&m.m(t,null),ie(t,h),ie(t,c),d=!0,f||(p=[Yh(e,"click",r[16]),E2(u=$h.call(null,t,r[18]))],f=!0)},p(g,_){(!d||_&12)&&o!==(o=g[2].findIndex(g[15])+1+"")&&T_(a,o),g[1]?m?m.p(g,_):(m=jd(g),m.c(),m.m(t,h)):m&&(m.d(1),m=null),u&&B2(u.update)&&_&2&&u.update.call(null,g[18]),(!d||_&2)&&To(t,"closed",!g[1])},i(g){d||($n(s.$$.fragment,g),d=!0)},o(g){Eh(s.$$.fragment,g),d=!1},d(g){g&&Lo(t),I2(s),m&&m.d(),f=!1,D2(p)}}}function jd(r){let t,e=[],i=new Map,s,n,o,a,l,h=Hd(r[2]);const c=u=>u[28];for(let u=0;u{i=null}),A2())},i(s){e||($n(i),e=!0)},o(s){Eh(i),e=!1},d(s){s&&Lo(t),i&&i.d(s)}}}function G2(r){return r!==null}function H2(r,t,e){let i,s,n,o,a,l,h=!1,{layer_files:c=[]}=t,{enable_layers:u=!0}=t;const{pixi:d,current_layer:f,dimensions:p,register_context:m,command_manager:g,current_history:_}=N2(rs);Ir(r,d,E=>e(19,i=E)),Ir(r,f,E=>e(3,l=E)),Ir(r,p,E=>e(13,o=E));const{can_undo:v}=g;Ir(r,v,E=>e(20,n=E));const y=iT(),b=y.active_layer;Ir(r,b,E=>e(14,a=E));const x=y.layers;Ir(r,x,E=>e(2,s=E)),m("layers",{init_fn:()=>{w()},reset_fn:()=>{y.reset()}});async function S(){s.some(C=>C.composite.texture?.width!=o[0]||C.composite.texture?.height!=o[1])&&(y.reset(),!c||c.length==0?w():T(c))}async function w(){if(!i)return;const E=y.add_layer(i.layer_container,i.renderer,...o);n||s.length>0?g.execute(E):E.execute()}async function T(E){if(await Xd(),!E||E.length==0){y.reset(),w();return}if(!i)return;const C=await Promise.all(E.map(X=>!X||!X.url?null:fetch(X.url))),G=await Promise.all(C.map(X=>X?X.blob():null));y.reset();for(const X of G.filter(G2)){const N=await y.add_layer_from_blob(i.layer_container,i.renderer,X,i.view);n&&s.length===0?g.execute(N):N.execute()}}L2(async()=>{await Xd(),i&&$d(d,i={...i,get_layers:y.get_layers},i)});const I=E=>E===l,B=()=>e(1,h=!h),P=E=>$d(f,l=y.change_active_layer(E),l),M=()=>e(1,h=!1);return r.$$set=E=>{"layer_files"in E&&e(12,c=E.layer_files),"enable_layers"in E&&e(0,u=E.enable_layers)},r.$$.update=()=>{r.$$.dirty&16384&&f.set(a),r.$$.dirty&8192&&S(),r.$$.dirty&4096&&T(c)},[u,h,s,l,d,f,p,v,y,b,x,w,c,o,a,I,B,P,M]}class z2 extends T2{constructor(t){super(),M2(this,t,H2,U2,F2,{layer_files:12,enable_layers:0})}get layer_files(){return this.$$.ctx[12]}set layer_files(t){this.$$set({layer_files:t}),zd()}get enable_layers(){return this.$$.ctx[0]}set enable_layers(t){this.$$set({enable_layers:t}),zd()}}const $2=/^(#\s*)(.+)$/m;function X2(r){const t=r.trim(),e=t.match($2);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:V2,add_flush_callback:rr,append:Eo,attr:Go,bind:sr,binding_callbacks:Si,bubble:qd,check_outros:fl,create_component:ki,destroy_component:Di,detach:Dt,element:ss,empty:Ho,flush:gt,group_outros:pl,init:W2,insert:Ft,mount_component:Fi,noop:j2,safe_not_equal:Y2,set_data:E_,set_style:Zd,space:oi,text:A_,transition_in:Bt,transition_out:qt}=window.__gradio__svelte__internal,{createEventDispatcher:q2}=window.__gradio__svelte__internal;function Kd(r){let t,e;return t=new RA({props:{crop_constraint:r[29]}}),{c(){ki(t.$$.fragment)},m(i,s){Fi(t,i,s),e=!0},p(i,s){const n={};s[0]&536870912&&(n.crop_constraint=i[29]),t.$set(n)},i(i){e||(Bt(t.$$.fragment,i),e=!0)},o(i){qt(t.$$.fragment,i),e=!1},d(i){Di(t,i)}}}function Jd(r){let t,e;return t=new __({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(){ki(t.$$.fragment)},m(i,s){Fi(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||(Bt(t.$$.fragment,i),e=!0)},o(i){qt(t.$$.fragment,i),e=!1},d(i){Di(t,i)}}}function Qd(r){let t,e;return t=new __({props:{default_size:r[2].default_size,mode:"erase"}}),{c(){ki(t.$$.fragment)},m(i,s){Fi(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||(Bt(t.$$.fragment,i),e=!0)},o(i){qt(t.$$.fragment,i),e=!1},d(i){Di(t,i)}}}function Z2(r){let t,e,i,s,n,o,a,l=r[11].includes("crop"),h,c,u,d;t=new z2({props:{layer_files:r[10]?.layers||null,enable_layers:r[12]}});function f(b){r[37](b)}function p(b){r[38](b)}function m(b){r[39](b)}let g={i18n:r[5],root:r[6],sources:r[3],upload:r[16],stream_handler:r[17],canvas_size:r[14],background_file:r[10]?.background||r[10]?.composite||null,fixed_canvas:r[15]};r[0]!==void 0&&(g.dragging=r[0]),r[22]!==void 0&&(g.bg=r[22]),r[25]!==void 0&&(g.active_mode=r[25]),i=new VA({props:g}),Si.push(()=>sr(i,"dragging",f)),Si.push(()=>sr(i,"bg",p)),Si.push(()=>sr(i,"active_mode",m));let _=l&&Kd(r),v=r[1]&&Jd(r),y=r[1]&&r[2]&&Qd(r);return{c(){ki(t.$$.fragment),e=oi(),ki(i.$$.fragment),a=oi(),_&&_.c(),h=oi(),v&&v.c(),c=oi(),y&&y.c(),u=Ho()},m(b,x){Fi(t,b,x),Ft(b,e,x),Fi(i,b,x),Ft(b,a,x),_&&_.m(b,x),Ft(b,h,x),v&&v.m(b,x),Ft(b,c,x),y&&y.m(b,x),Ft(b,u,x),d=!0},p(b,x){const S={};x[0]&1024&&(S.layer_files=b[10]?.layers||null),x[0]&4096&&(S.enable_layers=b[12]),t.$set(S);const w={};x[0]&32&&(w.i18n=b[5]),x[0]&64&&(w.root=b[6]),x[0]&8&&(w.sources=b[3]),x[0]&65536&&(w.upload=b[16]),x[0]&131072&&(w.stream_handler=b[17]),x[0]&16384&&(w.canvas_size=b[14]),x[0]&1024&&(w.background_file=b[10]?.background||b[10]?.composite||null),x[0]&32768&&(w.fixed_canvas=b[15]),!s&&x[0]&1&&(s=!0,w.dragging=b[0],rr(()=>s=!1)),!n&&x[0]&4194304&&(n=!0,w.bg=b[22],rr(()=>n=!1)),!o&&x[0]&33554432&&(o=!0,w.active_mode=b[25],rr(()=>o=!1)),i.$set(w),x[0]&2048&&(l=b[11].includes("crop")),l?_?(_.p(b,x),x[0]&2048&&Bt(_,1)):(_=Kd(b),_.c(),Bt(_,1),_.m(h.parentNode,h)):_&&(pl(),qt(_,1,1,()=>{_=null}),fl()),b[1]?v?(v.p(b,x),x[0]&2&&Bt(v,1)):(v=Jd(b),v.c(),Bt(v,1),v.m(c.parentNode,c)):v&&(pl(),qt(v,1,1,()=>{v=null}),fl()),b[1]&&b[2]?y?(y.p(b,x),x[0]&6&&Bt(y,1)):(y=Qd(b),y.c(),Bt(y,1),y.m(u.parentNode,u)):y&&(pl(),qt(y,1,1,()=>{y=null}),fl())},i(b){d||(Bt(t.$$.fragment,b),Bt(i.$$.fragment,b),Bt(_),Bt(v),Bt(y),d=!0)},o(b){qt(t.$$.fragment,b),qt(i.$$.fragment,b),qt(_),qt(v),qt(y),d=!1},d(b){b&&(Dt(e),Dt(a),Dt(h),Dt(c),Dt(u)),Di(t,b),Di(i,b),_&&_.d(b),v&&v.d(b),y&&y.d(b)}}}function tf(r){let t,e,i,s=r[3]&&r[3].length&&ef(r),n=r[3]&&r[3].length&&r[1]&&!r[18]&&nf(),o=r[1]&&!r[18]&&of();return{c(){t=ss("div"),s&&s.c(),e=oi(),n&&n.c(),i=oi(),o&&o.c(),Go(t,"class","empty wrap svelte-1jsrluz"),Zd(t,"height",`${r[26]}px`)},m(a,l){Ft(a,t,l),s&&s.m(t,null),Eo(t,e),n&&n.m(t,null),Eo(t,i),o&&o.m(t,null)},p(a,l){a[3]&&a[3].length?s?s.p(a,l):(s=ef(a),s.c(),s.m(t,e)):s&&(s.d(1),s=null),a[3]&&a[3].length&&a[1]&&!a[18]?n||(n=nf(),n.c(),n.m(t,i)):n&&(n.d(1),n=null),a[1]&&!a[18]?o||(o=of(),o.c(),o.m(t,null)):o&&(o.d(1),o=null),l[0]&67108864&&Zd(t,"height",`${a[26]}px`)},d(a){a&&Dt(t),s&&s.d(),n&&n.d(),o&&o.d()}}}function ef(r){let t;function e(n,o){return n[28]||n[27]?J2:K2}let i=e(r),s=i(r);return{c(){s.c(),t=Ho()},m(n,o){s.m(n,o),Ft(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&&Dt(t),s.d(n)}}}function K2(r){let t;return{c(){t=ss("div"),t.textContent="Upload an image"},m(e,i){Ft(e,t,i)},p:j2,d(e){e&&Dt(t)}}}function J2(r){let t,e,i=r[28]&&rf(r),s=r[27]&&sf(r);return{c(){i&&i.c(),t=oi(),s&&s.c(),e=Ho()},m(n,o){i&&i.m(n,o),Ft(n,t,o),s&&s.m(n,o),Ft(n,e,o)},p(n,o){n[28]?i?i.p(n,o):(i=rf(n),i.c(),i.m(t.parentNode,t)):i&&(i.d(1),i=null),n[27]?s?s.p(n,o):(s=sf(n),s.c(),s.m(e.parentNode,e)):s&&(s.d(1),s=null)},d(n){n&&(Dt(t),Dt(e)),i&&i.d(n),s&&s.d(n)}}}function rf(r){let t,e;return{c(){t=ss("h2"),e=A_(r[28]),Go(t,"class","svelte-1jsrluz")},m(i,s){Ft(i,t,s),Eo(t,e)},p(i,s){s[0]&268435456&&E_(e,i[28])},d(i){i&&Dt(t)}}}function sf(r){let t,e;return{c(){t=ss("p"),e=A_(r[27]),Go(t,"class","svelte-1jsrluz")},m(i,s){Ft(i,t,s),Eo(t,e)},p(i,s){s[0]&134217728&&E_(e,i[27])},d(i){i&&Dt(t)}}}function nf(r){let t;return{c(){t=ss("div"),t.textContent="or",Go(t,"class","or svelte-1jsrluz")},m(e,i){Ft(e,t,i)},d(e){e&&Dt(t)}}}function of(r){let t;return{c(){t=ss("div"),t.textContent="select the draw tool to start"},m(e,i){Ft(e,t,i)},d(e){e&&Dt(t)}}}function Q2(r){let t,e,i,s;t=new Vg({props:{i18n:r[5],$$slots:{default:[Z2]},$$scope:{ctx:r}}});let n=!r[22]&&!r[24]&&r[25]!=="webcam"&&r[13]!=="error"&&tf(r);return{c(){ki(t.$$.fragment),e=oi(),n&&n.c(),i=Ho()},m(o,a){Fi(t,o,a),Ft(o,e,a),n&&n.m(o,a),Ft(o,i,a),s=!0},p(o,a){const l={};a[0]&32&&(l.i18n=o[5]),a[0]&574872687|a[1]&1048576&&(l.$$scope={dirty:a,ctx:o}),t.$set(l),!o[22]&&!o[24]&&o[25]!=="webcam"&&o[13]!=="error"?n?n.p(o,a):(n=tf(o),n.c(),n.m(i.parentNode,i)):n&&(n.d(1),n=null)},i(o){s||(Bt(t.$$.fragment,o),s=!0)},o(o){qt(t.$$.fragment,o),s=!1},d(o){o&&(Dt(e),Dt(i)),Di(t,o),n&&n.d(o)}}}function tS(r){let t,e,i,s,n,o,a,l;t=new X_({props:{show_label:r[8],Icon:Ah,label:r[7]||r[5]("image.image")}});function h(p){r[41](p)}function c(p){r[42](p)}function u(p){r[43](p)}function d(p){r[44](p)}let f={canvas_size:r[14],crop_size:Array.isArray(r[4])?r[4]:void 0,parent_height:r[19],changeable:r[9],sources:r[3],crop_constraint:!!r[29],full_history:r[20],$$slots:{default:[Q2]},$$scope:{ctx:r}};return r[26]!==void 0&&(f.height=r[26]),r[23]!==void 0&&(f.canvas_height=r[23]),r[24]!==void 0&&(f.history=r[24]),r[22]!==void 0&&(f.bg=r[22]),i=new w2({props:f}),r[40](i),Si.push(()=>sr(i,"height",h)),Si.push(()=>sr(i,"canvas_height",c)),Si.push(()=>sr(i,"history",u)),Si.push(()=>sr(i,"bg",d)),i.$on("history",r[45]),i.$on("save",r[46]),i.$on("change",r[31]),i.$on("clear",r[47]),{c(){ki(t.$$.fragment),e=oi(),ki(i.$$.fragment)},m(p,m){Fi(t,p,m),Ft(p,e,m),Fi(i,p,m),l=!0},p(p,m){const g={};m[0]&256&&(g.show_label=p[8]),m[0]&160&&(g.label=p[7]||p[5]("image.image")),t.$set(g);const _={};m[0]&16384&&(_.canvas_size=p[14]),m[0]&16&&(_.crop_size=Array.isArray(p[4])?p[4]:void 0),m[0]&524288&&(_.parent_height=p[19]),m[0]&512&&(_.changeable=p[9]),m[0]&8&&(_.sources=p[3]),m[0]&536870912&&(_.crop_constraint=!!p[29]),m[0]&1048576&&(_.full_history=p[20]),m[0]&1061682287|m[1]&1048576&&(_.$$scope={dirty:m,ctx:p}),!s&&m[0]&67108864&&(s=!0,_.height=p[26],rr(()=>s=!1)),!n&&m[0]&8388608&&(n=!0,_.canvas_height=p[23],rr(()=>n=!1)),!o&&m[0]&16777216&&(o=!0,_.history=p[24],rr(()=>o=!1)),!a&&m[0]&4194304&&(a=!0,_.bg=p[22],rr(()=>a=!1)),i.$set(_)},i(p){l||(Bt(t.$$.fragment,p),Bt(i.$$.fragment,p),l=!0)},o(p){qt(t.$$.fragment,p),qt(i.$$.fragment,p),l=!1},d(p){p&&Dt(e),Di(t,p),r[40](null),Di(i,p)}}}function eS(r){return!!r}function iS(r){return!!r}function af(){return new Promise(r=>setTimeout(()=>r(),30))}function rS(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,{fixed_canvas:x=!1}=t,{realtime:S}=t,{upload:w}=t,{stream_handler:T}=t,{dragging:I}=t,{placeholder:B=void 0}=t,{dynamic_height:P=void 0}=t,{height:M}=t,{full_history:E=null}=t;const C=q2();let G;async function X(){let F;try{F=await G.get_blobs()}catch{return{background:null,layers:[],composite:null}}const ge=F.background?w(await jo([new File([F.background],"background.png")]),u):Promise.resolve(null),ye=F.layers.filter(eS).map(async(oe,z)=>w(await jo([new File([oe],`layer_${z}.png`)]),u)),Re=F.composite?w(await jo([new File([F.composite],"composite.png")]),u):Promise.resolve(null),[Vt,ne,...Gi]=await Promise.all([ge,Re,...ye]);return{background:Array.isArray(Vt)?Vt[0]:Vt,layers:Gi.flatMap(oe=>Array.isArray(oe)?oe:[oe]).filter(iS),composite:Array.isArray(ne)?ne[0]:ne}}function N(F){G&&F==null&&(G.handle_remove(),C("receive_null"))}let J=!1,H=!1,{image_id:A=null}=t,L=!1,V=!1;async function D(F){if(!S)return;if(L){V=!0;return}L=!0,await af();const ge=await G.get_blobs(),ye=[];let Re=Math.random().toString(36).substring(2);ge.background&&ye.push([Re,"background",new File([ge.background],"background.png"),null]),ge.composite&&ye.push([Re,"composite",new File([ge.composite],"composite.png"),null]),ge.layers.forEach((Vt,ne)=>{Vt&&ye.push([Re,"layer",new File([Vt],`layer_${ne}.png`),ne])}),await Promise.all(ye.map(async([Vt,ne,Gi,oe])=>v({binary:!0,data:{file:Gi,id:Vt,type:ne,index:oe}}))),e(33,A=Re),C("change"),await af(),L=!1,V&&(V=!1,L=!1,D())}let R=null,et=M-100,tt;function st(F){I=F,e(0,I)}function ft(F){J=F,e(22,J)}function vt(F){R=F,e(25,R)}function pt(F){Si[F?"unshift":"push"](()=>{G=F,e(21,G)})}function ot(F){et=F,e(26,et)}function ut(F){tt=F,e(23,tt)}function lt(F){H=F,e(24,H)}function mt(F){J=F,e(22,J)}function U(F){qd.call(this,r,F)}function Et(F){qd.call(this,r,F)}const zt=()=>C("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(34,v=F.accept_blobs),"status"in F&&e(13,y=F.status),"canvas_size"in F&&e(14,b=F.canvas_size),"fixed_canvas"in F&&e(15,x=F.fixed_canvas),"realtime"in F&&e(35,S=F.realtime),"upload"in F&&e(16,w=F.upload),"stream_handler"in F&&e(17,T=F.stream_handler),"dragging"in F&&e(0,I=F.dragging),"placeholder"in F&&e(18,B=F.placeholder),"dynamic_height"in F&&e(32,P=F.dynamic_height),"height"in F&&e(19,M=F.height),"full_history"in F&&e(20,E=F.full_history),"image_id"in F&&e(33,A=F.image_id)},r.$$.update=()=>{r.$$.dirty[0]&4194304&&J&&C("upload"),r.$$.dirty[0]&1024&&N(m),r.$$.dirty[0]&16&&e(29,i=h),r.$$.dirty[0]&2097160&&G&&G.set_tool&&(l&&l.length?G.set_tool("bg"):G.set_tool("draw")),r.$$.dirty[0]&8388608&&e(32,P=tt),r.$$.dirty[0]&262144&&e(28,[s,n]=B?X2(B):[!1,!1],s,(e(27,n),e(18,B)))},[I,o,a,l,h,c,u,d,f,p,m,g,_,y,b,x,w,T,B,M,E,G,J,tt,H,R,et,n,s,i,C,D,P,A,v,S,X,st,ft,vt,pt,ot,ut,lt,mt,U,Et,zt]}class sS extends V2{constructor(t){super(),W2(this,t,rS,tS,Y2,{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:34,status:13,canvas_size:14,fixed_canvas:15,realtime:35,upload:16,stream_handler:17,dragging:0,placeholder:18,dynamic_height:32,height:19,full_history:20,get_data:36,image_id:33},null,[-1,-1])}get brush(){return this.$$.ctx[1]}set brush(t){this.$$set({brush:t}),gt()}get eraser(){return this.$$.ctx[2]}set eraser(t){this.$$set({eraser:t}),gt()}get sources(){return this.$$.ctx[3]}set sources(t){this.$$set({sources:t}),gt()}get crop_size(){return this.$$.ctx[4]}set crop_size(t){this.$$set({crop_size:t}),gt()}get i18n(){return this.$$.ctx[5]}set i18n(t){this.$$set({i18n:t}),gt()}get root(){return this.$$.ctx[6]}set root(t){this.$$set({root:t}),gt()}get label(){return this.$$.ctx[7]}set label(t){this.$$set({label:t}),gt()}get show_label(){return this.$$.ctx[8]}set show_label(t){this.$$set({show_label:t}),gt()}get changeable(){return this.$$.ctx[9]}set changeable(t){this.$$set({changeable:t}),gt()}get value(){return this.$$.ctx[10]}set value(t){this.$$set({value:t}),gt()}get transforms(){return this.$$.ctx[11]}set transforms(t){this.$$set({transforms:t}),gt()}get layers(){return this.$$.ctx[12]}set layers(t){this.$$set({layers:t}),gt()}get accept_blobs(){return this.$$.ctx[34]}set accept_blobs(t){this.$$set({accept_blobs:t}),gt()}get status(){return this.$$.ctx[13]}set status(t){this.$$set({status:t}),gt()}get canvas_size(){return this.$$.ctx[14]}set canvas_size(t){this.$$set({canvas_size:t}),gt()}get fixed_canvas(){return this.$$.ctx[15]}set fixed_canvas(t){this.$$set({fixed_canvas:t}),gt()}get realtime(){return this.$$.ctx[35]}set realtime(t){this.$$set({realtime:t}),gt()}get upload(){return this.$$.ctx[16]}set upload(t){this.$$set({upload:t}),gt()}get stream_handler(){return this.$$.ctx[17]}set stream_handler(t){this.$$set({stream_handler:t}),gt()}get dragging(){return this.$$.ctx[0]}set dragging(t){this.$$set({dragging:t}),gt()}get placeholder(){return this.$$.ctx[18]}set placeholder(t){this.$$set({placeholder:t}),gt()}get dynamic_height(){return this.$$.ctx[32]}set dynamic_height(t){this.$$set({dynamic_height:t}),gt()}get height(){return this.$$.ctx[19]}set height(t){this.$$set({height:t}),gt()}get full_history(){return this.$$.ctx[20]}set full_history(t){this.$$set({full_history:t}),gt()}get get_data(){return this.$$.ctx[36]}get image_id(){return this.$$.ctx[33]}set image_id(t){this.$$set({image_id:t}),gt()}}const{SvelteComponent:nS,add_flush_callback:_l,assign:S_,bind:ml,binding_callbacks:Xn,bubble:oS,check_outros:aS,create_component:Jr,destroy_component:Qr,detach:qh,empty:lS,flush:ct,get_spread_object:C_,get_spread_update:I_,group_outros:hS,init:cS,insert:Zh,mount_component:ts,not_equal:uS,space:R_,transition_in:Oi,transition_out:Ni}=window.__gradio__svelte__internal,{tick:dS}=window.__gradio__svelte__internal;function fS(r){let t,e;return t=new lf({props:{visible:r[5],variant:r[35]?"solid":"dashed",border_mode:r[34]?"focus":"base",padding:!1,elem_id:r[3],elem_classes:r[4],height:r[10]||r[36],width:r[11],allow_overflow:!1,container:r[13],scale:r[14],min_width:r[15],$$slots:{default:[_S]},$$scope:{ctx:r}}}),{c(){Jr(t.$$.fragment)},m(i,s){ts(t,i,s),e=!0},p(i,s){const n={};s[0]&32&&(n.visible=i[5]),s[1]&16&&(n.variant=i[35]?"solid":"dashed"),s[1]&8&&(n.border_mode=i[34]?"focus":"base"),s[0]&8&&(n.elem_id=i[3]),s[0]&16&&(n.elem_classes=i[4]),s[0]&1024|s[1]&32&&(n.height=i[10]||i[36]),s[0]&2048&&(n.width=i[11]),s[0]&8192&&(n.container=i[13]),s[0]&16384&&(n.scale=i[14]),s[0]&32768&&(n.min_width=i[15]),s[0]&1610221255|s[1]&15|s[2]&64&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(Oi(t.$$.fragment,i),e=!0)},o(i){Ni(t.$$.fragment,i),e=!1},d(i){Qr(t,i)}}}function pS(r){let t,e;return t=new lf({props:{visible:r[5],variant:"solid",border_mode:r[34]?"focus":"base",padding:!1,elem_id:r[3],elem_classes:r[4],height:r[10],width:r[11],allow_overflow:!1,container:r[13],scale:r[14],min_width:r[15],$$slots:{default:[mS]},$$scope:{ctx:r}}}),{c(){Jr(t.$$.fragment)},m(i,s){ts(t,i,s),e=!0},p(i,s){const n={};s[0]&32&&(n.visible=i[5]),s[1]&8&&(n.border_mode=i[34]?"focus":"base"),s[0]&8&&(n.elem_id=i[3]),s[0]&16&&(n.elem_classes=i[4]),s[0]&1024&&(n.height=i[10]),s[0]&2048&&(n.width=i[11]),s[0]&8192&&(n.container=i[13]),s[0]&16384&&(n.scale=i[14]),s[0]&32768&&(n.min_width=i[15]),s[0]&1610682819|s[2]&64&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(Oi(t.$$.fragment,i),e=!0)},o(i){Ni(t.$$.fragment,i),e=!1},d(i){Qr(t,i)}}}function _S(r){let t,e,i,s,n,o,a;const l=[{autoscroll:r[30].autoscroll},{i18n:r[30].i18n},r[1]];let h={};for(let p=0;pml(i,"dragging",c)),Xn.push(()=>ml(i,"image_id",u)),r[50](i),Xn.push(()=>ml(i,"dynamic_height",d)),i.$on("history",r[52]),i.$on("change",r[53]),i.$on("save",r[54]),i.$on("edit",r[55]),i.$on("clear",r[56]),i.$on("drag",r[57]),i.$on("upload",r[58]),i.$on("share",r[59]),i.$on("error",r[60]),i.$on("receive_null",r[61]),i.$on("error",r[62]),{c(){Jr(t.$$.fragment),e=R_(),Jr(i.$$.fragment)},m(p,m){ts(t,p,m),Zh(p,e,m),ts(i,p,m),a=!0},p(p,m){const g=m[0]&1073741826?I_(l,[m[0]&1073741824&&{autoscroll:p[30].autoscroll},m[0]&1073741824&&{i18n:p[30].i18n},m[0]&2&&C_(p[1])]):{};t.$set(g);const _={};m[0]&134217728&&(_.canvas_size=p[27]),m[0]&4194304&&(_.crop_size=p[22]),m[0]&1&&(_.value=p[0]),m[0]&512&&(_.root=p[9]),m[0]&131072&&(_.sources=p[17]),m[0]&64&&(_.label=p[6]),m[0]&128&&(_.show_label=p[7]),m[0]&1024&&(_.height=p[10]),m[0]&268435456&&(_.fixed_canvas=p[28]),m[0]&1048576&&(_.brush=p[20]),m[0]&2097152&&(_.eraser=p[21]),m[0]&33554432&&(_.changeable=p[25].includes("apply")),m[0]&33554432&&(_.realtime=p[25].includes("change")||p[25].includes("input")),m[0]&1073741824&&(_.i18n=p[30].i18n),m[0]&8388608&&(_.transforms=p[23]),m[0]&67108864&&(_.accept_blobs=p[26].accept_blobs),m[0]&16777216&&(_.layers=p[24]),m[0]&2&&(_.status=p[1]?.status),m[0]&1073741824&&(_.upload=p[46]),m[0]&1073741824&&(_.stream_handler=p[47]),m[0]&524288&&(_.placeholder=p[19]),m[0]&4&&(_.full_history=p[2]),!s&&m[1]&8&&(s=!0,_.dragging=p[34],_l(()=>s=!1)),!n&&m[1]&4&&(n=!0,_.image_id=p[33],_l(()=>n=!1)),!o&&m[1]&1&&(o=!0,_.dynamic_height=p[31],_l(()=>o=!1)),i.$set(_)},i(p){a||(Oi(t.$$.fragment,p),Oi(i.$$.fragment,p),a=!0)},o(p){Ni(t.$$.fragment,p),Ni(i.$$.fragment,p),a=!1},d(p){p&&qh(e),Qr(t,p),r[50](null),Qr(i,p)}}}function mS(r){let t,e,i,s;const n=[{autoscroll:r[30].autoscroll},{i18n:r[30].i18n},r[1]];let o={};for(let a=0;a{o[c]=null}),aS(),e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),Oi(e,1),e.m(i.parentNode,i))},i(l){s||(Oi(e),s=!0)},o(l){Ni(e),s=!1},d(l){l&&qh(i),o[t].d(l)}}}function yS(r,t,e){let i,s,{elem_id:n=""}=t,{elem_classes:o=[]}=t,{visible:a=!0}=t,{value:l={background:null,layers:[],composite:null}}=t,{label:h}=t,{show_label:c}=t,{show_download_button:u}=t,{root:d}=t,{value_is_output:f=!1}=t,{height:p}=t,{width:m}=t,{_selectable:g=!1}=t,{container:_=!0}=t,{scale:v=null}=t,{min_width:y=void 0}=t,{loading_status:b}=t,{show_share_button:x=!1}=t,{sources:S=["upload","clipboard","webcam"]}=t,{interactive:w}=t,{placeholder:T}=t,{brush:I}=t,{eraser:B}=t,{crop_size:P=null}=t,{transforms:M=["crop"]}=t,{layers:E=!0}=t,{attached_events:C=[]}=t,{server:G}=t,{canvas_size:X}=t,{fixed_canvas:N=!1}=t,{show_fullscreen_button:J=!0}=t,{full_history:H=null}=t,{gradio:A}=t,L,V=null;async function D(){if(V){const Vo={id:V};return e(33,V=null),Vo}return await L.get_data()}let R;const et=typeof window<"u",tt=et?window.requestAnimationFrame:k=>k();function st(){return new Promise(k=>{tt(()=>tt(()=>k()))})}async function ft(){await st(),l&&(l.background||l.layers?.length||l.composite)&&A.dispatch("change")}function vt(){A.dispatch("apply")}function pt(){A.dispatch("change"),f||(A.dispatch("input"),dS().then(k=>e(39,f=!1)))}let ot,ut=Math.max(X[1]/(et?window.devicePixelRatio:1),250);const lt=()=>A.dispatch("clear_status",b),mt=({detail:k})=>A.dispatch("select",k),U=({detail:k})=>A.dispatch("share",k),Et=({detail:k})=>A.dispatch("error",k),zt=()=>A.dispatch("clear_status",b),F=(...k)=>A.client.upload(...k),ge=(...k)=>A.client.stream(...k);function ye(k){R=k,e(34,R)}function Re(k){V=k,e(33,V)}function Vt(k){Xn[k?"unshift":"push"](()=>{L=k,e(32,L)})}function ne(k){ot=k,e(31,ot)}const Gi=k=>e(2,H=k.detail),oe=()=>pt(),z=k=>vt(),Wt=()=>A.dispatch("edit"),Kt=()=>A.dispatch("clear"),_t=({detail:k})=>e(34,R=k),St=()=>A.dispatch("upload"),We=({detail:k})=>A.dispatch("share",k),zo=({detail:k})=>{e(1,b=b||{}),e(1,b.status="error",b),A.dispatch("error",k)},$o=()=>e(0,l={background:null,layers:[],composite:null});function Xo(k){oS.call(this,r,k)}return r.$$set=k=>{"elem_id"in k&&e(3,n=k.elem_id),"elem_classes"in k&&e(4,o=k.elem_classes),"visible"in k&&e(5,a=k.visible),"value"in k&&e(0,l=k.value),"label"in k&&e(6,h=k.label),"show_label"in k&&e(7,c=k.show_label),"show_download_button"in k&&e(8,u=k.show_download_button),"root"in k&&e(9,d=k.root),"value_is_output"in k&&e(39,f=k.value_is_output),"height"in k&&e(10,p=k.height),"width"in k&&e(11,m=k.width),"_selectable"in k&&e(12,g=k._selectable),"container"in k&&e(13,_=k.container),"scale"in k&&e(14,v=k.scale),"min_width"in k&&e(15,y=k.min_width),"loading_status"in k&&e(1,b=k.loading_status),"show_share_button"in k&&e(16,x=k.show_share_button),"sources"in k&&e(17,S=k.sources),"interactive"in k&&e(18,w=k.interactive),"placeholder"in k&&e(19,T=k.placeholder),"brush"in k&&e(20,I=k.brush),"eraser"in k&&e(21,B=k.eraser),"crop_size"in k&&e(22,P=k.crop_size),"transforms"in k&&e(23,M=k.transforms),"layers"in k&&e(24,E=k.layers),"attached_events"in k&&e(25,C=k.attached_events),"server"in k&&e(26,G=k.server),"canvas_size"in k&&e(27,X=k.canvas_size),"fixed_canvas"in k&&e(28,N=k.fixed_canvas),"show_fullscreen_button"in k&&e(29,J=k.show_fullscreen_button),"full_history"in k&&e(2,H=k.full_history),"gradio"in k&&e(30,A=k.gradio)},r.$$.update=()=>{r.$$.dirty[0]&1&&l&&ft(),r.$$.dirty[1]&1&&e(36,i=Math.max((ot??ut)+100,250)),r.$$.dirty[0]&1&&e(35,s=l?.background||l?.layers?.length||l?.composite)},[l,b,H,n,o,a,h,c,u,d,p,m,g,_,v,y,x,S,w,T,I,B,P,M,E,C,G,X,N,J,A,ot,L,V,R,s,i,vt,pt,f,D,lt,mt,U,Et,zt,F,ge,ye,Re,Vt,ne,Gi,oe,z,Wt,Kt,_t,St,We,zo,$o,Xo]}class pC extends nS{constructor(t){super(),cS(this,t,yS,gS,uS,{elem_id:3,elem_classes:4,visible:5,value:0,label:6,show_label:7,show_download_button:8,root:9,value_is_output:39,height:10,width:11,_selectable:12,container:13,scale:14,min_width:15,loading_status:1,show_share_button:16,sources:17,interactive:18,placeholder:19,brush:20,eraser:21,crop_size:22,transforms:23,layers:24,attached_events:25,server:26,canvas_size:27,fixed_canvas:28,show_fullscreen_button:29,full_history:2,gradio:30,get_value:40},null,[-1,-1,-1])}get elem_id(){return this.$$.ctx[3]}set elem_id(t){this.$$set({elem_id:t}),ct()}get elem_classes(){return this.$$.ctx[4]}set elem_classes(t){this.$$set({elem_classes:t}),ct()}get visible(){return this.$$.ctx[5]}set visible(t){this.$$set({visible:t}),ct()}get value(){return this.$$.ctx[0]}set value(t){this.$$set({value:t}),ct()}get label(){return this.$$.ctx[6]}set label(t){this.$$set({label:t}),ct()}get show_label(){return this.$$.ctx[7]}set show_label(t){this.$$set({show_label:t}),ct()}get show_download_button(){return this.$$.ctx[8]}set show_download_button(t){this.$$set({show_download_button:t}),ct()}get root(){return this.$$.ctx[9]}set root(t){this.$$set({root:t}),ct()}get value_is_output(){return this.$$.ctx[39]}set value_is_output(t){this.$$set({value_is_output:t}),ct()}get height(){return this.$$.ctx[10]}set height(t){this.$$set({height:t}),ct()}get width(){return this.$$.ctx[11]}set width(t){this.$$set({width:t}),ct()}get _selectable(){return this.$$.ctx[12]}set _selectable(t){this.$$set({_selectable:t}),ct()}get container(){return this.$$.ctx[13]}set container(t){this.$$set({container:t}),ct()}get scale(){return this.$$.ctx[14]}set scale(t){this.$$set({scale:t}),ct()}get min_width(){return this.$$.ctx[15]}set min_width(t){this.$$set({min_width:t}),ct()}get loading_status(){return this.$$.ctx[1]}set loading_status(t){this.$$set({loading_status:t}),ct()}get show_share_button(){return this.$$.ctx[16]}set show_share_button(t){this.$$set({show_share_button:t}),ct()}get sources(){return this.$$.ctx[17]}set sources(t){this.$$set({sources:t}),ct()}get interactive(){return this.$$.ctx[18]}set interactive(t){this.$$set({interactive:t}),ct()}get placeholder(){return this.$$.ctx[19]}set placeholder(t){this.$$set({placeholder:t}),ct()}get brush(){return this.$$.ctx[20]}set brush(t){this.$$set({brush:t}),ct()}get eraser(){return this.$$.ctx[21]}set eraser(t){this.$$set({eraser:t}),ct()}get crop_size(){return this.$$.ctx[22]}set crop_size(t){this.$$set({crop_size:t}),ct()}get transforms(){return this.$$.ctx[23]}set transforms(t){this.$$set({transforms:t}),ct()}get layers(){return this.$$.ctx[24]}set layers(t){this.$$set({layers:t}),ct()}get attached_events(){return this.$$.ctx[25]}set attached_events(t){this.$$set({attached_events:t}),ct()}get server(){return this.$$.ctx[26]}set server(t){this.$$set({server:t}),ct()}get canvas_size(){return this.$$.ctx[27]}set canvas_size(t){this.$$set({canvas_size:t}),ct()}get fixed_canvas(){return this.$$.ctx[28]}set fixed_canvas(t){this.$$set({fixed_canvas:t}),ct()}get show_fullscreen_button(){return this.$$.ctx[29]}set show_fullscreen_button(t){this.$$set({show_fullscreen_button:t}),ct()}get full_history(){return this.$$.ctx[2]}set full_history(t){this.$$set({full_history:t}),ct()}get gradio(){return this.$$.ctx[30]}set gradio(t){this.$$set({gradio:t}),ct()}get get_value(){return this.$$.ctx[40]}}export{pC as default}; //# sourceMappingURL=Index-DltgmnBG.js.map