import { f as fallback } from './async-Djx13DAD.js';
import { b as spread_props, c as bind_props, d as attr_class, i as slot, a as attr, g as attr_style, j as stringify } from './index-B7gr0Dsc.js';
import { I as Ie$1, S as Ss$1, a as an$1 } from './2-CeYbpaU1.js';
import { c as createEventDispatcher } from './index-server-lqjMX237.js';
import { g } from './utils.svelte-D8Xdzglu.js';
import Q$1 from './ImagePreview-C_D-UOrN.js';
import { G } from './Block-2-03Azgw.js';
import './MarkdownCode.svelte_svelte_type_style_lang-DJRtJayx.js';
import { R } from './index3-DONAw0dG.js';
import { i } from './Image2-CJoaEJF4.js';
import { s } from './tinycolor-DfhFic3A.js';
import { e } from './Check-THd8EJll.js';
import { k } from './BlockLabel-DYKzuObf.js';
import { e as escape_html } from './escaping-CBnpiEl5.js';
import './context-BZS6UlnY.js';
import './uneval-DjLoL4oF.js';
import './clone-BLo8hHdj.js';
import './index5-BoOEKc6P.js';
import './dev-fallback-Bc5Ork7Y.js';
import './DownloadLink-BLkRTIUs.js';
import './IconButton-7VBZdgpA.js';
import './Empty-uaeWNu3s.js';
import './ShareButton-B1Vd_e6T.js';
import './Download-rAXPPveZ.js';
import './IconButtonWrapper-DlgTGGi-.js';
import './FullscreenButton-DPSRpBkM.js';
import './Maximize-DxOGYNPn.js';
import './Image-Bw5_tidM.js';
import './prism-python-BaDPvmdn.js';
import './spring-DyDQVd5U.js';
import './Clear-CiR-WD8W.js';

function At(s$1,t){s$1.component(e=>{let i,r=t.Icon,n=fallback(t.label,""),o=fallback(t.show_label,false),a=fallback(t.pending,false),h=fallback(t.size,"small"),l=fallback(t.padded,true),c=fallback(t.highlight,false),u=fallback(t.disabled,false),f=fallback(t.hasPopup,false),d=fallback(t.color,"var(--block-label-text-color)"),_=fallback(t.transparent,false),g=fallback(t.background,"var(--background-fill-primary)"),p=fallback(t.offset,0),m=fallback(t.label_position,"left"),y=fallback(t.roundedness,"quite"),x=fallback(t.onclick,void 0);i=c?"var(--color-accent)":d.toString(),e.push(`<button${attr("disabled",u,true)}${attr("aria-label",n)}${attr("aria-haspopup",f)}${attr("title",n)}${attr_class(`${stringify(y)}-round`,"svelte-1lrnmgy",{pending:a,padded:l,highlight:c,transparent:_})}${attr_style("",{color:!u&&i?i:"var(--block-label-text-color)","--bg-color":u?"auto":g,"margin-left":p+"px"})}>`),o&&m==="left"?(e.push("<!--[-->"),e.push(`<span style="margin-left: 4px;" class="svelte-1lrnmgy">${escape_html(n)}</span>`)):e.push("<!--[!-->"),e.push(`<!--]--> <div${attr_class("svelte-1lrnmgy",void 0,{small:h==="small",large:h==="large",medium:h==="medium"})}>`),r(e,{}),e.push("<!----></div> "),o&&m==="right"?(e.push("<!--[-->"),e.push(`<span style="margin-right: 4px;" class="svelte-1lrnmgy">${escape_html(n)}</span>`)):e.push("<!--[!-->"),e.push("<!--]--></button>"),bind_props(t,{Icon:r,label:n,show_label:o,pending:a,size:h,padded:l,highlight:c,disabled:u,hasPopup:f,color:d,transparent:_,background:g,offset:p,label_position:m,roundedness:y,onclick:x});});}var B=(s=>(s.Application="application",s.WebGLPipes="webgl-pipes",s.WebGLPipesAdaptor="webgl-pipes-adaptor",s.WebGLSystem="webgl-system",s.WebGPUPipes="webgpu-pipes",s.WebGPUPipesAdaptor="webgpu-pipes-adaptor",s.WebGPUSystem="webgpu-system",s.CanvasSystem="canvas-system",s.CanvasPipesAdaptor="canvas-pipes-adaptor",s.CanvasPipes="canvas-pipes",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s.MaskEffect="mask-effect",s.BlendMode="blend-mode",s.TextureSource="texture-source",s.Environment="environment",s.ShapeBuilder="shape-builder",s.Batcher="batcher",s))(B||{});const gs=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s};}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},Je=(s,t)=>gs(s).priority??t,ft={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(gs).forEach(t=>{t.type.forEach(e=>this._removeHandlers[e]?.(t));}),this},add(...s){return s.map(gs).forEach(t=>{t.type.forEach(e=>{const i=this._addHandlers,r=this._queue;i[e]?i[e]?.(t):(r[e]=r[e]||[],r[e]?.push(t));});}),this},handle(s,t,e){const i=this._addHandlers,r=this._removeHandlers;if(i[s]||r[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,r[s]=e;const n=this._queue;return n[s]&&(n[s]?.forEach(o=>t(o)),delete n[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref);},e=>{e.name&&delete t[e.name];})},handleByNamedList(s,t,e=-1){return this.handle(s,i=>{t.findIndex(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,o)=>Je(o.value,e)-Je(n.value,e)));},i=>{const r=t.findIndex(n=>n.name===i.name);r!==-1&&t.splice(r,1);})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,n)=>Je(n,e)-Je(r,e)));},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1);})},mixin(s,...t){for(const e of t)Object.defineProperties(s.prototype,Object.getOwnPropertyDescriptors(e));}},Na={extension:{type:B.Environment,name:"browser",priority:-1},test:()=>true,load:async()=>{await import('./browserAll-B9hV4A6o.js');}},Wa={extension:{type:B.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await import('./webworkerAll-CL7I_0hg.js');}};class pt{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t;}clone(t){return new pt(t??this._observer,this._x,this._y)}set(t=0,e=t){return (this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return (this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return `[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this));}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this));}}var Oi={exports:{}},hr;function Ha(){return hr||(hr=1,(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=false));function r(h,l,c){this.fn=h,this.context=l,this.once=c||false;}function n(h,l,c,u,f){if(typeof c!="function")throw new TypeError("The listener must be a function");var d=new r(c,u||h,f),_=e?e+l:l;return h._events[_]?h._events[_].fn?h._events[_]=[h._events[_],d]:h._events[_].push(d):(h._events[_]=d,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new i:delete h._events[l];}function a(){this._events=new i,this._eventsCount=0;}a.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)t.call(c,u)&&l.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=e?e+l:l,u=this._events[c];if(!u)return [];if(u.fn)return [u.fn];for(var f=0,d=u.length,_=new Array(d);f<d;f++)_[f]=u[f].fn;return _},a.prototype.listenerCount=function(l){var c=e?e+l:l,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(l,c,u,f,d,_){var g=e?e+l:l;if(!this._events[g])return  false;var p=this._events[g],m=arguments.length,y,x;if(p.fn){switch(p.once&&this.removeListener(l,p.fn,void 0,true),m){case 1:return p.fn.call(p.context),true;case 2:return p.fn.call(p.context,c),true;case 3:return p.fn.call(p.context,c,u),true;case 4:return p.fn.call(p.context,c,u,f),true;case 5:return p.fn.call(p.context,c,u,f,d),true;case 6:return p.fn.call(p.context,c,u,f,d,_),true}for(x=1,y=new Array(m-1);x<m;x++)y[x-1]=arguments[x];p.fn.apply(p.context,y);}else {var b=p.length,A;for(x=0;x<b;x++)switch(p[x].once&&this.removeListener(l,p[x].fn,void 0,true),m){case 1:p[x].fn.call(p[x].context);break;case 2:p[x].fn.call(p[x].context,c);break;case 3:p[x].fn.call(p[x].context,c,u);break;case 4:p[x].fn.call(p[x].context,c,u,f);break;default:if(!y)for(A=1,y=new Array(m-1);A<m;A++)y[A-1]=arguments[A];p[x].fn.apply(p[x].context,y);}}return  true},a.prototype.on=function(l,c,u){return n(this,l,c,u,false)},a.prototype.once=function(l,c,u){return n(this,l,c,u,true)},a.prototype.removeListener=function(l,c,u,f){var d=e?e+l:l;if(!this._events[d])return this;if(!c)return o(this,d),this;var _=this._events[d];if(_.fn)_.fn===c&&(!f||_.once)&&(!u||_.context===u)&&o(this,d);else {for(var g=0,p=[],m=_.length;g<m;g++)(_[g].fn!==c||f&&!_[g].once||u&&_[g].context!==u)&&p.push(_[g]);p.length?this._events[d]=p.length===1?p[0]:p:o(this,d);}return this},a.prototype.removeAllListeners=function(l){var c;return l?(c=e?e+l:l,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,s.exports=a;})(Oi)),Oi.exports}var Va=Ha();const Ot=an$1(Va),Ya=Math.PI*2,Xa=180/Math.PI,ja=Math.PI/180;class N{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e;}clone(){return new N(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}toString(){return `[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Gi.x=0,Gi.y=0,Gi}}const Gi=new N;class H{constructor(t=1,e=0,i=0,r=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=r,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,r,n,o){return this.a=t,this.b=e,this.c=i,this.d=r,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 N;const i=t.x,r=t.y;return e.x=this.a*i+this.c*r+this.tx,e.y=this.b*i+this.d*r+this.ty,e}applyInverse(t,e){e=e||new N;const i=this.a,r=this.b,n=this.c,o=this.d,a=this.tx,h=this.ty,l=1/(i*o+n*-r),c=t.x,u=t.y;return e.x=o*l*c+-n*l*u+(h*n-a*o)*l,e.y=i*l*u+-r*l*c+(-h*i+a*r)*l,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),r=this.a,n=this.c,o=this.tx;return this.a=r*e-this.b*i,this.b=r*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,r=this.c,n=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*r,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}appendFrom(t,e){const i=t.a,r=t.b,n=t.c,o=t.d,a=t.tx,h=t.ty,l=e.a,c=e.b,u=e.c,f=e.d;return this.a=i*l+r*u,this.b=i*c+r*f,this.c=n*l+o*u,this.d=n*c+o*f,this.tx=a*l+h*u+e.tx,this.ty=a*c+h*f+e.ty,this}setTransform(t,e,i,r,n,o,a,h,l){return this.a=Math.cos(a+l)*n,this.b=Math.sin(a+l)*n,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*o,this.tx=t-(i*this.a+r*this.c),this.ty=e-(i*this.b+r*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,r=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=r*t.a+this.d*t.c,this.d=r*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,r=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-r,n),h=Math.atan2(i,e),l=Math.abs(a+h);return l<1e-5||Math.abs(Ya-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=h),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(r*r+n*n),t.position.x=this.tx+(o.x*e+o.y*r),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,o=t*r-e*i;return this.a=r/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-r*n)/o,this.ty=-(t*this.ty-e*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}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 H;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}equals(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}toString(){return `[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Ka.identity()}static get shared(){return qa.identity()}}const qa=new H,Ka=new H,ie=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],se=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],re=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ne=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],ms=[],Pn=[],$e=Math.sign;function Za(){for(let s=0;s<16;s++){const t=[];ms.push(t);for(let e=0;e<16;e++){const i=$e(ie[s]*ie[e]+re[s]*se[e]),r=$e(se[s]*ie[e]+ne[s]*se[e]),n=$e(ie[s]*re[e]+re[s]*ne[e]),o=$e(se[s]*re[e]+ne[s]*ne[e]);for(let a=0;a<16;a++)if(ie[a]===i&&se[a]===r&&re[a]===n&&ne[a]===o){t.push(a);break}}}for(let s=0;s<16;s++){const t=new H;t.set(ie[s],se[s],re[s],ne[s],0,0),Pn.push(t);}}Za();const K={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:s=>ie[s],uY:s=>se[s],vX:s=>re[s],vY:s=>ne[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>ms[s][t],sub:(s,t)=>ms[s][K.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?K.S:K.N:Math.abs(t)*2<=Math.abs(s)?s>0?K.E:K.W:t>0?s>0?K.SE:K.SW:s>0?K.NE:K.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const r=Pn[K.inv(t)];r.tx=e,r.ty=i,s.append(r);},transformRectCoords:(s,t,e,i)=>{const{x:r,y:n,width:o,height:a}=s,{x:h,y:l,width:c,height:u}=t;return e===K.E?(i.set(r+h,n+l,o,a),i):e===K.S?i.set(c-n-a+h,r+l,a,o):e===K.W?i.set(c-r-o+h,u-n-a+l,o,a):e===K.N?i.set(n+h,u-r-o+l,a,o):i.set(r+h,n+l,o,a)}},ti=[new N,new N,new N,new N];class Z{constructor(t=0,e=0,i=0,r=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(r);}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new Z(0,0,0,0)}clone(){return new Z(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?false:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i,r=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return  false;const a=this.x,h=this.y,l=i*(1-r),c=i-l,u=a-l,f=a+n+l,d=h-l,_=h+o+l,g=a+c,p=a+n-c,m=h+c,y=h+o-c;return t>=u&&t<=f&&e>=d&&e<=_&&!(t>g&&t<p&&e>m&&e<y)}intersects(t,e){if(!e){const E=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=E)return  false;const M=this.y<t.y?t.y:this.y;return (this.bottom>t.bottom?t.bottom:this.bottom)>M}const i=this.left,r=this.right,n=this.top,o=this.bottom;if(r<=i||o<=n)return  false;const a=ti[0].set(t.left,t.top),h=ti[1].set(t.left,t.bottom),l=ti[2].set(t.right,t.top),c=ti[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return  false;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(a.x,h.x,l.x,c.x)<=i||Math.min(a.x,h.x,l.x,c.x)>=r||Math.max(a.y,h.y,l.y,c.y)<=n||Math.min(a.y,h.y,l.y,c.y)>=o))return  false;const f=u*(h.y-a.y),d=u*(a.x-h.x),_=f*i+d*n,g=f*r+d*n,p=f*i+d*o,m=f*r+d*o;if(Math.max(_,g,p,m)<=f*a.x+d*a.y||Math.min(_,g,p,m)>=f*c.x+d*c.y)return  false;const y=u*(a.y-l.y),x=u*(l.x-a.x),b=y*i+x*n,A=y*r+x*n,w=y*i+x*o,k=y*r+x*o;return !(Math.max(b,A,w,k)<=y*a.x+x*a.y||Math.min(b,A,w,k)>=y*c.x+x*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),r=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=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,r=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=r-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=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=r,this.height=n-r,this}getBounds(t){return t||(t=new Z),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return  false;const e=t.x,i=t.y,r=t.x+t.width,n=t.y+t.height;return e>=this.x&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&r>=this.x&&r<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(t,e,i,r){return this.x=t,this.y=e,this.width=i,this.height=r,this}toString(){return `[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Di={default:-1};function st(s="default"){return Di[s]===void 0&&(Di[s]=-1),++Di[s]}const lr=new Set,j="8.0.0",Qa="8.3.4",ge={quiet:false,noColor:false},D=(s,t,e=3)=>{if(ge.quiet||lr.has(t))return;let i=new Error().stack;const r=`${t}
Deprecated since v${s}`,n=typeof console.groupCollapsed=="function"&&!ge.noColor;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",r):(i=i.split(`
`).splice(e).join(`
`),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",r),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",r),console.warn(i))),lr.add(t);};Object.defineProperties(D,{quiet:{get:()=>ge.quiet,set:s=>{ge.quiet=s;},enumerable:true,configurable:false},noColor:{get:()=>ge.noColor,set:s=>{ge.noColor=s;},enumerable:true,configurable:false}});const In=()=>{};function bi(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function cr(s){return !(s&s-1)&&!!s}function zn(s){const t={};for(const e in s)s[e]!==void 0&&(t[e]=s[e]);return t}const ur=Object.create(null);function Ja(s){const t=ur[s];return t===void 0&&(ur[s]=st("resource")),t}const En=class Rn extends Ot{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=false,t={...Rn.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1;}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t;}get addressMode(){return this.addressModeU}set wrapMode(t){D(j,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t;}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t;}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear");}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this);}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=Ja(t),this._resourceId}destroy(){this.destroyed=true,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners();}};En.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let wi=En;const Fn=class Bn extends Ot{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=st("textureSource"),this._resourceType="textureSource",this._resourceId=st("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=false,this.format="rgba8unorm",this.dimension="2d",this.antialias=false,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...Bn.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new wi(zn(t)),this.destroyed=false,this._refreshPOT();}get source(){return this}get style(){return this._style}set style(t){this.style!==t&&(this._style?.off("change",this._onStyleChange,this),this._style=t,this._style?.on("change",this._onStyleChange,this),this._onStyleChange());}set maxAnisotropy(t){this._style.maxAnisotropy=t;}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t;}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t;}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t;}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t;}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t;}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t;}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t;}_onStyleChange(){this.emit("styleChange",this);}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this);}destroy(){this.destroyed=true,this.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners();}unload(){this._resourceId=st("resource"),this.emit("change",this),this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy?.();this._gpuData=Object.create(null);}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t);}resize(t,e,i){i||(i=this._resolution),t||(t=this.width),e||(e=this.height);const r=Math.round(t*i),n=Math.round(e*i);return this.width=r/i,this.height=n/i,this._resolution=i,this.pixelWidth===r&&this.pixelHeight===n?false:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=st("resource"),this.emit("change",this),true)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this);}set wrapMode(t){this._style.wrapMode=t;}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t;}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=cr(this.pixelWidth)&&cr(this.pixelHeight);}static test(t){throw new Error("Unimplemented")}};Fn.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:false,sampleCount:1,antialias:false,autoGarbageCollect:false};let It=Fn;class Xs extends It{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(i="bgra8unorm")),super({...t,resource:e,format:i}),this.uploadMethodId="buffer";}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}Xs.extension=B.TextureSource;const dr=new H;class $a{constructor(t,e){this.mapCoord=new H,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=false,this.texture=t;}get texture(){return this._texture}set texture(t){this.texture!==t&&(this._texture?.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update());}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let r=0;r<t.length;r+=2){const n=t[r],o=t[r+1];e[r]=n*i.a+o*i.c+i.tx,e[r+1]=n*i.b+o*i.d+i.ty;}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const i=t.orig,r=t.trim;r&&(dr.set(i.width/r.width,0,0,i.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(dr));const n=t.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,h=this.clampOffset/n._resolution;return o[0]=(t.frame.x+a+h)/n.width,o[1]=(t.frame.y+a+h)/n.height,o[2]=(t.frame.x+t.frame.width-a+h)/n.width,o[3]=(t.frame.y+t.frame.height-a+h)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&t.rotate===0,true}}class W extends Ot{constructor({source:t,label:e,frame:i,orig:r,trim:n,defaultAnchor:o,defaultBorders:a,rotate:h,dynamic:l}={}){if(super(),this.uid=st("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Z,this.noFrame=false,this.dynamic=false,this.isTexture=true,this.label=e,this.source=t?.source??new It,this.noFrame=!i,i)this.frame.copyFrom(i);else {const{width:c,height:u}=this._source;this.frame.width=c,this.frame.height=u;}this.orig=r||this.frame,this.trim=n,this.rotate=h??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=false,this.dynamic=l||false,this.updateUvs();}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this);}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new $a(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:i,height:r}=this._source,n=e.x/i,o=e.y/r,a=e.width/i,h=e.height/r;let l=this.rotate;if(l){const c=a/2,u=h/2,f=n+c,d=o+u;l=K.add(l,K.NW),t.x0=f+c*K.uX(l),t.y0=d+u*K.uY(l),l=K.add(l,2),t.x1=f+c*K.uX(l),t.y1=d+u*K.uY(l),l=K.add(l,2),t.x2=f+c*K.uX(l),t.y2=d+u*K.uY(l),l=K.add(l,2),t.x3=f+c*K.uX(l),t.y3=d+u*K.uY(l);}else t.x0=n,t.y0=o,t.x1=n+a,t.y1=o,t.x2=n+a,t.y2=o+h,t.x3=n,t.y3=o+h;}destroy(t=false){this._source&&(this._source.off("resize",this.update,this),t&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=true,this.emit("destroy",this),this.removeAllListeners();}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this);}get baseTexture(){return D(j,"Texture.baseTexture is now Texture.source"),this._source}}W.EMPTY=new W({label:"EMPTY",source:new It({label:"EMPTY"})});W.EMPTY.destroy=In;W.WHITE=new W({source:new Xs({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});W.WHITE.destroy=In;function th(s,t,e){const{width:i,height:r}=e.orig,n=e.trim;if(n){const o=n.width,a=n.height;s.minX=n.x-t._x*i,s.maxX=s.minX+o,s.minY=n.y-t._y*r,s.maxY=s.minY+a;}else s.minX=-t._x*i,s.maxX=s.minX+i,s.minY=-t._y*r,s.maxY=s.minY+r;}const fr=new H;class Lt{constructor(t=1/0,e=1/0,i=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=fr,this.minX=t,this.minY=e,this.maxX=i,this.maxY=r;}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Z);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=fr,this}set(t,e,i,r){this.minX=t,this.minY=e,this.maxX=i,this.maxY=r;}addFrame(t,e,i,r,n){n||(n=this.matrix);const o=n.a,a=n.b,h=n.c,l=n.d,c=n.tx,u=n.ty;let f=this.minX,d=this.minY,_=this.maxX,g=this.maxY,p=o*t+h*e+c,m=a*t+l*e+u;p<f&&(f=p),m<d&&(d=m),p>_&&(_=p),m>g&&(g=m),p=o*i+h*e+c,m=a*i+l*e+u,p<f&&(f=p),m<d&&(d=m),p>_&&(_=p),m>g&&(g=m),p=o*t+h*r+c,m=a*t+l*r+u,p<f&&(f=p),m<d&&(d=m),p>_&&(_=p),m>g&&(g=m),p=o*i+h*r+c,m=a*i+l*r+u,p<f&&(f=p),m<d&&(d=m),p>_&&(_=p),m>g&&(g=m),this.minX=f,this.minY=d,this.maxX=_,this.maxY=g;}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e);}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e);}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY;}applyMatrix(t){const e=this.minX,i=this.minY,r=this.maxX,n=this.maxY,{a:o,b:a,c:h,d:l,tx:c,ty:u}=t;let f=o*e+h*i+c,d=a*e+l*i+u;this.minX=f,this.minY=d,this.maxX=f,this.maxY=d,f=o*r+h*i+c,d=a*r+l*i+u,this.minX=f<this.minX?f:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=d>this.maxY?d:this.maxY,f=o*e+h*n+c,d=a*e+l*n+u,this.minX=f<this.minX?f:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=d>this.maxY?d:this.maxY,f=o*r+h*n+c,d=a*r+l*n+u,this.minX=f<this.minX?f:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=d>this.maxY?d:this.maxY;}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,r){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>r&&(this.maxY=r),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new Lt(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e;}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e;}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t;}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t;}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,r){let n=this.minX,o=this.minY,a=this.maxX,h=this.maxY;r||(r=this.matrix);const l=r.a,c=r.b,u=r.c,f=r.d,d=r.tx,_=r.ty;for(let g=e;g<i;g+=2){const p=t[g],m=t[g+1],y=l*p+u*m+d,x=c*p+f*m+_;n=y<n?y:n,o=x<o?x:o,a=y>a?y:a,h=x>h?x:h;}this.minX=n,this.minY=o,this.maxX=a,this.maxY=h;}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return `[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}var eh={grad:.9,turn:360,rad:360/(2*Math.PI)},Ht=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},lt=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},Tt=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},Ln=function(s){return (s=isFinite(s)?s%360:0)>0?s:s+360},_r=function(s){return {r:Tt(s.r,0,255),g:Tt(s.g,0,255),b:Tt(s.b,0,255),a:Tt(s.a)}},Ui=function(s){return {r:lt(s.r),g:lt(s.g),b:lt(s.b),a:lt(s.a,3)}},ih=/^#([0-9a-f]{3,8})$/i,ei=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},On=function(s){var t=s.r,e=s.g,i=s.b,r=s.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:r}},Gn=function(s){var t=s.h,e=s.s,i=s.v,r=s.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),l=n%6;return {r:255*[i,a,o,o,h,i][l],g:255*[h,i,i,a,o,o][l],b:255*[o,o,h,i,i,a][l],a:r}},pr=function(s){return {h:Ln(s.h),s:Tt(s.s,0,100),l:Tt(s.l,0,100),a:Tt(s.a)}},gr=function(s){return {h:lt(s.h),s:lt(s.s),l:lt(s.l),a:lt(s.a,3)}},mr=function(s){return Gn((e=(t=s).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;},Ne=function(s){return {h:(t=On(s)).h,s:(r=(200-(e=t.s))*(i=t.v)/100)>0&&r<200?e*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,i,r;},sh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,nh=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,oh=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ys={string:[[function(s){var t=ih.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?lt(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?lt(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=nh.exec(s)||oh.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:_r({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(s){var t=sh.exec(s)||rh.exec(s);if(!t)return null;var e,i,r=pr({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(eh[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return mr(r)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=r===void 0?1:r;return Ht(t)&&Ht(e)&&Ht(i)?_r({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,r=s.a,n=r===void 0?1:r;if(!Ht(t)||!Ht(e)||!Ht(i))return null;var o=pr({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return mr(o)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,r=s.a,n=r===void 0?1:r;if(!Ht(t)||!Ht(e)||!Ht(i))return null;var o=(function(a){return {h:Ln(a.h),s:Tt(a.s,0,100),v:Tt(a.v,0,100),a:Tt(a.a)}})({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Gn(o)},"hsv"]]},yr=function(s,t){for(var e=0;e<t.length;e++){var i=t[e][0](s);if(i)return [i,t[e][1]]}return [null,void 0]},ah=function(s){return typeof s=="string"?yr(s.trim(),ys.string):typeof s=="object"&&s!==null?yr(s,ys.object):[null,void 0]},Ni=function(s,t){var e=Ne(s);return {h:e.h,s:Tt(e.s+100*t,0,100),l:e.l,a:e.a}},Wi=function(s){return (299*s.r+587*s.g+114*s.b)/1e3/255},xr=function(s,t){var e=Ne(s);return {h:e.h,s:e.s,l:Tt(e.l+100*t,0,100),a:e.a}},xs=(function(){function s(t){this.parsed=ah(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1};}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return lt(Wi(this.rgba),2)},s.prototype.isDark=function(){return Wi(this.rgba)<.5},s.prototype.isLight=function(){return Wi(this.rgba)>=.5},s.prototype.toHex=function(){return t=Ui(this.rgba),e=t.r,i=t.g,r=t.b,o=(n=t.a)<1?ei(lt(255*n)):"","#"+ei(e)+ei(i)+ei(r)+o;var t,e,i,r,n,o;},s.prototype.toRgb=function(){return Ui(this.rgba)},s.prototype.toRgbString=function(){return t=Ui(this.rgba),e=t.r,i=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+r+", "+n+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,n;},s.prototype.toHsl=function(){return gr(Ne(this.rgba))},s.prototype.toHslString=function(){return t=gr(Ne(this.rgba)),e=t.h,i=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+n+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,n;},s.prototype.toHsv=function(){return t=On(this.rgba),{h:lt(t.h),s:lt(t.s),v:lt(t.v),a:lt(t.a,3)};var t;},s.prototype.invert=function(){return Dt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t;},s.prototype.saturate=function(t){return t===void 0&&(t=.1),Dt(Ni(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),Dt(Ni(this.rgba,-t))},s.prototype.grayscale=function(){return Dt(Ni(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),Dt(xr(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),Dt(xr(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?Dt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):lt(this.rgba.a,3);var e;},s.prototype.hue=function(t){var e=Ne(this.rgba);return typeof t=="number"?Dt({h:t,s:e.s,l:e.l,a:e.a}):lt(e.h)},s.prototype.isEqual=function(t){return this.toHex()===Dt(t).toHex()},s})(),Dt=function(s){return s instanceof xs?s:new xs(s)},br=[],hh=function(s){s.forEach(function(t){br.indexOf(t)<0&&(t(xs,ys),br.push(t));});};function lh(s,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 r in e)i[e[r]]=r;var n={};s.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return "transparent";var a,h,l=i[this.toHex()];if(l)return l;if(o?.closest){var c=this.toRgb(),u=1/0,f="black";if(!n.length)for(var d in e)n[d]=new s(e[d]).toRgb();for(var _ in e){var g=(a=c,h=n[_],Math.pow(a.r-h.r,2)+Math.pow(a.g-h.g,2)+Math.pow(a.b-h.b,2));g<u&&(u=g,f=_);}return f}},t.string.push([function(o){var a=o.toLowerCase(),h=a==="transparent"?"#0000":e[a];return h?new s(h).toRgb():null},"name"]);}hh([lh]);const be=class Oe{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 Oe)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else {if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value));}}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  false;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?false:t.every((n,o)=>n===e[o]);if(t!==null&&e!==null){const n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?false:n.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,i,r]=this._components;return {r:t,g:e,b:i,a:r}}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,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(r*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,r,n]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return (i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return (t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,r,n]=Oe._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=r,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=true){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=true){if(t===1)return (255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(r<<8)+n}toHex(){const t=this._int.toString(16);return `#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,i,r,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,r=(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,r,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,r,n=255]=t,e/=255,i/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=Oe.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`);}const o=Dt(t);o.isValid()&&({r:e,g:i,b:r,a:n}=o.rgba,e/=255,i/=255,r/=255);}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=r,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((r,n)=>{t[n]=Math.min(Math.max(r,e),i);}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof Oe||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};be.shared=new be;be._temp=new be;be.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let ot=be;const ch={cullArea:null,cullable:false,cullableChildren:true};let Hi=0;const wr=500;function J(...s){Hi!==wr&&(Hi++,Hi===wr?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...s));}const Qe={_registeredResources:new Set,register(s){this._registeredResources.add(s);},unregister(s){this._registeredResources.delete(s);},release(){this._registeredResources.forEach(s=>s.clear());},get registeredCount(){return this._registeredResources.size},isRegistered(s){return this._registeredResources.has(s)},reset(){this._registeredResources.clear();}};class uh{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e);}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t;}get(t){let e;return this._index>0?e=this._pool[--this._index]:(e=new this._classType,this._count++),e.init?.(t),e}return(t){t.reset?.(),this._pool[this._index++]=t;}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0;}}class dh{constructor(){this._poolsByClass=new Map;}prepopulate(t,e){this.getPool(t).prepopulate(e);}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t);}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new uh(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize};}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear();}}const Pt=new dh;Qe.register(Pt);const fh={get isCachedAsTexture(){return !!this.renderGroup?.isCachedAsTexture},cacheAsTexture(s){typeof s=="boolean"&&s===false?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(s===true?{}:s));},updateCacheTexture(){this.renderGroup?.updateCacheTexture();},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(s){D("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(s);}};function _h(s,t,e){const i=s.length;let r;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(r=t;r<n;++r)s[r]=s[r+e];s.length=n;}const ph={allowChildren:true,removeChildren(s=0,t){const e=t??this.children.length,i=e-s,r=[];if(i>0&&i<=e){for(let o=e-1;o>=s;o--){const a=this.children[o];a&&(r.push(a),a.parent=null);}_h(this.children,s,e);const n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(r);for(let o=0;o<r.length;++o){const a=r[o];a.parentRenderLayer?.detach(a),this.emit("childRemoved",a,this,o),r[o].emit("removed",this);}return r.length>0&&this._didViewChangeTick++,r}else if(i===0&&this.children.length===0)return r;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(s){const t=this.getChildAt(s);return this.removeChild(t)},getChildAt(s){if(s<0||s>=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,t);},getChildIndex(s){const t=this.children.indexOf(s);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(s,t){this.allowChildren||D(j,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${s}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(s.parent){const r=s.parent.children.indexOf(s);if(s.parent===this&&r===t)return s;r!==-1&&s.parent.children.splice(r,1);}t===e.length?e.push(s):e.splice(t,0,s),s.parent=this,s.didChange=true,s._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(s),this.sortableChildren&&(this.sortDirty=true),this.emit("childAdded",s,this,t),s.emit("added",this),s},swapChildren(s,t){if(s===t)return;const e=this.getChildIndex(s),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=s;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=true),this._didContainerChangeTick++;},removeFromParent(){this.parent?.removeChild(this);},reparentChild(...s){return s.length===1?this.reparentChildAt(s[0],this.children.length):(s.forEach(t=>this.reparentChildAt(t,this.children.length)),s[0])},reparentChildAt(s,t){if(s.parent===this)return this.setChildIndex(s,t),s;const e=s.worldTransform.clone();s.removeFromParent(),this.addChildAt(s,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),s.setFromMatrix(e),s},replaceChild(s,t){s.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(s)),t.setFromMatrix(s.localTransform),t.updateLocalTransform(),this.removeChild(s);}},gh={collectRenderables(s,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(s,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,s):this.collectRenderablesWithEffects(s,t,e));},collectRenderablesSimple(s,t,e){const i=this.children,r=i.length;for(let n=0;n<r;n++)i[n].collectRenderables(s,t,e);},collectRenderablesWithEffects(s,t,e){const{renderPipes:i}=t;for(let r=0;r<this.effects.length;r++){const n=this.effects[r];i[n.pipe].push(n,this,s);}this.collectRenderablesSimple(s,t,e);for(let r=this.effects.length-1;r>=0;r--){const n=this.effects[r];i[n.pipe].pop(n,this,s);}}};class vr{constructor(){this.pipe="filter",this.priority=1;}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null;}}class mh{constructor(){this._effectClasses=[],this._tests=[],this._initialized=false;}init(){this._initialized||(this._initialized=true,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t});}));}add(t){this._tests.push(t);}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const i=this._tests[e];if(i.test(t))return Pt.get(i.maskClass,t)}return t}returnMaskEffect(t){Pt.return(t);}}const bs=new mh;ft.handleByList(B.MaskEffect,bs._effectClasses);const yh={_maskEffect:null,_maskOptions:{inverse:false},_filterEffect:null,effects:[],_markStructureAsChanged(){const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=true);},addEffect(s){this.effects.indexOf(s)===-1&&(this.effects.push(s),this.effects.sort((e,i)=>e.priority-i.priority),this._markStructureAsChanged(),this._updateIsSimple());},removeEffect(s){const t=this.effects.indexOf(s);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple());},set mask(s){const t=this._maskEffect;t?.mask!==s&&(t&&(this.removeEffect(t),bs.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=bs.getMaskEffect(s),this.addEffect(this._maskEffect)));},get mask(){return this._maskEffect?.mask},setMask(s){this._maskOptions={...this._maskOptions,...s},s.mask&&(this.mask=s.mask),this._markStructureAsChanged();},set filters(s){!Array.isArray(s)&&s&&(s=[s]);const t=this._filterEffect||(this._filterEffect=new vr);s=s;const e=s?.length>0,i=t.filters?.length>0,r=e!==i;s=Array.isArray(s)?s.slice(0):s,t.filters=Object.freeze(s),r&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=s??null));},get filters(){return this._filterEffect?.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new vr),this._filterEffect.filterArea=s;},get filterArea(){return this._filterEffect?.filterArea}},xh={label:null,get name(){return D(j,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){D(j,"Container.name property has been removed, use Container.label instead"),this.label=s;},getChildByName(s,t=false){return this.getChildByLabel(s,t)},getChildByLabel(s,t=false){const e=this.children;for(let i=0;i<e.length;i++){const r=e[i];if(r.label===s||s instanceof RegExp&&s.test(r.label))return r}if(t)for(let i=0;i<e.length;i++){const n=e[i].getChildByLabel(s,true);if(n)return n}return null},getChildrenByLabel(s,t=false,e=[]){const i=this.children;for(let r=0;r<i.length;r++){const n=i[r];(n.label===s||s instanceof RegExp&&s.test(n.label))&&e.push(n);}if(t)for(let r=0;r<i.length;r++)i[r].getChildrenByLabel(s,true,e);return e}},yt=Pt.getPool(H),Vt=Pt.getPool(Lt),bh=new H,wh={getFastGlobalBounds(s,t){t||(t=new Lt),t.clear(),this._getGlobalBoundsRecursive(!!s,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(s,t,e){let i=t;if(s&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const r=!!this.effects.length;if((this.renderGroup||r)&&(i=Vt.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else {if(this.renderPipeId){const o=this.bounds;i.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform);}const n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(s,i,e);}if(r){let n=false;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(n||(n=true,i.applyMatrix(o.worldTransform)),this.effects[a].addBounds(i,true));n&&i.applyMatrix(o.worldTransform.copyTo(bh).invert()),t.addBounds(i),Vt.return(i);}else this.renderGroup&&(t.addBounds(i,this.relativeGroupTransform),Vt.return(i));}};function Dn(s,t,e){e.clear();let i,r;return s.parent?t?i=s.parent.worldTransform:(r=yt.get().identity(),i=js(s,r)):i=H.IDENTITY,Un(s,e,i,t),r&&yt.return(r),e.isValid||e.set(0,0,0,0),e}function Un(s,t,e,i){if(!s.visible||!s.measurable)return;let r;i?r=s.worldTransform:(s.updateLocalTransform(),r=yt.get(),r.appendFrom(s.localTransform,e));const n=t,o=!!s.effects.length;if(o&&(t=Vt.get().clear()),s.boundsArea)t.addRect(s.boundsArea,r);else {const a=s.bounds;a&&!a.isEmpty()&&(t.matrix=r,t.addBounds(a));for(let h=0;h<s.children.length;h++)Un(s.children[h],t,r,i);}if(o){for(let a=0;a<s.effects.length;a++)s.effects[a].addBounds?.(t);n.addBounds(t,H.IDENTITY),Vt.return(t);}i||yt.return(r);}function js(s,t){const e=s.parent;return e&&(js(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function Nn(s,t){if(s===16777215||!t)return t;if(t===16777215||!s)return s;const e=s>>16&255,i=s>>8&255,r=s&255,n=t>>16&255,o=t>>8&255,a=t&255,h=e*n/255|0,l=i*o/255|0,c=r*a/255|0;return (h<<16)+(l<<8)+c}const kr=16777215;function Ar(s,t){return s===kr?t:t===kr?s:Nn(s,t)}function _i(s){return ((s&255)<<16)+(s&65280)+(s>>16&255)}const vh={getGlobalAlpha(s){if(s)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(s=new H,t){if(t)return s.copyFrom(this.worldTransform);this.updateLocalTransform();const e=js(this,yt.get().identity());return s.appendFrom(this.localTransform,e),yt.return(e),s},getGlobalTint(s){if(s)return this.renderGroup?_i(this.renderGroup.worldColor):this.parentRenderGroup?_i(Ar(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=Ar(t,e.localColor),e=e.parent;return _i(t)}};function Wn(s,t,e){return t.clear(),e||(e=H.IDENTITY),Hn(s,t,e,s,true),t.isValid||t.set(0,0,0,0),t}function Hn(s,t,e,i,r){let n;if(r)n=yt.get(),n=e.copyTo(n);else {if(!s.visible||!s.measurable)return;s.updateLocalTransform();const h=s.localTransform;n=yt.get(),n.appendFrom(h,e);}const o=t,a=!!s.effects.length;if(a&&(t=Vt.get().clear()),s.boundsArea)t.addRect(s.boundsArea,n);else {s.renderPipeId&&(t.matrix=n,t.addBounds(s.bounds));const h=s.children;for(let l=0;l<h.length;l++)Hn(h[l],t,n,i,false);}if(a){for(let h=0;h<s.effects.length;h++)s.effects[h].addLocalBounds?.(t,i);o.addBounds(t,H.IDENTITY),Vt.return(t);}yt.return(n);}function Vn(s,t){const e=s.children;for(let i=0;i<e.length;i++){const r=e[i],n=r.uid,o=(r._didViewChangeTick&65535)<<16|r._didContainerChangeTick&65535,a=t.index;(t.data[a]!==n||t.data[a+1]!==o)&&(t.data[t.index]=n,t.data[t.index+1]=o,t.didChange=true),t.index=a+2,r.children.length&&Vn(r,t);}return t.didChange}const kh=new H,Ah={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(s,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=s/t*e:this.scale.x=e;},_setHeight(s,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=s/t*e:this.scale.y=e;},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:false,localBounds:new Lt});const s=this._localBoundsCacheData;return s.index=1,s.didChange=false,s.data[0]!==this._didViewChangeTick&&(s.didChange=true,s.data[0]=this._didViewChangeTick),Vn(this,s),s.didChange&&Wn(this,s.localBounds,kh),s.localBounds},getBounds(s,t){return Dn(this,s,t||new Lt)}},Sh={_onRender:null,set onRender(s){const t=this.renderGroup||this.parentRenderGroup;if(!s){this._onRender&&t?.removeOnRender(this),this._onRender=null;return}this._onRender||t?.addOnRender(this),this._onRender=s;},get onRender(){return this._onRender}},Ch={_zIndex:0,sortDirty:false,sortableChildren:false,get zIndex(){return this._zIndex},set zIndex(s){this._zIndex!==s&&(this._zIndex=s,this.depthOfChildModified());},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=true,this.parent.sortDirty=true),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=true);},sortChildren(){this.sortDirty&&(this.sortDirty=false,this.children.sort(Mh));}};function Mh(s,t){return s._zIndex-t._zIndex}const Th={getGlobalPosition(s=new N,t=false){return this.parent?this.parent.toGlobal(this._position,s,t):(s.x=this._position.x,s.y=this._position.y),s},toGlobal(s,t,e=false){const i=this.getGlobalTransform(yt.get(),e);return t=i.apply(s,t),yt.return(i),t},toLocal(s,t,e,i){t&&(s=t.toGlobal(s,e,i));const r=this.getGlobalTransform(yt.get(),i);return e=r.applyInverse(s,e),yt.return(r),e}};class Yn{constructor(){this.uid=st("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0;}reset(){this.instructionSize=0;}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0;}add(t){this.instructions[this.instructionSize++]=t;}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"]);}}let Ph=0;class Ih{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=false,this.textureStyle=new wi(this.textureOptions);}createTexture(t,e,i){const r=new It({...this.textureOptions,width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:false});return new W({source:r,label:`texturePool_${Ph++}`})}getOptimalTexture(t,e,i=1,r){let n=Math.ceil(t*i-1e-6),o=Math.ceil(e*i-1e-6);n=bi(n),o=bi(o);const a=(n<<17)+(o<<1)+(r?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let h=this._texturePool[a].pop();return h||(h=this.createTexture(n,o,r)),h.source._resolution=i,h.source.width=n/i,h.source.height=o/i,h.source.pixelWidth=n,h.source.pixelHeight=o,h.frame.x=0,h.frame.y=0,h.frame.width=t,h.frame.height=e,h.updateUvs(),this._poolKeyHash[h.uid]=a,h}getSameSizeTexture(t,e=false){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t,e=false){const i=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[i].push(t);}clear(t){if(t=t!==false,t)for(const e in this._texturePool){const i=this._texturePool[e];if(i)for(let r=0;r<i.length;r++)i[r].destroy(true);}this._texturePool={};}}const we=new Ih;Qe.register(we);class zh{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=false,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new H,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=true,this.instructionSet=new Yn,this._onRenderContainers=[],this.textureNeedsUpdate=true,this.isCachedAsTexture=false,this._matrixDirty=7;}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=true;const e=t.children;for(let i=0;i<e.length;i++){const r=e[i];r._updateFlags=15,this.addChild(r);}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=true,this.textureNeedsUpdate=true;}disableCacheAsTexture(){this.isCachedAsTexture=false,this.texture&&(we.returnTexture(this.texture,true),this.texture=null);}updateCacheTexture(){this.textureNeedsUpdate=true;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture();}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0;}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=true,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture();}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t);}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null;}addChild(t){if(this.structureDidChange=true,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=true,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i]);}removeChild(t){if(this.structureDidChange=true,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let i=0;i<e.length;i++)this.removeChild(e[i]);}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e]);}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t;}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=false);}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t;}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t);}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1);}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t);}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null;}getChildren(t=[]){const e=this.root.children;for(let i=0;i<e.length;i++)this._getChildren(e[i],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const i=t.children;for(let r=0;r<i.length;r++)this._getChildren(i[r],e);return e}invalidateMatrices(){this._matrixDirty=7;}get inverseWorldTransform(){return (this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new H),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return (this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new H),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y))}get inverseParentTextureTransform(){if((this._matrixDirty&4)===0)return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new H),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function Eh(s,t,e={}){for(const i in t)!e[i]&&t[i]!==void 0&&(s[i]=t[i]);}const Vi=new pt(null),ii=new pt(null),Yi=new pt(null,1,1),si=new pt(null),Sr=1,Rh=2,Xi=4;class U extends Ot{constructor(t={}){super(),this.uid=st("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=false,this.didViewUpdate=false,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=true,this.measurable=true,this.isSimple=true,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new H,this.relativeGroupTransform=new H,this.groupTransform=this.relativeGroupTransform,this.destroyed=false,this._position=new pt(this,0,0),this._scale=Yi,this._pivot=ii,this._origin=si,this._skew=Vi,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],Eh(this,t,{children:true,parent:true,effects:true}),t.children?.forEach(e=>this.addChild(e)),t.parent?.addChild(this);}static mixin(t){D("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),ft.mixin(U,t);}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095;}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(this.allowChildren||D(j,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let r=0;r<t.length;r++)this.addChild(t[r]);return t[0]}const e=t[0],i=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),i&&(i.structureDidChange=true),e):(e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=true),e.parent=this,e.didChange=true,e._updateFlags=15,i&&i.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,e._zIndex!==0&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let r=0;r<t.length;r++)this.removeChild(t[r]);return t[0]}const e=t[0],i=this.children.indexOf(e);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=true,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this));}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup());}get isRenderGroup(){return !!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),this.renderGroup=Pt.get(zh,this),this.groupTransform=H.IDENTITY,t?.addChild(this),this._updateIsSimple();}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),Pt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t?.addChild(this),this._updateIsSimple();}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0;}get worldTransform(){return this._worldTransform||(this._worldTransform=new H),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t;}get y(){return this._position.y}set y(t){this._position.y=t;}get position(){return this._position}set position(t){this._position.copyFrom(t);}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew));}get angle(){return this.rotation*Xa}set angle(t){this.rotation=t*ja;}get pivot(){return this._pivot===ii&&(this._pivot=new pt(this,0,0)),this._pivot}set pivot(t){this._pivot===ii&&(this._pivot=new pt(this,0,0),this._origin!==si&&J("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t);}get skew(){return this._skew===Vi&&(this._skew=new pt(this,0,0)),this._skew}set skew(t){this._skew===Vi&&(this._skew=new pt(this,0,0)),this._skew.copyFrom(t);}get scale(){return this._scale===Yi&&(this._scale=new pt(this,1,1)),this._scale}set scale(t){this._scale===Yi&&(this._scale=new pt(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t);}get origin(){return this._origin===si&&(this._origin=new pt(this,0,0)),this._origin}set origin(t){this._origin===si&&(this._origin=new pt(this,0,0),this._pivot!==ii&&J("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._origin.set(t):this._origin.copyFrom(t);}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e);}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e);}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const i=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.height);}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x);}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this);}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,r=this._pivot,n=this._origin,o=this._position,a=i._x,h=i._y,l=r._x,c=r._y,u=-n._x,f=-n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*h,e.d=this._sy*h,e.tx=o._x-(l*e.a+c*e.c)+(u*e.a+f*e.c)-u,e.ty=o._y-(l*e.b+c*e.d)+(u*e.b+f*e.d)-f;}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=Sr,this._onUpdate());}get alpha(){return this.localAlpha}set tint(t){const i=ot.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=Sr,this._onUpdate());}get tint(){return _i(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=true),this._updateFlags|=Rh,this.localBlendMode=t,this._onUpdate());}get blendMode(){return this.localBlendMode}get visible(){return !!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=true),this._updateFlags|=Xi,this.localDisplayStatus^=2,this._onUpdate());}get culled(){return !(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=true),this._updateFlags|=Xi,this.localDisplayStatus^=4,this._onUpdate());}get renderable(){return !!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=Xi,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=true),this._onUpdate());}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=false){if(this.destroyed)return;this.destroyed=true;let e;if(this.children.length&&(e=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t?.children)&&e)for(let r=0;r<e.length;++r)e[r].destroy(t);this.renderGroup?.destroy(),this.renderGroup=null;}}ft.mixin(U,ph,wh,Th,Sh,Ah,yh,xh,Ch,ch,fh,vh,gh);class Xn extends U{constructor(t){super(t),this.canBundle=true,this.allowChildren=false,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=true,this._gcLastUsed=-1,this._bounds=new Lt(0,1,0,0),this._boundsDirty=true,this.autoGarbageCollect=t.autoGarbageCollect??true;}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=false,this._bounds):this._bounds}get roundPixels(){return !!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0;}containsPoint(t){const e=this.bounds,{x:i,y:r}=t;return i>=e.minX&&i<=e.maxX&&r>=e.minY&&r<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=true,this.didViewUpdate)return;this.didViewUpdate=true;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this);}unload(){this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null),this.onViewUpdate();}destroy(t){this.unload(),super.destroy(t),this._bounds=null;}collectRenderablesSimple(t,e,i){const{renderPipes:r}=e;r.blendMode.pushBlendMode(this,this.groupBlendMode,t),r[this.renderPipeId].addRenderable(this,t),this.didViewUpdate=false;const o=this.children,a=o.length;for(let h=0;h<a;h++)o[h].collectRenderables(t,e,i);r.blendMode.popBlendMode(t);}}class q extends Xn{constructor(t=W.EMPTY){t instanceof W&&(t={texture:t});const{texture:e=W.EMPTY,anchor:i,roundPixels:r,width:n,height:o,...a}=t;super({label:"Sprite",...a}),this.renderPipeId="sprite",this.batched=true,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new pt({_onUpdate:()=>{this.onViewUpdate();}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=false,this.roundPixels=r??false,n!==void 0&&(this.width=n),o!==void 0&&(this.height=o);}static from(t,e=false){return t instanceof W?new q(t):new q(W.from(t,e))}set texture(t){t||(t=W.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate());}get texture(){return this._texture}get visualBounds(){return th(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return D("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:r,height:n}=e.orig;i.minX=-t._x*r,i.maxX=i.minX+r,i.minY=-t._y*n,i.maxY=i.minY+n;}destroy(t=false){if(super.destroy(t),typeof t=="boolean"?t:t?.texture){const i=typeof t=="boolean"?t:t?.textureSource;this._texture.destroy(i);}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null;}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t);}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t;}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t;}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height);}}const Fh=new Lt;function jn(s,t,e){const i=Fh;s.measurable=true,Dn(s,e,i),t.addBoundsMask(i),s.measurable=false;}function qn(s,t,e){const i=Vt.get();s.measurable=true;const r=yt.get().identity(),n=Kn(s,e,r);Wn(s,i,n),s.measurable=false,t.addBoundsMask(i),yt.return(r),Vt.return(i);}function Kn(s,t,e){return s?(s!==t&&(Kn(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(J("Mask bounds, renderable is not inside the root container"),e)}class Zn{constructor(t){this.priority=0,this.inverse=false,this.pipe="alphaMask",t?.mask&&this.init(t.mask);}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof q),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=false;}reset(){this.mask!==null&&(this.mask.measurable=true,this.mask=null);}addBounds(t,e){this.inverse||jn(this.mask,t,e);}addLocalBounds(t,e){qn(this.mask,t,e);}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset();}static test(t){return t instanceof q}}Zn.extension=B.MaskEffect;class Qn{constructor(t){this.priority=0,this.pipe="colorMask",t?.mask&&this.init(t.mask);}init(t){this.mask=t;}destroy(){}static test(t){return typeof t=="number"}}Qn.extension=B.MaskEffect;class Jn{constructor(t){this.priority=0,this.pipe="stencilMask",t?.mask&&this.init(t.mask);}init(t){this.mask=t,this.mask.includeInBuild=false,this.mask.measurable=false;}reset(){this.mask!==null&&(this.mask.measurable=true,this.mask.includeInBuild=true,this.mask=null);}addBounds(t,e){jn(this.mask,t,e);}addLocalBounds(t,e){qn(this.mask,t,e);}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset();}static test(t){return t instanceof U}}Jn.extension=B.MaskEffect;const Bh={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")};let Cr=Bh;const $={get(){return Cr},set(s){Cr=s;}};class $n extends It{constructor(t){t.resource||(t.resource=$.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent;}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight);}resize(t=this.width,e=this.height,i=this._resolution){const r=super.resize(t,e,i);return r&&this.resizeCanvas(),r}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}$n.extension=B.TextureSource;class ce extends It{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=true;}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}ce.extension=B.TextureSource;var ws=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(ws||{});class ji{constructor(t,e=null,i=0,r=false){this.next=null,this.previous=null,this._destroyed=false,this._fn=t,this._context=e,this.priority=i,this._once=r;}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(true),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=false){this._destroyed=true,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 to=class kt{constructor(){this.autoStart=false,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=false,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=false,this._lastFrame=-1,this._head=new ji(null,null,1/0),this.deltaMS=1/kt.targetFPMS,this.elapsedMS=1/kt.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=ws.NORMAL){return this._addListener(new ji(t,e,i))}addOnce(t,e,i=ws.NORMAL){return this._addListener(new ji(t,e,i,true))}_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=true,this._requestIfNeeded());}stop(){this.started&&(this.started=false,this._cancelIfNeeded());}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(true);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*kt.targetFPMS;const i=this._head;let r=i.next;for(;r;)r=r.emit(this);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,kt.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(!kt._shared){const t=kt._shared=new kt;t.autoStart=true,t._protected=true;}return kt._shared}static get system(){if(!kt._system){const t=kt._system=new kt;t.autoStart=true,t._protected=true;}return kt._system}};to.targetFPMS=.06;let ri=to,qi;async function eo(){return qi??(qi=(async()=>{const t=$.get().createCanvas(1,1).getContext("webgl");if(!t)return "premultiply-alpha-on-upload";const e=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=false,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load();});if(!e)return "premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,false),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(r),t.deleteTexture(i),t.getExtension("WEBGL_lose_context")?.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),qi}const Ci=class io extends It{constructor(t){super(t),this.isReady=false,this.uploadMethodId="video",t={...io.defaultOptions,...t},this._autoUpdate=true,this._isConnectedToTicker=false,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==false,this.alphaMode=t.alphaMode??"premultiply-alpha-on-upload",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._onCanPlayThrough=this._onCanPlayThrough.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),t.autoLoad!==false&&this.load();}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=ri.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t);}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update();}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback);}get isValid(){return !!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return (t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=true),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,true)),this.alphaMode=await eo(),this._load=new Promise((i,r)=>{this.isValid?i(this):(this._resolve=i,this._reject=r,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`));})),t.load());}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,true),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null);}_isSourcePlaying(){const t=this.resource;return !t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate();}_onPlayStop(){this._configureAutoUpdate();}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0);}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady();}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady();}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=true,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play();}destroy(){this._configureAutoUpdate();const t=this.resource;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._onCanPlayThrough),t.removeEventListener("error",this._onError,true),t.pause(),t.src="",t.load()),super.destroy();}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.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(ri.shared.remove(this.updateFrame,this),this._isConnectedToTicker=false,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(ri.shared.add(this.updateFrame,this),this._isConnectedToTicker=true,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ri.shared.remove(this.updateFrame,this),this._isConnectedToTicker=false,this._msToNextUpdate=0));}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Ci.extension=B.TextureSource;Ci.defaultOptions={...It.defaultOptions,autoLoad:true,autoPlay:true,updateFPS:0,crossorigin:true,loop:false,muted:true,playsinline:true,preload:false};Ci.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let We=Ci;const Bt=(s,t,e=false)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s);class Lh{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||J(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=Bt(t);let r;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.test(e)){r=l.getCacheableAssets(i,e);break}}const n=new Map(Object.entries(r||{}));r||i.forEach(h=>{n.set(h,e);});const o=[...n.keys()],a={cacheKeys:o,keys:i};i.forEach(h=>{this._cacheMap.set(h,a);}),o.forEach(h=>{const l=r?r[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&J("[Cache] already has key:",h),this._cache.set(h,n.get(h));});}remove(t){if(!this._cacheMap.has(t)){J(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(r=>{this._cache.delete(r);}),e.keys.forEach(r=>{this._cacheMap.delete(r);});}get parsers(){return this._parsers}}const Q=new Lh,vs=[];ft.handleByList(B.TextureSource,vs);function so(s={}){const t=s&&s.resource,e=t?s.resource:s,i=t?s:{resource:s};for(let r=0;r<vs.length;r++){const n=vs[r];if(n.test(e))return new n(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function Oh(s={},t=false){const e=s&&s.resource,i=e?s.resource:s,r=e?s:{resource:s};if(!t&&Q.has(i))return Q.get(i);const n=new W({source:so(r)});return n.on("destroy",()=>{Q.has(i)&&Q.remove(i);}),t||Q.set(i,n),n}function Gh(s,t=false){return typeof s=="string"?Q.get(s):s instanceof It?new W({source:s}):Oh(s,t)}W.from=Gh;It.from=so;ft.add(Zn,Qn,Jn,We,ce,$n,Xs);var Qt=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(Qt||{});function Ft(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function Ie(s){return s.split("?")[0].split("#")[0]}function Dh(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Uh(s,t,e){return s.replace(new RegExp(Dh(t),"g"),e)}function Nh(s,t){let e="",i=0,r=-1,n=0,o=-1;for(let a=0;a<=s.length;++a){if(a<s.length)o=s.charCodeAt(a);else {if(o===47)break;o=47;}if(o===47){if(!(r===a-1||n===1))if(r!==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 h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),r=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=a,n=0;continue}}}else e.length>0?e+=`/${s.slice(r+1,a)}`:e=s.slice(r+1,a),i=a-r-1;r=a,n=0;}else o===46&&n!==-1?++n:n=-1;}return e}const Ct={toPosix(s){return Uh(s,"\\","/")},isUrl(s){return /^https?:/.test(this.toPosix(s))},isDataUrl(s){return /^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return /^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){Ft(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(Ft(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=Ie(this.toPosix(t??$.get().getBaseUrl())),r=Ie(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?Ct.join(r,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(Ft(s),s.length===0)return ".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=Nh(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return Ft(s),s=this.toPosix(s),this.hasProtocol(s)?true:s.startsWith("/")},join(...s){if(s.length===0)return ".";let t;for(let e=0;e<s.length;++e){const i=s[e];if(Ft(i),i.length>0)if(t===void 0)t=i;else {const r=s[e-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${i}`:t+=`/${i}`;}}return t===void 0?".":this.normalize(t)},dirname(s){if(Ft(s),s.length===0)return ".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,r=true;const n=this.getProtocol(s),o=s;s=s.slice(n.length);for(let a=s.length-1;a>=1;--a)if(t=s.charCodeAt(a),t===47){if(!r){i=a;break}}else r=false;return i===-1?e?"/":this.isUrl(o)?n+s:n:e&&i===1?"//":n+s.slice(0,i)},rootname(s){Ft(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/");}return t},basename(s,t){Ft(s),t&&Ft(t),s=Ie(this.toPosix(s));let e=0,i=-1,r=true,n;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return "";let o=t.length-1,a=-1;for(n=s.length-1;n>=0;--n){const h=s.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else a===-1&&(r=false,a=n+1),o>=0&&(h===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a));}return e===i?i=a:i===-1&&(i=s.length),s.slice(e,i)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!r){e=n+1;break}}else i===-1&&(r=false,i=n+1);return i===-1?"":s.slice(e,i)},extname(s){Ft(s),s=Ie(this.toPosix(s));let t=-1,e=0,i=-1,r=true,n=0;for(let o=s.length-1;o>=0;--o){const a=s.charCodeAt(o);if(a===47){if(!r){e=o+1;break}continue}i===-1&&(r=false,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?"":s.slice(t,i)},parse(s){Ft(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=Ie(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let r;t.root=this.rootname(s),i||this.hasProtocol(s)?r=1:r=0;let n=-1,o=0,a=-1,h=true,l=s.length-1,c=0;for(;l>=r;--l){if(e=s.charCodeAt(l),e===47){if(!h){o=l+1;break}continue}a===-1&&(h=false,a=l+1),e===46?n===-1?n=l: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=s.slice(1,a):t.base=t.name=s.slice(o,a)):(o===0&&i?(t.name=s.slice(1,n),t.base=s.slice(1,a)):(t.name=s.slice(o,n),t.base=s.slice(o,a)),t.ext=s.slice(n,a)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function ro(s,t,e,i,r){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?ro(s.replace(i[e],a),t,e+1,i,r):r.push(s.replace(i[e],a));}}function Wh(s){const t=/\{(.*?)\}/g,e=s.match(t),i=[];if(e){const r=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");r.push(o);}),ro(s,r,0,e,i);}else i.push(s);return i}const vi=s=>!Array.isArray(s);class Ae{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,src:i}=t;return Bt(e||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(o=>o?.src??o):n?.src?n.src:n,true)}addManifest(t){this._manifest&&J("[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=[];let r=e;Array.isArray(e)||(r=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:{alias:n,...o})),r.forEach(n=>{const o=n.src,a=n.alias;let h;if(typeof a=="string"){const l=this._createBundleAssetId(t,a);i.push(l),h=[a,l];}else {const l=a.map(c=>this._createBundleAssetId(t,c));i.push(...l),h=[...a,...l];}this.add({...n,alias:h,src:o});}),this._bundles[t]=i;}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=n=>{this.hasKey(n)&&J(`[Resolver] already has key: ${n} overwriting`);},Bt(e).forEach(n=>{const{src:o}=n;let{data:a,format:h,loadParser:l,parser:c}=n;const u=Bt(o).map(g=>typeof g=="string"?Wh(g):Array.isArray(g)?g:[g]),f=this.getAlias(n);Array.isArray(f)?f.forEach(i):i(f);const d=[],_=g=>({...this._parsers.find(m=>m.test(g))?.parse(g),src:g});u.forEach(g=>{g.forEach(p=>{let m={};if(typeof p!="object"?m=_(p):(a=p.data??a,h=p.format??h,(p.loadParser||p.parser)&&(l=p.loadParser??l,c=p.parser??c),m={..._(p.src),...p}),!f)throw new Error(`[Resolver] alias is undefined for this asset: ${m.src}`);m=this._buildResolvedAsset(m,{aliases:f,data:a,format:h,loadParser:l,parser:c,progressSize:n.progressSize}),d.push(m);});}),f.forEach(g=>{this._assetMap[g]=d;});});}resolveBundle(t){const e=vi(t);t=Bt(t);const i={};return t.forEach(r=>{const n=this._bundles[r];if(n){const o=this.resolve(n),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(r,h)]=l;}i[r]=a;}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const r in e)i[r]=e[r].src;return i}return e.src}resolve(t){const e=vi(t);t=Bt(t);const i={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const o=this._getPreferredOrder(n);o?.priority.forEach(a=>{o.params[a].forEach(h=>{const l=n.filter(c=>c[a]?c[a]===h:false);l.length&&(n=l);});}),this._resolverHash[r]=n[0];}else this._resolverHash[r]=this._buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r];}),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[e],r=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(r)return r}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:r,loadParser:n,parser:o,format:a,progressSize:h}=e;return (this._basePath||this._rootPath)&&(t.src=Ct.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=n??t.loadParser,t.parser=o??t.parser,t.format=a??t.format??Hh(t.src),h!==void 0&&(t.progressSize=h),t}}Ae.RETINA_PREFIX=/@([0-9\.]+)x/;function Hh(s){return s.split(".").pop().split("?").shift().split("#").shift()}const ks=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s},no=class Ge{constructor(t,e){this.linkedSheets=[];let i=t;t?.source instanceof It&&(i={texture:t,data:e});const{texture:r,data:n,cachePrefix:o=""}=i;this.cachePrefix=o,this._texture=r instanceof W?r:null,this.textureSource=r.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,r.source.resolution=this.resolution):this.resolution=r.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null;}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Ge.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch();})}_processFrames(t){let e=t;const i=Ge.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const r=this._frameKeys[e],n=this._frames[r],o=n.frame;if(o){let a=null,h=null;const l=n.trimmed!==false&&n.sourceSize?n.sourceSize:n.frame,c=new Z(0,0,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution);n.rotated?a=new Z(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 Z(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!==false&&n.spriteSourceSize&&(h=new Z(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[r]=new W({source:this.textureSource,frame:a,orig:c,trim:h,rotate:n.rotated?2:0,defaultAnchor:n.anchor,defaultBorders:n.borders,label:r.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 r=t[e][i];this.animations[e].push(this.textures[r]);}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures);}_nextBatch(){this._processFrames(this._batchIndex*Ge.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Ge.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete());},0);}destroy(t=false){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.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[];}};no.BATCH_SIZE=1e3;let Mr=no;const Vh=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function oo(s,t,e){const i={};if(s.forEach(r=>{i[r]=t;}),Object.keys(t.textures).forEach(r=>{i[`${t.cachePrefix}${r}`]=t.textures[r];}),!e){const r=Ct.dirname(s[0]);t.linkedSheets.forEach((n,o)=>{const a=oo([`${r}/${t.data.meta.related_multi_packs[o]}`],n,true);Object.assign(i,a);});}return i}const Yh={extension:B.Asset,cache:{test:s=>s instanceof Mr,getCacheableAssets:(s,t)=>oo(s,t,false)},resolver:{extension:{type:B.ResolveParser,name:"resolveSpritesheet"},test:s=>{const e=s.split("?")[0].split("."),i=e.pop(),r=e.pop();return i==="json"&&Vh.includes(r)},parse:s=>{const t=s.split(".");return {resolution:parseFloat(Ae.RETINA_PREFIX.exec(s)?.[1]??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:B.LoadParser,priority:Qt.Normal,name:"spritesheetLoader"},async testParse(s,t){return Ct.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){const{texture:i,imageFilename:r,textureOptions:n,cachePrefix:o}=t?.data??{};let a=Ct.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let h;if(i instanceof W)h=i;else {const u=ks(a+(r??s.meta.image),t.src);h=(await e.load([{src:u,data:n}]))[u];}const l=new Mr({texture:h.source,data:s,cachePrefix:o});await l.parse();const c=s?.meta?.related_multi_packs;if(Array.isArray(c)){const u=[];for(const d of c){if(typeof d!="string")continue;let _=a+d;t.data?.ignoreMultiPack||(_=ks(_,t.src),u.push(e.load({src:_,data:{textureOptions:n,ignoreMultiPack:true}})));}const f=await Promise.all(u);l.linkedSheets=f,f.forEach(d=>{d.linkedSheets=[l].concat(l.linkedSheets.filter(_=>_!==d));});}return l},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(false);}}};ft.add(Yh);const Ki=Object.create(null),Tr=Object.create(null);function qs(s,t){let e=Tr[s];return e===void 0&&(Ki[t]===void 0&&(Ki[t]=1),Tr[s]=e=Ki[t]++),e}let ni;function ao(){return (!ni||ni?.isContextLost())&&(ni=$.get().createCanvas().getContext("webgl",{})),ni}let oi;function Xh(){if(!oi){oi="mediump";const s=ao();s&&s.getShaderPrecisionFormat&&(oi=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump");}return oi}function jh(s,t,e){return t?s:e?(s=s.replace("out vec4 finalColor;",""),`

        #ifdef GL_ES // This checks if it is WebGL1
        #define in varying
        #define finalColor gl_FragColor
        #define texture texture2D
        #endif
        ${s}
        `):`

        #ifdef GL_ES // This checks if it is WebGL1
        #define in attribute
        #define out varying
        #endif
        ${s}
        `}function qh(s,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let r=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return r==="highp"&&i!=="highp"&&(r="mediump"),`precision ${r} float;
${s}`}else if(i!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function Kh(s,t){return t?`#version 300 es
${s}`:s}const Zh={},Qh={};function Jh(s,{name:t="pixi-program"},e=true){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?Zh:Qh;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`}
${s}`}function $h(s,t){return t?s.replace("#version 300 es",""):s}const Zi={stripVersion:$h,ensurePrecision:qh,addProgramDefines:jh,setProgramName:Jh,insertVersion:Kh},ze=Object.create(null),ho=class As{constructor(t){t={...As.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Xh()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let r=t.fragment,n=t.vertex;Object.keys(Zi).forEach(o=>{const a=i[o];r=Zi[o](r,a,true),n=Zi[o](n,a,false);}),this.fragment=r,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=qs(`${this.vertex}:${this.fragment}`,"gl-program");}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null,ze[this._cacheKey]=null;}static from(t){const e=`${t.vertex}:${t.fragment}`;return ze[e]||(ze[e]=new As(t),ze[e]._cacheKey=e),ze[e]}};ho.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let ve=ho;const Pr={uint8x2:{size:2,stride:2,normalised:false},uint8x4:{size:4,stride:4,normalised:false},sint8x2:{size:2,stride:2,normalised:false},sint8x4:{size:4,stride:4,normalised:false},unorm8x2:{size:2,stride:2,normalised:true},unorm8x4:{size:4,stride:4,normalised:true},snorm8x2:{size:2,stride:2,normalised:true},snorm8x4:{size:4,stride:4,normalised:true},uint16x2:{size:2,stride:4,normalised:false},uint16x4:{size:4,stride:8,normalised:false},sint16x2:{size:2,stride:4,normalised:false},sint16x4:{size:4,stride:8,normalised:false},unorm16x2:{size:2,stride:4,normalised:true},unorm16x4:{size:4,stride:8,normalised:true},snorm16x2:{size:2,stride:4,normalised:true},snorm16x4:{size:4,stride:8,normalised:true},float16x2:{size:2,stride:4,normalised:false},float16x4:{size:4,stride:8,normalised:false},float32:{size:1,stride:4,normalised:false},float32x2:{size:2,stride:8,normalised:false},float32x3:{size:3,stride:12,normalised:false},float32x4:{size:4,stride:16,normalised:false},uint32:{size:1,stride:4,normalised:false},uint32x2:{size:2,stride:8,normalised:false},uint32x3:{size:3,stride:12,normalised:false},uint32x4:{size:4,stride:16,normalised:false},sint32:{size:1,stride:4,normalised:false},sint32x2:{size:2,stride:8,normalised:false},sint32x3:{size:3,stride:12,normalised:false},sint32x4:{size:4,stride:16,normalised:false}};function tl(s){return Pr[s]??Pr.float32}const el={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"};function il({source:s,entryPoint:t}){const e={},i=s.indexOf(`fn ${t}`);if(i!==-1){const r=s.indexOf("->",i);if(r!==-1){const n=s.substring(i,r),o=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let a;for(;(a=o.exec(n))!==null;){const h=el[a[3]]??"float32";e[a[2]]={location:parseInt(a[1],10),format:h,stride:tl(h).stride,offset:0,instance:false,start:0};}}}return e}function Qi(s){const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,n=/:\s*(\w+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=s.match(t)?.map(u=>({group:parseInt(u.match(e)[1],10),binding:parseInt(u.match(i)[1],10),name:u.match(r)[2],isUniform:u.match(r)[1]==="<uniform>",type:u.match(n)[1]}));if(!l)return {groups:[],structs:[]};const c=s.match(o)?.map(u=>{const f=u.match(h)[1],d=u.match(a).reduce((_,g)=>{const[p,m]=g.split(":");return _[p.trim()]=m.trim(),_},{});return d?{name:f,members:d}:null}).filter(({name:u})=>l.some(f=>f.type===u))??[];return {groups:l,structs:c}}var De=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(De||{});function sl({groups:s}){const t=[];for(let e=0;e<s.length;e++){const i=s[e];t[i.group]||(t[i.group]=[]),i.isUniform?t[i.group].push({binding:i.binding,visibility:De.VERTEX|De.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:De.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"&&t[i.group].push({binding:i.binding,visibility:De.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:false}});}return t}function rl({groups:s}){const t=[];for(let e=0;e<s.length;e++){const i=s[e];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding;}return t}function nl(s,t){const e=new Set,i=new Set,r=[...s.structs,...t.structs].filter(o=>e.has(o.name)?false:(e.add(o.name),true)),n=[...s.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?false:(i.add(a),true)});return {structs:r,groups:n}}const Ee=Object.create(null);class Zt{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:r,gpuLayout:n,name:o}=t;if(this.name=o,this.fragment=e,this.vertex=i,e.source===i.source){const a=Qi(e.source);this.structsAndGroups=a;}else {const a=Qi(i.source),h=Qi(e.source);this.structsAndGroups=nl(a,h);}this.layout=r??rl(this.structsAndGroups),this.gpuLayout=n??sl(this.structsAndGroups),this.autoAssignGlobalUniforms=this.layout[0]?.globalUniforms!==void 0,this.autoAssignLocalUniforms=this.layout[1]?.localUniforms!==void 0,this._generateProgramKey();}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=qs(i,"program");}get attributeData(){return this._attributeData??(this._attributeData=il(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,Ee[this._cacheKey]=null;}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return Ee[e]||(Ee[e]=new Zt(t),Ee[e]._cacheKey=e),Ee[e]}}const lo=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],ol=lo.reduce((s,t)=>(s[t]=true,s),{});function al(s,t){switch(s){case "f32":return 0;case "vec2<f32>":return new Float32Array(2*t);case "vec3<f32>":return new Float32Array(3*t);case "vec4<f32>":return new Float32Array(4*t);case "mat2x2<f32>":return new Float32Array([1,0,0,1]);case "mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case "mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const co=class uo{constructor(t,e){this._touched=0,this.uid=st("uniform"),this._resourceType="uniformGroup",this._resourceId=st("resource"),this.isUniformGroup=true,this._dirtyId=0,this.destroyed=false,e={...uo.defaultOptions,...e},this.uniformStructures=t;const i={};for(const r in t){const n=t[r];if(n.name=r,n.size=n.size??1,!ol[n.type]){const o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,h]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${h} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${lo.join(", ")}`)}n.value??(n.value=al(n.type,n.size)),i[r]=n.value;}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=qs(Object.keys(i).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group");}update(){this._dirtyId++;}};co.defaultOptions={ubo:false,isStatic:false};let fo=co;class pi{constructor(t){this.resources=Object.create(null),this._dirty=true;let e=0;for(const i in t){const r=t[i];this.setResource(r,e++);}this._updateKey();}_updateKey(){if(!this._dirty)return;this._dirty=false;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|");}setResource(t,e){const i=this.resources[e];t!==i&&(i&&t.off?.("change",this.onResourceChange,this),t.on?.("change",this.onResourceChange,this),this.resources[e]=t,this._dirty=true);}getResource(t){return this.resources[t]}_touch(t,e){const i=this.resources;for(const r in i)i[r]._gcLastUsed=t,i[r]._touched=e;}destroy(){const t=this.resources;for(const e in t)t[e]?.off?.("change",this.onResourceChange,this);this.resources=null;}onResourceChange(t){if(this._dirty=true,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null);}else this._updateKey();}}var Ss=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.BOTH=3]="BOTH",s))(Ss||{});class Mi extends Ot{constructor(t){super(),this.uid=st("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=false;let{gpuProgram:e,glProgram:i,groups:r,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=i,o===void 0&&(o=0,e&&(o|=Ss.WEBGPU),i&&(o|=Ss.WEBGL)),this.compatibleRenderers=o;const h={};if(!n&&!r&&(n={}),n&&r)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&r&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&r&&a)for(const l in a)for(const c in a[l]){const u=a[l][c];h[u]={group:l,binding:c,name:u};}else if(e&&r&&!a){const l=e.structsAndGroups.groups;a={},l.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,h[c.name]=c;});}else if(n){r={},a={},e&&e.structsAndGroups.groups.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,h[u.name]=u;});let l=0;for(const c in n)h[c]||(r[99]||(r[99]=new pi,this._ownedBindGroups.push(r[99])),h[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++);for(const c in n){const u=c;let f=n[c];!f.source&&!f._resourceType&&(f=new fo(f));const d=h[u];d&&(r[d.group]||(r[d.group]=new pi,this._ownedBindGroups.push(r[d.group])),r[d.group].setResource(f,d.binding));}}this.groups=r,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(r,h);}addResource(t,e,i){var r,n;(r=this._uniformBindMap)[e]||(r[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new pi,this._ownedBindGroups.push(this.groups[e]));}_buildResourceAccessor(t,e){const i={};for(const r in e){const n=e[r];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding);}});}return i}destroy(t=false){this._destroyed||(this._destroyed=true,this.emit("destroy",this),t&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(e=>{e.destroy();}),this._ownedBindGroups=null,this.resources=null,this.groups=null);}static from(t){const{gpu:e,gl:i,...r}=t;let n,o;return e&&(n=Zt.from(e)),i&&(o=ve.from(i)),new Mi({gpuProgram:n,glProgram:o,...r})}}const hl={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},Ji=0,$i=1,ts=2,es=3,is=4,ss=5,Cs=class _o{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=true,this.depthMask=true;}get blend(){return !!(this.data&1<<Ji)}set blend(t){!!(this.data&1<<Ji)!==t&&(this.data^=1<<Ji);}get offsets(){return !!(this.data&1<<$i)}set offsets(t){!!(this.data&1<<$i)!==t&&(this.data^=1<<$i);}set cullMode(t){if(t==="none"){this.culling=false;return}this.culling=true,this.clockwiseFrontFace=t==="front";}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return !!(this.data&1<<ts)}set culling(t){!!(this.data&1<<ts)!==t&&(this.data^=1<<ts);}get depthTest(){return !!(this.data&1<<es)}set depthTest(t){!!(this.data&1<<es)!==t&&(this.data^=1<<es);}get depthMask(){return !!(this.data&1<<ss)}set depthMask(t){!!(this.data&1<<ss)!==t&&(this.data^=1<<ss);}get clockwiseFrontFace(){return !!(this.data&1<<is)}set clockwiseFrontFace(t){!!(this.data&1<<is)!==t&&(this.data^=1<<is);}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=hl[t]||0;}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t;}toString(){return `[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const t=new _o;return t.depthTest=false,t.blend=true,t}};Cs.default2d=Cs.for2d();let ll=Cs;const po=class Ms extends Mi{constructor(t){t={...Ms.defaultOptions,...t},super(t),this.enabled=true,this._state=ll.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3);}apply(t,e,i,r){t.applyFilter(this,e,i,r);}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t;}static from(t){const{gpu:e,gl:i,...r}=t;let n,o;return e&&(n=Zt.from(e)),i&&(o=ve.from(i)),new Ms({gpuProgram:n,glProgram:o,...r})}};po.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:false,clipToViewport:true};let Ts=po;const Ps=[];ft.handleByNamedList(B.Environment,Ps);async function cl(s){if(!s)for(let t=0;t<Ps.length;t++){const e=Ps[t];if(e.value.test()){await e.value.load();return}}}let Re;function ul(){if(typeof Re=="boolean")return Re;try{Re=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0;}catch{Re=false;}return Re}function Ir(s,t,e=2){const i=t&&t.length,r=i?t[0]*e:s.length;let n=go(s,0,r,e,true);const o=[];if(!n||n.next===n.prev)return o;let a,h,l;if(i&&(n=gl(s,t,n,e)),s.length>80*e){a=s[0],h=s[1];let c=a,u=h;for(let f=e;f<r;f+=e){const d=s[f],_=s[f+1];d<a&&(a=d),_<h&&(h=_),d>c&&(c=d),_>u&&(u=_);}l=Math.max(c-a,u-h),l=l!==0?32767/l:0;}return Xe(n,o,e,a,h,l,0),o}function go(s,t,e,i,r){let n;if(r===Ml(s,t,e,i)>0)for(let o=t;o<e;o+=i)n=zr(o/i|0,s[o],s[o+1],n);else for(let o=e-i;o>=t;o-=i)n=zr(o/i|0,s[o],s[o+1],n);return n&&ke(n,n.next)&&(qe(n),n=n.next),n}function ue(s,t){if(!s)return s;t||(t=s);let e=s,i;do if(i=false,!e.steiner&&(ke(e,e.next)||tt(e.prev,e,e.next)===0)){if(qe(e),e=t=e.prev,e===e.next)break;i=true;}else e=e.next;while(i||e!==t);return t}function Xe(s,t,e,i,r,n,o){if(!s)return;!o&&n&&wl(s,i,r,n);let a=s;for(;s.prev!==s.next;){const h=s.prev,l=s.next;if(n?fl(s,i,r,n):dl(s)){t.push(h.i,s.i,l.i),qe(s),s=l.next,a=l.next;continue}if(s=l,s===a){o?o===1?(s=_l(ue(s),t),Xe(s,t,e,i,r,n,2)):o===2&&pl(s,t,e,i,r,n):Xe(ue(s),t,e,i,r,n,1);break}}}function dl(s){const t=s.prev,e=s,i=s.next;if(tt(t,e,i)>=0)return  false;const r=t.x,n=e.x,o=i.x,a=t.y,h=e.y,l=i.y,c=Math.min(r,n,o),u=Math.min(a,h,l),f=Math.max(r,n,o),d=Math.max(a,h,l);let _=i.next;for(;_!==t;){if(_.x>=c&&_.x<=f&&_.y>=u&&_.y<=d&&Ue(r,a,n,h,o,l,_.x,_.y)&&tt(_.prev,_,_.next)>=0)return  false;_=_.next;}return  true}function fl(s,t,e,i){const r=s.prev,n=s,o=s.next;if(tt(r,n,o)>=0)return  false;const a=r.x,h=n.x,l=o.x,c=r.y,u=n.y,f=o.y,d=Math.min(a,h,l),_=Math.min(c,u,f),g=Math.max(a,h,l),p=Math.max(c,u,f),m=Is(d,_,t,e,i),y=Is(g,p,t,e,i);let x=s.prevZ,b=s.nextZ;for(;x&&x.z>=m&&b&&b.z<=y;){if(x.x>=d&&x.x<=g&&x.y>=_&&x.y<=p&&x!==r&&x!==o&&Ue(a,c,h,u,l,f,x.x,x.y)&&tt(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=d&&b.x<=g&&b.y>=_&&b.y<=p&&b!==r&&b!==o&&Ue(a,c,h,u,l,f,b.x,b.y)&&tt(b.prev,b,b.next)>=0))return  false;b=b.nextZ;}for(;x&&x.z>=m;){if(x.x>=d&&x.x<=g&&x.y>=_&&x.y<=p&&x!==r&&x!==o&&Ue(a,c,h,u,l,f,x.x,x.y)&&tt(x.prev,x,x.next)>=0)return  false;x=x.prevZ;}for(;b&&b.z<=y;){if(b.x>=d&&b.x<=g&&b.y>=_&&b.y<=p&&b!==r&&b!==o&&Ue(a,c,h,u,l,f,b.x,b.y)&&tt(b.prev,b,b.next)>=0)return  false;b=b.nextZ;}return  true}function _l(s,t){let e=s;do{const i=e.prev,r=e.next.next;!ke(i,r)&&yo(i,e,e.next,r)&&je(i,r)&&je(r,i)&&(t.push(i.i,e.i,r.i),qe(e),qe(e.next),e=s=r),e=e.next;}while(e!==s);return ue(e)}function pl(s,t,e,i,r,n){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Al(o,a)){let h=xo(o,a);o=ue(o,o.next),h=ue(h,h.next),Xe(o,t,e,i,r,n,0),Xe(h,t,e,i,r,n,0);return}a=a.next;}o=o.next;}while(o!==s)}function gl(s,t,e,i){const r=[];for(let n=0,o=t.length;n<o;n++){const a=t[n]*i,h=n<o-1?t[n+1]*i:s.length,l=go(s,a,h,i,false);l===l.next&&(l.steiner=true),r.push(kl(l));}r.sort(ml);for(let n=0;n<r.length;n++)e=yl(r[n],e);return e}function ml(s,t){let e=s.x-t.x;if(e===0&&(e=s.y-t.y,e===0)){const i=(s.next.y-s.y)/(s.next.x-s.x),r=(t.next.y-t.y)/(t.next.x-t.x);e=i-r;}return e}function yl(s,t){const e=xl(s,t);if(!e)return t;const i=xo(e,s);return ue(i,i.next),ue(e,e.next)}function xl(s,t){let e=t;const i=s.x,r=s.y;let n=-1/0,o;if(ke(s,e))return e;do{if(ke(s,e.next))return e.next;if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){const u=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(u<=i&&u>n&&(n=u,o=e.x<e.next.x?e:e.next,u===i))return o}e=e.next;}while(e!==t);if(!o)return null;const a=o,h=o.x,l=o.y;let c=1/0;e=o;do{if(i>=e.x&&e.x>=h&&i!==e.x&&mo(r<l?i:n,r,h,l,r<l?n:i,r,e.x,e.y)){const u=Math.abs(r-e.y)/(i-e.x);je(e,s)&&(u<c||u===c&&(e.x>o.x||e.x===o.x&&bl(o,e)))&&(o=e,c=u);}e=e.next;}while(e!==a);return o}function bl(s,t){return tt(s.prev,s,t.prev)<0&&tt(t.next,s,s.next)<0}function wl(s,t,e,i){let r=s;do r.z===0&&(r.z=Is(r.x,r.y,t,e,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==s);r.prevZ.nextZ=null,r.prevZ=null,vl(r);}function vl(s){let t,e=1;do{let i=s,r;s=null;let n=null;for(t=0;i;){t++;let o=i,a=0;for(let l=0;l<e&&(a++,o=o.nextZ,!!o);l++);let h=e;for(;a>0||h>0&&o;)a!==0&&(h===0||!o||i.z<=o.z)?(r=i,i=i.nextZ,a--):(r=o,o=o.nextZ,h--),n?n.nextZ=r:s=r,r.prevZ=n,n=r;i=o;}n.nextZ=null,e*=2;}while(t>1);return s}function Is(s,t,e,i,r){return s=(s-e)*r|0,t=(t-i)*r|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function kl(s){let t=s,e=s;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==s);return e}function mo(s,t,e,i,r,n,o,a){return (r-o)*(t-a)>=(s-o)*(n-a)&&(s-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(r-o)*(i-a)}function Ue(s,t,e,i,r,n,o,a){return !(s===o&&t===a)&&mo(s,t,e,i,r,n,o,a)}function Al(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!Sl(s,t)&&(je(s,t)&&je(t,s)&&Cl(s,t)&&(tt(s.prev,s,t.prev)||tt(s,t.prev,t))||ke(s,t)&&tt(s.prev,s,s.next)>0&&tt(t.prev,t,t.next)>0)}function tt(s,t,e){return (t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function ke(s,t){return s.x===t.x&&s.y===t.y}function yo(s,t,e,i){const r=hi(tt(s,t,e)),n=hi(tt(s,t,i)),o=hi(tt(e,i,s)),a=hi(tt(e,i,t));return !!(r!==n&&o!==a||r===0&&ai(s,e,t)||n===0&&ai(s,i,t)||o===0&&ai(e,s,i)||a===0&&ai(e,t,i))}function ai(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function hi(s){return s>0?1:s<0?-1:0}function Sl(s,t){let e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&yo(e,e.next,s,t))return  true;e=e.next;}while(e!==s);return  false}function je(s,t){return tt(s.prev,s,s.next)<0?tt(s,t,s.next)>=0&&tt(s,s.prev,t)>=0:tt(s,t,s.prev)<0||tt(s,s.next,t)<0}function Cl(s,t){let e=s,i=false;const r=(s.x+t.x)/2,n=(s.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&r<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==s);return i}function xo(s,t){const e=zs(s.i,s.x,s.y),i=zs(t.i,t.x,t.y),r=s.next,n=t.prev;return s.next=t,t.prev=s,e.next=r,r.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function zr(s,t,e,i){const r=zs(s,t,e);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function qe(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ);}function zs(s,t,e){return {i:s,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:false}}function Ml(s,t,e,i){let r=0;for(let n=t,o=e-i;n<e;n+=i)r+=(s[o]-s[n])*(s[n+1]+s[o+1]),o=n;return r}const Tl=Ir.default||Ir;var bo=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=16384]="COLOR",s[s.STENCIL=1024]="STENCIL",s[s.DEPTH=256]="DEPTH",s[s.COLOR_DEPTH=16640]="COLOR_DEPTH",s[s.COLOR_STENCIL=17408]="COLOR_STENCIL",s[s.DEPTH_STENCIL=1280]="DEPTH_STENCIL",s[s.ALL=17664]="ALL",s))(bo||{});class Pl{constructor(t){this.items=[],this._name=t;}emit(t,e,i,r,n,o,a,h){const{name:l,items:c}=this;for(let u=0,f=c.length;u<f;u++)c[u][l](t,e,i,r,n,o,a,h);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return 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}}const Il=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],wo=class vo extends Ot{constructor(t){super(),this.tick=0,this.uid=st("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const e=[...Il,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck();}async init(t={}){const e=t.skipExtensionImports===true?true:t.manageImports===false;await cl(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash)t={...this._systemsHash[i].constructor.defaultOptions,...t};t={...vo.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(t);this._initOptions=t;}render(t,e){this.tick++;let i=t;if(i instanceof U&&(i={container:i},e&&(D(j,"passing a second argument is deprecated, please use render options instead"),i.target=e.renderTexture)),i.target||(i.target=this.view.renderTarget),i.target===this.view.renderTarget&&(this._lastObjectRendered=i.container,i.clearColor??(i.clearColor=this.background.colorRgba),i.clear??(i.clear=this.background.clearBeforeRender)),i.clearColor){const r=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=r?i.clearColor:ot.shared.setValue(i.clearColor).toArray();}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),i.container.visible&&(i.container.enableRenderGroup(),this.runners.prerender.emit(i),this.runners.renderStart.emit(i),this.runners.render.emit(i),this.runners.renderEnd.emit(i),this.runners.postrender.emit(i));}resize(t,e,i){const r=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==r&&this.runners.resolutionChange.emit(i);}clear(t={}){const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=bo.ALL);const{clear:i,clearColor:r,target:n}=t;ot.shared.setValue(r??this.background.colorRgba),e.renderTarget.clear(n,i,ot.shared.toArray());}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t);}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new Pl(e);});}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name);}}_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 r in this.runners)this.runners[r].add(i);return this}_addPipes(t,e){const i=e.reduce((r,n)=>(r[n.name]=n.value,r),{});t.forEach(r=>{const n=r.value,o=r.name,a=i[o];this.renderPipes[o]=new n(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o]);});}destroy(t=false){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===true||typeof t=="object"&&t.releaseGlobalResources)&&Qe.release(),Object.values(this.runners).forEach(e=>{e.destroy();}),this._systemsHash=null,this.renderPipes=null;}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return !!this._roundPixels}_unsafeEvalCheck(){if(!ul())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit();}};wo.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:false,roundPixels:false};let ko=wo,li;function zl(s){return li!==void 0||(li=(()=>{const t={stencil:true,failIfMajorPerformanceCaveat:s??ko.defaultOptions.failIfMajorPerformanceCaveat};try{if(!$.get().getWebGLRenderingContext())return !1;let i=$.get().createCanvas().getContext("webgl",t);const r=!!i?.getContextAttributes()?.stencil;if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext();}return i=null,r}catch{return  false}})()),li}let ci;async function El(s={}){return ci!==void 0||(ci=await(async()=>{const t=$.get().getNavigator().gpu;if(!t)return  false;try{return await(await t.requestAdapter(s)).requestDevice(),!0}catch{return  false}})()),ci}const Er=["webgl","webgpu","canvas"];async function Rl(s){let t=[];s.preference?(t.push(s.preference),Er.forEach(n=>{n!==s.preference&&t.push(n);})):t=Er.slice();let e,i={};for(let n=0;n<t.length;n++){const o=t[n];if(o==="webgpu"&&await El()){const{WebGPURenderer:a}=await import('./WebGPURenderer-CIQymNqd.js');e=a,i={...s,...s.webgpu};break}else if(o==="webgl"&&zl(s.failIfMajorPerformanceCaveat??ko.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await import('./WebGLRenderer-Djwm6Q5G.js');e=a,i={...s,...s.webgl};break}else if(o==="canvas")throw i={...s},new Error("CanvasRenderer is not yet implemented")}if(delete i.webgpu,delete i.webgl,!e)throw new Error("No available renderer for the current environment");const r=new e;return await r.init(i),r}const Ao="8.15.0";class So{static init(){globalThis.__PIXI_APP_INIT__?.(this,Ao);}static destroy(){}}So.extension=B.Application;class Fl{constructor(t){this._renderer=t;}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,Ao);}destroy(){this._renderer=null;}}Fl.extension={type:[B.WebGLSystem,B.WebGPUSystem],name:"initHook",priority:-10};const Co=class Es{constructor(...t){this.stage=new U,t[0]!==void 0&&D(j,"Application constructor options are deprecated, please use Application.init() instead.");}async init(t){t={...t},this.stage||(this.stage=new U),this.renderer=await Rl(t),Es._plugins.forEach(e=>{e.init.call(this,t);});}render(){this.renderer.render({container:this.stage});}get canvas(){return this.renderer.canvas}get view(){return D(j,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=false,e=false){const i=Es._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this);}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null;}};Co._plugins=[];let Mo=Co;ft.handleByList(B.Application,Mo._plugins);ft.add(So);class To extends Ot{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=true,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100;}get font(){return D(j,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return D(j,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return D(j,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return D(j,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return D(j,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=false){this.emit("destroy",this),this.removeAllListeners();for(const e in this.chars)this.chars[e].texture?.destroy();this.chars=null,t&&(this.pages.forEach(e=>e.texture.destroy(true)),this.pages=null);}}class Bl{constructor(t=0,e=0,i=false){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=e;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev);}return this}entries(t=this.keys()){const e=new Array(t.length);for(let i=0;i<t.length;i++){const r=t[i];e[i]=[r,this.get(r)];}return e}evict(t=false){if(t||this.size>0){const e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null);}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t));}keys(){const t=new Array(this.size);let e=this.first,i=0;for(;e!==null;)t[i++]=e.key,e=e.next;return t}setWithEvicted(t,e,i=this.resetTtl){let r=null;if(this.has(t))this.set(t,e,true,i);else {this.max>0&&this.size===this.max&&(r={...this.first},this.evict(true));let n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=n:this.last.next=n,this.last=n;}return r}set(t,e,i=false,r=this.resetTtl){let n=this.items[t];return i||n!==void 0?(n.value=e,i===false&&r&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(true),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(t=this.keys()){const e=new Array(t.length);for(let i=0;i<t.length;i++)e[i]=this.get(t[i]);return e}}function Po(s=1e3,t=0,e=false){if(isNaN(s)||s<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof e!="boolean")throw new TypeError("Invalid resetTtl value");return new Bl(s,t,e)}const Ll=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Rs(s){const t=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let e=s.fontFamily;Array.isArray(s.fontFamily)||(e=s.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let r=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!Ll.includes(r)&&(r=`"${r}"`),e[i]=r;}return `${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}const rs={willReadFrequently:true},Gt=class z{static get experimentalLetterSpacingSupported(){let t=z._experimentalLetterSpacingSupported;if(t===void 0){const e=$.get().getCanvasRenderingContext2D().prototype;t=z._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e;}return t}constructor(t,e,i,r,n,o,a,h,l){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=h,this.fontProperties=l;}static measureText(t=" ",e,i=z._canvas,r=e.wordWrap){const n=`${t}-${e.styleKey}-wordWrap-${r}`;if(z._measurementCache.has(n))return z._measurementCache.get(n);const o=Rs(e),a=z.measureFont(o);a.fontSize===0&&(a.fontSize=e.fontSize,a.ascent=e.fontSize);const h=z.__context;h.font=o;const c=(r?z._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),u=new Array(c.length);let f=0;for(let y=0;y<c.length;y++){const x=z._measureText(c[y],e.letterSpacing,h);u[y]=x,f=Math.max(f,x);}const d=e._stroke?.width||0;let _=f+d;e.dropShadow&&(_+=e.dropShadow.distance);const g=e.lineHeight||a.fontSize;let p=Math.max(g,a.fontSize+d)+(c.length-1)*(g+e.leading);e.dropShadow&&(p+=e.dropShadow.distance);const m=new z(t,e,_,p,c,u,g+e.leading,f,a);return z._measurementCache.set(n,m),m}static _measureText(t,e,i){let r=false;z.experimentalLetterSpacingSupported&&(z.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,r=true):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const n=i.measureText(t);let o=n.width;const a=-n.actualBoundingBoxLeft;let l=n.actualBoundingBoxRight-a;if(o>0)if(r)o-=e,l-=e;else {const c=(z.graphemeSegmenter(t).length-1)*e;o+=c,l+=c;}return Math.max(o,l)}static _wordWrap(t,e,i=z._canvas){const r=i.getContext("2d",rs);let n=0,o="",a="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,u=z._collapseSpaces(c),f=z._collapseNewlines(c);let d=!u;const _=e.wordWrapWidth+l,g=z._tokenize(t);for(let p=0;p<g.length;p++){let m=g[p];if(z._isNewline(m)){if(!f){a+=z._addLine(o),d=!u,o="",n=0;continue}m=" ";}if(u){const x=z.isBreakingSpace(m),b=z.isBreakingSpace(o[o.length-1]);if(x&&b)continue}const y=z._getFromCache(m,l,h,r);if(y>_)if(o!==""&&(a+=z._addLine(o),o="",n=0),z.canBreakWords(m,e.breakWords)){const x=z.wordWrapSplit(m);for(let b=0;b<x.length;b++){let A=x[b],w=A,k=1;for(;x[b+k];){const I=x[b+k];if(!z.canBreakChars(w,I,m,b,e.breakWords))A+=I;else break;w=I,k++;}b+=k-1;const E=z._getFromCache(A,l,h,r);E+n>_&&(a+=z._addLine(o),d=false,o="",n=0),o+=A,n+=E;}}else {o.length>0&&(a+=z._addLine(o),o="",n=0);const x=p===g.length-1;a+=z._addLine(m,!x),d=false,o="",n=0;}else y+n>_&&(d=false,a+=z._addLine(o),o="",n=0),(o.length>0||!z.isBreakingSpace(m)||d)&&(o+=m,n+=y);}return a+=z._addLine(o,false),a}static _addLine(t,e=true){return t=z._trimRight(t),t=e?`${t}
`:t,t}static _getFromCache(t,e,i,r){let n=i[t];return typeof n!="number"&&(n=z._measureText(t,e,r)+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"?false:z._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?false:z._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let r=0;r<t.length;r++){const n=t[r],o=t[r+1];if(z.isBreakingSpace(n,o)||z._isNewline(n)){i!==""&&(e.push(i),i=""),n==="\r"&&o===`
`?(e.push(`\r
`),r++):e.push(n);continue}i+=n;}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,r,n){return  true}static wordWrapSplit(t){return z.graphemeSegmenter(t)}static measureFont(t){if(z._fonts[t])return z._fonts[t];const e=z._context;e.font=t;const i=e.measureText(z.METRICS_STRING+z.BASELINE_SYMBOL),r={ascent:i.actualBoundingBoxAscent,descent:i.actualBoundingBoxDescent,fontSize:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent};return z._fonts[t]=r,r}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",rs)?.measureText)return z.__canvas=e,e;t=$.get().createCanvas();}catch{t=$.get().createCanvas();}t.width=t.height=10,z.__canvas=t;}return z.__canvas}static get _context(){return z.__context||(z.__context=z._canvas.getContext("2d",rs)),z.__context}};Gt.METRICS_STRING="|ÉqÅ";Gt.BASELINE_SYMBOL="M";Gt.BASELINE_MULTIPLIER=1.4;Gt.HEIGHT_MULTIPLIER=2;Gt.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){const s=new Intl.Segmenter;return t=>{const e=s.segment(t),i=[];let r=0;for(const n of e)i[r++]=n.segment;return i}}return s=>[...s]})();Gt.experimentalLetterSpacing=false;Gt._fonts={};Gt._newlines=[10,13];Gt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];Gt._measurementCache=Po(1e3);let gi=Gt;const Rr=[{offset:0,color:"white"},{offset:1,color:"black"}],Ks=class Fs{constructor(...t){this.uid=st("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=Ol(t);e={...e.type==="radial"?Fs.defaultRadialOptions:Fs.defaultLinearOptions,...zn(e)},this._textureSize=e.textureSize,this._wrapMode=e.wrapMode,e.type==="radial"?(this.center=e.center,this.outerCenter=e.outerCenter??this.center,this.innerRadius=e.innerRadius,this.outerRadius=e.outerRadius,this.scale=e.scale,this.rotation=e.rotation):(this.start=e.start,this.end=e.end),this.textureSpace=e.textureSpace,this.type=e.type,e.colorStops.forEach(r=>{this.addColorStop(r.offset,r.color);});}addColorStop(t,e){return this.colorStops.push({offset:t,color:ot.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:r}=this.end,n=i-t,o=r-e;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const p=t;t=i,i=p,n*=-1;}if(o<0){const p=e;e=r,r=p,o*=-1;}}const h=this.colorStops.length?this.colorStops:Rr,l=this._textureSize,{canvas:c,context:u}=Br(l,1),f=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);Fr(f,h),u.fillStyle=f,u.fillRect(0,0,l,1),this.texture=new W({source:new ce({resource:c,addressMode:this._wrapMode})});const d=Math.sqrt(n*n+o*o),_=Math.atan2(o,n),g=new H;g.scale(d/l,1),g.rotate(_),g.translate(t,e),this.textureSpace==="local"&&g.scale(l,l),this.transform=g;}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient();}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Rr,e=this._textureSize,{canvas:i,context:r}=Br(e,e),{x:n,y:o}=this.center,{x:a,y:h}=this.outerCenter,l=this.innerRadius,c=this.outerRadius,u=a-c,f=h-c,d=e/(c*2),_=(n-u)*d,g=(o-f)*d,p=r.createRadialGradient(_,g,l*d,(a-u)*d,(h-f)*d,c*d);Fr(p,t),r.fillStyle=t[t.length-1].color,r.fillRect(0,0,e,e),r.fillStyle=p,r.translate(_,g),r.rotate(this.rotation),r.scale(1,this.scale),r.translate(-_,-g),r.fillRect(0,0,e,e),this.texture=new W({source:new ce({resource:i,addressMode:this._wrapMode})});const m=new H;m.scale(1/d,1/d),m.translate(u,f),this.textureSpace==="local"&&m.scale(e,e),this.transform=m;}destroy(){this.texture?.destroy(true),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null;}get styleKey(){return `fill-gradient-${this.uid}-${this._tick}`}};Ks.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};Ks.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Xt=Ks;function Fr(s,t){for(let e=0;e<t.length;e++){const i=t[e];s.addColorStop(i.offset,i.color);}}function Br(s,t){const e=$.get().createCanvas(s,t),i=e.getContext("2d");return {canvas:e,context:i}}function Ol(s){let t=s[0]??{};return (typeof t=="number"||s[1])&&(D("8.5.2","use options object instead"),t={type:"linear",start:{x:s[0],y:s[1]},end:{x:s[2],y:s[3]},textureSpace:s[4],textureSize:s[5]??Xt.defaultLinearOptions.textureSize}),t}const Lr={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class Ti{constructor(t,e){this.uid=st("fillPattern"),this._tick=0,this.transform=new H,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Lr[e].addressModeU,t.source.style.addressModeV=Lr[e].addressModeV);}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._tick++;}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture=t,this._tick++);}get styleKey(){return `fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(true),this.texture=null;}}var ns,Or;function Gl(){if(Or)return ns;Or=1,ns=e;var s={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function e(n){var o=[];return n.replace(t,function(a,h,l){var c=h.toLowerCase();for(l=r(l),c=="m"&&l.length>2&&(o.push([h].concat(l.splice(0,2))),c="l",h=h=="m"?"l":"L");;){if(l.length==s[c])return l.unshift(h),o.push(l);if(l.length<s[c])throw new Error("malformed path data");o.push([h].concat(l.splice(0,s[c])));}}),o}var i=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function r(n){var o=n.match(i);return o?o.map(Number):[]}return ns}var Dl=Gl();const Ul=an$1(Dl);function Nl(s,t){const e=Ul(s),i=[];let r=null,n=0,o=0;for(let a=0;a<e.length;a++){const h=e[a],l=h[0],c=h;switch(l){case "M":n=c[1],o=c[2],t.moveTo(n,o);break;case "m":n+=c[1],o+=c[2],t.moveTo(n,o);break;case "H":n=c[1],t.lineTo(n,o);break;case "h":n+=c[1],t.lineTo(n,o);break;case "V":o=c[1],t.lineTo(n,o);break;case "v":o+=c[1],t.lineTo(n,o);break;case "L":n=c[1],o=c[2],t.lineTo(n,o);break;case "l":n+=c[1],o+=c[2],t.lineTo(n,o);break;case "C":n=c[5],o=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],n,o);break;case "c":t.bezierCurveTo(n+c[1],o+c[2],n+c[3],o+c[4],n+c[5],o+c[6]),n+=c[5],o+=c[6];break;case "S":n=c[3],o=c[4],t.bezierCurveToShort(c[1],c[2],n,o);break;case "s":t.bezierCurveToShort(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case "Q":n=c[3],o=c[4],t.quadraticCurveTo(c[1],c[2],n,o);break;case "q":t.quadraticCurveTo(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case "T":n=c[1],o=c[2],t.quadraticCurveToShort(n,o);break;case "t":n+=c[1],o+=c[2],t.quadraticCurveToShort(n,o);break;case "A":n=c[6],o=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case "a":n+=c[6],o+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case "Z":case "z":t.closePath(),i.length>0&&(r=i.pop(),r?(n=r.startX,o=r.startY):(n=0,o=0)),r=null;break;default:J(`Unknown SVG path command: ${l}`);}l!=="Z"&&l!=="z"&&r===null&&(r={startX:n,startY:o},i.push(r));}return t}class Zs{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i;}clone(){return new Zs(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return  false;const i=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=i}strokeContains(t,e,i,r=.5){if(this.radius===0)return  false;const n=this.x-t,o=this.y-e,a=this.radius,h=(1-r)*i,l=Math.sqrt(n*n+o*o);return l<=a+h&&l>a-(i-h)}getBounds(t){return t||(t=new Z),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return `[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class Qs{constructor(t=0,e=0,i=0,r=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=r;}clone(){return new Qs(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return  false;let i=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return i*=i,r*=r,i+r<=1}strokeContains(t,e,i,r=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return  false;const a=i*(1-r),h=i-a,l=n-h,c=o-h,u=n+a,f=o+a,d=t-this.x,_=e-this.y,g=d*d/(l*l)+_*_/(c*c),p=d*d/(u*u)+_*_/(f*f);return g>1&&p<=1}getBounds(t){return t||(t=new Z),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return `[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function Wl(s,t,e,i,r,n){const o=s-e,a=t-i,h=r-e,l=n-i,c=o*h+a*l,u=h*h+l*l;let f=-1;u!==0&&(f=c/u);let d,_;f<0?(d=e,_=i):f>1?(d=r,_=n):(d=e+f*h,_=i+f*l);const g=s-d,p=t-_;return g*g+p*p}let Hl,Vl;class He{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let r=0,n=e.length;r<n;r++)i.push(e[r].x,e[r].y);e=i;}this.points=e,this.closePath=true;}isClockwise(){let t=0;const e=this.points,i=e.length;for(let r=0;r<i;r+=2){const n=e[r],o=e[r+1],a=e[(r+2)%i],h=e[(r+3)%i];t+=(a-n)*(h+o);}return t<0}containsPolygon(t){const e=this.getBounds(Hl),i=t.getBounds(Vl);if(!e.containsRect(i))return  false;const r=t.points;for(let n=0;n<r.length;n+=2){const o=r[n],a=r[n+1];if(!this.contains(o,a))return  false}return  true}clone(){const t=this.points.slice(),e=new He(t);return e.closePath=this.closePath,e}contains(t,e){let i=false;const r=this.points.length/2;for(let n=0,o=r-1;n<r;o=n++){const a=this.points[n*2],h=this.points[n*2+1],l=this.points[o*2],c=this.points[o*2+1];h>e!=c>e&&t<(l-a)*((e-h)/(c-h))+a&&(i=!i);}return i}strokeContains(t,e,i,r=.5){const n=i*i,o=n*(1-r),a=n-o,{points:h}=this,l=h.length-(this.closePath?0:2);for(let c=0;c<l;c+=2){const u=h[c],f=h[c+1],d=h[(c+2)%h.length],_=h[(c+3)%h.length],g=Wl(t,e,u,f,d,_),p=Math.sign((d-u)*(e-f)-(_-f)*(t-u));if(g<=(p<0?a:o))return  true}return  false}getBounds(t){t||(t=new Z);const e=this.points;let i=1/0,r=-1/0,n=1/0,o=-1/0;for(let a=0,h=e.length;a<h;a+=2){const l=e[a],c=e[a+1];i=l<i?l:i,r=l>r?l:r,n=c<n?c:n,o=c>o?c:o;}return t.x=i,t.width=r-i,t.y=n,t.height=o-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return `[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return D("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return D("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const ui=(s,t,e,i,r,n,o)=>{const a=s-e,h=t-i,l=Math.sqrt(a*a+h*h);return l>=r-n&&l<=r+o};class Js{constructor(t=0,e=0,i=0,r=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=r,this.radius=n;}getBounds(t){return t||(t=new Z),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Js(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return  false;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  true;let r=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(r*r+n*n<=o||(r=t-(this.x+this.width-i),r*r+n*n<=o)||(n=e-(this.y+this.height-i),r*r+n*n<=o)||(r=t-(this.x+i),r*r+n*n<=o))return  true}return  false}strokeContains(t,e,i,r=.5){const{x:n,y:o,width:a,height:h,radius:l}=this,c=i*(1-r),u=i-c,f=n+l,d=o+l,_=a-l*2,g=h-l*2,p=n+a,m=o+h;return (t>=n-c&&t<=n+u||t>=p-u&&t<=p+c)&&e>=d&&e<=d+g||(e>=o-c&&e<=o+u||e>=m-u&&e<=m+c)&&t>=f&&t<=f+_?true:t<f&&e<d&&ui(t,e,f,d,l,u,c)||t>p-l&&e<d&&ui(t,e,p-l,d,l,u,c)||t>p-l&&e>m-l&&ui(t,e,p-l,m-l,l,u,c)||t<f&&e>m-l&&ui(t,e,f,m-l,l,u,c)}toString(){return `[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const Io={};function Yl(s,t,e){let i=2166136261;for(let r=0;r<t;r++)i^=s[r].uid,i=Math.imul(i,16777619),i>>>=0;return Io[i]||Xl(s,t,i,e)}function Xl(s,t,e,i){const r={};let n=0;for(let a=0;a<i;a++){const h=a<t?s[a]:W.EMPTY.source;r[n++]=h.source,r[n++]=h.style;}const o=new pi(r);return Io[e]=o,o}class Gr{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),this.size=this.rawBinaryData.byteLength;}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 int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=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`)}}}function Dr(s,t){const e=s.byteLength/8|0,i=new Float64Array(s,0,e);new Float64Array(t,0,e).set(i);const n=s.byteLength-e*8;if(n>0){const o=new Uint8Array(s,e*8,n);new Uint8Array(t,e*8,n).set(o);}}const jl={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var ql=(s=>(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",s[s.NONE=5]="NONE",s))(ql||{});function Ur(s,t){return t.alphaMode==="no-premultiply-alpha"&&jl[s]||s}const Kl=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
`);function Zl(s){let t="";for(let e=0;e<s;++e)e>0&&(t+=`
else `),e<s-1&&(t+=`if(test == ${e}.0){}`);return t}function Ql(s,t){if(s===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const i=Kl.replace(/%forloop%/gi,Zl(s));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))s=s/2|0;else break}}finally{t.deleteShader(e);}return s}let fe=null;function Jl(){if(fe)return fe;const s=ao();return fe=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),fe=Ql(fe,s),s.getExtension("WEBGL_lose_context")?.loseContext(),fe}class $l{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0;}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null;}this.count=0;}}class tc{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new $l,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=true;}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null;}}const Ve=[];let ki=0;Qe.register({clear:()=>{if(Ve.length>0)for(const s of Ve)s&&s.destroy();Ve.length=0,ki=0;}});function Nr(){return ki>0?Ve[--ki]:new tc}function Wr(s){Ve[ki++]=s;}let Fe=0;const zo=class Eo{constructor(t){this.uid=st("batcher"),this.dirty=true,this.batchIndex=0,this.batches=[],this._elements=[],t={...Eo.defaultOptions,...t},t.maxTextures||(D("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=Jl());const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:r}=t;this.attributeBuffer=new Gr(i*4),this.indexBuffer=new Uint16Array(r),this.maxTextures=e;}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)Wr(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=true;}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize;}checkAndUpdateTexture(t,e){const i=t._batch.textures.ids[e._source.uid];return !i&&i!==0?false:(t._textureId=i,t.texture=e,true)}updateElement(t){this.dirty=true;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId);}break(t){const e=this._elements;if(!e[this.elementStart])return;let i=Nr(),r=i.textures;r.clear();const n=e[this.elementStart];let o=Ur(n.blendMode,n.texture._source),a=n.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const h=this.attributeBuffer.float32View,l=this.attributeBuffer.uint32View,c=this.indexBuffer;let u=this._batchIndexSize,f=this._batchIndexStart,d="startBatch";const _=this.maxTextures;for(let g=this.elementStart;g<this.elementSize;++g){const p=e[g];e[g]=null;const y=p.texture._source,x=Ur(p.blendMode,y),b=o!==x||a!==p.topology;if(y._batchTick===Fe&&!b){p._textureId=y._textureBindLocation,u+=p.indexSize,p.packAsQuad?(this.packQuadAttributes(p,h,l,p._attributeStart,p._textureId),this.packQuadIndex(c,p._indexStart,p._attributeStart/this.vertexSize)):(this.packAttributes(p,h,l,p._attributeStart,p._textureId),this.packIndex(p,c,p._indexStart,p._attributeStart/this.vertexSize)),p._batch=i;continue}y._batchTick=Fe,(r.count>=_||b)&&(this._finishBatch(i,f,u-f,r,o,a,t,d),d="renderBatch",f=u,o=x,a=p.topology,i=Nr(),r=i.textures,r.clear(),++Fe),p._textureId=y._textureBindLocation=r.count,r.ids[y.uid]=r.count,r.textures[r.count++]=y,p._batch=i,u+=p.indexSize,p.packAsQuad?(this.packQuadAttributes(p,h,l,p._attributeStart,p._textureId),this.packQuadIndex(c,p._indexStart,p._attributeStart/this.vertexSize)):(this.packAttributes(p,h,l,p._attributeStart,p._textureId),this.packIndex(p,c,p._indexStart,p._attributeStart/this.vertexSize));}r.count>0&&(this._finishBatch(i,f,u-f,r,o,a,t,d),f=u,++Fe),this.elementStart=this.elementSize,this._batchIndexStart=f,this._batchIndexSize=u;}_finishBatch(t,e,i,r,n,o,a,h){t.gpuBindGroup=null,t.bindGroup=null,t.action=h,t.batcher=this,t.textures=r,t.blendMode=n,t.topology=o,t.start=e,t.size=i,++Fe,this.batches[this.batchIndex++]=t,a.add(t);}finish(t){this.break(t);}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4);}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t);}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new Gr(e);Dr(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i;}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const r=i>65535?new Uint32Array(i):new Uint16Array(i);if(r.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)r[n]=e[n];else Dr(e.buffer,r.buffer);this.indexBuffer=r;}packQuadIndex(t,e,i){t[e]=i+0,t[e+1]=i+1,t[e+2]=i+2,t[e+3]=i+0,t[e+4]=i+2,t[e+5]=i+3;}packIndex(t,e,i,r){const n=t.indices,o=t.indexSize,a=t.indexOffset,h=t.attributeOffset;for(let l=0;l<o;l++)e[i++]=r+n[l+a]-h;}destroy(t={}){if(this.batches!==null){for(let e=0;e<this.batchIndex;e++)Wr(this.batches[e]);this.batches=null,this.geometry.destroy(true),this.geometry=null,t.shader&&(this.shader?.destroy(),this.shader=null);for(let e=0;e<this._elements.length;e++)this._elements[e]&&(this._elements[e]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null;}}};zo.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let ec=zo;var vt=(s=>(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(vt||{});class Ke extends Ot{constructor(t){let{data:e,size:i}=t;const{usage:r,label:n,shrinkToFit:o}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=true,this.uid=st("buffer"),this._resourceType="buffer",this._resourceId=st("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=true,this.destroyed=false,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i??(i=e?.byteLength);const a=!!e;this.descriptor={size:i,usage:r,mappedAtCreation:a,label:n},this.shrinkToFit=o??true;}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,true);}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return !!(this.descriptor.usage&vt.STATIC)}set static(t){t?this.descriptor.usage|=vt.STATIC:this.descriptor.usage&=~vt.STATIC;}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const r=this._data;if(this._data=t,this._dataInt32=null,!r||r.length!==t.length){!this.shrinkToFit&&r&&t.byteLength<r.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=st("resource"),this.emit("change",this));return}i&&this.emit("update",this);}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this);}unload(){this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null);}destroy(){this.destroyed=true,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners();}}function Ro(s,t){if(!(s instanceof Ke)){let e=t?vt.INDEX:vt.VERTEX;s instanceof Array&&(t?(s=new Uint32Array(s),e=vt.INDEX|vt.COPY_DST):(s=new Float32Array(s),e=vt.VERTEX|vt.COPY_DST)),s=new Ke({data:s,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e});}return s}function ic(s,t,e){const i=s.getAttribute(t);if(!i)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const r=i.buffer.data;let n=1/0,o=1/0,a=-1/0,h=-1/0;const l=r.BYTES_PER_ELEMENT,c=(i.offset||0)/l,u=(i.stride||8)/l;for(let f=c;f<r.length;f+=u){const d=r[f],_=r[f+1];d>a&&(a=d),_>h&&(h=_),d<n&&(n=d),_<o&&(o=_);}return e.minX=n,e.minY=o,e.maxX=a,e.maxY=h,e}function sc(s){return (s instanceof Ke||Array.isArray(s)||s.BYTES_PER_ELEMENT)&&(s={buffer:s}),s.buffer=Ro(s.buffer,false),s}class rc extends Ot{constructor(t={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=true,this._gcLastUsed=-1,this.uid=st("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new Lt,this._boundsDirty=true;const{attributes:e,indexBuffer:i,topology:r}=t;if(this.buffers=[],this.attributes={},e)for(const n in e)this.addAttribute(n,e[n]);this.instanceCount=t.instanceCount??1,i&&this.addIndex(i),this.topology=r||"triangle-list";}onBufferUpdate(){this._boundsDirty=true,this.emit("update",this);}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){const i=sc(e);this.buffers.indexOf(i.buffer)===-1&&(this.buffers.push(i.buffer),i.buffer.on("update",this.onBufferUpdate,this),i.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=i;}addIndex(t){this.indexBuffer=Ro(t,true),this.buffers.push(this.indexBuffer);}get bounds(){return this._boundsDirty?(this._boundsDirty=false,ic(this,"aPosition",this._bounds)):this._bounds}unload(){this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null);}destroy(t=false){this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(e=>e.destroy()),this.unload(),this.indexBuffer?.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null;}}const nc=new Float32Array(1),oc=new Uint32Array(1);class ac extends rc{constructor(){const e=new Ke({data:nc,label:"attribute-batch-buffer",usage:vt.VERTEX|vt.COPY_DST,shrinkToFit:false}),i=new Ke({data:oc,label:"index-batch-buffer",usage:vt.INDEX|vt.COPY_DST,shrinkToFit:false}),r=24;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:r,offset:0},aUV:{buffer:e,format:"float32x2",stride:r,offset:8},aColor:{buffer:e,format:"unorm8x4",stride:r,offset:16},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:r,offset:20}},indexBuffer:i});}}function Hr(s,t,e){if(s)for(const i in s){const r=i.toLocaleLowerCase(),n=t[r];if(n){let o=s[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o);}else J(`${i} placement hook does not exist in shader`);}}const hc=/\{\{(.*?)\}\}/g;function Vr(s){const t={};return (s.match(hc)?.map(i=>i.replace(/[{()}]/g,""))??[]).forEach(i=>{t[i]=[];}),t}function Yr(s,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1]);}function Xr(s,t,e=false){const i=[];Yr(t,i),s.forEach(a=>{a.header&&Yr(a.header,i);});const r=i;e&&r.sort();const n=r.map((a,h)=>`       @location(${h}) ${a},`).join(`
`);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
${n}
`),o}function jr(s,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1]);}function lc(s){const e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function cc(s){const t=/@.*?\s+/g;return s.replace(t,"")}function uc(s,t){const e=[];jr(t,e),s.forEach(h=>{h.header&&jr(h.header,e);});let i=0;const r=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${i++}) ${h}`).join(`,
`),n=e.sort().map(h=>`       var ${cc(h)};`).join(`
`),o=`return VSOutput(
            ${e.sort().map(h=>` ${lc(h)}`).join(`,
`)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
${r}
`),a=a.replace("{{start}}",`
${n}
`),a=a.replace("{{return}}",`
${o}
`),a}function qr(s,t){let e=s;for(const i in t){const r=t[i];r.join(`
`).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----//
${r.join(`
`)}
//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"");}return e}const Kt=Object.create(null),os=new Map;let dc=0;function fc({template:s,bits:t}){const e=Fo(s,t);if(Kt[e])return Kt[e];const{vertex:i,fragment:r}=pc(s,t);return Kt[e]=Bo(i,r,t),Kt[e]}function _c({template:s,bits:t}){const e=Fo(s,t);return Kt[e]||(Kt[e]=Bo(s.vertex,s.fragment,t)),Kt[e]}function pc(s,t){const e=t.map(o=>o.vertex).filter(o=>!!o),i=t.map(o=>o.fragment).filter(o=>!!o);let r=Xr(e,s.vertex,true);r=uc(e,r);const n=Xr(i,s.fragment,true);return {vertex:r,fragment:n}}function Fo(s,t){return t.map(e=>(os.has(e)||os.set(e,dc++),os.get(e))).sort((e,i)=>e-i).join("-")+s.vertex+s.fragment}function Bo(s,t,e){const i=Vr(s),r=Vr(t);return e.forEach(n=>{Hr(n.vertex,i,n.name),Hr(n.fragment,r,n.name);}),{vertex:qr(s,i),fragment:qr(t,r)}}const gc=`
    @in aPosition: vec2<f32>;
    @in aUV: vec2<f32>;

    @out @builtin(position) vPosition: vec4<f32>;
    @out vUV : vec2<f32>;
    @out vColor : vec4<f32>;

    {{header}}

    struct VSOutput {
        {{struct}}
    };

    @vertex
    fn main( {{in}} ) -> VSOutput {

        var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
        var modelMatrix = mat3x3<f32>(
            1.0, 0.0, 0.0,
            0.0, 1.0, 0.0,
            0.0, 0.0, 1.0
          );
        var position = aPosition;
        var uv = aUV;

        {{start}}

        vColor = vec4<f32>(1., 1., 1., 1.);

        {{main}}

        vUV = uv;

        var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;

        vPosition =  vec4<f32>((modelViewProjectionMatrix *  vec3<f32>(position, 1.0)).xy, 0.0, 1.0);

        vColor *= globalUniforms.uWorldColorAlpha;

        {{end}}

        {{return}}
    };
`,mc=`
    @in vUV : vec2<f32>;
    @in vColor : vec4<f32>;

    {{header}}

    @fragment
    fn main(
        {{in}}
      ) -> @location(0) vec4<f32> {

        {{start}}

        var outColor:vec4<f32>;

        {{main}}

        var finalColor:vec4<f32> = outColor * vColor;

        {{end}}

        return finalColor;
      };
`,yc=`
    in vec2 aPosition;
    in vec2 aUV;

    out vec4 vColor;
    out vec2 vUV;

    {{header}}

    void main(void){

        mat3 worldTransformMatrix = uWorldTransformMatrix;
        mat3 modelMatrix = mat3(
            1.0, 0.0, 0.0,
            0.0, 1.0, 0.0,
            0.0, 0.0, 1.0
          );
        vec2 position = aPosition;
        vec2 uv = aUV;

        {{start}}

        vColor = vec4(1.);

        {{main}}

        vUV = uv;

        mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;

        gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);

        vColor *= uWorldColorAlpha;

        {{end}}
    }
`,xc=`

    in vec4 vColor;
    in vec2 vUV;

    out vec4 finalColor;

    {{header}}

    void main(void) {

        {{start}}

        vec4 outColor;

        {{main}}

        finalColor = outColor * vColor;

        {{end}}
    }
`,bc={name:"global-uniforms-bit",vertex:{header:`
        struct GlobalUniforms {
            uProjectionMatrix:mat3x3<f32>,
            uWorldTransformMatrix:mat3x3<f32>,
            uWorldColorAlpha: vec4<f32>,
            uResolution: vec2<f32>,
        }

        @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
        `}},wc={name:"global-uniforms-bit",vertex:{header:`
          uniform mat3 uProjectionMatrix;
          uniform mat3 uWorldTransformMatrix;
          uniform vec4 uWorldColorAlpha;
          uniform vec2 uResolution;
        `}};function vc({bits:s,name:t}){const e=fc({template:{fragment:mc,vertex:gc},bits:[bc,...s]});return Zt.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function kc({bits:s,name:t}){return new ve({name:t,..._c({template:{vertex:yc,fragment:xc},bits:[wc,...s]})})}const Ac={name:"color-bit",vertex:{header:`
            @in aColor: vec4<f32>;
        `,main:`
            vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
        `}},Sc={name:"color-bit",vertex:{header:`
            in vec4 aColor;
        `,main:`
            vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
        `}},as={};function Cc(s){const t=[];if(s===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else {let e=0;for(let i=0;i<s;i++)t.push(`@group(1) @binding(${e++}) var textureSource${i+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`);}return t.join(`
`)}function Mc(s){const t=[];if(s===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else {t.push("switch vTextureId {");for(let e=0;e<s;e++)e===s-1?t.push("  default:{"):t.push(`  case ${e}:{`),t.push(`      outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push("      break;}");t.push("}");}return t.join(`
`)}function Tc(s){return as[s]||(as[s]={name:"texture-batch-bit",vertex:{header:`
                @in aTextureIdAndRound: vec2<u32>;
                @out @interpolate(flat) vTextureId : u32;
            `,main:`
                vTextureId = aTextureIdAndRound.y;
            `,end:`
                if(aTextureIdAndRound.x == 1)
                {
                    vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
                }
            `},fragment:{header:`
                @in @interpolate(flat) vTextureId: u32;

                ${Cc(s)}
            `,main:`
                var uvDx = dpdx(vUV);
                var uvDy = dpdy(vUV);

                ${Mc(s)}
            `}}),as[s]}const hs={};function Pc(s){const t=[];for(let e=0;e<s;e++)e>0&&t.push("else"),e<s-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(`	outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
`)}function Ic(s){return hs[s]||(hs[s]={name:"texture-batch-bit",vertex:{header:`
                in vec2 aTextureIdAndRound;
                out float vTextureId;

            `,main:`
                vTextureId = aTextureIdAndRound.y;
            `,end:`
                if(aTextureIdAndRound.x == 1.)
                {
                    gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
                }
            `},fragment:{header:`
                in float vTextureId;

                uniform sampler2D uTextures[${s}];

            `,main:`

                ${Pc(s)}
            `}}),hs[s]}const zc={name:"round-pixels-bit",vertex:{header:`
            fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
            {
                return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
            }
        `}},Ec={name:"round-pixels-bit",vertex:{header:`
            vec2 roundPixels(vec2 position, vec2 targetSize)
            {
                return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
            }
        `}},Kr={};function Rc(s){let t=Kr[s];if(t)return t;const e=new Int32Array(s);for(let i=0;i<s;i++)e[i]=i;return t=Kr[s]=new fo({uTextures:{value:e,type:"i32",size:s}},{isStatic:true}),t}class Zr extends Mi{constructor(t){const e=kc({name:"batch",bits:[Sc,Ic(t),Ec]}),i=vc({name:"batch",bits:[Ac,Tc(t),zc]});super({glProgram:e,gpuProgram:i,resources:{batchSamplers:Rc(t)}}),this.maxTextures=t;}}let Be=null;const Lo=class Oo extends ec{constructor(t){super(t),this.geometry=new ac,this.name=Oo.extension.name,this.vertexSize=6,Be??(Be=new Zr(t.maxTextures)),this.shader=Be;}packAttributes(t,e,i,r,n){const o=n<<16|t.roundPixels&65535,a=t.transform,h=a.a,l=a.b,c=a.c,u=a.d,f=a.tx,d=a.ty,{positions:_,uvs:g}=t,p=t.color,m=t.attributeOffset,y=m+t.attributeSize;for(let x=m;x<y;x++){const b=x*2,A=_[b],w=_[b+1];e[r++]=h*A+c*w+f,e[r++]=u*w+l*A+d,e[r++]=g[b],e[r++]=g[b+1],i[r++]=p,i[r++]=o;}}packQuadAttributes(t,e,i,r,n){const o=t.texture,a=t.transform,h=a.a,l=a.b,c=a.c,u=a.d,f=a.tx,d=a.ty,_=t.bounds,g=_.maxX,p=_.minX,m=_.maxY,y=_.minY,x=o.uvs,b=t.color,A=n<<16|t.roundPixels&65535;e[r+0]=h*p+c*y+f,e[r+1]=u*y+l*p+d,e[r+2]=x.x0,e[r+3]=x.y0,i[r+4]=b,i[r+5]=A,e[r+6]=h*g+c*y+f,e[r+7]=u*y+l*g+d,e[r+8]=x.x1,e[r+9]=x.y1,i[r+10]=b,i[r+11]=A,e[r+12]=h*g+c*m+f,e[r+13]=u*m+l*g+d,e[r+14]=x.x2,e[r+15]=x.y2,i[r+16]=b,i[r+17]=A,e[r+18]=h*p+c*m+f,e[r+19]=u*m+l*p+d,e[r+20]=x.x3,e[r+21]=x.y3,i[r+22]=b,i[r+23]=A;}_updateMaxTextures(t){this.shader.maxTextures!==t&&(Be=new Zr(t),this.shader=Be);}destroy(){this.shader=null,super.destroy();}};Lo.extension={type:[B.Batcher],name:"default"};let Fc=Lo;class Bc{constructor(t){this.items=Object.create(null);const{renderer:e,type:i,onUnload:r,priority:n,name:o}=t;this._renderer=e,e.gc.addResourceHash(this,"items",i,n??0),this._onUnload=r,this.name=o;}add(t){return this.items[t.uid]?false:(this.items[t.uid]=t,t.once("unload",this.remove,this),t._gcLastUsed=this._renderer.gc.now,true)}remove(t,...e){if(!this.items[t.uid])return;const i=t._gpuData[this._renderer.uid];i&&(this._onUnload?.(t,...e),i.destroy(),t._gpuData[this._renderer.uid]=null,this.items[t.uid]=null);}removeAll(...t){Object.values(this.items).forEach(e=>e&&this.remove(e,...t));}destroy(...t){this.removeAll(...t),this.items=Object.create(null),this._renderer=null,this._onUnload=null;}}function Lc(s,t,e,i,r,n,o,a=null){let h=0;e*=t,r*=n;const l=a.a,c=a.b,u=a.c,f=a.d,d=a.tx,_=a.ty;for(;h<o;){const g=s[e],p=s[e+1];i[r]=l*g+u*p+d,i[r+1]=c*g+f*p+_,r+=n,e+=t,h++;}}function Oc(s,t,e,i){let r=0;for(t*=e;r<i;)s[t]=0,s[t+1]=0,t+=e,r++;}function Go(s,t,e,i,r){const n=t.a,o=t.b,a=t.c,h=t.d,l=t.tx,c=t.ty;e||(e=0),i||(i=2),r||(r=s.length/i-e);let u=e*i;for(let f=0;f<r;f++){const d=s[u],_=s[u+1];s[u]=n*d+a*_+l,s[u+1]=o*d+h*_+c,u+=i;}}const Gc=new H;class Do{constructor(){this.packAsQuad=false,this.batcherName="default",this.topology="triangle-list",this.applyTransform=true,this.roundPixels=0,this._batcher=null,this._batch=null;}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,i=this.renderable;return i?Nn(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){return this.renderable?.groupTransform||Gc}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology;}reset(){this.applyTransform=true,this.renderable=null,this.topology="triangle-list";}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null;}}const Ze={extension:{type:B.ShapeBuilder,name:"circle"},build(s,t){let e,i,r,n,o,a;if(s.type==="circle"){const b=s;if(o=a=b.radius,o<=0)return  false;e=b.x,i=b.y,r=n=0;}else if(s.type==="ellipse"){const b=s;if(o=b.halfWidth,a=b.halfHeight,o<=0||a<=0)return  false;e=b.x,i=b.y,r=n=0;}else {const b=s,A=b.width/2,w=b.height/2;e=b.x+A,i=b.y+w,o=a=Math.max(0,Math.min(b.radius,Math.min(A,w))),r=A-o,n=w-a;}if(r<0||n<0)return  false;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(r?4:0)+(n?4:0);if(l===0)return  false;if(h===0)return t[0]=t[6]=e+r,t[1]=t[3]=i+n,t[2]=t[4]=e-r,t[5]=t[7]=i-n,true;let c=0,u=h*4+(r?2:0)+2,f=u,d=l,_=r+o,g=n,p=e+_,m=e-_,y=i+g;if(t[c++]=p,t[c++]=y,t[--u]=y,t[--u]=m,n){const b=i-g;t[f++]=m,t[f++]=b,t[--d]=b,t[--d]=p;}for(let b=1;b<h;b++){const A=Math.PI/2*(b/h),w=r+Math.cos(A)*o,k=n+Math.sin(A)*a,E=e+w,I=e-w,M=i+k,T=i-k;t[c++]=E,t[c++]=M,t[--u]=M,t[--u]=I,t[f++]=I,t[f++]=T,t[--d]=T,t[--d]=E;}_=r,g=n+a,p=e+_,m=e-_,y=i+g;const x=i-g;return t[c++]=p,t[c++]=y,t[--d]=x,t[--d]=p,r&&(t[c++]=m,t[c++]=y,t[--d]=x,t[--d]=m),true},triangulate(s,t,e,i,r,n){if(s.length===0)return;let o=0,a=0;for(let c=0;c<s.length;c+=2)o+=s[c],a+=s[c+1];o/=s.length/2,a/=s.length/2;let h=i;t[h*e]=o,t[h*e+1]=a;const l=h++;for(let c=0;c<s.length;c+=2)t[h*e]=s[c],t[h*e+1]=s[c+1],c>0&&(r[n++]=h,r[n++]=l,r[n++]=h-1),h++;r[n++]=l+1,r[n++]=l,r[n++]=h-1;}},Dc={...Ze,extension:{...Ze.extension,name:"ellipse"}},Uc={...Ze,extension:{...Ze.extension,name:"roundedRectangle"}},Uo=1e-4,Qr=1e-4;function Nc(s){const t=s.length;if(t<6)return 1;let e=0;for(let i=0,r=s[t-2],n=s[t-1];i<t;i+=2){const o=s[i],a=s[i+1];e+=(o-r)*(a+n),r=o,n=a;}return e<0?-1:1}function Jr(s,t,e,i,r,n,o,a){const h=s-e*r,l=t-i*r,c=s+e*n,u=t+i*n;let f,d;o?(f=i,d=-e):(f=-i,d=e);const _=h+f,g=l+d,p=c+f,m=u+d;return a.push(_,g),a.push(p,m),2}function ee(s,t,e,i,r,n,o,a){const h=e-s,l=i-t;let c=Math.atan2(h,l),u=Math.atan2(r-s,n-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let f=c;const d=u-c,_=Math.abs(d),g=Math.sqrt(h*h+l*l),p=(15*_*Math.sqrt(g)/Math.PI>>0)+1,m=d/p;if(f+=m,a){o.push(s,t),o.push(e,i);for(let y=1,x=f;y<p;y++,x+=m)o.push(s,t),o.push(s+Math.sin(x)*g,t+Math.cos(x)*g);o.push(s,t),o.push(r,n);}else {o.push(e,i),o.push(s,t);for(let y=1,x=f;y<p;y++,x+=m)o.push(s+Math.sin(x)*g,t+Math.cos(x)*g),o.push(s,t);o.push(r,n),o.push(s,t);}return p*2}function Wc(s,t,e,i,r,n){const o=Uo;if(s.length===0)return;const a=t;let h=a.alignment;if(t.alignment!==.5){let V=Nc(s);h=(h-.5)*V+.5;}const l=new N(s[0],s[1]),c=new N(s[s.length-2],s[s.length-1]),u=i,f=Math.abs(l.x-c.x)<o&&Math.abs(l.y-c.y)<o;if(u){s=s.slice(),f&&(s.pop(),s.pop(),c.set(s[s.length-2],s[s.length-1]));const V=(l.x+c.x)*.5,_t=(c.y+l.y)*.5;s.unshift(V,_t),s.push(V,_t);}const d=r,_=s.length/2;let g=s.length;const p=d.length/2,m=a.width/2,y=m*m,x=a.miterLimit*a.miterLimit;let b=s[0],A=s[1],w=s[2],k=s[3],E=0,I=0,M=-(A-k),T=b-w,Y=0,X=0,S=Math.sqrt(M*M+T*T);M/=S,T/=S,M*=m,T*=m;const R=h,P=(1-R)*2,L=R*2;u||(a.cap==="round"?g+=ee(b-M*(P-L)*.5,A-T*(P-L)*.5,b-M*P,A-T*P,b+M*L,A+T*L,d,true)+2:a.cap==="square"&&(g+=Jr(b,A,M,T,P,L,true,d))),d.push(b-M*P,A-T*P),d.push(b+M*L,A+T*L);for(let V=1;V<_-1;++V){b=s[(V-1)*2],A=s[(V-1)*2+1],w=s[V*2],k=s[V*2+1],E=s[(V+1)*2],I=s[(V+1)*2+1],M=-(A-k),T=b-w,S=Math.sqrt(M*M+T*T),M/=S,T/=S,M*=m,T*=m,Y=-(k-I),X=w-E,S=Math.sqrt(Y*Y+X*X),Y/=S,X/=S,Y*=m,X*=m;const _t=w-b,xt=A-k,zt=w-E,et=I-k,ht=_t*zt+xt*et,Et=xt*zt-et*_t,ct=Et<0;if(Math.abs(Et)<.001*Math.abs(ht)){d.push(w-M*P,k-T*P),d.push(w+M*L,k+T*L),ht>=0&&(a.join==="round"?g+=ee(w,k,w-M*P,k-T*P,w-Y*P,k-X*P,d,false)+4:g+=2,d.push(w-Y*L,k-X*L),d.push(w+Y*P,k+X*P));continue}const rt=(-M+b)*(-T+k)-(-M+w)*(-T+A),O=(-Y+E)*(-X+k)-(-Y+w)*(-X+I),Nt=(_t*O-zt*rt)/Et,qt=(et*rt-xt*O)/Et,ut=(Nt-w)*(Nt-w)+(qt-k)*(qt-k),gt=w+(Nt-w)*P,bt=k+(qt-k)*P,dt=w-(Nt-w)*L,Rt=k-(qt-k)*L,Wt=Math.min(_t*_t+xt*xt,zt*zt+et*et),Me=ct?P:L,zi=Wt+Me*Me*y;ut<=zi?a.join==="bevel"||ut/y>x?(ct?(d.push(gt,bt),d.push(w+M*L,k+T*L),d.push(gt,bt),d.push(w+Y*L,k+X*L)):(d.push(w-M*P,k-T*P),d.push(dt,Rt),d.push(w-Y*P,k-X*P),d.push(dt,Rt)),g+=2):a.join==="round"?ct?(d.push(gt,bt),d.push(w+M*L,k+T*L),g+=ee(w,k,w+M*L,k+T*L,w+Y*L,k+X*L,d,true)+4,d.push(gt,bt),d.push(w+Y*L,k+X*L)):(d.push(w-M*P,k-T*P),d.push(dt,Rt),g+=ee(w,k,w-M*P,k-T*P,w-Y*P,k-X*P,d,false)+4,d.push(w-Y*P,k-X*P),d.push(dt,Rt)):(d.push(gt,bt),d.push(dt,Rt)):(d.push(w-M*P,k-T*P),d.push(w+M*L,k+T*L),a.join==="round"?ct?g+=ee(w,k,w+M*L,k+T*L,w+Y*L,k+X*L,d,true)+2:g+=ee(w,k,w-M*P,k-T*P,w-Y*P,k-X*P,d,false)+2:a.join==="miter"&&ut/y<=x&&(ct?(d.push(dt,Rt),d.push(dt,Rt)):(d.push(gt,bt),d.push(gt,bt)),g+=2),d.push(w-Y*P,k-X*P),d.push(w+Y*L,k+X*L),g+=2);}b=s[(_-2)*2],A=s[(_-2)*2+1],w=s[(_-1)*2],k=s[(_-1)*2+1],M=-(A-k),T=b-w,S=Math.sqrt(M*M+T*T),M/=S,T/=S,M*=m,T*=m,d.push(w-M*P,k-T*P),d.push(w+M*L,k+T*L),u||(a.cap==="round"?g+=ee(w-M*(P-L)*.5,k-T*(P-L)*.5,w-M*P,k-T*P,w+M*L,k+T*L,d,false)+2:a.cap==="square"&&(g+=Jr(w,k,M,T,P,L,false,d)));const F=Qr*Qr;for(let V=p;V<g+p-2;++V)b=d[V*2],A=d[V*2+1],w=d[(V+1)*2],k=d[(V+1)*2+1],E=d[(V+2)*2],I=d[(V+2)*2+1],!(Math.abs(b*(k-I)+w*(I-A)+E*(A-k))<F)&&n.push(V,V+1,V+2);}function Hc(s,t,e,i){const r=Uo;if(s.length===0)return;const n=s[0],o=s[1],a=s[s.length-2],h=s[s.length-1],l=t||Math.abs(n-a)<r&&Math.abs(o-h)<r,c=e,u=s.length/2,f=c.length/2;for(let d=0;d<u;d++)c.push(s[d*2]),c.push(s[d*2+1]);for(let d=0;d<u-1;d++)i.push(f+d,f+d+1);l&&i.push(f+u-1,f);}function No(s,t,e,i,r,n,o){const a=Tl(s,t,2);if(!a)return;for(let l=0;l<a.length;l+=3)n[o++]=a[l]+r,n[o++]=a[l+1]+r,n[o++]=a[l+2]+r;let h=r*i;for(let l=0;l<s.length;l+=2)e[h]=s[l],e[h+1]=s[l+1],h+=i;}const Vc=[],Yc={extension:{type:B.ShapeBuilder,name:"polygon"},build(s,t){for(let e=0;e<s.points.length;e++)t[e]=s.points[e];return  true},triangulate(s,t,e,i,r,n){No(s,Vc,t,e,i,r,n);}},Xc={extension:{type:B.ShapeBuilder,name:"rectangle"},build(s,t){const e=s,i=e.x,r=e.y,n=e.width,o=e.height;return n>0&&o>0?(t[0]=i,t[1]=r,t[2]=i+n,t[3]=r,t[4]=i+n,t[5]=r+o,t[6]=i,t[7]=r+o,true):false},triangulate(s,t,e,i,r,n){let o=0;i*=e,t[i+o]=s[0],t[i+o+1]=s[1],o+=e,t[i+o]=s[2],t[i+o+1]=s[3],o+=e,t[i+o]=s[6],t[i+o+1]=s[7],o+=e,t[i+o]=s[4],t[i+o+1]=s[5],o+=e;const a=i/e;r[n++]=a,r[n++]=a+1,r[n++]=a+2,r[n++]=a+1,r[n++]=a+3,r[n++]=a+2;}},jc={extension:{type:B.ShapeBuilder,name:"triangle"},build(s,t){return t[0]=s.x,t[1]=s.y,t[2]=s.x2,t[3]=s.y2,t[4]=s.x3,t[5]=s.y3,true},triangulate(s,t,e,i,r,n){let o=0;i*=e,t[i+o]=s[0],t[i+o+1]=s[1],o+=e,t[i+o]=s[2],t[i+o+1]=s[3],o+=e,t[i+o]=s[4],t[i+o+1]=s[5];const a=i/e;r[n++]=a,r[n++]=a+1,r[n++]=a+2;}},qc=new H,Kc=new Z;function Zc(s,t,e,i){const r=t.matrix?s.copyFrom(t.matrix).invert():s.identity();if(t.textureSpace==="local"){const o=e.getBounds(Kc);t.width&&o.pad(t.width);const{x:a,y:h}=o,l=1/o.width,c=1/o.height,u=-a*l,f=-h*c,d=r.a,_=r.b,g=r.c,p=r.d;r.a*=l,r.b*=l,r.c*=c,r.d*=c,r.tx=u*d+f*g+r.tx,r.ty=u*_+f*p+r.ty;}else r.translate(t.texture.frame.x,t.texture.frame.y),r.scale(1/t.texture.source.width,1/t.texture.source.height);const n=t.texture.source.style;return !(t.fill instanceof Xt)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),i&&r.append(qc.copyFrom(i).invert()),r}const Pi={};ft.handleByMap(B.ShapeBuilder,Pi);ft.add(Xc,Yc,jc,Ze,Dc,Uc);const Qc=new Z,Jc=new H;function $c(s,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let r=0;r<s.instructions.length;r++){const n=s.instructions[r];if(n.action==="texture")tu(n.data,i,e);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,h=n.data.style,l=n.data.hole;o&&l&&$r(l.shapePath,h,true,i,e),l&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=l.shapePath.shapePrimitives),$r(a,h,o,i,e);}}}function tu(s,t,e){const i=[],r=Pi.rectangle,n=Qc;n.x=s.dx,n.y=s.dy,n.width=s.dw,n.height=s.dh;const o=s.transform;if(!r.build(n,i))return;const{vertices:a,uvs:h,indices:l}=e,c=l.length,u=a.length/2;o&&Go(i,o),r.triangulate(i,a,2,u,l,c);const f=s.image,d=f.uvs;h.push(d.x0,d.y0,d.x1,d.y1,d.x3,d.y3,d.x2,d.y2);const _=Pt.get(Do);_.indexOffset=c,_.indexSize=l.length-c,_.attributeOffset=u,_.attributeSize=a.length/2-u,_.baseColor=s.style,_.alpha=s.alpha,_.texture=f,_.geometryData=e,t.push(_);}function $r(s,t,e,i,r){const{vertices:n,uvs:o,indices:a}=r;s.shapePrimitives.forEach(({shape:h,transform:l,holes:c})=>{const u=[],f=Pi[h.type];if(!f.build(h,u))return;const d=a.length,_=n.length/2;let g="triangle-list";if(l&&Go(u,l),e){const x=h.closePath??true,b=t;b.pixelLine?(Hc(u,x,n,a),g="line-list"):Wc(u,b,false,x,n,a);}else if(c){const x=[],b=u.slice();eu(c).forEach(w=>{x.push(b.length/2),b.push(...w);}),No(b,x,n,2,_,a,d);}else f.triangulate(u,n,2,_,a,d);const p=o.length/2,m=t.texture;if(m!==W.WHITE){const x=Zc(Jc,t,h,l);Lc(n,2,_,o,p,2,n.length/2-_,x);}else Oc(o,p,2,n.length/2-_);const y=Pt.get(Do);y.indexOffset=d,y.indexSize=a.length-d,y.attributeOffset=_,y.attributeSize=n.length/2-_,y.baseColor=t.color,y.alpha=t.alpha,y.texture=m,y.geometryData=r,y.topology=g,i.push(y);});}function eu(s){const t=[];for(let e=0;e<s.length;e++){const i=s[e].shape,r=[];Pi[i.type].build(i,r)&&t.push(r);}return t}class iu{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]};}reset(){this.batches&&this.batches.forEach(t=>{Pt.return(t);}),this.graphicsData&&Pt.return(this.graphicsData),this.isBatchable=false,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null;}destroy(){this.reset(),this.batches=null,this.geometryData=null;}}class su{constructor(){this.instructions=new Yn;}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Fc({maxTextures:e}),this.instructions.reset();}get geometry(){return D(Qa,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null;}}const $s=class Bs{constructor(t){this._renderer=t,this._managedContexts=new Bc({renderer:t,type:"resource",name:"graphicsContext"});}init(t){Bs.defaultOptions.bezierSmoothness=t?.bezierSmoothness??Bs.defaultOptions.bezierSmoothness;}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=!!t._gpuData[this._renderer.uid],i=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!e){e&&i.reset(),$c(t,i);const r=t.batchMode;t.customShader||r==="no-batch"?i.isBatchable=false:r==="auto"?i.isBatchable=i.geometryData.vertices.length<400:i.isBatchable=true,t.dirty=false;}return i}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=Pt.get(su,{maxTextures:this._renderer.limits.maxBatchableTextures}),i=t._gpuData[this._renderer.uid],{batches:r,geometryData:n}=i;i.graphicsData=e;const o=n.vertices.length,a=n.indices.length;for(let u=0;u<r.length;u++)r[u].applyTransform=false;const h=e.batcher;h.ensureAttributeBuffer(o),h.ensureIndexBuffer(a),h.begin();for(let u=0;u<r.length;u++){const f=r[u];h.add(f);}h.finish(e.instructions);const l=h.geometry;l.indexBuffer.setDataWithSize(h.indexBuffer,h.indexSize,true),l.buffers[0].setDataWithSize(h.attributeBuffer.float32View,h.attributeSize,true);const c=h.batches;for(let u=0;u<c.length;u++){const f=c[u];f.bindGroup=Yl(f.textures.textures,f.textures.count,this._renderer.limits.maxBatchableTextures);}return e}_initContext(t){const e=new iu;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null;}};$s.extension={type:[B.WebGLSystem,B.WebGPUSystem,B.CanvasSystem],name:"graphicsContext"};$s.defaultOptions={bezierSmoothness:.5};let Wo=$s;const ru=8,di=11920929e-14,nu=1;function Ho(s,t,e,i,r,n,o,a,h,l){const u=Math.min(.99,Math.max(0,l??Wo.defaultOptions.bezierSmoothness));let f=(nu-u)/1;return f*=f,ou(t,e,i,r,n,o,a,h,s,f),s}function ou(s,t,e,i,r,n,o,a,h,l){Ls(s,t,e,i,r,n,o,a,h,l,0),h.push(o,a);}function Ls(s,t,e,i,r,n,o,a,h,l,c){if(c>ru)return;const u=(s+e)/2,f=(t+i)/2,d=(e+r)/2,_=(i+n)/2,g=(r+o)/2,p=(n+a)/2,m=(u+d)/2,y=(f+_)/2,x=(d+g)/2,b=(_+p)/2,A=(m+x)/2,w=(y+b)/2;if(c>0){let k=o-s,E=a-t;const I=Math.abs((e-o)*E-(i-a)*k),M=Math.abs((r-o)*E-(n-a)*k);if(I>di&&M>di){if((I+M)*(I+M)<=l*(k*k+E*E)){h.push(A,w);return}}else if(I>di){if(I*I<=l*(k*k+E*E)){h.push(A,w);return}}else if(M>di){if(M*M<=l*(k*k+E*E)){h.push(A,w);return}}else if(k=A-(s+o)/2,E=w-(t+a)/2,k*k+E*E<=l){h.push(A,w);return}}Ls(s,t,u,f,m,y,A,w,h,l,c+1),Ls(A,w,x,b,g,p,o,a,h,l,c+1);}const au=8,hu=11920929e-14,lu=1;function cu(s,t,e,i,r,n,o,a){const l=Math.min(.99,Math.max(0,a??Wo.defaultOptions.bezierSmoothness));let c=(lu-l)/1;return c*=c,uu(t,e,i,r,n,o,s,c),s}function uu(s,t,e,i,r,n,o,a){Os(o,s,t,e,i,r,n,a,0),o.push(r,n);}function Os(s,t,e,i,r,n,o,a,h){if(h>au)return;const l=(t+i)/2,c=(e+r)/2,u=(i+n)/2,f=(r+o)/2,d=(l+u)/2,_=(c+f)/2;let g=n-t,p=o-e;const m=Math.abs((i-n)*p-(r-o)*g);if(m>hu){if(m*m<=a*(g*g+p*p)){s.push(d,_);return}}else if(g=d-(t+n)/2,p=_-(e+o)/2,g*g+p*p<=a){s.push(d,_);return}Os(s,t,e,l,c,d,_,a,h+1),Os(s,d,_,u,f,n,o,a,h+1);}function Vo(s,t,e,i,r,n,o,a){let h=Math.abs(r-n);(!o&&r>n||o&&n>r)&&(h=2*Math.PI-h),a||(a=Math.max(6,Math.floor(6*Math.pow(i,1/3)*(h/Math.PI)))),a=Math.max(a,3);let l=h/a,c=r;l*=o?-1:1;for(let u=0;u<a+1;u++){const f=Math.cos(c),d=Math.sin(c),_=t+f*i,g=e+d*i;s.push(_,g),c+=l;}}function du(s,t,e,i,r,n){const o=s[s.length-2],h=s[s.length-1]-e,l=o-t,c=r-e,u=i-t,f=Math.abs(h*u-l*c);if(f<1e-8||n===0){(s[s.length-2]!==t||s[s.length-1]!==e)&&s.push(t,e);return}const d=h*h+l*l,_=c*c+u*u,g=h*c+l*u,p=n*Math.sqrt(d)/f,m=n*Math.sqrt(_)/f,y=p*g/d,x=m*g/_,b=p*u+m*l,A=p*c+m*h,w=l*(m+y),k=h*(m+y),E=u*(p+x),I=c*(p+x),M=Math.atan2(k-A,w-b),T=Math.atan2(I-A,E-b);Vo(s,b+t,A+e,n,M,T,l*c>u*h);}const Ye=Math.PI*2,ls={centerX:0,centerY:0,ang1:0,ang2:0},cs=({x:s,y:t},e,i,r,n,o,a,h)=>{s*=e,t*=i;const l=r*s-n*t,c=n*s+r*t;return h.x=l+o,h.y=c+a,h};function fu(s,t){const e=t===-1.5707963267948966?-0.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,r=Math.cos(s),n=Math.sin(s),o=Math.cos(s+t),a=Math.sin(s+t);return [{x:r-n*i,y:n+r*i},{x:o+a*i,y:a-o*i},{x:o,y:a}]}const tn=(s,t,e,i)=>{const r=s*i-t*e<0?-1:1;let n=s*e+t*i;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},_u=(s,t,e,i,r,n,o,a,h,l,c,u,f)=>{const d=Math.pow(r,2),_=Math.pow(n,2),g=Math.pow(c,2),p=Math.pow(u,2);let m=d*_-d*p-_*g;m<0&&(m=0),m/=d*p+_*g,m=Math.sqrt(m)*(o===a?-1:1);const y=m*r/n*u,x=m*-n/r*c,b=l*y-h*x+(s+e)/2,A=h*y+l*x+(t+i)/2,w=(c-y)/r,k=(u-x)/n,E=(-c-y)/r,I=(-u-x)/n,M=tn(1,0,w,k);let T=tn(w,k,E,I);a===0&&T>0&&(T-=Ye),a===1&&T<0&&(T+=Ye),f.centerX=b,f.centerY=A,f.ang1=M,f.ang2=T;};function pu(s,t,e,i,r,n,o,a=0,h=0,l=0){if(n===0||o===0)return;const c=Math.sin(a*Ye/360),u=Math.cos(a*Ye/360),f=u*(t-i)/2+c*(e-r)/2,d=-c*(t-i)/2+u*(e-r)/2;if(f===0&&d===0)return;n=Math.abs(n),o=Math.abs(o);const _=Math.pow(f,2)/Math.pow(n,2)+Math.pow(d,2)/Math.pow(o,2);_>1&&(n*=Math.sqrt(_),o*=Math.sqrt(_)),_u(t,e,i,r,n,o,h,l,c,u,f,d,ls);let{ang1:g,ang2:p}=ls;const{centerX:m,centerY:y}=ls;let x=Math.abs(p)/(Ye/4);Math.abs(1-x)<1e-7&&(x=1);const b=Math.max(Math.ceil(x),1);p/=b;let A=s[s.length-2],w=s[s.length-1];const k={x:0,y:0};for(let E=0;E<b;E++){const I=fu(g,p),{x:M,y:T}=cs(I[0],n,o,u,c,m,y,k),{x:Y,y:X}=cs(I[1],n,o,u,c,m,y,k),{x:S,y:R}=cs(I[2],n,o,u,c,m,y,k);Ho(s,A,w,M,T,Y,X,S,R),A=S,w=R,g+=p;}}function gu(s,t,e){const i=(o,a)=>{const h=a.x-o.x,l=a.y-o.y,c=Math.sqrt(h*h+l*l),u=h/c,f=l/c;return {len:c,nx:u,ny:f}},r=(o,a)=>{o===0?s.moveTo(a.x,a.y):s.lineTo(a.x,a.y);};let n=t[t.length-1];for(let o=0;o<t.length;o++){const a=t[o%t.length],h=a.radius??e;if(h<=0){r(o,a),n=a;continue}const l=t[(o+1)%t.length],c=i(a,n),u=i(a,l);if(c.len<1e-4||u.len<1e-4){r(o,a),n=a;continue}let f=Math.asin(c.nx*u.ny-c.ny*u.nx),d=1,_=false;c.nx*u.nx-c.ny*-u.ny<0?f<0?f=Math.PI+f:(f=Math.PI-f,d=-1,_=true):f>0&&(d=-1,_=true);const g=f/2;let p,m=Math.abs(Math.cos(g)*h/Math.sin(g));m>Math.min(c.len/2,u.len/2)?(m=Math.min(c.len/2,u.len/2),p=Math.abs(m*Math.sin(g)/Math.cos(g))):p=h;const y=a.x+u.nx*m+-u.ny*p*d,x=a.y+u.ny*m+u.nx*p*d,b=Math.atan2(c.ny,c.nx)+Math.PI/2*d,A=Math.atan2(u.ny,u.nx)-Math.PI/2*d;o===0&&s.moveTo(y+Math.cos(b)*p,x+Math.sin(b)*p),s.arc(y,x,p,b,A,_),n=a;}}function mu(s,t,e,i){const r=(a,h)=>Math.sqrt((a.x-h.x)**2+(a.y-h.y)**2),n=(a,h,l)=>({x:a.x+(h.x-a.x)*l,y:a.y+(h.y-a.y)*l}),o=t.length;for(let a=0;a<o;a++){const h=t[(a+1)%o],l=h.radius??e;if(l<=0){a===0?s.moveTo(h.x,h.y):s.lineTo(h.x,h.y);continue}const c=t[a],u=t[(a+2)%o],f=r(c,h);let d;if(f<1e-4)d=h;else {const p=Math.min(f/2,l);d=n(h,c,p/f);}const _=r(u,h);let g;if(_<1e-4)g=h;else {const p=Math.min(_/2,l);g=n(h,u,p/_);}a===0?s.moveTo(d.x,d.y):s.lineTo(d.x,d.y),s.quadraticCurveTo(h.x,h.y,g.x,g.y,i);}}const yu=new Z;class xu{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Lt,this._graphicsPath2D=t,this.signed=t.checkForHoles;}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const i=this._currentPoly.points,r=i[i.length-2],n=i[i.length-1];return (r!==t||n!==e)&&i.push(t,e),this}arc(t,e,i,r,n,o){this._ensurePoly(false);const a=this._currentPoly.points;return Vo(a,t,e,i,r,n,o),this}arcTo(t,e,i,r,n){this._ensurePoly();const o=this._currentPoly.points;return du(o,t,e,i,r,n),this}arcToSvg(t,e,i,r,n,o,a){const h=this._currentPoly.points;return pu(h,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,i,r,n),this}bezierCurveTo(t,e,i,r,n,o,a){this._ensurePoly();const h=this._currentPoly;return Ho(this._currentPoly.points,h.lastX,h.lastY,t,e,i,r,n,o,a),this}quadraticCurveTo(t,e,i,r,n){this._ensurePoly();const o=this._currentPoly;return cu(this._currentPoly.points,o.lastX,o.lastY,t,e,i,r,n),this}closePath(){return this.endPoly(true),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(true),t.transform(e));const i=this.shapePrimitives,r=i.length;for(let n=0;n<t.instructions.length;n++){const o=t.instructions[n];this[o.action](...o.data);}if(t.checkForHoles&&i.length-r>1){let n=null;for(let o=r;o<i.length;o++){const a=i[o];if(a.shape.type==="polygon"){const h=a.shape,l=n?.shape;l&&l.containsPolygon(h)?(n.holes||(n.holes=[]),n.holes.push(a),i.copyWithin(o,o+1),i.length--,o--):n=a;}}}return this}finish(t=false){this.endPoly(t);}rect(t,e,i,r,n){return this.drawShape(new Z(t,e,i,r),n),this}circle(t,e,i,r){return this.drawShape(new Zs(t,e,i),r),this}poly(t,e,i){const r=new He(t);return r.closePath=e,this.drawShape(r,i),this}regularPoly(t,e,i,r,n=0,o){r=Math.max(r|0,3);const a=-1*Math.PI/2+n,h=Math.PI*2/r,l=[];for(let c=0;c<r;c++){const u=a-c*h;l.push(t+i*Math.cos(u),e+i*Math.sin(u));}return this.poly(l,true,o),this}roundPoly(t,e,i,r,n,o=0,a){if(r=Math.max(r|0,3),n<=0)return this.regularPoly(t,e,i,r,o);const h=i*Math.sin(Math.PI/r)-.001;n=Math.min(n,h);const l=-1*Math.PI/2+o,c=Math.PI*2/r,u=(r-2)*Math.PI/r/2;for(let f=0;f<r;f++){const d=f*c+l,_=t+i*Math.cos(d),g=e+i*Math.sin(d),p=d+Math.PI+u,m=d-Math.PI-u,y=_+n*Math.cos(p),x=g+n*Math.sin(p),b=_+n*Math.cos(m),A=g+n*Math.sin(m);f===0?this.moveTo(y,x):this.lineTo(y,x),this.quadraticCurveTo(_,g,b,A,a);}return this.closePath()}roundShape(t,e,i=false,r){return t.length<3?this:(i?mu(this,t,e,r):gu(this,t,e),this.closePath())}filletRect(t,e,i,r,n){if(n===0)return this.rect(t,e,i,r);const o=Math.min(i,r)/2,a=Math.min(o,Math.max(-o,n)),h=t+i,l=e+r,c=a<0?-a:0,u=Math.abs(a);return this.moveTo(t,e+u).arcTo(t+c,e+c,t+u,e,u).lineTo(h-u,e).arcTo(h-c,e+c,h,e+u,u).lineTo(h,l-u).arcTo(h-c,l-c,t+i-u,l,u).lineTo(t+u,l).arcTo(t+c,l-c,t,l-u,u).closePath()}chamferRect(t,e,i,r,n,o){if(n<=0)return this.rect(t,e,i,r);const a=Math.min(n,Math.min(i,r)/2),h=t+i,l=e+r,c=[t+a,e,h-a,e,h,e+a,h,l-a,h-a,l,t+a,l,t,l-a,t,e+a];for(let u=c.length-1;u>=2;u-=2)c[u]===c[u-2]&&c[u-1]===c[u-3]&&c.splice(u-1,2);return this.poly(c,true,o)}ellipse(t,e,i,r,n){return this.drawShape(new Qs(t,e,i,r),n),this}roundRect(t,e,i,r,n,o){return this.drawShape(new Js(t,e,i,r,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new He,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=false){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=true){if(!this._currentPoly&&(this._currentPoly=new He,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,r=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,o=i;i=n.a*i+n.c*r+n.tx,r=n.b*o+n.d*r+n.ty;}this._currentPoly.points.push(i,r);}else this._currentPoly.points.push(0,0);}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.data);}this.finish();}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let i=0;i<e.length;i++){const r=e[i],n=r.shape.getBounds(yu);r.transform?t.addRect(n,r.transform):t.addRect(n);}return t}}class Yt{constructor(t,e=false){this.instructions=[],this.uid=st("graphicsPath"),this._dirty=true,this.checkForHoles=e,typeof t=="string"?Nl(t,this):this.instructions=t?.slice()??[];}get shapePath(){return this._shapePath||(this._shapePath=new xu(this)),this._dirty&&(this._dirty=false,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=true,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=true,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=true,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=true,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=true,this}bezierCurveToShort(t,e,i,r,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(N.shared);let h=0,l=0;if(!o||o.action!=="bezierCurveTo")h=a.x,l=a.y;else {h=o.data[2],l=o.data[3];const c=a.x,u=a.y;h=c+(c-h),l=u+(u-l);}return this.instructions.push({action:"bezierCurveTo",data:[h,l,t,e,i,r,n]}),this._dirty=true,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=true,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=true,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=true,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=true,this}quadraticCurveToShort(t,e,i){const r=this.instructions[this.instructions.length-1],n=this.getLastPoint(N.shared);let o=0,a=0;if(!r||r.action!=="quadraticCurveTo")o=n.x,a=n.y;else {o=r.data[0],a=r.data[1];const h=n.x,l=n.y;o=h+(h-o),a=l+(l-a);}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,t,e,i]}),this._dirty=true,this}rect(t,e,i,r,n){return this.instructions.push({action:"rect",data:[t,e,i,r,n]}),this._dirty=true,this}circle(t,e,i,r){return this.instructions.push({action:"circle",data:[t,e,i,r]}),this._dirty=true,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=true,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=true,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=true,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=true,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=true,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=true,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=true,this}star(t,e,i,r,n,o,a){n||(n=r/2);const h=-1*Math.PI/2+o,l=i*2,c=Math.PI*2/l,u=[];for(let f=0;f<l;f++){const d=f%2?n:r,_=f*c+h;u.push(t+d*Math.cos(_),e+d*Math.sin(_));}return this.poly(u,true,a),this}clone(t=false){const e=new Yt;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const r=this.instructions[i];e.instructions.push({action:r.action,data:r.data.slice()});}return e}clear(){return this.instructions.length=0,this._dirty=true,this}transform(t){if(t.isIdentity())return this;const e=t.a,i=t.b,r=t.c,n=t.d,o=t.tx,a=t.ty;let h=0,l=0,c=0,u=0,f=0,d=0,_=0,g=0;for(let p=0;p<this.instructions.length;p++){const m=this.instructions[p],y=m.data;switch(m.action){case "moveTo":case "lineTo":h=y[0],l=y[1],y[0]=e*h+r*l+o,y[1]=i*h+n*l+a;break;case "bezierCurveTo":c=y[0],u=y[1],f=y[2],d=y[3],h=y[4],l=y[5],y[0]=e*c+r*u+o,y[1]=i*c+n*u+a,y[2]=e*f+r*d+o,y[3]=i*f+n*d+a,y[4]=e*h+r*l+o,y[5]=i*h+n*l+a;break;case "quadraticCurveTo":c=y[0],u=y[1],h=y[2],l=y[3],y[0]=e*c+r*u+o,y[1]=i*c+n*u+a,y[2]=e*h+r*l+o,y[3]=i*h+n*l+a;break;case "arcToSvg":h=y[5],l=y[6],_=y[0],g=y[1],y[0]=e*_+r*g,y[1]=i*_+n*g,y[5]=e*h+r*l+o,y[6]=i*h+n*l+a;break;case "circle":y[4]=Le(y[3],t);break;case "rect":y[4]=Le(y[4],t);break;case "ellipse":y[8]=Le(y[8],t);break;case "roundRect":y[5]=Le(y[5],t);break;case "addPath":y[0].transform(t);break;case "poly":y[2]=Le(y[2],t);break;default:J("unknown transform action",m.action);break}}return this._dirty=true,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,i=this.instructions[e];if(!i)return t.x=0,t.y=0,t;for(;i.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;i=this.instructions[e];}switch(i.action){case "moveTo":case "lineTo":t.x=i.data[0],t.y=i.data[1];break;case "quadraticCurveTo":t.x=i.data[2],t.y=i.data[3];break;case "bezierCurveTo":t.x=i.data[4],t.y=i.data[5];break;case "arc":case "arcToSvg":t.x=i.data[5],t.y=i.data[6];break;case "addPath":i.data[0].getLastPoint(t);break}return t}}function Le(s,t){return s?s.prepend(t):t.clone()}function it(s,t,e){const i=s.getAttribute(t);return i?Number(i):e}function bu(s,t){const e=s.querySelectorAll("defs");for(let i=0;i<e.length;i++){const r=e[i];for(let n=0;n<r.children.length;n++){const o=r.children[n];switch(o.nodeName.toLowerCase()){case "lineargradient":t.defs[o.id]=wu(o);break;case "radialgradient":t.defs[o.id]=vu();break}}}}function wu(s){const t=it(s,"x1",0),e=it(s,"y1",0),i=it(s,"x2",1),r=it(s,"y2",0),n=s.getAttribute("gradientUnits")||"objectBoundingBox",o=new Xt(t,e,i,r,n==="objectBoundingBox"?"local":"global");for(let a=0;a<s.children.length;a++){const h=s.children[a],l=it(h,"offset",0),c=ot.shared.setValue(h.getAttribute("stop-color")).toNumber();o.addColorStop(l,c);}return o}function vu(s){return J("[SVG Parser] Radial gradients are not yet supported"),new Xt(0,0,1,0)}function en(s){const t=s.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const sn={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}};function Yo(s,t){const e=s.getAttribute("style"),i={},r={},n={strokeStyle:i,fillStyle:r,useFill:false,useStroke:false};for(const o in sn){const a=s.getAttribute(o);a&&rn(t,n,o,a.trim());}if(e){const o=e.split(";");for(let a=0;a<o.length;a++){const h=o[a].trim(),[l,c]=h.split(":");sn[l]&&rn(t,n,l,c.trim());}}return {strokeStyle:n.useStroke?i:null,fillStyle:n.useFill?r:null,useFill:n.useFill,useStroke:n.useStroke}}function rn(s,t,e,i){switch(e){case "stroke":if(i!=="none"){if(i.startsWith("url(")){const r=en(i);t.strokeStyle.fill=s.defs[r];}else t.strokeStyle.color=ot.shared.setValue(i).toNumber();t.useStroke=true;}break;case "stroke-width":t.strokeStyle.width=Number(i);break;case "fill":if(i!=="none"){if(i.startsWith("url(")){const r=en(i);t.fillStyle.fill=s.defs[r];}else t.fillStyle.color=ot.shared.setValue(i).toNumber();t.useFill=true;}break;case "fill-opacity":t.fillStyle.alpha=Number(i);break;case "stroke-opacity":t.strokeStyle.alpha=Number(i);break;case "opacity":t.fillStyle.alpha=Number(i),t.strokeStyle.alpha=Number(i);break}}function ku(s){if(s.length<=2)return  true;const t=s.map(a=>a.area).sort((a,h)=>h-a),[e,i]=t,r=t[t.length-1],n=e/i,o=i/r;return !(n>3&&o<2)}function Au(s){return s.split(/(?=[Mm])/).filter(i=>i.trim().length>0)}function Su(s){const t=s.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),i=[],r=[];for(let c=0;c<e.length;c+=2)c+1<e.length&&(i.push(e[c]),r.push(e[c+1]));if(i.length===0||r.length===0)return 0;const n=Math.min(...i),o=Math.max(...i),a=Math.min(...r),h=Math.max(...r);return (o-n)*(h-a)}function nn(s,t){const e=new Yt(s,false);for(const i of e.instructions)t.instructions.push(i);}function Cu(s,t){if(typeof s=="string"){const o=document.createElement("div");o.innerHTML=s.trim(),s=o.querySelector("svg");}const e={context:t,defs:{},path:new Yt};bu(s,e);const i=s.children,{fillStyle:r,strokeStyle:n}=Yo(s,e);for(let o=0;o<i.length;o++){const a=i[o];a.nodeName.toLowerCase()!=="defs"&&Xo(a,e,r,n);}return t}function Xo(s,t,e,i){const r=s.children,{fillStyle:n,strokeStyle:o}=Yo(s,t);n&&e?e={...e,...n}:n&&(e=n),o&&i?i={...i,...o}:o&&(i=o);const a=!e&&!i;a&&(e={color:0});let h,l,c,u,f,d,_,g,p,m,y,x,b,A,w,k,E;switch(s.nodeName.toLowerCase()){case "path":{A=s.getAttribute("d");const I=s.getAttribute("fill-rule"),M=Au(A),T=I==="evenodd",Y=M.length>1;if(T&&Y){const S=M.map(P=>({path:P,area:Su(P)}));if(S.sort((P,L)=>L.area-P.area),M.length>3||!ku(S))for(let P=0;P<S.length;P++){const L=S[P],F=P===0;t.context.beginPath();const V=new Yt(void 0,true);nn(L.path,V),t.context.path(V),F?(e&&t.context.fill(e),i&&t.context.stroke(i)):t.context.cut();}else for(let P=0;P<S.length;P++){const L=S[P],F=P%2===1;t.context.beginPath();const V=new Yt(void 0,true);nn(L.path,V),t.context.path(V),F?t.context.cut():(e&&t.context.fill(e),i&&t.context.stroke(i));}}else {const S=I?I==="evenodd":true;w=new Yt(A,S),t.context.path(w),e&&t.context.fill(e),i&&t.context.stroke(i);}break}case "circle":_=it(s,"cx",0),g=it(s,"cy",0),p=it(s,"r",0),t.context.ellipse(_,g,p,p),e&&t.context.fill(e),i&&t.context.stroke(i);break;case "rect":h=it(s,"x",0),l=it(s,"y",0),k=it(s,"width",0),E=it(s,"height",0),m=it(s,"rx",0),y=it(s,"ry",0),m||y?t.context.roundRect(h,l,k,E,m||y):t.context.rect(h,l,k,E),e&&t.context.fill(e),i&&t.context.stroke(i);break;case "ellipse":_=it(s,"cx",0),g=it(s,"cy",0),m=it(s,"rx",0),y=it(s,"ry",0),t.context.beginPath(),t.context.ellipse(_,g,m,y),e&&t.context.fill(e),i&&t.context.stroke(i);break;case "line":c=it(s,"x1",0),u=it(s,"y1",0),f=it(s,"x2",0),d=it(s,"y2",0),t.context.beginPath(),t.context.moveTo(c,u),t.context.lineTo(f,d),i&&t.context.stroke(i);break;case "polygon":b=s.getAttribute("points"),x=b.match(/-?\d+/g).map(I=>parseInt(I,10)),t.context.poly(x,true),e&&t.context.fill(e),i&&t.context.stroke(i);break;case "polyline":b=s.getAttribute("points"),x=b.match(/-?\d+/g).map(I=>parseInt(I,10)),t.context.poly(x,false),i&&t.context.stroke(i);break;case "g":case "svg":break;default:{J(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}a&&(e=null);for(let I=0;I<r.length;I++)Xo(r[I],t,e,i);}function Mu(s){return ot.isColorLike(s)}function on(s){return s instanceof Ti}function an(s){return s instanceof Xt}function Tu(s){return s instanceof W}function Pu(s,t,e){const i=ot.shared.setValue(t??0);return s.color=i.toNumber(),s.alpha=i.alpha===1?e.alpha:i.alpha,s.texture=W.WHITE,{...e,...s}}function Iu(s,t,e){return s.texture=t,{...e,...s}}function hn(s,t,e){return s.fill=t,s.color=16777215,s.texture=t.texture,s.matrix=t.transform,{...e,...s}}function ln(s,t,e){return t.buildGradient(),s.fill=t,s.color=16777215,s.texture=t.texture,s.matrix=t.transform,s.textureSpace=t.textureSpace,{...e,...s}}function zu(s,t){const e={...t,...s},i=ot.shared.setValue(e.color);return e.alpha*=i.alpha,e.color=i.toNumber(),e}function ae(s,t){if(s==null)return null;const e={},i=s;return Mu(s)?Pu(e,s,t):Tu(s)?Iu(e,s,t):on(s)?hn(e,s,t):an(s)?ln(e,s,t):i.fill&&on(i.fill)?hn(i,i.fill,t):i.fill&&an(i.fill)?ln(i,i.fill,t):zu(i,t)}function Ai(s,t){const{width:e,alignment:i,miterLimit:r,cap:n,join:o,pixelLine:a,...h}=t,l=ae(s,h);return l?{width:e,alignment:i,miterLimit:r,cap:n,join:o,pixelLine:a,...l}:null}const Eu=new N,cn=new H,tr=class Ut extends Ot{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=true,this._gcLastUsed=-1,this.uid=st("graphicsContext"),this.dirty=true,this.batchMode="auto",this.instructions=[],this.destroyed=false,this._activePath=new Yt,this._transform=new H,this._fillStyle={...Ut.defaultFillStyle},this._strokeStyle={...Ut.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Lt,this._boundsDirty=true;}clone(){const t=new Ut;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...this._strokeStyle},t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=true,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=ae(t,Ut.defaultFillStyle);}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Ai(t,Ut.defaultStrokeStyle);}setFillStyle(t){return this._fillStyle=ae(t,Ut.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=ae(t,Ut.defaultStrokeStyle),this}texture(t,e,i,r,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:r||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?ot.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Yt,this}fill(t,e){let i;const r=this.instructions[this.instructions.length-1];return this._tick===0&&r?.action==="stroke"?i=r.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(D(j,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=ae(t,Ut.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(N.shared);this._activePath.clear(),this._activePath.moveTo(t,e);}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&i?.action==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Ai(t,Ut.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(i);else {e.data.hole=i;break}}return this._initNextPathLocation(),this}arc(t,e,i,r,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,i,r,n,o),this}arcTo(t,e,i,r,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*r+o.tx,o.b*i+o.d*r+o.ty,n),this}arcToSvg(t,e,i,r,n,o,a){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,i,r,n,h.a*o+h.c*a+h.tx,h.b*o+h.d*a+h.ty),this}bezierCurveTo(t,e,i,r,n,o,a){this._tick++;const h=this._transform;return this._activePath.bezierCurveTo(h.a*t+h.c*e+h.tx,h.b*t+h.d*e+h.ty,h.a*i+h.c*r+h.tx,h.b*i+h.d*r+h.ty,h.a*n+h.c*o+h.tx,h.b*n+h.d*o+h.ty,a),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(t,e,i,r){return this._tick++,this._activePath.ellipse(t,e,i,r,this._transform.clone()),this}circle(t,e,i){return this._tick++,this._activePath.circle(t,e,i,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;const i=this._transform,r=this._activePath.instructions,n=i.a*t+i.c*e+i.tx,o=i.b*t+i.d*e+i.ty;return r.length===1&&r[0].action==="moveTo"?(r[0].data[0]=n,r[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,i,r,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*r+o.tx,o.b*i+o.d*r+o.ty,n),this}rect(t,e,i,r){return this._tick++,this._activePath.rect(t,e,i,r,this._transform.clone()),this}roundRect(t,e,i,r,n){return this._tick++,this._activePath.roundRect(t,e,i,r,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,r,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,i,r,n,o),this}roundPoly(t,e,i,r,n,o){return this._tick++,this._activePath.roundPoly(t,e,i,r,n,o),this}roundShape(t,e,i,r){return this._tick++,this._activePath.roundShape(t,e,i,r),this}filletRect(t,e,i,r,n){return this._tick++,this._activePath.filletRect(t,e,i,r,n),this}chamferRect(t,e,i,r,n,o){return this._tick++,this._activePath.chamferRect(t,e,i,r,n,o),this}star(t,e,i,r,n=0,o=0){return this._tick++,this._activePath.star(t,e,i,r,n,o,this._transform.clone()),this}svg(t){return this._tick++,Cu(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,r,n,o){return t instanceof H?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,r,n,o),this)}transform(t,e,i,r,n,o){return t instanceof H?(this._transform.append(t),this):(cn.set(t,e,i,r,n,o),this._transform.append(cn),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=true,!this.dirty&&(this.emit("update",this,16),this.dirty=true);}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=false;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const i=this.instructions[e],r=i.action;if(r==="fill"){const n=i.data;t.addBounds(n.path.bounds);}else if(r==="texture"){const n=i.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform);}if(r==="stroke"){const n=i.data,o=n.style.alignment,a=n.style.width*(1-o),h=n.path.bounds;t.addFrame(h.minX-a,h.minY-a,h.maxX+a,h.maxY+a);}}return t}containsPoint(t){if(!this.bounds.containsPoint(t.x,t.y))return  false;const e=this.instructions;let i=false;for(let r=0;r<e.length;r++){const n=e[r],o=n.data,a=o.path;if(!n.action||!a)continue;const h=o.style,l=a.shapePath.shapePrimitives;for(let c=0;c<l.length;c++){const u=l[c].shape;if(!h||!u)continue;const f=l[c].transform,d=f?f.applyInverse(t,Eu):t;if(n.action==="fill")i=u.contains(d.x,d.y);else {const g=h;i=u.strokeContains(d.x,d.y,g.width,g.alignment);}const _=o.hole;if(_){const g=_.shapePath?.shapePrimitives;if(g)for(let p=0;p<g.length;p++)g[p].shape.contains(d.x,d.y)&&(i=false);}if(i)return  true}}return i}unload(){this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null);}destroy(t=false){if(this.destroyed)return;if(this.destroyed=true,this._stateStack.length=0,this._transform=null,this.unload(),this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t?.texture){const i=typeof t=="boolean"?t:t?.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(i)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(i));}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null;}};tr.defaultFillStyle={color:16777215,alpha:1,texture:W.WHITE,matrix:null,fill:null,textureSpace:"local"};tr.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:W.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:false};let Mt=tr;const er=class _e extends Ot{constructor(t={}){super(),this.uid=st("textStyle"),this._tick=0,Ru(t);const e={..._e.defaultTextStyle,...t};for(const i in e){const r=i;this[r]=e[i];}this.update(),this._tick=0;}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.update());}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.update());}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(t!==null&&typeof t=="object"?this._dropShadow=this._createProxy({..._e.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({..._e.defaultDropShadow}):null,this.update());}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.update());}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update());}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t.toLowerCase(),this.update());}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.update());}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.update());}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.update());}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.update());}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.update());}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.update());}get filters(){return this._filters}set filters(t){this._filters!==t&&(this._filters=Object.freeze(t),this.update());}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.update());}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.update());}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.update());}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.update());}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.update());}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy({...Mt.defaultFillStyle,...t},()=>{this._fill=ae({...this._originalFill},Mt.defaultFillStyle);})),this._fill=ae(t===0?"black":t,Mt.defaultFillStyle),this.update());}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...Mt.defaultStrokeStyle,...t},()=>{this._stroke=Ai({...this._originalStroke},Mt.defaultStrokeStyle);})),this._stroke=Ai(t,Mt.defaultStrokeStyle),this.update());}update(){this._tick++,this.emit("update",this);}reset(){const t=_e.defaultTextStyle;for(const e in t)this[e]=t[e];}get styleKey(){return `${this.uid}-${this._tick}`}clone(){return new _e({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0})}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=false){if(this.removeAllListeners(),typeof t=="boolean"?t:t?.texture){const i=typeof t=="boolean"?t:t?.textureSource;this._fill?.texture&&this._fill.texture.destroy(i),this._originalFill?.texture&&this._originalFill.texture.destroy(i),this._stroke?.texture&&this._stroke.texture.destroy(i),this._originalStroke?.texture&&this._originalStroke.texture.destroy(i);}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null;}_createProxy(t,e){return new Proxy(t,{set:(i,r,n)=>(i[r]===n||(i[r]=n,e?.(r,n),this.update()),true)})}_isFillStyle(t){return (t??null)!==null&&!(ot.isColorLike(t)||t instanceof Xt||t instanceof Ti)}};er.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};er.defaultTextStyle={align:"left",breakWords:false,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:false,whiteSpace:"pre",wordWrap:false,wordWrapWidth:100};let Si=er;function Ru(s){const t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=Si.defaultDropShadow;s.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance};}if(t.strokeThickness!==void 0){D(j,"strokeThickness is now a part of stroke");const e=t.stroke;let i={};if(ot.isColorLike(e))i.color=e;else if(e instanceof Xt||e instanceof Ti)i.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))i=e;else throw new Error("Invalid stroke value.");s.stroke={...i,width:t.strokeThickness};}if(Array.isArray(t.fillGradientStops)){if(D(j,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(t.fill)||t.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");t.fill.length!==t.fillGradientStops.length&&J("The number of fill colors must match the number of fill gradient stops.");const e=new Xt({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),i=t.fillGradientStops.slice(),r=t.fill.map(n=>ot.shared.setValue(n).toNumber());i.forEach((n,o)=>{e.addColorStop(n,r[o]);}),s.fill={fill:e};}}class Fu{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=false;}_createCanvasAndContext(t,e){const i=$.get().createCanvas();i.width=t,i.height=e;const r=i.getContext("2d");return {canvas:i,context:r}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=bi(t),e=bi(e);const r=(t<<17)+(e<<1);this._canvasPool[r]||(this._canvasPool[r]=[]);let n=this._canvasPool[r].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:r}=e,n=(i<<17)+(r<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,r),this._canvasPool[n].push(t);}clear(){this._canvasPool={};}}const Gs=new Fu;Qe.register(Gs);const un=1e5;function dn(s,t,e,i=0){if(s.texture===W.WHITE&&!s.fill)return ot.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof Ti){const r=s.fill,n=t.createPattern(r.texture.source.resource,"repeat"),o=r.transform.copyTo(H.shared);return o.scale(r.texture.frame.width,r.texture.frame.height),n.setTransform(o),n}else if(s.fill instanceof Xt){const r=s.fill,n=r.type==="linear",o=r.textureSpace==="local";let a=1,h=1;o&&e&&(a=e.width+i,h=e.height+i);let l,c=false;if(n){const{start:u,end:f}=r;l=t.createLinearGradient(u.x*a,u.y*h,f.x*a,f.y*h),c=Math.abs(f.x-u.x)<Math.abs((f.y-u.y)*.1);}else {const{center:u,innerRadius:f,outerCenter:d,outerRadius:_}=r;l=t.createRadialGradient(u.x*a,u.y*h,f*a,d.x*a,d.y*h,_*a);}if(c&&o&&e){const u=e.lineHeight/h;for(let f=0;f<e.lines.length;f++){const d=(f*e.lineHeight+i/2)/h;r.colorStops.forEach(_=>{const g=d+_.offset*u;l.addColorStop(Math.floor(g*un)/un,ot.shared.setValue(_.color).toHex());});}}else r.colorStops.forEach(u=>{l.addColorStop(u.offset,ot.shared.setValue(u.color).toHex());});return l}}else {const r=t.createPattern(s.texture.source.resource,"repeat"),n=s.matrix.copyTo(H.shared);return n.scale(s.texture.frame.width,s.texture.frame.height),r.setTransform(n),r}return J("FillStyle not recognised",s),"red"}const jo=class qo extends To{constructor(t){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=false;const e={...qo.defaultOptions,...t};this._textureSize=e.textureSize,this._mipmap=e.mipmap;const i=e.style.clone();e.overrideFill&&(i._fill.color=16777215,i._fill.alpha=1,i._fill.texture=W.WHITE,i._fill.fill=null),this.applyFillAsTint=e.overrideFill;const r=i.fontSize;i.fontSize=this.baseMeasurementFontSize;const n=Rs(i);e.overrideSize?i._stroke&&(i._stroke.width*=this.baseRenderedFontSize/r):i.fontSize=this.baseRenderedFontSize=r,this._style=i,this._skipKerning=e.skipKerning??false,this.resolution=e.resolution??1,this._padding=e.padding??4,e.textureStyle&&(this._textureStyle=e.textureStyle instanceof wi?e.textureStyle:new wi(e.textureStyle)),this.fontMetrics=gi.measureFont(n),this.lineHeight=i.lineHeight||this.fontMetrics.fontSize||i.fontSize;}ensureCharacters(t){const e=gi.graphemeSegmenter(t).filter(p=>!this._currentChars.includes(p)).filter((p,m,y)=>y.indexOf(p)===m);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let i;this._currentPageIndex===-1?i=this._nextPage():i=this.pages[this._currentPageIndex];let{canvas:r,context:n}=i.canvasAndContext,o=i.texture.source;const a=this._style;let h=this._currentX,l=this._currentY,c=this._currentMaxCharHeight;const u=this.baseRenderedFontSize/this.baseMeasurementFontSize,f=this._padding*u;let d=false;const _=r.width/this.resolution,g=r.height/this.resolution;for(let p=0;p<e.length;p++){const m=e[p],y=gi.measureText(m,a,r,false);y.lineHeight=y.height;const x=y.width*u,b=Math.ceil((a.fontStyle==="italic"?2:1)*x),A=y.height*u,w=b+f*2,k=A+f*2;if(d=false,m!==`
`&&m!=="\r"&&m!=="	"&&m!==" "&&(d=true,c=Math.ceil(Math.max(k,c))),h+w>_&&(l+=c,c=k,h=0,l+c>g)){o.update();const I=this._nextPage();r=I.canvasAndContext.canvas,n=I.canvasAndContext.context,o=I.texture.source,h=0,l=0,c=0;}const E=x/u-(a.dropShadow?.distance??0)-(a._stroke?.width??0);if(this.chars[m]={id:m.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:E,kerning:{}},d){this._drawGlyph(n,y,h+f,l+f,u,a);const I=o.width*u,M=o.height*u,T=new Z(h/I*o.width,l/M*o.height,w/I*o.width,k/M*o.height);this.chars[m].texture=new W({source:o,frame:T}),h+=Math.ceil(w);}}o.update(),this._currentX=h,this._currentY=l,this._currentMaxCharHeight=c,this._skipKerning&&this._applyKerning(e,n);}get pageTextures(){return D(j,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const i=this._measureCache;for(let r=0;r<t.length;r++){const n=t[r];for(let o=0;o<this._currentChars.length;o++){const a=this._currentChars[o];let h=i[n];h||(h=i[n]=e.measureText(n).width);let l=i[a];l||(l=i[a]=e.measureText(a).width);let c=e.measureText(n+a).width,u=c-(h+l);u&&(this.chars[n].kerning[a]=u),c=e.measureText(n+a).width,u=c-(h+l),u&&(this.chars[a].kerning[n]=u);}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=Gs.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),r=new W({source:new ce({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(r.source.style=this._textureStyle);const n={canvasAndContext:e,texture:r};return this.pages[this._currentPageIndex]=n,n}_setupContext(t,e,i){e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=Rs(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const r=e._stroke,n=r?.width??0;if(r&&(t.lineWidth=n,t.lineJoin=r.join,t.miterLimit=r.miterLimit,t.strokeStyle=dn(r,t)),e._fill&&(t.fillStyle=dn(e._fill,t)),e.dropShadow){const o=e.dropShadow,a=ot.shared.setValue(o.color).toArray(),h=o.blur*i,l=o.distance*i;t.shadowColor=`rgba(${a[0]*255},${a[1]*255},${a[2]*255},${o.alpha})`,t.shadowBlur=h,t.shadowOffsetX=Math.cos(o.angle)*l,t.shadowOffsetY=Math.sin(o.angle)*l;}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;}_drawGlyph(t,e,i,r,n,o){const a=e.text,h=e.fontProperties,c=(o._stroke?.width??0)*n,u=i+c/2,f=r-c/2,d=h.descent*n,_=e.lineHeight*n;let g=false;o.stroke&&c&&(g=true,t.strokeText(a,u,f+_-d));const{shadowBlur:p,shadowOffsetX:m,shadowOffsetY:y}=t;o._fill&&(g&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(a,u,f+_-d)),g&&(t.shadowBlur=p,t.shadowOffsetX=m,t.shadowOffsetY=y);}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];Gs.returnCanvasAndContext(e),i.destroy(true);}this.pages=null;}};jo.defaultOptions={textureSize:512,style:new Si,mipmap:true};let fn=jo;function Bu(s,t,e,i){const r={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};r.offsetY=e.baseLineOffset;let n=r.lines[0],o=null,a=true;const h={width:0,start:0,index:0,positions:[],chars:[]},l=e.baseMeasurementFontSize/t.fontSize,c=t.letterSpacing*l,u=t.wordWrapWidth*l,f=t.lineHeight?t.lineHeight*l:e.lineHeight,d=t.wordWrap&&t.breakWords,_=m=>{const y=n.width;for(let x=0;x<h.index;x++){const b=m.positions[x];n.chars.push(m.chars[x]),n.charPositions.push(b+y);}n.width+=m.width,a=false,h.width=0,h.index=0,h.chars.length=0;},g=()=>{let m=n.chars.length-1;if(i){let y=n.chars[m];for(;y===" ";)n.width-=e.chars[y].xAdvance,y=n.chars[--m];}r.width=Math.max(r.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=true,r.lines.push(n),r.height+=f;},p=m=>m-c>u;for(let m=0;m<s.length+1;m++){let y;const x=m===s.length;x||(y=s[m]);const b=e.chars[y]||e.chars[" "];if(/(?:\s)/.test(y)||y==="\r"||y===`
`||x){if(!a&&t.wordWrap&&p(n.width+h.width)?(g(),_(h),x||n.charPositions.push(0)):(h.start=n.width,_(h),x||n.charPositions.push(0)),y==="\r"||y===`
`)g();else if(!x){const E=b.xAdvance+(b.kerning[o]||0)+c;n.width+=E,n.spaceWidth=E,n.spacesIndex.push(n.charPositions.length),n.chars.push(y);}}else {const k=b.kerning[o]||0,E=b.xAdvance+k+c;d&&p(n.width+h.width+E)&&(_(h),g()),h.positions[h.index++]=h.width+k,h.chars.push(y),h.width+=E;}o=y;}return g(),t.align==="center"?Lu(r):t.align==="right"?Ou(r):t.align==="justify"&&Gu(r),r}function Lu(s){for(let t=0;t<s.lines.length;t++){const e=s.lines[t],i=s.width/2-e.width/2;for(let r=0;r<e.charPositions.length;r++)e.charPositions[r]+=i;}}function Ou(s){for(let t=0;t<s.lines.length;t++){const e=s.lines[t],i=s.width-e.width;for(let r=0;r<e.charPositions.length;r++)e.charPositions[r]+=i;}}function Gu(s){const t=s.width;for(let e=0;e<s.lines.length;e++){const i=s.lines[e];let r=0,n=i.spacesIndex[r++],o=0;const a=i.spacesIndex.length,l=(t-i.width)/a;for(let c=0;c<i.charPositions.length;c++)c===n&&(n=i.spacesIndex[r++],o+=l),i.charPositions[c]+=o;}}function Du(s){if(s==="")return [];typeof s=="string"&&(s=[s]);const t=[];for(let e=0,i=s.length;e<i;e++){const r=s[e];if(Array.isArray(r)){if(r.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${r.length}.`);if(r[0].length===0||r[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const n=r[0].charCodeAt(0),o=r[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,h=o;a<=h;a++)t.push(String.fromCharCode(a));}else t.push(...Array.from(r));}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}let fi=0;class Uu{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:false,textureStyle:null},this.measureCache=Po(1e3);}getFont(t,e){let i=`${e.fontFamily}-bitmap`,r=true;if(e._fill.fill&&!e._stroke?(i+=e._fill.fill.styleKey,r=false):(e._stroke||e.dropShadow)&&(i=`${e.styleKey}-bitmap`,r=false),!Q.has(i)){const o=Object.create(e);o.lineHeight=0;const a=new fn({style:o,overrideFill:r,overrideSize:true,...this.defaultOptions});fi++,fi>50&&J("BitmapText",`You have dynamically created ${fi} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),a.once("destroy",()=>{fi--,Q.remove(i);}),Q.set(i,a);}const n=Q.get(i);return n.ensureCharacters?.(t),n}getLayout(t,e,i=true){const r=this.getFont(t,e),n=`${t}-${e.styleKey}-${i}`;if(this.measureCache.has(n))return this.measureCache.get(n);const o=gi.graphemeSegmenter(t),a=Bu(o,e,r,i);return this.measureCache.set(n,a),a}measureText(t,e,i=true){return this.getLayout(t,e,i)}install(...t){let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:t[2]?.chars,resolution:t[2]?.resolution,padding:t[2]?.padding,skipKerning:t[2]?.skipKerning},D(j,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const i=e?.name;if(!i)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const r=e.style,n=r instanceof Si?r:new Si(r),o=e.dynamicFill??this._canUseTintForStyle(n),a=new fn({style:n,overrideFill:o,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:false,textureStyle:e.textureStyle}),h=Du(e.chars);return a.ensureCharacters(h.join("")),Q.set(`${i}-bitmap`,a),a.once("destroy",()=>Q.remove(`${i}-bitmap`)),a}uninstall(t){const e=`${t}-bitmap`,i=Q.get(e);i&&i.destroy();}_canUseTintForStyle(t){return !t._stroke&&(!t.dropShadow||t.dropShadow.color===0)&&!t._fill.fill&&t._fill.color===16777215}}const _n=new Uu;class Ko extends To{constructor(t,e){super();const{textures:i,data:r}=t;Object.keys(r.pages).forEach(n=>{const o=r.pages[parseInt(n,10)],a=i[o.id];this.pages.push({texture:a});}),Object.keys(r.chars).forEach(n=>{const o=r.chars[n],{frame:a,source:h,rotate:l}=i[o.page],c=K.transformRectCoords(o,a,l,new Z),u=new W({frame:c,orig:new Z(0,0,o.width,o.height),source:h,rotate:l});this.chars[n]={id:n.codePointAt(0),xOffset:o.xOffset,yOffset:o.yOffset,xAdvance:o.xAdvance,kerning:o.kerning??{},texture:u};}),this.baseRenderedFontSize=r.fontSize,this.baseMeasurementFontSize=r.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:r.fontSize},this.baseLineOffset=r.baseLineOffset,this.lineHeight=r.lineHeight,this.fontFamily=r.fontFamily,this.distanceField=r.distanceField??{type:"none",range:0},this.url=e;}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(true);}this.pages=null;}static install(t){_n.install(t);}static uninstall(t){_n.uninstall(t);}}const us={test(s){return typeof s=="string"&&s.startsWith("info face=")},parse(s){const t=s.match(/^[a-z]+\s+.+$/gm),e={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const u in t){const f=t[u].match(/^[a-z]+/gm)[0],d=t[u].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),_={};for(const g in d){const p=d[g].split("="),m=p[0],y=p[1].replace(/"/gm,""),x=parseFloat(y),b=isNaN(x)?y:x;_[m]=b;}e[f].push(_);}const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[r]=e.info,[n]=e.common,[o]=e.distanceField??[];o&&(i.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),i.fontSize=parseInt(r.size,10),i.fontFamily=r.face,i.lineHeight=parseInt(n.lineHeight,10);const a=e.page;for(let u=0;u<a.length;u++)i.pages.push({id:parseInt(a[u].id,10)||0,file:a[u].file});const h={};i.baseLineOffset=i.lineHeight-parseInt(n.base,10);const l=e.char;for(let u=0;u<l.length;u++){const f=l[u],d=parseInt(f.id,10);let _=f.letter??f.char??String.fromCharCode(d);_==="space"&&(_=" "),h[d]=_,i.chars[_]={id:d,page:parseInt(f.page,10)||0,x:parseInt(f.x,10),y:parseInt(f.y,10),width:parseInt(f.width,10),height:parseInt(f.height,10),xOffset:parseInt(f.xoffset,10),yOffset:parseInt(f.yoffset,10),xAdvance:parseInt(f.xadvance,10),kerning:{}};}const c=e.kerning||[];for(let u=0;u<c.length;u++){const f=parseInt(c[u].first,10),d=parseInt(c[u].second,10),_=parseInt(c[u].amount,10);i.chars[h[d]].kerning[h[f]]=_;}return i}},pn={test(s){const t=s;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(s){const t={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},e=s.getElementsByTagName("info")[0],i=s.getElementsByTagName("common")[0],r=s.getElementsByTagName("distanceField")[0];r&&(t.distanceField={type:r.getAttribute("fieldType"),range:parseInt(r.getAttribute("distanceRange"),10)});const n=s.getElementsByTagName("page"),o=s.getElementsByTagName("char"),a=s.getElementsByTagName("kerning");t.fontSize=parseInt(e.getAttribute("size"),10),t.fontFamily=e.getAttribute("face"),t.lineHeight=parseInt(i.getAttribute("lineHeight"),10);for(let l=0;l<n.length;l++)t.pages.push({id:parseInt(n[l].getAttribute("id"),10)||0,file:n[l].getAttribute("file")});const h={};t.baseLineOffset=t.lineHeight-parseInt(i.getAttribute("base"),10);for(let l=0;l<o.length;l++){const c=o[l],u=parseInt(c.getAttribute("id"),10);let f=c.getAttribute("letter")??c.getAttribute("char")??String.fromCharCode(u);f==="space"&&(f=" "),h[u]=f,t.chars[f]={id:u,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),kerning:{}};}for(let l=0;l<a.length;l++){const c=parseInt(a[l].getAttribute("first"),10),u=parseInt(a[l].getAttribute("second"),10),f=parseInt(a[l].getAttribute("amount"),10);t.chars[h[u]].kerning[h[c]]=f;}return t}},gn={test(s){return typeof s=="string"&&s.match(/<font(\s|>)/)?pn.test($.get().parseXML(s)):false},parse(s){return pn.parse($.get().parseXML(s))}},Nu=[".xml",".fnt"],Wu={extension:{type:B.CacheParser,name:"cacheBitmapFont"},test:s=>s instanceof Ko,getCacheableAssets(s,t){const e={};return s.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t;}),e[`${t.fontFamily}-bitmap`]=t,e}},Hu={extension:{type:B.LoadParser,priority:Qt.Normal},name:"loadBitmapFont",id:"bitmap-font",test(s){return Nu.includes(Ct.extname(s).toLowerCase())},async testParse(s){return us.test(s)||gn.test(s)},async parse(s,t,e){const i=us.test(s)?us.parse(s):gn.parse(s),{src:r}=t,{pages:n}=i,o=[],a=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:false,resolution:1}:{};for(let u=0;u<n.length;++u){const f=n[u].file;let d=Ct.join(Ct.dirname(r),f);d=ks(d,r),o.push({src:d,data:a});}const h=await e.load(o),l=o.map(u=>h[u.src]);return new Ko({data:i,textures:l},r)},async load(s,t){return await(await $.get().fetch(s)).text()},async unload(s,t,e){await Promise.all(s.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),s.destroy();}};class Vu{constructor(t,e=false){this._loader=t,this._assetList=[],this._isLoading=false,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=true;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=false,this._next();}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next());}}const Yu={extension:{type:B.CacheParser,name:"cacheTextureArray"},test:s=>Array.isArray(s)&&s.every(t=>t instanceof W),getCacheableAssets:(s,t)=>{const e={};return s.forEach(i=>{t.forEach((r,n)=>{e[i+(n===0?"":n+1)]=r;});}),e}};async function Zo(s){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(true);},e.onerror=()=>{t(false);},e.src=s;});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t);}catch{return  false}return  true}return  false}const Xu={extension:{type:B.DetectionParser,priority:1},test:async()=>Zo("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")},mn=["png","jpg","jpeg"],ju={extension:{type:B.DetectionParser,priority:-1},test:()=>Promise.resolve(true),add:async s=>[...s,...mn],remove:async s=>s.filter(t=>!mn.includes(t))},qu="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Ii(s){return qu?false:document.createElement("video").canPlayType(s)!==""}const Ku={extension:{type:B.DetectionParser,priority:0},test:async()=>Ii("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")},Zu={extension:{type:B.DetectionParser,priority:0},test:async()=>Ii("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")},Qu={extension:{type:B.DetectionParser,priority:0},test:async()=>Ii("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")},Ju={extension:{type:B.DetectionParser,priority:0},test:async()=>Zo("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")},Qo=class mi{constructor(){this.loadOptions={...mi.defaultOptions},this._parsers=[],this._parsersValidated=false,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=false,t[e]=i,true)}),this.promiseCache={};}reset(){this._parsersValidated=false,this.promiseCache={};}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{let r=null,n=null;if((e.parser||e.loadParser)&&(n=this._parserHash[e.parser||e.loadParser],e.loadParser&&J(`[Assets] "loadParser" is deprecated, use "parser" instead for ${t}`),n||J(`[Assets] specified load parser "${e.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 J(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}r=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?.(r,e,this)&&(r=await a.parse(r,e,this)||r,i.parser=a);}return r})(),i}async load(t,e){this._parsersValidated||this._validateParsers();const i=typeof e=="function"?{...mi.defaultOptions,...this.loadOptions,onProgress:e}:{...mi.defaultOptions,...this.loadOptions,...e||{}},{onProgress:r,onError:n,strategy:o,retryCount:a,retryDelay:h}=i;let l=0;const c={},u=vi(t),f=Bt(t,g=>({alias:[g],src:g,data:{}})),d=f.reduce((g,p)=>g+(p.progressSize||1),0),_=f.map(async g=>{const p=Ct.toAbsolute(g.src);c[g.src]||(await this._loadAssetWithRetry(p,g,{onProgress:r,onError:n,strategy:o,retryCount:a,retryDelay:h},c),l+=g.progressSize||1,r&&r(l/d));});return await Promise.all(_),u?c[f[0].src]:c}async unload(t){const i=Bt(t,r=>({alias:[r],src:r})).map(async r=>{const n=Ct.toAbsolute(r.src),o=this.promiseCache[n];if(o){const a=await o.promise;delete this.promiseCache[n],await o.parser?.unload?.(a,r,this);}});await Promise.all(i);}_validateParsers(){this._parsersValidated=true,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(!e.name&&!e.id?J("[Assets] parser should have an id"):(t[e.name]||t[e.id])&&J(`[Assets] parser id conflict "${e.id}"`),t[e.name]=e,e.id&&(t[e.id]=e),t),{});}async _loadAssetWithRetry(t,e,i,r){let n=0;const{onError:o,strategy:a,retryCount:h,retryDelay:l}=i,c=u=>new Promise(f=>setTimeout(f,u));for(;;)try{this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),r[e.src]=await this.promiseCache[t].promise;return}catch(u){delete this.promiseCache[t],delete r[e.src],n++;const f=a!=="retry"||n>h;if(a==="retry"&&!f){o&&o(u,e),await c(l);continue}if(a==="skip"){o&&o(u,e);return}o&&o(u,e);const d=new Error(`[Loader.load] Failed to load ${t}.
${u}`);throw u instanceof Error&&u.stack&&(d.stack=u.stack),d}}};Qo.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let $u=Qo;function Se(s,t){if(Array.isArray(t)){for(const e of t)if(s.startsWith(`data:${e}`))return  true;return  false}return s.startsWith(`data:${t}`)}function Ce(s,t){const e=s.split("?")[0],i=Ct.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const td=".json",ed="application/json",id={extension:{type:B.LoadParser,priority:Qt.Low},name:"loadJson",id:"json",test(s){return Se(s,ed)||Ce(s,td)},async load(s){return await(await $.get().fetch(s)).json()}},sd=".txt",rd="text/plain",nd={name:"loadTxt",id:"text",extension:{type:B.LoadParser,priority:Qt.Low,name:"loadTxt"},test(s){return Se(s,rd)||Ce(s,sd)},async load(s){return await(await $.get().fetch(s)).text()}},od=["normal","bold","100","200","300","400","500","600","700","800","900"],ad=[".ttf",".otf",".woff",".woff2"],hd=["font/ttf","font/otf","font/woff","font/woff2"],ld=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function cd(s){const t=Ct.extname(s),r=Ct.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1));let n=r.length>0;for(const a of r)if(!a.match(ld)){n=false;break}let o=r.join(" ");return n||(o=`"${o.replace(/[\\"]/g,"\\$&")}"`),o}const ud=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function dd(s){return ud.test(s)?s:encodeURI(s)}const fd={extension:{type:B.LoadParser,priority:Qt.Low},name:"loadWebFont",id:"web-font",test(s){return Se(s,hd)||Ce(s,ad)},async load(s,t){const e=$.get().getFontFaceSet();if(e){const i=[],r=t.data?.family??cd(s),n=t.data?.weights?.filter(a=>od.includes(a))??["normal"],o=t.data??{};for(let a=0;a<n.length;a++){const h=n[a],l=new FontFace(r,`url(${dd(s)})`,{...o,weight:h});await l.load(),e.add(l),i.push(l);}return Q.has(`${r}-and-url`)?Q.get(`${r}-and-url`).entries.push({url:s,faces:i}):Q.set(`${r}-and-url`,{entries:[{url:s,faces:i}]}),i.length===1?i[0]:i}return J("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(s){const t=Array.isArray(s)?s:[s],e=t[0].family,i=Q.get(`${e}-and-url`),r=i.entries.find(n=>n.faces.some(o=>t.indexOf(o)!==-1));r.faces=r.faces.filter(n=>t.indexOf(n)===-1),r.faces.length===0&&(i.entries=i.entries.filter(n=>n!==r)),t.forEach(n=>{$.get().getFontFaceSet().delete(n);}),i.entries.length===0&&Q.remove(`${e}-and-url`);}};function ir(s,t=1){const e=Ae.RETINA_PREFIX?.exec(s);return e?parseFloat(e[1]):t}function sr(s,t,e){s.label=e,s._sourceOrigin=e;const i=new W({source:s,label:e}),r=()=>{delete t.promiseCache[e],Q.has(e)&&Q.remove(e);};return i.source.once("destroy",()=>{t.promiseCache[e]&&(J("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),r());}),i.once("destroy",()=>{s.destroyed||(J("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r());}),i}const _d=".svg",pd="image/svg+xml",gd={extension:{type:B.LoadParser,priority:Qt.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:false},test(s){return Se(s,pd)||Ce(s,_d)},async load(s,t,e){return t.data?.parseAsGraphicsContext??this.config.parseAsGraphicsContext?yd(s):md(s,t,e,this.config.crossOrigin)},unload(s){s.destroy(true);}};async function md(s,t,e,i){const r=await $.get().fetch(s),n=$.get().createImage();n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await r.text())}`,n.crossOrigin=i,await n.decode();const o=t.data?.width??n.width,a=t.data?.height??n.height,h=t.data?.resolution||ir(s),l=Math.ceil(o*h),c=Math.ceil(a*h),u=$.get().createCanvas(l,c),f=u.getContext("2d");f.imageSmoothingEnabled=true,f.imageSmoothingQuality="high",f.drawImage(n,0,0,o*h,a*h);const{parseAsGraphicsContext:d,..._}=t.data??{},g=new ce({resource:u,alphaMode:"premultiply-alpha-on-upload",resolution:h,..._});return sr(g,e,s)}async function yd(s){const e=await(await $.get().fetch(s)).text(),i=new Mt;return i.svg(e),i}const xd=`(function () {
    'use strict';

    const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
    async function checkImageBitmap() {
      try {
        if (typeof createImageBitmap !== "function")
          return false;
        const response = await fetch(WHITE_PNG);
        const imageBlob = await response.blob();
        const imageBitmap = await createImageBitmap(imageBlob);
        return imageBitmap.width === 1 && imageBitmap.height === 1;
      } catch (_e) {
        return false;
      }
    }
    void checkImageBitmap().then((result) => {
      self.postMessage(result);
    });

})();
`;let ye=null,Ds=class{constructor(){ye||(ye=URL.createObjectURL(new Blob([xd],{type:"application/javascript"}))),this.worker=new Worker(ye);}};Ds.revokeObjectURL=function(){ye&&(URL.revokeObjectURL(ye),ye=null);};const bd=`(function () {
    'use strict';

    async function loadImageBitmap(url, alphaMode) {
      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();
      return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);
    }
    self.onmessage = async (event) => {
      try {
        const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);
        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 xe=null;class Jo{constructor(){xe||(xe=URL.createObjectURL(new Blob([bd],{type:"application/javascript"}))),this.worker=new Worker(xe);}}Jo.revokeObjectURL=function(){xe&&(URL.revokeObjectURL(xe),xe=null);};let yn=0,ds;class wd{constructor(){this._initialized=false,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={};}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new Ds;e.addEventListener("message",i=>{e.terminate(),Ds.revokeObjectURL(),t(i.data);});}),this._isImageBitmapSupported)}loadImageBitmap(t,e){return this._run("loadImageBitmap",[t,e?.data?.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=true);}_getWorker(){ds===void 0&&(ds=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return !t&&this._createdWorkers<ds&&(this._createdWorkers++,t=new Jo().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next();})),t}_returnWorker(t){this._workerPool.push(t);}_complete(t){this._resolveHash[t.uuid]&&(t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),delete this._resolveHash[t.uuid]);}async _run(t,e){await this._initWorkers();const i=new Promise((r,n)=>{this._queue.push({id:t,arguments:e,resolve:r,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[yn]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:yn++,id:i});}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t?.(new Error("WorkerManager has been reset before completion"));}),this._resolveHash={},this._queue.length=0,this._initialized=false,this._createdWorkers=0;}}const xn=new wd,vd=[".jpeg",".jpg",".png",".webp",".avif"],kd=["image/jpeg","image/png","image/webp","image/avif"];async function Ad(s,t){const e=await $.get().fetch(s);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${e.status} ${e.statusText}`);const i=await e.blob();return t?.data?.alphaMode==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}const $o={name:"loadTextures",id:"texture",extension:{type:B.LoadParser,priority:Qt.High,name:"loadTextures"},config:{preferWorkers:true,preferCreateImageBitmap:true,crossOrigin:"anonymous"},test(s){return Se(s,kd)||Ce(s,vd)},async load(s,t,e){let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await xn.isImageBitmapSupported()?i=await xn.loadImageBitmap(s,t):i=await Ad(s,t):i=await new Promise((n,o)=>{i=$.get().createImage(),i.crossOrigin=this.config.crossOrigin,i.src=s,i.complete?n(i):(i.onload=()=>{n(i);},i.onerror=o);});const r=new ce({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:t.data?.resolution||ir(s),...t.data});return sr(r,e,s)},unload(s){s.destroy(true);}},Sd=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let fs,_s;function Cd(s,t,e){e===void 0&&!t.startsWith("data:")?s.crossOrigin=Td(t):e!==false&&(s.crossOrigin=typeof e=="string"?e:"anonymous");}function Md(s){return new Promise((t,e)=>{s.addEventListener("canplaythrough",i),s.addEventListener("error",r),s.load();function i(){n(),t();}function r(o){n(),e(o);}function n(){s.removeEventListener("canplaythrough",i),s.removeEventListener("error",r);}})}function Td(s,t=globalThis.location){if(s.startsWith("data:"))return "";t||(t=globalThis.location);const e=new URL(s,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function Pd(){const s=[],t=[];for(const e of Sd){const i=We.MIME_TYPES[e.substring(1)]||`video/${e.substring(1)}`;Ii(i)&&(s.push(e),t.includes(i)||t.push(i));}return {validVideoExtensions:s,validVideoMime:t}}const Id={name:"loadVideo",id:"video",extension:{type:B.LoadParser,name:"loadVideo"},test(s){if(!fs||!_s){const{validVideoExtensions:i,validVideoMime:r}=Pd();fs=i,_s=r;}const t=Se(s,_s),e=Ce(s,fs);return t||e},async load(s,t,e){const i={...We.defaultOptions,resolution:t.data?.resolution||ir(s),alphaMode:t.data?.alphaMode||await eo(),...t.data},r=document.createElement("video"),n={preload:i.autoLoad!==false?"auto":void 0,"webkit-playsinline":i.playsinline!==false?"":void 0,playsinline:i.playsinline!==false?"":void 0,muted:i.muted===true?"":void 0,loop:i.loop===true?"":void 0,autoplay:i.autoPlay!==false?"":void 0};Object.keys(n).forEach(h=>{const l=n[h];l!==void 0&&r.setAttribute(h,l);}),i.muted===true&&(r.muted=true),Cd(r,s,i.crossorigin);const o=document.createElement("source");let a;if(i.mime)a=i.mime;else if(s.startsWith("data:"))a=s.slice(5,s.indexOf(";"));else if(!s.startsWith("blob:")){const h=s.split("?")[0].slice(s.lastIndexOf(".")+1).toLowerCase();a=We.MIME_TYPES[h]||`video/${h}`;}return o.src=s,a&&(o.type=a),new Promise(h=>{const l=async()=>{const c=new We({...i,resource:r});r.removeEventListener("canplay",l),t.data.preload&&await Md(r),h(sr(c,e,s));};i.preload&&!i.autoPlay&&r.load(),r.addEventListener("canplay",l),r.appendChild(o);})},unload(s){s.destroy(true);}},ta={extension:{type:B.ResolveParser,name:"resolveTexture"},test:$o.test,parse:s=>({resolution:parseFloat(Ae.RETINA_PREFIX.exec(s)?.[1]??"1"),format:s.split(".").pop(),src:s})},zd={extension:{type:B.ResolveParser,priority:-2,name:"resolveJson"},test:s=>Ae.RETINA_PREFIX.test(s)&&s.endsWith(".json"),parse:ta.parse};class Ed{constructor(){this._detections=[],this._initialized=false,this.resolver=new Ae,this.loader=new $u,this.cache=Q,this._backgroundLoader=new Vu(this.loader),this._backgroundLoader.active=true,this.reset();}async init(t={}){if(this._initialized){J("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=true,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,r=await this._detectFormats({preferredFormats:t.texturePreference?.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:r,resolution:i}}),t.preferences&&this.setPreferences(t.preferences),t.loadOptions&&(this.loader.loadOptions={...this.loader.loadOptions,...t.loadOptions});}add(t){this.resolver.add(t);}async load(t,e){this._initialized||await this.init();const i=vi(t),r=Bt(t).map(a=>{if(typeof a!="string"){const h=this.resolver.getAlias(a);return h.some(l=>!this.resolver.hasKey(l))&&this.add(a),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(r),o=await this._mapLoadToResolve(n,e);return i?o[r[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e);}async loadBundle(t,e){this._initialized||await this.init();let i=false;typeof t=="string"&&(i=true,t=[t]);const r=this.resolver.resolveBundle(t),n={},o=Object.keys(r);let a=0;const h=[],l=()=>{e?.(h.reduce((u,f)=>u+f,0)/a);},c=o.map((u,f)=>{const d=r[u],_=Object.values(d),p=[...new Set(_.flat())].reduce((m,y)=>m+(y.progressSize||1),0);return h.push(0),a+=p,this._mapLoadToResolve(d,m=>{h[f]=m*p,l();}).then(m=>{n[u]=m;})});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=false;}get(t){if(typeof t=="string")return Q.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=Q.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=false;const r=await this.loader.load(i,e);this._backgroundLoader.active=true;const n={};return i.forEach(o=>{const a=r[o.src],h=[o.src];o.alias&&h.push(...o.alias),h.forEach(l=>{n[l]=a;}),Q.set(h,a);}),n}async unload(t){this._initialized||await this.init();const e=Bt(t).map(r=>typeof r!="string"?r.src:r),i=this.resolver.resolve(e);await this._unloadFromResolved(i);}async unloadBundle(t){this._initialized||await this.init(),t=Bt(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(i);}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{Q.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,r)=>e.indexOf(i)===r),e}get detections(){return this._detections}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 he=new Ed;ft.handleByList(B.LoadParser,he.loader.parsers).handleByList(B.ResolveParser,he.resolver.parsers).handleByList(B.CacheParser,he.cache.parsers).handleByList(B.DetectionParser,he.detections);ft.add(Yu,ju,Xu,Ju,Ku,Zu,Qu,id,nd,fd,gd,$o,Id,Hu,Wu,ta,zd);const bn={loader:B.LoadParser,resolver:B.ResolveParser,cache:B.CacheParser,detection:B.DetectionParser};ft.handle(B.Asset,s=>{const t=s.ref;Object.entries(bn).filter(([e])=>!!t[e]).forEach(([e,i])=>ft.add(Object.assign(t[e],{extension:t[e].extension??i})));},s=>{const t=s.ref;Object.keys(bn).filter(e=>!!t[e]).forEach(e=>ft.remove(t[e]));});class nt extends Xn{constructor(t){t instanceof Mt&&(t={context:t});const{context:e,roundPixels:i,...r}=t||{};super({label:"Graphics",...r}),this.renderPipeId="graphics",e?this.context=e:(this.context=this._ownedContext=new Mt,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=true,this.allowChildren=false,this.roundPixels=i??false;}set context(t){t!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=t,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate());}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===true||t?.context===true)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t);}_onTouch(t){this._gcLastUsed=t,this._context._gcLastUsed=t;}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t;}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t;}clone(t=false){return t?new nt(this._context.clone()):(this._ownedContext=null,new nt(this._context))}lineStyle(t,e,i){D(j,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const r={};return t&&(r.width=t),e&&(r.color=e),i&&(r.alpha=i),this.context.strokeStyle=r,this}beginFill(t,e){D(j,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return t!==void 0&&(i.color=t),e!==void 0&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){D(j,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return (t.width!==Mt.defaultStrokeStyle.width||t.color!==Mt.defaultStrokeStyle.color||t.alpha!==Mt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return D(j,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return D(j,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return D(j,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return D(j,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return D(j,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return D(j,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}class mt extends W{static create(t){const{dynamic:e,...i}=t;return new mt({source:new It(i),dynamic:e??false})}resize(t,e,i){return this.source.resize(t,e,i),this}}var Us=(s=>(s.CLAMP="clamp-to-edge",s.REPEAT="repeat",s.MIRRORED_REPEAT="mirror-repeat",s))(Us||{});new Proxy(Us,{get(s,t){return D(j,`DRAW_MODES.${t} is deprecated, use '${Us[t]}' instead`),s[t]}});var Ns=(s=>(s.NEAREST="nearest",s.LINEAR="linear",s))(Ns||{});new Proxy(Ns,{get(s,t){return D(j,`DRAW_MODES.${t} is deprecated, use '${Ns[t]}' instead`),s[t]}});ft.add(Na,Wa);var Ws=`in vec2 aPosition;
out vec2 vTextureCoord;

uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;

vec4 filterVertexPosition( void )
{
    vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
    
    position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
    position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;

    return vec4(position, 0.0, 1.0);
}

vec2 filterTextureCoord( void )
{
    return aPosition * (uOutputFrame.zw * uInputSize.zw);
}

void main(void)
{
    gl_Position = filterVertexPosition();
    vTextureCoord = filterTextureCoord();
}
`,Hs=`struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,
};

@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;

struct VSOutput {
    @builtin(position) position: vec4<f32>,
    @location(0) uv : vec2<f32>
  };

fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
    var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;

    position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
    position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;

    return vec4(position, 0.0, 1.0);
}

fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}

fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
  return  (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);  
}

fn getSize() -> vec2<f32>
{
  return gfu.uGlobalFrame.zw;
}
  
@vertex
fn mainVertex(
  @location(0) aPosition : vec2<f32>, 
) -> VSOutput {
  return VSOutput(
   filterVertexPosition(aPosition),
   filterTextureCoord(aPosition)
  );
}`,Gd=`
in vec2 vTextureCoord;
out vec4 finalColor;

uniform sampler2D uTexture;
uniform vec2 uOffset;

void main(void)
{
    vec4 color = vec4(0.0);

    // Sample top left pixel
    color += texture(uTexture, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y));

    // Sample top right pixel
    color += texture(uTexture, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y));

    // Sample bottom right pixel
    color += texture(uTexture, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y));

    // Sample bottom left pixel
    color += texture(uTexture, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y));

    // Average
    color *= 0.25;

    finalColor = color;
}`,Dd=`struct KawaseBlurUniforms {
  uOffset:vec2<f32>,
};

@group(0) @binding(1) var uTexture: texture_2d<f32>; 
@group(0) @binding(2) var uSampler: sampler;
@group(1) @binding(0) var<uniform> kawaseBlurUniforms : KawaseBlurUniforms;

@fragment
fn mainFragment(
  @builtin(position) position: vec4<f32>,
  @location(0) uv : vec2<f32>
) -> @location(0) vec4<f32> {
  let uOffset = kawaseBlurUniforms.uOffset;
  var color: vec4<f32> = vec4<f32>(0.0);

  // Sample top left pixel
  color += textureSample(uTexture, uSampler, vec2<f32>(uv.x - uOffset.x, uv.y + uOffset.y));
  // Sample top right pixel
  color += textureSample(uTexture, uSampler, vec2<f32>(uv.x + uOffset.x, uv.y + uOffset.y));
  // Sample bottom right pixel
  color += textureSample(uTexture, uSampler, vec2<f32>(uv.x + uOffset.x, uv.y - uOffset.y));
  // Sample bottom left pixel
  color += textureSample(uTexture, uSampler, vec2<f32>(uv.x - uOffset.x, uv.y - uOffset.y));
  // Average
  color *= 0.25;

  return color;
}`,Ud=`
precision highp float;
in vec2 vTextureCoord;
out vec4 finalColor;

uniform sampler2D uTexture;
uniform vec2 uOffset;

uniform vec4 uInputClamp;

void main(void)
{
    vec4 color = vec4(0.0);

    // Sample top left pixel
    color += texture(uTexture, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y), uInputClamp.xy, uInputClamp.zw));

    // Sample top right pixel
    color += texture(uTexture, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y), uInputClamp.xy, uInputClamp.zw));

    // Sample bottom right pixel
    color += texture(uTexture, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y), uInputClamp.xy, uInputClamp.zw));

    // Sample bottom left pixel
    color += texture(uTexture, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y), uInputClamp.xy, uInputClamp.zw));

    // Average
    color *= 0.25;

    finalColor = color;
}
`,Nd=`struct KawaseBlurUniforms {
  uOffset:vec2<f32>,
};

struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,
};

@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;

@group(0) @binding(1) var uTexture: texture_2d<f32>; 
@group(0) @binding(2) var uSampler: sampler;
@group(1) @binding(0) var<uniform> kawaseBlurUniforms : KawaseBlurUniforms;

@fragment
fn mainFragment(
  @builtin(position) position: vec4<f32>,
  @location(0) uv : vec2<f32>
) -> @location(0) vec4<f32> {
  let uOffset = kawaseBlurUniforms.uOffset;
  var color: vec4<f32> = vec4(0.0);

  // Sample top left pixel
  color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x - uOffset.x, uv.y + uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
  // Sample top right pixel
  color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x + uOffset.x, uv.y + uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
  // Sample bottom right pixel
  color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x + uOffset.x, uv.y - uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
  // Sample bottom left pixel
  color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x - uOffset.x, uv.y - uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
  // Average
  color *= 0.25;
    
  return color;
}`,Wd=Object.defineProperty,Hd=(s,t,e)=>t in s?Wd(s,t,{enumerable:true,configurable:true,writable:true,value:e}):s[t]=e,oe=(s,t,e)=>(Hd(s,typeof t!="symbol"?t+"":t,e),e);const ea=class ia extends Ts{constructor(...t){let e=t[0]??{};(typeof e=="number"||Array.isArray(e))&&(D("6.0.0","KawaseBlurFilter constructor params are now options object. See params: { strength, quality, clamp, pixelSize }"),e={strength:e},t[1]!==void 0&&(e.quality=t[1]),t[2]!==void 0&&(e.clamp=t[2])),e={...ia.DEFAULT_OPTIONS,...e};const i=Zt.from({vertex:{source:Hs,entryPoint:"mainVertex"},fragment:{source:e?.clamp?Nd:Dd,entryPoint:"mainFragment"}}),r=ve.from({vertex:Ws,fragment:e?.clamp?Ud:Gd,name:"kawase-blur-filter"});super({gpuProgram:i,glProgram:r,resources:{kawaseBlurUniforms:{uOffset:{value:new Float32Array(2),type:"vec2<f32>"}}}}),oe(this,"uniforms"),oe(this,"_pixelSize",{x:0,y:0}),oe(this,"_clamp"),oe(this,"_kernels",[]),oe(this,"_blur"),oe(this,"_quality"),this.uniforms=this.resources.kawaseBlurUniforms.uniforms,this.pixelSize=e.pixelSize??{x:1,y:1},Array.isArray(e.strength)?this.kernels=e.strength:typeof e.strength=="number"&&(this._blur=e.strength,this.quality=e.quality??3),this._clamp=!!e.clamp;}apply(t,e,i,r){const n=this.pixelSizeX/e.source.width,o=this.pixelSizeY/e.source.height;let a;if(this._quality===1||this._blur===0)a=this._kernels[0]+.5,this.uniforms.uOffset[0]=a*n,this.uniforms.uOffset[1]=a*o,t.applyFilter(this,e,i,r);else {const h=we.getSameSizeTexture(e);let l=e,c=h,u;const f=this._quality-1;for(let d=0;d<f;d++)a=this._kernels[d]+.5,this.uniforms.uOffset[0]=a*n,this.uniforms.uOffset[1]=a*o,t.applyFilter(this,l,c,true),u=l,l=c,c=u;a=this._kernels[f]+.5,this.uniforms.uOffset[0]=a*n,this.uniforms.uOffset[1]=a*o,t.applyFilter(this,l,i,r),we.returnTexture(h);}}get strength(){return this._blur}set strength(t){this._blur=t,this._generateKernels();}get quality(){return this._quality}set quality(t){this._quality=Math.max(1,Math.round(t)),this._generateKernels();}get kernels(){return this._kernels}set kernels(t){Array.isArray(t)&&t.length>0?(this._kernels=t,this._quality=t.length,this._blur=Math.max(...t)):(this._kernels=[0],this._quality=1);}get pixelSize(){return this._pixelSize}set pixelSize(t){if(typeof t=="number"){this.pixelSizeX=this.pixelSizeY=t;return}if(Array.isArray(t)){this.pixelSizeX=t[0],this.pixelSizeY=t[1];return}this._pixelSize=t;}get pixelSizeX(){return this.pixelSize.x}set pixelSizeX(t){this.pixelSize.x=t;}get pixelSizeY(){return this.pixelSize.y}set pixelSizeY(t){this.pixelSize.y=t;}get clamp(){return this._clamp}_updatePadding(){this.padding=Math.ceil(this._kernels.reduce((t,e)=>t+e+.5,0));}_generateKernels(){const t=this._blur,e=this._quality,i=[t];if(t>0){let r=t;const n=t/e;for(let o=1;o<e;o++)r-=n,i.push(r);}this._kernels=i,this._updatePadding();}};oe(ea,"DEFAULT_OPTIONS",{strength:4,quality:3,clamp:false,pixelSize:{x:1,y:1}});let Vd=ea;var Yd=`precision highp float;
in vec2 vTextureCoord;
out vec4 finalColor;

uniform sampler2D uTexture;
uniform float uAlpha;
uniform vec3 uColor;
uniform vec2 uOffset;

uniform vec4 uInputSize;

void main(void){
    vec4 sample = texture(uTexture, vTextureCoord - uOffset * uInputSize.zw);

    // Premultiply alpha
    sample.rgb = uColor.rgb * sample.a;

    // alpha user alpha
    sample *= uAlpha;

    finalColor = sample;
}`,Xd=`struct DropShadowUniforms {
  uAlpha: f32,
  uColor: vec3<f32>,
  uOffset: vec2<f32>,
};

struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,
};

@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;

@group(0) @binding(1) var uTexture: texture_2d<f32>; 
@group(0) @binding(2) var uSampler: sampler;
@group(1) @binding(0) var<uniform> dropShadowUniforms : DropShadowUniforms;

@fragment
fn mainFragment(
  @builtin(position) position: vec4<f32>,
  @location(0) uv : vec2<f32>
) -> @location(0) vec4<f32> {
  var color: vec4<f32> = textureSample(uTexture, uSampler, uv - dropShadowUniforms.uOffset * gfu.uInputSize.zw);

  // Premultiply alpha
  color = vec4<f32>(vec3<f32>(dropShadowUniforms.uColor.rgb * color.a), color.a);
  // alpha user alpha
  color *= dropShadowUniforms.uAlpha;

  return color;
}`,jd=Object.defineProperty,qd=(s,t,e)=>t in s?jd(s,t,{enumerable:true,configurable:true,writable:true,value:e}):s[t]=e,pe=(s,t,e)=>(qd(s,typeof t!="symbol"?t+"":t,e),e);const sa=class ra extends Ts{constructor(t){t={...ra.DEFAULT_OPTIONS,...t};const e=Zt.from({vertex:{source:Hs,entryPoint:"mainVertex"},fragment:{source:Xd,entryPoint:"mainFragment"}}),i=ve.from({vertex:Ws,fragment:Yd,name:"drop-shadow-filter"});super({gpuProgram:e,glProgram:i,resources:{dropShadowUniforms:{uAlpha:{value:t.alpha,type:"f32"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uOffset:{value:t.offset,type:"vec2<f32>"}}},resolution:t.resolution}),pe(this,"uniforms"),pe(this,"shadowOnly",false),pe(this,"_color"),pe(this,"_blurFilter"),pe(this,"_basePass"),this.uniforms=this.resources.dropShadowUniforms.uniforms,this._color=new ot,this.color=t.color??0,this._blurFilter=new Vd({strength:t.kernels??t.blur,quality:t.kernels?void 0:t.quality}),this._basePass=new Ts({gpuProgram:Zt.from({vertex:{source:Hs,entryPoint:"mainVertex"},fragment:{source:`
                    @group(0) @binding(1) var uTexture: texture_2d<f32>; 
                    @group(0) @binding(2) var uSampler: sampler;
                    @fragment
                    fn mainFragment(
                        @builtin(position) position: vec4<f32>,
                        @location(0) uv : vec2<f32>
                    ) -> @location(0) vec4<f32> {
                        return textureSample(uTexture, uSampler, uv);
                    }
                    `,entryPoint:"mainFragment"}}),glProgram:ve.from({vertex:Ws,fragment:`
                in vec2 vTextureCoord;
                out vec4 finalColor;
                uniform sampler2D uTexture;

                void main(void){
                    finalColor = texture(uTexture, vTextureCoord);
                }
                `,name:"drop-shadow-filter"}),resources:{}}),Object.assign(this,t);}apply(t,e,i,r){const n=we.getSameSizeTexture(e);t.applyFilter(this,e,n,true),this._blurFilter.apply(t,n,i,r),this.shadowOnly||t.applyFilter(this._basePass,e,i,false),we.returnTexture(n);}get offset(){return this.uniforms.uOffset}set offset(t){this.uniforms.uOffset=t,this._updatePadding();}get offsetX(){return this.offset.x}set offsetX(t){this.offset.x=t,this._updatePadding();}get offsetY(){return this.offset.y}set offsetY(t){this.offset.y=t,this._updatePadding();}get color(){return this._color.value}set color(t){this._color.setValue(t);const[e,i,r]=this._color.toArray();this.uniforms.uColor[0]=e,this.uniforms.uColor[1]=i,this.uniforms.uColor[2]=r;}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t;}get blur(){return this._blurFilter.strength}set blur(t){this._blurFilter.strength=t,this._updatePadding();}get quality(){return this._blurFilter.quality}set quality(t){this._blurFilter.quality=t,this._updatePadding();}get kernels(){return this._blurFilter.kernels}set kernels(t){this._blurFilter.kernels=t;}get pixelSize(){return this._blurFilter.pixelSize}set pixelSize(t){typeof t=="number"&&(t={x:t,y:t}),Array.isArray(t)&&(t={x:t[0],y:t[1]}),this._blurFilter.pixelSize=t;}get pixelSizeX(){return this._blurFilter.pixelSizeX}set pixelSizeX(t){this._blurFilter.pixelSizeX=t;}get pixelSizeY(){return this._blurFilter.pixelSizeY}set pixelSizeY(t){this._blurFilter.pixelSizeY=t;}_updatePadding(){const t=Math.max(Math.abs(this.offsetX),Math.abs(this.offsetY));this.padding=t+this.blur*2+this.quality*4;}};pe(sa,"DEFAULT_OPTIONS",{offset:{x:4,y:4},color:0,alpha:.5,shadowOnly:false,kernels:void 0,blur:2,quality:3,pixelSize:{x:1,y:1},resolution:1});function yf(s$1,t){s$1.component(e$1=>{const i=createEventDispatcher(),r=true;let n=fallback(t.changeable,false),o=fallback(t.sources,()=>["upload","webcam","clipboard"],true),a=fallback(t.transforms,()=>["crop","resize"],true),h=t.canvas_size,l=fallback(t.is_dragging,false),c=fallback(t.background_image,false),u=t.brush_options,f=t.eraser_options,d=fallback(t.fixed_canvas,false),_=t.root,g=t.i18n,p=t.upload,m=t.composite,y=t.layers,x=t.background,b=fallback(t.border_region,0),A=t.layer_options,w=t.current_tool,k=t.webcam_options,E=fallback(t.show_download_button,false),I=t.theme_mode,M=fallback(t.full_history,null);let P=fallback(t.has_drawn,false);async function L(){return {background:null,layers:[],composite:null}}let F;function V(C){F.add_image({image:C});}async function xt(C){return;}async function zt(C){}let ut,gt,bt=fallback(t.can_undo,false);function Wt({tool:C}){F.set_tool(C),w=C;}function Me({tool:C,subtool:G}){F.set_subtool(G),at=G;}function oa(){const C=u.default_color==="auto"?u.colors[0]:u.default_color;if(Array.isArray(C))C[0],C[1];else {const G=s(C);G.getAlpha()<1?G.getAlpha():1;}typeof u.default_size=="number"?u.default_size:25;}function aa(){f.default_size==="auto"?25:f.default_size;}let at=null;async function ca(){const{image:C}=await ut.get_crop_bounds();C&&(await F.add_image({image:C,resize:false}),Me({tool:"image",subtool:null}),i("input"));}let rr=x;x==null&&y.length==0&&m==null&&F,rr!==x&&(Wt({tool:"draw"}),Me({tool:"draw",subtool:null}),w="draw",rr=x),w==="image"&&at==="crop"&&gt.set_zoom("fit"),c=bt&&F.command_manager.contains("AddImage"),u&&oa(),f&&aa(),w!=="image"||w==="image"&&c||w==="image"&&at==="webcam"||o.includes("upload"),xt(),zt();let $t=true,Ri;function ua(C){C.push(`<div data-testid="image"${attr_class("image-container svelte-6fnl1z",void 0,{"dark-bg":at==="crop"})} aria-label="Click to upload or drop files" aria-dropeffect="copy">`),C.push("<!--[!-->"),C.push(`<!--]--> <div${attr_class("pixi-target svelte-6fnl1z",void 0,{visible:at!=="crop"})}></div> <div${attr_class("pixi-target-crop svelte-6fnl1z",void 0,{visible:at==="crop"})}></div> `),at==="crop"?(C.push("<!--[-->"),C.push('<div class="crop-confirm-button svelte-6fnl1z">'),At(C,{Icon:e,label:"Confirm crop",show_label:true,size:"large",padded:true,color:"white",background:"var(--color-green-500)",label_position:"right",onclick:ca}),C.push("<!----></div>")):C.push("<!--[!-->"),C.push("<!--]--> <!--[-->"),slot(C,t,"default",{},null),C.push("<!--]--></div>");}do $t=true,Ri=e$1.copy(),ua(Ri);while(!$t);e$1.subsume(Ri),bind_props(t,{changeable:n,sources:o,transforms:a,canvas_size:h,is_dragging:l,background_image:c,brush_options:u,eraser_options:f,fixed_canvas:d,root:_,i18n:g,upload:p,composite:m,layers:y,background:x,border_region:b,layer_options:A,current_tool:w,webcam_options:k,show_download_button:E,theme_mode:I,full_history:M,has_drawn:P,can_undo:bt,antialias:r,get_blobs:L,add_image:V,add_image_from_url:xt,add_layers_from_url:zt});});}const xf=/^(#\s*)(.+)$/m;function bf(s){const t=s.trim(),e=t.match(xf);if(!e)return [false,t||false];const[i,,r]=e,n=r.trim();if(t===i)return [n,false];const o=e.index!==void 0?e.index+i.length:0,h=t.substring(o).trim()||false;return [n,h]}function wf(s$1,t){s$1.component(e=>{let i$1,r,n=t.brush,o=t.eraser,a=t.sources,h=t.i18n,l=t.root,c=fallback(t.label,void 0),u=t.show_label,f=fallback(t.changeable,false),d=t.theme_mode,_=t.layers,g=t.composite,p=t.background,m=t.layer_options,y=t.transforms,x=t.accept_blobs,b=t.canvas_size,A=fallback(t.fixed_canvas,false),w=t.realtime,k$1=t.upload,E=t.is_dragging,I=fallback(t.placeholder,void 0),M=t.border_region,T=fallback(t.full_history,null),Y=t.webcam_options,X=fallback(t.show_download_button,false);let R,P=false;function L(rt){return !!rt}function F(rt){return !!rt}async function V(){let rt;try{rt=await R.get_blobs();}catch{return {background:null,layers:[],composite:null}}const O=rt.background?k$1(await Ss$1([new File([rt.background],"background.png")]),l):Promise.resolve(null),Nt=rt.layers.filter(L).map(async(dt,Rt)=>k$1(await Ss$1([new File([dt],`layer_${Rt}.png`)]),l)),qt=rt.composite?k$1(await Ss$1([new File([rt.composite],"composite.png")]),l):Promise.resolve(null),[ut,gt,...bt]=await Promise.all([O,qt,...Nt]);return {background:Array.isArray(ut)?ut[0]:ut,layers:bt.flatMap(dt=>Array.isArray(dt)?dt:[dt]).filter(F),composite:Array.isArray(gt)?gt[0]:gt}}let _t=false,xt,zt=fallback(t.image_id,null),et;[i$1,r]=I?bf(I):[false,false];let ht=true,Et;function ct(rt){k(rt,{show_label:u,Icon:i,label:c||h("image.image")}),rt.push("<!----> "),yf(rt,{transforms:y,composite:g,layers:_,background:p,canvas_size:b,changeable:f,sources:a,brush_options:n,eraser_options:o,fixed_canvas:A,border_region:M,layer_options:m,i18n:h,root:l,upload:k$1,webcam_options:Y,show_download_button:X,theme_mode:d,get background_image(){return _t},set background_image(O){_t=O,ht=false;},get current_tool(){return et},set current_tool(O){et=O,ht=false;},get is_dragging(){return E},set is_dragging(O){E=O,ht=false;},get has_drawn(){return P},set has_drawn(O){P=O,ht=false;},get can_undo(){return xt},set can_undo(O){xt=O,ht=false;},get full_history(){return T},set full_history(O){T=O,ht=false;},children:O=>{et==="image"&&!xt?(O.push("<!--[-->"),O.push('<div class="empty wrap svelte-b4yllx">'),a&&a.length?(O.push("<!--[-->"),i$1||r?(O.push("<!--[-->"),i$1?(O.push("<!--[-->"),O.push(`<h2 class="svelte-b4yllx">${escape_html(i$1)}</h2>`)):O.push("<!--[!-->"),O.push("<!--]--> "),r?(O.push("<!--[-->"),O.push(`<p class="svelte-b4yllx">${escape_html(r)}</p>`)):O.push("<!--[!-->"),O.push("<!--]-->")):(O.push("<!--[!-->"),O.push("<div>Upload an image</div>")),O.push("<!--]-->")):O.push("<!--[!-->"),O.push("<!--]--> "),a&&a.length&&n&&!I?(O.push("<!--[-->"),O.push('<div class="or svelte-b4yllx">or</div>')):O.push("<!--[!-->"),O.push("<!--]--> "),n&&!I?(O.push("<!--[-->"),O.push("<div>select the draw tool to start</div>")):O.push("<!--[!-->"),O.push("<!--]--></div>")):O.push("<!--[!-->"),O.push("<!--]-->");},$$slots:{default:true}}),rt.push("<!---->");}do ht=true,Et=e.copy(),ct(Et);while(!ht);e.subsume(Et),bind_props(t,{brush:n,eraser:o,sources:a,i18n:h,root:l,label:c,show_label:u,changeable:f,theme_mode:d,layers:_,composite:g,background:p,layer_options:m,transforms:y,accept_blobs:x,canvas_size:b,fixed_canvas:A,realtime:w,upload:k$1,is_dragging:E,placeholder:I,border_region:M,full_history:T,webcam_options:Y,show_download_button:X,image_id:zt,get_data:V});});}function vf(s$1,t){s$1.component(e=>{let{$$slots:i,$$events:r,...n}=t;class o extends g{async get_data(){const b=await super.get_data(),A=await c();return {...b,value:A}}}const a=new o(n,{server:{accept_blobs:()=>{}},buttons:[],height:350,border_region:0});let h,l=null;async function c(){if(l){const b={id:l};return l=null,b}return await h.get_data()}let u,f=a.props.value?.background||a.props.value?.layers?.length||a.props.value?.composite,d=a.props.value?.background?new Ie$1(a.props.value.background):null,_=a.props.value?.composite?new Ie$1(a.props.value.composite):null,g$1=a.props.value?.layers?.map(x=>new Ie$1(x))||[],p=true,m;function y(x){a.shared.interactive?(x.push("<!--[!-->"),G(x,{visible:a.shared.visible,variant:f?"solid":"dashed",border_mode:u?"focus":"base",padding:false,elem_id:a.shared.elem_id,elem_classes:a.shared.elem_classes,height:a.props.height,width:a.props.width,allow_overflow:true,overflow_behavior:"visible",container:a.shared.container,scale:a.shared.scale,min_width:a.shared.min_width,children:b=>{R(b,spread_props([{autoscroll:a.shared.autoscroll,i18n:a.i18n},a.shared.loading_status,{on_clear_status:()=>a.dispatch("clear_status",a.shared.loading_status)}])),b.push("<!----> "),wf(b,{border_region:a.props.border_region,canvas_size:a.props.canvas_size,layers:g$1,composite:_,background:d,root:a.shared.root,sources:a.props.sources,label:a.shared.label,show_label:a.shared.show_label,fixed_canvas:a.props.fixed_canvas,brush:a.props.brush,eraser:a.props.eraser,changeable:a.shared.attached_events.includes("apply"),realtime:a.shared.attached_events.includes("change")||a.shared.attached_events.includes("input"),i18n:a.i18n,transforms:a.props.transforms,accept_blobs:a.shared.server.accept_blobs,layer_options:a.props.layers,upload:(...A)=>a.shared.client.upload(...A),placeholder:a.props.placeholder,webcam_options:a.props.webcam_options,show_download_button:a.props.buttons===null?true:a.props.buttons.includes("download"),theme_mode:a.shared.theme_mode,get is_dragging(){return u},set is_dragging(A){u=A,p=false;},get image_id(){return l},set image_id(A){l=A,p=false;}}),b.push("<!---->");},$$slots:{default:true}})):(x.push("<!--[-->"),G(x,{visible:a.shared.visible,variant:"solid",border_mode:u?"focus":"base",padding:false,elem_id:a.shared.elem_id,elem_classes:a.shared.elem_classes,height:a.props.height,width:a.props.width,allow_overflow:true,overflow_behavior:"visible",container:a.shared.container,scale:a.shared.scale,min_width:a.shared.min_width,children:b=>{R(b,spread_props([{autoscroll:a.shared.autoscroll,i18n:a.i18n},a.shared.loading_status,{on_clear_status:()=>a.dispatch("clear_status",a.shared.loading_status)}])),b.push("<!----> "),Q$1(b,{value:a.props.value?.composite||null,label:a.shared.label,show_label:a.shared.show_label,buttons:a.props.buttons,selectable:a.props._selectable,i18n:a.i18n}),b.push("<!---->");},$$slots:{default:true}})),x.push("<!--]-->");}do p=true,m=e.copy(),y(m);while(!p);e.subsume(m);});}const s_=Object.freeze(Object.defineProperty({__proto__:null,default:vf},Symbol.toStringTag,{value:"Module"}));

export { Rh as $, ko as A, vt as B, U as C, $ as D, B as E, Ts as F, Bc as G, Pt as H, Dn as I, Lt as J, we as K, vr as L, H as M, q as N, tl as O, N as P, ul as Q, Ss as R, ll as S, ri as T, ws as U, Qe as V, Z as W, Pl as X, Ar as Y, Xi as Z, Sr as _, Ot as a, wi as a0, ot as a1, zh as a2, Wn as a3, mt as a4, Ao as a5, D as a6, j as a7, Fl as a8, rc as a9, Ql as aa, kc as ab, Sc as ac, Ic as ad, Ec as ae, Rc as af, bi as ag, gi as ah, Rs as ai, dn as aj, Do as ak, Ur as al, Gr as am, _n as an, Bu as ao, Q as ap, nt as aq, th as ar, Si as as, Wo as at, s_ as au, ql as b, Ke as c, pi as d, ft as e, Dr as f, Yl as g, qs as h, bo as i, $n as j, It as k, fo as l, Gs as m, vc as n, Ac as o, Tc as p, zc as q, _h as r, Mi as s, W as t, st as u, $a as v, J as w, Zt as x, ve as y, Fc as z };
//# sourceMappingURL=Index4-dyLjg8C9.js.map
