mirror of
https://github.com/Ladebeze66/projetcbaollm.git
synced 2025-12-18 21:37:51 +01:00
1176 lines
566 KiB
JavaScript
1176 lines
566 KiB
JavaScript
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;a<n.length;a+=1){let l=oc(r,n,a),h=o(l);e.set(h,t[a]=ac(h,l))}return{c(){for(let a=0;a<t.length;a+=1)t[a].c();i=gf()},m(a,l){for(let h=0;h<t.length;h+=1)t[h]&&t[h].m(a,l);Wn(a,i,l),s=!0},p(a,l){l&394&&(n=sc(a[1]),kg(),t=Lg(t,l,o,1,a,n,e,i.parentNode,Fg,ac,i,oc),Cg())},i(a){if(!s){for(let l=0;l<n.length;l+=1)jn(t[l]);s=!0}},o(a){for(let l=0;l<t.length;l+=1)Yn(t[l]);s=!1},d(a){a&&Vn(i);for(let l=0;l<t.length;l+=1)t[l].d(a)}}}function $g(r){let t,e,i,s,n;const o=r[11].default,a=Ig(o,r,r[15],null);return i=new ng({props:{show_border:!1,$$slots:{default:[zg]},$$scope:{ctx:r}}}),{c(){a&&a.c(),t=Ng(),e=Rg("div"),_f(i.$$.fragment),Ag(e,"class","toolbar-wrap svelte-k9d7m2"),Eg(()=>r[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);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(h){var c=e?e+h:h,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(h,c,u,d,f,p){var m=e?e+h:h;if(!this._events[m])return!1;var g=this._events[m],_=arguments.length,v,y;if(g.fn){switch(g.once&&this.removeListener(h,g.fn,void 0,!0),_){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,u),!0;case 4:return g.fn.call(g.context,c,u,d),!0;case 5:return g.fn.call(g.context,c,u,d,f),!0;case 6:return g.fn.call(g.context,c,u,d,f,p),!0}for(y=1,v=new Array(_-1);y<_;y++)v[y-1]=arguments[y];g.fn.apply(g.context,v)}else{var b=g.length,x;for(y=0;y<b;y++)switch(g[y].once&&this.removeListener(h,g[y].fn,void 0,!0),_){case 1:g[y].fn.call(g[y].context);break;case 2:g[y].fn.call(g[y].context,c);break;case 3:g[y].fn.call(g[y].context,c,u);break;case 4:g[y].fn.call(g[y].context,c,u,d);break;default:if(!v)for(x=1,v=new Array(_-1);x<_;x++)v[x-1]=arguments[x];g[y].fn.apply(g[y].context,v)}}return!0},a.prototype.on=function(h,c,u){return n(this,h,c,u,!1)},a.prototype.once=function(h,c,u){return n(this,h,c,u,!0)},a.prototype.removeListener=function(h,c,u,d){var f=e?e+h:h;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var m=0,g=[],_=p.length;m<_;m++)(p[m].fn!==c||d&&!p[m].once||u&&p[m].context!==u)&&g.push(p[m]);g.length?this._events[f]=g.length===1?g[0]:g:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=e?e+h:h,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(bf);var qg=bf.exports;const Fs=uf(qg);var Ch={exports:{}};Ch.exports=So;Ch.exports.default=So;function So(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=xf(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,l,h,c,u,d,f;if(i&&(n=t0(r,t,n,e)),r.length>80*e){a=h=r[0],l=c=r[1];for(var p=e;p<s;p+=e)u=r[p],d=r[p+1],u<a&&(a=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);f=Math.max(h-a,c-l),f=f!==0?32767/f:0}return 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<e;n+=i)o=bc(n,r[n],r[n+1],o);else for(n=e-i;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=s<n?s<o?s:o:n<o?n:o,u=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,f=a>l?a>h?a:h:l>h?l:h,p=i.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&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=a<l?a<h?a:h:l<h?l:h,p=c<u?c<d?c:d:u<d?u:d,m=a>l?a>h?a:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,_=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<o;n++)a=t[n]*i,l=n<o-1?t[n+1]*i:r.length,h=xf(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(a0(h));for(s.sort(e0),n=0;n<s.length;n++)e=i0(s[n],e);return e}function e0(r,t){return r.x-t.x}function i0(r,t){var e=r0(r,t);if(!e)return t;var i=Tf(e,r);return hr(i,i.next),hr(e,e.next)}function r0(r,t){var e=t,i=r.x,s=r.y,n=-1/0,o;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var a=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===i))return o}e=e.next}while(e!==t);if(!o)return null;var l=o,h=o.x,c=o.y,u=1/0,d;e=o;do i>=e.x&&e.x>=h&&i!==e.x&&Or(s<c?i:n,s,h,c,s<c?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),Ms(e,r)&&(d<u||d===u&&(e.x>o.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;t<h&&(a++,i=i.nextZ,!!i);t++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}n.nextZ=null,h*=2}while(o>1);return r}function 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<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function Or(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function 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;a<l;a++){var h=t[a]*e,c=a<l-1?t[a+1]*e:r.length;o-=Math.abs(Tl(r,h,c,e))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,f=i[a+1]*e,p=i[a+2]*e;u+=Math.abs((r[d]-r[p])*(r[f+1]-r[d+1])-(r[d]-r[f])*(r[p+1]-r[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function Tl(r,t,e,i){for(var s=0,n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}So.flatten=function(r){for(var t=r[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,s=0;s<r.length;s++){for(var n=0;n<r[s].length;n++)for(var o=0;o<t;o++)e.vertices.push(r[s][n][o]);s>0&&(i+=r[s-1].length,e.holes.push(i))}return e};var 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<D;)R=A.charCodeAt(V++),R>=55296&&R<=56319&&V<D?(et=A.charCodeAt(V++),(et&64512)==56320?L.push(((R&1023)<<10)+(et&1023)+65536):(L.push(R),V--)):L.push(R);return L}function M(A){return I(A,function(L){var V="";return L>65535&&(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<st;++ft)A.charCodeAt(ft)>=128&&T("not-basic"),L.push(A.charCodeAt(ft));for(vt=st>0?st+1:0;vt<V;){for(pt=R,ot=1,ut=l;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,!(lt<mt);ut+=l)U=l-mt,ot>x(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<lt;++tt)ot=A[tt],ot<128&&ut.push(S(ot));for(D=R=ut.length,R&&ut.push(m);D<lt;){for(st=a,tt=0;tt<lt;++tt)ot=A[tt],ot>=L&&ot<st&&(st=ot);for(mt=D+1,st-L>x((a-V)/mt)&&T("overflow"),V+=(st-L)*mt,L=st,tt=0;tt<lt;++tt)if(ot=A[tt],ot<L&&++V>a&&T("overflow"),ot==L){for(ft=V,vt=l;pt=vt<=et?h:vt>=et+c?c:vt-et,!(ft<pt);vt+=l)Et=ft-pt,U=l-pt,ut.push(S(C(pt+Et%U,0))),ft=x(Et/U);ut.push(S(C(ft,0))),et=G(V,mt,D==R),V=0,++D}++V,++L}return ut.join("")}function J(A){return B(A,function(L){return g.test(L)?X(L.slice(4).toLowerCase()):L})}function H(A){return B(A,function(L){return _.test(L)?"xn--"+N(L):L})}if(o={version:"1.4.1",ucs2:{decode:P,encode:M},decode:X,encode:N,toASCII:H,toUnicode:J},i&&s)if(r.exports==i)s.exports=o;else for(w in o)o.hasOwnProperty(w)&&(i[w]=o[w]);else e.punycode=o})(bn)})(qn,qn.exports);var f0=qn.exports,p0=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),i=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var s=42;t[e]=s;for(e in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var n=Object.getOwnPropertySymbols(t);if(n.length!==1||n[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(t,e);if(o.value!==s||o.enumerable!==!0)return!1}return!0},xc=typeof Symbol<"u"&&Symbol,_0=p0,m0=function(){return typeof xc!="function"||typeof Symbol!="function"||typeof xc("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:_0()},wc={foo:{}},g0=Object,y0=function(){return{__proto__:wc}.foo===wc.foo&&!({__proto__:null}instanceof g0)},v0="Function.prototype.bind called on incompatible ",b0=Object.prototype.toString,x0=Math.max,w0="[object Function]",Tc=function(t,e){for(var i=[],s=0;s<t.length;s+=1)i[s]=t[s];for(var n=0;n<e.length;n+=1)i[n+t.length]=e[n];return i},T0=function(t,e){for(var i=[],s=e,n=0;s<t.length;s+=1,n+=1)i[n]=t[s];return i},E0=function(r,t){for(var e="",i=0;i<r.length;i+=1)e+=r[i],i+1<r.length&&(e+=t);return e},A0=function(t){var e=this;if(typeof e!="function"||b0.apply(e)!==w0)throw new TypeError(v0+e);for(var i=T0(arguments,1),s,n=function(){if(this instanceof s){var c=e.apply(this,Tc(i,arguments));return Object(c)===c?c:this}return e.apply(t,Tc(i,arguments))},o=x0(0,e.length-i.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+E0(a,",")+"){ return binder.apply(this,arguments); }")(n),e.prototype){var h=function(){};h.prototype=e.prototype,s.prototype=new h,h.prototype=null}return s},S0=A0,Ih=Function.prototype.bind||S0,C0=Function.prototype.call,I0=Object.prototype.hasOwnProperty,R0=Ih,P0=R0.call(C0,I0),at,Wr=SyntaxError,Ef=Function,Ur=TypeError,la=function(r){try{return Ef('"use strict"; return ('+r+").constructor;")()}catch{}},nr=Object.getOwnPropertyDescriptor;if(nr)try{nr({},"")}catch{nr=null}var ha=function(){throw new Ur},M0=nr?function(){try{return arguments.callee,ha}catch{try{return nr(arguments,"callee").get}catch{return ha}}}():ha,br=m0(),B0=y0(),Pt=Object.getPrototypeOf||(B0?function(r){return r.__proto__}:null),Rr={},k0=typeof Uint8Array>"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;c+=1){var d=i[c],f=Kn(d,0,1),p=Kn(d,-1);if((f==='"'||f==="'"||f==="`"||p==='"'||p==="'"||p==="`")&&f!==p)throw new Wr("property names with quotes must have matching quotes");if((d==="constructor"||!u)&&(l=!0),s+="."+d,o="%"+s+"%",Zn(or,o))a=or[o];else if(a!=null){if(!(d in a)){if(!e)throw new Ur("base intrinsic for "+t+" exists, but the property is not available.");return}if(nr&&c+1>=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+="</"+kc.call(String(t.nodeName))+">",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;e<i;e++)if(r[e]===t)return e;return-1}function v1(r){if(!Jn||!r||typeof r!="object")return!1;try{Jn.call(r);try{Qn.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function b1(r){if(!xs||!r||typeof r!="object")return!1;try{xs.call(r,xs);try{ws.call(r,ws)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function x1(r){if(!Bc||!r||typeof r!="object")return!1;try{return Bc.call(r),!0}catch{}return!1}function w1(r){if(!Qn||!r||typeof r!="object")return!1;try{Qn.call(r);try{Jn.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function T1(r){if(!ws||!r||typeof r!="object")return!1;try{ws.call(r,ws);try{xs.call(r,xs)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function E1(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Of(r,t){if(r.length>t.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<r.length;t++)if(Ff(r[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;s<r.length;s++)i[s]=gi(r,s)?t(r[s],r):""}var n=typeof da=="function"?da(r):[],o;if(jr){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var l in r)gi(r,l)&&(e&&String(Number(l))===l&&l<r.length||jr&&o["$"+l]instanceof Symbol||(Mf.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof da=="function")for(var h=0;h<n.length;h++)Bf.call(r,n[h])&&i.push("["+t(n[h])+"]: "+t(r[n[h]],r));return i}var kh=pr,es=Q0,I1=h1,R1=kh("%TypeError%"),Xs=kh("%WeakMap%",!0),Vs=kh("%Map%",!0),P1=es("WeakMap.prototype.get",!0),M1=es("WeakMap.prototype.set",!0),B1=es("WeakMap.prototype.has",!0),k1=es("Map.prototype.get",!0),D1=es("Map.prototype.set",!0),F1=es("Map.prototype.has",!0),Dh=function(r,t){for(var e=r,i;(i=e.next)!==null;e=i)if(i.key===t)return e.next=i.next,i.next=r.next,r.next=i,i},O1=function(r,t){var e=Dh(r,t);return e&&e.value},N1=function(r,t,e){var i=Dh(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},L1=function(r,t){return!!Dh(r,t)},U1=function(){var t,e,i,s={assert:function(n){if(!s.has(n))throw new R1("Side channel does not contain "+I1(n))},get:function(n){if(Xs&&n&&(typeof n=="object"||typeof n=="function")){if(t)return P1(t,n)}else if(Vs){if(e)return k1(e,n)}else if(i)return O1(i,n)},has:function(n){if(Xs&&n&&(typeof n=="object"||typeof n=="function")){if(t)return B1(t,n)}else if(Vs){if(e)return F1(e,n)}else if(i)return L1(i,n);return!1},set:function(n,o){Xs&&n&&(typeof n=="object"||typeof n=="function")?(t||(t=new Xs),M1(t,n,o)):Vs?(e||(e=new Vs),D1(e,n,o)):(i||(i={key:{},next:null}),N1(i,n,o))}};return s},G1=String.prototype.replace,H1=/%20/g,pa={RFC1738:"RFC1738",RFC3986:"RFC3986"},Fh={default:pa.RFC3986,formatters:{RFC1738:function(r){return G1.call(r,H1,"+")},RFC3986:function(r){return String(r)}},RFC1738:pa.RFC1738,RFC3986:pa.RFC3986},z1=Fh,_a=Object.prototype.hasOwnProperty,Qi=Array.isArray,Pe=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),$1=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(Qi(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},Nf=function(t,e){for(var i=e&&e.plainObjects?Object.create(null):{},s=0;s<t.length;++s)typeof t[s]<"u"&&(i[s]=t[s]);return i},X1=function r(t,e,i){if(!e)return t;if(typeof e!="object"){if(Qi(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!_a.call(Object.prototype,e))&&(t[e]=!0);else return[t,e];return t}if(!t||typeof t!="object")return[t].concat(e);var s=t;return Qi(t)&&!Qi(e)&&(s=Nf(t,i)),Qi(t)&&Qi(e)?(e.forEach(function(n,o){if(_a.call(t,o)){var a=t[o];a&&typeof a=="object"&&n&&typeof n=="object"?t[o]=r(a,n,i):t.push(n)}else t[o]=n}),t):Object.keys(e).reduce(function(n,o){var a=e[o];return _a.call(n,o)?n[o]=r(n[o],a,i):n[o]=a,n},s)},V1=function(t,e){return Object.keys(e).reduce(function(i,s){return i[s]=e[s],i},t)},W1=function(r,t,e){var i=r.replace(/\+/g," ");if(e==="iso-8859-1")return i.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(i)}catch{return i}},j1=function(t,e,i,s,n){if(t.length===0)return t;var o=t;if(typeof t=="symbol"?o=Symbol.prototype.toString.call(t):typeof t!="string"&&(o=String(t)),i==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(c){return"%26%23"+parseInt(c.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;++l){var h=o.charCodeAt(l);if(h===45||h===46||h===95||h===126||h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||n===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<e.length;++s)for(var n=e[s],o=n.obj[n.prop],a=Object.keys(o),l=0;l<a.length;++l){var h=a[l],c=o[h];typeof c=="object"&&c!==null&&i.indexOf(c)===-1&&(e.push({obj:o,prop:h}),i.push(c))}return $1(e),t},q1=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},Z1=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},K1=function(t,e){return[].concat(t,e)},J1=function(t,e){if(Qi(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)},Lf={arrayToObject:Nf,assign:V1,combine:K1,compact:Y1,decode:W1,encode:j1,isBuffer:Z1,isRegExp:q1,maybeMap:J1,merge:X1},Uf=U1,Tn=Lf,Ts=Fh,Q1=Object.prototype.hasOwnProperty,zc={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},Qe=Array.isArray,ty=Array.prototype.push,Gf=function(r,t){ty.apply(r,Qe(t)?t:[t])},ey=Date.prototype.toISOString,$c=Ts.default,Ot={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:Tn.encode,encodeValuesOnly:!1,format:$c,formatter:Ts.formatters[$c],indices:!1,serializeDate:function(t){return ey.call(t)},skipNulls:!1,strictNullHandling:!1},iy=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},ma={},ry=function r(t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,g){for(var _=t,v=g,y=0,b=!1;(v=v.get(ma))!==void 0&&!b;){var x=v.get(t);if(y+=1,typeof x<"u"){if(x===y)throw new RangeError("Cyclic object value");b=!0}typeof v.get(ma)>"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<T.length;++P){var M=T[P],E=typeof M=="object"&&typeof M.value<"u"?M.value:_[M];if(!(o&&E===null)){var C=Qe(_)?typeof i=="function"?i(B,M):B:B+(c?"."+M:"["+M+"]");g.set(t,y);var G=Uf();G.set(ma,g),Gf(w,r(E,C,i,s,n,o,i==="comma"&&p&&Qe(_)?null:a,l,h,c,u,d,f,p,m,G))}}return w},sy=function(t){if(!t)return Ot;if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");var e=t.charset||Ot.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var i=Ts.default;if(typeof t.format<"u"){if(!Q1.call(Ts.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=Ts.formatters[i],n=Ot.filter;return(typeof t.filter=="function"||Qe(t.filter))&&(n=t.filter),{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:Ot.addQueryPrefix,allowDots:typeof t.allowDots>"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;u<s.length;++u){var d=s[u];i.skipNulls&&e[d]===null||Gf(o,ry(e[d],d,l,h,i.strictNullHandling,i.skipNulls,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,c))}var f=o.join(i.delimiter),p=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?p+="utf8=%26%2310003%3B&":p+="utf8=%E2%9C%93&"),f.length>0?p+f:""},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<o.length;++l)o[l].indexOf("utf8=")===0&&(o[l]===hy?h="utf-8":o[l]===ly&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var c=o[l],u=c.indexOf("]="),d=u===-1?c.indexOf("="):u+1,f,p;d===-1?(f=e.decoder(c,Rt.decoder,h,"key"),p=e.strictNullHandling?null:""):(f=e.decoder(c.slice(0,d),Rt.decoder,h,"key"),p=Yr.maybeMap(Hf(c.slice(d+1),e),function(m){return e.decoder(m,Rt.decoder,h,"value")})),p&&e.interpretNumericEntities&&h==="iso-8859-1"&&(p=ay(p)),c.indexOf("[]=")>-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<i.depth;){if(u+=1,!i.plainObjects&&Ml.call(Object.prototype,l[1].slice(1,-1))&&!i.allowPrototypes)return;c.push(l[1])}return l&&c.push("["+n.slice(l.index)+"]"),uy(c,e,i,s)}},fy=function(t){if(!t)return Rt;if(t.decoder!==null&&t.decoder!==void 0&&typeof t.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=typeof t.charset>"u"?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<n.length;++o){var a=n[o],l=dy(a,i[a],e,typeof r=="string");s=Yr.merge(s,l,e)}return e.allowSparse===!0?s:Yr.compact(s)},_y=ny,my=py,gy=Fh,yy={formats:gy,parse:my,stringify:_y},vy=f0;function ai(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var by=/^([a-z0-9.+-]+:)/i,xy=/:[0-9]*$/,wy=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,Ty=["<",">",'"',"`"," ","\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&&i<r.indexOf("#")?"?":"#",n=r.split(s),o=/\\/g;n[0]=n[0].replace(o,"/"),r=n.join(s);var a=r;if(a=a.trim(),!e&&r.split("#").length===1){var l=wy.exec(a);if(l)return this.path=a,this.href=a,this.pathname=l[1],l[2]?(this.search=l[2],t?this.query=Dl.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var h=by.exec(a);if(h){h=h[0];var c=h.toLowerCase();this.protocol=c,a=a.substr(h.length)}if(e||h||a.match(/^\/\/[^@/]+@[^@/]+/)){var u=a.substr(0,2)==="//";u&&!(h&&kl[h])&&(a=a.substr(2),this.slashes=!0)}if(!kl[h]&&(u||h&&!Gr[h])){for(var d=-1,f=0;f<Vc.length;f++){var p=a.indexOf(Vc[f]);p!==-1&&(d===-1||p<d)&&(d=p)}var m,g;d===-1?g=a.lastIndexOf("@"):g=a.lastIndexOf("@",d),g!==-1&&(m=a.slice(0,g),a=a.slice(g+1),this.auth=decodeURIComponent(m)),d=-1;for(var f=0;f<Xc.length;f++){var p=a.indexOf(Xc[f]);p!==-1&&(d===-1||p<d)&&(d=p)}d===-1&&(d=a.length),this.host=a.slice(0,d),a=a.slice(d),this.parseHost(),this.hostname=this.hostname||"";var _=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!_)for(var v=this.hostname.split(/\./),f=0,y=v.length;f<y;f++){var b=v[f];if(b&&!b.match(Wc)){for(var x="",S=0,w=b.length;S<w;S++)b.charCodeAt(S)>127?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;f<y;f++){var E=Bl[f];if(a.indexOf(E)!==-1){var C=encodeURIComponent(E);C===E&&(C=escape(E)),a=a.split(E).join(C)}}var G=a.indexOf("#");G!==-1&&(this.hash=a.substr(G),a=a.slice(0,G));var X=a.indexOf("?");if(X!==-1?(this.search=a.substr(X),this.query=a.substr(X+1),t&&(this.query=Dl.parse(this.query)),a=a.slice(0,X)):t&&(this.search="",this.query={}),a&&(this.pathname=a),Gr[c]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var P=this.pathname||"",N=this.search||"";this.path=P+N}return this.href=this.format(),this};ai.prototype.format=function(){var r=this.auth||"";r&&(r=encodeURIComponent(r),r=r.replace(/%3A/i,":"),r+="@");var t=this.protocol||"",e=this.pathname||"",i=this.hash||"",s=!1,n="";this.host?s=r+this.host:this.hostname&&(s=r+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(n=Dl.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||Gr[t])&&s!==!1?(s="//"+(s||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):s||(s=""),i&&i.charAt(0)!=="#"&&(i="#"+i),o&&o.charAt(0)!=="?"&&(o="?"+o),e=e.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),o=o.replace("#","%23"),t+s+e+o+i};ai.prototype.resolve=function(r){return this.resolveObject(Iy(r,!1,!0)).format()};ai.prototype.resolveObject=function(r){if(typeof r=="string"){var t=new ai;t.parse(r,!1,!0),r=t}for(var e=new ai,i=Object.keys(this),s=0;s<i.length;s++){var n=i[s];e[n]=this[n]}if(e.hash=r.hash,r.href==="")return e.href=e.format(),e;if(r.slashes&&!r.protocol){for(var o=Object.keys(r),a=0;a<o.length;a++){var l=o[a];l!=="protocol"&&(e[l]=r[l])}return Gr[e.protocol]&&e.hostname&&!e.pathname&&(e.pathname="/",e.path=e.pathname),e.href=e.format(),e}if(r.protocol&&r.protocol!==e.protocol){if(!Gr[r.protocol]){for(var h=Object.keys(r),c=0;c<h.length;c++){var u=h[c];e[u]=r[u]}return e.href=e.format(),e}if(e.protocol=r.protocol,!r.host&&!kl[r.protocol]){for(var y=(r.pathname||"").split("/");y.length&&!(r.host=y.shift()););r.host||(r.host=""),r.hostname||(r.hostname=""),y[0]!==""&&y.unshift(""),y.length<2&&y.unshift(""),e.pathname=y.join("/")}else e.pathname=r.pathname;if(e.search=r.search,e.query=r.query,e.host=r.host||"",e.auth=r.auth,e.hostname=r.hostname||r.host,e.port=r.port,e.pathname||e.search){var d=e.pathname||"",f=e.search||"";e.path=d+f}return e.slashes=e.slashes||r.slashes,e.href=e.format(),e}var p=e.pathname&&e.pathname.charAt(0)==="/",m=r.host||r.pathname&&r.pathname.charAt(0)==="/",g=m||p||e.host&&r.pathname,_=g,v=e.pathname&&e.pathname.split("/")||[],y=r.pathname&&r.pathname.split("/")||[],b=e.protocol&&!Gr[e.protocol];if(b&&(e.hostname="",e.port=null,e.host&&(v[0]===""?v[0]=e.host:v.unshift(e.host)),e.host="",r.protocol&&(r.hostname=null,r.port=null,r.host&&(y[0]===""?y[0]=r.host:y.unshift(r.host)),r.host=null),g=g&&(y[0]===""||v[0]==="")),m)e.host=r.host||r.host===""?r.host:e.host,e.hostname=r.hostname||r.hostname===""?r.hostname:e.hostname,e.search=r.search,e.query=r.query,v=y;else if(y.length)v||(v=[]),v.pop(),v=v.concat(y),e.search=r.search,e.query=r.query;else if(r.search!=null){if(b){e.host=v.shift(),e.hostname=e.host;var x=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;x&&(e.auth=x.shift(),e.hostname=x.shift(),e.host=e.hostname)}return e.search=r.search,e.query=r.query,(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!v.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;for(var 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(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=a,n=0;continue}}}else e.length>0?e+=`/${r.slice(s+1,a)}`:e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const 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;e<r.length;++e){const i=r[e];if(be(i),i.length>0)if(t===void 0)t=i;else{const s=r[e-1]??"";this.extname(s)?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(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<t.length;e++){var i=t[e][0](r);if(i)return[i,t[e][1]]}return[null,void 0]},Gy=function(r){return typeof r=="string"?Jc(r.trim(),Fl.string):typeof r=="object"&&r!==null?Jc(r,Fl.object):[null,void 0]},ba=function(r,t){var e=Es(r);return{h:e.h,s:_e(e.s+100*t,0,100),l:e.l,a:e.a}},xa=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},Qc=function(r,t){var e=Es(r);return{h:e.h,s:e.s,l:_e(e.l+100*t,0,100),a:e.a}},Ol=function(){function r(t){this.parsed=Gy(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return Mt(xa(this.rgba),2)},r.prototype.isDark=function(){return xa(this.rgba)<.5},r.prototype.isLight=function(){return xa(this.rgba)>=.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));m<u&&(u=m,d=p)}return d}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new r(l).toRgb():null},"name"])}Hy([zy]);const Pr=class En{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof En)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,s]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toRgbArray(t){t=t??[];const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,s,n]=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<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}function jf(r){if(r.BYTES_PER_ELEMENT===4)return r instanceof Float32Array?"Float32Array":r instanceof Uint32Array?"Uint32Array":"Int32Array";if(r.BYTES_PER_ELEMENT===2){if(r instanceof Uint16Array)return"Uint16Array"}else if(r.BYTES_PER_ELEMENT===1&&r instanceof Uint8Array)return"Uint8Array";return null}function to(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function 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<n;++s)r[s]=r[s+e];r.length=n}function Ti(r){return r===0?0:r<0?-1:1}let jy=0;function cr(){return++jy}const Nl=class{constructor(r,t,e,i){this.left=r,this.top=t,this.right=e,this.bottom=i}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};Nl.EMPTY=new Nl(0,0,0,0);let ru=Nl;const su={},De=Object.create(null),hi=Object.create(null);class Yy{constructor(t,e,i){this._canvas=j.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||j.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function nu(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function ou(r,t,e,i,s){const n=4*t;for(let o=i,a=i*n+4*e;o<=s;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function qy(r){const{width:t,height:e}=r,i=r.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const s=i.getImageData(0,0,t,e).data;let n=0,o=0,a=t-1,l=e-1;for(;o<e&&nu(s,t,o);)++o;if(o===e)return ru.EMPTY;for(;nu(s,t,l);)--l;for(;ou(s,t,n,o,l);)++n;for(;ou(s,t,a,o,l);)--a;return++a,++l,new ru(n,o,a,l)}function Zy(r){const t=qy(r),{width:e,height:i}=t;let s=null;if(!t.isEmpty()){const n=r.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");s=n.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:s}}function Ky(r,t=globalThis.location){if(r.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function li(r,t=1){const e=j.RETINA_PREFIX?.exec(r);return e?parseFloat(e[1]):t}var $=(r=>(r.Renderer="renderer",r.Application="application",r.RendererSystem="renderer-webgl-system",r.RendererPlugin="renderer-webgl-plugin",r.CanvasRendererSystem="renderer-canvas-system",r.CanvasRendererPlugin="renderer-canvas-plugin",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r))($||{});const 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;e<r;++e)e>0&&(t+=`
|
|
else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function tv(r,t){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);for(;;){const i=Jy.replace(/%forloop%/gi,Qy(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const wa=0,Ta=1,Ea=2,Aa=3,Sa=4,Ca=5;class Ve{constructor(){this.data=0,this.blendMode=Q.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<wa)}set blend(t){!!(this.data&1<<wa)!==t&&(this.data^=1<<wa)}get offsets(){return!!(this.data&1<<Ta)}set offsets(t){!!(this.data&1<<Ta)!==t&&(this.data^=1<<Ta)}get culling(){return!!(this.data&1<<Ea)}set culling(t){!!(this.data&1<<Ea)!==t&&(this.data^=1<<Ea)}get depthTest(){return!!(this.data&1<<Aa)}set depthTest(t){!!(this.data&1<<Aa)!==t&&(this.data^=1<<Aa)}get depthMask(){return!!(this.data&1<<Ca)}set depthMask(t){!!(this.data&1<<Ca)!==t&&(this.data^=1<<Ca)}get clockwiseFrontFace(){return!!(this.data&1<<Sa)}set clockwiseFrontFace(t){!!(this.data&1<<Sa)!==t&&(this.data^=1<<Sa)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==Q.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Ve;return t.depthTest=!1,t.blend=!0,t}}Ve.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const Gl=[];function Yf(r,t){if(!r)return null;let e="";if(typeof r=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(r);i&&(e=i[1].toLowerCase())}for(let i=Gl.length-1;i>=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;u<d;u++)c[u][h](t,e,i,s,n,o,a,l);return c===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(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;e<t.textureCacheIds.length;++e)delete hi[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};Hl.defaultOptions={mipmap:Xe.POW2,anisotropicLevel:0,scaleMode:ti.LINEAR,wrapMode:Ii.CLAMP,alphaMode:Zt.UNPACK,target:Lr.TEXTURE_2D,format:O.RGBA,type:K.UNSIGNED_BYTE},Hl._globalBatch=0;let rt=Hl;class zl{constructor(){this.texArray=null,this.blend=0,this.type=He.TRIANGLES,this.start=0,this.size=0,this.data=null}}let iv=0;class Tt{constructor(t,e=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=e,this.id=iv++,this.disposeRunner=new Se("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?ze.ELEMENT_ARRAY_BUFFER:ze.ARRAY_BUFFER}get index(){return this.type===ze.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Tt(t)}}class eo{constructor(t,e=0,i=!1,s=K.FLOAT,n,o,a,l=1){this.buffer=t,this.size=e,this.normalized=i,this.type=s,this.stride=n,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(t,e,i,s,n){return new eo(t,e,i,s,n)}}const rv={Float32Array,Uint32Array,Int32Array,Uint8Array};function sv(r,t){let e=0,i=0;const s={};for(let l=0;l<r.length;l++)i+=t[l],e+=r[l].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let l=0;l<r.length;l++){const h=t[l],c=r[l],u=jf(c);s[u]||(s[u]=new rv[u](n)),o=s[u];for(let d=0;d<c.length;d++){const f=(d/h|0)*i+a,p=d%h;o[f+p]=c[d]}a+=h}return new Float32Array(n)}const lu={5126:4,5123:2,5121:1};let nv=0;const ov={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class Pi{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=nv++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new Se("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,s=!1,n,o,a,l=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Tt||(e instanceof Array&&(e=new Float32Array(e)),e=new Tt(e));const h=t.split("|");if(h.length>1){for(let u=0;u<h.length;u++)this.addAttribute(h[u],e,i,s,n);return this}let c=this.buffers.indexOf(e);return c===-1&&(this.buffers.push(e),c=this.buffers.length-1),this.attributes[t]=new eo(c,i,s,n,o,a,l),this.instanced=this.instanced||l,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof Tt||(t instanceof Array&&(t=new Uint16Array(t)),t=new Tt(t)),t.type=ze.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],i=new Tt;let s;for(s in this.attributes){const n=this.attributes[s],o=this.buffers[n.buffer];t.push(o.data),e.push(n.size*lu[n.type]/4),n.buffer=0}for(i.data=sv(t,e),s=0;s<this.buffers.length;s++)this.buffers[s]!==this.indexBuffer&&this.buffers[s].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new Pi;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new Tt(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new eo(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=ze.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new Pi,i=[],s=[],n=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)s[l]=s[l]||0,s[l]+=o.buffers[l].data.length,n[l]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new ov[jf(o.buffers[a].data)](s[a]),e.buffers[a]=new Tt(i[a]);for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)i[l].set(o.buffers[l].data,n[l]),n[l]+=o.buffers[l].data.length}if(e.attributes=o.attributes,o.indexBuffer){e.indexBuffer=e.buffers[o.buffers.indexOf(o.indexBuffer)],e.indexBuffer.type=ze.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,c=0;for(let u=0;u<o.buffers.length;u++)if(o.buffers[u]!==o.indexBuffer){c=u;break}for(const u in o.attributes){const d=o.attributes[u];(d.buffer|0)===c&&(l+=d.size*lu[d.type]/4)}for(let u=0;u<t.length;u++){const d=t[u].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+h]+=a;a+=t[u].buffers[c].data.length/l,h+=d.length}}return e}}class qf extends Pi{constructor(t=!1){super(),this._buffer=new Tt(null,t,!1),this._indexBuffer=new Tt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,K.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,K.FLOAT).addAttribute("aColor",this._buffer,4,!0,K.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,K.FLOAT).addIndex(this._indexBuffer)}}const io=Math.PI*2,av=180/Math.PI,lv=Math.PI/180;var kt=(r=>(r[r.POLY=0]="POLY",r[r.RECT=1]="RECT",r[r.CIRC=2]="CIRC",r[r.ELIP=3]="ELIP",r[r.RREC=4]="RREC",r))(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.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const T=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=T)return!1;const I=this.y<t.y?t.y:this.y;return(this.bottom>t.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;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.type=kt.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new ar(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],l=this.points[n*2+1],h=this.points[o*2],c=this.points[o*2+1];l>e!=c>e&&t<(h-a)*((e-l)/(c-l))+a&&(i=!i)}return i}}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;e<t.length;e++)t[e]=!1;return t}function Kf(r,t){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Ia(2*t);case"bvec3":return Ia(3*t);case"bvec4":return Ia(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const zr=[{test:r=>r.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<zr.length;a++)if(zr[a].test(s,n)){e.push(zr[a].code(i,n)),o=!0;break}if(!o){const a=(s.size===1&&!s.isArray?dv:fv)[s.type].replace("location",`ud["${i}"].location`);e.push(`
|
|
cu = ud["${i}"];
|
|
cv = cu.value;
|
|
v = uv["${i}"];
|
|
${a};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
|
|
`))}const Jf={};let qs=Jf;function _v(){if(qs===Jf||qs?.isContextLost()){const r=j.ADAPTER.createCanvas();let t;j.PREFER_ENV>=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;i<e.length;++i){const s=e[i];Ks[r[s]]=uu[s]}}return Ks[t]}function du(r,t,e){if(r.substring(0,9)!=="precision"){let i=t;return t===pe.HIGH&&e!==pe.HIGH&&(i=pe.MEDIUM),`precision ${i} float;
|
|
${r}`}else if(e!==pe.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let ls;function vv(){if(typeof ls=="boolean")return ls;try{ls=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{ls=!1}return ls}let bv=0;const Js={},Vl=class Br{constructor(t,e,i="pixi-shader",s={}){this.extra={},this.id=bv++,this.vertexSrc=t||Br.defaultVertexSrc,this.fragmentSrc=e||Br.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=s,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),Js[i]?(Js[i]++,i+=`-${Js[i]}`):Js[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
|
|
${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i}
|
|
${this.fragmentSrc}`,this.vertexSrc=du(this.vertexSrc,Br.defaultVertexPrecision,pe.HIGH),this.fragmentSrc=du(this.fragmentSrc,Br.defaultFragmentPrecision,mv())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return uv}static get defaultFragmentSrc(){return cv}static from(t,e,i){const s=t+e;let n=su[s];return n||(su[s]=n=new Br(t,e,i)),n}};Vl.defaultVertexPrecision=pe.HIGH,Vl.defaultFragmentPrecision=ei.apple.device?pe.HIGH:pe.MEDIUM;let ri=Vl,xv=0;class Ce{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=xv++,this.static=!!e,this.ubo=!!i,t instanceof Tt?(this.buffer=t,this.buffer.type=ze.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new Tt(new Float32Array(1)),this.buffer.type=ze.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,i){if(!this.ubo)this.uniforms[t]=new Ce(e,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,e,i){return new Ce(t,e,i)}static uboFrom(t,e){return new Ce(t,e??!0,!0)}}class $e{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof Ce?this.uniformGroup=e:this.uniformGroup=new Ce(e):this.uniformGroup=new Ce({}),this.disposeRunner=new Se("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const s=e.uniforms[i];if(s.group===!0&&this.checkUniformExists(t,s))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,i){const s=ri.from(t,e);return new $e(s,i)}}class wv{constructor(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},!e.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!e.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=n;this.defaultGroupCache[t]=Ce.from({uSamplers:i},!0);let s=this.fragTemplate;s=s.replace(/%count%/gi,`${t}`),s=s.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new ri(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new yt,default:this.defaultGroupCache[t]};return new $e(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
|
|
`,e+=`
|
|
`;for(let i=0;i<t;i++)i>0&&(e+=`
|
|
else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=`
|
|
{`,e+=`
|
|
color = texture2D(uSamplers[${i}], vTextureCoord);`,e+=`
|
|
}`;return e+=`
|
|
`,e+=`
|
|
`,e}}class Wl{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}function Tv(){return!ei.apple.device}function Ev(r){let t=!0;const e=j.ADAPTER.getNavigator();if(ei.tablet||ei.phone){if(ei.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(ei.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?r:4}class Bo{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var Av=`varying vec2 vTextureCoord;
|
|
varying vec4 vColor;
|
|
varying float vTextureId;
|
|
uniform sampler2D uSamplers[%count%];
|
|
|
|
void main(void){
|
|
vec4 color;
|
|
%forloop%
|
|
gl_FragColor = color * vColor;
|
|
}
|
|
`,Sv=`precision highp float;
|
|
attribute vec2 aVertexPosition;
|
|
attribute vec2 aTextureCoord;
|
|
attribute vec4 aColor;
|
|
attribute float aTextureId;
|
|
|
|
uniform mat3 projectionMatrix;
|
|
uniform mat3 translationMatrix;
|
|
uniform vec4 tint;
|
|
|
|
varying vec2 vTextureCoord;
|
|
varying vec4 vColor;
|
|
varying float vTextureId;
|
|
|
|
void main(void){
|
|
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
|
|
vTextureCoord = aTextureCoord;
|
|
vTextureId = aTextureId;
|
|
vColor = aColor * tint;
|
|
}
|
|
`;const fs=class Te extends Bo{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=qf,this.vertexSize=6,this.state=Ve.for2d(),this.size=Te.defaultBatchSize*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),t.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??Ev(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??Tv(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return nt("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Sv}static get defaultFragmentTemplate(){return Av}setShaderGenerator({vertex:t=Te.defaultVertexSrc,fragment:e=Te.defaultFragmentTemplate}={}){this.shaderGenerator=new wv(t,e)}contextChange(){const t=this.renderer.gl;j.PREFER_ENV===fr.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Te.defaultMaxTextures),this.maxTextures=tv(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:e}=Te,i=this.size/4,s=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new zl);for(;e.length<s;)e.push(new Wl);for(let n=0;n<this.maxTextures;n++)this._tempBoundTextures[n]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:e}=this,i=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<this._bufferSize;++u){const d=t[u];t[u]=null,d._batchEnabled!==a&&(h.count>=e&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,c,u),c=u,h=i[++l],++a),d._batchEnabled=a,d.touched=o,h.elements[h.count++]=d)}h.count>0&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,c,this._bufferSize),++l,++a);for(let u=0;u<n.length;u++)n[u]=null;rt._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,l=Te._drawCallPool;let h=this._dcIndex,c=this._aIndex,u=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=t;for(let f=e;f<i;++f){const p=s[f],m=p._texture.baseTexture,g=Vf[m.alphaMode?1:0][p.blendMode];s[f]=null,e<f&&d.blend!==g&&(d.size=u-d.start,e=f,d=l[++h],d.texArray=t,d.start=u),this.packInterleavedGeometry(p,n,o,c,u),c+=p.vertexData.length/2*a,u+=p.indices.length,d.blend=g}e<i&&(d.size=u-d.start,++h),this._dcIndex=h,this._aIndex=c,this._iIndex=u}bindAndClearTexArray(t){const e=this.renderer.texture;for(let i=0;i<t.count;i++)e.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:i}=this;Te.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:i}=this.renderer,s=Te._drawCallPool;let n=null;for(let o=0;o<t;o++){const{texArray:a,type:l,size:h,start:c,blend:u}=s[o];n!==a&&(n=a,this.bindAndClearTexArray(a)),this.state.blendMode=u,i.set(this.state),e.drawElements(l,h,e.UNSIGNED_SHORT,c*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),Te.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(t){const e=to(Math.ceil(t/8)),i=iu(e),s=e*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._aBuffers[s];return n||(this._aBuffers[s]=n=new Ul(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=to(Math.ceil(t/12)),i=iu(e),s=e*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._iBuffers[i];return n||(this._iBuffers[i]=n=new Uint16Array(s)),n}packInterleavedGeometry(t,e,i,s,n){const{uint32View:o,float32View:a}=e,l=s/this.vertexSize,h=t.uvs,c=t.indices,u=t.vertexData,d=t._texture.baseTexture._batchLocation,f=Math.min(t.worldAlpha,1),p=dt.shared.setValue(t._tintRGB).toPremultiplied(f,t._texture.baseTexture.alphaMode>0);for(let m=0;m<u.length;m+=2)a[s++]=u[m],a[s++]=u[m+1],a[s++]=h[m],a[s++]=h[m+1],o[s++]=p,a[s++]=d;for(let m=0;m<c.length;m++)i[n++]=l+c[m]}};fs.defaultBatchSize=4096,fs.extension={name:"batch",type:$.RendererPlugin},fs._drawCallPool=[],fs._textureArrayPool=[];let Ki=fs;q.add(Ki);var Cv=`varying vec2 vTextureCoord;
|
|
|
|
uniform sampler2D uSampler;
|
|
|
|
void main(void){
|
|
gl_FragColor = texture2D(uSampler, vTextureCoord);
|
|
}
|
|
`,Iv=`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 jl=class ps extends $e{constructor(t,e,i){const s=ri.from(t||ps.defaultVertexSrc,e||ps.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=ps.defaultResolution,this.multisample=ps.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Ve}apply(t,e,i,s,n){t.applyFilter(this,e,i,s)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return Iv}static get defaultFragmentSrc(){return Cv}};jl.defaultResolution=1,jl.defaultMultisample=At.NONE;let Lt=jl;class ro{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new dt(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:s}=t,n=i??e;n!==void 0&&(this.color=n),this.alpha=s}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}ro.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},ro.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"background"};q.add(ro);class ep{constructor(t){this.renderer=t,this.emptyRenderer=new Bo(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:i}=this.renderer.texture;for(let s=e-1;s>=0;--s)t[s]=i[s]||null,t[s]&&(t[s]._batchLocation=s)}boundArray(t,e,i,s){const{elements:n,ids:o,count:a}=t;let l=0;for(let h=0;h<a;h++){const c=n[h],u=c._batchLocation;if(u>=0&&u<s&&e[u]===c){o[h]=u;continue}for(;l<s;){const d=e[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,c._batchLocation=l,e[l]=c;break}}}destroy(){this.renderer=null}}ep.extension={type:$.RendererSystem,name:"batch"};q.add(ep);let fu=0;class so{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=fu++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=fu++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;e.addEventListener!==void 0&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let i;if(j.PREFER_ENV>=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<this.colorTextures.length;i++){const s=this.colorTextures[i],n=s.resolution;s.setSize(t/n,e/n)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class ip extends rt{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],s=arguments[2],n=arguments[3];t={width:e,height:i,scaleMode:s,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=At.NONE),super(null,t),this.mipmap=Xe.OFF,this.valid=!0,this._clear=new dt([0,0,0,0]),this.framebuffer=new Yl(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Mi extends ks{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.width,s=e.naturalHeight||e.videoHeight||e.height;super(i,s),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=Ky(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,s){const n=t.gl,o=e.realWidth,a=e.realHeight;if(s=s||this.source,typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement){if(!s.complete||s.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement&&s.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Zt.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&i.width===o&&i.height===a?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,i.type,s):(i.width=o,i.height=a,n.texImage2D(e.target,0,i.internalFormat,e.format,i.type,s)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class rp extends Mi{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;Mi.crossOrigin(i,t,e.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??j.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,i)=>{const s=this.source;this.url=s.src;const n=()=>{this.destroyed||(s.onload=null,s.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};s.complete&&s.src?n():(s.onload=n,s.onerror=o=>{i(o),this.onError.emit(o)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(s=>s.blob()).then(s=>e(s,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Zt.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let s=!0;const n=e._glTextures;for(const o in n){const a=n[o];if(a!==i&&a.dirtyId!==e.dirtyId){s=!1;break}}s&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class 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;e<t.textureCacheIds.length;++e)De[t.textureCacheIds[e]]===t&&delete De[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:i,width:s,height:n}=t,o=e+s>this.baseTexture.width,a=i+n>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${e} + ${s} = ${e+s} > ${this.baseTexture.width}`,c=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${c}`)}this.valid=s&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return Y._EMPTY||(Y._EMPTY=new Y(new rt),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;s<i.length;s++)i[s].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}sp.SCREEN_KEY=-1;class Rv extends Pi{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class np extends Pi{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new Tt(this.vertices),this.uvBuffer=new Tt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,s=0;return this.uvs[0]=i,this.uvs[1]=s,this.uvs[2]=i+e.width/t.width,this.uvs[3]=s,this.uvs[4]=i+e.width/t.width,this.uvs[5]=s+e.height/t.height,this.uvs[6]=i,this.uvs[7]=s+e.height/t.height,i=e.x,s=e.y,this.vertices[0]=i,this.vertices[1]=s,this.vertices[2]=i+e.width,this.vertices[3]=s,this.vertices[4]=i+e.width,this.vertices[5]=s+e.height,this.vertices[6]=i,this.vertices[7]=s+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class Pv{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=At.NONE,this.sourceFrame=new it,this.destinationFrame=new it,this.bindingSourceFrame=new it,this.bindingDestinationFrame=new it,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const tn=[new ht,new ht,new ht,new ht],Ra=new yt;class op{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new sp,this.statePool=[],this.quad=new Rv,this.quadUv=new np,this.tempRect=new it,this.activeState={},this.globalUniforms=new Ce({outputFrame:new it,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const i=this.renderer,s=this.defaultFilterStack,n=this.statePool.pop()||new Pv,o=i.renderTexture;let a,l;if(o.current){const g=o.current;a=g.resolution,l=g.multisample}else a=i.resolution,l=i.multisample;let h=e[0].resolution||a,c=e[0].multisample??l,u=e[0].padding,d=e[0].autoFit,f=e[0].legacy??!0;for(let g=1;g<e.length;g++){const _=e[g];h=Math.min(h,_.resolution||a),c=Math.min(c,_.multisample??l),u=this.useMaxPadding?Math.max(u,_.padding):u+_.padding,d=d&&_.autoFit,f=f||(_.legacy??!0)}s.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),s.push(n),n.resolution=h,n.multisample=c,n.legacy=f,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(u);const p=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(Ra.copyFrom(i.projection.transform).invert(),p),d?(n.sourceFrame.fit(p),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(p)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,o.current?o.current.resolution:i.resolution,o.sourceFrame,o.destinationFrame,i.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,h,c),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const m=this.tempRect;m.x=0,m.y=0,m.width=n.sourceFrame.width,m.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(o.sourceFrame),n.bindingDestinationFrame.copyFrom(o.destinationFrame),n.transform=i.projection.transform,i.projection.transform=null,o.bind(n.renderTexture,n.sourceFrame,m),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const s=this.globalUniforms.uniforms;s.outputFrame=e.sourceFrame,s.resolution=e.resolution;const n=s.inputSize,o=s.inputPixel,a=s.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],o[0]=Math.round(n[0]*e.resolution),o[1]=Math.round(n[1]*e.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=e.sourceFrame.width*n[2]-.5*o[2],a[3]=e.sourceFrame.height*n[3]-.5*o[3],e.legacy){const h=s.filterArea;h[0]=e.destinationFrame.width,h[1]=e.destinationFrame.height,h[2]=e.sourceFrame.x,h[3]=e.sourceFrame.y,s.filterClamp=s.inputClamp}this.globalUniforms.update();const l=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,e.renderTexture,l.renderTexture,Ne.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let h=e.renderTexture,c=this.getOptimalFilterTexture(h.width,h.height,e.resolution);c.filterFrame=h.filterFrame;let u=0;for(u=0;u<i.length-1;++u){u===1&&e.multisample>1&&(c=this.getOptimalFilterTexture(h.width,h.height,e.resolution),c.filterFrame=h.filterFrame),i[u].apply(this,h,c,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<t.colorTextures.length;o++){const a=t.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const o=e.width>>i,a=e.height>>i,l=o/e.width;this.setViewport(e.x*l,e.y*l,o,a)}else{const o=t.width>>i,a=t.height>>i;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,s.bindFramebuffer(s.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,i,s){const n=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),s=Math.round(s),(n.width!==i||n.height!==s||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=i,n.height=s,this.gl.viewport(t,e,i,s))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,e,i,s,n=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;o<n;o++){const a=s[o],l=a.parentTextureArray||a;this.renderer.texture.bind(l,0),o===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,s=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let o=n.length;i.drawBuffers||(o=Math.min(o,1)),s.multisample>1&&this.canMultisampleFramebuffer(t)?s.msaaBuffer=s.msaaBuffer||i.createRenderbuffer():s.msaaBuffer&&(i.deleteRenderbuffer(s.msaaBuffer),s.msaaBuffer=null,s.blitFramebuffer&&(s.blitFramebuffer.dispose(),s.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=n[l],c=h.parentTextureArray||h;this.renderer.texture.bind(c,0),l===0&&s.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,c._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,s.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,c._glTextures[this.CONTEXT_UID].texture,e),a.push(i.COLOR_ATTACHMENT0+l))}if(a.length>1&&i.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const l=t.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH_STENCIL):t.depth&&t.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH24_STENCIL8):t.depth?(l=i.DEPTH_ATTACHMENT,h=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,h=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,h,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,h,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,s.stencil)}else s.stencil&&(i.deleteRenderbuffer(s.stencil),s.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=At.NONE;if(t<=1||e===null)return i;for(let s=0;s<e.length;s++)if(e[s]<=t){i=e[s];break}return i===1&&(i=At.NONE),i}blit(t,e,i){const{current:s,renderer:n,gl:o,CONTEXT_UID:a}=this;if(n.context.webGLVersion!==2||!s)return;const l=s.glFramebuffers[a];if(!l)return;if(!t){if(!l.msaaBuffer)return;const c=s.colorTextures[0];if(!c)return;l.blitFramebuffer||(l.blitFramebuffer=new Yl(s.width,s.height),l.blitFramebuffer.addColorTexture(0,c)),t=l.blitFramebuffer,t.colorTextures[0]!==c&&(t.colorTextures[0]=c,t.dirtyId++,t.dirtyFormat++),(t.width!==s.width||t.height!==s.height)&&(t.width=s.width,t.height=s.height,t.dirtyId++,t.dirtySize++)}e||(e=Bv,e.width=s.width,e.height=s.height),i||(i=e);const h=e.width===i.width&&e.height===i.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,o.COLOR_BUFFER_BIT,h?o.NEAREST:o.LINEAR),o.bindFramebuffer(o.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const i=t.glFramebuffers[this.CONTEXT_UID],s=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(s.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&s.deleteRenderbuffer(i.msaaBuffer),i.stencil&&s.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,s=t.height,n=this.gl,o=e.stencil=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,o);let a,l;this.renderer.context.webGLVersion===1?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH_STENCIL):t.depth?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH24_STENCIL8):(a=n.STENCIL_ATTACHMENT,l=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,l,i,s):n.renderbufferStorage(n.RENDERBUFFER,l,i,s),n.framebufferRenderbuffer(n.FRAMEBUFFER,a,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new it}destroy(){this.renderer=null}}ap.extension={type:$.RendererSystem,name:"framebuffer"};q.add(ap);const Pa={5126:4,5123:2,5121:1};class lp{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;j.PREFER_ENV===fr.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=s=>i.bindVertexArrayOES(s),t.deleteVertexArray=s=>i.deleteVertexArrayOES(s)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n),t.drawElementsInstanced=(s,n,o,a,l)=>i.drawElementsInstancedANGLE(s,n,o,a,l),t.drawArraysInstanced=(s,n,o,a)=>i.drawArraysInstancedANGLE(s,n,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:i}=this;let s=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;s||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=s={},n=!0);const o=s[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==o&&(this._activeVao=o,this.hasVao?i.bindVertexArray(o):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.update(s)}}checkCompatibility(t,e){const i=t.attributes,s=e.attributeData;for(const n in s)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,s=e.attributeData,n=["g",t.id];for(const o in i)s[o]&&n.push(o,s[o].location);return n.join("-")}initGeometryVao(t,e,i=!0){const s=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,a=e.program;a.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const l=this.getSignature(t,a),h=t.glVertexArrayObjects[this.CONTEXT_UID];let c=h[l];if(c)return h[a.id]=c,c;const u=t.buffers,d=t.attributes,f={},p={};for(const m in u)f[m]=0,p[m]=0;for(const m in d)!d[m].size&&a.attributeData[m]?d[m].size=a.attributeData[m].size:d[m].size||console.warn(`PIXI Geometry attribute '${m}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[m].buffer]+=d[m].size*Pa[d[m].type];for(const m in d){const g=d[m],_=g.size;g.stride===void 0&&(f[g.buffer]===_*Pa[g.type]?g.stride=0:g.stride=f[g.buffer]),g.start===void 0&&(g.start=p[g.buffer],p[g.buffer]+=_*Pa[g.type])}c=s.createVertexArray(),s.bindVertexArray(c);for(let m=0;m<u.length;m++){const g=u[m];o.bind(g),i&&g._glBuffers[n].refCount++}return this.activateVao(t,a),h[a.id]=c,h[l]=c,s.bindVertexArray(null),o.unbind(ze.ARRAY_BUFFER),c}disposeGeometry(t,e){if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,n=t.buffers,o=this.renderer?.buffer;if(t.disposeRunner.remove(this),!!i){if(o)for(let a=0;a<n.length;a++){const l=n[a]._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&o.dispose(n[a],e))}if(!e){for(const a in i)if(a[0]==="g"){const l=i[a];this._activeVao===l&&this.unbind(),s.deleteVertexArray(l)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=this.gl,s=this.CONTEXT_UID,n=this.renderer.buffer,o=t.buffers,a=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let l=null;for(const h in a){const c=a[h],u=o[c.buffer],d=u._glBuffers[s];if(e.attributeData[h]){l!==d&&(n.bind(u),l=d);const f=e.attributeData[h].location;if(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,c.size,c.type||i.FLOAT,c.normalized,c.stride,c.start),c.instance)if(this.hasInstance)i.vertexAttribDivisor(f,c.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,s){const{gl:n}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,l=a===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,l,(i||0)*a,s||1):n.drawElements(t,e||o.indexBuffer.data.length,l,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?n.drawArraysInstanced(t,i,e||o.getSize(),s||1):n.drawArrays(t,i,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}lp.extension={type:$.RendererSystem,name:"geometry"};q.add(lp);const _u=new yt;class hp{constructor(t,e){this._texture=t,this.mapCoord=new yt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],o=t[s+1];e[s]=n*i.a+o*i.c+i.tx,e[s+1]=n*i.b+o*i.d+i.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const i=e._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const s=e.orig,n=e.trim;n&&(_u.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(_u));const o=e.baseTexture,a=this.uClampFrame,l=this.clampMargin/o.resolution,h=this.clampOffset;return a[0]=(e._frame.x+l+h)/o.width,a[1]=(e._frame.y+l+h)/o.height,a[2]=(e._frame.x+e._frame.width-l+h)/o.width,a[3]=(e._frame.y+e._frame.height-l+h)/o.height,this.uClampOffset[0]=h/o.realWidth,this.uClampOffset[1]=h/o.realHeight,this.isSimple=e._frame.width===o.width&&e._frame.height===o.height&&e.rotate===0,!0}}var kv=`varying vec2 vMaskCoord;
|
|
varying vec2 vTextureCoord;
|
|
|
|
uniform sampler2D uSampler;
|
|
uniform sampler2D mask;
|
|
uniform float alpha;
|
|
uniform float npmAlpha;
|
|
uniform vec4 maskClamp;
|
|
|
|
void main(void)
|
|
{
|
|
float clip = step(3.5,
|
|
step(maskClamp.x, vMaskCoord.x) +
|
|
step(maskClamp.y, vMaskCoord.y) +
|
|
step(vMaskCoord.x, maskClamp.z) +
|
|
step(vMaskCoord.y, maskClamp.w));
|
|
|
|
vec4 original = texture2D(uSampler, vTextureCoord);
|
|
vec4 masky = texture2D(mask, vMaskCoord);
|
|
float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
|
|
|
|
original *= (alphaMul * masky.r * alpha * clip);
|
|
|
|
gl_FragColor = original;
|
|
}
|
|
`,Dv=`attribute vec2 aVertexPosition;
|
|
attribute vec2 aTextureCoord;
|
|
|
|
uniform mat3 projectionMatrix;
|
|
uniform mat3 otherMatrix;
|
|
|
|
varying vec2 vMaskCoord;
|
|
varying vec2 vTextureCoord;
|
|
|
|
void main(void)
|
|
{
|
|
gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
|
|
vTextureCoord = aTextureCoord;
|
|
vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;
|
|
}
|
|
`;class Fv extends Lt{constructor(t,e,i){let s=null;typeof t!="string"&&e===void 0&&i===void 0&&(s=t,t=void 0,e=void 0,i=void 0),super(t||Dv,e||kv,i),this.maskSprite=s,this.maskMatrix=new yt}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,s){const n=this._maskSprite,o=n._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new hp(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,t.applyFilter(this,e,i,s))}}class Ov{constructor(t=null){this.type=Ct.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Lt.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=Ct.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class cp{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let i=e;if(!i.isMaskData){const n=this.maskDataPool.pop()||new Ov;n.pooled=!0,n.maskObject=e,i=n}const s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(s),i._colorMask=s?s._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==Ct.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case Ct.SCISSOR:this.renderer.scissor.push(i);break;case Ct.STENCIL:this.renderer.stencil.push(i);break;case Ct.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case Ct.COLOR:this.pushColorMask(i);break}i.type===Ct.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case Ct.SCISSOR:this.renderer.scissor.pop(e);break;case Ct.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case Ct.SPRITE:this.popSpriteMask(e);break;case Ct.COLOR:this.popColorMask(e);break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===Ct.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=Ct.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=Ct.SCISSOR:t.type=Ct.STENCIL:t.type=Ct.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let s=t._filters;s||(s=this.alphaMaskPool[this.alphaMaskIndex],s||(s=this.alphaMaskPool[this.alphaMaskIndex]=[new Fv])),s[0].resolution=t.resolution,s[0].multisample=t.multisample,s[0].maskSprite=e;const n=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,s),i.filterArea=n,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}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;s<i;s++){const n=t.getActiveAttrib(r,s);if(n.name.startsWith("gl_"))continue;const o=tp(t,n.type),a={type:o,name:n.name,size:Qf(o),location:t.getAttribLocation(r,n.name)};e[n.name]=a}return e}function Hv(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let s=0;s<i;s++){const n=t.getActiveUniform(r,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=tp(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:Kf(l,n.size)}}return e}function zv(r,t){const e=hu(r,r.VERTEX_SHADER,t.vertexSrc),i=hu(r,r.FRAGMENT_SHADER,t.fragmentSrc),s=r.createProgram();r.attachShader(s,e),r.attachShader(s,i);const n=t.extra?.transformFeedbackVaryings;if(n&&(typeof r.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||gv(r,s,e,i),t.attributeData=Gv(s,r),t.uniformData=Hv(s,r),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const a=Object.keys(t.attributeData);a.sort((l,h)=>l>h?1:-1);for(let l=0;l<a.length;l++)t.attributeData[a[l]].location=l,r.bindAttribLocation(s,l,a[l]);r.linkProgram(s)}r.deleteShader(e),r.deleteShader(i);const o={};for(const a in t.uniformData){const l=t.uniformData[a];o[a]={location:r.getUniformLocation(s,a),value:Kf(l.type,l.size)}}return new Uv(s,o)}function $v(r,t,e,i,s){e.buffer.update(s)}const Xv={float:`
|
|
data[offset] = v;
|
|
`,vec2:`
|
|
data[offset] = v[0];
|
|
data[offset+1] = v[1];
|
|
`,vec3:`
|
|
data[offset] = v[0];
|
|
data[offset+1] = v[1];
|
|
data[offset+2] = v[2];
|
|
|
|
`,vec4:`
|
|
data[offset] = v[0];
|
|
data[offset+1] = v[1];
|
|
data[offset+2] = v[2];
|
|
data[offset+3] = v[3];
|
|
`,mat2:`
|
|
data[offset] = v[0];
|
|
data[offset+1] = v[1];
|
|
|
|
data[offset+4] = v[2];
|
|
data[offset+5] = v[3];
|
|
`,mat3:`
|
|
data[offset] = v[0];
|
|
data[offset+1] = v[1];
|
|
data[offset+2] = v[2];
|
|
|
|
data[offset + 4] = v[3];
|
|
data[offset + 5] = v[4];
|
|
data[offset + 6] = v[5];
|
|
|
|
data[offset + 8] = v[6];
|
|
data[offset + 9] = v[7];
|
|
data[offset + 10] = v[8];
|
|
`,mat4:`
|
|
for(var i = 0; i < 16; i++)
|
|
{
|
|
data[offset + i] = v[i];
|
|
}
|
|
`},yp={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:16*2,mat3:16*3,mat4:16*4};function Vv(r){const t=r.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,i=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(e=yp[o.data.type],o.data.size>1&&(e=Math.max(e,16)*o.data.size),o.dataLen=e,i%e!==0&&i<16){const a=i%e%16;i+=a,s+=a}i+e>16?(s=Math.ceil(s/16)*16,o.offset=s,s+=e,i=e):(o.offset=s,i+=e,s+=e)}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}function 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;o<i.length;o++){const a=i[o],l=r.uniforms[a.data.name],h=a.data.name;let c=!1;for(let u=0;u<zr.length;u++){const d=zr[u];if(d.codeUbo&&d.test(a.data,l)){n.push(`offset = ${a.offset/4};`,zr[u].codeUbo(a.data.name,l)),c=!0;break}}if(!c)if(a.data.size>1){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<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(ql.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(ql.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const e=this.blendModes[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};bp.extension={type:$.RendererSystem,name:"state"};let ib=bp;q.add(ib);class rb extends Fs{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(s=>t.systems[s]),i=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(const s of i)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new 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;s<e.length;s++){const n=e[s];n.resource&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[s]=null,i=!0)}if(i){let s=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[s++]=e[n]);e.length=s}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};_s.defaultMode=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<e;s++)this.boundTextures[s]=null;this.emptyTextures={};const i=new Ma(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Ma(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){const{gl:i}=this;if(t=t?.castToBaseTexture(),t?.valid&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[s].samplerType!==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<t.buffers.length;o++){const a=t.buffers[o];a&&(i.buffer.update(a),a._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&n.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}wp.extension={type:$.RendererSystem,name:"transformFeedback"};q.add(wp);class oo{constructor(t){this.renderer=t}init(t){this.screen=new it(0,0,t.width,t.height),this.element=t.view||j.ADAPTER.createCanvas(),this.resolution=t.resolution||j.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const i=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",i,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){t&&this.element.parentNode?.removeChild(this.element),this.renderer=null,this.element=null,this.screen=null}}oo.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},oo.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"_view"};q.add(oo);j.PREFER_ENV=fr.WEBGL2;j.STRICT_TEXTURE_CACHE=!1;j.RENDER_OPTIONS={...so.defaultOptions,...ro.defaultOptions,...oo.defaultOptions,...no.defaultOptions};Object.defineProperties(j,{WRAP_MODE:{get(){return rt.defaultOptions.wrapMode},set(r){nt("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),rt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return rt.defaultOptions.scaleMode},set(r){nt("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),rt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return rt.defaultOptions.mipmap},set(r){nt("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),rt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return rt.defaultOptions.anisotropicLevel},set(r){nt("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),rt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return nt("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Lt.defaultResolution},set(r){Lt.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return nt("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Lt.defaultMultisample},set(r){Lt.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return Ki.defaultMaxTextures},set(r){nt("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Ki.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return Ki.defaultBatchSize},set(r){nt("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Ki.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return Ki.canUploadSameBuffer},set(r){nt("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Ki.canUploadSameBuffer=r}},GC_MODE:{get(){return Ji.defaultMode},set(r){nt("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Ji.defaultMode=r}},GC_MAX_IDLE:{get(){return Ji.defaultMaxIdle},set(r){nt("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Ji.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return Ji.defaultCheckCountMax},set(r){nt("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Ji.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return ri.defaultVertexPrecision},set(r){nt("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),ri.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return ri.defaultFragmentPrecision},set(r){nt("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),ri.defaultFragmentPrecision=r}}});var ur=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(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._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Qt.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,Qt.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!Qt._shared){const t=Qt._shared=new Qt;t.autoStart=!0,t._protected=!0}return Qt._shared}static get system(){if(!Qt._system){const t=Qt._system=new Qt;t.autoStart=!0,t._protected=!0}return Qt._system}};Tp.targetFPMS=.06;let se=Tp;Object.defineProperties(j,{TARGET_FPMS:{get(){return se.targetFPMS},set(r){nt("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),se.targetFPMS=r}}});class Ep{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,ur.LOW)},get(){return this._ticker}}),this.stop=()=>{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;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new cb(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Ip.extension={type:$.RendererSystem,name:"buffer"};q.add(Ip);class Rp{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let s,n,o,a;if(e&&(s=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(s||(this.lastObjectRendered=t),!a){const l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(s),i.batch.currentRenderer.start(),(n??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),s&&(e.blit&&i.framebuffer.blit(),s.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Rp.extension={type:$.RendererSystem,name:"objectRenderer"};q.add(Rp);const Cn=class Zl extends rb{constructor(t){super(),this.type=vf.WEBGL,t=Object.assign({},j.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new Ce({projectionMatrix:new yt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Zl.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(e),"useContextAlpha"in t&&(nt("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=Zl.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t?.forceCanvas?!1:ky()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return nt("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return nt("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return nt("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return nt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){nt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return nt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){nt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return nt("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};Cn.extension={type:$.Renderer,priority:1},Cn.__plugins={},Cn.__systems={};let Lh=Cn;q.handleByMap($.RendererPlugin,Lh.__plugins);q.handleByMap($.RendererSystem,Lh.__systems);q.add(Lh);class Pp extends ks{constructor(t,e){const{width:i,height:s}=e||{};super(i,s),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const o=new rt;this.items.push(o),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof ks?this.addResourceAt(t[i],i):this.addResourceAt(Yf(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{const{realWidth:e,realHeight:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}}class 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;l<s;l++){const h=o[l];n[l]<h.dirtyId&&(n[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,e.format,i.type,h.resource.source))}return!0}}class db extends Mi{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Mp=class ms extends Pp{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==ms.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<ms.SIDES;a++)this.items[a].target=Lr.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,t&&this.initFromArray(t,e),n!==!1&&this.load()}bind(t){super.bind(t),t.target=Lr.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=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<ms.SIDES;n++){const o=this.items[n];(s[n]<o.dirtyId||i.dirtyId<e.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(t,o,i),s[n]=o.dirtyId):s[n]<-1&&(t.gl.texImage2D(o.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),s[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===ms.SIDES}};Mp.SIDES=6;let fb=Mp;class Nr extends Mi{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=Nr.EMPTY,s=t,n=!0):(i=t,s=null,n=!1),super(i),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??n,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const i=await 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*\<svg/m,Kl.SVG_SIZE=/<svg[^>]*(?:\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<t.length;++n){const o=document.createElement("source");let{src:a,mime:l}=t[n];if(a=a||t[n],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),c=h.slice(h.lastIndexOf(".")+1);l=l||th.MIME_TYPES[c]||`video/${c}`}o.src=a,l&&(o.type=l),i.appendChild(o)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const e=se.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(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=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[2],a=t[3],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[4],a=t[5],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[6],a=t[7],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,this.minX=e,this.minY=i,this.maxX=s,this.maxY=n}addFrame(t,e,i,s,n){this.addFrameMatrix(t.worldTransform,e,i,s,n)}addFrameMatrix(t,e,i,s,n){const o=t.a,a=t.b,l=t.c,h=t.d,c=t.tx,u=t.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,g=o*e+l*i+c,_=a*e+h*i+u;d=g<d?g:d,f=_<f?_:f,p=g>p?g:p,m=_>m?_:m,g=o*s+l*i+c,_=a*s+h*i+u,d=g<d?g:d,f=_<f?_:f,p=g>p?g:p,m=_>m?_:m,g=o*e+l*n+c,_=a*e+h*n+u,d=g<d?g:d,f=_<f?_:f,p=g>p?g:p,m=_>m?_:m,g=o*s+l*n+c,_=a*s+h*n+u,d=g<d?g:d,f=_<f?_:f,p=g>p?g:p,m=_>m?_:m,this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}addVertexData(t,e,i){let s=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let l=e;l<i;l+=2){const h=t[l],c=t[l+1];s=h<s?h:s,n=c<n?c:n,o=h>o?h:o,a=c>a?c:a}this.minX=s,this.minY=n,this.maxX=o,this.maxY=a}addVertices(t,e,i,s){this.addVerticesMatrix(t.worldTransform,e,i,s)}addVerticesMatrix(t,e,i,s,n=0,o=n){const a=t.a,l=t.b,h=t.c,c=t.d,u=t.tx,d=t.ty;let f=this.minX,p=this.minY,m=this.maxX,g=this.maxY;for(let _=i;_<s;_+=2){const v=e[_],y=e[_+1],b=a*v+h*y+u,x=c*y+l*v+d;f=Math.min(f,b-n),m=Math.max(m,b+n),p=Math.min(p,x-o),g=Math.max(g,x+o)}this.minX=f,this.minY=p,this.maxX=m,this.maxY=g}addBounds(t){const e=this.minX,i=this.minY,s=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>s?t.maxX:s,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,s=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>c?o:c}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const i=t.minX>e.x?t.minX:e.x,s=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,o=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>c?o:c}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,s,n,o){t-=n,e-=o,i+=n,s+=o,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>s?this.maxY:s}}class wt extends 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;i<e.length;++i){const s=e[i];Object.defineProperty(wt.prototype,s,Object.getOwnPropertyDescriptor(t,s))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new it),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new it),t=this._localBoundsRect),this._localBounds||(this._localBounds=new ao);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=i?.worldAlpha??1,this.transform=this._tempDisplayObjectParent.transform;const s=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=s,this._bounds.updateID+=this._boundsID-n,o}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,s){return e&&(t=e.toGlobal(t,i,s)),s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){this.parent?.removeChild(this)}setTransform(t=0,e=0,i=1,s=1,n=0,o=0,a=0,l=0,h=0){return this.position.x=t,this.position.y=e,this.scale.x=i||1,this.scale.y=s||1,this.rotation=n,this.skew.x=o,this.skew.y=a,this.pivot.x=l,this.pivot.y=h,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new pb),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*av}set angle(t){this.transform.rotation=t*lv}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex=t,this.parent&&(this.parent.sortDirty=!0)}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount--,e._maskRefCount===0&&(e.renderable=!0,e.isMask=!1))}if(this._mask=t,this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount===0&&(e.renderable=!1,e.isMask=!0),e._maskRefCount++)}}}}class pb extends wt{constructor(){super(...arguments),this.sortDirty=null}}wt.prototype.displayObjectUpdateTransform=wt.prototype.updateTransform;const _b=new yt;function mb(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const kp=class eh extends wt{constructor(){super(),this.children=[],this.sortableChildren=eh.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),s=this.getChildIndex(e);this.children[i]=e,this.children[s]=t,this.onChildrenChange(i<s?i:s)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);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;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],i=this.children.indexOf(e);if(i===-1)return null;e.parent=null,e.transform._parentID=-1,Hr(this.children,i,1),this._boundsID++,this.onChildrenChange(i),e.emit("removed",this),this.emit("childRemoved",e,this,i)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,Hr(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const i=t,s=e,n=s-i;let o;if(n>0&&n<=s){o=this.children.splice(i,n);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let a=0;a<o.length;++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,i=this.children.length;e<i;++e){const s=this.children[e];s._lastSortedIndex=e,!t&&s.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(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;t<e;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const i=e._mask.isMaskData?e._mask.maskObject:e._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(e._bounds,i._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const i=super.getLocalBounds(t);if(!e)for(let s=0,n=this.children.length;s<n;++s){const o=this.children[s];o.visible&&o.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,s;this.cullArea?(i=this.cullArea,s=this.worldTransform):this._render!==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<a;++o){const l=this.children[o],h=l.cullable;l.cullable=h||!this.cullArea,l.render(t),l.cullable=h}}render(t){if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||this.filters?.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let e=0,i=this.children.length;e<i;++e)this.children[e].render(t)}}renderAdvanced(t){const e=this.filters,i=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let n=0;n<e.length;n++)e[n].enabled&&this._enabledFilters.push(e[n])}const s=e&&this._enabledFilters?.length||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==Ct.NONE));if(s&&t.batch.flush(),e&&this._enabledFilters?.length&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let n=0,o=this.children.length;n<o;++n)this.children[n].render(t)}s&&t.batch.flush(),i&&t.mask.pop(this),e&&this._enabledFilters?.length&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t?.children,i=this.removeChildren(0,this.children.length);if(e)for(let s=0;s<i.length;++s)i[s].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}};kp.defaultSortableChildren=!1;let Ut=kp;Ut.prototype.containerUpdateTransform=Ut.prototype.updateTransform;Object.defineProperties(j,{SORTABLE_CHILDREN:{get(){return Ut.defaultSortableChildren},set(r){nt("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),Ut.defaultSortableChildren=r}}});const cs=new ht,gb=new Uint16Array([0,1,2,0,2,3]);class Xt extends Ut{constructor(t){super(),this._anchor=new ii(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new dt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=Q.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||Y.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=gb,this.pluginName="batch",this.isSprite=!0,this._roundPixels=j.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=Ti(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=Ti(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this.vertexData,c=t.trim,u=t.orig,d=this._anchor;let f=0,p=0,m=0,g=0;if(c?(p=c.x-d._x*u.width,f=p+c.width,g=c.y-d._y*u.height,m=g+c.height):(p=-d._x*u.width,f=p+u.width,g=-d._y*u.height,m=g+u.height),h[0]=i*p+n*g+a,h[1]=o*g+s*p+l,h[2]=i*f+n*g+a,h[3]=o*g+s*f+l,h[4]=i*f+n*m+a,h[5]=o*m+s*f+l,h[6]=i*p+n*m+a,h[7]=o*m+s*p+l,this._roundPixels){const _=j.RESOLUTION;for(let v=0;v<h.length;++v)h[v]=Math.round(h[v]*_)/_}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,i=t.orig,s=this._anchor,n=this.transform.worldTransform,o=n.a,a=n.b,l=n.c,h=n.d,c=n.tx,u=n.ty,d=-s._x*i.width,f=d+i.width,p=-s._y*i.height,m=p+i.height;if(e[0]=o*d+l*p+c,e[1]=h*p+a*d+u,e[2]=o*f+l*p+c,e[3]=h*p+a*f+u,e[4]=o*f+l*m+c,e[5]=h*m+a*f+u,e[6]=o*d+l*m+c,e[7]=h*m+a*d+u,this._roundPixels){const g=j.RESOLUTION;for(let _=0;_<e.length;++_)e[_]=Math.round(e[_]*g)/g}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new ao),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new it),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,cs);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return cs.x>=s&&cs.x<s+e&&(n=-i*this.anchor.y,cs.y>=n&&cs.y<n+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t?.texture){const e=typeof t=="boolean"?t:t?.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const i=t instanceof Y?t:Y.from(t,e);return new Xt(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=Ti(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=Ti(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||Y.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Dp=new yt;wt.prototype._cacheAsBitmap=!1;wt.prototype._cacheData=null;wt.prototype._cacheAsBitmapResolution=null;wt.prototype._cacheAsBitmapMultisample=null;class yb{constructor(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}Object.defineProperties(wt.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(r){r!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=r,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(r){r!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=r,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(r){if(this._cacheAsBitmap===r)return;this._cacheAsBitmap=r;let t;r?(this._cacheData||(this._cacheData=new yb),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}});wt.prototype._renderCached=function(r){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(r),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(r))};wt.prototype._initCachedDisplayObject=function(r){if(this._cacheData?.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new it,!0);if(this.filters?.length){const d=this.filters[0].padding;e.pad(d)}const i=this.cacheAsBitmapResolution||r.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const s=r.renderTexture.current,n=r.renderTexture.sourceFrame.clone(),o=r.renderTexture.destinationFrame.clone(),a=r.projection.transform,l=Gt.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${cr()}`;this._cacheData.textureCacheId=h,rt.addToCache(l.baseTexture,h),Y.addToCache(l,h);const c=this.transform.localTransform.copyTo(Dp).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:l,clear:!0,transform:c,skipUpdateTransform:!1}),r.framebuffer.blit(),r.projection.transform=a,r.renderTexture.bind(s,n,o),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const u=new Xt(l);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(e.x/e.width),u.anchor.y=-(e.y/e.height),u.alpha=t,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=u.containsPoint.bind(u)};wt.prototype._renderCachedCanvas=function(r){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(r),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(r))};wt.prototype._initCachedDisplayObjectCanvas=function(r){if(this._cacheData?.sprite)return;const t=this.getLocalBounds(new it,!0),e=this.alpha;this.alpha=1;const i=r.canvasContext.activeContext,s=r._projTransform,n=this.cacheAsBitmapResolution||r.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const o=Gt.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${cr()}`;this._cacheData.textureCacheId=a,rt.addToCache(o.baseTexture,a),Y.addToCache(o,a);const l=Dp;this.transform.localTransform.copyTo(l),l.invert(),l.tx-=t.x,l.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,{renderTexture:o,clear:!0,transform:l,skipUpdateTransform:!1}),r.canvasContext.activeContext=i,r._projTransform=s,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=e;const h=new Xt(o);h.transform.worldTransform=this.transform.worldTransform,h.anchor.x=-(t.x/t.width),h.anchor.y=-(t.y/t.height),h.alpha=e,h._bounds=this._bounds,this._cacheData.sprite=h,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=r._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=h.containsPoint.bind(h)};wt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID};wt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)};wt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,rt.removeFromCache(this._cacheData.textureCacheId),Y.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null};wt.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)};wt.prototype.name=null;Ut.prototype.getChildByName=function(r,t){for(let e=0,i=this.children.length;e<i;e++)if(this.children[e].name===r)return this.children[e];if(t)for(let e=0,i=this.children.length;e<i;e++){const s=this.children[e];if(!s.getChildByName)continue;const n=s.getChildByName(r,!0);if(n)return n}return null};wt.prototype.getGlobalPosition=function(r=new ht,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var vb=`varying vec2 vTextureCoord;
|
|
|
|
uniform sampler2D uSampler;
|
|
uniform float uAlpha;
|
|
|
|
void main(void)
|
|
{
|
|
gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
|
|
}
|
|
`;class bb extends Lt{constructor(t=1){super(hb,vb,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const xb={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},wb=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
|
|
`);function Tb(r){const t=xb[r],e=t.length;let i=wb,s="";const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<r;a++){let l=n.replace("%index%",a.toString());o=a,a>=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),s+=l,s+=`
|
|
`}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<r;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),s+=a,s+=`
|
|
`}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}class ih extends Lt{constructor(t,e=8,i=4,s=Lt.defaultResolution,n=5){const o=Ab(n,t),a=Tb(n);super(o,a),this.horizontal=t,this.resolution=s,this._quality=0,this.quality=i,this.blur=e}apply(t,e,i,s){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/e.width):this.uniforms.strength=1/i.height*(i.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,i,s);else{const n=t.getFilterTexture(),o=t.renderer;let a=e,l=n;this.state.blend=!1,t.applyFilter(this,a,l,Ne.CLEAR);for(let h=1;h<this.passes-1;h++){t.bindAndClear(a,Ne.BLIT),this.uniforms.uSampler=l;const c=l;l=a,a=c,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,l,i,s),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class Sb extends Lt{constructor(t=8,e=4,i=Lt.defaultResolution,s=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new ih(!0,t,e,i,s),this.blurYFilter=new ih(!1,t,e,i,s),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,s){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=t.getFilterTexture();this.blurXFilter.apply(t,e,a,Ne.CLEAR),this.blurYFilter.apply(t,a,i,s),t.returnFilterTexture(a)}else o?this.blurYFilter.apply(t,e,i,s):this.blurXFilter.apply(t,e,i,s)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var Cb=`varying vec2 vTextureCoord;
|
|
uniform sampler2D uSampler;
|
|
uniform float m[20];
|
|
uniform float uAlpha;
|
|
|
|
void main(void)
|
|
{
|
|
vec4 c = texture2D(uSampler, vTextureCoord);
|
|
|
|
if (uAlpha == 0.0) {
|
|
gl_FragColor = c;
|
|
return;
|
|
}
|
|
|
|
// Un-premultiply alpha before applying the color matrix. See issue #3539.
|
|
if (c.a > 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._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const xi=new Ob;class Ns{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Ns.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ht,this.page=new ht,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class lo extends Ns{constructor(){super(...arguments),this.client=new ht,this.movement=new ht,this.offset=new ht,this.global=new ht,this.screen=new ht}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,s,n,o,a,l,h,c,u,d,f,p,m){throw new Error("Method not implemented.")}}class Ee extends lo{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class $r extends lo{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}$r.DOM_DELTA_PIXEL=0,$r.DOM_DELTA_LINE=1,$r.DOM_DELTA_PAGE=2;const Nb=2048,Lb=new ht,ka=new ht;class Ub{constructor(t){this.dispatch=new Fs,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,s)=>i.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.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<s;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){xi.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,Lb.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let s=i.length-2;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)s.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<Nb&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,s,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(xi.pauseUpdate=!1),t.interactiveChildren&&t.children){const c=t.children;for(let u=c.length-1;u>=0;u--){const d=c[u],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,s,n,o||n(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const l=this._isInteractive(e),h=t.isInteractive();return l&&h&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,i)&&s(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(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<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const s=this.allocateEvent(Ee);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=i??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent($r);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(Ee);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Ee&&e instanceof Ee&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof lo&&e instanceof lo&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}const Gb=1,Hb={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},sh=class nh{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Ub(null),xi.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new Ee(null),this.rootWheelEvent=new $r(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...nh.defaultEventFeatures},{set:(e,i,s)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[i]=s,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{view:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,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;i<s;i++){const n=e[i],o=this.bootstrapEvent(this.rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,xi.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",s=this.normalizeToPointerData(t);for(let n=0,o=s.length;n<o;n++){const a=this.bootstrapEvent(this.rootPointerEvent,s[n]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,xi.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;xi.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;xi.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,e,i){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(i-s.top)*(this.domElement.height/s.height)*n}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const n=t.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=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<e.length;i++)this.updateAccessibleObjects(e[i])}update(){const t=performance.now();if(ei.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:i,width:s,height:n}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:l}=this.renderer,h=s/o*l,c=n/a*l;let u=this.div;u.style.left=`${e}px`,u.style.top=`${i}px`,u.style.width=`${o}px`,u.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const f=this.children[d];if(f.renderId!==this.renderId)f._accessibleActive=!1,Hr(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{u=f._accessibleDiv;let p=f.hitArea;const m=f.worldTransform;f.hitArea?(u.style.left=`${(m.tx+p.x*m.a)*h}px`,u.style.top=`${(m.ty+p.y*m.d)*c}px`,u.style.width=`${p.width*m.a*h}px`,u.style.height=`${p.height*m.d*c}px`):(p=f.getBounds(),this.capHitArea(p),u.style.left=`${p.x*h}px`,u.style.top=`${p.y*c}px`,u.style.width=`${p.width*h}px`,u.style.height=`${p.height*c}px`,u.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(u.title=f.accessibleTitle),u.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&u.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==u.title||f.tabIndex!==u.tabIndex)&&(u.title=f.accessibleTitle,u.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(u))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${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<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}function is(r,t){if(Array.isArray(t)){for(const e of t)if(r.startsWith(`data:${e}`))return!0;return!1}return r.startsWith(`data:${t}`)}function Ui(r,t){const e=r.split("?")[0],i=It.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const Ae=(r,t,e=!1)=>(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<n.length;o++){const a=n[o];e<t.length-1?Up(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function Kb(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const s=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),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<this.parsers.length;a++){const l=this.parsers[a];if(l.test(e)){s=l.getCacheableAssets(i,e);break}}s||(s={},i.forEach(a=>{s[a]=e}));const n=Object.keys(s),o={cacheKeys:n,keys:i};if(i.forEach(a=>{this._cacheMap.set(a,o)}),n.forEach(a=>{this._cache.has(a)&&this._cache.get(a)!==e&&console.warn("[Cache] already has key:",a),this._cache.set(a,s[a])}),e instanceof Y){const a=e;i.forEach(l=>{a.baseTexture!==Y.EMPTY.baseTexture&&rt.addToCache(a.baseTexture,l),Y.addToCache(a,l)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const 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<this.parsers.length;o++){const a=this.parsers[o];if(a.load&&a.test?.(t,e,this)){n=a;break}}if(!n)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(t,e,this),i.parser=n;for(let o=0;o<this.parsers.length;o++){const a=this.parsers[o];a.parse&&a.parse&&await a.testParse?.(s,e,this)&&(s=await a.parse(s,e,this)||s,i.parser=a)}return s})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const s={},n=ho(t),o=Ae(t,h=>({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;a<n.length;a++){const l=n[a],h=new FontFace(s,`url(${dx(r)})`,{...o,weight:l});await h.load(),e.add(h),i.push(h)}return i.length===1?i[0]:i}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(r){(Array.isArray(r)?r:[r]).forEach(t=>j.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<Da&&(Fa||(Fa=URL.createObjectURL(new Blob([mx.code],{type:"application/javascript"}))),this._createdWorkers++,t=new Worker(Fa),t.addEventListener("message",e=>{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((s,n)=>{this.queue.push({id:t,arguments:e,resolve:s,reject:n})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),i=e.id;this.resolveHash[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._parsers.length;b++){const x=this._parsers[b];if(x.test(v)){y=x.parse(v);break}}}else u=v.data??u,d=v.format??d,f=v.loadParser??f,y={...y,...v};if(!m)throw new Error(`[Resolver] alias is undefined for this asset: ${y.src}`);y=this.buildResolvedAsset(y,{aliases:m,data:u,format:d,loadParser:f}),g.push(y)})}),m.forEach(_=>{this._assetMap[_]=g})})}resolveBundle(t){const e=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;e<t.length;e++){const i=t[0],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}buildResolvedAsset(t,e){const{aliases:i,data:s,loadParser:n,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=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<t.length;i++)e[i]=tr.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=Object.values(t),s=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const o={};return i.forEach((a,l)=>{const h=n[a.src],c=[a.src];a.alias&&c.push(...a.alias),o[s[l]]=h,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<o;n++){const{levelID:a,levelWidth:l,levelHeight:h,levelBuffer:c}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,a,this.format,l,h,0,c)}return!0}onBlobLoaded(){this._levelBuffers=lr._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t>=36196)return"etc1";if(t>=35986&&t<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")}static _createLevelBuffers(t,e,i,s,n,o,a){const l=new Array(i);let h=t.byteOffset,c=o,u=a,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*co[e];for(let m=0;m<i;m++)l[m]={levelID:m,levelWidth:i>1?c:d,levelHeight:i>1?u:f,levelBuffer:new Uint8Array(t.buffer,h,p)},h+=p,c=c>>1||1,u=u>>1||1,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*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<n;w++){const T=Math.max(1,b+3&-4),I=Math.max(1,x+3&-4),B=T*I*v;y+=B,b=b>>>1,x=x>>>1}let S=_;for(let w=0;w<p;w++)g.push(new Uint8Array(r,S,y)),S+=y}return g.map(v=>new 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;E<f;E++){const C=i.getUint32(M,s);let G=M+4;for(let X=0;X<u;X++){let N=y[X];N||(N=y[X]=new Array(f)),N[E]={levelID:E,levelWidth:f>1||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;e<Ru.length;e++)if(t.getUint8(e)!==Ru[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function lw(r){switch(r){case O.RGBA:return O.RGBA_INTEGER;case O.RGB:return O.RGB_INTEGER;case O.RG:return O.RG_INTEGER;case O.RED:return O.RED_INTEGER;default:return r}}function hw(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(hh+s,e),o=hh+s+4,a=3-(n+3)%4;if(n===0||n>t-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<n&&r.getUint8(o+l)!==0;l++);if(l===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const h=new TextDecoder().decode(new Uint8Array(r.buffer,o,l)),c=new DataView(r.buffer,o+l+1,n-l-1);i.set(h,c),s+=4+n+a}return i}const cw={extension:{type:$.LoadParser,priority:Ie.High},name:"loadDDS",test(r){return Ui(r,".dds")},async load(r,t,e){const i=await(await j.ADAPTER.fetch(r)).arrayBuffer(),s=iw(i).map(n=>{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<n;a++){const l=a*s,h=(i-a-1)*s;o.set(t.subarray(l,l+s)),t.copyWithin(l,h,h+s),t.set(o,h)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let i=0;i<e;i+=4){const s=t[i+3];if(s!==0){const n=255.001/s;t[i]=t[i]*n+.5,t[i+1]=t[i+1]*n+.5,t[i+2]=t[i+2]*n+.5}}}};Hp.extension={name:"extract",type:$.RendererSystem};let pw=Hp;q.add(pw);const uo={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===kt.CIRC){const p=r.shape;e=p.x,i=p.y,o=a=p.radius,s=n=0}else if(r.type===kt.ELIP){const p=r.shape;e=p.x,i=p.y,o=p.width,a=p.height,s=n=0}else{const p=r.shape,m=p.width/2,g=p.height/2;e=p.x+m,i=p.y+g,o=a=Math.max(0,Math.min(p.radius,Math.min(m,g))),s=m-o,n=g-a}if(!(o>=0&&a>=0&&s>=0&&n>=0)){t.length=0;return}const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(s?4:0)+(n?4:0);if(t.length=h,h===0)return;if(l===0){t.length=8,t[0]=t[6]=e+s,t[1]=t[3]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n;return}let c=0,u=l*4+(s?2:0)+2,d=u,f=h;{const p=s+o,m=n,g=e+p,_=e-p,v=i+m;if(t[c++]=g,t[c++]=v,t[--u]=v,t[--u]=_,n){const y=i-m;t[d++]=_,t[d++]=y,t[--f]=y,t[--f]=g}}for(let p=1;p<l;p++){const m=Math.PI/2*(p/l),g=s+Math.cos(m)*o,_=n+Math.sin(m)*a,v=e+g,y=e-g,b=i+_,x=i-_;t[c++]=v,t[c++]=b,t[--u]=b,t[--u]=y,t[d++]=y,t[d++]=x,t[--f]=x,t[--f]=v}{const p=s,m=n+a,g=e+p,_=e-p,v=i+m,y=i-m;t[c++]=g,t[c++]=v,t[--f]=y,t[--f]=g,s&&(t[c++]=_,t[c++]=v,t[--f]=y,t[--f]=_)}},triangulate(r,t){const e=r.points,i=t.points,s=t.indices;if(e.length===0)return;let n=i.length/2;const o=n;let a,l;if(r.type!==kt.RREC){const c=r.shape;a=c.x,l=c.y}else{const c=r.shape;a=c.x+c.width/2,l=c.y+c.height/2}const h=r.matrix;i.push(r.matrix?h.a*a+h.c*l+h.tx:a,r.matrix?h.b*a+h.d*l+h.ty:l),n++,i.push(e[0],e[1]);for(let c=2;c<e.length;c+=2)i.push(e[c],e[c+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function Mu(r,t=!1){const e=r.length;if(e<6)return;let i=0;for(let s=0,n=r[e-2],o=r[e-1];s<e;s+=2){const a=r[s],l=r[s+1];i+=(a-n)*(l+o),n=a,o=l}if(!t&&i>0||t&&i<=0){const s=e/2;for(let n=s+s%2;n<e;n+=2){const o=e-n-2,a=e-n-1,l=n,h=n+1;[r[o],r[l]]=[r[l],r[o]],[r[a],r[h]]=[r[h],r[a]]}}}const zp={build(r){r.points=r.shape.points.slice()},triangulate(r,t){let e=r.points;const i=r.holes,s=t.points,n=t.indices;if(e.length>=6){Mu(e,!1);const o=[];for(let h=0;h<i.length;h++){const c=i[h];Mu(c.points,!0),o.push(e.length/2),e=e.concat(c.points)}const a=d0(e,o,2);if(!a)return;const l=s.length/2;for(let h=0;h<a.length;h+=3)n.push(a[h]+l),n.push(a[h+1]+l),n.push(a[h+2]+l);for(let h=0;h<e.length;h++)s.push(e[h])}}},_w={build(r){const t=r.shape,e=t.x,i=t.y,s=t.width,n=t.height,o=r.points;o.length=0,s>=0&&n>=0&&o.push(e,i,e+s,i,e+s,i+n,e,i+n)},triangulate(r,t){const e=r.points,i=t.points;if(e.length===0)return;const s=i.length/2;i.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},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 e<this.minSegments?e=this.minSegments:e>this.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&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),m=Math.sqrt(l*l+h*h),g=(15*p*Math.sqrt(m)/Math.PI>>0)+1,_=f/g;if(d+=_,a){o.push(r,t,e,i);for(let v=1,y=d;v<g;v++,y+=_)o.push(r,t,r+Math.sin(y)*m,t+Math.cos(y)*m);o.push(r,t,s,n)}else{o.push(e,i,r,t);for(let v=1,y=d;v<g;v++,y+=_)o.push(r+Math.sin(y)*m,t+Math.cos(y)*m,r,t);o.push(s,n,r,t)}return g*2}function yw(r,t){const e=r.shape;let i=r.points||e.points.slice();const s=t.closePointEps;if(i.length===0)return;const n=r.lineStyle,o=new ht(i[0],i[1]),a=new ht(i[i.length-2],i[i.length-1]),l=e.type!==kt.POLY||e.closeStroke,h=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;if(l){i=i.slice(),h&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const N=(o.x+a.x)*.5,J=(a.y+o.y)*.5;i.unshift(N,J),i.push(N,J)}const c=t.points,u=i.length/2;let d=i.length;const f=c.length/2,p=n.width/2,m=p*p,g=n.miterLimit*n.miterLimit;let _=i[0],v=i[1],y=i[2],b=i[3],x=0,S=0,w=-(v-b),T=_-y,I=0,B=0,P=Math.sqrt(w*w+T*T);w/=P,T/=P,w*=p,T*=p;const M=n.alignment,E=(1-M)*2,C=M*2;l||(n.cap===Ei.ROUND?d+=$i(_-w*(E-C)*.5,v-T*(E-C)*.5,_-w*E,v-T*E,_+w*C,v+T*C,c,!0)+2:n.cap===Ei.SQUARE&&(d+=ku(_,v,w,T,E,C,!0,c))),c.push(_-w*E,v-T*E,_+w*C,v+T*C);for(let N=1;N<u-1;++N){_=i[(N-1)*2],v=i[(N-1)*2+1],y=i[N*2],b=i[N*2+1],x=i[(N+1)*2],S=i[(N+1)*2+1],w=-(v-b),T=_-y,P=Math.sqrt(w*w+T*T),w/=P,T/=P,w*=p,T*=p,I=-(b-S),B=y-x,P=Math.sqrt(I*I+B*B),I/=P,B/=P,I*=p,B*=p;const J=y-_,H=v-b,A=y-x,L=S-b,V=J*A+H*L,D=H*A-L*J,R=D<0;if(Math.abs(D)<.001*Math.abs(V)){c.push(y-w*E,b-T*E,y+w*C,b+T*C),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;N<d+f-2;++N)_=c[N*2],v=c[N*2+1],y=c[(N+1)*2],b=c[(N+1)*2+1],x=c[(N+2)*2],S=c[(N+2)*2+1],!(Math.abs(_*(b-S)+y*(S-v)+x*(v-b))<X)&&G.push(N,N+1,N+2)}function vw(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==kt.POLY||i.closeStroke;if(s.length===0)return;const o=t.points,a=t.indices,l=s.length/2,h=o.length/2;let c=h;for(o.push(s[0],s[1]),e=1;e<l;e++)o.push(s[e*2],s[e*2+1]),a.push(c,c+1),c++;n&&a.push(c,h)}function Du(r,t){r.lineStyle.native?vw(r,t):yw(r,t)}class Hh{static curveLength(t,e,i,s,n,o){const a=t-2*i+n,l=e-2*s+o,h=2*i-2*t,c=2*s-2*e,u=4*(a*a+l*l),d=4*(a*h+l*c),f=h*h+c*c,p=2*Math.sqrt(u+d+f),m=Math.sqrt(u),g=2*u*m,_=2*Math.sqrt(f),v=d/m;return(g*p+m*d*(p-_)+(4*f*u-d*d)*Math.log((2*m+v+p)/(v+_)))/(4*g)}static curveTo(t,e,i,s,n){const o=n[n.length-2],a=n[n.length-1],l=qr._segmentsCount(Hh.curveLength(o,a,t,e,i,s));let h=0,c=0;for(let u=1;u<=l;++u){const d=u/l;h=o+(t-o)*d,c=a+(e-a)*d,n.push(h+(t+(i-t)*d-h)*d,c+(e+(s-e)*d-c)*d)}}}const Na={[kt.POLY]:zp,[kt.CIRC]:uo,[kt.ELIP]:uo,[kt.RECT]:_w,[kt.RREC]:mw},Fu=[],hn=[];class fo{constructor(t,e=null,i=null,s=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=s,this.type=t.type}clone(){return new fo(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const wr=new ht,$p=class Xp extends qf{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new ao,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),hn.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),Fu.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,s=null){const n=new 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;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const e=this.graphicsData;for(let i=0;i<e.length;++i){const s=e[i];if(s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(t,wr):wr.copyFrom(t),s.shape.contains(wr.x,wr.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(wr.x,wr.y)){n=!0;break}}if(!n)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let i=null,s=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],s=i.style);for(let l=this.shapeIndex;l<e.length;l++){this.shapeIndex++;const h=e[l],c=h.fillStyle,u=h.lineStyle;Na[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(c.visible||u.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const f=d===0?c:u;if(!f.visible)continue;const p=f.texture.baseTexture,m=this.indices.length,g=this.points.length/2;p.wrapMode=Ii.REPEAT,d===0?this.processFill(h):this.processLine(h);const _=this.points.length/2-g;_!==0&&(i&&!this._compareStyles(s,f)&&(i.end(m,g),i=null),i||(i=Fu.pop()||new gw,i.begin(f,m,g),this.batches.push(i),s=f),this.addUvs(this.points,t,f.texture,g,_,f.matrix))}}const n=this.indices.length,o=this.points.length/2;if(i&&i.end(n,o),this.batches.length===0){this.batchable=!0;return}const a=o>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&a===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=a?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const i=this.graphicsData[t],s=i.fillStyle,n=i.lineStyle;if(s&&!s.texture.baseTexture.valid||n&&!n.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,i=t.length;e<i;e++){const s=t[e];for(let n=0;n<s.size;n++){const o=s.start+n;this.indicesUint16[o]=this.indicesUint16[o]-s.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<Xp.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++rt._globalBatch;for(let u=0;u<this.drawCalls.length;u++)this.drawCalls[u].texArray.clear(),hn.push(this.drawCalls[u]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=hn.pop();s||(s=new zl,s.texArray=new Wl),s.texArray.count=0,s.start=0,s.size=0,s.type=He.TRIANGLES;let n=0,o=null,a=0,l=!1,h=He.TRIANGLES,c=0;this.drawCalls.push(s);for(let u=0;u<this.batches.length;u++){const d=this.batches[u],f=8,p=d.style,m=p.texture.baseTexture;l!==!!p.native&&(l=!!p.native,h=l?He.LINES:He.TRIANGLES,o=null,n=f,t++),o!==m&&(o=m,m._batchEnabled!==t&&(n===f&&(t++,n=0,s.size>0&&(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;h<t.length/2;h++)o[l++]=t[h*2],o[l++]=t[h*2+1],o[l++]=e[h*2],o[l++]=e[h*2+1],a[l++]=i[h],o[l++]=s[h];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?zp.triangulate(t,this):Na[t.type].triangulate(t,this)}processLine(t){Du(t,this);for(let e=0;e<t.holes.length;e++)Du(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];Na[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let i=0;i<t.length/2;i++){const s=t[i*2],n=t[i*2+1];t[i*2]=e.a*s+e.c*n+e.tx,t[i*2+1]=e.b*s+e.d*n+e.ty}}addColors(t,e,i,s,n=0){const o=dt.shared.setValue(e).toLittleEndianNumber(),a=dt.shared.setValue(o).toPremultiplied(i);t.length=Math.max(t.length,n+s);for(let l=0;l<s;l++)t[n+l]=a}addTextureIds(t,e,i,s=0){t.length=Math.max(t.length,s+i);for(let n=0;n<i;n++)t[s+n]=e}addUvs(t,e,i,s,n,o=null){let a=0;const l=e.length,h=i.frame;for(;a<n;){let u=t[(s+a)*2],d=t[(s+a)*2+1];if(o){const f=o.a*u+o.c*d+o.tx;d=o.b*u+o.d*d+o.ty,u=f}a++,e.push(u/h.width,d/h.height)}const c=i.baseTexture;(h.width<c.width||h.height<c.height)&&this.adjustUvs(e,i,l,n)}adjustUvs(t,e,i,s){const n=e.baseTexture,o=1e-6,a=i+s*2,l=e.frame,h=l.width/n.width,c=l.height/n.height;let u=l.x/l.width,d=l.y/l.height,f=Math.floor(t[i]+o),p=Math.floor(t[i+1]+o);for(let m=i+2;m<a;m+=2)f=Math.min(f,Math.floor(t[m]+o)),p=Math.min(p,Math.floor(t[m+1]+o));u-=f,d-=p;for(let m=i;m<a;m+=2)t[m]=(t[m]+u)*h,t[m+1]=(t[m+1]+d)*c}};$p.BATCHABLE_SIZE=100;let bw=$p;class Do{constructor(){this.color=16777215,this.alpha=1,this.texture=Y.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Do;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=Y.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class zh extends Do{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=Ei.BUTT,this.join=fe.MITER,this.miterLimit=10}clone(){const t=new zh;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=Ei.BUTT,this.join=fe.MITER,this.miterLimit=10}}const La={},ch=class Rn extends Ut{constructor(t=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new Do,this._lineStyle=new zh,this._matrix=null,this._holeMode=!1,this.state=Ve.for2d(),this._geometry=t||new bw,this._geometry.refCount++,this._transformID=-1,this._tintColor=new dt(16777215),this.blendMode=Q.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new Rn(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,s=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:s,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:Y.WHITE,color:t?.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:Ei.BUTT,join:fe.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new 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);u<h&&d<h||c.push(a,l)}else this.moveTo(a,l),c=this.currentPath.points;return Bu.arc(a,l,t,e,i,s,n,o,c),this}beginFill(t=0,e){return this.beginTextureFill({texture:Y.WHITE,color:t,alpha:e})}normalizeColor(t){const e=dt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:Y.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,s){return this.drawShape(new 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;s<i;s++){const n=t.batches[s],o=n.style.color,a=new Float32Array(this.vertexData.buffer,n.attribStart*4*2,n.attribSize*2),l=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),h=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),c={vertexData:a,blendMode:e,indices:h,uvs:l,_batchRGB:dt.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=c}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,i=this.batches.length;e<i;e++){const s=this.batches[e];s.worldAlpha=this.worldAlpha*s.alpha,t.plugins[this.pluginName].render(s)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,s=this.worldAlpha,n=e.uniforms,o=i.drawCalls;n.translationMatrix=this.transform.worldTransform,dt.shared.setValue(this._tintColor).premultiply(s).toArray(n.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let a=0,l=o.length;a<l;a++)this._renderDrawCallDirect(t,i.drawCalls[a])}_renderDrawCallDirect(t,e){const{texArray:i,type:s,size:n,start:o}=e,a=i.count;for(let l=0;l<a;l++)t.texture.bind(i.elements[l],l);t.geometry.draw(s,n,o)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!La[i]){const{maxTextures:s}=t.plugins[i],n=new Int32Array(s);for(let l=0;l<s;l++)n[l]=l;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new yt,default:Ce.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;La[i]=new $e(a,o)}e=La[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:s,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,i,s,n)}containsPoint(t){return this.worldTransform.applyInverse(t,Rn._TEMP_POINT),this._geometry.containsPoint(Rn._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=dt.shared.setValue(this._tintColor).multiply(e._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this._geometry.points,c=this.vertexData;let u=0;for(let d=0;d<h.length;d+=2){const f=h[d],p=h[d+1];c[u++]=i*f+n*p+a,c[u++]=o*p+s*f+l}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};ch.curves=qr,ch._TEMP_POINT=new ht;let dr=ch;class xw{constructor(t,e){this.uvBuffer=t,this.uvMatrix=e,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const e=this.uvBuffer.data;(!this.data||this.data.length!==e.length)&&(this.data=new Float32Array(e.length)),this.uvMatrix.multiplyUvs(e,this.data),this._updateID++}}const Ua=new ht,Ou=new ar,Vp=class Wp extends Ut{constructor(t,e,i,s=He.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||Ve.for2d(),this.drawMode=s,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=j.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const e=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===He.TRIANGLES&&e.length<Wp.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const e=this.shader;e.alpha=this.worldAlpha,e.update&&e.update(),t.batch.flush(),e.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(e),t.state.set(this.state),t.geometry.bind(this.geometry,e),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const e=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const s=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[s]),t.plugins[s].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const s=this.transform.worldTransform,n=s.a,o=s.b,a=s.c,l=s.d,h=s.tx,c=s.ty,u=this.vertexData;for(let d=0;d<u.length/2;d++){const f=e[d*2],p=e[d*2+1];u[d*2]=n*f+a*p+h,u[d*2+1]=o*f+l*p+c}if(this._roundPixels){const d=j.RESOLUTION;for(let f=0;f<u.length;++f)u[f]=Math.round(u[f]*d)/d}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new xw(t,e.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,Ua);const e=this.geometry.getBuffer("aVertexPosition").data,i=Ou.points,s=this.geometry.getIndex().data,n=s.length,o=this.drawMode===4?3:1;for(let a=0;a+2<n;a+=o){const l=s[a]*2,h=s[a+1]*2,c=s[a+2]*2;if(i[0]=e[l],i[1]=e[l+1],i[2]=e[h],i[3]=e[h+1],i[4]=e[c],i[5]=e[c+1],Ou.contains(Ua.x,Ua.y))return!0}return!1}destroy(t){super.destroy(t),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};Vp.BATCHABLE_SIZE=100;let Nu=Vp;class ww extends Pi{constructor(t,e,i){super();const s=new Tt(t),n=new Tt(e,!0),o=new Tt(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,K.FLOAT).addAttribute("aTextureCoord",n,2,!1,K.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var Tw=`varying vec2 vTextureCoord;
|
|
uniform vec4 uColor;
|
|
|
|
uniform sampler2D uSampler;
|
|
|
|
void main(void)
|
|
{
|
|
gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
|
|
}
|
|
`,Ew=`attribute vec2 aVertexPosition;
|
|
attribute vec2 aTextureCoord;
|
|
|
|
uniform mat3 projectionMatrix;
|
|
uniform mat3 translationMatrix;
|
|
uniform mat3 uTextureMatrix;
|
|
|
|
varying vec2 vTextureCoord;
|
|
|
|
void main(void)
|
|
{
|
|
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
|
|
vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
|
|
}
|
|
`;class Lu extends $e{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:yt.IDENTITY,uColor:new Float32Array([1,1,1,1])};e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e),e.uniforms&&Object.assign(i,e.uniforms),super(e.program||ri.from(Ew,Tw),i),this._colorDirty=!1,this.uvMatrix=new hp(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new dt(e.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=e.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this.tint&&(this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}get tintValue(){return this._tintColor.toNumber()}update(){if(this._colorDirty){this._colorDirty=!1;const t=this.texture.baseTexture.alphaMode;dt.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class Uu{constructor(t,e,i){this.geometry=new Pi,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let s=0;s<t.length;++s){let n=t[s];n={attributeName:n.attributeName,size:n.size,uploadFunction:n.uploadFunction,type:n.type||K.FLOAT,offset:n.offset},e[s]?this.dynamicProperties.push(n):this.staticProperties.push(n)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const t=this.geometry;let e=0;this.indexBuffer=new Tt(Wy(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];a.offset=e,e+=a.size,this.dynamicStride+=a.size}const i=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(i),this.dynamicDataUint32=new Uint32Array(i),this.dynamicBuffer=new Tt(this.dynamicData,!1,!1);let s=0;this.staticStride=0;for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];a.offset=s,s+=a.size,this.staticStride+=a.size}const n=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(n),this.staticDataUint32=new Uint32Array(n),this.staticBuffer=new Tt(this.staticData,!0,!1);for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];t.addAttribute(a.attributeName,this.dynamicBuffer,0,a.type===K.UNSIGNED_BYTE,a.type,this.dynamicStride*4,a.offset*4)}for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];t.addAttribute(a.attributeName,this.staticBuffer,0,a.type===K.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(t,e,i){for(let s=0;s<this.dynamicProperties.length;s++){const n=this.dynamicProperties[s];n.uploadFunction(t,e,i,n.type===K.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,n.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,i){for(let s=0;s<this.staticProperties.length;s++){const n=this.staticProperties[s];n.uploadFunction(t,e,i,n.type===K.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,n.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var Aw=`varying vec2 vTextureCoord;
|
|
varying vec4 vColor;
|
|
|
|
uniform sampler2D uSampler;
|
|
|
|
void main(void){
|
|
vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
|
|
gl_FragColor = color;
|
|
}`,Sw=`attribute vec2 aVertexPosition;
|
|
attribute vec2 aTextureCoord;
|
|
attribute vec4 aColor;
|
|
|
|
attribute vec2 aPositionCoord;
|
|
attribute float aRotation;
|
|
|
|
uniform mat3 translationMatrix;
|
|
uniform vec4 uColor;
|
|
|
|
varying vec2 vTextureCoord;
|
|
varying vec4 vColor;
|
|
|
|
void main(void){
|
|
float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);
|
|
float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);
|
|
|
|
vec2 v = vec2(x, y);
|
|
v = v + aPositionCoord;
|
|
|
|
gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
|
|
|
|
vTextureCoord = aTextureCoord;
|
|
vColor = aColor * uColor;
|
|
}
|
|
`;class jp extends Bo{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new yt,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:K.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=$e.from(Sw,Aw,{}),this.state=Ve.for2d()}render(t){const e=t.children,i=t._maxSize,s=t._batchSize,n=this.renderer;let o=e.length;if(o===0)return;o>i&&!t.autoResize&&(o=i);let a=t._buffers;a||(a=t._buffers=this.generateBuffers(t));const l=e[0]._texture.baseTexture,h=l.alphaMode>0;this.state.blendMode=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;f<o;f+=s,p+=1){let m=o-f;m>s&&(m=s),p>=a.length&&a.push(this._generateOneMoreBuffer(t));const g=a[p];g.uploadDynamic(e,f,m);const _=t._bufferUpdateIDs[p]||0;d=d||g._updateID<_,d&&(g._updateID=t._updateID,g.uploadStatic(e,f,m)),n.geometry.bind(g.geometry),c.drawElements(c.TRIANGLES,m*6,c.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],i=t._maxSize,s=t._batchSize,n=t._properties;for(let o=0;o<i;o+=s)e.push(new Uu(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new Uu(this.properties,i,e)}uploadVertices(t,e,i,s,n,o){let a=0,l=0,h=0,c=0;for(let u=0;u<i;++u){const d=t[e+u],f=d._texture,p=d.scale.x,m=d.scale.y,g=f.trim,_=f.orig;g?(l=g.x-d.anchor.x*_.width,a=l+g.width,c=g.y-d.anchor.y*_.height,h=c+g.height):(a=_.width*(1-d.anchor.x),l=_.width*-d.anchor.x,h=_.height*(1-d.anchor.y),c=_.height*-d.anchor.y),s[o]=l*p,s[o+1]=c*m,s[o+n]=a*p,s[o+n+1]=c*m,s[o+n*2]=a*p,s[o+n*2+1]=h*m,s[o+n*3]=l*p,s[o+n*3+1]=h*m,o+=n*4}}uploadPosition(t,e,i,s,n,o){for(let a=0;a<i;a++){const l=t[e+a].position;s[o]=l.x,s[o+1]=l.y,s[o+n]=l.x,s[o+n+1]=l.y,s[o+n*2]=l.x,s[o+n*2+1]=l.y,s[o+n*3]=l.x,s[o+n*3+1]=l.y,o+=n*4}}uploadRotation(t,e,i,s,n,o){for(let a=0;a<i;a++){const l=t[e+a].rotation;s[o]=l,s[o+n]=l,s[o+n*2]=l,s[o+n*3]=l,o+=n*4}}uploadUvs(t,e,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a]._texture._uvs;l?(s[o]=l.x0,s[o+1]=l.y0,s[o+n]=l.x1,s[o+n+1]=l.y1,s[o+n*2]=l.x2,s[o+n*2+1]=l.y2,s[o+n*3]=l.x3,s[o+n*3+1]=l.y3,o+=n*4):(s[o]=0,s[o+1]=0,s[o+n]=0,s[o+n+1]=0,s[o+n*2]=0,s[o+n*2+1]=0,s[o+n*3]=0,s[o+n*3+1]=0,o+=n*4)}}uploadTint(t,e,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a],h=dt.shared.setValue(l._tintRGB).toPremultiplied(l.alpha,l.texture.baseTexture.alphaMode>0);s[o]=h,s[o+n]=h,s[o+n*2]=h,s[o+n*3]=h,o+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}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;p<l.length;p++){const m=Z._measureText(l[p],e.letterSpacing,a);h[p]=m,c=Math.max(c,m)}let u=c+e.strokeThickness;e.dropShadow&&(u+=e.dropShadowDistance);const d=e.lineHeight||o.fontSize+e.strokeThickness;let f=Math.max(d,o.fontSize+e.strokeThickness*2)+e.leading+(l.length-1)*(d+e.leading);return e.dropShadow&&(f+=e.dropShadowDistance),new Z(t,e,u,f,l,h,d+e.leading,c,o)}static _measureText(t,e,i){let s=!1;Z.experimentalLetterSpacingSupported&&(Z.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(s?n-=e:n+=(Z.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=Z._canvas){const s=i.getContext("2d",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;g<m.length;g++){let _=m[g];if(Z.isNewline(_)){if(!d){a+=Z.addLine(o),f=!u,o="",n=0;continue}_=" "}if(u){const y=Z.isBreakingSpace(_),b=Z.isBreakingSpace(o[o.length-1]);if(y&&b)continue}const v=Z.getFromCache(_,h,l,s);if(v>p)if(o!==""&&(a+=Z.addLine(o),o="",n=0),Z.canBreakWords(_,e.breakWords)){const y=Z.wordWrapSplit(_);for(let b=0;b<y.length;b++){let x=y[b],S=x,w=1;for(;y[b+w];){const I=y[b+w];if(!Z.canBreakChars(S,I,_,b,e.breakWords))x+=I;else break;S=I,w++}b+=w-1;const T=Z.getFromCache(x,h,l,s);T+n>p&&(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;s<t.length;s++){const n=t[s],o=t[s+1];if(Z.isBreakingSpace(n,o)||Z.isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return Z.graphemeSegmenter(t)}static measureFont(t){if(Z._fonts[t])return Z._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=Z._canvas,s=Z._context;s.font=t;const n=Z.METRICS_STRING+Z.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(Z.BASELINE_SYMBOL).width);const l=Math.ceil(Z.HEIGHT_MULTIPLIER*a);if(a=a*Z.BASELINE_MULTIPLIER|0,o===0||l===0)return Z._fonts[t]=e,e;i.width=o,i.height=l,s.fillStyle="#f00",s.fillRect(0,0,o,l),s.font=t,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,a);const h=s.getImageData(0,0,o,l).data,c=h.length,u=o*4;let d=0,f=0,p=!1;for(d=0;d<a;++d){for(let m=0;m<u;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f+=u;else break}for(e.ascent=a-d,f=c-u,p=!1,d=l;d>a;--d){for(let m=0;m<u;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f-=u;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,Z._fonts[t]=e,e}static clearMetrics(t=""){t?delete Z._fonts[t]:Z._fonts={}}static get _canvas(){if(!Z.__canvas){let t;try{const e=new OffscreenCanvas(0,0);if(e.getContext("2d",cn)?.measureText)return Z.__canvas=e,e;t=j.ADAPTER.createCanvas()}catch{t=j.ADAPTER.createCanvas()}t.width=t.height=10,Z.__canvas=t}return Z.__canvas}static get _context(){return Z.__context||(Z.__context=Z._canvas.getContext("2d",cn)),Z.__context}};Fe.METRICS_STRING="|ÉqÅ",Fe.BASELINE_SYMBOL="M",Fe.BASELINE_MULTIPLIER=1.4,Fe.HEIGHT_MULTIPLIER=2,Fe.graphemeSegmenter=(()=>{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;e<r.length;++e)if(r[e]!==t[e])return!1;return!0}function Ha(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const Rw={texture:!0,children:!1,baseTexture:!0},qp=class uh extends Xt{constructor(t,e,i){let s=!1;i||(i=j.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=Y.from(i);n.orig=new it,n.trim=new it,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=uh.defaultResolution??j.RESOLUTION,this._autoResolution=uh.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=e,this.localStyleID=-1}static get experimentalLetterSpacing(){return yi.experimentalLetterSpacing}static set experimentalLetterSpacing(t){nt("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),yi.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,s=yi.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=s.width,o=s.height,a=s.lines,l=s.lineHeight,h=s.lineWidths,c=s.maxLineWidth,u=s.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,n)+e.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,o)+e.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;let d,f;const p=e.dropShadow?2:1;for(let m=0;m<p;++m){const g=e.dropShadow&&m===0,_=g?Math.ceil(Math.max(1,o)+e.padding*2):0,v=_*this._resolution;if(g){i.fillStyle="black",i.strokeStyle="black";const b=e.dropShadowColor,x=e.dropShadowBlur*this._resolution,S=e.dropShadowDistance*this._resolution;i.shadowColor=dt.shared.setValue(b).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=x,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*S,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*S+v}else i.fillStyle=this._generateFillStyle(e,a,s),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let y=(l-u.fontSize)/2;l-u.fontSize<0&&(y=0);for(let b=0;b<a.length;b++)d=e.strokeThickness/2,f=e.strokeThickness/2+b*l+u.ascent+y,e.align==="right"?d+=c-h[b]:e.align==="center"&&(d+=(c-h[b])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[b],d+e.padding,f+e.padding-_,!0),e.fill&&this.drawLetterSpacing(a[b],d+e.padding,f+e.padding-_)}this.updateTexture()}drawLetterSpacing(t,e,i,s=!1){const n=this._style.letterSpacing;let o=!1;if(yi.experimentalLetterSpacingSupported&&(yi.experimentalLetterSpacing?(this.context.letterSpacing=`${n}px`,this.context.textLetterSpacing=`${n}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),n===0||o){s?this.context.strokeText(t,e,i):this.context.fillText(t,e,i);return}let a=e;const l=yi.graphemeSegmenter(t);let h=this.context.measureText(t).width,c=0;for(let u=0;u<l.length;++u){const d=l[u];s?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let f="";for(let p=u+1;p<l.length;++p)f+=l[p];c=this.context.measureText(f).width,a+=h-c+n,h=c}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=Zy(t);o.data&&(t.width=o.width,t.height=o.height,this.context.putImageData(o.data,0,0))}const e=this._texture,i=this._style,s=i.trim?0:i.padding,n=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-s,e.trim.y=-s,e.orig.width=e._frame.width-s*2,e.orig.height=e._frame.height-s*2,this._onTextureUpdate(),n.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,i){const s=t.fill;if(Array.isArray(s)){if(s.length===1)return s[0]}else return s;let n;const o=t.dropShadow?t.dropShadowDistance:0,a=t.padding||0,l=this.canvas.width/this._resolution-o-a*2,h=this.canvas.height/this._resolution-o-a*2,c=s.slice(),u=t.fillGradientStops.slice();if(!u.length){const d=c.length+1;for(let f=1;f<d;++f)u.push(f/d)}if(c.unshift(s[0]),u.unshift(0),c.push(s[s.length-1]),u.push(1),t.fillGradientType===Fo.LINEAR_VERTICAL){n=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=i.fontProperties.fontSize+t.strokeThickness;for(let f=0;f<e.length;f++){const p=i.lineHeight*(f-1)+d,m=i.lineHeight*f;let g=m;f>0&&p>m&&(g=(m+p)/2);const _=m+d,v=i.lineHeight*(f+1);let y=_;f+1<e.length&&v<_&&(y=(_+v)/2);const b=(y-g)/h;for(let x=0;x<c.length;x++){let S=0;typeof u[x]=="number"?S=u[x]:S=x/c.length;let w=Math.min(1,Math.max(0,g/h+S*b));w=Number(w.toFixed(5)),n.addColorStop(w,c[x])}}}else{n=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=c.length+1;let f=1;for(let p=0;p<c.length;p++){let m;typeof u[p]=="number"?m=u[p]:m=f/d,n.addColorStop(m,c[p]),f++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Rw,t),super.destroy(t),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this.updateText(!0);const e=Ti(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const e=Ti(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof Bi?this._style=t:this._style=new Bi(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};qp.defaultAutoResolution=!0;let Zp=qp;class Pw{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function Mw(r,t){let e=!1;if(r?._textures?.length){for(let i=0;i<r._textures.length;i++)if(r._textures[i]instanceof Y){const s=r._textures[i].baseTexture;t.includes(s)||(t.push(s),e=!0)}}return e}function Bw(r,t){if(r.baseTexture instanceof rt){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function kw(r,t){if(r._texture&&r._texture instanceof Y){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function Dw(r,t){return t instanceof Zp?(t.updateText(!0),!0):!1}function Fw(r,t){if(t instanceof Bi){const e=t.toFontString();return yi.measureFont(e),!0}return!1}function Ow(r,t){if(r instanceof Zp){t.includes(r.style)||t.push(r.style),t.includes(r)||t.push(r);const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function Nw(r,t){return r instanceof Bi?(t.includes(r)||t.push(r),!0):!1}const Kp=class Jp{constructor(t){this.limiter=new Pw(Jp.uploadsPerFrame),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(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<s;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)se.system.addOnce(this.tick,this,ur.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,i=t.length;e<i;e++)t[e]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof Ut)for(let e=t.children.length-1;e>=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;s<i.length;s++){const{texture:n}=i[s].style;n&&Qp(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function Uw(r,t){return r instanceof dr?(t.push(r),!0):!1}class t_ extends dh{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(Uw),this.registerUploadHook(Qp),this.registerUploadHook(Lw)}}t_.extension={name:"prepare",type:$.RendererSystem};q.add(t_);var Gw=`#version 300 es
|
|
#define SHADER_NAME Tiling-Sprite-100
|
|
|
|
precision lowp float;
|
|
|
|
in vec2 vTextureCoord;
|
|
|
|
out vec4 fragmentColor;
|
|
|
|
uniform sampler2D uSampler;
|
|
uniform vec4 uColor;
|
|
uniform mat3 uMapCoord;
|
|
uniform vec4 uClampFrame;
|
|
uniform vec2 uClampOffset;
|
|
|
|
void main(void)
|
|
{
|
|
vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
|
|
coord = (uMapCoord * vec3(coord, 1.0)).xy;
|
|
vec2 unclamped = coord;
|
|
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
|
|
|
|
vec4 texSample = texture(uSampler, coord, unclamped == coord ? 0.0f : -32.0f);// lod-bias very negative to force lod 0
|
|
|
|
fragmentColor = texSample * uColor;
|
|
}
|
|
`,Hw=`#version 300 es
|
|
#define SHADER_NAME Tiling-Sprite-300
|
|
|
|
precision lowp float;
|
|
|
|
in vec2 aVertexPosition;
|
|
in vec2 aTextureCoord;
|
|
|
|
uniform mat3 projectionMatrix;
|
|
uniform mat3 translationMatrix;
|
|
uniform mat3 uTransform;
|
|
|
|
out vec2 vTextureCoord;
|
|
|
|
void main(void)
|
|
{
|
|
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
|
|
vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
|
|
}
|
|
`,zw=`#version 100
|
|
#ifdef GL_EXT_shader_texture_lod
|
|
#extension GL_EXT_shader_texture_lod : enable
|
|
#endif
|
|
#define SHADER_NAME Tiling-Sprite-100
|
|
|
|
precision lowp float;
|
|
|
|
varying vec2 vTextureCoord;
|
|
|
|
uniform sampler2D uSampler;
|
|
uniform vec4 uColor;
|
|
uniform mat3 uMapCoord;
|
|
uniform vec4 uClampFrame;
|
|
uniform vec2 uClampOffset;
|
|
|
|
void main(void)
|
|
{
|
|
vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
|
|
coord = (uMapCoord * vec3(coord, 1.0)).xy;
|
|
vec2 unclamped = coord;
|
|
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
|
|
|
|
#ifdef GL_EXT_shader_texture_lod
|
|
vec4 texSample = unclamped == coord
|
|
? texture2D(uSampler, coord)
|
|
: texture2DLodEXT(uSampler, coord, 0);
|
|
#else
|
|
vec4 texSample = texture2D(uSampler, coord);
|
|
#endif
|
|
|
|
gl_FragColor = texSample * uColor;
|
|
}
|
|
`,Gu=`#version 100
|
|
#define SHADER_NAME Tiling-Sprite-100
|
|
|
|
precision lowp float;
|
|
|
|
attribute vec2 aVertexPosition;
|
|
attribute vec2 aTextureCoord;
|
|
|
|
uniform mat3 projectionMatrix;
|
|
uniform mat3 translationMatrix;
|
|
uniform mat3 uTransform;
|
|
|
|
varying vec2 vTextureCoord;
|
|
|
|
void main(void)
|
|
{
|
|
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
|
|
vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
|
|
}
|
|
`,$w=`#version 100
|
|
#define SHADER_NAME Tiling-Sprite-Simple-100
|
|
|
|
precision lowp float;
|
|
|
|
varying vec2 vTextureCoord;
|
|
|
|
uniform sampler2D uSampler;
|
|
uniform vec4 uColor;
|
|
|
|
void main(void)
|
|
{
|
|
vec4 texSample = texture2D(uSampler, vTextureCoord);
|
|
gl_FragColor = texSample * uColor;
|
|
}
|
|
`;const un=new yt;class e_ extends Bo{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new np,this.state=Ve.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=$e.from(Gu,$w,e),this.shader=t.context.webGLVersion>1?$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<i&&e<this._frameKeys.length;){const s=this._frameKeys[e],n=this._frames[s],o=n.frame;if(o){let a=null,l=null;const h=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,c=new it(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?a=new it(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):a=new it(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(l=new it(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[s]=new Y(this.baseTexture,a,c,l,n.rotated?2:0,n.anchor,n.borders),Y.addToCache(this.textures[s],s.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*vs.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*vs.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){for(const e in this.textures)this.textures[e].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(this._texture?.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};i_.BATCH_SIZE=1e3;let Hu=i_;const Xw=["jpg","png","jpeg","avif","webp"];function r_(r,t,e){const i={};if(r.forEach(s=>{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<i.length;h++)e.info.push({face:i[h].getAttribute("face"),size:parseInt(i[h].getAttribute("size"),10)});for(let h=0;h<s.length;h++)e.common.push({lineHeight:parseInt(s[h].getAttribute("lineHeight"),10)});for(let h=0;h<n.length;h++)e.page.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});for(let h=0;h<o.length;h++){const c=o[h];e.char.push({id:parseInt(c.getAttribute("id"),10),page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xoffset:parseInt(c.getAttribute("xoffset"),10),yoffset:parseInt(c.getAttribute("yoffset"),10),xadvance:parseInt(c.getAttribute("xadvance"),10)})}for(let h=0;h<a.length;h++)e.kerning.push({first:parseInt(a[h].getAttribute("first"),10),second:parseInt(a[h].getAttribute("second"),10),amount:parseInt(a[h].getAttribute("amount"),10)});for(let h=0;h<l.length;h++)e.distanceField.push({fieldType:l[h].getAttribute("fieldType"),distanceRange:parseInt(l[h].getAttribute("distanceRange"),10)});return e}}class ph{static test(t){return typeof t=="string"&&t.includes("<font>")?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<za.length;t++)if(za[t].test(r))return za[t];return null}function jw(r,t,e,i,s,n){const o=e.fill;if(Array.isArray(o)){if(o.length===1)return o[0]}else return o;let a;const l=e.dropShadow?e.dropShadowDistance:0,h=e.padding||0,c=r.width/i-l-h*2,u=r.height/i-l-h*2,d=o.slice(),f=e.fillGradientStops.slice();if(!f.length){const p=d.length+1;for(let m=1;m<p;++m)f.push(m/p)}if(d.unshift(o[0]),f.unshift(0),d.push(o[o.length-1]),f.push(1),e.fillGradientType===Fo.LINEAR_VERTICAL){a=t.createLinearGradient(c/2,h,c/2,u+h);let p=0;const m=(n.fontProperties.fontSize+e.strokeThickness)/u;for(let g=0;g<s.length;g++){const _=n.lineHeight*g;for(let v=0;v<d.length;v++){let y=0;typeof f[v]=="number"?y=f[v]:y=v/d.length;const b=_/u+y*m;let x=Math.max(p,b);x=Math.min(x,1),a.addColorStop(x,d[v]),p=x}}}else{a=t.createLinearGradient(h,u/2,c+h,u/2);const p=d.length+1;let m=1;for(let g=0;g<d.length;g++){let _;typeof f[g]=="number"?_=f[g]:_=m/p,a.addColorStop(_,d[g]),m++}}return a}function Yw(r,t,e,i,s,n,o){const a=e.text,l=e.fontProperties;t.translate(i,s),t.scale(n,n);const h=o.strokeThickness/2,c=-(o.strokeThickness/2);if(t.font=o.toFontString(),t.lineWidth=o.strokeThickness,t.textBaseline=o.textBaseline,t.lineJoin=o.lineJoin,t.miterLimit=o.miterLimit,t.fillStyle=jw(r,t,o,n,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const u=o.dropShadowColor,d=o.dropShadowBlur*n,f=o.dropShadowDistance*n;t.shadowColor=dt.shared.setValue(u).setAlpha(o.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(o.dropShadowAngle)*f,t.shadowOffsetY=Math.sin(o.dropShadowAngle)*f}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;o.stroke&&o.strokeThickness&&t.strokeText(a,h,c+e.lineHeight-l.descent),o.fill&&t.fillText(a,h,c+e.lineHeight-l.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Mn(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function s_(r){return Array.from?Array.from(r):r.split("")}function qw(r){typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const s=r[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);const n=s[0].charCodeAt(0),o=s[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...s_(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const fi=class Oe{constructor(t,e,i){const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,l=li(o.file),h={};this._ownsTextures=i,this.font=s.face,this.size=s.size,this.lineHeight=n.lineHeight/l,this.chars={},this.pageTextures=h;for(let c=0;c<t.page.length;c++){const{id:u,file:d}=t.page[c];h[u]=e instanceof Array?e[c]:e[d],a?.fieldType&&a.fieldType!=="none"&&(h[u].baseTexture.alphaMode=Zt.NO_PREMULTIPLIED_ALPHA,h[u].baseTexture.mipmap=Xe.OFF)}for(let c=0;c<t.char.length;c++){const{id:u,page:d}=t.char[c];let{x:f,y:p,width:m,height:g,xoffset:_,yoffset:v,xadvance:y}=t.char[c];f/=l,p/=l,m/=l,g/=l,_/=l,v/=l,y/=l;const b=new it(f+h[d].frame.x/l,p+h[d].frame.y/l,m,g);this.chars[u]={xOffset:_,yOffset:v,xAdvance:y,kerning:{},texture:new Y(h[d].baseTexture,b),page:d}}for(let c=0;c<t.kerning.length;c++){let{first:u,second:d,amount:f}=t.kerning[c];u/=l,d/=l,f/=l,this.chars[d]&&(this.chars[d].kerning[u]=f)}this.distanceFieldRange=a?.distanceRange,this.distanceFieldType=a?.fieldType?.toLowerCase()??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,i){let s;if(t instanceof po)s=t;else{const o=Ww(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof Y&&(e=[e]);const n=new Oe(s,e,i);return Oe.available[n.font]=n,n}static uninstall(t){const e=Oe.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete Oe.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:s,padding:n,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},Oe.defaultOptions,i),c=qw(s),u=e instanceof Bi?e:new Bi(e),d=a,f=new po;f.info[0]={face:u.fontFamily,size:u.fontSize},f.common[0]={lineHeight:u.fontSize};let p=0,m=0,g,_,v,y=0;const b=[];for(let S=0;S<c.length;S++){g||(g=j.ADAPTER.createCanvas(),g.width=a,g.height=l,_=g.getContext("2d"),v=new rt(g,{resolution:o,...h}),b.push(new Y(v)),f.page.push({id:b.length-1,file:""}));const w=c[S],T=yi.measureText(w,u,!1,g),I=T.width,B=Math.ceil(T.height),P=Math.ceil((u.fontStyle==="italic"?2:1)*I);if(m>=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<w;S++){const T=c[S];for(let I=0;I<w;I++){const B=c[I],P=_.measureText(T).width,M=_.measureText(B).width,E=_.measureText(T+B).width-(P+M);E&&f.kerning.push({first:Mn(T),second:Mn(B),amount:E})}}const x=new Oe(f,b,!0);return Oe.available[t]!==void 0&&Oe.uninstall(t),Oe.available[t]=x,x}};fi.ALPHA=[["a","z"],["A","Z"]," "],fi.NUMERIC=[["0","9"]],fi.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],fi.ASCII=[[" ","~"]],fi.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:fi.ALPHANUMERIC},fi.available={};let pi=fi;var Zw=`// Pixi texture info\r
|
|
varying vec2 vTextureCoord;\r
|
|
uniform sampler2D uSampler;\r
|
|
\r
|
|
// Tint\r
|
|
uniform vec4 uColor;\r
|
|
\r
|
|
// on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r
|
|
uniform float uFWidth;\r
|
|
\r
|
|
void main(void) {\r
|
|
\r
|
|
// To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r
|
|
vec4 texColor = texture2D(uSampler, vTextureCoord);\r
|
|
\r
|
|
// MSDF\r
|
|
float median = texColor.r + texColor.g + texColor.b -\r
|
|
min(texColor.r, min(texColor.g, texColor.b)) -\r
|
|
max(texColor.r, max(texColor.g, texColor.b));\r
|
|
// SDF\r
|
|
median = min(median, texColor.a);\r
|
|
\r
|
|
float screenPxDistance = uFWidth * (median - 0.5);\r
|
|
float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r
|
|
if (median < 0.01) {\r
|
|
alpha = 0.0;\r
|
|
} else if (median > 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;P<h.length;P++){const M=h[P],E=Mn(M);if(/(?:\s)/.test(M)&&(g=P,_=f,b++),M==="\r"||M===`
|
|
`){o.push(f),a.push(-1),p=Math.max(p,f),++m,++v,s.x=0,s.y+=t.lineHeight,d=null,b=0;continue}const C=t.chars[E];if(!C)continue;d&&C.kerning[d]&&(s.x+=C.kerning[d]);const G=Xu.pop()||{texture:Y.EMPTY,line:0,charCode:0,prevSpaces:0,position:new ht};G.texture=C.texture,G.line=m,G.charCode=E,G.position.x=Math.round(s.x+C.xOffset+this._letterSpacing/2),G.position.y=Math.round(s.y+C.yOffset),G.prevSpaces=b,n.push(G),f=G.position.x+Math.max(C.xAdvance-C.xOffset,C.texture.orig.width),s.x+=C.xAdvance+this._letterSpacing,y=Math.max(y,C.yOffset+C.texture.height),d=E,g!==-1&&c>0&&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;P<w;P++){const M=n[P].texture,E=M.baseTexture.uid;if(!T[E]){let C=u.pop();if(!C){const X=new ww;let N,J;t.distanceFieldType==="none"?(N=new Lu(Y.EMPTY),J=Q.NORMAL):(N=new Lu(Y.EMPTY,{program:ri.from(Kw,Zw),uniforms:{uFWidth:0}}),J=Q.NORMAL_NPM);const H=new Nu(X,N);H.blendMode=J,C={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:H,vertices:null,uvs:null,indices:null}}C.index=0,C.indexCount=0,C.vertexCount=0,C.uvsCount=0,C.total=0;const{_textureCache:G}=this;G[E]=G[E]||new Y(M.baseTexture),C.mesh.texture=G[E],C.mesh.tint=this._tintColor.value,I.push(C),T[E]=C}T[E].total++}for(let P=0;P<B.length;P++)I.includes(B[P])||this.removeChild(B[P].mesh);for(let P=0;P<I.length;P++)I[P].mesh.parent!==this&&this.addChild(I[P].mesh);this._activePagesMeshData=I;for(const P in T){const M=T[P],E=M.total;if(!(M.indices?.length>6*E)||M.vertices.length<Nu.BATCHABLE_SIZE*2)M.vertices=new Float32Array(4*2*E),M.uvs=new Float32Array(4*2*E),M.indices=new Uint16Array(6*E);else{const C=M.total,G=M.vertices;for(let X=C*4*2;X<G.length;X++)G[X]=0}M.mesh.size=6*E}for(let P=0;P<w;P++){const M=n[P];let E=M.position.x+S[M.line]*(this._align==="justify"?M.prevSpaces:1);this._roundPixels&&(E=Math.round(E));const C=E*i,G=M.position.y*i,X=M.texture,N=T[X.baseTexture.uid],J=X.frame,H=X._uvs,A=N.index++;N.indices[A*6+0]=0+A*4,N.indices[A*6+1]=1+A*4,N.indices[A*6+2]=2+A*4,N.indices[A*6+3]=0+A*4,N.indices[A*6+4]=2+A*4,N.indices[A*6+5]=3+A*4,N.vertices[A*8+0]=C,N.vertices[A*8+1]=G,N.vertices[A*8+2]=C+J.width*i,N.vertices[A*8+3]=G,N.vertices[A*8+4]=C+J.width*i,N.vertices[A*8+5]=G+J.height*i,N.vertices[A*8+6]=C,N.vertices[A*8+7]=G+J.height*i,N.uvs[A*8+0]=H.x0,N.uvs[A*8+1]=H.y0,N.uvs[A*8+2]=H.x1,N.uvs[A*8+3]=H.y1,N.uvs[A*8+4]=H.x2,N.uvs[A*8+5]=H.y2,N.uvs[A*8+6]=H.x3,N.uvs[A*8+7]=H.y3}this._textWidth=p*i,this._textHeight=(s.y+t.lineHeight)*i;for(const P in T){const M=T[P];if(this.anchor.x!==0||this.anchor.y!==0){let X=0;const N=this._textWidth*this.anchor.x,J=this._textHeight*this.anchor.y;for(let H=0;H<M.total;H++)M.vertices[X++]-=N,M.vertices[X++]-=J,M.vertices[X++]-=N,M.vertices[X++]-=J,M.vertices[X++]-=N,M.vertices[X++]-=J,M.vertices[X++]-=N,M.vertices[X++]-=J}this._maxLineHeight=y*i;const E=M.mesh.geometry.getBuffer("aVertexPosition"),C=M.mesh.geometry.getBuffer("aTextureCoord"),G=M.mesh.geometry.getIndex();E.data=M.vertices,C.data=M.uvs,G.data=M.indices,E.update(),C.update(),G.update()}for(let P=0;P<n.length;P++)Xu.push(n[P]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:e,distanceFieldType:i,size:s}=pi.available[this._fontName];if(i!=="none"){const{a:n,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(n*n+o*o),c=Math.sqrt(a*a+l*l),u=(Math.abs(h)+Math.abs(c))/2,d=this.fontSize/s,f=t._view.resolution;for(const p of this._activePagesMeshData)p.mesh.shader.uniforms.uFWidth=u*e*d*f}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=pi.available[this._fontName];if(!t)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==t&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(t){if(this.tint!==t){this._tintColor.setValue(t);for(let e=0;e<this._activePagesMeshData.length;e++)this._activePagesMeshData[e].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!pi.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??pi.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:e}=this,i=pi.available[this._fontName].distanceFieldType==="none"?zu:$u;i.push(...this._activePagesMeshData);for(const s of this._activePagesMeshData)this.removeChild(s.mesh);this._activePagesMeshData=[],i.filter(s=>e[s.mesh.texture.baseTexture.uid]).forEach(s=>{s.mesh.texture=Y.EMPTY});for(const s in e)e[s].destroy(),delete e[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};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;h<n.length;++h){const c=n[h].file;let u=It.join(It.dirname(s),c);u=lh(u,s),o.push(u)}const a=await e.load(o),l=o.map(h=>a[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<this._updateID){l();return}await e.onBeforeDraw(),i.src=s.src,s.onload=null,s.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:s}=this,{padding:n}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/s,e.trim.height=e._frame.height=i.height/s,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,s),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Fr.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&this._style?.cleanFonts(),this._style=e,this._svgRoot?.remove(),this._svgRoot=e,this._domElement?.remove(),this._domElement=e,this._foreignObject?.remove(),this._foreignObject=e,this._styleElement?.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=Ti(this.scale.x)||1;this.scale.x=e*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const e=Ti(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof $a?(this.ownsStyle=!1,this._style=t):t instanceof Bi?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=$a.from(t)):(this.ownsStyle=!0,this._style=new $a(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," ")}};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 r<t?t:r>e?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<o;h++){const c=r.x+h*a,u=r.y+h*l;e.push({x:c,y:u})}return e}function oT(r,t,e,i){const s=[];let n,o,a,l=!1,h=0;return{drawing:!1,start:function({x:c,y:u,size:d,color:f=new dt("black"),opacity:p,set_initial_texture:m=!0}){m&&(a=Gt.create({width:e.draw_texture.width,height:e.draw_texture.height}),r.render(e.composite,{renderTexture:a})),n={x:c,y:u,size:d,color:f,opacity:p},s.push({x:c,y:u}),o=o_(h++),Va(o,c,u,f,d),r.render(o,{renderTexture:i==="draw"?e.draw_texture:e.erase_texture,clear:!1}),this.drawing=!0},continue:function({x:c,y:u}){const d=s[s.length-1],f=nT(d,{x:c,y:u});for(let p=0;p<f.length;p++){const{x:m,y:g}=f[p];Va(o,m,g,n.color,n.size),s.push({x:m,y:g})}r.render(o,{renderTexture:i==="draw"?e.draw_texture:e.erase_texture,clear:!1}),o.clear()},stop:function(){const c=Gt.create({width:e.draw_texture.width,height:e.draw_texture.height});r.render(e.composite,{renderTexture:c}),r.render(new Xt(c),{renderTexture:e.draw_texture});const u=new dr().beginFill(0,0).drawRect(0,0,e.erase_texture.width,e.erase_texture.height).endFill();r.render(u,{renderTexture:e.erase_texture,clear:!0}),l=!0,this.drawing=!1},execute:function(){if(!l){for(let c=1;c<s.length;c++){const{x:u,y:d}=s[c];Va(o,u,d,n.color,n.size)}r.render(o,{renderTexture:i==="draw"?e.draw_texture:e.erase_texture,clear:!1}),this.stop()}},undo:function(){const c=new dr().beginFill(0,0).drawRect(0,0,e.erase_texture.width,e.erase_texture.height).endFill();r.render(new Xt(a),{renderTexture:e.draw_texture}),r.render(c,{renderTexture:e.erase_texture,clear:!0}),this.stop(),l=!1}}}function $h(r,t){const e=i=>{r&&!r.contains(i.target)&&!i.defaultPrevented&&t(i)};return document.addEventListener("mousedown",e,!0),{destroy(){document.removeEventListener("mousedown",e,!0)}}}const{SvelteComponent: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;l<o.length;l+=1)a[l]=td(Ku(r,o,l));return{c(){t=si("div");for(let l=0;l<a.length;l+=1)a[l].c();e=Bn(),i=si("button"),Ri(i,"class","color colorpicker svelte-287ern"),me(i,"hidden",!r[0]),Ri(t,"class","swatch svelte-287ern")},m(l,h){Kr(l,t,h);for(let c=0;c<a.length;c+=1)a[c]&&a[c].m(t,null);er(t,e),er(t,i),s||(n=Xh(i,"click",r[5]),s=!0)},p(l,h){if(h&22){o=_o(l[1]);let c;for(c=0;c<o.length;c+=1){const u=Ku(l,o,c);a[c]?a[c].p(u,h):(a[c]=td(u),a[c].c(),a[c].m(t,e))}for(;c<a.length;c+=1)a[c].d(1);a.length=o.length}h&1&&me(i,"hidden",!l[0])},d(l){l&&Zr(t),a_(a,l),s=!1,n()}}}function td(r){let t,e,i;function s(){return r[10](r[16],r[14])}return{c(){t=si("button"),Ri(t,"class","color svelte-287ern"),mo(t,"background-color",r[14]),me(t,"empty",r[14]===null),me(t,"selected",`edit-${r[16]}`===r[2])},m(n,o){Kr(n,t,o),e||(i=Xh(t,"click",s),e=!0)},p(n,o){r=n,o&2&&mo(t,"background-color",r[14]),o&2&&me(t,"empty",r[14]===null),o&4&&me(t,"selected",`edit-${r[16]}`===r[2])},d(n){n&&Zr(t),e=!1,i()}}}function ed(r){let t,e,i;function s(){return r[11](r[16],r[14])}return{c(){t=si("button"),Ri(t,"class","color svelte-287ern"),mo(t,"background-color",r[14]),me(t,"empty",r[14]===null),me(t,"selected",`select-${r[16]}`===r[2])},m(n,o){Kr(n,t,o),e||(i=Xh(t,"click",s),e=!0)},p(n,o){r=n,o&8&&mo(t,"background-color",r[14]),o&8&&me(t,"empty",r[14]===null),o&4&&me(t,"selected",`select-${r[16]}`===r[2])},d(n){n&&Zr(t),e=!1,i()}}}function ST(r){let t,e,i,s,n,o,a,l,h,c=!r[0]&&Ju(r);s=new Dm({});let u=r[1]&&Qu(r),d=_o(r[3]),f=[];for(let p=0;p<d.length;p+=1)f[p]=ed(Zu(r,d,p));return{c(){c&&c.c(),t=Bn(),e=si("div"),i=si("span"),yT(s.$$.fragment),n=Bn(),o=si("div"),u&&u.c(),a=Bn(),l=si("menu");for(let p=0;p<f.length;p+=1)f[p].c();Ri(i,"class","icon-wrap svelte-287ern"),Ri(l,"class","swatch svelte-287ern"),Ri(e,"class","swatch-wrap svelte-287ern")},m(p,m){c&&c.m(p,m),Kr(p,t,m),Kr(p,e,m),er(e,i),xT(s,i,null),er(e,n),er(e,o),u&&u.m(o,null),er(o,a),er(o,l);for(let g=0;g<f.length;g+=1)f[g]&&f[g].m(l,null);h=!0},p(p,[m]){if(p[0]?c&&(c.d(1),c=null):c?c.p(p,m):(c=Ju(p),c.c(),c.m(t.parentNode,t)),p[1]?u?u.p(p,m):(u=Qu(p),u.c(),u.m(o,a)):u&&(u.d(1),u=null),m&28){d=_o(p[3]);let g;for(g=0;g<d.length;g+=1){const _=Zu(p,d,g);f[g]?f[g].p(_,m):(f[g]=ed(_),f[g].c(),f[g].m(l,null))}for(;g<f.length;g+=1)f[g].d(1);f.length=d.length}},i(p){h||(TT(s.$$.fragment,p),h=!0)},o(p){ET(s.$$.fragment,p),h=!1},d(p){p&&(Zr(t),Zr(e)),c&&c.d(p),vT(s),u&&u.d(),a_(f,p)}}}function CT(r,t,e){let i,{selected_color:s}=t,{colors:n}=t,{user_colors:o=[]}=t,{show_empty:a=!1}=t,{current_mode:l="hex"}=t,{color_picker:h=!1}=t;const c=AT();function u(_,v){return v==="hex"?Ci(_).toHexString():v==="rgb"?Ci(_).toRgbString():Ci(_).toHslString()}let d=`select-${n.findIndex(_=>u(_,l)===u(s,l))}`;function f(_,v){e(2,d=`${_}-${v.index}`),c(_,v)}function p(){c("select",{index:null,color:s}),e(0,h=!h)}const m=(_,v)=>f("edit",{index:_,color:v}),g=(_,v)=>f("select",{index:_,color:v});return r.$$set=_=>{"selected_color"in _&&e(6,s=_.selected_color),"colors"in _&&e(7,n=_.colors),"user_colors"in _&&e(1,o=_.user_colors),"show_empty"in _&&e(8,a=_.show_empty),"current_mode"in _&&e(9,l=_.current_mode),"color_picker"in _&&e(0,h=_.color_picker)},r.$$.update=()=>{r.$$.dirty&384&&e(3,i=a?n:n.filter(_=>_))},[h,o,d,i,f,p,s,n,a,l,m,g]}class 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;_<m.length;_+=1)g[_]=ad(od(r,m,_));return{c(){t=mi("div"),e=mi("button"),i=Ya(),s=mi("div"),n=mi("div"),o=mi("input"),a=Ya(),l=mi("button"),p&&p.c(),h=Ya(),c=mi("div");for(let _=0;_<g.length;_+=1)g[_].c();_i(e,"class","swatch svelte-w84deg"),sd(e,"background",r[0]),_i(o,"type","text"),o.value=r[2],_i(o,"class","svelte-w84deg"),_i(l,"class","eyedropper svelte-w84deg"),_i(n,"class","input-wrap svelte-w84deg"),_i(c,"class","buttons svelte-w84deg"),_i(t,"class","input svelte-w84deg")},m(_,v){h_(_,t,v),qe(t,e),qe(t,i),qe(t,s),qe(s,n),qe(n,o),qe(n,a),qe(n,l),p&&p.m(l,null),qe(s,h),qe(s,c);for(let y=0;y<g.length;y+=1)g[y]&&g[y].m(c,null);u=!0,d||(f=[kn(e,"click",r[6]),kn(o,"change",r[7]),kn(l,"click",r[4])],d=!0)},p(_,[v]){if(v&1&&sd(e,"background",_[0]),(!u||v&4&&o.value!==_[2])&&(o.value=_[2]),v&10){m=id(_[3]);let y;for(y=0;y<m.length;y+=1){const b=od(_,m,y);g[y]?g[y].p(b,v):(g[y]=ad(b),g[y].c(),g[y].m(c,null))}for(;y<g.length;y+=1)g[y].d(1);g.length=m.length}},i(_){u||(c_(p),u=!0)},o(_){u_(p),u=!1},d(_){_&&l_(t),p&&p.d(),BT(g,_),d=!1,FT(f)}}}function GT(r,t,e){let i,{color:s}=t,{current_mode:n="hex"}=t;const o=NT(),a=[["Hex","hex"],["RGB","rgb"],["HSL","hsl"]];function l(p,m){return m==="hex"?Ci(p).toHexString():m==="rgb"?Ci(p).toRgbString():Ci(p).toHslString()}function h(){new EyeDropper().open().then(m=>{e(0,s=m.sRGBHex)})}const c=!!window.EyeDropper;function u(){o("selected",i),o("close")}const d=p=>e(0,s=p.currentTarget.value),f=p=>e(1,n=p);return r.$$set=p=>{"color"in p&&e(0,s=p.color),"current_mode"in p&&e(1,n=p.current_mode)},r.$$.update=()=>{r.$$.dirty&3&&e(2,i=l(s,n)),r.$$.dirty&4&&i&&o("selected",i)},[s,n,i,a,h,c,u,d,f]}class 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;_<d.length;_+=1)f[_]=Ed(Td(r,d,_));const p=_=>vh(f[_],1,1,()=>{f[_]=null});let m=nl({length:25}),g=[];for(let _=0;_<m.length;_+=1)g[_]=cA(hA(r,m,_));return{c(){t=Un("div"),e=Un("div");for(let _=0;_<f.length;_+=1)f[_].c();i=oA(),s=Un("div");for(let _=0;_<g.length;_+=1)g[_].c();Ln(s,"class","grid svelte-12y7ld0"),wd(s,"finished",r[6]),Ln(e,"class","box svelte-12y7ld0"),ci(e,"width",n),ci(e,"height",o),ci(e,"top",a),ci(e,"left",l),Ln(t,"class","wrap svelte-12y7ld0")},m(_,v){y_(_,t,v),sl(t,e);for(let y=0;y<f.length;y+=1)f[y]&&f[y].m(e,null);sl(e,i),sl(e,s);for(let y=0;y<g.length;y+=1)g[y]&&g[y].m(s,null);h=!0,c||(u=[ol(window,"mousemove",r[11]),ol(window,"mouseup",r[10]),ol(s,"mousedown",r[9])],c=!0)},p(_,v){if(v[0]&386){d=nl(_[7]);let y;for(y=0;y<d.length;y+=1){const b=Td(_,d,y);f[y]?(f[y].p(b,v),Gn(f[y],1)):(f[y]=Ed(b),f[y].c(),Gn(f[y],1),f[y].m(e,i))}for(eA(),y=d.length;y<f.length;y+=1)p(y);JE()}(!h||v[0]&64)&&wd(s,"finished",_[6]),v[0]&8&&n!==(n=`${_[3]}px`)&&ci(e,"width",n),v[0]&4&&o!==(o=`${_[2]}px`)&&ci(e,"height",o),v[0]&16&&a!==(a=`${_[4]}px`)&&ci(e,"top",a),v[0]&32&&l!==(l=`${_[5]}px`)&&ci(e,"left",l)},i(_){if(!h){for(let v=0;v<d.length;v+=1)Gn(f[v]);h=!0}},o(_){f=f.filter(Boolean);for(let v=0;v<f.length;v+=1)vh(f[v]);h=!1},d(_){_&&g_(t),xd(f,_),xd(g,_),c=!1,sA(u)}}}function dA(r,t,e){let i,s=v_,n=()=>(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;v<f.length;v+=1){let y=Md(r,f,v),b=p(y);i.set(b,e[v]=kd(b,y))}function m(v){r[24](v)}let g={hidden:r[2]||r[1]==="webcam"||r[11]!=="bg",filetype:"image/*",root:r[3],disable_click:!r[4].includes("upload"),format:"blob",upload:r[7],stream_handler:r[8]};r[0]!==void 0&&(g.dragging=r[0]),l=new $_({props:g}),r[23](l),b_.push(()=>DA(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;v<e.length;v+=1)e[v].c();s=ll(),n=Ss("span"),o=ll(),a=Ss("div"),Vh(l.$$.fragment),c=ll(),_&&_.c(),As(n,"class","sep svelte-ip7ypz"),As(t,"class","source-wrap svelte-ip7ypz"),As(a,"class","upload-container svelte-ip7ypz"),Rd(a,"click-disabled",!!r[2]||r[1]==="webcam"||r[11]!=="bg"),vi(a,"height",u)},m(v,y){Vr(v,t,y);for(let b=0;b<e.length;b+=1)e[b]&&e[b].m(t,null);zn(t,s),zn(t,n),Vr(v,o,y),Vr(v,a,y),jh(l,a,null),zn(a,c),_&&_.m(a,null),d=!0},p(v,y){y[0]&1024&&(f=Id(v[10]),wh(),e=GA(e,y,p,1,v,f,i,t,LA,kd,s,Md),xh());const b={};y[0]&2054&&(b.hidden=v[2]||v[1]==="webcam"||v[11]!=="bg"),y[0]&8&&(b.root=v[3]),y[0]&16&&(b.disable_click=!v[4].includes("upload")),y[0]&128&&(b.upload=v[7]),y[0]&256&&(b.stream_handler=v[8]),!h&&y[0]&1&&(h=!0,b.dragging=v[0],kA(()=>h=!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<f.length;y+=1)Ge(e[y]);Ge(l.$$.fragment,v),Ge(_),d=!0}},o(v){for(let y=0;y<e.length;y+=1)Ai(e[y]);Ai(l.$$.fragment,v),Ai(_),d=!1},d(v){v&&(Xr(t),Xr(o),Xr(a));for(let y=0;y<e.length;y+=1)e[y].d();r[23](null),Wh(l),_&&_.d()}}}function kd(r,t){let e,i,s;return i=new pf({props:{Icon:t[38],size:"medium",padded:!1,label:t[39]+" button",hasPopup:!0,transparent:!0}}),i.$on("click",function(){OA(t[41])&&t[41].apply(this,arguments)}),{key:r,first:null,c(){e=x_(),Vh(i.$$.fragment),this.first=e},m(n,o){Vr(n,e,o),jh(i,n,o),s=!0},p(n,o){t=n;const a={};o[0]&1024&&(a.Icon=t[38]),o[0]&1024&&(a.label=t[39]+" button"),i.$set(a)},i(n){s||(Ge(i.$$.fragment,n),s=!0)},o(n){Ai(i.$$.fragment,n),s=!1},d(n){n&&Xr(e),Wh(i,n)}}}function Dd(r){let t,e,i,s=`${r[12].child_width}px`,n=`${r[12].child_height}px`,o=`${r[12].child_top-r[12].parent_top}px`,a;return i=new D_({props:{upload:r[7],root:r[3],mirror_webcam:r[5],streaming:!1,mode:"image",include_audio:!1,i18n:r[6]}}),i.$on("capture",r[17]),i.$on("error",r[26]),i.$on("drag",r[27]),{c(){t=Ss("div"),e=Ss("div"),Vh(i.$$.fragment),As(e,"class","modal-inner svelte-ip7ypz"),As(t,"class","modal svelte-ip7ypz"),vi(t,"max-width",s),vi(t,"max-height",n),vi(t,"top",o)},m(l,h){Vr(l,t,h),zn(t,e),jh(i,e,null),a=!0},p(l,h){const c={};h[0]&128&&(c.upload=l[7]),h[0]&8&&(c.root=l[3]),h[0]&32&&(c.mirror_webcam=l[5]),h[0]&64&&(c.i18n=l[6]),i.$set(c),h[0]&4096&&s!==(s=`${l[12].child_width}px`)&&vi(t,"max-width",s),h[0]&4096&&n!==(n=`${l[12].child_height}px`)&&vi(t,"max-height",n),h[0]&4096&&o!==(o=`${l[12].child_top-l[12].parent_top}px`)&&vi(t,"top",o)},i(l){a||(Ge(i.$$.fragment,l),a=!0)},o(l){Ai(i.$$.fragment,l),a=!1},d(l){l&&Xr(t),Wh(i)}}}function $A(r){let t,e,i,s,n=r[4].length&&Bd(r);return{c(){n&&n.c(),t=x_()},m(o,a){n&&n.m(o,a),Vr(o,t,a),e=!0,i||(s=NA(window,"keydown",r[18]),i=!0)},p(o,a){o[4].length?n?(n.p(o,a),a[0]&16&&Ge(n,1)):(n=Bd(o),n.c(),Ge(n,1),n.m(t.parentNode,t)):n&&(wh(),Ai(n,1,1,()=>{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;et<R.length;et++){const tt=R[et].types.find(st=>st.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<h.length;u+=1){let d=Vd(r,h,u),f=c(d);i.set(f,e[u]=Yd(f,d))}return{c(){t=ni("ul");for(let u=0;u<e.length;u+=1)e[u].c();s=Th(),n=ni("li"),o=ni("button"),o.textContent="+",re(o,"aria-label","Add Layer"),re(o,"class","svelte-wbw3z5"),re(n,"class","svelte-wbw3z5"),re(t,"class","svelte-wbw3z5")},m(u,d){Uo(u,t,d);for(let f=0;f<e.length;f+=1)e[f]&&e[f].m(t,null);ie(t,s),ie(t,n),ie(n,o),a||(l=Yh(o,"click",r[11]),a=!0)},p(u,d){d&268&&(h=Hd(u[2]),e=O2(e,d,c,1,u,h,i,t,C2,Yd,s,Vd))},d(u){u&&Lo(t);for(let d=0;d<e.length;d+=1)e[d].d();a=!1,l()}}}function Yd(r,t){let e,i,s,n=t[28]+1+"",o,a,l,h;function c(){return t[17](t[28])}return{key:r,first:null,c(){e=ni("li"),i=ni("button"),s=wo("Layer "),o=wo(n),re(i,"aria-label",a=`layer-${t[28]+1}`),re(i,"class","svelte-wbw3z5"),To(i,"selected_layer",t[3]===t[26]),re(e,"class","svelte-wbw3z5"),this.first=e},m(u,d){Uo(u,e,d),ie(e,i),ie(i,s),ie(i,o),l||(h=Yh(i,"click",c),l=!0)},p(u,d){t=u,d&4&&n!==(n=t[28]+1+"")&&T_(o,n),d&4&&a!==(a=`layer-${t[28]+1}`)&&re(i,"aria-label",a),d&12&&To(i,"selected_layer",t[3]===t[26])},d(u){u&&Lo(e),l=!1,h()}}}function U2(r){let t,e,i=r[0]&&Wd(r);return{c(){i&&i.c(),t=R2()},m(s,n){i&&i.m(s,n),Uo(s,t,n),e=!0},p(s,[n]){s[0]?i?(i.p(s,n),n&1&&$n(i,1)):(i=Wd(s),i.c(),$n(i,1),i.m(t.parentNode,t)):i&&(P2(),Eh(i,1,1,()=>{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;p<l.length;p+=1)h=S_(h,l[p]);t=new cf({props:h}),t.$on("clear_status",r[45]);function c(p){r[48](p)}function u(p){r[49](p)}function d(p){r[51](p)}let f={canvas_size:r[27],crop_size:r[22],value:r[0],root:r[9],sources:r[17],label:r[6],show_label:r[7],height:r[10],fixed_canvas:r[28],brush:r[20],eraser:r[21],changeable:r[25].includes("apply"),realtime:r[25].includes("change")||r[25].includes("input"),i18n:r[30].i18n,transforms:r[23],accept_blobs:r[26].accept_blobs,layers:r[24],status:r[1]?.status,upload:r[46],stream_handler:r[47],placeholder:r[19],full_history:r[2]};return r[34]!==void 0&&(f.dragging=r[34]),r[33]!==void 0&&(f.image_id=r[33]),r[31]!==void 0&&(f.dynamic_height=r[31]),i=new sS({props:f}),Xn.push(()=>ml(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<n.length;a+=1)o=S_(o,n[a]);return t=new cf({props:o}),t.$on("clear_status",r[41]),i=new k_({props:{value:r[0]?.composite||null,label:r[6],show_label:r[7],show_download_button:r[8],selectable:r[12],show_share_button:r[16],i18n:r[30].i18n,show_fullscreen_button:r[29]}}),i.$on("select",r[42]),i.$on("share",r[43]),i.$on("error",r[44]),{c(){Jr(t.$$.fragment),e=R_(),Jr(i.$$.fragment)},m(a,l){ts(t,a,l),Zh(a,e,l),ts(i,a,l),s=!0},p(a,l){const h=l[0]&1073741826?I_(n,[l[0]&1073741824&&{autoscroll:a[30].autoscroll},l[0]&1073741824&&{i18n:a[30].i18n},l[0]&2&&C_(a[1])]):{};t.$set(h);const c={};l[0]&1&&(c.value=a[0]?.composite||null),l[0]&64&&(c.label=a[6]),l[0]&128&&(c.show_label=a[7]),l[0]&256&&(c.show_download_button=a[8]),l[0]&4096&&(c.selectable=a[12]),l[0]&65536&&(c.show_share_button=a[16]),l[0]&1073741824&&(c.i18n=a[30].i18n),l[0]&536870912&&(c.show_fullscreen_button=a[29]),i.$set(c)},i(a){s||(Oi(t.$$.fragment,a),Oi(i.$$.fragment,a),s=!0)},o(a){Ni(t.$$.fragment,a),Ni(i.$$.fragment,a),s=!1},d(a){a&&qh(e),Qr(t,a),Qr(i,a)}}}function gS(r){let t,e,i,s;const n=[pS,fS],o=[];function a(l,h){return l[18]?1:0}return t=a(r),e=o[t]=n[t](r),{c(){e.c(),i=lS()},m(l,h){o[t].m(l,h),Zh(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?o[t].p(l,h):(hS(),Ni(o[c],1,1,()=>{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
|