brain0 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -0
- package/bin/brain0.js +269 -0
- package/package.json +53 -0
- package/src/lib.mjs +72 -0
- package/vendor/gui/assets/BufferResource-VGpCfGWQ.js +186 -0
- package/vendor/gui/assets/BufferResource-VGpCfGWQ.js.map +1 -0
- package/vendor/gui/assets/CanvasRenderer-fCJxZSuL.js +2 -0
- package/vendor/gui/assets/CanvasRenderer-fCJxZSuL.js.map +1 -0
- package/vendor/gui/assets/Filter-DBNO82oR.js +2 -0
- package/vendor/gui/assets/Filter-DBNO82oR.js.map +1 -0
- package/vendor/gui/assets/RenderTargetSystem-DxpnxrEz.js +185 -0
- package/vendor/gui/assets/RenderTargetSystem-DxpnxrEz.js.map +1 -0
- package/vendor/gui/assets/WebGLRenderer-DyKdZImF.js +157 -0
- package/vendor/gui/assets/WebGLRenderer-DyKdZImF.js.map +1 -0
- package/vendor/gui/assets/WebGPURenderer-DkU0IC2y.js +42 -0
- package/vendor/gui/assets/WebGPURenderer-DkU0IC2y.js.map +1 -0
- package/vendor/gui/assets/browserAll-Cx9RpU85.js +15 -0
- package/vendor/gui/assets/browserAll-Cx9RpU85.js.map +1 -0
- package/vendor/gui/assets/index-QopGLZI_.js +256 -0
- package/vendor/gui/assets/index-QopGLZI_.js.map +1 -0
- package/vendor/gui/assets/webworkerAll-DTnGa_dQ.js +84 -0
- package/vendor/gui/assets/webworkerAll-DTnGa_dQ.js.map +1 -0
- package/vendor/gui/brain0-logo.svg +1 -0
- package/vendor/gui/brain0-wordmark.svg +1 -0
- package/vendor/gui/index.html +506 -0
- package/vendor/server/server.js +1907 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-Cx9RpU85.js","assets/webworkerAll-DTnGa_dQ.js","assets/Filter-DBNO82oR.js","assets/WebGPURenderer-DkU0IC2y.js","assets/BufferResource-VGpCfGWQ.js","assets/RenderTargetSystem-DxpnxrEz.js","assets/WebGLRenderer-DyKdZImF.js","assets/CanvasRenderer-fCJxZSuL.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Mo=Object.defineProperty;var Ao=(s,t,e)=>t in s?Mo(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var X=(s,t,e)=>Ao(s,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function e(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(n){if(n.ep)return;n.ep=!0;const r=e(n);fetch(n.href,r)}})();class Po{constructor(t=""){this.base=t}async load(){const t=await fetch(`${this.base}/graph.json`);if(!t.ok)throw new Error(`failed to load graph: ${t.status}`);return await t.json()}async debug(t,e){try{const i=e?`&phase=${e}`:"",n=await fetch(`${this.base}/api/debug?q=${encodeURIComponent(t)}${i}`);return n.ok?await n.json():{tasks:[],artifacts:[],explanation:"",error:"llm-unreachable"}}catch{return{tasks:[],artifacts:[],explanation:"",error:"llm-unreachable"}}}async detail(t){const e=await fetch(`${this.base}/api/node?id=${encodeURIComponent(t)}`);if(e.ok)return await e.json()}async diff(t){const e=await fetch(`${this.base}/api/diff?ref=${encodeURIComponent(t)}`);return e.ok?await e.json():{}}async refresh(){const t=await fetch(`${this.base}/api/refresh`,{method:"POST",headers:{"x-brain0-refresh":"1"}});return!t.ok&&t.status!==409?{state:"error",error:(await t.json().catch(()=>({}))).error??`http ${t.status}`}:await t.json()}async refreshStatus(){const t=await fetch(`${this.base}/api/refresh/status`);return t.ok?await t.json():{state:"idle",phase:"",lines:[]}}}const ko="modulepreload",Io=function(s){return"/"+s},Ei={},Me=function(t,e,i){let n=Promise.resolve();if(e&&e.length>0){let o=function(l){return Promise.all(l.map(c=>Promise.resolve(c).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),h=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));n=o(e.map(l=>{if(l=Io(l),l in Ei)return;Ei[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const f=document.createElement("link");if(f.rel=c?"stylesheet":ko,c||(f.as="script"),f.crossOrigin="",f.href=l,h&&f.setAttribute("nonce",h),document.head.appendChild(f),c)return new Promise((d,p)=>{f.addEventListener("load",d),f.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return n.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return t().catch(r)})};var z=(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.TextureUploaderWebGL="texture-uploader-webgl",s.TextureUploaderWebGPU="texture-uploader-webgpu",s.Environment="environment",s.ShapeBuilder="shape-builder",s.Batcher="batcher",s))(z||{});const js=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},Ue=(s,t)=>js(s).priority??t,nt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(js).forEach(t=>{t.type.forEach(e=>{var i,n;return(n=(i=this._removeHandlers)[e])==null?void 0:n.call(i,t)})}),this},add(...s){return s.map(js).forEach(t=>{t.type.forEach(e=>{var r,o;const i=this._addHandlers,n=this._queue;i[e]?(o=i[e])==null||o.call(i,t):(n[e]=n[e]||[],(r=n[e])==null||r.push(t))})}),this},handle(s,t,e){var o;const i=this._addHandlers,n=this._removeHandlers;if(i[s]||n[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,n[s]=e;const r=this._queue;return r[s]&&((o=r[s])==null||o.forEach(a=>t(a)),delete r[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(r=>r.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((r,o)=>Ue(o.value,e)-Ue(r.value,e)))},i=>{const n=t.findIndex(r=>r.name===i.name);n!==-1&&t.splice(n,1)})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((n,r)=>Ue(r,e)-Ue(n,e)))},i=>{const n=t.indexOf(i.ref);n!==-1&&t.splice(n,1)})},mixin(s,...t){for(const e of t)Object.defineProperties(s.prototype,Object.getOwnPropertyDescriptors(e))}},Ro={extension:{type:z.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Me(()=>import("./browserAll-Cx9RpU85.js"),__vite__mapDeps([0,1,2]))}},Eo={extension:{type:z.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Me(()=>import("./webworkerAll-DTnGa_dQ.js"),__vite__mapDeps([1,2]))}};class ct{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new ct(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))}}function Bo(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var ms={exports:{}},Bi;function Fo(){return Bi||(Bi=1,(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function n(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function r(h,l,c,u,f){if(typeof c!="function")throw new TypeError("The listener must be a function");var d=new n(c,u||h,f),p=e?e+l:l;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],d]:h._events[p].push(d):(h._events[p]=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,p=new Array(d);f<d;f++)p[f]=u[f].fn;return p},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,p){var m=e?e+l:l;if(!this._events[m])return!1;var g=this._events[m],x=arguments.length,y,_;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),x){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,u),!0;case 4:return g.fn.call(g.context,c,u,f),!0;case 5:return g.fn.call(g.context,c,u,f,d),!0;case 6:return g.fn.call(g.context,c,u,f,d,p),!0}for(_=1,y=new Array(x-1);_<x;_++)y[_-1]=arguments[_];g.fn.apply(g.context,y)}else{var b=g.length,S;for(_=0;_<b;_++)switch(g[_].once&&this.removeListener(l,g[_].fn,void 0,!0),x){case 1:g[_].fn.call(g[_].context);break;case 2:g[_].fn.call(g[_].context,c);break;case 3:g[_].fn.call(g[_].context,c,u);break;case 4:g[_].fn.call(g[_].context,c,u,f);break;default:if(!y)for(S=1,y=new Array(x-1);S<x;S++)y[S-1]=arguments[S];g[_].fn.apply(g[_].context,y)}}return!0},a.prototype.on=function(l,c,u){return r(this,l,c,u,!1)},a.prototype.once=function(l,c,u){return r(this,l,c,u,!0)},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 p=this._events[d];if(p.fn)p.fn===c&&(!f||p.once)&&(!u||p.context===u)&&o(this,d);else{for(var m=0,g=[],x=p.length;m<x;m++)(p[m].fn!==c||f&&!p[m].once||u&&p[m].context!==u)&&g.push(p[m]);g.length?this._events[d]=g.length===1?g[0]:g: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})(ms)),ms.exports}var Lo=Fo();const It=Bo(Lo),Go=Math.PI*2,$o=180/Math.PI,Do=Math.PI/180;class dt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new dt(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 xs.x=0,xs.y=0,xs}}const xs=new dt;class N{constructor(t=1,e=0,i=0,n=1,r=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,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,n,r,o){return this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,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 dt;const i=t.x,n=t.y;return e.x=this.a*i+this.c*n+this.tx,e.y=this.b*i+this.d*n+this.ty,e}applyInverse(t,e){e=e||new dt;const i=this.a,n=this.b,r=this.c,o=this.d,a=this.tx,h=this.ty,l=1/(i*o+r*-n),c=t.x,u=t.y;return e.x=o*l*c+-r*l*u+(h*r-a*o)*l,e.y=i*l*u+-n*l*c+(-h*i+a*n)*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),n=this.a,r=this.c,o=this.tx;return this.a=n*e-this.b*i,this.b=n*i+this.b*e,this.c=r*e-this.d*i,this.d=r*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,n=this.c,r=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*i+t.b*r,this.c=t.c*e+t.d*n,this.d=t.c*i+t.d*r,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*i+t.ty*r+this.ty,this}appendFrom(t,e){const i=t.a,n=t.b,r=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+n*u,this.b=i*c+n*f,this.c=r*l+o*u,this.d=r*c+o*f,this.tx=a*l+h*u+e.tx,this.ty=a*c+h*f+e.ty,this}setTransform(t,e,i,n,r,o,a,h,l){return this.a=Math.cos(a+l)*r,this.b=Math.sin(a+l)*r,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*o,this.tx=t-(i*this.a+n*this.c),this.ty=e-(i*this.b+n*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,n=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=n*t.a+this.d*t.c,this.d=n*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,n=this.c,r=this.d,o=t.pivot,a=-Math.atan2(-n,r),h=Math.atan2(i,e),l=Math.abs(a+h);return l<1e-5||Math.abs(Go-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(n*n+r*r),t.position.x=this.tx+(o.x*e+o.y*n),t.position.y=this.ty+(o.x*i+o.y*r),t}invert(){const t=this.a,e=this.b,i=this.c,n=this.d,r=this.tx,o=t*n-e*i;return this.a=n/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-n*r)/o,this.ty=-(t*this.ty-e*r)/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 N;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 Oo.identity()}static get shared(){return zo.identity()}}const zo=new N,Oo=new N,jt=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],qt=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Kt=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Zt=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],qs=[],jn=[],Ne=Math.sign;function Wo(){for(let s=0;s<16;s++){const t=[];qs.push(t);for(let e=0;e<16;e++){const i=Ne(jt[s]*jt[e]+Kt[s]*qt[e]),n=Ne(qt[s]*jt[e]+Zt[s]*qt[e]),r=Ne(jt[s]*Kt[e]+Kt[s]*Zt[e]),o=Ne(qt[s]*Kt[e]+Zt[s]*Zt[e]);for(let a=0;a<16;a++)if(jt[a]===i&&qt[a]===n&&Kt[a]===r&&Zt[a]===o){t.push(a);break}}}for(let s=0;s<16;s++){const t=new N;t.set(jt[s],qt[s],Kt[s],Zt[s],0,0),jn.push(t)}}Wo();const U={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=>jt[s],uY:s=>qt[s],vX:s=>Kt[s],vY:s=>Zt[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>qs[s][t],sub:(s,t)=>qs[s][U.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?U.S:U.N:Math.abs(t)*2<=Math.abs(s)?s>0?U.E:U.W:t>0?s>0?U.SE:U.SW:s>0?U.NE:U.NW,matrixAppendRotationInv:(s,t,e=0,i=0,n=0,r=0)=>{const o=jn[U.inv(t)],a=o.a,h=o.b,l=o.c,c=o.d,u=e-Math.min(0,a*n,l*r,a*n+l*r),f=i-Math.min(0,h*n,c*r,h*n+c*r),d=s.a,p=s.b,m=s.c,g=s.d;s.a=a*d+h*m,s.b=a*p+h*g,s.c=l*d+c*m,s.d=l*p+c*g,s.tx=u*d+f*m+s.tx,s.ty=u*p+f*g+s.ty},transformRectCoords:(s,t,e,i)=>{const{x:n,y:r,width:o,height:a}=s,{x:h,y:l,width:c,height:u}=t;return e===U.E?(i.set(n+h,r+l,o,a),i):e===U.S?i.set(c-r-a+h,n+l,a,o):e===U.W?i.set(c-n-o+h,u-r-a+l,o,a):e===U.N?i.set(r+h,u-n-o+l,a,o):i.set(n+h,r+l,o,a)}},He=[new dt,new dt,new dt,new dt];class it{constructor(t=0,e=0,i=0,n=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(n)}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 it(0,0,0,0)}clone(){return new it(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?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i,n=.5){const{width:r,height:o}=this;if(r<=0||o<=0)return!1;const a=this.x,h=this.y,l=i*(1-n),c=i-l,u=a-l,f=a+r+l,d=h-l,p=h+o+l,m=a+c,g=a+r-c,x=h+c,y=h+o-c;return t>=u&&t<=f&&e>=d&&e<=p&&!(t>m&&t<g&&e>x&&e<y)}intersects(t,e){if(!e){const R=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=R)return!1;const M=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>M}const i=this.left,n=this.right,r=this.top,o=this.bottom;if(n<=i||o<=r)return!1;const a=He[0].set(t.left,t.top),h=He[1].set(t.left,t.bottom),l=He[2].set(t.right,t.top),c=He[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(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)>=n||Math.max(a.y,h.y,l.y,c.y)<=r||Math.min(a.y,h.y,l.y,c.y)>=o))return!1;const f=u*(h.y-a.y),d=u*(a.x-h.x),p=f*i+d*r,m=f*n+d*r,g=f*i+d*o,x=f*n+d*o;if(Math.max(p,m,g,x)<=f*a.x+d*a.y||Math.min(p,m,g,x)>=f*c.x+d*c.y)return!1;const y=u*(a.y-l.y),_=u*(l.x-a.x),b=y*i+_*r,S=y*n+_*r,w=y*i+_*o,v=y*n+_*o;return!(Math.max(b,S,w,v)<=y*a.x+_*a.y||Math.min(b,S,w,v)>=y*c.x+_*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),r=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=n,this.height=Math.max(r-n,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,n=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=n-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),n=Math.min(this.y,t.y),r=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=n,this.height=r-n,this}getBounds(t){return t||(t=new it),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,n=t.x+t.width,r=t.y+t.height;return e>=this.x&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&n>=this.x&&n<this.x+this.width&&r>=this.y&&r<this.y+this.height}set(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const ys={default:-1};function st(s="default"){return ys[s]===void 0&&(ys[s]=-1),++ys[s]}const Fi=new Set,et="8.0.0",Uo="8.3.4",le={quiet:!1,noColor:!1},H=((s,t,e=3)=>{if(le.quiet||Fi.has(t))return;let i=new Error().stack;const n=`${t}
|
|
3
|
+
Deprecated since v${s}`,r=typeof console.groupCollapsed=="function"&&!le.noColor;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",n):(i=i.split(`
|
|
4
|
+
`).splice(e).join(`
|
|
5
|
+
`),r?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",n),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",n),console.warn(i))),Fi.add(t)});Object.defineProperties(H,{quiet:{get:()=>le.quiet,set:s=>{le.quiet=s},enumerable:!0,configurable:!1},noColor:{get:()=>le.noColor,set:s=>{le.noColor=s},enumerable:!0,configurable:!1}});const qn=()=>{};function de(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 Li(s){return!(s&s-1)&&!!s}function Kn(s){const t={};for(const e in s)s[e]!==void 0&&(t[e]=s[e]);return t}const Gi=Object.create(null);function No(s){const t=Gi[s];return t===void 0&&(Gi[s]=st("resource")),t}const Zn=class Qn extends It{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...Qn.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){H(et,"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=No(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Zn.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let fe=Zn;const Jn=class tr extends It{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=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this.antialias=!1,this.transient=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...tr.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.viewDimension=t.viewDimension??t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.transient=t.transient??!1,this.alphaMode=t.alphaMode,this.style=new fe(Kn(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.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=!0,this.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){var t,e;this._resourceId=st("resource"),this.emit("change",this),this.emit("unload",this);for(const i in this._gpuData)(e=(t=this._gpuData[i])==null?void 0:t.destroy)==null||e.call(t);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 n=Math.round(t*i),r=Math.round(e*i);return this.width=n/i,this.height=r/i,this._resolution=i,this.pixelWidth===n&&this.pixelHeight===r?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=r,this.emit("resize",this),this._resourceId=st("resource"),this.emit("change",this),!0)}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=Li(this.pixelWidth)&&Li(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Jn.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let vt=Jn;class gi extends vt{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":(e instanceof Int8Array,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}}gi.extension=z.TextureSource;const $i=new N;class Ho{constructor(t,e){this.mapCoord=new N,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this._texture!==t&&((e=this._texture)==null||e.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 n=0;n<t.length;n+=2){const r=t[n],o=t[n+1];e[n]=r*i.a+o*i.c+i.tx,e[n+1]=r*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,n=t.trim;n&&($i.set(i.width/n.width,0,0,i.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append($i));const r=t.source,o=this.uClampFrame,a=this.clampMargin/r._resolution,h=this.clampOffset/r._resolution;return o[0]=(t.frame.x+a+h)/r.width,o[1]=(t.frame.y+a+h)/r.height,o[2]=(t.frame.x+t.frame.width-a+h)/r.width,o[3]=(t.frame.y+t.frame.height-a+h)/r.height,this.uClampOffset[0]=this.clampOffset/r.pixelWidth,this.uClampOffset[1]=this.clampOffset/r.pixelHeight,this.isSimple=t.frame.width===r.width&&t.frame.height===r.height&&t.rotate===0,!0}}class q extends It{constructor({source:t,label:e,frame:i,orig:n,trim:r,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 it,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(t==null?void 0:t.source)??new vt,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=n||this.frame,this.trim=r,this.rotate=h??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=l||!1,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 Ho(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:n}=this._source,r=e.x/i,o=e.y/n,a=e.width/i,h=e.height/n;let l=this.rotate;if(l){const c=a/2,u=h/2,f=r+c,d=o+u;l=U.add(l,U.NW),t.x0=f+c*U.uX(l),t.y0=d+u*U.uY(l),l=U.add(l,2),t.x1=f+c*U.uX(l),t.y1=d+u*U.uY(l),l=U.add(l,2),t.x2=f+c*U.uX(l),t.y2=d+u*U.uY(l),l=U.add(l,2),t.x3=f+c*U.uX(l),t.y3=d+u*U.uY(l)}else t.x0=r,t.y0=o,t.x1=r+a,t.y1=o,t.x2=r+a,t.y2=o+h,t.x3=r,t.y3=o+h}destroy(t=!1){this._source&&(this._source.off("resize",this.update,this),t&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,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 H(et,"Texture.baseTexture is now Texture.source"),this._source}}q.EMPTY=new q({label:"EMPTY",source:new vt({label:"EMPTY"})});q.EMPTY.destroy=qn;q.WHITE=new q({source:new gi({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});q.WHITE.destroy=qn;function er(s,t,e){const{width:i,height:n}=e.orig,r=e.trim;if(r){const o=r.width,a=r.height;s.minX=r.x-t._x*i,s.maxX=s.minX+o,s.minY=r.y-t._y*n,s.maxY=s.minY+a}else s.minX=-t._x*i,s.maxX=s.minX+i,s.minY=-t._y*n,s.maxY=s.minY+n}const Di=new N;class St{constructor(t=1/0,e=1/0,i=-1/0,n=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Di,this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new it);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=Di,this}set(t,e,i,n){this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}addFrame(t,e,i,n,r){r||(r=this.matrix);const o=r.a,a=r.b,h=r.c,l=r.d,c=r.tx,u=r.ty;let f=this.minX,d=this.minY,p=this.maxX,m=this.maxY,g=o*t+h*e+c,x=a*t+l*e+u;g<f&&(f=g),x<d&&(d=x),g>p&&(p=g),x>m&&(m=x),g=o*i+h*e+c,x=a*i+l*e+u,g<f&&(f=g),x<d&&(d=x),g>p&&(p=g),x>m&&(m=x),g=o*t+h*n+c,x=a*t+l*n+u,g<f&&(f=g),x<d&&(d=x),g>p&&(p=g),x>m&&(m=x),g=o*i+h*n+c,x=a*i+l*n+u,g<f&&(f=g),x<d&&(d=x),g>p&&(p=g),x>m&&(m=x),this.minX=f,this.minY=d,this.maxX=p,this.maxY=m}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,n=this.maxX,r=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*n+h*i+c,d=a*n+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*r+c,d=a*e+l*r+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*n+h*r+c,d=a*n+l*r+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,n){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>n&&(this.maxY=n),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 St(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,n){let r=this.minX,o=this.minY,a=this.maxX,h=this.maxY;n||(n=this.matrix);const l=n.a,c=n.b,u=n.c,f=n.d,d=n.tx,p=n.ty;for(let m=e;m<i;m+=2){const g=t[m],x=t[m+1],y=l*g+u*x+d,_=c*g+f*x+p;r=y<r?y:r,o=_<o?_:o,a=y>a?y:a,h=_>h?_:h}this.minX=r,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 Vo={grad:.9,turn:360,rad:360/(2*Math.PI)},Et=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},ht=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},bt=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},sr=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},zi=function(s){return{r:bt(s.r,0,255),g:bt(s.g,0,255),b:bt(s.b,0,255),a:bt(s.a)}},_s=function(s){return{r:ht(s.r),g:ht(s.g),b:ht(s.b),a:ht(s.a,3)}},Xo=/^#([0-9a-f]{3,8})$/i,Ve=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},ir=function(s){var t=s.r,e=s.g,i=s.b,n=s.a,r=Math.max(t,e,i),o=r-Math.min(t,e,i),a=o?r===t?(e-i)/o:r===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:r?o/r*100:0,v:r/255*100,a:n}},nr=function(s){var t=s.h,e=s.s,i=s.v,n=s.a;t=t/360*6,e/=100,i/=100;var r=Math.floor(t),o=i*(1-e),a=i*(1-(t-r)*e),h=i*(1-(1-t+r)*e),l=r%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:n}},Oi=function(s){return{h:sr(s.h),s:bt(s.s,0,100),l:bt(s.l,0,100),a:bt(s.a)}},Wi=function(s){return{h:ht(s.h),s:ht(s.s),l:ht(s.l),a:ht(s.a,3)}},Ui=function(s){return nr((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},Ae=function(s){return{h:(t=ir(s)).h,s:(n=(200-(e=t.s))*(i=t.v)/100)>0&&n<200?e*i/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,i,n},Yo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,jo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,qo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ko=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ks={string:[[function(s){var t=Xo.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?ht(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?ht(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=qo.exec(s)||Ko.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:zi({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=Yo.exec(s)||jo.exec(s);if(!t)return null;var e,i,n=Oi({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Vo[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Ui(n)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,n=s.a,r=n===void 0?1:n;return Et(t)&&Et(e)&&Et(i)?zi({r:Number(t),g:Number(e),b:Number(i),a:Number(r)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,n=s.a,r=n===void 0?1:n;if(!Et(t)||!Et(e)||!Et(i))return null;var o=Oi({h:Number(t),s:Number(e),l:Number(i),a:Number(r)});return Ui(o)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,n=s.a,r=n===void 0?1:n;if(!Et(t)||!Et(e)||!Et(i))return null;var o=(function(a){return{h:sr(a.h),s:bt(a.s,0,100),v:bt(a.v,0,100),a:bt(a.a)}})({h:Number(t),s:Number(e),v:Number(i),a:Number(r)});return nr(o)},"hsv"]]},Ni=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]},Zo=function(s){return typeof s=="string"?Ni(s.trim(),Ks.string):typeof s=="object"&&s!==null?Ni(s,Ks.object):[null,void 0]},bs=function(s,t){var e=Ae(s);return{h:e.h,s:bt(e.s+100*t,0,100),l:e.l,a:e.a}},ws=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},Hi=function(s,t){var e=Ae(s);return{h:e.h,s:e.s,l:bt(e.l+100*t,0,100),a:e.a}},Zs=(function(){function s(t){this.parsed=Zo(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 ht(ws(this.rgba),2)},s.prototype.isDark=function(){return ws(this.rgba)<.5},s.prototype.isLight=function(){return ws(this.rgba)>=.5},s.prototype.toHex=function(){return t=_s(this.rgba),e=t.r,i=t.g,n=t.b,o=(r=t.a)<1?Ve(ht(255*r)):"","#"+Ve(e)+Ve(i)+Ve(n)+o;var t,e,i,n,r,o},s.prototype.toRgb=function(){return _s(this.rgba)},s.prototype.toRgbString=function(){return t=_s(this.rgba),e=t.r,i=t.g,n=t.b,(r=t.a)<1?"rgba("+e+", "+i+", "+n+", "+r+")":"rgb("+e+", "+i+", "+n+")";var t,e,i,n,r},s.prototype.toHsl=function(){return Wi(Ae(this.rgba))},s.prototype.toHslString=function(){return t=Wi(Ae(this.rgba)),e=t.h,i=t.s,n=t.l,(r=t.a)<1?"hsla("+e+", "+i+"%, "+n+"%, "+r+")":"hsl("+e+", "+i+"%, "+n+"%)";var t,e,i,n,r},s.prototype.toHsv=function(){return t=ir(this.rgba),{h:ht(t.h),s:ht(t.s),v:ht(t.v),a:ht(t.a,3)};var t},s.prototype.invert=function(){return At({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),At(bs(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),At(bs(this.rgba,-t))},s.prototype.grayscale=function(){return At(bs(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),At(Hi(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),At(Hi(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"?At({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):ht(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=Ae(this.rgba);return typeof t=="number"?At({h:t,s:e.s,l:e.l,a:e.a}):ht(e.h)},s.prototype.isEqual=function(t){return this.toHex()===At(t).toHex()},s})(),At=function(s){return s instanceof Zs?s:new Zs(s)},Vi=[],Qo=function(s){s.forEach(function(t){Vi.indexOf(t)<0&&(t(Zs,Ks),Vi.push(t))})};function Jo(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 n in e)i[e[n]]=n;var r={};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!=null&&o.closest){var c=this.toRgb(),u=1/0,f="black";if(!r.length)for(var d in e)r[d]=new s(e[d]).toRgb();for(var p in e){var m=(a=c,h=r[p],Math.pow(a.r-h.r,2)+Math.pow(a.g-h.g,2)+Math.pow(a.b-h.b,2));m<u&&(u=m,f=p)}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"])}Qo([Jo]);const pe=class ve{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 ve)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!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((r,o)=>r===e[o]);if(t!==null&&e!==null){const r=Object.keys(t),o=Object.keys(e);return r.length!==o.length?!1:r.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,i,n]=this._components;return{r:t,g:e,b:i,a:n}}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,n]=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(n*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,n,r]=this._components;return t[0]=e,t[1]=i,t[2]=n,t[3]=r,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,n]=this._components;return t[0]=e,t[1]=i,t[2]=n,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,n,r]=ve._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=n,this._components[3]*=r,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,n=this._int>>8&255,r=this._int&255;return e&&(i=i*t+.5|0,n=n*t+.5|0,r=r*t+.5|0),(t*255<<24)+(i<<16)+(n<<8)+r}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._value=null,this}_normalize(t){let e,i,n,r;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,n=(o&255)/255,r=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,n,r=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,n,r=255]=t,e/=255,i/=255,n/=255,r/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=ve.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=At(t);o.isValid()&&({r:e,g:i,b:n,a:r}=o.rgba,e/=255,i/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=n,this._components[3]=r,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((n,r)=>{t[r]=Math.min(Math.max(n,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof ve||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}};pe.shared=new pe;pe._temp=new pe;pe.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let J=pe;const ta={cullArea:null,cullable:!1,cullableChildren:!0};let Ss=0;const Xi=500;function mt(...s){Ss!==Xi&&(Ss++,Ss===Xi?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...s))}const Oe={_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 ea{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){var i;let e;return this._index>0?e=this._pool[--this._index]:(e=new this._classType,this._count++),(i=e.init)==null||i.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),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 sa{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 ea(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 yt=new sa;Oe.register(yt);const ia={get isCachedAsTexture(){var s;return!!((s=this.renderGroup)!=null&&s.isCachedAsTexture)},cacheAsTexture(s){typeof s=="boolean"&&s===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(s===!0?{}:s))},updateCacheTexture(){var s;(s=this.renderGroup)==null||s.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(s){H("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(s)}};function na(s,t,e){const i=s.length;let n;if(t>=i||e===0)return;e=t+e>i?i-t:e;const r=i-e;for(n=t;n<r;++n)s[n]=s[n+e];s.length=r}const ra={allowChildren:!0,removeChildren(s=0,t){var r;const e=t??this.children.length,i=e-s,n=[];if(i>0&&i<=e){for(let a=e-1;a>=s;a--){const h=this.children[a];h&&(n.push(h),h.parent=null)}na(this.children,s,e);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(n);for(let a=0;a<n.length;++a){const h=n[a];(r=h.parentRenderLayer)==null||r.detach(h),this.emit("childRemoved",h,this,a),n[a].emit("removed",this)}return n.length>0&&this._didViewChangeTick++,n}else if(i===0&&this.children.length===0)return n;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||H(et,"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}`);const i=s.parent===this;if(s.parent){const r=s.parent.children.indexOf(s);if(i){if(r===t)return s;s.parent.children.splice(r,1)}else s.removeFromParent()}t===e.length?e.push(s):e.splice(t,0,s),s.parent=this,s.didChange=!0,s._updateFlags=15;const n=this.renderGroup||this.parentRenderGroup;return n&&n.addChild(s),this.sortableChildren&&(this.sortDirty=!0),i||(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 n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var s;(s=this.parent)==null||s.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)}},oa={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,n=i.length;for(let r=0;r<n;r++)i[r].collectRenderables(s,t,e)},collectRenderablesWithEffects(s,t,e){const{renderPipes:i}=t;for(let n=0;n<this.effects.length;n++){const r=this.effects[n];i[r.pipe].push(r,this,s)}this.collectRenderablesSimple(s,t,e);for(let n=this.effects.length-1;n>=0;n--){const r=this.effects[n];i[r.pipe].pop(r,this,s)}}};class Yi{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 aa{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,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 yt.get(i.maskClass,t)}return t}returnMaskEffect(t){yt.return(t)}}const Qs=new aa;nt.handleByList(z.MaskEffect,Qs._effectClasses);const ha={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0)},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==null?void 0:t.mask)!==s&&(t&&(this.removeEffect(t),Qs.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=Qs.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){var s;return(s=this._maskEffect)==null?void 0:s.mask},setMask(s){this._maskOptions={...this._maskOptions,...s},s.mask&&(this.mask=s.mask),this._markStructureAsChanged()},set filters(s){var r;!Array.isArray(s)&&s&&(s=[s]);const t=this._filterEffect||(this._filterEffect=new Yi);s=s;const e=(s==null?void 0:s.length)>0,i=((r=t.filters)==null?void 0:r.length)>0,n=e!==i;s=Array.isArray(s)?s.slice(0):s,t.filters=Object.freeze(s),n&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=s??null))},get filters(){var s;return(s=this._filterEffect)==null?void 0:s.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new Yi),this._filterEffect.filterArea=s},get filterArea(){var s;return(s=this._filterEffect)==null?void 0:s.filterArea}},la={label:null,get name(){return H(et,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){H(et,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,t=!1){return this.getChildByLabel(s,t)},getChildByLabel(s,t=!1){const e=this.children;for(let i=0;i<e.length;i++){const n=e[i];if(n.label===s||s instanceof RegExp&&s.test(n.label))return n}if(t)for(let i=0;i<e.length;i++){const r=e[i].getChildByLabel(s,!0);if(r)return r}return null},getChildrenByLabel(s,t=!1,e=[]){const i=this.children;for(let n=0;n<i.length;n++){const r=i[n];(r.label===s||s instanceof RegExp&&s.test(r.label))&&e.push(r)}if(t)for(let n=0;n<i.length;n++)i[n].getChildrenByLabel(s,!0,e);return e}},gt=yt.getPool(N),Gt=yt.getPool(St),ca=new N,ua={getFastGlobalBounds(s,t){t||(t=new St),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 n=!!this.effects.length;if((this.renderGroup||n)&&(i=Gt.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 r=this.children;for(let o=0;o<r.length;o++)r[o]._getGlobalBoundsRecursive(s,i,e)}if(n){let r=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(r||(r=!0,i.applyMatrix(o.worldTransform)),this.effects[a].addBounds(i,!0));r&&i.applyMatrix(o.worldTransform.copyTo(ca).invert()),t.addBounds(i),Gt.return(i)}else this.renderGroup&&(t.addBounds(i,this.relativeGroupTransform),Gt.return(i))}};function rr(s,t,e){e.clear();let i,n;return s.parent?t?i=s.parent.worldTransform:(n=gt.get().identity(),i=mi(s,n)):i=N.IDENTITY,or(s,e,i,t),n&>.return(n),e.isValid||e.set(0,0,0,0),e}function or(s,t,e,i){var a,h;if(!s.visible||!s.measurable)return;let n;i?n=s.worldTransform:(s.updateLocalTransform(),n=gt.get(),n.appendFrom(s.localTransform,e));const r=t,o=!!s.effects.length;if(o&&(t=Gt.get().clear()),s.boundsArea)t.addRect(s.boundsArea,n);else{const l=s.bounds;l&&!l.isEmpty()&&(t.matrix=n,t.addBounds(l));for(let c=0;c<s.children.length;c++)or(s.children[c],t,n,i)}if(o){for(let l=0;l<s.effects.length;l++)(h=(a=s.effects[l]).addBounds)==null||h.call(a,t);r.addBounds(t,N.IDENTITY),Gt.return(t)}i||gt.return(n)}function mi(s,t){const e=s.parent;return e&&(mi(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function ar(s,t){if(s===16777215||!t)return t;if(t===16777215||!s)return s;const e=s>>16&255,i=s>>8&255,n=s&255,r=t>>16&255,o=t>>8&255,a=t&255,h=e*r/255|0,l=i*o/255|0,c=n*a/255|0;return(h<<16)+(l<<8)+c}const ji=16777215;function qi(s,t){return s===ji?t:t===ji?s:ar(s,t)}function ss(s){return((s&255)<<16)+(s&65280)+(s>>16&255)}const da={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 N,t){if(t)return s.copyFrom(this.worldTransform);this.updateLocalTransform();const e=mi(this,gt.get().identity());return s.appendFrom(this.localTransform,e),gt.return(e),s},getGlobalTint(s){if(s)return this.renderGroup?ss(this.renderGroup.worldColor):this.parentRenderGroup?ss(qi(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=qi(t,e.localColor),e=e.parent;return ss(t)}};function hr(s,t,e){return t.clear(),e||(e=N.IDENTITY),lr(s,t,e,s,!0),t.isValid||t.set(0,0,0,0),t}function lr(s,t,e,i,n){var h,l;let r;if(n)r=gt.get(),r=e.copyTo(r);else{if(!s.visible||!s.measurable)return;s.updateLocalTransform();const c=s.localTransform;r=gt.get(),r.appendFrom(c,e)}const o=t,a=!!s.effects.length;if(a&&(t=Gt.get().clear()),s.boundsArea)t.addRect(s.boundsArea,r);else{s.renderPipeId&&(t.matrix=r,t.addBounds(s.bounds));const c=s.children;for(let u=0;u<c.length;u++)lr(c[u],t,r,i,!1)}if(a){for(let c=0;c<s.effects.length;c++)(l=(h=s.effects[c]).addLocalBounds)==null||l.call(h,t,i);o.addBounds(t,N.IDENTITY),Gt.return(t)}gt.return(r)}function cr(s,t){const e=s.children;for(let i=0;i<e.length;i++){const n=e[i],r=n.uid,o=(n._didViewChangeTick&65535)<<16|n._didContainerChangeTick&65535,a=t.index;(t.data[a]!==r||t.data[a+1]!==o)&&(t.data[t.index]=r,t.data[t.index+1]=o,t.didChange=!0),t.index=a+2,n.children.length&&cr(n,t)}return t.didChange}const fa=new N,pa={_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:!1,localBounds:new St});const s=this._localBoundsCacheData;return s.index=1,s.didChange=!1,s.data[0]!==this._didViewChangeTick&&(s.didChange=!0,s.data[0]=this._didViewChangeTick),cr(this,s),s.didChange&&hr(this,s.localBounds,fa),s.localBounds},getBounds(s,t){return rr(this,s,t||new St)}},ga={_onRender:null,set onRender(s){const t=this.renderGroup||this.parentRenderGroup;if(!s){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=s},get onRender(){return this._onRender}},ma={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(s){this._zIndex!==s&&(this._zIndex=s,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(xa))}};function xa(s,t){return s._zIndex-t._zIndex}const ya={getGlobalPosition(s=new dt,t=!1){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=!1){const i=this.getGlobalTransform(gt.get(),e);return t=i.apply(s,t),gt.return(i),t},toLocal(s,t,e,i){t&&(s=t.toGlobal(s,e,i));const n=this.getGlobalTransform(gt.get(),i);return e=n.applyInverse(s,e),gt.return(n),e}};class xi{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 _a=0;class ba{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new fe(this.textureOptions)}createTexture(t,e,i,n){const r=new vt({...this.textureOptions,width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1,autoGenerateMipmaps:n});return new q({source:r,label:`texturePool_${_a++}`})}getOptimalTexture(t,e,i=1,n,r=!1){let o=Math.ceil(t*i-1e-6),a=Math.ceil(e*i-1e-6);o=de(o),a=de(a);const h=n?1:0,l=r?1:0,c=(o<<17)+(a<<2)+(l<<1)+h;this._texturePool[c]||(this._texturePool[c]=[]);let u=this._texturePool[c].pop();return u||(u=this.createTexture(o,a,n,r)),u.source._resolution=i,u.source.width=o/i,u.source.height=a/i,u.source.pixelWidth=o,u.source.pixelHeight=a,u.frame.x=0,u.frame.y=0,u.frame.width=t,u.frame.height=e,u.updateUvs(),this._poolKeyHash[u.uid]=c,u}getSameSizeTexture(t,e=!1){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t,e=!1){const i=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[i].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const i=this._texturePool[e];if(i)for(let n=0;n<i.length;n++)i[n].destroy(!0)}this._texturePool={}}}const us=new ba;Oe.register(us);class wa{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new N,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=!0,this.instructionSet=new xi,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let i=0;i<e.length;i++){const n=e[i];n._updateFlags=15,this.addChild(n)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(us.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;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=!0,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=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,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=!0,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=!1)}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 n=0;n<i.length;n++)this._getChildren(i[n],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new N),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new N),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 N),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 Sa(s,t,e={}){for(const i in t)!e[i]&&t[i]!==void 0&&(s[i]=t[i])}const vs=new ct(null),Xe=new ct(null),Cs=new ct(null,1,1),Ye=new ct(null),Ki=1,va=2,Ts=4;class kt extends It{constructor(t={}){var e,i;super(),this.uid=st("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new N,this.relativeGroupTransform=new N,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new ct(this,0,0),this._scale=Cs,this._pivot=Xe,this._origin=Ye,this._skew=vs,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=[],Sa(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(n=>this.addChild(n)),(i=t.parent)==null||i.addChild(this)}static mixin(t){H("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),nt.mixin(kt,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||H(et,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let n=0;n<t.length;n++)this.addChild(t[n]);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=!0),e):(e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,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 n=0;n<t.length;n++)this.removeChild(t[n]);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=!0,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==null||t.removeChild(this),this.renderGroup=yt.get(wa,this),this.groupTransform=N.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),yt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new N),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*$o}set angle(t){this.rotation=t*Do}get pivot(){return this._pivot===Xe&&(this._pivot=new ct(this,0,0)),this._pivot}set pivot(t){this._pivot===Xe&&(this._pivot=new ct(this,0,0),this._origin!==Ye&&mt("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===vs&&(this._skew=new ct(this,0,0)),this._skew}set skew(t){this._skew===vs&&(this._skew=new ct(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Cs&&(this._scale=new ct(this,1,1)),this._scale}set scale(t){this._scale===Cs&&(this._scale=new ct(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===Ye&&(this._origin=new ct(this,0,0)),this._origin}set origin(t){this._origin===Ye&&(this._origin=new ct(this,0,0),this._pivot!==Xe&&mt("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:this.scale.x,typeof t.scaleY=="number"?t.scaleY: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,n=this._pivot,r=this._origin,o=this._position,a=i._x,h=i._y,l=n._x,c=n._y,u=-r._x,f=-r._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|=Ki,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const i=J.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=Ki,this._onUpdate())}get tint(){return ss(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=va,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=!0),this._updateFlags|=Ts,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",t))}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Ts,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|=Ts,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var n;if(this.destroyed)return;this.destroyed=!0;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==null?void 0:t.children)&&e)for(let r=0;r<e.length;++r)e[r].destroy(t);(n=this.renderGroup)==null||n.destroy(),this.renderGroup=null}}nt.mixin(kt,ra,ua,ya,ga,pa,ha,la,ma,ta,ia,da,oa);class yi extends kt{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new St(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=t.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,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:n}=t;return i>=e.minX&&i<=e.maxX&&n>=e.minY&&n<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||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:n}=e;n.blendMode.pushBlendMode(this,this.groupBlendMode,t);const o=n[this.renderPipeId];o!=null&&o.addRenderable&&o.addRenderable(this,t),this.didViewUpdate=!1;const a=this.children,h=a.length;for(let l=0;l<h;l++)a[l].collectRenderables(t,e,i);n.blendMode.popBlendMode(t)}}class Re extends yi{constructor(t=q.EMPTY){t instanceof q&&(t={texture:t});const{texture:e=q.EMPTY,anchor:i,roundPixels:n,width:r,height:o,...a}=t;super({label:"Sprite",...a}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new ct({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=n??!1,r!==void 0&&(this.width=r),o!==void 0&&(this.height=o)}static from(t,e=!1){return t instanceof q?new Re(t):new Re(q.from(t,e))}set texture(t){t||(t=q.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 er(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return H("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:n,height:r}=e.orig;i.minX=-t._x*n,i.maxX=i.minX+n,i.minY=-t._y*r,i.maxY=i.minY+r}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0: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 Ca=new St;function ur(s,t,e){const i=Ca;s.measurable=!0,rr(s,e,i),t.addBoundsMask(i),s.measurable=!1}function dr(s,t,e){const i=Gt.get();s.measurable=!0;const n=gt.get().identity(),r=fr(s,e,n);hr(s,i,r),s.measurable=!1,t.addBoundsMask(i),gt.return(n),Gt.return(i)}function fr(s,t,e){return s?(s!==t&&(fr(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(mt("Mask bounds, renderable is not inside the root container"),e)}class pr{constructor(t){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Re),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(t,e){this.inverse||ur(this.mask,t,e)}addLocalBounds(t,e){dr(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof Re}}pr.extension=z.MaskEffect;class gr{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}gr.extension=z.MaskEffect;class mr{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,e){ur(this.mask,t,e)}addLocalBounds(t,e){dr(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof kt}}mr.extension=z.MaskEffect;const Ta={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 Zi=Ta;const ot={get(){return Zi},set(s){Zi=s}};class xr extends vt{constructor(t){t.resource||(t.resource=ot.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 n=super.resize(t,e,i);return n&&this.resizeCanvas(),n}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"))}}xr.extension=z.TextureSource;class rs extends vt{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}rs.extension=z.TextureSource;var os=(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))(os||{});class Ms{constructor(t,e=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=n}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const yr=class _t{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Ms(null,null,1/0),this.deltaMS=1/_t.targetFPMS,this.elapsedMS=1/_t.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=os.NORMAL){return this._addListener(new Ms(t,e,i))}addOnce(t,e,i=os.NORMAL){return this._addListener(new Ms(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const r=t-this._lastFrame|0;if(r<this._minElapsedMS)return;this._lastFrame=t-r%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*_t.targetFPMS;const i=this._head;let n=i.next;for(;n;)n=n.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(Math.max(0,t)/1e3,_t.targetFPMS);this._maxElapsedMS=1/e,this._minElapsedMS&&t>this.maxFPS&&(this.maxFPS=t)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){t===0?this._minElapsedMS=0:(t<this.minFPS&&(this.minFPS=t),this._minElapsedMS=1/(t/1e3))}static get shared(){if(!_t._shared){const t=_t._shared=new _t;t.autoStart=!0,t._protected=!0}return _t._shared}static get system(){if(!_t._system){const t=_t._system=new _t;t.autoStart=!0,t._protected=!0}return _t._system}};yr.targetFPMS=.06;let ce=yr,As;async function Ma(){return As??(As=(async()=>{var o;const t=ot.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(a=>{const h=document.createElement("video");h.onloadeddata=()=>a(h),h.onerror=()=>a(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const r=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,r),t.deleteFramebuffer(n),t.deleteTexture(i),(o=t.getExtension("WEBGL_lose_context"))==null||o.loseContext(),r[0]<=r[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),As}const ds=class _r extends vt{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={..._r.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,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),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=ce.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=!0),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,!0)),this.isValid||t.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await Ma(),this._load=new Promise((i,n)=>{this.isValid?i(this):(this._resolve=i,this._reject=n,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,!0),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._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&this.isValid&&(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("loadedmetadata",this._onLoadedMetadata),t.removeEventListener("error",this._onError,!0),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&&(ce.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,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||(ce.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ce.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};ds.extension=z.TextureSource;ds.defaultOptions={...vt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};ds.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Aa=ds;const ae=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s);class Pa{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||mt(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=ae(t);let n;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.test(e)){n=l.getCacheableAssets(i,e);break}}const r=new Map(Object.entries(n||{}));n||i.forEach(h=>{r.set(h,e)});const o=[...r.keys()],a={cacheKeys:o,keys:i};i.forEach(h=>{this._cacheMap.set(h,a)}),o.forEach(h=>{const l=n?n[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&mt("[Cache] already has key:",h),this._cache.set(h,r.get(h))})}remove(t){if(!this._cacheMap.has(t)){mt(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(n=>{this._cache.delete(n)}),e.keys.forEach(n=>{this._cacheMap.delete(n)})}get parsers(){return this._parsers}}const he=new Pa,Js=[];nt.handleByList(z.TextureSource,Js);function br(s={}){const t=s&&s.resource,e=t?s.resource:s,i=t?s:{resource:s};for(let n=0;n<Js.length;n++){const r=Js[n];if(r.test(e))return new r(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function ka(s={},t=!1){const e=s&&s.resource,i=e?s.resource:s,n=e?s:{resource:s};if(!t&&he.has(i))return he.get(i);const r=new q({source:br(n)});return r.on("destroy",()=>{he.has(i)&&he.remove(i)}),t||he.set(i,r),r}function Ia(s,t=!1){return typeof s=="string"?he.get(s):s instanceof vt?new q({source:s}):ka(s,t)}q.from=Ia;vt.from=br;nt.add(pr,gr,mr,Aa,rs,xr,gi);var wr=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(wr||{});function Tt(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function xe(s){return s.split("?")[0].split("#")[0]}function Ra(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ea(s,t,e){return s.replace(new RegExp(Ra(t),"g"),e)}function Ba(s,t){let e="",i=0,n=-1,r=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(!(n===a-1||r===1))if(n!==a-1&&r===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("/")),n=a,r=0;continue}}else if(e.length===2||e.length===1){e="",i=0,n=a,r=0;continue}}}else e.length>0?e+=`/${s.slice(n+1,a)}`:e=s.slice(n+1,a),i=a-n-1;n=a,r=0}else o===46&&r!==-1?++r:r=-1}return e}const Ee={toPosix(s){return Ea(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){Tt(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(Tt(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=xe(this.toPosix(t??ot.get().getBaseUrl())),n=xe(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?Ee.join(n,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(Tt(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=Ba(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return Tt(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e<s.length;++e){const i=s[e];if(Tt(i),i.length>0)if(t===void 0)t=i;else{const n=s[e-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(Tt(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,n=!0;const r=this.getProtocol(s),o=s;s=s.slice(r.length);for(let a=s.length-1;a>=1;--a)if(t=s.charCodeAt(a),t===47){if(!n){i=a;break}}else n=!1;return i===-1?e?"/":this.isUrl(o)?r+s:r:e&&i===1?"//":r+s.slice(0,i)},rootname(s){Tt(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){Tt(s),t&&Tt(t),s=xe(this.toPosix(s));let e=0,i=-1,n=!0,r;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(r=s.length-1;r>=0;--r){const h=s.charCodeAt(r);if(h===47){if(!n){e=r+1;break}}else a===-1&&(n=!1,a=r+1),o>=0&&(h===t.charCodeAt(o)?--o===-1&&(i=r):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=s.length),s.slice(e,i)}for(r=s.length-1;r>=0;--r)if(s.charCodeAt(r)===47){if(!n){e=r+1;break}}else i===-1&&(n=!1,i=r+1);return i===-1?"":s.slice(e,i)},extname(s){Tt(s),s=xe(this.toPosix(s));let t=-1,e=0,i=-1,n=!0,r=0;for(let o=s.length-1;o>=0;--o){const a=s.charCodeAt(o);if(a===47){if(!n){e=o+1;break}continue}i===-1&&(n=!1,i=o+1),a===46?t===-1?t=o:r!==1&&(r=1):t!==-1&&(r=-1)}return t===-1||i===-1||r===0||r===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){Tt(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=xe(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let n;t.root=this.rootname(s),i||this.hasProtocol(s)?n=1:n=0;let r=-1,o=0,a=-1,h=!0,l=s.length-1,c=0;for(;l>=n;--l){if(e=s.charCodeAt(l),e===47){if(!h){o=l+1;break}continue}a===-1&&(h=!1,a=l+1),e===46?r===-1?r=l:c!==1&&(c=1):r!==-1&&(c=-1)}return r===-1||a===-1||c===0||c===1&&r===a-1&&r===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,r),t.base=s.slice(1,a)):(t.name=s.slice(o,r),t.base=s.slice(o,a)),t.ext=s.slice(r,a)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function Sr(s,t,e,i,n){const r=t[e];for(let o=0;o<r.length;o++){const a=r[o];e<t.length-1?Sr(s.replace(i[e],a),t,e+1,i,n):n.push(s.replace(i[e],a))}}function Fa(s){const t=/\{(.*?)\}/g,e=s.match(t),i=[];if(e){const n=[];e.forEach(r=>{const o=r.substring(1,r.length-1).split(",");n.push(o)}),Sr(s,n,0,e,i)}else i.push(s);return i}const Qi=s=>!Array.isArray(s);class vr{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 ae(e||i,r=>typeof r=="string"?r:Array.isArray(r)?r.map(o=>(o==null?void 0:o.src)??o):r!=null&&r.src?r.src:r,!0)}removeAlias(t,e){this._assetMap[t]&&(e&&e!==this._resolverHash[t]||(delete this._resolverHash[t],delete this._assetMap[t]))}addManifest(t){this._manifest&&mt("[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 n=e;Array.isArray(e)||(n=Object.entries(e).map(([r,o])=>typeof o=="string"||Array.isArray(o)?{alias:r,src:o}:{alias:r,...o})),n.forEach(r=>{const o=r.src,a=r.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({...r,alias:h,src:o})}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=r=>{this.hasKey(r)&&mt(`[Resolver] already has key: ${r} overwriting`)},ae(e).forEach(r=>{const{src:o}=r;let{data:a,format:h,loadParser:l,parser:c}=r;const u=ae(o).map(m=>typeof m=="string"?Fa(m):Array.isArray(m)?m:[m]),f=this.getAlias(r);Array.isArray(f)?f.forEach(i):i(f);const d=[],p=m=>{const g=this._parsers.find(x=>x.test(m));return{src:m,...g==null?void 0:g.parse(m)}};u.forEach(m=>{m.forEach(g=>{let x={};if(typeof g!="object"?x=p(g):(a=g.data??a,h=g.format??h,(g.loadParser||g.parser)&&(l=g.loadParser??l,c=g.parser??c),x={...p(g.src),...g}),!f)throw new Error(`[Resolver] alias is undefined for this asset: ${x.src}`);x=this._buildResolvedAsset(x,{aliases:f,data:a,format:h,loadParser:l,parser:c,progressSize:r.progressSize}),d.push(x)})}),f.forEach(m=>{this._assetMap[m]=d})})}resolveBundle(t){const e=Qi(t);t=ae(t);const i={};return t.forEach(n=>{const r=this._bundles[n];if(r){const o=this.resolve(r),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(n,h)]=l}i[n]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const n in e)i[n]=e[n].src;return i}return e.src}resolve(t){const e=Qi(t);t=ae(t);const i={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let r=this._assetMap[n];const o=this._getPreferredOrder(r);o==null||o.priority.forEach(a=>{o.params[a].forEach(h=>{const l=r.filter(c=>c[a]?c[a]===h:!1);l.length&&(r=l)})}),this._resolverHash[n]=r[0]}else this._resolverHash[n]=this._buildResolvedAsset({alias:[n],src:n},{});i[n]=this._resolverHash[n]}),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],n=this._preferredOrder.find(r=>r.params.format.includes(i.format));if(n)return n}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:n,loadParser:r,parser:o,format:a,progressSize:h}=e;return(this._basePath||this._rootPath)&&(t.src=Ee.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=r??t.loadParser,t.parser=o??t.parser,t.format=a??t.format??La(t.src),h!==void 0&&(t.progressSize=h),t}}vr.RETINA_PREFIX=/@([0-9\.]+)x/;function La(s){return s.split(".").pop().split("?").shift().split("#").shift()}const Ji=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s},Cr=class Ce{constructor(t,e){this.linkedSheets=[];let i=t;(t==null?void 0:t.source)instanceof vt&&(i={texture:t,data:e});const{texture:n,data:r,cachePrefix:o=""}=i;this.cachePrefix=o,this._texture=n instanceof q?n:null,this.textureSource=n.source,this.textures={},this.animations={},this.data=r;const a=parseFloat(r.meta.scale);a?(this.resolution=a,n.source.resolution=this.resolution):this.resolution=n.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<=Ce.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,e=!1){let i=t;const n=e?1/0:Ce.BATCH_SIZE;for(;i-t<n&&i<this._frameKeys.length;){const r=this._frameKeys[i],o=this._frames[r],a=o.frame;if(a){let h=null,l=null;const c=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,u=new it(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);o.rotated?h=new it(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):h=new it(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),o.trimmed!==!1&&o.spriteSourceSize&&(l=new it(Math.floor(o.spriteSourceSize.x)/this.resolution,Math.floor(o.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[r]=new q({source:this.textureSource,frame:h,orig:u,trim:l,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:r.toString()})}i++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const n=t[e][i];this.animations[e].push(this.textures[n])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Ce.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Ce.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};Cr.BATCH_SIZE=1e3;let tn=Cr;const Ga=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Tr(s,t,e){const i={};if(s.forEach(n=>{i[n]=t}),Object.keys(t.textures).forEach(n=>{i[`${t.cachePrefix}${n}`]=t.textures[n]}),!e){const n=Ee.dirname(s[0]);t.linkedSheets.forEach((r,o)=>{const a=Tr([`${n}/${t.data.meta.related_multi_packs[o]}`],r,!0);Object.assign(i,a)})}return i}const $a={extension:z.Asset,cache:{test:s=>s instanceof tn,getCacheableAssets:(s,t)=>Tr(s,t,!1)},resolver:{extension:{type:z.ResolveParser,name:"resolveSpritesheet"},test:s=>{const e=s.split("?")[0].split("."),i=e.pop(),n=e.pop();return i==="json"&&Ga.includes(n)},parse:s=>{var e;const t=s.split(".");return{resolution:parseFloat(((e=vr.RETINA_PREFIX.exec(s))==null?void 0:e[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:z.LoadParser,priority:wr.Normal,name:"spritesheetLoader"},async testParse(s,t){return Ee.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){var u,f;const{texture:i,imageFilename:n,textureOptions:r,cachePrefix:o}=(t==null?void 0:t.data)??{};let a=Ee.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let h;if(i instanceof q)h=i;else{const d=Ji(a+(n??s.meta.image),t.src);h=(await e.load([{src:d,data:r}]))[d]}const l=new tn({texture:h.source,data:s,cachePrefix:o});await l.parse();const c=(u=s==null?void 0:s.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(c)){const d=[];for(const m of c){if(typeof m!="string")continue;let g=a+m;(f=t.data)!=null&&f.ignoreMultiPack||(g=Ji(g,t.src),d.push(e.load({src:g,data:{textureOptions:r,ignoreMultiPack:!0}})))}const p=await Promise.all(d);l.linkedSheets=p,p.forEach(m=>{m.linkedSheets=[l].concat(l.linkedSheets.filter(g=>g!==m))})}return l},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};nt.add($a);const Ps=Object.create(null),en=Object.create(null);function _i(s,t){let e=en[s];return e===void 0&&(Ps[t]===void 0&&(Ps[t]=1),en[s]=e=Ps[t]++),e}let se;function Mr(){return(!se||se!=null&&se.isContextLost())&&(se=ot.get().createCanvas().getContext("webgl",{})),se}let je;function Da(){if(!je){je="mediump";const s=Mr();s&&s.getShaderPrecisionFormat&&(je=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return je}function za(s,t,e){return t?s:e?(s=s.replace("out vec4 finalColor;",""),`
|
|
6
|
+
|
|
7
|
+
#ifdef GL_ES // This checks if it is WebGL1
|
|
8
|
+
#define in varying
|
|
9
|
+
#define finalColor gl_FragColor
|
|
10
|
+
#define texture texture2D
|
|
11
|
+
#endif
|
|
12
|
+
${s}
|
|
13
|
+
`):`
|
|
14
|
+
|
|
15
|
+
#ifdef GL_ES // This checks if it is WebGL1
|
|
16
|
+
#define in attribute
|
|
17
|
+
#define out varying
|
|
18
|
+
#endif
|
|
19
|
+
${s}
|
|
20
|
+
`}function Oa(s,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let n=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return n==="highp"&&i!=="highp"&&(n="mediump"),`precision ${n} float;
|
|
21
|
+
${s}`}else if(i!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function Wa(s,t){return t?`#version 300 es
|
|
22
|
+
${s}`:s}const Ua={},Na={};function Ha(s,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?Ua:Na;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`}
|
|
23
|
+
${s}`}function Va(s,t){return t?s.replace("#version 300 es",""):s}const ks={stripVersion:Va,ensurePrecision:Oa,addProgramDefines:za,setProgramName:Ha,insertVersion:Wa},ye=Object.create(null),Ar=class ti{constructor(t){t={...ti.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Da()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,r=t.vertex;Object.keys(ks).forEach(o=>{const a=i[o];n=ks[o](n,a,!0),r=ks[o](r,a,!1)}),this.fragment=n,this.vertex=r,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=_i(`${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,ye[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return ye[e]||(ye[e]=new ti(t),ye[e]._cacheKey=e),ye[e]}};Ar.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Pr=Ar;const sn={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function Xa(s){return sn[s]??sn.float32}const Ya={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",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"},nn=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function rn(s,t){let e;for(;(e=nn.exec(s))!==null;){const i=Ya[e[3]]??"float32";t[e[2]]={location:parseInt(e[1],10),format:i,stride:Xa(i).stride,offset:0,instance:!1,start:0}}nn.lastIndex=0}function ja(s){return s.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function qa({source:s,entryPoint:t}){const e={},i=ja(s),n=i.indexOf(`fn ${t}(`);if(n===-1)return e;const r=i.indexOf("->",n);if(r===-1)return e;const o=i.substring(n,r);if(rn(o,e),Object.keys(e).length===0){const a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){const h=a[1],l=new RegExp(`struct\\s+${h}\\s*\\{([^}]+)\\}`,"s"),c=i.match(l);c&&rn(c[1],e)}}return e}function Is(s){var u,f;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,r=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(u=s.match(t))==null?void 0:u.map(d=>({group:parseInt(d.match(e)[1],10),binding:parseInt(d.match(i)[1],10),name:d.match(n)[2],isUniform:d.match(n)[1]==="<uniform>",type:d.match(r)[1]}));if(!l)return{groups:[],structs:[]};const c=((f=s.match(o))==null?void 0:f.map(d=>{const p=d.match(h)[1],m=d.match(a).reduce((g,x)=>{const[y,_]=x.split(":");return g[y.trim()]=_.trim(),g},{});return m?{name:p,members:m}:null}).filter(({name:d})=>l.some(p=>p.type===d||p.type.includes(`<${d}>`))))??[];return{groups:l,structs:c}}var Qt=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(Qt||{});function Ka({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:Qt.VERTEX|Qt.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:Qt.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"||i.type.startsWith("texture_2d<")?t[i.group].push({binding:i.binding,visibility:Qt.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):i.type==="texture_2d_array"||i.type.startsWith("texture_2d_array<")?t[i.group].push({binding:i.binding,visibility:Qt.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(i.type==="texture_cube"||i.type.startsWith("texture_cube<"))&&t[i.group].push({binding:i.binding,visibility:Qt.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let e=0;e<t.length;e++)t[e]||(t[e]=[]);return t}function Za({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 Qa(s,t){const e=new Set,i=new Set,n=[...s.structs,...t.structs].filter(o=>e.has(o.name)?!1:(e.add(o.name),!0)),r=[...s.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:n,groups:r}}const _e=Object.create(null);class fs{constructor(t){var a,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:n,gpuLayout:r,name:o}=t;if(this.name=o,this.fragment=e,this.vertex=i,e.source===i.source){const l=Is(e.source);this.structsAndGroups=l}else{const l=Is(i.source),c=Is(e.source);this.structsAndGroups=Qa(l,c)}this.layout=n??Za(this.structsAndGroups),this.gpuLayout=r??Ka(this.structsAndGroups),this.autoAssignGlobalUniforms=((a=this.layout[0])==null?void 0:a.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=_i(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=qa(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,_e[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return _e[e]||(_e[e]=new fs(t),_e[e]._cacheKey=e),_e[e]}}const kr=["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>"],Ja=kr.reduce((s,t)=>(s[t]=!0,s),{});function th(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 Ir=class Rr{constructor(t,e){this._touched=0,this.uid=st("uniform"),this._resourceType="uniformGroup",this._resourceId=st("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...Rr.defaultOptions,...e},this.uniformStructures=t;const i={};for(const n in t){const r=t[n];if(r.name=n,r.size=r.size??1,!Ja[r.type]){const o=r.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,h]=o;throw new Error(`Uniform type ${r.type} is not supported. Use type: '${a}', size: ${h} instead.`)}throw new Error(`Uniform type ${r.type} is not supported. Supported uniform types are: ${kr.join(", ")}`)}r.value??(r.value=th(r.type,r.size)),i[n]=r.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=_i(Object.keys(i).map(n=>`${n}-${t[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Ir.defaultOptions={ubo:!1,isStatic:!1};let Er=Ir;class is{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const n=t[i];this.setResource(n,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var n,r;const i=this.resources[e];t!==i&&((n=i==null?void 0:i.off)==null||n.call(i,"change",this.onResourceChange,this),(r=t.on)==null||r.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t,e){const i=this.resources;for(const n in i)i[n]._gcLastUsed=t,i[n]._touched=e}destroy(){var e;const t=this.resources;for(const i in t){const n=t[i];(e=n==null?void 0:n.off)==null||e.call(n,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){this._dirty=!0,t.destroyed?this.destroy():this._updateKey()}}var ei=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.CANVAS=4]="CANVAS",s[s.BOTH=3]="BOTH",s))(ei||{});class bi extends It{constructor(t){super(),this.uid=st("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:i,groups:n,resources:r,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=i,o===void 0&&(o=0,e&&(o|=ei.WEBGPU),i&&(o|=ei.WEBGL)),this.compatibleRenderers=o;const h={};if(!r&&!n&&(r={}),r&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&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&&n&&!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(r){n={},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 r)h[c]||(n[99]||(n[99]=new is,this._ownedBindGroups.push(n[99])),h[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++);for(const c in r){const u=c;let f=r[c];!f.source&&!f._resourceType&&(f=new Er(f));const d=h[u];d&&(n[d.group]||(n[d.group]=new is,this._ownedBindGroups.push(n[d.group])),n[d.group].setResource(f,d.binding))}}this.groups=n,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(n,h)}addResource(t,e,i){var n,r;(n=this._uniformBindMap)[e]||(n[e]={}),(r=this._uniformBindMap[e])[i]||(r[i]=t),this.groups[e]||(this.groups[e]=new is,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const n in e){const r=e[n];Object.defineProperty(i,r.name,{get(){return t[r.group].getResource(r.binding)},set(o){t[r.group].setResource(o,r.binding)}})}return i}destroy(t=!1){var e,i;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(n=>{n.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const{gpu:e,gl:i,...n}=t;let r,o;return e&&(r=fs.from(e)),i&&(o=Pr.from(i)),new bi({gpuProgram:r,glProgram:o,...n})}}const eh={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},Rs=0,Es=1,Bs=2,Fs=3,Ls=4,Gs=5,si=class Br{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Rs)}set blend(t){!!(this.data&1<<Rs)!==t&&(this.data^=1<<Rs)}get offsets(){return!!(this.data&1<<Es)}set offsets(t){!!(this.data&1<<Es)!==t&&(this.data^=1<<Es)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<Bs)}set culling(t){!!(this.data&1<<Bs)!==t&&(this.data^=1<<Bs)}get depthTest(){return!!(this.data&1<<Fs)}set depthTest(t){!!(this.data&1<<Fs)!==t&&(this.data^=1<<Fs)}get depthMask(){return!!(this.data&1<<Gs)}set depthMask(t){!!(this.data&1<<Gs)!==t&&(this.data^=1<<Gs)}get clockwiseFrontFace(){return!!(this.data&1<<Ls)}set clockwiseFrontFace(t){!!(this.data&1<<Ls)!==t&&(this.data^=1<<Ls)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=eh[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 Br;return t.depthTest=!1,t.blend=!0,t}};si.default2d=si.for2d();let Fr=si;const ii=[];nt.handleByNamedList(z.Environment,ii);async function sh(s){if(!s)for(let t=0;t<ii.length;t++){const e=ii[t];if(e.value.test()){await e.value.load();return}}}let be;function ih(){if(typeof be=="boolean")return be;try{be=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{be=!1}return be}function on(s,t,e=2){const i=t&&t.length,n=i?t[0]*e:s.length;let r=Lr(s,0,n,e,!0);const o=[];if(!r||r.next===r.prev)return o;let a,h,l;if(i&&(r=hh(s,t,r,e)),s.length>80*e){a=s[0],h=s[1];let c=a,u=h;for(let f=e;f<n;f+=e){const d=s[f],p=s[f+1];d<a&&(a=d),p<h&&(h=p),d>c&&(c=d),p>u&&(u=p)}l=Math.max(c-a,u-h),l=l!==0?32767/l:0}return Be(r,o,e,a,h,l,0),o}function Lr(s,t,e,i,n){let r;if(n===_h(s,t,e,i)>0)for(let o=t;o<e;o+=i)r=an(o/i|0,s[o],s[o+1],r);else for(let o=e-i;o>=t;o-=i)r=an(o/i|0,s[o],s[o+1],r);return r&&ge(r,r.next)&&(Le(r),r=r.next),r}function ee(s,t){if(!s)return s;t||(t=s);let e=s,i;do if(i=!1,!e.steiner&&(ge(e,e.next)||Q(e.prev,e,e.next)===0)){if(Le(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Be(s,t,e,i,n,r,o){if(!s)return;!o&&r&&fh(s,i,n,r);let a=s;for(;s.prev!==s.next;){const h=s.prev,l=s.next;if(r?rh(s,i,n,r):nh(s)){t.push(h.i,s.i,l.i),Le(s),s=l.next,a=l.next;continue}if(s=l,s===a){o?o===1?(s=oh(ee(s),t),Be(s,t,e,i,n,r,2)):o===2&&ah(s,t,e,i,n,r):Be(ee(s),t,e,i,n,r,1);break}}}function nh(s){const t=s.prev,e=s,i=s.next;if(Q(t,e,i)>=0)return!1;const n=t.x,r=e.x,o=i.x,a=t.y,h=e.y,l=i.y,c=Math.min(n,r,o),u=Math.min(a,h,l),f=Math.max(n,r,o),d=Math.max(a,h,l);let p=i.next;for(;p!==t;){if(p.x>=c&&p.x<=f&&p.y>=u&&p.y<=d&&Te(n,a,r,h,o,l,p.x,p.y)&&Q(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function rh(s,t,e,i){const n=s.prev,r=s,o=s.next;if(Q(n,r,o)>=0)return!1;const a=n.x,h=r.x,l=o.x,c=n.y,u=r.y,f=o.y,d=Math.min(a,h,l),p=Math.min(c,u,f),m=Math.max(a,h,l),g=Math.max(c,u,f),x=ni(d,p,t,e,i),y=ni(m,g,t,e,i);let _=s.prevZ,b=s.nextZ;for(;_&&_.z>=x&&b&&b.z<=y;){if(_.x>=d&&_.x<=m&&_.y>=p&&_.y<=g&&_!==n&&_!==o&&Te(a,c,h,u,l,f,_.x,_.y)&&Q(_.prev,_,_.next)>=0||(_=_.prevZ,b.x>=d&&b.x<=m&&b.y>=p&&b.y<=g&&b!==n&&b!==o&&Te(a,c,h,u,l,f,b.x,b.y)&&Q(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;_&&_.z>=x;){if(_.x>=d&&_.x<=m&&_.y>=p&&_.y<=g&&_!==n&&_!==o&&Te(a,c,h,u,l,f,_.x,_.y)&&Q(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;b&&b.z<=y;){if(b.x>=d&&b.x<=m&&b.y>=p&&b.y<=g&&b!==n&&b!==o&&Te(a,c,h,u,l,f,b.x,b.y)&&Q(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function oh(s,t){let e=s;do{const i=e.prev,n=e.next.next;!ge(i,n)&&$r(i,e,e.next,n)&&Fe(i,n)&&Fe(n,i)&&(t.push(i.i,e.i,n.i),Le(e),Le(e.next),e=s=n),e=e.next}while(e!==s);return ee(e)}function ah(s,t,e,i,n,r){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&mh(o,a)){let h=Dr(o,a);o=ee(o,o.next),h=ee(h,h.next),Be(o,t,e,i,n,r,0),Be(h,t,e,i,n,r,0);return}a=a.next}o=o.next}while(o!==s)}function hh(s,t,e,i){const n=[];for(let r=0,o=t.length;r<o;r++){const a=t[r]*i,h=r<o-1?t[r+1]*i:s.length,l=Lr(s,a,h,i,!1);l===l.next&&(l.steiner=!0),n.push(gh(l))}n.sort(lh);for(let r=0;r<n.length;r++)e=ch(n[r],e);return e}function lh(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),n=(t.next.y-t.y)/(t.next.x-t.x);e=i-n}return e}function ch(s,t){const e=uh(s,t);if(!e)return t;const i=Dr(e,s);return ee(i,i.next),ee(e,e.next)}function uh(s,t){let e=t;const i=s.x,n=s.y;let r=-1/0,o;if(ge(s,e))return e;do{if(ge(s,e.next))return e.next;if(n<=e.y&&n>=e.next.y&&e.next.y!==e.y){const u=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(u<=i&&u>r&&(r=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&&Gr(n<l?i:r,n,h,l,n<l?r:i,n,e.x,e.y)){const u=Math.abs(n-e.y)/(i-e.x);Fe(e,s)&&(u<c||u===c&&(e.x>o.x||e.x===o.x&&dh(o,e)))&&(o=e,c=u)}e=e.next}while(e!==a);return o}function dh(s,t){return Q(s.prev,s,t.prev)<0&&Q(t.next,s,s.next)<0}function fh(s,t,e,i){let n=s;do n.z===0&&(n.z=ni(n.x,n.y,t,e,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==s);n.prevZ.nextZ=null,n.prevZ=null,ph(n)}function ph(s){let t,e=1;do{let i=s,n;s=null;let r=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)?(n=i,i=i.nextZ,a--):(n=o,o=o.nextZ,h--),r?r.nextZ=n:s=n,n.prevZ=r,r=n;i=o}r.nextZ=null,e*=2}while(t>1);return s}function ni(s,t,e,i,n){return s=(s-e)*n|0,t=(t-i)*n|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 gh(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 Gr(s,t,e,i,n,r,o,a){return(n-o)*(t-a)>=(s-o)*(r-a)&&(s-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(r-a)>=(n-o)*(i-a)}function Te(s,t,e,i,n,r,o,a){return!(s===o&&t===a)&&Gr(s,t,e,i,n,r,o,a)}function mh(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!xh(s,t)&&(Fe(s,t)&&Fe(t,s)&&yh(s,t)&&(Q(s.prev,s,t.prev)||Q(s,t.prev,t))||ge(s,t)&&Q(s.prev,s,s.next)>0&&Q(t.prev,t,t.next)>0)}function Q(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function ge(s,t){return s.x===t.x&&s.y===t.y}function $r(s,t,e,i){const n=Ke(Q(s,t,e)),r=Ke(Q(s,t,i)),o=Ke(Q(e,i,s)),a=Ke(Q(e,i,t));return!!(n!==r&&o!==a||n===0&&qe(s,e,t)||r===0&&qe(s,i,t)||o===0&&qe(e,s,i)||a===0&&qe(e,t,i))}function qe(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 Ke(s){return s>0?1:s<0?-1:0}function xh(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&&$r(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function Fe(s,t){return Q(s.prev,s,s.next)<0?Q(s,t,s.next)>=0&&Q(s,s.prev,t)>=0:Q(s,t,s.prev)<0||Q(s,s.next,t)<0}function yh(s,t){let e=s,i=!1;const n=(s.x+t.x)/2,r=(s.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&n<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==s);return i}function Dr(s,t){const e=ri(s.i,s.x,s.y),i=ri(t.i,t.x,t.y),n=s.next,r=t.prev;return s.next=t,t.prev=s,e.next=n,n.prev=e,i.next=e,e.prev=i,r.next=i,i.prev=r,i}function an(s,t,e,i){const n=ri(s,t,e);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function Le(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 ri(s,t,e){return{i:s,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function _h(s,t,e,i){let n=0;for(let r=t,o=e-i;r<e;r+=i)n+=(s[o]-s[r])*(s[r+1]+s[o+1]),o=r;return n}const bh=on.default||on;var zr=(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))(zr||{});class wh{constructor(t){this.items=[],this._name=t}emit(t,e,i,n,r,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,n,r,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 Sh=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Or=class Wr extends It{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=[...Sh,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await sh(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={...Wr.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 kt&&(i={container:i},e&&(H(et,"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 n=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=n?i.clearColor:J.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 n=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!==n&&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=zr.ALL);const{clear:i,clearColor:n,target:r,mipLevel:o,layer:a}=t;J.shared.setValue(n??this.background.colorRgba),e.renderTarget.clear(r,i,J.shared.toArray(),o??0,a??0)}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 wh(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 n in this.runners)this.runners[n].add(i);return this}_addPipes(t,e){const i=e.reduce((n,r)=>(n[r.name]=r.value,n),{});t.forEach(n=>{const r=n.value,o=n.name,a=i[o];this.renderPipes[o]=new r(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&Oe.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!ih())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()}};Or.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Ur=Or,Ze;function vh(s){return Ze!==void 0||(Ze=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:s??Ur.defaultOptions.failIfMajorPerformanceCaveat};try{if(!ot.get().getWebGLRenderingContext())return!1;let n=ot.get().createCanvas().getContext("webgl",t);const r=!!((e=n==null?void 0:n.getContextAttributes())!=null&&e.stencil);if(n){const o=n.getExtension("WEBGL_lose_context");o&&o.loseContext()}return n=null,r}catch{return!1}})()),Ze}let Qe;async function Ch(s={}){return Qe!==void 0||(Qe=await(async()=>{const t=ot.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),Qe}const hn=["webgl","webgpu","canvas"];async function Th(s){let t=[];s.preference?Array.isArray(s.preference)?t=s.preference.slice():(t.push(s.preference),hn.forEach(r=>{r!==s.preference&&t.push(r)})):t=hn.slice();let e,i={};for(let r=0;r<t.length;r++){const o=t[r];if(o==="webgpu"&&await Ch()){const{WebGPURenderer:a}=await Me(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer-DkU0IC2y.js");return{WebGPURenderer:h}},__vite__mapDeps([3,4,5,2]));e=a,i={...s,...s.webgpu};break}else if(o==="webgl"&&vh(s.failIfMajorPerformanceCaveat??Ur.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await Me(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-DyKdZImF.js");return{WebGLRenderer:h}},__vite__mapDeps([6,4,5,2]));e=a,i={...s,...s.webgl};break}else if(o==="canvas"){const{CanvasRenderer:a}=await Me(async()=>{const{CanvasRenderer:h}=await import("./CanvasRenderer-fCJxZSuL.js");return{CanvasRenderer:h}},__vite__mapDeps([7,5,2]));e=a,i={...s,...s.canvasOptions};break}}if(delete i.webgpu,delete i.webgl,delete i.canvasOptions,!e)throw new Error("No available renderer for the current environment");const n=new e;return await n.init(i),n}const Nr="8.19.0";class Hr{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,Nr)}static destroy(){}}Hr.extension=z.Application;class Mh{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,Nr)}destroy(){this._renderer=null}}Mh.extension={type:[z.WebGLSystem,z.WebGPUSystem],name:"initHook",priority:-10};class Vr{static init(t){Object.defineProperty(this,"resizeTo",{configurable:!0,set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:n,clientHeight:r}=this._resizeTo;e=n,i=r}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Vr.extension=z.Application;class Xr{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{configurable:!0,set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,os.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?ce.shared:new ce,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Xr.extension=z.Application;nt.add(Vr);nt.add(Xr);const Yr=class oi{constructor(...t){this.stage=new kt,t[0]!==void 0&&H(et,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.stage||(this.stage=new kt),this.renderer=await Th(t),oi._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return H(et,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}get domContainerRoot(){var t;return(t=this.renderer.renderPipes.dom)==null?void 0:t._domElement}destroy(t=!1,e=!1){const i=oi._plugins.slice(0);i.reverse(),i.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Yr._plugins=[];let jr=Yr;nt.handleByList(z.Application,jr._plugins);nt.add(Hr);const $s={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Ah=/([astvzqmhlc])([^astvzqmhlc]*)/gi,Ph=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;function kh(s){const t=[];return s.replace(Ah,(e,i,n)=>{let r=i.toLowerCase(),o=i;const a=Ih(n);for(r==="m"&&a.length>2&&(t.push([o,...a.splice(0,2)]),r="l",o=o==="m"?"l":"L");;){if(a.length===$s[r])return t.push([o,...a]),"";if(a.length<$s[r])throw new Error("malformed path data");t.push([o,...a.splice(0,$s[r])])}}),t}function Ih(s){const t=s.match(Ph);return t?t.map(Number):[]}function Rh(s,t){const e=kh(s),i=[];let n=null,r=0,o=0;for(let a=0;a<e.length;a++){const h=e[a],l=h[0],c=h;switch(l){case"M":r=c[1],o=c[2],t.moveTo(r,o);break;case"m":r+=c[1],o+=c[2],t.moveTo(r,o);break;case"H":r=c[1],t.lineTo(r,o);break;case"h":r+=c[1],t.lineTo(r,o);break;case"V":o=c[1],t.lineTo(r,o);break;case"v":o+=c[1],t.lineTo(r,o);break;case"L":r=c[1],o=c[2],t.lineTo(r,o);break;case"l":r+=c[1],o+=c[2],t.lineTo(r,o);break;case"C":r=c[5],o=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],r,o);break;case"c":t.bezierCurveTo(r+c[1],o+c[2],r+c[3],o+c[4],r+c[5],o+c[6]),r+=c[5],o+=c[6];break;case"S":r=c[3],o=c[4],t.bezierCurveToShort(c[1],c[2],r,o);break;case"s":t.bezierCurveToShort(r+c[1],o+c[2],r+c[3],o+c[4]),r+=c[3],o+=c[4];break;case"Q":r=c[3],o=c[4],t.quadraticCurveTo(c[1],c[2],r,o);break;case"q":t.quadraticCurveTo(r+c[1],o+c[2],r+c[3],o+c[4]),r+=c[3],o+=c[4];break;case"T":r=c[1],o=c[2],t.quadraticCurveToShort(r,o);break;case"t":r+=c[1],o+=c[2],t.quadraticCurveToShort(r,o);break;case"A":r=c[6],o=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,o);break;case"a":r+=c[6],o+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,o);break;case"Z":case"z":t.closePath(),i.length>0&&(n=i.pop(),n?(r=n.startX,o=n.startY):(r=0,o=0)),n=null;break;default:mt(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&n===null&&(n={startX:r,startY:o},i.push(n))}return t}class wi{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new wi(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-t,r=this.y-e;return n*=n,r*=r,n+r<=i}strokeContains(t,e,i,n=.5){if(this.radius===0)return!1;const r=this.x-t,o=this.y-e,a=this.radius,h=(1-n)*i,l=Math.sqrt(r*r+o*o);return l<=a+h&&l>a-(i-h)}getBounds(t){return t||(t=new it),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 Si{constructor(t=0,e=0,i=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=n}clone(){return new Si(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,n=(e-this.y)/this.halfHeight;return i*=i,n*=n,i+n<=1}strokeContains(t,e,i,n=.5){const{halfWidth:r,halfHeight:o}=this;if(r<=0||o<=0)return!1;const a=i*(1-n),h=i-a,l=r-h,c=o-h,u=r+a,f=o+a,d=t-this.x,p=e-this.y,m=d*d/(l*l)+p*p/(c*c),g=d*d/(u*u)+p*p/(f*f);return m>1&&g<=1}getBounds(t){return t||(t=new it),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 Eh(s,t,e,i,n,r){const o=s-e,a=t-i,h=n-e,l=r-i,c=o*h+a*l,u=h*h+l*l;let f=-1;u!==0&&(f=c/u);let d,p;f<0?(d=e,p=i):f>1?(d=n,p=r):(d=e+f*h,p=i+f*l);const m=s-d,g=t-p;return m*m+g*g}let Bh,Fh;class Pe{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let n=0,r=e.length;n<r;n++)i.push(e[n].x,e[n].y);e=i}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,i=e.length;for(let n=0;n<i;n+=2){const r=e[n],o=e[n+1],a=e[(n+2)%i],h=e[(n+3)%i];t+=(a-r)*(h+o)}return t<0}containsPolygon(t){const e=this.getBounds(Bh),i=t.getBounds(Fh);if(!e.containsRect(i))return!1;const n=t.points;for(let r=0;r<n.length;r+=2){const o=n[r],a=n[r+1];if(!this.contains(o,a))return!1}return!0}clone(){const t=this.points.slice(),e=new Pe(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const n=this.points.length/2;for(let r=0,o=n-1;r<n;o=r++){const a=this.points[r*2],h=this.points[r*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,n=.5){const r=i*i,o=r*(1-n),a=r-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],p=h[(c+3)%h.length],m=Eh(t,e,u,f,d,p),g=Math.sign((d-u)*(e-f)-(p-f)*(t-u));if(m<=(g<0?a:o))return!0}return!1}getBounds(t){t||(t=new it);const e=this.points;let i=1/0,n=-1/0,r=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,n=l>n?l:n,r=c<r?c:r,o=c>o?c:o}return t.x=i,t.width=n-i,t.y=r,t.height=o-r,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 H("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return H("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 Je=(s,t,e,i,n,r,o)=>{const a=s-e,h=t-i,l=Math.sqrt(a*a+h*h);return l>=n-r&&l<=n+o};class vi{constructor(t=0,e=0,i=0,n=0,r=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=n,this.radius=r}getBounds(t){return t||(t=new it),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new vi(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!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let n=t-(this.x+i),r=e-(this.y+i);const o=i*i;if(n*n+r*r<=o||(n=t-(this.x+this.width-i),n*n+r*r<=o)||(r=e-(this.y+this.height-i),n*n+r*r<=o)||(n=t-(this.x+i),n*n+r*r<=o))return!0}return!1}strokeContains(t,e,i,n=.5){const{x:r,y:o,width:a,height:h,radius:l}=this,c=i*(1-n),u=i-c,f=r+l,d=o+l,p=a-l*2,m=h-l*2,g=r+a,x=o+h;return(t>=r-c&&t<=r+u||t>=g-u&&t<=g+c)&&e>=d&&e<=d+m||(e>=o-c&&e<=o+u||e>=x-u&&e<=x+c)&&t>=f&&t<=f+p?!0:t<f&&e<d&&Je(t,e,f,d,l,u,c)||t>g-l&&e<d&&Je(t,e,g-l,d,l,u,c)||t>g-l&&e>x-l&&Je(t,e,g-l,x-l,l,u,c)||t<f&&e>x-l&&Je(t,e,f,x-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 qr={};function Lh(s,t,e){let i=2166136261;for(let n=0;n<t;n++)i^=s[n].uid,i=Math.imul(i,16777619),i>>>=0;return qr[i]||Gh(s,t,i,e)}function Gh(s,t,e,i){const n={};let r=0;for(let a=0;a<i;a++){const h=a<t?s[a]:q.EMPTY.source;n[r++]=h.source,n[r++]=h.style}const o=new is(n);return qr[e]=o,o}class ln{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 cn(s,t,e,i){if(e??(e=0),i??(i=Math.min(s.byteLength-e,t.byteLength)),!(e&7)&&!(i&7)){const n=i/8;new Float64Array(t,0,n).set(new Float64Array(s,e,n))}else if(!(e&3)&&!(i&3)){const n=i/4;new Float32Array(t,0,n).set(new Float32Array(s,e,n))}else new Uint8Array(t).set(new Uint8Array(s,e,i))}const $h={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Dh=(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))(Dh||{});function un(s,t){return t.alphaMode==="no-premultiply-alpha"&&$h[s]||s}const zh=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
24
|
+
`);function Oh(s){let t="";for(let e=0;e<s;++e)e>0&&(t+=`
|
|
25
|
+
else `),e<s-1&&(t+=`if(test == ${e}.0){}`);return t}function Wh(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=zh.replace(/%forloop%/gi,Oh(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 ie=null;function Uh(){var t;if(ie)return ie;const s=Mr();return ie=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),ie=Wh(ie,s),(t=s.getExtension("WEBGL_lose_context"))==null||t.loseContext(),ie}class Nh{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 Hh{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Nh,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}const ke=[];let as=0;Oe.register({clear:()=>{if(ke.length>0)for(const s of ke)s&&s.destroy();ke.length=0,as=0}});function dn(){return as>0?ke[--as]:new Hh}function fn(s){s.elements=null,ke[as++]=s}let we=0;const Kr=class Zr{constructor(t){this.uid=st("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...Zr.defaultOptions,...t},t.maxTextures||(H("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=Uh());const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:n}=t;this.attributeBuffer=new ln(i*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)fn(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}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?!1:(t._textureId=i,t.texture=e,!0)}updateElement(t){this.dirty=!0;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=dn(),n=i.textures;n.clear();const r=e[this.elementStart];let o=un(r.blendMode,r.texture._source),a=r.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",p=[];const m=this.maxTextures;for(let g=this.elementStart;g<this.elementSize;++g){const x=e[g];e[g]=null;const _=x.texture._source,b=un(x.blendMode,_),S=o!==b||a!==x.topology;if(_._batchTick===we&&!S){x._textureId=_._textureBindLocation,u+=x.indexSize,x.packAsQuad?(this.packQuadAttributes(x,h,l,x._attributeStart,x._textureId),this.packQuadIndex(c,x._indexStart,x._attributeStart/this.vertexSize)):(this.packAttributes(x,h,l,x._attributeStart,x._textureId),this.packIndex(x,c,x._indexStart,x._attributeStart/this.vertexSize)),x._batch=i,p.push(x);continue}_._batchTick=we,(n.count>=m||S)&&(this._finishBatch(i,f,u-f,n,o,a,t,d,p),d="renderBatch",f=u,o=b,a=x.topology,i=dn(),n=i.textures,n.clear(),p=[],++we),x._textureId=_._textureBindLocation=n.count,n.ids[_.uid]=n.count,n.textures[n.count++]=_,x._batch=i,p.push(x),u+=x.indexSize,x.packAsQuad?(this.packQuadAttributes(x,h,l,x._attributeStart,x._textureId),this.packQuadIndex(c,x._indexStart,x._attributeStart/this.vertexSize)):(this.packAttributes(x,h,l,x._attributeStart,x._textureId),this.packIndex(x,c,x._indexStart,x._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(i,f,u-f,n,o,a,t,d,p),f=u,++we),this.elementStart=this.elementSize,this._batchIndexStart=f,this._batchIndexSize=u}_finishBatch(t,e,i,n,r,o,a,h,l){t.gpuBindGroup=null,t.bindGroup=null,t.action=h,t.batcher=this,t.textures=n,t.blendMode=r,t.topology=o,t.start=e,t.size=i,t.elements=l,++we,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 ln(e);cn(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 n=i>65535?new Uint32Array(i):new Uint16Array(i);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let r=0;r<e.length;r++)n[r]=e[r];else cn(e.buffer,n.buffer);this.indexBuffer=n}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,n){const r=t.indices,o=t.indexSize,a=t.indexOffset,h=t.attributeOffset;for(let l=0;l<o;l++)e[i++]=n+r[l+a]-h}destroy(t={}){var e;if(this.batches!==null){for(let i=0;i<this.batchIndex;i++)fn(this.batches[i]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,t.shader&&((e=this.shader)==null||e.destroy(),this.shader=null);for(let i=0;i<this._elements.length;i++)this._elements[i]&&(this._elements[i]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};Kr.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Vh=Kr;var xt=(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))(xt||{});class Ge extends It{constructor(t){let{data:e,size:i}=t;const{usage:n,label:r,shrinkToFit:o}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=st("buffer"),this._resourceType="buffer",this._resourceId=st("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i??(i=e==null?void 0:e.byteLength);const a=!!e;this.descriptor={size:i,usage:n,mappedAtCreation:a,label:r},this.shrinkToFit=o??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&xt.STATIC)}set static(t){t?this.descriptor.usage|=xt.STATIC:this.descriptor.usage&=~xt.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 n=this._data;if(this._data=t,this._dataInt32=null,!n||n.length!==t.length){!this.shrinkToFit&&n&&t.byteLength<n.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(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function Qr(s,t){if(!(s instanceof Ge)){let e=t?xt.INDEX:xt.VERTEX;s instanceof Array&&(t?(s=new Uint32Array(s),e=xt.INDEX|xt.COPY_DST):(s=new Float32Array(s),e=xt.VERTEX|xt.COPY_DST)),s=new Ge({data:s,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return s}function Xh(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 n=i.buffer.data;let r=1/0,o=1/0,a=-1/0,h=-1/0;const l=n.BYTES_PER_ELEMENT,c=(i.offset||0)/l,u=(i.stride||8)/l;for(let f=c;f<n.length;f+=u){const d=n[f],p=n[f+1];d>a&&(a=d),p>h&&(h=p),d<r&&(r=d),p<o&&(o=p)}return e.minX=r,e.minY=o,e.maxX=a,e.maxY=h,e}function Yh(s){return(s instanceof Ge||Array.isArray(s)||s.BYTES_PER_ELEMENT)&&(s={buffer:s}),s.buffer=Qr(s.buffer,!1),s}class jh extends It{constructor(t={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=st("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new St,this._boundsDirty=!0;const{attributes:e,indexBuffer:i,topology:n}=t;if(this.buffers=[],this.attributes={},e)for(const r in e)this.addAttribute(r,e[r]);this.instanceCount=t.instanceCount??1,i&&this.addIndex(i),this.topology=n||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,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=Yh(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=Qr(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Xh(this,"aPosition",this._bounds)):this._bounds}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(i=>i.destroy()),this.unload(),(e=this.indexBuffer)==null||e.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const qh=new Float32Array(1),Kh=new Uint32Array(1);class Zh extends jh{constructor(){const e=new Ge({data:qh,label:"attribute-batch-buffer",usage:xt.VERTEX|xt.COPY_DST,shrinkToFit:!1}),i=new Ge({data:Kh,label:"index-batch-buffer",usage:xt.INDEX|xt.COPY_DST,shrinkToFit:!1}),n=24;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:n,offset:0},aUV:{buffer:e,format:"float32x2",stride:n,offset:8},aColor:{buffer:e,format:"unorm8x4",stride:n,offset:16},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:n,offset:20}},indexBuffer:i})}}function pn(s,t,e){if(s)for(const i in s){const n=i.toLocaleLowerCase(),r=t[n];if(r){let o=s[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&r.push(`//----${e}----//`),r.push(o)}else mt(`${i} placement hook does not exist in shader`)}}const Qh=/\{\{(.*?)\}\}/g;function gn(s){var i;const t={};return(((i=s.match(Qh))==null?void 0:i.map(n=>n.replace(/[{()}]/g,"")))??[]).forEach(n=>{t[n]=[]}),t}function mn(s,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function xn(s,t,e=!1){const i=[];mn(t,i),s.forEach(a=>{a.header&&mn(a.header,i)});const n=i;e&&n.sort();const r=n.map((a,h)=>` @location(${h}) ${a},`).join(`
|
|
26
|
+
`);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
|
|
27
|
+
${r}
|
|
28
|
+
`),o}function yn(s,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function Jh(s){const e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function tl(s){const t=/@.*?\s+/g;return s.replace(t,"")}function el(s,t){const e=[];yn(t,e),s.forEach(h=>{h.header&&yn(h.header,e)});let i=0;const n=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${i++}) ${h}`).join(`,
|
|
29
|
+
`),r=e.sort().map(h=>` var ${tl(h)};`).join(`
|
|
30
|
+
`),o=`return VSOutput(
|
|
31
|
+
${e.sort().map(h=>` ${Jh(h)}`).join(`,
|
|
32
|
+
`)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
|
|
33
|
+
${n}
|
|
34
|
+
`),a=a.replace("{{start}}",`
|
|
35
|
+
${r}
|
|
36
|
+
`),a=a.replace("{{return}}",`
|
|
37
|
+
${o}
|
|
38
|
+
`),a}function _n(s,t){let e=s;for(const i in t){const n=t[i];n.join(`
|
|
39
|
+
`).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----//
|
|
40
|
+
${n.join(`
|
|
41
|
+
`)}
|
|
42
|
+
//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const Wt=Object.create(null),Ds=new Map;let sl=0;function il({template:s,bits:t}){const e=Jr(s,t);if(Wt[e])return Wt[e];const{vertex:i,fragment:n}=rl(s,t);return Wt[e]=to(i,n,t),Wt[e]}function nl({template:s,bits:t}){const e=Jr(s,t);return Wt[e]||(Wt[e]=to(s.vertex,s.fragment,t)),Wt[e]}function rl(s,t){const e=t.map(o=>o.vertex).filter(o=>!!o),i=t.map(o=>o.fragment).filter(o=>!!o);let n=xn(e,s.vertex,!0);n=el(e,n);const r=xn(i,s.fragment,!0);return{vertex:n,fragment:r}}function Jr(s,t){return t.map(e=>(Ds.has(e)||Ds.set(e,sl++),Ds.get(e))).sort((e,i)=>e-i).join("-")+s.vertex+s.fragment}function to(s,t,e){const i=gn(s),n=gn(t);return e.forEach(r=>{pn(r.vertex,i,r.name),pn(r.fragment,n,r.name)}),{vertex:_n(s,i),fragment:_n(t,n)}}const ol=`
|
|
43
|
+
@in aPosition: vec2<f32>;
|
|
44
|
+
@in aUV: vec2<f32>;
|
|
45
|
+
|
|
46
|
+
@out @builtin(position) vPosition: vec4<f32>;
|
|
47
|
+
@out vUV : vec2<f32>;
|
|
48
|
+
@out vColor : vec4<f32>;
|
|
49
|
+
|
|
50
|
+
{{header}}
|
|
51
|
+
|
|
52
|
+
struct VSOutput {
|
|
53
|
+
{{struct}}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
@vertex
|
|
57
|
+
fn main( {{in}} ) -> VSOutput {
|
|
58
|
+
|
|
59
|
+
var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
|
|
60
|
+
var modelMatrix = mat3x3<f32>(
|
|
61
|
+
1.0, 0.0, 0.0,
|
|
62
|
+
0.0, 1.0, 0.0,
|
|
63
|
+
0.0, 0.0, 1.0
|
|
64
|
+
);
|
|
65
|
+
var position = aPosition;
|
|
66
|
+
var uv = aUV;
|
|
67
|
+
|
|
68
|
+
{{start}}
|
|
69
|
+
|
|
70
|
+
vColor = vec4<f32>(1., 1., 1., 1.);
|
|
71
|
+
|
|
72
|
+
{{main}}
|
|
73
|
+
|
|
74
|
+
vUV = uv;
|
|
75
|
+
|
|
76
|
+
var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
|
77
|
+
|
|
78
|
+
vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
|
|
79
|
+
|
|
80
|
+
vColor *= globalUniforms.uWorldColorAlpha;
|
|
81
|
+
|
|
82
|
+
{{end}}
|
|
83
|
+
|
|
84
|
+
{{return}}
|
|
85
|
+
};
|
|
86
|
+
`,al=`
|
|
87
|
+
@in vUV : vec2<f32>;
|
|
88
|
+
@in vColor : vec4<f32>;
|
|
89
|
+
|
|
90
|
+
{{header}}
|
|
91
|
+
|
|
92
|
+
@fragment
|
|
93
|
+
fn main(
|
|
94
|
+
{{in}}
|
|
95
|
+
) -> @location(0) vec4<f32> {
|
|
96
|
+
|
|
97
|
+
{{start}}
|
|
98
|
+
|
|
99
|
+
var outColor:vec4<f32>;
|
|
100
|
+
|
|
101
|
+
{{main}}
|
|
102
|
+
|
|
103
|
+
var finalColor:vec4<f32> = outColor * vColor;
|
|
104
|
+
|
|
105
|
+
{{end}}
|
|
106
|
+
|
|
107
|
+
return finalColor;
|
|
108
|
+
};
|
|
109
|
+
`,hl=`
|
|
110
|
+
in vec2 aPosition;
|
|
111
|
+
in vec2 aUV;
|
|
112
|
+
|
|
113
|
+
out vec4 vColor;
|
|
114
|
+
out vec2 vUV;
|
|
115
|
+
|
|
116
|
+
{{header}}
|
|
117
|
+
|
|
118
|
+
void main(void){
|
|
119
|
+
|
|
120
|
+
mat3 worldTransformMatrix = uWorldTransformMatrix;
|
|
121
|
+
mat3 modelMatrix = mat3(
|
|
122
|
+
1.0, 0.0, 0.0,
|
|
123
|
+
0.0, 1.0, 0.0,
|
|
124
|
+
0.0, 0.0, 1.0
|
|
125
|
+
);
|
|
126
|
+
vec2 position = aPosition;
|
|
127
|
+
vec2 uv = aUV;
|
|
128
|
+
|
|
129
|
+
{{start}}
|
|
130
|
+
|
|
131
|
+
vColor = vec4(1.);
|
|
132
|
+
|
|
133
|
+
{{main}}
|
|
134
|
+
|
|
135
|
+
vUV = uv;
|
|
136
|
+
|
|
137
|
+
mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
|
138
|
+
|
|
139
|
+
gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
140
|
+
|
|
141
|
+
vColor *= uWorldColorAlpha;
|
|
142
|
+
|
|
143
|
+
{{end}}
|
|
144
|
+
}
|
|
145
|
+
`,ll=`
|
|
146
|
+
|
|
147
|
+
in vec4 vColor;
|
|
148
|
+
in vec2 vUV;
|
|
149
|
+
|
|
150
|
+
out vec4 finalColor;
|
|
151
|
+
|
|
152
|
+
{{header}}
|
|
153
|
+
|
|
154
|
+
void main(void) {
|
|
155
|
+
|
|
156
|
+
{{start}}
|
|
157
|
+
|
|
158
|
+
vec4 outColor;
|
|
159
|
+
|
|
160
|
+
{{main}}
|
|
161
|
+
|
|
162
|
+
finalColor = outColor * vColor;
|
|
163
|
+
|
|
164
|
+
{{end}}
|
|
165
|
+
}
|
|
166
|
+
`,cl={name:"global-uniforms-bit",vertex:{header:`
|
|
167
|
+
struct GlobalUniforms {
|
|
168
|
+
uProjectionMatrix:mat3x3<f32>,
|
|
169
|
+
uWorldTransformMatrix:mat3x3<f32>,
|
|
170
|
+
uWorldColorAlpha: vec4<f32>,
|
|
171
|
+
uResolution: vec2<f32>,
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
@group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
|
|
175
|
+
`}},ul={name:"global-uniforms-bit",vertex:{header:`
|
|
176
|
+
uniform mat3 uProjectionMatrix;
|
|
177
|
+
uniform mat3 uWorldTransformMatrix;
|
|
178
|
+
uniform vec4 uWorldColorAlpha;
|
|
179
|
+
uniform vec2 uResolution;
|
|
180
|
+
`}};function dl({bits:s,name:t}){const e=il({template:{fragment:al,vertex:ol},bits:[cl,...s]});return fs.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function fl({bits:s,name:t}){return new Pr({name:t,...nl({template:{vertex:hl,fragment:ll},bits:[ul,...s]})})}const pl={name:"color-bit",vertex:{header:`
|
|
181
|
+
@in aColor: vec4<f32>;
|
|
182
|
+
`,main:`
|
|
183
|
+
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
|
|
184
|
+
`}},gl={name:"color-bit",vertex:{header:`
|
|
185
|
+
in vec4 aColor;
|
|
186
|
+
`,main:`
|
|
187
|
+
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
|
|
188
|
+
`}},zs={};function ml(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(`
|
|
189
|
+
`)}function xl(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(`
|
|
190
|
+
`)}function yl(s){return zs[s]||(zs[s]={name:"texture-batch-bit",vertex:{header:`
|
|
191
|
+
@in aTextureIdAndRound: vec2<u32>;
|
|
192
|
+
@out @interpolate(flat) vTextureId : u32;
|
|
193
|
+
`,main:`
|
|
194
|
+
vTextureId = aTextureIdAndRound.y;
|
|
195
|
+
`,end:`
|
|
196
|
+
if(aTextureIdAndRound.x == 1)
|
|
197
|
+
{
|
|
198
|
+
vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
199
|
+
}
|
|
200
|
+
`},fragment:{header:`
|
|
201
|
+
@in @interpolate(flat) vTextureId: u32;
|
|
202
|
+
|
|
203
|
+
${ml(s)}
|
|
204
|
+
`,main:`
|
|
205
|
+
var uvDx = dpdx(vUV);
|
|
206
|
+
var uvDy = dpdy(vUV);
|
|
207
|
+
|
|
208
|
+
${xl(s)}
|
|
209
|
+
`}}),zs[s]}const Os={};function _l(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(`
|
|
210
|
+
`)}function bl(s){return Os[s]||(Os[s]={name:"texture-batch-bit",vertex:{header:`
|
|
211
|
+
in vec2 aTextureIdAndRound;
|
|
212
|
+
out float vTextureId;
|
|
213
|
+
|
|
214
|
+
`,main:`
|
|
215
|
+
vTextureId = aTextureIdAndRound.y;
|
|
216
|
+
`,end:`
|
|
217
|
+
if(aTextureIdAndRound.x == 1.)
|
|
218
|
+
{
|
|
219
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
220
|
+
}
|
|
221
|
+
`},fragment:{header:`
|
|
222
|
+
in float vTextureId;
|
|
223
|
+
|
|
224
|
+
uniform sampler2D uTextures[${s}];
|
|
225
|
+
|
|
226
|
+
`,main:`
|
|
227
|
+
|
|
228
|
+
${_l(s)}
|
|
229
|
+
`}}),Os[s]}const wl={name:"round-pixels-bit",vertex:{header:`
|
|
230
|
+
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
|
|
231
|
+
{
|
|
232
|
+
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
233
|
+
}
|
|
234
|
+
`}},Sl={name:"round-pixels-bit",vertex:{header:`
|
|
235
|
+
vec2 roundPixels(vec2 position, vec2 targetSize)
|
|
236
|
+
{
|
|
237
|
+
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
238
|
+
}
|
|
239
|
+
`}},bn={};function vl(s){let t=bn[s];if(t)return t;const e=new Int32Array(s);for(let i=0;i<s;i++)e[i]=i;return t=bn[s]=new Er({uTextures:{value:e,type:"i32",size:s}},{isStatic:!0}),t}class wn extends bi{constructor(t){const e=fl({name:"batch",bits:[gl,bl(t),Sl]}),i=dl({name:"batch",bits:[pl,yl(t),wl]});super({glProgram:e,gpuProgram:i,resources:{batchSamplers:vl(t)}}),this.maxTextures=t}}let Se=null;const eo=class so extends Vh{constructor(t){super(t),this.geometry=new Zh,this.name=so.extension.name,this.vertexSize=6,Se??(Se=new wn(t.maxTextures)),this.shader=Se}packAttributes(t,e,i,n,r){const o=r<<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:p,uvs:m}=t,g=t.color,x=t.attributeOffset,y=x+t.attributeSize;for(let _=x;_<y;_++){const b=_*2,S=p[b],w=p[b+1];e[n++]=h*S+c*w+f,e[n++]=u*w+l*S+d,e[n++]=m[b],e[n++]=m[b+1],i[n++]=g,i[n++]=o}}packQuadAttributes(t,e,i,n,r){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,p=t.bounds,m=p.maxX,g=p.minX,x=p.maxY,y=p.minY,_=o.uvs,b=t.color,S=r<<16|t.roundPixels&65535;e[n+0]=h*g+c*y+f,e[n+1]=u*y+l*g+d,e[n+2]=_.x0,e[n+3]=_.y0,i[n+4]=b,i[n+5]=S,e[n+6]=h*m+c*y+f,e[n+7]=u*y+l*m+d,e[n+8]=_.x1,e[n+9]=_.y1,i[n+10]=b,i[n+11]=S,e[n+12]=h*m+c*x+f,e[n+13]=u*x+l*m+d,e[n+14]=_.x2,e[n+15]=_.y2,i[n+16]=b,i[n+17]=S,e[n+18]=h*g+c*x+f,e[n+19]=u*x+l*g+d,e[n+20]=_.x3,e[n+21]=_.y3,i[n+22]=b,i[n+23]=S}_updateMaxTextures(t){this.shader.maxTextures!==t&&(Se=new wn(t),this.shader=Se)}destroy(){this.shader=null,super.destroy()}};eo.extension={type:[z.Batcher],name:"default"};let Cl=eo;class We{constructor(t){this.items=Object.create(null);const{renderer:e,type:i,onUnload:n,priority:r,name:o}=t;this._renderer=e,e.gc.addResourceHash(this,"items",i,r??0),this._onUnload=n,this.name=o}add(t){return this.items[t.uid]?!1:(this.items[t.uid]=t,t.once("unload",this.remove,this),t._gcLastUsed=this._renderer.gc.now,!0)}remove(t,...e){var n;if(!this.items[t.uid])return;const i=t._gpuData[this._renderer.uid];i&&((n=this._onUnload)==null||n.call(this,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 Tl(s,t,e,i,n,r,o,a=null){let h=0;e*=t,n*=r;const l=a.a,c=a.b,u=a.c,f=a.d,d=a.tx,p=a.ty;for(;h<o;){const m=s[e],g=s[e+1];i[n]=l*m+u*g+d,i[n+1]=c*m+f*g+p,n+=r,e+=t,h++}}function Ml(s,t,e,i){let n=0;for(t*=e;n<i;)s[t]=0,s[t+1]=0,t+=e,n++}function io(s,t,e,i,n){const r=t.a,o=t.b,a=t.c,h=t.d,l=t.tx,c=t.ty;e||(e=0),i||(i=2),n||(n=s.length/i-e);let u=e*i;for(let f=0;f<n;f++){const d=s[u],p=s[u+1];s[u]=r*d+a*p+l,s[u+1]=o*d+h*p+c,u+=i}}const Al=new N;class Ci{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,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?ar(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||Al}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=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}const $e={extension:{type:z.ShapeBuilder,name:"circle"},build(s,t){let e,i,n,r,o,a;if(s.type==="circle"){const b=s;if(o=a=b.radius,o<=0)return!1;e=b.x,i=b.y,n=r=0}else if(s.type==="ellipse"){const b=s;if(o=b.halfWidth,a=b.halfHeight,o<=0||a<=0)return!1;e=b.x,i=b.y,n=r=0}else{const b=s,S=b.width/2,w=b.height/2;e=b.x+S,i=b.y+w,o=a=Math.max(0,Math.min(b.radius,Math.min(S,w))),n=S-o,r=w-a}if(n<0||r<0)return!1;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(n?4:0)+(r?4:0);if(l===0)return!1;if(h===0)return t[0]=t[6]=e+n,t[1]=t[3]=i+r,t[2]=t[4]=e-n,t[5]=t[7]=i-r,!0;let c=0,u=h*4+(n?2:0)+2,f=u,d=l,p=n+o,m=r,g=e+p,x=e-p,y=i+m;if(t[c++]=g,t[c++]=y,t[--u]=y,t[--u]=x,r){const b=i-m;t[f++]=x,t[f++]=b,t[--d]=b,t[--d]=g}for(let b=1;b<h;b++){const S=Math.PI/2*(b/h),w=n+Math.cos(S)*o,v=r+Math.sin(S)*a,R=e+w,T=e-w,M=i+v,P=i-v;t[c++]=R,t[c++]=M,t[--u]=M,t[--u]=T,t[f++]=T,t[f++]=P,t[--d]=P,t[--d]=R}p=n,m=r+a,g=e+p,x=e-p,y=i+m;const _=i-m;return t[c++]=g,t[c++]=y,t[--d]=_,t[--d]=g,n&&(t[c++]=x,t[c++]=y,t[--d]=_,t[--d]=x),!0},triangulate(s,t,e,i,n,r){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&&(n[r++]=h,n[r++]=l,n[r++]=h-1),h++;n[r++]=l+1,n[r++]=l,n[r++]=h-1}},Pl={...$e,extension:{...$e.extension,name:"ellipse"}},kl={...$e,extension:{...$e.extension,name:"roundedRectangle"}},no=1e-4,Sn=1e-4;function Il(s){const t=s.length;if(t<6)return 1;let e=0;for(let i=0,n=s[t-2],r=s[t-1];i<t;i+=2){const o=s[i],a=s[i+1];e+=(o-n)*(a+r),n=o,r=a}return e<0?-1:1}function vn(s,t,e,i,n,r,o,a){const h=s-e*n,l=t-i*n,c=s+e*r,u=t+i*r;let f,d;o?(f=i,d=-e):(f=-i,d=e);const p=h+f,m=l+d,g=c+f,x=u+d;return a.push(p,m),a.push(g,x),2}function Xt(s,t,e,i,n,r,o,a){const h=e-s,l=i-t;let c=Math.atan2(h,l),u=Math.atan2(n-s,r-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let f=c;const d=u-c,p=Math.abs(d),m=Math.sqrt(h*h+l*l),g=(15*p*Math.sqrt(m)/Math.PI>>0)+1,x=d/g;if(f+=x,a){o.push(s,t),o.push(e,i);for(let y=1,_=f;y<g;y++,_+=x)o.push(s,t),o.push(s+Math.sin(_)*m,t+Math.cos(_)*m);o.push(s,t),o.push(n,r)}else{o.push(e,i),o.push(s,t);for(let y=1,_=f;y<g;y++,_+=x)o.push(s+Math.sin(_)*m,t+Math.cos(_)*m),o.push(s,t);o.push(n,r),o.push(s,t)}return g*2}function Rl(s,t,e,i,n,r){const o=no;if(s.length===0)return;const a=t;let h=a.alignment;if(t.alignment!==.5){let F=Il(s);h=(h-.5)*F+.5}const l=new dt(s[0],s[1]),c=new dt(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 F=(l.x+c.x)*.5,O=(c.y+l.y)*.5;s.unshift(F,O),s.push(F,O)}const d=n,p=s.length/2;let m=s.length;const g=d.length/2,x=a.width/2,y=x*x,_=a.miterLimit*a.miterLimit;let b=s[0],S=s[1],w=s[2],v=s[3],R=0,T=0,M=-(S-v),P=b-w,k=0,I=0,G=Math.sqrt(M*M+P*P);M/=G,P/=G,M*=x,P*=x;const at=h,A=(1-at)*2,B=at*2;u||(a.cap==="round"?m+=Xt(b-M*(A-B)*.5,S-P*(A-B)*.5,b-M*A,S-P*A,b+M*B,S+P*B,d,!0)+2:a.cap==="square"&&(m+=vn(b,S,M,P,A,B,!0,d))),d.push(b-M*A,S-P*A),d.push(b+M*B,S+P*B);for(let F=1;F<p-1;++F){b=s[(F-1)*2],S=s[(F-1)*2+1],w=s[F*2],v=s[F*2+1],R=s[(F+1)*2],T=s[(F+1)*2+1],M=-(S-v),P=b-w,G=Math.sqrt(M*M+P*P),M/=G,P/=G,M*=x,P*=x,k=-(v-T),I=w-R,G=Math.sqrt(k*k+I*I),k/=G,I/=G,k*=x,I*=x;const O=w-b,K=S-v,C=w-R,E=T-v,$=O*C+K*E,V=K*C-E*O,W=V<0;if(Math.abs(V)<.001*Math.abs($)){d.push(w-M*A,v-P*A),d.push(w+M*B,v+P*B),$>=0&&(a.join==="round"?m+=Xt(w,v,w-M*A,v-P*A,w-k*A,v-I*A,d,!1)+4:m+=2,d.push(w-k*B,v-I*B),d.push(w+k*A,v+I*A));continue}const j=(-M+b)*(-P+v)-(-M+w)*(-P+S),ft=(-k+R)*(-I+v)-(-k+w)*(-I+T),Ct=(O*ft-C*j)/V,Ut=(E*j-K*ft)/V,rt=(Ct-w)*(Ct-w)+(Ut-v)*(Ut-v),Rt=w+(Ct-w)*A,Nt=v+(Ut-v)*A,Ht=w-(Ct-w)*B,Vt=v-(Ut-v)*B,Co=Math.min(O*O+K*K,C*C+E*E),Ri=W?A:B,To=Co+Ri*Ri*y;rt<=To?a.join==="bevel"||rt/y>_?(W?(d.push(Rt,Nt),d.push(w+M*B,v+P*B),d.push(Rt,Nt),d.push(w+k*B,v+I*B)):(d.push(w-M*A,v-P*A),d.push(Ht,Vt),d.push(w-k*A,v-I*A),d.push(Ht,Vt)),m+=2):a.join==="round"?W?(d.push(Rt,Nt),d.push(w+M*B,v+P*B),m+=Xt(w,v,w+M*B,v+P*B,w+k*B,v+I*B,d,!0)+4,d.push(Rt,Nt),d.push(w+k*B,v+I*B)):(d.push(w-M*A,v-P*A),d.push(Ht,Vt),m+=Xt(w,v,w-M*A,v-P*A,w-k*A,v-I*A,d,!1)+4,d.push(w-k*A,v-I*A),d.push(Ht,Vt)):(d.push(Rt,Nt),d.push(Ht,Vt)):(d.push(w-M*A,v-P*A),d.push(w+M*B,v+P*B),a.join==="round"?W?m+=Xt(w,v,w+M*B,v+P*B,w+k*B,v+I*B,d,!0)+2:m+=Xt(w,v,w-M*A,v-P*A,w-k*A,v-I*A,d,!1)+2:a.join==="miter"&&rt/y<=_&&(W?(d.push(Ht,Vt),d.push(Ht,Vt)):(d.push(Rt,Nt),d.push(Rt,Nt)),m+=2),d.push(w-k*A,v-I*A),d.push(w+k*B,v+I*B),m+=2)}b=s[(p-2)*2],S=s[(p-2)*2+1],w=s[(p-1)*2],v=s[(p-1)*2+1],M=-(S-v),P=b-w,G=Math.sqrt(M*M+P*P),M/=G,P/=G,M*=x,P*=x,d.push(w-M*A,v-P*A),d.push(w+M*B,v+P*B),u||(a.cap==="round"?m+=Xt(w-M*(A-B)*.5,v-P*(A-B)*.5,w-M*A,v-P*A,w+M*B,v+P*B,d,!1)+2:a.cap==="square"&&(m+=vn(w,v,M,P,A,B,!1,d)));const Y=Sn*Sn;for(let F=g;F<m+g-2;++F)b=d[F*2],S=d[F*2+1],w=d[(F+1)*2],v=d[(F+1)*2+1],R=d[(F+2)*2],T=d[(F+2)*2+1],!(Math.abs(b*(v-T)+w*(T-S)+R*(S-v))<Y)&&r.push(F,F+1,F+2)}function El(s,t,e,i){const n=no;if(s.length===0)return;const r=s[0],o=s[1],a=s[s.length-2],h=s[s.length-1],l=t||Math.abs(r-a)<n&&Math.abs(o-h)<n,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 ro(s,t,e,i,n,r,o){const a=bh(s,t,2);if(!a)return;for(let l=0;l<a.length;l+=3)r[o++]=a[l]+n,r[o++]=a[l+1]+n,r[o++]=a[l+2]+n;let h=n*i;for(let l=0;l<s.length;l+=2)e[h]=s[l],e[h+1]=s[l+1],h+=i}const Bl=[],Fl={extension:{type:z.ShapeBuilder,name:"polygon"},build(s,t){for(let e=0;e<s.points.length;e++)t[e]=s.points[e];return!0},triangulate(s,t,e,i,n,r){ro(s,Bl,t,e,i,n,r)}},Ll={extension:{type:z.ShapeBuilder,name:"rectangle"},build(s,t){const e=s,i=e.x,n=e.y,r=e.width,o=e.height;return r>0&&o>0?(t[0]=i,t[1]=n,t[2]=i+r,t[3]=n,t[4]=i+r,t[5]=n+o,t[6]=i,t[7]=n+o,!0):!1},triangulate(s,t,e,i,n,r){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;n[r++]=a,n[r++]=a+1,n[r++]=a+2,n[r++]=a+1,n[r++]=a+3,n[r++]=a+2}},Gl={extension:{type:z.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,!0},triangulate(s,t,e,i,n,r){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;n[r++]=a,n[r++]=a+1,n[r++]=a+2}},Cn=[{offset:0,color:"white"},{offset:1,color:"black"}],Ti=class ai{constructor(...t){this.uid=st("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=$l(t);e={...e.type==="radial"?ai.defaultRadialOptions:ai.defaultLinearOptions,...Kn(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(n=>{this.addColorStop(n.offset,n.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:J.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:n}=this.end,r=i-t,o=n-e;const a=r<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(r<0){const g=t;t=i,i=g,r*=-1}if(o<0){const g=e;e=n,n=g,o*=-1}}const h=this.colorStops.length?this.colorStops:Cn,l=this._textureSize,{canvas:c,context:u}=Mn(l,1),f=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);Tn(f,h),u.fillStyle=f,u.fillRect(0,0,l,1),this.texture=new q({source:new rs({resource:c,addressMode:this._wrapMode})});const d=Math.sqrt(r*r+o*o),p=Math.atan2(o,r),m=new N;m.scale(d/l,1),m.rotate(p),m.translate(t,e),this.textureSpace==="local"&&m.scale(l,l),this.transform=m}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Cn,e=this._textureSize,{canvas:i,context:n}=Mn(e,e),{x:r,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),p=(r-u)*d,m=(o-f)*d,g=n.createRadialGradient(p,m,l*d,(a-u)*d,(h-f)*d,c*d);Tn(g,t),n.fillStyle=t[t.length-1].color,n.fillRect(0,0,e,e),n.fillStyle=g,n.translate(p,m),n.rotate(this.rotation),n.scale(1,this.scale),n.translate(-p,-m),n.fillRect(0,0,e,e),this.texture=new q({source:new rs({resource:i,addressMode:this._wrapMode})});const x=new N;this.textureSpace==="local"?x.scale(2*c,2*c):x.scale(1/d,1/d),x.translate(u,f),this.transform=x}destroy(){var t;(t=this.texture)==null||t.destroy(!0),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}`}};Ti.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};Ti.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,rotation:0,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Dt=Ti;function Tn(s,t){for(let e=0;e<t.length;e++){const i=t[e];s.addColorStop(i.offset,i.color)}}function Mn(s,t){const e=ot.get().createCanvas(s,t),i=e.getContext("2d");return{canvas:e,context:i}}function $l(s){let t=s[0]??{};return(typeof t=="number"||s[1])&&(H("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]??Dt.defaultLinearOptions.textureSize}),t}const Dl=new N,zl=new it;function Ol(s,t,e,i){const n=t.matrix?s.copyFrom(t.matrix).invert():s.identity();if(t.textureSpace==="local"){const o=e.getBounds(zl);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=n.a,p=n.b,m=n.c,g=n.d;n.a*=l,n.b*=l,n.c*=c,n.d*=c,n.tx=u*d+f*m+n.tx,n.ty=u*p+f*g+n.ty}else n.translate(t.texture.frame.x,t.texture.frame.y),n.scale(1/t.texture.source.width,1/t.texture.source.height);const r=t.texture.source.style;return!(t.fill instanceof Dt)&&r.addressMode==="clamp-to-edge"&&(r.addressMode="repeat",r.update()),i&&n.append(Dl.copyFrom(i).invert()),n}const ps={};nt.handleByMap(z.ShapeBuilder,ps);nt.add(Ll,Fl,Gl,$e,Pl,kl);const Wl=new it,Ul=new N;function Nl(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 n=0;n<s.instructions.length;n++){const r=s.instructions[n];if(r.action==="texture")Hl(r.data,i,e);else if(r.action==="fill"||r.action==="stroke"){const o=r.action==="stroke",a=r.data.path.shapePath,h=r.data.style,l=r.data.hole;o&&l&&An(l.shapePath,h,!0,i,e),l&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=l.shapePath.shapePrimitives),An(a,h,o,i,e)}}}function Hl(s,t,e){const i=[],n=ps.rectangle,r=Wl;r.x=s.dx,r.y=s.dy,r.width=s.dw,r.height=s.dh;const o=s.transform;if(!n.build(r,i))return;const{vertices:a,uvs:h,indices:l}=e,c=l.length,u=a.length/2;o&&io(i,o),n.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 p=yt.get(Ci);p.indexOffset=c,p.indexSize=l.length-c,p.attributeOffset=u,p.attributeSize=a.length/2-u,p.baseColor=s.style,p.alpha=s.alpha,p.texture=f,p.geometryData=e,t.push(p)}function An(s,t,e,i,n){const{vertices:r,uvs:o,indices:a}=n;s.shapePrimitives.forEach(({shape:h,transform:l,holes:c})=>{const u=[],f=ps[h.type];if(!f.build(h,u))return;const d=a.length,p=r.length/2;let m="triangle-list";if(l&&io(u,l),e){const _=h.closePath??!0,b=t;b.pixelLine?(El(u,_,r,a),m="line-list"):Rl(u,b,!1,_,r,a)}else if(c){const _=[],b=u.slice();Vl(c).forEach(w=>{_.push(b.length/2),b.push(...w)}),ro(b,_,r,2,p,a,d)}else f.triangulate(u,r,2,p,a,d);const g=o.length/2,x=t.texture;if(x!==q.WHITE){const _=Ol(Ul,t,h,l);Tl(r,2,p,o,g,2,r.length/2-p,_)}else Ml(o,g,2,r.length/2-p);const y=yt.get(Ci);y.indexOffset=d,y.indexSize=a.length-d,y.attributeOffset=p,y.attributeSize=r.length/2-p,y.baseColor=t.color,y.alpha=t.alpha,y.texture=x,y.geometryData=n,y.topology=m,i.push(y)})}function Vl(s){const t=[];for(let e=0;e<s.length;e++){const i=s[e].shape,n=[];ps[i.type].build(i,n)&&t.push(n)}return t}class Xl{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(t=>{yt.return(t)}),this.graphicsData&&yt.return(this.graphicsData),this.isBatchable=!1,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 Yl{constructor(){this.instructions=new xi}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Cl({maxTextures:e}),this.instructions.reset()}get geometry(){return H(Uo,"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 Mi=class hi{constructor(t){this._renderer=t,this._managedContexts=new We({renderer:t,type:"resource",name:"graphicsContext"})}init(t){hi.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??hi.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(),Nl(t,i);const n=t.batchMode;t.customShader||n==="no-batch"?i.isBatchable=!1:n==="auto"?i.isBatchable=i.geometryData.vertices.length<400:i.isBatchable=!0,t.dirty=!1}return i}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=yt.get(Yl,{maxTextures:this._renderer.limits.maxBatchableTextures}),i=t._gpuData[this._renderer.uid],{batches:n,geometryData:r}=i;i.graphicsData=e;const o=r.vertices.length,a=r.indices.length;for(let u=0;u<n.length;u++)n[u].applyTransform=!1;const h=e.batcher;h.ensureAttributeBuffer(o),h.ensureIndexBuffer(a),h.begin();for(let u=0;u<n.length;u++){const f=n[u];h.add(f)}h.finish(e.instructions);const l=h.geometry;l.indexBuffer.setDataWithSize(h.indexBuffer,h.indexSize,!0),l.buffers[0].setDataWithSize(h.attributeBuffer.float32View,h.attributeSize,!0);const c=h.batches;for(let u=0;u<c.length;u++){const f=c[u];f.bindGroup=Lh(f.textures.textures,f.textures.count,this._renderer.limits.maxBatchableTextures)}return e}_initContext(t){const e=new Xl;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};Mi.extension={type:[z.WebGLSystem,z.WebGPUSystem],name:"graphicsContext"};Mi.defaultOptions={bezierSmoothness:.5};let Ai=Mi;const jl=8,ts=11920929e-14,ql=1;function oo(s,t,e,i,n,r,o,a,h,l){const u=Math.min(.99,Math.max(0,l??Ai.defaultOptions.bezierSmoothness));let f=(ql-u)/1;return f*=f,Kl(t,e,i,n,r,o,a,h,s,f),s}function Kl(s,t,e,i,n,r,o,a,h,l){li(s,t,e,i,n,r,o,a,h,l,0),h.push(o,a)}function li(s,t,e,i,n,r,o,a,h,l,c){if(c>jl)return;const u=(s+e)/2,f=(t+i)/2,d=(e+n)/2,p=(i+r)/2,m=(n+o)/2,g=(r+a)/2,x=(u+d)/2,y=(f+p)/2,_=(d+m)/2,b=(p+g)/2,S=(x+_)/2,w=(y+b)/2;if(c>0){let v=o-s,R=a-t;const T=Math.abs((e-o)*R-(i-a)*v),M=Math.abs((n-o)*R-(r-a)*v);if(T>ts&&M>ts){if((T+M)*(T+M)<=l*(v*v+R*R)){h.push(S,w);return}}else if(T>ts){if(T*T<=l*(v*v+R*R)){h.push(S,w);return}}else if(M>ts){if(M*M<=l*(v*v+R*R)){h.push(S,w);return}}else if(v=S-(s+o)/2,R=w-(t+a)/2,v*v+R*R<=l){h.push(S,w);return}}li(s,t,u,f,x,y,S,w,h,l,c+1),li(S,w,_,b,m,g,o,a,h,l,c+1)}const Zl=8,Ql=11920929e-14,Jl=1;function tc(s,t,e,i,n,r,o,a){const l=Math.min(.99,Math.max(0,a??Ai.defaultOptions.bezierSmoothness));let c=(Jl-l)/1;return c*=c,ec(t,e,i,n,r,o,s,c),s}function ec(s,t,e,i,n,r,o,a){ci(o,s,t,e,i,n,r,a,0),o.push(n,r)}function ci(s,t,e,i,n,r,o,a,h){if(h>Zl)return;const l=(t+i)/2,c=(e+n)/2,u=(i+r)/2,f=(n+o)/2,d=(l+u)/2,p=(c+f)/2;let m=r-t,g=o-e;const x=Math.abs((i-r)*g-(n-o)*m);if(x>Ql){if(x*x<=a*(m*m+g*g)){s.push(d,p);return}}else if(m=d-(t+r)/2,g=p-(e+o)/2,m*m+g*g<=a){s.push(d,p);return}ci(s,t,e,l,c,d,p,a,h+1),ci(s,d,p,u,f,r,o,a,h+1)}function ao(s,t,e,i,n,r,o,a){let h=Math.abs(n-r);(!o&&n>r||o&&r>n)&&(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=n;l*=o?-1:1;for(let u=0;u<a+1;u++){const f=Math.cos(c),d=Math.sin(c),p=t+f*i,m=e+d*i;s.push(p,m),c+=l}}function sc(s,t,e,i,n,r){const o=s[s.length-2],h=s[s.length-1]-e,l=o-t,c=n-e,u=i-t,f=Math.abs(h*u-l*c);if(f<1e-8||r===0){(s[s.length-2]!==t||s[s.length-1]!==e)&&s.push(t,e);return}const d=h*h+l*l,p=c*c+u*u,m=h*c+l*u,g=r*Math.sqrt(d)/f,x=r*Math.sqrt(p)/f,y=g*m/d,_=x*m/p,b=g*u+x*l,S=g*c+x*h,w=l*(x+y),v=h*(x+y),R=u*(g+_),T=c*(g+_),M=Math.atan2(v-S,w-b),P=Math.atan2(T-S,R-b);ao(s,b+t,S+e,r,M,P,l*c>u*h)}const Ie=Math.PI*2,Ws={centerX:0,centerY:0,ang1:0,ang2:0},Us=({x:s,y:t},e,i,n,r,o,a,h)=>{s*=e,t*=i;const l=n*s-r*t,c=r*s+n*t;return h.x=l+o,h.y=c+a,h};function ic(s,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,n=Math.cos(s),r=Math.sin(s),o=Math.cos(s+t),a=Math.sin(s+t);return[{x:n-r*i,y:r+n*i},{x:o+a*i,y:a-o*i},{x:o,y:a}]}const Pn=(s,t,e,i)=>{const n=s*i-t*e<0?-1:1;let r=s*e+t*i;return r>1&&(r=1),r<-1&&(r=-1),n*Math.acos(r)},nc=(s,t,e,i,n,r,o,a,h,l,c,u,f)=>{const d=Math.pow(n,2),p=Math.pow(r,2),m=Math.pow(c,2),g=Math.pow(u,2);let x=d*p-d*g-p*m;x<0&&(x=0),x/=d*g+p*m,x=Math.sqrt(x)*(o===a?-1:1);const y=x*n/r*u,_=x*-r/n*c,b=l*y-h*_+(s+e)/2,S=h*y+l*_+(t+i)/2,w=(c-y)/n,v=(u-_)/r,R=(-c-y)/n,T=(-u-_)/r,M=Pn(1,0,w,v);let P=Pn(w,v,R,T);a===0&&P>0&&(P-=Ie),a===1&&P<0&&(P+=Ie),f.centerX=b,f.centerY=S,f.ang1=M,f.ang2=P};function rc(s,t,e,i,n,r,o,a=0,h=0,l=0){if(r===0||o===0)return;const c=Math.sin(a*Ie/360),u=Math.cos(a*Ie/360),f=u*(t-i)/2+c*(e-n)/2,d=-c*(t-i)/2+u*(e-n)/2;if(f===0&&d===0)return;r=Math.abs(r),o=Math.abs(o);const p=Math.pow(f,2)/Math.pow(r,2)+Math.pow(d,2)/Math.pow(o,2);p>1&&(r*=Math.sqrt(p),o*=Math.sqrt(p)),nc(t,e,i,n,r,o,h,l,c,u,f,d,Ws);let{ang1:m,ang2:g}=Ws;const{centerX:x,centerY:y}=Ws;let _=Math.abs(g)/(Ie/4);Math.abs(1-_)<1e-7&&(_=1);const b=Math.max(Math.ceil(_),1);g/=b;let S=s[s.length-2],w=s[s.length-1];const v={x:0,y:0};for(let R=0;R<b;R++){const T=ic(m,g),{x:M,y:P}=Us(T[0],r,o,u,c,x,y,v),{x:k,y:I}=Us(T[1],r,o,u,c,x,y,v),{x:G,y:at}=Us(T[2],r,o,u,c,x,y,v);oo(s,S,w,M,P,k,I,G,at),S=G,w=at,m+=g}}function oc(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}},n=(o,a)=>{o===0?s.moveTo(a.x,a.y):s.lineTo(a.x,a.y)};let r=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){n(o,a),r=a;continue}const l=t[(o+1)%t.length],c=i(a,r),u=i(a,l);if(c.len<1e-4||u.len<1e-4){n(o,a),r=a;continue}let f=Math.asin(c.nx*u.ny-c.ny*u.nx),d=1,p=!1;c.nx*u.nx-c.ny*-u.ny<0?f<0?f=Math.PI+f:(f=Math.PI-f,d=-1,p=!0):f>0&&(d=-1,p=!0);const m=f/2;let g,x=Math.abs(Math.cos(m)*h/Math.sin(m));x>Math.min(c.len/2,u.len/2)?(x=Math.min(c.len/2,u.len/2),g=Math.abs(x*Math.sin(m)/Math.cos(m))):g=h;const y=a.x+u.nx*x+-u.ny*g*d,_=a.y+u.ny*x+u.nx*g*d,b=Math.atan2(c.ny,c.nx)+Math.PI/2*d,S=Math.atan2(u.ny,u.nx)-Math.PI/2*d;o===0&&s.moveTo(y+Math.cos(b)*g,_+Math.sin(b)*g),s.arc(y,_,g,b,S,p),r=a}}function ac(s,t,e,i){const n=(a,h)=>Math.sqrt((a.x-h.x)**2+(a.y-h.y)**2),r=(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=n(c,h);let d;if(f<1e-4)d=h;else{const g=Math.min(f/2,l);d=r(h,c,g/f)}const p=n(u,h);let m;if(p<1e-4)m=h;else{const g=Math.min(p/2,l);m=r(h,u,g/p)}a===0?s.moveTo(d.x,d.y):s.lineTo(d.x,d.y),s.quadraticCurveTo(h.x,h.y,m.x,m.y,i)}}const hc=new it;class lc{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new St,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,n=i[i.length-2],r=i[i.length-1];return(n!==t||r!==e)&&i.push(t,e),this}arc(t,e,i,n,r,o){this._ensurePoly(!1);const a=this._currentPoly.points;return ao(a,t,e,i,n,r,o),this}arcTo(t,e,i,n,r){this._ensurePoly();const o=this._currentPoly.points;return sc(o,t,e,i,n,r),this}arcToSvg(t,e,i,n,r,o,a){const h=this._currentPoly.points;return rc(h,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,i,n,r),this}bezierCurveTo(t,e,i,n,r,o,a){this._ensurePoly();const h=this._currentPoly;return oo(this._currentPoly.points,h.lastX,h.lastY,t,e,i,n,r,o,a),this}quadraticCurveTo(t,e,i,n,r){this._ensurePoly();const o=this._currentPoly;return tc(this._currentPoly.points,o.lastX,o.lastY,t,e,i,n,r),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));const i=this.shapePrimitives,n=i.length;for(let r=0;r<t.instructions.length;r++){const o=t.instructions[r];this[o.action](...o.data)}if(t.checkForHoles&&i.length-n>1){let r=null;for(let o=n;o<i.length;o++){const a=i[o];if(a.shape.type==="polygon"){const h=a.shape,l=r==null?void 0:r.shape;l&&l.containsPolygon(h)?(r.holes||(r.holes=[]),r.holes.push(a),i.copyWithin(o,o+1),i.length--,o--):r=a}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,n,r){return this.drawShape(new it(t,e,i,n),r),this}circle(t,e,i,n){return this.drawShape(new wi(t,e,i),n),this}poly(t,e,i){const n=new Pe(t);return n.closePath=e,this.drawShape(n,i),this}regularPoly(t,e,i,n,r=0,o){n=Math.max(n|0,3);const a=-1*Math.PI/2+r,h=Math.PI*2/n,l=[];for(let c=0;c<n;c++){const u=a-c*h;l.push(t+i*Math.cos(u),e+i*Math.sin(u))}return this.poly(l,!0,o),this}roundPoly(t,e,i,n,r,o=0,a){if(n=Math.max(n|0,3),r<=0)return this.regularPoly(t,e,i,n,o);const h=i*Math.sin(Math.PI/n)-.001;r=Math.min(r,h);const l=-1*Math.PI/2+o,c=Math.PI*2/n,u=(n-2)*Math.PI/n/2;for(let f=0;f<n;f++){const d=f*c+l,p=t+i*Math.cos(d),m=e+i*Math.sin(d),g=d+Math.PI+u,x=d-Math.PI-u,y=p+r*Math.cos(g),_=m+r*Math.sin(g),b=p+r*Math.cos(x),S=m+r*Math.sin(x);f===0?this.moveTo(y,_):this.lineTo(y,_),this.quadraticCurveTo(p,m,b,S,a)}return this.closePath()}roundShape(t,e,i=!1,n){return t.length<3?this:(i?ac(this,t,e,n):oc(this,t,e),this.closePath())}filletRect(t,e,i,n,r){if(r===0)return this.rect(t,e,i,n);const o=Math.min(i,n)/2,a=Math.min(o,Math.max(-o,r)),h=t+i,l=e+n,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,n,r,o){if(r<=0)return this.rect(t,e,i,n);const a=Math.min(r,Math.min(i,n)/2),h=t+i,l=e+n,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,!0,o)}ellipse(t,e,i,n,r){return this.drawShape(new Si(t,e,i,n),r),this}roundRect(t,e,i,n,r,o){return this.drawShape(new vi(t,e,i,n,r),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 Pe,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new Pe,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const r=e.transform,o=i;i=r.a*i+r.c*n+r.tx,n=r.b*o+r.d*n+r.ty}this._currentPoly.points.push(i,n)}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 n=e[i],r=n.shape.getBounds(hc);n.transform?t.addRect(r,n.transform):t.addRect(r)}return t}}class $t{constructor(t,e=!1){this.instructions=[],this.uid=st("graphicsPath"),this._dirty=!0,this.checkForHoles=e,typeof t=="string"?Rh(t,this):this.instructions=(t==null?void 0:t.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new lc(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,i,n,r){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(dt.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,n,r]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,i){const n=this.instructions[this.instructions.length-1],r=this.getLastPoint(dt.shared);let o=0,a=0;if(!n||n.action!=="quadraticCurveTo")o=r.x,a=r.y;else{o=n.data[0],a=n.data[1];const h=r.x,l=r.y;o=h+(h-o),a=l+(l-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,t,e,i]}),this._dirty=!0,this}rect(t,e,i,n,r){return this.instructions.push({action:"rect",data:[t,e,i,n,r]}),this._dirty=!0,this}circle(t,e,i,n){return this.instructions.push({action:"circle",data:[t,e,i,n]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,i,n,r,o,a){r||(r=n/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?r:n,p=f*c+h;u.push(t+d*Math.cos(p),e+d*Math.sin(p))}return this.poly(u,!0,a),this}clone(t=!1){const e=new $t;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const n=this.instructions[i];e.instructions.push({action:n.action,data:n.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,i=t.b,n=t.c,r=t.d,o=t.tx,a=t.ty;let h=0,l=0,c=0,u=0,f=0,d=0,p=0,m=0;for(let g=0;g<this.instructions.length;g++){const x=this.instructions[g],y=x.data;switch(x.action){case"moveTo":case"lineTo":h=y[0],l=y[1],y[0]=e*h+n*l+o,y[1]=i*h+r*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+n*u+o,y[1]=i*c+r*u+a,y[2]=e*f+n*d+o,y[3]=i*f+r*d+a,y[4]=e*h+n*l+o,y[5]=i*h+r*l+a;break;case"quadraticCurveTo":c=y[0],u=y[1],h=y[2],l=y[3],y[0]=e*c+n*u+o,y[1]=i*c+r*u+a,y[2]=e*h+n*l+o,y[3]=i*h+r*l+a;break;case"arcToSvg":h=y[5],l=y[6],p=y[0],m=y[1],y[0]=e*p+n*m,y[1]=i*p+r*m,y[5]=e*h+n*l+o,y[6]=i*h+r*l+a;break;case"circle":y[4]=ne(y[3],t);break;case"rect":y[4]=ne(y[4],t);break;case"ellipse":y[8]=ne(y[8],t);break;case"roundRect":y[5]=ne(y[5],t);break;case"addPath":y[0].transform(t);break;case"poly":y[2]=ne(y[2],t);break;case"regularPoly":case"chamferRect":y[5]=ne(y[5],t);break;case"closePath":break;default:mt("unknown transform action",x.action);break}}return this._dirty=!0,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 ne(s,t){return s?s.prepend(t):t.clone()}function tt(s,t,e){const i=s.getAttribute(t);return i?Number(i):e}function cc(s,t){const e=s.querySelectorAll("defs");for(let i=0;i<e.length;i++){const n=e[i];for(let r=0;r<n.children.length;r++){const o=n.children[r];switch(o.nodeName.toLowerCase()){case"lineargradient":t.defs[o.id]=uc(o);break;case"radialgradient":t.defs[o.id]=dc();break}}}}function uc(s){const t=tt(s,"x1",0),e=tt(s,"y1",0),i=tt(s,"x2",1),n=tt(s,"y2",0),r=s.getAttribute("gradientUnits")||"objectBoundingBox",o=new Dt(t,e,i,n,r==="objectBoundingBox"?"local":"global");for(let a=0;a<s.children.length;a++){const h=s.children[a],l=tt(h,"offset",0),c=J.shared.setValue(h.getAttribute("stop-color")).toNumber();o.addColorStop(l,c)}return o}function dc(s){return mt("[SVG Parser] Radial gradients are not yet supported"),new Dt(0,0,1,0)}function kn(s){const t=s.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const In={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 ho(s,t){const e=s.getAttribute("style"),i={},n={},r={strokeStyle:i,fillStyle:n,useFill:!1,useStroke:!1};for(const o in In){const a=s.getAttribute(o);a&&Rn(t,r,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(":");In[l]&&Rn(t,r,l,c.trim())}}return{strokeStyle:r.useStroke?i:null,fillStyle:r.useFill?n:null,useFill:r.useFill,useStroke:r.useStroke}}function Rn(s,t,e,i){switch(e){case"stroke":if(i!=="none"){if(i.startsWith("url(")){const n=kn(i);t.strokeStyle.fill=s.defs[n]}else t.strokeStyle.color=J.shared.setValue(i).toNumber();t.useStroke=!0}break;case"stroke-width":t.strokeStyle.width=Number(i);break;case"fill":if(i!=="none"){if(i.startsWith("url(")){const n=kn(i);t.fillStyle.fill=s.defs[n]}else t.fillStyle.color=J.shared.setValue(i).toNumber();t.useFill=!0}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 fc(s){if(s.length<=2)return!0;const t=s.map(a=>a.area).sort((a,h)=>h-a),[e,i]=t,n=t[t.length-1],r=e/i,o=i/n;return!(r>3&&o<2)}function pc(s){return s.split(/(?=[Mm])/).filter(i=>i.trim().length>0)}function gc(s){const t=s.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),i=[],n=[];for(let c=0;c<e.length;c+=2)c+1<e.length&&(i.push(e[c]),n.push(e[c+1]));if(i.length===0||n.length===0)return 0;const r=Math.min(...i),o=Math.max(...i),a=Math.min(...n),h=Math.max(...n);return(o-r)*(h-a)}function En(s,t){const e=new $t(s,!1);for(const i of e.instructions)t.instructions.push(i)}function mc(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 $t};cc(s,e);const i=s.children,{fillStyle:n,strokeStyle:r}=ho(s,e);for(let o=0;o<i.length;o++){const a=i[o];a.nodeName.toLowerCase()!=="defs"&&lo(a,e,n,r)}return t}function lo(s,t,e,i){const n=s.children,{fillStyle:r,strokeStyle:o}=ho(s,t);r&&e?e={...e,...r}:r&&(e=r),o&&i?i={...i,...o}:o&&(i=o);const a=!e&&!i;a&&(e={color:0});let h,l,c,u,f,d,p,m,g,x,y,_,b,S,w,v,R;switch(s.nodeName.toLowerCase()){case"path":{S=s.getAttribute("d");const T=s.getAttribute("fill-rule"),M=pc(S),P=T==="evenodd",k=M.length>1;if(P&&k){const G=M.map(A=>({path:A,area:gc(A)}));if(G.sort((A,B)=>B.area-A.area),M.length>3||!fc(G))for(let A=0;A<G.length;A++){const B=G[A],Y=A===0;t.context.beginPath();const F=new $t(void 0,!0);En(B.path,F),t.context.path(F),Y?(e&&t.context.fill(e),i&&t.context.stroke(i)):t.context.cut()}else for(let A=0;A<G.length;A++){const B=G[A],Y=A%2===1;t.context.beginPath();const F=new $t(void 0,!0);En(B.path,F),t.context.path(F),Y?t.context.cut():(e&&t.context.fill(e),i&&t.context.stroke(i))}}else{const G=T?T==="evenodd":!0;w=new $t(S,G),t.context.path(w),e&&t.context.fill(e),i&&t.context.stroke(i)}break}case"circle":p=tt(s,"cx",0),m=tt(s,"cy",0),g=tt(s,"r",0),t.context.ellipse(p,m,g,g),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"rect":h=tt(s,"x",0),l=tt(s,"y",0),v=tt(s,"width",0),R=tt(s,"height",0),x=tt(s,"rx",0),y=tt(s,"ry",0),x||y?t.context.roundRect(h,l,v,R,x||y):t.context.rect(h,l,v,R),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"ellipse":p=tt(s,"cx",0),m=tt(s,"cy",0),x=tt(s,"rx",0),y=tt(s,"ry",0),t.context.beginPath(),t.context.ellipse(p,m,x,y),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"line":c=tt(s,"x1",0),u=tt(s,"y1",0),f=tt(s,"x2",0),d=tt(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"),_=b.match(/-?\d+/g).map(T=>parseInt(T,10)),t.context.poly(_,!0),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"polyline":b=s.getAttribute("points"),_=b.match(/-?\d+/g).map(T=>parseInt(T,10)),t.context.poly(_,!1),i&&t.context.stroke(i);break;case"g":case"svg":break;default:{mt(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}a&&(e=null);for(let T=0;T<n.length;T++)lo(n[T],t,e,i)}function xc(s){return s.texture!==void 0}const Bn={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 gs{constructor(t,e){this.uid=st("fillPattern"),this._tick=0,this.transform=new N;const i=xc(t)?t:{texture:t,repetition:e};this.texture=i.texture,this.textureSpace=i.textureSpace??"global";const n=i.repetition;n&&(this.texture.source.style.addressModeU=Bn[n].addressModeU,this.texture.source.style.addressModeV=Bn[n].addressModeV)}setTransform(t){if(t){if(this.transform.equals(t))return;this.transform.copyFrom(t)}else{if(this.transform.isIdentity())return;this.transform.identity()}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(!0),this.texture=null}}function yc(s){return J.isColorLike(s)}function Fn(s){return s instanceof gs}function Ln(s){return s instanceof Dt}function _c(s){return s instanceof q}function bc(s,t,e){const i=J.shared.setValue(t??0);return s.color=i.toNumber(),s.alpha=i.alpha===1?e.alpha:i.alpha,s.texture=q.WHITE,{...e,...s}}function wc(s,t,e){return s.texture=t,{...e,...s}}function Gn(s,t,e){return s.fill=t,s.color=16777215,s.texture=t.texture,s.matrix=t.transform,s.textureSpace=t.textureSpace,{...e,...s}}function $n(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 Sc(s,t){const e={...t,...s},i=J.shared.setValue(e.color);return e.alpha*=i.alpha,e.color=i.toNumber(),e}function te(s,t){if(s==null)return null;const e={},i=s;return yc(s)?bc(e,s,t):_c(s)?wc(e,s,t):Fn(s)?Gn(e,s,t):Ln(s)?$n(e,s,t):i.fill&&Fn(i.fill)?Gn(i,i.fill,t):i.fill&&Ln(i.fill)?$n(i,i.fill,t):Sc(i,t)}function hs(s,t){const{width:e,alignment:i,miterLimit:n,cap:r,join:o,pixelLine:a,...h}=t,l=te(s,h);return l?{width:e,alignment:i,miterLimit:n,cap:r,join:o,pixelLine:a,...l}:null}function vc(s,t){let e=1;const i=s.shapePath.shapePrimitives;for(let n=0;n<i.length;n++){const r=i[n].shape;if(r.type!=="polygon")continue;const o=r.points,a=o.length;if(a<6)continue;const h=r.closePath;for(let l=0;l<a;l+=2){if(!h&&(l===0||l===a-2))continue;const c=(l-2+a)%a,u=(l+2)%a,f=o[c],d=o[c+1],p=o[l],m=o[l+1],g=o[u],x=o[u+1],y=f-p,_=d-m,b=g-p,S=x-m,w=y*y+_*_,v=b*b+S*S;if(w<1e-12||v<1e-12)continue;let M=(y*b+_*S)/Math.sqrt(w*v);M<-1?M=-1:M>1&&(M=1);const P=Math.sqrt((1-M)*.5);if(P<1e-6)continue;const k=Math.min(1/P,t);k>e&&(e=k)}}return e}const Cc=new dt,Dn=new N,Pi=class Pt extends It{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=st("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new $t,this._transform=new N,this._fillStyle={...Pt.defaultFillStyle},this._strokeStyle={...Pt.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new St,this._boundsDirty=!0}clone(){const t=new Pt;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=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=te(t,Pt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=hs(t,Pt.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=te(t,Pt.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=te(t,Pt.defaultStrokeStyle),this}texture(t,e,i,n,r,o){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:n||0,dw:r||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e||e===0?J.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new $t,this}fill(t,e){let i;const n=this.instructions[this.instructions.length-1];return this._tick===0&&(n==null?void 0:n.action)==="stroke"?i=n.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(H(et,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=te(t,Pt.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(dt.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==null?void 0:i.action)==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=hs(t,Pt.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,n,r,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,n,r,o),this}arcTo(t,e,i,n,r){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*n+o.tx,o.b*i+o.d*n+o.ty,r),this}arcToSvg(t,e,i,n,r,o,a){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,i,n,r,h.a*o+h.c*a+h.tx,h.b*o+h.d*a+h.ty),this}bezierCurveTo(t,e,i,n,r,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*n+h.tx,h.b*i+h.d*n+h.ty,h.a*r+h.c*o+h.tx,h.b*r+h.d*o+h.ty,a),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,i,n){return this._tick++,this._activePath.ellipse(t,e,i,n,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,n=this._activePath.instructions,r=i.a*t+i.c*e+i.tx,o=i.b*t+i.d*e+i.ty;return n.length===1&&n[0].action==="moveTo"?(n[0].data[0]=r,n[0].data[1]=o,this):(this._activePath.moveTo(r,o),this)}quadraticCurveTo(t,e,i,n,r){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*n+o.tx,o.b*i+o.d*n+o.ty,r),this}rect(t,e,i,n){return this._tick++,this._activePath.rect(t,e,i,n,this._transform.clone()),this}roundRect(t,e,i,n,r){return this._tick++,this._activePath.roundRect(t,e,i,n,r,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,n,r=0,o){return this._tick++,this._activePath.regularPoly(t,e,i,n,r,o),this}roundPoly(t,e,i,n,r,o){return this._tick++,this._activePath.roundPoly(t,e,i,n,r,o),this}roundShape(t,e,i,n){return this._tick++,this._activePath.roundShape(t,e,i,n),this}filletRect(t,e,i,n,r){return this._tick++,this._activePath.filletRect(t,e,i,n,r),this}chamferRect(t,e,i,n,r,o){return this._tick++,this._activePath.chamferRect(t,e,i,n,r,o),this}star(t,e,i,n,r=0,o=0){return this._tick++,this._activePath.star(t,e,i,n,r,o,this._transform.clone()),this}svg(t){return this._tick++,mc(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,n,r,o){return t instanceof N?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,n,r,o),this)}transform(t,e,i,n,r,o){return t instanceof N?(this._transform.append(t),this):(Dn.set(t,e,i,n,r,o),this._transform.append(Dn),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=!0,this.dirty=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const i=this.instructions[e],n=i.action;if(n==="fill"){const r=i.data;t.addBounds(r.path.bounds)}else if(n==="texture"){const r=i.data;t.addFrame(r.dx,r.dy,r.dx+r.dw,r.dy+r.dh,r.transform)}if(n==="stroke"){const r=i.data,o=r.style.alignment;let a=r.style.width*(1-o);r.style.join==="miter"&&(a*=vc(r.path,r.style.miterLimit));const h=r.path.bounds;t.addFrame(h.minX-a,h.minY-a,h.maxX+a,h.maxY+a)}}return t.isValid||t.set(0,0,0,0),t}containsPoint(t){var n;if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let i=!1;for(let r=0;r<e.length;r++){const o=e[r],a=o.data,h=a.path;if(!o.action||!h)continue;const l=a.style,c=h.shapePath.shapePrimitives;for(let u=0;u<c.length;u++){const f=c[u].shape;if(!l||!f)continue;const d=c[u].transform,p=d?d.applyInverse(t,Cc):t;if(o.action==="fill")i=f.contains(p.x,p.y);else{const g=l;i=f.strokeContains(p.x,p.y,g.width,g.alignment)}const m=a.hole;if(m){const g=(n=m.shapePath)==null?void 0:n.shapePrimitives;if(g)for(let x=0;x<g.length;x++)g[x].shape.contains(p.x,p.y)&&(i=!1)}if(i)return!0}}return i}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(t=!1){if(this.destroyed)return;if(this.destroyed=!0,this._stateStack.length=0,this._transform=null,this.unload(),this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0: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}};Pi.defaultFillStyle={color:16777215,alpha:1,texture:q.WHITE,matrix:null,fill:null,textureSpace:"local"};Pi.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:q.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Mt=Pi,re;function zn(s){const t=ot.get().createCanvas(6,1),e=t.getContext("2d");return e.fillStyle=s,e.fillRect(0,0,6,1),t}function Tc(){if(re!==void 0)return re;try{const s=zn("#ff00ff"),t=zn("#ffff00"),i=ot.get().createCanvas(6,1).getContext("2d");i.globalCompositeOperation="multiply",i.drawImage(s,0,0),i.drawImage(t,2,0);const n=i.getImageData(2,0,1,1);if(!n)re=!1;else{const r=n.data;re=r[0]===255&&r[1]===0&&r[2]===0}}catch{re=!1}return re}const Z={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Tc(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:s=>{const t=s.source,e=t==null?void 0:t.resource;if(!e)return null;const i=t.alphaMode==="premultiplied-alpha",n=t.resourceWidth??t.pixelWidth,r=t.resourceHeight??t.pixelHeight,o=n!==t.pixelWidth||r!==t.pixelHeight;if(i){if((e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)&&!o)return e;const a=Z._unpremultipliedCache.get(t);if((a==null?void 0:a.resourceId)===t._resourceId)return a.canvas}if(e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Uint32Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof ArrayBuffer){const a=Z._canvasSourceCache.get(t);if((a==null?void 0:a.resourceId)===t._resourceId)return a.canvas;const h=ot.get().createCanvas(t.pixelWidth,t.pixelHeight),l=h.getContext("2d"),c=l.createImageData(t.pixelWidth,t.pixelHeight),u=c.data,f=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(t.format==="bgra8unorm")for(let d=0;d<u.length&&d+3<f.length;d+=4)u[d]=f[d+2],u[d+1]=f[d+1],u[d+2]=f[d],u[d+3]=f[d+3];else u.set(f.subarray(0,u.length));return l.putImageData(c,0,0),Z._canvasSourceCache.set(t,{canvas:h,resourceId:t._resourceId}),h}if(i){const a=ot.get().createCanvas(t.pixelWidth,t.pixelHeight),h=a.getContext("2d",{willReadFrequently:!0});a.width=t.pixelWidth,a.height=t.pixelHeight,h.drawImage(e,0,0);const l=h.getImageData(0,0,a.width,a.height),c=l.data;for(let u=0;u<c.length;u+=4){const f=c[u+3];if(f>0){const d=255/f;c[u]=Math.min(255,c[u]*d+.5),c[u+1]=Math.min(255,c[u+1]*d+.5),c[u+2]=Math.min(255,c[u+2]*d+.5)}}return h.putImageData(l,0,0),Z._unpremultipliedCache.set(t,{canvas:a,resourceId:t._resourceId}),a}if(o){const a=Z._canvasSourceCache.get(t);if((a==null?void 0:a.resourceId)===t._resourceId)return a.canvas;const h=ot.get().createCanvas(t.pixelWidth,t.pixelHeight),l=h.getContext("2d");return h.width=t.pixelWidth,h.height=t.pixelHeight,l.drawImage(e,0,0),Z._canvasSourceCache.set(t,{canvas:h,resourceId:t._resourceId}),h}return e},getTintedCanvas:(s,t)=>{const e=s.texture,i=J.shared.setValue(t).toHex(),n=e.tintCache||(e.tintCache={}),r=n[i],o=e.source._resourceId;if((r==null?void 0:r.tintId)===o)return r;const a=r&&"getContext"in r?r:ot.get().createCanvas();return Z.tintMethod(e,t,a),a.tintId=o,n[i]=a,n[i]},getTintedPattern:(s,t)=>{const e=J.shared.setValue(t).toHex(),i=s.patternCache||(s.patternCache={}),n=s.source._resourceId;let r=i[e];return(r==null?void 0:r.tintId)===n||(Z.canvas||(Z.canvas=ot.get().createCanvas()),Z.tintMethod(s,t,Z.canvas),r=Z.canvas.getContext("2d").createPattern(Z.canvas,"repeat"),r.tintId=n,i[e]=r),r},applyPatternTransform:(s,t,e=!0)=>{if(!t)return;const i=s;if(!i.setTransform)return;const n=globalThis.DOMMatrix;if(!n)return;const r=new n([t.a,t.b,t.c,t.d,t.tx,t.ty]);i.setTransform(e?r.inverse():r)},tintWithMultiply:(s,t,e)=>{const i=e.getContext("2d"),n=s.frame.clone(),r=s.source._resolution??s.source.resolution??1,o=s.rotate;n.x*=r,n.y*=r,n.width*=r,n.height*=r;const a=U.isVertical(o),h=a?n.height:n.width,l=a?n.width:n.height;e.width=Math.ceil(h),e.height=Math.ceil(l),i.save(),i.fillStyle=J.shared.setValue(t).toHex(),i.fillRect(0,0,h,l),i.globalCompositeOperation="multiply";const c=Z.getCanvasSource(s);if(!c){i.restore();return}o&&Z._applyInverseRotation(i,o,n.width,n.height),i.drawImage(c,n.x,n.y,n.width,n.height,0,0,n.width,n.height),i.globalCompositeOperation="destination-atop",i.drawImage(c,n.x,n.y,n.width,n.height,0,0,n.width,n.height),i.restore()},tintWithOverlay:(s,t,e)=>{const i=e.getContext("2d"),n=s.frame.clone(),r=s.source._resolution??s.source.resolution??1,o=s.rotate;n.x*=r,n.y*=r,n.width*=r,n.height*=r;const a=U.isVertical(o),h=a?n.height:n.width,l=a?n.width:n.height;e.width=Math.ceil(h),e.height=Math.ceil(l),i.save(),i.globalCompositeOperation="copy",i.fillStyle=J.shared.setValue(t).toHex(),i.fillRect(0,0,h,l),i.globalCompositeOperation="destination-atop";const c=Z.getCanvasSource(s);if(!c){i.restore();return}o&&Z._applyInverseRotation(i,o,n.width,n.height),i.drawImage(c,n.x,n.y,n.width,n.height,0,0,n.width,n.height),i.restore()},tintWithPerPixel:(s,t,e)=>{const i=e.getContext("2d"),n=s.frame.clone(),r=s.source._resolution??s.source.resolution??1,o=s.rotate;n.x*=r,n.y*=r,n.width*=r,n.height*=r;const a=U.isVertical(o),h=a?n.height:n.width,l=a?n.width:n.height;e.width=Math.ceil(h),e.height=Math.ceil(l),i.save(),i.globalCompositeOperation="copy";const c=Z.getCanvasSource(s);if(!c){i.restore();return}o&&Z._applyInverseRotation(i,o,n.width,n.height),i.drawImage(c,n.x,n.y,n.width,n.height,0,0,n.width,n.height),i.restore();const u=t>>16&255,f=t>>8&255,d=t&255,p=i.getImageData(0,0,h,l),m=p.data;for(let g=0;g<m.length;g+=4)m[g]=m[g]*u/255,m[g+1]=m[g+1]*f/255,m[g+2]=m[g+2]*d/255;i.putImageData(p,0,0)},_applyInverseRotation:(s,t,e,i)=>{const n=U.inv(t),r=U.uX(n),o=U.uY(n),a=U.vX(n),h=U.vY(n),l=-Math.min(0,r*e,a*i,r*e+a*i),c=-Math.min(0,o*e,h*i,o*e+h*i);s.transform(r,o,a,h,l,c)}};Z.tintMethod=Z.canUseMultiply?Z.tintWithMultiply:Z.tintWithPerPixel;class Mc{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=ot.get().createCanvas();i.width=t,i.height=e;const n=i.getContext("2d");return{canvas:i,context:n}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=de(t),e=de(e);const n=(t<<17)+(e<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let r=this._canvasPool[n].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:n}=e,r=(i<<17)+(n<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,n),this._canvasPool[r].push(t)}clear(){this._canvasPool={}}}const ui=new Mc;Oe.register(ui);const Ac=new St;function Pc(s,t,e,i,n=!1){const r=Ac;r.minX=0,r.minY=0,r.maxX=s.width/i|0,r.maxY=s.height/i|0;const o=us.getOptimalTexture(r.width,r.height,i,!1,n);return o.source.uploadMethodId="image",o.source.resource=s,o.source.alphaMode="premultiply-alpha-on-upload",o.frame.width=t/i,o.frame.height=e/i,o.source.emit("update",o.source),o.updateUvs(),o}class kc{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class Ic{constructor(){this.instructions=new xi}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const ki=class di{constructor(t){this._renderer=t,this._managedContexts=new We({renderer:t,type:"resource",name:"graphicsContext"})}init(t){di.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??di.defaultOptions.bezierSmoothness}getContextRenderData(t){return this.getGpuContext(t).graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=t._gpuData,i=!!e[this._renderer.uid],n=e[this._renderer.uid]||this._initContext(t);return(t.dirty||!i)&&(i&&n.reset(),n.isBatchable=!1,t.dirty=!1),n}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=new Ic,i=this.getGpuContext(t);return i.graphicsData=e,e.init(),e}_initContext(t){const e=new kc;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};ki.extension={type:[z.CanvasSystem],name:"graphicsContext"};ki.defaultOptions={bezierSmoothness:.5};let Rc=ki;class co{constructor(t,e){this.state=Fr.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new We({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){return!1}addRenderable(t,e){this._managedGraphics.add(t),this.renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){t.isRenderable&&this._adaptor.execute(this,t)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}}co.extension={type:[z.CanvasPipes],name:"graphics"};function Ec(s,t,e){const i=(s>>24&255)/255;t[e++]=(s&255)/255*i,t[e++]=(s>>8&255)/255*i,t[e++]=(s>>16&255)/255*i,t[e++]=i}class Bc{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{yt.return(t)}),this.batches.length=0}}class uo{constructor(t,e){this.state=Fr.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new We({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,i=!!t._gpuData,r=this.renderer.graphicsContext.updateGpuContext(e);return!!(r.isBatchable||i!==r.isBatchable)}addRenderable(t,e){const n=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),n.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const i=this._getGpuDataForRenderable(t).batches;for(let n=0;n<i.length;n++){const r=i[n];r._batcher.updateElement(r)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,i=t.context;if(!e.graphicsContext.getGpuContext(i).batches.length)return;const r=i.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const o=r.resources.localUniforms.uniforms;o.uTransformMatrix=t.groupTransform,o.uRound=e._roundPixels|t._roundPixels,Ec(t.groupColorAlpha,o.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),n=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),n.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const i=this.renderer.renderPipes.batch,n=this._getGpuDataForRenderable(t).batches;for(let r=0;r<n.length;r++){const o=n[r];i.addToBatch(o,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new Bc;return t._gpuData[this.renderer.uid]=e,this._managedGraphics.add(t),e}_updateBatchesForRenderable(t,e){const i=t.context,r=this.renderer.graphicsContext.getGpuContext(i),o=this.renderer._roundPixels|t._roundPixels;e.batches=r.batches.map(a=>{const h=yt.get(Ci);return a.copyTo(h),h.renderable=t,h.roundPixels=o,h})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}uo.extension={type:[z.WebGLPipes,z.WebGPUPipes],name:"graphics"};nt.add(co);nt.add(uo);nt.add(Rc);nt.add(Ai);class De extends yi{constructor(t){t instanceof Mt&&(t={context:t});const{context:e,roundPixels:i,...n}=t||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",e?this.context=e:(this.context=this._ownedContext=new Mt,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=i??!1}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===!0||(t==null?void 0:t.context)===!0)&&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=!1){return t?new De(this._context.clone()):(this._ownedContext=null,new De(this._context))}lineStyle(t,e,i){H(et,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const n={};return t&&(n.width=t),e&&(n.color=e),i&&(n.alpha=i),this.context.strokeStyle=n,this}beginFill(t,e){H(et,"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(){H(et,"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 H(et,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return H(et,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return H(et,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return H(et,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return H(et,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return H(et,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}class Fc extends yi{constructor(t,e){const{text:i,resolution:n,style:r,anchor:o,width:a,height:h,roundPixels:l,...c}=t;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i??"",this.style=r,this.resolution=n??null,this.allowChildren=!1,this._anchor=new ct({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),this.roundPixels=l??!1,a!==void 0&&(this.width=a),h!==void 0&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t||(t={}),(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.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.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,n=-e*this.anchor.x;let r=0;return t.x>=n&&t.x<=n+e&&(r=-i*this.anchor.y,t.y>=r&&t.y<=r+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function Lc(s,t){let e=s[0]??{};return(typeof e=="string"||s[1])&&(H(et,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:s[1]}),e}let Yt=null,Ft=null;function Gc(s,t){Yt||(Yt=ot.get().createCanvas(256,128),Ft=Yt.getContext("2d",{willReadFrequently:!0}),Ft.globalCompositeOperation="copy",Ft.globalAlpha=1),(Yt.width<s||Yt.height<t)&&(Yt.width=de(s),Yt.height=de(t))}function On(s,t,e){for(let i=0,n=4*e*t;i<t;++i,n+=4)if(s[n+3]!==0)return!1;return!0}function Wn(s,t,e,i,n){const r=4*t;for(let o=i,a=i*r+4*e;o<=n;++o,a+=r)if(s[a+3]!==0)return!1;return!0}function $c(...s){let t=s[0];t.canvas||(t={canvas:s[0],resolution:s[1]});const{canvas:e}=t,i=Math.min(t.resolution??1,1),n=t.width??e.width,r=t.height??e.height;let o=t.output;if(Gc(n,r),!Ft)throw new TypeError("Failed to get canvas 2D context");Ft.drawImage(e,0,0,n,r,0,0,n*i,r*i);const h=Ft.getImageData(0,0,n,r).data;let l=0,c=0,u=n-1,f=r-1;for(;c<r&&On(h,n,c);)++c;if(c===r)return it.EMPTY;for(;On(h,n,f);)--f;for(;Wn(h,n,l,c,f);)++l;for(;Wn(h,n,u,c,f);)--u;return++u,++f,Ft.globalCompositeOperation="source-over",Ft.strokeRect(l,c,u-l,f-c),Ft.globalCompositeOperation="copy",o??(o=new it),o.set(l/i,c/i,(u-l)/i,(f-c)/i),o}/**
|
|
240
|
+
* tiny-lru
|
|
241
|
+
*
|
|
242
|
+
* @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
243
|
+
* @license BSD-3-Clause
|
|
244
|
+
* @version 11.4.7
|
|
245
|
+
*/class Dc{constructor(t=0,e=0,i=!1){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 n=t[i];e[i]=[n,this.get(n)]}return e}evict(t=!1){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 n=null;if(this.has(t))this.set(t,e,!0,i);else{this.max>0&&this.size===this.max&&(n={...this.first},this.evict(!0));let r=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=r:this.last.next=r,this.last=r}return n}set(t,e,i=!1,n=this.resetTtl){let r=this.items[t];return i||r!==void 0?(r.value=e,i===!1&&n&&(r.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(r)):(this.max>0&&this.size===this.max&&this.evict(!0),r=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=r:this.last.next=r,this.last=r),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 zc(s=1e3,t=0,e=!1){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 Dc(s,t,e)}function fo(s){return!!s.tagStyles&&Object.keys(s.tagStyles).length>0}function po(s){return s.includes("<")}function Oc(s,t){return s.clone().assign(t)}function Wc(s,t){const e=[],i=t.tagStyles;if(!fo(t)||!po(s))return e.push({text:s,style:t}),e;const n=[t],r=[];let o="",a=0;for(;a<s.length;){const h=s[a];if(h==="<"){const l=s.indexOf(">",a);if(l===-1){o+=h,a++;continue}const c=s.indexOf("<",a+1);if(c!==-1&&c<l){o+=h,a++;continue}const u=s.slice(a+1,l);if(u.startsWith("/")){const f=u.slice(1).trim();if(r.length>0&&r[r.length-1]===f){o.length>0&&(e.push({text:o,style:n[n.length-1]}),o=""),n.pop(),r.pop(),a=l+1;continue}else{o+=s.slice(a,l+1),a=l+1;continue}}else{const f=u.trim();if(i[f]){o.length>0&&(e.push({text:o,style:n[n.length-1]}),o="");const d=n[n.length-1],p=Oc(d,i[f]);n.push(p),r.push(f),a=l+1;continue}else{o+=s.slice(a,l+1),a=l+1;continue}}}else o+=h,a++}return o.length>0&&e.push({text:o,style:n[n.length-1]}),e}const Uc=[10,13],Nc=new Set(Uc),Hc=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Vc=new Set(Hc),Xc=[9,32];new Set(Xc);const Yc=[45,8208,8211,8212,173],jc=new Set(Yc),qc=/(\r\n|\r|\n)/,Kc=/(?:\r\n|\r|\n)/;function ls(s){return typeof s!="string"?!1:Nc.has(s.charCodeAt(0))}function wt(s,t){return typeof s!="string"?!1:Vc.has(s.charCodeAt(0))}function Zc(s){return typeof s!="string"?!1:jc.has(s.charCodeAt(0))}function go(s){return s==="normal"||s==="pre-line"}function mo(s){return s==="normal"}function Bt(s){if(typeof s!="string")return"";let t=s.length-1;for(;t>=0&&wt(s[t]);)t--;return t<s.length-1?s.slice(0,t+1):s}function xo(s){const t=[],e=[];if(typeof s!="string")return t;for(let i=0;i<s.length;i++){const n=s[i],r=s[i+1];if(wt(n)||ls(n)){e.length>0&&(t.push(e.join("")),e.length=0),n==="\r"&&r===`
|
|
246
|
+
`?(t.push(`\r
|
|
247
|
+
`),i++):t.push(n);continue}e.push(n),Zc(n)&&r&&!wt(r)&&!ls(r)&&(t.push(e.join("")),e.length=0)}return e.length>0&&t.push(e.join("")),t}function yo(s,t,e,i){const n=e(s),r=[];for(let o=0;o<n.length;o++){let a=n[o],h=a,l=1;for(;n[o+l];){const c=n[o+l];if(!i(h,c,s,o,t))a+=c,h=c,l++;else break}o+=l-1,r.push(a)}return r}const Qc=/\r\n|\r|\n/g;function Jc(s,t,e,i,n,r,o,a,h){var G,at;const l=Wc(s,t);if(mo(t.whiteSpace))for(let A=0;A<l.length;A++){const B=l[A];l[A]={text:B.text.replace(Qc," "),style:B.style}}const u=[];let f=[];for(const A of l){const B=A.text.split(qc);for(let Y=0;Y<B.length;Y++){const F=B[Y];F===`\r
|
|
248
|
+
`||F==="\r"||F===`
|
|
249
|
+
`?(u.push(f),f=[]):F.length>0&&f.push({text:F,style:A.style})}}(f.length>0||u.length===0)&&u.push(f);const d=e?tu(u,t,i,r,a,h):u,p=[],m=[],g=[],x=[],y=[];let _=0;const b=t._fontString,S=o(b);S.fontSize===0&&(S.fontSize=t.fontSize,S.ascent=t.fontSize);let w="",v=!!t.dropShadow,R=((G=t._stroke)==null?void 0:G.width)||0;for(const A of d){let B=0,Y=S.ascent,F=S.descent,O="";for(const C of A){const E=C.style._fontString,$=o(E);E!==w&&(i.font=E,w=E);const V=n(C.text,C.style.letterSpacing,i);B+=V,Y=Math.max(Y,$.ascent),F=Math.max(F,$.descent),O+=C.text;const W=((at=C.style._stroke)==null?void 0:at.width)||0;W>R&&(R=W),!v&&C.style.dropShadow&&(v=!0)}A.length===0&&(Y=S.ascent,F=S.descent),p.push(B),m.push(Y),g.push(F),y.push(O);const K=t.lineHeight||Y+F;x.push(K+t.leading),_=Math.max(_,B)}const T=R,M=_+T+(t.dropShadow?t.dropShadow.distance:0);let P=0;for(let A=0;A<x.length;A++)P+=x[A];P=Math.max(P,x[0]+T);const k=P+(t.dropShadow?t.dropShadow.distance:0),I=t.lineHeight||S.fontSize;return{width:M,height:k,lines:y,lineWidths:p,lineHeight:I+t.leading,maxLineWidth:_,fontProperties:S,runsByLine:d,lineAscents:m,lineDescents:g,lineHeights:x,hasDropShadow:v}}function tu(s,t,e,i,n,r){var g;const{letterSpacing:o,whiteSpace:a,wordWrapWidth:h,breakWords:l}=t,c=go(a),u=h+o,f={};let d="";const p=(x,y)=>{const _=`${x}|${y.styleKey}`;let b=f[_];if(b===void 0){const S=y._fontString;S!==d&&(e.font=S,d=S),b=i(x,y.letterSpacing,e)+y.letterSpacing,f[_]=b}return b},m=[];for(const x of s){const y=eu(x),_=m.length,b=k=>{let I=0,G=k;do{const{token:at,style:A}=y[G];I+=p(at,A),G++}while(G<y.length&&y[G].continuesFromPrevious);return I},S=k=>{const I=[];let G=k;do I.push({token:y[G].token,style:y[G].style}),G++;while(G<y.length&&y[G].continuesFromPrevious);return I};let w=[],v=0,R=!c,T=null;const M=()=>{T&&T.text.length>0&&w.push(T),T=null},P=()=>{if(M(),w.length>0){const k=w[w.length-1];k.text=Bt(k.text),k.text.length===0&&w.pop()}m.push(w),w=[],v=0,R=!1};for(let k=0;k<y.length;k++){const{token:I,style:G,continuesFromPrevious:at}=y[k],A=p(I,G);if(c){const F=wt(I),O=(T==null?void 0:T.text[T.text.length-1])??((g=w[w.length-1])==null?void 0:g.text.slice(-1))??"",K=O?wt(O):!1;if(F&&K)continue}const B=!at,Y=B?b(k):A;if(Y>u&&B)if(v>0&&P(),l){const F=S(k);for(let O=0;O<F.length;O++){const K=F[O].token,C=F[O].style,E=yo(K,l,r,n);for(const $ of E){const V=p($,C);V+v>u&&P(),!T||T.style!==C?(M(),T={text:$,style:C}):T.text+=$,v+=V}}k+=F.length-1}else{const F=S(k);M(),m.push(F.map(O=>({text:O.token,style:O.style}))),R=!1,k+=F.length-1}else if(Y+v>u&&B){if(wt(I)){R=!1;continue}P(),T={text:I,style:G},v=A}else if(at&&!l)!T||T.style!==G?(M(),T={text:I,style:G}):T.text+=I,v+=A;else{const F=wt(I);if(v===0&&F&&!R)continue;!T||T.style!==G?(M(),T={text:I,style:G}):T.text+=I,v+=A}}if(M(),w.length>0){const k=w[w.length-1];k.text=Bt(k.text),k.text.length===0&&w.pop()}(w.length>0||m.length===_)&&m.push(w)}return m}function eu(s){const t=[];let e=!1;for(const i of s){const n=xo(i.text);let r=!0;for(const o of n){const a=wt(o)||ls(o),h=r&&e&&!a;t.push({token:o,style:i.style,continuesFromPrevious:h}),e=!a,r=!1}}return t}const su={willReadFrequently:!0};function Un(s,t,e,i,n){let r=e[s];return typeof r!="number"&&(r=n(s,t,i)+t,e[s]=r),r}function iu(s,t,e,i,n,r,o){const a=e.getContext("2d",su);a.font=t._fontString;let h=0,l="";const c=[],u=Object.create(null),{letterSpacing:f,whiteSpace:d}=t,p=go(d),m=mo(d);let g=!p;const x=t.wordWrapWidth+f,y=xo(s);for(let b=0;b<y.length;b++){let S=y[b];if(ls(S)){if(!m){c.push(Bt(l)),g=!p,l="",h=0;continue}S=" "}if(p){const v=wt(S),R=wt(l[l.length-1]);if(v&&R)continue}const w=Un(S,f,u,a,i);if(w>x)if(l!==""&&(c.push(Bt(l)),l="",h=0),n(S,t.breakWords)){const v=yo(S,t.breakWords,o,r);for(const R of v){const T=Un(R,f,u,a,i);T+h>x&&(c.push(Bt(l)),g=!1,l="",h=0),l+=R,h+=T}}else l.length>0&&(c.push(Bt(l)),l="",h=0),c.push(Bt(S)),g=!1,l="",h=0;else w+h>x&&(g=!1,c.push(Bt(l)),l="",h=0),(l.length>0||!wt(S)||g)&&(l+=S,h+=w)}const _=Bt(l);return _.length>0&&c.push(_),c.join(`
|
|
250
|
+
`)}const Nn={willReadFrequently:!0},zt=class D{static get experimentalLetterSpacingSupported(){let t=D._experimentalLetterSpacingSupported;if(t===void 0){const e=ot.get().getCanvasRenderingContext2D().prototype;t=D._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,n,r,o,a,h,l,c){this.text=t,this.style=e,this.width=i,this.height=n,this.lines=r,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=h,this.fontProperties=l,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(t=" ",e,i=D._canvas,n=e.wordWrap){var b;const r=`${t}-${e.styleKey}-wordWrap-${n}`;if(D._measurementCache.has(r))return D._measurementCache.get(r);if(fo(e)&&po(t)){const S=Jc(t,e,n,D._context,D._measureText,D._measureTextAdvance,D.measureFont,D.canBreakChars,D.wordWrapSplit),w=new D(t,e,S.width,S.height,S.lines,S.lineWidths,S.lineHeight,S.maxLineWidth,S.fontProperties,{runsByLine:S.runsByLine,lineAscents:S.lineAscents,lineDescents:S.lineDescents,lineHeights:S.lineHeights,hasDropShadow:S.hasDropShadow});return D._measurementCache.set(r,w),w}const a=e._fontString,h=D.measureFont(a);h.fontSize===0&&(h.fontSize=e.fontSize,h.ascent=e.fontSize,h.descent=0);const l=D._context;l.font=a;const u=(n?D._wordWrap(t,e,i):t).split(Kc),f=new Array(u.length);let d=0;for(let S=0;S<u.length;S++){const w=D._measureText(u[S],e.letterSpacing,l);f[S]=w,d=Math.max(d,w)}const p=((b=e._stroke)==null?void 0:b.width)??0,m=e.lineHeight||h.fontSize,g=D._adjustWidthForStyle(d,e),x=Math.max(m,h.fontSize+p)+(u.length-1)*(m+e.leading),y=D._adjustHeightForStyle(x,e),_=new D(t,e,g,y,u,f,m+e.leading,d,h);return D._measurementCache.set(r,_),_}static _adjustWidthForStyle(t,e){var r;const i=((r=e._stroke)==null?void 0:r.width)||0;let n=t+i;return e.dropShadow&&(n+=e.dropShadow.distance),n}static _adjustHeightForStyle(t,e){let i=t;return e.dropShadow&&(i+=e.dropShadow.distance),i}static _measureText(t,e,i){const{metricWidth:n,metrics:r,letterSpacingVal:o}=D._measureTextCore(t,e,i),a=-(r.actualBoundingBoxLeft??0);let l=(r.actualBoundingBoxRight??0)-a;return r.width>0&&(l+=o),Math.max(n,l)}static _measureTextAdvance(t,e,i){return D._measureTextCore(t,e,i).metricWidth}static _measureTextCore(t,e,i){let n=!1;D.experimentalLetterSpacingSupported&&(D.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,n=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const r=i.measureText(t);let o=r.width,a=0;return o>0&&(n?a=-e:a=(D.graphemeSegmenter(t).length-1)*e,o+=a),{metricWidth:o,metrics:r,letterSpacingVal:a}}static _wordWrap(t,e,i=D._canvas){return iu(t,e,i,D._measureTextAdvance,D.canBreakWords,D.canBreakChars,D.wordWrapSplit)}static isBreakingSpace(t,e){return wt(t)}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,n,r){return!0}static wordWrapSplit(t){return D.graphemeSegmenter(t)}static measureFont(t){if(D._fonts[t])return D._fonts[t];const e=D._context;e.font=t;const i=e.measureText(D.METRICS_STRING+D.BASELINE_SYMBOL),n=i.actualBoundingBoxAscent??0,r=i.actualBoundingBoxDescent??0,o={ascent:n,descent:r,fontSize:n+r};return D._fonts[t]=o,o}static clearMetrics(t=""){t?delete D._fonts[t]:D._fonts={}}static get _canvas(){if(!D.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",Nn);if(i!=null&&i.measureText)return D.__canvas=e,e;t=ot.get().createCanvas()}catch{t=ot.get().createCanvas()}t.width=t.height=10,D.__canvas=t}return D.__canvas}static get _context(){return D.__context||(D.__context=D._canvas.getContext("2d",Nn)),D.__context}};zt.METRICS_STRING="|ÉqÅ";zt.BASELINE_SYMBOL="M";zt.BASELINE_MULTIPLIER=1.4;zt.HEIGHT_MULTIPLIER=2;zt.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>{const e=s.segment(t),i=[];let n=0;for(const r of e)i[n++]=r.segment;return i}}return s=>[...s]})();zt.experimentalLetterSpacing=!1;zt._fonts={};zt._measurementCache=zc(1e3);let Ot=zt;const nu=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function fi(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 n=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!nu.includes(n)&&(n=`"${n}"`),e[i]=n}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}const Hn=1e5;function es(s,t,e,i=0,n=0,r=0){if(s.texture===q.WHITE&&!s.fill)return J.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof gs){const o=s.fill,a=t.createPattern(o.texture.source.resource,"repeat");return Z.applyPatternTransform(a,o.transform,!1),a}else if(s.fill instanceof Dt){const o=s.fill,a=o.type==="linear",h=o.textureSpace==="local";let l=1,c=1;h&&e&&(l=e.width+i,c=e.height+i);let u,f=!1;if(a){const{start:d,end:p}=o;u=t.createLinearGradient(d.x*l+n,d.y*c+r,p.x*l+n,p.y*c+r),f=Math.abs(p.x-d.x)<Math.abs((p.y-d.y)*.1)}else{const{center:d,innerRadius:p,outerCenter:m,outerRadius:g}=o;u=t.createRadialGradient(d.x*l+n,d.y*c+r,p*l,m.x*l+n,m.y*c+r,g*l)}if(f&&h&&e){const d=e.lineHeight/c;for(let p=0;p<e.lines.length;p++){const m=(p*e.lineHeight+i/2)/c;o.colorStops.forEach(g=>{let x=m+g.offset*d;x=Math.max(0,Math.min(1,x)),u.addColorStop(Math.floor(x*Hn)/Hn,J.shared.setValue(g.color).toHex())})}}else o.colorStops.forEach(d=>{u.addColorStop(d.offset,J.shared.setValue(d.color).toHex())});return u}}else{const o=t.createPattern(s.texture.source.resource,"repeat"),a=s.matrix.copyTo(N.shared);return a.scale(s.texture.source.pixelWidth,s.texture.source.pixelHeight),o.setTransform(a),o}return mt("FillStyle not recognised",s),"red"}const Vn=new it;function oe(s){let t=0;for(let e=0;e<s.length;e++)s.charCodeAt(e)===32&&t++;return t}class ru{getCanvasAndContext(t){const{text:e,style:i,resolution:n=1}=t,r=i._getFinalPadding(),o=Ot.measureText(e||" ",i),a=Math.ceil(Math.ceil(Math.max(1,o.width)+r*2)*n),h=Math.ceil(Math.ceil(Math.max(1,o.height)+r*2)*n),l=ui.getOptimalCanvasAndContext(a,h);this._renderTextToCanvas(i,r,n,l,o);const c=i.trim?$c({canvas:l.canvas,width:a,height:h,resolution:1,output:Vn}):Vn.set(0,0,a,h);return{canvasAndContext:l,frame:c}}returnCanvasAndContext(t){ui.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,i,n,r){var S,w,v;if(r.runsByLine&&r.runsByLine.length>0){this._renderTaggedTextToCanvas(r,t,e,i,n);return}const{canvas:o,context:a}=n,h=fi(t),l=r.lines,c=r.lineHeight,u=r.lineWidths,f=r.maxLineWidth,d=r.fontProperties,p=o.height;if(a.resetTransform(),a.scale(i,i),a.textBaseline=t.textBaseline,(S=t._stroke)!=null&&S.width){const R=t._stroke;a.lineWidth=R.width,a.miterLimit=R.miterLimit,a.lineJoin=R.join,a.lineCap=R.cap}a.font=h;let m,g;const x=t.dropShadow?2:1,_=(((w=t._stroke)==null?void 0:w.width)??0)/2;let b=(c-d.fontSize)/2;c-d.fontSize<0&&(b=0);for(let R=0;R<x;++R){const T=t.dropShadow&&R===0,M=T?Math.ceil(Math.max(1,p)+e*2):0,P=M*i;if(T)this._setupDropShadow(a,t,i,P);else{const k=t._gradientBounds,I=t._gradientOffset;if(k){const G={width:k.width,height:k.height,lineHeight:k.height,lines:r.lines};this._setFillAndStrokeStyles(a,t,G,e,_,(I==null?void 0:I.x)??0,(I==null?void 0:I.y)??0)}else I?this._setFillAndStrokeStyles(a,t,r,e,_,I.x,I.y):this._setFillAndStrokeStyles(a,t,r,e,_);a.shadowColor="rgba(0,0,0,0)"}for(let k=0;k<l.length;k++){m=_,g=_+k*c+d.ascent+b,m+=this._getAlignmentOffset(u[k],f,t.align);let I=0;if(t.align==="justify"&&t.wordWrap&&k<l.length-1){const G=oe(l[k]);G>0&&(I=(f-u[k])/G)}(v=t._stroke)!=null&&v.width&&this._drawLetterSpacing(l[k],t,n,m+e,g+e-M,!0,I),t._fill!==void 0&&this._drawLetterSpacing(l[k],t,n,m+e,g+e-M,!1,I)}}}_renderTaggedTextToCanvas(t,e,i,n,r){var _,b,S;const{canvas:o,context:a}=r,{runsByLine:h,lineWidths:l,maxLineWidth:c,lineAscents:u,lineHeights:f,hasDropShadow:d}=t,p=o.height;a.resetTransform(),a.scale(n,n),a.textBaseline=e.textBaseline;const m=d?2:1;let g=((_=e._stroke)==null?void 0:_.width)??0;for(const w of h)for(const v of w){const R=((b=v.style._stroke)==null?void 0:b.width)??0;R>g&&(g=R)}const x=g/2,y=[];for(let w=0;w<h.length;w++){const v=h[w],R=[];for(const T of v){const M=fi(T.style);a.font=M,R.push({width:Ot._measureText(T.text,T.style.letterSpacing,a),font:M})}y.push(R)}for(let w=0;w<m;++w){const v=d&&w===0,R=v?Math.ceil(Math.max(1,p)+i*2):0,T=R*n;v||(a.shadowColor="rgba(0,0,0,0)");let M=x;for(let P=0;P<h.length;P++){const k=h[P],I=l[P],G=u[P],at=f[P],A=y[P];let B=x;B+=this._getAlignmentOffset(I,c,e.align);let Y=0;if(e.align==="justify"&&e.wordWrap&&P<h.length-1){let K=0;for(const C of k)K+=oe(C.text);K>0&&(Y=(c-I)/K)}const F=M+G;let O=B+i;for(let K=0;K<k.length;K++){const C=k[K],{width:E,font:$}=A[K];if(a.font=$,a.textBaseline=C.style.textBaseline,(S=C.style._stroke)!=null&&S.width){const W=C.style._stroke;if(a.lineWidth=W.width,a.miterLimit=W.miterLimit,a.lineJoin=W.join,a.lineCap=W.cap,v)if(C.style.dropShadow)this._setupDropShadow(a,C.style,n,T);else{const j=oe(C.text);O+=E+j*Y;continue}else{const j=Ot.measureFont($),ft=C.style.lineHeight||j.fontSize,Ct={width:E,height:ft,lineHeight:ft,lines:[C.text]};a.strokeStyle=es(W,a,Ct,i*2,O-i,M)}this._drawLetterSpacing(C.text,C.style,r,O,F+i-R,!0,Y)}const V=oe(C.text);O+=E+V*Y}O=B+i;for(let K=0;K<k.length;K++){const C=k[K],{width:E,font:$}=A[K];if(a.font=$,a.textBaseline=C.style.textBaseline,C.style._fill!==void 0){if(v)if(C.style.dropShadow)this._setupDropShadow(a,C.style,n,T);else{const W=oe(C.text);O+=E+W*Y;continue}else{const W=Ot.measureFont($),j=C.style.lineHeight||W.fontSize,ft={width:E,height:j,lineHeight:j,lines:[C.text]};a.fillStyle=es(C.style._fill,a,ft,i*2,O-i,M)}this._drawLetterSpacing(C.text,C.style,r,O,F+i-R,!1,Y)}const V=oe(C.text);O+=E+V*Y}M+=at}}}_setFillAndStrokeStyles(t,e,i,n,r,o=0,a=0){var h;if(t.fillStyle=e._fill?es(e._fill,t,i,n*2,o,a):null,(h=e._stroke)!=null&&h.width){const l=r+n*2;t.strokeStyle=es(e._stroke,t,i,l,o,a)}}_setupDropShadow(t,e,i,n){t.fillStyle="black",t.strokeStyle="black";const r=e.dropShadow,o=r.color,a=r.alpha;t.shadowColor=J.shared.setValue(o).setAlpha(a).toRgbaString();const h=r.blur*i,l=r.distance*i;t.shadowBlur=h,t.shadowOffsetX=Math.cos(r.angle)*l,t.shadowOffsetY=Math.sin(r.angle)*l+n}_getAlignmentOffset(t,e,i){return i==="right"?e-t:i==="center"?(e-t)/2:0}_drawLetterSpacing(t,e,i,n,r,o=!1,a=0){const{context:h}=i,l=e.letterSpacing;let c=!1;if(Ot.experimentalLetterSpacingSupported&&(Ot.experimentalLetterSpacing?(h.letterSpacing=`${l}px`,h.textLetterSpacing=`${l}px`,c=!0):(h.letterSpacing="0px",h.textLetterSpacing="0px")),(l===0||c)&&a===0){o?h.strokeText(t,n,r):h.fillText(t,n,r);return}if(a!==0&&(l===0||c)){const m=t.split(" ");let g=n;const x=h.measureText(" ").width;for(let y=0;y<m.length;y++)o?h.strokeText(m[y],g,r):h.fillText(m[y],g,r),g+=h.measureText(m[y]).width+x+a;return}let u=n;const f=Ot.graphemeSegmenter(t);let d=h.measureText(t).width,p=0;for(let m=0;m<f.length;++m){const g=f[m];o?h.strokeText(g,u,r):h.fillText(g,u,r);let x="";for(let y=m+1;y<f.length;++y)x+=f[y];p=h.measureText(x).width,u+=d-p+l,g===" "&&(u+=a),d=p}}}const ue=new ru,Ii=class Jt extends It{constructor(t={}){super(),this.uid=st("textStyle"),this._tick=0,this._cachedFontString=null,ou(t),t instanceof Jt&&(t=t._toObject());const n={...Jt.defaultTextStyle,...t};for(const r in n){const o=r;this[o]=n[r]}this._tagStyles=t.tagStyles??void 0,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({...Jt.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...Jt.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=te({...this._originalFill},Mt.defaultFillStyle)})),this._fill=te(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=hs({...this._originalStroke},Mt.defaultStrokeStyle)})),this._stroke=hs(t,Mt.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const t=Jt.defaultTextStyle;for(const e in t)this[e]=t[e]}assign(t){for(const e in t){const i=e;this[i]=t[e]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=fi(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill?{...this._fill}:void 0,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?{...this._stroke}:void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?{...this._tagStyles}:void 0}}clone(){return new Jt(this._toObject())}_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=!1){var i,n,r,o;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const a=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(i=this._fill)!=null&&i.texture&&this._fill.texture.destroy(a),(n=this._originalFill)!=null&&n.texture&&this._originalFill.texture.destroy(a),(r=this._stroke)!=null&&r.texture&&this._stroke.texture.destroy(a),(o=this._originalStroke)!=null&&o.texture&&this._originalStroke.texture.destroy(a)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(i,n,r)=>(i[n]===r||(i[n]=r,e==null||e(n,r),this.update()),!0)})}_isFillStyle(t){return(t??null)!==null&&!(J.isColorLike(t)||t instanceof Dt||t instanceof gs)}};Ii.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Ii.defaultTextStyle={align:"left",breakWords:!1,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:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let me=Ii;function ou(s){const t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=me.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){H(et,"strokeThickness is now a part of stroke");const e=t.stroke;let i={};if(J.isColorLike(e))i.color=e;else if(e instanceof Dt||e instanceof gs)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(H(et,"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&&mt("The number of fill colors must match the number of fill gradient stops.");const e=new Dt({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),i=t.fillGradientStops.slice(),n=t.fill.map(r=>J.shared.setValue(r).toNumber());i.forEach((r,o)=>{e.addColorStop(r,n[o])}),s.fill={fill:e}}}function au(s,t){const{texture:e,bounds:i}=s,n=t._style._getFinalPadding();er(i,t._anchor,e);const r=t._anchor._x*n*2,o=t._anchor._y*n*2;i.minX-=n-r,i.minY-=n-o,i.maxX-=n-r,i.maxY-=n-o}class hu{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}class lu extends hu{}class _o{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new We({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i?!0:t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const n=t._autoResolution?this._renderer.resolution:t.resolution;(i.currentKey!==t.styleKey||t._resolution!==n)&&this._updateGpuText(t),t._didTextUpdate=!1,au(i,t)}this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new lu;return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{canvasText:i}=this._renderer;i.getReferenceCount(e.currentKey)>0?i.decreaseReferenceCount(e.currentKey):e.texture&&i.returnTexture(e.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}_o.extension={type:[z.WebGLPipes,z.WebGPUPipes,z.CanvasPipes],name:"text"};class bo{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,i,n){typeof t=="string"&&(H("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:i,resolution:e}),t.style instanceof me||(t.style=new me(t.style)),t.textureStyle instanceof fe||(t.textureStyle=new fe(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:r,style:o,textureStyle:a,autoGenerateMipmaps:h}=t,l=t.resolution??this._renderer.resolution,{frame:c,canvasAndContext:u}=ue.getCanvasAndContext({text:r,style:o,resolution:l}),f=Pc(u.canvas,c.width,c.height,l,h);if(a&&(f.source.style=a),o.trim&&(c.pad(o.padding),f.frame.copyFrom(c),f.frame.scale(1/l),f.updateUvs()),o.filters){const d=this._applyFilters(f,o.filters);return this.returnTexture(f),ue.returnCanvasAndContext(u),d}return this._renderer.texture.initSource(f._source),this._retainCanvasContext||ue.returnCanvasAndContext(u),f}returnTexture(t){const e=t.source,i=e.resource;if(this._retainCanvasContext&&(i!=null&&i.getContext)){const n=i.getContext("2d");n&&ue.returnCanvasAndContext({canvas:i,context:n})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",us.returnTexture(t,!0)}renderTextToCanvas(){H("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const i=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle,autoGenerateMipmaps:t.autoGenerateMipmaps});return this._activeTextures[e]={texture:i,usageCount:1},i}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null))}getReferenceCount(t){var e;return((e=this._activeTextures[t])==null?void 0:e.usageCount)??0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const i=this._renderer.renderTarget.renderTarget,n=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(i,!1),n}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}class wo extends bo{constructor(t){super(t,!0)}}wo.extension={type:[z.CanvasSystem],name:"canvasText"};class So extends bo{constructor(t){super(t,!1)}}So.extension={type:[z.WebGLSystem,z.WebGPUSystem],name:"canvasText"};nt.add(wo);nt.add(So);nt.add(_o);class cu extends Fc{constructor(...t){const e=Lc(t,"Text");super(e,me),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof fe?e.textureStyle:new fe(e.textureStyle)),this.autoGenerateMipmaps=e.autoGenerateMipmaps??vt.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,n=0;if(this._style.trim){const{frame:r,canvasAndContext:o}=ue.getCanvasAndContext({text:this.text,style:this._style,resolution:1});ue.returnCanvasAndContext(o),i=r.width,n=r.height}else{const r=Ot.measureText(this._text,this._style);i=r.width,n=r.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}}nt.add(Ro,Eo);const uu={repulsion:2e3,spring:.02,restLength:60,gravity:.01,damping:.85},Ns=30;class Xn{constructor(t,e=uu){X(this,"nodes");X(this,"index",new Map);X(this,"edges");this.params=e;const i=Math.max(t.nodes.length,1);this.nodes=t.nodes.map((n,r)=>{this.index.set(n.id,r);const o=2*Math.PI*r/i;return{id:n.id,x:Math.cos(o)*200,y:Math.sin(o)*200,vx:0,vy:0}}),this.edges=[];for(const n of t.edges){const r=this.index.get(n.src),o=this.index.get(n.dst);r!==void 0&&o!==void 0&&this.edges.push([r,o])}}step(){const{repulsion:t,spring:e,restLength:i,gravity:n,damping:r}=this.params,o=this.nodes.length;for(let a=0;a<o;a++){const h=this.nodes[a];for(let l=a+1;l<o;l++){const c=this.nodes[l];let u=h.x-c.x,f=h.y-c.y,d=u*u+f*f;d<.01&&(u=(a-l)*.01+.01,f=.01,d=u*u+f*f);const p=t/d,m=Math.sqrt(d),g=u/m*p,x=f/m*p;h.vx+=g,h.vy+=x,c.vx-=g,c.vy-=x}}for(const[a,h]of this.edges){const l=this.nodes[a],c=this.nodes[h],u=c.x-l.x,f=c.y-l.y,d=Math.sqrt(u*u+f*f)||.01,p=e*(d-i),m=u/d*p,g=f/d*p;l.vx+=m,l.vy+=g,c.vx-=m,c.vy-=g}for(const a of this.nodes){a.vx=(a.vx-a.x*n)*r,a.vy=(a.vy-a.y*n)*r;const h=Math.hypot(a.vx,a.vy);h>Ns&&(a.vx=a.vx/h*Ns,a.vy=a.vy/h*Ns),a.x+=a.vx,a.y+=a.vy}}bounds(){let t=1/0,e=1/0,i=-1/0,n=-1/0;for(const r of this.nodes)r.x<t&&(t=r.x),r.x>i&&(i=r.x),r.y<e&&(e=r.y),r.y>n&&(n=r.y);return Number.isFinite(t)?{minX:t,minY:e,maxX:i,maxY:n}:{minX:0,minY:0,maxX:0,maxY:0}}run(t){for(let e=0;e<t;e++)this.step()}normalize(t){const{minX:e,minY:i,maxX:n,maxY:r}=this.bounds(),o=(e+n)/2,a=(i+r)/2,h=t/Math.max(n-e,r-i,1);for(const l of this.nodes)l.x=(l.x-o)*h,l.y=(l.y-a)*h,l.vx=0,l.vy=0}relax(t,e){const i=this.nodes.length;for(let n=0;n<e;n++){let r=!1;for(let o=0;o<i;o++){const a=this.nodes[o];for(let h=o+1;h<i;h++){const l=this.nodes[h];let c=l.x-a.x,u=l.y-a.y,f=Math.sqrt(c*c+u*u);if(f<1e-6&&(c=(h-o)*.01+.01,u=.01,f=Math.sqrt(c*c+u*u)),f<t){const d=(t-f)/2,p=c/f,m=u/f;a.x-=p*d,a.y-=m*d,l.x+=p*d,l.y+=m*d,r=!0}}}if(!r)break}this.recenter()}recenter(){const{minX:t,minY:e,maxX:i,maxY:n}=this.bounds(),r=(t+i)/2,o=(e+n)/2;for(const a of this.nodes)a.x-=r,a.y-=o}position(t){const e=this.index.get(t);return e===void 0?void 0:{x:this.nodes[e].x,y:this.nodes[e].y}}}const du=6187730,fu=2303274,ns=8556543,pu={gold:14201418,critical:14048348,warn:14721850,info:ns};function gu(s,t){if(!s)return t;const e=Number.parseInt(s.replace("#",""),16);return Number.isNaN(e)?t:e}function mu(s){if(s.kind==="task")return s.ref?s.ref.slice(0,7):"commit";const t=s.label;if(s.level==="module")return t;const e=t.split("::");if(e.length>1)return e[e.length-1]||t;const i=t.split("/");return i[i.length-1]||t}const lt=class lt{constructor(){X(this,"app",new jr);X(this,"world",new kt);X(this,"edges",new De);X(this,"nodeGraphics",new Map);X(this,"labels",new kt);X(this,"nodeLabels",new Map);X(this,"artifactLabelStyle",new me({fontFamily:"Inter, system-ui, sans-serif",fontSize:12,fill:9080728}));X(this,"commitLabelStyle",new me({fontFamily:"JetBrains Mono, ui-monospace, monospace",fontSize:11,fill:8556543}));X(this,"snapshot",{repo:"",nodes:[],edges:[]});X(this,"layout",new Xn(this.snapshot));X(this,"byId",new Map);X(this,"zoom",1);X(this,"level","file");X(this,"highlights",new Set);X(this,"highlightSeverity",new Map);X(this,"selectedId",null);X(this,"timeCutoff",Number.POSITIVE_INFINITY);X(this,"onSelect",()=>{});X(this,"onDeselect",()=>{});X(this,"onViewChange",()=>{})}async init(t){await this.app.init({background:"#010102",resizeTo:t,antialias:!0}),t.appendChild(this.app.canvas),this.app.stage.addChild(this.world),this.world.addChild(this.edges),this.edges.eventMode="none",this.world.addChild(this.labels),this.labels.eventMode="none",this.app.stage.eventMode="static",this.app.stage.hitArea=this.app.screen,this.installPanAndZoom(t),this.app.ticker.add(()=>this.draw())}setSnapshot(t){this.snapshot=t,this.byId=new Map(t.nodes.map(e=>[e.id,e])),this.layout=new Xn(t),this.layout.run(lt.SETTLE_ITERS),this.layout.normalize(lt.LAYOUT_SPAN),this.layout.relax(lt.MIN_NODE_DIST,lt.RELAX_ITERS);for(const e of this.nodeGraphics.values())e.destroy();this.nodeGraphics.clear();for(const e of this.nodeLabels.values())e.destroy();this.nodeLabels.clear();for(const e of t.nodes){const i=new De;i.eventMode="static",i.cursor="pointer",i.label=e.id,this.world.addChild(i),this.nodeGraphics.set(e.id,i);const n=new cu({text:mu(e),style:e.kind==="task"?this.commitLabelStyle:this.artifactLabelStyle});n.anchor.set(.5,0),n.eventMode="none",n.resolution=3,this.labels.addChild(n),this.nodeLabels.set(e.id,n)}this.world.addChild(this.labels),this.frameLevel()}visibleAtLevel(t){return t.kind==="task"?this.level==="file"||this.level==="symbol":t.level===this.level}setLevel(t){this.level=t,this.frameLevel()}frameLevel(){const t=this.app.screen.width,e=this.app.screen.height;let i=1/0,n=1/0,r=-1/0,o=-1/0;for(const d of this.snapshot.nodes){if(!this.visibleAtLevel(d))continue;const p=this.layout.position(d.id);p&&(p.x<i&&(i=p.x),p.x>r&&(r=p.x),p.y<n&&(n=p.y),p.y>o&&(o=p.y))}if(!Number.isFinite(i)){this.zoom=1,this.world.scale.set(1),this.world.position.set(t/2,e/2),this.onViewChange(this.zoom,this.level);return}const a=1.16,h=(r-i)*a||1,l=(o-n)*a||1,c=Math.min(lt.FIT_MAX_ZOOM,Math.max(lt.MIN_ZOOM,Math.min(t/h,e/l))),u=(i+r)/2,f=(n+o)/2;this.zoom=c,this.world.scale.set(c),this.world.position.set(t/2-u*c,e/2-f*c),this.onViewChange(this.zoom,this.level)}setZoom(t){const e=Math.min(lt.MAX_ZOOM,Math.max(lt.MIN_ZOOM,t)),i=this.app.screen.width/2,n=this.app.screen.height/2,r=(i-this.world.x)/this.zoom,o=(n-this.world.y)/this.zoom;this.zoom=e,this.world.scale.set(e),this.world.position.set(i-r*e,n-o*e),this.onViewChange(this.zoom,this.level)}zoomBy(t){this.setZoom(this.zoom*t)}resetView(){this.frameLevel()}setHighlights(t,e){this.selectedId=null,this.highlights=t,this.highlightSeverity=e??new Map}setSelection(t){this.selectedId=t,this.highlightSeverity=new Map;const e=new Set;if(t){e.add(t);for(const i of this.snapshot.edges)i.src===t?e.add(i.dst):i.dst===t&&e.add(i.src)}this.highlights=e}setTimeCutoff(t){this.timeCutoff=t}nodeRadius(t){if(t.kind==="task")return 7;switch(t.level){case"repo":return 16;case"module":return 12;case"file":return 9;default:return 6}}isVisible(t){return t.timestamp&&Date.parse(t.timestamp)>this.timeCutoff?!1:this.highlights.has(t.id)?!0:this.visibleAtLevel(t)}draw(){for(const i of this.snapshot.nodes){const n=this.nodeGraphics.get(i.id),r=this.layout.position(i.id),o=this.nodeLabels.get(i.id);if(!n||!r)continue;const a=this.isVisible(i);if(n.visible=a,o&&(o.visible=a),!a)continue;n.position.set(r.x,r.y),n.clear();const h=this.nodeRadius(i),l=i.kind==="task"?du:gu(i.colorHex,7239297);n.circle(0,0,h).fill(l);let c=1;if(i.id===this.selectedId)n.stroke({width:3.5,color:ns});else if(this.highlights.has(i.id)){const u=this.highlightSeverity.get(i.id);n.stroke({width:u&&u!=="info"?3:2,color:pu[u??"info"]??ns})}else c=this.highlights.size>0?.28:1;n.alpha=c,o&&(o.scale.set(1/this.zoom),o.position.set(r.x,r.y+h+7/this.zoom),o.alpha=c)}const t=this.selectedId!==null,e=t||this.highlights.size>0;this.edges.clear();for(const i of this.snapshot.edges){const n=this.byId.get(i.src),r=this.byId.get(i.dst);if(!n||!r||!this.isVisible(n)||!this.isVisible(r))continue;const o=this.layout.position(i.src),a=this.layout.position(i.dst);if(!o||!a)continue;const h=t?i.src===this.selectedId||i.dst===this.selectedId:this.highlights.has(i.src)&&this.highlights.has(i.dst);this.edges.moveTo(o.x,o.y).lineTo(a.x,a.y).stroke({width:h?2:1,color:h?ns:fu,alpha:e&&!h?.12:1})}}installPanAndZoom(t){let e=!1,i=!1,n=0,r=0,o=0,a=0,h=null;const l=4;this.app.stage.on("pointerdown",u=>{var d;e=!0,i=!1,n=o=u.globalX,r=a=u.globalY;const f=((d=u.target)==null?void 0:d.label)??"";h=this.byId.has(f)?f:null}),this.app.stage.on("globalpointermove",u=>{e&&(Math.hypot(u.globalX-o,u.globalY-a)>l&&(i=!0),this.world.x+=u.globalX-n,this.world.y+=u.globalY-r,n=u.globalX,r=u.globalY)});const c=()=>{if(e&&!i){const u=h?this.byId.get(h):void 0;u?(this.setSelection(u.id),this.onSelect(u)):(this.selectedId!==null||this.highlights.size>0)&&(this.setSelection(null),this.onDeselect())}e=!1,h=null};this.app.stage.on("pointerup",c),this.app.stage.on("pointerupoutside",c),t.addEventListener("wheel",u=>{u.preventDefault(),this.zoomBy(u.deltaY<0?1.1:1/1.1)}),this.world.position.set(this.app.screen.width/2,this.app.screen.height/2)}};X(lt,"SETTLE_ITERS",400),X(lt,"LAYOUT_SPAN",1400),X(lt,"MIN_NODE_DIST",120),X(lt,"RELAX_ITERS",160),X(lt,"MIN_ZOOM",.1),X(lt,"MAX_ZOOM",12),X(lt,"FIT_MAX_ZOOM",2.5);let pi=lt;function ut(s){const t=document.getElementById(s);if(!t)throw new Error(`missing element #${s}`);return t}async function xu(){const s=ut("stage"),t=ut("prompt"),e=ut("send"),i=ut("promptbar"),n=ut("timeline"),r=ut("panel"),o=ut("refresh"),a=ut("refresh-status"),h=new Po,l=new pi;await l.init(s);const c=r.innerHTML;let u=null,f=null;const d=new Set;let p=null;const m=async C=>{var W;const E=C.dataset.ref,$=(W=C.parentElement)==null?void 0:W.querySelector(".diff-slot");if(!E||!$||$.dataset.loaded==="1")return;C.textContent="loading…";const V=await h.diff(E);$.dataset.loaded="1",$.style.display="block",$.innerHTML=V.encrypted?'<p class="muted">payload encrypted — re-run ingest with --no-encrypt-payload to preview</p>':V.diff?Su(V.diff):'<p class="muted">diff not available — the payload is encrypted (.enc) or none was stored. Re-run: <code>brain0 ingest … --no-encrypt-payload</code></p>',C.textContent="Hide details"},g=()=>{r.querySelectorAll("button.see-details[data-autoload]").forEach(C=>void m(C))},x=(C,E)=>{u=C,r.scrollTop=0,h.detail(C).then($=>{if(u!==C)return;if(!$){r.innerHTML='<p class="muted">not found</p>';return}const V=E!=null&&E.results?'<button class="back-link" data-back="results">← back to results</button>':E!=null&&E.commit?`<button class="back-link" data-commit="${L(E.commit)}">← back to commit</button>`:"",W={kind:$.kind==="artifact"?"artifact":"task",label:$.label};r.innerHTML=V+Yn(W,$),g()}).catch(()=>{u===C&&(r.innerHTML='<p class="muted">failed to load</p>')})},y=(C,E)=>{const $=new Map,V=new Set,W=(j,ft)=>{d.has(j)&&(V.add(j),ft&&$.set(j,ft))};for(const j of C.tasks)W(j);for(const j of C.artifacts)W(j);for(const j of E)j.kind!=="version"&&W(j.id,j.severity);l.setHighlights(V,$)},_=()=>{if(!p){r.innerHTML=c;return}u=null,y(p.result,p.findings),r.scrollTop=0,r.innerHTML=Hs(p.result,p.findings)};l.onSelect=C=>{u=C.id,C.kind==="task"&&(f=C.id),r.scrollTop=0,r.innerHTML=`${Vs(C)}<p class="muted">loading…</p>`,h.detail(C.id).then(E=>{u===C.id&&(E?(r.innerHTML=Yn(C,E),g()):r.innerHTML=Vs(C))}).catch(()=>{u===C.id&&(r.innerHTML=Vs(C))})},l.onDeselect=()=>{u=null,r.scrollTop=0,r.innerHTML=p?Hs(p.result,p.findings):c};const b=ut("lod"),S=ut("zoom-pct"),w=Array.from(b.querySelectorAll(".lod-step"));l.onViewChange=(C,E)=>{S.textContent=`${Math.round(C*100)}%`;for(const $ of w)$.classList.toggle("active",$.dataset.level===E)},ut("zoom-in").addEventListener("click",()=>l.zoomBy(1.3)),ut("zoom-out").addEventListener("click",()=>l.zoomBy(1/1.3)),ut("zoom-fit").addEventListener("click",()=>l.resetView());for(const C of w)C.addEventListener("click",()=>{const E=C.dataset.level;E&&l.setLevel(E)});r.addEventListener("click",C=>{var Ut;const E=C.target,$=E.closest(".prompt-item");if($){const rt=$.dataset.task;rt&&x(rt,f?{commit:f}:void 0);return}const V=E.closest(".back-link");if(V){if(V.dataset.back==="results"){_();return}const rt=V.dataset.commit;rt&&x(rt);return}const W=E.closest(".finding-card");if(W){const rt=W.dataset.id;rt&&(d.has(rt)&&l.setSelection(rt),x(rt,{results:!0}));return}const j=E.closest(".chip-more");if(j){const rt=j.closest(".chips");if(rt){const Rt=rt.classList.toggle("expanded");j.textContent=Rt?"show less":`+${j.dataset.count} more`}return}const ft=E.closest(".see-details");if(!ft)return;const Ct=(Ut=ft.parentElement)==null?void 0:Ut.querySelector(".diff-slot");if(Ct){if(Ct.dataset.loaded==="1"){const rt=Ct.style.display!=="none";Ct.style.display=rt?"none":"block",ft.textContent=rt?"See details":"Hide details";return}m(ft)}});let v;try{v=await h.load()}catch{r.innerHTML='<h3>No data</h3><p class="muted">Run the brain0 observer and serve <code>graph.json</code> + <code>/api/debug</code>.</p>';return}const R=ut("tl-start"),T=ut("tl-end"),M=ut("tl-now"),P=C=>new Date(C).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),k=C=>{const E=Math.round(C*100);n.style.background=`linear-gradient(90deg, var(--accent) ${E}%, var(--hairline-strong) ${E}%)`},I={minTime:0,maxTime:0,hasTime:!1},G=()=>{const C=Number(n.value)/100;if(!I.hasTime){l.setTimeCutoff(Number.POSITIVE_INFINITY),M.textContent="all",k(1);return}const E=I.minTime+(I.maxTime-I.minTime)*C;l.setTimeCutoff(C>=1?Number.POSITIVE_INFINITY:E),M.textContent=C>=1?"all":`≤ ${P(E)}`,k(C)};n.addEventListener("input",G);const at=C=>{l.setSnapshot(C),d.clear();for(const $ of C.nodes)d.add($.id);const E=C.nodes.map($=>$.timestamp?Date.parse($.timestamp):NaN).filter($=>!Number.isNaN($));I.minTime=E.length?Math.min(...E):0,I.maxTime=E.length?Math.max(...E):0,I.hasTime=E.length>0&&I.maxTime>I.minTime,R.textContent=I.hasTime?P(I.minTime):"—",T.textContent=I.hasTime?P(I.maxTime):"—",n.disabled=!I.hasTime,G()};at(v);let A=null;o.addEventListener("click",()=>{o.disabled||(o.disabled=!0,a.textContent="refreshing…",(async()=>{const C=await h.refresh();if(C.state==="error"){a.textContent=C.error??"failed",o.disabled=!1;return}A!==null&&clearInterval(A),A=setInterval(()=>{(async()=>{const E=await h.refreshStatus();if(E.state==="running")a.textContent=E.lines.at(-1)??E.phase??"working…";else if(E.state==="done"){A!==null&&clearInterval(A);const $=await h.load();at($),u&&!$.nodes.some(V=>V.id===u)&&(u=null,r.innerHTML=c),a.textContent="updated",o.disabled=!1}else E.state==="error"&&(A!==null&&clearInterval(A),a.textContent=E.error??"failed",o.disabled=!1)})()},1e3)})())});const B=()=>{t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,168)}px`},Y=()=>{const C=t.value.trim().length>0;e.disabled=!C,e.classList.toggle("ready",C)},F=()=>{const C=t.value.trim();C&&(K(C),t.value="",B(),Y())};t.addEventListener("input",()=>{B(),Y()}),t.addEventListener("keydown",C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),F())}),i.addEventListener("submit",C=>{C.preventDefault(),F()}),Y();let O=0;async function K(C){r.scrollTop=0,r.innerHTML='<p class="muted">searching…</p>';const E=++O;h.debug(C,"retrieve").then(W=>{if(E!==O||W.error)return;y(W,W.findings??[]);const j=W.tasks.length+W.artifacts.length;r.innerHTML=`<p class="muted">${j} related node(s) highlighted — thinking…</p>`}).catch(()=>{});let $;try{if($=await h.debug(C),E!==O)return}catch{r.innerHTML='<p class="muted">request failed — is the server running?</p>';return}const V=$.findings??[];p={result:$,findings:V},y($,V),u=null,r.innerHTML=Hs($,V)}}function Hs(s,t){var u,f;const e=s.intent??"debug",i=e==="audit"?"Audit":"Debug",n=`<div class="hd"><div class="hd-top"><span class="badge badge-${e}">${e}</span>`+(s.confidence!==void 0&&s.confidence<.34&&!s.error?'<span class="muted" style="font-size:11px">low confidence — rephrase to steer debug/audit</span>':"")+`</div><div class="hd-title">${i}</div></div>`;let r="";const o=s.provider;if(o)if(o.zeroEgress)r=`<p class="ask-notice ok">model: ${L(o.name)} · local, zero egress</p>`;else{const d=[];d.push(o.remote?`LLM ${L(o.name)} (remote, redacted)`:`LLM ${L(o.name)} (local)`),(u=o.embedder)!=null&&u.remote&&d.push(`embeddings ${L(o.embedder.name)} (remote, redacted)`),r=`<p class="ask-notice warn">${d.join(" · ")} — not zero-egress</p>`}const a=s.error?'<p class="ask-notice err">⚠ No LLM reachable — run <code>ollama serve</code> or set an API key / <code>BRAIN0_LLM_*</code>. Showing retrieval highlights only.</p>':"";let h="";if(e==="audit"&&s.distribution){const d=s.distribution,p=(f=s.goldSignals)!=null&&f.length?` · <b>${s.goldSignals.length}</b> gold (safe→dangerous)`:"";h=`<h4>risk across the repo</h4><div class="dist"><span class="dist-g">${d.green} safe</span> · <span class="dist-y">${d.yellow} watch</span> · <span class="dist-r">${d.red} risky</span>${p}</div>`}const l=s.explanation?`<p class="ask-explain">${L(s.explanation)}</p>`:"";let c="";if(t.length){const d=t.map(p=>{const m=p.path?Lt(p.path):p.id,g=p.external?'<span class="read-ext">external read</span>':"",x=p.verdict?`<span class="f-verdict">${L(p.verdict)}</span>`:"";return`<button class="finding-card sev-${p.severity}" data-id="${L(p.id)}"><span class="f-top"><span class="sev-dot"></span>${L(p.severity)}${x}${g}</span><span class="f-name">${L(m)}</span><span class="f-reason">${L(p.reason)}</span></button>`}).join("");c=`<h4>findings (${t.length})</h4><div class="finding-list">${d}</div>`}return`${n}${r}${a}${l}${h}${c}`}function Vs(s){if(s.kind==="task"){const i=[];return s.ref&&i.push(pt(`<span class="k">commit</span> ${L(s.ref.slice(0,10))}`)),s.author&&i.push(pt(`<span class="k">by</span> ${L(s.author)}`)),s.timestamp&&i.push(pt(ze(s.timestamp),s.timestamp)),`<div class="hd"><div class="hd-top"><span class="badge badge-commit">commit</span></div><div class="hd-title">Commit</div><div class="pills">${i.join("")}</div><div class="hd-id">${L(s.id)}</div></div>`}const t=Lt(s.label),e=[];if(s.risk){const i=vo(s.risk);e.push(pt(`<span class="dot" style="background:${L(s.colorHex??"#8a8f98")}"></span>risk ${i.label} · ${i.score.toFixed(2)}`))}return`<div class="hd"><div class="hd-top"><span class="badge badge-artifact">${L(s.level??"code")}</span><span class="hd-title hd-title-sm">${L(t)}</span></div><div class="pills">${e.join("")}</div></div>`}function ze(s){const t=Date.parse(s);if(Number.isNaN(t))return s;const e=Math.max(0,Math.round((Date.now()-t)/1e3));if(e<60)return"just now";const i=Math.round(e/60);if(i<60)return`${i}m ago`;const n=Math.round(i/60);if(n<24)return`${n}h ago`;const r=Math.round(n/24);if(r<30)return`${r}d ago`;const o=Math.round(r/30);return o<12?`${o}mo ago`:`${Math.round(o/12)}y ago`}function Lt(s){const t=s.split("/");return t[t.length-1]||s}function pt(s,t){return`<span class="pill"${t?` title="${L(t)}"`:""}>${s}</span>`}function vo(s){const t=Math.max(0,Math.min(1,s.apriori)),e=Math.max(0,Math.min(1,s.aposteriori)),i=1-(1-t)*(1-e);return{label:i<.34?"low":i<.67?"medium":"high",score:i}}function yu(s,t){var o;if(t.kind==="task"){const a=t.versions[t.versions.length-1],h=(o=a==null?void 0:a.summary)==null?void 0:o.trim(),l=h?L(cs(h,180)):"Coding intent",c=[];t.agent&&c.push(pt(`<span class="k">agent</span> ${L(t.agent)}`)),t.author&&c.push(pt(`<span class="k">by</span> ${L(t.author)}`)),t.createdAt&&c.push(pt(ze(t.createdAt),t.createdAt));const u=t.versions.length;return c.push(pt(`${u} turn${u===1?"":"s"}`)),`<div class="hd"><div class="hd-top"><span class="badge badge-task">intent</span></div><div class="hd-title">${l}</div><div class="pills">${c.join("")}</div><div class="hd-id">${L(t.id)}</div></div>`}const e=t.path??t.label,i=Lt(e),n=[];if(s.risk){const a=vo(s.risk);n.push(pt(`<span class="dot" style="background:${L(s.colorHex??"#8a8f98")}"></span>risk ${a.label} · ${a.score.toFixed(2)}`,`a-priori ${s.risk.apriori.toFixed(2)} · a-posteriori ${s.risk.aposteriori.toFixed(2)}`))}t.childCount&&n.push(pt(`${t.childCount} children`));const r=t.versions[t.versions.length-1];return r!=null&&r.timestamp&&n.push(pt(`changed ${ze(r.timestamp)}`,r.timestamp)),`<div class="hd"><div class="hd-top"><span class="badge badge-artifact">${L(t.level??"code")}</span><span class="hd-title hd-title-sm">${L(i)}</span></div>`+(i!==e?`<div class="hd-sub">${L(e)}</div>`:"")+`<div class="pills">${n.join("")}</div></div>`}function _u(s){const t=s.indexOf(`
|
|
251
|
+
`);return(t===-1?s:s.slice(0,t)).trim()}function bu(s){var m,g;const t=(m=s.message)==null?void 0:m.trim(),e=t?L(cs(_u(t),200)):"Commit",i=[];s.author&&i.push(pt(`<span class="k">by</span> ${L(s.author)}`)),s.source&&i.push(pt(`<span class="k">commit</span> ${L(s.source)}`)),s.createdAt&&i.push(pt(ze(s.createdAt),s.createdAt));const n=((g=s.changedFiles)==null?void 0:g.length)??0;i.push(pt(`${n} file${n===1?"":"s"}`));const r=`<div class="hd"><div class="hd-top"><span class="badge badge-commit">commit</span></div><div class="hd-title">${e}</div><div class="pills">${i.join("")}</div><div class="hd-id">${L(s.id)}</div></div>`,o=t&&t.split(`
|
|
252
|
+
`).length>1?`<pre class="commit-msg">${L(t)}</pre>`:"",a=s.prompts??[];let h;if(a.length){const x=a.map(y=>{var w;const _=(w=y.summary)!=null&&w.trim()?L(cs(y.summary.trim(),240)):"(no summary)",b=[y.agent,y.author].filter(Boolean).map(v=>L(v)).join(" · "),S=y.when?` · ${L(ze(y.when))}`:"";return`<button class="prompt-item" data-task="${L(y.taskId)}"><span class="prompt-sum">${_}</span><span class="prompt-meta">${b}${S}</span></button>`}).join("");h=`<h4>prompts behind this commit (${a.length})</h4><div class="prompt-list">${x}</div>`}else h='<h4>prompts behind this commit</h4><p class="muted">no agent prompt linked to these files</p>';const l=s.reads??[],c=s.readSecrets??[];let u="";if(l.length||c.length){const x=T=>T.startsWith("/")||/^[A-Za-z]:[\\/]/.test(T),y=new Set(c.map(T=>T.path)),_=T=>{const M=T.split("/").filter(Boolean);return M.length>1?M.slice(-2).join("/"):T},b=c.map(T=>({text:`${Lt(T.path)} · ${T.kinds[0]??"secret"}`,title:`${T.path} — ${T.kinds.join(", ")}`,cls:"chip-secret"})),S=l.filter(T=>x(T)&&!y.has(T)).map(T=>({text:_(T),title:T,cls:"chip-external"})),w=l.filter(T=>!x(T)&&!y.has(T)).map(T=>({text:Lt(T),title:T,cls:""})),v=[];b.length&&v.push(Xs("⚠ read secrets","these files' CONTENT held secrets when the agent read them (kinds only — values are never stored)",b)),S.length&&v.push(Xs("outside the repo","reads from outside the project tree that reached the model's context",S)),w.length&&v.push(Xs("repo files","project files loaded into the model's context",w));const R=[`${l.length} read`,c.length?`${c.length} with secrets`:"",S.length?`${S.length} external`:""].filter(Boolean).join(" · ");u=`<h4>files read for this commit</h4><p class="read-sum">${L(R)}</p><div class="vfiles">${v.join("")}</div>`}const f=s.changedFiles??[];let d="";if(f.length){const x=f.map(y=>{const _=y.changeKind?`<span class="cf-kind">${L(y.changeKind)}</span>`:"",b=y.linesAdded!==void 0||y.linesRemoved!==void 0?`<span class="cf-stat"><span class="add">+${y.linesAdded??0}</span> <span class="del">−${y.linesRemoved??0}</span></span>`:"",S=y.diffRef?`<button class="see-details" data-ref="${L(y.diffRef)}">See details</button><div class="diff-slot" style="display:none"></div>`:"";return`<div class="cf"><div class="cf-head"><code class="cf-path">${L(y.path)}</code>${_}${b}</div>`+S+"</div>"}).join("");d=`<h4>files changed (${f.length})</h4><div class="cf-list">${x}</div>`}const p=s.note?`<p class="muted">⚠ ${L(s.note)}</p>`:"";return`${r}${o}${h}${u}${d}${p}`}function Yn(s,t){if(t.kind==="commit")return bu(t);const e=t.kind,i=yu(s,t);let n="";t.kind==="artifact"&&t.intents&&(t.intents.length?n=`<h4>changed by intent</h4><ul>${t.intents.map(c=>`<li>${L(c.agent||"?")}${c.author?` (${L(c.author)})`:""} — ${L(c.when)}</li>`).join("")}</ul>`:n='<h4>changed by intent</h4><p class="muted">no agent intent linked — recorded only as a git commit by its committer</p>');const r=t.kind==="artifact"&&(t.level==="file"||t.level==="symbol"),o=t.versions.slice(-8).reverse().map((l,c)=>wu(e,l,r&&c===0)).join(""),a=t.note?`<p class="muted">⚠ ${L(t.note)}</p>`:"",h=t.versions.length;return`${i}${n}<h4>history (${h} version${h===1?"":"s"})</h4>${o}${a}`}function wu(s,t,e=!1){const i=[];if(i.push(`<div class="ts">${L(t.timestamp)}</div>`),s==="artifact"){const n=[];if(t.changeKind&&n.push(L(t.changeKind)),(t.linesAdded!==void 0||t.linesRemoved!==void 0)&&n.push(`+${t.linesAdded??0}/-${t.linesRemoved??0}`),t.committer&&n.push(`committed by ${L(t.committer)}`),t.source&&n.push(L(t.source)),n.length&&i.push(`<div>${n.join(" · ")}</div>`),t.diffRef){t.diffOfPath&&i.push(`<div class="muted">diff of containing file: <code>${L(t.diffOfPath)}</code></div>`);const r=e?" data-autoload":"";i.push(`<button class="see-details" data-ref="${L(t.diffRef)}"${r}>See details</button><div class="diff-slot" style="display:none"></div>`)}}else{t.summary&&i.push(`<p class="vsum">${L(cs(t.summary,600))}</p>`);const n=[];t.declared&&t.declared.length&&n.push(Ys("declared","files this turn said it changed",t.declared,"")),t.driftUndeclared&&t.driftUndeclared.length&&n.push(Ys("⚠ changed, not declared","the agent changed these without saying so",t.driftUndeclared,"undeclared")),t.driftPhantom&&t.driftPhantom.length&&n.push(Ys("declared, not observed","the agent said it changed these, but no change was seen",t.driftPhantom,"phantom")),n.length&&i.push(`<div class="vfiles">${n.join("")}</div>`)}return`<div class="version">${i.join("")}</div>`}function Xs(s,t,e){const n=e.map((o,a)=>`<span class="chip${o.cls?` ${o.cls}`:""}${a>=12?" chip-hidden":""}" title="${L(o.title)}">${L(o.text)}</span>`).join(""),r=e.length>12?`<button class="chip chip-more" data-count="${e.length-12}">+${e.length-12} more</button>`:"";return`<div class="vf-row"><span class="vf-label" title="${L(t)}">${L(s)}</span><span class="chips">${n}${r}</span></div>`}function Ys(s,t,e,i){const r=new Map;for(const c of e)r.set(Lt(c),(r.get(Lt(c))??0)+1);const o=c=>(r.get(Lt(c))??0)<2?Lt(c):c.split("/").slice(-2).join("/"),a=i?` chip-${i}`:"",h=e.map((c,u)=>`<span class="chip${a}${u>=12?" chip-hidden":""}" title="${L(c)}">${L(o(c))}</span>`).join(""),l=e.length>12?`<button class="chip chip-more" data-count="${e.length-12}">+${e.length-12} more</button>`:"";return`<div class="vf-row"><span class="vf-label" title="${L(t)}">${L(s)}</span><span class="chips">${h}${l}</span></div>`}function cs(s,t){return s.length>t?`${s.slice(0,t)}… (${s.length} chars)`:s}function Su(s){const e=s.split(`
|
|
253
|
+
`),n=e.slice(0,4e3).map(o=>{let a="ctx";return o.startsWith("+++")||o.startsWith("---")?a="meta":o.startsWith("+")?a="add":o.startsWith("-")?a="del":o.startsWith("@@")?a="hunk":(o.startsWith("diff ")||o.startsWith("index "))&&(a="meta"),`<span class="dl ${a}">${L(o)||" "}</span>`}).join(`
|
|
254
|
+
`),r=e.length>4e3?`
|
|
255
|
+
<span class="dl meta">… ${e.length-4e3} more lines</span>`:"";return`<pre class="diff">${n}${r}</pre>`}function L(s){return s.replace(/[&<>"]/g,t=>t==="&"?"&":t==="<"?"<":t===">"?">":""")}xu();export{rr as $,Ur as A,Ge as B,J as C,ot as D,It as E,Dt as F,fs as G,cn as H,is as I,_i as J,zr as K,vt as L,N as M,Er as N,ui as O,dt as P,dl as Q,ei as R,bi as S,q as T,os as U,pl as V,wl as W,yl as X,Ho as Y,Cl as Z,yt as _,Fr as a,St as a0,us as a1,Yi as a2,Re as a3,hu as a4,wa as a5,qi as a6,Ts as a7,Ki as a8,va as a9,fe as aa,it as ab,hr as ac,Ec as ad,Nr as ae,H as af,Oe as ag,et as ah,Mh as ai,wh as aj,jh as ak,Wh as al,fl as am,gl as an,Sl as ao,bl as ap,vl as aq,Pc as ar,Pr as b,Dh as c,xt as d,st as e,Z as f,Xa as g,U as h,ss as i,z as j,De as k,Rl as l,ar as m,Tc as n,Ol as o,gs as p,xr as q,nt as r,ps as s,ce as t,ih as u,na as v,mt as w,kt as x,Lh as y,We as z};
|
|
256
|
+
//# sourceMappingURL=index-QopGLZI_.js.map
|