@ray-js/robot-map-sdk 0.0.14 → 0.0.15-beta.2
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/dist/constant/methods.js +1 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.rjs.js +1 -1
- package/dist-app/assets/{index-BNBxfMSM.js → index-Bp45lae8.js} +1 -1
- package/dist-app/index.html +1 -1
- package/dist-docs/404.html +2 -2
- package/dist-docs/assets/{app.DHRGs5Zc.js → app.lMYOOdZH.js} +1 -1
- package/dist-docs/assets/chunks/@localSearchIndexroot.BEvT9k6w.js +1 -0
- package/dist-docs/assets/chunks/{BitmapFont.CcysO3pT.js → BitmapFont.Cpozytzm.js} +1 -1
- package/dist-docs/assets/chunks/{BufferResource.C_MJ8LV7.js → BufferResource.qf38G7-x.js} +1 -1
- package/dist-docs/assets/chunks/{CanvasRenderer.AFx6MHtI.js → CanvasRenderer.Ctg0gCbc.js} +1 -1
- package/dist-docs/assets/chunks/{RenderTargetSystem.DlyLBS5z.js → RenderTargetSystem.XgJ7iKOj.js} +1 -1
- package/dist-docs/assets/chunks/{VPLocalSearchBox.DeambLpp.js → VPLocalSearchBox.CQigGpc1.js} +1 -1
- package/dist-docs/assets/chunks/{WebGLRenderer.uIm0oBU6.js → WebGLRenderer.CHLGFw15.js} +1 -1
- package/dist-docs/assets/chunks/{WebGPURenderer.KCAyMTek.js → WebGPURenderer.D_v-7q0a.js} +1 -1
- package/dist-docs/assets/chunks/{browserAll.5RQbY4cm.js → browserAll.Fx8qgu2O.js} +1 -1
- package/dist-docs/assets/chunks/{index.BLj_eQCu.js → index.CYU0ay78.js} +48 -48
- package/dist-docs/assets/chunks/{theme.DZz2Y3xc.js → theme.DCRyNh1R.js} +3 -3
- package/dist-docs/assets/chunks/{webworkerAll.D3-je4ql.js → webworkerAll.ClxrVaPQ.js} +1 -1
- package/dist-docs/assets/{guide_advanced-usage.md.B0nlUHzZ.js → guide_advanced-usage.md.BboplJc2.js} +15 -3
- package/dist-docs/assets/{guide_advanced-usage.md.B0nlUHzZ.lean.js → guide_advanced-usage.md.BboplJc2.lean.js} +1 -1
- package/dist-docs/assets/{guide_getting-started.md.BxrBbc12.js → guide_getting-started.md.CE5TiXtc.js} +1 -1
- package/dist-docs/guide/advanced-usage.html +18 -6
- package/dist-docs/guide/concepts.html +3 -3
- package/dist-docs/guide/getting-started.html +5 -5
- package/dist-docs/guide/mcp.html +3 -3
- package/dist-docs/hashmap.json +1 -1
- package/dist-docs/index.html +3 -3
- package/dist-docs/plans/2026-03-04-detected-objects-visibility-design.html +3 -3
- package/dist-docs/plans/2026-03-04-show-detected-objects-implementation-plan.html +3 -3
- package/dist-docs/plans/2026-03-10-simulator-debug-design.html +3 -3
- package/dist-docs/plans/2026-03-10-simulator-events-console-design.html +3 -3
- package/dist-docs/plans/2026-03-10-simulator-events-console-implementation-plan.html +3 -3
- package/dist-docs/plans/2026-03-10-simulator-runtime-controls-design.html +3 -3
- package/dist-docs/plans/2026-03-10-simulator-runtime-controls-implementation-plan.html +3 -3
- package/dist-docs/plans/2026-03-10-testing-rollout-next-steps-plan.html +3 -3
- package/dist-docs/plans/2026-03-11-simulator-logger-dump-implementation-plan.html +3 -3
- package/dist-docs/reference/callbacks.html +3 -3
- package/dist-docs/reference/config.html +3 -3
- package/dist-docs/reference/data.html +3 -3
- package/dist-docs/reference/methods.html +3 -3
- package/dist-docs/reference/runtime.html +3 -3
- package/dist-docs/reference/types.html +3 -3
- package/dist-docs/reference/utils.html +3 -3
- package/dist-docs/simulator/index.html +3 -3
- package/package.json +1 -1
- package/dist-docs/assets/chunks/@localSearchIndexroot.RPRwAWt3.js +0 -1
- /package/dist-docs/assets/{guide_getting-started.md.BxrBbc12.lean.js → guide_getting-started.md.CE5TiXtc.lean.js} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chunks/browserAll.
|
|
2
|
-
var Tc=Object.defineProperty;var kc=(r,e,t)=>e in r?Tc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var g=(r,e,t)=>kc(r,typeof e!="symbol"?e+"":e,t);import{V as _e}from"./framework.CBLqO2Q1.js";import{L as th,u as eh,m as ih,G as Rc,E as Ec,d as Ee,y as Ic,Q as Bc,v as sh,H as Dc,R as Fc,T as zc,i as cr,U as nh,V as Lc,W as Oc,I as Gc,X as Wc,K as $r,Y as Uc,e as Hc,w as Vc,l as kn,f as Nc,a as jc,x as Qr,Z as Yc,h as Xc,_ as Zc,j as qc,$ as rh,a0 as Kc,a1 as $c,C as Qc,a2 as Jc,N as Rn,O as td,P as ed,M as Jr}from"./mapValues.D2X8cRgC.js";import{N as re,H as id,a as sd}from"./theme.DZz2Y3xc.js";var I=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(I||{});const En=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},qi=(r,e)=>En(r).priority??e,$={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(En).forEach(e=>{e.type.forEach(t=>{var i,s;return(s=(i=this._removeHandlers)[t])==null?void 0:s.call(i,e)})}),this},add(...r){return r.map(En).forEach(e=>{e.type.forEach(t=>{var n,o;const i=this._addHandlers,s=this._queue;i[t]?(o=i[t])==null||o.call(i,e):(s[t]=s[t]||[],(n=s[t])==null||n.push(e))})}),this},handle(r,e,t){var o;const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=e,s[r]=t;const n=this._queue;return n[r]&&((o=n[r])==null||o.forEach(a=>e(a)),delete n[r]),this},handleByMap(r,e){return this.handle(r,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByNamedList(r,e,t=-1){return this.handle(r,i=>{e.findIndex(n=>n.name===i.name)>=0||(e.push({name:i.name,value:i.ref}),e.sort((n,o)=>qi(o.value,t)-qi(n.value,t)))},i=>{const s=e.findIndex(n=>n.name===i.name);s!==-1&&e.splice(s,1)})},handleByList(r,e,t=-1){return this.handle(r,i=>{e.includes(i.ref)||(e.push(i.ref),e.sort((s,n)=>qi(n,t)-qi(s,t)))},i=>{const s=e.indexOf(i.ref);s!==-1&&e.splice(s,1)})},mixin(r,...e){for(const t of e)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(t))}},nd={extension:{type:I.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await _e(()=>import("./browserAll.5RQbY4cm.js"),__vite__mapDeps([0,1,2,3,4]))}},rd={extension:{type:I.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await _e(()=>import("./webworkerAll.D3-je4ql.js"),__vite__mapDeps([1,2,3,4]))}};class ct{constructor(e,t,i){this._x=t||0,this._y=i||0,this._observer=e}clone(e){return new ct(e??this._observer,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.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(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}var oh={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function n(h,l,c,d,u){if(typeof c!="function")throw new TypeError("The listener must be a function");var p=new s(c,d||h,u),f=t?t+l:l;return h._events[f]?h._events[f].fn?h._events[f]=[h._events[f],p]:h._events[f].push(p):(h._events[f]=p,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,d;if(this._eventsCount===0)return l;for(d in c=this._events)e.call(c,d)&&l.push(t?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=t?t+l:l,d=this._events[c];if(!d)return[];if(d.fn)return[d.fn];for(var u=0,p=d.length,f=new Array(p);u<p;u++)f[u]=d[u].fn;return f},a.prototype.listenerCount=function(l){var c=t?t+l:l,d=this._events[c];return d?d.fn?1:d.length:0},a.prototype.emit=function(l,c,d,u,p,f){var y=t?t+l:l;if(!this._events[y])return!1;var m=this._events[y],x=arguments.length,S,v;if(m.fn){switch(m.once&&this.removeListener(l,m.fn,void 0,!0),x){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,c),!0;case 3:return m.fn.call(m.context,c,d),!0;case 4:return m.fn.call(m.context,c,d,u),!0;case 5:return m.fn.call(m.context,c,d,u,p),!0;case 6:return m.fn.call(m.context,c,d,u,p,f),!0}for(v=1,S=new Array(x-1);v<x;v++)S[v-1]=arguments[v];m.fn.apply(m.context,S)}else{var b=m.length,P;for(v=0;v<b;v++)switch(m[v].once&&this.removeListener(l,m[v].fn,void 0,!0),x){case 1:m[v].fn.call(m[v].context);break;case 2:m[v].fn.call(m[v].context,c);break;case 3:m[v].fn.call(m[v].context,c,d);break;case 4:m[v].fn.call(m[v].context,c,d,u);break;default:if(!S)for(P=1,S=new Array(x-1);P<x;P++)S[P-1]=arguments[P];m[v].fn.apply(m[v].context,S)}}return!0},a.prototype.on=function(l,c,d){return n(this,l,c,d,!1)},a.prototype.once=function(l,c,d){return n(this,l,c,d,!0)},a.prototype.removeListener=function(l,c,d,u){var p=t?t+l:l;if(!this._events[p])return this;if(!c)return o(this,p),this;var f=this._events[p];if(f.fn)f.fn===c&&(!u||f.once)&&(!d||f.context===d)&&o(this,p);else{for(var y=0,m=[],x=f.length;y<x;y++)(f[y].fn!==c||u&&!f[y].once||d&&f[y].context!==d)&&m.push(f[y]);m.length?this._events[p]=m.length===1?m[0]:m:o(this,p)}return this},a.prototype.removeAllListeners=function(l){var c;return l?(c=t?t+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=t,a.EventEmitter=a,r.exports=a})(oh);var od=oh.exports;const Yt=th(od),ad=Math.PI*2,hd=180/Math.PI,ld=Math.PI/180;class tt{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new tt(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Vs.x=0,Vs.y=0,Vs}}const Vs=new tt;class U{constructor(e=1,t=0,i=0,s=1,n=0,o=0){this.array=null,this.a=e,this.b=t,this.c=i,this.d=s,this.tx=n,this.ty=o}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,i,s,n,o){return this.a=e,this.b=t,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(e,t){this.array||(this.array=new Float32Array(9));const i=t||this.array;return e?(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(e,t){t=t||new tt;const i=e.x,s=e.y;return t.x=this.a*i+this.c*s+this.tx,t.y=this.b*i+this.d*s+this.ty,t}applyInverse(e,t){t=t||new tt;const i=this.a,s=this.b,n=this.c,o=this.d,a=this.tx,h=this.ty,l=1/(i*o+n*-s),c=e.x,d=e.y;return t.x=o*l*c+-n*l*d+(h*n-a*o)*l,t.y=i*l*d+-s*l*c+(-h*i+a*s)*l,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){const t=Math.cos(e),i=Math.sin(e),s=this.a,n=this.c,o=this.tx;return this.a=s*t-this.b*i,this.b=s*i+this.b*t,this.c=n*t-this.d*i,this.d=n*i+this.d*t,this.tx=o*t-this.ty*i,this.ty=o*i+this.ty*t,this}append(e){const t=this.a,i=this.b,s=this.c,n=this.d;return this.a=e.a*t+e.b*s,this.b=e.a*i+e.b*n,this.c=e.c*t+e.d*s,this.d=e.c*i+e.d*n,this.tx=e.tx*t+e.ty*s+this.tx,this.ty=e.tx*i+e.ty*n+this.ty,this}appendFrom(e,t){const i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,h=e.ty,l=t.a,c=t.b,d=t.c,u=t.d;return this.a=i*l+s*d,this.b=i*c+s*u,this.c=n*l+o*d,this.d=n*c+o*u,this.tx=a*l+h*d+t.tx,this.ty=a*c+h*u+t.ty,this}setTransform(e,t,i,s,n,o,a,h,l){return this.a=Math.cos(a+l)*n,this.b=Math.sin(a+l)*n,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*o,this.tx=e-(i*this.a+s*this.c),this.ty=t-(i*this.b+s*this.d),this}prepend(e){const t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const i=this.a,s=this.c;this.a=i*e.a+this.b*e.c,this.b=i*e.b+this.b*e.d,this.c=s*e.a+this.d*e.c,this.d=s*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){const t=this.a,i=this.b,s=this.c,n=this.d,o=e.pivot,a=-Math.atan2(-s,n),h=Math.atan2(i,t),l=Math.abs(a+h);return l<1e-5||Math.abs(ad-l)<1e-5?(e.rotation=h,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=a,e.skew.y=h),e.scale.x=Math.sqrt(t*t+i*i),e.scale.y=Math.sqrt(s*s+n*n),e.position.x=this.tx+(o.x*t+o.y*s),e.position.y=this.ty+(o.x*i+o.y*n),e}invert(){const e=this.a,t=this.b,i=this.c,s=this.d,n=this.tx,o=e*s-t*i;return this.a=s/o,this.b=-t/o,this.c=-i/o,this.d=e/o,this.tx=(i*this.ty-s*n)/o,this.ty=-(e*this.ty-t*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const e=new U;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.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 dd.identity()}static get shared(){return cd.identity()}}const cd=new U,dd=new U,ve=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],be=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],we=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Ce=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],In=[],ah=[],Ki=Math.sign;function ud(){for(let r=0;r<16;r++){const e=[];In.push(e);for(let t=0;t<16;t++){const i=Ki(ve[r]*ve[t]+we[r]*be[t]),s=Ki(be[r]*ve[t]+Ce[r]*be[t]),n=Ki(ve[r]*we[t]+we[r]*Ce[t]),o=Ki(be[r]*we[t]+Ce[r]*Ce[t]);for(let a=0;a<16;a++)if(ve[a]===i&&be[a]===s&&we[a]===n&&Ce[a]===o){e.push(a);break}}}for(let r=0;r<16;r++){const e=new U;e.set(ve[r],be[r],we[r],Ce[r],0,0),ah.push(e)}}ud();const X={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>ve[r],uY:r=>be[r],vX:r=>we[r],vY:r=>Ce[r],inv:r=>r&8?r&15:-r&7,add:(r,e)=>In[r][e],sub:(r,e)=>In[r][X.inv(e)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,e)=>Math.abs(r)*2<=Math.abs(e)?e>=0?X.S:X.N:Math.abs(e)*2<=Math.abs(r)?r>0?X.E:X.W:e>0?r>0?X.SE:X.SW:r>0?X.NE:X.NW,matrixAppendRotationInv:(r,e,t=0,i=0,s=0,n=0)=>{const o=ah[X.inv(e)],a=o.a,h=o.b,l=o.c,c=o.d,d=t-Math.min(0,a*s,l*n,a*s+l*n),u=i-Math.min(0,h*s,c*n,h*s+c*n),p=r.a,f=r.b,y=r.c,m=r.d;r.a=a*p+h*y,r.b=a*f+h*m,r.c=l*p+c*y,r.d=l*f+c*m,r.tx=d*p+u*y+r.tx,r.ty=d*f+u*m+r.ty},transformRectCoords:(r,e,t,i)=>{const{x:s,y:n,width:o,height:a}=r,{x:h,y:l,width:c,height:d}=e;return t===X.E?(i.set(s+h,n+l,o,a),i):t===X.S?i.set(c-n-a+h,s+l,a,o):t===X.W?i.set(c-s-o+h,d-n-a+l,o,a):t===X.N?i.set(n+h,d-s-o+l,a,o):i.set(s+h,n+l,o,a)}},$i=[new tt,new tt,new tt,new tt];class et{constructor(e=0,t=0,i=0,s=0){this.type="rectangle",this.x=Number(e),this.y=Number(t),this.width=Number(i),this.height=Number(s)}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 et(0,0,0,0)}clone(){return new et(this.x,this.y,this.width,this.height)}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}strokeContains(e,t,i,s=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,h=this.y,l=i*(1-s),c=i-l,d=a-l,u=a+n+l,p=h-l,f=h+o+l,y=a+c,m=a+n-c,x=h+c,S=h+o-c;return e>=d&&e<=u&&t>=p&&t<=f&&!(e>y&&e<m&&t>x&&t<S)}intersects(e,t){if(!t){const k=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=k)return!1;const T=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>T}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=$i[0].set(e.left,e.top),h=$i[1].set(e.left,e.bottom),l=$i[2].set(e.right,e.top),c=$i[3].set(e.right,e.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const d=Math.sign(t.a*t.d-t.b*t.c);if(d===0||(t.apply(a,a),t.apply(h,h),t.apply(l,l),t.apply(c,c),Math.max(a.x,h.x,l.x,c.x)<=i||Math.min(a.x,h.x,l.x,c.x)>=s||Math.max(a.y,h.y,l.y,c.y)<=n||Math.min(a.y,h.y,l.y,c.y)>=o))return!1;const u=d*(h.y-a.y),p=d*(a.x-h.x),f=u*i+p*n,y=u*s+p*n,m=u*i+p*o,x=u*s+p*o;if(Math.max(f,y,m,x)<=u*a.x+p*a.y||Math.min(f,y,m,x)>=u*c.x+p*c.y)return!1;const S=d*(a.y-l.y),v=d*(l.x-a.x),b=S*i+v*n,P=S*s+v*n,C=S*i+v*o,A=S*s+v*o;return!(Math.max(b,P,C,A)<=S*a.x+v*a.y||Math.min(b,P,C,A)>=S*c.x+v*c.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){const t=Math.max(this.x,e.x),i=Math.min(this.x+this.width,e.x+e.width),s=Math.max(this.y,e.y),n=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(i-t,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(e=1,t=.001){const i=Math.ceil((this.x+this.width-t)*e)/e,s=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=i-this.x,this.height=s-this.y,this}scale(e,t=e){return this.x*=e,this.y*=t,this.width*=e,this.height*=t,this}enlarge(e){const t=Math.min(this.x,e.x),i=Math.max(this.x+this.width,e.x+e.width),s=Math.min(this.y,e.y),n=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=i-t,this.y=s,this.height=n-s,this}getBounds(e){return e||(e=new et),e.copyFrom(this),e}containsRect(e){if(this.width<=0||this.height<=0)return!1;const t=e.x,i=e.y,s=e.x+e.width,n=e.y+e.height;return t>=this.x&&t<this.x+this.width&&i>=this.y&&i<this.y+this.height&&s>=this.x&&s<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(e,t,i,s){return this.x=e,this.y=t,this.width=i,this.height=s,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Ns={default:-1};function dt(r="default"){return Ns[r]===void 0&&(Ns[r]=-1),++Ns[r]}const to=new Set,J="8.0.0",pd="8.3.4",He={quiet:!1,noColor:!1},V=(r,e,t=3)=>{if(He.quiet||to.has(e))return;let i=new Error().stack;const s=`${e}
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chunks/browserAll.Fx8qgu2O.js","assets/chunks/webworkerAll.ClxrVaPQ.js","assets/chunks/framework.CBLqO2Q1.js","assets/chunks/mapValues.D2X8cRgC.js","assets/chunks/theme.DCRyNh1R.js","assets/chunks/WebGPURenderer.D_v-7q0a.js","assets/chunks/BufferResource.qf38G7-x.js","assets/chunks/RenderTargetSystem.XgJ7iKOj.js","assets/chunks/WebGLRenderer.CHLGFw15.js","assets/chunks/CanvasRenderer.Ctg0gCbc.js","assets/chunks/BitmapFont.Cpozytzm.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Mc=Object.defineProperty;var _c=(r,e,t)=>e in r?Mc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var g=(r,e,t)=>_c(r,typeof e!="symbol"?e+"":e,t);import{V as _e}from"./framework.CBLqO2Q1.js";import{L as Qa,u as Ja,m as th,G as Tc,E as kc,d as Ee,y as Rc,Q as Ec,v as eh,H as Ic,R as Bc,T as Dc,i as lr,U as ih,V as Fc,W as zc,I as Lc,X as Oc,K as Kr,Y as Wc,e as Gc,w as Uc,l as kn,f as Hc,a as Vc,x as $r,Z as Nc,h as jc,_ as Yc,j as Xc,$ as sh,a0 as Zc,a1 as qc,C as Kc,a2 as $c,N as Rn,O as Qc,P as Jc,M as Qr}from"./mapValues.D2X8cRgC.js";import{N as re,H as td,a as ed}from"./theme.DCRyNh1R.js";var I=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(I||{});const En=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},qi=(r,e)=>En(r).priority??e,$={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(En).forEach(e=>{e.type.forEach(t=>{var i,s;return(s=(i=this._removeHandlers)[t])==null?void 0:s.call(i,e)})}),this},add(...r){return r.map(En).forEach(e=>{e.type.forEach(t=>{var n,o;const i=this._addHandlers,s=this._queue;i[t]?(o=i[t])==null||o.call(i,e):(s[t]=s[t]||[],(n=s[t])==null||n.push(e))})}),this},handle(r,e,t){var o;const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=e,s[r]=t;const n=this._queue;return n[r]&&((o=n[r])==null||o.forEach(a=>e(a)),delete n[r]),this},handleByMap(r,e){return this.handle(r,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByNamedList(r,e,t=-1){return this.handle(r,i=>{e.findIndex(n=>n.name===i.name)>=0||(e.push({name:i.name,value:i.ref}),e.sort((n,o)=>qi(o.value,t)-qi(n.value,t)))},i=>{const s=e.findIndex(n=>n.name===i.name);s!==-1&&e.splice(s,1)})},handleByList(r,e,t=-1){return this.handle(r,i=>{e.includes(i.ref)||(e.push(i.ref),e.sort((s,n)=>qi(n,t)-qi(s,t)))},i=>{const s=e.indexOf(i.ref);s!==-1&&e.splice(s,1)})},mixin(r,...e){for(const t of e)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(t))}},id={extension:{type:I.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await _e(()=>import("./browserAll.Fx8qgu2O.js"),__vite__mapDeps([0,1,2,3,4]))}},sd={extension:{type:I.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await _e(()=>import("./webworkerAll.ClxrVaPQ.js"),__vite__mapDeps([1,2,3,4]))}};class ct{constructor(e,t,i){this._x=t||0,this._y=i||0,this._observer=e}clone(e){return new ct(e??this._observer,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.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(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}var nh={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function n(h,l,c,d,u){if(typeof c!="function")throw new TypeError("The listener must be a function");var p=new s(c,d||h,u),f=t?t+l:l;return h._events[f]?h._events[f].fn?h._events[f]=[h._events[f],p]:h._events[f].push(p):(h._events[f]=p,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,d;if(this._eventsCount===0)return l;for(d in c=this._events)e.call(c,d)&&l.push(t?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=t?t+l:l,d=this._events[c];if(!d)return[];if(d.fn)return[d.fn];for(var u=0,p=d.length,f=new Array(p);u<p;u++)f[u]=d[u].fn;return f},a.prototype.listenerCount=function(l){var c=t?t+l:l,d=this._events[c];return d?d.fn?1:d.length:0},a.prototype.emit=function(l,c,d,u,p,f){var y=t?t+l:l;if(!this._events[y])return!1;var m=this._events[y],x=arguments.length,S,v;if(m.fn){switch(m.once&&this.removeListener(l,m.fn,void 0,!0),x){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,c),!0;case 3:return m.fn.call(m.context,c,d),!0;case 4:return m.fn.call(m.context,c,d,u),!0;case 5:return m.fn.call(m.context,c,d,u,p),!0;case 6:return m.fn.call(m.context,c,d,u,p,f),!0}for(v=1,S=new Array(x-1);v<x;v++)S[v-1]=arguments[v];m.fn.apply(m.context,S)}else{var b=m.length,P;for(v=0;v<b;v++)switch(m[v].once&&this.removeListener(l,m[v].fn,void 0,!0),x){case 1:m[v].fn.call(m[v].context);break;case 2:m[v].fn.call(m[v].context,c);break;case 3:m[v].fn.call(m[v].context,c,d);break;case 4:m[v].fn.call(m[v].context,c,d,u);break;default:if(!S)for(P=1,S=new Array(x-1);P<x;P++)S[P-1]=arguments[P];m[v].fn.apply(m[v].context,S)}}return!0},a.prototype.on=function(l,c,d){return n(this,l,c,d,!1)},a.prototype.once=function(l,c,d){return n(this,l,c,d,!0)},a.prototype.removeListener=function(l,c,d,u){var p=t?t+l:l;if(!this._events[p])return this;if(!c)return o(this,p),this;var f=this._events[p];if(f.fn)f.fn===c&&(!u||f.once)&&(!d||f.context===d)&&o(this,p);else{for(var y=0,m=[],x=f.length;y<x;y++)(f[y].fn!==c||u&&!f[y].once||d&&f[y].context!==d)&&m.push(f[y]);m.length?this._events[p]=m.length===1?m[0]:m:o(this,p)}return this},a.prototype.removeAllListeners=function(l){var c;return l?(c=t?t+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=t,a.EventEmitter=a,r.exports=a})(nh);var nd=nh.exports;const Yt=Qa(nd),rd=Math.PI*2,od=180/Math.PI,ad=Math.PI/180;class tt{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new tt(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Vs.x=0,Vs.y=0,Vs}}const Vs=new tt;class U{constructor(e=1,t=0,i=0,s=1,n=0,o=0){this.array=null,this.a=e,this.b=t,this.c=i,this.d=s,this.tx=n,this.ty=o}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,i,s,n,o){return this.a=e,this.b=t,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(e,t){this.array||(this.array=new Float32Array(9));const i=t||this.array;return e?(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(e,t){t=t||new tt;const i=e.x,s=e.y;return t.x=this.a*i+this.c*s+this.tx,t.y=this.b*i+this.d*s+this.ty,t}applyInverse(e,t){t=t||new tt;const i=this.a,s=this.b,n=this.c,o=this.d,a=this.tx,h=this.ty,l=1/(i*o+n*-s),c=e.x,d=e.y;return t.x=o*l*c+-n*l*d+(h*n-a*o)*l,t.y=i*l*d+-s*l*c+(-h*i+a*s)*l,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){const t=Math.cos(e),i=Math.sin(e),s=this.a,n=this.c,o=this.tx;return this.a=s*t-this.b*i,this.b=s*i+this.b*t,this.c=n*t-this.d*i,this.d=n*i+this.d*t,this.tx=o*t-this.ty*i,this.ty=o*i+this.ty*t,this}append(e){const t=this.a,i=this.b,s=this.c,n=this.d;return this.a=e.a*t+e.b*s,this.b=e.a*i+e.b*n,this.c=e.c*t+e.d*s,this.d=e.c*i+e.d*n,this.tx=e.tx*t+e.ty*s+this.tx,this.ty=e.tx*i+e.ty*n+this.ty,this}appendFrom(e,t){const i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,h=e.ty,l=t.a,c=t.b,d=t.c,u=t.d;return this.a=i*l+s*d,this.b=i*c+s*u,this.c=n*l+o*d,this.d=n*c+o*u,this.tx=a*l+h*d+t.tx,this.ty=a*c+h*u+t.ty,this}setTransform(e,t,i,s,n,o,a,h,l){return this.a=Math.cos(a+l)*n,this.b=Math.sin(a+l)*n,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*o,this.tx=e-(i*this.a+s*this.c),this.ty=t-(i*this.b+s*this.d),this}prepend(e){const t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const i=this.a,s=this.c;this.a=i*e.a+this.b*e.c,this.b=i*e.b+this.b*e.d,this.c=s*e.a+this.d*e.c,this.d=s*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){const t=this.a,i=this.b,s=this.c,n=this.d,o=e.pivot,a=-Math.atan2(-s,n),h=Math.atan2(i,t),l=Math.abs(a+h);return l<1e-5||Math.abs(rd-l)<1e-5?(e.rotation=h,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=a,e.skew.y=h),e.scale.x=Math.sqrt(t*t+i*i),e.scale.y=Math.sqrt(s*s+n*n),e.position.x=this.tx+(o.x*t+o.y*s),e.position.y=this.ty+(o.x*i+o.y*n),e}invert(){const e=this.a,t=this.b,i=this.c,s=this.d,n=this.tx,o=e*s-t*i;return this.a=s/o,this.b=-t/o,this.c=-i/o,this.d=e/o,this.tx=(i*this.ty-s*n)/o,this.ty=-(e*this.ty-t*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const e=new U;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.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 ld.identity()}static get shared(){return hd.identity()}}const hd=new U,ld=new U,ve=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],be=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],we=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Ce=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],In=[],rh=[],Ki=Math.sign;function cd(){for(let r=0;r<16;r++){const e=[];In.push(e);for(let t=0;t<16;t++){const i=Ki(ve[r]*ve[t]+we[r]*be[t]),s=Ki(be[r]*ve[t]+Ce[r]*be[t]),n=Ki(ve[r]*we[t]+we[r]*Ce[t]),o=Ki(be[r]*we[t]+Ce[r]*Ce[t]);for(let a=0;a<16;a++)if(ve[a]===i&&be[a]===s&&we[a]===n&&Ce[a]===o){e.push(a);break}}}for(let r=0;r<16;r++){const e=new U;e.set(ve[r],be[r],we[r],Ce[r],0,0),rh.push(e)}}cd();const X={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>ve[r],uY:r=>be[r],vX:r=>we[r],vY:r=>Ce[r],inv:r=>r&8?r&15:-r&7,add:(r,e)=>In[r][e],sub:(r,e)=>In[r][X.inv(e)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,e)=>Math.abs(r)*2<=Math.abs(e)?e>=0?X.S:X.N:Math.abs(e)*2<=Math.abs(r)?r>0?X.E:X.W:e>0?r>0?X.SE:X.SW:r>0?X.NE:X.NW,matrixAppendRotationInv:(r,e,t=0,i=0,s=0,n=0)=>{const o=rh[X.inv(e)],a=o.a,h=o.b,l=o.c,c=o.d,d=t-Math.min(0,a*s,l*n,a*s+l*n),u=i-Math.min(0,h*s,c*n,h*s+c*n),p=r.a,f=r.b,y=r.c,m=r.d;r.a=a*p+h*y,r.b=a*f+h*m,r.c=l*p+c*y,r.d=l*f+c*m,r.tx=d*p+u*y+r.tx,r.ty=d*f+u*m+r.ty},transformRectCoords:(r,e,t,i)=>{const{x:s,y:n,width:o,height:a}=r,{x:h,y:l,width:c,height:d}=e;return t===X.E?(i.set(s+h,n+l,o,a),i):t===X.S?i.set(c-n-a+h,s+l,a,o):t===X.W?i.set(c-s-o+h,d-n-a+l,o,a):t===X.N?i.set(n+h,d-s-o+l,a,o):i.set(s+h,n+l,o,a)}},$i=[new tt,new tt,new tt,new tt];class et{constructor(e=0,t=0,i=0,s=0){this.type="rectangle",this.x=Number(e),this.y=Number(t),this.width=Number(i),this.height=Number(s)}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 et(0,0,0,0)}clone(){return new et(this.x,this.y,this.width,this.height)}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}strokeContains(e,t,i,s=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,h=this.y,l=i*(1-s),c=i-l,d=a-l,u=a+n+l,p=h-l,f=h+o+l,y=a+c,m=a+n-c,x=h+c,S=h+o-c;return e>=d&&e<=u&&t>=p&&t<=f&&!(e>y&&e<m&&t>x&&t<S)}intersects(e,t){if(!t){const k=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=k)return!1;const T=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>T}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=$i[0].set(e.left,e.top),h=$i[1].set(e.left,e.bottom),l=$i[2].set(e.right,e.top),c=$i[3].set(e.right,e.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const d=Math.sign(t.a*t.d-t.b*t.c);if(d===0||(t.apply(a,a),t.apply(h,h),t.apply(l,l),t.apply(c,c),Math.max(a.x,h.x,l.x,c.x)<=i||Math.min(a.x,h.x,l.x,c.x)>=s||Math.max(a.y,h.y,l.y,c.y)<=n||Math.min(a.y,h.y,l.y,c.y)>=o))return!1;const u=d*(h.y-a.y),p=d*(a.x-h.x),f=u*i+p*n,y=u*s+p*n,m=u*i+p*o,x=u*s+p*o;if(Math.max(f,y,m,x)<=u*a.x+p*a.y||Math.min(f,y,m,x)>=u*c.x+p*c.y)return!1;const S=d*(a.y-l.y),v=d*(l.x-a.x),b=S*i+v*n,P=S*s+v*n,C=S*i+v*o,A=S*s+v*o;return!(Math.max(b,P,C,A)<=S*a.x+v*a.y||Math.min(b,P,C,A)>=S*c.x+v*c.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){const t=Math.max(this.x,e.x),i=Math.min(this.x+this.width,e.x+e.width),s=Math.max(this.y,e.y),n=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(i-t,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(e=1,t=.001){const i=Math.ceil((this.x+this.width-t)*e)/e,s=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=i-this.x,this.height=s-this.y,this}scale(e,t=e){return this.x*=e,this.y*=t,this.width*=e,this.height*=t,this}enlarge(e){const t=Math.min(this.x,e.x),i=Math.max(this.x+this.width,e.x+e.width),s=Math.min(this.y,e.y),n=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=i-t,this.y=s,this.height=n-s,this}getBounds(e){return e||(e=new et),e.copyFrom(this),e}containsRect(e){if(this.width<=0||this.height<=0)return!1;const t=e.x,i=e.y,s=e.x+e.width,n=e.y+e.height;return t>=this.x&&t<this.x+this.width&&i>=this.y&&i<this.y+this.height&&s>=this.x&&s<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(e,t,i,s){return this.x=e,this.y=t,this.width=i,this.height=s,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Ns={default:-1};function dt(r="default"){return Ns[r]===void 0&&(Ns[r]=-1),++Ns[r]}const Jr=new Set,J="8.0.0",dd="8.3.4",He={quiet:!1,noColor:!1},V=(r,e,t=3)=>{if(He.quiet||Jr.has(e))return;let i=new Error().stack;const s=`${e}
|
|
3
3
|
Deprecated since v${r}`,n=typeof console.groupCollapsed=="function"&&!He.noColor;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",s):(i=i.split(`
|
|
4
4
|
`).splice(t).join(`
|
|
5
|
-
`),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",s),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",s),console.warn(i))),to.add(e)};Object.defineProperties(V,{quiet:{get:()=>He.quiet,set:r=>{He.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>He.noColor,set:r=>{He.noColor=r},enumerable:!0,configurable:!1}});const hh=()=>{};function Je(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function eo(r){return!(r&r-1)&&!!r}function lh(r){const e={};for(const t in r)r[t]!==void 0&&(e[t]=r[t]);return e}const io=Object.create(null);function fd(r){const e=io[r];return e===void 0&&(io[r]=dt("resource")),e}const ch=class dh extends Yt{constructor(e={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,e={...dh.defaultOptions,...e},this.addressMode=e.addressMode,this.addressModeU=e.addressModeU??this.addressModeU,this.addressModeV=e.addressModeV??this.addressModeV,this.addressModeW=e.addressModeW??this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=e.magFilter??this.magFilter,this.minFilter=e.minFilter??this.minFilter,this.mipmapFilter=e.mipmapFilter??this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=e.maxAnisotropy??1}set addressMode(e){this.addressModeU=e,this.addressModeV=e,this.addressModeW=e}get addressMode(){return this.addressModeU}set wrapMode(e){V(J,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=e}get wrapMode(){return this.addressMode}set scaleMode(e){this.magFilter=e,this.minFilter=e,this.mipmapFilter=e}get scaleMode(){return this.magFilter}set maxAnisotropy(e){this._maxAnisotropy=Math.min(e,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 e=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=fd(e),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};ch.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let ti=ch;const uh=class ph extends Yt{constructor(e={}){super(),this.options=e,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=dt("textureSource"),this._resourceType="textureSource",this._resourceId=dt("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._touched=0,this._batchTick=-1,this._textureBindLocation=-1,e={...ph.defaultOptions,...e},this.label=e.label??"",this.resource=e.resource,this.autoGarbageCollect=e.autoGarbageCollect,this._resolution=e.resolution,e.width?this.pixelWidth=e.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,e.height?this.pixelHeight=e.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=e.format,this.dimension=e.dimensions,this.viewDimension=e.viewDimension??e.dimensions,this.arrayLayerCount=e.arrayLayerCount,this.mipLevelCount=e.mipLevelCount,this.autoGenerateMipmaps=e.autoGenerateMipmaps,this.sampleCount=e.sampleCount,this.antialias=e.antialias,this.alphaMode=e.alphaMode,this.style=new ti(lh(e)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(e){var t,i;this.style!==e&&((t=this._style)==null||t.off("change",this._onStyleChange,this),this._style=e,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(e){this._style.maxAnisotropy=e}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(e){this._style.addressMode=e}get repeatMode(){return this._style.addressMode}set repeatMode(e){this._style.addressMode=e}get magFilter(){return this._style.magFilter}set magFilter(e){this._style.magFilter=e}get minFilter(){return this._style.minFilter}set minFilter(e){this._style.minFilter=e}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(e){this._style.mipmapFilter=e}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(e){this._style.lodMinClamp=e}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(e){this._style.lodMaxClamp=e}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const e=this._resolution;if(this.resize(this.resourceWidth/e,this.resourceHeight/e))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 e,t;this._resourceId=dt("resource"),this.emit("change",this),this.emit("unload",this);for(const i in this._gpuData)(t=(e=this._gpuData[i])==null?void 0:e.destroy)==null||t.call(e);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:e}=this;return e.naturalWidth||e.videoWidth||e.displayWidth||e.width}get resourceHeight(){const{resource:e}=this;return e.naturalHeight||e.videoHeight||e.displayHeight||e.height}get resolution(){return this._resolution}set resolution(e){this._resolution!==e&&(this._resolution=e,this.width=this.pixelWidth/e,this.height=this.pixelHeight/e)}resize(e,t,i){i||(i=this._resolution),e||(e=this.width),t||(t=this.height);const s=Math.round(e*i),n=Math.round(t*i);return this.width=s/i,this.height=n/i,this._resolution=i,this.pixelWidth===s&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=s,this.pixelHeight=n,this.emit("resize",this),this._resourceId=dt("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(e){this._style.wrapMode=e}get wrapMode(){return this._style.wrapMode}set scaleMode(e){this._style.scaleMode=e}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=eo(this.pixelWidth)&&eo(this.pixelHeight)}static test(e){throw new Error("Unimplemented")}};uh.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 Dt=uh;class dr extends Dt{constructor(e){const t=e.resource||new Float32Array(e.width*e.height*4);let i=e.format;i||(t instanceof Float32Array?i="rgba32float":t instanceof Int32Array||t instanceof Uint32Array?i="rgba32uint":t instanceof Int16Array||t instanceof Uint16Array?i="rgba16uint":(t instanceof Int8Array,i="bgra8unorm")),super({...e,resource:t,format:i}),this.uploadMethodId="buffer"}static test(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}}dr.extension=I.TextureSource;const so=new U;class gd{constructor(e,t){this.mapCoord=new U,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof t>"u"?this.clampMargin=e.width<10?0:.5:this.clampMargin=t,this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){var t;this.texture!==e&&((t=this._texture)==null||t.removeListener("update",this.update,this),this._texture=e,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(e,t){t===void 0&&(t=e);const i=this.mapCoord;for(let s=0;s<e.length;s+=2){const n=e[s],o=e[s+1];t[s]=n*i.a+o*i.c+i.tx,t[s+1]=n*i.b+o*i.d+i.ty}return t}update(){const e=this._texture;this._updateID++;const t=e.uvs;this.mapCoord.set(t.x1-t.x0,t.y1-t.y0,t.x3-t.x0,t.y3-t.y0,t.x0,t.y0);const i=e.orig,s=e.trim;s&&(so.set(i.width/s.width,0,0,i.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(so));const n=e.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,h=this.clampOffset/n._resolution;return o[0]=(e.frame.x+a+h)/n.width,o[1]=(e.frame.y+a+h)/n.height,o[2]=(e.frame.x+e.frame.width-a+h)/n.width,o[3]=(e.frame.y+e.frame.height-a+h)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=e.frame.width===n.width&&e.frame.height===n.height&&e.rotate===0,!0}}class G extends Yt{constructor({source:e,label:t,frame:i,orig:s,trim:n,defaultAnchor:o,defaultBorders:a,rotate:h,dynamic:l}={}){if(super(),this.uid=dt("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new et,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=(e==null?void 0:e.source)??new Dt,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:c,height:d}=this._source;this.frame.width=c,this.frame.height=d}this.orig=s||this.frame,this.trim=n,this.rotate=h??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=l||!1,this.updateUvs()}set source(e){this._source&&this._source.off("resize",this.update,this),this._source=e,e.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new gd(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:e,frame:t}=this,{width:i,height:s}=this._source,n=t.x/i,o=t.y/s,a=t.width/i,h=t.height/s;let l=this.rotate;if(l){const c=a/2,d=h/2,u=n+c,p=o+d;l=X.add(l,X.NW),e.x0=u+c*X.uX(l),e.y0=p+d*X.uY(l),l=X.add(l,2),e.x1=u+c*X.uX(l),e.y1=p+d*X.uY(l),l=X.add(l,2),e.x2=u+c*X.uX(l),e.y2=p+d*X.uY(l),l=X.add(l,2),e.x3=u+c*X.uX(l),e.y3=p+d*X.uY(l)}else e.x0=n,e.y0=o,e.x1=n+a,e.y1=o,e.x2=n+a,e.y2=o+h,e.x3=n,e.y3=o+h}destroy(e=!1){this._source&&(this._source.off("resize",this.update,this),e&&(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 V(J,"Texture.baseTexture is now Texture.source"),this._source}}G.EMPTY=new G({label:"EMPTY",source:new Dt({label:"EMPTY"})});G.EMPTY.destroy=hh;G.WHITE=new G({source:new dr({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});G.WHITE.destroy=hh;function fh(r,e,t){const{width:i,height:s}=t.orig,n=t.trim;if(n){const o=n.width,a=n.height;r.minX=n.x-e._x*i,r.maxX=r.minX+o,r.minY=n.y-e._y*s,r.maxY=r.minY+a}else r.minX=-e._x*i,r.maxX=r.minX+i,r.minY=-e._y*s,r.maxY=r.minY+s}const no=new U;class Bt{constructor(e=1/0,t=1/0,i=-1/0,s=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=no,this.minX=e,this.minY=t,this.maxX=i,this.maxY=s}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new et);const e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):e.copyFromBounds(this),e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=no,this}set(e,t,i,s){this.minX=e,this.minY=t,this.maxX=i,this.maxY=s}addFrame(e,t,i,s,n){n||(n=this.matrix);const o=n.a,a=n.b,h=n.c,l=n.d,c=n.tx,d=n.ty;let u=this.minX,p=this.minY,f=this.maxX,y=this.maxY,m=o*e+h*t+c,x=a*e+l*t+d;m<u&&(u=m),x<p&&(p=x),m>f&&(f=m),x>y&&(y=x),m=o*i+h*t+c,x=a*i+l*t+d,m<u&&(u=m),x<p&&(p=x),m>f&&(f=m),x>y&&(y=x),m=o*e+h*s+c,x=a*e+l*s+d,m<u&&(u=m),x<p&&(p=x),m>f&&(f=m),x>y&&(y=x),m=o*i+h*s+c,x=a*i+l*s+d,m<u&&(u=m),x<p&&(p=x),m>f&&(f=m),x>y&&(y=x),this.minX=u,this.minY=p,this.maxX=f,this.maxY=y}addRect(e,t){this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,t)}addBounds(e,t){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t)}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}applyMatrix(e){const t=this.minX,i=this.minY,s=this.maxX,n=this.maxY,{a:o,b:a,c:h,d:l,tx:c,ty:d}=e;let u=o*t+h*i+c,p=a*t+l*i+d;this.minX=u,this.minY=p,this.maxX=u,this.maxY=p,u=o*s+h*i+c,p=a*s+l*i+d,this.minX=u<this.minX?u:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=p>this.maxY?p:this.maxY,u=o*t+h*n+c,p=a*t+l*n+d,this.minX=u<this.minX?u:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=p>this.maxY?p:this.maxY,u=o*s+h*n+c,p=a*s+l*n+d,this.minX=u<this.minX?u:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=p>this.maxY?p:this.maxY}fit(e){return this.minX<e.left&&(this.minX=e.left),this.maxX>e.right&&(this.maxX=e.right),this.minY<e.top&&(this.minY=e.top),this.maxY>e.bottom&&(this.maxY=e.bottom),this}fitBounds(e,t,i,s){return this.minX<e&&(this.minX=e),this.maxX>t&&(this.maxX=t),this.minY<i&&(this.minY=i),this.maxY>s&&(this.maxY=s),this}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,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 Bt(this.minX,this.minY,this.maxX,this.maxY)}scale(e,t=e){return this.minX*=e,this.minY*=t,this.maxX*=e,this.maxY*=t,this}get x(){return this.minX}set x(e){const t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){const t=this.maxY-this.minY;this.minY=e,this.maxY=e+t}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}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(e,t,i,s){let n=this.minX,o=this.minY,a=this.maxX,h=this.maxY;s||(s=this.matrix);const l=s.a,c=s.b,d=s.c,u=s.d,p=s.tx,f=s.ty;for(let y=t;y<i;y+=2){const m=e[y],x=e[y+1],S=l*m+d*x+p,v=c*m+u*x+f;n=S<n?S:n,o=v<o?v:o,a=S>a?S:a,h=v>h?v:h}this.minX=n,this.minY=o,this.maxX=a,this.maxY=h}containsPoint(e,t){return this.minX<=e&&this.minY<=t&&this.maxX>=e&&this.maxY>=t}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(e){return this.minX=e.minX,this.minY=e.minY,this.maxX=e.maxX,this.maxY=e.maxY,this}}var md={grad:.9,turn:360,rad:360/(2*Math.PI)},Zt=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},St=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*r)/t+0},It=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),r>t?t:r>e?r:e},gh=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},ro=function(r){return{r:It(r.r,0,255),g:It(r.g,0,255),b:It(r.b,0,255),a:It(r.a)}},js=function(r){return{r:St(r.r),g:St(r.g),b:St(r.b),a:St(r.a,3)}},yd=/^#([0-9a-f]{3,8})$/i,Qi=function(r){var e=r.toString(16);return e.length<2?"0"+e:e},mh=function(r){var e=r.r,t=r.g,i=r.b,s=r.a,n=Math.max(e,t,i),o=n-Math.min(e,t,i),a=o?n===e?(t-i)/o:n===t?2+(i-e)/o:4+(e-t)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},yh=function(r){var e=r.h,t=r.s,i=r.v,s=r.a;e=e/360*6,t/=100,i/=100;var n=Math.floor(e),o=i*(1-t),a=i*(1-(e-n)*t),h=i*(1-(1-e+n)*t),l=n%6;return{r:255*[i,a,o,o,h,i][l],g:255*[h,i,i,a,o,o][l],b:255*[o,o,h,i,i,a][l],a:s}},oo=function(r){return{h:gh(r.h),s:It(r.s,0,100),l:It(r.l,0,100),a:It(r.a)}},ao=function(r){return{h:St(r.h),s:St(r.s),l:St(r.l),a:St(r.a,3)}},ho=function(r){return yh((t=(e=r).s,{h:e.h,s:(t*=((i=e.l)<50?i:100-i)/100)>0?2*t/(i+t)*100:0,v:i+t,a:e.a}));var e,t,i},Ai=function(r){return{h:(e=mh(r)).h,s:(s=(200-(t=e.s))*(i=e.v)/100)>0&&s<200?t*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:e.a};var e,t,i,s},xd=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Sd=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,vd=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bd=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Bn={string:[[function(r){var e=yd.exec(r);return e?(r=e[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?St(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?St(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var e=vd.exec(r)||bd.exec(r);return e?e[2]!==e[4]||e[4]!==e[6]?null:ro({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(r){var e=xd.exec(r)||Sd.exec(r);if(!e)return null;var t,i,s=oo({h:(t=e[1],i=e[2],i===void 0&&(i="deg"),Number(t)*(md[i]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return ho(s)},"hsl"]],object:[[function(r){var e=r.r,t=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return Zt(e)&&Zt(t)&&Zt(i)?ro({r:Number(e),g:Number(t),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var e=r.h,t=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!Zt(e)||!Zt(t)||!Zt(i))return null;var o=oo({h:Number(e),s:Number(t),l:Number(i),a:Number(n)});return ho(o)},"hsl"],[function(r){var e=r.h,t=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!Zt(e)||!Zt(t)||!Zt(i))return null;var o=function(a){return{h:gh(a.h),s:It(a.s,0,100),v:It(a.v,0,100),a:It(a.a)}}({h:Number(e),s:Number(t),v:Number(i),a:Number(n)});return yh(o)},"hsv"]]},lo=function(r,e){for(var t=0;t<e.length;t++){var i=e[t][0](r);if(i)return[i,e[t][1]]}return[null,void 0]},wd=function(r){return typeof r=="string"?lo(r.trim(),Bn.string):typeof r=="object"&&r!==null?lo(r,Bn.object):[null,void 0]},Ys=function(r,e){var t=Ai(r);return{h:t.h,s:It(t.s+100*e,0,100),l:t.l,a:t.a}},Xs=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},co=function(r,e){var t=Ai(r);return{h:t.h,s:t.s,l:It(t.l+100*e,0,100),a:t.a}},Dn=function(){function r(e){this.parsed=wd(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return St(Xs(this.rgba),2)},r.prototype.isDark=function(){return Xs(this.rgba)<.5},r.prototype.isLight=function(){return Xs(this.rgba)>=.5},r.prototype.toHex=function(){return e=js(this.rgba),t=e.r,i=e.g,s=e.b,o=(n=e.a)<1?Qi(St(255*n)):"","#"+Qi(t)+Qi(i)+Qi(s)+o;var e,t,i,s,n,o},r.prototype.toRgb=function(){return js(this.rgba)},r.prototype.toRgbString=function(){return e=js(this.rgba),t=e.r,i=e.g,s=e.b,(n=e.a)<1?"rgba("+t+", "+i+", "+s+", "+n+")":"rgb("+t+", "+i+", "+s+")";var e,t,i,s,n},r.prototype.toHsl=function(){return ao(Ai(this.rgba))},r.prototype.toHslString=function(){return e=ao(Ai(this.rgba)),t=e.h,i=e.s,s=e.l,(n=e.a)<1?"hsla("+t+", "+i+"%, "+s+"%, "+n+")":"hsl("+t+", "+i+"%, "+s+"%)";var e,t,i,s,n},r.prototype.toHsv=function(){return e=mh(this.rgba),{h:St(e.h),s:St(e.s),v:St(e.v),a:St(e.a,3)};var e},r.prototype.invert=function(){return Ut({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},r.prototype.saturate=function(e){return e===void 0&&(e=.1),Ut(Ys(this.rgba,e))},r.prototype.desaturate=function(e){return e===void 0&&(e=.1),Ut(Ys(this.rgba,-e))},r.prototype.grayscale=function(){return Ut(Ys(this.rgba,-1))},r.prototype.lighten=function(e){return e===void 0&&(e=.1),Ut(co(this.rgba,e))},r.prototype.darken=function(e){return e===void 0&&(e=.1),Ut(co(this.rgba,-e))},r.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},r.prototype.alpha=function(e){return typeof e=="number"?Ut({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):St(this.rgba.a,3);var t},r.prototype.hue=function(e){var t=Ai(this.rgba);return typeof e=="number"?Ut({h:e,s:t.s,l:t.l,a:t.a}):St(t.h)},r.prototype.isEqual=function(e){return this.toHex()===Ut(e).toHex()},r}(),Ut=function(r){return r instanceof Dn?r:new Dn(r)},uo=[],Cd=function(r){r.forEach(function(e){uo.indexOf(e)<0&&(e(Dn,Bn),uo.push(e))})};function Ad(r,e){var t={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var s in t)i[t[s]]=s;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,h,l=i[this.toHex()];if(l)return l;if(o!=null&&o.closest){var c=this.toRgb(),d=1/0,u="black";if(!n.length)for(var p in t)n[p]=new r(t[p]).toRgb();for(var f in t){var y=(a=c,h=n[f],Math.pow(a.r-h.r,2)+Math.pow(a.g-h.g,2)+Math.pow(a.b-h.b,2));y<d&&(d=y,u=f)}return u}},e.string.push([function(o){var a=o.toLowerCase(),h=a==="transparent"?"#0000":t[a];return h?new r(h).toRgb():null},"name"])}Cd([Ad]);const ei=class bi{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}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(e){return this.value=e,this}set value(e){if(e instanceof bi)this._value=this._cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(e===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,e))&&(this._value=this._cloneSource(e),this._normalize(this._value))}}get value(){return this._value}_cloneSource(e){return typeof e=="string"||typeof e=="number"||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e=="object"&&e!==null?{...e}:e}_isSourceEqual(e,t){const i=typeof e;if(i!==typeof t)return!1;if(i==="number"||i==="string"||e instanceof Number)return e===t;if(Array.isArray(e)&&Array.isArray(t)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(t))return e.length!==t.length?!1:e.every((n,o)=>n===t[o]);if(e!==null&&t!==null){const n=Object.keys(e),o=Object.keys(t);return n.length!==o.length?!1:n.every(a=>e[a]===t[a])}return e===t}toRgba(){const[e,t,i,s]=this._components;return{r:e,g:t,b:i,a:s}}toRgb(){const[e,t,i]=this._components;return{r:e,g:t,b:i}}toRgbaString(){const[e,t,i]=this.toUint8RgbArray();return`rgba(${e},${t},${i},${this.alpha})`}toUint8RgbArray(e){const[t,i,s]=this._components;return this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb),e[0]=Math.round(t*255),e[1]=Math.round(i*255),e[2]=Math.round(s*255),e}toArray(e){this._arrayRgba||(this._arrayRgba=[]),e||(e=this._arrayRgba);const[t,i,s,n]=this._components;return e[0]=t,e[1]=i,e[2]=s,e[3]=n,e}toRgbArray(e){this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb);const[t,i,s]=this._components;return e[0]=t,e[1]=i,e[2]=s,e}toNumber(){return this._int}toBgrNumber(){const[e,t,i]=this.toUint8RgbArray();return(i<<16)+(t<<8)+e}toLittleEndianNumber(){const e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){const[t,i,s,n]=bi._temp.setValue(e)._components;return this._components[0]*=t,this._components[1]*=i,this._components[2]*=s,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this._refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return t&&(i=i*e+.5|0,s=s*e+.5|0,n=n*e+.5|0),(e*255<<24)+(i<<16)+(s<<8)+n}toHex(){const e=this._int.toString(16);return`#${"000000".substring(0,6-e.length)+e}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(e){return this._components[3]=this._clamp(e),this}_normalize(e){let t,i,s,n;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){const o=e;t=(o>>16&255)/255,i=(o>>8&255)/255,s=(o&255)/255,n=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[t,i,s,n=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[t,i,s,n=255]=e,t/=255,i/=255,s/=255,n/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){const a=bi.HEX_PATTERN.exec(e);a&&(e=`#${a[2]}`)}const o=Ut(e);o.isValid()&&({r:t,g:i,b:s,a:n}=o.rgba,t/=255,i/=255,s/=255)}if(t!==void 0)this._components[0]=t,this._components[1]=i,this._components[2]=s,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${e}`)}_refreshInt(){this._clamp(this._components);const[e,t,i]=this._components;this._int=(e*255<<16)+(t*255<<8)+(i*255|0)}_clamp(e,t=0,i=1){return typeof e=="number"?Math.min(Math.max(e,t),i):(e.forEach((s,n)=>{e[n]=Math.min(Math.max(s,t),i)}),e)}static isColorLike(e){return typeof e=="number"||typeof e=="string"||e instanceof Number||e instanceof bi||Array.isArray(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||e.r!==void 0&&e.g!==void 0&&e.b!==void 0||e.r!==void 0&&e.g!==void 0&&e.b!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0&&e.a!==void 0}};ei.shared=new ei;ei._temp=new ei;ei.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let rt=ei;const Pd={cullArea:null,cullable:!1,cullableChildren:!0};let Zs=0;const po=500;function nt(...r){Zs!==po&&(Zs++,Zs===po?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}const Hi={_registeredResources:new Set,register(r){this._registeredResources.add(r)},unregister(r){this._registeredResources.delete(r)},release(){this._registeredResources.forEach(r=>r.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(r){return this._registeredResources.has(r)},reset(){this._registeredResources.clear()}};class Md{constructor(e,t){this._pool=[],this._count=0,this._index=0,this._classType=e,t&&this.prepopulate(t)}prepopulate(e){for(let t=0;t<e;t++)this._pool[this._index++]=new this._classType;this._count+=e}get(e){var i;let t;return this._index>0?t=this._pool[--this._index]:(t=new this._classType,this._count++),(i=t.init)==null||i.call(t,e),t}return(e){var t;(t=e.reset)==null||t.call(e),this._pool[this._index++]=e}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 e=0;e<this._index;e++)this._pool[e].destroy();this._pool.length=0,this._count=0,this._index=0}}class _d{constructor(){this._poolsByClass=new Map}prepopulate(e,t){this.getPool(e).prepopulate(t)}get(e,t){return this.getPool(e).get(t)}return(e){this.getPool(e.constructor).return(e)}getPool(e){return this._poolsByClass.has(e)||this._poolsByClass.set(e,new Md(e)),this._poolsByClass.get(e)}stats(){const e={};return this._poolsByClass.forEach(t=>{const i=e[t._classType.name]?t._classType.name+t._classType.ID:t._classType.name;e[i]={free:t.totalFree,used:t.totalUsed,size:t.totalSize}}),e}clear(){this._poolsByClass.forEach(e=>e.clear()),this._poolsByClass.clear()}}const _t=new _d;Hi.register(_t);const Td={get isCachedAsTexture(){var r;return!!((r=this.renderGroup)!=null&&r.isCachedAsTexture)},cacheAsTexture(r){typeof r=="boolean"&&r===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(r===!0?{}:r))},updateCacheTexture(){var r;(r=this.renderGroup)==null||r.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(r){V("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(r)}};function kd(r,e,t){const i=r.length;let s;if(e>=i||t===0)return;t=e+t>i?i-e:t;const n=i-t;for(s=e;s<n;++s)r[s]=r[s+t];r.length=n}const Rd={allowChildren:!0,removeChildren(r=0,e){var n;const t=e??this.children.length,i=t-r,s=[];if(i>0&&i<=t){for(let a=t-1;a>=r;a--){const h=this.children[a];h&&(s.push(h),h.parent=null)}kd(this.children,r,t);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(s);for(let a=0;a<s.length;++a){const h=s[a];(n=h.parentRenderLayer)==null||n.detach(h),this.emit("childRemoved",h,this,a),s[a].emit("removed",this)}return s.length>0&&this._didViewChangeTick++,s}else if(i===0&&this.children.length===0)return s;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){const e=this.getChildAt(r);return this.removeChild(e)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,e)},getChildIndex(r){const e=this.children.indexOf(r);if(e===-1)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(r,e){this.allowChildren||V(J,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:t}=this;if(e<0||e>t.length)throw new Error(`${r}addChildAt: The index ${e} supplied is out of bounds ${t.length}`);if(r.parent){const s=r.parent.children.indexOf(r);if(r.parent===this&&s===e)return r;s!==-1&&r.parent.children.splice(s,1)}e===t.length?t.push(r):t.splice(e,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(r),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",r,this,e),r.emit("added",this),r},swapChildren(r,e){if(r===e)return;const t=this.getChildIndex(r),i=this.getChildIndex(e);this.children[t]=e,this.children[i]=r;const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(e=>this.reparentChildAt(e,this.children.length)),r[0])},reparentChildAt(r,e){if(r.parent===this)return this.setChildIndex(r,e),r;const t=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,e);const i=this.worldTransform.clone();return i.invert(),t.prepend(i),r.setFromMatrix(t),r},replaceChild(r,e){r.updateLocalTransform(),this.addChildAt(e,this.getChildIndex(r)),e.setFromMatrix(r.localTransform),e.updateLocalTransform(),this.removeChild(r)}},Ed={collectRenderables(r,e,t){this.parentRenderLayer&&this.parentRenderLayer!==t||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,e,t):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,e,t))},collectRenderablesSimple(r,e,t){const i=this.children,s=i.length;for(let n=0;n<s;n++)i[n].collectRenderables(r,e,t)},collectRenderablesWithEffects(r,e,t){const{renderPipes:i}=e;for(let s=0;s<this.effects.length;s++){const n=this.effects[s];i[n.pipe].push(n,this,r)}this.collectRenderablesSimple(r,e,t);for(let s=this.effects.length-1;s>=0;s--){const n=this.effects[s];i[n.pipe].pop(n,this,r)}}};class fo{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let e=0;e<this.filters.length;e++)this.filters[e].destroy();this.filters=null,this.filterArea=null}}class Id{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(e=>{this.add({test:e.test,maskClass:e})}))}add(e){this._tests.push(e)}getMaskEffect(e){this._initialized||this.init();for(let t=0;t<this._tests.length;t++){const i=this._tests[t];if(i.test(e))return _t.get(i.maskClass,e)}return e}returnMaskEffect(e){_t.return(e)}}const Fn=new Id;$.handleByList(I.MaskEffect,Fn._effectClasses);const Bd={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0)},addEffect(r){this.effects.indexOf(r)===-1&&(this.effects.push(r),this.effects.sort((t,i)=>t.priority-i.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(r){const e=this.effects.indexOf(r);e!==-1&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(r){const e=this._maskEffect;(e==null?void 0:e.mask)!==r&&(e&&(this.removeEffect(e),Fn.returnMaskEffect(e),this._maskEffect=null),r!=null&&(this._maskEffect=Fn.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions={...this._maskOptions,...r},r.mask&&(this.mask=r.mask),this._markStructureAsChanged()},set filters(r){var n;!Array.isArray(r)&&r&&(r=[r]);const e=this._filterEffect||(this._filterEffect=new fo);r=r;const t=(r==null?void 0:r.length)>0,i=((n=e.filters)==null?void 0:n.length)>0,s=t!==i;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),s&&(t?this.addEffect(e):(this.removeEffect(e),e.filters=r??null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new fo),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},Dd={label:null,get name(){return V(J,"Container.name property has been removed, use Container.label instead"),this.label},set name(r){V(J,"Container.name property has been removed, use Container.label instead"),this.label=r},getChildByName(r,e=!1){return this.getChildByLabel(r,e)},getChildByLabel(r,e=!1){const t=this.children;for(let i=0;i<t.length;i++){const s=t[i];if(s.label===r||r instanceof RegExp&&r.test(s.label))return s}if(e)for(let i=0;i<t.length;i++){const n=t[i].getChildByLabel(r,!0);if(n)return n}return null},getChildrenByLabel(r,e=!1,t=[]){const i=this.children;for(let s=0;s<i.length;s++){const n=i[s];(n.label===r||r instanceof RegExp&&r.test(n.label))&&t.push(n)}if(e)for(let s=0;s<i.length;s++)i[s].getChildrenByLabel(r,!0,t);return t}},Pt=_t.getPool(U),Qt=_t.getPool(Bt),Fd=new U,zd={getFastGlobalBounds(r,e){e||(e=new Bt),e.clear(),this._getGlobalBoundsRecursive(!!r,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);const t=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(t.worldTransform),e},_getGlobalBoundsRecursive(r,e,t){let i=e;if(r&&this.parentRenderLayer&&this.parentRenderLayer!==t||this.localDisplayStatus!==7||!this.measurable)return;const s=!!this.effects.length;if((this.renderGroup||s)&&(i=Qt.get().clear()),this.boundsArea)e.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;i.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(r,i,t)}if(s){let n=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(n||(n=!0,i.applyMatrix(o.worldTransform)),this.effects[a].addBounds(i,!0));n&&i.applyMatrix(o.worldTransform.copyTo(Fd).invert()),e.addBounds(i),Qt.return(i)}else this.renderGroup&&(e.addBounds(i,this.relativeGroupTransform),Qt.return(i))}};function xh(r,e,t){t.clear();let i,s;return r.parent?e?i=r.parent.worldTransform:(s=Pt.get().identity(),i=ur(r,s)):i=U.IDENTITY,Sh(r,t,i,e),s&&Pt.return(s),t.isValid||t.set(0,0,0,0),t}function Sh(r,e,t,i){var a,h;if(!r.visible||!r.measurable)return;let s;i?s=r.worldTransform:(r.updateLocalTransform(),s=Pt.get(),s.appendFrom(r.localTransform,t));const n=e,o=!!r.effects.length;if(o&&(e=Qt.get().clear()),r.boundsArea)e.addRect(r.boundsArea,s);else{const l=r.bounds;l&&!l.isEmpty()&&(e.matrix=s,e.addBounds(l));for(let c=0;c<r.children.length;c++)Sh(r.children[c],e,s,i)}if(o){for(let l=0;l<r.effects.length;l++)(h=(a=r.effects[l]).addBounds)==null||h.call(a,e);n.addBounds(e,U.IDENTITY),Qt.return(e)}i||Pt.return(s)}function ur(r,e){const t=r.parent;return t&&(ur(t,e),t.updateLocalTransform(),e.append(t.localTransform)),e}function pr(r,e){if(r===16777215||!e)return e;if(e===16777215||!r)return r;const t=r>>16&255,i=r>>8&255,s=r&255,n=e>>16&255,o=e>>8&255,a=e&255,h=t*n/255|0,l=i*o/255|0,c=s*a/255|0;return(h<<16)+(l<<8)+c}const go=16777215;function mo(r,e){return r===go?e:e===go?r:pr(r,e)}function Pi(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const Ld={getGlobalAlpha(r){if(r)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let e=this.alpha,t=this.parent;for(;t;)e*=t.alpha,t=t.parent;return e},getGlobalTransform(r=new U,e){if(e)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const t=ur(this,Pt.get().identity());return r.appendFrom(this.localTransform,t),Pt.return(t),r},getGlobalTint(r){if(r)return this.renderGroup?Pi(this.renderGroup.worldColor):this.parentRenderGroup?Pi(mo(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,t=this.parent;for(;t;)e=mo(e,t.localColor),t=t.parent;return Pi(e)}};function vh(r,e,t){return e.clear(),t||(t=U.IDENTITY),bh(r,e,t,r,!0),e.isValid||e.set(0,0,0,0),e}function bh(r,e,t,i,s){var h,l;let n;if(s)n=Pt.get(),n=t.copyTo(n);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const c=r.localTransform;n=Pt.get(),n.appendFrom(c,t)}const o=e,a=!!r.effects.length;if(a&&(e=Qt.get().clear()),r.boundsArea)e.addRect(r.boundsArea,n);else{r.renderPipeId&&(e.matrix=n,e.addBounds(r.bounds));const c=r.children;for(let d=0;d<c.length;d++)bh(c[d],e,n,i,!1)}if(a){for(let c=0;c<r.effects.length;c++)(l=(h=r.effects[c]).addLocalBounds)==null||l.call(h,e,i);o.addBounds(e,U.IDENTITY),Qt.return(e)}Pt.return(n)}function wh(r,e){const t=r.children;for(let i=0;i<t.length;i++){const s=t[i],n=s.uid,o=(s._didViewChangeTick&65535)<<16|s._didContainerChangeTick&65535,a=e.index;(e.data[a]!==n||e.data[a+1]!==o)&&(e.data[e.index]=n,e.data[e.index+1]=o,e.didChange=!0),e.index=a+2,s.children.length&&wh(s,e)}return e.didChange}const Od=new U,Gd={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(r,e){const t=Math.sign(this.scale.x)||1;e!==0?this.scale.x=r/e*t:this.scale.x=t},_setHeight(r,e){const t=Math.sign(this.scale.y)||1;e!==0?this.scale.y=r/e*t:this.scale.y=t},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new Bt});const r=this._localBoundsCacheData;return r.index=1,r.didChange=!1,r.data[0]!==this._didViewChangeTick&&(r.didChange=!0,r.data[0]=this._didViewChangeTick),wh(this,r),r.didChange&&vh(this,r.localBounds,Od),r.localBounds},getBounds(r,e){return xh(this,r,e||new Bt)}},Wd={_onRender:null,set onRender(r){const e=this.renderGroup||this.parentRenderGroup;if(!r){this._onRender&&(e==null||e.removeOnRender(this)),this._onRender=null;return}this._onRender||e==null||e.addOnRender(this),this._onRender=r},get onRender(){return this._onRender}},Ud={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(r){this._zIndex!==r&&(this._zIndex=r,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(Hd))}};function Hd(r,e){return r._zIndex-e._zIndex}const Vd={getGlobalPosition(r=new tt,e=!1){return this.parent?this.parent.toGlobal(this._position,r,e):(r.x=this._position.x,r.y=this._position.y),r},toGlobal(r,e,t=!1){const i=this.getGlobalTransform(Pt.get(),t);return e=i.apply(r,e),Pt.return(i),e},toLocal(r,e,t,i){e&&(r=e.toGlobal(r,t,i));const s=this.getGlobalTransform(Pt.get(),i);return t=s.applyInverse(r,t),Pt.return(s),t}};class fr{constructor(){this.uid=dt("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(e){this.instructions[this.instructionSize++]=e}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}let Nd=0;class jd{constructor(e){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1,this.textureStyle=new ti(this.textureOptions)}createTexture(e,t,i){const s=new Dt({...this.textureOptions,width:e,height:t,resolution:1,antialias:i,autoGarbageCollect:!1});return new G({source:s,label:`texturePool_${Nd++}`})}getOptimalTexture(e,t,i=1,s){let n=Math.ceil(e*i-1e-6),o=Math.ceil(t*i-1e-6);n=Je(n),o=Je(o);const a=(n<<17)+(o<<1)+(s?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let h=this._texturePool[a].pop();return h||(h=this.createTexture(n,o,s)),h.source._resolution=i,h.source.width=n/i,h.source.height=o/i,h.source.pixelWidth=n,h.source.pixelHeight=o,h.frame.x=0,h.frame.y=0,h.frame.width=e,h.frame.height=t,h.updateUvs(),this._poolKeyHash[h.uid]=a,h}getSameSizeTexture(e,t=!1){const i=e.source;return this.getOptimalTexture(e.width,e.height,i._resolution,t)}returnTexture(e,t=!1){const i=this._poolKeyHash[e.uid];t&&(e.source.style=this.textureStyle),this._texturePool[i].push(e)}clear(e){if(e=e!==!1,e)for(const t in this._texturePool){const i=this._texturePool[t];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this._texturePool={}}}const _s=new jd;Hi.register(_s);class Yd{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new U,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 fr,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(e){this.root=e,e._onRender&&this.addOnRender(e),e.didChange=!0;const t=e.children;for(let i=0;i<t.length;i++){const s=t[i];s._updateFlags=15,this.addChild(s)}}enableCacheAsTexture(e={}){this.textureOptions=e,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(_s.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const e=this._parentCacheAsTextureRenderGroup;e&&!e.textureNeedsUpdate&&e.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const e in this.childrenToUpdate){const t=this.childrenToUpdate[e];t.list.fill(null),t.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(e){e.renderGroupParent&&e.renderGroupParent._removeRenderGroupChild(e),e.renderGroupParent=this,this.renderGroupChildren.push(e)}_removeRenderGroupChild(e){const t=this.renderGroupChildren.indexOf(e);t>-1&&this.renderGroupChildren.splice(t,1),e.renderGroupParent=null}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.updateTick=-1,e.parent===this.root?e.relativeRenderGroupDepth=1:e.relativeRenderGroupDepth=e.parent.relativeRenderGroupDepth+1,e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}e._onRender&&this.addOnRender(e);const t=e.children;for(let i=0;i<t.length;i++)this.addChild(t[i])}removeChild(e){if(this.structureDidChange=!0,e._onRender&&(e.renderGroup||this.removeOnRender(e)),e.parentRenderGroup=null,e.renderGroup){this._removeRenderGroupChild(e.renderGroup);return}const t=e.children;for(let i=0;i<t.length;i++)this.removeChild(t[i])}removeChildren(e){for(let t=0;t<e.length;t++)this.removeChild(e[t])}onChildUpdate(e){let t=this.childrenToUpdate[e.relativeRenderGroupDepth];t||(t=this.childrenToUpdate[e.relativeRenderGroupDepth]={index:0,list:[]}),t.list[t.index++]=e}updateRenderable(e){e.globalDisplayStatus<7||(this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e),e.didViewUpdate=!1)}onChildViewUpdate(e){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=e}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(e){this._onRenderContainers.push(e)}removeOnRender(e){this._onRenderContainers.splice(this._onRenderContainers.indexOf(e),1)}runOnRender(e){for(let t=0;t<this._onRenderContainers.length;t++)this._onRenderContainers[t]._onRender(e)}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(e=[]){const t=this.root.children;for(let i=0;i<t.length;i++)this._getChildren(t[i],e);return e}_getChildren(e,t=[]){if(t.push(e),e.renderGroup)return t;const i=e.children;for(let s=0;s<i.length;s++)this._getChildren(i[s],t);return t}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return this._matrixDirty&1?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new U),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return this._matrixDirty&2?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new U),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(this._matrixDirty&4))return this._inverseParentTextureTransform;this._matrixDirty&=-5;const e=this._parentCacheAsTextureRenderGroup;return e?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new U),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(e.inverseWorldTransform).translate(-e._textureBounds.x,-e._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function Xd(r,e,t={}){for(const i in e)!t[i]&&e[i]!==void 0&&(r[i]=e[i])}const qs=new ct(null),Ji=new ct(null),Ks=new ct(null,1,1),ts=new ct(null),yo=1,Zd=2,$s=4;class L extends Yt{constructor(e={}){var t,i;super(),this.uid=dt("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 U,this.relativeGroupTransform=new U,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new ct(this,0,0),this._scale=Ks,this._pivot=Ji,this._origin=ts,this._skew=qs,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=[],Xd(this,e,{children:!0,parent:!0,effects:!0}),(t=e.children)==null||t.forEach(s=>this.addChild(s)),(i=e.parent)==null||i.addChild(this)}static mixin(e){V("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),$.mixin(L,e)}set _didChangeId(e){this._didViewChangeTick=e>>12&4095,this._didContainerChangeTick=e&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...e){if(this.allowChildren||V(J,"addChild: Only Containers will be allowed to add children in v8.0.0"),e.length>1){for(let s=0;s<e.length;s++)this.addChild(e[s]);return e[0]}const t=e[0],i=this.renderGroup||this.parentRenderGroup;return t.parent===this?(this.children.splice(this.children.indexOf(t),1),this.children.push(t),i&&(i.structureDidChange=!0),t):(t.parent&&t.parent.removeChild(t),this.children.push(t),this.sortableChildren&&(this.sortDirty=!0),t.parent=this,t.didChange=!0,t._updateFlags=15,i&&i.addChild(t),this.emit("childAdded",t,this,this.children.length-1),t.emit("added",this),this._didViewChangeTick++,t._zIndex!==0&&t.depthOfChildModified(),t)}removeChild(...e){if(e.length>1){for(let s=0;s<e.length;s++)this.removeChild(e[s]);return e[0]}const t=e[0],i=this.children.indexOf(t);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(t):this.parentRenderGroup&&this.parentRenderGroup.removeChild(t),t.parentRenderLayer&&t.parentRenderLayer.detach(t),t.parent=null,this.emit("childRemoved",t,this,i),t.emit("removed",this)),t}_onUpdate(e){e&&e===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(e){!!this.renderGroup!==e&&(e?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const e=this.parentRenderGroup;e==null||e.removeChild(this),this.renderGroup=_t.get(Yd,this),this.groupTransform=U.IDENTITY,e==null||e.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const e=this.parentRenderGroup;e==null||e.removeChild(this),_t.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e==null||e.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new U),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(e){this._position.x=e}get y(){return this._position.y}set y(e){this._position.y=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this._skew))}get angle(){return this.rotation*hd}set angle(e){this.rotation=e*ld}get pivot(){return this._pivot===Ji&&(this._pivot=new ct(this,0,0)),this._pivot}set pivot(e){this._pivot===Ji&&(this._pivot=new ct(this,0,0),this._origin!==ts&&nt("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof e=="number"?this._pivot.set(e):this._pivot.copyFrom(e)}get skew(){return this._skew===qs&&(this._skew=new ct(this,0,0)),this._skew}set skew(e){this._skew===qs&&(this._skew=new ct(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===Ks&&(this._scale=new ct(this,1,1)),this._scale}set scale(e){this._scale===Ks&&(this._scale=new ct(this,0,0)),typeof e=="string"&&(e=parseFloat(e)),typeof e=="number"?this._scale.set(e):this._scale.copyFrom(e)}get origin(){return this._origin===ts&&(this._origin=new ct(this,0,0)),this._origin}set origin(e){this._origin===ts&&(this._origin=new ct(this,0,0),this._pivot!==Ji&&nt("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof e=="number"?this._origin.set(e):this._origin.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){const t=this.getLocalBounds().width;this._setWidth(e,t)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){const t=this.getLocalBounds().height;this._setHeight(e,t)}getSize(e){e||(e={});const t=this.getLocalBounds();return e.width=Math.abs(this.scale.x*t.width),e.height=Math.abs(this.scale.y*t.height),e}setSize(e,t){const i=this.getLocalBounds();typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,i.width),t!==void 0&&this._setHeight(t,i.height)}_updateSkew(){const e=this._rotation,t=this._skew;this._cx=Math.cos(e+t._y),this._sx=Math.sin(e+t._y),this._cy=-Math.sin(e-t._x),this._sy=Math.cos(e-t._x)}updateTransform(e){return this.position.set(typeof e.x=="number"?e.x:this.position.x,typeof e.y=="number"?e.y:this.position.y),this.scale.set(typeof e.scaleX=="number"?e.scaleX||1:this.scale.x,typeof e.scaleY=="number"?e.scaleY||1:this.scale.y),this.rotation=typeof e.rotation=="number"?e.rotation:this.rotation,this.skew.set(typeof e.skewX=="number"?e.skewX:this.skew.x,typeof e.skewY=="number"?e.skewY:this.skew.y),this.pivot.set(typeof e.pivotX=="number"?e.pivotX:this.pivot.x,typeof e.pivotY=="number"?e.pivotY:this.pivot.y),this.origin.set(typeof e.originX=="number"?e.originX:this.origin.x,typeof e.originY=="number"?e.originY:this.origin.y),this}setFromMatrix(e){e.decompose(this)}updateLocalTransform(){const e=this._didContainerChangeTick;if(this._didLocalTransformChangeId===e)return;this._didLocalTransformChangeId=e;const t=this.localTransform,i=this._scale,s=this._pivot,n=this._origin,o=this._position,a=i._x,h=i._y,l=s._x,c=s._y,d=-n._x,u=-n._y;t.a=this._cx*a,t.b=this._sx*a,t.c=this._cy*h,t.d=this._sy*h,t.tx=o._x-(l*t.a+c*t.c)+(d*t.a+u*t.c)-d,t.ty=o._y-(l*t.b+c*t.d)+(d*t.b+u*t.d)-u}set alpha(e){e!==this.localAlpha&&(this.localAlpha=e,this._updateFlags|=yo,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){const i=rt.shared.setValue(e??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=yo,this._onUpdate())}get tint(){return Pi(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Zd,this.localBlendMode=e,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){const t=e?2:0;(this.localDisplayStatus&2)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=$s,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(e){const t=e?0:4;(this.localDisplayStatus&4)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=$s,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){const t=e?1:0;(this.localDisplayStatus&1)!==t&&(this._updateFlags|=$s,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(e=!1){var s;if(this.destroyed)return;this.destroyed=!0;let t;if(this.children.length&&(t=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 e=="boolean"?e:e==null?void 0:e.children)&&t)for(let n=0;n<t.length;++n)t[n].destroy(e);(s=this.renderGroup)==null||s.destroy(),this.renderGroup=null}}$.mixin(L,Rd,zd,Vd,Wd,Gd,Bd,Dd,Ud,Pd,Td,Ld,Ed);class ai extends L{constructor(e){super(e),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 Bt(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=e.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(e){this._roundPixels=e?1:0}containsPoint(e){const t=this.bounds,{x:i,y:s}=e;return i>=t.minX&&i<=t.maxX&&s>=t.minY&&s<=t.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(e){this.unload(),super.destroy(e),this._bounds=null}collectRenderablesSimple(e,t,i){const{renderPipes:s}=t;s.blendMode.pushBlendMode(this,this.groupBlendMode,e);const o=s[this.renderPipeId];o!=null&&o.addRenderable&&o.addRenderable(this,e),this.didViewUpdate=!1;const a=this.children,h=a.length;for(let l=0;l<h;l++)a[l].collectRenderables(e,t,i);s.blendMode.popBlendMode(e)}}class jt extends ai{constructor(e=G.EMPTY){e instanceof G&&(e={texture:e});const{texture:t=G.EMPTY,anchor:i,roundPixels:s,width:n,height:o,...a}=e;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:t.defaultAnchor&&(this.anchor=t.defaultAnchor),this.texture=t,this.allowChildren=!1,this.roundPixels=s??!1,n!==void 0&&(this.width=n),o!==void 0&&(this.height=o)}static from(e,t=!1){return e instanceof G?new jt(e):new jt(G.from(e,t))}set texture(e){e||(e=G.EMPTY);const t=this._texture;t!==e&&(t&&t.dynamic&&t.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this._texture=e,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 fh(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return V("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const e=this._anchor,t=this._texture,i=this._bounds,{width:s,height:n}=t.orig;i.minX=-e._x*s,i.maxX=i.minX+s,i.minY=-e._y*n,i.maxY=i.minY+n}destroy(e=!1){if(super.destroy(e),typeof e=="boolean"?e:e==null?void 0:e.texture){const i=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._texture.destroy(i)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(e){this._setWidth(e,this._texture.orig.width),this._width=e}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(e){this._setHeight(e,this._texture.orig.height),this._height=e}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this._texture.orig.width,e.height=Math.abs(this.scale.y)*this._texture.orig.height,e}setSize(e,t){typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,this._texture.orig.width),t!==void 0&&this._setHeight(t,this._texture.orig.height)}}const qd=new Bt;function Ch(r,e,t){const i=qd;r.measurable=!0,xh(r,t,i),e.addBoundsMask(i),r.measurable=!1}function Ah(r,e,t){const i=Qt.get();r.measurable=!0;const s=Pt.get().identity(),n=Ph(r,t,s);vh(r,i,n),r.measurable=!1,e.addBoundsMask(i),Pt.return(s),Qt.return(i)}function Ph(r,e,t){return r?(r!==e&&(Ph(r.parent,e,t),r.updateLocalTransform(),t.append(r.localTransform)),t):(nt("Mask bounds, renderable is not inside the root container"),t)}class Mh{constructor(e){this.priority=0,this.inverse=!1,this.pipe="alphaMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof jt),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(e,t){this.inverse||Ch(this.mask,e,t)}addLocalBounds(e,t){Ah(this.mask,e,t)}containsPoint(e,t){const i=this.mask;return t(i,e)}destroy(){this.reset()}static test(e){return e instanceof jt}}Mh.extension=I.MaskEffect;class _h{constructor(e){this.priority=0,this.pipe="colorMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e}destroy(){}static test(e){return typeof e=="number"}}_h.extension=I.MaskEffect;class Th{constructor(e){this.priority=0,this.pipe="stencilMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(e,t){Ch(this.mask,e,t)}addLocalBounds(e,t){Ah(this.mask,e,t)}containsPoint(e,t){const i=this.mask;return t(i,e)}destroy(){this.reset()}static test(e){return e instanceof L}}Th.extension=I.MaskEffect;const Kd={createCanvas:(r,e)=>{const t=document.createElement("canvas");return t.width=r,t.height=e,t},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,e)=>fetch(r,e),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};let xo=Kd;const j={get(){return xo},set(r){xo=r}};class gr extends Dt{constructor(e){e.resource||(e.resource=j.get().createCanvas()),e.width||(e.width=e.resource.width,e.autoDensity||(e.width/=e.resolution)),e.height||(e.height=e.resource.height,e.autoDensity||(e.height/=e.resolution)),super(e),this.uploadMethodId="image",this.autoDensity=e.autoDensity,this.resizeCanvas(),this.transparent=!!e.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(e=this.width,t=this.height,i=this._resolution){const s=super.resize(e,t,i);return s&&this.resizeCanvas(),s}static test(e){return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&e instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}gr.extension=I.TextureSource;class ii extends Dt{constructor(e){super(e),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(e){return globalThis.HTMLImageElement&&e instanceof HTMLImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||globalThis.VideoFrame&&e instanceof VideoFrame}}ii.extension=I.TextureSource;var Ie=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(Ie||{});class Qs{constructor(e,t=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=t,this.priority=i,this._once=s}match(e,t=null){return this._fn===e&&this._context===t}emit(e){this._fn&&(this._context?this._fn.call(this._context,e):this._fn(e));const t=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!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 t=this.next;return this.next=e?null:t,this.previous=null,t}}const kh=class Tt{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 Qs(null,null,1/0),this.deltaMS=1/Tt.targetFPMS,this.elapsedMS=1/Tt.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),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(e,t,i=Ie.NORMAL){return this._addListener(new Qs(e,t,i))}addOnce(e,t,i=Ie.NORMAL){return this._addListener(new Qs(e,t,i,!0))}_addListener(e){let t=this._head.next,i=this._head;if(!t)e.connect(i);else{for(;t;){if(e.priority>t.priority){e.connect(i);break}i=t,t=t.next}e.previous||e.connect(i)}return this._startIfPossible(),this}remove(e,t){let i=this._head.next;for(;i;)i.match(e,t)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){const n=e-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=e-n%this._minElapsedMS}this.deltaMS=t,this.deltaTime=this.deltaMS*Tt.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const t=Math.min(this.maxFPS,e),i=Math.min(Math.max(0,t)/1e3,Tt.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){if(e===0)this._minElapsedMS=0;else{const t=Math.max(this.minFPS,e);this._minElapsedMS=1/(t/1e3)}}static get shared(){if(!Tt._shared){const e=Tt._shared=new Tt;e.autoStart=!0,e._protected=!0}return Tt._shared}static get system(){if(!Tt._system){const e=Tt._system=new Tt;e.autoStart=!0,e._protected=!0}return Tt._system}};kh.targetFPMS=.06;let yt=kh,Js;async function Rh(){return Js??(Js=(async()=>{var o;const e=j.get().createCanvas(1,1).getContext("webgl");if(!e)return"premultiply-alpha-on-upload";const t=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(!t)return"premultiply-alpha-on-upload";const i=e.createTexture();e.bindTexture(e.TEXTURE_2D,i);const s=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,s),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,i,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t);const n=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,n),e.deleteFramebuffer(s),e.deleteTexture(i),(o=e.getExtension("WEBGL_lose_context"))==null||o.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Js}const Ts=class Eh extends Dt{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...Eh.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this.alphaMode=e.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),e.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const e=yt.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!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 e=this.resource,t=this.options;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(t.preload||e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlayThrough),e.addEventListener("error",this._onError,!0)),this.alphaMode=await Rh(),this._load=new Promise((i,s)=>{this.isValid?i(this):(this._resolve=i,this._reject=s,t.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${t.preloadTimeoutMs}ms`))})),e.load())}),this._load}_onError(e){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){const e=this.resource;return!e.paused&&!e.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const e=this.resource;this.isValid&&(this.isReady=!0,this.resize(e.videoWidth,e.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const e=this.resource;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlayThrough),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(yt.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||(yt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(yt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};Ts.extension=I.TextureSource;Ts.defaultOptions={...Dt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Ts.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Mi=Ts;const zt=(r,e,t=!1)=>(Array.isArray(r)||(r=[r]),e?r.map(i=>typeof i=="string"||t?e(i):i):r);class $d{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){const t=this._cache.get(e);return t||nt(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){const i=zt(e);let s;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.test(t)){s=l.getCacheableAssets(i,t);break}}const n=new Map(Object.entries(s||{}));s||i.forEach(h=>{n.set(h,t)});const o=[...n.keys()],a={cacheKeys:o,keys:i};i.forEach(h=>{this._cacheMap.set(h,a)}),o.forEach(h=>{const l=s?s[h]:t;this._cache.has(h)&&this._cache.get(h)!==l&&nt("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(e){if(!this._cacheMap.has(e)){nt(`[Assets] Asset id ${e} was not found in the Cache`);return}const t=this._cacheMap.get(e);t.cacheKeys.forEach(s=>{this._cache.delete(s)}),t.keys.forEach(s=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}}const xt=new $d,zn=[];$.handleByList(I.TextureSource,zn);function Ih(r={}){const e=r&&r.resource,t=e?r.resource:r,i=e?r:{resource:r};for(let s=0;s<zn.length;s++){const n=zn[s];if(n.test(t))return new n(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function Qd(r={},e=!1){const t=r&&r.resource,i=t?r.resource:r,s=t?r:{resource:r};if(!e&&xt.has(i))return xt.get(i);const n=new G({source:Ih(s)});return n.on("destroy",()=>{xt.has(i)&&xt.remove(i)}),e||xt.set(i,n),n}function Jd(r,e=!1){return typeof r=="string"?xt.get(r):r instanceof Dt?new G({source:r}):Qd(r,e)}G.from=Jd;Dt.from=Ih;$.add(Mh,_h,Th,Mi,ii,gr,dr);var ue=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(ue||{});function Ft(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function di(r){return r.split("?")[0].split("#")[0]}function tu(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eu(r,e,t){return r.replace(new RegExp(tu(e),"g"),t)}function iu(r,e){let t="",i=0,s=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(t.length<2||i!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){const h=t.lastIndexOf("/");if(h!==t.length-1){h===-1?(t="",i=0):(t=t.slice(0,h),i=t.length-1-t.lastIndexOf("/")),s=a,n=0;continue}}else if(t.length===2||t.length===1){t="",i=0,s=a,n=0;continue}}}else t.length>0?t+=`/${r.slice(s+1,a)}`:t=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return t}const Mt={toPosix(r){return eu(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){Ft(r),r=this.toPosix(r);const e=/^file:\/\/\//.exec(r);if(e)return e[0];const t=/^[^/:]+:\/{0,2}/.exec(r);return t?t[0]:""},toAbsolute(r,e,t){if(Ft(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=di(this.toPosix(e??j.get().getBaseUrl())),s=di(this.toPosix(t??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?Mt.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(Ft(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let e="";const t=r.startsWith("/");this.hasProtocol(r)&&(e=this.rootname(r),r=r.slice(e.length));const i=r.endsWith("/");return r=iu(r),r.length>0&&i&&(r+="/"),t?`/${r}`:e+r},isAbsolute(r){return Ft(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let e;for(let t=0;t<r.length;++t){const i=r[t];if(Ft(i),i.length>0)if(e===void 0)e=i;else{const s=r[t-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?e+=`/../${i}`:e+=`/${i}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(Ft(r),r.length===0)return".";r=this.toPosix(r);let e=r.charCodeAt(0);const t=e===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(e=r.charCodeAt(a),e===47){if(!s){i=a;break}}else s=!1;return i===-1?t?"/":this.isUrl(o)?n+r:n:t&&i===1?"//":n+r.slice(0,i)},rootname(r){Ft(r),r=this.toPosix(r);let e="";if(r.startsWith("/")?e="/":e=this.getProtocol(r),this.isUrl(r)){const t=r.indexOf("/",e.length);t!==-1?e=r.slice(0,t):e=r,e.endsWith("/")||(e+="/")}return e},basename(r,e){Ft(r),e&&Ft(e),r=di(this.toPosix(r));let t=0,i=-1,s=!0,n;if(e!==void 0&&e.length>0&&e.length<=r.length){if(e.length===r.length&&e===r)return"";let o=e.length-1,a=-1;for(n=r.length-1;n>=0;--n){const h=r.charCodeAt(n);if(h===47){if(!s){t=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(h===e.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return t===i?i=a:i===-1&&(i=r.length),r.slice(t,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){t=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(t,i)},extname(r){Ft(r),r=di(this.toPosix(r));let e=-1,t=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){t=o+1;break}continue}i===-1&&(s=!1,i=o+1),a===46?e===-1?e=o:n!==1&&(n=1):e!==-1&&(n=-1)}return e===-1||i===-1||n===0||n===1&&e===i-1&&e===t+1?"":r.slice(e,i)},parse(r){Ft(r);const e={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return e;r=di(this.toPosix(r));let t=r.charCodeAt(0);const i=this.isAbsolute(r);let s;e.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let n=-1,o=0,a=-1,h=!0,l=r.length-1,c=0;for(;l>=s;--l){if(t=r.charCodeAt(l),t===47){if(!h){o=l+1;break}continue}a===-1&&(h=!1,a=l+1),t===46?n===-1?n=l:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&i?e.base=e.name=r.slice(1,a):e.base=e.name=r.slice(o,a)):(o===0&&i?(e.name=r.slice(1,n),e.base=r.slice(1,a)):(e.name=r.slice(o,n),e.base=r.slice(o,a)),e.ext=r.slice(n,a)),e.dir=this.dirname(r),e},sep:"/",delimiter:":",joinExtensions:[".html"]};function Bh(r,e,t,i,s){const n=e[t];for(let o=0;o<n.length;o++){const a=n[o];t<e.length-1?Bh(r.replace(i[t],a),e,t+1,i,s):s.push(r.replace(i[t],a))}}function su(r){const e=/\{(.*?)\}/g,t=r.match(e),i=[];if(t){const s=[];t.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),Bh(r,s,0,t,i)}else i.push(r);return i}const ms=r=>!Array.isArray(r);class hi{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${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(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}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(e){if(typeof e=="string")this._defaultSearchParams=e;else{const t=e;this._defaultSearchParams=Object.keys(t).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(t[i])}`).join("&")}}getAlias(e){const{alias:t,src:i}=e;return zt(t||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(o=>(o==null?void 0:o.src)??o):n!=null&&n.src?n.src:n,!0)}addManifest(e){this._manifest&&nt("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){const i=[];let s=t;Array.isArray(t)||(s=Object.entries(t).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:{alias:n,...o})),s.forEach(n=>{const o=n.src,a=n.alias;let h;if(typeof a=="string"){const l=this._createBundleAssetId(e,a);i.push(l),h=[a,l]}else{const l=a.map(c=>this._createBundleAssetId(e,c));i.push(...l),h=[...a,...l]}this.add({...n,alias:h,src:o})}),this._bundles[e]=i}add(e){const t=[];Array.isArray(e)?t.push(...e):t.push(e);let i;i=n=>{this.hasKey(n)&&nt(`[Resolver] already has key: ${n} overwriting`)},zt(t).forEach(n=>{const{src:o}=n;let{data:a,format:h,loadParser:l,parser:c}=n;const d=zt(o).map(y=>typeof y=="string"?su(y):Array.isArray(y)?y:[y]),u=this.getAlias(n);Array.isArray(u)?u.forEach(i):i(u);const p=[],f=y=>{const m=this._parsers.find(x=>x.test(y));return{src:y,...m==null?void 0:m.parse(y)}};d.forEach(y=>{y.forEach(m=>{let x={};if(typeof m!="object"?x=f(m):(a=m.data??a,h=m.format??h,(m.loadParser||m.parser)&&(l=m.loadParser??l,c=m.parser??c),x={...f(m.src),...m}),!u)throw new Error(`[Resolver] alias is undefined for this asset: ${x.src}`);x=this._buildResolvedAsset(x,{aliases:u,data:a,format:h,loadParser:l,parser:c,progressSize:n.progressSize}),p.push(x)})}),u.forEach(y=>{this._assetMap[y]=p})})}resolveBundle(e){const t=ms(e);e=zt(e);const i={};return e.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(s,h)]=l}i[s]=a}}),t?i[e[0]]:i}resolveUrl(e){const t=this.resolve(e);if(typeof e!="string"){const i={};for(const s in t)i[s]=t[s].src;return i}return t.src}resolve(e){const t=ms(e);e=zt(e);const i={};return e.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(h=>{const l=n.filter(c=>c[a]?c[a]===h:!1);l.length&&(n=l)})}),this._resolverHash[s]=n[0]}else this._resolverHash[s]=this._buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),t?i[e[0]]:i}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;t<e.length;t++){const i=e[t],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;const t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}_buildResolvedAsset(e,t){const{aliases:i,data:s,loadParser:n,parser:o,format:a,progressSize:h}=t;return(this._basePath||this._rootPath)&&(e.src=Mt.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=i??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...s||{},...e.data},e.loadParser=n??e.loadParser,e.parser=o??e.parser,e.format=a??e.format??nu(e.src),h!==void 0&&(e.progressSize=h),e}}hi.RETINA_PREFIX=/@([0-9\.]+)x/;function nu(r){return r.split(".").pop().split("?").shift().split("#").shift()}const Ln=(r,e)=>{const t=e.split("?")[1];return t&&(r+=`?${t}`),r},Dh=class wi{constructor(e,t){this.linkedSheets=[];let i=e;(e==null?void 0:e.source)instanceof Dt&&(i={texture:e,data:t});const{texture:s,data:n,cachePrefix:o=""}=i;this.cachePrefix=o,this._texture=s instanceof G?s:null,this.textureSource=s.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,s.source.resolution=this.resolution):this.resolution=s.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=wi.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(e,t=!1){let i=e;const s=t?1/0:wi.BATCH_SIZE;for(;i-e<s&&i<this._frameKeys.length;){const n=this._frameKeys[i],o=this._frames[n],a=o.frame;if(a){let h=null,l=null;const c=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,d=new et(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);o.rotated?h=new et(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 et(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 et(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[n]=new G({source:this.textureSource,frame:h,orig:d,trim:l,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:n.toString()})}i++}}_processAnimations(){const e=this.data.animations||{};for(const t in e){this.animations[t]=[];for(let i=0;i<e[t].length;i++){const s=e[t][i];this.animations[t].push(this.textures[s])}}}_parseComplete(){const e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*wi.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*wi.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){var t;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&((t=this._texture)==null||t.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};Dh.BATCH_SIZE=1e3;let On=Dh;const ru=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Fh(r,e,t){const i={};if(r.forEach(s=>{i[s]=e}),Object.keys(e.textures).forEach(s=>{i[`${e.cachePrefix}${s}`]=e.textures[s]}),!t){const s=Mt.dirname(r[0]);e.linkedSheets.forEach((n,o)=>{const a=Fh([`${s}/${e.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const ou={extension:I.Asset,cache:{test:r=>r instanceof On,getCacheableAssets:(r,e)=>Fh(r,e,!1)},resolver:{extension:{type:I.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),i=t.pop(),s=t.pop();return i==="json"&&ru.includes(s)},parse:r=>{var t;const e=r.split(".");return{resolution:parseFloat(((t=hi.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:e[e.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:I.LoadParser,priority:ue.Normal,name:"spritesheetLoader"},async testParse(r,e){return Mt.extname(e.src).toLowerCase()===".json"&&!!r.frames},async parse(r,e,t){var d,u;const{texture:i,imageFilename:s,textureOptions:n,cachePrefix:o}=(e==null?void 0:e.data)??{};let a=Mt.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let h;if(i instanceof G)h=i;else{const p=Ln(a+(s??r.meta.image),e.src);h=(await t.load([{src:p,data:n}]))[p]}const l=new On({texture:h.source,data:r,cachePrefix:o});await l.parse();const c=(d=r==null?void 0:r.meta)==null?void 0:d.related_multi_packs;if(Array.isArray(c)){const p=[];for(const y of c){if(typeof y!="string")continue;let m=a+y;(u=e.data)!=null&&u.ignoreMultiPack||(m=Ln(m,e.src),p.push(t.load({src:m,data:{textureOptions:n,ignoreMultiPack:!0}})))}const f=await Promise.all(p);l.linkedSheets=f,f.forEach(y=>{y.linkedSheets=[l].concat(l.linkedSheets.filter(m=>m!==y))})}return l},async unload(r,e,t){await t.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};$.add(ou);class au{constructor(e){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),i=this._canvas.width,s=this._canvas.height,n=t.width/i*this._renderer.resolution,o=t.height/s*this._renderer.resolution,a=t.left,h=t.top,l=`translate(${a}px, ${h}px) scale(${n}, ${o})`;l!==this._lastTransform&&(this._domElement.style.transform=l,this._lastTransform=l)},this._domElement=e.domElement,this._renderer=e.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(e=>{for(const t of e){if(t.target!==this._canvas)continue;const i=this.canvas.width,s=this.canvas.height,n=t.contentRect.width/i*this._renderer.resolution,o=t.contentRect.height/s*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||yt.shared.add(this.updateTranslation,this,Ie.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&yt.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class mr{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=mr.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new tt,this.page=new tt,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var tn=/iPhone/i,So=/iPod/i,vo=/iPad/i,bo=/\biOS-universal(?:.+)Mac\b/i,en=/\bAndroid(?:.+)Mobile\b/i,wo=/Android/i,ze=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,es=/Silk/i,qt=/Windows Phone/i,Co=/\bWindows(?:.+)ARM\b/i,Ao=/BlackBerry/i,Po=/BB10/i,Mo=/Opera Mini/i,_o=/\b(CriOS|Chrome)(?:.+)Mobile/i,To=/Mobile(?:.+)Firefox\b/i,ko=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function hu(r){return function(e){return e.test(r)}}function Ro(r){var e={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?e.userAgent=r:r&&r.userAgent&&(e={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var s=hu(t),n={apple:{phone:s(tn)&&!s(qt),ipod:s(So),tablet:!s(tn)&&(s(vo)||ko(e))&&!s(qt),universal:s(bo),device:(s(tn)||s(So)||s(vo)||s(bo)||ko(e))&&!s(qt)},amazon:{phone:s(ze),tablet:!s(ze)&&s(es),device:s(ze)||s(es)},android:{phone:!s(qt)&&s(ze)||!s(qt)&&s(en),tablet:!s(qt)&&!s(ze)&&!s(en)&&(s(es)||s(wo)),device:!s(qt)&&(s(ze)||s(es)||s(en)||s(wo))||s(/\bokhttp\b/i)},windows:{phone:s(qt),tablet:s(Co),device:s(qt)||s(Co)},other:{blackberry:s(Ao),blackberry10:s(Po),opera:s(Mo),firefox:s(To),chrome:s(_o),device:s(Ao)||s(Po)||s(Mo)||s(To)||s(_o)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const lu=Ro.default??Ro,Gn=lu(globalThis.navigator),sn=Object.create(null),Eo=Object.create(null);function yr(r,e){let t=Eo[r];return t===void 0&&(sn[e]===void 0&&(sn[e]=1),Eo[r]=t=sn[e]++),t}let Le;function zh(){return(!Le||Le!=null&&Le.isContextLost())&&(Le=j.get().createCanvas().getContext("webgl",{})),Le}let is;function cu(){if(!is){is="mediump";const r=zh();r&&r.getShaderPrecisionFormat&&(is=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return is}function du(r,e,t){return e?r:t?(r=r.replace("out vec4 finalColor;",""),`
|
|
5
|
+
`),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",s),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",s),console.warn(i))),Jr.add(e)};Object.defineProperties(V,{quiet:{get:()=>He.quiet,set:r=>{He.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>He.noColor,set:r=>{He.noColor=r},enumerable:!0,configurable:!1}});const oh=()=>{};function Je(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function to(r){return!(r&r-1)&&!!r}function ah(r){const e={};for(const t in r)r[t]!==void 0&&(e[t]=r[t]);return e}const eo=Object.create(null);function ud(r){const e=eo[r];return e===void 0&&(eo[r]=dt("resource")),e}const hh=class lh extends Yt{constructor(e={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,e={...lh.defaultOptions,...e},this.addressMode=e.addressMode,this.addressModeU=e.addressModeU??this.addressModeU,this.addressModeV=e.addressModeV??this.addressModeV,this.addressModeW=e.addressModeW??this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=e.magFilter??this.magFilter,this.minFilter=e.minFilter??this.minFilter,this.mipmapFilter=e.mipmapFilter??this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=e.maxAnisotropy??1}set addressMode(e){this.addressModeU=e,this.addressModeV=e,this.addressModeW=e}get addressMode(){return this.addressModeU}set wrapMode(e){V(J,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=e}get wrapMode(){return this.addressMode}set scaleMode(e){this.magFilter=e,this.minFilter=e,this.mipmapFilter=e}get scaleMode(){return this.magFilter}set maxAnisotropy(e){this._maxAnisotropy=Math.min(e,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 e=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=ud(e),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};hh.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let ti=hh;const ch=class dh extends Yt{constructor(e={}){super(),this.options=e,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=dt("textureSource"),this._resourceType="textureSource",this._resourceId=dt("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._touched=0,this._batchTick=-1,this._textureBindLocation=-1,e={...dh.defaultOptions,...e},this.label=e.label??"",this.resource=e.resource,this.autoGarbageCollect=e.autoGarbageCollect,this._resolution=e.resolution,e.width?this.pixelWidth=e.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,e.height?this.pixelHeight=e.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=e.format,this.dimension=e.dimensions,this.viewDimension=e.viewDimension??e.dimensions,this.arrayLayerCount=e.arrayLayerCount,this.mipLevelCount=e.mipLevelCount,this.autoGenerateMipmaps=e.autoGenerateMipmaps,this.sampleCount=e.sampleCount,this.antialias=e.antialias,this.alphaMode=e.alphaMode,this.style=new ti(ah(e)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(e){var t,i;this.style!==e&&((t=this._style)==null||t.off("change",this._onStyleChange,this),this._style=e,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(e){this._style.maxAnisotropy=e}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(e){this._style.addressMode=e}get repeatMode(){return this._style.addressMode}set repeatMode(e){this._style.addressMode=e}get magFilter(){return this._style.magFilter}set magFilter(e){this._style.magFilter=e}get minFilter(){return this._style.minFilter}set minFilter(e){this._style.minFilter=e}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(e){this._style.mipmapFilter=e}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(e){this._style.lodMinClamp=e}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(e){this._style.lodMaxClamp=e}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const e=this._resolution;if(this.resize(this.resourceWidth/e,this.resourceHeight/e))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 e,t;this._resourceId=dt("resource"),this.emit("change",this),this.emit("unload",this);for(const i in this._gpuData)(t=(e=this._gpuData[i])==null?void 0:e.destroy)==null||t.call(e);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:e}=this;return e.naturalWidth||e.videoWidth||e.displayWidth||e.width}get resourceHeight(){const{resource:e}=this;return e.naturalHeight||e.videoHeight||e.displayHeight||e.height}get resolution(){return this._resolution}set resolution(e){this._resolution!==e&&(this._resolution=e,this.width=this.pixelWidth/e,this.height=this.pixelHeight/e)}resize(e,t,i){i||(i=this._resolution),e||(e=this.width),t||(t=this.height);const s=Math.round(e*i),n=Math.round(t*i);return this.width=s/i,this.height=n/i,this._resolution=i,this.pixelWidth===s&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=s,this.pixelHeight=n,this.emit("resize",this),this._resourceId=dt("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(e){this._style.wrapMode=e}get wrapMode(){return this._style.wrapMode}set scaleMode(e){this._style.scaleMode=e}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=to(this.pixelWidth)&&to(this.pixelHeight)}static test(e){throw new Error("Unimplemented")}};ch.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 Dt=ch;class cr extends Dt{constructor(e){const t=e.resource||new Float32Array(e.width*e.height*4);let i=e.format;i||(t instanceof Float32Array?i="rgba32float":t instanceof Int32Array||t instanceof Uint32Array?i="rgba32uint":t instanceof Int16Array||t instanceof Uint16Array?i="rgba16uint":(t instanceof Int8Array,i="bgra8unorm")),super({...e,resource:t,format:i}),this.uploadMethodId="buffer"}static test(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}}cr.extension=I.TextureSource;const io=new U;class pd{constructor(e,t){this.mapCoord=new U,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof t>"u"?this.clampMargin=e.width<10?0:.5:this.clampMargin=t,this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){var t;this.texture!==e&&((t=this._texture)==null||t.removeListener("update",this.update,this),this._texture=e,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(e,t){t===void 0&&(t=e);const i=this.mapCoord;for(let s=0;s<e.length;s+=2){const n=e[s],o=e[s+1];t[s]=n*i.a+o*i.c+i.tx,t[s+1]=n*i.b+o*i.d+i.ty}return t}update(){const e=this._texture;this._updateID++;const t=e.uvs;this.mapCoord.set(t.x1-t.x0,t.y1-t.y0,t.x3-t.x0,t.y3-t.y0,t.x0,t.y0);const i=e.orig,s=e.trim;s&&(io.set(i.width/s.width,0,0,i.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(io));const n=e.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,h=this.clampOffset/n._resolution;return o[0]=(e.frame.x+a+h)/n.width,o[1]=(e.frame.y+a+h)/n.height,o[2]=(e.frame.x+e.frame.width-a+h)/n.width,o[3]=(e.frame.y+e.frame.height-a+h)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=e.frame.width===n.width&&e.frame.height===n.height&&e.rotate===0,!0}}class W extends Yt{constructor({source:e,label:t,frame:i,orig:s,trim:n,defaultAnchor:o,defaultBorders:a,rotate:h,dynamic:l}={}){if(super(),this.uid=dt("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new et,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=(e==null?void 0:e.source)??new Dt,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:c,height:d}=this._source;this.frame.width=c,this.frame.height=d}this.orig=s||this.frame,this.trim=n,this.rotate=h??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=l||!1,this.updateUvs()}set source(e){this._source&&this._source.off("resize",this.update,this),this._source=e,e.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new pd(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:e,frame:t}=this,{width:i,height:s}=this._source,n=t.x/i,o=t.y/s,a=t.width/i,h=t.height/s;let l=this.rotate;if(l){const c=a/2,d=h/2,u=n+c,p=o+d;l=X.add(l,X.NW),e.x0=u+c*X.uX(l),e.y0=p+d*X.uY(l),l=X.add(l,2),e.x1=u+c*X.uX(l),e.y1=p+d*X.uY(l),l=X.add(l,2),e.x2=u+c*X.uX(l),e.y2=p+d*X.uY(l),l=X.add(l,2),e.x3=u+c*X.uX(l),e.y3=p+d*X.uY(l)}else e.x0=n,e.y0=o,e.x1=n+a,e.y1=o,e.x2=n+a,e.y2=o+h,e.x3=n,e.y3=o+h}destroy(e=!1){this._source&&(this._source.off("resize",this.update,this),e&&(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 V(J,"Texture.baseTexture is now Texture.source"),this._source}}W.EMPTY=new W({label:"EMPTY",source:new Dt({label:"EMPTY"})});W.EMPTY.destroy=oh;W.WHITE=new W({source:new cr({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});W.WHITE.destroy=oh;function uh(r,e,t){const{width:i,height:s}=t.orig,n=t.trim;if(n){const o=n.width,a=n.height;r.minX=n.x-e._x*i,r.maxX=r.minX+o,r.minY=n.y-e._y*s,r.maxY=r.minY+a}else r.minX=-e._x*i,r.maxX=r.minX+i,r.minY=-e._y*s,r.maxY=r.minY+s}const so=new U;class Bt{constructor(e=1/0,t=1/0,i=-1/0,s=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=so,this.minX=e,this.minY=t,this.maxX=i,this.maxY=s}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new et);const e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):e.copyFromBounds(this),e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=so,this}set(e,t,i,s){this.minX=e,this.minY=t,this.maxX=i,this.maxY=s}addFrame(e,t,i,s,n){n||(n=this.matrix);const o=n.a,a=n.b,h=n.c,l=n.d,c=n.tx,d=n.ty;let u=this.minX,p=this.minY,f=this.maxX,y=this.maxY,m=o*e+h*t+c,x=a*e+l*t+d;m<u&&(u=m),x<p&&(p=x),m>f&&(f=m),x>y&&(y=x),m=o*i+h*t+c,x=a*i+l*t+d,m<u&&(u=m),x<p&&(p=x),m>f&&(f=m),x>y&&(y=x),m=o*e+h*s+c,x=a*e+l*s+d,m<u&&(u=m),x<p&&(p=x),m>f&&(f=m),x>y&&(y=x),m=o*i+h*s+c,x=a*i+l*s+d,m<u&&(u=m),x<p&&(p=x),m>f&&(f=m),x>y&&(y=x),this.minX=u,this.minY=p,this.maxX=f,this.maxY=y}addRect(e,t){this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,t)}addBounds(e,t){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t)}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}applyMatrix(e){const t=this.minX,i=this.minY,s=this.maxX,n=this.maxY,{a:o,b:a,c:h,d:l,tx:c,ty:d}=e;let u=o*t+h*i+c,p=a*t+l*i+d;this.minX=u,this.minY=p,this.maxX=u,this.maxY=p,u=o*s+h*i+c,p=a*s+l*i+d,this.minX=u<this.minX?u:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=p>this.maxY?p:this.maxY,u=o*t+h*n+c,p=a*t+l*n+d,this.minX=u<this.minX?u:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=p>this.maxY?p:this.maxY,u=o*s+h*n+c,p=a*s+l*n+d,this.minX=u<this.minX?u:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=p>this.maxY?p:this.maxY}fit(e){return this.minX<e.left&&(this.minX=e.left),this.maxX>e.right&&(this.maxX=e.right),this.minY<e.top&&(this.minY=e.top),this.maxY>e.bottom&&(this.maxY=e.bottom),this}fitBounds(e,t,i,s){return this.minX<e&&(this.minX=e),this.maxX>t&&(this.maxX=t),this.minY<i&&(this.minY=i),this.maxY>s&&(this.maxY=s),this}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,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 Bt(this.minX,this.minY,this.maxX,this.maxY)}scale(e,t=e){return this.minX*=e,this.minY*=t,this.maxX*=e,this.maxY*=t,this}get x(){return this.minX}set x(e){const t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){const t=this.maxY-this.minY;this.minY=e,this.maxY=e+t}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}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(e,t,i,s){let n=this.minX,o=this.minY,a=this.maxX,h=this.maxY;s||(s=this.matrix);const l=s.a,c=s.b,d=s.c,u=s.d,p=s.tx,f=s.ty;for(let y=t;y<i;y+=2){const m=e[y],x=e[y+1],S=l*m+d*x+p,v=c*m+u*x+f;n=S<n?S:n,o=v<o?v:o,a=S>a?S:a,h=v>h?v:h}this.minX=n,this.minY=o,this.maxX=a,this.maxY=h}containsPoint(e,t){return this.minX<=e&&this.minY<=t&&this.maxX>=e&&this.maxY>=t}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(e){return this.minX=e.minX,this.minY=e.minY,this.maxX=e.maxX,this.maxY=e.maxY,this}}var fd={grad:.9,turn:360,rad:360/(2*Math.PI)},Zt=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},St=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*r)/t+0},It=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),r>t?t:r>e?r:e},ph=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},no=function(r){return{r:It(r.r,0,255),g:It(r.g,0,255),b:It(r.b,0,255),a:It(r.a)}},js=function(r){return{r:St(r.r),g:St(r.g),b:St(r.b),a:St(r.a,3)}},gd=/^#([0-9a-f]{3,8})$/i,Qi=function(r){var e=r.toString(16);return e.length<2?"0"+e:e},fh=function(r){var e=r.r,t=r.g,i=r.b,s=r.a,n=Math.max(e,t,i),o=n-Math.min(e,t,i),a=o?n===e?(t-i)/o:n===t?2+(i-e)/o:4+(e-t)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},gh=function(r){var e=r.h,t=r.s,i=r.v,s=r.a;e=e/360*6,t/=100,i/=100;var n=Math.floor(e),o=i*(1-t),a=i*(1-(e-n)*t),h=i*(1-(1-e+n)*t),l=n%6;return{r:255*[i,a,o,o,h,i][l],g:255*[h,i,i,a,o,o][l],b:255*[o,o,h,i,i,a][l],a:s}},ro=function(r){return{h:ph(r.h),s:It(r.s,0,100),l:It(r.l,0,100),a:It(r.a)}},oo=function(r){return{h:St(r.h),s:St(r.s),l:St(r.l),a:St(r.a,3)}},ao=function(r){return gh((t=(e=r).s,{h:e.h,s:(t*=((i=e.l)<50?i:100-i)/100)>0?2*t/(i+t)*100:0,v:i+t,a:e.a}));var e,t,i},Ai=function(r){return{h:(e=fh(r)).h,s:(s=(200-(t=e.s))*(i=e.v)/100)>0&&s<200?t*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:e.a};var e,t,i,s},md=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,yd=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,xd=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Sd=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Bn={string:[[function(r){var e=gd.exec(r);return e?(r=e[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?St(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?St(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var e=xd.exec(r)||Sd.exec(r);return e?e[2]!==e[4]||e[4]!==e[6]?null:no({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(r){var e=md.exec(r)||yd.exec(r);if(!e)return null;var t,i,s=ro({h:(t=e[1],i=e[2],i===void 0&&(i="deg"),Number(t)*(fd[i]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return ao(s)},"hsl"]],object:[[function(r){var e=r.r,t=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return Zt(e)&&Zt(t)&&Zt(i)?no({r:Number(e),g:Number(t),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var e=r.h,t=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!Zt(e)||!Zt(t)||!Zt(i))return null;var o=ro({h:Number(e),s:Number(t),l:Number(i),a:Number(n)});return ao(o)},"hsl"],[function(r){var e=r.h,t=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!Zt(e)||!Zt(t)||!Zt(i))return null;var o=function(a){return{h:ph(a.h),s:It(a.s,0,100),v:It(a.v,0,100),a:It(a.a)}}({h:Number(e),s:Number(t),v:Number(i),a:Number(n)});return gh(o)},"hsv"]]},ho=function(r,e){for(var t=0;t<e.length;t++){var i=e[t][0](r);if(i)return[i,e[t][1]]}return[null,void 0]},vd=function(r){return typeof r=="string"?ho(r.trim(),Bn.string):typeof r=="object"&&r!==null?ho(r,Bn.object):[null,void 0]},Ys=function(r,e){var t=Ai(r);return{h:t.h,s:It(t.s+100*e,0,100),l:t.l,a:t.a}},Xs=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},lo=function(r,e){var t=Ai(r);return{h:t.h,s:t.s,l:It(t.l+100*e,0,100),a:t.a}},Dn=function(){function r(e){this.parsed=vd(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return St(Xs(this.rgba),2)},r.prototype.isDark=function(){return Xs(this.rgba)<.5},r.prototype.isLight=function(){return Xs(this.rgba)>=.5},r.prototype.toHex=function(){return e=js(this.rgba),t=e.r,i=e.g,s=e.b,o=(n=e.a)<1?Qi(St(255*n)):"","#"+Qi(t)+Qi(i)+Qi(s)+o;var e,t,i,s,n,o},r.prototype.toRgb=function(){return js(this.rgba)},r.prototype.toRgbString=function(){return e=js(this.rgba),t=e.r,i=e.g,s=e.b,(n=e.a)<1?"rgba("+t+", "+i+", "+s+", "+n+")":"rgb("+t+", "+i+", "+s+")";var e,t,i,s,n},r.prototype.toHsl=function(){return oo(Ai(this.rgba))},r.prototype.toHslString=function(){return e=oo(Ai(this.rgba)),t=e.h,i=e.s,s=e.l,(n=e.a)<1?"hsla("+t+", "+i+"%, "+s+"%, "+n+")":"hsl("+t+", "+i+"%, "+s+"%)";var e,t,i,s,n},r.prototype.toHsv=function(){return e=fh(this.rgba),{h:St(e.h),s:St(e.s),v:St(e.v),a:St(e.a,3)};var e},r.prototype.invert=function(){return Ut({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},r.prototype.saturate=function(e){return e===void 0&&(e=.1),Ut(Ys(this.rgba,e))},r.prototype.desaturate=function(e){return e===void 0&&(e=.1),Ut(Ys(this.rgba,-e))},r.prototype.grayscale=function(){return Ut(Ys(this.rgba,-1))},r.prototype.lighten=function(e){return e===void 0&&(e=.1),Ut(lo(this.rgba,e))},r.prototype.darken=function(e){return e===void 0&&(e=.1),Ut(lo(this.rgba,-e))},r.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},r.prototype.alpha=function(e){return typeof e=="number"?Ut({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):St(this.rgba.a,3);var t},r.prototype.hue=function(e){var t=Ai(this.rgba);return typeof e=="number"?Ut({h:e,s:t.s,l:t.l,a:t.a}):St(t.h)},r.prototype.isEqual=function(e){return this.toHex()===Ut(e).toHex()},r}(),Ut=function(r){return r instanceof Dn?r:new Dn(r)},co=[],bd=function(r){r.forEach(function(e){co.indexOf(e)<0&&(e(Dn,Bn),co.push(e))})};function wd(r,e){var t={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var s in t)i[t[s]]=s;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,h,l=i[this.toHex()];if(l)return l;if(o!=null&&o.closest){var c=this.toRgb(),d=1/0,u="black";if(!n.length)for(var p in t)n[p]=new r(t[p]).toRgb();for(var f in t){var y=(a=c,h=n[f],Math.pow(a.r-h.r,2)+Math.pow(a.g-h.g,2)+Math.pow(a.b-h.b,2));y<d&&(d=y,u=f)}return u}},e.string.push([function(o){var a=o.toLowerCase(),h=a==="transparent"?"#0000":t[a];return h?new r(h).toRgb():null},"name"])}bd([wd]);const ei=class bi{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}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(e){return this.value=e,this}set value(e){if(e instanceof bi)this._value=this._cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(e===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,e))&&(this._value=this._cloneSource(e),this._normalize(this._value))}}get value(){return this._value}_cloneSource(e){return typeof e=="string"||typeof e=="number"||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e=="object"&&e!==null?{...e}:e}_isSourceEqual(e,t){const i=typeof e;if(i!==typeof t)return!1;if(i==="number"||i==="string"||e instanceof Number)return e===t;if(Array.isArray(e)&&Array.isArray(t)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(t))return e.length!==t.length?!1:e.every((n,o)=>n===t[o]);if(e!==null&&t!==null){const n=Object.keys(e),o=Object.keys(t);return n.length!==o.length?!1:n.every(a=>e[a]===t[a])}return e===t}toRgba(){const[e,t,i,s]=this._components;return{r:e,g:t,b:i,a:s}}toRgb(){const[e,t,i]=this._components;return{r:e,g:t,b:i}}toRgbaString(){const[e,t,i]=this.toUint8RgbArray();return`rgba(${e},${t},${i},${this.alpha})`}toUint8RgbArray(e){const[t,i,s]=this._components;return this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb),e[0]=Math.round(t*255),e[1]=Math.round(i*255),e[2]=Math.round(s*255),e}toArray(e){this._arrayRgba||(this._arrayRgba=[]),e||(e=this._arrayRgba);const[t,i,s,n]=this._components;return e[0]=t,e[1]=i,e[2]=s,e[3]=n,e}toRgbArray(e){this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb);const[t,i,s]=this._components;return e[0]=t,e[1]=i,e[2]=s,e}toNumber(){return this._int}toBgrNumber(){const[e,t,i]=this.toUint8RgbArray();return(i<<16)+(t<<8)+e}toLittleEndianNumber(){const e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){const[t,i,s,n]=bi._temp.setValue(e)._components;return this._components[0]*=t,this._components[1]*=i,this._components[2]*=s,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this._refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return t&&(i=i*e+.5|0,s=s*e+.5|0,n=n*e+.5|0),(e*255<<24)+(i<<16)+(s<<8)+n}toHex(){const e=this._int.toString(16);return`#${"000000".substring(0,6-e.length)+e}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(e){return this._components[3]=this._clamp(e),this}_normalize(e){let t,i,s,n;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){const o=e;t=(o>>16&255)/255,i=(o>>8&255)/255,s=(o&255)/255,n=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[t,i,s,n=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[t,i,s,n=255]=e,t/=255,i/=255,s/=255,n/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){const a=bi.HEX_PATTERN.exec(e);a&&(e=`#${a[2]}`)}const o=Ut(e);o.isValid()&&({r:t,g:i,b:s,a:n}=o.rgba,t/=255,i/=255,s/=255)}if(t!==void 0)this._components[0]=t,this._components[1]=i,this._components[2]=s,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${e}`)}_refreshInt(){this._clamp(this._components);const[e,t,i]=this._components;this._int=(e*255<<16)+(t*255<<8)+(i*255|0)}_clamp(e,t=0,i=1){return typeof e=="number"?Math.min(Math.max(e,t),i):(e.forEach((s,n)=>{e[n]=Math.min(Math.max(s,t),i)}),e)}static isColorLike(e){return typeof e=="number"||typeof e=="string"||e instanceof Number||e instanceof bi||Array.isArray(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||e.r!==void 0&&e.g!==void 0&&e.b!==void 0||e.r!==void 0&&e.g!==void 0&&e.b!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0&&e.a!==void 0}};ei.shared=new ei;ei._temp=new ei;ei.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let rt=ei;const Cd={cullArea:null,cullable:!1,cullableChildren:!0};let Zs=0;const uo=500;function nt(...r){Zs!==uo&&(Zs++,Zs===uo?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}const Hi={_registeredResources:new Set,register(r){this._registeredResources.add(r)},unregister(r){this._registeredResources.delete(r)},release(){this._registeredResources.forEach(r=>r.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(r){return this._registeredResources.has(r)},reset(){this._registeredResources.clear()}};class Ad{constructor(e,t){this._pool=[],this._count=0,this._index=0,this._classType=e,t&&this.prepopulate(t)}prepopulate(e){for(let t=0;t<e;t++)this._pool[this._index++]=new this._classType;this._count+=e}get(e){var i;let t;return this._index>0?t=this._pool[--this._index]:(t=new this._classType,this._count++),(i=t.init)==null||i.call(t,e),t}return(e){var t;(t=e.reset)==null||t.call(e),this._pool[this._index++]=e}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 e=0;e<this._index;e++)this._pool[e].destroy();this._pool.length=0,this._count=0,this._index=0}}class Pd{constructor(){this._poolsByClass=new Map}prepopulate(e,t){this.getPool(e).prepopulate(t)}get(e,t){return this.getPool(e).get(t)}return(e){this.getPool(e.constructor).return(e)}getPool(e){return this._poolsByClass.has(e)||this._poolsByClass.set(e,new Ad(e)),this._poolsByClass.get(e)}stats(){const e={};return this._poolsByClass.forEach(t=>{const i=e[t._classType.name]?t._classType.name+t._classType.ID:t._classType.name;e[i]={free:t.totalFree,used:t.totalUsed,size:t.totalSize}}),e}clear(){this._poolsByClass.forEach(e=>e.clear()),this._poolsByClass.clear()}}const _t=new Pd;Hi.register(_t);const Md={get isCachedAsTexture(){var r;return!!((r=this.renderGroup)!=null&&r.isCachedAsTexture)},cacheAsTexture(r){typeof r=="boolean"&&r===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(r===!0?{}:r))},updateCacheTexture(){var r;(r=this.renderGroup)==null||r.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(r){V("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(r)}};function _d(r,e,t){const i=r.length;let s;if(e>=i||t===0)return;t=e+t>i?i-e:t;const n=i-t;for(s=e;s<n;++s)r[s]=r[s+t];r.length=n}const Td={allowChildren:!0,removeChildren(r=0,e){var n;const t=e??this.children.length,i=t-r,s=[];if(i>0&&i<=t){for(let a=t-1;a>=r;a--){const h=this.children[a];h&&(s.push(h),h.parent=null)}_d(this.children,r,t);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(s);for(let a=0;a<s.length;++a){const h=s[a];(n=h.parentRenderLayer)==null||n.detach(h),this.emit("childRemoved",h,this,a),s[a].emit("removed",this)}return s.length>0&&this._didViewChangeTick++,s}else if(i===0&&this.children.length===0)return s;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){const e=this.getChildAt(r);return this.removeChild(e)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,e)},getChildIndex(r){const e=this.children.indexOf(r);if(e===-1)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(r,e){this.allowChildren||V(J,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:t}=this;if(e<0||e>t.length)throw new Error(`${r}addChildAt: The index ${e} supplied is out of bounds ${t.length}`);if(r.parent){const s=r.parent.children.indexOf(r);if(r.parent===this&&s===e)return r;s!==-1&&r.parent.children.splice(s,1)}e===t.length?t.push(r):t.splice(e,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(r),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",r,this,e),r.emit("added",this),r},swapChildren(r,e){if(r===e)return;const t=this.getChildIndex(r),i=this.getChildIndex(e);this.children[t]=e,this.children[i]=r;const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(e=>this.reparentChildAt(e,this.children.length)),r[0])},reparentChildAt(r,e){if(r.parent===this)return this.setChildIndex(r,e),r;const t=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,e);const i=this.worldTransform.clone();return i.invert(),t.prepend(i),r.setFromMatrix(t),r},replaceChild(r,e){r.updateLocalTransform(),this.addChildAt(e,this.getChildIndex(r)),e.setFromMatrix(r.localTransform),e.updateLocalTransform(),this.removeChild(r)}},kd={collectRenderables(r,e,t){this.parentRenderLayer&&this.parentRenderLayer!==t||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,e,t):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,e,t))},collectRenderablesSimple(r,e,t){const i=this.children,s=i.length;for(let n=0;n<s;n++)i[n].collectRenderables(r,e,t)},collectRenderablesWithEffects(r,e,t){const{renderPipes:i}=e;for(let s=0;s<this.effects.length;s++){const n=this.effects[s];i[n.pipe].push(n,this,r)}this.collectRenderablesSimple(r,e,t);for(let s=this.effects.length-1;s>=0;s--){const n=this.effects[s];i[n.pipe].pop(n,this,r)}}};class po{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let e=0;e<this.filters.length;e++)this.filters[e].destroy();this.filters=null,this.filterArea=null}}class Rd{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(e=>{this.add({test:e.test,maskClass:e})}))}add(e){this._tests.push(e)}getMaskEffect(e){this._initialized||this.init();for(let t=0;t<this._tests.length;t++){const i=this._tests[t];if(i.test(e))return _t.get(i.maskClass,e)}return e}returnMaskEffect(e){_t.return(e)}}const Fn=new Rd;$.handleByList(I.MaskEffect,Fn._effectClasses);const Ed={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0)},addEffect(r){this.effects.indexOf(r)===-1&&(this.effects.push(r),this.effects.sort((t,i)=>t.priority-i.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(r){const e=this.effects.indexOf(r);e!==-1&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(r){const e=this._maskEffect;(e==null?void 0:e.mask)!==r&&(e&&(this.removeEffect(e),Fn.returnMaskEffect(e),this._maskEffect=null),r!=null&&(this._maskEffect=Fn.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions={...this._maskOptions,...r},r.mask&&(this.mask=r.mask),this._markStructureAsChanged()},set filters(r){var n;!Array.isArray(r)&&r&&(r=[r]);const e=this._filterEffect||(this._filterEffect=new po);r=r;const t=(r==null?void 0:r.length)>0,i=((n=e.filters)==null?void 0:n.length)>0,s=t!==i;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),s&&(t?this.addEffect(e):(this.removeEffect(e),e.filters=r??null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new po),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},Id={label:null,get name(){return V(J,"Container.name property has been removed, use Container.label instead"),this.label},set name(r){V(J,"Container.name property has been removed, use Container.label instead"),this.label=r},getChildByName(r,e=!1){return this.getChildByLabel(r,e)},getChildByLabel(r,e=!1){const t=this.children;for(let i=0;i<t.length;i++){const s=t[i];if(s.label===r||r instanceof RegExp&&r.test(s.label))return s}if(e)for(let i=0;i<t.length;i++){const n=t[i].getChildByLabel(r,!0);if(n)return n}return null},getChildrenByLabel(r,e=!1,t=[]){const i=this.children;for(let s=0;s<i.length;s++){const n=i[s];(n.label===r||r instanceof RegExp&&r.test(n.label))&&t.push(n)}if(e)for(let s=0;s<i.length;s++)i[s].getChildrenByLabel(r,!0,t);return t}},Pt=_t.getPool(U),Qt=_t.getPool(Bt),Bd=new U,Dd={getFastGlobalBounds(r,e){e||(e=new Bt),e.clear(),this._getGlobalBoundsRecursive(!!r,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);const t=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(t.worldTransform),e},_getGlobalBoundsRecursive(r,e,t){let i=e;if(r&&this.parentRenderLayer&&this.parentRenderLayer!==t||this.localDisplayStatus!==7||!this.measurable)return;const s=!!this.effects.length;if((this.renderGroup||s)&&(i=Qt.get().clear()),this.boundsArea)e.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;i.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(r,i,t)}if(s){let n=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(n||(n=!0,i.applyMatrix(o.worldTransform)),this.effects[a].addBounds(i,!0));n&&i.applyMatrix(o.worldTransform.copyTo(Bd).invert()),e.addBounds(i),Qt.return(i)}else this.renderGroup&&(e.addBounds(i,this.relativeGroupTransform),Qt.return(i))}};function mh(r,e,t){t.clear();let i,s;return r.parent?e?i=r.parent.worldTransform:(s=Pt.get().identity(),i=dr(r,s)):i=U.IDENTITY,yh(r,t,i,e),s&&Pt.return(s),t.isValid||t.set(0,0,0,0),t}function yh(r,e,t,i){var a,h;if(!r.visible||!r.measurable)return;let s;i?s=r.worldTransform:(r.updateLocalTransform(),s=Pt.get(),s.appendFrom(r.localTransform,t));const n=e,o=!!r.effects.length;if(o&&(e=Qt.get().clear()),r.boundsArea)e.addRect(r.boundsArea,s);else{const l=r.bounds;l&&!l.isEmpty()&&(e.matrix=s,e.addBounds(l));for(let c=0;c<r.children.length;c++)yh(r.children[c],e,s,i)}if(o){for(let l=0;l<r.effects.length;l++)(h=(a=r.effects[l]).addBounds)==null||h.call(a,e);n.addBounds(e,U.IDENTITY),Qt.return(e)}i||Pt.return(s)}function dr(r,e){const t=r.parent;return t&&(dr(t,e),t.updateLocalTransform(),e.append(t.localTransform)),e}function ur(r,e){if(r===16777215||!e)return e;if(e===16777215||!r)return r;const t=r>>16&255,i=r>>8&255,s=r&255,n=e>>16&255,o=e>>8&255,a=e&255,h=t*n/255|0,l=i*o/255|0,c=s*a/255|0;return(h<<16)+(l<<8)+c}const fo=16777215;function go(r,e){return r===fo?e:e===fo?r:ur(r,e)}function Pi(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const Fd={getGlobalAlpha(r){if(r)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let e=this.alpha,t=this.parent;for(;t;)e*=t.alpha,t=t.parent;return e},getGlobalTransform(r=new U,e){if(e)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const t=dr(this,Pt.get().identity());return r.appendFrom(this.localTransform,t),Pt.return(t),r},getGlobalTint(r){if(r)return this.renderGroup?Pi(this.renderGroup.worldColor):this.parentRenderGroup?Pi(go(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,t=this.parent;for(;t;)e=go(e,t.localColor),t=t.parent;return Pi(e)}};function xh(r,e,t){return e.clear(),t||(t=U.IDENTITY),Sh(r,e,t,r,!0),e.isValid||e.set(0,0,0,0),e}function Sh(r,e,t,i,s){var h,l;let n;if(s)n=Pt.get(),n=t.copyTo(n);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const c=r.localTransform;n=Pt.get(),n.appendFrom(c,t)}const o=e,a=!!r.effects.length;if(a&&(e=Qt.get().clear()),r.boundsArea)e.addRect(r.boundsArea,n);else{r.renderPipeId&&(e.matrix=n,e.addBounds(r.bounds));const c=r.children;for(let d=0;d<c.length;d++)Sh(c[d],e,n,i,!1)}if(a){for(let c=0;c<r.effects.length;c++)(l=(h=r.effects[c]).addLocalBounds)==null||l.call(h,e,i);o.addBounds(e,U.IDENTITY),Qt.return(e)}Pt.return(n)}function vh(r,e){const t=r.children;for(let i=0;i<t.length;i++){const s=t[i],n=s.uid,o=(s._didViewChangeTick&65535)<<16|s._didContainerChangeTick&65535,a=e.index;(e.data[a]!==n||e.data[a+1]!==o)&&(e.data[e.index]=n,e.data[e.index+1]=o,e.didChange=!0),e.index=a+2,s.children.length&&vh(s,e)}return e.didChange}const zd=new U,Ld={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(r,e){const t=Math.sign(this.scale.x)||1;e!==0?this.scale.x=r/e*t:this.scale.x=t},_setHeight(r,e){const t=Math.sign(this.scale.y)||1;e!==0?this.scale.y=r/e*t:this.scale.y=t},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new Bt});const r=this._localBoundsCacheData;return r.index=1,r.didChange=!1,r.data[0]!==this._didViewChangeTick&&(r.didChange=!0,r.data[0]=this._didViewChangeTick),vh(this,r),r.didChange&&xh(this,r.localBounds,zd),r.localBounds},getBounds(r,e){return mh(this,r,e||new Bt)}},Od={_onRender:null,set onRender(r){const e=this.renderGroup||this.parentRenderGroup;if(!r){this._onRender&&(e==null||e.removeOnRender(this)),this._onRender=null;return}this._onRender||e==null||e.addOnRender(this),this._onRender=r},get onRender(){return this._onRender}},Wd={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(r){this._zIndex!==r&&(this._zIndex=r,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(Gd))}};function Gd(r,e){return r._zIndex-e._zIndex}const Ud={getGlobalPosition(r=new tt,e=!1){return this.parent?this.parent.toGlobal(this._position,r,e):(r.x=this._position.x,r.y=this._position.y),r},toGlobal(r,e,t=!1){const i=this.getGlobalTransform(Pt.get(),t);return e=i.apply(r,e),Pt.return(i),e},toLocal(r,e,t,i){e&&(r=e.toGlobal(r,t,i));const s=this.getGlobalTransform(Pt.get(),i);return t=s.applyInverse(r,t),Pt.return(s),t}};class pr{constructor(){this.uid=dt("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(e){this.instructions[this.instructionSize++]=e}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}let Hd=0;class Vd{constructor(e){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1,this.textureStyle=new ti(this.textureOptions)}createTexture(e,t,i){const s=new Dt({...this.textureOptions,width:e,height:t,resolution:1,antialias:i,autoGarbageCollect:!1});return new W({source:s,label:`texturePool_${Hd++}`})}getOptimalTexture(e,t,i=1,s){let n=Math.ceil(e*i-1e-6),o=Math.ceil(t*i-1e-6);n=Je(n),o=Je(o);const a=(n<<17)+(o<<1)+(s?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let h=this._texturePool[a].pop();return h||(h=this.createTexture(n,o,s)),h.source._resolution=i,h.source.width=n/i,h.source.height=o/i,h.source.pixelWidth=n,h.source.pixelHeight=o,h.frame.x=0,h.frame.y=0,h.frame.width=e,h.frame.height=t,h.updateUvs(),this._poolKeyHash[h.uid]=a,h}getSameSizeTexture(e,t=!1){const i=e.source;return this.getOptimalTexture(e.width,e.height,i._resolution,t)}returnTexture(e,t=!1){const i=this._poolKeyHash[e.uid];t&&(e.source.style=this.textureStyle),this._texturePool[i].push(e)}clear(e){if(e=e!==!1,e)for(const t in this._texturePool){const i=this._texturePool[t];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this._texturePool={}}}const _s=new Vd;Hi.register(_s);class Nd{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new U,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 pr,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(e){this.root=e,e._onRender&&this.addOnRender(e),e.didChange=!0;const t=e.children;for(let i=0;i<t.length;i++){const s=t[i];s._updateFlags=15,this.addChild(s)}}enableCacheAsTexture(e={}){this.textureOptions=e,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(_s.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const e=this._parentCacheAsTextureRenderGroup;e&&!e.textureNeedsUpdate&&e.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const e in this.childrenToUpdate){const t=this.childrenToUpdate[e];t.list.fill(null),t.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(e){e.renderGroupParent&&e.renderGroupParent._removeRenderGroupChild(e),e.renderGroupParent=this,this.renderGroupChildren.push(e)}_removeRenderGroupChild(e){const t=this.renderGroupChildren.indexOf(e);t>-1&&this.renderGroupChildren.splice(t,1),e.renderGroupParent=null}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.updateTick=-1,e.parent===this.root?e.relativeRenderGroupDepth=1:e.relativeRenderGroupDepth=e.parent.relativeRenderGroupDepth+1,e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}e._onRender&&this.addOnRender(e);const t=e.children;for(let i=0;i<t.length;i++)this.addChild(t[i])}removeChild(e){if(this.structureDidChange=!0,e._onRender&&(e.renderGroup||this.removeOnRender(e)),e.parentRenderGroup=null,e.renderGroup){this._removeRenderGroupChild(e.renderGroup);return}const t=e.children;for(let i=0;i<t.length;i++)this.removeChild(t[i])}removeChildren(e){for(let t=0;t<e.length;t++)this.removeChild(e[t])}onChildUpdate(e){let t=this.childrenToUpdate[e.relativeRenderGroupDepth];t||(t=this.childrenToUpdate[e.relativeRenderGroupDepth]={index:0,list:[]}),t.list[t.index++]=e}updateRenderable(e){e.globalDisplayStatus<7||(this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e),e.didViewUpdate=!1)}onChildViewUpdate(e){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=e}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(e){this._onRenderContainers.push(e)}removeOnRender(e){this._onRenderContainers.splice(this._onRenderContainers.indexOf(e),1)}runOnRender(e){for(let t=0;t<this._onRenderContainers.length;t++)this._onRenderContainers[t]._onRender(e)}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(e=[]){const t=this.root.children;for(let i=0;i<t.length;i++)this._getChildren(t[i],e);return e}_getChildren(e,t=[]){if(t.push(e),e.renderGroup)return t;const i=e.children;for(let s=0;s<i.length;s++)this._getChildren(i[s],t);return t}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return this._matrixDirty&1?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new U),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return this._matrixDirty&2?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new U),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(this._matrixDirty&4))return this._inverseParentTextureTransform;this._matrixDirty&=-5;const e=this._parentCacheAsTextureRenderGroup;return e?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new U),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(e.inverseWorldTransform).translate(-e._textureBounds.x,-e._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function jd(r,e,t={}){for(const i in e)!t[i]&&e[i]!==void 0&&(r[i]=e[i])}const qs=new ct(null),Ji=new ct(null),Ks=new ct(null,1,1),ts=new ct(null),mo=1,Yd=2,$s=4;class L extends Yt{constructor(e={}){var t,i;super(),this.uid=dt("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 U,this.relativeGroupTransform=new U,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new ct(this,0,0),this._scale=Ks,this._pivot=Ji,this._origin=ts,this._skew=qs,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=[],jd(this,e,{children:!0,parent:!0,effects:!0}),(t=e.children)==null||t.forEach(s=>this.addChild(s)),(i=e.parent)==null||i.addChild(this)}static mixin(e){V("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),$.mixin(L,e)}set _didChangeId(e){this._didViewChangeTick=e>>12&4095,this._didContainerChangeTick=e&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...e){if(this.allowChildren||V(J,"addChild: Only Containers will be allowed to add children in v8.0.0"),e.length>1){for(let s=0;s<e.length;s++)this.addChild(e[s]);return e[0]}const t=e[0],i=this.renderGroup||this.parentRenderGroup;return t.parent===this?(this.children.splice(this.children.indexOf(t),1),this.children.push(t),i&&(i.structureDidChange=!0),t):(t.parent&&t.parent.removeChild(t),this.children.push(t),this.sortableChildren&&(this.sortDirty=!0),t.parent=this,t.didChange=!0,t._updateFlags=15,i&&i.addChild(t),this.emit("childAdded",t,this,this.children.length-1),t.emit("added",this),this._didViewChangeTick++,t._zIndex!==0&&t.depthOfChildModified(),t)}removeChild(...e){if(e.length>1){for(let s=0;s<e.length;s++)this.removeChild(e[s]);return e[0]}const t=e[0],i=this.children.indexOf(t);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(t):this.parentRenderGroup&&this.parentRenderGroup.removeChild(t),t.parentRenderLayer&&t.parentRenderLayer.detach(t),t.parent=null,this.emit("childRemoved",t,this,i),t.emit("removed",this)),t}_onUpdate(e){e&&e===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(e){!!this.renderGroup!==e&&(e?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const e=this.parentRenderGroup;e==null||e.removeChild(this),this.renderGroup=_t.get(Nd,this),this.groupTransform=U.IDENTITY,e==null||e.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const e=this.parentRenderGroup;e==null||e.removeChild(this),_t.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e==null||e.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new U),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(e){this._position.x=e}get y(){return this._position.y}set y(e){this._position.y=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this._skew))}get angle(){return this.rotation*od}set angle(e){this.rotation=e*ad}get pivot(){return this._pivot===Ji&&(this._pivot=new ct(this,0,0)),this._pivot}set pivot(e){this._pivot===Ji&&(this._pivot=new ct(this,0,0),this._origin!==ts&&nt("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof e=="number"?this._pivot.set(e):this._pivot.copyFrom(e)}get skew(){return this._skew===qs&&(this._skew=new ct(this,0,0)),this._skew}set skew(e){this._skew===qs&&(this._skew=new ct(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===Ks&&(this._scale=new ct(this,1,1)),this._scale}set scale(e){this._scale===Ks&&(this._scale=new ct(this,0,0)),typeof e=="string"&&(e=parseFloat(e)),typeof e=="number"?this._scale.set(e):this._scale.copyFrom(e)}get origin(){return this._origin===ts&&(this._origin=new ct(this,0,0)),this._origin}set origin(e){this._origin===ts&&(this._origin=new ct(this,0,0),this._pivot!==Ji&&nt("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof e=="number"?this._origin.set(e):this._origin.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){const t=this.getLocalBounds().width;this._setWidth(e,t)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){const t=this.getLocalBounds().height;this._setHeight(e,t)}getSize(e){e||(e={});const t=this.getLocalBounds();return e.width=Math.abs(this.scale.x*t.width),e.height=Math.abs(this.scale.y*t.height),e}setSize(e,t){const i=this.getLocalBounds();typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,i.width),t!==void 0&&this._setHeight(t,i.height)}_updateSkew(){const e=this._rotation,t=this._skew;this._cx=Math.cos(e+t._y),this._sx=Math.sin(e+t._y),this._cy=-Math.sin(e-t._x),this._sy=Math.cos(e-t._x)}updateTransform(e){return this.position.set(typeof e.x=="number"?e.x:this.position.x,typeof e.y=="number"?e.y:this.position.y),this.scale.set(typeof e.scaleX=="number"?e.scaleX||1:this.scale.x,typeof e.scaleY=="number"?e.scaleY||1:this.scale.y),this.rotation=typeof e.rotation=="number"?e.rotation:this.rotation,this.skew.set(typeof e.skewX=="number"?e.skewX:this.skew.x,typeof e.skewY=="number"?e.skewY:this.skew.y),this.pivot.set(typeof e.pivotX=="number"?e.pivotX:this.pivot.x,typeof e.pivotY=="number"?e.pivotY:this.pivot.y),this.origin.set(typeof e.originX=="number"?e.originX:this.origin.x,typeof e.originY=="number"?e.originY:this.origin.y),this}setFromMatrix(e){e.decompose(this)}updateLocalTransform(){const e=this._didContainerChangeTick;if(this._didLocalTransformChangeId===e)return;this._didLocalTransformChangeId=e;const t=this.localTransform,i=this._scale,s=this._pivot,n=this._origin,o=this._position,a=i._x,h=i._y,l=s._x,c=s._y,d=-n._x,u=-n._y;t.a=this._cx*a,t.b=this._sx*a,t.c=this._cy*h,t.d=this._sy*h,t.tx=o._x-(l*t.a+c*t.c)+(d*t.a+u*t.c)-d,t.ty=o._y-(l*t.b+c*t.d)+(d*t.b+u*t.d)-u}set alpha(e){e!==this.localAlpha&&(this.localAlpha=e,this._updateFlags|=mo,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){const i=rt.shared.setValue(e??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=mo,this._onUpdate())}get tint(){return Pi(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Yd,this.localBlendMode=e,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){const t=e?2:0;(this.localDisplayStatus&2)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=$s,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(e){const t=e?0:4;(this.localDisplayStatus&4)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=$s,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){const t=e?1:0;(this.localDisplayStatus&1)!==t&&(this._updateFlags|=$s,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(e=!1){var s;if(this.destroyed)return;this.destroyed=!0;let t;if(this.children.length&&(t=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 e=="boolean"?e:e==null?void 0:e.children)&&t)for(let n=0;n<t.length;++n)t[n].destroy(e);(s=this.renderGroup)==null||s.destroy(),this.renderGroup=null}}$.mixin(L,Td,Dd,Ud,Od,Ld,Ed,Id,Wd,Cd,Md,Fd,kd);class ai extends L{constructor(e){super(e),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 Bt(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=e.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(e){this._roundPixels=e?1:0}containsPoint(e){const t=this.bounds,{x:i,y:s}=e;return i>=t.minX&&i<=t.maxX&&s>=t.minY&&s<=t.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(e){this.unload(),super.destroy(e),this._bounds=null}collectRenderablesSimple(e,t,i){const{renderPipes:s}=t;s.blendMode.pushBlendMode(this,this.groupBlendMode,e);const o=s[this.renderPipeId];o!=null&&o.addRenderable&&o.addRenderable(this,e),this.didViewUpdate=!1;const a=this.children,h=a.length;for(let l=0;l<h;l++)a[l].collectRenderables(e,t,i);s.blendMode.popBlendMode(e)}}class jt extends ai{constructor(e=W.EMPTY){e instanceof W&&(e={texture:e});const{texture:t=W.EMPTY,anchor:i,roundPixels:s,width:n,height:o,...a}=e;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:t.defaultAnchor&&(this.anchor=t.defaultAnchor),this.texture=t,this.allowChildren=!1,this.roundPixels=s??!1,n!==void 0&&(this.width=n),o!==void 0&&(this.height=o)}static from(e,t=!1){return e instanceof W?new jt(e):new jt(W.from(e,t))}set texture(e){e||(e=W.EMPTY);const t=this._texture;t!==e&&(t&&t.dynamic&&t.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this._texture=e,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 uh(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return V("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const e=this._anchor,t=this._texture,i=this._bounds,{width:s,height:n}=t.orig;i.minX=-e._x*s,i.maxX=i.minX+s,i.minY=-e._y*n,i.maxY=i.minY+n}destroy(e=!1){if(super.destroy(e),typeof e=="boolean"?e:e==null?void 0:e.texture){const i=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._texture.destroy(i)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(e){this._setWidth(e,this._texture.orig.width),this._width=e}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(e){this._setHeight(e,this._texture.orig.height),this._height=e}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this._texture.orig.width,e.height=Math.abs(this.scale.y)*this._texture.orig.height,e}setSize(e,t){typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,this._texture.orig.width),t!==void 0&&this._setHeight(t,this._texture.orig.height)}}const Xd=new Bt;function bh(r,e,t){const i=Xd;r.measurable=!0,mh(r,t,i),e.addBoundsMask(i),r.measurable=!1}function wh(r,e,t){const i=Qt.get();r.measurable=!0;const s=Pt.get().identity(),n=Ch(r,t,s);xh(r,i,n),r.measurable=!1,e.addBoundsMask(i),Pt.return(s),Qt.return(i)}function Ch(r,e,t){return r?(r!==e&&(Ch(r.parent,e,t),r.updateLocalTransform(),t.append(r.localTransform)),t):(nt("Mask bounds, renderable is not inside the root container"),t)}class Ah{constructor(e){this.priority=0,this.inverse=!1,this.pipe="alphaMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof jt),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(e,t){this.inverse||bh(this.mask,e,t)}addLocalBounds(e,t){wh(this.mask,e,t)}containsPoint(e,t){const i=this.mask;return t(i,e)}destroy(){this.reset()}static test(e){return e instanceof jt}}Ah.extension=I.MaskEffect;class Ph{constructor(e){this.priority=0,this.pipe="colorMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e}destroy(){}static test(e){return typeof e=="number"}}Ph.extension=I.MaskEffect;class Mh{constructor(e){this.priority=0,this.pipe="stencilMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(e,t){bh(this.mask,e,t)}addLocalBounds(e,t){wh(this.mask,e,t)}containsPoint(e,t){const i=this.mask;return t(i,e)}destroy(){this.reset()}static test(e){return e instanceof L}}Mh.extension=I.MaskEffect;const Zd={createCanvas:(r,e)=>{const t=document.createElement("canvas");return t.width=r,t.height=e,t},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,e)=>fetch(r,e),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};let yo=Zd;const j={get(){return yo},set(r){yo=r}};class fr extends Dt{constructor(e){e.resource||(e.resource=j.get().createCanvas()),e.width||(e.width=e.resource.width,e.autoDensity||(e.width/=e.resolution)),e.height||(e.height=e.resource.height,e.autoDensity||(e.height/=e.resolution)),super(e),this.uploadMethodId="image",this.autoDensity=e.autoDensity,this.resizeCanvas(),this.transparent=!!e.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(e=this.width,t=this.height,i=this._resolution){const s=super.resize(e,t,i);return s&&this.resizeCanvas(),s}static test(e){return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&e instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}fr.extension=I.TextureSource;class ii extends Dt{constructor(e){super(e),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(e){return globalThis.HTMLImageElement&&e instanceof HTMLImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||globalThis.VideoFrame&&e instanceof VideoFrame}}ii.extension=I.TextureSource;var Ie=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(Ie||{});class Qs{constructor(e,t=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=t,this.priority=i,this._once=s}match(e,t=null){return this._fn===e&&this._context===t}emit(e){this._fn&&(this._context?this._fn.call(this._context,e):this._fn(e));const t=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!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 t=this.next;return this.next=e?null:t,this.previous=null,t}}const _h=class Tt{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 Qs(null,null,1/0),this.deltaMS=1/Tt.targetFPMS,this.elapsedMS=1/Tt.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),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(e,t,i=Ie.NORMAL){return this._addListener(new Qs(e,t,i))}addOnce(e,t,i=Ie.NORMAL){return this._addListener(new Qs(e,t,i,!0))}_addListener(e){let t=this._head.next,i=this._head;if(!t)e.connect(i);else{for(;t;){if(e.priority>t.priority){e.connect(i);break}i=t,t=t.next}e.previous||e.connect(i)}return this._startIfPossible(),this}remove(e,t){let i=this._head.next;for(;i;)i.match(e,t)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){const n=e-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=e-n%this._minElapsedMS}this.deltaMS=t,this.deltaTime=this.deltaMS*Tt.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const t=Math.min(this.maxFPS,e),i=Math.min(Math.max(0,t)/1e3,Tt.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){if(e===0)this._minElapsedMS=0;else{const t=Math.max(this.minFPS,e);this._minElapsedMS=1/(t/1e3)}}static get shared(){if(!Tt._shared){const e=Tt._shared=new Tt;e.autoStart=!0,e._protected=!0}return Tt._shared}static get system(){if(!Tt._system){const e=Tt._system=new Tt;e.autoStart=!0,e._protected=!0}return Tt._system}};_h.targetFPMS=.06;let yt=_h,Js;async function Th(){return Js??(Js=(async()=>{var o;const e=j.get().createCanvas(1,1).getContext("webgl");if(!e)return"premultiply-alpha-on-upload";const t=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(!t)return"premultiply-alpha-on-upload";const i=e.createTexture();e.bindTexture(e.TEXTURE_2D,i);const s=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,s),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,i,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t);const n=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,n),e.deleteFramebuffer(s),e.deleteTexture(i),(o=e.getExtension("WEBGL_lose_context"))==null||o.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Js}const Ts=class kh extends Dt{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...kh.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this.alphaMode=e.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),e.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const e=yt.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!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 e=this.resource,t=this.options;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(t.preload||e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlayThrough),e.addEventListener("error",this._onError,!0)),this.alphaMode=await Th(),this._load=new Promise((i,s)=>{this.isValid?i(this):(this._resolve=i,this._reject=s,t.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${t.preloadTimeoutMs}ms`))})),e.load())}),this._load}_onError(e){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){const e=this.resource;return!e.paused&&!e.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const e=this.resource;this.isValid&&(this.isReady=!0,this.resize(e.videoWidth,e.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const e=this.resource;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlayThrough),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(yt.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||(yt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(yt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};Ts.extension=I.TextureSource;Ts.defaultOptions={...Dt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Ts.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Mi=Ts;const zt=(r,e,t=!1)=>(Array.isArray(r)||(r=[r]),e?r.map(i=>typeof i=="string"||t?e(i):i):r);class qd{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){const t=this._cache.get(e);return t||nt(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){const i=zt(e);let s;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.test(t)){s=l.getCacheableAssets(i,t);break}}const n=new Map(Object.entries(s||{}));s||i.forEach(h=>{n.set(h,t)});const o=[...n.keys()],a={cacheKeys:o,keys:i};i.forEach(h=>{this._cacheMap.set(h,a)}),o.forEach(h=>{const l=s?s[h]:t;this._cache.has(h)&&this._cache.get(h)!==l&&nt("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(e){if(!this._cacheMap.has(e)){nt(`[Assets] Asset id ${e} was not found in the Cache`);return}const t=this._cacheMap.get(e);t.cacheKeys.forEach(s=>{this._cache.delete(s)}),t.keys.forEach(s=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}}const xt=new qd,zn=[];$.handleByList(I.TextureSource,zn);function Rh(r={}){const e=r&&r.resource,t=e?r.resource:r,i=e?r:{resource:r};for(let s=0;s<zn.length;s++){const n=zn[s];if(n.test(t))return new n(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function Kd(r={},e=!1){const t=r&&r.resource,i=t?r.resource:r,s=t?r:{resource:r};if(!e&&xt.has(i))return xt.get(i);const n=new W({source:Rh(s)});return n.on("destroy",()=>{xt.has(i)&&xt.remove(i)}),e||xt.set(i,n),n}function $d(r,e=!1){return typeof r=="string"?xt.get(r):r instanceof Dt?new W({source:r}):Kd(r,e)}W.from=$d;Dt.from=Rh;$.add(Ah,Ph,Mh,Mi,ii,fr,cr);var ue=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(ue||{});function Ft(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function di(r){return r.split("?")[0].split("#")[0]}function Qd(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Jd(r,e,t){return r.replace(new RegExp(Qd(e),"g"),t)}function tu(r,e){let t="",i=0,s=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(t.length<2||i!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){const h=t.lastIndexOf("/");if(h!==t.length-1){h===-1?(t="",i=0):(t=t.slice(0,h),i=t.length-1-t.lastIndexOf("/")),s=a,n=0;continue}}else if(t.length===2||t.length===1){t="",i=0,s=a,n=0;continue}}}else t.length>0?t+=`/${r.slice(s+1,a)}`:t=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return t}const Mt={toPosix(r){return Jd(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){Ft(r),r=this.toPosix(r);const e=/^file:\/\/\//.exec(r);if(e)return e[0];const t=/^[^/:]+:\/{0,2}/.exec(r);return t?t[0]:""},toAbsolute(r,e,t){if(Ft(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=di(this.toPosix(e??j.get().getBaseUrl())),s=di(this.toPosix(t??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?Mt.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(Ft(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let e="";const t=r.startsWith("/");this.hasProtocol(r)&&(e=this.rootname(r),r=r.slice(e.length));const i=r.endsWith("/");return r=tu(r),r.length>0&&i&&(r+="/"),t?`/${r}`:e+r},isAbsolute(r){return Ft(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let e;for(let t=0;t<r.length;++t){const i=r[t];if(Ft(i),i.length>0)if(e===void 0)e=i;else{const s=r[t-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?e+=`/../${i}`:e+=`/${i}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(Ft(r),r.length===0)return".";r=this.toPosix(r);let e=r.charCodeAt(0);const t=e===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(e=r.charCodeAt(a),e===47){if(!s){i=a;break}}else s=!1;return i===-1?t?"/":this.isUrl(o)?n+r:n:t&&i===1?"//":n+r.slice(0,i)},rootname(r){Ft(r),r=this.toPosix(r);let e="";if(r.startsWith("/")?e="/":e=this.getProtocol(r),this.isUrl(r)){const t=r.indexOf("/",e.length);t!==-1?e=r.slice(0,t):e=r,e.endsWith("/")||(e+="/")}return e},basename(r,e){Ft(r),e&&Ft(e),r=di(this.toPosix(r));let t=0,i=-1,s=!0,n;if(e!==void 0&&e.length>0&&e.length<=r.length){if(e.length===r.length&&e===r)return"";let o=e.length-1,a=-1;for(n=r.length-1;n>=0;--n){const h=r.charCodeAt(n);if(h===47){if(!s){t=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(h===e.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return t===i?i=a:i===-1&&(i=r.length),r.slice(t,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){t=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(t,i)},extname(r){Ft(r),r=di(this.toPosix(r));let e=-1,t=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){t=o+1;break}continue}i===-1&&(s=!1,i=o+1),a===46?e===-1?e=o:n!==1&&(n=1):e!==-1&&(n=-1)}return e===-1||i===-1||n===0||n===1&&e===i-1&&e===t+1?"":r.slice(e,i)},parse(r){Ft(r);const e={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return e;r=di(this.toPosix(r));let t=r.charCodeAt(0);const i=this.isAbsolute(r);let s;e.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let n=-1,o=0,a=-1,h=!0,l=r.length-1,c=0;for(;l>=s;--l){if(t=r.charCodeAt(l),t===47){if(!h){o=l+1;break}continue}a===-1&&(h=!1,a=l+1),t===46?n===-1?n=l:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&i?e.base=e.name=r.slice(1,a):e.base=e.name=r.slice(o,a)):(o===0&&i?(e.name=r.slice(1,n),e.base=r.slice(1,a)):(e.name=r.slice(o,n),e.base=r.slice(o,a)),e.ext=r.slice(n,a)),e.dir=this.dirname(r),e},sep:"/",delimiter:":",joinExtensions:[".html"]};function Eh(r,e,t,i,s){const n=e[t];for(let o=0;o<n.length;o++){const a=n[o];t<e.length-1?Eh(r.replace(i[t],a),e,t+1,i,s):s.push(r.replace(i[t],a))}}function eu(r){const e=/\{(.*?)\}/g,t=r.match(e),i=[];if(t){const s=[];t.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),Eh(r,s,0,t,i)}else i.push(r);return i}const ms=r=>!Array.isArray(r);class hi{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${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(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}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(e){if(typeof e=="string")this._defaultSearchParams=e;else{const t=e;this._defaultSearchParams=Object.keys(t).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(t[i])}`).join("&")}}getAlias(e){const{alias:t,src:i}=e;return zt(t||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(o=>(o==null?void 0:o.src)??o):n!=null&&n.src?n.src:n,!0)}addManifest(e){this._manifest&&nt("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){const i=[];let s=t;Array.isArray(t)||(s=Object.entries(t).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:{alias:n,...o})),s.forEach(n=>{const o=n.src,a=n.alias;let h;if(typeof a=="string"){const l=this._createBundleAssetId(e,a);i.push(l),h=[a,l]}else{const l=a.map(c=>this._createBundleAssetId(e,c));i.push(...l),h=[...a,...l]}this.add({...n,alias:h,src:o})}),this._bundles[e]=i}add(e){const t=[];Array.isArray(e)?t.push(...e):t.push(e);let i;i=n=>{this.hasKey(n)&&nt(`[Resolver] already has key: ${n} overwriting`)},zt(t).forEach(n=>{const{src:o}=n;let{data:a,format:h,loadParser:l,parser:c}=n;const d=zt(o).map(y=>typeof y=="string"?eu(y):Array.isArray(y)?y:[y]),u=this.getAlias(n);Array.isArray(u)?u.forEach(i):i(u);const p=[],f=y=>{const m=this._parsers.find(x=>x.test(y));return{src:y,...m==null?void 0:m.parse(y)}};d.forEach(y=>{y.forEach(m=>{let x={};if(typeof m!="object"?x=f(m):(a=m.data??a,h=m.format??h,(m.loadParser||m.parser)&&(l=m.loadParser??l,c=m.parser??c),x={...f(m.src),...m}),!u)throw new Error(`[Resolver] alias is undefined for this asset: ${x.src}`);x=this._buildResolvedAsset(x,{aliases:u,data:a,format:h,loadParser:l,parser:c,progressSize:n.progressSize}),p.push(x)})}),u.forEach(y=>{this._assetMap[y]=p})})}resolveBundle(e){const t=ms(e);e=zt(e);const i={};return e.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(s,h)]=l}i[s]=a}}),t?i[e[0]]:i}resolveUrl(e){const t=this.resolve(e);if(typeof e!="string"){const i={};for(const s in t)i[s]=t[s].src;return i}return t.src}resolve(e){const t=ms(e);e=zt(e);const i={};return e.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(h=>{const l=n.filter(c=>c[a]?c[a]===h:!1);l.length&&(n=l)})}),this._resolverHash[s]=n[0]}else this._resolverHash[s]=this._buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),t?i[e[0]]:i}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;t<e.length;t++){const i=e[t],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;const t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}_buildResolvedAsset(e,t){const{aliases:i,data:s,loadParser:n,parser:o,format:a,progressSize:h}=t;return(this._basePath||this._rootPath)&&(e.src=Mt.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=i??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...s||{},...e.data},e.loadParser=n??e.loadParser,e.parser=o??e.parser,e.format=a??e.format??iu(e.src),h!==void 0&&(e.progressSize=h),e}}hi.RETINA_PREFIX=/@([0-9\.]+)x/;function iu(r){return r.split(".").pop().split("?").shift().split("#").shift()}const Ln=(r,e)=>{const t=e.split("?")[1];return t&&(r+=`?${t}`),r},Ih=class wi{constructor(e,t){this.linkedSheets=[];let i=e;(e==null?void 0:e.source)instanceof Dt&&(i={texture:e,data:t});const{texture:s,data:n,cachePrefix:o=""}=i;this.cachePrefix=o,this._texture=s instanceof W?s:null,this.textureSource=s.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,s.source.resolution=this.resolution):this.resolution=s.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=wi.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(e,t=!1){let i=e;const s=t?1/0:wi.BATCH_SIZE;for(;i-e<s&&i<this._frameKeys.length;){const n=this._frameKeys[i],o=this._frames[n],a=o.frame;if(a){let h=null,l=null;const c=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,d=new et(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);o.rotated?h=new et(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 et(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 et(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[n]=new W({source:this.textureSource,frame:h,orig:d,trim:l,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:n.toString()})}i++}}_processAnimations(){const e=this.data.animations||{};for(const t in e){this.animations[t]=[];for(let i=0;i<e[t].length;i++){const s=e[t][i];this.animations[t].push(this.textures[s])}}}_parseComplete(){const e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*wi.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*wi.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){var t;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&((t=this._texture)==null||t.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};Ih.BATCH_SIZE=1e3;let On=Ih;const su=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Bh(r,e,t){const i={};if(r.forEach(s=>{i[s]=e}),Object.keys(e.textures).forEach(s=>{i[`${e.cachePrefix}${s}`]=e.textures[s]}),!t){const s=Mt.dirname(r[0]);e.linkedSheets.forEach((n,o)=>{const a=Bh([`${s}/${e.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const nu={extension:I.Asset,cache:{test:r=>r instanceof On,getCacheableAssets:(r,e)=>Bh(r,e,!1)},resolver:{extension:{type:I.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),i=t.pop(),s=t.pop();return i==="json"&&su.includes(s)},parse:r=>{var t;const e=r.split(".");return{resolution:parseFloat(((t=hi.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:e[e.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:I.LoadParser,priority:ue.Normal,name:"spritesheetLoader"},async testParse(r,e){return Mt.extname(e.src).toLowerCase()===".json"&&!!r.frames},async parse(r,e,t){var d,u;const{texture:i,imageFilename:s,textureOptions:n,cachePrefix:o}=(e==null?void 0:e.data)??{};let a=Mt.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let h;if(i instanceof W)h=i;else{const p=Ln(a+(s??r.meta.image),e.src);h=(await t.load([{src:p,data:n}]))[p]}const l=new On({texture:h.source,data:r,cachePrefix:o});await l.parse();const c=(d=r==null?void 0:r.meta)==null?void 0:d.related_multi_packs;if(Array.isArray(c)){const p=[];for(const y of c){if(typeof y!="string")continue;let m=a+y;(u=e.data)!=null&&u.ignoreMultiPack||(m=Ln(m,e.src),p.push(t.load({src:m,data:{textureOptions:n,ignoreMultiPack:!0}})))}const f=await Promise.all(p);l.linkedSheets=f,f.forEach(y=>{y.linkedSheets=[l].concat(l.linkedSheets.filter(m=>m!==y))})}return l},async unload(r,e,t){await t.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};$.add(nu);class ru{constructor(e){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),i=this._canvas.width,s=this._canvas.height,n=t.width/i*this._renderer.resolution,o=t.height/s*this._renderer.resolution,a=t.left,h=t.top,l=`translate(${a}px, ${h}px) scale(${n}, ${o})`;l!==this._lastTransform&&(this._domElement.style.transform=l,this._lastTransform=l)},this._domElement=e.domElement,this._renderer=e.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(e=>{for(const t of e){if(t.target!==this._canvas)continue;const i=this.canvas.width,s=this.canvas.height,n=t.contentRect.width/i*this._renderer.resolution,o=t.contentRect.height/s*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||yt.shared.add(this.updateTranslation,this,Ie.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&yt.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class gr{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=gr.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new tt,this.page=new tt,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var tn=/iPhone/i,xo=/iPod/i,So=/iPad/i,vo=/\biOS-universal(?:.+)Mac\b/i,en=/\bAndroid(?:.+)Mobile\b/i,bo=/Android/i,ze=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,es=/Silk/i,qt=/Windows Phone/i,wo=/\bWindows(?:.+)ARM\b/i,Co=/BlackBerry/i,Ao=/BB10/i,Po=/Opera Mini/i,Mo=/\b(CriOS|Chrome)(?:.+)Mobile/i,_o=/Mobile(?:.+)Firefox\b/i,To=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function ou(r){return function(e){return e.test(r)}}function ko(r){var e={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?e.userAgent=r:r&&r.userAgent&&(e={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var s=ou(t),n={apple:{phone:s(tn)&&!s(qt),ipod:s(xo),tablet:!s(tn)&&(s(So)||To(e))&&!s(qt),universal:s(vo),device:(s(tn)||s(xo)||s(So)||s(vo)||To(e))&&!s(qt)},amazon:{phone:s(ze),tablet:!s(ze)&&s(es),device:s(ze)||s(es)},android:{phone:!s(qt)&&s(ze)||!s(qt)&&s(en),tablet:!s(qt)&&!s(ze)&&!s(en)&&(s(es)||s(bo)),device:!s(qt)&&(s(ze)||s(es)||s(en)||s(bo))||s(/\bokhttp\b/i)},windows:{phone:s(qt),tablet:s(wo),device:s(qt)||s(wo)},other:{blackberry:s(Co),blackberry10:s(Ao),opera:s(Po),firefox:s(_o),chrome:s(Mo),device:s(Co)||s(Ao)||s(Po)||s(_o)||s(Mo)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const au=ko.default??ko,hu=au(globalThis.navigator),sn=Object.create(null),Ro=Object.create(null);function mr(r,e){let t=Ro[r];return t===void 0&&(sn[e]===void 0&&(sn[e]=1),Ro[r]=t=sn[e]++),t}let Le;function Dh(){return(!Le||Le!=null&&Le.isContextLost())&&(Le=j.get().createCanvas().getContext("webgl",{})),Le}let is;function lu(){if(!is){is="mediump";const r=Dh();r&&r.getShaderPrecisionFormat&&(is=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return is}function cu(r,e,t){return e?r:t?(r=r.replace("out vec4 finalColor;",""),`
|
|
6
6
|
|
|
7
7
|
#ifdef GL_ES // This checks if it is WebGL1
|
|
8
8
|
#define in varying
|
|
@@ -17,30 +17,30 @@ Deprecated since v${r}`,n=typeof console.groupCollapsed=="function"&&!He.noColor
|
|
|
17
17
|
#define out varying
|
|
18
18
|
#endif
|
|
19
19
|
${r}
|
|
20
|
-
`}function
|
|
21
|
-
${r}`}else if(i!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function
|
|
22
|
-
${r}`:r}const
|
|
23
|
-
${r}`}function yu(r,e){return e?r.replace("#version 300 es",""):r}const nn={stripVersion:yu,ensurePrecision:uu,addProgramDefines:du,setProgramName:mu,insertVersion:pu},ui=Object.create(null),Lh=class Wn{constructor(e){e={...Wn.defaultOptions,...e};const t=e.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:t,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:cu()},setProgramName:{name:e.name},addProgramDefines:t,insertVersion:t};let s=e.fragment,n=e.vertex;Object.keys(nn).forEach(o=>{const a=i[o];s=nn[o](s,a,!0),n=nn[o](n,a,!1)}),this.fragment=s,this.vertex=n,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=yr(`${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,ui[this._cacheKey]=null}static from(e){const t=`${e.vertex}:${e.fragment}`;return ui[t]||(ui[t]=new Wn(e),ui[t]._cacheKey=t),ui[t]}};Lh.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let si=Lh;const Io={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 xu(r){return Io[r]??Io.float32}const Su={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"},Bo=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function Do(r,e){let t;for(;(t=Bo.exec(r))!==null;){const i=Su[t[3]]??"float32";e[t[2]]={location:parseInt(t[1],10),format:i,stride:xu(i).stride,offset:0,instance:!1,start:0}}Bo.lastIndex=0}function vu(r){return r.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function bu({source:r,entryPoint:e}){const t={},i=vu(r),s=i.indexOf(`fn ${e}(`);if(s===-1)return t;const n=i.indexOf("->",s);if(n===-1)return t;const o=i.substring(s,n);if(Do(o,t),Object.keys(t).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&&Do(c[1],t)}}return t}function rn(r){var d,u;const e=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,t=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,s=/var(<[^>]+>)? (\w+)/,n=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(d=r.match(e))==null?void 0:d.map(p=>({group:parseInt(p.match(t)[1],10),binding:parseInt(p.match(i)[1],10),name:p.match(s)[2],isUniform:p.match(s)[1]==="<uniform>",type:p.match(n)[1]}));if(!l)return{groups:[],structs:[]};const c=((u=r.match(o))==null?void 0:u.map(p=>{const f=p.match(h)[1],y=p.match(a).reduce((m,x)=>{const[S,v]=x.split(":");return m[S.trim()]=v.trim(),m},{});return y?{name:f,members:y}:null}).filter(({name:p})=>l.some(f=>f.type===p||f.type.includes(`<${p}>`))))??[];return{groups:l,structs:c}}var Ae=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(Ae||{});function wu({groups:r}){const e=[];for(let t=0;t<r.length;t++){const i=r[t];e[i.group]||(e[i.group]=[]),i.isUniform?e[i.group].push({binding:i.binding,visibility:Ae.VERTEX|Ae.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?e[i.group].push({binding:i.binding,visibility:Ae.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"||i.type.startsWith("texture_2d<")?e[i.group].push({binding:i.binding,visibility:Ae.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):i.type==="texture_2d_array"||i.type.startsWith("texture_2d_array<")?e[i.group].push({binding:i.binding,visibility:Ae.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(i.type==="texture_cube"||i.type.startsWith("texture_cube<"))&&e[i.group].push({binding:i.binding,visibility:Ae.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let t=0;t<e.length;t++)e[t]||(e[t]=[]);return e}function Cu({groups:r}){const e=[];for(let t=0;t<r.length;t++){const i=r[t];e[i.group]||(e[i.group]={}),e[i.group][i.name]=i.binding}return e}function Au(r,e){const t=new Set,i=new Set,s=[...r.structs,...e.structs].filter(o=>t.has(o.name)?!1:(t.add(o.name),!0)),n=[...r.groups,...e.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:s,groups:n}}const pi=Object.create(null);class le{constructor(e){var a,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:t,vertex:i,layout:s,gpuLayout:n,name:o}=e;if(this.name=o,this.fragment=t,this.vertex=i,t.source===i.source){const l=rn(t.source);this.structsAndGroups=l}else{const l=rn(i.source),c=rn(t.source);this.structsAndGroups=Au(l,c)}this.layout=s??Cu(this.structsAndGroups),this.gpuLayout=n??wu(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:e,fragment:t}=this,i=e.source+t.source+e.entryPoint+t.entryPoint;this._layoutKey=yr(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=bu(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,pi[this._cacheKey]=null}static from(e){const t=`${e.vertex.source}:${e.fragment.source}:${e.fragment.entryPoint}:${e.vertex.entryPoint}`;return pi[t]||(pi[t]=new le(e),pi[t]._cacheKey=t),pi[t]}}const Oh=["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>"],Pu=Oh.reduce((r,e)=>(r[e]=!0,r),{});function Mu(r,e){switch(r){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*e);case"vec3<f32>":return new Float32Array(3*e);case"vec4<f32>":return new Float32Array(4*e);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 Gh=class Wh{constructor(e,t){this._touched=0,this.uid=dt("uniform"),this._resourceType="uniformGroup",this._resourceId=dt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,t={...Wh.defaultOptions,...t},this.uniformStructures=e;const i={};for(const s in e){const n=e[s];if(n.name=s,n.size=n.size??1,!Pu[n.type]){const o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,h]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${h} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${Oh.join(", ")}`)}n.value??(n.value=Mu(n.type,n.size)),i[s]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=t.ubo,this.isStatic=t.isStatic,this._signature=yr(Object.keys(i).map(s=>`${s}-${e[s].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Gh.defaultOptions={ubo:!1,isStatic:!1};let ni=Gh;class _i{constructor(e){this.resources=Object.create(null),this._dirty=!0;let t=0;for(const i in e){const s=e[i];this.setResource(s,t++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const e=[];let t=0;for(const i in this.resources)e[t++]=this.resources[i]._resourceId;this._key=e.join("|")}setResource(e,t){var s,n;const i=this.resources[t];e!==i&&(i&&((s=i.off)==null||s.call(i,"change",this.onResourceChange,this)),(n=e.on)==null||n.call(e,"change",this.onResourceChange,this),this.resources[t]=e,this._dirty=!0)}getResource(e){return this.resources[e]}_touch(e,t){const i=this.resources;for(const s in i)i[s]._gcLastUsed=e,i[s]._touched=t}destroy(){var t;const e=this.resources;for(const i in e){const s=e[i];(t=s==null?void 0:s.off)==null||t.call(s,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(e){if(this._dirty=!0,e.destroyed){const t=this.resources;for(const i in t)t[i]===e&&(t[i]=null)}else this._updateKey()}}var Fi=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.CANVAS=4]="CANVAS",r[r.BOTH=3]="BOTH",r))(Fi||{});class Be extends Yt{constructor(e){super(),this.uid=dt("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:t,glProgram:i,groups:s,resources:n,compatibleRenderers:o,groupMap:a}=e;this.gpuProgram=t,this.glProgram=i,o===void 0&&(o=0,t&&(o|=Fi.WEBGPU),i&&(o|=Fi.WEBGL)),this.compatibleRenderers=o;const h={};if(!n&&!s&&(n={}),n&&s)throw new Error("[Shader] Cannot have both resources and groups");if(!t&&s&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!t&&s&&a)for(const l in a)for(const c in a[l]){const d=a[l][c];h[d]={group:l,binding:c,name:d}}else if(t&&s&&!a){const l=t.structsAndGroups.groups;a={},l.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,h[c.name]=c})}else if(n){s={},a={},t&&t.structsAndGroups.groups.forEach(d=>{a[d.group]=a[d.group]||{},a[d.group][d.binding]=d.name,h[d.name]=d});let l=0;for(const c in n)h[c]||(s[99]||(s[99]=new _i,this._ownedBindGroups.push(s[99])),h[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++);for(const c in n){const d=c;let u=n[c];!u.source&&!u._resourceType&&(u=new ni(u));const p=h[d];p&&(s[p.group]||(s[p.group]=new _i,this._ownedBindGroups.push(s[p.group])),s[p.group].setResource(u,p.binding))}}this.groups=s,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(s,h)}addResource(e,t,i){var s,n;(s=this._uniformBindMap)[t]||(s[t]={}),(n=this._uniformBindMap[t])[i]||(n[i]=e),this.groups[t]||(this.groups[t]=new _i,this._ownedBindGroups.push(this.groups[t]))}_buildResourceAccessor(e,t){const i={};for(const s in t){const n=t[s];Object.defineProperty(i,n.name,{get(){return e[n.group].getResource(n.binding)},set(o){e[n.group].setResource(o,n.binding)}})}return i}destroy(e=!1){var t,i;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),e&&((t=this.gpuProgram)==null||t.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(s=>{s.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(e){const{gpu:t,gl:i,...s}=e;let n,o;return t&&(n=le.from(t)),i&&(o=si.from(i)),new Be({gpuProgram:n,glProgram:o,...s})}}const _u={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},on=0,an=1,hn=2,ln=3,cn=4,dn=5,Un=class Uh{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<on)}set blend(e){!!(this.data&1<<on)!==e&&(this.data^=1<<on)}get offsets(){return!!(this.data&1<<an)}set offsets(e){!!(this.data&1<<an)!==e&&(this.data^=1<<an)}set cullMode(e){if(e==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=e==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<hn)}set culling(e){!!(this.data&1<<hn)!==e&&(this.data^=1<<hn)}get depthTest(){return!!(this.data&1<<ln)}set depthTest(e){!!(this.data&1<<ln)!==e&&(this.data^=1<<ln)}get depthMask(){return!!(this.data&1<<dn)}set depthMask(e){!!(this.data&1<<dn)!==e&&(this.data^=1<<dn)}get clockwiseFrontFace(){return!!(this.data&1<<cn)}set clockwiseFrontFace(e){!!(this.data&1<<cn)!==e&&(this.data^=1<<cn)}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!=="none",this._blendMode=e,this._blendModeId=_u[e]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const e=new Uh;return e.depthTest=!1,e.blend=!0,e}};Un.default2d=Un.for2d();let Vi=Un;const Hh=class Hn extends Be{constructor(e){e={...Hn.defaultOptions,...e},super(e),this.enabled=!0,this._state=Vi.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1),e.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,i,s){e.applyFilter(this,t,i,s)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:i,...s}=e;let n,o;return t&&(n=le.from(t)),i&&(o=si.from(i)),new Hn({gpuProgram:n,glProgram:o,...s})}};Hh.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Tu=Hh;const Vn=[];$.handleByNamedList(I.Environment,Vn);async function ku(r){if(!r)for(let e=0;e<Vn.length;e++){const t=Vn[e];if(t.value.test()){await t.value.load();return}}}let fi;function Ru(){if(typeof fi=="boolean")return fi;try{fi=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{fi=!1}return fi}function Fo(r,e,t=2){const i=e&&e.length,s=i?e[0]*t:r.length;let n=Vh(r,0,s,t,!0);const o=[];if(!n||n.next===n.prev)return o;let a,h,l;if(i&&(n=Fu(r,e,n,t)),r.length>80*t){a=r[0],h=r[1];let c=a,d=h;for(let u=t;u<s;u+=t){const p=r[u],f=r[u+1];p<a&&(a=p),f<h&&(h=f),p>c&&(c=p),f>d&&(d=f)}l=Math.max(c-a,d-h),l=l!==0?32767/l:0}return zi(n,o,t,a,h,l,0),o}function Vh(r,e,t,i,s){let n;if(s===Yu(r,e,t,i)>0)for(let o=e;o<t;o+=i)n=zo(o/i|0,r[o],r[o+1],n);else for(let o=t-i;o>=e;o-=i)n=zo(o/i|0,r[o],r[o+1],n);return n&&ri(n,n.next)&&(Oi(n),n=n.next),n}function De(r,e){if(!r)return r;e||(e=r);let t=r,i;do if(i=!1,!t.steiner&&(ri(t,t.next)||at(t.prev,t,t.next)===0)){if(Oi(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function zi(r,e,t,i,s,n,o){if(!r)return;!o&&n&&Wu(r,i,s,n);let a=r;for(;r.prev!==r.next;){const h=r.prev,l=r.next;if(n?Iu(r,i,s,n):Eu(r)){e.push(h.i,r.i,l.i),Oi(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=Bu(De(r),e),zi(r,e,t,i,s,n,2)):o===2&&Du(r,e,t,i,s,n):zi(De(r),e,t,i,s,n,1);break}}}function Eu(r){const e=r.prev,t=r,i=r.next;if(at(e,t,i)>=0)return!1;const s=e.x,n=t.x,o=i.x,a=e.y,h=t.y,l=i.y,c=Math.min(s,n,o),d=Math.min(a,h,l),u=Math.max(s,n,o),p=Math.max(a,h,l);let f=i.next;for(;f!==e;){if(f.x>=c&&f.x<=u&&f.y>=d&&f.y<=p&&Ci(s,a,n,h,o,l,f.x,f.y)&&at(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Iu(r,e,t,i){const s=r.prev,n=r,o=r.next;if(at(s,n,o)>=0)return!1;const a=s.x,h=n.x,l=o.x,c=s.y,d=n.y,u=o.y,p=Math.min(a,h,l),f=Math.min(c,d,u),y=Math.max(a,h,l),m=Math.max(c,d,u),x=Nn(p,f,e,t,i),S=Nn(y,m,e,t,i);let v=r.prevZ,b=r.nextZ;for(;v&&v.z>=x&&b&&b.z<=S;){if(v.x>=p&&v.x<=y&&v.y>=f&&v.y<=m&&v!==s&&v!==o&&Ci(a,c,h,d,l,u,v.x,v.y)&&at(v.prev,v,v.next)>=0||(v=v.prevZ,b.x>=p&&b.x<=y&&b.y>=f&&b.y<=m&&b!==s&&b!==o&&Ci(a,c,h,d,l,u,b.x,b.y)&&at(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=x;){if(v.x>=p&&v.x<=y&&v.y>=f&&v.y<=m&&v!==s&&v!==o&&Ci(a,c,h,d,l,u,v.x,v.y)&&at(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=S;){if(b.x>=p&&b.x<=y&&b.y>=f&&b.y<=m&&b!==s&&b!==o&&Ci(a,c,h,d,l,u,b.x,b.y)&&at(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Bu(r,e){let t=r;do{const i=t.prev,s=t.next.next;!ri(i,s)&&jh(i,t,t.next,s)&&Li(i,s)&&Li(s,i)&&(e.push(i.i,t.i,s.i),Oi(t),Oi(t.next),t=r=s),t=t.next}while(t!==r);return De(t)}function Du(r,e,t,i,s,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Vu(o,a)){let h=Yh(o,a);o=De(o,o.next),h=De(h,h.next),zi(o,e,t,i,s,n,0),zi(h,e,t,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function Fu(r,e,t,i){const s=[];for(let n=0,o=e.length;n<o;n++){const a=e[n]*i,h=n<o-1?e[n+1]*i:r.length,l=Vh(r,a,h,i,!1);l===l.next&&(l.steiner=!0),s.push(Hu(l))}s.sort(zu);for(let n=0;n<s.length;n++)t=Lu(s[n],t);return t}function zu(r,e){let t=r.x-e.x;if(t===0&&(t=r.y-e.y,t===0)){const i=(r.next.y-r.y)/(r.next.x-r.x),s=(e.next.y-e.y)/(e.next.x-e.x);t=i-s}return t}function Lu(r,e){const t=Ou(r,e);if(!t)return e;const i=Yh(t,r);return De(i,i.next),De(t,t.next)}function Ou(r,e){let t=e;const i=r.x,s=r.y;let n=-1/0,o;if(ri(r,t))return t;do{if(ri(r,t.next))return t.next;if(s<=t.y&&s>=t.next.y&&t.next.y!==t.y){const d=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>n&&(n=d,o=t.x<t.next.x?t:t.next,d===i))return o}t=t.next}while(t!==e);if(!o)return null;const a=o,h=o.x,l=o.y;let c=1/0;t=o;do{if(i>=t.x&&t.x>=h&&i!==t.x&&Nh(s<l?i:n,s,h,l,s<l?n:i,s,t.x,t.y)){const d=Math.abs(s-t.y)/(i-t.x);Li(t,r)&&(d<c||d===c&&(t.x>o.x||t.x===o.x&&Gu(o,t)))&&(o=t,c=d)}t=t.next}while(t!==a);return o}function Gu(r,e){return at(r.prev,r,e.prev)<0&&at(e.next,r,r.next)<0}function Wu(r,e,t,i){let s=r;do s.z===0&&(s.z=Nn(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,Uu(s)}function Uu(r){let e,t=1;do{let i=r,s;r=null;let n=null;for(e=0;i;){e++;let o=i,a=0;for(let l=0;l<t&&(a++,o=o.nextZ,!!o);l++);let h=t;for(;a>0||h>0&&o;)a!==0&&(h===0||!o||i.z<=o.z)?(s=i,i=i.nextZ,a--):(s=o,o=o.nextZ,h--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;i=o}n.nextZ=null,t*=2}while(e>1);return r}function Nn(r,e,t,i,s){return r=(r-t)*s|0,e=(e-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function Hu(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function Nh(r,e,t,i,s,n,o,a){return(s-o)*(e-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(n-a)>=(s-o)*(i-a)}function Ci(r,e,t,i,s,n,o,a){return!(r===o&&e===a)&&Nh(r,e,t,i,s,n,o,a)}function Vu(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!Nu(r,e)&&(Li(r,e)&&Li(e,r)&&ju(r,e)&&(at(r.prev,r,e.prev)||at(r,e.prev,e))||ri(r,e)&&at(r.prev,r,r.next)>0&&at(e.prev,e,e.next)>0)}function at(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function ri(r,e){return r.x===e.x&&r.y===e.y}function jh(r,e,t,i){const s=ns(at(r,e,t)),n=ns(at(r,e,i)),o=ns(at(t,i,r)),a=ns(at(t,i,e));return!!(s!==n&&o!==a||s===0&&ss(r,t,e)||n===0&&ss(r,i,e)||o===0&&ss(t,r,i)||a===0&&ss(t,e,i))}function ss(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function ns(r){return r>0?1:r<0?-1:0}function Nu(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&jh(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Li(r,e){return at(r.prev,r,r.next)<0?at(r,e,r.next)>=0&&at(r,r.prev,e)>=0:at(r,e,r.prev)<0||at(r,r.next,e)<0}function ju(r,e){let t=r,i=!1;const s=(r.x+e.x)/2,n=(r.y+e.y)/2;do t.y>n!=t.next.y>n&&t.next.y!==t.y&&s<(t.next.x-t.x)*(n-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==r);return i}function Yh(r,e){const t=jn(r.i,r.x,r.y),i=jn(e.i,e.x,e.y),s=r.next,n=e.prev;return r.next=e,e.prev=r,t.next=s,s.prev=t,i.next=t,t.prev=i,n.next=i,i.prev=n,i}function zo(r,e,t,i){const s=jn(r,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Oi(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function jn(r,e,t){return{i:r,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Yu(r,e,t,i){let s=0;for(let n=e,o=t-i;n<t;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}const Xu=Fo.default||Fo;var Xh=(r=>(r[r.NONE=0]="NONE",r[r.COLOR=16384]="COLOR",r[r.STENCIL=1024]="STENCIL",r[r.DEPTH=256]="DEPTH",r[r.COLOR_DEPTH=16640]="COLOR_DEPTH",r[r.COLOR_STENCIL=17408]="COLOR_STENCIL",r[r.DEPTH_STENCIL=1280]="DEPTH_STENCIL",r[r.ALL=17664]="ALL",r))(Xh||{});class Zu{constructor(e){this.items=[],this._name=e}emit(e,t,i,s,n,o,a,h){const{name:l,items:c}=this;for(let d=0,u=c.length;d<u;d++)c[d][l](e,t,i,s,n,o,a,h);return this}add(e){return e[this._name]&&(this.remove(e),this.items.push(e)),this}remove(e){const t=this.items.indexOf(e);return t!==-1&&this.items.splice(t,1),this}contains(e){return this.items.indexOf(e)!==-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 qu=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Zh=class qh extends Yt{constructor(e){super(),this.tick=0,this.uid=dt("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=e.type,this.name=e.name,this.config=e;const t=[...qu,...this.config.runners??[]];this._addRunners(...t),this._unsafeEvalCheck()}async init(e={}){const t=e.skipExtensionImports===!0?!0:e.manageImports===!1;await ku(t),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash)e={...this._systemsHash[i].constructor.defaultOptions,...e};e={...qh.defaultOptions,...e},this._roundPixels=e.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(e);this._initOptions=e}render(e,t){this.tick++;let i=e;if(i instanceof L&&(i={container:i},t&&(V(J,"passing a second argument is deprecated, please use render options instead"),i.target=t.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 s=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=s?i.clearColor:rt.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(e,t,i){const s=this.view.resolution;this.view.resize(e,t,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==s&&this.runners.resolutionChange.emit(i)}clear(e={}){const t=this;e.target||(e.target=t.renderTarget.renderTarget),e.clearColor||(e.clearColor=this.background.colorRgba),e.clear??(e.clear=Xh.ALL);const{clear:i,clearColor:s,target:n,mipLevel:o,layer:a}=e;rt.shared.setValue(s??this.background.colorRgba),t.renderTarget.clear(n,i,rt.shared.toArray(),o??0,a??0)}get resolution(){return this.view.resolution}set resolution(e){this.view.resolution=e,this.runners.resolutionChange.emit(e)}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(...e){e.forEach(t=>{this.runners[t]=new Zu(t)})}_addSystems(e){let t;for(t in e){const i=e[t];this._addSystem(i.value,i.name)}}_addSystem(e,t){const i=new e(this);if(this[t])throw new Error(`Whoops! The name "${t}" is already in use`);this[t]=i,this._systemsHash[t]=i;for(const s in this.runners)this.runners[s].add(i);return this}_addPipes(e,t){const i=t.reduce((s,n)=>(s[n.name]=n.value,s),{});e.forEach(s=>{const n=s.value,o=s.name,a=i[o];this.renderPipes[o]=new n(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(e=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(e),(e===!0||typeof e=="object"&&e.releaseGlobalResources)&&Hi.release(),Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(e){return this.textureGenerator.generateTexture(e)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Ru())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()}};Zh.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Kh=Zh,rs;function Ku(r){return rs!==void 0||(rs=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r??Kh.defaultOptions.failIfMajorPerformanceCaveat};try{if(!j.get().getWebGLRenderingContext())return!1;let s=j.get().createCanvas().getContext("webgl",e);const n=!!((t=s==null?void 0:s.getContextAttributes())!=null&&t.stencil);if(s){const o=s.getExtension("WEBGL_lose_context");o&&o.loseContext()}return s=null,n}catch{return!1}})()),rs}let os;async function $u(r={}){return os!==void 0||(os=await(async()=>{const e=j.get().getNavigator().gpu;if(!e)return!1;try{return await(await e.requestAdapter(r)).requestDevice(),!0}catch{return!1}})()),os}const Lo=["webgl","webgpu","canvas"];async function Qu(r){let e=[];r.preference?(e.push(r.preference),Lo.forEach(n=>{n!==r.preference&&e.push(n)})):e=Lo.slice();let t,i={};for(let n=0;n<e.length;n++){const o=e[n];if(o==="webgpu"&&await $u()){const{WebGPURenderer:a}=await _e(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer.KCAyMTek.js");return{WebGPURenderer:h}},__vite__mapDeps([5,6,7,2,3,4]));t=a,i={...r,...r.webgpu};break}else if(o==="webgl"&&Ku(r.failIfMajorPerformanceCaveat??Kh.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await _e(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer.uIm0oBU6.js");return{WebGLRenderer:h}},__vite__mapDeps([8,6,7,2,3,4]));t=a,i={...r,...r.webgl};break}else if(o==="canvas"){const{CanvasRenderer:a}=await _e(async()=>{const{CanvasRenderer:h}=await import("./CanvasRenderer.AFx6MHtI.js");return{CanvasRenderer:h}},__vite__mapDeps([9,7,2,3,4]));t=a,i={...r,...r.canvasOptions};break}}if(delete i.webgpu,delete i.webgl,delete i.canvasOptions,!t)throw new Error("No available renderer for the current environment");const s=new t;return await s.init(i),s}const $h="8.16.0";class Qh{static init(){var e;(e=globalThis.__PIXI_APP_INIT__)==null||e.call(globalThis,this,$h)}static destroy(){}}Qh.extension=I.Application;class Ju{constructor(e){this._renderer=e}init(){var e;(e=globalThis.__PIXI_RENDERER_INIT__)==null||e.call(globalThis,this._renderer,$h)}destroy(){this._renderer=null}}Ju.extension={type:[I.WebGLSystem,I.WebGPUSystem],name:"initHook",priority:-10};class Jh{static init(e){Object.defineProperty(this,"resizeTo",{configurable:!0,set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(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 t,i;if(this._resizeTo===globalThis.window)t=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;t=s,i=n}this.renderer.resize(t,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Jh.extension=I.Application;class tl{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{configurable:!0,set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,Ie.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?yt.shared:new yt,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}tl.extension=I.Application;$.add(Jh);$.add(tl);const el=class Yn{constructor(...e){this.stage=new L,e[0]!==void 0&&V(J,"Application constructor options are deprecated, please use Application.init() instead.")}async init(e){e={...e},this.stage||(this.stage=new L),this.renderer=await Qu(e),Yn._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return V(J,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(e=!1,t=!1){const i=Yn._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(t),this.stage=null,this.renderer.destroy(e),this.renderer=null}};el._plugins=[];let il=el;$.handleByList(I.Application,il._plugins);$.add(Qh);const un={test(r){return typeof r=="string"&&r.startsWith("info face=")},parse(r){const e=r.match(/^[a-z]+\s+.+$/gm),t={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const d in e){const u=e[d].match(/^[a-z]+/gm)[0],p=e[d].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),f={};for(const y in p){const m=p[y].split("="),x=m[0],S=m[1].replace(/"/gm,""),v=parseFloat(S),b=isNaN(v)?S:v;f[x]=b}t[u].push(f)}const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[s]=t.info,[n]=t.common,[o]=t.distanceField??[];o&&(i.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),i.fontSize=parseInt(s.size,10),i.fontFamily=s.face,i.lineHeight=parseInt(n.lineHeight,10);const a=t.page;for(let d=0;d<a.length;d++)i.pages.push({id:parseInt(a[d].id,10)||0,file:a[d].file});const h={};i.baseLineOffset=i.lineHeight-parseInt(n.base,10);const l=t.char;for(let d=0;d<l.length;d++){const u=l[d],p=parseInt(u.id,10);let f=u.letter??u.char??String.fromCharCode(p);f==="space"&&(f=" "),h[p]=f,i.chars[f]={id:p,page:parseInt(u.page,10)||0,x:parseInt(u.x,10),y:parseInt(u.y,10),width:parseInt(u.width,10),height:parseInt(u.height,10),xOffset:parseInt(u.xoffset,10),yOffset:parseInt(u.yoffset,10),xAdvance:parseInt(u.xadvance,10),kerning:{}}}const c=t.kerning||[];for(let d=0;d<c.length;d++){const u=parseInt(c[d].first,10),p=parseInt(c[d].second,10),f=parseInt(c[d].amount,10);i.chars[h[p]].kerning[h[u]]=f}return i}},Oo={test(r){const e=r;return typeof e!="string"&&"getElementsByTagName"in e&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(r){const e={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},t=r.getElementsByTagName("info")[0],i=r.getElementsByTagName("common")[0],s=r.getElementsByTagName("distanceField")[0];s&&(e.distanceField={type:s.getAttribute("fieldType"),range:parseInt(s.getAttribute("distanceRange"),10)});const n=r.getElementsByTagName("page"),o=r.getElementsByTagName("char"),a=r.getElementsByTagName("kerning");e.fontSize=parseInt(t.getAttribute("size"),10),e.fontFamily=t.getAttribute("face"),e.lineHeight=parseInt(i.getAttribute("lineHeight"),10);for(let l=0;l<n.length;l++)e.pages.push({id:parseInt(n[l].getAttribute("id"),10)||0,file:n[l].getAttribute("file")});const h={};e.baseLineOffset=e.lineHeight-parseInt(i.getAttribute("base"),10);for(let l=0;l<o.length;l++){const c=o[l],d=parseInt(c.getAttribute("id"),10);let u=c.getAttribute("letter")??c.getAttribute("char")??String.fromCharCode(d);u==="space"&&(u=" "),h[d]=u,e.chars[u]={id:d,page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xOffset:parseInt(c.getAttribute("xoffset"),10),yOffset:parseInt(c.getAttribute("yoffset"),10),xAdvance:parseInt(c.getAttribute("xadvance"),10),kerning:{}}}for(let l=0;l<a.length;l++){const c=parseInt(a[l].getAttribute("first"),10),d=parseInt(a[l].getAttribute("second"),10),u=parseInt(a[l].getAttribute("amount"),10);e.chars[h[d]].kerning[h[c]]=u}return e}},Go={test(r){return typeof r=="string"&&r.match(/<font(\s|>)/)?Oo.test(j.get().parseXML(r)):!1},parse(r){return Oo.parse(j.get().parseXML(r))}},tp=[".xml",".fnt"],ep={extension:{type:I.CacheParser,name:"cacheBitmapFont"},test:r=>!!(r!=null&&r.pages)&&!!(r!=null&&r.chars)&&typeof(r==null?void 0:r.fontFamily)=="string",getCacheableAssets(r,e){const t={};return r.forEach(i=>{t[i]=e,t[`${i}-bitmap`]=e}),t[`${e.fontFamily}-bitmap`]=e,t}},ip={extension:{type:I.LoadParser,priority:ue.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return tp.includes(Mt.extname(r).toLowerCase())},async testParse(r){return un.test(r)||Go.test(r)},async parse(r,e,t){const i=un.test(r)?un.parse(r):Go.parse(r),{src:s}=e,{pages:n}=i,o=[],a=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let u=0;u<n.length;++u){const p=n[u].file;let f=Mt.join(Mt.dirname(s),p);f=Ln(f,s),o.push({src:f,data:a})}const[h,{BitmapFont:l}]=await Promise.all([t.load(o),_e(()=>import("./BitmapFont.CcysO3pT.js"),__vite__mapDeps([10,2,3,4]))]),c=o.map(u=>h[u.src]);return new l({data:i,textures:c},s)},async load(r,e){return await(await j.get().fetch(r)).text()},async unload(r,e,t){await Promise.all(r.pages.map(i=>t.unload(i.texture.source._sourceOrigin))),r.destroy()}};class sp{constructor(e,t=!1){this._loader=e,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=t}add(e){e.forEach(t=>{this._assetList.push(t)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const e=[],t=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<t;i++)e.push(this._assetList.pop());await this._loader.load(e),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(e){this._isActive!==e&&(this._isActive=e,e&&!this._isLoading&&this._next())}}const np={extension:{type:I.CacheParser,name:"cacheTextureArray"},test:r=>Array.isArray(r)&&r.every(e=>e instanceof G),getCacheableAssets:(r,e)=>{const t={};return r.forEach(i=>{e.forEach((s,n)=>{t[i+(n===0?"":n+1)]=s})}),t}};async function sl(r){if("Image"in globalThis)return new Promise(e=>{const t=new Image;t.onload=()=>{e(!0)},t.onerror=()=>{e(!1)},t.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const e=await(await fetch(r)).blob();await createImageBitmap(e)}catch{return!1}return!0}return!1}const rp={extension:{type:I.DetectionParser,priority:1},test:async()=>sl("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(e=>e!=="avif")},Wo=["png","jpg","jpeg"],op={extension:{type:I.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Wo],remove:async r=>r.filter(e=>!Wo.includes(e))},ap="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function ks(r){return ap?!1:document.createElement("video").canPlayType(r)!==""}const hp={extension:{type:I.DetectionParser,priority:0},test:async()=>ks("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(e=>e!=="mp4"&&e!=="m4v")},lp={extension:{type:I.DetectionParser,priority:0},test:async()=>ks("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(e=>e!=="ogv")},cp={extension:{type:I.DetectionParser,priority:0},test:async()=>ks("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(e=>e!=="webm")},dp={extension:{type:I.DetectionParser,priority:0},test:async()=>sl("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(e=>e!=="webp")},nl=class us{constructor(){this.loadOptions={...us.defaultOptions},this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(e,t,i)=>(this._parsersValidated=!1,e[t]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(e,t){const i={promise:null,parser:null};return i.promise=(async()=>{var o,a;let s=null,n=null;if((t.parser||t.loadParser)&&(n=this._parserHash[t.parser||t.loadParser],t.loadParser&&nt(`[Assets] "loadParser" is deprecated, use "parser" instead for ${e}`),n||nt(`[Assets] specified load parser "${t.parser||t.loadParser}" not found while loading ${e}`)),!n){for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.load&&((o=l.test)!=null&&o.call(l,e,t,this))){n=l;break}}if(!n)return nt(`[Assets] ${e} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(e,t,this),i.parser=n;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];l.parse&&l.parse&&await((a=l.testParse)==null?void 0:a.call(l,s,t,this))&&(s=await l.parse(s,t,this)||s,i.parser=l)}return s})(),i}async load(e,t){this._parsersValidated||this._validateParsers();const i=typeof t=="function"?{...us.defaultOptions,...this.loadOptions,onProgress:t}:{...us.defaultOptions,...this.loadOptions,...t||{}},{onProgress:s,onError:n,strategy:o,retryCount:a,retryDelay:h}=i;let l=0;const c={},d=ms(e),u=zt(e,y=>({alias:[y],src:y,data:{}})),p=u.reduce((y,m)=>y+(m.progressSize||1),0),f=u.map(async y=>{const m=Mt.toAbsolute(y.src);c[y.src]||(await this._loadAssetWithRetry(m,y,{onProgress:s,onError:n,strategy:o,retryCount:a,retryDelay:h},c),l+=y.progressSize||1,s&&s(l/p))});return await Promise.all(f),d?c[u[0].src]:c}async unload(e){const i=zt(e,s=>({alias:[s],src:s})).map(async s=>{var a,h;const n=Mt.toAbsolute(s.src),o=this.promiseCache[n];if(o){const l=await o.promise;delete this.promiseCache[n],await((h=(a=o.parser)==null?void 0:a.unload)==null?void 0:h.call(a,l,s,this))}});await Promise.all(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(e=>e.name||e.id).reduce((e,t)=>(!t.name&&!t.id?nt("[Assets] parser should have an id"):(e[t.name]||e[t.id])&&nt(`[Assets] parser id conflict "${t.id}"`),e[t.name]=t,t.id&&(e[t.id]=t),e),{})}async _loadAssetWithRetry(e,t,i,s){let n=0;const{onError:o,strategy:a,retryCount:h,retryDelay:l}=i,c=d=>new Promise(u=>setTimeout(u,d));for(;;)try{this.promiseCache[e]||(this.promiseCache[e]=this._getLoadPromiseAndParser(e,t)),s[t.src]=await this.promiseCache[e].promise;return}catch(d){delete this.promiseCache[e],delete s[t.src],n++;const u=a!=="retry"||n>h;if(a==="retry"&&!u){o&&o(d,t),await c(l);continue}if(a==="skip"){o&&o(d,t);return}o&&o(d,t);const p=new Error(`[Loader.load] Failed to load ${e}.
|
|
24
|
-
${d}`);throw d instanceof Error&&d.stack&&(p.stack=d.stack),p}}};nl.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let up=nl;function pe(r,e){if(Array.isArray(e)){for(const t of e)if(r.startsWith(`data:${t}`))return!0;return!1}return r.startsWith(`data:${e}`)}function li(r,e){const t=r.split("?")[0],i=Mt.extname(t).toLowerCase();return Array.isArray(e)?e.includes(i):i===e}const pp=".json",fp="application/json",gp={extension:{type:I.LoadParser,priority:ue.Low},name:"loadJson",id:"json",test(r){return pe(r,fp)||li(r,pp)},async load(r){return await(await j.get().fetch(r)).json()}},mp=".txt",yp="text/plain",xp={name:"loadTxt",id:"text",extension:{type:I.LoadParser,priority:ue.Low,name:"loadTxt"},test(r){return pe(r,yp)||li(r,mp)},async load(r){return await(await j.get().fetch(r)).text()}},Sp=["normal","bold","100","200","300","400","500","600","700","800","900"],vp=[".ttf",".otf",".woff",".woff2"],bp=["font/ttf","font/otf","font/woff","font/woff2"],wp=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Cp(r){const e=Mt.extname(r),s=Mt.basename(r,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1));let n=s.length>0;for(const a of s)if(!a.match(wp)){n=!1;break}let o=s.join(" ");return n||(o=`"${o.replace(/[\\"]/g,"\\$&")}"`),o}const Ap=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Pp(r){return Ap.test(r)?r:encodeURI(r)}const Mp={extension:{type:I.LoadParser,priority:ue.Low},name:"loadWebFont",id:"web-font",test(r){return pe(r,bp)||li(r,vp)},async load(r,e){var i,s,n;const t=j.get().getFontFaceSet();if(t){const o=[],a=((i=e.data)==null?void 0:i.family)??Cp(r),h=((n=(s=e.data)==null?void 0:s.weights)==null?void 0:n.filter(c=>Sp.includes(c)))??["normal"],l=e.data??{};for(let c=0;c<h.length;c++){const d=h[c],u=new FontFace(a,`url(${Pp(r)})`,{...l,weight:d});await u.load(),t.add(u),o.push(u)}return xt.has(`${a}-and-url`)?xt.get(`${a}-and-url`).entries.push({url:r,faces:o}):xt.set(`${a}-and-url`,{entries:[{url:r,faces:o}]}),o.length===1?o[0]:o}return nt("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(r){const e=Array.isArray(r)?r:[r],t=e[0].family,i=xt.get(`${t}-and-url`),s=i.entries.find(n=>n.faces.some(o=>e.indexOf(o)!==-1));s.faces=s.faces.filter(n=>e.indexOf(n)===-1),s.faces.length===0&&(i.entries=i.entries.filter(n=>n!==s)),e.forEach(n=>{j.get().getFontFaceSet().delete(n)}),i.entries.length===0&&xt.remove(`${t}-and-url`)}};var _p=kp,pn={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Tp=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function kp(r){var e=[];return r.replace(Tp,function(t,i,s){var n=i.toLowerCase();for(s=Ep(s),n=="m"&&s.length>2&&(e.push([i].concat(s.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(s.length==pn[n])return s.unshift(i),e.push(s);if(s.length<pn[n])throw new Error("malformed path data");e.push([i].concat(s.splice(0,pn[n])))}}),e}var Rp=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function Ep(r){var e=r.match(Rp);return e?e.map(Number):[]}const Ip=th(_p);function Bp(r,e){const t=Ip(r),i=[];let s=null,n=0,o=0;for(let a=0;a<t.length;a++){const h=t[a],l=h[0],c=h;switch(l){case"M":n=c[1],o=c[2],e.moveTo(n,o);break;case"m":n+=c[1],o+=c[2],e.moveTo(n,o);break;case"H":n=c[1],e.lineTo(n,o);break;case"h":n+=c[1],e.lineTo(n,o);break;case"V":o=c[1],e.lineTo(n,o);break;case"v":o+=c[1],e.lineTo(n,o);break;case"L":n=c[1],o=c[2],e.lineTo(n,o);break;case"l":n+=c[1],o+=c[2],e.lineTo(n,o);break;case"C":n=c[5],o=c[6],e.bezierCurveTo(c[1],c[2],c[3],c[4],n,o);break;case"c":e.bezierCurveTo(n+c[1],o+c[2],n+c[3],o+c[4],n+c[5],o+c[6]),n+=c[5],o+=c[6];break;case"S":n=c[3],o=c[4],e.bezierCurveToShort(c[1],c[2],n,o);break;case"s":e.bezierCurveToShort(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"Q":n=c[3],o=c[4],e.quadraticCurveTo(c[1],c[2],n,o);break;case"q":e.quadraticCurveTo(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"T":n=c[1],o=c[2],e.quadraticCurveToShort(n,o);break;case"t":n+=c[1],o+=c[2],e.quadraticCurveToShort(n,o);break;case"A":n=c[6],o=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"a":n+=c[6],o+=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"Z":case"z":e.closePath(),i.length>0&&(s=i.pop(),s?(n=s.startX,o=s.startY):(n=0,o=0)),s=null;break;default:nt(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&s===null&&(s={startX:n,startY:o},i.push(s))}return e}class Rs{constructor(e=0,t=0,i=0){this.type="circle",this.x=e,this.y=t,this.radius=i}clone(){return new Rs(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-e,n=this.y-t;return s*=s,n*=n,s+n<=i}strokeContains(e,t,i,s=.5){if(this.radius===0)return!1;const n=this.x-e,o=this.y-t,a=this.radius,h=(1-s)*i,l=Math.sqrt(n*n+o*o);return l<=a+h&&l>a-(i-h)}getBounds(e){return e||(e=new et),e.x=this.x-this.radius,e.y=this.y-this.radius,e.width=this.radius*2,e.height=this.radius*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class xr{constructor(e=0,t=0,i=0,s=0){this.type="ellipse",this.x=e,this.y=t,this.halfWidth=i,this.halfHeight=s}clone(){return new xr(this.x,this.y,this.halfWidth,this.halfHeight)}contains(e,t){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(e-this.x)/this.halfWidth,s=(t-this.y)/this.halfHeight;return i*=i,s*=s,i+s<=1}strokeContains(e,t,i,s=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=i*(1-s),h=i-a,l=n-h,c=o-h,d=n+a,u=o+a,p=e-this.x,f=t-this.y,y=p*p/(l*l)+f*f/(c*c),m=p*p/(d*d)+f*f/(u*u);return y>1&&m<=1}getBounds(e){return e||(e=new et),e.x=this.x-this.halfWidth,e.y=this.y-this.halfHeight,e.width=this.halfWidth*2,e.height=this.halfHeight*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.halfWidth=e.halfWidth,this.halfHeight=e.halfHeight,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function Dp(r,e,t,i,s,n){const o=r-t,a=e-i,h=s-t,l=n-i,c=o*h+a*l,d=h*h+l*l;let u=-1;d!==0&&(u=c/d);let p,f;u<0?(p=t,f=i):u>1?(p=s,f=n):(p=t+u*h,f=i+u*l);const y=r-p,m=e-f;return y*y+m*m}let Fp,zp;class Te{constructor(...e){this.type="polygon";let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!="number"){const i=[];for(let s=0,n=t.length;s<n;s++)i.push(t[s].x,t[s].y);t=i}this.points=t,this.closePath=!0}isClockwise(){let e=0;const t=this.points,i=t.length;for(let s=0;s<i;s+=2){const n=t[s],o=t[s+1],a=t[(s+2)%i],h=t[(s+3)%i];e+=(a-n)*(h+o)}return e<0}containsPolygon(e){const t=this.getBounds(Fp),i=e.getBounds(zp);if(!t.containsRect(i))return!1;const s=e.points;for(let n=0;n<s.length;n+=2){const o=s[n],a=s[n+1];if(!this.contains(o,a))return!1}return!0}clone(){const e=this.points.slice(),t=new Te(e);return t.closePath=this.closePath,t}contains(e,t){let i=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],h=this.points[n*2+1],l=this.points[o*2],c=this.points[o*2+1];h>t!=c>t&&e<(l-a)*((t-h)/(c-h))+a&&(i=!i)}return i}strokeContains(e,t,i,s=.5){const n=i*i,o=n*(1-s),a=n-o,{points:h}=this,l=h.length-(this.closePath?0:2);for(let c=0;c<l;c+=2){const d=h[c],u=h[c+1],p=h[(c+2)%h.length],f=h[(c+3)%h.length],y=Dp(e,t,d,u,p,f),m=Math.sign((p-d)*(t-u)-(f-u)*(e-d));if(y<=(m<0?a:o))return!0}return!1}getBounds(e){e||(e=new et);const t=this.points;let i=1/0,s=-1/0,n=1/0,o=-1/0;for(let a=0,h=t.length;a<h;a+=2){const l=t[a],c=t[a+1];i=l<i?l:i,s=l>s?l:s,n=c<n?c:n,o=c>o?c:o}return e.x=i,e.width=s-i,e.y=n,e.height=o-n,e}copyFrom(e){return this.points=e.points.slice(),this.closePath=e.closePath,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((e,t)=>`${e}, ${t}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return V("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return V("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 as=(r,e,t,i,s,n,o)=>{const a=r-t,h=e-i,l=Math.sqrt(a*a+h*h);return l>=s-n&&l<=s+o};class Sr{constructor(e=0,t=0,i=0,s=0,n=20){this.type="roundedRectangle",this.x=e,this.y=t,this.width=i,this.height=s,this.radius=n}getBounds(e){return e||(e=new et),e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new Sr(this.x,this.y,this.width,this.height,this.radius)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+i&&t<=this.y+this.height-i||e>=this.x+i&&e<=this.x+this.width-i)return!0;let s=e-(this.x+i),n=t-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=e-(this.x+this.width-i),s*s+n*n<=o)||(n=t-(this.y+this.height-i),s*s+n*n<=o)||(s=e-(this.x+i),s*s+n*n<=o))return!0}return!1}strokeContains(e,t,i,s=.5){const{x:n,y:o,width:a,height:h,radius:l}=this,c=i*(1-s),d=i-c,u=n+l,p=o+l,f=a-l*2,y=h-l*2,m=n+a,x=o+h;return(e>=n-c&&e<=n+d||e>=m-d&&e<=m+c)&&t>=p&&t<=p+y||(t>=o-c&&t<=o+d||t>=x-d&&t<=x+c)&&e>=u&&e<=u+f?!0:e<u&&t<p&&as(e,t,u,p,l,d,c)||e>m-l&&t<p&&as(e,t,m-l,p,l,d,c)||e>m-l&&t>x-l&&as(e,t,m-l,x-l,l,d,c)||e<u&&t>x-l&&as(e,t,u,x-l,l,d,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const rl={};function Lp(r,e,t){let i=2166136261;for(let s=0;s<e;s++)i^=r[s].uid,i=Math.imul(i,16777619),i>>>=0;return rl[i]||Op(r,e,i,t)}function Op(r,e,t,i){const s={};let n=0;for(let a=0;a<i;a++){const h=a<e?r[a]:G.EMPTY.source;s[n++]=h.source,s[n++]=h.style}const o=new _i(s);return rl[t]=o,o}class Uo{constructor(e){typeof e=="number"?this.rawBinaryData=new ArrayBuffer(e):e instanceof Uint8Array?this.rawBinaryData=e.buffer:this.rawBinaryData=e,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(e){return this[`${e}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(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${e} isn't a valid view type`)}}}function Ho(r,e,t,i){if(t??(t=0),i??(i=Math.min(r.byteLength-t,e.byteLength)),!(t&7)&&!(i&7)){const s=i/8;new Float64Array(e,0,s).set(new Float64Array(r,t,s))}else if(!(t&3)&&!(i&3)){const s=i/4;new Float32Array(e,0,s).set(new Float32Array(r,t,s))}else new Uint8Array(e).set(new Uint8Array(r,t,i))}const Gp={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Wp=(r=>(r[r.DISABLED=0]="DISABLED",r[r.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",r[r.MASK_ACTIVE=2]="MASK_ACTIVE",r[r.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",r[r.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",r[r.NONE=5]="NONE",r))(Wp||{});function ys(r,e){return e.alphaMode==="no-premultiply-alpha"&&Gp[r]||r}const Up=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
25
|
-
`);function
|
|
26
|
-
else `),t<r-1&&(e+=`if(test == ${t}.0){}`);return e}function Vp(r,e){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const t=e.createShader(e.FRAGMENT_SHADER);try{for(;;){const i=Up.replace(/%forloop%/gi,Hp(r));if(e.shaderSource(t,i),e.compileShader(t),!e.getShaderParameter(t,e.COMPILE_STATUS))r=r/2|0;else break}}finally{e.deleteShader(t)}return r}let Oe=null;function Np(){var e;if(Oe)return Oe;const r=zh();return Oe=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),Oe=Vp(Oe,r),(e=r.getExtension("WEBGL_lose_context"))==null||e.loseContext(),Oe}class jp{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let e=0;e<this.count;e++){const t=this.textures[e];this.textures[e]=null,this.ids[t.uid]=null}this.count=0}}class Yp{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new jp,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 Ti=[];let xs=0;Hi.register({clear:()=>{if(Ti.length>0)for(const r of Ti)r&&r.destroy();Ti.length=0,xs=0}});function Vo(){return xs>0?Ti[--xs]:new Yp}function No(r){r.elements=null,Ti[xs++]=r}let gi=0;const ol=class al{constructor(e){this.uid=dt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],e={...al.defaultOptions,...e},e.maxTextures||(V("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),e.maxTextures=Np());const{maxTextures:t,attributesInitialSize:i,indicesInitialSize:s}=e;this.attributeBuffer=new Uo(i*4),this.indexBuffer=new Uint16Array(s),this.maxTextures=t}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let e=0;e<this.batchIndex;e++)No(this.batches[e]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(e){this._elements[this.elementSize++]=e,e._indexStart=this.indexSize,e._attributeStart=this.attributeSize,e._batcher=this,this.indexSize+=e.indexSize,this.attributeSize+=e.attributeSize*this.vertexSize}checkAndUpdateTexture(e,t){const i=e._batch.textures.ids[t._source.uid];return!i&&i!==0?!1:(e._textureId=i,e.texture=t,!0)}updateElement(e){this.dirty=!0;const t=this.attributeBuffer;e.packAsQuad?this.packQuadAttributes(e,t.float32View,t.uint32View,e._attributeStart,e._textureId):this.packAttributes(e,t.float32View,t.uint32View,e._attributeStart,e._textureId)}break(e){const t=this._elements;if(!t[this.elementStart])return;let i=Vo(),s=i.textures;s.clear();const n=t[this.elementStart];let o=ys(n.blendMode,n.texture._source),a=n.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const h=this.attributeBuffer.float32View,l=this.attributeBuffer.uint32View,c=this.indexBuffer;let d=this._batchIndexSize,u=this._batchIndexStart,p="startBatch",f=[];const y=this.maxTextures;for(let m=this.elementStart;m<this.elementSize;++m){const x=t[m];t[m]=null;const v=x.texture._source,b=ys(x.blendMode,v),P=o!==b||a!==x.topology;if(v._batchTick===gi&&!P){x._textureId=v._textureBindLocation,d+=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,f.push(x);continue}v._batchTick=gi,(s.count>=y||P)&&(this._finishBatch(i,u,d-u,s,o,a,e,p,f),p="renderBatch",u=d,o=b,a=x.topology,i=Vo(),s=i.textures,s.clear(),f=[],++gi),x._textureId=v._textureBindLocation=s.count,s.ids[v.uid]=s.count,s.textures[s.count++]=v,x._batch=i,f.push(x),d+=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))}s.count>0&&(this._finishBatch(i,u,d-u,s,o,a,e,p,f),u=d,++gi),this.elementStart=this.elementSize,this._batchIndexStart=u,this._batchIndexSize=d}_finishBatch(e,t,i,s,n,o,a,h,l){e.gpuBindGroup=null,e.bindGroup=null,e.action=h,e.batcher=this,e.textures=s,e.blendMode=n,e.topology=o,e.start=t,e.size=i,e.elements=l,++gi,this.batches[this.batchIndex++]=e,a.add(e)}finish(e){this.break(e)}ensureAttributeBuffer(e){e*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(e*4)}ensureIndexBuffer(e){e<=this.indexBuffer.length||this._resizeIndexBuffer(e)}_resizeAttributeBuffer(e){const t=Math.max(e,this.attributeBuffer.size*2),i=new Uo(t);Ho(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(e){const t=this.indexBuffer;let i=Math.max(e,t.length*1.5);i+=i%2;const s=i>65535?new Uint32Array(i):new Uint16Array(i);if(s.BYTES_PER_ELEMENT!==t.BYTES_PER_ELEMENT)for(let n=0;n<t.length;n++)s[n]=t[n];else Ho(t.buffer,s.buffer);this.indexBuffer=s}packQuadIndex(e,t,i){e[t]=i+0,e[t+1]=i+1,e[t+2]=i+2,e[t+3]=i+0,e[t+4]=i+2,e[t+5]=i+3}packIndex(e,t,i,s){const n=e.indices,o=e.indexSize,a=e.indexOffset,h=e.attributeOffset;for(let l=0;l<o;l++)t[i++]=s+n[l+a]-h}destroy(e={}){var t;if(this.batches!==null){for(let i=0;i<this.batchIndex;i++)No(this.batches[i]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,e.shader&&((t=this.shader)==null||t.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}}};ol.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Xp=ol;var ft=(r=>(r[r.MAP_READ=1]="MAP_READ",r[r.MAP_WRITE=2]="MAP_WRITE",r[r.COPY_SRC=4]="COPY_SRC",r[r.COPY_DST=8]="COPY_DST",r[r.INDEX=16]="INDEX",r[r.VERTEX=32]="VERTEX",r[r.UNIFORM=64]="UNIFORM",r[r.STORAGE=128]="STORAGE",r[r.INDIRECT=256]="INDIRECT",r[r.QUERY_RESOLVE=512]="QUERY_RESOLVE",r[r.STATIC=1024]="STATIC",r))(ft||{});class he extends Yt{constructor(e){let{data:t,size:i}=e;const{usage:s,label:n,shrinkToFit:o}=e;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=dt("buffer"),this._resourceType="buffer",this._resourceId=dt("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,t instanceof Array&&(t=new Float32Array(t)),this._data=t,i??(i=t==null?void 0:t.byteLength);const a=!!t;this.descriptor={size:i,usage:s,mappedAtCreation:a,label:n},this.shrinkToFit=o??!0}get data(){return this._data}set data(e){this.setDataWithSize(e,e.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&ft.STATIC)}set static(e){e?this.descriptor.usage|=ft.STATIC:this.descriptor.usage&=~ft.STATIC}setDataWithSize(e,t,i){if(this._updateID++,this._updateSize=t*e.BYTES_PER_ELEMENT,this._data===e){i&&this.emit("update",this);return}const s=this._data;if(this._data=e,this._dataInt32=null,!s||s.length!==e.length){!this.shrinkToFit&&s&&e.byteLength<s.byteLength?i&&this.emit("update",this):(this.descriptor.size=e.byteLength,this._resourceId=dt("resource"),this.emit("change",this));return}i&&this.emit("update",this)}update(e){this._updateSize=e??this._updateSize,this._updateID++,this.emit("update",this)}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.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 hl(r,e){if(!(r instanceof he)){let t=e?ft.INDEX:ft.VERTEX;r instanceof Array&&(e?(r=new Uint32Array(r),t=ft.INDEX|ft.COPY_DST):(r=new Float32Array(r),t=ft.VERTEX|ft.COPY_DST)),r=new he({data:r,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:t})}return r}function Zp(r,e,t){const i=r.getAttribute(e);if(!i)return t.minX=0,t.minY=0,t.maxX=0,t.maxY=0,t;const s=i.buffer.data;let n=1/0,o=1/0,a=-1/0,h=-1/0;const l=s.BYTES_PER_ELEMENT,c=(i.offset||0)/l,d=(i.stride||2*4)/l;for(let u=c;u<s.length;u+=d){const p=s[u],f=s[u+1];p>a&&(a=p),f>h&&(h=f),p<n&&(n=p),f<o&&(o=f)}return t.minX=n,t.minY=o,t.maxX=a,t.maxY=h,t}function qp(r){return(r instanceof he||Array.isArray(r)||r.BYTES_PER_ELEMENT)&&(r={buffer:r}),r.buffer=hl(r.buffer,!1),r}class Gi extends Yt{constructor(e={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=dt("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new Bt,this._boundsDirty=!0;const{attributes:t,indexBuffer:i,topology:s}=e;if(this.buffers=[],this.attributes={},t)for(const n in t)this.addAttribute(n,t[n]);this.instanceCount=e.instanceCount??1,i&&this.addIndex(i),this.topology=s||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(e){return this.attributes[e]}getIndex(){return this.indexBuffer}getBuffer(e){return this.getAttribute(e).buffer}getSize(){for(const e in this.attributes){const t=this.attributes[e];return t.buffer.data.length/(t.stride/4||t.size)}return 0}addAttribute(e,t){const i=qp(t);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[e]=i}addIndex(e){this.indexBuffer=hl(e,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Zp(this,"aPosition",this._bounds)):this._bounds}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.destroy();this._gpuData=Object.create(null)}destroy(e=!1){var t;this.emit("destroy",this),this.removeAllListeners(),e&&this.buffers.forEach(i=>i.destroy()),this.unload(),(t=this.indexBuffer)==null||t.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Kp=new Float32Array(1),$p=new Uint32Array(1);class Qp extends Gi{constructor(){const t=new he({data:Kp,label:"attribute-batch-buffer",usage:ft.VERTEX|ft.COPY_DST,shrinkToFit:!1}),i=new he({data:$p,label:"index-batch-buffer",usage:ft.INDEX|ft.COPY_DST,shrinkToFit:!1}),s=6*4;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:s,offset:0},aUV:{buffer:t,format:"float32x2",stride:s,offset:2*4},aColor:{buffer:t,format:"unorm8x4",stride:s,offset:4*4},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:s,offset:5*4}},indexBuffer:i})}}function jo(r,e,t){if(r)for(const i in r){const s=i.toLocaleLowerCase(),n=e[s];if(n){let o=r[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),t&&n.push(`//----${t}----//`),n.push(o)}else nt(`${i} placement hook does not exist in shader`)}}const Jp=/\{\{(.*?)\}\}/g;function Yo(r){var i;const e={};return(((i=r.match(Jp))==null?void 0:i.map(s=>s.replace(/[{()}]/g,"")))??[]).forEach(s=>{e[s]=[]}),e}function Xo(r,e){let t;const i=/@in\s+([^;]+);/g;for(;(t=i.exec(r))!==null;)e.push(t[1])}function Zo(r,e,t=!1){const i=[];Xo(e,i),r.forEach(a=>{a.header&&Xo(a.header,i)});const s=i;t&&s.sort();const n=s.map((a,h)=>` @location(${h}) ${a},`).join(`
|
|
20
|
+
`}function du(r,e,t){const i=t?e.maxSupportedFragmentPrecision:e.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let s=t?e.requestedFragmentPrecision:e.requestedVertexPrecision;return s==="highp"&&i!=="highp"&&(s="mediump"),`precision ${s} float;
|
|
21
|
+
${r}`}else if(i!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function uu(r,e){return e?`#version 300 es
|
|
22
|
+
${r}`:r}const pu={},fu={};function gu(r,{name:e="pixi-program"},t=!0){e=e.replace(/\s+/g,"-"),e+=t?"-fragment":"-vertex";const i=t?pu:fu;return i[e]?(i[e]++,e+=`-${i[e]}`):i[e]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${e}`}
|
|
23
|
+
${r}`}function mu(r,e){return e?r.replace("#version 300 es",""):r}const nn={stripVersion:mu,ensurePrecision:du,addProgramDefines:cu,setProgramName:gu,insertVersion:uu},ui=Object.create(null),Fh=class Wn{constructor(e){e={...Wn.defaultOptions,...e};const t=e.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:t,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:lu()},setProgramName:{name:e.name},addProgramDefines:t,insertVersion:t};let s=e.fragment,n=e.vertex;Object.keys(nn).forEach(o=>{const a=i[o];s=nn[o](s,a,!0),n=nn[o](n,a,!1)}),this.fragment=s,this.vertex=n,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=mr(`${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,ui[this._cacheKey]=null}static from(e){const t=`${e.vertex}:${e.fragment}`;return ui[t]||(ui[t]=new Wn(e),ui[t]._cacheKey=t),ui[t]}};Fh.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let si=Fh;const Eo={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 yu(r){return Eo[r]??Eo.float32}const xu={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"},Io=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function Bo(r,e){let t;for(;(t=Io.exec(r))!==null;){const i=xu[t[3]]??"float32";e[t[2]]={location:parseInt(t[1],10),format:i,stride:yu(i).stride,offset:0,instance:!1,start:0}}Io.lastIndex=0}function Su(r){return r.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function vu({source:r,entryPoint:e}){const t={},i=Su(r),s=i.indexOf(`fn ${e}(`);if(s===-1)return t;const n=i.indexOf("->",s);if(n===-1)return t;const o=i.substring(s,n);if(Bo(o,t),Object.keys(t).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&&Bo(c[1],t)}}return t}function rn(r){var d,u;const e=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,t=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,s=/var(<[^>]+>)? (\w+)/,n=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(d=r.match(e))==null?void 0:d.map(p=>({group:parseInt(p.match(t)[1],10),binding:parseInt(p.match(i)[1],10),name:p.match(s)[2],isUniform:p.match(s)[1]==="<uniform>",type:p.match(n)[1]}));if(!l)return{groups:[],structs:[]};const c=((u=r.match(o))==null?void 0:u.map(p=>{const f=p.match(h)[1],y=p.match(a).reduce((m,x)=>{const[S,v]=x.split(":");return m[S.trim()]=v.trim(),m},{});return y?{name:f,members:y}:null}).filter(({name:p})=>l.some(f=>f.type===p||f.type.includes(`<${p}>`))))??[];return{groups:l,structs:c}}var Ae=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(Ae||{});function bu({groups:r}){const e=[];for(let t=0;t<r.length;t++){const i=r[t];e[i.group]||(e[i.group]=[]),i.isUniform?e[i.group].push({binding:i.binding,visibility:Ae.VERTEX|Ae.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?e[i.group].push({binding:i.binding,visibility:Ae.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"||i.type.startsWith("texture_2d<")?e[i.group].push({binding:i.binding,visibility:Ae.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):i.type==="texture_2d_array"||i.type.startsWith("texture_2d_array<")?e[i.group].push({binding:i.binding,visibility:Ae.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(i.type==="texture_cube"||i.type.startsWith("texture_cube<"))&&e[i.group].push({binding:i.binding,visibility:Ae.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let t=0;t<e.length;t++)e[t]||(e[t]=[]);return e}function wu({groups:r}){const e=[];for(let t=0;t<r.length;t++){const i=r[t];e[i.group]||(e[i.group]={}),e[i.group][i.name]=i.binding}return e}function Cu(r,e){const t=new Set,i=new Set,s=[...r.structs,...e.structs].filter(o=>t.has(o.name)?!1:(t.add(o.name),!0)),n=[...r.groups,...e.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:s,groups:n}}const pi=Object.create(null);class le{constructor(e){var a,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:t,vertex:i,layout:s,gpuLayout:n,name:o}=e;if(this.name=o,this.fragment=t,this.vertex=i,t.source===i.source){const l=rn(t.source);this.structsAndGroups=l}else{const l=rn(i.source),c=rn(t.source);this.structsAndGroups=Cu(l,c)}this.layout=s??wu(this.structsAndGroups),this.gpuLayout=n??bu(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:e,fragment:t}=this,i=e.source+t.source+e.entryPoint+t.entryPoint;this._layoutKey=mr(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=vu(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,pi[this._cacheKey]=null}static from(e){const t=`${e.vertex.source}:${e.fragment.source}:${e.fragment.entryPoint}:${e.vertex.entryPoint}`;return pi[t]||(pi[t]=new le(e),pi[t]._cacheKey=t),pi[t]}}const zh=["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>"],Au=zh.reduce((r,e)=>(r[e]=!0,r),{});function Pu(r,e){switch(r){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*e);case"vec3<f32>":return new Float32Array(3*e);case"vec4<f32>":return new Float32Array(4*e);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 Lh=class Oh{constructor(e,t){this._touched=0,this.uid=dt("uniform"),this._resourceType="uniformGroup",this._resourceId=dt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,t={...Oh.defaultOptions,...t},this.uniformStructures=e;const i={};for(const s in e){const n=e[s];if(n.name=s,n.size=n.size??1,!Au[n.type]){const o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,h]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${h} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${zh.join(", ")}`)}n.value??(n.value=Pu(n.type,n.size)),i[s]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=t.ubo,this.isStatic=t.isStatic,this._signature=mr(Object.keys(i).map(s=>`${s}-${e[s].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Lh.defaultOptions={ubo:!1,isStatic:!1};let ni=Lh;class _i{constructor(e){this.resources=Object.create(null),this._dirty=!0;let t=0;for(const i in e){const s=e[i];this.setResource(s,t++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const e=[];let t=0;for(const i in this.resources)e[t++]=this.resources[i]._resourceId;this._key=e.join("|")}setResource(e,t){var s,n;const i=this.resources[t];e!==i&&(i&&((s=i.off)==null||s.call(i,"change",this.onResourceChange,this)),(n=e.on)==null||n.call(e,"change",this.onResourceChange,this),this.resources[t]=e,this._dirty=!0)}getResource(e){return this.resources[e]}_touch(e,t){const i=this.resources;for(const s in i)i[s]._gcLastUsed=e,i[s]._touched=t}destroy(){var t;const e=this.resources;for(const i in e){const s=e[i];(t=s==null?void 0:s.off)==null||t.call(s,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(e){if(this._dirty=!0,e.destroyed){const t=this.resources;for(const i in t)t[i]===e&&(t[i]=null)}else this._updateKey()}}var Fi=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.CANVAS=4]="CANVAS",r[r.BOTH=3]="BOTH",r))(Fi||{});class Be extends Yt{constructor(e){super(),this.uid=dt("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:t,glProgram:i,groups:s,resources:n,compatibleRenderers:o,groupMap:a}=e;this.gpuProgram=t,this.glProgram=i,o===void 0&&(o=0,t&&(o|=Fi.WEBGPU),i&&(o|=Fi.WEBGL)),this.compatibleRenderers=o;const h={};if(!n&&!s&&(n={}),n&&s)throw new Error("[Shader] Cannot have both resources and groups");if(!t&&s&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!t&&s&&a)for(const l in a)for(const c in a[l]){const d=a[l][c];h[d]={group:l,binding:c,name:d}}else if(t&&s&&!a){const l=t.structsAndGroups.groups;a={},l.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,h[c.name]=c})}else if(n){s={},a={},t&&t.structsAndGroups.groups.forEach(d=>{a[d.group]=a[d.group]||{},a[d.group][d.binding]=d.name,h[d.name]=d});let l=0;for(const c in n)h[c]||(s[99]||(s[99]=new _i,this._ownedBindGroups.push(s[99])),h[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++);for(const c in n){const d=c;let u=n[c];!u.source&&!u._resourceType&&(u=new ni(u));const p=h[d];p&&(s[p.group]||(s[p.group]=new _i,this._ownedBindGroups.push(s[p.group])),s[p.group].setResource(u,p.binding))}}this.groups=s,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(s,h)}addResource(e,t,i){var s,n;(s=this._uniformBindMap)[t]||(s[t]={}),(n=this._uniformBindMap[t])[i]||(n[i]=e),this.groups[t]||(this.groups[t]=new _i,this._ownedBindGroups.push(this.groups[t]))}_buildResourceAccessor(e,t){const i={};for(const s in t){const n=t[s];Object.defineProperty(i,n.name,{get(){return e[n.group].getResource(n.binding)},set(o){e[n.group].setResource(o,n.binding)}})}return i}destroy(e=!1){var t,i;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),e&&((t=this.gpuProgram)==null||t.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(s=>{s.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(e){const{gpu:t,gl:i,...s}=e;let n,o;return t&&(n=le.from(t)),i&&(o=si.from(i)),new Be({gpuProgram:n,glProgram:o,...s})}}const Mu={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},on=0,an=1,hn=2,ln=3,cn=4,dn=5,Gn=class Wh{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<on)}set blend(e){!!(this.data&1<<on)!==e&&(this.data^=1<<on)}get offsets(){return!!(this.data&1<<an)}set offsets(e){!!(this.data&1<<an)!==e&&(this.data^=1<<an)}set cullMode(e){if(e==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=e==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<hn)}set culling(e){!!(this.data&1<<hn)!==e&&(this.data^=1<<hn)}get depthTest(){return!!(this.data&1<<ln)}set depthTest(e){!!(this.data&1<<ln)!==e&&(this.data^=1<<ln)}get depthMask(){return!!(this.data&1<<dn)}set depthMask(e){!!(this.data&1<<dn)!==e&&(this.data^=1<<dn)}get clockwiseFrontFace(){return!!(this.data&1<<cn)}set clockwiseFrontFace(e){!!(this.data&1<<cn)!==e&&(this.data^=1<<cn)}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!=="none",this._blendMode=e,this._blendModeId=Mu[e]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const e=new Wh;return e.depthTest=!1,e.blend=!0,e}};Gn.default2d=Gn.for2d();let Vi=Gn;const Gh=class Un extends Be{constructor(e){e={...Un.defaultOptions,...e},super(e),this.enabled=!0,this._state=Vi.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1),e.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,i,s){e.applyFilter(this,t,i,s)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:i,...s}=e;let n,o;return t&&(n=le.from(t)),i&&(o=si.from(i)),new Un({gpuProgram:n,glProgram:o,...s})}};Gh.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let _u=Gh;const Hn=[];$.handleByNamedList(I.Environment,Hn);async function Tu(r){if(!r)for(let e=0;e<Hn.length;e++){const t=Hn[e];if(t.value.test()){await t.value.load();return}}}let fi;function ku(){if(typeof fi=="boolean")return fi;try{fi=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{fi=!1}return fi}function Do(r,e,t=2){const i=e&&e.length,s=i?e[0]*t:r.length;let n=Uh(r,0,s,t,!0);const o=[];if(!n||n.next===n.prev)return o;let a,h,l;if(i&&(n=Du(r,e,n,t)),r.length>80*t){a=r[0],h=r[1];let c=a,d=h;for(let u=t;u<s;u+=t){const p=r[u],f=r[u+1];p<a&&(a=p),f<h&&(h=f),p>c&&(c=p),f>d&&(d=f)}l=Math.max(c-a,d-h),l=l!==0?32767/l:0}return zi(n,o,t,a,h,l,0),o}function Uh(r,e,t,i,s){let n;if(s===ju(r,e,t,i)>0)for(let o=e;o<t;o+=i)n=Fo(o/i|0,r[o],r[o+1],n);else for(let o=t-i;o>=e;o-=i)n=Fo(o/i|0,r[o],r[o+1],n);return n&&ri(n,n.next)&&(Oi(n),n=n.next),n}function De(r,e){if(!r)return r;e||(e=r);let t=r,i;do if(i=!1,!t.steiner&&(ri(t,t.next)||at(t.prev,t,t.next)===0)){if(Oi(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function zi(r,e,t,i,s,n,o){if(!r)return;!o&&n&&Wu(r,i,s,n);let a=r;for(;r.prev!==r.next;){const h=r.prev,l=r.next;if(n?Eu(r,i,s,n):Ru(r)){e.push(h.i,r.i,l.i),Oi(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=Iu(De(r),e),zi(r,e,t,i,s,n,2)):o===2&&Bu(r,e,t,i,s,n):zi(De(r),e,t,i,s,n,1);break}}}function Ru(r){const e=r.prev,t=r,i=r.next;if(at(e,t,i)>=0)return!1;const s=e.x,n=t.x,o=i.x,a=e.y,h=t.y,l=i.y,c=Math.min(s,n,o),d=Math.min(a,h,l),u=Math.max(s,n,o),p=Math.max(a,h,l);let f=i.next;for(;f!==e;){if(f.x>=c&&f.x<=u&&f.y>=d&&f.y<=p&&Ci(s,a,n,h,o,l,f.x,f.y)&&at(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Eu(r,e,t,i){const s=r.prev,n=r,o=r.next;if(at(s,n,o)>=0)return!1;const a=s.x,h=n.x,l=o.x,c=s.y,d=n.y,u=o.y,p=Math.min(a,h,l),f=Math.min(c,d,u),y=Math.max(a,h,l),m=Math.max(c,d,u),x=Vn(p,f,e,t,i),S=Vn(y,m,e,t,i);let v=r.prevZ,b=r.nextZ;for(;v&&v.z>=x&&b&&b.z<=S;){if(v.x>=p&&v.x<=y&&v.y>=f&&v.y<=m&&v!==s&&v!==o&&Ci(a,c,h,d,l,u,v.x,v.y)&&at(v.prev,v,v.next)>=0||(v=v.prevZ,b.x>=p&&b.x<=y&&b.y>=f&&b.y<=m&&b!==s&&b!==o&&Ci(a,c,h,d,l,u,b.x,b.y)&&at(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=x;){if(v.x>=p&&v.x<=y&&v.y>=f&&v.y<=m&&v!==s&&v!==o&&Ci(a,c,h,d,l,u,v.x,v.y)&&at(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=S;){if(b.x>=p&&b.x<=y&&b.y>=f&&b.y<=m&&b!==s&&b!==o&&Ci(a,c,h,d,l,u,b.x,b.y)&&at(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Iu(r,e){let t=r;do{const i=t.prev,s=t.next.next;!ri(i,s)&&Vh(i,t,t.next,s)&&Li(i,s)&&Li(s,i)&&(e.push(i.i,t.i,s.i),Oi(t),Oi(t.next),t=r=s),t=t.next}while(t!==r);return De(t)}function Bu(r,e,t,i,s,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Hu(o,a)){let h=Nh(o,a);o=De(o,o.next),h=De(h,h.next),zi(o,e,t,i,s,n,0),zi(h,e,t,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function Du(r,e,t,i){const s=[];for(let n=0,o=e.length;n<o;n++){const a=e[n]*i,h=n<o-1?e[n+1]*i:r.length,l=Uh(r,a,h,i,!1);l===l.next&&(l.steiner=!0),s.push(Uu(l))}s.sort(Fu);for(let n=0;n<s.length;n++)t=zu(s[n],t);return t}function Fu(r,e){let t=r.x-e.x;if(t===0&&(t=r.y-e.y,t===0)){const i=(r.next.y-r.y)/(r.next.x-r.x),s=(e.next.y-e.y)/(e.next.x-e.x);t=i-s}return t}function zu(r,e){const t=Lu(r,e);if(!t)return e;const i=Nh(t,r);return De(i,i.next),De(t,t.next)}function Lu(r,e){let t=e;const i=r.x,s=r.y;let n=-1/0,o;if(ri(r,t))return t;do{if(ri(r,t.next))return t.next;if(s<=t.y&&s>=t.next.y&&t.next.y!==t.y){const d=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>n&&(n=d,o=t.x<t.next.x?t:t.next,d===i))return o}t=t.next}while(t!==e);if(!o)return null;const a=o,h=o.x,l=o.y;let c=1/0;t=o;do{if(i>=t.x&&t.x>=h&&i!==t.x&&Hh(s<l?i:n,s,h,l,s<l?n:i,s,t.x,t.y)){const d=Math.abs(s-t.y)/(i-t.x);Li(t,r)&&(d<c||d===c&&(t.x>o.x||t.x===o.x&&Ou(o,t)))&&(o=t,c=d)}t=t.next}while(t!==a);return o}function Ou(r,e){return at(r.prev,r,e.prev)<0&&at(e.next,r,r.next)<0}function Wu(r,e,t,i){let s=r;do s.z===0&&(s.z=Vn(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,Gu(s)}function Gu(r){let e,t=1;do{let i=r,s;r=null;let n=null;for(e=0;i;){e++;let o=i,a=0;for(let l=0;l<t&&(a++,o=o.nextZ,!!o);l++);let h=t;for(;a>0||h>0&&o;)a!==0&&(h===0||!o||i.z<=o.z)?(s=i,i=i.nextZ,a--):(s=o,o=o.nextZ,h--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;i=o}n.nextZ=null,t*=2}while(e>1);return r}function Vn(r,e,t,i,s){return r=(r-t)*s|0,e=(e-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function Uu(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function Hh(r,e,t,i,s,n,o,a){return(s-o)*(e-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(n-a)>=(s-o)*(i-a)}function Ci(r,e,t,i,s,n,o,a){return!(r===o&&e===a)&&Hh(r,e,t,i,s,n,o,a)}function Hu(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!Vu(r,e)&&(Li(r,e)&&Li(e,r)&&Nu(r,e)&&(at(r.prev,r,e.prev)||at(r,e.prev,e))||ri(r,e)&&at(r.prev,r,r.next)>0&&at(e.prev,e,e.next)>0)}function at(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function ri(r,e){return r.x===e.x&&r.y===e.y}function Vh(r,e,t,i){const s=ns(at(r,e,t)),n=ns(at(r,e,i)),o=ns(at(t,i,r)),a=ns(at(t,i,e));return!!(s!==n&&o!==a||s===0&&ss(r,t,e)||n===0&&ss(r,i,e)||o===0&&ss(t,r,i)||a===0&&ss(t,e,i))}function ss(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function ns(r){return r>0?1:r<0?-1:0}function Vu(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Vh(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Li(r,e){return at(r.prev,r,r.next)<0?at(r,e,r.next)>=0&&at(r,r.prev,e)>=0:at(r,e,r.prev)<0||at(r,r.next,e)<0}function Nu(r,e){let t=r,i=!1;const s=(r.x+e.x)/2,n=(r.y+e.y)/2;do t.y>n!=t.next.y>n&&t.next.y!==t.y&&s<(t.next.x-t.x)*(n-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==r);return i}function Nh(r,e){const t=Nn(r.i,r.x,r.y),i=Nn(e.i,e.x,e.y),s=r.next,n=e.prev;return r.next=e,e.prev=r,t.next=s,s.prev=t,i.next=t,t.prev=i,n.next=i,i.prev=n,i}function Fo(r,e,t,i){const s=Nn(r,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Oi(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Nn(r,e,t){return{i:r,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function ju(r,e,t,i){let s=0;for(let n=e,o=t-i;n<t;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}const Yu=Do.default||Do;var jh=(r=>(r[r.NONE=0]="NONE",r[r.COLOR=16384]="COLOR",r[r.STENCIL=1024]="STENCIL",r[r.DEPTH=256]="DEPTH",r[r.COLOR_DEPTH=16640]="COLOR_DEPTH",r[r.COLOR_STENCIL=17408]="COLOR_STENCIL",r[r.DEPTH_STENCIL=1280]="DEPTH_STENCIL",r[r.ALL=17664]="ALL",r))(jh||{});class Xu{constructor(e){this.items=[],this._name=e}emit(e,t,i,s,n,o,a,h){const{name:l,items:c}=this;for(let d=0,u=c.length;d<u;d++)c[d][l](e,t,i,s,n,o,a,h);return this}add(e){return e[this._name]&&(this.remove(e),this.items.push(e)),this}remove(e){const t=this.items.indexOf(e);return t!==-1&&this.items.splice(t,1),this}contains(e){return this.items.indexOf(e)!==-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 Zu=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Yh=class Xh extends Yt{constructor(e){super(),this.tick=0,this.uid=dt("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=e.type,this.name=e.name,this.config=e;const t=[...Zu,...this.config.runners??[]];this._addRunners(...t),this._unsafeEvalCheck()}async init(e={}){const t=e.skipExtensionImports===!0?!0:e.manageImports===!1;await Tu(t),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash)e={...this._systemsHash[i].constructor.defaultOptions,...e};e={...Xh.defaultOptions,...e},this._roundPixels=e.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(e);this._initOptions=e}render(e,t){this.tick++;let i=e;if(i instanceof L&&(i={container:i},t&&(V(J,"passing a second argument is deprecated, please use render options instead"),i.target=t.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 s=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=s?i.clearColor:rt.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(e,t,i){const s=this.view.resolution;this.view.resize(e,t,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==s&&this.runners.resolutionChange.emit(i)}clear(e={}){const t=this;e.target||(e.target=t.renderTarget.renderTarget),e.clearColor||(e.clearColor=this.background.colorRgba),e.clear??(e.clear=jh.ALL);const{clear:i,clearColor:s,target:n,mipLevel:o,layer:a}=e;rt.shared.setValue(s??this.background.colorRgba),t.renderTarget.clear(n,i,rt.shared.toArray(),o??0,a??0)}get resolution(){return this.view.resolution}set resolution(e){this.view.resolution=e,this.runners.resolutionChange.emit(e)}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(...e){e.forEach(t=>{this.runners[t]=new Xu(t)})}_addSystems(e){let t;for(t in e){const i=e[t];this._addSystem(i.value,i.name)}}_addSystem(e,t){const i=new e(this);if(this[t])throw new Error(`Whoops! The name "${t}" is already in use`);this[t]=i,this._systemsHash[t]=i;for(const s in this.runners)this.runners[s].add(i);return this}_addPipes(e,t){const i=t.reduce((s,n)=>(s[n.name]=n.value,s),{});e.forEach(s=>{const n=s.value,o=s.name,a=i[o];this.renderPipes[o]=new n(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(e=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(e),(e===!0||typeof e=="object"&&e.releaseGlobalResources)&&Hi.release(),Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(e){return this.textureGenerator.generateTexture(e)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!ku())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()}};Yh.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Zh=Yh,rs;function qu(r){return rs!==void 0||(rs=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r??Zh.defaultOptions.failIfMajorPerformanceCaveat};try{if(!j.get().getWebGLRenderingContext())return!1;let s=j.get().createCanvas().getContext("webgl",e);const n=!!((t=s==null?void 0:s.getContextAttributes())!=null&&t.stencil);if(s){const o=s.getExtension("WEBGL_lose_context");o&&o.loseContext()}return s=null,n}catch{return!1}})()),rs}let os;async function Ku(r={}){return os!==void 0||(os=await(async()=>{const e=j.get().getNavigator().gpu;if(!e)return!1;try{return await(await e.requestAdapter(r)).requestDevice(),!0}catch{return!1}})()),os}const zo=["webgl","webgpu","canvas"];async function $u(r){let e=[];r.preference?(e.push(r.preference),zo.forEach(n=>{n!==r.preference&&e.push(n)})):e=zo.slice();let t,i={};for(let n=0;n<e.length;n++){const o=e[n];if(o==="webgpu"&&await Ku()){const{WebGPURenderer:a}=await _e(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer.D_v-7q0a.js");return{WebGPURenderer:h}},__vite__mapDeps([5,6,7,2,3,4]));t=a,i={...r,...r.webgpu};break}else if(o==="webgl"&&qu(r.failIfMajorPerformanceCaveat??Zh.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await _e(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer.CHLGFw15.js");return{WebGLRenderer:h}},__vite__mapDeps([8,6,7,2,3,4]));t=a,i={...r,...r.webgl};break}else if(o==="canvas"){const{CanvasRenderer:a}=await _e(async()=>{const{CanvasRenderer:h}=await import("./CanvasRenderer.Ctg0gCbc.js");return{CanvasRenderer:h}},__vite__mapDeps([9,7,2,3,4]));t=a,i={...r,...r.canvasOptions};break}}if(delete i.webgpu,delete i.webgl,delete i.canvasOptions,!t)throw new Error("No available renderer for the current environment");const s=new t;return await s.init(i),s}const qh="8.16.0";class Kh{static init(){var e;(e=globalThis.__PIXI_APP_INIT__)==null||e.call(globalThis,this,qh)}static destroy(){}}Kh.extension=I.Application;class Qu{constructor(e){this._renderer=e}init(){var e;(e=globalThis.__PIXI_RENDERER_INIT__)==null||e.call(globalThis,this._renderer,qh)}destroy(){this._renderer=null}}Qu.extension={type:[I.WebGLSystem,I.WebGPUSystem],name:"initHook",priority:-10};class $h{static init(e){Object.defineProperty(this,"resizeTo",{configurable:!0,set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(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 t,i;if(this._resizeTo===globalThis.window)t=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;t=s,i=n}this.renderer.resize(t,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}$h.extension=I.Application;class Qh{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{configurable:!0,set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,Ie.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?yt.shared:new yt,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}Qh.extension=I.Application;$.add($h);$.add(Qh);const Jh=class jn{constructor(...e){this.stage=new L,e[0]!==void 0&&V(J,"Application constructor options are deprecated, please use Application.init() instead.")}async init(e){e={...e},this.stage||(this.stage=new L),this.renderer=await $u(e),jn._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return V(J,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(e=!1,t=!1){const i=jn._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(t),this.stage=null,this.renderer.destroy(e),this.renderer=null}};Jh._plugins=[];let tl=Jh;$.handleByList(I.Application,tl._plugins);$.add(Kh);const un={test(r){return typeof r=="string"&&r.startsWith("info face=")},parse(r){const e=r.match(/^[a-z]+\s+.+$/gm),t={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const d in e){const u=e[d].match(/^[a-z]+/gm)[0],p=e[d].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),f={};for(const y in p){const m=p[y].split("="),x=m[0],S=m[1].replace(/"/gm,""),v=parseFloat(S),b=isNaN(v)?S:v;f[x]=b}t[u].push(f)}const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[s]=t.info,[n]=t.common,[o]=t.distanceField??[];o&&(i.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),i.fontSize=parseInt(s.size,10),i.fontFamily=s.face,i.lineHeight=parseInt(n.lineHeight,10);const a=t.page;for(let d=0;d<a.length;d++)i.pages.push({id:parseInt(a[d].id,10)||0,file:a[d].file});const h={};i.baseLineOffset=i.lineHeight-parseInt(n.base,10);const l=t.char;for(let d=0;d<l.length;d++){const u=l[d],p=parseInt(u.id,10);let f=u.letter??u.char??String.fromCharCode(p);f==="space"&&(f=" "),h[p]=f,i.chars[f]={id:p,page:parseInt(u.page,10)||0,x:parseInt(u.x,10),y:parseInt(u.y,10),width:parseInt(u.width,10),height:parseInt(u.height,10),xOffset:parseInt(u.xoffset,10),yOffset:parseInt(u.yoffset,10),xAdvance:parseInt(u.xadvance,10),kerning:{}}}const c=t.kerning||[];for(let d=0;d<c.length;d++){const u=parseInt(c[d].first,10),p=parseInt(c[d].second,10),f=parseInt(c[d].amount,10);i.chars[h[p]].kerning[h[u]]=f}return i}},Lo={test(r){const e=r;return typeof e!="string"&&"getElementsByTagName"in e&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(r){const e={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},t=r.getElementsByTagName("info")[0],i=r.getElementsByTagName("common")[0],s=r.getElementsByTagName("distanceField")[0];s&&(e.distanceField={type:s.getAttribute("fieldType"),range:parseInt(s.getAttribute("distanceRange"),10)});const n=r.getElementsByTagName("page"),o=r.getElementsByTagName("char"),a=r.getElementsByTagName("kerning");e.fontSize=parseInt(t.getAttribute("size"),10),e.fontFamily=t.getAttribute("face"),e.lineHeight=parseInt(i.getAttribute("lineHeight"),10);for(let l=0;l<n.length;l++)e.pages.push({id:parseInt(n[l].getAttribute("id"),10)||0,file:n[l].getAttribute("file")});const h={};e.baseLineOffset=e.lineHeight-parseInt(i.getAttribute("base"),10);for(let l=0;l<o.length;l++){const c=o[l],d=parseInt(c.getAttribute("id"),10);let u=c.getAttribute("letter")??c.getAttribute("char")??String.fromCharCode(d);u==="space"&&(u=" "),h[d]=u,e.chars[u]={id:d,page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xOffset:parseInt(c.getAttribute("xoffset"),10),yOffset:parseInt(c.getAttribute("yoffset"),10),xAdvance:parseInt(c.getAttribute("xadvance"),10),kerning:{}}}for(let l=0;l<a.length;l++){const c=parseInt(a[l].getAttribute("first"),10),d=parseInt(a[l].getAttribute("second"),10),u=parseInt(a[l].getAttribute("amount"),10);e.chars[h[d]].kerning[h[c]]=u}return e}},Oo={test(r){return typeof r=="string"&&r.match(/<font(\s|>)/)?Lo.test(j.get().parseXML(r)):!1},parse(r){return Lo.parse(j.get().parseXML(r))}},Ju=[".xml",".fnt"],tp={extension:{type:I.CacheParser,name:"cacheBitmapFont"},test:r=>!!(r!=null&&r.pages)&&!!(r!=null&&r.chars)&&typeof(r==null?void 0:r.fontFamily)=="string",getCacheableAssets(r,e){const t={};return r.forEach(i=>{t[i]=e,t[`${i}-bitmap`]=e}),t[`${e.fontFamily}-bitmap`]=e,t}},ep={extension:{type:I.LoadParser,priority:ue.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return Ju.includes(Mt.extname(r).toLowerCase())},async testParse(r){return un.test(r)||Oo.test(r)},async parse(r,e,t){const i=un.test(r)?un.parse(r):Oo.parse(r),{src:s}=e,{pages:n}=i,o=[],a=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let u=0;u<n.length;++u){const p=n[u].file;let f=Mt.join(Mt.dirname(s),p);f=Ln(f,s),o.push({src:f,data:a})}const[h,{BitmapFont:l}]=await Promise.all([t.load(o),_e(()=>import("./BitmapFont.Cpozytzm.js"),__vite__mapDeps([10,2,3,4]))]),c=o.map(u=>h[u.src]);return new l({data:i,textures:c},s)},async load(r,e){return await(await j.get().fetch(r)).text()},async unload(r,e,t){await Promise.all(r.pages.map(i=>t.unload(i.texture.source._sourceOrigin))),r.destroy()}};class ip{constructor(e,t=!1){this._loader=e,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=t}add(e){e.forEach(t=>{this._assetList.push(t)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const e=[],t=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<t;i++)e.push(this._assetList.pop());await this._loader.load(e),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(e){this._isActive!==e&&(this._isActive=e,e&&!this._isLoading&&this._next())}}const sp={extension:{type:I.CacheParser,name:"cacheTextureArray"},test:r=>Array.isArray(r)&&r.every(e=>e instanceof W),getCacheableAssets:(r,e)=>{const t={};return r.forEach(i=>{e.forEach((s,n)=>{t[i+(n===0?"":n+1)]=s})}),t}};async function el(r){if("Image"in globalThis)return new Promise(e=>{const t=new Image;t.onload=()=>{e(!0)},t.onerror=()=>{e(!1)},t.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const e=await(await fetch(r)).blob();await createImageBitmap(e)}catch{return!1}return!0}return!1}const np={extension:{type:I.DetectionParser,priority:1},test:async()=>el("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(e=>e!=="avif")},Wo=["png","jpg","jpeg"],rp={extension:{type:I.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Wo],remove:async r=>r.filter(e=>!Wo.includes(e))},op="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function ks(r){return op?!1:document.createElement("video").canPlayType(r)!==""}const ap={extension:{type:I.DetectionParser,priority:0},test:async()=>ks("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(e=>e!=="mp4"&&e!=="m4v")},hp={extension:{type:I.DetectionParser,priority:0},test:async()=>ks("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(e=>e!=="ogv")},lp={extension:{type:I.DetectionParser,priority:0},test:async()=>ks("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(e=>e!=="webm")},cp={extension:{type:I.DetectionParser,priority:0},test:async()=>el("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(e=>e!=="webp")},il=class us{constructor(){this.loadOptions={...us.defaultOptions},this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(e,t,i)=>(this._parsersValidated=!1,e[t]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(e,t){const i={promise:null,parser:null};return i.promise=(async()=>{var o,a;let s=null,n=null;if((t.parser||t.loadParser)&&(n=this._parserHash[t.parser||t.loadParser],t.loadParser&&nt(`[Assets] "loadParser" is deprecated, use "parser" instead for ${e}`),n||nt(`[Assets] specified load parser "${t.parser||t.loadParser}" not found while loading ${e}`)),!n){for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.load&&((o=l.test)!=null&&o.call(l,e,t,this))){n=l;break}}if(!n)return nt(`[Assets] ${e} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(e,t,this),i.parser=n;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];l.parse&&l.parse&&await((a=l.testParse)==null?void 0:a.call(l,s,t,this))&&(s=await l.parse(s,t,this)||s,i.parser=l)}return s})(),i}async load(e,t){this._parsersValidated||this._validateParsers();const i=typeof t=="function"?{...us.defaultOptions,...this.loadOptions,onProgress:t}:{...us.defaultOptions,...this.loadOptions,...t||{}},{onProgress:s,onError:n,strategy:o,retryCount:a,retryDelay:h}=i;let l=0;const c={},d=ms(e),u=zt(e,y=>({alias:[y],src:y,data:{}})),p=u.reduce((y,m)=>y+(m.progressSize||1),0),f=u.map(async y=>{const m=Mt.toAbsolute(y.src);c[y.src]||(await this._loadAssetWithRetry(m,y,{onProgress:s,onError:n,strategy:o,retryCount:a,retryDelay:h},c),l+=y.progressSize||1,s&&s(l/p))});return await Promise.all(f),d?c[u[0].src]:c}async unload(e){const i=zt(e,s=>({alias:[s],src:s})).map(async s=>{var a,h;const n=Mt.toAbsolute(s.src),o=this.promiseCache[n];if(o){const l=await o.promise;delete this.promiseCache[n],await((h=(a=o.parser)==null?void 0:a.unload)==null?void 0:h.call(a,l,s,this))}});await Promise.all(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(e=>e.name||e.id).reduce((e,t)=>(!t.name&&!t.id?nt("[Assets] parser should have an id"):(e[t.name]||e[t.id])&&nt(`[Assets] parser id conflict "${t.id}"`),e[t.name]=t,t.id&&(e[t.id]=t),e),{})}async _loadAssetWithRetry(e,t,i,s){let n=0;const{onError:o,strategy:a,retryCount:h,retryDelay:l}=i,c=d=>new Promise(u=>setTimeout(u,d));for(;;)try{this.promiseCache[e]||(this.promiseCache[e]=this._getLoadPromiseAndParser(e,t)),s[t.src]=await this.promiseCache[e].promise;return}catch(d){delete this.promiseCache[e],delete s[t.src],n++;const u=a!=="retry"||n>h;if(a==="retry"&&!u){o&&o(d,t),await c(l);continue}if(a==="skip"){o&&o(d,t);return}o&&o(d,t);const p=new Error(`[Loader.load] Failed to load ${e}.
|
|
24
|
+
${d}`);throw d instanceof Error&&d.stack&&(p.stack=d.stack),p}}};il.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let dp=il;function pe(r,e){if(Array.isArray(e)){for(const t of e)if(r.startsWith(`data:${t}`))return!0;return!1}return r.startsWith(`data:${e}`)}function li(r,e){const t=r.split("?")[0],i=Mt.extname(t).toLowerCase();return Array.isArray(e)?e.includes(i):i===e}const up=".json",pp="application/json",fp={extension:{type:I.LoadParser,priority:ue.Low},name:"loadJson",id:"json",test(r){return pe(r,pp)||li(r,up)},async load(r){return await(await j.get().fetch(r)).json()}},gp=".txt",mp="text/plain",yp={name:"loadTxt",id:"text",extension:{type:I.LoadParser,priority:ue.Low,name:"loadTxt"},test(r){return pe(r,mp)||li(r,gp)},async load(r){return await(await j.get().fetch(r)).text()}},xp=["normal","bold","100","200","300","400","500","600","700","800","900"],Sp=[".ttf",".otf",".woff",".woff2"],vp=["font/ttf","font/otf","font/woff","font/woff2"],bp=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function wp(r){const e=Mt.extname(r),s=Mt.basename(r,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1));let n=s.length>0;for(const a of s)if(!a.match(bp)){n=!1;break}let o=s.join(" ");return n||(o=`"${o.replace(/[\\"]/g,"\\$&")}"`),o}const Cp=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Ap(r){return Cp.test(r)?r:encodeURI(r)}const Pp={extension:{type:I.LoadParser,priority:ue.Low},name:"loadWebFont",id:"web-font",test(r){return pe(r,vp)||li(r,Sp)},async load(r,e){var i,s,n;const t=j.get().getFontFaceSet();if(t){const o=[],a=((i=e.data)==null?void 0:i.family)??wp(r),h=((n=(s=e.data)==null?void 0:s.weights)==null?void 0:n.filter(c=>xp.includes(c)))??["normal"],l=e.data??{};for(let c=0;c<h.length;c++){const d=h[c],u=new FontFace(a,`url(${Ap(r)})`,{...l,weight:d});await u.load(),t.add(u),o.push(u)}return xt.has(`${a}-and-url`)?xt.get(`${a}-and-url`).entries.push({url:r,faces:o}):xt.set(`${a}-and-url`,{entries:[{url:r,faces:o}]}),o.length===1?o[0]:o}return nt("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(r){const e=Array.isArray(r)?r:[r],t=e[0].family,i=xt.get(`${t}-and-url`),s=i.entries.find(n=>n.faces.some(o=>e.indexOf(o)!==-1));s.faces=s.faces.filter(n=>e.indexOf(n)===-1),s.faces.length===0&&(i.entries=i.entries.filter(n=>n!==s)),e.forEach(n=>{j.get().getFontFaceSet().delete(n)}),i.entries.length===0&&xt.remove(`${t}-and-url`)}};var Mp=Tp,pn={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},_p=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function Tp(r){var e=[];return r.replace(_p,function(t,i,s){var n=i.toLowerCase();for(s=Rp(s),n=="m"&&s.length>2&&(e.push([i].concat(s.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(s.length==pn[n])return s.unshift(i),e.push(s);if(s.length<pn[n])throw new Error("malformed path data");e.push([i].concat(s.splice(0,pn[n])))}}),e}var kp=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function Rp(r){var e=r.match(kp);return e?e.map(Number):[]}const Ep=Qa(Mp);function Ip(r,e){const t=Ep(r),i=[];let s=null,n=0,o=0;for(let a=0;a<t.length;a++){const h=t[a],l=h[0],c=h;switch(l){case"M":n=c[1],o=c[2],e.moveTo(n,o);break;case"m":n+=c[1],o+=c[2],e.moveTo(n,o);break;case"H":n=c[1],e.lineTo(n,o);break;case"h":n+=c[1],e.lineTo(n,o);break;case"V":o=c[1],e.lineTo(n,o);break;case"v":o+=c[1],e.lineTo(n,o);break;case"L":n=c[1],o=c[2],e.lineTo(n,o);break;case"l":n+=c[1],o+=c[2],e.lineTo(n,o);break;case"C":n=c[5],o=c[6],e.bezierCurveTo(c[1],c[2],c[3],c[4],n,o);break;case"c":e.bezierCurveTo(n+c[1],o+c[2],n+c[3],o+c[4],n+c[5],o+c[6]),n+=c[5],o+=c[6];break;case"S":n=c[3],o=c[4],e.bezierCurveToShort(c[1],c[2],n,o);break;case"s":e.bezierCurveToShort(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"Q":n=c[3],o=c[4],e.quadraticCurveTo(c[1],c[2],n,o);break;case"q":e.quadraticCurveTo(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"T":n=c[1],o=c[2],e.quadraticCurveToShort(n,o);break;case"t":n+=c[1],o+=c[2],e.quadraticCurveToShort(n,o);break;case"A":n=c[6],o=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"a":n+=c[6],o+=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"Z":case"z":e.closePath(),i.length>0&&(s=i.pop(),s?(n=s.startX,o=s.startY):(n=0,o=0)),s=null;break;default:nt(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&s===null&&(s={startX:n,startY:o},i.push(s))}return e}class Rs{constructor(e=0,t=0,i=0){this.type="circle",this.x=e,this.y=t,this.radius=i}clone(){return new Rs(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-e,n=this.y-t;return s*=s,n*=n,s+n<=i}strokeContains(e,t,i,s=.5){if(this.radius===0)return!1;const n=this.x-e,o=this.y-t,a=this.radius,h=(1-s)*i,l=Math.sqrt(n*n+o*o);return l<=a+h&&l>a-(i-h)}getBounds(e){return e||(e=new et),e.x=this.x-this.radius,e.y=this.y-this.radius,e.width=this.radius*2,e.height=this.radius*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class yr{constructor(e=0,t=0,i=0,s=0){this.type="ellipse",this.x=e,this.y=t,this.halfWidth=i,this.halfHeight=s}clone(){return new yr(this.x,this.y,this.halfWidth,this.halfHeight)}contains(e,t){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(e-this.x)/this.halfWidth,s=(t-this.y)/this.halfHeight;return i*=i,s*=s,i+s<=1}strokeContains(e,t,i,s=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=i*(1-s),h=i-a,l=n-h,c=o-h,d=n+a,u=o+a,p=e-this.x,f=t-this.y,y=p*p/(l*l)+f*f/(c*c),m=p*p/(d*d)+f*f/(u*u);return y>1&&m<=1}getBounds(e){return e||(e=new et),e.x=this.x-this.halfWidth,e.y=this.y-this.halfHeight,e.width=this.halfWidth*2,e.height=this.halfHeight*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.halfWidth=e.halfWidth,this.halfHeight=e.halfHeight,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function Bp(r,e,t,i,s,n){const o=r-t,a=e-i,h=s-t,l=n-i,c=o*h+a*l,d=h*h+l*l;let u=-1;d!==0&&(u=c/d);let p,f;u<0?(p=t,f=i):u>1?(p=s,f=n):(p=t+u*h,f=i+u*l);const y=r-p,m=e-f;return y*y+m*m}let Dp,Fp;class Te{constructor(...e){this.type="polygon";let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!="number"){const i=[];for(let s=0,n=t.length;s<n;s++)i.push(t[s].x,t[s].y);t=i}this.points=t,this.closePath=!0}isClockwise(){let e=0;const t=this.points,i=t.length;for(let s=0;s<i;s+=2){const n=t[s],o=t[s+1],a=t[(s+2)%i],h=t[(s+3)%i];e+=(a-n)*(h+o)}return e<0}containsPolygon(e){const t=this.getBounds(Dp),i=e.getBounds(Fp);if(!t.containsRect(i))return!1;const s=e.points;for(let n=0;n<s.length;n+=2){const o=s[n],a=s[n+1];if(!this.contains(o,a))return!1}return!0}clone(){const e=this.points.slice(),t=new Te(e);return t.closePath=this.closePath,t}contains(e,t){let i=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],h=this.points[n*2+1],l=this.points[o*2],c=this.points[o*2+1];h>t!=c>t&&e<(l-a)*((t-h)/(c-h))+a&&(i=!i)}return i}strokeContains(e,t,i,s=.5){const n=i*i,o=n*(1-s),a=n-o,{points:h}=this,l=h.length-(this.closePath?0:2);for(let c=0;c<l;c+=2){const d=h[c],u=h[c+1],p=h[(c+2)%h.length],f=h[(c+3)%h.length],y=Bp(e,t,d,u,p,f),m=Math.sign((p-d)*(t-u)-(f-u)*(e-d));if(y<=(m<0?a:o))return!0}return!1}getBounds(e){e||(e=new et);const t=this.points;let i=1/0,s=-1/0,n=1/0,o=-1/0;for(let a=0,h=t.length;a<h;a+=2){const l=t[a],c=t[a+1];i=l<i?l:i,s=l>s?l:s,n=c<n?c:n,o=c>o?c:o}return e.x=i,e.width=s-i,e.y=n,e.height=o-n,e}copyFrom(e){return this.points=e.points.slice(),this.closePath=e.closePath,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((e,t)=>`${e}, ${t}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return V("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return V("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 as=(r,e,t,i,s,n,o)=>{const a=r-t,h=e-i,l=Math.sqrt(a*a+h*h);return l>=s-n&&l<=s+o};class xr{constructor(e=0,t=0,i=0,s=0,n=20){this.type="roundedRectangle",this.x=e,this.y=t,this.width=i,this.height=s,this.radius=n}getBounds(e){return e||(e=new et),e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new xr(this.x,this.y,this.width,this.height,this.radius)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+i&&t<=this.y+this.height-i||e>=this.x+i&&e<=this.x+this.width-i)return!0;let s=e-(this.x+i),n=t-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=e-(this.x+this.width-i),s*s+n*n<=o)||(n=t-(this.y+this.height-i),s*s+n*n<=o)||(s=e-(this.x+i),s*s+n*n<=o))return!0}return!1}strokeContains(e,t,i,s=.5){const{x:n,y:o,width:a,height:h,radius:l}=this,c=i*(1-s),d=i-c,u=n+l,p=o+l,f=a-l*2,y=h-l*2,m=n+a,x=o+h;return(e>=n-c&&e<=n+d||e>=m-d&&e<=m+c)&&t>=p&&t<=p+y||(t>=o-c&&t<=o+d||t>=x-d&&t<=x+c)&&e>=u&&e<=u+f?!0:e<u&&t<p&&as(e,t,u,p,l,d,c)||e>m-l&&t<p&&as(e,t,m-l,p,l,d,c)||e>m-l&&t>x-l&&as(e,t,m-l,x-l,l,d,c)||e<u&&t>x-l&&as(e,t,u,x-l,l,d,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const sl={};function zp(r,e,t){let i=2166136261;for(let s=0;s<e;s++)i^=r[s].uid,i=Math.imul(i,16777619),i>>>=0;return sl[i]||Lp(r,e,i,t)}function Lp(r,e,t,i){const s={};let n=0;for(let a=0;a<i;a++){const h=a<e?r[a]:W.EMPTY.source;s[n++]=h.source,s[n++]=h.style}const o=new _i(s);return sl[t]=o,o}class Go{constructor(e){typeof e=="number"?this.rawBinaryData=new ArrayBuffer(e):e instanceof Uint8Array?this.rawBinaryData=e.buffer:this.rawBinaryData=e,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(e){return this[`${e}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(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${e} isn't a valid view type`)}}}function Uo(r,e,t,i){if(t??(t=0),i??(i=Math.min(r.byteLength-t,e.byteLength)),!(t&7)&&!(i&7)){const s=i/8;new Float64Array(e,0,s).set(new Float64Array(r,t,s))}else if(!(t&3)&&!(i&3)){const s=i/4;new Float32Array(e,0,s).set(new Float32Array(r,t,s))}else new Uint8Array(e).set(new Uint8Array(r,t,i))}const Op={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Wp=(r=>(r[r.DISABLED=0]="DISABLED",r[r.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",r[r.MASK_ACTIVE=2]="MASK_ACTIVE",r[r.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",r[r.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",r[r.NONE=5]="NONE",r))(Wp||{});function ys(r,e){return e.alphaMode==="no-premultiply-alpha"&&Op[r]||r}const Gp=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
25
|
+
`);function Up(r){let e="";for(let t=0;t<r;++t)t>0&&(e+=`
|
|
26
|
+
else `),t<r-1&&(e+=`if(test == ${t}.0){}`);return e}function Hp(r,e){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const t=e.createShader(e.FRAGMENT_SHADER);try{for(;;){const i=Gp.replace(/%forloop%/gi,Up(r));if(e.shaderSource(t,i),e.compileShader(t),!e.getShaderParameter(t,e.COMPILE_STATUS))r=r/2|0;else break}}finally{e.deleteShader(t)}return r}let Oe=null;function Vp(){var e;if(Oe)return Oe;const r=Dh();return Oe=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),Oe=Hp(Oe,r),(e=r.getExtension("WEBGL_lose_context"))==null||e.loseContext(),Oe}class Np{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let e=0;e<this.count;e++){const t=this.textures[e];this.textures[e]=null,this.ids[t.uid]=null}this.count=0}}class jp{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Np,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 Ti=[];let xs=0;Hi.register({clear:()=>{if(Ti.length>0)for(const r of Ti)r&&r.destroy();Ti.length=0,xs=0}});function Ho(){return xs>0?Ti[--xs]:new jp}function Vo(r){r.elements=null,Ti[xs++]=r}let gi=0;const nl=class rl{constructor(e){this.uid=dt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],e={...rl.defaultOptions,...e},e.maxTextures||(V("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),e.maxTextures=Vp());const{maxTextures:t,attributesInitialSize:i,indicesInitialSize:s}=e;this.attributeBuffer=new Go(i*4),this.indexBuffer=new Uint16Array(s),this.maxTextures=t}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let e=0;e<this.batchIndex;e++)Vo(this.batches[e]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(e){this._elements[this.elementSize++]=e,e._indexStart=this.indexSize,e._attributeStart=this.attributeSize,e._batcher=this,this.indexSize+=e.indexSize,this.attributeSize+=e.attributeSize*this.vertexSize}checkAndUpdateTexture(e,t){const i=e._batch.textures.ids[t._source.uid];return!i&&i!==0?!1:(e._textureId=i,e.texture=t,!0)}updateElement(e){this.dirty=!0;const t=this.attributeBuffer;e.packAsQuad?this.packQuadAttributes(e,t.float32View,t.uint32View,e._attributeStart,e._textureId):this.packAttributes(e,t.float32View,t.uint32View,e._attributeStart,e._textureId)}break(e){const t=this._elements;if(!t[this.elementStart])return;let i=Ho(),s=i.textures;s.clear();const n=t[this.elementStart];let o=ys(n.blendMode,n.texture._source),a=n.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const h=this.attributeBuffer.float32View,l=this.attributeBuffer.uint32View,c=this.indexBuffer;let d=this._batchIndexSize,u=this._batchIndexStart,p="startBatch",f=[];const y=this.maxTextures;for(let m=this.elementStart;m<this.elementSize;++m){const x=t[m];t[m]=null;const v=x.texture._source,b=ys(x.blendMode,v),P=o!==b||a!==x.topology;if(v._batchTick===gi&&!P){x._textureId=v._textureBindLocation,d+=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,f.push(x);continue}v._batchTick=gi,(s.count>=y||P)&&(this._finishBatch(i,u,d-u,s,o,a,e,p,f),p="renderBatch",u=d,o=b,a=x.topology,i=Ho(),s=i.textures,s.clear(),f=[],++gi),x._textureId=v._textureBindLocation=s.count,s.ids[v.uid]=s.count,s.textures[s.count++]=v,x._batch=i,f.push(x),d+=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))}s.count>0&&(this._finishBatch(i,u,d-u,s,o,a,e,p,f),u=d,++gi),this.elementStart=this.elementSize,this._batchIndexStart=u,this._batchIndexSize=d}_finishBatch(e,t,i,s,n,o,a,h,l){e.gpuBindGroup=null,e.bindGroup=null,e.action=h,e.batcher=this,e.textures=s,e.blendMode=n,e.topology=o,e.start=t,e.size=i,e.elements=l,++gi,this.batches[this.batchIndex++]=e,a.add(e)}finish(e){this.break(e)}ensureAttributeBuffer(e){e*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(e*4)}ensureIndexBuffer(e){e<=this.indexBuffer.length||this._resizeIndexBuffer(e)}_resizeAttributeBuffer(e){const t=Math.max(e,this.attributeBuffer.size*2),i=new Go(t);Uo(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(e){const t=this.indexBuffer;let i=Math.max(e,t.length*1.5);i+=i%2;const s=i>65535?new Uint32Array(i):new Uint16Array(i);if(s.BYTES_PER_ELEMENT!==t.BYTES_PER_ELEMENT)for(let n=0;n<t.length;n++)s[n]=t[n];else Uo(t.buffer,s.buffer);this.indexBuffer=s}packQuadIndex(e,t,i){e[t]=i+0,e[t+1]=i+1,e[t+2]=i+2,e[t+3]=i+0,e[t+4]=i+2,e[t+5]=i+3}packIndex(e,t,i,s){const n=e.indices,o=e.indexSize,a=e.indexOffset,h=e.attributeOffset;for(let l=0;l<o;l++)t[i++]=s+n[l+a]-h}destroy(e={}){var t;if(this.batches!==null){for(let i=0;i<this.batchIndex;i++)Vo(this.batches[i]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,e.shader&&((t=this.shader)==null||t.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}}};nl.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Yp=nl;var ft=(r=>(r[r.MAP_READ=1]="MAP_READ",r[r.MAP_WRITE=2]="MAP_WRITE",r[r.COPY_SRC=4]="COPY_SRC",r[r.COPY_DST=8]="COPY_DST",r[r.INDEX=16]="INDEX",r[r.VERTEX=32]="VERTEX",r[r.UNIFORM=64]="UNIFORM",r[r.STORAGE=128]="STORAGE",r[r.INDIRECT=256]="INDIRECT",r[r.QUERY_RESOLVE=512]="QUERY_RESOLVE",r[r.STATIC=1024]="STATIC",r))(ft||{});class he extends Yt{constructor(e){let{data:t,size:i}=e;const{usage:s,label:n,shrinkToFit:o}=e;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=dt("buffer"),this._resourceType="buffer",this._resourceId=dt("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,t instanceof Array&&(t=new Float32Array(t)),this._data=t,i??(i=t==null?void 0:t.byteLength);const a=!!t;this.descriptor={size:i,usage:s,mappedAtCreation:a,label:n},this.shrinkToFit=o??!0}get data(){return this._data}set data(e){this.setDataWithSize(e,e.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&ft.STATIC)}set static(e){e?this.descriptor.usage|=ft.STATIC:this.descriptor.usage&=~ft.STATIC}setDataWithSize(e,t,i){if(this._updateID++,this._updateSize=t*e.BYTES_PER_ELEMENT,this._data===e){i&&this.emit("update",this);return}const s=this._data;if(this._data=e,this._dataInt32=null,!s||s.length!==e.length){!this.shrinkToFit&&s&&e.byteLength<s.byteLength?i&&this.emit("update",this):(this.descriptor.size=e.byteLength,this._resourceId=dt("resource"),this.emit("change",this));return}i&&this.emit("update",this)}update(e){this._updateSize=e??this._updateSize,this._updateID++,this.emit("update",this)}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.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 ol(r,e){if(!(r instanceof he)){let t=e?ft.INDEX:ft.VERTEX;r instanceof Array&&(e?(r=new Uint32Array(r),t=ft.INDEX|ft.COPY_DST):(r=new Float32Array(r),t=ft.VERTEX|ft.COPY_DST)),r=new he({data:r,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:t})}return r}function Xp(r,e,t){const i=r.getAttribute(e);if(!i)return t.minX=0,t.minY=0,t.maxX=0,t.maxY=0,t;const s=i.buffer.data;let n=1/0,o=1/0,a=-1/0,h=-1/0;const l=s.BYTES_PER_ELEMENT,c=(i.offset||0)/l,d=(i.stride||2*4)/l;for(let u=c;u<s.length;u+=d){const p=s[u],f=s[u+1];p>a&&(a=p),f>h&&(h=f),p<n&&(n=p),f<o&&(o=f)}return t.minX=n,t.minY=o,t.maxX=a,t.maxY=h,t}function Zp(r){return(r instanceof he||Array.isArray(r)||r.BYTES_PER_ELEMENT)&&(r={buffer:r}),r.buffer=ol(r.buffer,!1),r}class Wi extends Yt{constructor(e={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=dt("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new Bt,this._boundsDirty=!0;const{attributes:t,indexBuffer:i,topology:s}=e;if(this.buffers=[],this.attributes={},t)for(const n in t)this.addAttribute(n,t[n]);this.instanceCount=e.instanceCount??1,i&&this.addIndex(i),this.topology=s||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(e){return this.attributes[e]}getIndex(){return this.indexBuffer}getBuffer(e){return this.getAttribute(e).buffer}getSize(){for(const e in this.attributes){const t=this.attributes[e];return t.buffer.data.length/(t.stride/4||t.size)}return 0}addAttribute(e,t){const i=Zp(t);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[e]=i}addIndex(e){this.indexBuffer=ol(e,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Xp(this,"aPosition",this._bounds)):this._bounds}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.destroy();this._gpuData=Object.create(null)}destroy(e=!1){var t;this.emit("destroy",this),this.removeAllListeners(),e&&this.buffers.forEach(i=>i.destroy()),this.unload(),(t=this.indexBuffer)==null||t.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const qp=new Float32Array(1),Kp=new Uint32Array(1);class $p extends Wi{constructor(){const t=new he({data:qp,label:"attribute-batch-buffer",usage:ft.VERTEX|ft.COPY_DST,shrinkToFit:!1}),i=new he({data:Kp,label:"index-batch-buffer",usage:ft.INDEX|ft.COPY_DST,shrinkToFit:!1}),s=6*4;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:s,offset:0},aUV:{buffer:t,format:"float32x2",stride:s,offset:2*4},aColor:{buffer:t,format:"unorm8x4",stride:s,offset:4*4},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:s,offset:5*4}},indexBuffer:i})}}function No(r,e,t){if(r)for(const i in r){const s=i.toLocaleLowerCase(),n=e[s];if(n){let o=r[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),t&&n.push(`//----${t}----//`),n.push(o)}else nt(`${i} placement hook does not exist in shader`)}}const Qp=/\{\{(.*?)\}\}/g;function jo(r){var i;const e={};return(((i=r.match(Qp))==null?void 0:i.map(s=>s.replace(/[{()}]/g,"")))??[]).forEach(s=>{e[s]=[]}),e}function Yo(r,e){let t;const i=/@in\s+([^;]+);/g;for(;(t=i.exec(r))!==null;)e.push(t[1])}function Xo(r,e,t=!1){const i=[];Yo(e,i),r.forEach(a=>{a.header&&Yo(a.header,i)});const s=i;t&&s.sort();const n=s.map((a,h)=>` @location(${h}) ${a},`).join(`
|
|
27
27
|
`);let o=e.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
|
|
28
28
|
${n}
|
|
29
|
-
`),o}function
|
|
30
|
-
`),n=t.sort().map(h=>` var ${
|
|
29
|
+
`),o}function Zo(r,e){let t;const i=/@out\s+([^;]+);/g;for(;(t=i.exec(r))!==null;)e.push(t[1])}function Jp(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function tf(r){const e=/@.*?\s+/g;return r.replace(e,"")}function ef(r,e){const t=[];Zo(e,t),r.forEach(h=>{h.header&&Zo(h.header,t)});let i=0;const s=t.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${i++}) ${h}`).join(`,
|
|
30
|
+
`),n=t.sort().map(h=>` var ${tf(h)};`).join(`
|
|
31
31
|
`),o=`return VSOutput(
|
|
32
|
-
${t.sort().map(h=>` ${
|
|
32
|
+
${t.sort().map(h=>` ${Jp(h)}`).join(`,
|
|
33
33
|
`)});`;let a=e.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
|
|
34
34
|
${s}
|
|
35
35
|
`),a=a.replace("{{start}}",`
|
|
36
36
|
${n}
|
|
37
37
|
`),a=a.replace("{{return}}",`
|
|
38
38
|
${o}
|
|
39
|
-
`),a}function
|
|
39
|
+
`),a}function qo(r,e){let t=r;for(const i in e){const s=e[i];s.join(`
|
|
40
40
|
`).length?t=t.replace(`{{${i}}}`,`//-----${i} START-----//
|
|
41
41
|
${s.join(`
|
|
42
42
|
`)}
|
|
43
|
-
//----${i} FINISH----//`):t=t.replace(`{{${i}}}`,"")}return t}const oe=Object.create(null),fn=new Map;let
|
|
43
|
+
//----${i} FINISH----//`):t=t.replace(`{{${i}}}`,"")}return t}const oe=Object.create(null),fn=new Map;let sf=0;function nf({template:r,bits:e}){const t=al(r,e);if(oe[t])return oe[t];const{vertex:i,fragment:s}=of(r,e);return oe[t]=hl(i,s,e),oe[t]}function rf({template:r,bits:e}){const t=al(r,e);return oe[t]||(oe[t]=hl(r.vertex,r.fragment,e)),oe[t]}function of(r,e){const t=e.map(o=>o.vertex).filter(o=>!!o),i=e.map(o=>o.fragment).filter(o=>!!o);let s=Xo(t,r.vertex,!0);s=ef(t,s);const n=Xo(i,r.fragment,!0);return{vertex:s,fragment:n}}function al(r,e){return e.map(t=>(fn.has(t)||fn.set(t,sf++),fn.get(t))).sort((t,i)=>t-i).join("-")+r.vertex+r.fragment}function hl(r,e,t){const i=jo(r),s=jo(e);return t.forEach(n=>{No(n.vertex,i,n.name),No(n.fragment,s,n.name)}),{vertex:qo(r,i),fragment:qo(e,s)}}const af=`
|
|
44
44
|
@in aPosition: vec2<f32>;
|
|
45
45
|
@in aUV: vec2<f32>;
|
|
46
46
|
|
|
@@ -84,7 +84,7 @@ ${s.join(`
|
|
|
84
84
|
|
|
85
85
|
{{return}}
|
|
86
86
|
};
|
|
87
|
-
`,
|
|
87
|
+
`,hf=`
|
|
88
88
|
@in vUV : vec2<f32>;
|
|
89
89
|
@in vColor : vec4<f32>;
|
|
90
90
|
|
|
@@ -107,7 +107,7 @@ ${s.join(`
|
|
|
107
107
|
|
|
108
108
|
return finalColor;
|
|
109
109
|
};
|
|
110
|
-
`,
|
|
110
|
+
`,lf=`
|
|
111
111
|
in vec2 aPosition;
|
|
112
112
|
in vec2 aUV;
|
|
113
113
|
|
|
@@ -143,7 +143,7 @@ ${s.join(`
|
|
|
143
143
|
|
|
144
144
|
{{end}}
|
|
145
145
|
}
|
|
146
|
-
`,
|
|
146
|
+
`,cf=`
|
|
147
147
|
|
|
148
148
|
in vec4 vColor;
|
|
149
149
|
in vec2 vUV;
|
|
@@ -164,7 +164,7 @@ ${s.join(`
|
|
|
164
164
|
|
|
165
165
|
{{end}}
|
|
166
166
|
}
|
|
167
|
-
`,
|
|
167
|
+
`,df={name:"global-uniforms-bit",vertex:{header:`
|
|
168
168
|
struct GlobalUniforms {
|
|
169
169
|
uProjectionMatrix:mat3x3<f32>,
|
|
170
170
|
uWorldTransformMatrix:mat3x3<f32>,
|
|
@@ -173,22 +173,22 @@ ${s.join(`
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
@group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
|
|
176
|
-
`}},
|
|
176
|
+
`}},uf={name:"global-uniforms-bit",vertex:{header:`
|
|
177
177
|
uniform mat3 uProjectionMatrix;
|
|
178
178
|
uniform mat3 uWorldTransformMatrix;
|
|
179
179
|
uniform vec4 uWorldColorAlpha;
|
|
180
180
|
uniform vec2 uResolution;
|
|
181
|
-
`}};function
|
|
181
|
+
`}};function ll({bits:r,name:e}){const t=nf({template:{fragment:hf,vertex:af},bits:[df,...r]});return le.from({name:e,vertex:{source:t.vertex,entryPoint:"main"},fragment:{source:t.fragment,entryPoint:"main"}})}function cl({bits:r,name:e}){return new si({name:e,...rf({template:{vertex:lf,fragment:cf},bits:[uf,...r]})})}const pf={name:"color-bit",vertex:{header:`
|
|
182
182
|
@in aColor: vec4<f32>;
|
|
183
183
|
`,main:`
|
|
184
184
|
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
|
|
185
|
-
`}},
|
|
185
|
+
`}},ff={name:"color-bit",vertex:{header:`
|
|
186
186
|
in vec4 aColor;
|
|
187
187
|
`,main:`
|
|
188
188
|
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
|
|
189
|
-
`}},gn={};function
|
|
190
|
-
`)}function
|
|
191
|
-
`)}function
|
|
189
|
+
`}},gn={};function gf(r){const e=[];if(r===1)e.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),e.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let t=0;for(let i=0;i<r;i++)e.push(`@group(1) @binding(${t++}) var textureSource${i+1}: texture_2d<f32>;`),e.push(`@group(1) @binding(${t++}) var textureSampler${i+1}: sampler;`)}return e.join(`
|
|
190
|
+
`)}function mf(r){const e=[];if(r===1)e.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{e.push("switch vTextureId {");for(let t=0;t<r;t++)t===r-1?e.push(" default:{"):e.push(` case ${t}:{`),e.push(` outColor = textureSampleGrad(textureSource${t+1}, textureSampler${t+1}, vUV, uvDx, uvDy);`),e.push(" break;}");e.push("}")}return e.join(`
|
|
191
|
+
`)}function yf(r){return gn[r]||(gn[r]={name:"texture-batch-bit",vertex:{header:`
|
|
192
192
|
@in aTextureIdAndRound: vec2<u32>;
|
|
193
193
|
@out @interpolate(flat) vTextureId : u32;
|
|
194
194
|
`,main:`
|
|
@@ -201,14 +201,14 @@ ${s.join(`
|
|
|
201
201
|
`},fragment:{header:`
|
|
202
202
|
@in @interpolate(flat) vTextureId: u32;
|
|
203
203
|
|
|
204
|
-
${
|
|
204
|
+
${gf(r)}
|
|
205
205
|
`,main:`
|
|
206
206
|
var uvDx = dpdx(vUV);
|
|
207
207
|
var uvDy = dpdy(vUV);
|
|
208
208
|
|
|
209
|
-
${
|
|
210
|
-
`}}),gn[r]}const mn={};function
|
|
211
|
-
`)}function
|
|
209
|
+
${mf(r)}
|
|
210
|
+
`}}),gn[r]}const mn={};function xf(r){const e=[];for(let t=0;t<r;t++)t>0&&e.push("else"),t<r-1&&e.push(`if(vTextureId < ${t}.5)`),e.push("{"),e.push(` outColor = texture(uTextures[${t}], vUV);`),e.push("}");return e.join(`
|
|
211
|
+
`)}function Sf(r){return mn[r]||(mn[r]={name:"texture-batch-bit",vertex:{header:`
|
|
212
212
|
in vec2 aTextureIdAndRound;
|
|
213
213
|
out float vTextureId;
|
|
214
214
|
|
|
@@ -226,18 +226,18 @@ ${s.join(`
|
|
|
226
226
|
|
|
227
227
|
`,main:`
|
|
228
228
|
|
|
229
|
-
${
|
|
230
|
-
`}}),mn[r]}const
|
|
229
|
+
${xf(r)}
|
|
230
|
+
`}}),mn[r]}const dl={name:"round-pixels-bit",vertex:{header:`
|
|
231
231
|
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
|
|
232
232
|
{
|
|
233
233
|
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
234
234
|
}
|
|
235
|
-
`}},
|
|
235
|
+
`}},ul={name:"round-pixels-bit",vertex:{header:`
|
|
236
236
|
vec2 roundPixels(vec2 position, vec2 targetSize)
|
|
237
237
|
{
|
|
238
238
|
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
239
239
|
}
|
|
240
|
-
`}},$o={};function bf(r){let e=$o[r];if(e)return e;const t=new Int32Array(r);for(let i=0;i<r;i++)t[i]=i;return e=$o[r]=new ni({uTextures:{value:t,type:"i32",size:r}},{isStatic:!0}),e}class Qo extends Be{constructor(e){const t=ul({name:"batch",bits:[gf,vf(e),fl]}),i=dl({name:"batch",bits:[ff,xf(e),pl]});super({glProgram:t,gpuProgram:i,resources:{batchSamplers:bf(e)}}),this.maxTextures=e}}let mi=null;const gl=class ml extends Xp{constructor(e){super(e),this.geometry=new Qp,this.name=ml.extension.name,this.vertexSize=6,mi??(mi=new Qo(e.maxTextures)),this.shader=mi}packAttributes(e,t,i,s,n){const o=n<<16|e.roundPixels&65535,a=e.transform,h=a.a,l=a.b,c=a.c,d=a.d,u=a.tx,p=a.ty,{positions:f,uvs:y}=e,m=e.color,x=e.attributeOffset,S=x+e.attributeSize;for(let v=x;v<S;v++){const b=v*2,P=f[b],C=f[b+1];t[s++]=h*P+c*C+u,t[s++]=d*C+l*P+p,t[s++]=y[b],t[s++]=y[b+1],i[s++]=m,i[s++]=o}}packQuadAttributes(e,t,i,s,n){const o=e.texture,a=e.transform,h=a.a,l=a.b,c=a.c,d=a.d,u=a.tx,p=a.ty,f=e.bounds,y=f.maxX,m=f.minX,x=f.maxY,S=f.minY,v=o.uvs,b=e.color,P=n<<16|e.roundPixels&65535;t[s+0]=h*m+c*S+u,t[s+1]=d*S+l*m+p,t[s+2]=v.x0,t[s+3]=v.y0,i[s+4]=b,i[s+5]=P,t[s+6]=h*y+c*S+u,t[s+7]=d*S+l*y+p,t[s+8]=v.x1,t[s+9]=v.y1,i[s+10]=b,i[s+11]=P,t[s+12]=h*y+c*x+u,t[s+13]=d*x+l*y+p,t[s+14]=v.x2,t[s+15]=v.y2,i[s+16]=b,i[s+17]=P,t[s+18]=h*m+c*x+u,t[s+19]=d*x+l*m+p,t[s+20]=v.x3,t[s+21]=v.y3,i[s+22]=b,i[s+23]=P}_updateMaxTextures(e){this.shader.maxTextures!==e&&(mi=new Qo(e),this.shader=mi)}destroy(){this.shader=null,super.destroy()}};gl.extension={type:[I.Batcher],name:"default"};let wf=gl;class ci{constructor(e){this.items=Object.create(null);const{renderer:t,type:i,onUnload:s,priority:n,name:o}=e;this._renderer=t,t.gc.addResourceHash(this,"items",i,n??0),this._onUnload=s,this.name=o}add(e){return this.items[e.uid]?!1:(this.items[e.uid]=e,e.once("unload",this.remove,this),e._gcLastUsed=this._renderer.gc.now,!0)}remove(e,...t){var s;if(!this.items[e.uid])return;const i=e._gpuData[this._renderer.uid];i&&((s=this._onUnload)==null||s.call(this,e,...t),i.destroy(),e._gpuData[this._renderer.uid]=null,this.items[e.uid]=null)}removeAll(...e){Object.values(this.items).forEach(t=>t&&this.remove(t,...e))}destroy(...e){this.removeAll(...e),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function Cf(r,e,t,i,s,n,o,a=null){let h=0;t*=e,s*=n;const l=a.a,c=a.b,d=a.c,u=a.d,p=a.tx,f=a.ty;for(;h<o;){const y=r[t],m=r[t+1];i[s]=l*y+d*m+p,i[s+1]=c*y+u*m+f,s+=n,t+=e,h++}}function Af(r,e,t,i){let s=0;for(e*=t;s<i;)r[e]=0,r[e+1]=0,e+=t,s++}function yl(r,e,t,i,s){const n=e.a,o=e.b,a=e.c,h=e.d,l=e.tx,c=e.ty;t||(t=0),i||(i=2),s||(s=r.length/i-t);let d=t*i;for(let u=0;u<s;u++){const p=r[d],f=r[d+1];r[d]=n*p+a*f+l,r[d+1]=o*p+h*f+c,d+=i}}const Pf=new U;class vr{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 e=this.baseColor,t=e>>16|e&65280|(e&255)<<16,i=this.renderable;return i?pr(t,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):t+(this.alpha*255<<24)}get transform(){var e;return((e=this.renderable)==null?void 0:e.groupTransform)||Pf}copyTo(e){e.indexOffset=this.indexOffset,e.indexSize=this.indexSize,e.attributeOffset=this.attributeOffset,e.attributeSize=this.attributeSize,e.baseColor=this.baseColor,e.alpha=this.alpha,e.texture=this.texture,e.geometryData=this.geometryData,e.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 Wi={extension:{type:I.ShapeBuilder,name:"circle"},build(r,e){let t,i,s,n,o,a;if(r.type==="circle"){const b=r;if(o=a=b.radius,o<=0)return!1;t=b.x,i=b.y,s=n=0}else if(r.type==="ellipse"){const b=r;if(o=b.halfWidth,a=b.halfHeight,o<=0||a<=0)return!1;t=b.x,i=b.y,s=n=0}else{const b=r,P=b.width/2,C=b.height/2;t=b.x+P,i=b.y+C,o=a=Math.max(0,Math.min(b.radius,Math.min(P,C))),s=P-o,n=C-a}if(s<0||n<0)return!1;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(s?4:0)+(n?4:0);if(l===0)return!1;if(h===0)return e[0]=e[6]=t+s,e[1]=e[3]=i+n,e[2]=e[4]=t-s,e[5]=e[7]=i-n,!0;let c=0,d=h*4+(s?2:0)+2,u=d,p=l,f=s+o,y=n,m=t+f,x=t-f,S=i+y;if(e[c++]=m,e[c++]=S,e[--d]=S,e[--d]=x,n){const b=i-y;e[u++]=x,e[u++]=b,e[--p]=b,e[--p]=m}for(let b=1;b<h;b++){const P=Math.PI/2*(b/h),C=s+Math.cos(P)*o,A=n+Math.sin(P)*a,k=t+C,M=t-C,T=i+A,_=i-A;e[c++]=k,e[c++]=T,e[--d]=T,e[--d]=M,e[u++]=M,e[u++]=_,e[--p]=_,e[--p]=k}f=s,y=n+a,m=t+f,x=t-f,S=i+y;const v=i-y;return e[c++]=m,e[c++]=S,e[--p]=v,e[--p]=m,s&&(e[c++]=x,e[c++]=S,e[--p]=v,e[--p]=x),!0},triangulate(r,e,t,i,s,n){if(r.length===0)return;let o=0,a=0;for(let c=0;c<r.length;c+=2)o+=r[c],a+=r[c+1];o/=r.length/2,a/=r.length/2;let h=i;e[h*t]=o,e[h*t+1]=a;const l=h++;for(let c=0;c<r.length;c+=2)e[h*t]=r[c],e[h*t+1]=r[c+1],c>0&&(s[n++]=h,s[n++]=l,s[n++]=h-1),h++;s[n++]=l+1,s[n++]=l,s[n++]=h-1}},Mf={...Wi,extension:{...Wi.extension,name:"ellipse"}},_f={...Wi,extension:{...Wi.extension,name:"roundedRectangle"}},xl=1e-4,Jo=1e-4;function Tf(r){const e=r.length;if(e<6)return 1;let t=0;for(let i=0,s=r[e-2],n=r[e-1];i<e;i+=2){const o=r[i],a=r[i+1];t+=(o-s)*(a+n),s=o,n=a}return t<0?-1:1}function ta(r,e,t,i,s,n,o,a){const h=r-t*s,l=e-i*s,c=r+t*n,d=e+i*n;let u,p;o?(u=i,p=-t):(u=-i,p=t);const f=h+u,y=l+p,m=c+u,x=d+p;return a.push(f,y),a.push(m,x),2}function xe(r,e,t,i,s,n,o,a){const h=t-r,l=i-e;let c=Math.atan2(h,l),d=Math.atan2(s-r,n-e);a&&c<d?c+=Math.PI*2:!a&&c>d&&(d+=Math.PI*2);let u=c;const p=d-c,f=Math.abs(p),y=Math.sqrt(h*h+l*l),m=(15*f*Math.sqrt(y)/Math.PI>>0)+1,x=p/m;if(u+=x,a){o.push(r,e),o.push(t,i);for(let S=1,v=u;S<m;S++,v+=x)o.push(r,e),o.push(r+Math.sin(v)*y,e+Math.cos(v)*y);o.push(r,e),o.push(s,n)}else{o.push(t,i),o.push(r,e);for(let S=1,v=u;S<m;S++,v+=x)o.push(r+Math.sin(v)*y,e+Math.cos(v)*y),o.push(r,e);o.push(s,n),o.push(r,e)}return m*2}function kf(r,e,t,i,s,n){const o=xl;if(r.length===0)return;const a=e;let h=a.alignment;if(e.alignment!==.5){let z=Tf(r);h=(h-.5)*z+.5}const l=new tt(r[0],r[1]),c=new tt(r[r.length-2],r[r.length-1]),d=i,u=Math.abs(l.x-c.x)<o&&Math.abs(l.y-c.y)<o;if(d){r=r.slice(),u&&(r.pop(),r.pop(),c.set(r[r.length-2],r[r.length-1]));const z=(l.x+c.x)*.5,q=(c.y+l.y)*.5;r.unshift(z,q),r.push(z,q)}const p=s,f=r.length/2;let y=r.length;const m=p.length/2,x=a.width/2,S=x*x,v=a.miterLimit*a.miterLimit;let b=r[0],P=r[1],C=r[2],A=r[3],k=0,M=0,T=-(P-A),_=b-C,E=0,B=0,F=Math.sqrt(T*T+_*_);T/=F,_/=F,T*=x,_*=x;const Z=h,R=(1-Z)*2,D=Z*2;d||(a.cap==="round"?y+=xe(b-T*(R-D)*.5,P-_*(R-D)*.5,b-T*R,P-_*R,b+T*D,P+_*D,p,!0)+2:a.cap==="square"&&(y+=ta(b,P,T,_,R,D,!0,p))),p.push(b-T*R,P-_*R),p.push(b+T*D,P+_*D);for(let z=1;z<f-1;++z){b=r[(z-1)*2],P=r[(z-1)*2+1],C=r[z*2],A=r[z*2+1],k=r[(z+1)*2],M=r[(z+1)*2+1],T=-(P-A),_=b-C,F=Math.sqrt(T*T+_*_),T/=F,_/=F,T*=x,_*=x,E=-(A-M),B=C-k,F=Math.sqrt(E*E+B*B),E/=F,B/=F,E*=x,B*=x;const q=C-b,Y=P-A,ht=C-k,bt=M-A,wt=q*ht+Y*bt,kt=Y*ht-bt*q,Gt=kt<0;if(Math.abs(kt)<.001*Math.abs(wt)){p.push(C-T*R,A-_*R),p.push(C+T*D,A+_*D),wt>=0&&(a.join==="round"?y+=xe(C,A,C-T*R,A-_*R,C-E*R,A-B*R,p,!1)+4:y+=2,p.push(C-E*D,A-B*D),p.push(C+E*R,A+B*R));continue}const Yi=(-T+b)*(-_+A)-(-T+C)*(-_+P),qr=(-E+k)*(-B+A)-(-E+C)*(-B+M),Xi=(q*qr-ht*Yi)/kt,Zi=(bt*Yi-Y*qr)/kt,Hs=(Xi-C)*(Xi-C)+(Zi-A)*(Zi-A),fe=C+(Xi-C)*R,ge=A+(Zi-A)*R,me=C-(Xi-C)*D,ye=A-(Zi-A)*D,Mc=Math.min(q*q+Y*Y,ht*ht+bt*bt),Kr=Gt?R:D,_c=Mc+Kr*Kr*S;Hs<=_c?a.join==="bevel"||Hs/S>v?(Gt?(p.push(fe,ge),p.push(C+T*D,A+_*D),p.push(fe,ge),p.push(C+E*D,A+B*D)):(p.push(C-T*R,A-_*R),p.push(me,ye),p.push(C-E*R,A-B*R),p.push(me,ye)),y+=2):a.join==="round"?Gt?(p.push(fe,ge),p.push(C+T*D,A+_*D),y+=xe(C,A,C+T*D,A+_*D,C+E*D,A+B*D,p,!0)+4,p.push(fe,ge),p.push(C+E*D,A+B*D)):(p.push(C-T*R,A-_*R),p.push(me,ye),y+=xe(C,A,C-T*R,A-_*R,C-E*R,A-B*R,p,!1)+4,p.push(C-E*R,A-B*R),p.push(me,ye)):(p.push(fe,ge),p.push(me,ye)):(p.push(C-T*R,A-_*R),p.push(C+T*D,A+_*D),a.join==="round"?Gt?y+=xe(C,A,C+T*D,A+_*D,C+E*D,A+B*D,p,!0)+2:y+=xe(C,A,C-T*R,A-_*R,C-E*R,A-B*R,p,!1)+2:a.join==="miter"&&Hs/S<=v&&(Gt?(p.push(me,ye),p.push(me,ye)):(p.push(fe,ge),p.push(fe,ge)),y+=2),p.push(C-E*R,A-B*R),p.push(C+E*D,A+B*D),y+=2)}b=r[(f-2)*2],P=r[(f-2)*2+1],C=r[(f-1)*2],A=r[(f-1)*2+1],T=-(P-A),_=b-C,F=Math.sqrt(T*T+_*_),T/=F,_/=F,T*=x,_*=x,p.push(C-T*R,A-_*R),p.push(C+T*D,A+_*D),d||(a.cap==="round"?y+=xe(C-T*(R-D)*.5,A-_*(R-D)*.5,C-T*R,A-_*R,C+T*D,A+_*D,p,!1)+2:a.cap==="square"&&(y+=ta(C,A,T,_,R,D,!1,p)));const ot=Jo*Jo;for(let z=m;z<y+m-2;++z)b=p[z*2],P=p[z*2+1],C=p[(z+1)*2],A=p[(z+1)*2+1],k=p[(z+2)*2],M=p[(z+2)*2+1],!(Math.abs(b*(A-M)+C*(M-P)+k*(P-A))<ot)&&n.push(z,z+1,z+2)}function Rf(r,e,t,i){const s=xl;if(r.length===0)return;const n=r[0],o=r[1],a=r[r.length-2],h=r[r.length-1],l=e||Math.abs(n-a)<s&&Math.abs(o-h)<s,c=t,d=r.length/2,u=c.length/2;for(let p=0;p<d;p++)c.push(r[p*2]),c.push(r[p*2+1]);for(let p=0;p<d-1;p++)i.push(u+p,u+p+1);l&&i.push(u+d-1,u)}function Sl(r,e,t,i,s,n,o){const a=Xu(r,e,2);if(!a)return;for(let l=0;l<a.length;l+=3)n[o++]=a[l]+s,n[o++]=a[l+1]+s,n[o++]=a[l+2]+s;let h=s*i;for(let l=0;l<r.length;l+=2)t[h]=r[l],t[h+1]=r[l+1],h+=i}const Ef=[],If={extension:{type:I.ShapeBuilder,name:"polygon"},build(r,e){for(let t=0;t<r.points.length;t++)e[t]=r.points[t];return!0},triangulate(r,e,t,i,s,n){Sl(r,Ef,e,t,i,s,n)}},Bf={extension:{type:I.ShapeBuilder,name:"rectangle"},build(r,e){const t=r,i=t.x,s=t.y,n=t.width,o=t.height;return n>0&&o>0?(e[0]=i,e[1]=s,e[2]=i+n,e[3]=s,e[4]=i+n,e[5]=s+o,e[6]=i,e[7]=s+o,!0):!1},triangulate(r,e,t,i,s,n){let o=0;i*=t,e[i+o]=r[0],e[i+o+1]=r[1],o+=t,e[i+o]=r[2],e[i+o+1]=r[3],o+=t,e[i+o]=r[6],e[i+o+1]=r[7],o+=t,e[i+o]=r[4],e[i+o+1]=r[5],o+=t;const a=i/t;s[n++]=a,s[n++]=a+1,s[n++]=a+2,s[n++]=a+1,s[n++]=a+3,s[n++]=a+2}},Df={extension:{type:I.ShapeBuilder,name:"triangle"},build(r,e){return e[0]=r.x,e[1]=r.y,e[2]=r.x2,e[3]=r.y2,e[4]=r.x3,e[5]=r.y3,!0},triangulate(r,e,t,i,s,n){let o=0;i*=t,e[i+o]=r[0],e[i+o+1]=r[1],o+=t,e[i+o]=r[2],e[i+o+1]=r[3],o+=t,e[i+o]=r[4],e[i+o+1]=r[5];const a=i/t;s[n++]=a,s[n++]=a+1,s[n++]=a+2}},ea=[{offset:0,color:"white"},{offset:1,color:"black"}],br=class Xn{constructor(...e){this.uid=dt("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let t=Ff(e);t={...t.type==="radial"?Xn.defaultRadialOptions:Xn.defaultLinearOptions,...lh(t)},this._textureSize=t.textureSize,this._wrapMode=t.wrapMode,t.type==="radial"?(this.center=t.center,this.outerCenter=t.outerCenter??this.center,this.innerRadius=t.innerRadius,this.outerRadius=t.outerRadius,this.scale=t.scale,this.rotation=t.rotation):(this.start=t.start,this.end=t.end),this.textureSpace=t.textureSpace,this.type=t.type,t.colorStops.forEach(s=>{this.addColorStop(s.offset,s.color)})}addColorStop(e,t){return this.colorStops.push({offset:e,color:rt.shared.setValue(t).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:e,y:t}=this.start,{x:i,y:s}=this.end,n=i-e,o=s-t;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const m=e;e=i,i=m,n*=-1}if(o<0){const m=t;t=s,s=m,o*=-1}}const h=this.colorStops.length?this.colorStops:ea,l=this._textureSize,{canvas:c,context:d}=sa(l,1),u=a?d.createLinearGradient(this._textureSize,0,0,0):d.createLinearGradient(0,0,this._textureSize,0);ia(u,h),d.fillStyle=u,d.fillRect(0,0,l,1),this.texture=new G({source:new ii({resource:c,addressMode:this._wrapMode})});const p=Math.sqrt(n*n+o*o),f=Math.atan2(o,n),y=new U;y.scale(p/l,1),y.rotate(f),y.translate(e,t),this.textureSpace==="local"&&y.scale(l,l),this.transform=y}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const e=this.colorStops.length?this.colorStops:ea,t=this._textureSize,{canvas:i,context:s}=sa(t,t),{x:n,y:o}=this.center,{x:a,y:h}=this.outerCenter,l=this.innerRadius,c=this.outerRadius,d=a-c,u=h-c,p=t/(c*2),f=(n-d)*p,y=(o-u)*p,m=s.createRadialGradient(f,y,l*p,(a-d)*p,(h-u)*p,c*p);ia(m,e),s.fillStyle=e[e.length-1].color,s.fillRect(0,0,t,t),s.fillStyle=m,s.translate(f,y),s.rotate(this.rotation),s.scale(1,this.scale),s.translate(-f,-y),s.fillRect(0,0,t,t),this.texture=new G({source:new ii({resource:i,addressMode:this._wrapMode})});const x=new U;x.scale(1/p,1/p),x.translate(d,u),this.textureSpace==="local"&&x.scale(t,t),this.transform=x}destroy(){var e;(e=this.texture)==null||e.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}`}};br.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};br.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Ot=br;function ia(r,e){for(let t=0;t<e.length;t++){const i=e[t];r.addColorStop(i.offset,i.color)}}function sa(r,e){const t=j.get().createCanvas(r,e),i=t.getContext("2d");return{canvas:t,context:i}}function Ff(r){let e=r[0]??{};return(typeof e=="number"||r[1])&&(V("8.5.2","use options object instead"),e={type:"linear",start:{x:r[0],y:r[1]},end:{x:r[2],y:r[3]},textureSpace:r[4],textureSize:r[5]??Ot.defaultLinearOptions.textureSize}),e}const zf=new U,Lf=new et;function Of(r,e,t,i){const s=e.matrix?r.copyFrom(e.matrix).invert():r.identity();if(e.textureSpace==="local"){const o=t.getBounds(Lf);e.width&&o.pad(e.width);const{x:a,y:h}=o,l=1/o.width,c=1/o.height,d=-a*l,u=-h*c,p=s.a,f=s.b,y=s.c,m=s.d;s.a*=l,s.b*=l,s.c*=c,s.d*=c,s.tx=d*p+u*y+s.tx,s.ty=d*f+u*m+s.ty}else s.translate(e.texture.frame.x,e.texture.frame.y),s.scale(1/e.texture.source.width,1/e.texture.source.height);const n=e.texture.source.style;return!(e.fill instanceof Ot)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),i&&s.append(zf.copyFrom(i).invert()),s}const Es={};$.handleByMap(I.ShapeBuilder,Es);$.add(Bf,If,Df,Wi,Mf,_f);const Gf=new et,Wf=new U;function Uf(r,e){const{geometryData:t,batches:i}=e;i.length=0,t.indices.length=0,t.vertices.length=0,t.uvs.length=0;for(let s=0;s<r.instructions.length;s++){const n=r.instructions[s];if(n.action==="texture")Hf(n.data,i,t);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,h=n.data.style,l=n.data.hole;o&&l&&na(l.shapePath,h,!0,i,t),l&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=l.shapePath.shapePrimitives),na(a,h,o,i,t)}}}function Hf(r,e,t){const i=[],s=Es.rectangle,n=Gf;n.x=r.dx,n.y=r.dy,n.width=r.dw,n.height=r.dh;const o=r.transform;if(!s.build(n,i))return;const{vertices:a,uvs:h,indices:l}=t,c=l.length,d=a.length/2;o&&yl(i,o),s.triangulate(i,a,2,d,l,c);const u=r.image,p=u.uvs;h.push(p.x0,p.y0,p.x1,p.y1,p.x3,p.y3,p.x2,p.y2);const f=_t.get(vr);f.indexOffset=c,f.indexSize=l.length-c,f.attributeOffset=d,f.attributeSize=a.length/2-d,f.baseColor=r.style,f.alpha=r.alpha,f.texture=u,f.geometryData=t,e.push(f)}function na(r,e,t,i,s){const{vertices:n,uvs:o,indices:a}=s;r.shapePrimitives.forEach(({shape:h,transform:l,holes:c})=>{const d=[],u=Es[h.type];if(!u.build(h,d))return;const p=a.length,f=n.length/2;let y="triangle-list";if(l&&yl(d,l),t){const v=h.closePath??!0,b=e;b.pixelLine?(Rf(d,v,n,a),y="line-list"):kf(d,b,!1,v,n,a)}else if(c){const v=[],b=d.slice();Vf(c).forEach(C=>{v.push(b.length/2),b.push(...C)}),Sl(b,v,n,2,f,a,p)}else u.triangulate(d,n,2,f,a,p);const m=o.length/2,x=e.texture;if(x!==G.WHITE){const v=Of(Wf,e,h,l);Cf(n,2,f,o,m,2,n.length/2-f,v)}else Af(o,m,2,n.length/2-f);const S=_t.get(vr);S.indexOffset=p,S.indexSize=a.length-p,S.attributeOffset=f,S.attributeSize=n.length/2-f,S.baseColor=e.color,S.alpha=e.alpha,S.texture=x,S.geometryData=s,S.topology=y,i.push(S)})}function Vf(r){const e=[];for(let t=0;t<r.length;t++){const i=r[t].shape,s=[];Es[i.type].build(i,s)&&e.push(s)}return e}class Nf{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(e=>{_t.return(e)}),this.graphicsData&&_t.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 jf{constructor(){this.instructions=new fr}init(e){const t=e.maxTextures;this.batcher?this.batcher._updateMaxTextures(t):this.batcher=new wf({maxTextures:t}),this.instructions.reset()}get geometry(){return V(pd,"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 wr=class Zn{constructor(e){this._renderer=e,this._managedContexts=new ci({renderer:e,type:"resource",name:"graphicsContext"})}init(e){Zn.defaultOptions.bezierSmoothness=(e==null?void 0:e.bezierSmoothness)??Zn.defaultOptions.bezierSmoothness}getContextRenderData(e){return e._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(e)}updateGpuContext(e){const t=!!e._gpuData[this._renderer.uid],i=e._gpuData[this._renderer.uid]||this._initContext(e);if(e.dirty||!t){t&&i.reset(),Uf(e,i);const s=e.batchMode;e.customShader||s==="no-batch"?i.isBatchable=!1:s==="auto"?i.isBatchable=i.geometryData.vertices.length<400:i.isBatchable=!0,e.dirty=!1}return i}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){const t=_t.get(jf,{maxTextures:this._renderer.limits.maxBatchableTextures}),i=e._gpuData[this._renderer.uid],{batches:s,geometryData:n}=i;i.graphicsData=t;const o=n.vertices.length,a=n.indices.length;for(let d=0;d<s.length;d++)s[d].applyTransform=!1;const h=t.batcher;h.ensureAttributeBuffer(o),h.ensureIndexBuffer(a),h.begin();for(let d=0;d<s.length;d++){const u=s[d];h.add(u)}h.finish(t.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 d=0;d<c.length;d++){const u=c[d];u.bindGroup=Lp(u.textures.textures,u.textures.count,this._renderer.limits.maxBatchableTextures)}return t}_initContext(e){const t=new Nf;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};wr.extension={type:[I.WebGLSystem,I.WebGPUSystem],name:"graphicsContext"};wr.defaultOptions={bezierSmoothness:.5};let Cr=wr;const Yf=8,hs=11920929e-14,Xf=1;function vl(r,e,t,i,s,n,o,a,h,l){const d=Math.min(.99,Math.max(0,l??Cr.defaultOptions.bezierSmoothness));let u=(Xf-d)/1;return u*=u,Zf(e,t,i,s,n,o,a,h,r,u),r}function Zf(r,e,t,i,s,n,o,a,h,l){qn(r,e,t,i,s,n,o,a,h,l,0),h.push(o,a)}function qn(r,e,t,i,s,n,o,a,h,l,c){if(c>Yf)return;const d=(r+t)/2,u=(e+i)/2,p=(t+s)/2,f=(i+n)/2,y=(s+o)/2,m=(n+a)/2,x=(d+p)/2,S=(u+f)/2,v=(p+y)/2,b=(f+m)/2,P=(x+v)/2,C=(S+b)/2;if(c>0){let A=o-r,k=a-e;const M=Math.abs((t-o)*k-(i-a)*A),T=Math.abs((s-o)*k-(n-a)*A);if(M>hs&&T>hs){if((M+T)*(M+T)<=l*(A*A+k*k)){h.push(P,C);return}}else if(M>hs){if(M*M<=l*(A*A+k*k)){h.push(P,C);return}}else if(T>hs){if(T*T<=l*(A*A+k*k)){h.push(P,C);return}}else if(A=P-(r+o)/2,k=C-(e+a)/2,A*A+k*k<=l){h.push(P,C);return}}qn(r,e,d,u,x,S,P,C,h,l,c+1),qn(P,C,v,b,y,m,o,a,h,l,c+1)}const qf=8,Kf=11920929e-14,$f=1;function Qf(r,e,t,i,s,n,o,a){const l=Math.min(.99,Math.max(0,a??Cr.defaultOptions.bezierSmoothness));let c=($f-l)/1;return c*=c,Jf(e,t,i,s,n,o,r,c),r}function Jf(r,e,t,i,s,n,o,a){Kn(o,r,e,t,i,s,n,a,0),o.push(s,n)}function Kn(r,e,t,i,s,n,o,a,h){if(h>qf)return;const l=(e+i)/2,c=(t+s)/2,d=(i+n)/2,u=(s+o)/2,p=(l+d)/2,f=(c+u)/2;let y=n-e,m=o-t;const x=Math.abs((i-n)*m-(s-o)*y);if(x>Kf){if(x*x<=a*(y*y+m*m)){r.push(p,f);return}}else if(y=p-(e+n)/2,m=f-(t+o)/2,y*y+m*m<=a){r.push(p,f);return}Kn(r,e,t,l,c,p,f,a,h+1),Kn(r,p,f,d,u,n,o,a,h+1)}function bl(r,e,t,i,s,n,o,a){let h=Math.abs(s-n);(!o&&s>n||o&&n>s)&&(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=s;l*=o?-1:1;for(let d=0;d<a+1;d++){const u=Math.cos(c),p=Math.sin(c),f=e+u*i,y=t+p*i;r.push(f,y),c+=l}}function tg(r,e,t,i,s,n){const o=r[r.length-2],h=r[r.length-1]-t,l=o-e,c=s-t,d=i-e,u=Math.abs(h*d-l*c);if(u<1e-8||n===0){(r[r.length-2]!==e||r[r.length-1]!==t)&&r.push(e,t);return}const p=h*h+l*l,f=c*c+d*d,y=h*c+l*d,m=n*Math.sqrt(p)/u,x=n*Math.sqrt(f)/u,S=m*y/p,v=x*y/f,b=m*d+x*l,P=m*c+x*h,C=l*(x+S),A=h*(x+S),k=d*(m+v),M=c*(m+v),T=Math.atan2(A-P,C-b),_=Math.atan2(M-P,k-b);bl(r,b+e,P+t,n,T,_,l*c>d*h)}const ki=Math.PI*2,yn={centerX:0,centerY:0,ang1:0,ang2:0},xn=({x:r,y:e},t,i,s,n,o,a,h)=>{r*=t,e*=i;const l=s*r-n*e,c=n*r+s*e;return h.x=l+o,h.y=c+a,h};function eg(r,e){const t=e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),i=e===1.5707963267948966?.551915024494:t,s=Math.cos(r),n=Math.sin(r),o=Math.cos(r+e),a=Math.sin(r+e);return[{x:s-n*i,y:n+s*i},{x:o+a*i,y:a-o*i},{x:o,y:a}]}const ra=(r,e,t,i)=>{const s=r*i-e*t<0?-1:1;let n=r*t+e*i;return n>1&&(n=1),n<-1&&(n=-1),s*Math.acos(n)},ig=(r,e,t,i,s,n,o,a,h,l,c,d,u)=>{const p=Math.pow(s,2),f=Math.pow(n,2),y=Math.pow(c,2),m=Math.pow(d,2);let x=p*f-p*m-f*y;x<0&&(x=0),x/=p*m+f*y,x=Math.sqrt(x)*(o===a?-1:1);const S=x*s/n*d,v=x*-n/s*c,b=l*S-h*v+(r+t)/2,P=h*S+l*v+(e+i)/2,C=(c-S)/s,A=(d-v)/n,k=(-c-S)/s,M=(-d-v)/n,T=ra(1,0,C,A);let _=ra(C,A,k,M);a===0&&_>0&&(_-=ki),a===1&&_<0&&(_+=ki),u.centerX=b,u.centerY=P,u.ang1=T,u.ang2=_};function sg(r,e,t,i,s,n,o,a=0,h=0,l=0){if(n===0||o===0)return;const c=Math.sin(a*ki/360),d=Math.cos(a*ki/360),u=d*(e-i)/2+c*(t-s)/2,p=-c*(e-i)/2+d*(t-s)/2;if(u===0&&p===0)return;n=Math.abs(n),o=Math.abs(o);const f=Math.pow(u,2)/Math.pow(n,2)+Math.pow(p,2)/Math.pow(o,2);f>1&&(n*=Math.sqrt(f),o*=Math.sqrt(f)),ig(e,t,i,s,n,o,h,l,c,d,u,p,yn);let{ang1:y,ang2:m}=yn;const{centerX:x,centerY:S}=yn;let v=Math.abs(m)/(ki/4);Math.abs(1-v)<1e-7&&(v=1);const b=Math.max(Math.ceil(v),1);m/=b;let P=r[r.length-2],C=r[r.length-1];const A={x:0,y:0};for(let k=0;k<b;k++){const M=eg(y,m),{x:T,y:_}=xn(M[0],n,o,d,c,x,S,A),{x:E,y:B}=xn(M[1],n,o,d,c,x,S,A),{x:F,y:Z}=xn(M[2],n,o,d,c,x,S,A);vl(r,P,C,T,_,E,B,F,Z),P=F,C=Z,y+=m}}function ng(r,e,t){const i=(o,a)=>{const h=a.x-o.x,l=a.y-o.y,c=Math.sqrt(h*h+l*l),d=h/c,u=l/c;return{len:c,nx:d,ny:u}},s=(o,a)=>{o===0?r.moveTo(a.x,a.y):r.lineTo(a.x,a.y)};let n=e[e.length-1];for(let o=0;o<e.length;o++){const a=e[o%e.length],h=a.radius??t;if(h<=0){s(o,a),n=a;continue}const l=e[(o+1)%e.length],c=i(a,n),d=i(a,l);if(c.len<1e-4||d.len<1e-4){s(o,a),n=a;continue}let u=Math.asin(c.nx*d.ny-c.ny*d.nx),p=1,f=!1;c.nx*d.nx-c.ny*-d.ny<0?u<0?u=Math.PI+u:(u=Math.PI-u,p=-1,f=!0):u>0&&(p=-1,f=!0);const y=u/2;let m,x=Math.abs(Math.cos(y)*h/Math.sin(y));x>Math.min(c.len/2,d.len/2)?(x=Math.min(c.len/2,d.len/2),m=Math.abs(x*Math.sin(y)/Math.cos(y))):m=h;const S=a.x+d.nx*x+-d.ny*m*p,v=a.y+d.ny*x+d.nx*m*p,b=Math.atan2(c.ny,c.nx)+Math.PI/2*p,P=Math.atan2(d.ny,d.nx)-Math.PI/2*p;o===0&&r.moveTo(S+Math.cos(b)*m,v+Math.sin(b)*m),r.arc(S,v,m,b,P,f),n=a}}function rg(r,e,t,i){const s=(a,h)=>Math.sqrt((a.x-h.x)**2+(a.y-h.y)**2),n=(a,h,l)=>({x:a.x+(h.x-a.x)*l,y:a.y+(h.y-a.y)*l}),o=e.length;for(let a=0;a<o;a++){const h=e[(a+1)%o],l=h.radius??t;if(l<=0){a===0?r.moveTo(h.x,h.y):r.lineTo(h.x,h.y);continue}const c=e[a],d=e[(a+2)%o],u=s(c,h);let p;if(u<1e-4)p=h;else{const m=Math.min(u/2,l);p=n(h,c,m/u)}const f=s(d,h);let y;if(f<1e-4)y=h;else{const m=Math.min(f/2,l);y=n(h,d,m/f)}a===0?r.moveTo(p.x,p.y):r.lineTo(p.x,p.y),r.quadraticCurveTo(h.x,h.y,y.x,y.y,i)}}const og=new et;class ag{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Bt,this._graphicsPath2D=e,this.signed=e.checkForHoles}moveTo(e,t){return this.startPoly(e,t),this}lineTo(e,t){this._ensurePoly();const i=this._currentPoly.points,s=i[i.length-2],n=i[i.length-1];return(s!==e||n!==t)&&i.push(e,t),this}arc(e,t,i,s,n,o){this._ensurePoly(!1);const a=this._currentPoly.points;return bl(a,e,t,i,s,n,o),this}arcTo(e,t,i,s,n){this._ensurePoly();const o=this._currentPoly.points;return tg(o,e,t,i,s,n),this}arcToSvg(e,t,i,s,n,o,a){const h=this._currentPoly.points;return sg(h,this._currentPoly.lastX,this._currentPoly.lastY,o,a,e,t,i,s,n),this}bezierCurveTo(e,t,i,s,n,o,a){this._ensurePoly();const h=this._currentPoly;return vl(this._currentPoly.points,h.lastX,h.lastY,e,t,i,s,n,o,a),this}quadraticCurveTo(e,t,i,s,n){this._ensurePoly();const o=this._currentPoly;return Qf(this._currentPoly.points,o.lastX,o.lastY,e,t,i,s,n),this}closePath(){return this.endPoly(!0),this}addPath(e,t){this.endPoly(),t&&!t.isIdentity()&&(e=e.clone(!0),e.transform(t));const i=this.shapePrimitives,s=i.length;for(let n=0;n<e.instructions.length;n++){const o=e.instructions[n];this[o.action](...o.data)}if(e.checkForHoles&&i.length-s>1){let n=null;for(let o=s;o<i.length;o++){const a=i[o];if(a.shape.type==="polygon"){const h=a.shape,l=n==null?void 0:n.shape;l&&l.containsPolygon(h)?(n.holes||(n.holes=[]),n.holes.push(a),i.copyWithin(o,o+1),i.length--,o--):n=a}}}return this}finish(e=!1){this.endPoly(e)}rect(e,t,i,s,n){return this.drawShape(new et(e,t,i,s),n),this}circle(e,t,i,s){return this.drawShape(new Rs(e,t,i),s),this}poly(e,t,i){const s=new Te(e);return s.closePath=t,this.drawShape(s,i),this}regularPoly(e,t,i,s,n=0,o){s=Math.max(s|0,3);const a=-1*Math.PI/2+n,h=Math.PI*2/s,l=[];for(let c=0;c<s;c++){const d=a-c*h;l.push(e+i*Math.cos(d),t+i*Math.sin(d))}return this.poly(l,!0,o),this}roundPoly(e,t,i,s,n,o=0,a){if(s=Math.max(s|0,3),n<=0)return this.regularPoly(e,t,i,s,o);const h=i*Math.sin(Math.PI/s)-.001;n=Math.min(n,h);const l=-1*Math.PI/2+o,c=Math.PI*2/s,d=(s-2)*Math.PI/s/2;for(let u=0;u<s;u++){const p=u*c+l,f=e+i*Math.cos(p),y=t+i*Math.sin(p),m=p+Math.PI+d,x=p-Math.PI-d,S=f+n*Math.cos(m),v=y+n*Math.sin(m),b=f+n*Math.cos(x),P=y+n*Math.sin(x);u===0?this.moveTo(S,v):this.lineTo(S,v),this.quadraticCurveTo(f,y,b,P,a)}return this.closePath()}roundShape(e,t,i=!1,s){return e.length<3?this:(i?rg(this,e,t,s):ng(this,e,t),this.closePath())}filletRect(e,t,i,s,n){if(n===0)return this.rect(e,t,i,s);const o=Math.min(i,s)/2,a=Math.min(o,Math.max(-o,n)),h=e+i,l=t+s,c=a<0?-a:0,d=Math.abs(a);return this.moveTo(e,t+d).arcTo(e+c,t+c,e+d,t,d).lineTo(h-d,t).arcTo(h-c,t+c,h,t+d,d).lineTo(h,l-d).arcTo(h-c,l-c,e+i-d,l,d).lineTo(e+d,l).arcTo(e+c,l-c,e,l-d,d).closePath()}chamferRect(e,t,i,s,n,o){if(n<=0)return this.rect(e,t,i,s);const a=Math.min(n,Math.min(i,s)/2),h=e+i,l=t+s,c=[e+a,t,h-a,t,h,t+a,h,l-a,h-a,l,e+a,l,e,l-a,e,t+a];for(let d=c.length-1;d>=2;d-=2)c[d]===c[d-2]&&c[d-1]===c[d-3]&&c.splice(d-1,2);return this.poly(c,!0,o)}ellipse(e,t,i,s,n){return this.drawShape(new xr(e,t,i,s),n),this}roundRect(e,t,i,s,n,o){return this.drawShape(new Sr(e,t,i,s,n),o),this}drawShape(e,t){return this.endPoly(),this.shapePrimitives.push({shape:e,transform:t}),this}startPoly(e,t){let i=this._currentPoly;return i&&this.endPoly(),i=new Te,i.points.push(e,t),this._currentPoly=i,this}endPoly(e=!1){const t=this._currentPoly;return t&&t.points.length>2&&(t.closePath=e,this.shapePrimitives.push({shape:t})),this._currentPoly=null,this}_ensurePoly(e=!0){if(!this._currentPoly&&(this._currentPoly=new Te,e)){const t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let i=t.shape.x,s=t.shape.y;if(t.transform&&!t.transform.isIdentity()){const n=t.transform,o=i;i=n.a*i+n.c*s+n.tx,s=n.b*o+n.d*s+n.ty}this._currentPoly.points.push(i,s)}else this._currentPoly.points.push(0,0)}}buildPath(){const e=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let t=0;t<e.instructions.length;t++){const i=e.instructions[t];this[i.action](...i.data)}this.finish()}get bounds(){const e=this._bounds;e.clear();const t=this.shapePrimitives;for(let i=0;i<t.length;i++){const s=t[i],n=s.shape.getBounds(og);s.transform?e.addRect(n,s.transform):e.addRect(n)}return e}}class Jt{constructor(e,t=!1){this.instructions=[],this.uid=dt("graphicsPath"),this._dirty=!0,this.checkForHoles=t,typeof e=="string"?Bp(e,this):this.instructions=(e==null?void 0:e.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new ag(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(e,t){return e=e.clone(),this.instructions.push({action:"addPath",data:[e,t]}),this._dirty=!0,this}arc(...e){return this.instructions.push({action:"arc",data:e}),this._dirty=!0,this}arcTo(...e){return this.instructions.push({action:"arcTo",data:e}),this._dirty=!0,this}arcToSvg(...e){return this.instructions.push({action:"arcToSvg",data:e}),this._dirty=!0,this}bezierCurveTo(...e){return this.instructions.push({action:"bezierCurveTo",data:e}),this._dirty=!0,this}bezierCurveToShort(e,t,i,s,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(tt.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,d=a.y;h=c+(c-h),l=d+(d-l)}return this.instructions.push({action:"bezierCurveTo",data:[h,l,e,t,i,s,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...e){return this.instructions.push({action:"ellipse",data:e}),this._dirty=!0,this}lineTo(...e){return this.instructions.push({action:"lineTo",data:e}),this._dirty=!0,this}moveTo(...e){return this.instructions.push({action:"moveTo",data:e}),this}quadraticCurveTo(...e){return this.instructions.push({action:"quadraticCurveTo",data:e}),this._dirty=!0,this}quadraticCurveToShort(e,t,i){const s=this.instructions[this.instructions.length-1],n=this.getLastPoint(tt.shared);let o=0,a=0;if(!s||s.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=s.data[0],a=s.data[1];const h=n.x,l=n.y;o=h+(h-o),a=l+(l-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,e,t,i]}),this._dirty=!0,this}rect(e,t,i,s,n){return this.instructions.push({action:"rect",data:[e,t,i,s,n]}),this._dirty=!0,this}circle(e,t,i,s){return this.instructions.push({action:"circle",data:[e,t,i,s]}),this._dirty=!0,this}roundRect(...e){return this.instructions.push({action:"roundRect",data:e}),this._dirty=!0,this}poly(...e){return this.instructions.push({action:"poly",data:e}),this._dirty=!0,this}regularPoly(...e){return this.instructions.push({action:"regularPoly",data:e}),this._dirty=!0,this}roundPoly(...e){return this.instructions.push({action:"roundPoly",data:e}),this._dirty=!0,this}roundShape(...e){return this.instructions.push({action:"roundShape",data:e}),this._dirty=!0,this}filletRect(...e){return this.instructions.push({action:"filletRect",data:e}),this._dirty=!0,this}chamferRect(...e){return this.instructions.push({action:"chamferRect",data:e}),this._dirty=!0,this}star(e,t,i,s,n,o,a){n||(n=s/2);const h=-1*Math.PI/2+o,l=i*2,c=Math.PI*2/l,d=[];for(let u=0;u<l;u++){const p=u%2?n:s,f=u*c+h;d.push(e+p*Math.cos(f),t+p*Math.sin(f))}return this.poly(d,!0,a),this}clone(e=!1){const t=new Jt;if(t.checkForHoles=this.checkForHoles,!e)t.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const s=this.instructions[i];t.instructions.push({action:s.action,data:s.data.slice()})}return t}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(e){if(e.isIdentity())return this;const t=e.a,i=e.b,s=e.c,n=e.d,o=e.tx,a=e.ty;let h=0,l=0,c=0,d=0,u=0,p=0,f=0,y=0;for(let m=0;m<this.instructions.length;m++){const x=this.instructions[m],S=x.data;switch(x.action){case"moveTo":case"lineTo":h=S[0],l=S[1],S[0]=t*h+s*l+o,S[1]=i*h+n*l+a;break;case"bezierCurveTo":c=S[0],d=S[1],u=S[2],p=S[3],h=S[4],l=S[5],S[0]=t*c+s*d+o,S[1]=i*c+n*d+a,S[2]=t*u+s*p+o,S[3]=i*u+n*p+a,S[4]=t*h+s*l+o,S[5]=i*h+n*l+a;break;case"quadraticCurveTo":c=S[0],d=S[1],h=S[2],l=S[3],S[0]=t*c+s*d+o,S[1]=i*c+n*d+a,S[2]=t*h+s*l+o,S[3]=i*h+n*l+a;break;case"arcToSvg":h=S[5],l=S[6],f=S[0],y=S[1],S[0]=t*f+s*y,S[1]=i*f+n*y,S[5]=t*h+s*l+o,S[6]=i*h+n*l+a;break;case"circle":S[4]=yi(S[3],e);break;case"rect":S[4]=yi(S[4],e);break;case"ellipse":S[8]=yi(S[8],e);break;case"roundRect":S[5]=yi(S[5],e);break;case"addPath":S[0].transform(e);break;case"poly":S[2]=yi(S[2],e);break;default:nt("unknown transform action",x.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(e){let t=this.instructions.length-1,i=this.instructions[t];if(!i)return e.x=0,e.y=0,e;for(;i.action==="closePath";){if(t--,t<0)return e.x=0,e.y=0,e;i=this.instructions[t]}switch(i.action){case"moveTo":case"lineTo":e.x=i.data[0],e.y=i.data[1];break;case"quadraticCurveTo":e.x=i.data[2],e.y=i.data[3];break;case"bezierCurveTo":e.x=i.data[4],e.y=i.data[5];break;case"arc":case"arcToSvg":e.x=i.data[5],e.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(e);break}return e}}function yi(r,e){return r?r.prepend(e):e.clone()}function lt(r,e,t){const i=r.getAttribute(e);return i?Number(i):t}function hg(r,e){const t=r.querySelectorAll("defs");for(let i=0;i<t.length;i++){const s=t[i];for(let n=0;n<s.children.length;n++){const o=s.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":e.defs[o.id]=lg(o);break;case"radialgradient":e.defs[o.id]=cg();break}}}}function lg(r){const e=lt(r,"x1",0),t=lt(r,"y1",0),i=lt(r,"x2",1),s=lt(r,"y2",0),n=r.getAttribute("gradientUnits")||"objectBoundingBox",o=new Ot(e,t,i,s,n==="objectBoundingBox"?"local":"global");for(let a=0;a<r.children.length;a++){const h=r.children[a],l=lt(h,"offset",0),c=rt.shared.setValue(h.getAttribute("stop-color")).toNumber();o.addColorStop(l,c)}return o}function cg(r){return nt("[SVG Parser] Radial gradients are not yet supported"),new Ot(0,0,1,0)}function oa(r){const e=r.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}const aa={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 wl(r,e){const t=r.getAttribute("style"),i={},s={},n={strokeStyle:i,fillStyle:s,useFill:!1,useStroke:!1};for(const o in aa){const a=r.getAttribute(o);a&&ha(e,n,o,a.trim())}if(t){const o=t.split(";");for(let a=0;a<o.length;a++){const h=o[a].trim(),[l,c]=h.split(":");aa[l]&&ha(e,n,l,c.trim())}}return{strokeStyle:n.useStroke?i:null,fillStyle:n.useFill?s:null,useFill:n.useFill,useStroke:n.useStroke}}function ha(r,e,t,i){switch(t){case"stroke":if(i!=="none"){if(i.startsWith("url(")){const s=oa(i);e.strokeStyle.fill=r.defs[s]}else e.strokeStyle.color=rt.shared.setValue(i).toNumber();e.useStroke=!0}break;case"stroke-width":e.strokeStyle.width=Number(i);break;case"fill":if(i!=="none"){if(i.startsWith("url(")){const s=oa(i);e.fillStyle.fill=r.defs[s]}else e.fillStyle.color=rt.shared.setValue(i).toNumber();e.useFill=!0}break;case"fill-opacity":e.fillStyle.alpha=Number(i);break;case"stroke-opacity":e.strokeStyle.alpha=Number(i);break;case"opacity":e.fillStyle.alpha=Number(i),e.strokeStyle.alpha=Number(i);break}}function dg(r){if(r.length<=2)return!0;const e=r.map(a=>a.area).sort((a,h)=>h-a),[t,i]=e,s=e[e.length-1],n=t/i,o=i/s;return!(n>3&&o<2)}function ug(r){return r.split(/(?=[Mm])/).filter(i=>i.trim().length>0)}function pg(r){const e=r.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!e||e.length<4)return 0;const t=e.map(Number),i=[],s=[];for(let c=0;c<t.length;c+=2)c+1<t.length&&(i.push(t[c]),s.push(t[c+1]));if(i.length===0||s.length===0)return 0;const n=Math.min(...i),o=Math.max(...i),a=Math.min(...s),h=Math.max(...s);return(o-n)*(h-a)}function la(r,e){const t=new Jt(r,!1);for(const i of t.instructions)e.instructions.push(i)}function fg(r,e){if(typeof r=="string"){const o=document.createElement("div");o.innerHTML=r.trim(),r=o.querySelector("svg")}const t={context:e,defs:{},path:new Jt};hg(r,t);const i=r.children,{fillStyle:s,strokeStyle:n}=wl(r,t);for(let o=0;o<i.length;o++){const a=i[o];a.nodeName.toLowerCase()!=="defs"&&Cl(a,t,s,n)}return e}function Cl(r,e,t,i){const s=r.children,{fillStyle:n,strokeStyle:o}=wl(r,e);n&&t?t={...t,...n}:n&&(t=n),o&&i?i={...i,...o}:o&&(i=o);const a=!t&&!i;a&&(t={color:0});let h,l,c,d,u,p,f,y,m,x,S,v,b,P,C,A,k;switch(r.nodeName.toLowerCase()){case"path":{P=r.getAttribute("d");const M=r.getAttribute("fill-rule"),T=ug(P),_=M==="evenodd",E=T.length>1;if(_&&E){const F=T.map(R=>({path:R,area:pg(R)}));if(F.sort((R,D)=>D.area-R.area),T.length>3||!dg(F))for(let R=0;R<F.length;R++){const D=F[R],ot=R===0;e.context.beginPath();const z=new Jt(void 0,!0);la(D.path,z),e.context.path(z),ot?(t&&e.context.fill(t),i&&e.context.stroke(i)):e.context.cut()}else for(let R=0;R<F.length;R++){const D=F[R],ot=R%2===1;e.context.beginPath();const z=new Jt(void 0,!0);la(D.path,z),e.context.path(z),ot?e.context.cut():(t&&e.context.fill(t),i&&e.context.stroke(i))}}else{const F=M?M==="evenodd":!0;C=new Jt(P,F),e.context.path(C),t&&e.context.fill(t),i&&e.context.stroke(i)}break}case"circle":f=lt(r,"cx",0),y=lt(r,"cy",0),m=lt(r,"r",0),e.context.ellipse(f,y,m,m),t&&e.context.fill(t),i&&e.context.stroke(i);break;case"rect":h=lt(r,"x",0),l=lt(r,"y",0),A=lt(r,"width",0),k=lt(r,"height",0),x=lt(r,"rx",0),S=lt(r,"ry",0),x||S?e.context.roundRect(h,l,A,k,x||S):e.context.rect(h,l,A,k),t&&e.context.fill(t),i&&e.context.stroke(i);break;case"ellipse":f=lt(r,"cx",0),y=lt(r,"cy",0),x=lt(r,"rx",0),S=lt(r,"ry",0),e.context.beginPath(),e.context.ellipse(f,y,x,S),t&&e.context.fill(t),i&&e.context.stroke(i);break;case"line":c=lt(r,"x1",0),d=lt(r,"y1",0),u=lt(r,"x2",0),p=lt(r,"y2",0),e.context.beginPath(),e.context.moveTo(c,d),e.context.lineTo(u,p),i&&e.context.stroke(i);break;case"polygon":b=r.getAttribute("points"),v=b.match(/-?\d+/g).map(M=>parseInt(M,10)),e.context.poly(v,!0),t&&e.context.fill(t),i&&e.context.stroke(i);break;case"polyline":b=r.getAttribute("points"),v=b.match(/-?\d+/g).map(M=>parseInt(M,10)),e.context.poly(v,!1),i&&e.context.stroke(i);break;case"g":case"svg":break;default:{nt(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}a&&(t=null);for(let M=0;M<s.length;M++)Cl(s[M],e,t,i)}const ca={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 Is{constructor(e,t){this.uid=dt("fillPattern"),this._tick=0,this.transform=new U,this.texture=e,this.transform.scale(1/e.frame.width,1/e.frame.height),t&&(e.source.style.addressModeU=ca[t].addressModeU,e.source.style.addressModeV=ca[t].addressModeV)}setTransform(e){const t=this.texture;this.transform.copyFrom(e),this.transform.invert(),this.transform.scale(1/t.frame.width,1/t.frame.height),this._tick++}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture=e,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}function gg(r){return rt.isColorLike(r)}function da(r){return r instanceof Is}function ua(r){return r instanceof Ot}function mg(r){return r instanceof G}function yg(r,e,t){const i=rt.shared.setValue(e??0);return r.color=i.toNumber(),r.alpha=i.alpha===1?t.alpha:i.alpha,r.texture=G.WHITE,{...t,...r}}function xg(r,e,t){return r.texture=e,{...t,...r}}function pa(r,e,t){return r.fill=e,r.color=16777215,r.texture=e.texture,r.matrix=e.transform,{...t,...r}}function fa(r,e,t){return e.buildGradient(),r.fill=e,r.color=16777215,r.texture=e.texture,r.matrix=e.transform,r.textureSpace=e.textureSpace,{...t,...r}}function Sg(r,e){const t={...e,...r},i=rt.shared.setValue(t.color);return t.alpha*=i.alpha,t.color=i.toNumber(),t}function Me(r,e){if(r==null)return null;const t={},i=r;return gg(r)?yg(t,r,e):mg(r)?xg(t,r,e):da(r)?pa(t,r,e):ua(r)?fa(t,r,e):i.fill&&da(i.fill)?pa(i,i.fill,e):i.fill&&ua(i.fill)?fa(i,i.fill,e):Sg(i,e)}function Ss(r,e){const{width:t,alignment:i,miterLimit:s,cap:n,join:o,pixelLine:a,...h}=e,l=Me(r,h);return l?{width:t,alignment:i,miterLimit:s,cap:n,join:o,pixelLine:a,...l}:null}const vg=new tt,ga=new U,Ar=class Ht extends Yt{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=dt("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new Jt,this._transform=new U,this._fillStyle={...Ht.defaultFillStyle},this._strokeStyle={...Ht.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Bt,this._boundsDirty=!0}clone(){const e=new Ht;return e.batchMode=this.batchMode,e.instructions=this.instructions.slice(),e._activePath=this._activePath.clone(),e._transform=this._transform.clone(),e._fillStyle={...this._fillStyle},e._strokeStyle={...this._strokeStyle},e._stateStack=this._stateStack.slice(),e._bounds=this._bounds.clone(),e._boundsDirty=!0,e}get fillStyle(){return this._fillStyle}set fillStyle(e){this._fillStyle=Me(e,Ht.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=Ss(e,Ht.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=Me(e,Ht.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=Me(e,Ht.defaultStrokeStyle),this}texture(e,t,i,s,n,o){return this.instructions.push({action:"texture",data:{image:e,dx:i||0,dy:s||0,dw:n||e.frame.width,dh:o||e.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:t||t===0?rt.shared.setValue(t).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Jt,this}fill(e,t){let i;const s=this.instructions[this.instructions.length-1];return this._tick===0&&(s==null?void 0:s.action)==="stroke"?i=s.data.path:i=this._activePath.clone(),i?(e!=null&&(t!==void 0&&typeof e=="number"&&(V(J,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:t}),this._fillStyle=Me(e,Ht.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:e,y:t}=this._activePath.getLastPoint(tt.shared);this._activePath.clear(),this._activePath.moveTo(e,t)}stroke(e){let t;const i=this.instructions[this.instructions.length-1];return this._tick===0&&(i==null?void 0:i.action)==="fill"?t=i.data.path:t=this._activePath.clone(),t?(e!=null&&(this._strokeStyle=Ss(e,Ht.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:t}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let e=0;e<2;e++){const t=this.instructions[this.instructions.length-1-e],i=this._activePath.clone();if(t&&(t.action==="stroke"||t.action==="fill"))if(t.data.hole)t.data.hole.addPath(i);else{t.data.hole=i;break}}return this._initNextPathLocation(),this}arc(e,t,i,s,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*e+a.c*t+a.tx,a.b*e+a.d*t+a.ty,i,s,n,o),this}arcTo(e,t,i,s,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*i+o.c*s+o.tx,o.b*i+o.d*s+o.ty,n),this}arcToSvg(e,t,i,s,n,o,a){this._tick++;const h=this._transform;return this._activePath.arcToSvg(e,t,i,s,n,h.a*o+h.c*a+h.tx,h.b*o+h.d*a+h.ty),this}bezierCurveTo(e,t,i,s,n,o,a){this._tick++;const h=this._transform;return this._activePath.bezierCurveTo(h.a*e+h.c*t+h.tx,h.b*e+h.d*t+h.ty,h.a*i+h.c*s+h.tx,h.b*i+h.d*s+h.ty,h.a*n+h.c*o+h.tx,h.b*n+h.d*o+h.ty,a),this}closePath(){var e;return this._tick++,(e=this._activePath)==null||e.closePath(),this}ellipse(e,t,i,s){return this._tick++,this._activePath.ellipse(e,t,i,s,this._transform.clone()),this}circle(e,t,i){return this._tick++,this._activePath.circle(e,t,i,this._transform.clone()),this}path(e){return this._tick++,this._activePath.addPath(e,this._transform.clone()),this}lineTo(e,t){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*e+i.c*t+i.tx,i.b*e+i.d*t+i.ty),this}moveTo(e,t){this._tick++;const i=this._transform,s=this._activePath.instructions,n=i.a*e+i.c*t+i.tx,o=i.b*e+i.d*t+i.ty;return s.length===1&&s[0].action==="moveTo"?(s[0].data[0]=n,s[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(e,t,i,s,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*i+o.c*s+o.tx,o.b*i+o.d*s+o.ty,n),this}rect(e,t,i,s){return this._tick++,this._activePath.rect(e,t,i,s,this._transform.clone()),this}roundRect(e,t,i,s,n){return this._tick++,this._activePath.roundRect(e,t,i,s,n,this._transform.clone()),this}poly(e,t){return this._tick++,this._activePath.poly(e,t,this._transform.clone()),this}regularPoly(e,t,i,s,n=0,o){return this._tick++,this._activePath.regularPoly(e,t,i,s,n,o),this}roundPoly(e,t,i,s,n,o){return this._tick++,this._activePath.roundPoly(e,t,i,s,n,o),this}roundShape(e,t,i,s){return this._tick++,this._activePath.roundShape(e,t,i,s),this}filletRect(e,t,i,s,n){return this._tick++,this._activePath.filletRect(e,t,i,s,n),this}chamferRect(e,t,i,s,n,o){return this._tick++,this._activePath.chamferRect(e,t,i,s,n,o),this}star(e,t,i,s,n=0,o=0){return this._tick++,this._activePath.star(e,t,i,s,n,o,this._transform.clone()),this}svg(e){return this._tick++,fg(e,this),this}restore(){const e=this._stateStack.pop();return e&&(this._transform=e.transform,this._fillStyle=e.fillStyle,this._strokeStyle=e.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(e){return this._transform.rotate(e),this}scale(e,t=e){return this._transform.scale(e,t),this}setTransform(e,t,i,s,n,o){return e instanceof U?(this._transform.set(e.a,e.b,e.c,e.d,e.tx,e.ty),this):(this._transform.set(e,t,i,s,n,o),this)}transform(e,t,i,s,n,o){return e instanceof U?(this._transform.append(e),this):(ga.set(e,t,i,s,n,o),this._transform.append(ga),this)}translate(e,t=e){return this._transform.translate(e,t),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,!this.dirty&&(this.emit("update",this,16),this.dirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const e=this._bounds;e.clear();for(let t=0;t<this.instructions.length;t++){const i=this.instructions[t],s=i.action;if(s==="fill"){const n=i.data;e.addBounds(n.path.bounds)}else if(s==="texture"){const n=i.data;e.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(s==="stroke"){const n=i.data,o=n.style.alignment,a=n.style.width*(1-o),h=n.path.bounds;e.addFrame(h.minX-a,h.minY-a,h.maxX+a,h.maxY+a)}}return e}containsPoint(e){var s;if(!this.bounds.containsPoint(e.x,e.y))return!1;const t=this.instructions;let i=!1;for(let n=0;n<t.length;n++){const o=t[n],a=o.data,h=a.path;if(!o.action||!h)continue;const l=a.style,c=h.shapePath.shapePrimitives;for(let d=0;d<c.length;d++){const u=c[d].shape;if(!l||!u)continue;const p=c[d].transform,f=p?p.applyInverse(e,vg):e;if(o.action==="fill")i=u.contains(f.x,f.y);else{const m=l;i=u.strokeContains(f.x,f.y,m.width,m.alignment)}const y=a.hole;if(y){const m=(s=y.shapePath)==null?void 0:s.shapePrimitives;if(m)for(let x=0;x<m.length;x++)m[x].shape.contains(f.x,f.y)&&(i=!1)}if(i)return!0}}return i}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.destroy();this._gpuData=Object.create(null)}destroy(e=!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 e=="boolean"?e:e==null?void 0:e.texture){const i=typeof e=="boolean"?e:e==null?void 0:e.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}};Ar.defaultFillStyle={color:16777215,alpha:1,texture:G.WHITE,matrix:null,fill:null,textureSpace:"local"};Ar.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:G.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let mt=Ar;function Pr(r,e=1){var i;const t=(i=hi.RETINA_PREFIX)==null?void 0:i.exec(r);return t?parseFloat(t[1]):e}function Mr(r,e,t){r.label=t,r._sourceOrigin=t;const i=new G({source:r,label:t}),s=()=>{delete e.promiseCache[t],xt.has(t)&&xt.remove(t)};return i.source.once("destroy",()=>{e.promiseCache[t]&&(nt("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),s())}),i.once("destroy",()=>{r.destroyed||(nt("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),s())}),i}const bg=".svg",_r="image/svg+xml",wg={extension:{type:I.LoadParser,priority:ue.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return pe(r,_r)||li(r,bg)},async load(r,e,t){var i;return((i=e.data)==null?void 0:i.parseAsGraphicsContext)??this.config.parseAsGraphicsContext?Pg(r):Cg(r,e,t,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function Cg(r,e,t,i){var m,x,S;const s=pe(r,_r),n=j.get().createImage();n.crossOrigin=i,n.src=r,await new Promise((v,b)=>{n.complete?v(n):(n.onload=()=>v(n),n.onerror=b)}),await n.decode();const o=((m=e.data)==null?void 0:m.width)??n.width,a=((x=e.data)==null?void 0:x.height)??n.height,h=((S=e.data)==null?void 0:S.resolution)||Pr(r),l=Math.ceil(o*h),c=Math.ceil(a*h),d=j.get().createCanvas(l,c),u=d.getContext("2d");u.imageSmoothingEnabled=!0,u.imageSmoothingQuality="high",u.drawImage(n,0,0,o*h,a*h);const{parseAsGraphicsContext:p,...f}=e.data??{},y=new ii({resource:d,alphaMode:"premultiply-alpha-on-upload",resolution:h,...f});return Mr(y,t,r)}function Ag(r){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let t="",i=0;for(r=r.replace(/[^A-Za-z0-9\+\/\=]/g,"");i<r.length;){const s=e.indexOf(r.charAt(i++)),n=e.indexOf(r.charAt(i++)),o=e.indexOf(r.charAt(i++)),a=e.indexOf(r.charAt(i++)),h=s<<2|n>>4,l=(n&15)<<4|o>>2,c=(o&3)<<6|a;t+=String.fromCharCode(h),o!==64&&(t+=String.fromCharCode(l)),a!==64&&(t+=String.fromCharCode(c))}return t}async function Pg(r){const e=pe(r,_r);let t;if(e)if(r.includes(";base64,")){const s=r.split(";base64,")[1];t=Ag(s)}else{const s=r.split(",")[1];t=decodeURIComponent(s)}else t=await(await j.get().fetch(r)).text();const i=new mt;return i.svg(t),i}const Mg=`(function () {
|
|
240
|
+
`}},Ko={};function vf(r){let e=Ko[r];if(e)return e;const t=new Int32Array(r);for(let i=0;i<r;i++)t[i]=i;return e=Ko[r]=new ni({uTextures:{value:t,type:"i32",size:r}},{isStatic:!0}),e}class $o extends Be{constructor(e){const t=cl({name:"batch",bits:[ff,Sf(e),ul]}),i=ll({name:"batch",bits:[pf,yf(e),dl]});super({glProgram:t,gpuProgram:i,resources:{batchSamplers:vf(e)}}),this.maxTextures=e}}let mi=null;const pl=class fl extends Yp{constructor(e){super(e),this.geometry=new $p,this.name=fl.extension.name,this.vertexSize=6,mi??(mi=new $o(e.maxTextures)),this.shader=mi}packAttributes(e,t,i,s,n){const o=n<<16|e.roundPixels&65535,a=e.transform,h=a.a,l=a.b,c=a.c,d=a.d,u=a.tx,p=a.ty,{positions:f,uvs:y}=e,m=e.color,x=e.attributeOffset,S=x+e.attributeSize;for(let v=x;v<S;v++){const b=v*2,P=f[b],C=f[b+1];t[s++]=h*P+c*C+u,t[s++]=d*C+l*P+p,t[s++]=y[b],t[s++]=y[b+1],i[s++]=m,i[s++]=o}}packQuadAttributes(e,t,i,s,n){const o=e.texture,a=e.transform,h=a.a,l=a.b,c=a.c,d=a.d,u=a.tx,p=a.ty,f=e.bounds,y=f.maxX,m=f.minX,x=f.maxY,S=f.minY,v=o.uvs,b=e.color,P=n<<16|e.roundPixels&65535;t[s+0]=h*m+c*S+u,t[s+1]=d*S+l*m+p,t[s+2]=v.x0,t[s+3]=v.y0,i[s+4]=b,i[s+5]=P,t[s+6]=h*y+c*S+u,t[s+7]=d*S+l*y+p,t[s+8]=v.x1,t[s+9]=v.y1,i[s+10]=b,i[s+11]=P,t[s+12]=h*y+c*x+u,t[s+13]=d*x+l*y+p,t[s+14]=v.x2,t[s+15]=v.y2,i[s+16]=b,i[s+17]=P,t[s+18]=h*m+c*x+u,t[s+19]=d*x+l*m+p,t[s+20]=v.x3,t[s+21]=v.y3,i[s+22]=b,i[s+23]=P}_updateMaxTextures(e){this.shader.maxTextures!==e&&(mi=new $o(e),this.shader=mi)}destroy(){this.shader=null,super.destroy()}};pl.extension={type:[I.Batcher],name:"default"};let bf=pl;class ci{constructor(e){this.items=Object.create(null);const{renderer:t,type:i,onUnload:s,priority:n,name:o}=e;this._renderer=t,t.gc.addResourceHash(this,"items",i,n??0),this._onUnload=s,this.name=o}add(e){return this.items[e.uid]?!1:(this.items[e.uid]=e,e.once("unload",this.remove,this),e._gcLastUsed=this._renderer.gc.now,!0)}remove(e,...t){var s;if(!this.items[e.uid])return;const i=e._gpuData[this._renderer.uid];i&&((s=this._onUnload)==null||s.call(this,e,...t),i.destroy(),e._gpuData[this._renderer.uid]=null,this.items[e.uid]=null)}removeAll(...e){Object.values(this.items).forEach(t=>t&&this.remove(t,...e))}destroy(...e){this.removeAll(...e),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function wf(r,e,t,i,s,n,o,a=null){let h=0;t*=e,s*=n;const l=a.a,c=a.b,d=a.c,u=a.d,p=a.tx,f=a.ty;for(;h<o;){const y=r[t],m=r[t+1];i[s]=l*y+d*m+p,i[s+1]=c*y+u*m+f,s+=n,t+=e,h++}}function Cf(r,e,t,i){let s=0;for(e*=t;s<i;)r[e]=0,r[e+1]=0,e+=t,s++}function gl(r,e,t,i,s){const n=e.a,o=e.b,a=e.c,h=e.d,l=e.tx,c=e.ty;t||(t=0),i||(i=2),s||(s=r.length/i-t);let d=t*i;for(let u=0;u<s;u++){const p=r[d],f=r[d+1];r[d]=n*p+a*f+l,r[d+1]=o*p+h*f+c,d+=i}}const Af=new U;class Sr{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 e=this.baseColor,t=e>>16|e&65280|(e&255)<<16,i=this.renderable;return i?ur(t,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):t+(this.alpha*255<<24)}get transform(){var e;return((e=this.renderable)==null?void 0:e.groupTransform)||Af}copyTo(e){e.indexOffset=this.indexOffset,e.indexSize=this.indexSize,e.attributeOffset=this.attributeOffset,e.attributeSize=this.attributeSize,e.baseColor=this.baseColor,e.alpha=this.alpha,e.texture=this.texture,e.geometryData=this.geometryData,e.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 Gi={extension:{type:I.ShapeBuilder,name:"circle"},build(r,e){let t,i,s,n,o,a;if(r.type==="circle"){const b=r;if(o=a=b.radius,o<=0)return!1;t=b.x,i=b.y,s=n=0}else if(r.type==="ellipse"){const b=r;if(o=b.halfWidth,a=b.halfHeight,o<=0||a<=0)return!1;t=b.x,i=b.y,s=n=0}else{const b=r,P=b.width/2,C=b.height/2;t=b.x+P,i=b.y+C,o=a=Math.max(0,Math.min(b.radius,Math.min(P,C))),s=P-o,n=C-a}if(s<0||n<0)return!1;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(s?4:0)+(n?4:0);if(l===0)return!1;if(h===0)return e[0]=e[6]=t+s,e[1]=e[3]=i+n,e[2]=e[4]=t-s,e[5]=e[7]=i-n,!0;let c=0,d=h*4+(s?2:0)+2,u=d,p=l,f=s+o,y=n,m=t+f,x=t-f,S=i+y;if(e[c++]=m,e[c++]=S,e[--d]=S,e[--d]=x,n){const b=i-y;e[u++]=x,e[u++]=b,e[--p]=b,e[--p]=m}for(let b=1;b<h;b++){const P=Math.PI/2*(b/h),C=s+Math.cos(P)*o,A=n+Math.sin(P)*a,k=t+C,M=t-C,T=i+A,_=i-A;e[c++]=k,e[c++]=T,e[--d]=T,e[--d]=M,e[u++]=M,e[u++]=_,e[--p]=_,e[--p]=k}f=s,y=n+a,m=t+f,x=t-f,S=i+y;const v=i-y;return e[c++]=m,e[c++]=S,e[--p]=v,e[--p]=m,s&&(e[c++]=x,e[c++]=S,e[--p]=v,e[--p]=x),!0},triangulate(r,e,t,i,s,n){if(r.length===0)return;let o=0,a=0;for(let c=0;c<r.length;c+=2)o+=r[c],a+=r[c+1];o/=r.length/2,a/=r.length/2;let h=i;e[h*t]=o,e[h*t+1]=a;const l=h++;for(let c=0;c<r.length;c+=2)e[h*t]=r[c],e[h*t+1]=r[c+1],c>0&&(s[n++]=h,s[n++]=l,s[n++]=h-1),h++;s[n++]=l+1,s[n++]=l,s[n++]=h-1}},Pf={...Gi,extension:{...Gi.extension,name:"ellipse"}},Mf={...Gi,extension:{...Gi.extension,name:"roundedRectangle"}},ml=1e-4,Qo=1e-4;function _f(r){const e=r.length;if(e<6)return 1;let t=0;for(let i=0,s=r[e-2],n=r[e-1];i<e;i+=2){const o=r[i],a=r[i+1];t+=(o-s)*(a+n),s=o,n=a}return t<0?-1:1}function Jo(r,e,t,i,s,n,o,a){const h=r-t*s,l=e-i*s,c=r+t*n,d=e+i*n;let u,p;o?(u=i,p=-t):(u=-i,p=t);const f=h+u,y=l+p,m=c+u,x=d+p;return a.push(f,y),a.push(m,x),2}function xe(r,e,t,i,s,n,o,a){const h=t-r,l=i-e;let c=Math.atan2(h,l),d=Math.atan2(s-r,n-e);a&&c<d?c+=Math.PI*2:!a&&c>d&&(d+=Math.PI*2);let u=c;const p=d-c,f=Math.abs(p),y=Math.sqrt(h*h+l*l),m=(15*f*Math.sqrt(y)/Math.PI>>0)+1,x=p/m;if(u+=x,a){o.push(r,e),o.push(t,i);for(let S=1,v=u;S<m;S++,v+=x)o.push(r,e),o.push(r+Math.sin(v)*y,e+Math.cos(v)*y);o.push(r,e),o.push(s,n)}else{o.push(t,i),o.push(r,e);for(let S=1,v=u;S<m;S++,v+=x)o.push(r+Math.sin(v)*y,e+Math.cos(v)*y),o.push(r,e);o.push(s,n),o.push(r,e)}return m*2}function Tf(r,e,t,i,s,n){const o=ml;if(r.length===0)return;const a=e;let h=a.alignment;if(e.alignment!==.5){let z=_f(r);h=(h-.5)*z+.5}const l=new tt(r[0],r[1]),c=new tt(r[r.length-2],r[r.length-1]),d=i,u=Math.abs(l.x-c.x)<o&&Math.abs(l.y-c.y)<o;if(d){r=r.slice(),u&&(r.pop(),r.pop(),c.set(r[r.length-2],r[r.length-1]));const z=(l.x+c.x)*.5,q=(c.y+l.y)*.5;r.unshift(z,q),r.push(z,q)}const p=s,f=r.length/2;let y=r.length;const m=p.length/2,x=a.width/2,S=x*x,v=a.miterLimit*a.miterLimit;let b=r[0],P=r[1],C=r[2],A=r[3],k=0,M=0,T=-(P-A),_=b-C,E=0,B=0,F=Math.sqrt(T*T+_*_);T/=F,_/=F,T*=x,_*=x;const Z=h,R=(1-Z)*2,D=Z*2;d||(a.cap==="round"?y+=xe(b-T*(R-D)*.5,P-_*(R-D)*.5,b-T*R,P-_*R,b+T*D,P+_*D,p,!0)+2:a.cap==="square"&&(y+=Jo(b,P,T,_,R,D,!0,p))),p.push(b-T*R,P-_*R),p.push(b+T*D,P+_*D);for(let z=1;z<f-1;++z){b=r[(z-1)*2],P=r[(z-1)*2+1],C=r[z*2],A=r[z*2+1],k=r[(z+1)*2],M=r[(z+1)*2+1],T=-(P-A),_=b-C,F=Math.sqrt(T*T+_*_),T/=F,_/=F,T*=x,_*=x,E=-(A-M),B=C-k,F=Math.sqrt(E*E+B*B),E/=F,B/=F,E*=x,B*=x;const q=C-b,Y=P-A,ht=C-k,bt=M-A,wt=q*ht+Y*bt,kt=Y*ht-bt*q,Wt=kt<0;if(Math.abs(kt)<.001*Math.abs(wt)){p.push(C-T*R,A-_*R),p.push(C+T*D,A+_*D),wt>=0&&(a.join==="round"?y+=xe(C,A,C-T*R,A-_*R,C-E*R,A-B*R,p,!1)+4:y+=2,p.push(C-E*D,A-B*D),p.push(C+E*R,A+B*R));continue}const Yi=(-T+b)*(-_+A)-(-T+C)*(-_+P),Zr=(-E+k)*(-B+A)-(-E+C)*(-B+M),Xi=(q*Zr-ht*Yi)/kt,Zi=(bt*Yi-Y*Zr)/kt,Hs=(Xi-C)*(Xi-C)+(Zi-A)*(Zi-A),fe=C+(Xi-C)*R,ge=A+(Zi-A)*R,me=C-(Xi-C)*D,ye=A-(Zi-A)*D,Ac=Math.min(q*q+Y*Y,ht*ht+bt*bt),qr=Wt?R:D,Pc=Ac+qr*qr*S;Hs<=Pc?a.join==="bevel"||Hs/S>v?(Wt?(p.push(fe,ge),p.push(C+T*D,A+_*D),p.push(fe,ge),p.push(C+E*D,A+B*D)):(p.push(C-T*R,A-_*R),p.push(me,ye),p.push(C-E*R,A-B*R),p.push(me,ye)),y+=2):a.join==="round"?Wt?(p.push(fe,ge),p.push(C+T*D,A+_*D),y+=xe(C,A,C+T*D,A+_*D,C+E*D,A+B*D,p,!0)+4,p.push(fe,ge),p.push(C+E*D,A+B*D)):(p.push(C-T*R,A-_*R),p.push(me,ye),y+=xe(C,A,C-T*R,A-_*R,C-E*R,A-B*R,p,!1)+4,p.push(C-E*R,A-B*R),p.push(me,ye)):(p.push(fe,ge),p.push(me,ye)):(p.push(C-T*R,A-_*R),p.push(C+T*D,A+_*D),a.join==="round"?Wt?y+=xe(C,A,C+T*D,A+_*D,C+E*D,A+B*D,p,!0)+2:y+=xe(C,A,C-T*R,A-_*R,C-E*R,A-B*R,p,!1)+2:a.join==="miter"&&Hs/S<=v&&(Wt?(p.push(me,ye),p.push(me,ye)):(p.push(fe,ge),p.push(fe,ge)),y+=2),p.push(C-E*R,A-B*R),p.push(C+E*D,A+B*D),y+=2)}b=r[(f-2)*2],P=r[(f-2)*2+1],C=r[(f-1)*2],A=r[(f-1)*2+1],T=-(P-A),_=b-C,F=Math.sqrt(T*T+_*_),T/=F,_/=F,T*=x,_*=x,p.push(C-T*R,A-_*R),p.push(C+T*D,A+_*D),d||(a.cap==="round"?y+=xe(C-T*(R-D)*.5,A-_*(R-D)*.5,C-T*R,A-_*R,C+T*D,A+_*D,p,!1)+2:a.cap==="square"&&(y+=Jo(C,A,T,_,R,D,!1,p)));const ot=Qo*Qo;for(let z=m;z<y+m-2;++z)b=p[z*2],P=p[z*2+1],C=p[(z+1)*2],A=p[(z+1)*2+1],k=p[(z+2)*2],M=p[(z+2)*2+1],!(Math.abs(b*(A-M)+C*(M-P)+k*(P-A))<ot)&&n.push(z,z+1,z+2)}function kf(r,e,t,i){const s=ml;if(r.length===0)return;const n=r[0],o=r[1],a=r[r.length-2],h=r[r.length-1],l=e||Math.abs(n-a)<s&&Math.abs(o-h)<s,c=t,d=r.length/2,u=c.length/2;for(let p=0;p<d;p++)c.push(r[p*2]),c.push(r[p*2+1]);for(let p=0;p<d-1;p++)i.push(u+p,u+p+1);l&&i.push(u+d-1,u)}function yl(r,e,t,i,s,n,o){const a=Yu(r,e,2);if(!a)return;for(let l=0;l<a.length;l+=3)n[o++]=a[l]+s,n[o++]=a[l+1]+s,n[o++]=a[l+2]+s;let h=s*i;for(let l=0;l<r.length;l+=2)t[h]=r[l],t[h+1]=r[l+1],h+=i}const Rf=[],Ef={extension:{type:I.ShapeBuilder,name:"polygon"},build(r,e){for(let t=0;t<r.points.length;t++)e[t]=r.points[t];return!0},triangulate(r,e,t,i,s,n){yl(r,Rf,e,t,i,s,n)}},If={extension:{type:I.ShapeBuilder,name:"rectangle"},build(r,e){const t=r,i=t.x,s=t.y,n=t.width,o=t.height;return n>0&&o>0?(e[0]=i,e[1]=s,e[2]=i+n,e[3]=s,e[4]=i+n,e[5]=s+o,e[6]=i,e[7]=s+o,!0):!1},triangulate(r,e,t,i,s,n){let o=0;i*=t,e[i+o]=r[0],e[i+o+1]=r[1],o+=t,e[i+o]=r[2],e[i+o+1]=r[3],o+=t,e[i+o]=r[6],e[i+o+1]=r[7],o+=t,e[i+o]=r[4],e[i+o+1]=r[5],o+=t;const a=i/t;s[n++]=a,s[n++]=a+1,s[n++]=a+2,s[n++]=a+1,s[n++]=a+3,s[n++]=a+2}},Bf={extension:{type:I.ShapeBuilder,name:"triangle"},build(r,e){return e[0]=r.x,e[1]=r.y,e[2]=r.x2,e[3]=r.y2,e[4]=r.x3,e[5]=r.y3,!0},triangulate(r,e,t,i,s,n){let o=0;i*=t,e[i+o]=r[0],e[i+o+1]=r[1],o+=t,e[i+o]=r[2],e[i+o+1]=r[3],o+=t,e[i+o]=r[4],e[i+o+1]=r[5];const a=i/t;s[n++]=a,s[n++]=a+1,s[n++]=a+2}},ta=[{offset:0,color:"white"},{offset:1,color:"black"}],vr=class Yn{constructor(...e){this.uid=dt("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let t=Df(e);t={...t.type==="radial"?Yn.defaultRadialOptions:Yn.defaultLinearOptions,...ah(t)},this._textureSize=t.textureSize,this._wrapMode=t.wrapMode,t.type==="radial"?(this.center=t.center,this.outerCenter=t.outerCenter??this.center,this.innerRadius=t.innerRadius,this.outerRadius=t.outerRadius,this.scale=t.scale,this.rotation=t.rotation):(this.start=t.start,this.end=t.end),this.textureSpace=t.textureSpace,this.type=t.type,t.colorStops.forEach(s=>{this.addColorStop(s.offset,s.color)})}addColorStop(e,t){return this.colorStops.push({offset:e,color:rt.shared.setValue(t).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:e,y:t}=this.start,{x:i,y:s}=this.end,n=i-e,o=s-t;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const m=e;e=i,i=m,n*=-1}if(o<0){const m=t;t=s,s=m,o*=-1}}const h=this.colorStops.length?this.colorStops:ta,l=this._textureSize,{canvas:c,context:d}=ia(l,1),u=a?d.createLinearGradient(this._textureSize,0,0,0):d.createLinearGradient(0,0,this._textureSize,0);ea(u,h),d.fillStyle=u,d.fillRect(0,0,l,1),this.texture=new W({source:new ii({resource:c,addressMode:this._wrapMode})});const p=Math.sqrt(n*n+o*o),f=Math.atan2(o,n),y=new U;y.scale(p/l,1),y.rotate(f),y.translate(e,t),this.textureSpace==="local"&&y.scale(l,l),this.transform=y}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const e=this.colorStops.length?this.colorStops:ta,t=this._textureSize,{canvas:i,context:s}=ia(t,t),{x:n,y:o}=this.center,{x:a,y:h}=this.outerCenter,l=this.innerRadius,c=this.outerRadius,d=a-c,u=h-c,p=t/(c*2),f=(n-d)*p,y=(o-u)*p,m=s.createRadialGradient(f,y,l*p,(a-d)*p,(h-u)*p,c*p);ea(m,e),s.fillStyle=e[e.length-1].color,s.fillRect(0,0,t,t),s.fillStyle=m,s.translate(f,y),s.rotate(this.rotation),s.scale(1,this.scale),s.translate(-f,-y),s.fillRect(0,0,t,t),this.texture=new W({source:new ii({resource:i,addressMode:this._wrapMode})});const x=new U;x.scale(1/p,1/p),x.translate(d,u),this.textureSpace==="local"&&x.scale(t,t),this.transform=x}destroy(){var e;(e=this.texture)==null||e.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}`}};vr.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};vr.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Ot=vr;function ea(r,e){for(let t=0;t<e.length;t++){const i=e[t];r.addColorStop(i.offset,i.color)}}function ia(r,e){const t=j.get().createCanvas(r,e),i=t.getContext("2d");return{canvas:t,context:i}}function Df(r){let e=r[0]??{};return(typeof e=="number"||r[1])&&(V("8.5.2","use options object instead"),e={type:"linear",start:{x:r[0],y:r[1]},end:{x:r[2],y:r[3]},textureSpace:r[4],textureSize:r[5]??Ot.defaultLinearOptions.textureSize}),e}const Ff=new U,zf=new et;function Lf(r,e,t,i){const s=e.matrix?r.copyFrom(e.matrix).invert():r.identity();if(e.textureSpace==="local"){const o=t.getBounds(zf);e.width&&o.pad(e.width);const{x:a,y:h}=o,l=1/o.width,c=1/o.height,d=-a*l,u=-h*c,p=s.a,f=s.b,y=s.c,m=s.d;s.a*=l,s.b*=l,s.c*=c,s.d*=c,s.tx=d*p+u*y+s.tx,s.ty=d*f+u*m+s.ty}else s.translate(e.texture.frame.x,e.texture.frame.y),s.scale(1/e.texture.source.width,1/e.texture.source.height);const n=e.texture.source.style;return!(e.fill instanceof Ot)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),i&&s.append(Ff.copyFrom(i).invert()),s}const Es={};$.handleByMap(I.ShapeBuilder,Es);$.add(If,Ef,Bf,Gi,Pf,Mf);const Of=new et,Wf=new U;function Gf(r,e){const{geometryData:t,batches:i}=e;i.length=0,t.indices.length=0,t.vertices.length=0,t.uvs.length=0;for(let s=0;s<r.instructions.length;s++){const n=r.instructions[s];if(n.action==="texture")Uf(n.data,i,t);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,h=n.data.style,l=n.data.hole;o&&l&&sa(l.shapePath,h,!0,i,t),l&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=l.shapePath.shapePrimitives),sa(a,h,o,i,t)}}}function Uf(r,e,t){const i=[],s=Es.rectangle,n=Of;n.x=r.dx,n.y=r.dy,n.width=r.dw,n.height=r.dh;const o=r.transform;if(!s.build(n,i))return;const{vertices:a,uvs:h,indices:l}=t,c=l.length,d=a.length/2;o&&gl(i,o),s.triangulate(i,a,2,d,l,c);const u=r.image,p=u.uvs;h.push(p.x0,p.y0,p.x1,p.y1,p.x3,p.y3,p.x2,p.y2);const f=_t.get(Sr);f.indexOffset=c,f.indexSize=l.length-c,f.attributeOffset=d,f.attributeSize=a.length/2-d,f.baseColor=r.style,f.alpha=r.alpha,f.texture=u,f.geometryData=t,e.push(f)}function sa(r,e,t,i,s){const{vertices:n,uvs:o,indices:a}=s;r.shapePrimitives.forEach(({shape:h,transform:l,holes:c})=>{const d=[],u=Es[h.type];if(!u.build(h,d))return;const p=a.length,f=n.length/2;let y="triangle-list";if(l&&gl(d,l),t){const v=h.closePath??!0,b=e;b.pixelLine?(kf(d,v,n,a),y="line-list"):Tf(d,b,!1,v,n,a)}else if(c){const v=[],b=d.slice();Hf(c).forEach(C=>{v.push(b.length/2),b.push(...C)}),yl(b,v,n,2,f,a,p)}else u.triangulate(d,n,2,f,a,p);const m=o.length/2,x=e.texture;if(x!==W.WHITE){const v=Lf(Wf,e,h,l);wf(n,2,f,o,m,2,n.length/2-f,v)}else Cf(o,m,2,n.length/2-f);const S=_t.get(Sr);S.indexOffset=p,S.indexSize=a.length-p,S.attributeOffset=f,S.attributeSize=n.length/2-f,S.baseColor=e.color,S.alpha=e.alpha,S.texture=x,S.geometryData=s,S.topology=y,i.push(S)})}function Hf(r){const e=[];for(let t=0;t<r.length;t++){const i=r[t].shape,s=[];Es[i.type].build(i,s)&&e.push(s)}return e}class Vf{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(e=>{_t.return(e)}),this.graphicsData&&_t.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 Nf{constructor(){this.instructions=new pr}init(e){const t=e.maxTextures;this.batcher?this.batcher._updateMaxTextures(t):this.batcher=new bf({maxTextures:t}),this.instructions.reset()}get geometry(){return V(dd,"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 br=class Xn{constructor(e){this._renderer=e,this._managedContexts=new ci({renderer:e,type:"resource",name:"graphicsContext"})}init(e){Xn.defaultOptions.bezierSmoothness=(e==null?void 0:e.bezierSmoothness)??Xn.defaultOptions.bezierSmoothness}getContextRenderData(e){return e._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(e)}updateGpuContext(e){const t=!!e._gpuData[this._renderer.uid],i=e._gpuData[this._renderer.uid]||this._initContext(e);if(e.dirty||!t){t&&i.reset(),Gf(e,i);const s=e.batchMode;e.customShader||s==="no-batch"?i.isBatchable=!1:s==="auto"?i.isBatchable=i.geometryData.vertices.length<400:i.isBatchable=!0,e.dirty=!1}return i}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){const t=_t.get(Nf,{maxTextures:this._renderer.limits.maxBatchableTextures}),i=e._gpuData[this._renderer.uid],{batches:s,geometryData:n}=i;i.graphicsData=t;const o=n.vertices.length,a=n.indices.length;for(let d=0;d<s.length;d++)s[d].applyTransform=!1;const h=t.batcher;h.ensureAttributeBuffer(o),h.ensureIndexBuffer(a),h.begin();for(let d=0;d<s.length;d++){const u=s[d];h.add(u)}h.finish(t.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 d=0;d<c.length;d++){const u=c[d];u.bindGroup=zp(u.textures.textures,u.textures.count,this._renderer.limits.maxBatchableTextures)}return t}_initContext(e){const t=new Vf;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};br.extension={type:[I.WebGLSystem,I.WebGPUSystem],name:"graphicsContext"};br.defaultOptions={bezierSmoothness:.5};let wr=br;const jf=8,hs=11920929e-14,Yf=1;function xl(r,e,t,i,s,n,o,a,h,l){const d=Math.min(.99,Math.max(0,l??wr.defaultOptions.bezierSmoothness));let u=(Yf-d)/1;return u*=u,Xf(e,t,i,s,n,o,a,h,r,u),r}function Xf(r,e,t,i,s,n,o,a,h,l){Zn(r,e,t,i,s,n,o,a,h,l,0),h.push(o,a)}function Zn(r,e,t,i,s,n,o,a,h,l,c){if(c>jf)return;const d=(r+t)/2,u=(e+i)/2,p=(t+s)/2,f=(i+n)/2,y=(s+o)/2,m=(n+a)/2,x=(d+p)/2,S=(u+f)/2,v=(p+y)/2,b=(f+m)/2,P=(x+v)/2,C=(S+b)/2;if(c>0){let A=o-r,k=a-e;const M=Math.abs((t-o)*k-(i-a)*A),T=Math.abs((s-o)*k-(n-a)*A);if(M>hs&&T>hs){if((M+T)*(M+T)<=l*(A*A+k*k)){h.push(P,C);return}}else if(M>hs){if(M*M<=l*(A*A+k*k)){h.push(P,C);return}}else if(T>hs){if(T*T<=l*(A*A+k*k)){h.push(P,C);return}}else if(A=P-(r+o)/2,k=C-(e+a)/2,A*A+k*k<=l){h.push(P,C);return}}Zn(r,e,d,u,x,S,P,C,h,l,c+1),Zn(P,C,v,b,y,m,o,a,h,l,c+1)}const Zf=8,qf=11920929e-14,Kf=1;function $f(r,e,t,i,s,n,o,a){const l=Math.min(.99,Math.max(0,a??wr.defaultOptions.bezierSmoothness));let c=(Kf-l)/1;return c*=c,Qf(e,t,i,s,n,o,r,c),r}function Qf(r,e,t,i,s,n,o,a){qn(o,r,e,t,i,s,n,a,0),o.push(s,n)}function qn(r,e,t,i,s,n,o,a,h){if(h>Zf)return;const l=(e+i)/2,c=(t+s)/2,d=(i+n)/2,u=(s+o)/2,p=(l+d)/2,f=(c+u)/2;let y=n-e,m=o-t;const x=Math.abs((i-n)*m-(s-o)*y);if(x>qf){if(x*x<=a*(y*y+m*m)){r.push(p,f);return}}else if(y=p-(e+n)/2,m=f-(t+o)/2,y*y+m*m<=a){r.push(p,f);return}qn(r,e,t,l,c,p,f,a,h+1),qn(r,p,f,d,u,n,o,a,h+1)}function Sl(r,e,t,i,s,n,o,a){let h=Math.abs(s-n);(!o&&s>n||o&&n>s)&&(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=s;l*=o?-1:1;for(let d=0;d<a+1;d++){const u=Math.cos(c),p=Math.sin(c),f=e+u*i,y=t+p*i;r.push(f,y),c+=l}}function Jf(r,e,t,i,s,n){const o=r[r.length-2],h=r[r.length-1]-t,l=o-e,c=s-t,d=i-e,u=Math.abs(h*d-l*c);if(u<1e-8||n===0){(r[r.length-2]!==e||r[r.length-1]!==t)&&r.push(e,t);return}const p=h*h+l*l,f=c*c+d*d,y=h*c+l*d,m=n*Math.sqrt(p)/u,x=n*Math.sqrt(f)/u,S=m*y/p,v=x*y/f,b=m*d+x*l,P=m*c+x*h,C=l*(x+S),A=h*(x+S),k=d*(m+v),M=c*(m+v),T=Math.atan2(A-P,C-b),_=Math.atan2(M-P,k-b);Sl(r,b+e,P+t,n,T,_,l*c>d*h)}const ki=Math.PI*2,yn={centerX:0,centerY:0,ang1:0,ang2:0},xn=({x:r,y:e},t,i,s,n,o,a,h)=>{r*=t,e*=i;const l=s*r-n*e,c=n*r+s*e;return h.x=l+o,h.y=c+a,h};function tg(r,e){const t=e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),i=e===1.5707963267948966?.551915024494:t,s=Math.cos(r),n=Math.sin(r),o=Math.cos(r+e),a=Math.sin(r+e);return[{x:s-n*i,y:n+s*i},{x:o+a*i,y:a-o*i},{x:o,y:a}]}const na=(r,e,t,i)=>{const s=r*i-e*t<0?-1:1;let n=r*t+e*i;return n>1&&(n=1),n<-1&&(n=-1),s*Math.acos(n)},eg=(r,e,t,i,s,n,o,a,h,l,c,d,u)=>{const p=Math.pow(s,2),f=Math.pow(n,2),y=Math.pow(c,2),m=Math.pow(d,2);let x=p*f-p*m-f*y;x<0&&(x=0),x/=p*m+f*y,x=Math.sqrt(x)*(o===a?-1:1);const S=x*s/n*d,v=x*-n/s*c,b=l*S-h*v+(r+t)/2,P=h*S+l*v+(e+i)/2,C=(c-S)/s,A=(d-v)/n,k=(-c-S)/s,M=(-d-v)/n,T=na(1,0,C,A);let _=na(C,A,k,M);a===0&&_>0&&(_-=ki),a===1&&_<0&&(_+=ki),u.centerX=b,u.centerY=P,u.ang1=T,u.ang2=_};function ig(r,e,t,i,s,n,o,a=0,h=0,l=0){if(n===0||o===0)return;const c=Math.sin(a*ki/360),d=Math.cos(a*ki/360),u=d*(e-i)/2+c*(t-s)/2,p=-c*(e-i)/2+d*(t-s)/2;if(u===0&&p===0)return;n=Math.abs(n),o=Math.abs(o);const f=Math.pow(u,2)/Math.pow(n,2)+Math.pow(p,2)/Math.pow(o,2);f>1&&(n*=Math.sqrt(f),o*=Math.sqrt(f)),eg(e,t,i,s,n,o,h,l,c,d,u,p,yn);let{ang1:y,ang2:m}=yn;const{centerX:x,centerY:S}=yn;let v=Math.abs(m)/(ki/4);Math.abs(1-v)<1e-7&&(v=1);const b=Math.max(Math.ceil(v),1);m/=b;let P=r[r.length-2],C=r[r.length-1];const A={x:0,y:0};for(let k=0;k<b;k++){const M=tg(y,m),{x:T,y:_}=xn(M[0],n,o,d,c,x,S,A),{x:E,y:B}=xn(M[1],n,o,d,c,x,S,A),{x:F,y:Z}=xn(M[2],n,o,d,c,x,S,A);xl(r,P,C,T,_,E,B,F,Z),P=F,C=Z,y+=m}}function sg(r,e,t){const i=(o,a)=>{const h=a.x-o.x,l=a.y-o.y,c=Math.sqrt(h*h+l*l),d=h/c,u=l/c;return{len:c,nx:d,ny:u}},s=(o,a)=>{o===0?r.moveTo(a.x,a.y):r.lineTo(a.x,a.y)};let n=e[e.length-1];for(let o=0;o<e.length;o++){const a=e[o%e.length],h=a.radius??t;if(h<=0){s(o,a),n=a;continue}const l=e[(o+1)%e.length],c=i(a,n),d=i(a,l);if(c.len<1e-4||d.len<1e-4){s(o,a),n=a;continue}let u=Math.asin(c.nx*d.ny-c.ny*d.nx),p=1,f=!1;c.nx*d.nx-c.ny*-d.ny<0?u<0?u=Math.PI+u:(u=Math.PI-u,p=-1,f=!0):u>0&&(p=-1,f=!0);const y=u/2;let m,x=Math.abs(Math.cos(y)*h/Math.sin(y));x>Math.min(c.len/2,d.len/2)?(x=Math.min(c.len/2,d.len/2),m=Math.abs(x*Math.sin(y)/Math.cos(y))):m=h;const S=a.x+d.nx*x+-d.ny*m*p,v=a.y+d.ny*x+d.nx*m*p,b=Math.atan2(c.ny,c.nx)+Math.PI/2*p,P=Math.atan2(d.ny,d.nx)-Math.PI/2*p;o===0&&r.moveTo(S+Math.cos(b)*m,v+Math.sin(b)*m),r.arc(S,v,m,b,P,f),n=a}}function ng(r,e,t,i){const s=(a,h)=>Math.sqrt((a.x-h.x)**2+(a.y-h.y)**2),n=(a,h,l)=>({x:a.x+(h.x-a.x)*l,y:a.y+(h.y-a.y)*l}),o=e.length;for(let a=0;a<o;a++){const h=e[(a+1)%o],l=h.radius??t;if(l<=0){a===0?r.moveTo(h.x,h.y):r.lineTo(h.x,h.y);continue}const c=e[a],d=e[(a+2)%o],u=s(c,h);let p;if(u<1e-4)p=h;else{const m=Math.min(u/2,l);p=n(h,c,m/u)}const f=s(d,h);let y;if(f<1e-4)y=h;else{const m=Math.min(f/2,l);y=n(h,d,m/f)}a===0?r.moveTo(p.x,p.y):r.lineTo(p.x,p.y),r.quadraticCurveTo(h.x,h.y,y.x,y.y,i)}}const rg=new et;class og{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Bt,this._graphicsPath2D=e,this.signed=e.checkForHoles}moveTo(e,t){return this.startPoly(e,t),this}lineTo(e,t){this._ensurePoly();const i=this._currentPoly.points,s=i[i.length-2],n=i[i.length-1];return(s!==e||n!==t)&&i.push(e,t),this}arc(e,t,i,s,n,o){this._ensurePoly(!1);const a=this._currentPoly.points;return Sl(a,e,t,i,s,n,o),this}arcTo(e,t,i,s,n){this._ensurePoly();const o=this._currentPoly.points;return Jf(o,e,t,i,s,n),this}arcToSvg(e,t,i,s,n,o,a){const h=this._currentPoly.points;return ig(h,this._currentPoly.lastX,this._currentPoly.lastY,o,a,e,t,i,s,n),this}bezierCurveTo(e,t,i,s,n,o,a){this._ensurePoly();const h=this._currentPoly;return xl(this._currentPoly.points,h.lastX,h.lastY,e,t,i,s,n,o,a),this}quadraticCurveTo(e,t,i,s,n){this._ensurePoly();const o=this._currentPoly;return $f(this._currentPoly.points,o.lastX,o.lastY,e,t,i,s,n),this}closePath(){return this.endPoly(!0),this}addPath(e,t){this.endPoly(),t&&!t.isIdentity()&&(e=e.clone(!0),e.transform(t));const i=this.shapePrimitives,s=i.length;for(let n=0;n<e.instructions.length;n++){const o=e.instructions[n];this[o.action](...o.data)}if(e.checkForHoles&&i.length-s>1){let n=null;for(let o=s;o<i.length;o++){const a=i[o];if(a.shape.type==="polygon"){const h=a.shape,l=n==null?void 0:n.shape;l&&l.containsPolygon(h)?(n.holes||(n.holes=[]),n.holes.push(a),i.copyWithin(o,o+1),i.length--,o--):n=a}}}return this}finish(e=!1){this.endPoly(e)}rect(e,t,i,s,n){return this.drawShape(new et(e,t,i,s),n),this}circle(e,t,i,s){return this.drawShape(new Rs(e,t,i),s),this}poly(e,t,i){const s=new Te(e);return s.closePath=t,this.drawShape(s,i),this}regularPoly(e,t,i,s,n=0,o){s=Math.max(s|0,3);const a=-1*Math.PI/2+n,h=Math.PI*2/s,l=[];for(let c=0;c<s;c++){const d=a-c*h;l.push(e+i*Math.cos(d),t+i*Math.sin(d))}return this.poly(l,!0,o),this}roundPoly(e,t,i,s,n,o=0,a){if(s=Math.max(s|0,3),n<=0)return this.regularPoly(e,t,i,s,o);const h=i*Math.sin(Math.PI/s)-.001;n=Math.min(n,h);const l=-1*Math.PI/2+o,c=Math.PI*2/s,d=(s-2)*Math.PI/s/2;for(let u=0;u<s;u++){const p=u*c+l,f=e+i*Math.cos(p),y=t+i*Math.sin(p),m=p+Math.PI+d,x=p-Math.PI-d,S=f+n*Math.cos(m),v=y+n*Math.sin(m),b=f+n*Math.cos(x),P=y+n*Math.sin(x);u===0?this.moveTo(S,v):this.lineTo(S,v),this.quadraticCurveTo(f,y,b,P,a)}return this.closePath()}roundShape(e,t,i=!1,s){return e.length<3?this:(i?ng(this,e,t,s):sg(this,e,t),this.closePath())}filletRect(e,t,i,s,n){if(n===0)return this.rect(e,t,i,s);const o=Math.min(i,s)/2,a=Math.min(o,Math.max(-o,n)),h=e+i,l=t+s,c=a<0?-a:0,d=Math.abs(a);return this.moveTo(e,t+d).arcTo(e+c,t+c,e+d,t,d).lineTo(h-d,t).arcTo(h-c,t+c,h,t+d,d).lineTo(h,l-d).arcTo(h-c,l-c,e+i-d,l,d).lineTo(e+d,l).arcTo(e+c,l-c,e,l-d,d).closePath()}chamferRect(e,t,i,s,n,o){if(n<=0)return this.rect(e,t,i,s);const a=Math.min(n,Math.min(i,s)/2),h=e+i,l=t+s,c=[e+a,t,h-a,t,h,t+a,h,l-a,h-a,l,e+a,l,e,l-a,e,t+a];for(let d=c.length-1;d>=2;d-=2)c[d]===c[d-2]&&c[d-1]===c[d-3]&&c.splice(d-1,2);return this.poly(c,!0,o)}ellipse(e,t,i,s,n){return this.drawShape(new yr(e,t,i,s),n),this}roundRect(e,t,i,s,n,o){return this.drawShape(new xr(e,t,i,s,n),o),this}drawShape(e,t){return this.endPoly(),this.shapePrimitives.push({shape:e,transform:t}),this}startPoly(e,t){let i=this._currentPoly;return i&&this.endPoly(),i=new Te,i.points.push(e,t),this._currentPoly=i,this}endPoly(e=!1){const t=this._currentPoly;return t&&t.points.length>2&&(t.closePath=e,this.shapePrimitives.push({shape:t})),this._currentPoly=null,this}_ensurePoly(e=!0){if(!this._currentPoly&&(this._currentPoly=new Te,e)){const t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let i=t.shape.x,s=t.shape.y;if(t.transform&&!t.transform.isIdentity()){const n=t.transform,o=i;i=n.a*i+n.c*s+n.tx,s=n.b*o+n.d*s+n.ty}this._currentPoly.points.push(i,s)}else this._currentPoly.points.push(0,0)}}buildPath(){const e=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let t=0;t<e.instructions.length;t++){const i=e.instructions[t];this[i.action](...i.data)}this.finish()}get bounds(){const e=this._bounds;e.clear();const t=this.shapePrimitives;for(let i=0;i<t.length;i++){const s=t[i],n=s.shape.getBounds(rg);s.transform?e.addRect(n,s.transform):e.addRect(n)}return e}}class Jt{constructor(e,t=!1){this.instructions=[],this.uid=dt("graphicsPath"),this._dirty=!0,this.checkForHoles=t,typeof e=="string"?Ip(e,this):this.instructions=(e==null?void 0:e.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new og(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(e,t){return e=e.clone(),this.instructions.push({action:"addPath",data:[e,t]}),this._dirty=!0,this}arc(...e){return this.instructions.push({action:"arc",data:e}),this._dirty=!0,this}arcTo(...e){return this.instructions.push({action:"arcTo",data:e}),this._dirty=!0,this}arcToSvg(...e){return this.instructions.push({action:"arcToSvg",data:e}),this._dirty=!0,this}bezierCurveTo(...e){return this.instructions.push({action:"bezierCurveTo",data:e}),this._dirty=!0,this}bezierCurveToShort(e,t,i,s,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(tt.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,d=a.y;h=c+(c-h),l=d+(d-l)}return this.instructions.push({action:"bezierCurveTo",data:[h,l,e,t,i,s,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...e){return this.instructions.push({action:"ellipse",data:e}),this._dirty=!0,this}lineTo(...e){return this.instructions.push({action:"lineTo",data:e}),this._dirty=!0,this}moveTo(...e){return this.instructions.push({action:"moveTo",data:e}),this}quadraticCurveTo(...e){return this.instructions.push({action:"quadraticCurveTo",data:e}),this._dirty=!0,this}quadraticCurveToShort(e,t,i){const s=this.instructions[this.instructions.length-1],n=this.getLastPoint(tt.shared);let o=0,a=0;if(!s||s.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=s.data[0],a=s.data[1];const h=n.x,l=n.y;o=h+(h-o),a=l+(l-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,e,t,i]}),this._dirty=!0,this}rect(e,t,i,s,n){return this.instructions.push({action:"rect",data:[e,t,i,s,n]}),this._dirty=!0,this}circle(e,t,i,s){return this.instructions.push({action:"circle",data:[e,t,i,s]}),this._dirty=!0,this}roundRect(...e){return this.instructions.push({action:"roundRect",data:e}),this._dirty=!0,this}poly(...e){return this.instructions.push({action:"poly",data:e}),this._dirty=!0,this}regularPoly(...e){return this.instructions.push({action:"regularPoly",data:e}),this._dirty=!0,this}roundPoly(...e){return this.instructions.push({action:"roundPoly",data:e}),this._dirty=!0,this}roundShape(...e){return this.instructions.push({action:"roundShape",data:e}),this._dirty=!0,this}filletRect(...e){return this.instructions.push({action:"filletRect",data:e}),this._dirty=!0,this}chamferRect(...e){return this.instructions.push({action:"chamferRect",data:e}),this._dirty=!0,this}star(e,t,i,s,n,o,a){n||(n=s/2);const h=-1*Math.PI/2+o,l=i*2,c=Math.PI*2/l,d=[];for(let u=0;u<l;u++){const p=u%2?n:s,f=u*c+h;d.push(e+p*Math.cos(f),t+p*Math.sin(f))}return this.poly(d,!0,a),this}clone(e=!1){const t=new Jt;if(t.checkForHoles=this.checkForHoles,!e)t.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const s=this.instructions[i];t.instructions.push({action:s.action,data:s.data.slice()})}return t}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(e){if(e.isIdentity())return this;const t=e.a,i=e.b,s=e.c,n=e.d,o=e.tx,a=e.ty;let h=0,l=0,c=0,d=0,u=0,p=0,f=0,y=0;for(let m=0;m<this.instructions.length;m++){const x=this.instructions[m],S=x.data;switch(x.action){case"moveTo":case"lineTo":h=S[0],l=S[1],S[0]=t*h+s*l+o,S[1]=i*h+n*l+a;break;case"bezierCurveTo":c=S[0],d=S[1],u=S[2],p=S[3],h=S[4],l=S[5],S[0]=t*c+s*d+o,S[1]=i*c+n*d+a,S[2]=t*u+s*p+o,S[3]=i*u+n*p+a,S[4]=t*h+s*l+o,S[5]=i*h+n*l+a;break;case"quadraticCurveTo":c=S[0],d=S[1],h=S[2],l=S[3],S[0]=t*c+s*d+o,S[1]=i*c+n*d+a,S[2]=t*h+s*l+o,S[3]=i*h+n*l+a;break;case"arcToSvg":h=S[5],l=S[6],f=S[0],y=S[1],S[0]=t*f+s*y,S[1]=i*f+n*y,S[5]=t*h+s*l+o,S[6]=i*h+n*l+a;break;case"circle":S[4]=yi(S[3],e);break;case"rect":S[4]=yi(S[4],e);break;case"ellipse":S[8]=yi(S[8],e);break;case"roundRect":S[5]=yi(S[5],e);break;case"addPath":S[0].transform(e);break;case"poly":S[2]=yi(S[2],e);break;default:nt("unknown transform action",x.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(e){let t=this.instructions.length-1,i=this.instructions[t];if(!i)return e.x=0,e.y=0,e;for(;i.action==="closePath";){if(t--,t<0)return e.x=0,e.y=0,e;i=this.instructions[t]}switch(i.action){case"moveTo":case"lineTo":e.x=i.data[0],e.y=i.data[1];break;case"quadraticCurveTo":e.x=i.data[2],e.y=i.data[3];break;case"bezierCurveTo":e.x=i.data[4],e.y=i.data[5];break;case"arc":case"arcToSvg":e.x=i.data[5],e.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(e);break}return e}}function yi(r,e){return r?r.prepend(e):e.clone()}function lt(r,e,t){const i=r.getAttribute(e);return i?Number(i):t}function ag(r,e){const t=r.querySelectorAll("defs");for(let i=0;i<t.length;i++){const s=t[i];for(let n=0;n<s.children.length;n++){const o=s.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":e.defs[o.id]=hg(o);break;case"radialgradient":e.defs[o.id]=lg();break}}}}function hg(r){const e=lt(r,"x1",0),t=lt(r,"y1",0),i=lt(r,"x2",1),s=lt(r,"y2",0),n=r.getAttribute("gradientUnits")||"objectBoundingBox",o=new Ot(e,t,i,s,n==="objectBoundingBox"?"local":"global");for(let a=0;a<r.children.length;a++){const h=r.children[a],l=lt(h,"offset",0),c=rt.shared.setValue(h.getAttribute("stop-color")).toNumber();o.addColorStop(l,c)}return o}function lg(r){return nt("[SVG Parser] Radial gradients are not yet supported"),new Ot(0,0,1,0)}function ra(r){const e=r.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}const oa={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 vl(r,e){const t=r.getAttribute("style"),i={},s={},n={strokeStyle:i,fillStyle:s,useFill:!1,useStroke:!1};for(const o in oa){const a=r.getAttribute(o);a&&aa(e,n,o,a.trim())}if(t){const o=t.split(";");for(let a=0;a<o.length;a++){const h=o[a].trim(),[l,c]=h.split(":");oa[l]&&aa(e,n,l,c.trim())}}return{strokeStyle:n.useStroke?i:null,fillStyle:n.useFill?s:null,useFill:n.useFill,useStroke:n.useStroke}}function aa(r,e,t,i){switch(t){case"stroke":if(i!=="none"){if(i.startsWith("url(")){const s=ra(i);e.strokeStyle.fill=r.defs[s]}else e.strokeStyle.color=rt.shared.setValue(i).toNumber();e.useStroke=!0}break;case"stroke-width":e.strokeStyle.width=Number(i);break;case"fill":if(i!=="none"){if(i.startsWith("url(")){const s=ra(i);e.fillStyle.fill=r.defs[s]}else e.fillStyle.color=rt.shared.setValue(i).toNumber();e.useFill=!0}break;case"fill-opacity":e.fillStyle.alpha=Number(i);break;case"stroke-opacity":e.strokeStyle.alpha=Number(i);break;case"opacity":e.fillStyle.alpha=Number(i),e.strokeStyle.alpha=Number(i);break}}function cg(r){if(r.length<=2)return!0;const e=r.map(a=>a.area).sort((a,h)=>h-a),[t,i]=e,s=e[e.length-1],n=t/i,o=i/s;return!(n>3&&o<2)}function dg(r){return r.split(/(?=[Mm])/).filter(i=>i.trim().length>0)}function ug(r){const e=r.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!e||e.length<4)return 0;const t=e.map(Number),i=[],s=[];for(let c=0;c<t.length;c+=2)c+1<t.length&&(i.push(t[c]),s.push(t[c+1]));if(i.length===0||s.length===0)return 0;const n=Math.min(...i),o=Math.max(...i),a=Math.min(...s),h=Math.max(...s);return(o-n)*(h-a)}function ha(r,e){const t=new Jt(r,!1);for(const i of t.instructions)e.instructions.push(i)}function pg(r,e){if(typeof r=="string"){const o=document.createElement("div");o.innerHTML=r.trim(),r=o.querySelector("svg")}const t={context:e,defs:{},path:new Jt};ag(r,t);const i=r.children,{fillStyle:s,strokeStyle:n}=vl(r,t);for(let o=0;o<i.length;o++){const a=i[o];a.nodeName.toLowerCase()!=="defs"&&bl(a,t,s,n)}return e}function bl(r,e,t,i){const s=r.children,{fillStyle:n,strokeStyle:o}=vl(r,e);n&&t?t={...t,...n}:n&&(t=n),o&&i?i={...i,...o}:o&&(i=o);const a=!t&&!i;a&&(t={color:0});let h,l,c,d,u,p,f,y,m,x,S,v,b,P,C,A,k;switch(r.nodeName.toLowerCase()){case"path":{P=r.getAttribute("d");const M=r.getAttribute("fill-rule"),T=dg(P),_=M==="evenodd",E=T.length>1;if(_&&E){const F=T.map(R=>({path:R,area:ug(R)}));if(F.sort((R,D)=>D.area-R.area),T.length>3||!cg(F))for(let R=0;R<F.length;R++){const D=F[R],ot=R===0;e.context.beginPath();const z=new Jt(void 0,!0);ha(D.path,z),e.context.path(z),ot?(t&&e.context.fill(t),i&&e.context.stroke(i)):e.context.cut()}else for(let R=0;R<F.length;R++){const D=F[R],ot=R%2===1;e.context.beginPath();const z=new Jt(void 0,!0);ha(D.path,z),e.context.path(z),ot?e.context.cut():(t&&e.context.fill(t),i&&e.context.stroke(i))}}else{const F=M?M==="evenodd":!0;C=new Jt(P,F),e.context.path(C),t&&e.context.fill(t),i&&e.context.stroke(i)}break}case"circle":f=lt(r,"cx",0),y=lt(r,"cy",0),m=lt(r,"r",0),e.context.ellipse(f,y,m,m),t&&e.context.fill(t),i&&e.context.stroke(i);break;case"rect":h=lt(r,"x",0),l=lt(r,"y",0),A=lt(r,"width",0),k=lt(r,"height",0),x=lt(r,"rx",0),S=lt(r,"ry",0),x||S?e.context.roundRect(h,l,A,k,x||S):e.context.rect(h,l,A,k),t&&e.context.fill(t),i&&e.context.stroke(i);break;case"ellipse":f=lt(r,"cx",0),y=lt(r,"cy",0),x=lt(r,"rx",0),S=lt(r,"ry",0),e.context.beginPath(),e.context.ellipse(f,y,x,S),t&&e.context.fill(t),i&&e.context.stroke(i);break;case"line":c=lt(r,"x1",0),d=lt(r,"y1",0),u=lt(r,"x2",0),p=lt(r,"y2",0),e.context.beginPath(),e.context.moveTo(c,d),e.context.lineTo(u,p),i&&e.context.stroke(i);break;case"polygon":b=r.getAttribute("points"),v=b.match(/-?\d+/g).map(M=>parseInt(M,10)),e.context.poly(v,!0),t&&e.context.fill(t),i&&e.context.stroke(i);break;case"polyline":b=r.getAttribute("points"),v=b.match(/-?\d+/g).map(M=>parseInt(M,10)),e.context.poly(v,!1),i&&e.context.stroke(i);break;case"g":case"svg":break;default:{nt(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}a&&(t=null);for(let M=0;M<s.length;M++)bl(s[M],e,t,i)}const la={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 Is{constructor(e,t){this.uid=dt("fillPattern"),this._tick=0,this.transform=new U,this.texture=e,this.transform.scale(1/e.frame.width,1/e.frame.height),t&&(e.source.style.addressModeU=la[t].addressModeU,e.source.style.addressModeV=la[t].addressModeV)}setTransform(e){const t=this.texture;this.transform.copyFrom(e),this.transform.invert(),this.transform.scale(1/t.frame.width,1/t.frame.height),this._tick++}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture=e,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}function fg(r){return rt.isColorLike(r)}function ca(r){return r instanceof Is}function da(r){return r instanceof Ot}function gg(r){return r instanceof W}function mg(r,e,t){const i=rt.shared.setValue(e??0);return r.color=i.toNumber(),r.alpha=i.alpha===1?t.alpha:i.alpha,r.texture=W.WHITE,{...t,...r}}function yg(r,e,t){return r.texture=e,{...t,...r}}function ua(r,e,t){return r.fill=e,r.color=16777215,r.texture=e.texture,r.matrix=e.transform,{...t,...r}}function pa(r,e,t){return e.buildGradient(),r.fill=e,r.color=16777215,r.texture=e.texture,r.matrix=e.transform,r.textureSpace=e.textureSpace,{...t,...r}}function xg(r,e){const t={...e,...r},i=rt.shared.setValue(t.color);return t.alpha*=i.alpha,t.color=i.toNumber(),t}function Me(r,e){if(r==null)return null;const t={},i=r;return fg(r)?mg(t,r,e):gg(r)?yg(t,r,e):ca(r)?ua(t,r,e):da(r)?pa(t,r,e):i.fill&&ca(i.fill)?ua(i,i.fill,e):i.fill&&da(i.fill)?pa(i,i.fill,e):xg(i,e)}function Ss(r,e){const{width:t,alignment:i,miterLimit:s,cap:n,join:o,pixelLine:a,...h}=e,l=Me(r,h);return l?{width:t,alignment:i,miterLimit:s,cap:n,join:o,pixelLine:a,...l}:null}const Sg=new tt,fa=new U,Cr=class Ht extends Yt{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=dt("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new Jt,this._transform=new U,this._fillStyle={...Ht.defaultFillStyle},this._strokeStyle={...Ht.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Bt,this._boundsDirty=!0}clone(){const e=new Ht;return e.batchMode=this.batchMode,e.instructions=this.instructions.slice(),e._activePath=this._activePath.clone(),e._transform=this._transform.clone(),e._fillStyle={...this._fillStyle},e._strokeStyle={...this._strokeStyle},e._stateStack=this._stateStack.slice(),e._bounds=this._bounds.clone(),e._boundsDirty=!0,e}get fillStyle(){return this._fillStyle}set fillStyle(e){this._fillStyle=Me(e,Ht.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=Ss(e,Ht.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=Me(e,Ht.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=Me(e,Ht.defaultStrokeStyle),this}texture(e,t,i,s,n,o){return this.instructions.push({action:"texture",data:{image:e,dx:i||0,dy:s||0,dw:n||e.frame.width,dh:o||e.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:t||t===0?rt.shared.setValue(t).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Jt,this}fill(e,t){let i;const s=this.instructions[this.instructions.length-1];return this._tick===0&&(s==null?void 0:s.action)==="stroke"?i=s.data.path:i=this._activePath.clone(),i?(e!=null&&(t!==void 0&&typeof e=="number"&&(V(J,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:t}),this._fillStyle=Me(e,Ht.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:e,y:t}=this._activePath.getLastPoint(tt.shared);this._activePath.clear(),this._activePath.moveTo(e,t)}stroke(e){let t;const i=this.instructions[this.instructions.length-1];return this._tick===0&&(i==null?void 0:i.action)==="fill"?t=i.data.path:t=this._activePath.clone(),t?(e!=null&&(this._strokeStyle=Ss(e,Ht.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:t}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let e=0;e<2;e++){const t=this.instructions[this.instructions.length-1-e],i=this._activePath.clone();if(t&&(t.action==="stroke"||t.action==="fill"))if(t.data.hole)t.data.hole.addPath(i);else{t.data.hole=i;break}}return this._initNextPathLocation(),this}arc(e,t,i,s,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*e+a.c*t+a.tx,a.b*e+a.d*t+a.ty,i,s,n,o),this}arcTo(e,t,i,s,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*i+o.c*s+o.tx,o.b*i+o.d*s+o.ty,n),this}arcToSvg(e,t,i,s,n,o,a){this._tick++;const h=this._transform;return this._activePath.arcToSvg(e,t,i,s,n,h.a*o+h.c*a+h.tx,h.b*o+h.d*a+h.ty),this}bezierCurveTo(e,t,i,s,n,o,a){this._tick++;const h=this._transform;return this._activePath.bezierCurveTo(h.a*e+h.c*t+h.tx,h.b*e+h.d*t+h.ty,h.a*i+h.c*s+h.tx,h.b*i+h.d*s+h.ty,h.a*n+h.c*o+h.tx,h.b*n+h.d*o+h.ty,a),this}closePath(){var e;return this._tick++,(e=this._activePath)==null||e.closePath(),this}ellipse(e,t,i,s){return this._tick++,this._activePath.ellipse(e,t,i,s,this._transform.clone()),this}circle(e,t,i){return this._tick++,this._activePath.circle(e,t,i,this._transform.clone()),this}path(e){return this._tick++,this._activePath.addPath(e,this._transform.clone()),this}lineTo(e,t){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*e+i.c*t+i.tx,i.b*e+i.d*t+i.ty),this}moveTo(e,t){this._tick++;const i=this._transform,s=this._activePath.instructions,n=i.a*e+i.c*t+i.tx,o=i.b*e+i.d*t+i.ty;return s.length===1&&s[0].action==="moveTo"?(s[0].data[0]=n,s[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(e,t,i,s,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*i+o.c*s+o.tx,o.b*i+o.d*s+o.ty,n),this}rect(e,t,i,s){return this._tick++,this._activePath.rect(e,t,i,s,this._transform.clone()),this}roundRect(e,t,i,s,n){return this._tick++,this._activePath.roundRect(e,t,i,s,n,this._transform.clone()),this}poly(e,t){return this._tick++,this._activePath.poly(e,t,this._transform.clone()),this}regularPoly(e,t,i,s,n=0,o){return this._tick++,this._activePath.regularPoly(e,t,i,s,n,o),this}roundPoly(e,t,i,s,n,o){return this._tick++,this._activePath.roundPoly(e,t,i,s,n,o),this}roundShape(e,t,i,s){return this._tick++,this._activePath.roundShape(e,t,i,s),this}filletRect(e,t,i,s,n){return this._tick++,this._activePath.filletRect(e,t,i,s,n),this}chamferRect(e,t,i,s,n,o){return this._tick++,this._activePath.chamferRect(e,t,i,s,n,o),this}star(e,t,i,s,n=0,o=0){return this._tick++,this._activePath.star(e,t,i,s,n,o,this._transform.clone()),this}svg(e){return this._tick++,pg(e,this),this}restore(){const e=this._stateStack.pop();return e&&(this._transform=e.transform,this._fillStyle=e.fillStyle,this._strokeStyle=e.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(e){return this._transform.rotate(e),this}scale(e,t=e){return this._transform.scale(e,t),this}setTransform(e,t,i,s,n,o){return e instanceof U?(this._transform.set(e.a,e.b,e.c,e.d,e.tx,e.ty),this):(this._transform.set(e,t,i,s,n,o),this)}transform(e,t,i,s,n,o){return e instanceof U?(this._transform.append(e),this):(fa.set(e,t,i,s,n,o),this._transform.append(fa),this)}translate(e,t=e){return this._transform.translate(e,t),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,!this.dirty&&(this.emit("update",this,16),this.dirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const e=this._bounds;e.clear();for(let t=0;t<this.instructions.length;t++){const i=this.instructions[t],s=i.action;if(s==="fill"){const n=i.data;e.addBounds(n.path.bounds)}else if(s==="texture"){const n=i.data;e.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(s==="stroke"){const n=i.data,o=n.style.alignment,a=n.style.width*(1-o),h=n.path.bounds;e.addFrame(h.minX-a,h.minY-a,h.maxX+a,h.maxY+a)}}return e}containsPoint(e){var s;if(!this.bounds.containsPoint(e.x,e.y))return!1;const t=this.instructions;let i=!1;for(let n=0;n<t.length;n++){const o=t[n],a=o.data,h=a.path;if(!o.action||!h)continue;const l=a.style,c=h.shapePath.shapePrimitives;for(let d=0;d<c.length;d++){const u=c[d].shape;if(!l||!u)continue;const p=c[d].transform,f=p?p.applyInverse(e,Sg):e;if(o.action==="fill")i=u.contains(f.x,f.y);else{const m=l;i=u.strokeContains(f.x,f.y,m.width,m.alignment)}const y=a.hole;if(y){const m=(s=y.shapePath)==null?void 0:s.shapePrimitives;if(m)for(let x=0;x<m.length;x++)m[x].shape.contains(f.x,f.y)&&(i=!1)}if(i)return!0}}return i}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.destroy();this._gpuData=Object.create(null)}destroy(e=!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 e=="boolean"?e:e==null?void 0:e.texture){const i=typeof e=="boolean"?e:e==null?void 0:e.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}};Cr.defaultFillStyle={color:16777215,alpha:1,texture:W.WHITE,matrix:null,fill:null,textureSpace:"local"};Cr.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:W.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let mt=Cr;function Ar(r,e=1){var i;const t=(i=hi.RETINA_PREFIX)==null?void 0:i.exec(r);return t?parseFloat(t[1]):e}function Pr(r,e,t){r.label=t,r._sourceOrigin=t;const i=new W({source:r,label:t}),s=()=>{delete e.promiseCache[t],xt.has(t)&&xt.remove(t)};return i.source.once("destroy",()=>{e.promiseCache[t]&&(nt("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),s())}),i.once("destroy",()=>{r.destroyed||(nt("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),s())}),i}const vg=".svg",Mr="image/svg+xml",bg={extension:{type:I.LoadParser,priority:ue.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return pe(r,Mr)||li(r,vg)},async load(r,e,t){var i;return((i=e.data)==null?void 0:i.parseAsGraphicsContext)??this.config.parseAsGraphicsContext?Ag(r):wg(r,e,t,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function wg(r,e,t,i){var m,x,S;const s=pe(r,Mr),n=j.get().createImage();n.crossOrigin=i,n.src=r,await new Promise((v,b)=>{n.complete?v(n):(n.onload=()=>v(n),n.onerror=b)}),await n.decode();const o=((m=e.data)==null?void 0:m.width)??n.width,a=((x=e.data)==null?void 0:x.height)??n.height,h=((S=e.data)==null?void 0:S.resolution)||Ar(r),l=Math.ceil(o*h),c=Math.ceil(a*h),d=j.get().createCanvas(l,c),u=d.getContext("2d");u.imageSmoothingEnabled=!0,u.imageSmoothingQuality="high",u.drawImage(n,0,0,o*h,a*h);const{parseAsGraphicsContext:p,...f}=e.data??{},y=new ii({resource:d,alphaMode:"premultiply-alpha-on-upload",resolution:h,...f});return Pr(y,t,r)}function Cg(r){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let t="",i=0;for(r=r.replace(/[^A-Za-z0-9\+\/\=]/g,"");i<r.length;){const s=e.indexOf(r.charAt(i++)),n=e.indexOf(r.charAt(i++)),o=e.indexOf(r.charAt(i++)),a=e.indexOf(r.charAt(i++)),h=s<<2|n>>4,l=(n&15)<<4|o>>2,c=(o&3)<<6|a;t+=String.fromCharCode(h),o!==64&&(t+=String.fromCharCode(l)),a!==64&&(t+=String.fromCharCode(c))}return t}async function Ag(r){const e=pe(r,Mr);let t;if(e)if(r.includes(";base64,")){const s=r.split(";base64,")[1];t=Cg(s)}else{const s=r.split(",")[1];t=decodeURIComponent(s)}else t=await(await j.get().fetch(r)).text();const i=new mt;return i.svg(t),i}const Pg=`(function () {
|
|
241
241
|
'use strict';
|
|
242
242
|
|
|
243
243
|
const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
|
|
@@ -257,7 +257,7 @@ ${s.join(`
|
|
|
257
257
|
});
|
|
258
258
|
|
|
259
259
|
})();
|
|
260
|
-
`;let Xe=null
|
|
260
|
+
`;let Xe=null,Kn=class{constructor(){Xe||(Xe=URL.createObjectURL(new Blob([Pg],{type:"application/javascript"}))),this.worker=new Worker(Xe)}};Kn.revokeObjectURL=function(){Xe&&(URL.revokeObjectURL(Xe),Xe=null)};const Mg=`(function () {
|
|
261
261
|
'use strict';
|
|
262
262
|
|
|
263
263
|
async function loadImageBitmap(url, alphaMode) {
|
|
@@ -286,7 +286,7 @@ ${s.join(`
|
|
|
286
286
|
};
|
|
287
287
|
|
|
288
288
|
})();
|
|
289
|
-
`;let Ze=null;class Al{constructor(){Ze||(Ze=URL.createObjectURL(new Blob([_g],{type:"application/javascript"}))),this.worker=new Worker(Ze)}}Al.revokeObjectURL=function(){Ze&&(URL.revokeObjectURL(Ze),Ze=null)};let ma=0,Sn;class Tg{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(e=>{const{worker:t}=new $n;t.addEventListener("message",i=>{t.terminate(),$n.revokeObjectURL(),e(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(e,t){var i;return this._run("loadImageBitmap",[e,(i=t==null?void 0:t.data)==null?void 0:i.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Sn===void 0&&(Sn=navigator.hardwareConcurrency||4);let e=this._workerPool.pop();return!e&&this._createdWorkers<Sn&&(this._createdWorkers++,e=new Al().worker,e.addEventListener("message",t=>{this._complete(t.data),this._returnWorker(t.target),this._next()})),e}_returnWorker(e){this._workerPool.push(e)}_complete(e){this._resolveHash[e.uuid]&&(e.error!==void 0?this._resolveHash[e.uuid].reject(e.error):this._resolveHash[e.uuid].resolve(e.data),delete this._resolveHash[e.uuid])}async _run(e,t){await this._initWorkers();const i=new Promise((s,n)=>{this._queue.push({id:e,arguments:t,resolve:s,reject:n})});return this._next(),i}_next(){if(!this._queue.length)return;const e=this._getWorker();if(!e)return;const t=this._queue.pop(),i=t.id;this._resolveHash[ma]={resolve:t.resolve,reject:t.reject},e.postMessage({data:t.arguments,uuid:ma++,id:i})}reset(){this._workerPool.forEach(e=>e.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:e})=>{e==null||e(new Error("WorkerManager has been reset before completion"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}}const ya=new Tg,kg=[".jpeg",".jpg",".png",".webp",".avif"],Rg=["image/jpeg","image/png","image/webp","image/avif"];async function Eg(r,e){var s;const t=await j.get().fetch(r);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${t.status} ${t.statusText}`);const i=await t.blob();return((s=e==null?void 0:e.data)==null?void 0:s.alphaMode)==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}const Pl={name:"loadTextures",id:"texture",extension:{type:I.LoadParser,priority:ue.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return pe(r,Rg)||li(r,kg)},async load(r,e,t){var n;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await ya.isImageBitmapSupported()?i=await ya.loadImageBitmap(r,e):i=await Eg(r,e):i=await new Promise((o,a)=>{i=j.get().createImage(),i.crossOrigin=this.config.crossOrigin,i.src=r,i.complete?o(i):(i.onload=()=>{o(i)},i.onerror=a)});const s=new ii({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((n=e.data)==null?void 0:n.resolution)||Pr(r),...e.data});return Mr(s,t,r)},unload(r){r.destroy(!0)}},Ig=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let vn,bn;function Bg(r,e,t){t===void 0&&!e.startsWith("data:")?r.crossOrigin=Fg(e):t!==!1&&(r.crossOrigin=typeof t=="string"?t:"anonymous")}function Dg(r){return new Promise((e,t)=>{r.addEventListener("canplaythrough",i),r.addEventListener("error",s),r.load();function i(){n(),e()}function s(o){n(),t(o)}function n(){r.removeEventListener("canplaythrough",i),r.removeEventListener("error",s)}})}function Fg(r,e=globalThis.location){if(r.startsWith("data:"))return"";e||(e=globalThis.location);const t=new URL(r,document.baseURI);return t.hostname!==e.hostname||t.port!==e.port||t.protocol!==e.protocol?"anonymous":""}function zg(){const r=[],e=[];for(const t of Ig){const i=Mi.MIME_TYPES[t.substring(1)]||`video/${t.substring(1)}`;ks(i)&&(r.push(t),e.includes(i)||e.push(i))}return{validVideoExtensions:r,validVideoMime:e}}const Lg={name:"loadVideo",id:"video",extension:{type:I.LoadParser,name:"loadVideo"},test(r){if(!vn||!bn){const{validVideoExtensions:i,validVideoMime:s}=zg();vn=i,bn=s}const e=pe(r,bn),t=li(r,vn);return e||t},async load(r,e,t){var h,l;const i={...Mi.defaultOptions,resolution:((h=e.data)==null?void 0:h.resolution)||Pr(r),alphaMode:((l=e.data)==null?void 0:l.alphaMode)||await Rh(),...e.data},s=document.createElement("video"),n={preload:i.autoLoad!==!1?"auto":void 0,"webkit-playsinline":i.playsinline!==!1?"":void 0,playsinline:i.playsinline!==!1?"":void 0,muted:i.muted===!0?"":void 0,loop:i.loop===!0?"":void 0,autoplay:i.autoPlay!==!1?"":void 0};Object.keys(n).forEach(c=>{const d=n[c];d!==void 0&&s.setAttribute(c,d)}),i.muted===!0&&(s.muted=!0),Bg(s,r,i.crossorigin);const o=document.createElement("source");let a;if(i.mime)a=i.mime;else if(r.startsWith("data:"))a=r.slice(5,r.indexOf(";"));else if(!r.startsWith("blob:")){const c=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase();a=Mi.MIME_TYPES[c]||`video/${c}`}return o.src=r,a&&(o.type=a),new Promise((c,d)=>{i.preload&&!i.autoPlay&&s.load(),s.addEventListener("canplay",u),s.addEventListener("error",p),o.addEventListener("error",p),s.appendChild(o);async function u(){const y=new Mi({...i,resource:s});f(),e.data.preload&&await Dg(s),c(Mr(y,t,r))}function p(y){f(),d(y)}function f(){s.removeEventListener("canplay",u),s.removeEventListener("error",p),o.removeEventListener("error",p)}})},unload(r){r.destroy(!0)}},Ml={extension:{type:I.ResolveParser,name:"resolveTexture"},test:Pl.test,parse:r=>{var e;return{resolution:parseFloat(((e=hi.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:r.split(".").pop(),src:r}}},Og={extension:{type:I.ResolveParser,priority:-2,name:"resolveJson"},test:r=>hi.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:Ml.parse};class Gg{constructor(){this._detections=[],this._initialized=!1,this.resolver=new hi,this.loader=new up,this.cache=xt,this._backgroundLoader=new sp(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(e={}){var n,o;if(this._initialized){nt("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,e.defaultSearchParams&&this.resolver.setDefaultSearchParams(e.defaultSearchParams),e.basePath&&(this.resolver.basePath=e.basePath),e.bundleIdentifier&&this.resolver.setBundleIdentifier(e.bundleIdentifier),e.manifest){let a=e.manifest;typeof a=="string"&&(a=await this.load(a)),this.resolver.addManifest(a)}const t=((n=e.texturePreference)==null?void 0:n.resolution)??1,i=typeof t=="number"?[t]:t,s=await this._detectFormats({preferredFormats:(o=e.texturePreference)==null?void 0:o.format,skipDetections:e.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:i}}),e.preferences&&this.setPreferences(e.preferences),e.loadOptions&&(this.loader.loadOptions={...this.loader.loadOptions,...e.loadOptions})}add(e){this.resolver.add(e)}async load(e,t){this._initialized||await this.init();const i=ms(e),s=zt(e).map(a=>{if(typeof a!="string"){const h=this.resolver.getAlias(a);return h.some(l=>!this.resolver.hasKey(l))&&this.add(a),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(s),o=await this._mapLoadToResolve(n,t);return i?o[s[0]]:o}addBundle(e,t){this.resolver.addBundle(e,t)}async loadBundle(e,t){this._initialized||await this.init();let i=!1;typeof e=="string"&&(i=!0,e=[e]);const s=this.resolver.resolveBundle(e),n={},o=Object.keys(s);let a=0;const h=[],l=()=>{t==null||t(h.reduce((d,u)=>d+u,0)/a)},c=o.map((d,u)=>{const p=s[d],f=Object.values(p),m=[...new Set(f.flat())].reduce((x,S)=>x+(S.progressSize||1),0);return h.push(0),a+=m,this._mapLoadToResolve(p,x=>{h[u]=x*m,l()}).then(x=>{n[d]=x})});return await Promise.all(c),i?n[e[0]]:n}async backgroundLoad(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolve(e);this._backgroundLoader.add(Object.values(t))}async backgroundLoadBundle(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolveBundle(e);Object.values(t).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(e){if(typeof e=="string")return xt.get(e);const t={};for(let i=0;i<e.length;i++)t[i]=xt.get(e[i]);return t}async _mapLoadToResolve(e,t){const i=[...new Set(Object.values(e))];this._backgroundLoader.active=!1;const s=await this.loader.load(i,t);this._backgroundLoader.active=!0;const n={};return i.forEach(o=>{const a=s[o.src],h=[o.src];o.alias&&h.push(...o.alias),h.forEach(l=>{n[l]=a}),xt.set(h,a)}),n}async unload(e){this._initialized||await this.init();const t=zt(e).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(t);await this._unloadFromResolved(i)}async unloadBundle(e){this._initialized||await this.init(),e=zt(e);const t=this.resolver.resolveBundle(e),i=Object.keys(t).map(s=>this._unloadFromResolved(t[s]));await Promise.all(i)}async _unloadFromResolved(e){const t=Object.values(e);t.forEach(i=>{xt.remove(i.src)}),await this.loader.unload(t)}async _detectFormats(e){let t=[];e.preferredFormats&&(t=Array.isArray(e.preferredFormats)?e.preferredFormats:[e.preferredFormats]);for(const i of e.detections)e.skipDetections||await i.test()?t=await i.add(t):e.skipDetections||(t=await i.remove(t));return t=t.filter((i,s)=>t.indexOf(i)===s),t}get detections(){return this._detections}setPreferences(e){this.loader.parsers.forEach(t=>{t.config&&Object.keys(t.config).filter(i=>i in e).forEach(i=>{t.config[i]=e[i]})})}}const N=new Gg;$.handleByList(I.LoadParser,N.loader.parsers).handleByList(I.ResolveParser,N.resolver.parsers).handleByList(I.CacheParser,N.cache.parsers).handleByList(I.DetectionParser,N.detections);$.add(np,op,rp,dp,hp,lp,cp,gp,xp,Mp,wg,Pl,Lg,ip,ep,Ml,Og);const xa={loader:I.LoadParser,resolver:I.ResolveParser,cache:I.CacheParser,detection:I.DetectionParser};$.handle(I.Asset,r=>{const e=r.ref;Object.entries(xa).filter(([t])=>!!e[t]).forEach(([t,i])=>$.add(Object.assign(e[t],{extension:e[t].extension??i})))},r=>{const e=r.ref;Object.keys(xa).filter(t=>!!e[t]).forEach(t=>$.remove(e[t]))});class _l{constructor(e){this._attachedDomElements=[],this._renderer=e,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new au({domElement:this._domElement,renderer:this._renderer})}addRenderable(e,t){this._attachedDomElements.includes(e)||this._attachedDomElements.push(e)}updateRenderable(e){}validateRenderable(e){return!0}postrender(){const e=this._attachedDomElements;if(e.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let t=0;t<e.length;t++){const i=e[t],s=i.element;if(!i.parent||i.globalDisplayStatus<7)s==null||s.remove(),e.splice(t,1),t--;else{this._domElement.contains(s)||(s.style.position="absolute",s.style.pointerEvents="auto",this._domElement.appendChild(s));const n=i.worldTransform,o=i._anchor,a=i.width*o.x,h=i.height*o.y;s.style.transformOrigin=`${a}px ${h}px`,s.style.transform=`matrix(${n.a}, ${n.b}, ${n.c}, ${n.d}, ${n.tx-a}, ${n.ty-h})`,s.style.opacity=i.groupAlpha.toString()}}}destroy(){var e;this._renderer.runners.postrender.remove(this);for(let t=0;t<this._attachedDomElements.length;t++)(e=this._attachedDomElements[t].element)==null||e.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}_l.extension={type:[I.WebGLPipes,I.WebGPUPipes,I.CanvasPipes],name:"dom"};$.add(_l);class Wg extends ai{constructor(e={}){const{element:t,anchor:i,...s}=e;super({label:"DOMContainer",...s}),this.renderPipeId="dom",this.batched=!1,this._anchor=new tt(0,0),i&&(this.anchor=i),this.element=e.element||document.createElement("div")}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}set element(e){this._element!==e&&(this._element=e,this.onViewUpdate())}get element(){return this._element}updateBounds(){const e=this._bounds,t=this._element;if(!t){e.minX=0,e.minY=0,e.maxX=0,e.maxY=0;return}const{offsetWidth:i,offsetHeight:s}=t;e.minX=0,e.maxX=i,e.minY=0,e.maxY=s}destroy(e=!1){var t,i;super.destroy(e),(i=(t=this._element)==null?void 0:t.parentNode)==null||i.removeChild(this._element),this._element=null,this._anchor=null}}class Ug extends mr{constructor(){super(...arguments),this.client=new tt,this.movement=new tt,this.offset=new tt,this.global=new tt,this.screen=new tt}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(e,t,i){return e.worldTransform.applyInverse(i||this.global,t)}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,i,s,n,o,a,h,l,c,d,u,p,f,y){throw new Error("Method not implemented.")}}class Sa extends Ug{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}var Hg=`in vec2 aPosition;
|
|
289
|
+
`;let Ze=null;class wl{constructor(){Ze||(Ze=URL.createObjectURL(new Blob([Mg],{type:"application/javascript"}))),this.worker=new Worker(Ze)}}wl.revokeObjectURL=function(){Ze&&(URL.revokeObjectURL(Ze),Ze=null)};let ga=0,Sn;class _g{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(e=>{const{worker:t}=new Kn;t.addEventListener("message",i=>{t.terminate(),Kn.revokeObjectURL(),e(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(e,t){var i;return this._run("loadImageBitmap",[e,(i=t==null?void 0:t.data)==null?void 0:i.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Sn===void 0&&(Sn=navigator.hardwareConcurrency||4);let e=this._workerPool.pop();return!e&&this._createdWorkers<Sn&&(this._createdWorkers++,e=new wl().worker,e.addEventListener("message",t=>{this._complete(t.data),this._returnWorker(t.target),this._next()})),e}_returnWorker(e){this._workerPool.push(e)}_complete(e){this._resolveHash[e.uuid]&&(e.error!==void 0?this._resolveHash[e.uuid].reject(e.error):this._resolveHash[e.uuid].resolve(e.data),delete this._resolveHash[e.uuid])}async _run(e,t){await this._initWorkers();const i=new Promise((s,n)=>{this._queue.push({id:e,arguments:t,resolve:s,reject:n})});return this._next(),i}_next(){if(!this._queue.length)return;const e=this._getWorker();if(!e)return;const t=this._queue.pop(),i=t.id;this._resolveHash[ga]={resolve:t.resolve,reject:t.reject},e.postMessage({data:t.arguments,uuid:ga++,id:i})}reset(){this._workerPool.forEach(e=>e.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:e})=>{e==null||e(new Error("WorkerManager has been reset before completion"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}}const ma=new _g,Tg=[".jpeg",".jpg",".png",".webp",".avif"],kg=["image/jpeg","image/png","image/webp","image/avif"];async function Rg(r,e){var s;const t=await j.get().fetch(r);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${t.status} ${t.statusText}`);const i=await t.blob();return((s=e==null?void 0:e.data)==null?void 0:s.alphaMode)==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}const Cl={name:"loadTextures",id:"texture",extension:{type:I.LoadParser,priority:ue.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return pe(r,kg)||li(r,Tg)},async load(r,e,t){var n;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await ma.isImageBitmapSupported()?i=await ma.loadImageBitmap(r,e):i=await Rg(r,e):i=await new Promise((o,a)=>{i=j.get().createImage(),i.crossOrigin=this.config.crossOrigin,i.src=r,i.complete?o(i):(i.onload=()=>{o(i)},i.onerror=a)});const s=new ii({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((n=e.data)==null?void 0:n.resolution)||Ar(r),...e.data});return Pr(s,t,r)},unload(r){r.destroy(!0)}},Eg=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let vn,bn;function Ig(r,e,t){t===void 0&&!e.startsWith("data:")?r.crossOrigin=Dg(e):t!==!1&&(r.crossOrigin=typeof t=="string"?t:"anonymous")}function Bg(r){return new Promise((e,t)=>{r.addEventListener("canplaythrough",i),r.addEventListener("error",s),r.load();function i(){n(),e()}function s(o){n(),t(o)}function n(){r.removeEventListener("canplaythrough",i),r.removeEventListener("error",s)}})}function Dg(r,e=globalThis.location){if(r.startsWith("data:"))return"";e||(e=globalThis.location);const t=new URL(r,document.baseURI);return t.hostname!==e.hostname||t.port!==e.port||t.protocol!==e.protocol?"anonymous":""}function Fg(){const r=[],e=[];for(const t of Eg){const i=Mi.MIME_TYPES[t.substring(1)]||`video/${t.substring(1)}`;ks(i)&&(r.push(t),e.includes(i)||e.push(i))}return{validVideoExtensions:r,validVideoMime:e}}const zg={name:"loadVideo",id:"video",extension:{type:I.LoadParser,name:"loadVideo"},test(r){if(!vn||!bn){const{validVideoExtensions:i,validVideoMime:s}=Fg();vn=i,bn=s}const e=pe(r,bn),t=li(r,vn);return e||t},async load(r,e,t){var h,l;const i={...Mi.defaultOptions,resolution:((h=e.data)==null?void 0:h.resolution)||Ar(r),alphaMode:((l=e.data)==null?void 0:l.alphaMode)||await Th(),...e.data},s=document.createElement("video"),n={preload:i.autoLoad!==!1?"auto":void 0,"webkit-playsinline":i.playsinline!==!1?"":void 0,playsinline:i.playsinline!==!1?"":void 0,muted:i.muted===!0?"":void 0,loop:i.loop===!0?"":void 0,autoplay:i.autoPlay!==!1?"":void 0};Object.keys(n).forEach(c=>{const d=n[c];d!==void 0&&s.setAttribute(c,d)}),i.muted===!0&&(s.muted=!0),Ig(s,r,i.crossorigin);const o=document.createElement("source");let a;if(i.mime)a=i.mime;else if(r.startsWith("data:"))a=r.slice(5,r.indexOf(";"));else if(!r.startsWith("blob:")){const c=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase();a=Mi.MIME_TYPES[c]||`video/${c}`}return o.src=r,a&&(o.type=a),new Promise((c,d)=>{i.preload&&!i.autoPlay&&s.load(),s.addEventListener("canplay",u),s.addEventListener("error",p),o.addEventListener("error",p),s.appendChild(o);async function u(){const y=new Mi({...i,resource:s});f(),e.data.preload&&await Bg(s),c(Pr(y,t,r))}function p(y){f(),d(y)}function f(){s.removeEventListener("canplay",u),s.removeEventListener("error",p),o.removeEventListener("error",p)}})},unload(r){r.destroy(!0)}},Al={extension:{type:I.ResolveParser,name:"resolveTexture"},test:Cl.test,parse:r=>{var e;return{resolution:parseFloat(((e=hi.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:r.split(".").pop(),src:r}}},Lg={extension:{type:I.ResolveParser,priority:-2,name:"resolveJson"},test:r=>hi.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:Al.parse};class Og{constructor(){this._detections=[],this._initialized=!1,this.resolver=new hi,this.loader=new dp,this.cache=xt,this._backgroundLoader=new ip(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(e={}){var n,o;if(this._initialized){nt("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,e.defaultSearchParams&&this.resolver.setDefaultSearchParams(e.defaultSearchParams),e.basePath&&(this.resolver.basePath=e.basePath),e.bundleIdentifier&&this.resolver.setBundleIdentifier(e.bundleIdentifier),e.manifest){let a=e.manifest;typeof a=="string"&&(a=await this.load(a)),this.resolver.addManifest(a)}const t=((n=e.texturePreference)==null?void 0:n.resolution)??1,i=typeof t=="number"?[t]:t,s=await this._detectFormats({preferredFormats:(o=e.texturePreference)==null?void 0:o.format,skipDetections:e.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:i}}),e.preferences&&this.setPreferences(e.preferences),e.loadOptions&&(this.loader.loadOptions={...this.loader.loadOptions,...e.loadOptions})}add(e){this.resolver.add(e)}async load(e,t){this._initialized||await this.init();const i=ms(e),s=zt(e).map(a=>{if(typeof a!="string"){const h=this.resolver.getAlias(a);return h.some(l=>!this.resolver.hasKey(l))&&this.add(a),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(s),o=await this._mapLoadToResolve(n,t);return i?o[s[0]]:o}addBundle(e,t){this.resolver.addBundle(e,t)}async loadBundle(e,t){this._initialized||await this.init();let i=!1;typeof e=="string"&&(i=!0,e=[e]);const s=this.resolver.resolveBundle(e),n={},o=Object.keys(s);let a=0;const h=[],l=()=>{t==null||t(h.reduce((d,u)=>d+u,0)/a)},c=o.map((d,u)=>{const p=s[d],f=Object.values(p),m=[...new Set(f.flat())].reduce((x,S)=>x+(S.progressSize||1),0);return h.push(0),a+=m,this._mapLoadToResolve(p,x=>{h[u]=x*m,l()}).then(x=>{n[d]=x})});return await Promise.all(c),i?n[e[0]]:n}async backgroundLoad(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolve(e);this._backgroundLoader.add(Object.values(t))}async backgroundLoadBundle(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolveBundle(e);Object.values(t).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(e){if(typeof e=="string")return xt.get(e);const t={};for(let i=0;i<e.length;i++)t[i]=xt.get(e[i]);return t}async _mapLoadToResolve(e,t){const i=[...new Set(Object.values(e))];this._backgroundLoader.active=!1;const s=await this.loader.load(i,t);this._backgroundLoader.active=!0;const n={};return i.forEach(o=>{const a=s[o.src],h=[o.src];o.alias&&h.push(...o.alias),h.forEach(l=>{n[l]=a}),xt.set(h,a)}),n}async unload(e){this._initialized||await this.init();const t=zt(e).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(t);await this._unloadFromResolved(i)}async unloadBundle(e){this._initialized||await this.init(),e=zt(e);const t=this.resolver.resolveBundle(e),i=Object.keys(t).map(s=>this._unloadFromResolved(t[s]));await Promise.all(i)}async _unloadFromResolved(e){const t=Object.values(e);t.forEach(i=>{xt.remove(i.src)}),await this.loader.unload(t)}async _detectFormats(e){let t=[];e.preferredFormats&&(t=Array.isArray(e.preferredFormats)?e.preferredFormats:[e.preferredFormats]);for(const i of e.detections)e.skipDetections||await i.test()?t=await i.add(t):e.skipDetections||(t=await i.remove(t));return t=t.filter((i,s)=>t.indexOf(i)===s),t}get detections(){return this._detections}setPreferences(e){this.loader.parsers.forEach(t=>{t.config&&Object.keys(t.config).filter(i=>i in e).forEach(i=>{t.config[i]=e[i]})})}}const N=new Og;$.handleByList(I.LoadParser,N.loader.parsers).handleByList(I.ResolveParser,N.resolver.parsers).handleByList(I.CacheParser,N.cache.parsers).handleByList(I.DetectionParser,N.detections);$.add(sp,rp,np,cp,ap,hp,lp,fp,yp,Pp,bg,Cl,zg,ep,tp,Al,Lg);const ya={loader:I.LoadParser,resolver:I.ResolveParser,cache:I.CacheParser,detection:I.DetectionParser};$.handle(I.Asset,r=>{const e=r.ref;Object.entries(ya).filter(([t])=>!!e[t]).forEach(([t,i])=>$.add(Object.assign(e[t],{extension:e[t].extension??i})))},r=>{const e=r.ref;Object.keys(ya).filter(t=>!!e[t]).forEach(t=>$.remove(e[t]))});class Pl{constructor(e){this._attachedDomElements=[],this._renderer=e,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new ru({domElement:this._domElement,renderer:this._renderer})}addRenderable(e,t){this._attachedDomElements.includes(e)||this._attachedDomElements.push(e)}updateRenderable(e){}validateRenderable(e){return!0}postrender(){const e=this._attachedDomElements;if(e.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let t=0;t<e.length;t++){const i=e[t],s=i.element;if(!i.parent||i.globalDisplayStatus<7)s==null||s.remove(),e.splice(t,1),t--;else{this._domElement.contains(s)||(s.style.position="absolute",s.style.pointerEvents="auto",this._domElement.appendChild(s));const n=i.worldTransform,o=i._anchor,a=i.width*o.x,h=i.height*o.y;s.style.transformOrigin=`${a}px ${h}px`,s.style.transform=`matrix(${n.a}, ${n.b}, ${n.c}, ${n.d}, ${n.tx-a}, ${n.ty-h})`,s.style.opacity=i.groupAlpha.toString()}}}destroy(){var e;this._renderer.runners.postrender.remove(this);for(let t=0;t<this._attachedDomElements.length;t++)(e=this._attachedDomElements[t].element)==null||e.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}Pl.extension={type:[I.WebGLPipes,I.WebGPUPipes,I.CanvasPipes],name:"dom"};$.add(Pl);class Wg extends ai{constructor(e={}){const{element:t,anchor:i,...s}=e;super({label:"DOMContainer",...s}),this.renderPipeId="dom",this.batched=!1,this._anchor=new tt(0,0),i&&(this.anchor=i),this.element=e.element||document.createElement("div")}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}set element(e){this._element!==e&&(this._element=e,this.onViewUpdate())}get element(){return this._element}updateBounds(){const e=this._bounds,t=this._element;if(!t){e.minX=0,e.minY=0,e.maxX=0,e.maxY=0;return}const{offsetWidth:i,offsetHeight:s}=t;e.minX=0,e.maxX=i,e.minY=0,e.maxY=s}destroy(e=!1){var t,i;super.destroy(e),(i=(t=this._element)==null?void 0:t.parentNode)==null||i.removeChild(this._element),this._element=null,this._anchor=null}}class Gg extends gr{constructor(){super(...arguments),this.client=new tt,this.movement=new tt,this.offset=new tt,this.global=new tt,this.screen=new tt}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(e,t,i){return e.worldTransform.applyInverse(i||this.global,t)}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,i,s,n,o,a,h,l,c,d,u,p,f,y){throw new Error("Method not implemented.")}}class xa extends Gg{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}var Ug=`in vec2 aPosition;
|
|
290
290
|
out vec2 vTextureCoord;
|
|
291
291
|
|
|
292
292
|
uniform vec4 uInputSize;
|
|
@@ -313,7 +313,7 @@ void main(void)
|
|
|
313
313
|
gl_Position = filterVertexPosition();
|
|
314
314
|
vTextureCoord = filterTextureCoord();
|
|
315
315
|
}
|
|
316
|
-
`,
|
|
316
|
+
`,Hg=`
|
|
317
317
|
in vec2 vTextureCoord;
|
|
318
318
|
|
|
319
319
|
out vec4 finalColor;
|
|
@@ -325,7 +325,7 @@ void main()
|
|
|
325
325
|
{
|
|
326
326
|
finalColor = texture(uTexture, vTextureCoord) * uAlpha;
|
|
327
327
|
}
|
|
328
|
-
`,
|
|
328
|
+
`,Sa=`struct GlobalFilterUniforms {
|
|
329
329
|
uInputSize:vec4<f32>,
|
|
330
330
|
uInputPixel:vec4<f32>,
|
|
331
331
|
uInputClamp:vec4<f32>,
|
|
@@ -393,7 +393,7 @@ fn mainFragment(
|
|
|
393
393
|
var sample = textureSample(uTexture, uSampler, uv);
|
|
394
394
|
|
|
395
395
|
return sample * alphaUniforms.uAlpha;
|
|
396
|
-
}`;const Tl=class kl extends Tu{constructor(e){e={...kl.defaultOptions,...e};const t=le.from({vertex:{source:va,entryPoint:"mainVertex"},fragment:{source:va,entryPoint:"mainFragment"}}),i=si.from({vertex:Hg,fragment:Vg,name:"alpha-filter"}),{alpha:s,...n}=e,o=new ni({uAlpha:{value:s,type:"f32"}});super({...n,gpuProgram:t,glProgram:i,resources:{alphaUniforms:o}})}get alpha(){return this.resources.alphaUniforms.uniforms.uAlpha}set alpha(e){this.resources.alphaUniforms.uniforms.uAlpha=e}};Tl.defaultOptions={alpha:1};let Ng=Tl;function ba(r,e,t,i,s,n,o,a){const h=o-t,l=a-i,c=s-t,d=n-i,u=r-t,p=e-i,f=h*h+l*l,y=h*c+l*d,m=h*u+l*p,x=c*c+d*d,S=c*u+d*p,v=1/(f*x-y*y),b=(x*m-y*S)*v,P=(f*S-y*m)*v;return b>=0&&P>=0&&b+P<1}class jg{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class Yg{constructor(){this.instructions=new fr}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const Tr=class Qn{constructor(e){this._renderer=e,this._managedContexts=new ci({renderer:e,type:"resource",name:"graphicsContext"})}init(e){Qn.defaultOptions.bezierSmoothness=(e==null?void 0:e.bezierSmoothness)??Qn.defaultOptions.bezierSmoothness}getContextRenderData(e){return this.getGpuContext(e).graphicsData||this._initContextRenderData(e)}updateGpuContext(e){const t=e._gpuData,i=!!t[this._renderer.uid],s=t[this._renderer.uid]||this._initContext(e);return(e.dirty||!i)&&(i&&s.reset(),s.isBatchable=!1,e.dirty=!1),s}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){const t=new Yg,i=this.getGpuContext(e);return i.graphicsData=t,t.init(),t}_initContext(e){const t=new jg;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};Tr.extension={type:[I.CanvasSystem],name:"graphicsContext"};Tr.defaultOptions={bezierSmoothness:.5};let Xg=Tr;class Rl{constructor(e,t){this.state=Vi.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new ci({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){return!1}addRenderable(e,t){this._managedGraphics.add(e),this.renderer.renderPipes.batch.break(t),t.add(e)}updateRenderable(e){}execute(e){e.isRenderable&&this._adaptor.execute(this,e)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}}Rl.extension={type:[I.CanvasPipes],name:"graphics"};function kr(r,e,t){const i=(r>>24&255)/255;e[t++]=(r&255)/255*i,e[t++]=(r>>8&255)/255*i,e[t++]=(r>>16&255)/255*i,e[t++]=i}class Zg{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(e=>{_t.return(e)}),this.batches.length=0}}class El{constructor(e,t){this.state=Vi.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new ci({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){const t=e.context,i=!!e._gpuData,n=this.renderer.graphicsContext.updateGpuContext(t);return!!(n.isBatchable||i!==n.isBatchable)}addRenderable(e,t){const s=this.renderer.graphicsContext.updateGpuContext(e.context);e.didViewUpdate&&this._rebuild(e),s.isBatchable?this._addToBatcher(e,t):(this.renderer.renderPipes.batch.break(t),t.add(e))}updateRenderable(e){const i=this._getGpuDataForRenderable(e).batches;for(let s=0;s<i.length;s++){const n=i[s];n._batcher.updateElement(n)}}execute(e){if(!e.isRenderable)return;const t=this.renderer,i=e.context;if(!t.graphicsContext.getGpuContext(i).batches.length)return;const n=i.customShader||this._adaptor.shader;this.state.blendMode=e.groupBlendMode;const o=n.resources.localUniforms.uniforms;o.uTransformMatrix=e.groupTransform,o.uRound=t._roundPixels|e._roundPixels,kr(e.groupColorAlpha,o.uColor,0),this._adaptor.execute(this,e)}_rebuild(e){const t=this._getGpuDataForRenderable(e),s=this.renderer.graphicsContext.updateGpuContext(e.context);t.destroy(),s.isBatchable&&this._updateBatchesForRenderable(e,t)}_addToBatcher(e,t){const i=this.renderer.renderPipes.batch,s=this._getGpuDataForRenderable(e).batches;for(let n=0;n<s.length;n++){const o=s[n];i.addToBatch(o,t)}}_getGpuDataForRenderable(e){return e._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(e)}_initGpuDataForRenderable(e){const t=new Zg;return e._gpuData[this.renderer.uid]=t,this._managedGraphics.add(e),t}_updateBatchesForRenderable(e,t){const i=e.context,n=this.renderer.graphicsContext.getGpuContext(i),o=this.renderer._roundPixels|e._roundPixels;t.batches=n.batches.map(a=>{const h=_t.get(vr);return a.copyTo(h),h.renderable=e,h.roundPixels=o,h})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}El.extension={type:[I.WebGLPipes,I.WebGPUPipes],name:"graphics"};$.add(Rl);$.add(El);$.add(Xg);$.add(Cr);class H extends ai{constructor(e){e instanceof mt&&(e={context:e});const{context:t,roundPixels:i,...s}=e||{};super({label:"Graphics",...s}),this.renderPipeId="graphics",t?this.context=t:(this.context=this._ownedContext=new mt,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=i??!1}set context(e){e!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=e,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(e){return this._context.containsPoint(e)}destroy(e){this._ownedContext&&!e?this._ownedContext.destroy(e):(e===!0||(e==null?void 0:e.context)===!0)&&this._context.destroy(e),this._ownedContext=null,this._context=null,super.destroy(e)}_onTouch(e){this._gcLastUsed=e,this._context._gcLastUsed=e}_callContextMethod(e,t){return this.context[e](...t),this}setFillStyle(...e){return this._callContextMethod("setFillStyle",e)}setStrokeStyle(...e){return this._callContextMethod("setStrokeStyle",e)}fill(...e){return this._callContextMethod("fill",e)}stroke(...e){return this._callContextMethod("stroke",e)}texture(...e){return this._callContextMethod("texture",e)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...e){return this._callContextMethod("arc",e)}arcTo(...e){return this._callContextMethod("arcTo",e)}arcToSvg(...e){return this._callContextMethod("arcToSvg",e)}bezierCurveTo(...e){return this._callContextMethod("bezierCurveTo",e)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...e){return this._callContextMethod("ellipse",e)}circle(...e){return this._callContextMethod("circle",e)}path(...e){return this._callContextMethod("path",e)}lineTo(...e){return this._callContextMethod("lineTo",e)}moveTo(...e){return this._callContextMethod("moveTo",e)}quadraticCurveTo(...e){return this._callContextMethod("quadraticCurveTo",e)}rect(...e){return this._callContextMethod("rect",e)}roundRect(...e){return this._callContextMethod("roundRect",e)}poly(...e){return this._callContextMethod("poly",e)}regularPoly(...e){return this._callContextMethod("regularPoly",e)}roundPoly(...e){return this._callContextMethod("roundPoly",e)}roundShape(...e){return this._callContextMethod("roundShape",e)}filletRect(...e){return this._callContextMethod("filletRect",e)}chamferRect(...e){return this._callContextMethod("chamferRect",e)}star(...e){return this._callContextMethod("star",e)}svg(...e){return this._callContextMethod("svg",e)}restore(...e){return this._callContextMethod("restore",e)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...e){return this._callContextMethod("rotate",e)}scaleTransform(...e){return this._callContextMethod("scale",e)}setTransform(...e){return this._callContextMethod("setTransform",e)}transform(...e){return this._callContextMethod("transform",e)}translateTransform(...e){return this._callContextMethod("translate",e)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(e){this._context.fillStyle=e}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(e){this._context.strokeStyle=e}clone(e=!1){return e?new H(this._context.clone()):(this._ownedContext=null,new H(this._context))}lineStyle(e,t,i){V(J,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const s={};return e&&(s.width=e),t&&(s.color=t),i&&(s.alpha=i),this.context.strokeStyle=s,this}beginFill(e,t){V(J,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return e!==void 0&&(i.color=e),t!==void 0&&(i.alpha=t),this.context.fillStyle=i,this}endFill(){V(J,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const e=this.context.strokeStyle;return(e.width!==mt.defaultStrokeStyle.width||e.color!==mt.defaultStrokeStyle.color||e.alpha!==mt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...e){return V(J,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",e)}drawEllipse(...e){return V(J,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",e)}drawPolygon(...e){return V(J,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",e)}drawRect(...e){return V(J,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",e)}drawRoundedRect(...e){return V(J,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",e)}drawStar(...e){return V(J,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",e)}}const Il=class Bl extends Gi{constructor(...e){let t=e[0]??{};t instanceof Float32Array&&(V(J,"use new MeshGeometry({ positions, uvs, indices }) instead"),t={positions:t,uvs:e[1],indices:e[2]}),t={...Bl.defaultOptions,...t};const i=t.positions||new Float32Array([0,0,1,0,1,1,0,1]);let s=t.uvs;s||(t.positions?s=new Float32Array(i.length):s=new Float32Array([0,0,1,0,1,1,0,1]));const n=t.indices||new Uint32Array([0,1,2,0,2,3]),o=t.shrinkBuffersToFit,a=new he({data:i,label:"attribute-mesh-positions",shrinkToFit:o,usage:ft.VERTEX|ft.COPY_DST}),h=new he({data:s,label:"attribute-mesh-uvs",shrinkToFit:o,usage:ft.VERTEX|ft.COPY_DST}),l=new he({data:n,label:"index-mesh-buffer",shrinkToFit:o,usage:ft.INDEX|ft.COPY_DST});super({attributes:{aPosition:{buffer:a,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:h,format:"float32x2",stride:2*4,offset:0}},indexBuffer:l,topology:t.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(e){this.attributes.aPosition.buffer.data=e}get uvs(){return this.attributes.aUV.buffer.data}set uvs(e){this.attributes.aUV.buffer.data=e}get indices(){return this.indexBuffer.data}set indices(e){this.indexBuffer.data=e}};Il.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Rr=Il;class Dl{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(e){this._topology=e}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(e){this.texture!==e&&(this.texture=e,this._textureMatrixUpdateId=-1)}get uvs(){const t=this.geometry.getBuffer("aUV"),i=t.data;let s=i;const n=this.texture.textureMatrix;return n.isSimple||(s=this._transformedUvs,(this._textureMatrixUpdateId!==n._updateID||this._uvUpdateId!==t._updateID)&&((!s||s.length<i.length)&&(s=this._transformedUvs=new Float32Array(i.length)),this._textureMatrixUpdateId=n._updateID,this._uvUpdateId=t._updateID,n.multiplyUvs(i,s))),s}get positions(){return this.geometry.positions}get indices(){return this.geometry.indices}get color(){return this.renderable.groupColorAlpha}get groupTransform(){return this.renderable.groupTransform}get attributeSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class wa{destroy(){}}class Fl{constructor(e,t){this.localUniforms=new ni({uTransformMatrix:{value:new U,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new _i({0:this.localUniforms}),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){const t=this._getMeshData(e),i=t.batched,s=e.batched;if(t.batched=s,i!==s)return!0;if(s){const n=e._geometry;if(n.indices.length!==t.indexSize||n.positions.length!==t.vertexSize)return t.indexSize=n.indices.length,t.vertexSize=n.positions.length,!0;const o=this._getBatchableMesh(e);return o.texture.uid!==e._texture.uid&&(o._textureMatrixUpdateId=-1),!o._batcher.checkAndUpdateTexture(o,e._texture)}return!1}addRenderable(e,t){var n,o;const i=this.renderer.renderPipes.batch,s=this._getMeshData(e);if(e.didViewUpdate&&(s.indexSize=(n=e._geometry.indices)==null?void 0:n.length,s.vertexSize=(o=e._geometry.positions)==null?void 0:o.length),s.batched){const a=this._getBatchableMesh(e);a.setTexture(e._texture),a.geometry=e._geometry,i.addToBatch(a,t)}else i.break(t),t.add(e)}updateRenderable(e){if(e.batched){const t=this._getBatchableMesh(e);t.setTexture(e._texture),t.geometry=e._geometry,t._batcher.updateElement(t)}}execute(e){if(!e.isRenderable)return;e.state.blendMode=ys(e.groupBlendMode,e.texture._source);const t=this.localUniforms;t.uniforms.uTransformMatrix=e.groupTransform,t.uniforms.uRound=this.renderer._roundPixels|e._roundPixels,t.update(),kr(e.groupColorAlpha,t.uniforms.uColor,0),this._adaptor.execute(this,e)}_getMeshData(e){var t,i;return(t=e._gpuData)[i=this.renderer.uid]||(t[i]=new wa),e._gpuData[this.renderer.uid].meshData||this._initMeshData(e)}_initMeshData(e){return e._gpuData[this.renderer.uid].meshData={batched:e.batched,indexSize:0,vertexSize:0},e._gpuData[this.renderer.uid].meshData}_getBatchableMesh(e){var t,i;return(t=e._gpuData)[i=this.renderer.uid]||(t[i]=new wa),e._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(e)}_initBatchableMesh(e){const t=new Dl;return t.renderable=e,t.setTexture(e._texture),t.transform=e.groupTransform,t.roundPixels=this.renderer._roundPixels|e._roundPixels,e._gpuData[this.renderer.uid].batchableMesh=t,t}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}Fl.extension={type:[I.WebGLPipes,I.WebGPUPipes],name:"mesh"};$.add(Fl);class Ca extends ai{constructor(...e){let t=e[0];t instanceof Gi&&(V(J,"Mesh: use new Mesh({ geometry, shader }) instead"),t={geometry:t,shader:e[1]},e[3]&&(V(J,"Mesh: drawMode argument has been removed, use geometry.topology instead"),t.geometry.topology=e[3]));const{geometry:i,shader:s,texture:n,roundPixels:o,state:a,...h}=t;super({label:"Mesh",...h}),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=s??null,this.texture=n??(s==null?void 0:s.texture)??G.WHITE,this.state=a??Vi.for2d(),this._geometry=i,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=o??!1}get material(){return V(J,"mesh.material property has been removed, use mesh.shader instead"),this._shader}set shader(e){this._shader!==e&&(this._shader=e,this.onViewUpdate())}get shader(){return this._shader}set geometry(e){var t;this._geometry!==e&&((t=this._geometry)==null||t.off("update",this.onViewUpdate,this),e.on("update",this.onViewUpdate,this),this._geometry=e,this.onViewUpdate())}get geometry(){return this._geometry}set texture(e){e||(e=G.EMPTY);const t=this._texture;t!==e&&(t&&t.dynamic&&t.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this.shader&&(this.shader.texture=e),this._texture=e,this.onViewUpdate())}get texture(){return this._texture}get batched(){return this._shader||this.state.data&12?!1:this._geometry instanceof Rr?this._geometry.batchMode==="auto"?this._geometry.positions.length/2<=100:this._geometry.batchMode==="batch":!1}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(e){const{x:t,y:i}=e;if(!this.bounds.containsPoint(t,i))return!1;const s=this.geometry.getBuffer("aPosition").data,n=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){const o=this.geometry.getIndex().data,a=o.length;for(let h=0;h+2<a;h+=n){const l=o[h]*2,c=o[h+1]*2,d=o[h+2]*2;if(ba(t,i,s[l],s[l+1],s[c],s[c+1],s[d],s[d+1]))return!0}}else{const o=s.length/2;for(let a=0;a+2<o;a+=n){const h=a*2,l=(a+1)*2,c=(a+2)*2;if(ba(t,i,s[h],s[h+1],s[l],s[l+1],s[c],s[c+1]))return!0}}return!1}destroy(e){var i;if(super.destroy(e),typeof e=="boolean"?e:e==null?void 0:e.texture){const s=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._texture.destroy(s)}(i=this._geometry)==null||i.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null}}class vs extends jt{constructor(...e){let t=e[0];Array.isArray(e[0])&&(t={textures:e[0],autoUpdate:e[1]});const{animationSpeed:i=1,autoPlay:s=!1,autoUpdate:n=!0,loop:o=!0,onComplete:a=null,onFrameChange:h=null,onLoop:l=null,textures:c,updateAnchor:d=!1,...u}=t,[p]=c;super({...u,texture:p instanceof G?p:p.texture}),this._textures=null,this._durations=null,this._autoUpdate=n,this._isConnectedToTicker=!1,this.animationSpeed=i,this.loop=o,this.updateAnchor=d,this.onComplete=a,this.onFrameChange=h,this.onLoop=l,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=c,s&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(yt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(yt.shared.add(this.update,this,Ie.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(e){this.stop(),this.currentFrame=e}gotoAndPlay(e){this.currentFrame=e,this.play()}update(e){if(!this._playing)return;const t=e.deltaTime,i=this.animationSpeed*t,s=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=i/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];const o=Math.sign(this.animationSpeed*t);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*o,this._currentTime+=o;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=i;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):s!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<s||this.animationSpeed<0&&this.currentFrame>s)&&this.onLoop(),this._updateTexture())}_updateTexture(){const e=this.currentFrame;this._previousFrame!==e&&(this._previousFrame=e,this.texture=this._textures[e],this.updateAnchor&&this.texture.defaultAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(e=!1){if(typeof e=="boolean"?e:e==null?void 0:e.texture){const i=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._textures.forEach(s=>{this.texture!==s&&s.destroy(i)})}this._textures=[],this._durations=null,this.stop(),super.destroy(e),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(e){const t=[];for(let i=0;i<e.length;++i)t.push(G.from(e[i]));return new vs(t)}static fromImages(e){const t=[];for(let i=0;i<e.length;++i)t.push(G.from(e[i]));return new vs(t)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(e){if(e[0]instanceof G)this._textures=e,this._durations=null;else{this._textures=[],this._durations=[];for(let t=0;t<e.length;t++)this._textures.push(e[t].texture),this._durations.push(e[t].time)}this._previousFrame=null,this.gotoAndStop(0),this._updateTexture()}get currentFrame(){let e=Math.floor(this._currentTime)%this._textures.length;return e<0&&(e+=this._textures.length),e}set currentFrame(e){if(e<0||e>this.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${e}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const t=this.currentFrame;this._currentTime=e,t!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,!this._autoUpdate&&this._isConnectedToTicker?(yt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(yt.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class qg{constructor({matrix:e,observer:t}={}){this.dirty=!0,this._matrix=e??new U,this.observer=t,this.position=new ct(this,0,0),this.scale=new ct(this,1,1),this.pivot=new ct(this,0,0),this.skew=new ct(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){const e=this._matrix;return this.dirty&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this.dirty=!1),e}_onUpdate(e){var t;this.dirty=!0,e===this.skew&&this.updateSkew(),(t=this.observer)==null||t._onUpdate(this)}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this.dirty=!0}toString(){return`[pixi.js/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`}setFromMatrix(e){e.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this.skew))}}let Ge;function Aa(r){const e=j.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=r,t.fillRect(0,0,6,1),e}function Kg(){if(Ge!==void 0)return Ge;try{const r=Aa("#ff00ff"),e=Aa("#ffff00"),i=j.get().createCanvas(6,1).getContext("2d");i.globalCompositeOperation="multiply",i.drawImage(r,0,0),i.drawImage(e,2,0);const s=i.getImageData(2,0,1,1);if(!s)Ge=!1;else{const n=s.data;Ge=n[0]===255&&n[1]===0&&n[2]===0}}catch{Ge=!1}return Ge}const st={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Kg(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:r=>{const e=r.source,t=e==null?void 0:e.resource;if(!t)return null;const i=e.alphaMode==="premultiplied-alpha",s=e.resourceWidth??e.pixelWidth,n=e.resourceHeight??e.pixelHeight,o=s!==e.pixelWidth||n!==e.pixelHeight;if(i){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!o)return t;const a=st._unpremultipliedCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const a=st._canvasSourceCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas;const h=j.get().createCanvas(e.pixelWidth,e.pixelHeight),l=h.getContext("2d"),c=l.createImageData(e.pixelWidth,e.pixelHeight),d=c.data,u=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let p=0;p<d.length&&p+3<u.length;p+=4)d[p]=u[p+2],d[p+1]=u[p+1],d[p+2]=u[p],d[p+3]=u[p+3];else d.set(u.subarray(0,d.length));return l.putImageData(c,0,0),st._canvasSourceCache.set(e,{canvas:h,resourceId:e._resourceId}),h}if(i){const a=j.get().createCanvas(e.pixelWidth,e.pixelHeight),h=a.getContext("2d",{willReadFrequently:!0});a.width=e.pixelWidth,a.height=e.pixelHeight,h.drawImage(t,0,0);const l=h.getImageData(0,0,a.width,a.height),c=l.data;for(let d=0;d<c.length;d+=4){const u=c[d+3];if(u>0){const p=255/u;c[d]=Math.min(255,c[d]*p+.5),c[d+1]=Math.min(255,c[d+1]*p+.5),c[d+2]=Math.min(255,c[d+2]*p+.5)}}return h.putImageData(l,0,0),st._unpremultipliedCache.set(e,{canvas:a,resourceId:e._resourceId}),a}if(o){const a=st._canvasSourceCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas;const h=j.get().createCanvas(e.pixelWidth,e.pixelHeight),l=h.getContext("2d");return h.width=e.pixelWidth,h.height=e.pixelHeight,l.drawImage(t,0,0),st._canvasSourceCache.set(e,{canvas:h,resourceId:e._resourceId}),h}return t},getTintedCanvas:(r,e)=>{const t=r.texture,i=rt.shared.setValue(e).toHex(),s=t.tintCache||(t.tintCache={}),n=s[i],o=t.source._resourceId;if((n==null?void 0:n.tintId)===o)return n;const a=n&&"getContext"in n?n:j.get().createCanvas();return st.tintMethod(t,e,a),a.tintId=o,s[i]=a,s[i]},getTintedPattern:(r,e)=>{const t=rt.shared.setValue(e).toHex(),i=r.patternCache||(r.patternCache={}),s=r.source._resourceId;let n=i[t];return(n==null?void 0:n.tintId)===s||(st.canvas||(st.canvas=j.get().createCanvas()),st.tintMethod(r,e,st.canvas),n=st.canvas.getContext("2d").createPattern(st.canvas,"repeat"),n.tintId=s,i[t]=n),n},applyPatternTransform:(r,e,t=!0)=>{if(!e)return;const i=r;if(!i.setTransform)return;const s=globalThis.DOMMatrix;if(!s)return;const n=new s([e.a,e.b,e.c,e.d,e.tx,e.ty]);i.setTransform(t?n.inverse():n)},tintWithMultiply:(r,e,t)=>{const i=t.getContext("2d"),s=r.frame.clone(),n=r.source._resolution??r.source.resolution??1,o=r.rotate;s.x*=n,s.y*=n,s.width*=n,s.height*=n;const a=X.isVertical(o),h=a?s.height:s.width,l=a?s.width:s.height;t.width=Math.ceil(h),t.height=Math.ceil(l),i.save(),i.fillStyle=rt.shared.setValue(e).toHex(),i.fillRect(0,0,h,l),i.globalCompositeOperation="multiply";const c=st.getCanvasSource(r);if(!c){i.restore();return}o&&st._applyInverseRotation(i,o,s.width,s.height),i.drawImage(c,s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.globalCompositeOperation="destination-atop",i.drawImage(c,s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.restore()},tintWithOverlay:(r,e,t)=>{const i=t.getContext("2d"),s=r.frame.clone(),n=r.source._resolution??r.source.resolution??1,o=r.rotate;s.x*=n,s.y*=n,s.width*=n,s.height*=n;const a=X.isVertical(o),h=a?s.height:s.width,l=a?s.width:s.height;t.width=Math.ceil(h),t.height=Math.ceil(l),i.save(),i.globalCompositeOperation="copy",i.fillStyle=rt.shared.setValue(e).toHex(),i.fillRect(0,0,h,l),i.globalCompositeOperation="destination-atop";const c=st.getCanvasSource(r);if(!c){i.restore();return}o&&st._applyInverseRotation(i,o,s.width,s.height),i.drawImage(c,s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.restore()},tintWithPerPixel:(r,e,t)=>{const i=t.getContext("2d"),s=r.frame.clone(),n=r.source._resolution??r.source.resolution??1,o=r.rotate;s.x*=n,s.y*=n,s.width*=n,s.height*=n;const a=X.isVertical(o),h=a?s.height:s.width,l=a?s.width:s.height;t.width=Math.ceil(h),t.height=Math.ceil(l),i.save(),i.globalCompositeOperation="copy";const c=st.getCanvasSource(r);if(!c){i.restore();return}o&&st._applyInverseRotation(i,o,s.width,s.height),i.drawImage(c,s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.restore();const d=e>>16&255,u=e>>8&255,p=e&255,f=i.getImageData(0,0,h,l),y=f.data;for(let m=0;m<y.length;m+=4)y[m]=y[m]*d/255,y[m+1]=y[m+1]*u/255,y[m+2]=y[m+2]*p/255;i.putImageData(f,0,0)},_applyInverseRotation:(r,e,t,i)=>{const s=X.inv(e),n=X.uX(s),o=X.uY(s),a=X.vX(s),h=X.vY(s),l=-Math.min(0,n*t,a*i,n*t+a*i),c=-Math.min(0,o*t,h*i,o*t+h*i);r.transform(n,o,a,h,l,c)}};st.tintMethod=st.canUseMultiply?st.tintWithMultiply:st.tintWithPerPixel;const ls=new U,xi=new U,Wt=[new tt,new tt,new tt,new tt];class zl{constructor(e){this._renderer=e}validateRenderable(e){return!1}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}updateRenderable(e){}execute(e){var A,k;const t=this._renderer,i=t.canvasContext,s=i.activeContext;s.save(),i.setBlendMode(e.groupBlendMode);const n=((A=t.globalUniforms.globalUniformData)==null?void 0:A.worldColor)??4294967295,o=e.groupColorAlpha,a=(n>>>24&255)/255,h=(o>>>24&255)/255,l=((k=t.filter)==null?void 0:k.alphaMultiplier)??1,c=a*h*l;if(c<=0){s.restore();return}s.globalAlpha=c;const d=n&16777215,u=o&16777215,p=Pi(pr(u,d)),f=e.texture,y=st.getTintedPattern(f,p),m=e.width,x=e.height,S=e.groupTransform,v=f.source._resolution??f.source.resolution??1;xi.copyFrom(e._tileTransform.matrix),e.applyAnchorToTexture||xi.translate(-e.anchor.x*m,-e.anchor.y*x),xi.scale(1/v,1/v),ls.identity(),ls.prepend(xi),ls.prepend(S);const b=t._roundPixels|e._roundPixels;i.setContextTransform(ls,b===1),s.fillStyle=y;const P=e.anchor.x*-m,C=e.anchor.y*-x;Wt[0].set(P,C),Wt[1].set(P+m,C),Wt[2].set(P+m,C+x),Wt[3].set(P,C+x);for(let M=0;M<4;M++)xi.applyInverse(Wt[M],Wt[M]);s.beginPath(),s.moveTo(Wt[0].x,Wt[0].y);for(let M=1;M<4;M++)s.lineTo(Wt[M].x,Wt[M].y);s.closePath(),s.fill(),s.restore()}destroy(){this._renderer=null}}zl.extension={type:[I.CanvasPipes],name:"tilingSprite"};const ps={name:"local-uniform-bit",vertex:{header:`
|
|
396
|
+
}`;const Ml=class _l extends _u{constructor(e){e={..._l.defaultOptions,...e};const t=le.from({vertex:{source:Sa,entryPoint:"mainVertex"},fragment:{source:Sa,entryPoint:"mainFragment"}}),i=si.from({vertex:Ug,fragment:Hg,name:"alpha-filter"}),{alpha:s,...n}=e,o=new ni({uAlpha:{value:s,type:"f32"}});super({...n,gpuProgram:t,glProgram:i,resources:{alphaUniforms:o}})}get alpha(){return this.resources.alphaUniforms.uniforms.uAlpha}set alpha(e){this.resources.alphaUniforms.uniforms.uAlpha=e}};Ml.defaultOptions={alpha:1};let Vg=Ml;function va(r,e,t,i,s,n,o,a){const h=o-t,l=a-i,c=s-t,d=n-i,u=r-t,p=e-i,f=h*h+l*l,y=h*c+l*d,m=h*u+l*p,x=c*c+d*d,S=c*u+d*p,v=1/(f*x-y*y),b=(x*m-y*S)*v,P=(f*S-y*m)*v;return b>=0&&P>=0&&b+P<1}class Ng{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class jg{constructor(){this.instructions=new pr}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const _r=class $n{constructor(e){this._renderer=e,this._managedContexts=new ci({renderer:e,type:"resource",name:"graphicsContext"})}init(e){$n.defaultOptions.bezierSmoothness=(e==null?void 0:e.bezierSmoothness)??$n.defaultOptions.bezierSmoothness}getContextRenderData(e){return this.getGpuContext(e).graphicsData||this._initContextRenderData(e)}updateGpuContext(e){const t=e._gpuData,i=!!t[this._renderer.uid],s=t[this._renderer.uid]||this._initContext(e);return(e.dirty||!i)&&(i&&s.reset(),s.isBatchable=!1,e.dirty=!1),s}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){const t=new jg,i=this.getGpuContext(e);return i.graphicsData=t,t.init(),t}_initContext(e){const t=new Ng;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};_r.extension={type:[I.CanvasSystem],name:"graphicsContext"};_r.defaultOptions={bezierSmoothness:.5};let Yg=_r;class Tl{constructor(e,t){this.state=Vi.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new ci({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){return!1}addRenderable(e,t){this._managedGraphics.add(e),this.renderer.renderPipes.batch.break(t),t.add(e)}updateRenderable(e){}execute(e){e.isRenderable&&this._adaptor.execute(this,e)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}}Tl.extension={type:[I.CanvasPipes],name:"graphics"};function Tr(r,e,t){const i=(r>>24&255)/255;e[t++]=(r&255)/255*i,e[t++]=(r>>8&255)/255*i,e[t++]=(r>>16&255)/255*i,e[t++]=i}class Xg{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(e=>{_t.return(e)}),this.batches.length=0}}class kl{constructor(e,t){this.state=Vi.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new ci({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){const t=e.context,i=!!e._gpuData,n=this.renderer.graphicsContext.updateGpuContext(t);return!!(n.isBatchable||i!==n.isBatchable)}addRenderable(e,t){const s=this.renderer.graphicsContext.updateGpuContext(e.context);e.didViewUpdate&&this._rebuild(e),s.isBatchable?this._addToBatcher(e,t):(this.renderer.renderPipes.batch.break(t),t.add(e))}updateRenderable(e){const i=this._getGpuDataForRenderable(e).batches;for(let s=0;s<i.length;s++){const n=i[s];n._batcher.updateElement(n)}}execute(e){if(!e.isRenderable)return;const t=this.renderer,i=e.context;if(!t.graphicsContext.getGpuContext(i).batches.length)return;const n=i.customShader||this._adaptor.shader;this.state.blendMode=e.groupBlendMode;const o=n.resources.localUniforms.uniforms;o.uTransformMatrix=e.groupTransform,o.uRound=t._roundPixels|e._roundPixels,Tr(e.groupColorAlpha,o.uColor,0),this._adaptor.execute(this,e)}_rebuild(e){const t=this._getGpuDataForRenderable(e),s=this.renderer.graphicsContext.updateGpuContext(e.context);t.destroy(),s.isBatchable&&this._updateBatchesForRenderable(e,t)}_addToBatcher(e,t){const i=this.renderer.renderPipes.batch,s=this._getGpuDataForRenderable(e).batches;for(let n=0;n<s.length;n++){const o=s[n];i.addToBatch(o,t)}}_getGpuDataForRenderable(e){return e._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(e)}_initGpuDataForRenderable(e){const t=new Xg;return e._gpuData[this.renderer.uid]=t,this._managedGraphics.add(e),t}_updateBatchesForRenderable(e,t){const i=e.context,n=this.renderer.graphicsContext.getGpuContext(i),o=this.renderer._roundPixels|e._roundPixels;t.batches=n.batches.map(a=>{const h=_t.get(Sr);return a.copyTo(h),h.renderable=e,h.roundPixels=o,h})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}kl.extension={type:[I.WebGLPipes,I.WebGPUPipes],name:"graphics"};$.add(Tl);$.add(kl);$.add(Yg);$.add(wr);class H extends ai{constructor(e){e instanceof mt&&(e={context:e});const{context:t,roundPixels:i,...s}=e||{};super({label:"Graphics",...s}),this.renderPipeId="graphics",t?this.context=t:(this.context=this._ownedContext=new mt,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=i??!1}set context(e){e!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=e,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(e){return this._context.containsPoint(e)}destroy(e){this._ownedContext&&!e?this._ownedContext.destroy(e):(e===!0||(e==null?void 0:e.context)===!0)&&this._context.destroy(e),this._ownedContext=null,this._context=null,super.destroy(e)}_onTouch(e){this._gcLastUsed=e,this._context._gcLastUsed=e}_callContextMethod(e,t){return this.context[e](...t),this}setFillStyle(...e){return this._callContextMethod("setFillStyle",e)}setStrokeStyle(...e){return this._callContextMethod("setStrokeStyle",e)}fill(...e){return this._callContextMethod("fill",e)}stroke(...e){return this._callContextMethod("stroke",e)}texture(...e){return this._callContextMethod("texture",e)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...e){return this._callContextMethod("arc",e)}arcTo(...e){return this._callContextMethod("arcTo",e)}arcToSvg(...e){return this._callContextMethod("arcToSvg",e)}bezierCurveTo(...e){return this._callContextMethod("bezierCurveTo",e)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...e){return this._callContextMethod("ellipse",e)}circle(...e){return this._callContextMethod("circle",e)}path(...e){return this._callContextMethod("path",e)}lineTo(...e){return this._callContextMethod("lineTo",e)}moveTo(...e){return this._callContextMethod("moveTo",e)}quadraticCurveTo(...e){return this._callContextMethod("quadraticCurveTo",e)}rect(...e){return this._callContextMethod("rect",e)}roundRect(...e){return this._callContextMethod("roundRect",e)}poly(...e){return this._callContextMethod("poly",e)}regularPoly(...e){return this._callContextMethod("regularPoly",e)}roundPoly(...e){return this._callContextMethod("roundPoly",e)}roundShape(...e){return this._callContextMethod("roundShape",e)}filletRect(...e){return this._callContextMethod("filletRect",e)}chamferRect(...e){return this._callContextMethod("chamferRect",e)}star(...e){return this._callContextMethod("star",e)}svg(...e){return this._callContextMethod("svg",e)}restore(...e){return this._callContextMethod("restore",e)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...e){return this._callContextMethod("rotate",e)}scaleTransform(...e){return this._callContextMethod("scale",e)}setTransform(...e){return this._callContextMethod("setTransform",e)}transform(...e){return this._callContextMethod("transform",e)}translateTransform(...e){return this._callContextMethod("translate",e)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(e){this._context.fillStyle=e}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(e){this._context.strokeStyle=e}clone(e=!1){return e?new H(this._context.clone()):(this._ownedContext=null,new H(this._context))}lineStyle(e,t,i){V(J,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const s={};return e&&(s.width=e),t&&(s.color=t),i&&(s.alpha=i),this.context.strokeStyle=s,this}beginFill(e,t){V(J,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return e!==void 0&&(i.color=e),t!==void 0&&(i.alpha=t),this.context.fillStyle=i,this}endFill(){V(J,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const e=this.context.strokeStyle;return(e.width!==mt.defaultStrokeStyle.width||e.color!==mt.defaultStrokeStyle.color||e.alpha!==mt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...e){return V(J,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",e)}drawEllipse(...e){return V(J,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",e)}drawPolygon(...e){return V(J,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",e)}drawRect(...e){return V(J,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",e)}drawRoundedRect(...e){return V(J,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",e)}drawStar(...e){return V(J,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",e)}}const Rl=class El extends Wi{constructor(...e){let t=e[0]??{};t instanceof Float32Array&&(V(J,"use new MeshGeometry({ positions, uvs, indices }) instead"),t={positions:t,uvs:e[1],indices:e[2]}),t={...El.defaultOptions,...t};const i=t.positions||new Float32Array([0,0,1,0,1,1,0,1]);let s=t.uvs;s||(t.positions?s=new Float32Array(i.length):s=new Float32Array([0,0,1,0,1,1,0,1]));const n=t.indices||new Uint32Array([0,1,2,0,2,3]),o=t.shrinkBuffersToFit,a=new he({data:i,label:"attribute-mesh-positions",shrinkToFit:o,usage:ft.VERTEX|ft.COPY_DST}),h=new he({data:s,label:"attribute-mesh-uvs",shrinkToFit:o,usage:ft.VERTEX|ft.COPY_DST}),l=new he({data:n,label:"index-mesh-buffer",shrinkToFit:o,usage:ft.INDEX|ft.COPY_DST});super({attributes:{aPosition:{buffer:a,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:h,format:"float32x2",stride:2*4,offset:0}},indexBuffer:l,topology:t.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(e){this.attributes.aPosition.buffer.data=e}get uvs(){return this.attributes.aUV.buffer.data}set uvs(e){this.attributes.aUV.buffer.data=e}get indices(){return this.indexBuffer.data}set indices(e){this.indexBuffer.data=e}};Rl.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let kr=Rl;class Il{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(e){this._topology=e}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(e){this.texture!==e&&(this.texture=e,this._textureMatrixUpdateId=-1)}get uvs(){const t=this.geometry.getBuffer("aUV"),i=t.data;let s=i;const n=this.texture.textureMatrix;return n.isSimple||(s=this._transformedUvs,(this._textureMatrixUpdateId!==n._updateID||this._uvUpdateId!==t._updateID)&&((!s||s.length<i.length)&&(s=this._transformedUvs=new Float32Array(i.length)),this._textureMatrixUpdateId=n._updateID,this._uvUpdateId=t._updateID,n.multiplyUvs(i,s))),s}get positions(){return this.geometry.positions}get indices(){return this.geometry.indices}get color(){return this.renderable.groupColorAlpha}get groupTransform(){return this.renderable.groupTransform}get attributeSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class ba{destroy(){}}class Bl{constructor(e,t){this.localUniforms=new ni({uTransformMatrix:{value:new U,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new _i({0:this.localUniforms}),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){const t=this._getMeshData(e),i=t.batched,s=e.batched;if(t.batched=s,i!==s)return!0;if(s){const n=e._geometry;if(n.indices.length!==t.indexSize||n.positions.length!==t.vertexSize)return t.indexSize=n.indices.length,t.vertexSize=n.positions.length,!0;const o=this._getBatchableMesh(e);return o.texture.uid!==e._texture.uid&&(o._textureMatrixUpdateId=-1),!o._batcher.checkAndUpdateTexture(o,e._texture)}return!1}addRenderable(e,t){var n,o;const i=this.renderer.renderPipes.batch,s=this._getMeshData(e);if(e.didViewUpdate&&(s.indexSize=(n=e._geometry.indices)==null?void 0:n.length,s.vertexSize=(o=e._geometry.positions)==null?void 0:o.length),s.batched){const a=this._getBatchableMesh(e);a.setTexture(e._texture),a.geometry=e._geometry,i.addToBatch(a,t)}else i.break(t),t.add(e)}updateRenderable(e){if(e.batched){const t=this._getBatchableMesh(e);t.setTexture(e._texture),t.geometry=e._geometry,t._batcher.updateElement(t)}}execute(e){if(!e.isRenderable)return;e.state.blendMode=ys(e.groupBlendMode,e.texture._source);const t=this.localUniforms;t.uniforms.uTransformMatrix=e.groupTransform,t.uniforms.uRound=this.renderer._roundPixels|e._roundPixels,t.update(),Tr(e.groupColorAlpha,t.uniforms.uColor,0),this._adaptor.execute(this,e)}_getMeshData(e){var t,i;return(t=e._gpuData)[i=this.renderer.uid]||(t[i]=new ba),e._gpuData[this.renderer.uid].meshData||this._initMeshData(e)}_initMeshData(e){return e._gpuData[this.renderer.uid].meshData={batched:e.batched,indexSize:0,vertexSize:0},e._gpuData[this.renderer.uid].meshData}_getBatchableMesh(e){var t,i;return(t=e._gpuData)[i=this.renderer.uid]||(t[i]=new ba),e._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(e)}_initBatchableMesh(e){const t=new Il;return t.renderable=e,t.setTexture(e._texture),t.transform=e.groupTransform,t.roundPixels=this.renderer._roundPixels|e._roundPixels,e._gpuData[this.renderer.uid].batchableMesh=t,t}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}Bl.extension={type:[I.WebGLPipes,I.WebGPUPipes],name:"mesh"};$.add(Bl);class wa extends ai{constructor(...e){let t=e[0];t instanceof Wi&&(V(J,"Mesh: use new Mesh({ geometry, shader }) instead"),t={geometry:t,shader:e[1]},e[3]&&(V(J,"Mesh: drawMode argument has been removed, use geometry.topology instead"),t.geometry.topology=e[3]));const{geometry:i,shader:s,texture:n,roundPixels:o,state:a,...h}=t;super({label:"Mesh",...h}),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=s??null,this.texture=n??(s==null?void 0:s.texture)??W.WHITE,this.state=a??Vi.for2d(),this._geometry=i,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=o??!1}get material(){return V(J,"mesh.material property has been removed, use mesh.shader instead"),this._shader}set shader(e){this._shader!==e&&(this._shader=e,this.onViewUpdate())}get shader(){return this._shader}set geometry(e){var t;this._geometry!==e&&((t=this._geometry)==null||t.off("update",this.onViewUpdate,this),e.on("update",this.onViewUpdate,this),this._geometry=e,this.onViewUpdate())}get geometry(){return this._geometry}set texture(e){e||(e=W.EMPTY);const t=this._texture;t!==e&&(t&&t.dynamic&&t.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this.shader&&(this.shader.texture=e),this._texture=e,this.onViewUpdate())}get texture(){return this._texture}get batched(){return this._shader||this.state.data&12?!1:this._geometry instanceof kr?this._geometry.batchMode==="auto"?this._geometry.positions.length/2<=100:this._geometry.batchMode==="batch":!1}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(e){const{x:t,y:i}=e;if(!this.bounds.containsPoint(t,i))return!1;const s=this.geometry.getBuffer("aPosition").data,n=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){const o=this.geometry.getIndex().data,a=o.length;for(let h=0;h+2<a;h+=n){const l=o[h]*2,c=o[h+1]*2,d=o[h+2]*2;if(va(t,i,s[l],s[l+1],s[c],s[c+1],s[d],s[d+1]))return!0}}else{const o=s.length/2;for(let a=0;a+2<o;a+=n){const h=a*2,l=(a+1)*2,c=(a+2)*2;if(va(t,i,s[h],s[h+1],s[l],s[l+1],s[c],s[c+1]))return!0}}return!1}destroy(e){var i;if(super.destroy(e),typeof e=="boolean"?e:e==null?void 0:e.texture){const s=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._texture.destroy(s)}(i=this._geometry)==null||i.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null}}class vs extends jt{constructor(...e){let t=e[0];Array.isArray(e[0])&&(t={textures:e[0],autoUpdate:e[1]});const{animationSpeed:i=1,autoPlay:s=!1,autoUpdate:n=!0,loop:o=!0,onComplete:a=null,onFrameChange:h=null,onLoop:l=null,textures:c,updateAnchor:d=!1,...u}=t,[p]=c;super({...u,texture:p instanceof W?p:p.texture}),this._textures=null,this._durations=null,this._autoUpdate=n,this._isConnectedToTicker=!1,this.animationSpeed=i,this.loop=o,this.updateAnchor=d,this.onComplete=a,this.onFrameChange=h,this.onLoop=l,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=c,s&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(yt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(yt.shared.add(this.update,this,Ie.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(e){this.stop(),this.currentFrame=e}gotoAndPlay(e){this.currentFrame=e,this.play()}update(e){if(!this._playing)return;const t=e.deltaTime,i=this.animationSpeed*t,s=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=i/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];const o=Math.sign(this.animationSpeed*t);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*o,this._currentTime+=o;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=i;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):s!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<s||this.animationSpeed<0&&this.currentFrame>s)&&this.onLoop(),this._updateTexture())}_updateTexture(){const e=this.currentFrame;this._previousFrame!==e&&(this._previousFrame=e,this.texture=this._textures[e],this.updateAnchor&&this.texture.defaultAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(e=!1){if(typeof e=="boolean"?e:e==null?void 0:e.texture){const i=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._textures.forEach(s=>{this.texture!==s&&s.destroy(i)})}this._textures=[],this._durations=null,this.stop(),super.destroy(e),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(e){const t=[];for(let i=0;i<e.length;++i)t.push(W.from(e[i]));return new vs(t)}static fromImages(e){const t=[];for(let i=0;i<e.length;++i)t.push(W.from(e[i]));return new vs(t)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(e){if(e[0]instanceof W)this._textures=e,this._durations=null;else{this._textures=[],this._durations=[];for(let t=0;t<e.length;t++)this._textures.push(e[t].texture),this._durations.push(e[t].time)}this._previousFrame=null,this.gotoAndStop(0),this._updateTexture()}get currentFrame(){let e=Math.floor(this._currentTime)%this._textures.length;return e<0&&(e+=this._textures.length),e}set currentFrame(e){if(e<0||e>this.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${e}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const t=this.currentFrame;this._currentTime=e,t!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,!this._autoUpdate&&this._isConnectedToTicker?(yt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(yt.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class Zg{constructor({matrix:e,observer:t}={}){this.dirty=!0,this._matrix=e??new U,this.observer=t,this.position=new ct(this,0,0),this.scale=new ct(this,1,1),this.pivot=new ct(this,0,0),this.skew=new ct(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){const e=this._matrix;return this.dirty&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this.dirty=!1),e}_onUpdate(e){var t;this.dirty=!0,e===this.skew&&this.updateSkew(),(t=this.observer)==null||t._onUpdate(this)}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this.dirty=!0}toString(){return`[pixi.js/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`}setFromMatrix(e){e.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this.skew))}}let We;function Ca(r){const e=j.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=r,t.fillRect(0,0,6,1),e}function qg(){if(We!==void 0)return We;try{const r=Ca("#ff00ff"),e=Ca("#ffff00"),i=j.get().createCanvas(6,1).getContext("2d");i.globalCompositeOperation="multiply",i.drawImage(r,0,0),i.drawImage(e,2,0);const s=i.getImageData(2,0,1,1);if(!s)We=!1;else{const n=s.data;We=n[0]===255&&n[1]===0&&n[2]===0}}catch{We=!1}return We}const st={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:qg(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:r=>{const e=r.source,t=e==null?void 0:e.resource;if(!t)return null;const i=e.alphaMode==="premultiplied-alpha",s=e.resourceWidth??e.pixelWidth,n=e.resourceHeight??e.pixelHeight,o=s!==e.pixelWidth||n!==e.pixelHeight;if(i){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!o)return t;const a=st._unpremultipliedCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const a=st._canvasSourceCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas;const h=j.get().createCanvas(e.pixelWidth,e.pixelHeight),l=h.getContext("2d"),c=l.createImageData(e.pixelWidth,e.pixelHeight),d=c.data,u=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let p=0;p<d.length&&p+3<u.length;p+=4)d[p]=u[p+2],d[p+1]=u[p+1],d[p+2]=u[p],d[p+3]=u[p+3];else d.set(u.subarray(0,d.length));return l.putImageData(c,0,0),st._canvasSourceCache.set(e,{canvas:h,resourceId:e._resourceId}),h}if(i){const a=j.get().createCanvas(e.pixelWidth,e.pixelHeight),h=a.getContext("2d",{willReadFrequently:!0});a.width=e.pixelWidth,a.height=e.pixelHeight,h.drawImage(t,0,0);const l=h.getImageData(0,0,a.width,a.height),c=l.data;for(let d=0;d<c.length;d+=4){const u=c[d+3];if(u>0){const p=255/u;c[d]=Math.min(255,c[d]*p+.5),c[d+1]=Math.min(255,c[d+1]*p+.5),c[d+2]=Math.min(255,c[d+2]*p+.5)}}return h.putImageData(l,0,0),st._unpremultipliedCache.set(e,{canvas:a,resourceId:e._resourceId}),a}if(o){const a=st._canvasSourceCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas;const h=j.get().createCanvas(e.pixelWidth,e.pixelHeight),l=h.getContext("2d");return h.width=e.pixelWidth,h.height=e.pixelHeight,l.drawImage(t,0,0),st._canvasSourceCache.set(e,{canvas:h,resourceId:e._resourceId}),h}return t},getTintedCanvas:(r,e)=>{const t=r.texture,i=rt.shared.setValue(e).toHex(),s=t.tintCache||(t.tintCache={}),n=s[i],o=t.source._resourceId;if((n==null?void 0:n.tintId)===o)return n;const a=n&&"getContext"in n?n:j.get().createCanvas();return st.tintMethod(t,e,a),a.tintId=o,s[i]=a,s[i]},getTintedPattern:(r,e)=>{const t=rt.shared.setValue(e).toHex(),i=r.patternCache||(r.patternCache={}),s=r.source._resourceId;let n=i[t];return(n==null?void 0:n.tintId)===s||(st.canvas||(st.canvas=j.get().createCanvas()),st.tintMethod(r,e,st.canvas),n=st.canvas.getContext("2d").createPattern(st.canvas,"repeat"),n.tintId=s,i[t]=n),n},applyPatternTransform:(r,e,t=!0)=>{if(!e)return;const i=r;if(!i.setTransform)return;const s=globalThis.DOMMatrix;if(!s)return;const n=new s([e.a,e.b,e.c,e.d,e.tx,e.ty]);i.setTransform(t?n.inverse():n)},tintWithMultiply:(r,e,t)=>{const i=t.getContext("2d"),s=r.frame.clone(),n=r.source._resolution??r.source.resolution??1,o=r.rotate;s.x*=n,s.y*=n,s.width*=n,s.height*=n;const a=X.isVertical(o),h=a?s.height:s.width,l=a?s.width:s.height;t.width=Math.ceil(h),t.height=Math.ceil(l),i.save(),i.fillStyle=rt.shared.setValue(e).toHex(),i.fillRect(0,0,h,l),i.globalCompositeOperation="multiply";const c=st.getCanvasSource(r);if(!c){i.restore();return}o&&st._applyInverseRotation(i,o,s.width,s.height),i.drawImage(c,s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.globalCompositeOperation="destination-atop",i.drawImage(c,s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.restore()},tintWithOverlay:(r,e,t)=>{const i=t.getContext("2d"),s=r.frame.clone(),n=r.source._resolution??r.source.resolution??1,o=r.rotate;s.x*=n,s.y*=n,s.width*=n,s.height*=n;const a=X.isVertical(o),h=a?s.height:s.width,l=a?s.width:s.height;t.width=Math.ceil(h),t.height=Math.ceil(l),i.save(),i.globalCompositeOperation="copy",i.fillStyle=rt.shared.setValue(e).toHex(),i.fillRect(0,0,h,l),i.globalCompositeOperation="destination-atop";const c=st.getCanvasSource(r);if(!c){i.restore();return}o&&st._applyInverseRotation(i,o,s.width,s.height),i.drawImage(c,s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.restore()},tintWithPerPixel:(r,e,t)=>{const i=t.getContext("2d"),s=r.frame.clone(),n=r.source._resolution??r.source.resolution??1,o=r.rotate;s.x*=n,s.y*=n,s.width*=n,s.height*=n;const a=X.isVertical(o),h=a?s.height:s.width,l=a?s.width:s.height;t.width=Math.ceil(h),t.height=Math.ceil(l),i.save(),i.globalCompositeOperation="copy";const c=st.getCanvasSource(r);if(!c){i.restore();return}o&&st._applyInverseRotation(i,o,s.width,s.height),i.drawImage(c,s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.restore();const d=e>>16&255,u=e>>8&255,p=e&255,f=i.getImageData(0,0,h,l),y=f.data;for(let m=0;m<y.length;m+=4)y[m]=y[m]*d/255,y[m+1]=y[m+1]*u/255,y[m+2]=y[m+2]*p/255;i.putImageData(f,0,0)},_applyInverseRotation:(r,e,t,i)=>{const s=X.inv(e),n=X.uX(s),o=X.uY(s),a=X.vX(s),h=X.vY(s),l=-Math.min(0,n*t,a*i,n*t+a*i),c=-Math.min(0,o*t,h*i,o*t+h*i);r.transform(n,o,a,h,l,c)}};st.tintMethod=st.canUseMultiply?st.tintWithMultiply:st.tintWithPerPixel;const ls=new U,xi=new U,Gt=[new tt,new tt,new tt,new tt];class Dl{constructor(e){this._renderer=e}validateRenderable(e){return!1}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}updateRenderable(e){}execute(e){var A,k;const t=this._renderer,i=t.canvasContext,s=i.activeContext;s.save(),i.setBlendMode(e.groupBlendMode);const n=((A=t.globalUniforms.globalUniformData)==null?void 0:A.worldColor)??4294967295,o=e.groupColorAlpha,a=(n>>>24&255)/255,h=(o>>>24&255)/255,l=((k=t.filter)==null?void 0:k.alphaMultiplier)??1,c=a*h*l;if(c<=0){s.restore();return}s.globalAlpha=c;const d=n&16777215,u=o&16777215,p=Pi(ur(u,d)),f=e.texture,y=st.getTintedPattern(f,p),m=e.width,x=e.height,S=e.groupTransform,v=f.source._resolution??f.source.resolution??1;xi.copyFrom(e._tileTransform.matrix),e.applyAnchorToTexture||xi.translate(-e.anchor.x*m,-e.anchor.y*x),xi.scale(1/v,1/v),ls.identity(),ls.prepend(xi),ls.prepend(S);const b=t._roundPixels|e._roundPixels;i.setContextTransform(ls,b===1),s.fillStyle=y;const P=e.anchor.x*-m,C=e.anchor.y*-x;Gt[0].set(P,C),Gt[1].set(P+m,C),Gt[2].set(P+m,C+x),Gt[3].set(P,C+x);for(let M=0;M<4;M++)xi.applyInverse(Gt[M],Gt[M]);s.beginPath(),s.moveTo(Gt[0].x,Gt[0].y);for(let M=1;M<4;M++)s.lineTo(Gt[M].x,Gt[M].y);s.closePath(),s.fill(),s.restore()}destroy(){this._renderer=null}}Dl.extension={type:[I.CanvasPipes],name:"tilingSprite"};const ps={name:"local-uniform-bit",vertex:{header:`
|
|
397
397
|
|
|
398
398
|
struct LocalUniforms {
|
|
399
399
|
uTransformMatrix:mat3x3<f32>,
|
|
@@ -410,7 +410,7 @@ fn mainFragment(
|
|
|
410
410
|
{
|
|
411
411
|
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
412
412
|
}
|
|
413
|
-
`}},
|
|
413
|
+
`}},i0={...ps,vertex:{...ps.vertex,header:ps.vertex.header.replace("group(1)","group(2)")}},Kg={name:"local-uniform-bit",vertex:{header:`
|
|
414
414
|
|
|
415
415
|
uniform mat3 uTransformMatrix;
|
|
416
416
|
uniform vec4 uColor;
|
|
@@ -423,7 +423,7 @@ fn mainFragment(
|
|
|
423
423
|
{
|
|
424
424
|
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
425
425
|
}
|
|
426
|
-
`}}
|
|
426
|
+
`}},$g={name:"tiling-bit",vertex:{header:`
|
|
427
427
|
struct TilingUniforms {
|
|
428
428
|
uMapCoord:mat3x3<f32>,
|
|
429
429
|
uClampFrame:vec4<f32>,
|
|
@@ -466,7 +466,7 @@ fn mainFragment(
|
|
|
466
466
|
}
|
|
467
467
|
|
|
468
468
|
outColor = textureSampleBias(uTexture, uSampler, coord, bias);
|
|
469
|
-
`}},
|
|
469
|
+
`}},Qg={name:"tiling-bit",vertex:{header:`
|
|
470
470
|
uniform mat3 uTextureTransform;
|
|
471
471
|
uniform vec4 uSizeAnchor;
|
|
472
472
|
|
|
@@ -488,18 +488,18 @@ fn mainFragment(
|
|
|
488
488
|
|
|
489
489
|
outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
|
|
490
490
|
|
|
491
|
-
`}};let wn,Cn;class tm extends Be{constructor(){wn??(wn=dl({name:"tiling-sprite-shader",bits:[ps,Qg,pl]})),Cn??(Cn=ul({name:"tiling-sprite-shader",bits:[$g,Jg,fl]}));const e=new ni({uMapCoord:{value:new U,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new U,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:Cn,gpuProgram:wn,resources:{localUniforms:new ni({uTransformMatrix:{value:new U,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:e,uTexture:G.EMPTY.source,uSampler:G.EMPTY.source.style}})}updateUniforms(e,t,i,s,n,o){const a=this.resources.tilingUniforms,h=o.width,l=o.height,c=o.textureMatrix,d=a.uniforms.uTextureTransform;d.set(i.a*h/e,i.b*h/t,i.c*l/e,i.d*l/t,i.tx/e,i.ty/t),d.invert(),a.uniforms.uMapCoord=c.mapCoord,a.uniforms.uClampFrame=c.uClampFrame,a.uniforms.uClampOffset=c.uClampOffset,a.uniforms.uTextureTransform=d,a.uniforms.uSizeAnchor[0]=e,a.uniforms.uSizeAnchor[1]=t,a.uniforms.uSizeAnchor[2]=s,a.uniforms.uSizeAnchor[3]=n,o&&(this.resources.uTexture=o.source,this.resources.uSampler=o.source.style)}}class em extends Rr{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}}function im(r,e){const t=r.anchor.x,i=r.anchor.y;e[0]=-t*r.width,e[1]=-i*r.height,e[2]=(1-t)*r.width,e[3]=-i*r.height,e[4]=(1-t)*r.width,e[5]=(1-i)*r.height,e[6]=-t*r.width,e[7]=(1-i)*r.height}function sm(r,e,t,i){let s=0;const n=r.length/e,o=i.a,a=i.b,h=i.c,l=i.d,c=i.tx,d=i.ty;for(t*=e;s<n;){const u=r[t],p=r[t+1];r[t]=o*u+h*p+c,r[t+1]=a*u+l*p+d,t+=e,s++}}function nm(r,e){const t=r.texture,i=t.frame.width,s=t.frame.height;let n=0,o=0;r.applyAnchorToTexture&&(n=r.anchor.x,o=r.anchor.y),e[0]=e[6]=-n,e[2]=e[4]=1-n,e[1]=e[3]=-o,e[5]=e[7]=1-o;const a=U.shared;a.copyFrom(r._tileTransform.matrix),a.tx/=r.width,a.ty/=r.height,a.invert(),a.scale(r.width/i,r.height/s),sm(e,2,0,a)}const fs=new em;class rm{constructor(){this.canBatch=!0,this.geometry=new Rr({indices:fs.indices.slice(),positions:fs.positions.slice(),uvs:fs.uvs.slice()})}destroy(){var e;this.geometry.destroy(),(e=this.shader)==null||e.destroy()}}class Ll{constructor(e){this._state=Vi.default2d,this._renderer=e,this._managedTilingSprites=new ci({renderer:e,type:"renderable",name:"tilingSprite"})}validateRenderable(e){const t=this._getTilingSpriteData(e),i=t.canBatch;this._updateCanBatch(e);const s=t.canBatch;if(s&&s===i){const{batchableMesh:n}=t;return!n._batcher.checkAndUpdateTexture(n,e.texture)}return i!==s}addRenderable(e,t){const i=this._renderer.renderPipes.batch;this._updateCanBatch(e);const s=this._getTilingSpriteData(e),{geometry:n,canBatch:o}=s;if(o){s.batchableMesh||(s.batchableMesh=new Dl);const a=s.batchableMesh;e.didViewUpdate&&(this._updateBatchableMesh(e),a.geometry=n,a.renderable=e,a.transform=e.groupTransform,a.setTexture(e._texture)),a.roundPixels=this._renderer._roundPixels|e._roundPixels,i.addToBatch(a,t)}else i.break(t),s.shader||(s.shader=new tm),this.updateRenderable(e),t.add(e)}execute(e){const t=this._renderer,{shader:i}=this._getTilingSpriteData(e);i.groups[0]=t.globalUniforms.bindGroup;const s=i.resources.localUniforms.uniforms;s.uTransformMatrix=e.groupTransform,s.uRound=t._roundPixels|e._roundPixels,kr(e.groupColorAlpha,s.uColor,0),this._state.blendMode=ys(e.groupBlendMode,e.texture._source),t.encoder.draw({geometry:fs,shader:i,state:this._state})}updateRenderable(e){const t=this._getTilingSpriteData(e),{canBatch:i}=t;if(i){const{batchableMesh:s}=t;e.didViewUpdate&&this._updateBatchableMesh(e),s._batcher.updateElement(s)}else if(e.didViewUpdate){const{shader:s}=t;s.updateUniforms(e.width,e.height,e._tileTransform.matrix,e.anchor.x,e.anchor.y,e.texture)}}_getTilingSpriteData(e){return e._gpuData[this._renderer.uid]||this._initTilingSpriteData(e)}_initTilingSpriteData(e){const t=new rm;return t.renderable=e,e._gpuData[this._renderer.uid]=t,this._managedTilingSprites.add(e),t}_updateBatchableMesh(e){const t=this._getTilingSpriteData(e),{geometry:i}=t,s=e.texture.source.style;s.addressMode!=="repeat"&&(s.addressMode="repeat",s.update()),nm(e,i.uvs),im(e,i.positions)}destroy(){this._managedTilingSprites.destroy(),this._renderer=null}_updateCanBatch(e){const t=this._getTilingSpriteData(e),i=e.texture;let s=!0;return this._renderer.type===Fi.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),t.canBatch=i.textureMatrix.isSimple&&(s||i.source.isPowerOfTwo),t.canBatch}}Ll.extension={type:[I.WebGLPipes,I.WebGPUPipes],name:"tilingSprite"};$.add(zl);$.add(Ll);const Ol=class gs extends ai{constructor(...e){let t=e[0]||{};t instanceof G&&(t={texture:t}),e.length>1&&(V(J,"use new TilingSprite({ texture, width:100, height:100 }) instead"),t.width=e[1],t.height=e[2]),t={...gs.defaultOptions,...t};const{texture:i,anchor:s,tilePosition:n,tileScale:o,tileRotation:a,width:h,height:l,applyAnchorToTexture:c,roundPixels:d,...u}=t??{};super({label:"TilingSprite",...u}),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new ct({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=c,this.texture=i,this._width=h??i.width,this._height=l??i.height,this._tileTransform=new qg({observer:{_onUpdate:()=>this.onViewUpdate()}}),s&&(this.anchor=s),this.tilePosition=n,this.tileScale=o,this.tileRotation=a,this.roundPixels=d??!1}static from(e,t={}){return typeof e=="string"?new gs({texture:xt.get(e),...t}):new gs({texture:e,...t})}get uvRespectAnchor(){return V(J,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(e){V(J,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture=e}get clampMargin(){return this._texture.textureMatrix.clampMargin}set clampMargin(e){this._texture.textureMatrix.clampMargin=e}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get tilePosition(){return this._tileTransform.position}set tilePosition(e){this._tileTransform.position.copyFrom(e)}get tileScale(){return this._tileTransform.scale}set tileScale(e){typeof e=="number"?this._tileTransform.scale.set(e):this._tileTransform.scale.copyFrom(e)}set tileRotation(e){this._tileTransform.rotation=e}get tileRotation(){return this._tileTransform.rotation}get tileTransform(){return this._tileTransform}set texture(e){e||(e=G.EMPTY);const t=this._texture;t!==e&&(t&&t.dynamic&&t.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this._texture=e,this.onViewUpdate())}get texture(){return this._texture}set width(e){this._width=e,this.onViewUpdate()}get width(){return this._width}set height(e){this._height=e,this.onViewUpdate()}get height(){return this._height}setSize(e,t){typeof e=="object"&&(t=e.height??e.width,e=e.width),this._width=e,this._height=t??e,this.onViewUpdate()}getSize(e){return e||(e={}),e.width=this._width,e.height=this._height,e}updateBounds(){const e=this._bounds,t=this._anchor,i=this._width,s=this._height;e.minX=-t._x*i,e.maxX=e.minX+i,e.minY=-t._y*s,e.maxY=e.minY+s}containsPoint(e){const t=this._width,i=this._height,s=-t*this._anchor._x;let n=0;return e.x>=s&&e.x<=s+t&&(n=-i*this._anchor._y,e.y>=n&&e.y<=n+i)}destroy(e=!1){if(super.destroy(e),this._anchor=null,this._tileTransform=null,this._bounds=null,typeof e=="boolean"?e:e==null?void 0:e.texture){const i=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._texture.destroy(i)}this._texture=null}};Ol.defaultOptions={texture:G.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let bs=Ol;class om extends ai{constructor(e,t){const{text:i,resolution:s,style:n,anchor:o,width:a,height:h,roundPixels:l,...c}=e;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=t,this.text=i??"",this.style=n,this.resolution=s??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(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}set text(e){e=e.toString(),this._text!==e&&(this._text=e,this.onViewUpdate())}get text(){return this._text}set resolution(e){this._autoResolution=e===null,this._resolution=e,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(e){var t;e||(e={}),(t=this._style)==null||t.off("update",this.onViewUpdate,this),e instanceof this._styleClass?this._style=e:this._style=new this._styleClass(e),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(e){this._setWidth(e,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(e){this._setHeight(e,this.bounds.height)}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this.bounds.width,e.height=Math.abs(this.scale.y)*this.bounds.height,e}setSize(e,t){typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,this.bounds.width),t!==void 0&&this._setHeight(t,this.bounds.height)}containsPoint(e){const t=this.bounds.width,i=this.bounds.height,s=-t*this.anchor.x;let n=0;return e.x>=s&&e.x<=s+t&&(n=-i*this.anchor.y,e.y>=n&&e.y<=n+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(e=!1){super.destroy(e),this.owner=null,this._bounds=null,this._anchor=null,(typeof e=="boolean"?e:e!=null&&e.style)&&this._style.destroy(e),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function am(r,e){let t=r[0]??{};return(typeof t=="string"||r[1])&&(V(J,`use new ${e}({ text: "hi!", style }) instead`),t={text:t,style:r[1]}),t}class hm{constructor(e){this._canvasPool=Object.create(null),this.canvasOptions=e||{},this.enableFullScreen=!1}_createCanvasAndContext(e,t){const i=j.get().createCanvas();i.width=e,i.height=t;const s=i.getContext("2d");return{canvas:i,context:s}}getOptimalCanvasAndContext(e,t,i=1){e=Math.ceil(e*i-1e-6),t=Math.ceil(t*i-1e-6),e=Je(e),t=Je(t);const s=(e<<17)+(t<<1);this._canvasPool[s]||(this._canvasPool[s]=[]);let n=this._canvasPool[s].pop();return n||(n=this._createCanvasAndContext(e,t)),n}returnCanvasAndContext(e){const t=e.canvas,{width:i,height:s}=t,n=(i<<17)+(s<<1);e.context.resetTransform(),e.context.clearRect(0,0,i,s),this._canvasPool[n].push(e)}clear(){this._canvasPool={}}}const Jn=new hm;Hi.register(Jn);let Se=null,$t=null;function lm(r,e){Se||(Se=j.get().createCanvas(256,128),$t=Se.getContext("2d",{willReadFrequently:!0}),$t.globalCompositeOperation="copy",$t.globalAlpha=1),(Se.width<r||Se.height<e)&&(Se.width=Je(r),Se.height=Je(e))}function Pa(r,e,t){for(let i=0,s=4*t*e;i<e;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function Ma(r,e,t,i,s){const n=4*e;for(let o=i,a=i*n+4*t;o<=s;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function cm(...r){let e=r[0];e.canvas||(e={canvas:r[0],resolution:r[1]});const{canvas:t}=e,i=Math.min(e.resolution??1,1),s=e.width??t.width,n=e.height??t.height;let o=e.output;if(lm(s,n),!$t)throw new TypeError("Failed to get canvas 2D context");$t.drawImage(t,0,0,s,n,0,0,s*i,n*i);const h=$t.getImageData(0,0,s,n).data;let l=0,c=0,d=s-1,u=n-1;for(;c<n&&Pa(h,s,c);)++c;if(c===n)return et.EMPTY;for(;Pa(h,s,u);)--u;for(;Ma(h,s,l,c,u);)++l;for(;Ma(h,s,d,c,u);)--d;return++d,++u,$t.globalCompositeOperation="source-over",$t.strokeRect(l,c,d-l,u-c),$t.globalCompositeOperation="copy",o??(o=new et),o.set(l/i,c/i,(d-l)/i,(u-c)/i),o}/**
|
|
491
|
+
`}};let wn,Cn;class Jg extends Be{constructor(){wn??(wn=ll({name:"tiling-sprite-shader",bits:[ps,$g,dl]})),Cn??(Cn=cl({name:"tiling-sprite-shader",bits:[Kg,Qg,ul]}));const e=new ni({uMapCoord:{value:new U,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new U,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:Cn,gpuProgram:wn,resources:{localUniforms:new ni({uTransformMatrix:{value:new U,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:e,uTexture:W.EMPTY.source,uSampler:W.EMPTY.source.style}})}updateUniforms(e,t,i,s,n,o){const a=this.resources.tilingUniforms,h=o.width,l=o.height,c=o.textureMatrix,d=a.uniforms.uTextureTransform;d.set(i.a*h/e,i.b*h/t,i.c*l/e,i.d*l/t,i.tx/e,i.ty/t),d.invert(),a.uniforms.uMapCoord=c.mapCoord,a.uniforms.uClampFrame=c.uClampFrame,a.uniforms.uClampOffset=c.uClampOffset,a.uniforms.uTextureTransform=d,a.uniforms.uSizeAnchor[0]=e,a.uniforms.uSizeAnchor[1]=t,a.uniforms.uSizeAnchor[2]=s,a.uniforms.uSizeAnchor[3]=n,o&&(this.resources.uTexture=o.source,this.resources.uSampler=o.source.style)}}class tm extends kr{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}}function em(r,e){const t=r.anchor.x,i=r.anchor.y;e[0]=-t*r.width,e[1]=-i*r.height,e[2]=(1-t)*r.width,e[3]=-i*r.height,e[4]=(1-t)*r.width,e[5]=(1-i)*r.height,e[6]=-t*r.width,e[7]=(1-i)*r.height}function im(r,e,t,i){let s=0;const n=r.length/e,o=i.a,a=i.b,h=i.c,l=i.d,c=i.tx,d=i.ty;for(t*=e;s<n;){const u=r[t],p=r[t+1];r[t]=o*u+h*p+c,r[t+1]=a*u+l*p+d,t+=e,s++}}function sm(r,e){const t=r.texture,i=t.frame.width,s=t.frame.height;let n=0,o=0;r.applyAnchorToTexture&&(n=r.anchor.x,o=r.anchor.y),e[0]=e[6]=-n,e[2]=e[4]=1-n,e[1]=e[3]=-o,e[5]=e[7]=1-o;const a=U.shared;a.copyFrom(r._tileTransform.matrix),a.tx/=r.width,a.ty/=r.height,a.invert(),a.scale(r.width/i,r.height/s),im(e,2,0,a)}const fs=new tm;class nm{constructor(){this.canBatch=!0,this.geometry=new kr({indices:fs.indices.slice(),positions:fs.positions.slice(),uvs:fs.uvs.slice()})}destroy(){var e;this.geometry.destroy(),(e=this.shader)==null||e.destroy()}}class Fl{constructor(e){this._state=Vi.default2d,this._renderer=e,this._managedTilingSprites=new ci({renderer:e,type:"renderable",name:"tilingSprite"})}validateRenderable(e){const t=this._getTilingSpriteData(e),i=t.canBatch;this._updateCanBatch(e);const s=t.canBatch;if(s&&s===i){const{batchableMesh:n}=t;return!n._batcher.checkAndUpdateTexture(n,e.texture)}return i!==s}addRenderable(e,t){const i=this._renderer.renderPipes.batch;this._updateCanBatch(e);const s=this._getTilingSpriteData(e),{geometry:n,canBatch:o}=s;if(o){s.batchableMesh||(s.batchableMesh=new Il);const a=s.batchableMesh;e.didViewUpdate&&(this._updateBatchableMesh(e),a.geometry=n,a.renderable=e,a.transform=e.groupTransform,a.setTexture(e._texture)),a.roundPixels=this._renderer._roundPixels|e._roundPixels,i.addToBatch(a,t)}else i.break(t),s.shader||(s.shader=new Jg),this.updateRenderable(e),t.add(e)}execute(e){const t=this._renderer,{shader:i}=this._getTilingSpriteData(e);i.groups[0]=t.globalUniforms.bindGroup;const s=i.resources.localUniforms.uniforms;s.uTransformMatrix=e.groupTransform,s.uRound=t._roundPixels|e._roundPixels,Tr(e.groupColorAlpha,s.uColor,0),this._state.blendMode=ys(e.groupBlendMode,e.texture._source),t.encoder.draw({geometry:fs,shader:i,state:this._state})}updateRenderable(e){const t=this._getTilingSpriteData(e),{canBatch:i}=t;if(i){const{batchableMesh:s}=t;e.didViewUpdate&&this._updateBatchableMesh(e),s._batcher.updateElement(s)}else if(e.didViewUpdate){const{shader:s}=t;s.updateUniforms(e.width,e.height,e._tileTransform.matrix,e.anchor.x,e.anchor.y,e.texture)}}_getTilingSpriteData(e){return e._gpuData[this._renderer.uid]||this._initTilingSpriteData(e)}_initTilingSpriteData(e){const t=new nm;return t.renderable=e,e._gpuData[this._renderer.uid]=t,this._managedTilingSprites.add(e),t}_updateBatchableMesh(e){const t=this._getTilingSpriteData(e),{geometry:i}=t,s=e.texture.source.style;s.addressMode!=="repeat"&&(s.addressMode="repeat",s.update()),sm(e,i.uvs),em(e,i.positions)}destroy(){this._managedTilingSprites.destroy(),this._renderer=null}_updateCanBatch(e){const t=this._getTilingSpriteData(e),i=e.texture;let s=!0;return this._renderer.type===Fi.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),t.canBatch=i.textureMatrix.isSimple&&(s||i.source.isPowerOfTwo),t.canBatch}}Fl.extension={type:[I.WebGLPipes,I.WebGPUPipes],name:"tilingSprite"};$.add(Dl);$.add(Fl);const zl=class gs extends ai{constructor(...e){let t=e[0]||{};t instanceof W&&(t={texture:t}),e.length>1&&(V(J,"use new TilingSprite({ texture, width:100, height:100 }) instead"),t.width=e[1],t.height=e[2]),t={...gs.defaultOptions,...t};const{texture:i,anchor:s,tilePosition:n,tileScale:o,tileRotation:a,width:h,height:l,applyAnchorToTexture:c,roundPixels:d,...u}=t??{};super({label:"TilingSprite",...u}),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new ct({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=c,this.texture=i,this._width=h??i.width,this._height=l??i.height,this._tileTransform=new Zg({observer:{_onUpdate:()=>this.onViewUpdate()}}),s&&(this.anchor=s),this.tilePosition=n,this.tileScale=o,this.tileRotation=a,this.roundPixels=d??!1}static from(e,t={}){return typeof e=="string"?new gs({texture:xt.get(e),...t}):new gs({texture:e,...t})}get uvRespectAnchor(){return V(J,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(e){V(J,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture=e}get clampMargin(){return this._texture.textureMatrix.clampMargin}set clampMargin(e){this._texture.textureMatrix.clampMargin=e}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get tilePosition(){return this._tileTransform.position}set tilePosition(e){this._tileTransform.position.copyFrom(e)}get tileScale(){return this._tileTransform.scale}set tileScale(e){typeof e=="number"?this._tileTransform.scale.set(e):this._tileTransform.scale.copyFrom(e)}set tileRotation(e){this._tileTransform.rotation=e}get tileRotation(){return this._tileTransform.rotation}get tileTransform(){return this._tileTransform}set texture(e){e||(e=W.EMPTY);const t=this._texture;t!==e&&(t&&t.dynamic&&t.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this._texture=e,this.onViewUpdate())}get texture(){return this._texture}set width(e){this._width=e,this.onViewUpdate()}get width(){return this._width}set height(e){this._height=e,this.onViewUpdate()}get height(){return this._height}setSize(e,t){typeof e=="object"&&(t=e.height??e.width,e=e.width),this._width=e,this._height=t??e,this.onViewUpdate()}getSize(e){return e||(e={}),e.width=this._width,e.height=this._height,e}updateBounds(){const e=this._bounds,t=this._anchor,i=this._width,s=this._height;e.minX=-t._x*i,e.maxX=e.minX+i,e.minY=-t._y*s,e.maxY=e.minY+s}containsPoint(e){const t=this._width,i=this._height,s=-t*this._anchor._x;let n=0;return e.x>=s&&e.x<=s+t&&(n=-i*this._anchor._y,e.y>=n&&e.y<=n+i)}destroy(e=!1){if(super.destroy(e),this._anchor=null,this._tileTransform=null,this._bounds=null,typeof e=="boolean"?e:e==null?void 0:e.texture){const i=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._texture.destroy(i)}this._texture=null}};zl.defaultOptions={texture:W.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let bs=zl;class rm extends ai{constructor(e,t){const{text:i,resolution:s,style:n,anchor:o,width:a,height:h,roundPixels:l,...c}=e;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=t,this.text=i??"",this.style=n,this.resolution=s??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(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}set text(e){e=e.toString(),this._text!==e&&(this._text=e,this.onViewUpdate())}get text(){return this._text}set resolution(e){this._autoResolution=e===null,this._resolution=e,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(e){var t;e||(e={}),(t=this._style)==null||t.off("update",this.onViewUpdate,this),e instanceof this._styleClass?this._style=e:this._style=new this._styleClass(e),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(e){this._setWidth(e,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(e){this._setHeight(e,this.bounds.height)}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this.bounds.width,e.height=Math.abs(this.scale.y)*this.bounds.height,e}setSize(e,t){typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,this.bounds.width),t!==void 0&&this._setHeight(t,this.bounds.height)}containsPoint(e){const t=this.bounds.width,i=this.bounds.height,s=-t*this.anchor.x;let n=0;return e.x>=s&&e.x<=s+t&&(n=-i*this.anchor.y,e.y>=n&&e.y<=n+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(e=!1){super.destroy(e),this.owner=null,this._bounds=null,this._anchor=null,(typeof e=="boolean"?e:e!=null&&e.style)&&this._style.destroy(e),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function om(r,e){let t=r[0]??{};return(typeof t=="string"||r[1])&&(V(J,`use new ${e}({ text: "hi!", style }) instead`),t={text:t,style:r[1]}),t}class am{constructor(e){this._canvasPool=Object.create(null),this.canvasOptions=e||{},this.enableFullScreen=!1}_createCanvasAndContext(e,t){const i=j.get().createCanvas();i.width=e,i.height=t;const s=i.getContext("2d");return{canvas:i,context:s}}getOptimalCanvasAndContext(e,t,i=1){e=Math.ceil(e*i-1e-6),t=Math.ceil(t*i-1e-6),e=Je(e),t=Je(t);const s=(e<<17)+(t<<1);this._canvasPool[s]||(this._canvasPool[s]=[]);let n=this._canvasPool[s].pop();return n||(n=this._createCanvasAndContext(e,t)),n}returnCanvasAndContext(e){const t=e.canvas,{width:i,height:s}=t,n=(i<<17)+(s<<1);e.context.resetTransform(),e.context.clearRect(0,0,i,s),this._canvasPool[n].push(e)}clear(){this._canvasPool={}}}const Qn=new am;Hi.register(Qn);let Se=null,$t=null;function hm(r,e){Se||(Se=j.get().createCanvas(256,128),$t=Se.getContext("2d",{willReadFrequently:!0}),$t.globalCompositeOperation="copy",$t.globalAlpha=1),(Se.width<r||Se.height<e)&&(Se.width=Je(r),Se.height=Je(e))}function Aa(r,e,t){for(let i=0,s=4*t*e;i<e;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function Pa(r,e,t,i,s){const n=4*e;for(let o=i,a=i*n+4*t;o<=s;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function lm(...r){let e=r[0];e.canvas||(e={canvas:r[0],resolution:r[1]});const{canvas:t}=e,i=Math.min(e.resolution??1,1),s=e.width??t.width,n=e.height??t.height;let o=e.output;if(hm(s,n),!$t)throw new TypeError("Failed to get canvas 2D context");$t.drawImage(t,0,0,s,n,0,0,s*i,n*i);const h=$t.getImageData(0,0,s,n).data;let l=0,c=0,d=s-1,u=n-1;for(;c<n&&Aa(h,s,c);)++c;if(c===n)return et.EMPTY;for(;Aa(h,s,u);)--u;for(;Pa(h,s,l,c,u);)++l;for(;Pa(h,s,d,c,u);)--d;return++d,++u,$t.globalCompositeOperation="source-over",$t.strokeRect(l,c,d-l,u-c),$t.globalCompositeOperation="copy",o??(o=new et),o.set(l/i,c/i,(d-l)/i,(u-c)/i),o}/**
|
|
492
492
|
* tiny-lru
|
|
493
493
|
*
|
|
494
494
|
* @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
495
495
|
* @license BSD-3-Clause
|
|
496
496
|
* @version 11.4.7
|
|
497
|
-
*/class
|
|
497
|
+
*/class cm{constructor(e=0,t=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=i,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const t=this.items[e];delete this.items[e],this.size--,t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){const t=new Array(e.length);for(let i=0;i<e.length;i++){const s=e[i];t[i]=[s,this.get(s)]}return t}evict(e=!1){if(e||this.size>0){const t=this.first;delete this.items[t.key],--this.size===0?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){const t=this.items[e];if(t!==void 0){if(this.ttl>0&&t.expiry<=Date.now()){this.delete(e);return}return this.moveToEnd(t),t.value}}has(e){return e in this.items}moveToEnd(e){this.last!==e&&(e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),e.prev=this.last,e.next=null,this.last!==null&&(this.last.next=e),this.last=e,this.first===null&&(this.first=e))}keys(){const e=new Array(this.size);let t=this.first,i=0;for(;t!==null;)e[i++]=t.key,t=t.next;return e}setWithEvicted(e,t,i=this.resetTtl){let s=null;if(this.has(e))this.set(e,t,!0,i);else{this.max>0&&this.size===this.max&&(s={...this.first},this.evict(!0));let n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t};++this.size===1?this.first=n:this.last.next=n,this.last=n}return s}set(e,t,i=!1,s=this.resetTtl){let n=this.items[e];return i||n!==void 0?(n.value=t,i===!1&&s&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(e=this.keys()){const t=new Array(e.length);for(let i=0;i<e.length;i++)t[i]=this.get(e[i]);return t}}function dm(r=1e3,e=0,t=!1){if(isNaN(r)||r<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if(typeof t!="boolean")throw new TypeError("Invalid resetTtl value");return new cm(r,e,t)}function Ll(r){return!!r.tagStyles&&Object.keys(r.tagStyles).length>0}function Ol(r){return r.includes("<")}function um(r,e){return r.clone().assign(e)}function pm(r,e){const t=[],i=e.tagStyles;if(!Ll(e)||!Ol(r))return t.push({text:r,style:e}),t;const s=[e],n=[];let o="",a=0;for(;a<r.length;){const h=r[a];if(h==="<"){const l=r.indexOf(">",a);if(l===-1){o+=h,a++;continue}const c=r.slice(a+1,l);if(c.startsWith("/")){const d=c.slice(1).trim();if(n.length>0&&n[n.length-1]===d){o.length>0&&(t.push({text:o,style:s[s.length-1]}),o=""),s.pop(),n.pop(),a=l+1;continue}else{o+=r.slice(a,l+1),a=l+1;continue}}else{const d=c.trim();if(i[d]){o.length>0&&(t.push({text:o,style:s[s.length-1]}),o="");const u=s[s.length-1],p=um(u,i[d]);s.push(p),n.push(d),a=l+1;continue}else{o+=r.slice(a,l+1),a=l+1;continue}}}else o+=h,a++}return o.length>0&&t.push({text:o,style:s[s.length-1]}),t}const fm=[10,13],gm=new Set(fm),mm=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],ym=new Set(mm),xm=/(\r\n|\r|\n)/,Sm=/(?:\r\n|\r|\n)/;function Rr(r){return typeof r!="string"?!1:gm.has(r.charCodeAt(0))}function Lt(r,e){return typeof r!="string"?!1:ym.has(r.charCodeAt(0))}function Wl(r){return r==="normal"||r==="pre-line"}function Gl(r){return r==="normal"}function Kt(r){if(typeof r!="string")return"";let e=r.length-1;for(;e>=0&&Lt(r[e]);)e--;return e<r.length-1?r.slice(0,e+1):r}function Ul(r){const e=[],t=[];if(typeof r!="string")return e;for(let i=0;i<r.length;i++){const s=r[i],n=r[i+1];if(Lt(s)||Rr(s)){t.length>0&&(e.push(t.join("")),t.length=0),s==="\r"&&n===`
|
|
498
498
|
`?(e.push(`\r
|
|
499
|
-
`),i++):e.push(s);continue}t.push(s)}return t.length>0&&e.push(t.join("")),e}function
|
|
499
|
+
`),i++):e.push(s);continue}t.push(s)}return t.length>0&&e.push(t.join("")),e}function Hl(r,e,t,i){const s=t(r),n=[];for(let o=0;o<s.length;o++){let a=s[o],h=a,l=1;for(;s[o+l];){const c=s[o+l];if(!i(h,c,r,o,e))a+=c,h=c,l++;else break}o+=l-1,n.push(a)}return n}const vm=/\r\n|\r|\n/g;function bm(r,e,t,i,s,n,o,a){var F;const h=pm(r,e);if(Gl(e.whiteSpace))for(let Z=0;Z<h.length;Z++){const R=h[Z];h[Z]={text:R.text.replace(vm," "),style:R.style}}const c=[];let d=[];for(const Z of h){const R=Z.text.split(xm);for(let D=0;D<R.length;D++){const ot=R[D];ot===`\r
|
|
500
500
|
`||ot==="\r"||ot===`
|
|
501
|
-
`?(c.push(d),d=[]):ot.length>0&&d.push({text:ot,style:Z.style})}}(d.length>0||c.length===0)&&c.push(d);const u=t?
|
|
502
|
-
`)}const Ta={willReadFrequently:!0},ie=class O{static get experimentalLetterSpacingSupported(){let e=O._experimentalLetterSpacingSupported;if(e===void 0){const t=j.get().getCanvasRenderingContext2D().prototype;e=O._experimentalLetterSpacingSupported="letterSpacing"in t||"textLetterSpacing"in t}return e}constructor(e,t,i,s,n,o,a,h,l,c){this.text=e,this.style=t,this.width=i,this.height=s,this.lines=n,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(e=" ",t,i=O._canvas,s=t.wordWrap){var P;const n=`${e}-${t.styleKey}-wordWrap-${s}`;if(O._measurementCache.has(n))return O._measurementCache.get(n);if(Gl(t)&&Wl(e)){const C=wm(e,t,s,O._context,O._measureText,O.measureFont,O.canBreakChars,O.wordWrapSplit),A=new O(e,t,C.width,C.height,C.lines,C.lineWidths,C.lineHeight,C.maxLineWidth,C.fontProperties,{runsByLine:C.runsByLine,lineAscents:C.lineAscents,lineDescents:C.lineDescents,lineHeights:C.lineHeights,hasDropShadow:C.hasDropShadow});return O._measurementCache.set(n,A),A}const a=t._fontString,h=O.measureFont(a);h.fontSize===0&&(h.fontSize=t.fontSize,h.ascent=t.fontSize,h.descent=0);const l=O._context;l.font=a;const d=(s?O._wordWrap(e,t,i):e).split(vm),u=new Array(d.length);let p=0;for(let C=0;C<d.length;C++){const A=O._measureText(d[C],t.letterSpacing,l);u[C]=A,p=Math.max(p,A)}const f=((P=t._stroke)==null?void 0:P.width)??0,y=t.lineHeight||h.fontSize,m=O._getAlignWidth(p,t,s),x=O._adjustWidthForStyle(m,t),S=Math.max(y,h.fontSize+f)+(d.length-1)*(y+t.leading),v=O._adjustHeightForStyle(S,t),b=new O(e,t,x,v,d,u,y+t.leading,p,h);return O._measurementCache.set(n,b),b}static _adjustWidthForStyle(e,t){var n;const i=((n=t._stroke)==null?void 0:n.width)||0;let s=e+i;return t.dropShadow&&(s+=t.dropShadow.distance),s}static _adjustHeightForStyle(e,t){let i=e;return t.dropShadow&&(i+=t.dropShadow.distance),i}static _getAlignWidth(e,t,i){return i&&t.align!=="left"&&t.align!=="justify"?Math.max(e,t.wordWrapWidth):e}static _measureText(e,t,i){let s=!1;O.experimentalLetterSpacingSupported&&(O.experimentalLetterSpacing?(i.letterSpacing=`${t}px`,i.textLetterSpacing=`${t}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const n=i.measureText(e);let o=n.width;const a=-(n.actualBoundingBoxLeft??0);let l=(n.actualBoundingBoxRight??0)-a;if(o>0)if(s)o-=t,l-=t;else{const c=(O.graphemeSegmenter(e).length-1)*t;o+=c,l+=c}return Math.max(o,l)}static _wordWrap(e,t,i=O._canvas){return Mm(e,t,i,O._measureText,O.canBreakWords,O.canBreakChars,O.wordWrapSplit)}static isBreakingSpace(e,t){return Lt(e)}static canBreakWords(e,t){return t}static canBreakChars(e,t,i,s,n){return!0}static wordWrapSplit(e){return O.graphemeSegmenter(e)}static measureFont(e){if(O._fonts[e])return O._fonts[e];const t=O._context;t.font=e;const i=t.measureText(O.METRICS_STRING+O.BASELINE_SYMBOL),s=i.actualBoundingBoxAscent??0,n=i.actualBoundingBoxDescent??0,o={ascent:s,descent:n,fontSize:s+n};return O._fonts[e]=o,o}static clearMetrics(e=""){e?delete O._fonts[e]:O._fonts={}}static get _canvas(){if(!O.__canvas){let e;try{const t=new OffscreenCanvas(0,0),i=t.getContext("2d",Ta);if(i!=null&&i.measureText)return O.__canvas=t,t;e=j.get().createCanvas()}catch{e=j.get().createCanvas()}e.width=e.height=10,O.__canvas=e}return O.__canvas}static get _context(){return O.__context||(O.__context=O._canvas.getContext("2d",Ta)),O.__context}};ie.METRICS_STRING="|ÉqÅ";ie.BASELINE_SYMBOL="M";ie.BASELINE_MULTIPLIER=1.4;ie.HEIGHT_MULTIPLIER=2;ie.graphemeSegmenter=r=>[...r];ie.experimentalLetterSpacing=!1;ie._fonts={};ie._measurementCache=um(1e3);let se=ie;const _m=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function tr(r){const e=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let t=r.fontFamily;Array.isArray(r.fontFamily)||(t=r.fontFamily.split(","));for(let i=t.length-1;i>=0;i--){let s=t[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!_m.includes(s)&&(s=`"${s}"`),t[i]=s}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${e} ${t.join(",")}`}const ka=1e5;function cs(r,e,t,i=0,s=0,n=0){if(r.texture===G.WHITE&&!r.fill)return rt.shared.setValue(r.color).setAlpha(r.alpha??1).toHexa();if(r.fill){if(r.fill instanceof Is){const o=r.fill,a=e.createPattern(o.texture.source.resource,"repeat"),h=o.transform.copyTo(U.shared);return h.scale(o.texture.source.pixelWidth,o.texture.source.pixelHeight),a.setTransform(h),a}else if(r.fill instanceof Ot){const o=r.fill,a=o.type==="linear",h=o.textureSpace==="local";let l=1,c=1;h&&t&&(l=t.width+i,c=t.height+i);let d,u=!1;if(a){const{start:p,end:f}=o;d=e.createLinearGradient(p.x*l+s,p.y*c+n,f.x*l+s,f.y*c+n),u=Math.abs(f.x-p.x)<Math.abs((f.y-p.y)*.1)}else{const{center:p,innerRadius:f,outerCenter:y,outerRadius:m}=o;d=e.createRadialGradient(p.x*l+s,p.y*c+n,f*l,y.x*l+s,y.y*c+n,m*l)}if(u&&h&&t){const p=t.lineHeight/c;for(let f=0;f<t.lines.length;f++){const y=(f*t.lineHeight+i/2)/c;o.colorStops.forEach(m=>{let x=y+m.offset*p;x=Math.max(0,Math.min(1,x)),d.addColorStop(Math.floor(x*ka)/ka,rt.shared.setValue(m.color).toHex())})}}else o.colorStops.forEach(p=>{d.addColorStop(p.offset,rt.shared.setValue(p.color).toHex())});return d}}else{const o=e.createPattern(r.texture.source.resource,"repeat"),a=r.matrix.copyTo(U.shared);return a.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),o.setTransform(a),o}return nt("FillStyle not recognised",r),"red"}const Ra=new et;class Tm{getCanvasAndContext(e){const{text:t,style:i,resolution:s=1}=e,n=i._getFinalPadding(),o=se.measureText(t||" ",i),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*s),h=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*s),l=Jn.getOptimalCanvasAndContext(a,h);this._renderTextToCanvas(i,n,s,l,o);const c=i.trim?cm({canvas:l.canvas,width:a,height:h,resolution:1,output:Ra}):Ra.set(0,0,a,h);return{canvasAndContext:l,frame:c}}returnCanvasAndContext(e){Jn.returnCanvasAndContext(e)}_renderTextToCanvas(e,t,i,s,n){var C,A,k;if(n.runsByLine&&n.runsByLine.length>0){this._renderTaggedTextToCanvas(n,e,t,i,s);return}const{canvas:o,context:a}=s,h=tr(e),l=n.lines,c=n.lineHeight,d=n.lineWidths,u=n.maxLineWidth,p=n.fontProperties,f=o.height;if(a.resetTransform(),a.scale(i,i),a.textBaseline=e.textBaseline,(C=e._stroke)!=null&&C.width){const M=e._stroke;a.lineWidth=M.width,a.miterLimit=M.miterLimit,a.lineJoin=M.join,a.lineCap=M.cap}a.font=h;let y,m;const x=e.dropShadow?2:1,S=e.wordWrap?e.wordWrapWidth:u,b=(((A=e._stroke)==null?void 0:A.width)??0)/2;let P=(c-p.fontSize)/2;c-p.fontSize<0&&(P=0);for(let M=0;M<x;++M){const T=e.dropShadow&&M===0,_=T?Math.ceil(Math.max(1,f)+t*2):0,E=_*i;if(T)this._setupDropShadow(a,e,i,E);else{const B=e._gradientBounds,F=e._gradientOffset;if(B){const Z={width:B.width,height:B.height,lineHeight:B.height,lines:n.lines};this._setFillAndStrokeStyles(a,e,Z,t,b,(F==null?void 0:F.x)??0,(F==null?void 0:F.y)??0)}else F?this._setFillAndStrokeStyles(a,e,n,t,b,F.x,F.y):this._setFillAndStrokeStyles(a,e,n,t,b);a.shadowColor="black"}for(let B=0;B<l.length;B++)y=b,m=b+B*c+p.ascent+P,y+=this._getAlignmentOffset(d[B],S,e.align),(k=e._stroke)!=null&&k.width&&this._drawLetterSpacing(l[B],e,s,y+t,m+t-_,!0),e._fill!==void 0&&this._drawLetterSpacing(l[B],e,s,y+t,m+t-_)}}_renderTaggedTextToCanvas(e,t,i,s,n){var b,P;const{canvas:o,context:a}=n,{runsByLine:h,lineWidths:l,maxLineWidth:c,lineAscents:d,lineHeights:u,hasDropShadow:p}=e,f=o.height;a.resetTransform(),a.scale(s,s),a.textBaseline=t.textBaseline;const y=p?2:1,m=t.wordWrap?t.wordWrapWidth:c,S=(((b=t._stroke)==null?void 0:b.width)??0)/2,v=[];for(let C=0;C<h.length;C++){const A=h[C],k=[];for(const M of A){const T=tr(M.style);a.font=T,k.push({width:se._measureText(M.text,M.style.letterSpacing,a),font:T})}v.push(k)}for(let C=0;C<y;++C){const A=p&&C===0,k=A?Math.ceil(Math.max(1,f)+i*2):0,M=k*s;A||(a.shadowColor="black");let T=S;for(let _=0;_<h.length;_++){const E=h[_],B=l[_],F=d[_],Z=u[_],R=v[_];let D=S;D+=this._getAlignmentOffset(B,m,t.align);const ot=T+F;let z=D+i;for(let q=0;q<E.length;q++){const Y=E[q],{width:ht,font:bt}=R[q];if(a.font=bt,a.textBaseline=Y.style.textBaseline,(P=Y.style._stroke)!=null&&P.width){const wt=Y.style._stroke;if(a.lineWidth=wt.width,a.miterLimit=wt.miterLimit,a.lineJoin=wt.join,a.lineCap=wt.cap,A)if(Y.style.dropShadow)this._setupDropShadow(a,Y.style,s,M);else{z+=ht;continue}else{const kt=se.measureFont(bt),Gt=Y.style.lineHeight||kt.fontSize,Yi={width:ht,height:Gt,lineHeight:Gt,lines:[Y.text]};a.strokeStyle=cs(wt,a,Yi,i*2,z-i,T)}this._drawLetterSpacing(Y.text,Y.style,n,z,ot+i-k,!0)}z+=ht}z=D+i;for(let q=0;q<E.length;q++){const Y=E[q],{width:ht,font:bt}=R[q];if(a.font=bt,a.textBaseline=Y.style.textBaseline,Y.style._fill!==void 0){if(A)if(Y.style.dropShadow)this._setupDropShadow(a,Y.style,s,M);else{z+=ht;continue}else{const wt=se.measureFont(bt),kt=Y.style.lineHeight||wt.fontSize,Gt={width:ht,height:kt,lineHeight:kt,lines:[Y.text]};a.fillStyle=cs(Y.style._fill,a,Gt,i*2,z-i,T)}this._drawLetterSpacing(Y.text,Y.style,n,z,ot+i-k,!1)}z+=ht}T+=Z}}}_setFillAndStrokeStyles(e,t,i,s,n,o=0,a=0){var h;if(e.fillStyle=t._fill?cs(t._fill,e,i,s*2,o,a):null,(h=t._stroke)!=null&&h.width){const l=n+s*2;e.strokeStyle=cs(t._stroke,e,i,l,o,a)}}_setupDropShadow(e,t,i,s){e.fillStyle="black",e.strokeStyle="black";const n=t.dropShadow,o=n.color,a=n.alpha;e.shadowColor=rt.shared.setValue(o).setAlpha(a).toRgbaString();const h=n.blur*i,l=n.distance*i;e.shadowBlur=h,e.shadowOffsetX=Math.cos(n.angle)*l,e.shadowOffsetY=Math.sin(n.angle)*l+s}_getAlignmentOffset(e,t,i){return i==="right"?t-e:i==="center"?(t-e)/2:0}_drawLetterSpacing(e,t,i,s,n,o=!1){const{context:a}=i,h=t.letterSpacing;let l=!1;if(se.experimentalLetterSpacingSupported&&(se.experimentalLetterSpacing?(a.letterSpacing=`${h}px`,a.textLetterSpacing=`${h}px`,l=!0):(a.letterSpacing="0px",a.textLetterSpacing="0px")),h===0||l){o?a.strokeText(e,s,n):a.fillText(e,s,n);return}let c=s;const d=se.graphemeSegmenter(e);let u=a.measureText(e).width,p=0;for(let f=0;f<d.length;++f){const y=d[f];o?a.strokeText(y,c,n):a.fillText(y,c,n);let m="";for(let x=f+1;x<d.length;++x)m+=d[x];p=a.measureText(m).width,c+=u-p+h,u=p}}}const Ve=new Tm,Ir=class Pe extends Yt{constructor(e={}){super(),this.uid=dt("textStyle"),this._tick=0,this._cachedFontString=null,km(e),e instanceof Pe&&(e=e._toObject());const s={...Pe.defaultTextStyle,...e};for(const n in s){const o=n;this[o]=s[n]}this._tagStyles=e.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.update())}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow!==e&&(e!==null&&typeof e=="object"?this._dropShadow=this._createProxy({...Pe.defaultDropShadow,...e}):this._dropShadow=e?this._createProxy({...Pe.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.update())}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(typeof e=="string"?this._fontSize=parseInt(e,10):this._fontSize=e,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.update())}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.update())}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.update())}get filters(){return this._filters}set filters(e){this._filters!==e&&(this._filters=Object.freeze(e),this.update())}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.update())}get fill(){return this._originalFill}set fill(e){e!==this._originalFill&&(this._originalFill=e,this._isFillStyle(e)&&(this._originalFill=this._createProxy({...mt.defaultFillStyle,...e},()=>{this._fill=Me({...this._originalFill},mt.defaultFillStyle)})),this._fill=Me(e===0?"black":e,mt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...mt.defaultStrokeStyle,...e},()=>{this._stroke=Ss({...this._originalStroke},mt.defaultStrokeStyle)})),this._stroke=Ss(e,mt.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(e){this._tagStyles!==e&&(this._tagStyles=e??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const e=Pe.defaultTextStyle;for(const t in e)this[t]=e[t]}assign(e){for(const t in e){const i=t;this[i]=e[t]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=tr(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 Pe(this._toObject())}_getFinalPadding(){let e=0;if(this._filters)for(let t=0;t<this._filters.length;t++)e+=this._filters[t].padding;return Math.max(this._padding,e)}destroy(e=!1){var i,s,n,o;if(this.removeAllListeners(),typeof e=="boolean"?e:e==null?void 0:e.texture){const a=typeof e=="boolean"?e:e==null?void 0:e.textureSource;(i=this._fill)!=null&&i.texture&&this._fill.texture.destroy(a),(s=this._originalFill)!=null&&s.texture&&this._originalFill.texture.destroy(a),(n=this._stroke)!=null&&n.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(e,t){return new Proxy(e,{set:(i,s,n)=>(i[s]===n||(i[s]=n,t==null||t(s,n),this.update()),!0)})}_isFillStyle(e){return(e??null)!==null&&!(rt.isColorLike(e)||e instanceof Ot||e instanceof Is)}};Ir.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Ir.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 ce=Ir;function km(r){const e=r;if(typeof e.dropShadow=="boolean"&&e.dropShadow){const t=ce.defaultDropShadow;r.dropShadow={alpha:e.dropShadowAlpha??t.alpha,angle:e.dropShadowAngle??t.angle,blur:e.dropShadowBlur??t.blur,color:e.dropShadowColor??t.color,distance:e.dropShadowDistance??t.distance}}if(e.strokeThickness!==void 0){V(J,"strokeThickness is now a part of stroke");const t=e.stroke;let i={};if(rt.isColorLike(t))i.color=t;else if(t instanceof Ot||t instanceof Is)i.fill=t;else if(Object.hasOwnProperty.call(t,"color")||Object.hasOwnProperty.call(t,"fill"))i=t;else throw new Error("Invalid stroke value.");r.stroke={...i,width:e.strokeThickness}}if(Array.isArray(e.fillGradientStops)){if(V(J,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(e.fill)||e.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");e.fill.length!==e.fillGradientStops.length&&nt("The number of fill colors must match the number of fill gradient stops.");const t=new Ot({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),i=e.fillGradientStops.slice(),s=e.fill.map(n=>rt.shared.setValue(n).toNumber());i.forEach((n,o)=>{t.addColorStop(n,s[o])}),r.fill={fill:t}}}function Rm(r,e){const{texture:t,bounds:i}=r,s=e._style._getFinalPadding();fh(i,e._anchor,t);const n=e._anchor._x*s*2,o=e._anchor._y*s*2;i.minX-=s-n,i.minY-=s-o,i.maxX-=s-n,i.maxY-=s-o}class Em{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 Im extends Em{}class jl{constructor(e){this._renderer=e,e.runners.resolutionChange.add(this),this._managedTexts=new ci({renderer:e,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const e in this._managedTexts.items){const t=this._managedTexts.items[e];t!=null&&t._autoResolution&&t.onViewUpdate()}}validateRenderable(e){const t=this._getGpuText(e),i=e.styleKey;return t.currentKey!==i?!0:e._didTextUpdate}addRenderable(e,t){const i=this._getGpuText(e);if(e._didTextUpdate){const s=e._autoResolution?this._renderer.resolution:e.resolution;(i.currentKey!==e.styleKey||e._resolution!==s)&&this._updateGpuText(e),e._didTextUpdate=!1,Rm(i,e)}this._renderer.renderPipes.batch.addToBatch(i,t)}updateRenderable(e){const t=this._getGpuText(e);t._batcher.updateElement(t)}_updateGpuText(e){const t=this._getGpuText(e);t.texture&&this._renderer.canvasText.decreaseReferenceCount(t.currentKey),e._resolution=e._autoResolution?this._renderer.resolution:e.resolution,t.texture=this._renderer.canvasText.getManagedTexture(e),t.currentKey=e.styleKey}_getGpuText(e){return e._gpuData[this._renderer.uid]||this.initGpuText(e)}initGpuText(e){const t=new Im;return t.currentKey="--",t.renderable=e,t.transform=e.groupTransform,t.bounds={minX:0,maxX:1,minY:0,maxY:0},t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,this._managedTexts.add(e),t}onTextUnload(e){const t=e._gpuData[this._renderer.uid];if(!t)return;const{canvasText:i}=this._renderer;i.getReferenceCount(t.currentKey)>0?i.decreaseReferenceCount(t.currentKey):t.texture&&i.returnTexture(t.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}jl.extension={type:[I.WebGLPipes,I.WebGPUPipes,I.CanvasPipes],name:"text"};const Bm=new Bt;function Dm(r,e,t,i){const s=Bm;s.minX=0,s.minY=0,s.maxX=r.width/i|0,s.maxY=r.height/i|0;const n=_s.getOptimalTexture(s.width,s.height,i,!1);return n.source.uploadMethodId="image",n.source.resource=r,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=e/i,n.frame.height=t/i,n.source.emit("update",n.source),n.updateUvs(),n}class Yl{constructor(e,t){this._activeTextures={},this._renderer=e,this._retainCanvasContext=t}getTexture(e,t,i,s){typeof e=="string"&&(V("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),e={text:e,style:i,resolution:t}),e.style instanceof ce||(e.style=new ce(e.style)),e.textureStyle instanceof ti||(e.textureStyle=new ti(e.textureStyle)),typeof e.text!="string"&&(e.text=e.text.toString());const{text:n,style:o,textureStyle:a}=e,h=e.resolution??this._renderer.resolution,{frame:l,canvasAndContext:c}=Ve.getCanvasAndContext({text:n,style:o,resolution:h}),d=Dm(c.canvas,l.width,l.height,h);if(a&&(d.source.style=a),o.trim&&(l.pad(o.padding),d.frame.copyFrom(l),d.frame.scale(1/h),d.updateUvs()),o.filters){const u=this._applyFilters(d,o.filters);return this.returnTexture(d),Ve.returnCanvasAndContext(c),u}return this._renderer.texture.initSource(d._source),this._retainCanvasContext||Ve.returnCanvasAndContext(c),d}returnTexture(e){const t=e.source,i=t.resource;if(this._retainCanvasContext&&(i!=null&&i.getContext)){const s=i.getContext("2d");s&&Ve.returnCanvasAndContext({canvas:i,context:s})}t.resource=null,t.uploadMethodId="unknown",t.alphaMode="no-premultiply-alpha",_s.returnTexture(e,!0)}renderTextToCanvas(){V("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(e){e._resolution=e._autoResolution?this._renderer.resolution:e.resolution;const t=e.styleKey;if(this._activeTextures[t])return this._increaseReferenceCount(t),this._activeTextures[t].texture;const i=this.getTexture({text:e.text,style:e.style,resolution:e._resolution,textureStyle:e.textureStyle});return this._activeTextures[t]={texture:i,usageCount:1},i}decreaseReferenceCount(e){const t=this._activeTextures[e];t&&(t.usageCount--,t.usageCount===0&&(this.returnTexture(t.texture),this._activeTextures[e]=null))}getReferenceCount(e){var t;return((t=this._activeTextures[e])==null?void 0:t.usageCount)??0}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}_applyFilters(e,t){const i=this._renderer.renderTarget.renderTarget,s=this._renderer.filter.generateFilteredTexture({texture:e,filters:t});return this._renderer.renderTarget.bind(i,!1),s}destroy(){this._renderer=null;for(const e in this._activeTextures)this._activeTextures[e]&&this.returnTexture(this._activeTextures[e].texture);this._activeTextures=null}}class Xl extends Yl{constructor(e){super(e,!0)}}Xl.extension={type:[I.CanvasSystem],name:"canvasText"};class Zl extends Yl{constructor(e){super(e,!1)}}Zl.extension={type:[I.WebGLSystem,I.WebGPUSystem],name:"canvasText"};$.add(Xl);$.add(Zl);$.add(jl);class Bs extends om{constructor(...e){const t=am(e,"Text");super(t,ce),this.renderPipeId="text",t.textureStyle&&(this.textureStyle=t.textureStyle instanceof ti?t.textureStyle:new ti(t.textureStyle))}updateBounds(){const e=this._bounds,t=this._anchor;let i=0,s=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=Ve.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Ve.returnCanvasAndContext(o),i=n.width,s=n.height}else{const n=se.measureText(this._text,this._style);i=n.width,s=n.height}e.minX=-t._x*i,e.maxX=e.minX+i,e.minY=-t._y*s,e.maxY=e.minY+s}}class Br extends G{static create(e){const{dynamic:t,...i}=e;return new Br({source:new Dt(i),dynamic:t??!1})}resize(e,t,i){return this.source.resize(e,t,i),this}}$.add(nd,rd);function Fm(r,e){var t=-1,i=r.length;for(e||(e=Array(i));++t<i;)e[t]=r[t];return e}function zm(r,e,t,i){var s=!t;t||(t={});for(var n=-1,o=e.length;++n<o;){var a=e[n],h=void 0;h===void 0&&(h=r[a]),s?eh(t,a,h):ih(t,a,h)}return t}function Lm(r){return Rc(function(e,t){var i=-1,s=t.length,n=s>1?t[s-1]:void 0,o=s>2?t[2]:void 0;for(n=r.length>3&&typeof n=="function"?(s--,n):void 0,o&&Ec(t[0],t[1],o)&&(n=s<3?void 0:n,s=1),e=Object(e);++i<s;){var a=t[i];a&&r(e,a,i,n)}return e})}function Om(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var Gm=Object.prototype,Wm=Gm.hasOwnProperty;function Um(r){if(!Ee(r))return Om(r);var e=Ic(r),t=[];for(var i in r)i=="constructor"&&(e||!Wm.call(r,i))||t.push(i);return t}function ql(r){return sh(r)?Bc(r,!0):Um(r)}function Hm(r){var e=r==null?0:r.length;return e?Dc(r):[]}function Vm(r){return Fc(zc(r,void 0,Hm),r+"")}var Nm="[object Object]",jm=Function.prototype,Ym=Object.prototype,Kl=jm.toString,Xm=Ym.hasOwnProperty,Zm=Kl.call(Object);function qm(r){if(!cr(r)||nh(r)!=Nm)return!1;var e=Lc(r);if(e===null)return!0;var t=Xm.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&Kl.call(t)==Zm}var Km=Wc.isFinite,$m=Math.min;function Qm(r){var e=Math[r];return function(t,i){if(t=Oc(t),i=i==null?0:$m(Gc(i),292),i&&Km(t)){var s=($r(t)+"e").split("e"),n=e(s[0]+"e"+(+s[1]+i));return s=($r(n)+"e").split("e"),+(s[0]+"e"+(+s[1]-i))}return e(t)}}function er(r,e,t){(t!==void 0&&!Uc(r[e],t)||t===void 0&&!(e in r))&&eh(r,e,t)}function Jm(r){return cr(r)&&sh(r)}function ir(r,e){if(!(e==="constructor"&&typeof r[e]=="function")&&e!="__proto__")return r[e]}function ty(r){return zm(r,ql(r))}function ey(r,e,t,i,s,n,o){var a=ir(r,t),h=ir(e,t),l=o.get(h);if(l){er(r,t,l);return}var c=n?n(a,h,t+"",r,e,o):void 0,d=c===void 0;if(d){var u=kn(h),p=!u&&Hc(h),f=!u&&!p&&Vc(h);c=h,u||p||f?kn(a)?c=a:Jm(a)?c=Fm(a):p?(d=!1,c=Nc(h,!0)):f?(d=!1,c=jc(h,!0)):c=[]:qm(h)||Qr(h)?(c=a,Qr(a)?c=ty(a):(!Ee(a)||Yc(a))&&(c=Xc(h))):d=!1}d&&(o.set(h,c),s(c,h,i,n,o),o.delete(h)),er(r,t,c)}function $l(r,e,t,i,s){r!==e&&Zc(e,function(n,o){if(s||(s=new qc),Ee(n))ey(r,e,o,t,$l,i,s);else{var a=i?i(ir(r,o),n,o+"",r,e,s):void 0;a===void 0&&(a=n),er(r,o,a)}},ql)}var Ea=Lm(function(r,e,t,i){$l(r,e,t,i)}),iy="[object Number]";function Ia(r){return typeof r=="number"||cr(r)&&nh(r)==iy}function sy(r,e,t,i){if(!Ee(r))return r;e=rh(e,r);for(var s=-1,n=e.length,o=n-1,a=r;a!=null&&++s<n;){var h=Kc(e[s]),l=t;if(h==="__proto__"||h==="constructor"||h==="prototype")return r;if(s!=o){var c=a[h];l=void 0,l===void 0&&(l=Ee(c)?c:$c(e[s+1])?[]:{})}ih(a,h,l),a=a[h]}return r}function ny(r,e,t){for(var i=-1,s=e.length,n={};++i<s;){var o=e[i],a=Qc(r,o);t(a,o)&&sy(n,rh(o,r),a)}return n}function ry(r,e){return ny(r,e,function(t,i){return Jc(r,i)})}var An=Vm(function(r,e){return r==null?{}:ry(r,e)}),Ba=Qm("round"),oy="Expected a function";function Ct(r,e,t){var i=!0,s=!0;if(typeof r!="function")throw new TypeError(oy);return Ee(t)&&(i="leading"in t?!!t.leading:i,s="trailing"in t?!!t.trailing:s),Rn(r,e,{leading:i,maxWait:e,trailing:s})}function ay(r){return r<.5?4*r*r*r:(r-1)*(2*r-2)*(2*r-2)+1}function Ql(r,e=2){if(r==null)return r;if(Ia(r))return Ba(r,e);if(kn(r))return td(r,t=>Ql(t,e));if(Ee(r)){const t=["x","y","rotation"];return ed(r,(i,s)=>Ia(i)&&t.includes(s)?Ba(i,e):i)}return r}let sr=null;function hy(r){sr=r}function Si(){return sr?sr():!1}const w={log(r,...e){Si()&&console.log(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #2196F3; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #2196F3;",...e)},warn(r,...e){Si()&&console.warn(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #FF9800; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #FF9800;",...e)},error(r,...e){Si()&&console.error(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #F44336; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #F44336;",...e)},debug(r,...e){Si()&&console.log(`%c[ray-2d-laser-map-sdk:DEBUG]%c ${r}`,"background: #9C27B0; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #9C27B0;",...e)},success(r,...e){Si()&&console.log(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #4CAF50; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #4CAF50;",...e)}},Da=r=>{if(r.length<=1)return[...r];const e=ly(r),t=e.slice(1).map((s,n)=>({prev:e[n],current:s})),i=new Map;return t.forEach(({prev:s,current:n})=>{cy(s,n).forEach(a=>{const h=`${a.x},${a.y}`;i.has(h)||i.set(h,a)})}),Array.from(i.values())},ly=r=>{if(r.length<=1)return[...r];const e=r[0],t=r[r.length-1];return e.x===t.x&&e.y===t.y?[...r]:[...r,e]},cy=(r,e)=>{const t=[],i=Math.abs(e.x-r.x),s=Math.abs(e.y-r.y),n=r.x<e.x?1:-1,o=r.y<e.y?1:-1;let a=i-s,h=r.x,l=r.y;for(;t.push({x:h,y:l}),!(h===e.x&&l===e.y);){const c=2*a;c>-s&&(a-=s,h+=n),c<i&&(a+=i,l+=o)}return t},Jl=(r,e)=>{let t=0,i=r.length-1;for(;t<=i;){const s=Math.floor((t+i)/2),n=r[s];if(n===e)return!0;n<e?t=s+1:i=s-1}return!1},dy=(r,e,t=1,i=2e3)=>{const s=[],n=e.x-r.x,o=e.y-r.y,a=Math.sqrt(n*n+o*o);if(a===0)return[r];const h=Math.min(Math.max(Math.ceil(a/t),2),i);for(let l=0;l<=h;l++){const c=l/h,d={x:r.x+c*n,y:r.y+c*o};s.push(d)}return s},Fa=(r,e,t,i,s,n=8)=>{const o=(e+i)/2,a=(t+s)/2,h={x:o,y:a},l=i-e,c=s-t,d=Math.min(n,Math.min(l,c)*.2);return Et(h,r)&&Ri(h,r)>=d?h:uy(r,h,d)},uy=(r,e,t)=>{const{minX:i,minY:s,maxX:n,maxY:o}=ws(r),a=n-i,h=o-s,l=e.x,c=e.y,d=Math.min(.5,Math.min(a,h)*.05),u=[];if(Et({x:l,y:c},r)){const S=Ri({x:l,y:c},r);u.push({point:{x:l,y:c},distance:S,centerDistance:0})}const p=Math.max(a,h)*.6,f=Math.PI/16;let y=0;const m=1e4;let x=!1;for(let S=d;S<=p&&!x;S+=d){const v=f*(1+S/p);for(let b=0;b<2*Math.PI;b+=v){if(y++,y>m){w.error(`[findBestInnerPoint] Iteration limit reached (${y}). Room size: ${a}x${h}`),x=!0;break}const P=l+S*Math.cos(b),C=c+S*Math.sin(b);if(P>=i&&P<=n&&C>=s&&C<=o){const A={x:P,y:C};if(Et(A,r)){const k=Ri(A,r),M=Q({x:P,y:C},{x:l,y:c});k>=t&&u.push({point:A,distance:k,centerDistance:M})}}}if(u.length>=15)break}if(u.length>0){const S=u.map(v=>({...v,score:v.distance*1.5-v.centerDistance*.5}));return S.sort((v,b)=>b.score-v.score),S[0].point}if(u.length===0){let S={x:l,y:c},v=0;const b=d*2;let P=0;const C=5e3;let A=!1;for(let k=i;k<=n&&!A;k+=b)for(let M=s;M<=o;M+=b){if(P++,P>C){w.error(`[findBestInnerPoint] Coarse search iteration limit reached. Room size: ${a}x${h}`),A=!0;break}const T={x:k,y:M};if(Et(T,r)){const _=Ri(T,r);_>v&&(v=_,S=T)}}return S}return{x:l,y:c}},Ri=(r,e)=>{let t=1/0;for(let i=0,s=e.length-1;i<e.length;s=i++){const n=e[s],o=e[i],a=Dr(r,n,o);t=Math.min(t,a)}return t},za=(r,e)=>e.length===1?Q(r,e[0]):e.length===2?Dr(r,e[0],e[1]):e.length===4?Et(r,e)?0:Ri(r,e):(w.warn(`[Distance] Invalid geometry: expected 1, 2 or 4 points, got ${e.length}`),1/0),Dr=(r,e,t)=>{const i=(e.x-t.x)**2+(e.y-t.y)**2;if(i===0)return Q(r,e);const s=Math.max(0,Math.min(1,((r.x-e.x)*(t.x-e.x)+(r.y-e.y)*(t.y-e.y))/i)),n=e.x+s*(t.x-e.x),o=e.y+s*(t.y-e.y);return Q(r,{x:n,y:o})},Et=(r,e,t=!1)=>{if(e.length<3)return!1;if(t&&py(r,e))return!0;let i=!1;for(let s=0,n=e.length-1;s<e.length;n=s++){const o=e[s].x,a=e[s].y,h=e[n].x,l=e[n].y;a>r.y!=l>r.y&&r.x<(h-o)*(r.y-a)/(l-a)+o&&(i=!i)}return i},py=(r,e)=>{if(e.length<2)return!1;for(let t=0;t<e.length;t++){const i=(t+1)%e.length;if(fy(r,e[t],e[i]))return!0}return!1},fy=(r,e,t,i=.5)=>{if(Dr(r,e,t)>i)return!1;const n=Math.min(e.x,t.x)-i,o=Math.max(e.x,t.x)+i,a=Math.min(e.y,t.y)-i,h=Math.max(e.y,t.y)+i;return r.x>=n&&r.x<=o&&r.y>=a&&r.y<=h},ws=r=>{if(r.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let e=1/0,t=1/0,i=-1/0,s=-1/0;for(const n of r)e=Math.min(e,n.x),t=Math.min(t,n.y),i=Math.max(i,n.x),s=Math.max(s,n.y);return{minX:e,minY:t,maxX:i,maxY:s}},de=r=>{const e=r.reduce((t,i)=>({x:t.x+i.x,y:t.y+i.y}),{x:0,y:0});return{x:e.x/r.length,y:e.y/r.length}},nr=(r,e,t)=>{if(r.length<4)return r;const[i,s,,n]=r,o=Q(i,s),a=Q(i,n),h=o<e||a<e,l=t!=null&&(o>t||a>t);if(!h&&!l)return r;const c=de(r),d=gt(K(i,s)),u=gt(K(i,n)),p=S=>{let v=S;return t!=null&&(v=Math.min(v,t)),Math.max(v,e)},f=p(o),y=p(a),m=f/2,x=y/2;return[{x:c.x-d.x*m-u.x*x,y:c.y-d.y*m-u.y*x},{x:c.x+d.x*m-u.x*x,y:c.y+d.y*m-u.y*x},{x:c.x+d.x*m+u.x*x,y:c.y+d.y*m+u.y*x},{x:c.x-d.x*m+u.x*x,y:c.y-d.y*m+u.y*x}]},Cs=r=>{if(r.length!==4)return r;const e=de(r),t=Q(r[0],r[1]),i=Q(r[1],r[2]),s=Math.atan2(r[1].y-r[0].y,r[1].x-r[0].x),n=[{x:-t/2,y:-i/2},{x:t/2,y:-i/2},{x:t/2,y:i/2},{x:-t/2,y:i/2}],o=Math.cos(s),a=Math.sin(s);return n.map(h=>({x:h.x*o-h.y*a+e.x,y:h.x*a+h.y*o+e.y}))},ae=(r,e,t,i=10,s)=>{if(t===0)return 1;const o=(r.x*e.x+r.y*e.y)/t/t,a=i/t;if(o<=0)return a;let h=o;if(s!=null){const l=s/t;h=Math.min(h,l)}return Math.max(h,a)},Q=(r,e)=>{const t=r.x-e.x,i=r.y-e.y;return Math.sqrt(t*t+i*i)},ee=r=>Math.sqrt(r.x*r.x+r.y*r.y),K=(r,e)=>({x:e.x-r.x,y:e.y-r.y}),gt=r=>{const e=ee(r);return e===0?{x:0,y:0}:{x:r.x/e,y:r.y/e}},tc=(r,e)=>{const t=K(r,e);return gt(t)},ec=r=>({x:-r.y,y:r.x}),ic=(r,e)=>{const t=tc(r,e);return ec(t)},sc=(r,e)=>{const t=gt(r),i=gt(e),s={x:(t.x+i.x)/2,y:(t.y+i.y)/2};return gt(s)},qe=(r,e,t=0)=>{const i=K(r,e);let s=Math.atan2(i.y,i.x),o=(s+t)%(2*Math.PI);return o>Math.PI&&(o-=2*Math.PI),o<-Math.PI&&(o+=2*Math.PI),(o>Math.PI/2||o<-Math.PI/2)&&(s+=Math.PI),s},nc=(r,e,t)=>{const i=de([r,e]),s=ic(r,e);return{x:i.x+s.x*t,y:i.y+s.y*t}},gy=(r,e,t)=>{const i=Math.cos(t),s=Math.sin(t),n=r.x-e.x,o=r.y-e.y;return{x:n*i-o*s+e.x,y:n*s+o*i+e.y}},Fr=(r,e,t)=>r.map(i=>gy(i,e,t)),my=(r,e,t)=>{if(Q(r,e)===0)return[r,r,r,r];const s=tc(r,e),n=ec(s),o={x:r.x-s.x*t,y:r.y-s.y*t},a={x:e.x+s.x*t,y:e.y+s.y*t};return[{x:o.x+n.x*t,y:o.y+n.y*t},{x:a.x+n.x*t,y:a.y+n.y*t},{x:a.x-n.x*t,y:a.y-n.y*t},{x:o.x-n.x*t,y:o.y-n.y*t}]},zr=(r,e)=>{if(r.length<3)return r;const t=[];for(let i=0;i<r.length;i++){const s=r[i],n=r[(i+1)%r.length],o=r[(i-1+r.length)%r.length],a=K(s,n);if(ee(a)===0){t.push(s);continue}const l=gt(a),c={x:l.y,y:-l.x},d=K(o,s),u=ee(d);let p={x:0,y:0};if(u>0){const S=gt(d);p={x:S.y,y:-S.x}}const f=sc(p,c),y=p.x*c.x+p.y*c.y,m=1/Math.max(.1,Math.sqrt((1+y)/2)),x={x:s.x+f.x*e*m,y:s.y+f.y*e*m};t.push(x)}return t},rc=(r,e,t)=>{if(Q(r,e)===0)return[];const s=ic(r,e),n=t/2;return[r.x+s.x*n,r.y+s.y*n,e.x+s.x*n,e.y+s.y*n,e.x-s.x*n,e.y-s.y*n,r.x-s.x*n,r.y-s.y*n]},Ds=(r,e,t,i)=>{const s=K(r,e),n=K(r,t),o=sc(s,n),a={x:-o.x,y:-o.y};return{x:r.x+a.x*i,y:r.y+a.y*i}},yy=(r,e,t,i,s,n)=>{const o=new Set(r),a=xy(r,e),h=Sy(a,o,e,t,i,s,n);return h||a},xy=(r,e)=>{let t=0,i=0;for(let s=0;s<r.length;s++){const n=r[s],o=n%e,a=Math.floor(n/e);t+=o,i+=a}return{x:t/r.length,y:i/r.length}},Sy=(r,e,t,i,s,n,o)=>{const a={x:i-10,y:r.y},h={x:n+10,y:r.y},l={x:i,y:s},c={x:i,y:o},d={x:n,y:s},u={x:n,y:o},p=Ui(a,h,l,c),f=Ui(a,h,d,u);if(!p||!f)return null;const y=[],m=Math.max(i,Math.min(p.x,f.x)),x=Math.min(n,Math.max(p.x,f.x)),S=Math.round(r.y);for(let v=Math.round(m);v<=Math.round(x);v++){const b=S*t+v;e.has(b)&&y.push({x:v,y:S})}if(y.length>=2){const v=vy(y),b={x:(v.min.x+v.max.x)/2,y:(v.min.y+v.max.y)/2},P=Math.round(b.y)*t+Math.round(b.x);if(e.has(P))return b}return null},Ui=(r,e,t,i)=>{const s=(r.x-t.x)*(e.y-t.y)-(r.y-t.y)*(e.x-t.x),n=(r.x-i.x)*(e.y-i.y)-(r.y-i.y)*(e.x-i.x);if(s*n>=0)return null;const o=(t.x-r.x)*(i.y-r.y)-(t.y-r.y)*(i.x-r.x),a=o+s-n;if(o*a>=0)return null;const h=o/(n-s),l=h*(e.x-r.x),c=h*(e.y-r.y);return{x:r.x+l,y:r.y+c}},vy=r=>{if(!r||r.length===0)return{min:{x:0,y:0},max:{x:0,y:0}};let e=r[0],t=r[0];const i=s=>s.x-s.y;for(let s=1;s<r.length;s++){const n=r[s];i(n)<i(e)&&(e=n),i(n)>i(t)&&(t=n)}return{min:e,max:t}},Pn=(r,e)=>({minX:Math.min(r.minX,e.minX),minY:Math.min(r.minY,e.minY),maxX:Math.max(r.maxX,e.maxX),maxY:Math.max(r.maxY,e.maxY)}),by=r=>{if(r.length===0)return{x:0,y:0,width:0,height:0};let e=r[0].x,t=r[0].y,i=r[0].x+r[0].width,s=r[0].y+r[0].height;return r.forEach(n=>{e=Math.min(e,n.x),t=Math.min(t,n.y),i=Math.max(i,n.x+n.width),s=Math.max(s,n.y+n.height)}),{x:e,y:t,width:i-e,height:s-t}},wy=(r,e,t)=>{let i=1/0,s=1/0,n=-1/0,o=-1/0;for(let a=0;a<r.obstacles.length;a++){const h=r.obstacles[a],l=h%e,c=Math.floor(h/e);i=Math.min(i,l),s=Math.min(s,c),n=Math.max(n,l),o=Math.max(o,c)}return r.rooms.forEach(a=>{for(let h=0;h<a.length;h++){const l=a[h],c=l%e,d=Math.floor(l/e);i=Math.min(i,c),s=Math.min(s,d),n=Math.max(n,c),o=Math.max(o,d)}}),i===1/0?{minX:0,minY:0,maxX:e,maxY:t}:{minX:Math.max(0,i),minY:Math.max(0,s),maxX:Math.min(e,n),maxY:Math.min(t,o)}},Cy=(r,e,t,i,s,n)=>{const o=t+s,a=i+n,h=Math.min(r.x,e.x),l=Math.max(r.x,e.x),c=Math.min(r.y,e.y),d=Math.max(r.y,e.y);if(l<t||h>o||d<i||c>a)return!1;if(La(r,t,i,s,n)||La(e,t,i,s,n))return!0;const u=[{x:t,y:i},{x:o,y:i},{x:o,y:a},{x:t,y:a}];for(let p=0;p<4;p++){const f=u[p],y=u[(p+1)%4];if(Ui(r,e,f,y))return!0}return!1},La=(r,e,t,i,s)=>r.x>=e&&r.x<=e+i&&r.y>=t&&r.y<=t+s,Ay=(r,e,t,i)=>{const s=t/2;return i==="horizontal"?[{x:r-s,y:e},{x:r+s,y:e}]:[{x:r,y:e-s},{x:r,y:e+s}]},Py=(r,e,t)=>{const i={x:e.x-r.x,y:e.y-r.y},s=Math.sqrt(i.x*i.x+i.y*i.y);if(s===0)return[r,e];const n={x:i.x/s,y:i.y/s},o={x:r.x-n.x*t,y:r.y-n.y*t},a={x:e.x+n.x*t,y:e.y+n.y*t};return[o,a]},Oa=(r,e,t)=>{const i=ws(r),s=ws(e),n=Math.max(0,Math.max(i.minX,s.minX)-Math.min(i.maxX,s.maxX)),o=Math.max(0,Math.max(i.minY,s.minY)-Math.min(i.maxY,s.maxY));if(n>t||o>t)return!1;let[a,h]=[r,e];e.length>r.length&&([a,h]=[e,r]);const l=Math.max(1,Math.floor(t)),c=new Map;for(const u of a){const p=Math.floor(u.x/l),f=Math.floor(u.y/l),y=`${p},${f}`;c.has(y)||c.set(y,[]),c.get(y).push(u)}const d=t*t;for(const u of h){const p=Math.floor(u.x/l),f=Math.floor(u.y/l);for(let y=-1;y<=1;y++)for(let m=-1;m<=1;m++){const x=`${p+y},${f+m}`,S=c.get(x);if(S)for(const v of S){const b=u.x-v.x,P=u.y-v.y;if(b*b+P*P<=d)return!0}}}return!1},Ga=(r,e,t,i)=>{let[s,n]=[r,e];e.length>r.length&&([s,n]=[e,r]);const o=new Set(s),a=i*i;for(let h=0;h<n.length;h++){const l=n[h],c=l%t,d=Math.floor(l/t);for(let u=-i;u<=i;u++)for(let p=-i;p<=i;p++){const f=c+u,m=(d+p)*t+f;if(o.has(m)&&u*u+p*p<=a)return!0}}return!1},Wa=(r,e)=>{if(r<=1)return!0;if(e.length===0)return!1;const t=Array.from({length:r},(a,h)=>h),i=Array(r).fill(0),s=a=>(t[a]!==a&&(t[a]=s(t[a])),t[a]),n=(a,h)=>{const l=s(a),c=s(h);l!==c&&(i[l]<i[c]?t[l]=c:i[l]>i[c]?t[c]=l:(t[c]=l,i[l]++))};for(const[a,h]of e)n(a,h);const o=s(0);for(let a=1;a<r;a++)if(s(a)!==o)return!1;return!0},My=(r,e,t,i="priority")=>{const s=new Map;if(r.length===0)return s;if(r.length===1)return s.set(r[0].id,0),s;const n=new Map;for(let l=0;l<r.length;l++){const c=r[l];n.has(c.id)||n.set(c.id,new Set);for(let d=l+1;d<r.length;d++){const u=r[d];e(c,u)&&(n.get(c.id).add(u.id),n.has(u.id)||n.set(u.id,new Set),n.get(u.id).add(c.id))}}const o=new Array(t).fill(0),a=[...r].sort((l,c)=>{const d=(n.get(l.id)||new Set).size,u=(n.get(c.id)||new Set).size,p=r.indexOf(l),f=r.indexOf(c),y=-p*.5+d*.5;return-f*.5+u*.5-y}),h=l=>{const c=n.get(l)||new Set,d=new Map;for(const u of c){const p=s.get(u);p!==void 0&&(d.has(p)||d.set(p,[]),d.get(p).push(u))}for(const[u,p]of d){if(p.length!==1)continue;const f=p[0],y=n.get(f)||new Set,m=new Set;for(const x of y){if(x===l)continue;const S=s.get(x);S!==void 0&&m.add(S)}for(let x=0;x<t;x++)if(x!==u&&!m.has(x))return o[u]--,o[x]++,s.set(f,x),u}return-1};for(const l of a){const c=n.get(l.id)||new Set,d=new Set;for(const p of c){const f=s.get(p);f!==void 0&&d.add(f)}let u=-1;if(i==="priority"){let p=-1,f=-1/0;for(let y=0;y<t;y++)if(!d.has(y)){const m=t-y,x=o[y]*.7,S=m-x;(S>f||S===f&&y<p)&&(f=S,p=y)}if(u=p,u===-1&&(u=h(l.id)),u===-1){w.warn(`[FourColor] Room ${l.id}: recolor failed, falling back to least-conflict color`);let y=1/0;for(let m=0;m<t;m++){let x=0;for(const S of c)s.get(S)===m&&x++;(x<y||x===y&&m<u)&&(y=x,u=m)}}o[u]++}else{const p=[];for(let f=0;f<t;f++)d.has(f)||p.push(f);if(p.length===0){if(u=h(l.id),u===-1){w.warn(`[FourColor] Room ${l.id}: recolor failed, falling back to least-conflict color`);let f=1/0,y=0;for(let m=0;m<t;m++)(o[m]<f||o[m]===f&&m<y)&&(f=o[m],y=m);u=y}}else{u=p[0];let f=o[u];for(const y of p)(o[y]<f||o[y]===f&&y<u)&&(u=y,f=o[y])}o[u]++}s.set(l.id,u)}return s},_y=Symbol(),Ua=Object.getPrototypeOf,rr=new WeakMap,Ty=r=>r&&(rr.has(r)?rr.get(r):Ua(r)===Object.prototype||Ua(r)===Array.prototype),ky=r=>Ty(r)&&r[_y]||null,Ha=(r,e=!0)=>{rr.set(r,e)},As={},Lr=r=>typeof r=="object"&&r!==null,Ry=r=>Lr(r)&&!Or.has(r)&&(Array.isArray(r)||!(Symbol.iterator in r))&&!(r instanceof WeakMap)&&!(r instanceof WeakSet)&&!(r instanceof Error)&&!(r instanceof Number)&&!(r instanceof Date)&&!(r instanceof String)&&!(r instanceof RegExp)&&!(r instanceof ArrayBuffer)&&!(r instanceof Promise),oc=(r,e)=>{const t=Va.get(r);if((t==null?void 0:t[0])===e)return t[1];const i=Array.isArray(r)?[]:Object.create(Object.getPrototypeOf(r));return Ha(i,!0),Va.set(r,[e,i]),Reflect.ownKeys(r).forEach(s=>{if(Object.getOwnPropertyDescriptor(i,s))return;const n=Reflect.get(r,s),{enumerable:o}=Reflect.getOwnPropertyDescriptor(r,s),a={value:n,enumerable:o,configurable:!0};if(Or.has(n))Ha(n,!1);else if(Fe.has(n)){const[h,l]=Fe.get(n);a.value=oc(h,l())}Object.defineProperty(i,s,a)}),Object.preventExtensions(i)},Ey=(r,e,t,i)=>({deleteProperty(s,n){const o=Reflect.get(s,n);t(n);const a=Reflect.deleteProperty(s,n);return a&&i(["delete",[n],o]),a},set(s,n,o,a){const h=!r()&&Reflect.has(s,n),l=Reflect.get(s,n,a);if(h&&(Na(l,o)||Ps.has(o)&&Na(l,Ps.get(o))))return!0;t(n),Lr(o)&&(o=ky(o)||o);const c=!Fe.has(o)&&By(o)?or(o):o;return e(n,c),Reflect.set(s,n,c,a),i(["set",[n],o,l]),!0}}),Fe=new WeakMap,Or=new WeakSet,Va=new WeakMap,Mn=[1],Ps=new WeakMap;let Na=Object.is,Iy=(r,e)=>new Proxy(r,e),By=Ry,Dy=oc,Fy=Ey;function or(r={}){if(!Lr(r))throw new Error("object required");const e=Ps.get(r);if(e)return e;let t=Mn[0];const i=new Set,s=(m,x=++Mn[0])=>{t!==x&&(n=t=x,i.forEach(S=>S(m,x)))};let n=t;const o=(m=Mn[0])=>(n!==m&&(n=m,h.forEach(([x])=>{const S=x[1](m);S>t&&(t=S)})),t),a=m=>(x,S)=>{const v=[...x];v[1]=[m,...v[1]],s(v,S)},h=new Map,l=(m,x)=>{const S=!Or.has(x)&&Fe.get(x);if(S){if((As?"production":void 0)!=="production"&&h.has(m))throw new Error("prop listener already exists");if(i.size){const v=S[2](a(m));h.set(m,[S,v])}else h.set(m,[S])}},c=m=>{var x;const S=h.get(m);S&&(h.delete(m),(x=S[1])==null||x.call(S))},d=m=>(i.add(m),i.size===1&&h.forEach(([S,v],b)=>{if((As?"production":void 0)!=="production"&&v)throw new Error("remove already exists");const P=S[2](a(b));h.set(b,[S,P])}),()=>{i.delete(m),i.size===0&&h.forEach(([S,v],b)=>{v&&(v(),h.set(b,[S]))})});let u=!0;const p=Fy(()=>u,l,c,s),f=Iy(r,p);Ps.set(r,f);const y=[r,o,d];return Fe.set(f,y),Reflect.ownKeys(r).forEach(m=>{const x=Object.getOwnPropertyDescriptor(r,m);"value"in x&&x.writable&&(f[m]=r[m])}),u=!1,f}function Fs(r,e,t){const i=Fe.get(r);(As?"production":void 0)!=="production"&&!i&&console.warn("Please use proxy object");let s;const n=[],o=i[2];let a=!1;const l=o(c=>{n.push(c),s||(s=Promise.resolve().then(()=>{s=void 0,a&&e(n.splice(0))}))});return a=!0,()=>{a=!1,l()}}function zy(r){const e=Fe.get(r);(As?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[t,i]=e;return Dy(t,i())}function W(r,e,t,i){let s=r[e];return Fs(r,()=>{const n=r[e];Object.is(s,n)||t(s=n)})}class Ly extends L{constructor(t){super();g(this,"dragStart",null);g(this,"initialTouchDistance",null);g(this,"initialScale",null);g(this,"activeTouches",new Map);g(this,"firstTouchId",null);g(this,"secondTouchId",null);g(this,"taintedPointers",new Set);g(this,"zoomFactor",.8);g(this,"scaleMin",.2);g(this,"scaleMax",5);g(this,"originalPosition",{x:0,y:0});g(this,"targetPosition",{x:0,y:0});g(this,"centerPosition",{x:0,y:0});g(this,"originalScale",{x:1,y:1});g(this,"targetScale",{x:1,y:1});g(this,"defaultScale",{x:1,y:1});g(this,"transitionDuration",500);g(this,"transitionStartTime",null);g(this,"initialPinchCenter",null);g(this,"isGestureValid",!0);g(this,"lastTapTime",0);g(this,"doubleTapDelay",300);g(this,"doubleTapZoomFactor",1.5);g(this,"lastTapPosition",null);g(this,"tapDistanceThreshold",20);g(this,"tapDetectionEnabled",!0);g(this,"mapClickStartPosition",null);g(this,"mapClickStartTime",0);g(this,"mapClickTimeThreshold",300);g(this,"mapClickMoveThreshold",10);g(this,"shouldSuppressMapClick",!1);g(this,"isGestureHijacked",!1);g(this,"hijackedPointerId",null);g(this,"isHijackPaused",!1);g(this,"interactionGraphics");g(this,"viewportBounds");g(this,"boundResetAnimation");g(this,"debouncedStopWheelRender");g(this,"debouncedLogWheelScale");g(this,"interactionState",{isInteracting:!1,isAnimating:!1,interactionTimer:null,renderReasons:new Set});g(this,"throttledAntiScale");g(this,"unsubscribeEnableInteraction",null);g(this,"handleSuppressMapClick",()=>{this.shouldSuppressMapClick=!0});g(this,"handleGestureHijacked",t=>{var n,o;this.isGestureHijacked=!0,this.hijackedPointerId=t.pointerId,this.isHijackPaused=!1,this.clearTouches();const i=t.global.x-this.viewportBounds.x,s=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:i,y:s}),this.firstTouchId=t.pointerId,this.dragStart={x:i,y:s},(o=(n=this.appService.events)==null?void 0:n.onGestureStart)==null||o.call(n)});this.appService=t;const i=t.getApp();this.viewportBounds=i.getViewportBounds(),this.eventMode="static",this.unsubscribeEnableInteraction=W(t.runtime,"enableInteraction",s=>{this.updateInteractionMode(s)}),this.updateInteractionMode(t.runtimeSnapshot.enableInteraction),this.interactionGraphics=new H,this.interactionGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill({color:"#ffffff",alpha:0}),this.addChild(this.interactionGraphics),this.scaleMax=i.scaleMax,this.scaleMin=i.scaleMin,this.centerPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.originalPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.targetPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.throttledAntiScale=Ct(s=>{this.appService.emitter.emit("antiScale",s)},16,{leading:!0,trailing:!0}),this.boundResetAnimation=this.resetAnimation.bind(this),this.debouncedStopWheelRender=Rn(()=>{i.stopRender("wheel")},300),this.debouncedLogWheelScale=Rn(s=>{w.debug("[Interaction] 滚轮缩放完成 - Scale:",s.toFixed(3))},500),this.setupInteraction()}updateInteractionMode(t){this.eventMode=t?"static":"none",w.debug(`[Interaction] 交互模式已更新: ${t?"启用":"禁用"}`)}setupInteraction(){this.on("pointerdown",t=>this.onPointerDown(t)),this.on("pointerup",t=>this.onPointerUp(t)),this.on("pointerupoutside",t=>this.onPointerUp(t)),this.on("pointermove",t=>this.onPointerMove(t)),this.on("wheel",t=>this.onWheel(t)),this.appService.emitter.on("gestureHijackStart",this.handleGestureHijacked),this.appService.emitter.on("suppressMapClick",this.handleSuppressMapClick),document.addEventListener("pointercancel",t=>{w.debug("[Interaction] Received global pointercancel"),this.handleGlobalCancel(t)})}handleGlobalCancel(t){const i=this.appService;if(this.isGestureHijacked){w.debug("[Interaction] 系统取消或移出视口,强制结束劫持手势");const s=i.getApp(),n=new Sa(s.renderer.events);n.pointerId=t.pointerId,i.emitter.emit("gestureHijackPointerUp",n),this.exitGestureHijacked()}this.clearTouches()}resetPan(t){const i=this.appService,s=i.getApp(),n=i.appContainer;this.transitionStartTime!==null&&(s.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null);const o=this.centerPosition.x-t.x*n.scale.x,a=this.centerPosition.y-t.y*n.scale.y;this.originalPosition={x:n.x,y:n.y},this.targetPosition={x:o,y:a},this.originalScale={x:n.scale.x,y:n.scale.y},this.targetScale={x:n.scale.x,y:n.scale.y};const h=Math.sqrt((n.x-o)**2+(n.y-a)**2),c=(d=>Math.pow(Math.min(1,d/1e3),.5))(h);this.transitionDuration=500+1e3*Math.min(1,Math.pow(c,2)),this.transitionStartTime=s.ticker.lastTime,s.ticker.add(this.boundResetAnimation)}setPanZoom({targetPosition:t,targetScale:i,setCenter:s=!1,setScale:n=!1}={},o=!0){const a=this.appService,h=a.getApp(),l=a.appContainer;if(s&&t&&(this.centerPosition={x:t.x,y:t.y},w.debug("[Interaction] Set center position:",this.centerPosition)),n&&i&&(this.defaultScale={x:i.x,y:i.y},w.debug("[Interaction] Set scale:",this.defaultScale)),this.originalPosition={x:l.x,y:l.y},this.originalScale={x:l.scale.x,y:l.scale.y},t?this.targetPosition=t:this.targetPosition={x:this.centerPosition.x,y:this.centerPosition.y},i?this.targetScale=i:this.targetScale=this.defaultScale,!o){l.position.set(this.targetPosition.x,this.targetPosition.y),l.scale.set(this.targetScale.x,this.targetScale.y),this.antiScale(this.targetScale.x),this.transitionStartTime!==null&&(h.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),w.debug("[Interaction] 直接设置缩放完成 - Scale:",this.targetScale.x.toFixed(3));return}const c=Math.sqrt((l.x-this.targetPosition.x)**2+(l.y-this.targetPosition.y)**2),u=(m=>Math.pow(Math.min(1,m/1e3),.5))(c),f=((m,x)=>Math.pow(Math.min(1,Math.abs(m-x)/Math.abs(.2-1)),.5))(l.scale.x,this.targetScale.x),y=u*.8+f*.2;this.transitionDuration=500+1e3*Math.min(1,Math.pow(y,2)),this.transitionStartTime!==null&&(h.ticker.remove(this.boundResetAnimation),this.interactionState.isAnimating=!1,h.stopRender("animation")),this.interactionState.isAnimating=!0,h.requestRender("animation",!0),this.transitionStartTime=h.ticker.lastTime,h.ticker.add(this.boundResetAnimation)}clearTouches(){var s,n;const i=this.appService.getApp();this.activeTouches.clear(),this.firstTouchId=null,this.secondTouchId=null,this.dragStart=null,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.isGestureValid=!0,this.taintedPointers.clear(),this.transitionStartTime!==null&&(i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),this.interactionState.isInteracting&&(this.interactionState.isInteracting=!1,(n=(s=this.appService.events)==null?void 0:s.onGestureEnd)==null||n.call(s)),i.stopRender("interaction")}checkEventListeners(){return{wheel:this.listenerCount("wheel"),pointerdown:this.listenerCount("pointerdown"),pointerup:this.listenerCount("pointerup"),pointerupoutside:this.listenerCount("pointerupoutside"),pointermove:this.listenerCount("pointermove")}}destroy(){this.checkEventListeners(),this.interactionState.interactionTimer&&clearTimeout(this.interactionState.interactionTimer),this.interactionState.renderReasons.clear(),this.interactionState.isInteracting=!1,this.interactionState.isAnimating=!1,this.debouncedStopWheelRender.cancel(),this.debouncedLogWheelScale.cancel(),this.unsubscribeEnableInteraction&&(this.unsubscribeEnableInteraction(),this.unsubscribeEnableInteraction=null),this.appService.emitter.off("gestureHijackStart",this.handleGestureHijacked),this.appService.emitter.off("suppressMapClick",this.handleSuppressMapClick),super.destroy()}exitGestureHijacked(){var i,s;const t=this.appService;this.hijackedPointerId!==null&&!this.isHijackPaused&&(this.activeTouches.delete(this.hijackedPointerId),this.firstTouchId===this.hijackedPointerId&&(this.firstTouchId=null,this.dragStart=null),this.secondTouchId===this.hijackedPointerId&&(this.secondTouchId=null)),this.isGestureHijacked=!1,this.hijackedPointerId=null,this.isHijackPaused=!1,(s=(i=t.events)==null?void 0:i.onGestureEnd)==null||s.call(i)}forceEndGesture(){if(this.isGestureHijacked){w.debug("[Interaction] 强制结束劫持手势");const t=this.appService.getApp(),i=new Sa(t.renderer.events);i.pointerId=this.hijackedPointerId,this.appService.emitter.emit("gestureHijackPointerUp",i),this.exitGestureHijacked()}this.clearTouches()}pauseGestureHijack(){this.isHijackPaused=!0}resumeGestureHijack(){this.isHijackPaused=!1}antiScale(t){this.throttledAntiScale(t)}resetAnimation(){const t=this.appService,i=t.getApp(),s=t.appContainer;if(this.transitionStartTime===null)return;const{targetPosition:n,targetScale:o}=this,a=i.ticker.lastTime,h=Math.min(1,(a-this.transitionStartTime)/this.transitionDuration);if(h>=1)s.position.set(n.x,n.y),s.scale.set(o.x,o.y),this.antiScale(o.x),i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null,this.interactionState.isAnimating=!1,i.stopRender("animation"),w.debug("[Interaction] 动画缩放完成 - Scale:",s.scale.x.toFixed(3));else{const l=ay(h),c=this.originalPosition.x+(n.x-this.originalPosition.x)*l,d=this.originalPosition.y+(n.y-this.originalPosition.y)*l,u=this.originalScale.x+(o.x-this.originalScale.x)*l,p=this.originalScale.y+(o.y-this.originalScale.y)*l;s.position.set(c,d),s.scale.set(u,p),this.antiScale(u)}}onWheel(t){const i=this.appService;if(this.isGestureHijacked){w.warn("⚠️ [onWheel] 被手势劫持阻止执行",{isGestureHijacked:this.isGestureHijacked,hijackedPointerId:this.hijackedPointerId,isHijackPaused:this.isHijackPaused});return}i.getApp().requestRender("wheel",!0),this.debouncedStopWheelRender();const{scaleMin:s,scaleMax:n}=this,o=i.appContainer;t.preventDefault();const a=t.global.x-this.viewportBounds.x,h=t.global.y-this.viewportBounds.y,l=(a-o.x)/o.scale.x,c=(h-o.y)/o.scale.y,d=t.deltaY>0?.95:1.05;let u=o.scale.x*d,p=o.scale.y*d;if(u=Math.max(s,Math.min(n,u)),p=Math.max(s,Math.min(n,p)),!(u!==o.scale.x||p!==o.scale.y))return;const y=a-l*u,m=h-c*p;try{o.scale.set(u,p),o.position.set(y,m),this.antiScale(u),this.debouncedLogWheelScale(u)}catch(x){w.error("❌ [onWheel] 应用缩放时发生错误:",x)}}onPointerDown(t){var l,c;const i=this.appService;this.interactionState.isInteracting||(this.interactionState.isInteracting=!0,i.getApp().requestRender("interaction",!0),(c=(l=i.events)==null?void 0:l.onGestureStart)==null||c.call(l)),this.isGestureHijacked&&t.pointerId!==this.hijackedPointerId&&!this.isHijackPaused&&this.pauseGestureHijack();const s=i.getApp(),n=i.appContainer;this.transitionStartTime!==null&&(s.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),this.activeTouches.size===0&&this.taintedPointers.size>0&&(w.debug("[Interaction] 清除污染指针列表,准备新手势",Array.from(this.taintedPointers)),this.taintedPointers.clear()),this.activeTouches.size===0&&(this.isGestureValid=!0,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.dragStart=null,this.firstTouchId=null,this.secondTouchId=null),this.activeTouches.has(t.pointerId)&&this.activeTouches.size===1&&(this.isGestureValid=!0);const o=t.global.x-this.viewportBounds.x,a=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:o,y:a});const h=this.activeTouches.size-this.taintedPointers.size;if(this.taintedPointers.size>0){w.debug("[Interaction] 存在污染指针,阻止多点触摸手势",Array.from(this.taintedPointers)),h===1&&!this.taintedPointers.has(t.pointerId)&&(this.firstTouchId=t.pointerId,this.dragStart={x:o,y:a});return}if(this.activeTouches.size===1)this.firstTouchId=t.pointerId,this.dragStart={x:o,y:a},this.mapClickStartPosition={x:o,y:a},this.mapClickStartTime=performance.now();else if(this.activeTouches.size===2){const d=Array.from(this.activeTouches.keys());this.secondTouchId=d.find(u=>u!==this.firstTouchId)||t.pointerId,this.setInitialScaleAndDistance(n),this.tapDetectionEnabled=!1}}onPointerUp(t){var n,o;const i=this.appService;if(this.taintedPointers.has(t.pointerId)&&(w.debug("[Interaction] 移除污染指针",t.pointerId),this.taintedPointers.delete(t.pointerId)),this.isGestureHijacked)if(t.pointerId===this.hijackedPointerId){i.emitter.emit("gestureHijackPointerUp",t),this.exitGestureHijacked();return}else this.isHijackPaused;if(!this.activeTouches.has(t.pointerId))return;const s=this.initialTouchDistance!==null&&this.initialScale!==null;if(this.activeTouches.delete(t.pointerId),w.debug(`[Interaction] onPointerUp, remaining touches: ${this.activeTouches.size}`),s&&this.activeTouches.size===1){this.isGestureValid=!1;const a=Array.from(this.activeTouches.keys());setTimeout(()=>{var h,l;!this.isGestureValid&&this.activeTouches.size>0&&(w.debug("[Interaction] 100ms 缓冲结束,检测到真正的幽灵指针,标记为污染并清理",a),a.forEach(c=>{this.activeTouches.has(c)&&(this.taintedPointers.add(c),this.activeTouches.delete(c),this.firstTouchId===c&&(this.firstTouchId=null,this.dragStart=null),this.secondTouchId===c&&(this.secondTouchId=null))}),this.activeTouches.size===0&&this.interactionState.isInteracting&&(w.debug("[Interaction] 清理幽灵指针后所有触摸点已释放,结束手势"),this.interactionState.isInteracting=!1,i.getApp().stopRender("interaction"),(l=(h=i.events)==null?void 0:h.onGestureEnd)==null||l.call(h)))},100),this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null}t.pointerId===this.firstTouchId?(this.firstTouchId=null,this.dragStart=null,this.activeTouches.size===0&&this.tapDetectionEnabled&&this.detectDoubleTap(t),this.activeTouches.size===0&&!s&&this.detectMapClick(t)):t.pointerId===this.secondTouchId&&(this.secondTouchId=null),this.isGestureHijacked&&this.isHijackPaused&&this.activeTouches.size===1&&Array.from(this.activeTouches.keys())[0]===this.hijackedPointerId&&this.resumeGestureHijack(),this.activeTouches.size===0&&(this.isGestureValid=!0,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.firstTouchId=null,this.secondTouchId=null,this.dragStart=null,this.tapDetectionEnabled=!0,this.interactionState.isInteracting&&(this.interactionState.isInteracting=!1,i.getApp().stopRender("interaction"),(o=(n=i.events)==null?void 0:n.onGestureEnd)==null||o.call(n)))}detectDoubleTap(t){const i=this.appService,{interactionConfig:s}=i;if(!s.enableDoubleTapZoom)return;const n=performance.now(),o={x:t.global.x-this.viewportBounds.x,y:t.global.y-this.viewportBounds.y};n-this.lastTapTime<this.doubleTapDelay&&this.lastTapPosition&&Q(o,this.lastTapPosition)<this.tapDistanceThreshold?(this.handleDoubleTap(o),this.lastTapTime=0,this.lastTapPosition=null):(this.lastTapTime=n,this.lastTapPosition=o)}detectMapClick(t){var h;const i=this.appService;if(!i.runtimeSnapshot.enableMapClickCapture||!((h=i.events)!=null&&h.onClickMap)||!this.mapClickStartPosition)return;const n=performance.now()-this.mapClickStartTime,o={x:t.global.x-this.viewportBounds.x,y:t.global.y-this.viewportBounds.y},a=Q(this.mapClickStartPosition,o);if(n<=this.mapClickTimeThreshold&&a<=this.mapClickMoveThreshold&&!this.shouldSuppressMapClick){const l=i.appContainer,c=i.mapState,d=(o.x-l.x)/l.scale.x,u=(o.y-l.y)/l.scale.y,p={x:d-((c==null?void 0:c.origin.x)||0),y:u-((c==null?void 0:c.origin.y)||0)};w.debug("[Interaction] 地图点击捕获",{screenPosition:o,containerPosition:{x:d,y:u},origin:c==null?void 0:c.origin,mapPosition:p,clickDuration:n,moveDistance:a}),i.events.onClickMap(p)}this.mapClickStartPosition=null,this.mapClickStartTime=0,this.shouldSuppressMapClick=!1}handleDoubleTap(t){const i=this.appService,s=i.getApp(),n=i.appContainer,{scaleMin:o,scaleMax:a,doubleTapZoomFactor:h}=this,l=t.x,c=t.y,d=(l-n.x)/n.scale.x,u=(c-n.y)/n.scale.y;let p=n.scale.x*h,f=n.scale.y*h;p=Math.max(o,Math.min(a,p)),f=Math.max(o,Math.min(a,f)),this.originalPosition={x:n.x,y:n.y},this.originalScale={x:n.scale.x,y:n.scale.y};const y=l-d*p,m=c-u*f;this.targetPosition={x:y,y:m},this.targetScale={x:p,y:f},this.interactionState.isAnimating=!0,s.requestRender("animation",!0),this.transitionDuration=300,this.transitionStartTime=s.ticker.lastTime,s.ticker.add(this.boundResetAnimation)}onPointerMove(t){if(this.isGestureHijacked&&!this.isHijackPaused)if(t.pointerId===this.hijackedPointerId){const n=t.global.x-this.viewportBounds.x,o=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:n,y:o}),this.appService.emitter.emit("gestureHijackPointerMove",t);return}else return;if(!this.activeTouches.has(t.pointerId)||!this.isGestureValid)return;if(this.taintedPointers.size>0&&(this.initialTouchDistance!==null||this.initialScale!==null)){w.debug("[Interaction] 存在污染指针,阻止多点触摸手势移动");return}const i=t.global.x-this.viewportBounds.x,s=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:i,y:s}),this.activeTouches.size===2&&this.initialTouchDistance!==null&&this.initialScale!==null&&this.applyPinchZoom(),this.activeTouches.size===1&&(this.initialTouchDistance!==null||this.initialScale!==null)&&(this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.secondTouchId=null),this.activeTouches.size===1&&t.pointerId===this.firstTouchId&&this.dragStart!==null&&!this.taintedPointers.has(t.pointerId)&&this.applyPan(t)}applyPan(t){const i=this.appService,s=this.activeTouches.get(t.pointerId),n=i.appContainer,{x:o,y:a}=this.dragStart;n.position.set(n.x+s.x-o,n.y+s.y-a),this.dragStart={x:s.x,y:s.y}}applyPinchZoom(){const i=this.appService.appContainer,s=Array.from(this.activeTouches.values());if(s.length<2||!this.initialTouchDistance||!this.initialScale||!this.initialPinchCenter)return;const n=Q(s[0],s[1]),o={x:(s[0].x+s[1].x)/2,y:(s[0].y+s[1].y)/2},a={x:(o.x-i.position.x)/i.scale.x,y:(o.y-i.position.y)/i.scale.y},h=(n/this.initialTouchDistance)**this.zoomFactor,l=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.x*h)),c=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.y*h));i.scale.set(l,c);let d=o.x-a.x*l,u=o.y-a.y*c;const p=o.x-this.initialPinchCenter.x,f=o.y-this.initialPinchCenter.y;d+=p,u+=f,i.position.set(d,u),this.antiScale(l),this.initialPinchCenter=o}setInitialScaleAndDistance(t){const i=Array.from(this.activeTouches.values());i.length<2||(this.initialTouchDistance=Q(i[0],i[1]),this.initialScale={x:t.scale.x,y:t.scale.y},this.initialPinchCenter={x:(i[0].x+i[1].x)/2,y:(i[0].y+i[1].y)/2})}}const Oy=["forbiddenSweepZone","forbiddenMopZone","cleanZone"];function Ne(r){return Oy.includes(r)}const Ei={forbiddenSweepZone:{minSize:1,iconWrapperFillColor:"#ff4444",strokeColor:"#ff4444",strokeWidth:2,fillColor:"rgba(255, 68, 68, 0.1)",outlineOffset:16,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",showRotateButton:!0,textColor:"#ff4444",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},forbiddenMopZone:{minSize:1,iconWrapperFillColor:"#fe8a07",strokeColor:"#fe8a07",strokeWidth:2,fillColor:"rgba(254, 138, 7, 0.1)",outlineOffset:16,outlineStrokeColor:"#fe8a07",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(254, 138, 7, 0.05)",showRotateButton:!0,textColor:"#fe8a07",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},cleanZone:{minSize:1,iconWrapperFillColor:"#5d68fe",strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",outlineOffset:16,outlineStrokeColor:"#5d68fe",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(93, 104, 254, 0.05)",showRotateButton:!0,textColor:"#5d68fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}}},Gy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAaVBMVEUAAAA3yFI4x1E3yFM4x1Q3yFI4x1I3yFM3ylVAz1BEzF44yFI3ylI3yFI2yVNGzF9GzGA3yFM4x1JKzWJY0nB62or///83yFL///+b46hQz2jN8dRp1n1Ey13y+/SC3ZPm+Om06r6n57PA80FIAAAAF3RSTlMA3yC/QO9grzAQ75+PcFDfz8+Ar2AwEAVwkmAAAANrSURBVGje1ZtpktowEEZbkiVvmG1m+Ixg1vsfMqnUVPWPkLG6W+DKu8CrJ7UBG5nEnLrtsQ1h5yIwOLcP45ReerovXWoPuIlrJ0/3wad2wI/Ep1S/PLUoIjQ13X4cUEzcNJW0TYCQUEP9zNpHqr2DHLvajzCwUY9ZcjARJ13uAWaCl3u3DhWI4p0+opTrwk7LlnmHYi74mb2/z0V0nbGAKzZ3DoLgRTFcVzhWUeB9n+daI5Yg4aNEDKRlbwOIgsvE2C7ub5QFl4pjV2WeOZjFgtk2e1/fWGwz7yHiPAvE2P3buwFkwSIxjtaB5mAWW0bb80ALglms3uYARhAsEONwyzuBEQSzWPkJ1kcwgmCZ2Hn1RHOwRoxRPdEcrBLDKyeLg5ViZw5WivFsDFaLgyn4a1aL0RiC82wQB0Pwp0UMr76G82wSj+oPrU+beNCudJ5tYiTlaF2s4vZ7pSHjOpvEPF4JMi42Ma/1EwRwsFbMay2c6YtNzHPtIYCDTWJ08p88F6OYN7mFAA7WinmTHSRc6ogP0quYg5nzDV6xwIleIOEyF3EpmK4kCy7jWnA3M60SjCONAu97tWC0oq+mj2rBCLR/bDCL3SrB2JFbJRiOBhTyWjMYkVDKuWYwQMXBb1WCWRzXCR7IrRPsaPfYYBaHVYKxp7BKMAK1qwRjpOMqwZhou0owEnWrBOOFTljm/fw3X6Zg9EQHqMimYCf+Qc9iU3ArvktlsSUY029xBxVZG8x35gM0ZEtwJFJvcrYEPxGpNzlrg/lRhIeGbAhGT/q1zobgQKRf66wL5ue32rnO+uDY0zcj5GRVMB+UUI9XVgej0TwoZ7E6OKj+GmCxJdiSnC3BzDOkZFMw4yAk24L1g52twdprOSuvYfPpvGz80GISRGRV8EQ3OEBCVn8tGRc7K4Kjp5tsISArghvbQT0Wc7Buopkdisni4H2dQ0ZZEFz1eFPmYInXfpAsy4Jjxw7baGdZcFPtsGAWPgAooIlFYkFw3FY8EJrLg11X8whsLg52ksO3+2VxafDOk4TNorgw+CiQ8oiZcVsS4wPMHDxpmKIxN5GSfgMDo6/7OoroInq4Ojz/vy/h/FFvBGM2jJ7q0Zdmt4lq06enuNDapru91za1Djc5tKmj+9K/pGkMe+cGILpdCO1x251Iyi/g4vimU9Z1kQAAAABJRU5ErkJggg==",Wy="/assets/robot.CSiuukeH.png",Uy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAgH/fIL9gcEDvoBDPsJCPUDD8BuiCAAACCklEQVRo3u3Zza6bMBCG4Y/434aQzP1fbCt14SOZSac+zPQs/C4jwaME7ICN1Wq1Wq1W87VYd0dEe9gy7MqBvuQi9OusHp3PenqMPeiix31uZU5YiVTlB3PCk5jSTXChS9kTV2m3uG/mR0zEtt0Ce7qWKw873FK5livx+VvgRJdyIr6IW9ou5Ux8T2jKgYcrNOXMwwGq8qYM83IqLKws+8rB2jISA+vLkbmr9eUnM1mry819+GO0Hs8ZPdPx3NCzlB16pvKBnqkc0TOVPXqWskPPVH6iZyp79CzlHUM2csSQiewwZCNHDJnIAUM2cgOTosy35CUvecn/W37H83C/C8nbyT6FMhjqcnsE6pnJOdBFTVPu7FiEqvwOxJTAyeN1KrQf8Z/ck9gyZPLL0Z+cF7N+l6yX8rL3r7P0z8tb6jreLV7pLba77K01IWcR/MlNwIycxDsS/Er8lFwFrv/szslBAEeJK5fl8CFx5bIc3jn3AKblQwBzrmuYl5/fgD0wL78EcOEv8Lzsp6cPB3xDDhBUmZlyWpYenZgvPC8Lj27cfta8HCEq0Fi2eN7OzFjSlwMDq8u+MLC6nAYYsJGfw3aWlVyH6cNK3obpw0qOrrsehnLfN9299Zu7j4FKiD97zeBvcgKfqlwaDNukI1JT3mBalyNs26RzgZb8gnlxpxIyVqvVarVarb70C7CyrCEVukMsAAAAAElFTkSuQmCC",Hy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMA3yC/EECAYM+f73CQr1Awj6BvNXOp4gAAAlpJREFUaN7s1t1ugzAMhmE7TgghgdL5/u91ndBK11SYfFonTcpzXl7yR0Nd13Vd13Xd/+VWVk6OAD7PzCxDIMCHbtrTQfQbR2o1oD/2q97A6agPBjrPsd4BU+ZZgfLehQcd9acMdKEXF31yoVNYX0uewAewb9mRtfFkmaHZcroDy1qZfMMCweULtEGCHprJlrU2kiXpsRXanPbG9mrJZIjQzxY12O/O0BoVNbFHTiPDe3q32lu6NtnzZAv257Zmn32bGP9LaBgfsh9VwameoCHbXRVgjWtTc1eLEZ71FNfa1WCEIxS2u0wWAcOO9UiknblBphLdTViKTMb7W12mEyJv2cHTLpRRd0PjRLGjU0IecvDVoLLo5ko3IY0yx2prGF2Qi/PI8lVzsj/TvLbg3YMl3cp6oHgC2MddjsMS6Bddnj8NAmQRw/OlJgBZxFUfpNf3Dsme6P1hCqx3k5SloYpO9XA//SWlVPLi6G1Cdev8K/I407Z3fUBweFnQLi5+tmcGOQzCMBA0EBKSllz4/1/b+x6QVXmqVp4PrBDGeHfP7ei7JX9LmXM1nlKHIwUK+JaMQbfHw1C6RCoMTQ57iEUMAkOTIwDiEGsCoGddMYouthdiiNFnmBJtQHQNohkWV7YRYJrol6wZ+DCE05kjBawteK4d0VnAbEGPfF8cTAvhPnAcq0VTHTkWIKwdLySsBQkgDBxBsjHJ2W6qB9zYskDADVbGpSB+Zru+NF4TEHb3UtUi2aHhUqq3aPn9H4XV4MLDU06PWgyhbaCsNlDjrbmcz8wzkyRJkuRDXlF2skMkf3lIAAAAAElFTkSuQmCC",Vy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMA359AIL+QYBDvMIBwr6CPz1BvDk7raQAAAplJREFUaN7t2tuO3CAMBmDbQALkOOv3f9dKrVbWMiSQTHGqiu96oz94OGeh67qu67rP+JF2ZObdTQb0GMcscAQdnlgoRkfkdxM0ZyVXN5k4b4bGkPOChbb4yAAJreDgoSnkIwaaGpif6V6RjxAktJq8QGMr5zlobUTdYGFRsdTlZAIFRm+dKPewF2iw/CaCioVToMMojyYRdJdFMagsTuVaB9DilacP4RQqXf6REfSMCtuP8uRlQRE2GcTezLQ4t9D0isWFAu1fK+MWmIXbzOlIHuFA3JAZqfq9vgKnAr1nY6nQ23dFIlSZOAu/bNKecJ5L8qi/lSu2n9F2RSRTM97o6vj84PBv8eLMhnxqu5XL7n6D02QzE80WDpj0/f1HDZaq+YV/I59tLnFqLC6zRSSFzHdYs+Seutel05WIjk4Q3myBc3Y456qCY3Zfa8fNnTx1bq8q9fC+JBpCPgXnuCjYZFdNcu3WKFjm3TUJtoHbBn9PkGmpiYv228PYDaPNDjorT51wtzpXGIw/6vwEVcHTjRuOxUDK/5xAVi4yl6fq/P7BrjJl1sx3ePGAwHj4pnYmmqNsss+NFw8I5W1cXTJCkbmUK0a812Cx1vy9IUw3j3a43aXTDsvr+fYxxPRXxxu5ItZvWyFl1szOeIZKdkVmHGJ5yGX3+YP7OffYBvd6dFS01/TnADTLjPe5rXqU/CfH0zkZn2pQ9XZLmGSVVUPpAUFL+Dcu9J67wgygxPFDl6dqH1/KX/gsaHjpfvYRk9732/K2GzWKvfBDya7yEkohWKmHLfXXX206l/oXvvmp/wMxfAShKR/4CLQ1PBVsg26py92LoLWJ9abNcjJGUPB++CcPGtJoZ0CPmdzOzLjT6KHruq7ruo/8Ani9wIJR4hr/AAAAAElFTkSuQmCC",Ny="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAIN9A7xC/gGDPn3BQkK8wj6DdtO0oAAADPElEQVRo3u2Z2Y7rIAyGwWYnS8fv/7BHlTpi0gacsuTc8N1VivqDF2yMmEwmk8lk0h9nFJHfohT90HEDIlLG5f810C/GdZJFQwkrznnQH3yPXUtDB0CefkVHbLPuooguKAd649GoaylRUlb0TmjW/cQwlm7fc6RzHleEKdbHFeXYr3ypdK0wUA7D+LgttB3lceLI2nPLQHlAHEHqt2WkEu6KrU2V8EolzBXzqCphQ0XwyteyRthTkfXK11gj/EMJPmRVP2Ekuh5emk7RI5wc+FWCqEJC2dZ8NQliiDKy1kFRi/OUJ3LlxIgGtJRyX34YQzqmhtUjLZRCB5iFtSA/d12OaZCiEw5yB2KoOC5bolwyjU8/9HYq7NhS3I49OxAhoztKGVJo8brtxA8vhqH+TaBK6XJqaYViDBKOaUpHvBTDWNYQdaYHWMVtGEp4FPeBybtR3IBecH9ZHuiJt7pbGDkbjIcnxjwifgwKAF/S1kbsN3BR9M62vB/brrffDJ0T9DF3Vdfk2Q1l8U/lZUz6RCphj/cqKFsuQBqPcVgqot5uGaU4Mb+rW+rv4wl5EPbXGgdsaaZTGV4utHS7/a7VDZQn/QUc2xBtN2NMeESHuD/7YffwXzb3WrGWPtjFpl9lLFd4qIxyL49sf04uIJ6tzdJ+T8GwuD0tlgVa7qYqZvOPhxFWJWtJMU6YsgAymT9IeNUioa0hCDplAg/UmVrhySEDOo3EWEzVHNHLE900PtZADHwV27KlMGE+LjE7b+yloiR6nYsldz2+uMqI/A0bziqEqzi4uOjCfPLA4bmmBH7fBoRS+Gm2nvLJlEtKLFWR5fNprHoAZMsz562QJLYul86Tciu+t5hL7YsXl8BiaDHvHQ4aBk+xEFobF63SQv2F2eYXq3jvyeOubc0sbdMZNzB5gj/wcsUqvx0gKlIbZr3AnwwanXO76MXGZMowPPMoMgzmTXcYO3P+D2D0YLrqnuGHKXPlHhYxGFdxJRsrTFEMZaEcaqyfJdM3j0MVZjJDMUzjPIzI9HPD0IoRHoZlfDwOzzygD0MC/adKIf1tdYL3s9XiFuSriUyd5H3gap7iYFbUYjKZTCaTSRP/AEYn9FrTdrbUAAAAAElFTkSuQmCC",jy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMA3yCAEGC/759AcFDPkDCvoI+BJCYaAAADo0lEQVRo3u2a2barIAyGCSQMjpX3f9izzunqoYoxbhD3jd9d6/CXEDJA1cPDw8PDw0MNYZkhxgh26VHdBhoXv/Ba3UPn4obljlGjjzlww6BtjL+iTHEfaG1tGxkW1RaIHIyx2wuPiqG1MKimvCJLW/cKvHCvmmJZYVJN0Y4T7lRbJs6/zOY+6vXFY36dEO6HusSlQ5hybzXiHC9VOTMsb6ta2j49Cl5tatKHtnyyx715DvuZxE0/06W190InLmdkwpugLE6j1cfL2SV/LkrWvPtArxJ9/sOSsbhLMr24YNDxF7vioKZPxIiR9y1TnLl85PC8e+Fq/ouGrGOUlZGdR4w5tmDAnLUtNyYqTdYYDzH7k6yPixQqqGCZ0NgztjTFFZkXhJ3eMQwJDjKX1xgJm5sUpJU4KBkXJbpU920GjEMsF44iDpMvrAc8C1aqFI7jZjZJdI+53tRpyHbzVpyF2RFI0yS8J6S0l+a3orMyp2yd7rQ6+XPNFKeMJ4fs6WV9yNdRaZKYkrIbvDHeDkINLen6s/l4/hRa+LFCP67Ew490B1Rn0Z33Y8D1d2TZEXhBt5ik7WJ0b0MHD2BJTmgjqkvQeuX8Fo+bVwjqWug7emg20hhUFwMrR3P3yK6NO+7Xw85eYuSJusV7b/q88vb/PsN6Zj3VDxb7ZciaqGkbPnX3vsnBPJJW1WBnd8MQup32VGuNF83k7LjAaxrubwV7lGperfZttRX28GhosmDIyckV9X//62hSMpXVAO0fFoDv2+qOfDfttssXzQzDfH55kZjk+A7AmoD/t40+XmFKG/PEC9+3LNYSWw8P1nu/Woq+dsCv790Gn7olkVNjHqTHzfdHPCXsUNbVki6t3+ZOKYeKzXCT5+J1i15Z4ZKgS5ulNV01ySSsX8jCdlNh2Lvssl37mrZtYjcgcp+fsr28irMSPPzBeu/rWRaeyk61gNlL9OsNbB5XmCKIiS5u1ejV9m3TQWOtmbjQV0xxwvKGImaVCA4G6hSB7+hn9oqR45bMyL5+EPapK49acWCiFh55TXfBqbaG/WGFw5dOwIbLMmV/dFphmadEXVkZ9KE1jRADTGmpOWih/DRHBZvrSs5NIVWImbuzJ4AE2TlZgTbK/xHIOyiaP3V2UBdhzv7zJfR0RVcjL1Wj2kJ82muLFhJ9O4BPA20xvyWMrqBTaOnXoJpjCpZTO2Wj7oCA2RtuDhIwm7TtCaP9Kw6zCerh4eHh4eFq/gDsgRtLdqAVbwAAAABJRU5ErkJggg==",Yy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA3yBgv58Q74BwQK+PzzBQHgQBUQAAAqhJREFUaN7t2etu8yAMBmBO4ZgQ7v9qv2na+kpVEgKOqfQN/1vK+hRjE9KKGTNmzJgxYwY9VCrOKDE8lCxfIR+SYwjx3ki7le+Qz03iXvrW8hOe7tov9276QnlFJMO+lLuycoDpyyxvvBdyg1iocLk3CyzwU8u83ZKxwAhispdyS8YCYzC1m27JyMy6INn8MhbYCPxD5Jfj78tO4Q+MZZPRSTt6Hz3FJ6fXAr81v2aV0Umb/RmPoYwyOsm9rgfUGqNsfi+Ho2t8MmZ3NNwpLjmXQ0JjA+ORcXk/2Ws9s7yejlassrQY15BsuhwvbmyBUV6vBjvFJ9ujwRqNxiPXTxF6rIyxUg2WNW6Qg2Uke7CMZNvBssYZYayMZKvBsnLYOcfKHvU1WEYzD5YVmnmwjPoaK2OcEYNl/VR9GdUoy2dayhfZKOdHDiPWlWZ5wQDKhEurjJbypAl3yJ56l8Ijy9ZU21aSC9sgaS2yxuftCayWs439LInbl8eEW2QUdiBmOopGORP3TYc9qEVGrl2fm3GEapOR69wFa3RFq7zjQZpQW1k0y5mweSFfVjTLlnQQWVAhbTLqMlG6SYpWGWVt6HBdHgBXZCKM70tFh0wqrhVV3SLTq9pjq26QyX2M7Sf0fweoSXv1IrplRbw79cpOCFJZx145dcL6MtdaVeVAOHOdLlUosipb8imz7xkDbm+unTp6qSKTQp6usikccv1p15fCKWPKbn93eWVMuSR0c4TBJ0u8l1l1jDEsuMQp53IQQ+TwMdl/TE6fku32B+XlD1ZYdJ+SbRosI2K1xozgukte0lJXToCUiOaMTfvV2VPQw4bk3lGXtLo+9UbxSGS9Jim/p7KZVef6eTuIAQGZDNPlKMYF/TcZuiyVGB3Wy7ItSsyYMWPG/xD/AIrSnldXeREbAAAAAElFTkSuQmCC",Xy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEXRSTlMA5cgdcw7XjzlWrIFkup0rSDjdhakAAAKOSURBVGje7ZnbkqQgDEAj95va//+1W7u1NVGpHiEJPHEep0ZPJyYBERaLxWKxWPDRaXPphOnE7S8uwmTM9p9JZvT+YGAG6J1rRu9cM3rnmtE714zeuWb0zjWjl2vme5XaLhQYSLx5tUbz2Bl23r0Ad/MJg9Du4X2YnYYRoAS99R8HYGtFbbYgz1F7a/MB4pjKi2ZCO5MayZ2PYndDmqq+d4AHn2GlbdXvMZW6wOQLy7xVgAcxyvtt84aUERNr/5ZINeAx71Ujvcw1Jd/BoW0FMdJLUmn9gVo20eml9kWTXdo7VCvBAWbd6wNGAmmFfO3P3PXfHliEvlFolVR9paZEIx+hkEP3fbxMyBiws93j1TMCJswiIxFyrgN+R/FDto4yfCM/5HILmBByZJeWoe0LE5DQtIBBc3Nd6mHZ28uRmekAXQRmrt1PpgHpLC/eziMDUHMdWI/4A53gUlFYY8tCJ5aQLORg7J8UVhfj4oPREDunqD1047Eh+sF5yXkHWOIGOC2ROc9YSRSX4rwzJdYM4PTi3BkAmV4glrXfK/QlJlSLBPFq1m9m5CvR9y4WCOzUy60jFTV/zxar2UPdR6Qpu0TE0fbHodqP03PtaZcd/LdUTboqABGFR5ikl3mgEgknskXkYFF1n8hqxygtxPSemFnFChhRt5Pqd+8u9Ykgbk1m9CIBWPir+SXb+uo9RD8ofo9C/mNf2K5k2/gtPUh/nFfxSzFguNj2ImZUlypqjdqqk/gFhrgU9dV6bA88gLQZ5bvPxmSfcFJJejHbHRgQpLhmbwFRTtWmVRqEsbkpzRbkCelNmzDcmeoUYBwhf6syH2AsNvrKrXy0MAMd87Grf8r9yJ8TFovFYrFYcPgDfFESW2IpAiAAAAAASUVORK5CYII=",Zy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgN8g7xBgcECfj6+/zzBQ4swJLwAAAaxJREFUaN7t2lluwzAMBFBq9SLbnfuftigQYD5SZLGpaQPoXWBgiqQdKDYMwzAMw3Wp5dySyVX8yNXEAm5kycy9CabAXG0yc7XJzNUmM1ebzFxtMnPVyczVJzP33mQdVRD132EHHjqsk5TxUE7WRYp4InZJLhFPxWL+Gl7QjPoMkmycK0DCoToySNjabCxxgzW8YTE3E94yeW8s+THveFNUTrD/NB84IWkLTdG9o2ULrGSc4PCGXAESrpEZJO2vDact4gempH1gWsS7g5K2pWkRzzAV7dKiqm0t2k5WGpclbaWpOlRaWOuMy7J4e9ChPWKatGuL1vO/HvTdFeFg9whWfW3CxQj+z2f8Z8G7Y7B+gbRPWpkTHFTtrwiatZ9cVOyEXfuOoFXbW/QlPmLKuCgXO2XRVppmcaUpahc1VfG3LUWX1lLv62AXRO0JU3VoafEsN9cLReVdzCEuNAWcMH3ynQRfzPorr1X8vBTEuTRlvChP5ojzrP+bQAl4QSjmL214oiXrY34Yvc3Wz7xm/Couyfoq8xLvU6tJpBqWPUYgx72Fr2TDMAzDMFzxDf7xFoVjSQNhAAAAAElFTkSuQmCC",qy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgN8g72AQn0Bwv4+vMM9QQt7wKQAAArJJREFUaN7tmtHOpCAMhbUgoqL2/Z92s5t/0/wtkRE4c8V3eTKZMy2lRZlpMBgMBoNBLS55n5zSdvb7OUFZ+C9+yWpAZv5hedRwvszzfy1mNKCvuNhfA/XFO1tf63IoDeVrXZLSwL7iEkhpYF9xccoZ5mudvdJAvsL285Hbau0snEH3q1lr7Zz8yCmbSmmNOM+PeCelrbQmHHEBcvaT1OwciItQkFpQWj2JPyBlljmBNlJ+O5PSABspv6mc0mo5PStKpT0rDVVYtphIaajCElZJttJes/ErNkm2aP06VnmZqXWZL34JZXYCYXZwfjfvSmseSWWc1JdosETbxK5KA1W0bVZOaS8InqsgJyFXTciDK1kl5Jo2ErkaCbmmvnbmtpCj0tABS3iX0sABS3iL0kC9w4bnlIYqaRteUhpuDwvB5podqGnZVhWUhistYZevUdojgZtxmcQ5cKYlr1Fp6ExLXrVWwnMzPhcBsHsIpx0UHMFLLKfaTWm4tiUc8lZEtPLTQ6fqiu+qi7gDV2ZOXN8wpkwn8gVj7kLuq4YxZo2tsf+asdPaMxfQGN9AUqaBpK+1zMWcAfFDYqkYEpE7ECvGYmCh7YC7aw1f1lfmKEPg5wipLae1EnenJV60hj/t+SC1xaIVWbtkeqLXT22xS6ad0cpQj9E0m9FUZulwtp12rnixSO2lFa2GfEKW4GatwUMmeaugrgjAqxwlZ7akgXs5ZVKWel0olu9iFqWB35NLUklpyJuB8kUM/k4i+MI47DuYZRAkpWGdpUtE6wvINuiPGdvnt6lb5nXVhvuDgL3wOJRWS5g/SnOw82WeGnE7F0jOnhR30eqJj9Z7tDfs+zL1IR6es9DqJu3r1zj1I8SVrOvvwG7/TwtTb9wyrxcRs6crzbdexXs/7nMaDAaDwWDwnj/NQlzrb+J5OQAAAABJRU5ErkJggg==",Ky="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMAYN+fgL9AIO8QcFDPfzCQr49fa1RRAwAAAnlJREFUaN7t2NmumzAQgOHxvhEgnfd/17ZKDhMMSmobz+mR/F1Fraq/jAeywDAMwzAMwzB8N6EfHPBS+ORn4GRxY4CToLCED9jD4bYa8Q3hMOEfU+AMUxdRcYdXfFK8YYWbO2f4hi9uPGHqUpkrHDHziydsMednjrDz21/J7ZXrH3YvNXo9he5h83qV83b1qneYFnren3fsGxYUyjfc9gzTYml40jT6juFtmZaTp6fpFqYDlgE2QdL0O4UdTfV0/t71CdOgE+wkGnaXcKTFyiw07B5hQ3+Sm76GHa4P06QdkPyY79eFJ/iij4M+HoO7LGyy+2YCcjJs1SEMTk2TDh++e4Qrw5/R6mnusKPFZg3TJVveMJ2y4g3Tfe6Zw/TgdLxheq9IvGHaa8EdBnzQPyEsVvO0qr8Mhb3au7sLR33HAvLTjZwKtqKIhXORPukXPHMKxA/PTOgV1u/nNsE/c3oTxVGye+79oizAy3k6YlaKlp7VDWsemLN9ECf0UTjrVl0wlklnXbrgXrfTcW+dwbpfJBYsY7Kfjz1Wfjk3WCjQdkSDxJd1A5ay9NBo+Z0tYSlNO9XQBYWlTPb9sfR86Z8X8ie34RqgkMNyNt9KaWs+X5WL++0wAiqsWG79+k9LxElbqCKxnKeDClBpxhoOmkWsEaGZwRoKmmEVCa0sEtZDXrCOgEYT1lmgTUDCesgJa4XWT8PEKLXuLkotBonX2iNJ0ETu98Vm96rYD1dedsgOq8MGWogsnLK3IJuFLzvkNQuL7AOOexO20MBkYV0QTpeNWh/DkIWve5uIk5TSPCQAoV7cAOD5ctFaR4CotXhIMwzDMAzDMAz/j98ceskaOhA77AAAAABJRU5ErkJggg==",$y="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAYJ+Av0Df7xBwIJBQz68wzE7woAAAAVNJREFUaN7t2d1ugzAMhmHHSUj4Kfj+r3asmxrIClKYlwzpe8446XuQgi0gAAAAgNuIxj4ZqmsI8s1RVSwvnmpyKWzpBMIII4zwWdjQCYQRRhhhhBE+hDDCCCOMMHX/IOzpxG3D0fJeSGHHe0b35VKBntSMUqLTvHlKhFZhGUiLsVu9ecNvENxP9MlkfurtzkRaeml0I89SJpKSIGUM6fBSaCQdVgo99J6YTQ45SjFPGiYpNtaexrofox5SLGgc8iDS5pCNJFX3LpYLnOIKXXvvWuSSRWMktjnkWS5hjZHY5JC9XDTUHYmJqTsSE1YciczcycbMHCRxlvU2vin7Kc4eyJ0klrzeMsBZ2GVhdxw2eiPxTXg+Do8KIzGFuyzMWVhr41vycMjCYxZW+3e5LCxZ2B6Gw0S/Mbjuk3tar3lrDfvXhbWeol2ZL5EAAAAAAOCvfQALwYE8tktFzgAAAABJRU5ErkJggg==",Qy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAANlBMVEUAAAD////////////////////////////////////////////////////////////////////xY8b8AAAAEnRSTlMA5VZzrI86yR0O12VHK4GeumR+Sig+AAAB1ElEQVRo3u3aYW+jMAyAYTuExEkItP//z550VHCVOGMzl02an6+b+i4hIRQNnHPOOed+KkoruNmAL7nAnQg3M9wp7OEMDA972MMe9vDvDkdgeNjDHvawhz38Xx72sIc9/H1hasNfLazGPZzDu8R8StG/XFIY4FCPFfERlC+XVBJ3cWZNeNKFA/u3N91S+upcx+2ntShGHDfLeGB4dzTVbxNyI2ImhGEbbnCnvIc7qNAUJFKBQ8+tu2iqZcgoNRIAs6wzKbpJluU/el7v7PSJbcy/tKcwtASqrtZotBP0ikG3ZNSbDMIjXtBOBkPCiba9yBQR61yAF9F6xJQlT0wJLyHBtZvsrzA+gVFFe66iXg3AwZdoPdO5y1bNDIym71YC3iQ5LGZ9OMielWs33kxZ9u2gFetdPIOJaH2z7LGKwos+fLqwPnRCzGePfLIRN9vFlcT/UjChWuKeZcSLr+jDD2ZIHbFOadXLyUVRG4twl0SyvXVhDvxZvAvW53FdhjCld+s8lLDEl4qIXb2hDBYdPdivMyUbh3eF39S9Xm6N/+qHKxe48jZm64Oq8mGgi+Vwfi7H01+5YuBFyVMDjfgJA5yj8LDO1qf8ZYSlVMA555xz7rv9AZlKFXj5dr43AAAAAElFTkSuQmCC",Jy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAQCBggN+/nxDvcM8wkFCwoI+ASc+UAAACfUlEQVRo3u3Z7XajIBCAYWAAAVET7v9iN6my6CR0lmo+Np3nV3vSkzcKQmkFY4wxxhhj78EFfQVOPJDr05cgCpNmVjyQuo3IlEVRPDUsxePEV4UlhzmcfVy44zCHPzkMnx2GV4eHV4X1W4WVKDjMYQ6/fRh+TTiswnJ2TtkoVw7+FLqEVfqeFjecNsl3amc4JoKrnOq93BeWVFgKpEsz7/bdav0lwOzUmw1rI77glIU94XblFnXPDZdJMfw8HBTiBM3n8Eh+xuu4pYycw6MttKovAkZQhku3t4su0xlk8kJcwug5rtwvq8TBZKLKSneDFIeLxIN8BJVFuQCAgMLTkUX7zagPKGzEsxhqtc5gsnBk+ITCorhdtI07aNTLg0qtjJBnfRXo2blbTHZhspIZ8bTua5e0zAVLjBmtLMAeff/DsGrIzu9j18tHlaQ2GmgK+zzI9M6niU82pSYyXwv9G6cKQRLbWIMghCuXXxcVuebT8ArZ5xldv1ibB5eYfG2DPJBXbBIZ7lMjtdqSVf02Do76T08rWA2yrocjeUxq1ZU1p/r2LiWjZ6BqK3krs94nPNSeYWqRMamZ2+wT5jxGtTHfyd7MKuWY2o3EzECTqL+7YwcyQ+8T2O30Dbdhm9rZO+tsDwVu5HuNT1j7Bpk+7MC9M8VIJKh9IvOySvtkHPEwGV++vOjt3+9td+VX+4RvmY31hykot3n6DFpOYfPTU9PksPG2q9AQDShscbjsDU7V0QdMQOEJhU8ofNhfnCYUtv8YDnvDHoV7FB62r/uyT+wjEwobFNbb1w87LgW8geBlbzTLmV2Kq+XcBiB3ht0IMMqL6ARjjDHGGGP/qT+Hf7FSTq027wAAAABJRU5ErkJggg==",tx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA378ggBAw78+fYECPcFCv86Xy/gAAAk9JREFUaN7t2WlPwzAMgGGnjnP2yP//tWgg0GavaVCOCpH3K1WfHWnjMpjNZrPZbDabzf5cZg8BYXTGq/TIBRgYBpd+8jAoCkt6aYURRZ9EBmQdvliZh77tKr3PQdd0Og16FtNNsL8LVv8OXu6C17tgfJYWNQ6G7ZtRHgEHwhDVJxsIAMAxuG8m7ObdWoMR/TkYg9Y7Qb6o143awto+DrQRMqFKj1ZqB9P34Raz7leOqmG5w6hTmRybLKpguaUqKtj+Yj0sb7dHwZyxNoKP9JyGN4X03NIFThuIjE3PHY3gcDUPI9vtdSOY2HkVigX9kqUy2MJVaJlM2XkuQBms4DLD5CM3OG/QDJayPl8BGlrCYOTbyr+keji/tOWCroelLJc2Oe42h6VMckGv0AOG7VVxyBe0hz4wc0QeKuAK2UEFXCE76gmDrnElXC8rhB6wlKXbHYY143aF4eCuRRgCo7yAx8B0F6w5rMbAxiaeHgGjTTLdB5ajrJS7wNKVbV1g6cpCF1i6sr0HLF2ZNV1gOdmpsDsm94GJMSieqhQ2gqXLH/uRyx1g//byMYnJzWF/csPYuNwY9qf7kWYyNYV1ZrJb+d8awjr7eTomN4Kla03+vuJbwVreG/Py2gaO1/uQ4RtGE/j6Z195UTWBXyeOpejrwBZw2WXq28Ou6MZEruhfbAf78HKFso0PVckFFX4zp6my8QZtyQ17+cWDDzr+EvMDtzL5k5UPaaTt43w7XGQ+347HgpOlA6EkMtEUHbdHhMtMjASz2Ww2m81ms9mIPgCfVZZTXlzW2AAAAABJRU5ErkJggg==",ex="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgCDf7xAwz0BwYL+fj1CvJC6qIwAAAtFJREFUaN7tmUlu7CAURelbg9n/av/kKyX7GnjGppRInGmED/AaoMIWi8VisVgsFou/gnE5hOAE+yIi7Lb8YLesGTLBassZFR2bjNjKNXPVmpc6cV64hSwtlGdz4KUHZ8BUL5rne+ebfaERXva6QkSKd+tIQvHw7FxIEczb1ABv4lPaqhx5dcnHj++Hb4s4b8m5nbnpGOUXxYcGnRiwH8xuzk5L3eul/jWvgPU0N3t/TRzKh9ifWpzStTghGAzJPAXd0TjOvatWsWGXxPJB4ZbJ/rEpIp7qHD7azutq+2mYtb3oubmfOBuuGL1FiWbFYqTkz0jTWzHGWCvCEcKvDzhh/4/LrIItHyyk5qkLIKFaFTyqYrkgtZit1VATu8CogZ6LdeybJxvvXiLl6P3EtO8QHhN66Hjrl7E9mQ0m9Ogh45oTFrJ5O+IP7osbTBjM1dQO4B1MLaVZ17xDQoOXRIR66Zl57Q9p/MotGMXsbyc0IlR/KG6pgeToeBELC6aYpcCEtvqON0HwiGb3zOuhUKrkAox7HUSuQXjv0SUU5CrF/Nwrbyaln+ClBYm/4dUSBg+a1T2vhcGDZmVu7bOFwaNmdy++w5NW5wKe40XkSRy/5HWYWjO9OPbD/kXv0HFo1HPvyEXLPfBq8NLNAZrdvZ4zavYPvaNm/qS5x9LCT/NuJ1Hey4HwHW/ALchTvAk2ltwQtideDi8Gmhm9asCLTdLAYrql4B94rSaXJ5ZCGPdKQU+chPeVxK/wWTebDkYytcyu3CCd1KGzV7bxbI/lDrb5cuF4YlWHa7IT16RV9endf52bm+JYD2FEL35fQIiJSIhg5znpK/ddcVOsQEz7ERVDJcdXvHdbIkbEQEUQSZViCrRfNCJuRR9s41u9kDC18XnvFX2j3bHLR/A2zSqzAzpzGh/tYdKy29xFhH9cPsZkxwho5wRbLBaLxWKxWCx+I/8ANf2/u2NhQhAAAAAASUVORK5CYII=",ix="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAIVBMVEUAAAD////////////////////////////////////////PIev5AAAACnRSTlMA7zC/QN+fgCAQTQcGNgAAAMRJREFUOMvd0jEKwkAURdFPBEkdsLFKyAYk2UIqO1uXYOUSXIJbCCiCqzTDe8Ei3qmDrz3caebH+7tHLLZ6fvZpHfFYhwaPV8jOiZ0zn5QTd3vlwIdGOXGhnDiUIytHdk7sHNk5sXNi53dg5a9lPQxDHc6vQUu5YlqjmFbGv++W1W2V5ctY5+L534vpt37E89lspr9eaKmzIfbVIfvqzJSbKTdjLsZczLkYczHmrZjyXWLKtaDcTLkZc+K2TzsTH/Xu2vkDlC8AMDsTJN8AAAAASUVORK5CYII=",sx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAG1BMVEUAAAD////////////////////////////////rTT7CAAAACHRSTlMAgL9g36+fQGFJCmkAAADFSURBVDjL3dS7DcJAEIRhniJ1SIgEBSAqQFRARguEJBTgxJqy7cDeX7ZGmtwX+fbu8+t2d7Pqsb99lqHH617XX6mZr26lrrCkdr58ljTxnTRxsHQZJwfBwXqWhoP1rmfDwfrVFA5mO3Ozm4DHRCwmZDExjwlaDPcYDrYcbDnYcrDlYM/BnoM9b+Jyvnl+tfxh+beA4elIwoGmdAjJlFIxJHIqg1hEuQRzAZ9c+dN6jmB4bj2hcYW2F5omLfe6PMH/0HLXPHpWgenjpk040QAAAABJRU5ErkJggg==",nx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAMAAAANIilAAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA32CAIEAQ779wz4+fUDCvilaH/gAAAZdJREFUSMftltuOxCAIhsWiVqst7/+0m5jsEIUqm72d/64M33BSWvfVP9WgzKZ4wqRyayhWojwbMwlVhfVAdAnrIeHmVK/TGWAvfOJDRAn3cGqSLURc8AJOSrcqcdIrGBT26r8EFd4FbsSBN2kDzgUnnsAOJohKwZSiBZ6PQpBG+5xP6gpWGGRgiksYDhGax0TFrWBAVzn03GqqK7igcwgces46L+DSS/IfuHDWopBBvrNdHBrdaAnuRdlH/p8xzfj7fLutkLr4JN+cyV7P535MqQQDzHnff4eRRu+DZ2dQ4Y4N8GGBK3sPa/mxwJnhoWawwG2EAxlnNXpnbqC5Yzg5Jz41VpgHe3LeVpg3hxebLV7HDgZ+Hi1YiNqmYZX339B/hNXlnpvrOTR2dgFfYlnCh66dXcCPGIwnThxoCSd5A4FYSzhwYLZZ4UO7+pcRTupRBBMciLQPFwQLfL68HTDt4fD2Jr4N8Ply91oSaeuBS9SO7BaOoLMHGeCq15tJwppTyk6qGuBG9KC6Hk6Y9ERRGXj31f/0A2zyPsVxnMRtAAAAAElFTkSuQmCC",rx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAJFBMVEUAAAD///////////////////////////////////////////+0CY3pAAAAC3RSTlMAYIDvMBDPv4+fcLUOqFYAAAEWSURBVDjLvZW9isJAFIXHkLCw1S5ss9ikt00h2ETyAqn0CaxsbHwCSyvfwN7KEUQ8L2dilJPE4Z5GPFXgy5efOzP3um6i1FkZeYtGQGrJgDflSrfkSjdk6kGZekimHpTHwIZ6Xz5Ngb9JWB8C2QD4KYBrAM9wymscT7AI4GSZuRq74ly6QOZ5g+O1C6fBzHvwd9nHSfu20aKPZ75dsHPZxckSKWVg1cVfgG9XO+/iuK485az/7uKpUyamTpmYOmVi6o18+X3kH9g9r7d3PYKRtJKNeIHFw8WniR8TZRFFFUsiFlRsB7mZ9FZ0g9eNvP/AIdIHWB9/3TwObD1H0bhE2xNNU7Rc0bAN3ethoUeNHlR6zIkheQMcOzccp+sDkgAAAABJRU5ErkJggg==",ox="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGBAMAAACDAP+3AAAALVBMVEUAAAD///////////////////////////////////////////////////////+hSKubAAAADnRSTlMAEN+AIO/Pn2AwUI+/cOwbbqMAAAEBSURBVEjH7dJBTsJAFMbxj0Ci4GZCjF7AdeMJTHXjBdy4afQCRC9gOEHjxj1H8AiewCOwKGmBEL4zwLSEB0x5bweb/nZdzL+vb4pG43w6MSy3LEbQtQbkErobkpkzM+TIzJBDaL5odi7o5c7OzKC4Yun+4DseseOB3gR7elH+KU/t2kxKZk7PtBKSf3qmx7WFmsHl9qBkfhF05GRKbxrcYERvKE1+4NCY3vxoRmbI4m3mHZVws3fAD73CHb3ozHUTyQQG9N4kU6NfjZps3lmrE7G0mb3eEyuSCXWNTCnVM6W2lZE98sX+0/NvaP659gpVX83IHmcwPCdFDMu1Q6NxeivVcQUNhbcOPQAAAABJRU5ErkJggg==",ax="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAUCAYAAACTQC2+AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEYSURBVEiJpZVRccMwEERvgsAMagiBYAiBEAgpAzEwBEEIhEAQBKUIUgavH4pnXM2tJTv7qdm7XelWkpkAMAIJeAF3YHA4AxApeACj6qdEBiDzH8HhhYqTPUNmZiehNZtZ7e7L4dVr47u2DcflgovDvQpuaIlMolC6BOZeY0vBSBl8jdRxCtmpy9ThoAw/dZG1SSU2rIlRbH9qiax6nEWPeSHcBOHWK7ISU0EKhj+Xvoj6Yl448snMfo823YFhe7s70RyD2C7AeYeIuoNxTfLeNvg83on67dsidwh5d/AlTQIXsf0jT9DUcqfCcd1hLLROYWkQneJ4lGem/6NvM3tWaz8Or157vmv7QQnHY3GJ/srvlMEnNhL6B6cIZVSNSYqvAAAAAElFTkSuQmCC",hx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAaCAYAAAC3g3x9AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEPSURBVEiJ7ZVdbcMwFIWPGYRBA6EMFgYthEEIBDPIGGQMuiGohiAQrCEIhG8PSdTKtW/srY87Ul6i60++5/5Y2hHQAzMQAL8Xb4EaYORRA9DUwlpgSsA2BaAthXVrinsKwHkP5gtAsXyNX5uG9ctpZPOVxa9gBPeFGQSgFXnzA9AlsjkaF7iKdAEmjCpidIGAS/RvKGqHBRz7OjoWM3tJB0mfzrmPUuAKfZX0Iulb0lvN2X+lFRflyzn3XgNgmeeTtqLwOHJ/aZuLMh0fftnYs4CrAT0mYB350ZtKloO/g/VG3C0rnrm+onSes2Aj6Bnbgk0zifVmVdGCmustB21I+zZS+4xGYL/edubuOcjpBwCFxkKYDWbkAAAAAElFTkSuQmCC",lx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAMAAAC8EZcfAAAAqFBMVEUAAAD////////////////////////////////////////////////09P////+vt//Kzv/f4f/z9P/y8//o6P/HzP/////z9P/i5P/////v8f/t7//k5P/m6P/w8v/q6//o6f/S1f/X2v9gbP/b3/+vs/+Vmv9daP7///+us/+aof7r7P9xe/719f+Fjv7W2f9ncv7Cxv+4vf+kqv57hP7h4/+Ql/7M0P8zzBhqAAAAJ3RSTlMAn4Ag3xC/70Bgz3Aw748gMJ/iv3BeUM+/r5+PYHCvgN+FQBWPQDAOL4ZsAAAGb0lEQVR42s2b2XbaMBCGbWzMvmUpJXuatpJteQXM+79ZOTZkKAeiGdlW9F9zlM+zSTNSrEY0vx9NV97SnUScRxP3zVtNn58cywjNn+xhxC8qunl4nlvfKWfwMuESTeznrvUtcu48jpQ30s84uOUURd5AJ6OzcM/+fpL7QRxvhGBMiE1cBOtsdxaZvY4uRMfmp0r8OGUXlRZ+8t9nLP5aJNXHC7MC4K5A5iEH/Wy79swWJ3T+hqEk/BNvP7bq6DuIvV3BCIoTiMU7qy05N+BawYhKwYxe32pFnU+8gIGUEH9bzct54wf5DKSKuGw8WZ6Oexo4VwkxO0bifTvuDQWrqfhYdaZNFpclr5SnrLbS/Jgr3cbCz8UkB92IN06TfBB99ZXueCm3kdPieALJ25j8w2Fx3ABfj5cKWKMKoiqZaxPOK75wwxrW5kA4r8k3gerSsERYedmplx/A1zzhtsqUGoTdAx9UvzZs6M6UAT2K/dQJPVW+3+3yAWFHje++aiTo+UvP5XulDbhK4Ji1qlg9UTz6/qG+p9zS+UZVT8laV6IWhk6PkiD1EyWiOvkWArBtFVXHrJLBOdOi6gT7RN9CopS1LnCyS29BAqZJATVPuj3IYC3aQZ4QDCiYNonyDy5oBvSZRmVlUfugGJCeIfVN+E4xYMa0KiMk8kh3BIIJB/hTwk6t4d3ExUaom/AGw/dLbZMT6ySE8WGQqpkQ0+M9qtTAYMvPlKxThVPNAwKwTJE16eP9kF9QtKZ9IzJN+uXiKWXlkF9RGJN9LJ8OT6kezjmoN/RWQ5eDcup+Z+M8XFC674OG0/6nF6afkFvRsI//0HYRcXSv7ZzNnGzOqVOdssP7JQF8JXlYRIB3rr53yBVBymPZLcpPSg6nB/uNrtyI9mid/xrT3/UoVTqRNLXjKhR3lB55Ihm3lU4h5a/rSKdjPiUIvx5pPhNCMK4qi4OY3wmCR0byKugjl8NU1nE1fydMGabydjggGHCEax9wUV3Ih3HlwGiDMyBy7yydvMXNuqRHrg/8RhwfHCzVAG/CtPzphyyJQ1wKgzswJsybSeMf+CSO4IiOMeEWHzY/ZGtleA93MYAOvtJksq9+RwOuwcO4JidAx82r7Ljvo791hGwT0UHoy2Y0CzTg7jxaZJG9QwHKJiA22hlbyDdcF5GgA8duBLA8aDk4QAddvILmAMvMtJAqf6wZMIIqo82CkCT0GKwPCDH4ULfMQM3va8/iTht1EPan+nXwmbbUCgdo0z77TvatO/Re3CMMRONG9uI++uCRcnQQ9vGN2FbWus9gLdwkBe3hDH+Gm1lfqPyFwF++ONjTVoEecEXWV1riO5wQaUIPP+0p5GPgFX7y4eNM2OewJMorL/ImMaNcATqYlzchYVTxKC/6W8Kshw8lDqZcS4byQ+aMMqkI5S8pp5SHBSmmzxlCymGnl/bVJbtT0vwtwFyVPFCuwTaH4a9zLf5oL29yzEXEEwQhOgy5O7i4b5Z8hCuNEF4G1A5CqDWVhv2LeKRrXQEhKA3CnPKSspLXOWEcd454UcGw8nGt9h3ULXSmHNSzp53BoDNdlXSQHxQPvyK3zpihlSb8qjJBfcU1s6Rakq+z4yuICeA1OS4bgI9rISYxoyiN4DQtyeNI5c2M8P9j3AVC5e1Mr4s+YIYq1+3B2s8yf13EjK4QTjIyzfU9O6JPlOE6LGRalVBe297rNiEYEKk3zSYEA5pqwjUYECcXtikdSiOKASGRM6ZJOcmAUAv5hmlRrPCI1Znoy5N0W24iM4ukd32vbHO4NqXI1ZHJMENZWlQ5ETzZaFMiUv3fpleuIwzTLTiYqhcdYZhBBpM1gycbrcmv9U9DDm+TEPiisaWoEbHzpm/BqgEI07g2i03A4Ym8qh6BsC2+hVVLD0DYDp9t1dQtELbBd2vVVXcIhM3zDbuWmYQnfEYSnvAZSSjjoxPaB0JD+fY6EppUXy4TmsoHhKbyAaGpfEBoKt8noV/zfAV8xhH653yGEV7gM4rwIp9BhFf4jCG8ymcI4Rd8RhB+yWcAoYTv2wl18wGhqXxAaCofEJrKB4Sm8gGhqXxAaCqfZXWkhD5tftUaoal8QGgqHxCaygeEpvIBoal8QGgqHxCaygeEpvIBoal8QGgqHxCaygeEpvIBoal8n4TG8u0JDefbExrOtyc0nG9PaDjfntBwvj1h03z/ABD9FUIpArU6AAAAAElFTkSuQmCC",cx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAACMCAMAAACZHrEMAAAAeFBMVEUAAAD///////////////////////////////////////////////////////////////////+Kior///+ZmZmRkZHw8PDFxcXT09Onp6fq6uq2trb4+Pjx8fG9vb2goKDi4uLMzMyvr6/39/fg4OC+vr7b29uYmJjRFtxTAAAAEnRSTlMAIN+A778QcGDPMJ9AkKCwUH/CxK06AAAEhUlEQVR42u2biZLaMAyGc5BACEcrxXEOjgW2u+//hjUsRdPJDLEti810+j3BP9Kvw04ccVgu0nKbJDM0zJIiK9Mfy+gbyBfr4iZiQLb+kUcvJP6Z4VOyeRy9hHyeoQXFQl7PqpyhLaWsnNXfQakb3Z8/PxUY1Oex7fVH93e6VhEhJ2X3fmgVEER7eEcik4lOXpKSxgh5xrnZiSZr/vDK+0HBKKp/JCyZR2GJs4eUFixpm4ecWCAsJMWO6o+cWbjg5Gv8Yt+CI+c9frEOlaLiblsNHuigqVomeKOrwItqH07N8m6XExB+wZmxJ/rinqIeGPQXvLEIomVPKWKkiqlmSVrCqGFkKv7yS6eAjeqYvokT0hJADa+mSEtANYXfTrr+8ouCQKi9fy+eD7wbyMVzX/PuKghIdbmZOPY0TA9B6fFK5pckDYE5UaJcq3oPweluiXKrqBKvkGEC26Z0CoxMkmiEuxxhMkpScPaOHl7hlTOI0FJo7APTgBBvTqGJ7d0rH5pSLjAUmtIlMC2I0VKvsVs1OxDkzb4NFzSUhDiQhW2ytFMgiLq14dh2RDYgSoOG1LbJnEGU1jJPOV4BOShP4/X0Aw3vIAfV08JuDT+AMAe71TyT6nhD0xTRGGQZSdStCVudrjsQp6aT94h/P0CcxsbBKe2bomibtreRG0zDE1Q5iWICOKNhazOyjyBOhYbE5lT7CTbIi5mhQYEo1Ggm0fMMeOW/mH9BzKSqKbHvM/I7xFZ+A6YOnE1i0fuz6k3goHLlgw6VI1czNYjT2dxE5PiSeaDQ6qxSSDuY/FvYHVVOIExD/h01zQ6Eqe0ur/LZC3a9Iy0Qz8lkV3LK0tbq4ko+T/X9oDKFPDlc6m3Ez3GN/XXnSrrvVS4XwYWwhTXtMuOk/CtGvn3JwqJ7RO/2oTIVHd21vX1pdPcgQo90CWzFRig0FBjnz4K/wPDtgTGhkSoodQ/MJL6YatfAUK+pIDAVugaGek0DgWn8/qFJJb7HHZHuFV3IE4Eb4Zqmkhur8OWt/X9Jy4J6mP6DYPyL9hbQvVTW7qRhE9WTe30oQiaqGrjXx8NvE0jSlXW4RB0YSaJmEyZR1eWRpO9PVE1J4ibqBEw0JYlDEWJGtchPErW+WrEMQ0liMufb5oN+FeSy5da3HmxUnPrm2eY4+CuZX991xTLMMuLDt01HVR2GzL/baBxcmbFt42viw8AwoR6J7I5+RxOMo6DMvUxc1SMdhjWkOiVkXnkTn3DsEwHzfYZ2LSQyb3gTY++2gM/iSIQFupRUdSHzSpA6lFRVk3ll2KDtcqNqepgiRF7YTqlOqpCGJdWMFrVcIQ0fg+mARc1/JqfHteAyEmeBY+2mRypqaVJ8voYekYpanvRp8ztePLTw2031pNltopdRkJqBlkGDkSb/S81QS5JHXPjvPVXNaTB8NQFfkfLf5QIQTC38XashLQ37jThfzRS0PAZDQ1rYr9X5ak60NLC18NVoAM0YjoGHptY+w1FKzSS0GDUT0mLUTEiLUTMhLUbNhLQYNRPSYtSE0fIbFg3xTdS8kE8AAAAASUVORK5CYII=",dx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAACMCAMAAACZHrEMAAAAdVBMVEUAAAD/////////////////////////////////////////////////////////////////RET/////W1v/6Oj/oqL/ubn/c3P/UFD/8/P/3Nz/ior/0ND/5+f/ra3/f3//T0//lZX/lpb/Z2f/xcX/9PT/aGguCk8uAAAAEXRSTlMAIN+A77+fEHDPMEBgkLBfUGJvpxAAAASDSURBVHja7ZyJkpswDIa5Cbla2WAI5Gqyu+//iCUhjaYzmdhGEst0+j3BP9KvwyZOQGG5jrNtFCWqJ4mKNIt/LoNvIF9vikS9It38zIMJCeNUvSVdhMEk5ItUOVCs5fWsskS5ksnKWf0dlNJU3UnrM/Sc9bXuqo/273StAkROym5/qc/wivqyV0gqE508QyUGhbzkZHaiyVo8vbK/nMHKuXsmLFoEvITpU0oNjtTmKScUCAtKcUP/kZPwBSffqIFDDZ6cDmpgw5Wi4mHbCkZQsaZqGak7rYZR6AOfmuXDLke4QwhOQp7oPx4p6oBA9+g6P1i0HDSQ0AcGNUvUwqOGkKlw8Et7BjJNS/RNGKEWBjW0mkItjGqKcTvpZvDLGZhoDuN78eKNd0kuXow1704DI3p3N3E40jAdsNIN29+4JFXAzBET5VvVB2CnvSfKr6KGfRcNw2ybzCswMknCEe5zhEkxSewcPD28UjdOIEKNoXEPjAEh9l6hCd3dKx+aTC4wGJrMJzA1iFF79Jq16mlBkL17Gy5wKAlxQQu7ZGnXgCDNvQ2HriPSgChG9cSuTeYEotSOecrVDZAD82Svp5+qZw9yYD2t3dbwXyDMxW01T107Ht00RWADLSNJc2/CTqfrFsQp8eRt8e8HiGNcHBzjvilK5dL2MvfBRD9BZbMoJoCT6tm6jOwriKNVT+RyqtXggryYRPU0IAo2mln0vB5147+Yf0HMrKopcu8z8jvEVn4Dxg6czmLR+7PqzeCgcuMDD5WWq5kSxGldbiJyNck8aJTTWaWYxMEnLCarg48gjEH/Wk2zA2FKt8urPJlg17sOC4SddIKV3AxLp531BHkqHweVOeTJ41IvEz/HGffrzpV039M+F8GFsIUr3GXsxPQrRrp90cKie0Tn96EyFh3dpbt9cXR3IEKn8BLYiYwaGnpgkFA9XfPtgelDI1VQzSMws/hiWvkGBnuNBma08g0M9hoDzJhxv6GJJb7HXRXeK/qQRwI3wqVlKlmG9y9+966DEaTcHtaf6F5fwoT5a4/BsvYn5k1Uh+4dQ8GZKG1xr5uH9zNI0o0NX6IuhCRhs+FJlP58Jun7E1VikqiJOgKRCpNEoeCYUbWiJwlbX9mQDINJIrKg2+YDfypIZUut7wo3KjJ5RLPNF9sv/bG+S00yzDKgQ7dNi1XNQ4rdZpxhtgEfeTTWxJc3hqE9Etld/Y8m2GH4WIwysS4tHYY0pNpGyLzyJj4q/ETASxj5nr8ri3npJlad3wKehIEIa+VTUvoTzStB7FFSukTzypAp1+WmGbRsAjnywnVKta6FRC8pYy1qj0IiPwarGIua/kyusmtRy0CctbK1m05hUUsTq/dr6JfCopYnftv8vj4n1ILtRr9pdlkwGQWqea2lCKYjRzUvtUTT/mdG9HLXakpKg6GrYXxFSn+XC4AQtdB3LYNaDPmNOF3NHLQ8B4NBLR6X8VJqjrg0kLXQ1VQAFWE4Mg/NqiIMR3Y1s9DSq5mRll7NjLT0amakpVczIy29mhlp6dXwaPkN5W7InuRCZwAAAAAASUVORK5CYII=",ux="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAPElEQVR4AezXMQoAMAgDwND//9n2B51EhxNcQ7gtJ7NX0wWiAAECBAgQIECAAAECBAgQWCFQb6G3/Sc7FwAA//+f4+OPAAAABklEQVQDAI04ICFaxIVcAAAAAElFTkSuQmCC",px="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwAgMAAACTeJdcAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAiSURBVDjLY2hgwA5GJUYliJBYhQMwOAwWF45KDEUJXOkKAA7xNyG+w0wTAAAAAElFTkSuQmCC",fx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAABgAgMAAAAm4hnjAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAjSURBVDjLY1gFBg4MQMAExGBqlDPKoS0HkuoGjXNGOcOVAwDBxwm1N3ts8gAAAABJRU5ErkJggg==",gx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAOklEQVR4AeySSQoAMAgDp/3/n9v4ABc8eRCSUyAwmgu8xIp9WYGfFpItgBk3OPpW5HAnMxBE0NciwAcAAP//bVPdOAAAAAZJREFUAwDM4hAZDjaEjwAAAABJRU5ErkJggg==",mx="/assets/doubleBed.CzextF6m.png",yx="/assets/sleep.C_YKDk6M.json",xx="/assets/sleep.CRKZ3XeQ.png",Sx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3%2014H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2011V14C3%2015.1046%203.89543%2016%205%2016H19C20.1046%2016%2021%2015.1046%2021%2014V11'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M6%2016V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M18%2016V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M4%2011C4%209.34315%205.34315%208%207%208H17C18.6569%208%2020%209.34315%2020%2011'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",vx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='12'%20cy='12'%20r='5'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M5%2010V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M19%2010V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2012H7'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M17%2012H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",bx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3%2018V7C3%205.89543%203.89543%205%205%205H19C20.1046%205%2021%205.89543%2021%207V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2014H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M7%2010H10V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M14%2010H17V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M2%2018H22'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",wx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2018V7C4%205.89543%204.89543%205%206%205H18C19.1046%205%2020%205.89543%2020%207V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M4%2014H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M9%2010H15V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2018H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Cx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2019.5C4%2018.1193%205.11929%2017%206.5%2017H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M6.5%202H20V22H6.5C5.11929%2022%204%2020.8807%204%2019.5V4.5C4%203.11929%205.11929%202%206.5%202Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M8%206H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M8%2010H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Ax="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6%208V18C6%2019.6569%207.34315%2021%209%2021H15C16.6569%2021%2018%2019.6569%2018%2018V8H6Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M4%208H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M9%205V8'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M15%205V8'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M12%203V8'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Px="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%207C7%204.23858%209.23858%202%2012%202C14.7614%202%2017%204.23858%2017%207V17H7V7Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M7%2013H17'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3ccircle%20cx='12'%20cy='10'%20r='1'%20fill='white'/%3e%3cpath%20d='M5%2017H19V20C19%2021.1046%2018.1046%2022%2017%2022H7C5.89543%2022%205%2021.1046%205%2020V17Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Mx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='5'%20y='4'%20width='14'%20height='16'%20rx='2'%20stroke='white'%20stroke-width='1.5'/%3e%3ccircle%20cx='12'%20cy='12'%20r='3'%20stroke='white'%20stroke-width='1.5'/%3e%3ccircle%20cx='12'%20cy='7'%20r='1'%20fill='white'/%3e%3c/svg%3e",_x="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%2010H17V15C17%2016.1046%2016.1046%2017%2015%2017H9C7.89543%2017%207%2016.1046%207%2015V10Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linejoin='round'/%3e%3cpath%20d='M5%2010V14C5%2015.1046%205.89543%2016%207%2016'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M19%2010V14C19%2015.1046%2018.1046%2016%2017%2016'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M8%2017V19'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M16%2017V19'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3c/svg%3e",Tx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%206H20V18H4V6Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linejoin='round'/%3e%3cpath%20d='M10%206V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M4%2012H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3c/svg%3e",kx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='12'%20cy='8'%20r='4'%20stroke='white'%20stroke-width='1.5'/%3e%3cpath%20d='M8%2012L5%2018H19L16%2012'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3ccircle%20cx='9'%20cy='8'%20r='0.5'%20fill='white'/%3e%3ccircle%20cx='15'%20cy='8'%20r='0.5'%20fill='white'/%3e%3c/svg%3e",Rx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%203V5M12%2019V21M21%2012H19M5%2012H3M18.36%205.64L16.95%207.05M7.05%2016.95L5.64%2018.36M18.36%2018.36L16.95%2016.95M7.05%207.05L5.64%205.64M16%2012C16%2014.2091%2014.2091%2016%2012%2016C9.79086%2016%208%2014.2091%208%2012C8%209.79086%209.79086%208%2012%208C14.2091%208%2016%209.79086%2016%2012Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Ex="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6%203V21M18%203V21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M6%2012H18'%20stroke='white'%20stroke-width='1.5'%20stroke-dasharray='2%202'/%3e%3c/svg%3e",Ix="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2011V17H20V11'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M8%2011V17M12%2011V17M16%2011V17'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M4%2011H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M6%207L18%207'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3c/svg%3e",Bx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6%207H4V17H6V7Z'%20fill='white'/%3e%3cpath%20d='M20%207H18V17H20V7Z'%20fill='white'/%3e%3crect%20x='6'%20y='11'%20width='12'%20height='2'%20fill='white'/%3e%3crect%20x='16'%20y='8'%20width='2'%20height='8'%20fill='white'/%3e%3crect%20x='6'%20y='8'%20width='2'%20height='8'%20fill='white'/%3e%3c/svg%3e",Dx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%205V19'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M8%208H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M8%2012H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M10%205L12%203L14%205'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Fx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3%209.5L12%203L21%209.5V20C21%2020.5523%2020.5523%2021%2020%2021H4C3.44772%2021%203%2020.5523%203%2020V9.5Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M9%2021V12H15V21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",vi="system-ui, -apple-system, sans-serif",zx=["#a8c8f5","#9de5c7","#d4b9f7","#ffd399"],Lx=["#d6e7fc","#d1f4e5","#ece0fb","#fff0d9"],_n=["#2563b8","#26966b","#7c3fb8","#d97706"],ja={global:{containerTop:"0px",containerLeft:"0px",containerWidth:"100%",containerHeight:"100%",backgroundColor:"#f6f6f6",backgroundAlpha:1,performanceMode:!1,resolution:window.devicePixelRatio||1,enableLogger:!1,rendererPreference:"webgpu"},map:{autoPaddingHorizontalPercent:.05,autoPaddingVerticalPercent:.05,adjacencyThreshold:3,originChangeAutoFitThreshold:2,sizeChangeAutoFitThreshold:10,obstacleColor:"#999999",freeColor:"#ebebeb",autoFitOffset:{x:0,y:0}},room:{colors:{sortBy:"index",strategy:"priority",active:[...zx],inactive:[...Lx],name:[..._n],propertyTheme:[..._n],selectionIndicatorBackground:[..._n],selectionIndicatorIcon:["#ffffff","#ffffff","#ffffff","#ffffff"],[re.NO_ROOM_DATA]:"#ebebeb",[re.ROOM_GAP]:"#ebebeb",[re.OBSTACLE_ROOM]:"#ebebeb",[re.UNKNOWN_ROOM]:"#ebebeb",[re.VERSION0_ROOM]:""},nameLabel:{fontSize:12,fontFamily:vi,fontWeight:"500"},type:{assets:[Fx,Sx,vx,bx,wx,Cx,Ax,Px,Mx,_x,Tx,kx,Rx,Ex,Ix,Bx,Dx],iconSize:12,gap:4,position:"left",container:{visible:!0,size:16,borderRadius:16}},property:{displayOrders:["cleanMode","suction","cistern","cleanTimes"],iconWidth:14,iconHeight:14,foldable:!0,offsetX:0,offsetY:6,iconGap:0,container:{backgroundColor:"#ffffff",paddingVertical:2,paddingHorizontal:2,borderRadius:16,tailHeight:2,tailWidth:8},suction:{assets:[Uy,Hy,Vy,Ny,jy]},cistern:{assets:[Yy,Xy,Zy,qy]},cleanMode:{assets:[Ky,$y,Qy,Jy]},cleanTimes:{assets:[tx,ex]},cleanOrder:{color:"#ffffff",fontFamily:vi,fontWeight:"400",fontSize:10,gapRight:2}},selectionIndicator:{iconSrc:ox,iconWidth:14,iconHeight:14,containerWidth:16,containerHeight:16,strokeWidth:2,strokeColor:"#ffffff",borderRadius:16,offsetY:4,offsetX:0,tailHeight:2,tailWidth:6},floorType:{assets:["",ux,px,fx],opacity:.1,scale:.2},enableElasticScale:!1,elasticMinScale:.6,elasticMaxScale:1.5},path:{lineWidthFixed:!1,incrementalThreshold:5,commonPath:{visible:!0,color:"#ffffff",width:.5},transitionPath:{visible:!1,color:"#ffffff",width:.5},chargePath:{visible:!1,color:"#ffffff",width:.5},mopPath:{lineVisible:!0,lineColor:"#ffffff",lineWidth:.5,trackVisible:!0,trackColor:"#ffffff",trackAlpha:.4,trackWidth:4}},carpet:{src:gx,opacity:.5,scale:.2},robot:{icon:{sizeFixed:!1,width:8,height:8,src:Wy},speed:0,rotationCorrection:0,sleepAnimation:{jsonSrc:yx,imageSrc:xx,framePrefix:"sleep_",width:16,height:16,sizeFixed:!1,frameCount:96,offsetX:8,offsetY:-8},ring:{size:1,color:"rgba(255, 68, 68, 0.2)",strokeWidth:1,strokeColor:"#ffffff",strokeDashed:!0,strokeDashArray:[4,4]},pulseCircle:{size:12,color:"#4cd964",strokeWidth:0,strokeColor:"#ffffff",duration:1e3,sizeFixed:!1,minScale:.5,maxScale:1,minAlpha:.5,maxAlpha:1}},chargingStation:{icon:{sizeFixed:!1,width:8,height:8,src:Gy},rotationCorrection:0,ring:{size:1,color:"rgba(255, 68, 68, 0.2)",strokeWidth:1,strokeColor:"#ffffff",strokeDashed:!0,strokeDashArray:[4,4]}},interaction:{zoomRange:{min:.5,max:8},fitMinScale:1,fitMaxScale:4,enable:!0,enableDoubleTapZoom:!0,enableRobotClick:!1,enableChargingStationClick:!1},controls:{iconWrapperWidth:24,iconWrapperHeight:24,iconWrapperBorderRadius:16,iconWidth:12,iconHeight:12,deleteIconSrc:sx,rotateIconSrc:nx,scaleIconSrc:ix,moveIconSrc:rx,horizontalScaleIconSrc:ax,verticalScaleIconSrc:hx,moveButtonOffset:30,textFontSize:12,textFontFamily:vi,textFontWeight:"400",renderOrder:["forbiddenSweepZone","forbiddenMopZone","cleanZone","virtualWall","spot","wayPoint","divider"],forbiddenSweepZone:Ei.forbiddenSweepZone,forbiddenMopZone:Ei.forbiddenMopZone,carpet:{minSize:1,iconWrapperFillColor:"#5d68fe",fillColor:"rgba(93, 104, 254, 0.1)",outlineOffset:30,outlineStrokeColor:"rgba(0, 0, 0, 0.7)",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(93, 104, 254, 0.05)",showRotateButton:!0,textColor:"#5d68fe",textPosition:"bottom",textOffset:20,editing:{isDashed:!0,dashArray:[4,3]},normal:{isDashed:!1,dashArray:[0,0]}},cleanZone:Ei.cleanZone,virtualWall:{iconWrapperFillColor:"#ff4444",lineWidth:2,lineColor:"#ff4444",hitAreaThickness:30,outlineOffset:16,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",minWidth:1,textColor:"#ff4444",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},spot:{iconSrc:lx,iconSize:8,iconSizeFixed:!1,size:1,strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",showText:!0,textColor:"#5d68fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0],showIcon:!0,showFrame:!0},normal:{isDashed:!1,dashArray:[0,0],showIcon:!1,showFrame:!0}},wayPoint:{showOrder:!0,normal:{iconSrc:cx,iconSize:32,orderText:{fontSize:10,fontFamily:vi,fontWeight:"600",color:"#8a8a8a"},orderContainer:{size:12,backgroundColor:"#ffffff",offsetY:20,offsetX:0}},editing:{iconSrc:dx,iconSize:38,orderText:{fontSize:14,fontFamily:vi,fontWeight:"600",color:"#ff4444"},orderContainer:{size:16,backgroundColor:"#ffffff",offsetY:23,offsetX:0}}}},furniture:{assets:[{type:1,src:mx,width:1.8,height:2}],opacity:1,iconWrapperFillColor:"#26a69a",outlineOffset:16,outlineStrokeColor:"#26a69a",outlineStrokeWidth:1.5,outlineFillColor:"rgba(38, 166, 154, 0.05)",outlineDashed:!0,outlineDashArray:[4,3],showSizeText:!0,textColor:"#26a69a",textPosition:"bottom",textOffset:8,minScaleRatio:.5,maxScaleRatio:2,rotateDirection:"cw",lockAspectRatio:!1},divider:{lineColor:"#ff4444",dashLineWidth:2,dashLineDashArray:[4,3],solidLineWidth:2,endPointSize:12,endPointColor:"#ff4444",endPointStrokeColor:"#ffffff",endPointStrokeWidth:2,hitAreaThickness:30,resetDividerWhenOutOfRoom:!1,defaultExtension:20,defaultDirection:"horizontal"},detectedObject:{height:43,width:38,interactive:!1,anchor:{x:.5,y:.5}},heatmap:{cellSize:2,maxDistance:14,smoothIterations:10,heatmapAlpha:.8,useGradient:!0,colorGradients:["#FF3B30","#FF7A00","#FFA100","#FFD700","#99DD70","#2EC070","#40E0D0","#88D0E9"]},snapshot:{format:"png",quality:1,antialias:!0,resolution:4}},Ox={dividingRoomId:-1,enableRoomSelection:!1,enableInteraction:!0,enableMapClickCapture:!1,editingForbiddenSweepZoneIds:[],editingForbiddenMopZoneIds:[],editingCleanZoneIds:[],editingCustomZoneIds:{},editingVirtualWallIds:[],editingSpotIds:[],editingWayPointIds:[],editingCarpetIds:[],editingFurnitureIds:[],roomPropertyFoldIds:[],roomSelectionMode:"checkmark",mapRotation:0,selectRoomIds:[],showRoomProperty:!1,showRoomOrder:!0,showRoomName:!0,showRoomType:!0,showPath:!0,showRobot:!0,showChargingStation:!0,showRoomFloorType:!0,showCarpet:!0,showDetectedObjects:!0,showFurnitures:!0,showCustomCarpets:!0,showChargingStationRing:!1,showRobotRing:!1,showRobotSleepAnimation:!1,showRobotPulseCircle:!1,unit:"meter",unitLabel:"m",selectedCarpetIds:[]},Ya="MAIN",ne=5e3;function Gx(r){return{all:r=r||new Map,on:function(e,t){var i=r.get(e);i?i.push(t):r.set(e,[t])},off:function(e,t){var i=r.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):r.set(e,[]))},emit:function(e,t){var i=r.get(e);i&&i.slice().map(function(s){s(t)}),(i=r.get("*"))&&i.slice().map(function(s){s(e,t)})}}}class ac{constructor(e){this.app=e}getApp(){return this.app}getConfig(){return this.getApp().config}getDebuggerMode(){return!1}getRoomData(e){return this.getApp().managers.roomsManager.getRoomPropertyById(e)}metersToPixels(e){return this.getApp().metersToPixels(e)}pixelsToMeters(e){return this.getApp().pixelsToMeters(e)}metersToDisplayUnit(e){const{unit:t}=this.runtimeSnapshot;switch(t){case"feet":return e*3.28084;case"centimeter":return e*100;case"meter":default:return e}}get ticker(){return this.getApp().ticker}get mapState(){return this.getApp().mapState}get isMapDrawn(){return this.getApp().isMapDrawn}get config(){return this.getConfig()}get gloalConfig(){return this.getConfig().global}get mapConfig(){return this.getConfig().map}get roomConfig(){return this.getConfig().room}get heatMapConfig(){return this.getConfig().heatmap}get pathConfig(){return this.getConfig().path}get carpetConfig(){return this.getConfig().carpet}get robotConfig(){return this.getConfig().robot}get chargingStationConfig(){return this.getConfig().chargingStation}get interactionConfig(){return this.getConfig().interaction}get controlsConfig(){return this.getConfig().controls}get furnitureConfig(){return this.getConfig().furniture}get dividerConfig(){return this.getConfig().divider}get detectedObjectConfig(){return this.getConfig().detectedObject}get snapshotConfig(){return this.getConfig().snapshot}get appContainer(){return this.getApp().components.appContainer}get interaction(){return this.getApp().components.interaction}get viewportContainer(){return this.getApp().components.viewportContainer}get mapManager(){return this.getApp().managers.mapManager}get pathManager(){return this.getApp().managers.pathManager}get heatmapManager(){return this.getApp().managers.heatmapManager}get controlsManager(){return this.getApp().managers.controlsManager}get detectedObjectManager(){return this.getApp().managers.detectedObjectManager}get customElementsManager(){return this.getApp().managers.customElementsManager}get roomsManager(){return this.getApp().managers.roomsManager}get editControlManager(){return this.getApp().managers.editControlManager}get furnitureManager(){return this.getApp().managers.furnitureManager}get runtime(){return this.getApp().runtime}get runtimeSnapshot(){return zy(this.getApp().runtime)}isInteractionEnabled(){return this.runtimeSnapshot.enableInteraction}fixPrecision(e,t){return Ql(e,t)}get events(){return this.getApp().events}get baseScale(){return this.getApp().components.interaction.targetScale.x}get currentScale(){return this.getApp().components.appContainer.scale.x}get emitter(){return this.getApp().emitter}getChargerPosition(){const e=this.mapState;return e?this.fixPrecision({x:e.charger.x-e.origin.x,y:e.charger.y-e.origin.y}):null}getRobotPosition(){const e=this.pathManager.robot;return e?e.getCurrentPosition():null}}let Wx="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Ux=(r=21)=>{let e="",t=r|0;for(;t--;)e+=Wx[Math.random()*64|0];return e};class Hx extends L{constructor(t,i){super();g(this,"viewportBounds",{x:0,y:0,width:0,height:0});g(this,"maskGraphics",null);g(this,"containerElement",null);this.containerElement=i||window,this.calculateViewportBounds(t.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),this.createMask()}calculateViewportBounds(t){const{containerTop:i,containerLeft:s,containerWidth:n,containerHeight:o}=t,{width:a,height:h}=this.getContainerSize(),l=this.parseSize(s,a),c=this.parseSize(i,h),d=this.parseSize(n,a),u=this.parseSize(o,h);this.viewportBounds={x:l,y:c,width:d,height:u}}getContainerSize(){if(!this.containerElement)return{width:window.innerWidth,height:window.innerHeight};if(this.containerElement===window)return{width:window.innerWidth,height:window.innerHeight};const t=this.containerElement;return{width:t.clientWidth||window.innerWidth,height:t.clientHeight||window.innerHeight}}createMask(){this.maskGraphics=new H,this.maskGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215),this.addChild(this.maskGraphics),this.mask=this.maskGraphics}parseSize(t,i){if(!isNaN(Number(t)))return Number(t);if(t=t.trim(),t.endsWith("%")){const s=parseFloat(t)/100;return i*s}if(t.endsWith("vw")){const s=parseFloat(t)/100;return window.innerWidth*s}if(t.endsWith("vh")){const s=parseFloat(t)/100;return window.innerHeight*s}if(t.endsWith("rpx")){const s=parseFloat(t),n=window.innerWidth/750;return s*n}return t.endsWith("px")||!isNaN(parseFloat(t))?parseFloat(t):(w.warn(`Cannot parse size value: ${t}`),0)}getViewportBounds(){return{...this.viewportBounds}}updateViewport(t){var i,s;this.calculateViewportBounds(t.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),(i=this.maskGraphics)==null||i.clear(),(s=this.maskGraphics)==null||s.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215)}addContent(t){this.addChild(t)}}const Vx="interaction",hc="roomFill",lc="free",Gr="roomFloorType",cc="carpet",dc="obstacle",uc="heatmap",pc="path",je="furniture",Ke="controls",fc="roomInfo",Ye="detectedObject",Ii="customElement",Bi="customElementGif",gc="chargingStation",mc="robot",$e="customCarpet",ke="editControls",Nx=[Vx,hc,lc,Gr,cc,$e,dc,uc,pc,je,fc,Ye,Ii,Bi,gc,mc,Ke,ke],jx=[Ke,ke,$e,Ii,Bi,Ye,je];class Yx extends L{constructor(t){super();g(this,"layers",new Map);g(this,"mapRotation",0);g(this,"backgroundGraphics");g(this,"lastBackgroundState",null);this.appService=t;const s=this.appService.getApp().getViewportBounds();this.position.set(Math.round(s.width/2),Math.round(s.height/2)),this.pivot.set(0,0),this.backgroundGraphics=new H,this.backgroundGraphics.label="snapshotBackground",this.backgroundGraphics.visible=!1,this.addChild(this.backgroundGraphics),this.initializeLayers()}initializeLayers(){Object.values(Nx).forEach(i=>{const s=new L;s.label=i,i===Ke&&(s.isRenderGroup=!0),i===ke&&(s.isRenderGroup=!0),i===Gr&&(s.eventMode="none"),this.layers.set(i,s),this.addChild(s)})}getLayer(t){return this.layers.get(t)}addToLayer(t,i,s){const n=this.layers.get(t);return n?(s!==void 0&&(i.zIndex=s),n.addChild(i),!0):(w.warn("[AppContainer Debug] Layer not found:",t),!1)}removeFromLayer(t,i){const s=this.layers.get(t);return s&&i.parent===s?(s.removeChild(i),!0):!1}clearLayer(t){const i=this.layers.get(t);return i?(i.removeChildren(),!0):!1}setLayerVisibility(t,i){const s=this.layers.get(t);return s?(s.visible=i,!0):!1}updateOriginTrackedLayers(t,i){jx.forEach(s=>{const n=this.layers.get(s);n&&n.position.set(t,i)})}getLayerVisibility(t){const i=this.layers.get(t);return i?i.visible:!1}setMapRotation(t){this.mapRotation=t*Math.PI/180,this.rotation=this.mapRotation}getMapRotation(){return this.mapRotation*180/Math.PI}getMapRotationRadians(){return this.mapRotation}getSnapshotBounds(){this.layers.forEach(s=>{});const t=this.backgroundGraphics.visible;this.backgroundGraphics.visible=!1;const i=this.getLocalBounds();return this.backgroundGraphics.visible=t,new et(i.x,i.y,i.width,i.height)}updateBackground(t,i){if(!i){this.backgroundGraphics.visible=!1,this.lastBackgroundState=null;return}const s=this.getSnapshotBounds(),{x:n,y:o,width:a,height:h}=s;if(this.lastBackgroundState&&this.lastBackgroundState.color===t&&this.lastBackgroundState.width===a&&this.lastBackgroundState.height===h&&this.lastBackgroundState.x===n&&this.lastBackgroundState.y===o){this.backgroundGraphics.visible=!0;return}this.backgroundGraphics.clear(),this.backgroundGraphics.rect(n,o,a,h).fill(t),this.backgroundGraphics.visible=!0,this.lastBackgroundState={color:t,x:n,y:o,width:a,height:h}}}class Xt extends jt{constructor(t,i){super(i);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"sizeFixed",!0);g(this,"baselineScale",1);this.appService=t,this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ct(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,i){this.fixedWidth=t,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,t&&this.isFixedSizeSet?this.applySize():!t&&this.isFixedSizeSet&&this.applySize()}set width(t){if(this.isFixedSizeSet){w.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置宽度");return}this.setFixedSize(t,this.fixedHeight||t)}set height(t){if(this.isFixedSizeSet){w.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置高度");return}this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(this.destroyed||!this.scale||!this.isFixedSizeSet||!this.texture||this.texture.width===0||this.texture.height===0)return;const t=this.appService,i=this.fixedWidth/this.texture.width,s=this.fixedHeight/this.texture.height;if(this.sizeFixed){const n=t.currentScale;if(n===0)return;const o=i/n,a=s/n;this.scale&&super.scale.set(o,a)}else this.scale&&super.scale.set(i/this.baselineScale,s/this.baselineScale)}updateScale(t){this.destroyed||!this.scale||this.sizeFixed&&(this.isFixedSizeSet?this.applySize():t!==0&&super.scale.set(1/t))}async loadTextureAndSetSize(t,i){try{const s=this.appService,n=await N.load(t);if(this.destroyed||(this.texture=n,this.destroyed)||(i.sizeFixed!==void 0&&this.setSizeFixed(i.sizeFixed),this.setFixedSize(i.width,i.height),this.destroyed))return;s.getApp().renderOnceNextFrame()}catch(s){w.error(`Failed to load texture "${t}":`,s)}}draw(t,i){const{x:s,y:n,rotation:o=0}=t;i&&!this.visible?this.visible=i():!i&&!this.visible&&(this.visible=!0),this.rotation=o,this.position.set(s,n)}set texture(t){super.texture=t,this.isFixedSizeSet&&t&&t.width>0&&t.height>0&&this.applySize()}get texture(){return super.texture}destroy(t){this.appService.emitter.off("antiScale",this.throttledUpdateScale),this.throttledUpdateScale.cancel(),super.destroy(t)}}class Xx extends Xt{constructor(e){super(e),this.appService=e,this.initializeSprite()}async initializeSprite(){const e=this.appService;await this.loadTextureAndSetSize("chargingStation",e.chargingStationConfig.icon)}async draw({x:e,y:t,rotation:i}){const s=this.appService;super.draw({x:e,y:t,rotation:i},()=>s.runtimeSnapshot.showChargingStation)}}class yc extends H{constructor(t,i){super();g(this,"currentPosition",null);g(this,"config");g(this,"handleScaleChange",()=>{this.redraw()});this.appService=t,this.setupAntiScaleListener(),this.config=i.config}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.handleScaleChange)}draw(t){const i=this.appService;this.currentPosition=t;const{size:s,color:n,strokeWidth:o,strokeColor:a,strokeDashed:h,strokeDashArray:l}=this.config;this.clear();const c=i.metersToPixels(s),d=i.getApp().toFixedSize(o);this.setFillStyle({color:n}),h&&l.length>=2?this.drawDashedCircle(t,c,a,d,l):this.circle(t.x,t.y,c).fill().stroke({color:a,width:d,cap:"round",join:"round"})}drawDashedCircle(t,i,s,n,o){const a=this.appService;this.circle(t.x,t.y,i).fill();const h=a.getApp().toFixedSize(o[0]),l=a.getApp().toFixedSize(o[1]),c=2*Math.PI*i,d=h+l,u=Math.floor(c/d);if(u===0){this.circle(t.x,t.y,i).stroke({color:s,width:n,cap:"round",join:"round"});return}const p=c/u,f=p*(h/d);for(let y=0;y<u;y++){const m=y*p/i,x=(y*p+f)/i,S=Math.max(4,Math.ceil(Math.abs(x-m)*i/2)),v=(x-m)/S;for(let b=0;b<=S;b++){const P=m+v*b,C=t.x+i*Math.cos(P),A=t.y+i*Math.sin(P);b===0?this.moveTo(C,A):this.lineTo(C,A)}}this.stroke({color:s,width:n,cap:"round",join:"round"})}redraw(){this.currentPosition&&this.draw(this.currentPosition)}destroy(){this.appService.emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class vt{constructor(e,t={}){g(this,"target");g(this,"isPointerDown",!1);g(this,"pointerDownPos",null);g(this,"clickThreshold");g(this,"stopPropagation");g(this,"clickCallback",null);this.target=e,this.clickThreshold=t.clickThreshold??10,this.stopPropagation=t.stopPropagation??!1,this.clickCallback=t.onClick||null,this.setup()}setup(){this.target.interactive=!0,this.target.eventMode="static",this.target.on("pointerdown",this.handlePointerDown.bind(this)),this.target.on("pointermove",this.handlePointerMove.bind(this)),this.target.on("pointerup",this.handlePointerUp.bind(this)),this.target.on("pointerupoutside",this.handlePointerUpOutside.bind(this))}handlePointerDown(e){this.stopPropagation&&e.stopPropagation(),this.isPointerDown=!0,this.pointerDownPos={x:e.globalX,y:e.globalY}}handlePointerMove(e){if(this.stopPropagation&&e.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const t=e.globalX-this.pointerDownPos.x,i=e.globalY-this.pointerDownPos.y;Math.sqrt(t*t+i*i)>this.clickThreshold&&(this.isPointerDown=!1,this.pointerDownPos=null)}}handlePointerUp(e){if(this.stopPropagation&&e.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const t=e.globalX-this.pointerDownPos.x,i=e.globalY-this.pointerDownPos.y;Math.sqrt(t*t+i*i)<=this.clickThreshold&&this.clickCallback&&this.clickCallback(e,this.target)}this.isPointerDown=!1,this.pointerDownPos=null}handlePointerUpOutside(){this.isPointerDown=!1,this.pointerDownPos=null}setClickCallback(e){return this.clickCallback=e,this}setClickThreshold(e){return this.clickThreshold=e,this}getTarget(){return this.target}isInteracting(){return this.isPointerDown}destroy(){this.target.off("pointerdown",this.handlePointerDown),this.target.off("pointermove",this.handlePointerMove),this.target.off("pointerup",this.handlePointerUp),this.target.off("pointerupoutside",this.handlePointerUpOutside),this.clickCallback=null}}class Zx extends L{constructor(t){super();g(this,"chargingStation");g(this,"ring");g(this,"unsubscribeFns",[]);g(this,"clickHandler");this.appService=t,t.appContainer.addToLayer(gc,this),this.ring=new yc(this.appService,{config:this.appService.chargingStationConfig.ring}),this.ring.visible=this.appService.runtimeSnapshot.showChargingStationRing,this.addChild(this.ring),this.chargingStation=new Xx(this.appService),this.addChild(this.chargingStation);const i=W(this.appService.runtime,"showChargingStationRing",s=>{w.log(`[runtime] showChargingStationRing: ${s}`),this.ring.visible=s});this.unsubscribeFns.push(i),this.initClickInteraction()}async draw({x:t,y:i,rotation:s}){if(t===0&&i===0){this.visible=!1;return}this.visible=!0,this.ring.draw({x:t,y:i}),await this.chargingStation.draw({x:t,y:i,rotation:s})}initClickInteraction(){const{enableChargingStationClick:t}=this.appService.interactionConfig;t&&(this.clickHandler||(this.clickHandler=new vt(this.chargingStation,{onClick:()=>{var i;if((i=this.appService.events)!=null&&i.onClickChargingStation){const s=this.appService.getChargerPosition()??{x:0,y:0};this.appService.events.onClickChargingStation({rotation:this.chargingStation.rotation,...s})}}})))}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.ring.destroy(),this.clickHandler&&this.clickHandler.destroy(),super.destroy()}}class qx extends L{constructor(t){super({isRenderGroup:!0});g(this,"carpetSprite",null);g(this,"carpetMask",null);this.appService=t,this.appService.appContainer.addToLayer(cc,this)}async createCarpetFromRasterData(t,i){const s=this.appService;if(!s.runtimeSnapshot.showCarpet||(this.clearCarpet(),t.length===0))return;const{src:n,opacity:o,scale:a}=s.carpetConfig,h=await N.load(n);if(!h){w.warn(`Carpet texture not found: ${n}`);return}const l=this.createCarpetGraphics(t,i),c=l.getLocalBounds();if(c.width===0||c.height===0)return;const d=new bs({texture:h,width:c.width,height:c.height});d.autoGarbageCollect=!1,d.x=c.x,d.y=c.y,d.alpha=o,d.tileScale.set(a);const u=new L;u.addChild(l),d.mask=u,this.addChild(d),this.carpetSprite=d,this.carpetMask=u,s.getApp().renderOnceNextFrame()}createCarpetGraphics(t,i){const s=new H;s.autoGarbageCollect=!1;for(let n=0;n<t.length;n++){const o=t[n],a=o%i,h=Math.floor(o/i);s.rect(a,h,1,1)}return s.fill(16777215),s}clearCarpet(){this.carpetSprite&&(this.removeChild(this.carpetSprite),this.carpetSprite.destroy(),this.carpetSprite=null),this.carpetMask&&(this.carpetMask.destroy({children:!0}),this.carpetMask=null)}async createCarpetFromStructuredData(t){const i=this.appService;if(!i.runtimeSnapshot.showCarpet||!t||(this.clearCarpet(),t.length===0))return;const{src:s,opacity:n,scale:o}=i.carpetConfig,a=await N.load(s);if(!a){w.warn(`Carpet texture not found: ${s}`);return}const h=this.createCarpetGraphicsFromStructuredData(t),l=h.getLocalBounds();if(l.width===0||l.height===0)return;const c=new bs({texture:a,width:l.width,height:l.height});c.autoGarbageCollect=!1,c.x=l.x,c.y=l.y,c.alpha=n,c.tileScale.set(o);const d=new L;d.addChild(h),c.mask=d,this.addChild(c),this.carpetSprite=c,this.carpetMask=d,i.getApp().renderOnceNextFrame()}createCarpetGraphicsFromStructuredData(t){const i=new H;i.autoGarbageCollect=!1;for(const s of t){const n=s.coordinates;for(let o=0;o<n.length;o+=2){const a=n[o],h=n[o+1];i.rect(a,h,1,1)}}return i.fill(16777215),i}destroy(){this.clearCarpet(),super.destroy()}}class Xa extends H{constructor(e){super(),this.appService=e,this.appService.appContainer.addToLayer(lc,this)}draw(e){const t=this.appService;this.clear(),this.setFillStyle({color:t.mapConfig.freeColor});for(const i of e){const s=i.coordinates;for(let n=0;n<s.length;n+=2){const o=s[n],a=s[n+1];this.rect(o,a,1,1)}}this.fill()}destroy(e){super.destroy(e)}}class Za extends H{constructor(e){super(),this.appService=e,this.appService.appContainer.addToLayer(dc,this)}draw(e){const t=this.appService;this.clear(),this.setFillStyle({color:t.mapConfig.obstacleColor});for(const i of e){const s=i.coordinates;for(let n=0;n<s.length;n+=2){const o=s[n],a=s[n+1];this.rect(o,a,1,1)}}this.fill()}drawRaster(e,t){const i=this.appService;if(this.clear(),e.length!==0){this.setFillStyle({color:i.mapConfig.obstacleColor});for(let s=0;s<e.length;s+=ne){const n=Math.min(s+ne,e.length);for(let o=s;o<n;o++){const a=e[o],h=a%t,l=Math.floor(a/t);this.rect(h,l,1,1)}this.fill(),n<e.length&&this.setFillStyle({color:i.mapConfig.obstacleColor})}}}destroy(e){super.destroy(e)}}class qa extends L{constructor(t){super({isRenderGroup:!0});g(this,"roomGraphicsMap",new Map);g(this,"roomContextMap",new Map);g(this,"roomClickHandlerMap",new Map);g(this,"unsubscribeFns",[]);g(this,"mapWidth",0);g(this,"rasterRoomDataMap",new Map);g(this,"structuredRoomGeometry",new Map);this.appService=t,this.appService.appContainer.addToLayer(hc,this);const i=Fs(this.appService.config.room.colors,()=>{this.refreshRoomColors()});this.unsubscribeFns.push(i)}draw(t){const i=this.appService;this.clearRooms();const s=i.roomConfig,{selectRoomIds:n,enableRoomSelection:o}=i.runtimeSnapshot;t.forEach(a=>{const h=a.id>=255,l=new H,c=new mt,d=new mt,u=new mt;if(h)c.setFillStyle({color:a.color}),d.setFillStyle({color:a.color}),u.setFillStyle({color:a.color});else{const p=a.colorIndex??0,f=s.colors.active[p%s.colors.active.length],y=s.colors.inactive[p%s.colors.inactive.length],m=(s.colors.normal||s.colors.active)[p%(s.colors.normal||s.colors.active).length];c.setFillStyle({color:f}),d.setFillStyle({color:y}),u.setFillStyle({color:m})}if(c.poly(a.polyPoints).fill(),d.poly(a.polyPoints).fill(),u.poly(a.polyPoints).fill(),a.outlinePoints.forEach(p=>{c.rect(p.x,p.y,1,1).fill(),d.rect(p.x,p.y,1,1).fill(),u.rect(p.x,p.y,1,1).fill()}),h?l.context=c:l.context=o?n.includes(a.id)?c:d:u,!h){const p=new vt(l,{clickThreshold:10,onClick:()=>{this.handleRoomClick(a.id)}});this.roomClickHandlerMap.set(a.id,p),this.structuredRoomGeometry.set(a.id,{polyPoints:a.polyPoints,outlinePoints:a.outlinePoints,colorIndex:a.colorIndex??0})}this.roomGraphicsMap.set(a.id,l),this.roomContextMap.set(a.id,{activeContext:c,inactiveContext:d,normalContext:u}),this.addChild(l)})}drawRaster(t){const i=this.appService;if(this.clearRooms(),this.mapWidth=t.width,t.sortedRooms.length===0)return;const{selectRoomIds:s,enableRoomSelection:n}=i.runtimeSnapshot;t.sortedRooms.forEach(o=>{this.drawRasterRoom(o,n,s)})}drawRasterRoom(t,i,s){const{roomId:n,pixelIndices:o,activeColor:a,inactiveColor:h}=t,c=this.appService.roomConfig;let d=a;const u=typeof n=="number";if(u){const S=t.colorIndex??0;d=(c.colors.normal||c.colors.active)[S%(c.colors.normal||c.colors.active).length]}const p=new H,f=new mt,y=new mt,m=new mt;f.setFillStyle({color:a}),y.setFillStyle({color:h}),m.setFillStyle({color:d}),this.drawPixelPointsInBatches(f,o,ne,this.mapWidth),this.drawPixelPointsInBatches(y,o,ne,this.mapWidth),this.drawPixelPointsInBatches(m,o,ne,this.mapWidth);const x=u&&s.includes(n);if(p.context=i?u&&x?f:y:m,u){const S=new vt(p,{clickThreshold:10,onClick:()=>{this.handleRoomClick(n)}});this.roomClickHandlerMap.set(n,S)}this.roomGraphicsMap.set(n,p),this.roomContextMap.set(n,{activeContext:f,inactiveContext:y,normalContext:m}),this.rasterRoomDataMap.set(n,t),this.addChild(p)}drawPixelPointsInBatches(t,i,s,n){for(let o=0;o<i.length;o+=s){const a=Math.min(o+s,i.length);for(let h=o;h<a;h++){const l=i[h],c=l%n,d=Math.floor(l/n);t.rect(c,d,1,1)}t.fill()}}handleRoomClick(t){var s,n;const i=this.appService;(n=(s=i.events)==null?void 0:s.onClickRoom)==null||n.call(s,i.getRoomData(t)??{id:t})}setRoomStateBySelectIds(t){const i=this.appService,{enableRoomSelection:s}=i.runtimeSnapshot;this.roomGraphicsMap.forEach((n,o)=>{if(typeof o=="number"){const a=this.roomContextMap.get(o);if(a)if(s){const h=t.includes(o);n.context=h?a.activeContext:a.inactiveContext}else n.context=a.normalContext}})}setRoomState(t,i){const s=this.roomGraphicsMap.get(t),n=this.roomContextMap.get(t);if(!s||!n){w.warn(`Room ${t} not found`);return}typeof t=="number"&&(s.context=i?n.activeContext:n.inactiveContext)}setAllRoomsState(t){this.roomGraphicsMap.forEach((i,s)=>{typeof s=="number"&&this.setRoomState(s,t)})}getRoomGraphicsMap(){const t=new Map;return this.roomGraphicsMap.forEach((i,s)=>{typeof s=="number"&&t.set(s,i)}),t}getRasterRoomData(t){return this.rasterRoomDataMap.get(t)||null}getMapWidth(){return this.mapWidth}isWallIntersectsAnyRoom(t){const s=this.appService.getApp().mapState;if(!s)return w.warn("[RoomFill] Map state not available"),!1;if(!t||t.length!==2)return w.warn("[RoomFill] Invalid wall points provided"),!1;const[n,o]=t,a={x:n.x+s.origin.x,y:n.y+s.origin.y},h={x:o.x+s.origin.x,y:o.y+s.origin.y};return s.mapType==="raster"?this.isWallIntersectsAnyRoomRaster(a,h):this.isWallIntersectsAnyRoomStructured(a,h)}isZoneIntersectsAnyRoom(t){const s=this.appService.getApp().mapState;if(!s)return w.warn("[RoomFill] Map state not available"),!1;if(!t||t.length!==4)return w.warn("[RoomFill] Invalid zone points provided"),!1;const n=t.map(o=>({x:o.x+s.origin.x,y:o.y+s.origin.y}));return s.mapType==="raster"?this.isZoneIntersectsAnyRoomRaster(n):this.isZoneIntersectsAnyRoomStructured(n)}isWallIntersectsAnyRoomRaster(t,i){if(this.mapWidth===0||this.rasterRoomDataMap.size===0)return!1;const s=this.getLinePixels(t,i);for(const n of this.rasterRoomDataMap.values())for(const o of s)if(Jl(n.pixelIndices,o))return!0;return!1}isWallIntersectsAnyRoomStructured(t,i){const n=this.appService.mapManager.getAllRooms();for(const o of n)if(!(!o.outlinePoints||o.outlinePoints.length<3)){if(Et(t,o.outlinePoints,!0)||Et(i,o.outlinePoints,!0))return!0;for(let a=0;a<o.outlinePoints.length;a++){const h=o.outlinePoints[a],l=o.outlinePoints[(a+1)%o.outlinePoints.length];if(Ui(t,i,h,l))return!0}}return!1}isZoneIntersectsAnyRoomRaster(t){if(this.mapWidth===0||this.rasterRoomDataMap.size===0)return!1;const i=[[t[0],t[1]],[t[1],t[2]],[t[2],t[3]],[t[3],t[0]]];for(const[n,o]of i)if(this.isWallIntersectsAnyRoomRaster(n,o))return!0;const s=this.rasterRoomDataMap.values().next().value;if(s&&s.pixelIndices.length>0){const n=s.pixelIndices[0],o=n%this.mapWidth,a=Math.floor(n/this.mapWidth);if(Et({x:o,y:a},t,!0))return!0}return!1}isZoneIntersectsAnyRoomStructured(t){const s=this.appService.mapManager.getAllRooms(),n=[[t[0],t[1]],[t[1],t[2]],[t[2],t[3]],[t[3],t[0]]];for(const o of s)if(!(!o.outlinePoints||o.outlinePoints.length<3)){for(const a of t)if(Et(a,o.outlinePoints,!0))return!0;for(const a of o.outlinePoints)if(Et(a,t,!0))return!0;for(const[a,h]of n)for(let l=0;l<o.outlinePoints.length;l++){const c=o.outlinePoints[l],d=o.outlinePoints[(l+1)%o.outlinePoints.length];if(Ui(a,h,c,d))return!0}}return!1}getLinePixels(t,i){const n=this.appService.getApp().mapState;if(!n)return[];const o=n.height,a=[],h=Math.round(t.x),l=Math.round(t.y),c=Math.round(i.x),d=Math.round(i.y),u=Math.abs(c-h),p=Math.abs(d-l),f=h<c?1:-1,y=l<d?1:-1;let m=u-p,x=h,S=l;for(;;){if(x>=0&&x<this.mapWidth&&S>=0&&S<o){const b=S*this.mapWidth+x;a.push(b)}if(x===c&&S===d)break;const v=2*m;v>-p&&(m-=p,x+=f),v<u&&(m+=u,S+=y)}return a}getZonePixels(t,i,s,n){const a=this.appService.getApp().mapState;if(!a)return[];const h=a.height,l=[],c=Math.max(0,Math.floor(t)),d=Math.min(this.mapWidth-1,Math.ceil(s)),u=Math.max(0,Math.floor(i)),p=Math.min(h-1,Math.ceil(n));for(let f=u;f<=p;f++)for(let y=c;y<=d;y++){const m=f*this.mapWidth+y;l.push(m)}return l}refreshRoomColors(){const{selectRoomIds:t,enableRoomSelection:i}=this.appService.runtimeSnapshot,s=this.appService.roomConfig;this.roomGraphicsMap.forEach((n,o)=>{if(typeof o!="number")return;const a=this.roomContextMap.get(o),h=this.structuredRoomGeometry.get(o);if(a&&h){const l=h.colorIndex,c=s.colors.active[l%s.colors.active.length],d=s.colors.inactive[l%s.colors.inactive.length],u=(s.colors.normal||s.colors.active)[l%(s.colors.normal||s.colors.active).length];a.activeContext.clear(),a.activeContext.setFillStyle({color:c}),a.activeContext.poly(h.polyPoints).fill(),h.outlinePoints.forEach(p=>{a.activeContext.rect(p.x,p.y,1,1).fill()}),a.inactiveContext.clear(),a.inactiveContext.setFillStyle({color:d}),a.inactiveContext.poly(h.polyPoints).fill(),h.outlinePoints.forEach(p=>{a.inactiveContext.rect(p.x,p.y,1,1).fill()}),a.normalContext.clear(),a.normalContext.setFillStyle({color:u}),a.normalContext.poly(h.polyPoints).fill(),h.outlinePoints.forEach(p=>{a.normalContext.rect(p.x,p.y,1,1).fill()}),n.context=i?t.includes(o)?a.activeContext:a.inactiveContext:a.normalContext}else if(a){const l=this.rasterRoomDataMap.get(o);if(l){const c=l.colorIndex??0,d=s.colors.active[c%s.colors.active.length],u=s.colors.inactive[c%s.colors.inactive.length],p=(s.colors.normal||s.colors.active)[c%(s.colors.normal||s.colors.active).length];a.activeContext.clear(),a.activeContext.setFillStyle({color:d}),this.drawPixelPointsInBatches(a.activeContext,l.pixelIndices,ne,this.mapWidth),a.inactiveContext.clear(),a.inactiveContext.setFillStyle({color:u}),this.drawPixelPointsInBatches(a.inactiveContext,l.pixelIndices,ne,this.mapWidth),a.normalContext.clear(),a.normalContext.setFillStyle({color:p}),this.drawPixelPointsInBatches(a.normalContext,l.pixelIndices,ne,this.mapWidth),n.context=i?t.includes(o)?a.activeContext:a.inactiveContext:a.normalContext}}}),this.appService.getApp().renderOnceNextFrame()}clearRooms(){this.children.length===0&&this.roomGraphicsMap.size===0||(this.roomGraphicsMap.forEach(t=>{try{t.destroy()}catch(i){w.warn("Error destroying room graphics:",i)}}),this.roomGraphicsMap.clear(),this.roomContextMap.forEach(t=>{try{t.activeContext.destroy(),t.inactiveContext.destroy(),t.normalContext.destroy()}catch(i){w.warn("Error destroying graphics context:",i)}}),this.roomContextMap.clear(),this.roomClickHandlerMap.forEach(t=>{try{t.destroy()}catch(i){w.warn("Error destroying click handler:",i)}}),this.roomClickHandlerMap.clear(),this.removeChildren(),this.rasterRoomDataMap.clear(),this.structuredRoomGeometry.clear())}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.clearRooms(),super.destroy()}}class Kx{constructor(e){g(this,"obstacle");g(this,"free");g(this,"roomFill");g(this,"carpet");g(this,"chargingStation");g(this,"mapBounds",{minX:0,minY:0,maxX:0,maxY:0});g(this,"lastMapId",null);g(this,"lastOrigin",null);g(this,"lastSize",null);g(this,"lastStatus",null);g(this,"roomGeometryMap",new Map);g(this,"rasterRoomPixelsMap",new Map);g(this,"fourColorCache",null);g(this,"carpetData",null);g(this,"unsubscribeFns",[]);this.appService=e,this.obstacle=new Za(this.appService),this.free=new Xa(this.appService),this.roomFill=new qa(this.appService),this.carpet=new qx(this.appService),this.chargingStation=new Zx(this.appService),this.validateColorConfig();const t=W(e.runtime,"enableRoomSelection",o=>{if(w.log(`[runtime] enableRoomSelection: ${o}`),o){this.roomFill.setAllRoomsState(!1);const a=this.appService.runtimeSnapshot.selectRoomIds;this.roomFill.setRoomStateBySelectIds(a)}else this.roomFill.setAllRoomsState(!0)}),i=W(e.runtime,"selectRoomIds",o=>{w.log(`[runtime] selectRoomIds: ${o}`),this.roomFill.setRoomStateBySelectIds(o)}),s=W(e.runtime,"showChargingStation",o=>{w.log(`[runtime] showChargingStation: ${o}`),this.chargingStation.visible=o}),n=W(e.runtime,"showCarpet",o=>{w.log(`[runtime] showCarpet: ${o}`),o?e.getApp().managers.customCarpetManager.getCustomCarpets().length===0&&this.createCarpet():this.carpet.clearCarpet()});this.unsubscribeFns.push(t,i,s,n)}async drawMap(e){const t=this.appService,{id:i,obstacles:s,free:n,rooms:o,charger:a,carpet:h,status:l,origin:c,size:d}=e;this.clearComponents(),this.resetGeometryData();const u=this.processRoomsGeometry(o);this.roomFill.draw(u),n&&this.free.draw(n),s&&this.obstacle.draw(s),this.carpetData=h,this.createCarpet();const p=this.mergeLayerBounds();Jr(p,this.mapBounds)||(w.debug("[Map] Map bounds updated:",p),this.mapBounds=p,this.shouldFitMapToView(i,l===1,{x:c[0],y:c[1]},{x:d[0],y:d[1]})&&(t.getApp().fitMapToView(this.mapBounds),this.lastMapId=i,this.lastOrigin={x:c[0],y:c[1]},this.lastSize={x:d[0],y:d[1]},this.lastStatus=l===1));const f=((e.charger.angle??0)+t.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:a.coordinate[0],y:a.coordinate[1],rotation:f}),await t.roomsManager.refresh(),!0}async drawRasterMap(e,t){const i=this.appService;this.clearComponents();const{id:s,width:n,height:o,charger:a,chargerDirection:h,status:l,origin:c}=t;w.debug("[Map] Parsed Raster Map Data",e),this.obstacle.drawRaster(e.obstacles,n),this.carpetData=this.convertRasterToStructuredData(e.carpet,n),i.getApp().managers.customCarpetManager.getCustomCarpets().length===0&&this.createCarpet();const u=this.processRasterData(e);this.roomFill.drawRaster(u);const p=wy(e,n,o);Jr(p,this.mapBounds)||(w.debug("[Map] Raster map bounds updated:",p),this.mapBounds=p,this.shouldFitMapToView(s,l,c,{x:n,y:o})&&(i.getApp().fitMapToView(this.mapBounds),this.lastMapId=s,this.lastOrigin={...c},this.lastSize={x:n,y:o},this.lastStatus=l));const f=(h+i.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:a.x,y:a.y,rotation:f}),this.generateRoomGeometryFromRaster(e),await i.roomsManager.refresh(),!0}resetGeometryData(){this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear(),this.fourColorCache=null,this.mapBounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}shouldFitMapToView(e,t,i,s){const n=this.appService,{originChangeAutoFitThreshold:o,sizeChangeAutoFitThreshold:a}=n.getApp().config.map;if(this.lastMapId!==e)return w.debug("[Map] Map ID changed, triggering fitMapToView"),!0;if(this.lastStatus!==null&&this.lastStatus!==t)return w.debug(`[Map] Map status changed (${this.lastStatus} -> ${t}), triggering fitMapToView`),!0;if(this.lastOrigin&&i){const h=Math.abs(i.x-this.lastOrigin.x),l=Math.abs(i.y-this.lastOrigin.y);if(h>o||l>o)return w.debug(`[Map] Origin change exceeded threshold (deltaX: ${h}, deltaY: ${l}, threshold: ${o}), triggering fitMapToView`),!0}if(this.lastSize&&s){const h=Math.abs(s.x-this.lastSize.x),l=Math.abs(s.y-this.lastSize.y);if(h>a||l>a)return w.debug(`[Map] Size change exceeded threshold (deltaX: ${h}, deltaY: ${l}, threshold: ${a}), triggering fitMapToView`),!0}return!1}convertRasterToStructuredData(e,t){if(e.length===0)return[];const i=[];for(let s=0;s<e.length;s++){const n=e[s],o=n%t,a=Math.floor(n/t);i.push(o,a)}return[{coordinates:i}]}async createCarpet(){!this.appService.runtimeSnapshot.showCarpet||!this.carpetData||await this.carpet.createCarpetFromStructuredData(this.carpetData)}processRoomsGeometry(e){if(!e)return[];const t=this.appService,{active:i}=t.roomConfig.colors,s=t.roomConfig.colors[re.UNKNOWN_ROOM];if(Object.keys(e).length===0)return this.mapBounds={minX:0,minY:0,maxX:0,maxY:0},[];const n=Object.keys(e).sort((u,p)=>Number(u)-Number(p)),o=n.filter(u=>Number(u)<255),a=n.filter(u=>Number(u)>=255),h=[],l=[];o.forEach(u=>{const{coordinates:p}=e[u];if(p.length<4)return;const f=p.filter(_=>!isFinite(_));if(f.length>0){w.error(`[Room ${u}] Contains ${f.length} invalid coordinates (NaN/Infinity)`);return}const y=Number(u);let m=1/0,x=1/0,S=-1/0,v=-1/0;const b=[];for(let _=0;_<p.length;_+=2){const E=p[_],B=p[_+1];m=Math.min(m,E),x=Math.min(x,B),S=Math.max(S,E),v=Math.max(v,B),b.push({x:E,y:B})}const P=S-m,C=v-x;if(P===0||C===0){w.error(`[Room ${u}] Degenerate polygon (${P}x${C}). Skipping.`);return}if(P<2||C<2){w.warn(`[Room ${u}] Room too small (${P}x${C}), skipping`);return}const A=new et(m,x,S-m+1,v-x+1),k=Da(b),M=k.flatMap(_=>[_.x+.5,_.y+.5]),T=Fa(k,m,x,S,v);l.push({id:y,points:b,outlinePoints:k,polyPoints:M,centerPoint:T,boundingBox:A}),this.mapBounds.minX=Math.min(this.mapBounds.minX,m),this.mapBounds.minY=Math.min(this.mapBounds.minY,x),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,S),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,v)});const c=[...l].sort((u,p)=>{if(t.roomConfig.colors.sortBy==="area"){const f=u.outlinePoints.length;return p.outlinePoints.length-f}else return u.id-p.id}),d=this.assignColorsUsingFourColorAlgorithm(c,i.length,"structured");return l.forEach(u=>{const p=d.get(u.id)||0,f=i[p],y={id:u.id,color:f,colorIndex:p,boundingBox:u.boundingBox,points:u.points,outlinePoints:u.outlinePoints,polyPoints:u.polyPoints,centerPoint:u.centerPoint};this.roomGeometryMap.set(u.id,y),h.push(y)}),a.forEach(u=>{const{coordinates:p}=e[u];if(p.length<4)return;const f=Number(u);let y=1/0,m=1/0,x=-1/0,S=-1/0;const v=[];for(let _=0;_<p.length;_+=2){const E=p[_],B=p[_+1];y=Math.min(y,E),m=Math.min(m,B),x=Math.max(x,E),S=Math.max(S,B),v.push({x:E,y:B})}const b=x-y,P=S-m;if(b===0||P===0){w.error(`[Unknown Room ${u}] Degenerate polygon (${b}x${P}). Skipping.`);return}if(b<2||P<2){w.warn(`[Unknown Room ${u}] Room too small (${b}x${P}), skipping`);return}const C=new et(y,m,x-y+1,S-m+1),A=Da(v),k=A.flatMap(_=>[_.x+.5,_.y+.5]),M=Fa(A,y,m,x,S),T={id:f,color:s,boundingBox:C,points:v,outlinePoints:A,polyPoints:k,centerPoint:M};h.push(T),this.mapBounds.minX=Math.min(this.mapBounds.minX,y),this.mapBounds.minY=Math.min(this.mapBounds.minY,m),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,x),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,S)}),h}mergeLayerBounds(){let e={...this.mapBounds};if(this.obstacle.bounds&&(e=Pn(e,this.obstacle.bounds)),this.free.bounds&&(e=Pn(e,this.free.bounds)),this.roomFill.children.length>0){const t=this.roomFill.getLocalBounds();t.width>0&&t.height>0&&(e=Pn(e,{minX:t.x,minY:t.y,maxX:t.x+t.width,maxY:t.y+t.height}))}return e}getRoomById(e){return this.roomGeometryMap.get(e)}getAllRooms(){return Array.from(this.roomGeometryMap.values())}isWallIntersectsAnyRoom(e){return this.roomFill.isWallIntersectsAnyRoom(e)}isZoneIntersectsAnyRoom(e){return this.roomFill.isZoneIntersectsAnyRoom(e)}areRoomsAdjacent(e){const t=this.appService,i=t.mapConfig.adjacencyThreshold;if(!e||e.length===0)return w.warn("[MapManager] No room IDs provided"),!1;if(e.length===1)return!0;const s=Array.from(new Set(e));if(s.length===1)return!0;const n=t.getApp().mapState;return((n==null?void 0:n.mapType)??"structured")==="raster"?this.areRasterRoomsAdjacentInternal(s,i):this.areStructuredRoomsAdjacentInternal(s,i)}areStructuredRoomsAdjacentInternal(e,t){const i=[];for(const n of e){const o=this.getRoomById(n);if(!o)return w.warn(`[MapManager] Room ${n} not found in map`),!1;if(!o.outlinePoints||o.outlinePoints.length===0)return w.warn(`[MapManager] Room ${n} has no outline points`),!1;i.push({id:n,points:o.outlinePoints})}const s=[];for(let n=0;n<i.length;n++)for(let o=n+1;o<i.length;o++){const a=i[n],h=i[o];Oa(a.points,h.points,t)&&s.push([n,o])}return Wa(i.length,s)}areRasterRoomsAdjacentInternal(e,t){const s=this.appService.getApp().mapState;if(!s)return w.warn("[MapManager] Map state not available"),!1;const n=s.width,o=[];for(const h of e){const l=this.getRasterRoomPixels(h);if(!l)return w.warn(`[MapManager] Room ${h} pixel data not found in raster map`),!1;o.push({id:h,pixels:l})}const a=[];for(let h=0;h<o.length;h++)for(let l=h+1;l<o.length;l++){const c=o[h],d=o[l];Ga(c.pixels,d.pixels,n,t)&&a.push([h,l])}return Wa(o.length,a)}isPointInAnyRoom(e){const i=this.appService.getApp().mapState;return i?(i.mapType??"structured")==="raster"?this.isPointInAnyRoomRasterInternal(e,i):this.isPointInAnyRoomStructuredInternal(e,i):(w.warn("[MapManager] Map state not available"),null)}isPointInAnyRoomStructuredInternal(e,t){const i=e.x+t.origin.x,s=e.y+t.origin.y,n={x:i,y:s},o=this.getAllRooms();for(const a of o)if(a.outlinePoints&&a.outlinePoints.length>=3&&Et(n,a.outlinePoints)){const l=this.appService.roomsManager.getRoomPropertyById(a.id);return l||(w.warn(`[MapManager] Room ${a.id} found in geometry but not in RoomManager`),null)}return null}isPointInAnyRoomRasterInternal(e,t){const i=t.width,s=t.height,n=e.x+t.origin.x,o=e.y+t.origin.y,a=Math.round(n),h=Math.round(o);if(a<0||a>=i||h<0||h>=s)return w.warn(`[MapManager] Point (${a}, ${h}) is out of map bounds (${i}x${s})`),null;const l=h*i+a,c=this.getAllRooms();for(const d of c){const u=this.getRasterRoomPixels(d.id);if(u&&u.length>0&&Jl(u,l)){const f=this.appService.roomsManager.getRoomPropertyById(d.id);return f||(w.warn(`[MapManager] Room ${d.id} found in geometry but not in RoomManager`),null)}}return null}clearComponents(){this.obstacle.clear(),this.obstacle.destroy(),this.obstacle=new Za(this.appService),this.free.clear(),this.free.destroy(),this.free=new Xa(this.appService),this.carpet.clearCarpet(),this.carpetData=null,this.roomFill.clearRooms(),this.roomFill.isRenderGroup&&(this.roomFill.isRenderGroup=!1),this.roomFill.removeChildren(),this.roomFill.destroy(),this.roomFill=new qa(this.appService)}processRasterData(e){const i=this.appService.roomConfig,s=[],n=[];e.rooms.forEach((d,u)=>{typeof u=="number"?s.push([u,d]):n.push([u,d])}),s.sort(([d],[u])=>d-u);const o=s.map(([d,u])=>({id:d,pixels:u})).sort((d,u)=>i.colors.sortBy==="area"?u.pixels.length-d.pixels.length:d.id-u.id),a=this.assignColorsUsingFourColorAlgorithm(o,i.colors.active.length,"raster"),h=s.map(([d,u])=>{const p=a.get(d)||0;return{roomId:d,pixelIndices:u,activeColor:i.colors.active[p],inactiveColor:i.colors.inactive[p%i.colors.inactive.length],colorIndex:p}}),l=n.map(([d,u])=>{let p=i.colors[d];return d===re.VERSION0_ROOM&&!p&&(p=i.colors[re.NO_ROOM_DATA]),{roomId:d,pixelIndices:u,activeColor:p,inactiveColor:p}}),c=[...h,...l];return{obstacles:e.obstacles,carpet:e.carpet,sortedRooms:c,width:e.width,height:e.height,totalPixels:e.totalPixels}}generateRoomGeometryFromRaster(e){const t=this.appService;this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear();const{active:i}=t.roomConfig.colors,s=[];e.rooms.forEach((h,l)=>{typeof l=="number"&&s.push(l)}),s.sort((h,l)=>h-l);const n=[];s.forEach(h=>{const l=e.rooms.get(h);this.rasterRoomPixelsMap.set(h,l);let c=1/0,d=1/0,u=-1/0,p=-1/0;for(let m=0;m<l.length;m++){const x=l[m],S=x%e.width,v=Math.floor(x/e.width);c=Math.min(c,S),d=Math.min(d,v),u=Math.max(u,S),p=Math.max(p,v)}const f=yy(l,e.width,c,d,u,p),y=new et(c,d,u-c+1,p-d+1);n.push({id:h,pixelIndices:l,boundingBox:y,centerPoint:f})});const o=[...n].sort((h,l)=>t.roomConfig.colors.sortBy==="area"?l.pixelIndices.length-h.pixelIndices.length:h.id-l.id),a=this.assignColorsUsingFourColorAlgorithm(o,i.length,"raster");n.forEach(h=>{const l=a.get(h.id)||0,c=i[l],d={id:h.id,color:c,colorIndex:l,boundingBox:h.boundingBox,points:[],outlinePoints:[],polyPoints:[],centerPoint:h.centerPoint};this.roomGeometryMap.set(h.id,d)})}getRasterRoomPixels(e){return this.rasterRoomPixelsMap.get(e)}validateColorConfig(){const t=this.appService.roomConfig.colors,i=t.active.length,s=t.inactive.length,n=t.name.length,o=t.propertyTheme.length,a=t.selectionIndicatorBackground.length,h=t.selectionIndicatorIcon.length;i<4&&w.warn(`[FourColor] room.colors.active requires at least 4 colors for the four-color theorem, but got ${i}. Adjacent rooms may have the same color.`),s!==i&&w.warn(`[FourColor] room.colors.inactive length (${s}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),n!==i&&w.warn(`[FourColor] room.colors.name length (${n}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),o!==i&&w.warn(`[FourColor] room.colors.propertyTheme length (${o}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),a!==i&&w.warn(`[FourColor] room.colors.selectionIndicatorBackground length (${a}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),h!==i&&w.warn(`[FourColor] room.colors.selectionIndicatorIcon length (${h}) does not match room.colors.active length (${i}). Using modulo for color assignment.`)}assignColorsUsingFourColorAlgorithm(e,t,i){var d;const s=this.appService,n=((d=s.mapState)==null?void 0:d.id)??null;if(this.fourColorCache&&this.fourColorCache.mapId===n&&this.fourColorCache.colorMap.size===e.length)return w.debug("[FourColor] Using cached color map"),this.fourColorCache.colorMap;const o=s.getApp().config.map.adjacencyThreshold||3,a=s.roomConfig.colors.strategy,l=My(e,(u,p)=>{var f;if(i==="structured"){const y=u.outlinePoints,m=p.outlinePoints;return!y||!m?!1:Oa(y,m,o)}else{const y=u.pixels,m=p.pixels;if(!y||!m)return!1;const x=((f=s.mapState)==null?void 0:f.width)||0;return Ga(y,m,x,o)}},t,a);this.fourColorCache={mapId:n,colorMap:l};const c=new Array(t).fill(0);return l.forEach(u=>{c[u]++}),w.debug("[FourColor] Color distribution:",c),l}destroy(){this.obstacle.destroy(),this.free.destroy(),this.roomFill.destroy(),this.carpet.destroy(),this.chargingStation.destroy(),this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[],this.fourColorCache=null}}class $x extends L{constructor(t){super({isRenderGroup:!0});g(this,"commonPath");g(this,"chargePath");g(this,"transitionsPath");g(this,"mopPath");g(this,"mopPathTrack");g(this,"mopPathTrackContainer");g(this,"debugPoints");g(this,"pathData",null);g(this,"lastPointCount",0);g(this,"lastDrawnPosition",null);g(this,"isRealTimeDrawing",!1);g(this,"throttledUpdateLineWidth");g(this,"throttledHandleRobotPosition");g(this,"unsubscribeFns",[]);g(this,"handleRobotAnimationComplete",()=>{this.isRealTimeDrawing&&this.stopRealTimeDrawing()});this.appService=t,this.appService.appContainer.addToLayer(pc,this),this.eventMode="none",this.commonPath=new H,this.chargePath=new H,this.transitionsPath=new H,this.mopPathTrackContainer=new L,this.mopPathTrackContainer.filters=[new Ng],this.mopPathTrack=new H,this.mopPath=new H,this.debugPoints=new H,this.mopPathTrackContainer.addChild(this.mopPathTrack),this.addChild(this.mopPathTrackContainer),this.addChild(this.commonPath),this.addChild(this.chargePath),this.addChild(this.transitionsPath),this.addChild(this.mopPath),this.addChild(this.debugPoints),this.visible=t.runtimeSnapshot.showPath,this.commonPath.visible=t.pathConfig.commonPath.visible,this.chargePath.visible=t.pathConfig.chargePath.visible,this.transitionsPath.visible=t.pathConfig.transitionPath.visible,this.mopPathTrackContainer.visible=t.pathConfig.mopPath.trackVisible,this.mopPath.visible=t.pathConfig.mopPath.lineVisible,this.throttledUpdateLineWidth=Ct(()=>{this.updateLineWidth()},50,{leading:!0,trailing:!0}),this.throttledHandleRobotPosition=Ct(this.handleRobotPositionUpdate.bind(this),0),this.registerEventListeners()}registerEventListeners(){const{emitter:t}=this.appService;t.on("antiScale",this.throttledUpdateLineWidth),t.on("robotPositionUpdate",this.throttledHandleRobotPosition),t.on("robotAnimationComplete",this.handleRobotAnimationComplete);const i=Fs(this.appService.config.path,()=>{this.pathData&&(this.redrawPaths(this.pathData),this.appService.getApp().renderOnceNextFrame())});this.unsubscribeFns.push(i)}handleRobotPositionUpdate(t){if(!this.isRealTimeDrawing||!this.lastDrawnPosition)return;const i=t.pathType||"common";let s=[];switch(i){case"common":s=[this.commonPath];break;case"charge":s=[this.chargePath];break;case"transitions":s=[this.transitionsPath];break;case"mop":s=[this.mopPathTrack,this.mopPath];break;default:s=[this.commonPath]}s.forEach(n=>{n.moveTo(this.lastDrawnPosition.x,this.lastDrawnPosition.y),n.lineTo(t.x,t.y),n.stroke()}),this.lastDrawnPosition={x:t.x,y:t.y}}updateLineWidth(){const t=this.appService;this.pathData&&t.pathConfig.lineWidthFixed&&this.redrawPaths(this.pathData)}redrawPaths(t){const{pathPoints:i}=t;if(this.commonPath.clear(),this.chargePath.clear(),this.transitionsPath.clear(),this.mopPathTrack.clear(),this.mopPath.clear(),this.debugPoints.clear(),!i||i.length===0)return;this.setupPathStyles(),this.drawPathSegments(i),this.commonPath.stroke(),this.chargePath.stroke(),this.transitionsPath.stroke(),this.mopPathTrack.stroke(),this.mopPath.stroke(),this.appService.getDebuggerMode()&&this.drawDebugPoints(i)}setupPathStyles(){var n;const t=this.appService,i=t.pathConfig,s=o=>i.lineWidthFixed?t.getApp().toFixedSize(o):o;this.commonPath.setStrokeStyle({width:s(i.commonPath.width),color:i.commonPath.color,join:"round",cap:"round"}),this.chargePath.setStrokeStyle({width:s(i.chargePath.width),color:i.chargePath.color,join:"round",cap:"round"}),this.transitionsPath.setStrokeStyle({width:s(i.transitionPath.width),color:i.transitionPath.color,join:"round",cap:"round"}),this.mopPathTrack.setStrokeStyle({width:s(i.mopPath.trackWidth),color:i.mopPath.trackColor,alpha:1,join:"round",cap:"round"}),(n=this.mopPathTrackContainer.filters)!=null&&n[0]&&(this.mopPathTrackContainer.filters[0].alpha=i.mopPath.trackAlpha),this.mopPathTrackContainer.visible=i.mopPath.trackVisible,this.mopPath.setStrokeStyle({width:s(i.mopPath.lineWidth),color:i.mopPath.lineColor,join:"round",cap:"round"}),this.mopPath.visible=i.mopPath.lineVisible}drawPathSegments(t){let i=null,s=null;for(let n=0;n<t.length;n++){const o=t[n],a=o.type||"common";let h;switch(a){case"common":h=[this.commonPath];break;case"charge":h=[this.chargePath];break;case"transitions":h=[this.transitionsPath];break;case"mop":h=[this.mopPathTrack,this.mopPath];break;default:h=[this.commonPath]}n===0||a!==i?h.forEach(c=>c.moveTo(o.x,o.y)):s&&h.length===s.length&&h.every((c,d)=>c===s[d])&&h.forEach(c=>c.lineTo(o.x,o.y)),i=a,s=h}}drawDebugPoints(t){const i={common:16711935,charge:65535,transitions:16776960,mop:65280},s=1;for(const n of t){const o=n.type||"common",a=i[o];this.debugPoints.rect(n.x-s/2,n.y-s/2,s,s),this.debugPoints.fill(a)}}updatePositionByOrigin(t,i){this.position.set(t,i)}drawFull(t){var i;w.debug("[Path] Draw Full Path",t),this.pathData=t,this.redrawPaths(t),this.lastPointCount=((i=t.pathPoints)==null?void 0:i.length)||0}drawIncremental(t){var o,a,h,l;const i=this.appService,s=this.lastPointCount,n=((o=t.pathPoints)==null?void 0:o.slice(s))||[];if(n.length>0)if(this.setupPathStyles(),w.debug("[Path] Draw Incremental Path",n),i.robotConfig.speed>0){if(this.isRealTimeDrawing=!0,s>0&&((a=this.pathData)!=null&&a.pathPoints)){const u=this.pathData.pathPoints[s-1];this.lastDrawnPosition={x:u.x,y:u.y}}}else this.drawNewPathSegments(n,s,t.pathPoints,(h=this.pathData)==null?void 0:h.pathPoints);this.pathData=t,this.lastPointCount=((l=t.pathPoints)==null?void 0:l.length)||0}drawNewPathSegments(t,i,s,n){if(!s||t.length===0)return;let o=null;i>0&&(n&&n[i-1]?o=n[i-1]:s[i-1]&&(o=s[i-1]));let a=null,h=null,l=!1;for(let c=0;c<t.length;c++){const d=t[c],u=d.type||"common";let p;switch(u){case"common":p=[this.commonPath];break;case"charge":p=[this.chargePath];break;case"transitions":p=[this.transitionsPath];break;case"mop":p=[this.mopPathTrack,this.mopPath];break;default:p=[this.commonPath]}u!==a||c===0?(h&&l&&h.forEach(y=>y.stroke()),a=u,h=p,l=!0,o&&c===0&&o.type===u?p.forEach(y=>{y.moveTo(o.x,o.y),y.lineTo(d.x,d.y)}):p.forEach(y=>y.moveTo(d.x,d.y))):p.forEach(y=>y.lineTo(d.x,d.y))}h&&l&&h.forEach(c=>c.stroke())}stopRealTimeDrawing(){this.isRealTimeDrawing=!1,this.lastDrawnPosition=null}clear(){this.commonPath.clear(),this.chargePath.clear(),this.transitionsPath.clear(),this.mopPathTrack.clear(),this.mopPath.clear(),this.debugPoints.clear(),this.pathData=null,this.lastPointCount=0,this.lastDrawnPosition=null,this.isRealTimeDrawing=!1}destroy(t){const{emitter:i}=this.appService;i.off("antiScale",this.throttledUpdateLineWidth),i.off("robotPositionUpdate",this.throttledHandleRobotPosition),i.off("robotAnimationComplete",this.handleRobotAnimationComplete),this.unsubscribeFns.forEach(s=>s()),this.unsubscribeFns=[],this.stopRealTimeDrawing(),super.destroy(t)}}class Qx extends Xt{constructor(e){super(e),this.appService=e,this.initializeSprite()}async initializeSprite(){await this.loadTextureAndSetSize("robot",this.appService.robotConfig.icon)}async draw({x:e,y:t,rotation:i}){super.draw({x:e,y:t,rotation:i})}}const it=class it extends vs{constructor(t,i){super(i||[]);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"sizeFixed",!0);g(this,"baselineScale",1);this.appService=t,this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ct(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,i){this.fixedWidth=t,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,t&&this.isFixedSizeSet?this.applySize():!t&&this.isFixedSizeSet&&this.applySize()}set width(t){this.isFixedSizeSet||this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet||this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.textures||this.textures.length===0||!this.textures[0]||this.textures[0].width===0||this.textures[0].height===0)return;const t=this.textures[0],i=this.fixedWidth/t.width,s=this.fixedHeight/t.height;if(this.sizeFixed){const n=this.appService.currentScale;if(n===0||!isFinite(n)){const h=i,l=s;super.scale.set(h,l);return}const o=i/n,a=s/n;super.scale.set(o,a)}else super.scale.set(i/this.baselineScale,s/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():t!==0&&super.scale.set(1/t))}static async loadAnimationTextures(t,i,s="sleep_",n=96){try{const a=await(await fetch(t)).json();a.meta&&(a.meta.image=i),await N.load(i);const h=G.from(i),l=new On(h.source,a);await l.parse();const c=[];for(let d=0;d<n;d++){const u=d.toString().padStart(3,"0"),p=`${s}${u}.png`,f=l.textures[p];f?c.push(f):w.warn(`[EnhancedAnimatedSprite] Frame not found: ${p}`)}return c}catch(o){return w.error("[EnhancedAnimatedSprite] Failed to load textures:",o),[]}}setupAnimation(t){t.sizeFixed!==void 0&&this.setSizeFixed(t.sizeFixed),this.setFixedSize(t.width,t.height),this.animationSpeed=.5,this.loop=!0,w.log(`Animation setup complete, visible=${this.visible}, scale=(${this.scale.x.toFixed(3)}, ${this.scale.y.toFixed(3)})`)}draw(t,i){const{x:s,y:n}=t;i&&!this.visible?this.visible=i():!i&&!this.visible&&(this.visible=!0),this.position.set(s,n)}play(){this.textures&&this.textures.length>0&&(super.play(),it.animatedSprites.add(this),it.startAnimationTicker())}stop(){super.stop(),it.animatedSprites.delete(this),it.updateAnimationTicker()}set textures(t){super.textures=t,this.isFixedSizeSet&&t&&t.length>0&&t[0]&&t[0].width>0&&t[0].height>0&&this.applySize()}get textures(){return super.textures}static startAnimationTicker(){var t;(t=it.animationTicker)!=null&&t.started||(it.animationTicker||(it.animationTicker=new yt,it.animationTicker.maxFPS=24,it.animationTicker.add(()=>{const i=it.animatedSprites.values().next().value;i&&it.updateAnimations(i.appService)})),it.animationTicker.start(),w.log("🎬 [AnimationTicker] Started animation ticker"))}static updateAnimationTicker(){it.animatedSprites.size>0?it.startAnimationTicker():it.stopAnimationTicker()}static stopAnimationTicker(){var t;(t=it.animationTicker)!=null&&t.started&&(w.log("⏸️ [AnimationTicker] Stopped animation ticker"),it.animationTicker.stop())}static updateAnimations(t){if(it.animatedSprites.size===0)return;const i=t.getApp();i.renderer.render(i.stage)}destroy(t){it.animatedSprites.delete(this),it.updateAnimationTicker(),this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}};g(it,"animationTicker",null),g(it,"animatedSprites",new Set);let Ms=it;class Wr extends Ms{constructor(t,i){super(t,i);g(this,"unsubscribeFns",[]);g(this,"throttledUpdateOffset");g(this,"fixedOffsetX",0);g(this,"fixedOffsetY",0);this.appService=t,this.throttledUpdateOffset=Ct(this.updateOffset.bind(this),30,{leading:!0,trailing:!0}),this.initializeAnimation()}static async create(t){const i=t.robotConfig,s=await Ms.loadAnimationTextures(i.sleepAnimation.jsonSrc,i.sleepAnimation.imageSrc,i.sleepAnimation.framePrefix,i.sleepAnimation.frameCount);s.length===0&&(w.warn("No textures loaded for sleep animation"),s.push(G.EMPTY));const n=new Wr(t,s);return n.setupAnimation({width:i.sleepAnimation.width,height:i.sleepAnimation.height,sizeFixed:i.sleepAnimation.sizeFixed}),n}initializeAnimation(){this.visible=!1,this.fixedOffsetX=this.appService.robotConfig.sleepAnimation.offsetX,this.fixedOffsetY=this.appService.robotConfig.sleepAnimation.offsetY,this.appService.emitter.on("antiScale",this.throttledUpdateOffset);const t=W(this.appService.runtime,"showRobotSleepAnimation",i=>{w.log(`[runtime] showRobotSleepAnimation: ${i}`),this.updateVisibility()});this.unsubscribeFns.push(t)}shouldShow(){const t=this.appService.runtimeSnapshot.showRobotSleepAnimation,i=this.parent,s=i?i.visible:!1,n=i&&(i.x!==0||i.y!==0);return t&&s&&!!n}updateVisibility(){const t=this.shouldShow();t&&!this.visible?(this.visible=!0,this.textures&&this.textures.length>0&&this.play()):!t&&this.visible?(this.visible=!1,this.stop()):!t&&this.playing&&this.stop()}updateOffset(){}draw(t){const i=this.appService.getApp().toFixedSize(this.appService.robotConfig.sleepAnimation.offsetX),s=this.appService.getApp().toFixedSize(this.appService.robotConfig.sleepAnimation.offsetY),n={...t,x:t.x+i,y:t.y+s};super.draw(n,()=>this.shouldShow()),this.updateVisibility()}onRobotVisibilityChanged(){this.updateVisibility()}set visible(t){const i=super.visible;super.visible=t,t&&!i&&this.textures&&this.textures.length>0?this.play():!t&&i&&this.playing&&this.stop()}get visible(){return super.visible}destroy(t){this.appService.emitter.off("antiScale",this.throttledUpdateOffset),this.unsubscribeFns.forEach(i=>i()),this.unsubscribeFns=[],this.stop(),super.destroy(t)}}class Jx extends H{constructor(t){super();g(this,"currentPosition",null);g(this,"animationStartTime",0);g(this,"isAnimating",!1);g(this,"handleScaleChange",()=>{this.redraw()});g(this,"updateAnimation",()=>{if(!this.currentPosition||!this.isAnimating||!this.visible)return;const t=this.appService,i=t.robotConfig.pulseCircle,n=(Date.now()-this.animationStartTime)%i.duration/i.duration,{minScale:o,maxScale:a,minAlpha:h,maxAlpha:l}=i,c=o+(a-o)*(Math.sin(n*Math.PI*2)*.5+.5),d=l-(l-h)*(c-o)/(a-o);super.clear();const{size:u,color:p,strokeWidth:f,strokeColor:y,sizeFixed:m}=i,S=(m?t.getApp().toFixedSize(u/2):u/2)*c,v=t.getApp().toFixedSize(f);this.setFillStyle({color:p,alpha:d}),this.circle(this.currentPosition.x,this.currentPosition.y,S).fill().stroke({color:y,width:v,alpha:d,cap:"round",join:"round"})});this.appService=t,this.setupAntiScaleListener()}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.handleScaleChange)}draw(t){this.currentPosition=t,this.isAnimating||this.startAnimation(),this.redraw()}startAnimation(){const t=this.appService;this.isAnimating||(this.isAnimating=!0,this.animationStartTime=Date.now(),t.getApp().ticker.add(this.updateAnimation,this),t.getApp().requestRender("pulse-circle-animation",!0))}stopAnimation(){const t=this.appService;this.isAnimating&&(this.isAnimating=!1,t.getApp().ticker.remove(this.updateAnimation,this),t.getApp().stopRender("pulse-circle-animation"))}redraw(){this.currentPosition&&this.isAnimating&&this.updateAnimation()}clearCircle(){super.clear()}remove(){this.stopAnimation(),this.clearCircle(),this.currentPosition=null}destroy(){this.stopAnimation(),this.appService.emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class tS extends L{constructor(t){super();g(this,"robot");g(this,"ring");g(this,"pulseCircle");g(this,"sleepAnimation",null);g(this,"unsubscribeFns",[]);g(this,"clickHandler");g(this,"targetPosition",null);g(this,"targetRotation",null);g(this,"isMoving",!1);g(this,"pathQueue",[]);g(this,"lastPosition",null);g(this,"currentPathType");g(this,"lastUpdateTime",0);g(this,"isCleared",!1);this.appService=t,t.appContainer.addToLayer(mc,this),this.visible=t.runtime.showRobot,this.ring=new yc(this.appService,{config:this.appService.robotConfig.ring}),this.ring.visible=this.appService.runtime.showRobotRing,this.addChild(this.ring),this.pulseCircle=new Jx(this.appService),this.pulseCircle.visible=t.runtime.showRobotPulseCircle,this.addChild(this.pulseCircle),this.robot=new Qx(this.appService),this.addChild(this.robot),this.lastUpdateTime=Date.now(),this.appService.robotConfig.speed>0&&this.appService.getApp().ticker.add(this.update,this);const s=W(this.appService.runtime,"showRobotRing",o=>{w.log(`[runtime] showRobotRing: ${o}`),this.ring.visible=o});this.unsubscribeFns.push(s);const n=W(this.appService.runtime,"showRobotPulseCircle",o=>{w.log(`[runtime] showRobotPulseCircle: ${o}`),o?(this.lastPosition&&this.pulseCircle.draw(this.lastPosition),this.pulseCircle.visible=!0):(this.pulseCircle.remove(),this.pulseCircle.visible=!1)});this.unsubscribeFns.push(n),this.initClickInteraction()}async initializeSleepAnimation(){try{this.sleepAnimation=await Wr.create(this.appService),this.addChild(this.sleepAnimation),w.log("Sleep animation added to robot")}catch(t){w.error("Failed to initialize sleep animation:",t)}}updatePositionByOrigin(t,i){this.position.set(t,i)}async draw({x:t,y:i,rotation:s}){this.isCleared&&(this.robot.visible=!0,this.ring.visible=this.appService.runtime.showRobotRing,this.pulseCircle.visible=this.appService.runtime.showRobotPulseCircle,this.sleepAnimation&&(this.sleepAnimation.visible=!0),this.isCleared=!1),this.ring.draw({x:t,y:i}),this.pulseCircle.draw({x:t,y:i}),await this.robot.draw({x:t,y:i,rotation:s}),this.sleepAnimation||await this.initializeSleepAnimation(),this.sleepAnimation.draw({x:t,y:i}),this.lastPosition={x:t,y:i},this.sleepAnimation.draw({x:t,y:i}),this.lastPosition={x:t,y:i}}initClickInteraction(){const{enableRobotClick:t}=this.appService.interactionConfig;t?this.clickHandler||(this.clickHandler=new vt(this.robot,{onClick:()=>{var s;const i=this.getCurrentPosition();i&&((s=this.appService.events)!=null&&s.onClickRobot)&&this.appService.events.onClickRobot({...i,rotation:this.robot.rotation})}})):this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=void 0,this.robot.interactive=!1,this.robot.eventMode="none")}getCurrentPosition(){return this.lastPosition?this.appService.fixPrecision({...this.lastPosition}):null}moveTo(t){this.pathQueue.push(t),this.isMoving||this.processNextPathPoint()}batchProcessQueue(t=!1){if(this.pathQueue.length===0)return;const i=[...this.pathQueue];if(t){const s=i[i.length-1];this.robot.position.set(s.x,s.y),s.rotation!==void 0&&(this.robot.rotation=s.rotation),this.lastPosition={x:s.x,y:s.y},this.pathQueue=[],this.isMoving=!1,this.targetPosition=null}else this.pathQueue.splice(0,i.length),this.pathQueue.length===0?(this.isMoving=!1,this.targetPosition=null):this.processNextPathPoint()}processNextPathPoint(){if(this.pathQueue.length===0){this.isMoving=!1,this.currentPathType=void 0,this.stopRobotAnimation(),this.appService.emitter.emit("robotAnimationComplete");return}this.isMoving||this.startRobotAnimation(),this.isMoving=!0;const t=this.pathQueue[0];this.targetPosition={x:t.x,y:t.y},this.currentPathType=t.type,t.rotation!==void 0&&(this.targetRotation=t.rotation),this.lastPosition||(this.lastPosition={x:this.robot.x,y:this.robot.y})}update(){const t=Date.now();if(this.lastUpdateTime===0){this.lastUpdateTime=t;return}let i=t-this.lastUpdateTime;if(this.lastUpdateTime=t,i>500&&(i=16.67),this.targetPosition){const s=this.targetPosition.x-this.robot.x,n=this.targetPosition.y-this.robot.y,o=Math.sqrt(s*s+n*n),a=this.appService.robotConfig.speed,h=this.appService.getApp().metersToPixels(a);if(a===0){this.robot.position.set(this.targetPosition.x,this.targetPosition.y),this.targetRotation!==null&&(this.robot.rotation=this.targetRotation,this.targetRotation=null),this.targetPosition=null,this.lastPosition={x:this.robot.x,y:this.robot.y},this.pathQueue.shift(),this.processNextPathPoint();return}const l=h*(i/1e3);o<l?(this.robot.position.set(this.targetPosition.x,this.targetPosition.y),this.targetRotation!==null&&(this.robot.rotation=this.targetRotation,this.targetRotation=null),this.targetPosition=null,this.lastPosition={x:this.robot.x,y:this.robot.y},this.pathQueue.shift(),this.processNextPathPoint()):(this.robot.x+=s*(l/o),this.robot.y+=n*(l/o),this.appService.emitter.emit("robotPositionUpdate",{x:this.robot.x,y:this.robot.y,pathType:this.currentPathType}),this.lastPosition={x:this.robot.x,y:this.robot.y})}}startRobotAnimation(){this.appService.getApp().requestRender("robot-animation",!0)}set visible(t){super.visible=t,this.sleepAnimation&&this.sleepAnimation.onRobotVisibilityChanged()}get visible(){return super.visible}stopRobotAnimation(){this.appService.getApp().stopRender("robot-animation")}remove(){this.pathQueue=[],this.isMoving=!1,this.targetPosition=null,this.stopRobotAnimation()}clear(){this.remove(),this.robot.visible=!1,this.ring.visible=!1,this.pulseCircle.remove(),this.sleepAnimation&&(this.sleepAnimation.visible=!1),this.lastPosition=null,this.isCleared=!0}destroy(t){this.unsubscribeFns.forEach(s=>s()),this.unsubscribeFns=[],this.stopRobotAnimation(),this.appService.robotConfig.speed>0&&this.appService.getApp().ticker.remove(this.update,this),this.ring.destroy(),this.pulseCircle.destroy(),this.clickHandler&&this.clickHandler.destroy(),super.destroy(t)}}class eS{constructor(e){g(this,"path");g(this,"robot");g(this,"unsubscribeFns",[]);g(this,"lastDrawnPathData",null);this.appService=e,this.path=new $x(this.appService),this.robot=new tS(this.appService);const t=W(e.runtime,"showPath",s=>{w.log(`[runtime] showPath: ${s}`),this.path.visible=s}),i=W(e.runtime,"showRobot",s=>{w.log(`[runtime] showRobot: ${s}`),this.robot.visible=s});this.unsubscribeFns.push(t,i)}draw(e){var s,n,o;const t=(s=e.pathHeader)==null?void 0:s.pathId,i=(o=(n=this.lastDrawnPathData)==null?void 0:n.pathHeader)==null?void 0:o.pathId;this.lastDrawnPathData&&t!==i&&(this.path.clear(),this.lastDrawnPathData=null),this.shouldUseIncrementalDraw(e)?this.incrementalDraw(e):this.fullDraw(e),this.lastDrawnPathData=e}shouldUseIncrementalDraw(e){var h,l,c,d;if(!this.lastDrawnPathData)return!1;const t=(h=e.pathHeader)==null?void 0:h.pathId,i=(l=this.lastDrawnPathData.pathHeader)==null?void 0:l.pathId;if(t!==i)return!1;const s=((c=e.pathPoints)==null?void 0:c.length)||0,n=((d=this.lastDrawnPathData.pathPoints)==null?void 0:d.length)||0,o=s-n,a=this.appService.pathConfig.incrementalThreshold;return!(o<=0||o>a)}fullDraw(e){if(this.path.stopRealTimeDrawing(),this.path.drawFull(e),e.pathPoints&&e.pathPoints.length>0){const t=e.pathPoints[e.pathPoints.length-1];this.moveRobotToPoint(t,e.pathHeader.direction,!1)}else this.robot.clear()}convertToRobotPoint(e,t){const i=t+this.appService.robotConfig.rotationCorrection;return{x:e.x,y:e.y,rotation:i*Math.PI/180,type:e.type}}moveRobotToPoint(e,t,i=!0){const s=this.convertToRobotPoint(e,t);i?this.robot.moveTo(s):(this.robot.remove(),this.robot.draw(s))}incrementalDraw(e){var o;if(!this.lastDrawnPathData||!e.pathPoints)return;this.path.drawIncremental(e);const t=((o=this.lastDrawnPathData.pathPoints)==null?void 0:o.length)||0,i=e.pathPoints.slice(t);if(i.length===0)return;if(this.appService.robotConfig.speed>0)i.forEach(a=>{this.moveRobotToPoint(a,e.pathHeader.direction,!0)});else{const a=i[i.length-1];this.moveRobotToPoint(a,e.pathHeader.direction,!1)}}batchProcessRobotQueue(e=!1){this.robot.batchProcessQueue(e)}updatePositionByOrigin(e,t){this.path.updatePositionByOrigin(e,t),this.robot.updatePositionByOrigin(e,t)}clear(){this.lastDrawnPathData=null,this.path.clear(),this.robot.clear()}destroy(){this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[],this.path.destroy(),this.robot.destroy()}}class iS extends L{constructor(t){super();g(this,"colorGradients",[]);g(this,"cellSize",2);this.appService=t,this.appService.appContainer.addToLayer(uc,this);const i=this.appService.heatMapConfig;this.colorGradients=i.colorGradients.map(s=>new rt(s).toArray().slice(0,3).join(",")),this.cellSize=i.cellSize}draw(t,i=.8){this.removeChildren();const{useGradient:s}=this.appService.heatMapConfig,n=s?this.gradientDrawing(t):this.gridDrawing(t);this.croppingHeatmap(n),n.alpha=i,this.addChild(n)}croppingHeatmap(t){var a;const i=((a=this.appService.mapState)==null?void 0:a.origin)||{x:0,y:0},n=this.appService.mapManager.roomFill.children.filter(h=>h instanceof H),o=new H;for(const h of n)o.context.instructions.push(...h.context.instructions);o.context.dirty=!0,o.position.set(-i.x,-i.y),t.setMask({mask:o}),this.addChild(o)}gridDrawing(t){const i=[],s=[],n=t.length,o=t[0].length;for(let c=0;c<n;c++)for(let d=0;d<o;d++){const u=t[c][d],p=this.cellSize/2,f=u.x-p,y=u.y-p,m=u.x+p,x=u.y+p;i.push(f,y),s.push(u.signal),i.push(m,y),s.push(u.signal),i.push(m,x),s.push(u.signal),i.push(f,y),s.push(u.signal),i.push(m,x),s.push(u.signal),i.push(f,x),s.push(u.signal)}const a=new Gi({attributes:{aPosition:new Float32Array(i),aSignal:new Float32Array(s)}}),h=new Be({glProgram:new si({vertex:`
|
|
501
|
+
`?(c.push(d),d=[]):ot.length>0&&d.push({text:ot,style:Z.style})}}(d.length>0||c.length===0)&&c.push(d);const u=t?wm(c,e,i,s,o,a):c,p=[],f=[],y=[],m=[],x=[];let S=0;const v=e._fontString,b=n(v);b.fontSize===0&&(b.fontSize=e.fontSize,b.ascent=e.fontSize);let P="",C=!!e.dropShadow;for(const Z of u){let R=0,D=b.ascent,ot=b.descent,z="";for(const Y of Z){const ht=Y.style._fontString,bt=n(ht);ht!==P&&(i.font=ht,P=ht);const wt=s(Y.text,Y.style.letterSpacing,i);R+=wt,D=Math.max(D,bt.ascent),ot=Math.max(ot,bt.descent),z+=Y.text,!C&&Y.style.dropShadow&&(C=!0)}Z.length===0&&(D=b.ascent,ot=b.descent),p.push(R),f.push(D),y.push(ot),x.push(z);const q=e.lineHeight||D+ot;m.push(q+e.leading),S=Math.max(S,R)}const A=((F=e._stroke)==null?void 0:F.width)||0,T=(t&&e.align!=="left"&&e.align!=="justify"?Math.max(S,e.wordWrapWidth):S)+A+(e.dropShadow?e.dropShadow.distance:0);let _=0;for(let Z=0;Z<m.length;Z++)_+=m[Z];_=Math.max(_,m[0]+A);const E=_+(e.dropShadow?e.dropShadow.distance:0),B=e.lineHeight||b.fontSize;return{width:T,height:E,lines:x,lineWidths:p,lineHeight:B+e.leading,maxLineWidth:S,fontProperties:b,runsByLine:u,lineAscents:f,lineDescents:y,lineHeights:m,hasDropShadow:C}}function wm(r,e,t,i,s,n){var m;const{letterSpacing:o,whiteSpace:a,wordWrapWidth:h,breakWords:l}=e,c=Wl(a),d=h+o,u={};let p="";const f=(x,S)=>{const v=`${x}|${S.styleKey}`;let b=u[v];if(b===void 0){const P=S._fontString;P!==p&&(t.font=P,p=P),b=i(x,S.letterSpacing,t)+S.letterSpacing,u[v]=b}return b},y=[];for(const x of r){const S=Cm(x),v=y.length,b=E=>{let B=0,F=E;do{const{token:Z,style:R}=S[F];B+=f(Z,R),F++}while(F<S.length&&S[F].continuesFromPrevious);return B},P=E=>{const B=[];let F=E;do B.push({token:S[F].token,style:S[F].style}),F++;while(F<S.length&&S[F].continuesFromPrevious);return B};let C=[],A=0,k=!c,M=null;const T=()=>{M&&M.text.length>0&&C.push(M),M=null},_=()=>{if(T(),C.length>0){const E=C[C.length-1];E.text=Kt(E.text),E.text.length===0&&C.pop()}y.push(C),C=[],A=0,k=!1};for(let E=0;E<S.length;E++){const{token:B,style:F,continuesFromPrevious:Z}=S[E],R=f(B,F);if(c){const z=Lt(B),q=(M==null?void 0:M.text[M.text.length-1])??((m=C[C.length-1])==null?void 0:m.text.slice(-1))??"",Y=q?Lt(q):!1;if(z&&Y)continue}const D=!Z,ot=D?b(E):R;if(ot>d&&D)if(A>0&&_(),l){const z=P(E);for(let q=0;q<z.length;q++){const Y=z[q].token,ht=z[q].style,bt=Hl(Y,l,n,s);for(const wt of bt){const kt=f(wt,ht);kt+A>d&&_(),!M||M.style!==ht?(T(),M={text:wt,style:ht}):M.text+=wt,A+=kt}}E+=z.length-1}else{const z=P(E);T(),y.push(z.map(q=>({text:q.token,style:q.style}))),k=!1,E+=z.length-1}else if(ot+A>d&&D){if(Lt(B)){k=!1;continue}_(),M={text:B,style:F},A=R}else if(Z&&!l)!M||M.style!==F?(T(),M={text:B,style:F}):M.text+=B,A+=R;else{const z=Lt(B);if(A===0&&z&&!k)continue;!M||M.style!==F?(T(),M={text:B,style:F}):M.text+=B,A+=R}}if(T(),C.length>0){const E=C[C.length-1];E.text=Kt(E.text),E.text.length===0&&C.pop()}(C.length>0||y.length===v)&&y.push(C)}return y}function Cm(r){const e=[];let t=!1;for(const i of r){const s=Ul(i.text);let n=!0;for(const o of s){const a=Lt(o)||Rr(o),h=n&&t&&!a;e.push({token:o,style:i.style,continuesFromPrevious:h}),t=!a,n=!1}}return e}const Am={willReadFrequently:!0};function Ma(r,e,t,i,s){let n=t[r];return typeof n!="number"&&(n=s(r,e,i)+e,t[r]=n),n}function Pm(r,e,t,i,s,n,o){const a=t.getContext("2d",Am);a.font=e._fontString;let h=0,l="";const c=[],d=Object.create(null),{letterSpacing:u,whiteSpace:p}=e,f=Wl(p),y=Gl(p);let m=!f;const x=e.wordWrapWidth+u,S=Ul(r);for(let b=0;b<S.length;b++){let P=S[b];if(Rr(P)){if(!y){c.push(Kt(l)),m=!f,l="",h=0;continue}P=" "}if(f){const A=Lt(P),k=Lt(l[l.length-1]);if(A&&k)continue}const C=Ma(P,u,d,a,i);if(C>x)if(l!==""&&(c.push(Kt(l)),l="",h=0),s(P,e.breakWords)){const A=Hl(P,e.breakWords,o,n);for(const k of A){const M=Ma(k,u,d,a,i);M+h>x&&(c.push(Kt(l)),m=!1,l="",h=0),l+=k,h+=M}}else l.length>0&&(c.push(Kt(l)),l="",h=0),c.push(Kt(P)),m=!1,l="",h=0;else C+h>x&&(m=!1,c.push(Kt(l)),l="",h=0),(l.length>0||!Lt(P)||m)&&(l+=P,h+=C)}const v=Kt(l);return v.length>0&&c.push(v),c.join(`
|
|
502
|
+
`)}const _a={willReadFrequently:!0},ie=class O{static get experimentalLetterSpacingSupported(){let e=O._experimentalLetterSpacingSupported;if(e===void 0){const t=j.get().getCanvasRenderingContext2D().prototype;e=O._experimentalLetterSpacingSupported="letterSpacing"in t||"textLetterSpacing"in t}return e}constructor(e,t,i,s,n,o,a,h,l,c){this.text=e,this.style=t,this.width=i,this.height=s,this.lines=n,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(e=" ",t,i=O._canvas,s=t.wordWrap){var P;const n=`${e}-${t.styleKey}-wordWrap-${s}`;if(O._measurementCache.has(n))return O._measurementCache.get(n);if(Ll(t)&&Ol(e)){const C=bm(e,t,s,O._context,O._measureText,O.measureFont,O.canBreakChars,O.wordWrapSplit),A=new O(e,t,C.width,C.height,C.lines,C.lineWidths,C.lineHeight,C.maxLineWidth,C.fontProperties,{runsByLine:C.runsByLine,lineAscents:C.lineAscents,lineDescents:C.lineDescents,lineHeights:C.lineHeights,hasDropShadow:C.hasDropShadow});return O._measurementCache.set(n,A),A}const a=t._fontString,h=O.measureFont(a);h.fontSize===0&&(h.fontSize=t.fontSize,h.ascent=t.fontSize,h.descent=0);const l=O._context;l.font=a;const d=(s?O._wordWrap(e,t,i):e).split(Sm),u=new Array(d.length);let p=0;for(let C=0;C<d.length;C++){const A=O._measureText(d[C],t.letterSpacing,l);u[C]=A,p=Math.max(p,A)}const f=((P=t._stroke)==null?void 0:P.width)??0,y=t.lineHeight||h.fontSize,m=O._getAlignWidth(p,t,s),x=O._adjustWidthForStyle(m,t),S=Math.max(y,h.fontSize+f)+(d.length-1)*(y+t.leading),v=O._adjustHeightForStyle(S,t),b=new O(e,t,x,v,d,u,y+t.leading,p,h);return O._measurementCache.set(n,b),b}static _adjustWidthForStyle(e,t){var n;const i=((n=t._stroke)==null?void 0:n.width)||0;let s=e+i;return t.dropShadow&&(s+=t.dropShadow.distance),s}static _adjustHeightForStyle(e,t){let i=e;return t.dropShadow&&(i+=t.dropShadow.distance),i}static _getAlignWidth(e,t,i){return i&&t.align!=="left"&&t.align!=="justify"?Math.max(e,t.wordWrapWidth):e}static _measureText(e,t,i){let s=!1;O.experimentalLetterSpacingSupported&&(O.experimentalLetterSpacing?(i.letterSpacing=`${t}px`,i.textLetterSpacing=`${t}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const n=i.measureText(e);let o=n.width;const a=-(n.actualBoundingBoxLeft??0);let l=(n.actualBoundingBoxRight??0)-a;if(o>0)if(s)o-=t,l-=t;else{const c=(O.graphemeSegmenter(e).length-1)*t;o+=c,l+=c}return Math.max(o,l)}static _wordWrap(e,t,i=O._canvas){return Pm(e,t,i,O._measureText,O.canBreakWords,O.canBreakChars,O.wordWrapSplit)}static isBreakingSpace(e,t){return Lt(e)}static canBreakWords(e,t){return t}static canBreakChars(e,t,i,s,n){return!0}static wordWrapSplit(e){return O.graphemeSegmenter(e)}static measureFont(e){if(O._fonts[e])return O._fonts[e];const t=O._context;t.font=e;const i=t.measureText(O.METRICS_STRING+O.BASELINE_SYMBOL),s=i.actualBoundingBoxAscent??0,n=i.actualBoundingBoxDescent??0,o={ascent:s,descent:n,fontSize:s+n};return O._fonts[e]=o,o}static clearMetrics(e=""){e?delete O._fonts[e]:O._fonts={}}static get _canvas(){if(!O.__canvas){let e;try{const t=new OffscreenCanvas(0,0),i=t.getContext("2d",_a);if(i!=null&&i.measureText)return O.__canvas=t,t;e=j.get().createCanvas()}catch{e=j.get().createCanvas()}e.width=e.height=10,O.__canvas=e}return O.__canvas}static get _context(){return O.__context||(O.__context=O._canvas.getContext("2d",_a)),O.__context}};ie.METRICS_STRING="|ÉqÅ";ie.BASELINE_SYMBOL="M";ie.BASELINE_MULTIPLIER=1.4;ie.HEIGHT_MULTIPLIER=2;ie.graphemeSegmenter=r=>[...r];ie.experimentalLetterSpacing=!1;ie._fonts={};ie._measurementCache=dm(1e3);let se=ie;const Mm=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Jn(r){const e=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let t=r.fontFamily;Array.isArray(r.fontFamily)||(t=r.fontFamily.split(","));for(let i=t.length-1;i>=0;i--){let s=t[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!Mm.includes(s)&&(s=`"${s}"`),t[i]=s}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${e} ${t.join(",")}`}const Ta=1e5;function cs(r,e,t,i=0,s=0,n=0){if(r.texture===W.WHITE&&!r.fill)return rt.shared.setValue(r.color).setAlpha(r.alpha??1).toHexa();if(r.fill){if(r.fill instanceof Is){const o=r.fill,a=e.createPattern(o.texture.source.resource,"repeat"),h=o.transform.copyTo(U.shared);return h.scale(o.texture.source.pixelWidth,o.texture.source.pixelHeight),a.setTransform(h),a}else if(r.fill instanceof Ot){const o=r.fill,a=o.type==="linear",h=o.textureSpace==="local";let l=1,c=1;h&&t&&(l=t.width+i,c=t.height+i);let d,u=!1;if(a){const{start:p,end:f}=o;d=e.createLinearGradient(p.x*l+s,p.y*c+n,f.x*l+s,f.y*c+n),u=Math.abs(f.x-p.x)<Math.abs((f.y-p.y)*.1)}else{const{center:p,innerRadius:f,outerCenter:y,outerRadius:m}=o;d=e.createRadialGradient(p.x*l+s,p.y*c+n,f*l,y.x*l+s,y.y*c+n,m*l)}if(u&&h&&t){const p=t.lineHeight/c;for(let f=0;f<t.lines.length;f++){const y=(f*t.lineHeight+i/2)/c;o.colorStops.forEach(m=>{let x=y+m.offset*p;x=Math.max(0,Math.min(1,x)),d.addColorStop(Math.floor(x*Ta)/Ta,rt.shared.setValue(m.color).toHex())})}}else o.colorStops.forEach(p=>{d.addColorStop(p.offset,rt.shared.setValue(p.color).toHex())});return d}}else{const o=e.createPattern(r.texture.source.resource,"repeat"),a=r.matrix.copyTo(U.shared);return a.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),o.setTransform(a),o}return nt("FillStyle not recognised",r),"red"}const ka=new et;class _m{getCanvasAndContext(e){const{text:t,style:i,resolution:s=1}=e,n=i._getFinalPadding(),o=se.measureText(t||" ",i),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*s),h=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*s),l=Qn.getOptimalCanvasAndContext(a,h);this._renderTextToCanvas(i,n,s,l,o);const c=i.trim?lm({canvas:l.canvas,width:a,height:h,resolution:1,output:ka}):ka.set(0,0,a,h);return{canvasAndContext:l,frame:c}}returnCanvasAndContext(e){Qn.returnCanvasAndContext(e)}_renderTextToCanvas(e,t,i,s,n){var C,A,k;if(n.runsByLine&&n.runsByLine.length>0){this._renderTaggedTextToCanvas(n,e,t,i,s);return}const{canvas:o,context:a}=s,h=Jn(e),l=n.lines,c=n.lineHeight,d=n.lineWidths,u=n.maxLineWidth,p=n.fontProperties,f=o.height;if(a.resetTransform(),a.scale(i,i),a.textBaseline=e.textBaseline,(C=e._stroke)!=null&&C.width){const M=e._stroke;a.lineWidth=M.width,a.miterLimit=M.miterLimit,a.lineJoin=M.join,a.lineCap=M.cap}a.font=h;let y,m;const x=e.dropShadow?2:1,S=e.wordWrap?e.wordWrapWidth:u,b=(((A=e._stroke)==null?void 0:A.width)??0)/2;let P=(c-p.fontSize)/2;c-p.fontSize<0&&(P=0);for(let M=0;M<x;++M){const T=e.dropShadow&&M===0,_=T?Math.ceil(Math.max(1,f)+t*2):0,E=_*i;if(T)this._setupDropShadow(a,e,i,E);else{const B=e._gradientBounds,F=e._gradientOffset;if(B){const Z={width:B.width,height:B.height,lineHeight:B.height,lines:n.lines};this._setFillAndStrokeStyles(a,e,Z,t,b,(F==null?void 0:F.x)??0,(F==null?void 0:F.y)??0)}else F?this._setFillAndStrokeStyles(a,e,n,t,b,F.x,F.y):this._setFillAndStrokeStyles(a,e,n,t,b);a.shadowColor="black"}for(let B=0;B<l.length;B++)y=b,m=b+B*c+p.ascent+P,y+=this._getAlignmentOffset(d[B],S,e.align),(k=e._stroke)!=null&&k.width&&this._drawLetterSpacing(l[B],e,s,y+t,m+t-_,!0),e._fill!==void 0&&this._drawLetterSpacing(l[B],e,s,y+t,m+t-_)}}_renderTaggedTextToCanvas(e,t,i,s,n){var b,P;const{canvas:o,context:a}=n,{runsByLine:h,lineWidths:l,maxLineWidth:c,lineAscents:d,lineHeights:u,hasDropShadow:p}=e,f=o.height;a.resetTransform(),a.scale(s,s),a.textBaseline=t.textBaseline;const y=p?2:1,m=t.wordWrap?t.wordWrapWidth:c,S=(((b=t._stroke)==null?void 0:b.width)??0)/2,v=[];for(let C=0;C<h.length;C++){const A=h[C],k=[];for(const M of A){const T=Jn(M.style);a.font=T,k.push({width:se._measureText(M.text,M.style.letterSpacing,a),font:T})}v.push(k)}for(let C=0;C<y;++C){const A=p&&C===0,k=A?Math.ceil(Math.max(1,f)+i*2):0,M=k*s;A||(a.shadowColor="black");let T=S;for(let _=0;_<h.length;_++){const E=h[_],B=l[_],F=d[_],Z=u[_],R=v[_];let D=S;D+=this._getAlignmentOffset(B,m,t.align);const ot=T+F;let z=D+i;for(let q=0;q<E.length;q++){const Y=E[q],{width:ht,font:bt}=R[q];if(a.font=bt,a.textBaseline=Y.style.textBaseline,(P=Y.style._stroke)!=null&&P.width){const wt=Y.style._stroke;if(a.lineWidth=wt.width,a.miterLimit=wt.miterLimit,a.lineJoin=wt.join,a.lineCap=wt.cap,A)if(Y.style.dropShadow)this._setupDropShadow(a,Y.style,s,M);else{z+=ht;continue}else{const kt=se.measureFont(bt),Wt=Y.style.lineHeight||kt.fontSize,Yi={width:ht,height:Wt,lineHeight:Wt,lines:[Y.text]};a.strokeStyle=cs(wt,a,Yi,i*2,z-i,T)}this._drawLetterSpacing(Y.text,Y.style,n,z,ot+i-k,!0)}z+=ht}z=D+i;for(let q=0;q<E.length;q++){const Y=E[q],{width:ht,font:bt}=R[q];if(a.font=bt,a.textBaseline=Y.style.textBaseline,Y.style._fill!==void 0){if(A)if(Y.style.dropShadow)this._setupDropShadow(a,Y.style,s,M);else{z+=ht;continue}else{const wt=se.measureFont(bt),kt=Y.style.lineHeight||wt.fontSize,Wt={width:ht,height:kt,lineHeight:kt,lines:[Y.text]};a.fillStyle=cs(Y.style._fill,a,Wt,i*2,z-i,T)}this._drawLetterSpacing(Y.text,Y.style,n,z,ot+i-k,!1)}z+=ht}T+=Z}}}_setFillAndStrokeStyles(e,t,i,s,n,o=0,a=0){var h;if(e.fillStyle=t._fill?cs(t._fill,e,i,s*2,o,a):null,(h=t._stroke)!=null&&h.width){const l=n+s*2;e.strokeStyle=cs(t._stroke,e,i,l,o,a)}}_setupDropShadow(e,t,i,s){e.fillStyle="black",e.strokeStyle="black";const n=t.dropShadow,o=n.color,a=n.alpha;e.shadowColor=rt.shared.setValue(o).setAlpha(a).toRgbaString();const h=n.blur*i,l=n.distance*i;e.shadowBlur=h,e.shadowOffsetX=Math.cos(n.angle)*l,e.shadowOffsetY=Math.sin(n.angle)*l+s}_getAlignmentOffset(e,t,i){return i==="right"?t-e:i==="center"?(t-e)/2:0}_drawLetterSpacing(e,t,i,s,n,o=!1){const{context:a}=i,h=t.letterSpacing;let l=!1;if(se.experimentalLetterSpacingSupported&&(se.experimentalLetterSpacing?(a.letterSpacing=`${h}px`,a.textLetterSpacing=`${h}px`,l=!0):(a.letterSpacing="0px",a.textLetterSpacing="0px")),h===0||l){o?a.strokeText(e,s,n):a.fillText(e,s,n);return}let c=s;const d=se.graphemeSegmenter(e);let u=a.measureText(e).width,p=0;for(let f=0;f<d.length;++f){const y=d[f];o?a.strokeText(y,c,n):a.fillText(y,c,n);let m="";for(let x=f+1;x<d.length;++x)m+=d[x];p=a.measureText(m).width,c+=u-p+h,u=p}}}const Ve=new _m,Er=class Pe extends Yt{constructor(e={}){super(),this.uid=dt("textStyle"),this._tick=0,this._cachedFontString=null,Tm(e),e instanceof Pe&&(e=e._toObject());const s={...Pe.defaultTextStyle,...e};for(const n in s){const o=n;this[o]=s[n]}this._tagStyles=e.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.update())}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow!==e&&(e!==null&&typeof e=="object"?this._dropShadow=this._createProxy({...Pe.defaultDropShadow,...e}):this._dropShadow=e?this._createProxy({...Pe.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.update())}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(typeof e=="string"?this._fontSize=parseInt(e,10):this._fontSize=e,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.update())}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.update())}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.update())}get filters(){return this._filters}set filters(e){this._filters!==e&&(this._filters=Object.freeze(e),this.update())}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.update())}get fill(){return this._originalFill}set fill(e){e!==this._originalFill&&(this._originalFill=e,this._isFillStyle(e)&&(this._originalFill=this._createProxy({...mt.defaultFillStyle,...e},()=>{this._fill=Me({...this._originalFill},mt.defaultFillStyle)})),this._fill=Me(e===0?"black":e,mt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...mt.defaultStrokeStyle,...e},()=>{this._stroke=Ss({...this._originalStroke},mt.defaultStrokeStyle)})),this._stroke=Ss(e,mt.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(e){this._tagStyles!==e&&(this._tagStyles=e??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const e=Pe.defaultTextStyle;for(const t in e)this[t]=e[t]}assign(e){for(const t in e){const i=t;this[i]=e[t]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=Jn(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 Pe(this._toObject())}_getFinalPadding(){let e=0;if(this._filters)for(let t=0;t<this._filters.length;t++)e+=this._filters[t].padding;return Math.max(this._padding,e)}destroy(e=!1){var i,s,n,o;if(this.removeAllListeners(),typeof e=="boolean"?e:e==null?void 0:e.texture){const a=typeof e=="boolean"?e:e==null?void 0:e.textureSource;(i=this._fill)!=null&&i.texture&&this._fill.texture.destroy(a),(s=this._originalFill)!=null&&s.texture&&this._originalFill.texture.destroy(a),(n=this._stroke)!=null&&n.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(e,t){return new Proxy(e,{set:(i,s,n)=>(i[s]===n||(i[s]=n,t==null||t(s,n),this.update()),!0)})}_isFillStyle(e){return(e??null)!==null&&!(rt.isColorLike(e)||e instanceof Ot||e instanceof Is)}};Er.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Er.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 ce=Er;function Tm(r){const e=r;if(typeof e.dropShadow=="boolean"&&e.dropShadow){const t=ce.defaultDropShadow;r.dropShadow={alpha:e.dropShadowAlpha??t.alpha,angle:e.dropShadowAngle??t.angle,blur:e.dropShadowBlur??t.blur,color:e.dropShadowColor??t.color,distance:e.dropShadowDistance??t.distance}}if(e.strokeThickness!==void 0){V(J,"strokeThickness is now a part of stroke");const t=e.stroke;let i={};if(rt.isColorLike(t))i.color=t;else if(t instanceof Ot||t instanceof Is)i.fill=t;else if(Object.hasOwnProperty.call(t,"color")||Object.hasOwnProperty.call(t,"fill"))i=t;else throw new Error("Invalid stroke value.");r.stroke={...i,width:e.strokeThickness}}if(Array.isArray(e.fillGradientStops)){if(V(J,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(e.fill)||e.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");e.fill.length!==e.fillGradientStops.length&&nt("The number of fill colors must match the number of fill gradient stops.");const t=new Ot({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),i=e.fillGradientStops.slice(),s=e.fill.map(n=>rt.shared.setValue(n).toNumber());i.forEach((n,o)=>{t.addColorStop(n,s[o])}),r.fill={fill:t}}}function km(r,e){const{texture:t,bounds:i}=r,s=e._style._getFinalPadding();uh(i,e._anchor,t);const n=e._anchor._x*s*2,o=e._anchor._y*s*2;i.minX-=s-n,i.minY-=s-o,i.maxX-=s-n,i.maxY-=s-o}class Rm{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 Em extends Rm{}class Vl{constructor(e){this._renderer=e,e.runners.resolutionChange.add(this),this._managedTexts=new ci({renderer:e,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const e in this._managedTexts.items){const t=this._managedTexts.items[e];t!=null&&t._autoResolution&&t.onViewUpdate()}}validateRenderable(e){const t=this._getGpuText(e),i=e.styleKey;return t.currentKey!==i?!0:e._didTextUpdate}addRenderable(e,t){const i=this._getGpuText(e);if(e._didTextUpdate){const s=e._autoResolution?this._renderer.resolution:e.resolution;(i.currentKey!==e.styleKey||e._resolution!==s)&&this._updateGpuText(e),e._didTextUpdate=!1,km(i,e)}this._renderer.renderPipes.batch.addToBatch(i,t)}updateRenderable(e){const t=this._getGpuText(e);t._batcher.updateElement(t)}_updateGpuText(e){const t=this._getGpuText(e);t.texture&&this._renderer.canvasText.decreaseReferenceCount(t.currentKey),e._resolution=e._autoResolution?this._renderer.resolution:e.resolution,t.texture=this._renderer.canvasText.getManagedTexture(e),t.currentKey=e.styleKey}_getGpuText(e){return e._gpuData[this._renderer.uid]||this.initGpuText(e)}initGpuText(e){const t=new Em;return t.currentKey="--",t.renderable=e,t.transform=e.groupTransform,t.bounds={minX:0,maxX:1,minY:0,maxY:0},t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,this._managedTexts.add(e),t}onTextUnload(e){const t=e._gpuData[this._renderer.uid];if(!t)return;const{canvasText:i}=this._renderer;i.getReferenceCount(t.currentKey)>0?i.decreaseReferenceCount(t.currentKey):t.texture&&i.returnTexture(t.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}Vl.extension={type:[I.WebGLPipes,I.WebGPUPipes,I.CanvasPipes],name:"text"};const Im=new Bt;function Bm(r,e,t,i){const s=Im;s.minX=0,s.minY=0,s.maxX=r.width/i|0,s.maxY=r.height/i|0;const n=_s.getOptimalTexture(s.width,s.height,i,!1);return n.source.uploadMethodId="image",n.source.resource=r,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=e/i,n.frame.height=t/i,n.source.emit("update",n.source),n.updateUvs(),n}class Nl{constructor(e,t){this._activeTextures={},this._renderer=e,this._retainCanvasContext=t}getTexture(e,t,i,s){typeof e=="string"&&(V("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),e={text:e,style:i,resolution:t}),e.style instanceof ce||(e.style=new ce(e.style)),e.textureStyle instanceof ti||(e.textureStyle=new ti(e.textureStyle)),typeof e.text!="string"&&(e.text=e.text.toString());const{text:n,style:o,textureStyle:a}=e,h=e.resolution??this._renderer.resolution,{frame:l,canvasAndContext:c}=Ve.getCanvasAndContext({text:n,style:o,resolution:h}),d=Bm(c.canvas,l.width,l.height,h);if(a&&(d.source.style=a),o.trim&&(l.pad(o.padding),d.frame.copyFrom(l),d.frame.scale(1/h),d.updateUvs()),o.filters){const u=this._applyFilters(d,o.filters);return this.returnTexture(d),Ve.returnCanvasAndContext(c),u}return this._renderer.texture.initSource(d._source),this._retainCanvasContext||Ve.returnCanvasAndContext(c),d}returnTexture(e){const t=e.source,i=t.resource;if(this._retainCanvasContext&&(i!=null&&i.getContext)){const s=i.getContext("2d");s&&Ve.returnCanvasAndContext({canvas:i,context:s})}t.resource=null,t.uploadMethodId="unknown",t.alphaMode="no-premultiply-alpha",_s.returnTexture(e,!0)}renderTextToCanvas(){V("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(e){e._resolution=e._autoResolution?this._renderer.resolution:e.resolution;const t=e.styleKey;if(this._activeTextures[t])return this._increaseReferenceCount(t),this._activeTextures[t].texture;const i=this.getTexture({text:e.text,style:e.style,resolution:e._resolution,textureStyle:e.textureStyle});return this._activeTextures[t]={texture:i,usageCount:1},i}decreaseReferenceCount(e){const t=this._activeTextures[e];t&&(t.usageCount--,t.usageCount===0&&(this.returnTexture(t.texture),this._activeTextures[e]=null))}getReferenceCount(e){var t;return((t=this._activeTextures[e])==null?void 0:t.usageCount)??0}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}_applyFilters(e,t){const i=this._renderer.renderTarget.renderTarget,s=this._renderer.filter.generateFilteredTexture({texture:e,filters:t});return this._renderer.renderTarget.bind(i,!1),s}destroy(){this._renderer=null;for(const e in this._activeTextures)this._activeTextures[e]&&this.returnTexture(this._activeTextures[e].texture);this._activeTextures=null}}class jl extends Nl{constructor(e){super(e,!0)}}jl.extension={type:[I.CanvasSystem],name:"canvasText"};class Yl extends Nl{constructor(e){super(e,!1)}}Yl.extension={type:[I.WebGLSystem,I.WebGPUSystem],name:"canvasText"};$.add(jl);$.add(Yl);$.add(Vl);class Bs extends rm{constructor(...e){const t=om(e,"Text");super(t,ce),this.renderPipeId="text",t.textureStyle&&(this.textureStyle=t.textureStyle instanceof ti?t.textureStyle:new ti(t.textureStyle))}updateBounds(){const e=this._bounds,t=this._anchor;let i=0,s=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=Ve.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Ve.returnCanvasAndContext(o),i=n.width,s=n.height}else{const n=se.measureText(this._text,this._style);i=n.width,s=n.height}e.minX=-t._x*i,e.maxX=e.minX+i,e.minY=-t._y*s,e.maxY=e.minY+s}}class Ir extends W{static create(e){const{dynamic:t,...i}=e;return new Ir({source:new Dt(i),dynamic:t??!1})}resize(e,t,i){return this.source.resize(e,t,i),this}}$.add(id,sd);function Dm(r,e){var t=-1,i=r.length;for(e||(e=Array(i));++t<i;)e[t]=r[t];return e}function Fm(r,e,t,i){var s=!t;t||(t={});for(var n=-1,o=e.length;++n<o;){var a=e[n],h=void 0;h===void 0&&(h=r[a]),s?Ja(t,a,h):th(t,a,h)}return t}function zm(r){return Tc(function(e,t){var i=-1,s=t.length,n=s>1?t[s-1]:void 0,o=s>2?t[2]:void 0;for(n=r.length>3&&typeof n=="function"?(s--,n):void 0,o&&kc(t[0],t[1],o)&&(n=s<3?void 0:n,s=1),e=Object(e);++i<s;){var a=t[i];a&&r(e,a,i,n)}return e})}function Lm(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var Om=Object.prototype,Wm=Om.hasOwnProperty;function Gm(r){if(!Ee(r))return Lm(r);var e=Rc(r),t=[];for(var i in r)i=="constructor"&&(e||!Wm.call(r,i))||t.push(i);return t}function Xl(r){return eh(r)?Ec(r,!0):Gm(r)}function Um(r){var e=r==null?0:r.length;return e?Ic(r):[]}function Hm(r){return Bc(Dc(r,void 0,Um),r+"")}var Vm="[object Object]",Nm=Function.prototype,jm=Object.prototype,Zl=Nm.toString,Ym=jm.hasOwnProperty,Xm=Zl.call(Object);function Zm(r){if(!lr(r)||ih(r)!=Vm)return!1;var e=Fc(r);if(e===null)return!0;var t=Ym.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&Zl.call(t)==Xm}var qm=Oc.isFinite,Km=Math.min;function $m(r){var e=Math[r];return function(t,i){if(t=zc(t),i=i==null?0:Km(Lc(i),292),i&&qm(t)){var s=(Kr(t)+"e").split("e"),n=e(s[0]+"e"+(+s[1]+i));return s=(Kr(n)+"e").split("e"),+(s[0]+"e"+(+s[1]-i))}return e(t)}}function tr(r,e,t){(t!==void 0&&!Wc(r[e],t)||t===void 0&&!(e in r))&&Ja(r,e,t)}function Qm(r){return lr(r)&&eh(r)}function er(r,e){if(!(e==="constructor"&&typeof r[e]=="function")&&e!="__proto__")return r[e]}function Jm(r){return Fm(r,Xl(r))}function ty(r,e,t,i,s,n,o){var a=er(r,t),h=er(e,t),l=o.get(h);if(l){tr(r,t,l);return}var c=n?n(a,h,t+"",r,e,o):void 0,d=c===void 0;if(d){var u=kn(h),p=!u&&Gc(h),f=!u&&!p&&Uc(h);c=h,u||p||f?kn(a)?c=a:Qm(a)?c=Dm(a):p?(d=!1,c=Hc(h,!0)):f?(d=!1,c=Vc(h,!0)):c=[]:Zm(h)||$r(h)?(c=a,$r(a)?c=Jm(a):(!Ee(a)||Nc(a))&&(c=jc(h))):d=!1}d&&(o.set(h,c),s(c,h,i,n,o),o.delete(h)),tr(r,t,c)}function ql(r,e,t,i,s){r!==e&&Yc(e,function(n,o){if(s||(s=new Xc),Ee(n))ty(r,e,o,t,ql,i,s);else{var a=i?i(er(r,o),n,o+"",r,e,s):void 0;a===void 0&&(a=n),tr(r,o,a)}},Xl)}var Ra=zm(function(r,e,t,i){ql(r,e,t,i)}),ey="[object Number]";function Ea(r){return typeof r=="number"||lr(r)&&ih(r)==ey}function iy(r,e,t,i){if(!Ee(r))return r;e=sh(e,r);for(var s=-1,n=e.length,o=n-1,a=r;a!=null&&++s<n;){var h=Zc(e[s]),l=t;if(h==="__proto__"||h==="constructor"||h==="prototype")return r;if(s!=o){var c=a[h];l=void 0,l===void 0&&(l=Ee(c)?c:qc(e[s+1])?[]:{})}th(a,h,l),a=a[h]}return r}function sy(r,e,t){for(var i=-1,s=e.length,n={};++i<s;){var o=e[i],a=Kc(r,o);t(a,o)&&iy(n,sh(o,r),a)}return n}function ny(r,e){return sy(r,e,function(t,i){return $c(r,i)})}var An=Hm(function(r,e){return r==null?{}:ny(r,e)}),Ia=$m("round"),ry="Expected a function";function Ct(r,e,t){var i=!0,s=!0;if(typeof r!="function")throw new TypeError(ry);return Ee(t)&&(i="leading"in t?!!t.leading:i,s="trailing"in t?!!t.trailing:s),Rn(r,e,{leading:i,maxWait:e,trailing:s})}function oy(r){return r<.5?4*r*r*r:(r-1)*(2*r-2)*(2*r-2)+1}function Kl(r,e=2){if(r==null)return r;if(Ea(r))return Ia(r,e);if(kn(r))return Qc(r,t=>Kl(t,e));if(Ee(r)){const t=["x","y","rotation"];return Jc(r,(i,s)=>Ea(i)&&t.includes(s)?Ia(i,e):i)}return r}let ir=null;function ay(r){ir=r}function Si(){return ir?ir():!1}const w={log(r,...e){Si()&&console.log(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #2196F3; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #2196F3;",...e)},warn(r,...e){Si()&&console.warn(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #FF9800; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #FF9800;",...e)},error(r,...e){Si()&&console.error(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #F44336; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #F44336;",...e)},debug(r,...e){Si()&&console.log(`%c[ray-2d-laser-map-sdk:DEBUG]%c ${r}`,"background: #9C27B0; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #9C27B0;",...e)},success(r,...e){Si()&&console.log(`%c[ray-2d-laser-map-sdk]%c ${r}`,"background: #4CAF50; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #4CAF50;",...e)}},Ba=r=>{if(r.length<=1)return[...r];const e=hy(r),t=e.slice(1).map((s,n)=>({prev:e[n],current:s})),i=new Map;return t.forEach(({prev:s,current:n})=>{ly(s,n).forEach(a=>{const h=`${a.x},${a.y}`;i.has(h)||i.set(h,a)})}),Array.from(i.values())},hy=r=>{if(r.length<=1)return[...r];const e=r[0],t=r[r.length-1];return e.x===t.x&&e.y===t.y?[...r]:[...r,e]},ly=(r,e)=>{const t=[],i=Math.abs(e.x-r.x),s=Math.abs(e.y-r.y),n=r.x<e.x?1:-1,o=r.y<e.y?1:-1;let a=i-s,h=r.x,l=r.y;for(;t.push({x:h,y:l}),!(h===e.x&&l===e.y);){const c=2*a;c>-s&&(a-=s,h+=n),c<i&&(a+=i,l+=o)}return t},$l=(r,e)=>{let t=0,i=r.length-1;for(;t<=i;){const s=Math.floor((t+i)/2),n=r[s];if(n===e)return!0;n<e?t=s+1:i=s-1}return!1},cy=(r,e,t=1,i=2e3)=>{const s=[],n=e.x-r.x,o=e.y-r.y,a=Math.sqrt(n*n+o*o);if(a===0)return[r];const h=Math.min(Math.max(Math.ceil(a/t),2),i);for(let l=0;l<=h;l++){const c=l/h,d={x:r.x+c*n,y:r.y+c*o};s.push(d)}return s},Da=(r,e,t,i,s,n=8)=>{const o=(e+i)/2,a=(t+s)/2,h={x:o,y:a},l=i-e,c=s-t,d=Math.min(n,Math.min(l,c)*.2);return Et(h,r)&&Ri(h,r)>=d?h:dy(r,h,d)},dy=(r,e,t)=>{const{minX:i,minY:s,maxX:n,maxY:o}=ws(r),a=n-i,h=o-s,l=e.x,c=e.y,d=Math.min(.5,Math.min(a,h)*.05),u=[];if(Et({x:l,y:c},r)){const S=Ri({x:l,y:c},r);u.push({point:{x:l,y:c},distance:S,centerDistance:0})}const p=Math.max(a,h)*.6,f=Math.PI/16;let y=0;const m=1e4;let x=!1;for(let S=d;S<=p&&!x;S+=d){const v=f*(1+S/p);for(let b=0;b<2*Math.PI;b+=v){if(y++,y>m){w.error(`[findBestInnerPoint] Iteration limit reached (${y}). Room size: ${a}x${h}`),x=!0;break}const P=l+S*Math.cos(b),C=c+S*Math.sin(b);if(P>=i&&P<=n&&C>=s&&C<=o){const A={x:P,y:C};if(Et(A,r)){const k=Ri(A,r),M=Q({x:P,y:C},{x:l,y:c});k>=t&&u.push({point:A,distance:k,centerDistance:M})}}}if(u.length>=15)break}if(u.length>0){const S=u.map(v=>({...v,score:v.distance*1.5-v.centerDistance*.5}));return S.sort((v,b)=>b.score-v.score),S[0].point}if(u.length===0){let S={x:l,y:c},v=0;const b=d*2;let P=0;const C=5e3;let A=!1;for(let k=i;k<=n&&!A;k+=b)for(let M=s;M<=o;M+=b){if(P++,P>C){w.error(`[findBestInnerPoint] Coarse search iteration limit reached. Room size: ${a}x${h}`),A=!0;break}const T={x:k,y:M};if(Et(T,r)){const _=Ri(T,r);_>v&&(v=_,S=T)}}return S}return{x:l,y:c}},Ri=(r,e)=>{let t=1/0;for(let i=0,s=e.length-1;i<e.length;s=i++){const n=e[s],o=e[i],a=Br(r,n,o);t=Math.min(t,a)}return t},Fa=(r,e)=>e.length===1?Q(r,e[0]):e.length===2?Br(r,e[0],e[1]):e.length===4?Et(r,e)?0:Ri(r,e):(w.warn(`[Distance] Invalid geometry: expected 1, 2 or 4 points, got ${e.length}`),1/0),Br=(r,e,t)=>{const i=(e.x-t.x)**2+(e.y-t.y)**2;if(i===0)return Q(r,e);const s=Math.max(0,Math.min(1,((r.x-e.x)*(t.x-e.x)+(r.y-e.y)*(t.y-e.y))/i)),n=e.x+s*(t.x-e.x),o=e.y+s*(t.y-e.y);return Q(r,{x:n,y:o})},Et=(r,e,t=!1)=>{if(e.length<3)return!1;if(t&&uy(r,e))return!0;let i=!1;for(let s=0,n=e.length-1;s<e.length;n=s++){const o=e[s].x,a=e[s].y,h=e[n].x,l=e[n].y;a>r.y!=l>r.y&&r.x<(h-o)*(r.y-a)/(l-a)+o&&(i=!i)}return i},uy=(r,e)=>{if(e.length<2)return!1;for(let t=0;t<e.length;t++){const i=(t+1)%e.length;if(py(r,e[t],e[i]))return!0}return!1},py=(r,e,t,i=.5)=>{if(Br(r,e,t)>i)return!1;const n=Math.min(e.x,t.x)-i,o=Math.max(e.x,t.x)+i,a=Math.min(e.y,t.y)-i,h=Math.max(e.y,t.y)+i;return r.x>=n&&r.x<=o&&r.y>=a&&r.y<=h},ws=r=>{if(r.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let e=1/0,t=1/0,i=-1/0,s=-1/0;for(const n of r)e=Math.min(e,n.x),t=Math.min(t,n.y),i=Math.max(i,n.x),s=Math.max(s,n.y);return{minX:e,minY:t,maxX:i,maxY:s}},de=r=>{const e=r.reduce((t,i)=>({x:t.x+i.x,y:t.y+i.y}),{x:0,y:0});return{x:e.x/r.length,y:e.y/r.length}},sr=(r,e,t)=>{if(r.length<4)return r;const[i,s,,n]=r,o=Q(i,s),a=Q(i,n),h=o<e||a<e,l=t!=null&&(o>t||a>t);if(!h&&!l)return r;const c=de(r),d=gt(K(i,s)),u=gt(K(i,n)),p=S=>{let v=S;return t!=null&&(v=Math.min(v,t)),Math.max(v,e)},f=p(o),y=p(a),m=f/2,x=y/2;return[{x:c.x-d.x*m-u.x*x,y:c.y-d.y*m-u.y*x},{x:c.x+d.x*m-u.x*x,y:c.y+d.y*m-u.y*x},{x:c.x+d.x*m+u.x*x,y:c.y+d.y*m+u.y*x},{x:c.x-d.x*m+u.x*x,y:c.y-d.y*m+u.y*x}]},Cs=r=>{if(r.length!==4)return r;const e=de(r),t=Q(r[0],r[1]),i=Q(r[1],r[2]),s=Math.atan2(r[1].y-r[0].y,r[1].x-r[0].x),n=[{x:-t/2,y:-i/2},{x:t/2,y:-i/2},{x:t/2,y:i/2},{x:-t/2,y:i/2}],o=Math.cos(s),a=Math.sin(s);return n.map(h=>({x:h.x*o-h.y*a+e.x,y:h.x*a+h.y*o+e.y}))},ae=(r,e,t,i=10,s)=>{if(t===0)return 1;const o=(r.x*e.x+r.y*e.y)/t/t,a=i/t;if(o<=0)return a;let h=o;if(s!=null){const l=s/t;h=Math.min(h,l)}return Math.max(h,a)},Q=(r,e)=>{const t=r.x-e.x,i=r.y-e.y;return Math.sqrt(t*t+i*i)},ee=r=>Math.sqrt(r.x*r.x+r.y*r.y),K=(r,e)=>({x:e.x-r.x,y:e.y-r.y}),gt=r=>{const e=ee(r);return e===0?{x:0,y:0}:{x:r.x/e,y:r.y/e}},Ql=(r,e)=>{const t=K(r,e);return gt(t)},Jl=r=>({x:-r.y,y:r.x}),tc=(r,e)=>{const t=Ql(r,e);return Jl(t)},ec=(r,e)=>{const t=gt(r),i=gt(e),s={x:(t.x+i.x)/2,y:(t.y+i.y)/2};return gt(s)},qe=(r,e,t=0)=>{const i=K(r,e);let s=Math.atan2(i.y,i.x),o=(s+t)%(2*Math.PI);return o>Math.PI&&(o-=2*Math.PI),o<-Math.PI&&(o+=2*Math.PI),(o>Math.PI/2||o<-Math.PI/2)&&(s+=Math.PI),s},ic=(r,e,t)=>{const i=de([r,e]),s=tc(r,e);return{x:i.x+s.x*t,y:i.y+s.y*t}},fy=(r,e,t)=>{const i=Math.cos(t),s=Math.sin(t),n=r.x-e.x,o=r.y-e.y;return{x:n*i-o*s+e.x,y:n*s+o*i+e.y}},Dr=(r,e,t)=>r.map(i=>fy(i,e,t)),gy=(r,e,t)=>{if(Q(r,e)===0)return[r,r,r,r];const s=Ql(r,e),n=Jl(s),o={x:r.x-s.x*t,y:r.y-s.y*t},a={x:e.x+s.x*t,y:e.y+s.y*t};return[{x:o.x+n.x*t,y:o.y+n.y*t},{x:a.x+n.x*t,y:a.y+n.y*t},{x:a.x-n.x*t,y:a.y-n.y*t},{x:o.x-n.x*t,y:o.y-n.y*t}]},Fr=(r,e)=>{if(r.length<3)return r;const t=[];for(let i=0;i<r.length;i++){const s=r[i],n=r[(i+1)%r.length],o=r[(i-1+r.length)%r.length],a=K(s,n);if(ee(a)===0){t.push(s);continue}const l=gt(a),c={x:l.y,y:-l.x},d=K(o,s),u=ee(d);let p={x:0,y:0};if(u>0){const S=gt(d);p={x:S.y,y:-S.x}}const f=ec(p,c),y=p.x*c.x+p.y*c.y,m=1/Math.max(.1,Math.sqrt((1+y)/2)),x={x:s.x+f.x*e*m,y:s.y+f.y*e*m};t.push(x)}return t},sc=(r,e,t)=>{if(Q(r,e)===0)return[];const s=tc(r,e),n=t/2;return[r.x+s.x*n,r.y+s.y*n,e.x+s.x*n,e.y+s.y*n,e.x-s.x*n,e.y-s.y*n,r.x-s.x*n,r.y-s.y*n]},Ds=(r,e,t,i)=>{const s=K(r,e),n=K(r,t),o=ec(s,n),a={x:-o.x,y:-o.y};return{x:r.x+a.x*i,y:r.y+a.y*i}},my=(r,e,t,i,s,n)=>{const o=new Set(r),a=yy(r,e),h=xy(a,o,e,t,i,s,n);return h||a},yy=(r,e)=>{let t=0,i=0;for(let s=0;s<r.length;s++){const n=r[s],o=n%e,a=Math.floor(n/e);t+=o,i+=a}return{x:t/r.length,y:i/r.length}},xy=(r,e,t,i,s,n,o)=>{const a={x:i-10,y:r.y},h={x:n+10,y:r.y},l={x:i,y:s},c={x:i,y:o},d={x:n,y:s},u={x:n,y:o},p=Ui(a,h,l,c),f=Ui(a,h,d,u);if(!p||!f)return null;const y=[],m=Math.max(i,Math.min(p.x,f.x)),x=Math.min(n,Math.max(p.x,f.x)),S=Math.round(r.y);for(let v=Math.round(m);v<=Math.round(x);v++){const b=S*t+v;e.has(b)&&y.push({x:v,y:S})}if(y.length>=2){const v=Sy(y),b={x:(v.min.x+v.max.x)/2,y:(v.min.y+v.max.y)/2},P=Math.round(b.y)*t+Math.round(b.x);if(e.has(P))return b}return null},Ui=(r,e,t,i)=>{const s=(r.x-t.x)*(e.y-t.y)-(r.y-t.y)*(e.x-t.x),n=(r.x-i.x)*(e.y-i.y)-(r.y-i.y)*(e.x-i.x);if(s*n>=0)return null;const o=(t.x-r.x)*(i.y-r.y)-(t.y-r.y)*(i.x-r.x),a=o+s-n;if(o*a>=0)return null;const h=o/(n-s),l=h*(e.x-r.x),c=h*(e.y-r.y);return{x:r.x+l,y:r.y+c}},Sy=r=>{if(!r||r.length===0)return{min:{x:0,y:0},max:{x:0,y:0}};let e=r[0],t=r[0];const i=s=>s.x-s.y;for(let s=1;s<r.length;s++){const n=r[s];i(n)<i(e)&&(e=n),i(n)>i(t)&&(t=n)}return{min:e,max:t}},Pn=(r,e)=>({minX:Math.min(r.minX,e.minX),minY:Math.min(r.minY,e.minY),maxX:Math.max(r.maxX,e.maxX),maxY:Math.max(r.maxY,e.maxY)}),vy=r=>{if(r.length===0)return{x:0,y:0,width:0,height:0};let e=r[0].x,t=r[0].y,i=r[0].x+r[0].width,s=r[0].y+r[0].height;return r.forEach(n=>{e=Math.min(e,n.x),t=Math.min(t,n.y),i=Math.max(i,n.x+n.width),s=Math.max(s,n.y+n.height)}),{x:e,y:t,width:i-e,height:s-t}},by=(r,e,t)=>{let i=1/0,s=1/0,n=-1/0,o=-1/0;for(let a=0;a<r.obstacles.length;a++){const h=r.obstacles[a],l=h%e,c=Math.floor(h/e);i=Math.min(i,l),s=Math.min(s,c),n=Math.max(n,l),o=Math.max(o,c)}return r.rooms.forEach(a=>{for(let h=0;h<a.length;h++){const l=a[h],c=l%e,d=Math.floor(l/e);i=Math.min(i,c),s=Math.min(s,d),n=Math.max(n,c),o=Math.max(o,d)}}),i===1/0?{minX:0,minY:0,maxX:e,maxY:t}:{minX:Math.max(0,i),minY:Math.max(0,s),maxX:Math.min(e,n),maxY:Math.min(t,o)}},wy=(r,e,t,i,s,n)=>{const o=t+s,a=i+n,h=Math.min(r.x,e.x),l=Math.max(r.x,e.x),c=Math.min(r.y,e.y),d=Math.max(r.y,e.y);if(l<t||h>o||d<i||c>a)return!1;if(za(r,t,i,s,n)||za(e,t,i,s,n))return!0;const u=[{x:t,y:i},{x:o,y:i},{x:o,y:a},{x:t,y:a}];for(let p=0;p<4;p++){const f=u[p],y=u[(p+1)%4];if(Ui(r,e,f,y))return!0}return!1},za=(r,e,t,i,s)=>r.x>=e&&r.x<=e+i&&r.y>=t&&r.y<=t+s,Cy=(r,e,t,i)=>{const s=t/2;return i==="horizontal"?[{x:r-s,y:e},{x:r+s,y:e}]:[{x:r,y:e-s},{x:r,y:e+s}]},Ay=(r,e,t)=>{const i={x:e.x-r.x,y:e.y-r.y},s=Math.sqrt(i.x*i.x+i.y*i.y);if(s===0)return[r,e];const n={x:i.x/s,y:i.y/s},o={x:r.x-n.x*t,y:r.y-n.y*t},a={x:e.x+n.x*t,y:e.y+n.y*t};return[o,a]},La=(r,e,t)=>{const i=ws(r),s=ws(e),n=Math.max(0,Math.max(i.minX,s.minX)-Math.min(i.maxX,s.maxX)),o=Math.max(0,Math.max(i.minY,s.minY)-Math.min(i.maxY,s.maxY));if(n>t||o>t)return!1;let[a,h]=[r,e];e.length>r.length&&([a,h]=[e,r]);const l=Math.max(1,Math.floor(t)),c=new Map;for(const u of a){const p=Math.floor(u.x/l),f=Math.floor(u.y/l),y=`${p},${f}`;c.has(y)||c.set(y,[]),c.get(y).push(u)}const d=t*t;for(const u of h){const p=Math.floor(u.x/l),f=Math.floor(u.y/l);for(let y=-1;y<=1;y++)for(let m=-1;m<=1;m++){const x=`${p+y},${f+m}`,S=c.get(x);if(S)for(const v of S){const b=u.x-v.x,P=u.y-v.y;if(b*b+P*P<=d)return!0}}}return!1},Oa=(r,e,t,i)=>{let[s,n]=[r,e];e.length>r.length&&([s,n]=[e,r]);const o=new Set(s),a=i*i;for(let h=0;h<n.length;h++){const l=n[h],c=l%t,d=Math.floor(l/t);for(let u=-i;u<=i;u++)for(let p=-i;p<=i;p++){const f=c+u,m=(d+p)*t+f;if(o.has(m)&&u*u+p*p<=a)return!0}}return!1},Wa=(r,e)=>{if(r<=1)return!0;if(e.length===0)return!1;const t=Array.from({length:r},(a,h)=>h),i=Array(r).fill(0),s=a=>(t[a]!==a&&(t[a]=s(t[a])),t[a]),n=(a,h)=>{const l=s(a),c=s(h);l!==c&&(i[l]<i[c]?t[l]=c:i[l]>i[c]?t[c]=l:(t[c]=l,i[l]++))};for(const[a,h]of e)n(a,h);const o=s(0);for(let a=1;a<r;a++)if(s(a)!==o)return!1;return!0},Py=(r,e,t,i="priority")=>{const s=new Map;if(r.length===0)return s;if(r.length===1)return s.set(r[0].id,0),s;const n=new Map;for(let l=0;l<r.length;l++){const c=r[l];n.has(c.id)||n.set(c.id,new Set);for(let d=l+1;d<r.length;d++){const u=r[d];e(c,u)&&(n.get(c.id).add(u.id),n.has(u.id)||n.set(u.id,new Set),n.get(u.id).add(c.id))}}const o=new Array(t).fill(0),a=[...r].sort((l,c)=>{const d=(n.get(l.id)||new Set).size,u=(n.get(c.id)||new Set).size,p=r.indexOf(l),f=r.indexOf(c),y=-p*.5+d*.5;return-f*.5+u*.5-y}),h=l=>{const c=n.get(l)||new Set,d=new Map;for(const u of c){const p=s.get(u);p!==void 0&&(d.has(p)||d.set(p,[]),d.get(p).push(u))}for(const[u,p]of d){if(p.length!==1)continue;const f=p[0],y=n.get(f)||new Set,m=new Set;for(const x of y){if(x===l)continue;const S=s.get(x);S!==void 0&&m.add(S)}for(let x=0;x<t;x++)if(x!==u&&!m.has(x))return o[u]--,o[x]++,s.set(f,x),u}return-1};for(const l of a){const c=n.get(l.id)||new Set,d=new Set;for(const p of c){const f=s.get(p);f!==void 0&&d.add(f)}let u=-1;if(i==="priority"){let p=-1,f=-1/0;for(let y=0;y<t;y++)if(!d.has(y)){const m=t-y,x=o[y]*.7,S=m-x;(S>f||S===f&&y<p)&&(f=S,p=y)}if(u=p,u===-1&&(u=h(l.id)),u===-1){w.warn(`[FourColor] Room ${l.id}: recolor failed, falling back to least-conflict color`);let y=1/0;for(let m=0;m<t;m++){let x=0;for(const S of c)s.get(S)===m&&x++;(x<y||x===y&&m<u)&&(y=x,u=m)}}o[u]++}else{const p=[];for(let f=0;f<t;f++)d.has(f)||p.push(f);if(p.length===0){if(u=h(l.id),u===-1){w.warn(`[FourColor] Room ${l.id}: recolor failed, falling back to least-conflict color`);let f=1/0,y=0;for(let m=0;m<t;m++)(o[m]<f||o[m]===f&&m<y)&&(f=o[m],y=m);u=y}}else{u=p[0];let f=o[u];for(const y of p)(o[y]<f||o[y]===f&&y<u)&&(u=y,f=o[y])}o[u]++}s.set(l.id,u)}return s},My=Symbol(),Ga=Object.getPrototypeOf,nr=new WeakMap,_y=r=>r&&(nr.has(r)?nr.get(r):Ga(r)===Object.prototype||Ga(r)===Array.prototype),Ty=r=>_y(r)&&r[My]||null,Ua=(r,e=!0)=>{nr.set(r,e)},As={},zr=r=>typeof r=="object"&&r!==null,ky=r=>zr(r)&&!Lr.has(r)&&(Array.isArray(r)||!(Symbol.iterator in r))&&!(r instanceof WeakMap)&&!(r instanceof WeakSet)&&!(r instanceof Error)&&!(r instanceof Number)&&!(r instanceof Date)&&!(r instanceof String)&&!(r instanceof RegExp)&&!(r instanceof ArrayBuffer)&&!(r instanceof Promise),nc=(r,e)=>{const t=Ha.get(r);if((t==null?void 0:t[0])===e)return t[1];const i=Array.isArray(r)?[]:Object.create(Object.getPrototypeOf(r));return Ua(i,!0),Ha.set(r,[e,i]),Reflect.ownKeys(r).forEach(s=>{if(Object.getOwnPropertyDescriptor(i,s))return;const n=Reflect.get(r,s),{enumerable:o}=Reflect.getOwnPropertyDescriptor(r,s),a={value:n,enumerable:o,configurable:!0};if(Lr.has(n))Ua(n,!1);else if(Fe.has(n)){const[h,l]=Fe.get(n);a.value=nc(h,l())}Object.defineProperty(i,s,a)}),Object.preventExtensions(i)},Ry=(r,e,t,i)=>({deleteProperty(s,n){const o=Reflect.get(s,n);t(n);const a=Reflect.deleteProperty(s,n);return a&&i(["delete",[n],o]),a},set(s,n,o,a){const h=!r()&&Reflect.has(s,n),l=Reflect.get(s,n,a);if(h&&(Va(l,o)||Ps.has(o)&&Va(l,Ps.get(o))))return!0;t(n),zr(o)&&(o=Ty(o)||o);const c=!Fe.has(o)&&Iy(o)?rr(o):o;return e(n,c),Reflect.set(s,n,c,a),i(["set",[n],o,l]),!0}}),Fe=new WeakMap,Lr=new WeakSet,Ha=new WeakMap,Mn=[1],Ps=new WeakMap;let Va=Object.is,Ey=(r,e)=>new Proxy(r,e),Iy=ky,By=nc,Dy=Ry;function rr(r={}){if(!zr(r))throw new Error("object required");const e=Ps.get(r);if(e)return e;let t=Mn[0];const i=new Set,s=(m,x=++Mn[0])=>{t!==x&&(n=t=x,i.forEach(S=>S(m,x)))};let n=t;const o=(m=Mn[0])=>(n!==m&&(n=m,h.forEach(([x])=>{const S=x[1](m);S>t&&(t=S)})),t),a=m=>(x,S)=>{const v=[...x];v[1]=[m,...v[1]],s(v,S)},h=new Map,l=(m,x)=>{const S=!Lr.has(x)&&Fe.get(x);if(S){if((As?"production":void 0)!=="production"&&h.has(m))throw new Error("prop listener already exists");if(i.size){const v=S[2](a(m));h.set(m,[S,v])}else h.set(m,[S])}},c=m=>{var x;const S=h.get(m);S&&(h.delete(m),(x=S[1])==null||x.call(S))},d=m=>(i.add(m),i.size===1&&h.forEach(([S,v],b)=>{if((As?"production":void 0)!=="production"&&v)throw new Error("remove already exists");const P=S[2](a(b));h.set(b,[S,P])}),()=>{i.delete(m),i.size===0&&h.forEach(([S,v],b)=>{v&&(v(),h.set(b,[S]))})});let u=!0;const p=Dy(()=>u,l,c,s),f=Ey(r,p);Ps.set(r,f);const y=[r,o,d];return Fe.set(f,y),Reflect.ownKeys(r).forEach(m=>{const x=Object.getOwnPropertyDescriptor(r,m);"value"in x&&x.writable&&(f[m]=r[m])}),u=!1,f}function Fs(r,e,t){const i=Fe.get(r);(As?"production":void 0)!=="production"&&!i&&console.warn("Please use proxy object");let s;const n=[],o=i[2];let a=!1;const l=o(c=>{n.push(c),s||(s=Promise.resolve().then(()=>{s=void 0,a&&e(n.splice(0))}))});return a=!0,()=>{a=!1,l()}}function Fy(r){const e=Fe.get(r);(As?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[t,i]=e;return By(t,i())}function G(r,e,t,i){let s=r[e];return Fs(r,()=>{const n=r[e];Object.is(s,n)||t(s=n)})}class zy extends L{constructor(t){super();g(this,"dragStart",null);g(this,"initialTouchDistance",null);g(this,"initialScale",null);g(this,"activeTouches",new Map);g(this,"firstTouchId",null);g(this,"secondTouchId",null);g(this,"taintedPointers",new Set);g(this,"zoomFactor",.8);g(this,"scaleMin",.2);g(this,"scaleMax",5);g(this,"originalPosition",{x:0,y:0});g(this,"targetPosition",{x:0,y:0});g(this,"centerPosition",{x:0,y:0});g(this,"originalScale",{x:1,y:1});g(this,"targetScale",{x:1,y:1});g(this,"defaultScale",{x:1,y:1});g(this,"transitionDuration",500);g(this,"transitionStartTime",null);g(this,"initialPinchCenter",null);g(this,"isGestureValid",!0);g(this,"lastTapTime",0);g(this,"doubleTapDelay",300);g(this,"doubleTapZoomFactor",1.5);g(this,"lastTapPosition",null);g(this,"tapDistanceThreshold",20);g(this,"tapDetectionEnabled",!0);g(this,"mapClickStartPosition",null);g(this,"mapClickStartTime",0);g(this,"mapClickTimeThreshold",300);g(this,"mapClickMoveThreshold",10);g(this,"shouldSuppressMapClick",!1);g(this,"isGestureHijacked",!1);g(this,"hijackedPointerId",null);g(this,"isHijackPaused",!1);g(this,"interactionGraphics");g(this,"viewportBounds");g(this,"boundResetAnimation");g(this,"debouncedStopWheelRender");g(this,"debouncedLogWheelScale");g(this,"interactionState",{isInteracting:!1,isAnimating:!1,interactionTimer:null,renderReasons:new Set});g(this,"throttledAntiScale");g(this,"unsubscribeEnableInteraction",null);g(this,"handleSuppressMapClick",()=>{this.shouldSuppressMapClick=!0});g(this,"handleGestureHijacked",t=>{var n,o;this.isGestureHijacked=!0,this.hijackedPointerId=t.pointerId,this.isHijackPaused=!1,this.clearTouches();const i=t.global.x-this.viewportBounds.x,s=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:i,y:s}),this.firstTouchId=t.pointerId,this.dragStart={x:i,y:s},(o=(n=this.appService.events)==null?void 0:n.onGestureStart)==null||o.call(n)});this.appService=t;const i=t.getApp();this.viewportBounds=i.getViewportBounds(),this.eventMode="static",this.unsubscribeEnableInteraction=G(t.runtime,"enableInteraction",s=>{this.updateInteractionMode(s)}),this.updateInteractionMode(t.runtimeSnapshot.enableInteraction),this.interactionGraphics=new H,this.interactionGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill({color:"#ffffff",alpha:0}),this.addChild(this.interactionGraphics),this.scaleMax=i.scaleMax,this.scaleMin=i.scaleMin,this.centerPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.originalPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.targetPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.throttledAntiScale=Ct(s=>{this.appService.emitter.emit("antiScale",s)},16,{leading:!0,trailing:!0}),this.boundResetAnimation=this.resetAnimation.bind(this),this.debouncedStopWheelRender=Rn(()=>{i.stopRender("wheel")},300),this.debouncedLogWheelScale=Rn(s=>{w.debug("[Interaction] 滚轮缩放完成 - Scale:",s.toFixed(3))},500),this.setupInteraction()}updateInteractionMode(t){this.eventMode=t?"static":"none",w.debug(`[Interaction] 交互模式已更新: ${t?"启用":"禁用"}`)}setupInteraction(){this.on("pointerdown",t=>this.onPointerDown(t)),this.on("pointerup",t=>this.onPointerUp(t)),this.on("pointerupoutside",t=>this.onPointerUp(t)),this.on("pointermove",t=>this.onPointerMove(t)),this.on("wheel",t=>this.onWheel(t)),this.appService.emitter.on("gestureHijackStart",this.handleGestureHijacked),this.appService.emitter.on("suppressMapClick",this.handleSuppressMapClick),document.addEventListener("pointercancel",t=>{w.debug("[Interaction] Received global pointercancel"),this.handleGlobalCancel(t)})}handleGlobalCancel(t){const i=this.appService;if(this.isGestureHijacked){w.debug("[Interaction] 系统取消或移出视口,强制结束劫持手势");const s=i.getApp(),n=new xa(s.renderer.events);n.pointerId=t.pointerId,i.emitter.emit("gestureHijackPointerUp",n),this.exitGestureHijacked()}this.clearTouches()}resetPan(t){const i=this.appService,s=i.getApp(),n=i.appContainer;this.transitionStartTime!==null&&(s.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null);const o=this.centerPosition.x-t.x*n.scale.x,a=this.centerPosition.y-t.y*n.scale.y;this.originalPosition={x:n.x,y:n.y},this.targetPosition={x:o,y:a},this.originalScale={x:n.scale.x,y:n.scale.y},this.targetScale={x:n.scale.x,y:n.scale.y};const h=Math.sqrt((n.x-o)**2+(n.y-a)**2),c=(d=>Math.pow(Math.min(1,d/1e3),.5))(h);this.transitionDuration=500+1e3*Math.min(1,Math.pow(c,2)),this.transitionStartTime=s.ticker.lastTime,s.ticker.add(this.boundResetAnimation)}setPanZoom({targetPosition:t,targetScale:i,setCenter:s=!1,setScale:n=!1}={},o=!0){const a=this.appService,h=a.getApp(),l=a.appContainer;if(s&&t&&(this.centerPosition={x:t.x,y:t.y},w.debug("[Interaction] Set center position:",this.centerPosition)),n&&i&&(this.defaultScale={x:i.x,y:i.y},w.debug("[Interaction] Set scale:",this.defaultScale)),this.originalPosition={x:l.x,y:l.y},this.originalScale={x:l.scale.x,y:l.scale.y},t?this.targetPosition=t:this.targetPosition={x:this.centerPosition.x,y:this.centerPosition.y},i?this.targetScale=i:this.targetScale=this.defaultScale,!o){l.position.set(this.targetPosition.x,this.targetPosition.y),l.scale.set(this.targetScale.x,this.targetScale.y),this.antiScale(this.targetScale.x),this.transitionStartTime!==null&&(h.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),w.debug("[Interaction] 直接设置缩放完成 - Scale:",this.targetScale.x.toFixed(3));return}const c=Math.sqrt((l.x-this.targetPosition.x)**2+(l.y-this.targetPosition.y)**2),u=(m=>Math.pow(Math.min(1,m/1e3),.5))(c),f=((m,x)=>Math.pow(Math.min(1,Math.abs(m-x)/Math.abs(.2-1)),.5))(l.scale.x,this.targetScale.x),y=u*.8+f*.2;this.transitionDuration=500+1e3*Math.min(1,Math.pow(y,2)),this.transitionStartTime!==null&&(h.ticker.remove(this.boundResetAnimation),this.interactionState.isAnimating=!1,h.stopRender("animation")),this.interactionState.isAnimating=!0,h.requestRender("animation",!0),this.transitionStartTime=h.ticker.lastTime,h.ticker.add(this.boundResetAnimation)}clearTouches(){var s,n;const i=this.appService.getApp();this.activeTouches.clear(),this.firstTouchId=null,this.secondTouchId=null,this.dragStart=null,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.isGestureValid=!0,this.taintedPointers.clear(),this.transitionStartTime!==null&&(i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),this.interactionState.isInteracting&&(this.interactionState.isInteracting=!1,(n=(s=this.appService.events)==null?void 0:s.onGestureEnd)==null||n.call(s)),i.stopRender("interaction")}checkEventListeners(){return{wheel:this.listenerCount("wheel"),pointerdown:this.listenerCount("pointerdown"),pointerup:this.listenerCount("pointerup"),pointerupoutside:this.listenerCount("pointerupoutside"),pointermove:this.listenerCount("pointermove")}}destroy(){this.checkEventListeners(),this.interactionState.interactionTimer&&clearTimeout(this.interactionState.interactionTimer),this.interactionState.renderReasons.clear(),this.interactionState.isInteracting=!1,this.interactionState.isAnimating=!1,this.debouncedStopWheelRender.cancel(),this.debouncedLogWheelScale.cancel(),this.unsubscribeEnableInteraction&&(this.unsubscribeEnableInteraction(),this.unsubscribeEnableInteraction=null),this.appService.emitter.off("gestureHijackStart",this.handleGestureHijacked),this.appService.emitter.off("suppressMapClick",this.handleSuppressMapClick),super.destroy()}exitGestureHijacked(){var i,s;const t=this.appService;this.hijackedPointerId!==null&&!this.isHijackPaused&&(this.activeTouches.delete(this.hijackedPointerId),this.firstTouchId===this.hijackedPointerId&&(this.firstTouchId=null,this.dragStart=null),this.secondTouchId===this.hijackedPointerId&&(this.secondTouchId=null)),this.isGestureHijacked=!1,this.hijackedPointerId=null,this.isHijackPaused=!1,(s=(i=t.events)==null?void 0:i.onGestureEnd)==null||s.call(i)}forceEndGesture(){if(this.isGestureHijacked){w.debug("[Interaction] 强制结束劫持手势");const t=this.appService.getApp(),i=new xa(t.renderer.events);i.pointerId=this.hijackedPointerId,this.appService.emitter.emit("gestureHijackPointerUp",i),this.exitGestureHijacked()}this.clearTouches()}pauseGestureHijack(){this.isHijackPaused=!0}resumeGestureHijack(){this.isHijackPaused=!1}antiScale(t){this.throttledAntiScale(t)}resetAnimation(){const t=this.appService,i=t.getApp(),s=t.appContainer;if(this.transitionStartTime===null)return;const{targetPosition:n,targetScale:o}=this,a=i.ticker.lastTime,h=Math.min(1,(a-this.transitionStartTime)/this.transitionDuration);if(h>=1)s.position.set(n.x,n.y),s.scale.set(o.x,o.y),this.antiScale(o.x),i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null,this.interactionState.isAnimating=!1,i.stopRender("animation"),w.debug("[Interaction] 动画缩放完成 - Scale:",s.scale.x.toFixed(3));else{const l=oy(h),c=this.originalPosition.x+(n.x-this.originalPosition.x)*l,d=this.originalPosition.y+(n.y-this.originalPosition.y)*l,u=this.originalScale.x+(o.x-this.originalScale.x)*l,p=this.originalScale.y+(o.y-this.originalScale.y)*l;s.position.set(c,d),s.scale.set(u,p),this.antiScale(u)}}onWheel(t){const i=this.appService;if(this.isGestureHijacked){w.warn("⚠️ [onWheel] 被手势劫持阻止执行",{isGestureHijacked:this.isGestureHijacked,hijackedPointerId:this.hijackedPointerId,isHijackPaused:this.isHijackPaused});return}i.getApp().requestRender("wheel",!0),this.debouncedStopWheelRender();const{scaleMin:s,scaleMax:n}=this,o=i.appContainer;t.preventDefault();const a=t.global.x-this.viewportBounds.x,h=t.global.y-this.viewportBounds.y,l=(a-o.x)/o.scale.x,c=(h-o.y)/o.scale.y,d=t.deltaY>0?.95:1.05;let u=o.scale.x*d,p=o.scale.y*d;if(u=Math.max(s,Math.min(n,u)),p=Math.max(s,Math.min(n,p)),!(u!==o.scale.x||p!==o.scale.y))return;const y=a-l*u,m=h-c*p;try{o.scale.set(u,p),o.position.set(y,m),this.antiScale(u),this.debouncedLogWheelScale(u)}catch(x){w.error("❌ [onWheel] 应用缩放时发生错误:",x)}}onPointerDown(t){var l,c;const i=this.appService;this.interactionState.isInteracting||(this.interactionState.isInteracting=!0,i.getApp().requestRender("interaction",!0),(c=(l=i.events)==null?void 0:l.onGestureStart)==null||c.call(l)),this.isGestureHijacked&&t.pointerId!==this.hijackedPointerId&&!this.isHijackPaused&&this.pauseGestureHijack();const s=i.getApp(),n=i.appContainer;this.transitionStartTime!==null&&(s.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),this.activeTouches.size===0&&this.taintedPointers.size>0&&(w.debug("[Interaction] 清除污染指针列表,准备新手势",Array.from(this.taintedPointers)),this.taintedPointers.clear()),this.activeTouches.size===0&&(this.isGestureValid=!0,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.dragStart=null,this.firstTouchId=null,this.secondTouchId=null),this.activeTouches.has(t.pointerId)&&this.activeTouches.size===1&&(this.isGestureValid=!0);const o=t.global.x-this.viewportBounds.x,a=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:o,y:a});const h=this.activeTouches.size-this.taintedPointers.size;if(this.taintedPointers.size>0){w.debug("[Interaction] 存在污染指针,阻止多点触摸手势",Array.from(this.taintedPointers)),h===1&&!this.taintedPointers.has(t.pointerId)&&(this.firstTouchId=t.pointerId,this.dragStart={x:o,y:a});return}if(this.activeTouches.size===1)this.firstTouchId=t.pointerId,this.dragStart={x:o,y:a},this.mapClickStartPosition={x:o,y:a},this.mapClickStartTime=performance.now();else if(this.activeTouches.size===2){const d=Array.from(this.activeTouches.keys());this.secondTouchId=d.find(u=>u!==this.firstTouchId)||t.pointerId,this.setInitialScaleAndDistance(n),this.tapDetectionEnabled=!1}}onPointerUp(t){var n,o;const i=this.appService;if(this.taintedPointers.has(t.pointerId)&&(w.debug("[Interaction] 移除污染指针",t.pointerId),this.taintedPointers.delete(t.pointerId)),this.isGestureHijacked)if(t.pointerId===this.hijackedPointerId){i.emitter.emit("gestureHijackPointerUp",t),this.exitGestureHijacked();return}else this.isHijackPaused;if(!this.activeTouches.has(t.pointerId))return;const s=this.initialTouchDistance!==null&&this.initialScale!==null;if(this.activeTouches.delete(t.pointerId),w.debug(`[Interaction] onPointerUp, remaining touches: ${this.activeTouches.size}`),s&&this.activeTouches.size===1){this.isGestureValid=!1;const a=Array.from(this.activeTouches.keys());setTimeout(()=>{var h,l;!this.isGestureValid&&this.activeTouches.size>0&&(w.debug("[Interaction] 100ms 缓冲结束,检测到真正的幽灵指针,标记为污染并清理",a),a.forEach(c=>{this.activeTouches.has(c)&&(this.taintedPointers.add(c),this.activeTouches.delete(c),this.firstTouchId===c&&(this.firstTouchId=null,this.dragStart=null),this.secondTouchId===c&&(this.secondTouchId=null))}),this.activeTouches.size===0&&this.interactionState.isInteracting&&(w.debug("[Interaction] 清理幽灵指针后所有触摸点已释放,结束手势"),this.interactionState.isInteracting=!1,i.getApp().stopRender("interaction"),(l=(h=i.events)==null?void 0:h.onGestureEnd)==null||l.call(h)))},100),this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null}t.pointerId===this.firstTouchId?(this.firstTouchId=null,this.dragStart=null,this.activeTouches.size===0&&this.tapDetectionEnabled&&this.detectDoubleTap(t),this.activeTouches.size===0&&!s&&this.detectMapClick(t)):t.pointerId===this.secondTouchId&&(this.secondTouchId=null),this.isGestureHijacked&&this.isHijackPaused&&this.activeTouches.size===1&&Array.from(this.activeTouches.keys())[0]===this.hijackedPointerId&&this.resumeGestureHijack(),this.activeTouches.size===0&&(this.isGestureValid=!0,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.firstTouchId=null,this.secondTouchId=null,this.dragStart=null,this.tapDetectionEnabled=!0,this.interactionState.isInteracting&&(this.interactionState.isInteracting=!1,i.getApp().stopRender("interaction"),(o=(n=i.events)==null?void 0:n.onGestureEnd)==null||o.call(n)))}detectDoubleTap(t){const i=this.appService,{interactionConfig:s}=i;if(!s.enableDoubleTapZoom)return;const n=performance.now(),o={x:t.global.x-this.viewportBounds.x,y:t.global.y-this.viewportBounds.y};n-this.lastTapTime<this.doubleTapDelay&&this.lastTapPosition&&Q(o,this.lastTapPosition)<this.tapDistanceThreshold?(this.handleDoubleTap(o),this.lastTapTime=0,this.lastTapPosition=null):(this.lastTapTime=n,this.lastTapPosition=o)}detectMapClick(t){var h;const i=this.appService;if(!i.runtimeSnapshot.enableMapClickCapture||!((h=i.events)!=null&&h.onClickMap)||!this.mapClickStartPosition)return;const n=performance.now()-this.mapClickStartTime,o={x:t.global.x-this.viewportBounds.x,y:t.global.y-this.viewportBounds.y},a=Q(this.mapClickStartPosition,o);if(n<=this.mapClickTimeThreshold&&a<=this.mapClickMoveThreshold&&!this.shouldSuppressMapClick){const l=i.appContainer,c=i.mapState,d=(o.x-l.x)/l.scale.x,u=(o.y-l.y)/l.scale.y,p={x:d-((c==null?void 0:c.origin.x)||0),y:u-((c==null?void 0:c.origin.y)||0)};w.debug("[Interaction] 地图点击捕获",{screenPosition:o,containerPosition:{x:d,y:u},origin:c==null?void 0:c.origin,mapPosition:p,clickDuration:n,moveDistance:a}),i.events.onClickMap(p)}this.mapClickStartPosition=null,this.mapClickStartTime=0,this.shouldSuppressMapClick=!1}handleDoubleTap(t){const i=this.appService,s=i.getApp(),n=i.appContainer,{scaleMin:o,scaleMax:a,doubleTapZoomFactor:h}=this,l=t.x,c=t.y,d=(l-n.x)/n.scale.x,u=(c-n.y)/n.scale.y;let p=n.scale.x*h,f=n.scale.y*h;p=Math.max(o,Math.min(a,p)),f=Math.max(o,Math.min(a,f)),this.originalPosition={x:n.x,y:n.y},this.originalScale={x:n.scale.x,y:n.scale.y};const y=l-d*p,m=c-u*f;this.targetPosition={x:y,y:m},this.targetScale={x:p,y:f},this.interactionState.isAnimating=!0,s.requestRender("animation",!0),this.transitionDuration=300,this.transitionStartTime=s.ticker.lastTime,s.ticker.add(this.boundResetAnimation)}onPointerMove(t){if(this.isGestureHijacked&&!this.isHijackPaused)if(t.pointerId===this.hijackedPointerId){const n=t.global.x-this.viewportBounds.x,o=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:n,y:o}),this.appService.emitter.emit("gestureHijackPointerMove",t);return}else return;if(!this.activeTouches.has(t.pointerId)||!this.isGestureValid)return;if(this.taintedPointers.size>0&&(this.initialTouchDistance!==null||this.initialScale!==null)){w.debug("[Interaction] 存在污染指针,阻止多点触摸手势移动");return}const i=t.global.x-this.viewportBounds.x,s=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:i,y:s}),this.activeTouches.size===2&&this.initialTouchDistance!==null&&this.initialScale!==null&&this.applyPinchZoom(),this.activeTouches.size===1&&(this.initialTouchDistance!==null||this.initialScale!==null)&&(this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.secondTouchId=null),this.activeTouches.size===1&&t.pointerId===this.firstTouchId&&this.dragStart!==null&&!this.taintedPointers.has(t.pointerId)&&this.applyPan(t)}applyPan(t){const i=this.appService,s=this.activeTouches.get(t.pointerId),n=i.appContainer,{x:o,y:a}=this.dragStart;n.position.set(n.x+s.x-o,n.y+s.y-a),this.dragStart={x:s.x,y:s.y}}applyPinchZoom(){const i=this.appService.appContainer,s=Array.from(this.activeTouches.values());if(s.length<2||!this.initialTouchDistance||!this.initialScale||!this.initialPinchCenter)return;const n=Q(s[0],s[1]),o={x:(s[0].x+s[1].x)/2,y:(s[0].y+s[1].y)/2},a={x:(o.x-i.position.x)/i.scale.x,y:(o.y-i.position.y)/i.scale.y},h=(n/this.initialTouchDistance)**this.zoomFactor,l=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.x*h)),c=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.y*h));i.scale.set(l,c);let d=o.x-a.x*l,u=o.y-a.y*c;const p=o.x-this.initialPinchCenter.x,f=o.y-this.initialPinchCenter.y;d+=p,u+=f,i.position.set(d,u),this.antiScale(l),this.initialPinchCenter=o}setInitialScaleAndDistance(t){const i=Array.from(this.activeTouches.values());i.length<2||(this.initialTouchDistance=Q(i[0],i[1]),this.initialScale={x:t.scale.x,y:t.scale.y},this.initialPinchCenter={x:(i[0].x+i[1].x)/2,y:(i[0].y+i[1].y)/2})}}const Ly=["forbiddenSweepZone","forbiddenMopZone","cleanZone"];function Ne(r){return Ly.includes(r)}const Ei={forbiddenSweepZone:{minSize:1,iconWrapperFillColor:"#ff4444",strokeColor:"#ff4444",strokeWidth:2,fillColor:"rgba(255, 68, 68, 0.1)",outlineOffset:16,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",showRotateButton:!0,textColor:"#ff4444",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},forbiddenMopZone:{minSize:1,iconWrapperFillColor:"#fe8a07",strokeColor:"#fe8a07",strokeWidth:2,fillColor:"rgba(254, 138, 7, 0.1)",outlineOffset:16,outlineStrokeColor:"#fe8a07",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(254, 138, 7, 0.05)",showRotateButton:!0,textColor:"#fe8a07",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},cleanZone:{minSize:1,iconWrapperFillColor:"#5d68fe",strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",outlineOffset:16,outlineStrokeColor:"#5d68fe",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(93, 104, 254, 0.05)",showRotateButton:!0,textColor:"#5d68fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}}},Oy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAaVBMVEUAAAA3yFI4x1E3yFM4x1Q3yFI4x1I3yFM3ylVAz1BEzF44yFI3ylI3yFI2yVNGzF9GzGA3yFM4x1JKzWJY0nB62or///83yFL///+b46hQz2jN8dRp1n1Ey13y+/SC3ZPm+Om06r6n57PA80FIAAAAF3RSTlMA3yC/QO9grzAQ75+PcFDfz8+Ar2AwEAVwkmAAAANrSURBVGje1ZtpktowEEZbkiVvmG1m+Ixg1vsfMqnUVPWPkLG6W+DKu8CrJ7UBG5nEnLrtsQ1h5yIwOLcP45ReerovXWoPuIlrJ0/3wad2wI/Ep1S/PLUoIjQ13X4cUEzcNJW0TYCQUEP9zNpHqr2DHLvajzCwUY9ZcjARJ13uAWaCl3u3DhWI4p0+opTrwk7LlnmHYi74mb2/z0V0nbGAKzZ3DoLgRTFcVzhWUeB9n+daI5Yg4aNEDKRlbwOIgsvE2C7ub5QFl4pjV2WeOZjFgtk2e1/fWGwz7yHiPAvE2P3buwFkwSIxjtaB5mAWW0bb80ALglms3uYARhAsEONwyzuBEQSzWPkJ1kcwgmCZ2Hn1RHOwRoxRPdEcrBLDKyeLg5ViZw5WivFsDFaLgyn4a1aL0RiC82wQB0Pwp0UMr76G82wSj+oPrU+beNCudJ5tYiTlaF2s4vZ7pSHjOpvEPF4JMi42Ma/1EwRwsFbMay2c6YtNzHPtIYCDTWJ08p88F6OYN7mFAA7WinmTHSRc6ogP0quYg5nzDV6xwIleIOEyF3EpmK4kCy7jWnA3M60SjCONAu97tWC0oq+mj2rBCLR/bDCL3SrB2JFbJRiOBhTyWjMYkVDKuWYwQMXBb1WCWRzXCR7IrRPsaPfYYBaHVYKxp7BKMAK1qwRjpOMqwZhou0owEnWrBOOFTljm/fw3X6Zg9EQHqMimYCf+Qc9iU3ArvktlsSUY029xBxVZG8x35gM0ZEtwJFJvcrYEPxGpNzlrg/lRhIeGbAhGT/q1zobgQKRf66wL5ue32rnO+uDY0zcj5GRVMB+UUI9XVgej0TwoZ7E6OKj+GmCxJdiSnC3BzDOkZFMw4yAk24L1g52twdprOSuvYfPpvGz80GISRGRV8EQ3OEBCVn8tGRc7K4Kjp5tsISArghvbQT0Wc7Buopkdisni4H2dQ0ZZEFz1eFPmYInXfpAsy4Jjxw7baGdZcFPtsGAWPgAooIlFYkFw3FY8EJrLg11X8whsLg52ksO3+2VxafDOk4TNorgw+CiQ8oiZcVsS4wPMHDxpmKIxN5GSfgMDo6/7OoroInq4Ojz/vy/h/FFvBGM2jJ7q0Zdmt4lq06enuNDapru91za1Djc5tKmj+9K/pGkMe+cGILpdCO1x251Iyi/g4vimU9Z1kQAAAABJRU5ErkJggg==",Wy="/assets/robot.CSiuukeH.png",Gy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAgH/fIL9gcEDvoBDPsJCPUDD8BuiCAAACCklEQVRo3u3Zza6bMBCG4Y/434aQzP1fbCt14SOZSac+zPQs/C4jwaME7ICN1Wq1Wq1W87VYd0dEe9gy7MqBvuQi9OusHp3PenqMPeiix31uZU5YiVTlB3PCk5jSTXChS9kTV2m3uG/mR0zEtt0Ce7qWKw873FK5livx+VvgRJdyIr6IW9ou5Ux8T2jKgYcrNOXMwwGq8qYM83IqLKws+8rB2jISA+vLkbmr9eUnM1mry819+GO0Hs8ZPdPx3NCzlB16pvKBnqkc0TOVPXqWskPPVH6iZyp79CzlHUM2csSQiewwZCNHDJnIAUM2cgOTosy35CUvecn/W37H83C/C8nbyT6FMhjqcnsE6pnJOdBFTVPu7FiEqvwOxJTAyeN1KrQf8Z/ck9gyZPLL0Z+cF7N+l6yX8rL3r7P0z8tb6jreLV7pLba77K01IWcR/MlNwIycxDsS/Er8lFwFrv/szslBAEeJK5fl8CFx5bIc3jn3AKblQwBzrmuYl5/fgD0wL78EcOEv8Lzsp6cPB3xDDhBUmZlyWpYenZgvPC8Lj27cfta8HCEq0Fi2eN7OzFjSlwMDq8u+MLC6nAYYsJGfw3aWlVyH6cNK3obpw0qOrrsehnLfN9299Zu7j4FKiD97zeBvcgKfqlwaDNukI1JT3mBalyNs26RzgZb8gnlxpxIyVqvVarVarb70C7CyrCEVukMsAAAAAElFTkSuQmCC",Uy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMA3yC/EECAYM+f73CQr1Awj6BvNXOp4gAAAlpJREFUaN7s1t1ugzAMhmE7TgghgdL5/u91ndBK11SYfFonTcpzXl7yR0Nd13Vd13Xd/+VWVk6OAD7PzCxDIMCHbtrTQfQbR2o1oD/2q97A6agPBjrPsd4BU+ZZgfLehQcd9acMdKEXF31yoVNYX0uewAewb9mRtfFkmaHZcroDy1qZfMMCweULtEGCHprJlrU2kiXpsRXanPbG9mrJZIjQzxY12O/O0BoVNbFHTiPDe3q32lu6NtnzZAv257Zmn32bGP9LaBgfsh9VwameoCHbXRVgjWtTc1eLEZ71FNfa1WCEIxS2u0wWAcOO9UiknblBphLdTViKTMb7W12mEyJv2cHTLpRRd0PjRLGjU0IecvDVoLLo5ko3IY0yx2prGF2Qi/PI8lVzsj/TvLbg3YMl3cp6oHgC2MddjsMS6Bddnj8NAmQRw/OlJgBZxFUfpNf3Dsme6P1hCqx3k5SloYpO9XA//SWlVPLi6G1Cdev8K/I407Z3fUBweFnQLi5+tmcGOQzCMBA0EBKSllz4/1/b+x6QVXmqVp4PrBDGeHfP7ei7JX9LmXM1nlKHIwUK+JaMQbfHw1C6RCoMTQ57iEUMAkOTIwDiEGsCoGddMYouthdiiNFnmBJtQHQNohkWV7YRYJrol6wZ+DCE05kjBawteK4d0VnAbEGPfF8cTAvhPnAcq0VTHTkWIKwdLySsBQkgDBxBsjHJ2W6qB9zYskDADVbGpSB+Zru+NF4TEHb3UtUi2aHhUqq3aPn9H4XV4MLDU06PWgyhbaCsNlDjrbmcz8wzkyRJkuRDXlF2skMkf3lIAAAAAElFTkSuQmCC",Hy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMA359AIL+QYBDvMIBwr6CPz1BvDk7raQAAAplJREFUaN7t2tuO3CAMBmDbQALkOOv3f9dKrVbWMiSQTHGqiu96oz94OGeh67qu67rP+JF2ZObdTQb0GMcscAQdnlgoRkfkdxM0ZyVXN5k4b4bGkPOChbb4yAAJreDgoSnkIwaaGpif6V6RjxAktJq8QGMr5zlobUTdYGFRsdTlZAIFRm+dKPewF2iw/CaCioVToMMojyYRdJdFMagsTuVaB9DilacP4RQqXf6REfSMCtuP8uRlQRE2GcTezLQ4t9D0isWFAu1fK+MWmIXbzOlIHuFA3JAZqfq9vgKnAr1nY6nQ23dFIlSZOAu/bNKecJ5L8qi/lSu2n9F2RSRTM97o6vj84PBv8eLMhnxqu5XL7n6D02QzE80WDpj0/f1HDZaq+YV/I59tLnFqLC6zRSSFzHdYs+Seutel05WIjk4Q3myBc3Y456qCY3Zfa8fNnTx1bq8q9fC+JBpCPgXnuCjYZFdNcu3WKFjm3TUJtoHbBn9PkGmpiYv228PYDaPNDjorT51wtzpXGIw/6vwEVcHTjRuOxUDK/5xAVi4yl6fq/P7BrjJl1sx3ePGAwHj4pnYmmqNsss+NFw8I5W1cXTJCkbmUK0a812Cx1vy9IUw3j3a43aXTDsvr+fYxxPRXxxu5ItZvWyFl1szOeIZKdkVmHGJ5yGX3+YP7OffYBvd6dFS01/TnADTLjPe5rXqU/CfH0zkZn2pQ9XZLmGSVVUPpAUFL+Dcu9J67wgygxPFDl6dqH1/KX/gsaHjpfvYRk9732/K2GzWKvfBDya7yEkohWKmHLfXXX206l/oXvvmp/wMxfAShKR/4CLQ1PBVsg26py92LoLWJ9abNcjJGUPB++CcPGtJoZ0CPmdzOzLjT6KHruq7ruo/8Ani9wIJR4hr/AAAAAElFTkSuQmCC",Vy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAIN9A7xC/gGDPn3BQkK8wj6DdtO0oAAADPElEQVRo3u2Z2Y7rIAyGwWYnS8fv/7BHlTpi0gacsuTc8N1VivqDF2yMmEwmk8lk0h9nFJHfohT90HEDIlLG5f810C/GdZJFQwkrznnQH3yPXUtDB0CefkVHbLPuooguKAd649GoaylRUlb0TmjW/cQwlm7fc6RzHleEKdbHFeXYr3ypdK0wUA7D+LgttB3lceLI2nPLQHlAHEHqt2WkEu6KrU2V8EolzBXzqCphQ0XwyteyRthTkfXK11gj/EMJPmRVP2Ekuh5emk7RI5wc+FWCqEJC2dZ8NQliiDKy1kFRi/OUJ3LlxIgGtJRyX34YQzqmhtUjLZRCB5iFtSA/d12OaZCiEw5yB2KoOC5bolwyjU8/9HYq7NhS3I49OxAhoztKGVJo8brtxA8vhqH+TaBK6XJqaYViDBKOaUpHvBTDWNYQdaYHWMVtGEp4FPeBybtR3IBecH9ZHuiJt7pbGDkbjIcnxjwifgwKAF/S1kbsN3BR9M62vB/brrffDJ0T9DF3Vdfk2Q1l8U/lZUz6RCphj/cqKFsuQBqPcVgqot5uGaU4Mb+rW+rv4wl5EPbXGgdsaaZTGV4utHS7/a7VDZQn/QUc2xBtN2NMeESHuD/7YffwXzb3WrGWPtjFpl9lLFd4qIxyL49sf04uIJ6tzdJ+T8GwuD0tlgVa7qYqZvOPhxFWJWtJMU6YsgAymT9IeNUioa0hCDplAg/UmVrhySEDOo3EWEzVHNHLE900PtZADHwV27KlMGE+LjE7b+yloiR6nYsldz2+uMqI/A0bziqEqzi4uOjCfPLA4bmmBH7fBoRS+Gm2nvLJlEtKLFWR5fNprHoAZMsz562QJLYul86Tciu+t5hL7YsXl8BiaDHvHQ4aBk+xEFobF63SQv2F2eYXq3jvyeOubc0sbdMZNzB5gj/wcsUqvx0gKlIbZr3AnwwanXO76MXGZMowPPMoMgzmTXcYO3P+D2D0YLrqnuGHKXPlHhYxGFdxJRsrTFEMZaEcaqyfJdM3j0MVZjJDMUzjPIzI9HPD0IoRHoZlfDwOzzygD0MC/adKIf1tdYL3s9XiFuSriUyd5H3gap7iYFbUYjKZTCaTSRP/AEYn9FrTdrbUAAAAAElFTkSuQmCC",Ny="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMA3yCAEGC/759AcFDPkDCvoI+BJCYaAAADo0lEQVRo3u2a2barIAyGCSQMjpX3f9izzunqoYoxbhD3jd9d6/CXEDJA1cPDw8PDw0MNYZkhxgh26VHdBhoXv/Ba3UPn4obljlGjjzlww6BtjL+iTHEfaG1tGxkW1RaIHIyx2wuPiqG1MKimvCJLW/cKvHCvmmJZYVJN0Y4T7lRbJs6/zOY+6vXFY36dEO6HusSlQ5hybzXiHC9VOTMsb6ta2j49Cl5tatKHtnyyx715DvuZxE0/06W190InLmdkwpugLE6j1cfL2SV/LkrWvPtArxJ9/sOSsbhLMr24YNDxF7vioKZPxIiR9y1TnLl85PC8e+Fq/ouGrGOUlZGdR4w5tmDAnLUtNyYqTdYYDzH7k6yPixQqqGCZ0NgztjTFFZkXhJ3eMQwJDjKX1xgJm5sUpJU4KBkXJbpU920GjEMsF44iDpMvrAc8C1aqFI7jZjZJdI+53tRpyHbzVpyF2RFI0yS8J6S0l+a3orMyp2yd7rQ6+XPNFKeMJ4fs6WV9yNdRaZKYkrIbvDHeDkINLen6s/l4/hRa+LFCP67Ew490B1Rn0Z33Y8D1d2TZEXhBt5ik7WJ0b0MHD2BJTmgjqkvQeuX8Fo+bVwjqWug7emg20hhUFwMrR3P3yK6NO+7Xw85eYuSJusV7b/q88vb/PsN6Zj3VDxb7ZciaqGkbPnX3vsnBPJJW1WBnd8MQup32VGuNF83k7LjAaxrubwV7lGperfZttRX28GhosmDIyckV9X//62hSMpXVAO0fFoDv2+qOfDfttssXzQzDfH55kZjk+A7AmoD/t40+XmFKG/PEC9+3LNYSWw8P1nu/Woq+dsCv790Gn7olkVNjHqTHzfdHPCXsUNbVki6t3+ZOKYeKzXCT5+J1i15Z4ZKgS5ulNV01ySSsX8jCdlNh2Lvssl37mrZtYjcgcp+fsr28irMSPPzBeu/rWRaeyk61gNlL9OsNbB5XmCKIiS5u1ejV9m3TQWOtmbjQV0xxwvKGImaVCA4G6hSB7+hn9oqR45bMyL5+EPapK49acWCiFh55TXfBqbaG/WGFw5dOwIbLMmV/dFphmadEXVkZ9KE1jRADTGmpOWih/DRHBZvrSs5NIVWImbuzJ4AE2TlZgTbK/xHIOyiaP3V2UBdhzv7zJfR0RVcjL1Wj2kJ82muLFhJ9O4BPA20xvyWMrqBTaOnXoJpjCpZTO2Wj7oCA2RtuDhIwm7TtCaP9Kw6zCerh4eHh4eFq/gDsgRtLdqAVbwAAAABJRU5ErkJggg==",jy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA3yBgv58Q74BwQK+PzzBQHgQBUQAAAqhJREFUaN7t2etu8yAMBmBO4ZgQ7v9qv2na+kpVEgKOqfQN/1vK+hRjE9KKGTNmzJgxYwY9VCrOKDE8lCxfIR+SYwjx3ki7le+Qz03iXvrW8hOe7tov9276QnlFJMO+lLuycoDpyyxvvBdyg1iocLk3CyzwU8u83ZKxwAhispdyS8YCYzC1m27JyMy6INn8MhbYCPxD5Jfj78tO4Q+MZZPRSTt6Hz3FJ6fXAr81v2aV0Umb/RmPoYwyOsm9rgfUGqNsfi+Ho2t8MmZ3NNwpLjmXQ0JjA+ORcXk/2Ws9s7yejlassrQY15BsuhwvbmyBUV6vBjvFJ9ujwRqNxiPXTxF6rIyxUg2WNW6Qg2Uke7CMZNvBssYZYayMZKvBsnLYOcfKHvU1WEYzD5YVmnmwjPoaK2OcEYNl/VR9GdUoy2dayhfZKOdHDiPWlWZ5wQDKhEurjJbypAl3yJ56l8Ijy9ZU21aSC9sgaS2yxuftCayWs439LInbl8eEW2QUdiBmOopGORP3TYc9qEVGrl2fm3GEapOR69wFa3RFq7zjQZpQW1k0y5mweSFfVjTLlnQQWVAhbTLqMlG6SYpWGWVt6HBdHgBXZCKM70tFh0wqrhVV3SLTq9pjq26QyX2M7Sf0fweoSXv1IrplRbw79cpOCFJZx145dcL6MtdaVeVAOHOdLlUosipb8imz7xkDbm+unTp6qSKTQp6usikccv1p15fCKWPKbn93eWVMuSR0c4TBJ0u8l1l1jDEsuMQp53IQQ+TwMdl/TE6fku32B+XlD1ZYdJ+SbRosI2K1xozgukte0lJXToCUiOaMTfvV2VPQw4bk3lGXtLo+9UbxSGS9Jim/p7KZVef6eTuIAQGZDNPlKMYF/TcZuiyVGB3Wy7ItSsyYMWPG/xD/AIrSnldXeREbAAAAAElFTkSuQmCC",Yy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEXRSTlMA5cgdcw7XjzlWrIFkup0rSDjdhakAAAKOSURBVGje7ZnbkqQgDEAj95va//+1W7u1NVGpHiEJPHEep0ZPJyYBERaLxWKxWPDRaXPphOnE7S8uwmTM9p9JZvT+YGAG6J1rRu9cM3rnmtE714zeuWb0zjWjl2vme5XaLhQYSLx5tUbz2Bl23r0Ad/MJg9Du4X2YnYYRoAS99R8HYGtFbbYgz1F7a/MB4pjKi2ZCO5MayZ2PYndDmqq+d4AHn2GlbdXvMZW6wOQLy7xVgAcxyvtt84aUERNr/5ZINeAx71Ujvcw1Jd/BoW0FMdJLUmn9gVo20eml9kWTXdo7VCvBAWbd6wNGAmmFfO3P3PXfHliEvlFolVR9paZEIx+hkEP3fbxMyBiws93j1TMCJswiIxFyrgN+R/FDto4yfCM/5HILmBByZJeWoe0LE5DQtIBBc3Nd6mHZ28uRmekAXQRmrt1PpgHpLC/eziMDUHMdWI/4A53gUlFYY8tCJ5aQLORg7J8UVhfj4oPREDunqD1047Eh+sF5yXkHWOIGOC2ROc9YSRSX4rwzJdYM4PTi3BkAmV4glrXfK/QlJlSLBPFq1m9m5CvR9y4WCOzUy60jFTV/zxar2UPdR6Qpu0TE0fbHodqP03PtaZcd/LdUTboqABGFR5ikl3mgEgknskXkYFF1n8hqxygtxPSemFnFChhRt5Pqd+8u9Ykgbk1m9CIBWPir+SXb+uo9RD8ofo9C/mNf2K5k2/gtPUh/nFfxSzFguNj2ImZUlypqjdqqk/gFhrgU9dV6bA88gLQZ5bvPxmSfcFJJejHbHRgQpLhmbwFRTtWmVRqEsbkpzRbkCelNmzDcmeoUYBwhf6syH2AsNvrKrXy0MAMd87Grf8r9yJ8TFovFYrFYcPgDfFESW2IpAiAAAAAASUVORK5CYII=",Xy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgN8g7xBgcECfj6+/zzBQ4swJLwAAAaxJREFUaN7t2lluwzAMBFBq9SLbnfuftigQYD5SZLGpaQPoXWBgiqQdKDYMwzAMw3Wp5dySyVX8yNXEAm5kycy9CabAXG0yc7XJzNUmM1ebzFxtMnPVyczVJzP33mQdVRD132EHHjqsk5TxUE7WRYp4InZJLhFPxWL+Gl7QjPoMkmycK0DCoToySNjabCxxgzW8YTE3E94yeW8s+THveFNUTrD/NB84IWkLTdG9o2ULrGSc4PCGXAESrpEZJO2vDact4gempH1gWsS7g5K2pWkRzzAV7dKiqm0t2k5WGpclbaWpOlRaWOuMy7J4e9ChPWKatGuL1vO/HvTdFeFg9whWfW3CxQj+z2f8Z8G7Y7B+gbRPWpkTHFTtrwiatZ9cVOyEXfuOoFXbW/QlPmLKuCgXO2XRVppmcaUpahc1VfG3LUWX1lLv62AXRO0JU3VoafEsN9cLReVdzCEuNAWcMH3ynQRfzPorr1X8vBTEuTRlvChP5ojzrP+bQAl4QSjmL214oiXrY34Yvc3Wz7xm/Couyfoq8xLvU6tJpBqWPUYgx72Fr2TDMAzDMFzxDf7xFoVjSQNhAAAAAElFTkSuQmCC",Zy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgN8g72AQn0Bwv4+vMM9QQt7wKQAAArJJREFUaN7tmtHOpCAMhbUgoqL2/Z92s5t/0/wtkRE4c8V3eTKZMy2lRZlpMBgMBoNBLS55n5zSdvb7OUFZ+C9+yWpAZv5hedRwvszzfy1mNKCvuNhfA/XFO1tf63IoDeVrXZLSwL7iEkhpYF9xccoZ5mudvdJAvsL285Hbau0snEH3q1lr7Zz8yCmbSmmNOM+PeCelrbQmHHEBcvaT1OwciItQkFpQWj2JPyBlljmBNlJ+O5PSABspv6mc0mo5PStKpT0rDVVYtphIaajCElZJttJes/ErNkm2aP06VnmZqXWZL34JZXYCYXZwfjfvSmseSWWc1JdosETbxK5KA1W0bVZOaS8InqsgJyFXTciDK1kl5Jo2ErkaCbmmvnbmtpCj0tABS3iX0sABS3iL0kC9w4bnlIYqaRteUhpuDwvB5podqGnZVhWUhistYZevUdojgZtxmcQ5cKYlr1Fp6ExLXrVWwnMzPhcBsHsIpx0UHMFLLKfaTWm4tiUc8lZEtPLTQ6fqiu+qi7gDV2ZOXN8wpkwn8gVj7kLuq4YxZo2tsf+asdPaMxfQGN9AUqaBpK+1zMWcAfFDYqkYEpE7ECvGYmCh7YC7aw1f1lfmKEPg5wipLae1EnenJV60hj/t+SC1xaIVWbtkeqLXT22xS6ad0cpQj9E0m9FUZulwtp12rnixSO2lFa2GfEKW4GatwUMmeaugrgjAqxwlZ7akgXs5ZVKWel0olu9iFqWB35NLUklpyJuB8kUM/k4i+MI47DuYZRAkpWGdpUtE6wvINuiPGdvnt6lb5nXVhvuDgL3wOJRWS5g/SnOw82WeGnE7F0jOnhR30eqJj9Z7tDfs+zL1IR6es9DqJu3r1zj1I8SVrOvvwG7/TwtTb9wyrxcRs6crzbdexXs/7nMaDAaDwWDwnj/NQlzrb+J5OQAAAABJRU5ErkJggg==",qy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMAYN+fgL9AIO8QcFDPfzCQr49fa1RRAwAAAnlJREFUaN7t2NmumzAQgOHxvhEgnfd/17ZKDhMMSmobz+mR/F1Fraq/jAeywDAMwzAMwzB8N6EfHPBS+ORn4GRxY4CToLCED9jD4bYa8Q3hMOEfU+AMUxdRcYdXfFK8YYWbO2f4hi9uPGHqUpkrHDHziydsMednjrDz21/J7ZXrH3YvNXo9he5h83qV83b1qneYFnren3fsGxYUyjfc9gzTYml40jT6juFtmZaTp6fpFqYDlgE2QdL0O4UdTfV0/t71CdOgE+wkGnaXcKTFyiw07B5hQ3+Sm76GHa4P06QdkPyY79eFJ/iij4M+HoO7LGyy+2YCcjJs1SEMTk2TDh++e4Qrw5/R6mnusKPFZg3TJVveMJ2y4g3Tfe6Zw/TgdLxheq9IvGHaa8EdBnzQPyEsVvO0qr8Mhb3au7sLR33HAvLTjZwKtqKIhXORPukXPHMKxA/PTOgV1u/nNsE/c3oTxVGye+79oizAy3k6YlaKlp7VDWsemLN9ECf0UTjrVl0wlklnXbrgXrfTcW+dwbpfJBYsY7Kfjz1Wfjk3WCjQdkSDxJd1A5ay9NBo+Z0tYSlNO9XQBYWlTPb9sfR86Z8X8ie34RqgkMNyNt9KaWs+X5WL++0wAiqsWG79+k9LxElbqCKxnKeDClBpxhoOmkWsEaGZwRoKmmEVCa0sEtZDXrCOgEYT1lmgTUDCesgJa4XWT8PEKLXuLkotBonX2iNJ0ETu98Vm96rYD1dedsgOq8MGWogsnLK3IJuFLzvkNQuL7AOOexO20MBkYV0QTpeNWh/DkIWve5uIk5TSPCQAoV7cAOD5ctFaR4CotXhIMwzDMAzDMAz/j98ceskaOhA77AAAAABJRU5ErkJggg==",Ky="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAYJ+Av0Df7xBwIJBQz68wzE7woAAAAVNJREFUaN7t2d1ugzAMhmHHSUj4Kfj+r3asmxrIClKYlwzpe8446XuQgi0gAAAAgNuIxj4ZqmsI8s1RVSwvnmpyKWzpBMIII4zwWdjQCYQRRhhhhBE+hDDCCCOMMHX/IOzpxG3D0fJeSGHHe0b35VKBntSMUqLTvHlKhFZhGUiLsVu9ecNvENxP9MlkfurtzkRaeml0I89SJpKSIGUM6fBSaCQdVgo99J6YTQ45SjFPGiYpNtaexrofox5SLGgc8iDS5pCNJFX3LpYLnOIKXXvvWuSSRWMktjnkWS5hjZHY5JC9XDTUHYmJqTsSE1YciczcycbMHCRxlvU2vin7Kc4eyJ0klrzeMsBZ2GVhdxw2eiPxTXg+Do8KIzGFuyzMWVhr41vycMjCYxZW+3e5LCxZ2B6Gw0S/Mbjuk3tar3lrDfvXhbWeol2ZL5EAAAAAAOCvfQALwYE8tktFzgAAAABJRU5ErkJggg==",$y="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAANlBMVEUAAAD////////////////////////////////////////////////////////////////////xY8b8AAAAEnRSTlMA5VZzrI86yR0O12VHK4GeumR+Sig+AAAB1ElEQVRo3u3aYW+jMAyAYTuExEkItP//z550VHCVOGMzl02an6+b+i4hIRQNnHPOOed+KkoruNmAL7nAnQg3M9wp7OEMDA972MMe9vDvDkdgeNjDHvawhz38Xx72sIc9/H1hasNfLazGPZzDu8R8StG/XFIY4FCPFfERlC+XVBJ3cWZNeNKFA/u3N91S+upcx+2ntShGHDfLeGB4dzTVbxNyI2ImhGEbbnCnvIc7qNAUJFKBQ8+tu2iqZcgoNRIAs6wzKbpJluU/el7v7PSJbcy/tKcwtASqrtZotBP0ikG3ZNSbDMIjXtBOBkPCiba9yBQR61yAF9F6xJQlT0wJLyHBtZvsrzA+gVFFe66iXg3AwZdoPdO5y1bNDIym71YC3iQ5LGZ9OMielWs33kxZ9u2gFetdPIOJaH2z7LGKwos+fLqwPnRCzGePfLIRN9vFlcT/UjChWuKeZcSLr+jDD2ZIHbFOadXLyUVRG4twl0SyvXVhDvxZvAvW53FdhjCld+s8lLDEl4qIXb2hDBYdPdivMyUbh3eF39S9Xm6N/+qHKxe48jZm64Oq8mGgi+Vwfi7H01+5YuBFyVMDjfgJA5yj8LDO1qf8ZYSlVMA555xz7rv9AZlKFXj5dr43AAAAAElFTkSuQmCC",Qy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAQCBggN+/nxDvcM8wkFCwoI+ASc+UAAACfUlEQVRo3u3Z7XajIBCAYWAAAVET7v9iN6my6CR0lmo+Np3nV3vSkzcKQmkFY4wxxhhj78EFfQVOPJDr05cgCpNmVjyQuo3IlEVRPDUsxePEV4UlhzmcfVy44zCHPzkMnx2GV4eHV4X1W4WVKDjMYQ6/fRh+TTiswnJ2TtkoVw7+FLqEVfqeFjecNsl3amc4JoKrnOq93BeWVFgKpEsz7/bdav0lwOzUmw1rI77glIU94XblFnXPDZdJMfw8HBTiBM3n8Eh+xuu4pYycw6MttKovAkZQhku3t4su0xlk8kJcwug5rtwvq8TBZKLKSneDFIeLxIN8BJVFuQCAgMLTkUX7zagPKGzEsxhqtc5gsnBk+ITCorhdtI07aNTLg0qtjJBnfRXo2blbTHZhspIZ8bTua5e0zAVLjBmtLMAeff/DsGrIzu9j18tHlaQ2GmgK+zzI9M6niU82pSYyXwv9G6cKQRLbWIMghCuXXxcVuebT8ArZ5xldv1ibB5eYfG2DPJBXbBIZ7lMjtdqSVf02Do76T08rWA2yrocjeUxq1ZU1p/r2LiWjZ6BqK3krs94nPNSeYWqRMamZ2+wT5jxGtTHfyd7MKuWY2o3EzECTqL+7YwcyQ+8T2O30Dbdhm9rZO+tsDwVu5HuNT1j7Bpk+7MC9M8VIJKh9IvOySvtkHPEwGV++vOjt3+9td+VX+4RvmY31hykot3n6DFpOYfPTU9PksPG2q9AQDShscbjsDU7V0QdMQOEJhU8ofNhfnCYUtv8YDnvDHoV7FB62r/uyT+wjEwobFNbb1w87LgW8geBlbzTLmV2Kq+XcBiB3ht0IMMqL6ARjjDHGGGP/qT+Hf7FSTq027wAAAABJRU5ErkJggg==",Jy="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA378ggBAw78+fYECPcFCv86Xy/gAAAk9JREFUaN7t2WlPwzAMgGGnjnP2yP//tWgg0GavaVCOCpH3K1WfHWnjMpjNZrPZbDabzf5cZg8BYXTGq/TIBRgYBpd+8jAoCkt6aYURRZ9EBmQdvliZh77tKr3PQdd0Og16FtNNsL8LVv8OXu6C17tgfJYWNQ6G7ZtRHgEHwhDVJxsIAMAxuG8m7ObdWoMR/TkYg9Y7Qb6o143awto+DrQRMqFKj1ZqB9P34Raz7leOqmG5w6hTmRybLKpguaUqKtj+Yj0sb7dHwZyxNoKP9JyGN4X03NIFThuIjE3PHY3gcDUPI9vtdSOY2HkVigX9kqUy2MJVaJlM2XkuQBms4DLD5CM3OG/QDJayPl8BGlrCYOTbyr+keji/tOWCroelLJc2Oe42h6VMckGv0AOG7VVxyBe0hz4wc0QeKuAK2UEFXCE76gmDrnElXC8rhB6wlKXbHYY143aF4eCuRRgCo7yAx8B0F6w5rMbAxiaeHgGjTTLdB5ajrJS7wNKVbV1g6cpCF1i6sr0HLF2ZNV1gOdmpsDsm94GJMSieqhQ2gqXLH/uRyx1g//byMYnJzWF/csPYuNwY9qf7kWYyNYV1ZrJb+d8awjr7eTomN4Kla03+vuJbwVreG/Py2gaO1/uQ4RtGE/j6Z195UTWBXyeOpejrwBZw2WXq28Ou6MZEruhfbAf78HKFso0PVckFFX4zp6my8QZtyQ17+cWDDzr+EvMDtzL5k5UPaaTt43w7XGQ+347HgpOlA6EkMtEUHbdHhMtMjASz2Ww2m81ms9mIPgCfVZZTXlzW2AAAAABJRU5ErkJggg==",tx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgCDf7xAwz0BwYL+fj1CvJC6qIwAAAtFJREFUaN7tmUlu7CAURelbg9n/av/kKyX7GnjGppRInGmED/AaoMIWi8VisVgsFou/gnE5hOAE+yIi7Lb8YLesGTLBassZFR2bjNjKNXPVmpc6cV64hSwtlGdz4KUHZ8BUL5rne+ebfaERXva6QkSKd+tIQvHw7FxIEczb1ABv4lPaqhx5dcnHj++Hb4s4b8m5nbnpGOUXxYcGnRiwH8xuzk5L3eul/jWvgPU0N3t/TRzKh9ifWpzStTghGAzJPAXd0TjOvatWsWGXxPJB4ZbJ/rEpIp7qHD7azutq+2mYtb3oubmfOBuuGL1FiWbFYqTkz0jTWzHGWCvCEcKvDzhh/4/LrIItHyyk5qkLIKFaFTyqYrkgtZit1VATu8CogZ6LdeybJxvvXiLl6P3EtO8QHhN66Hjrl7E9mQ0m9Ogh45oTFrJ5O+IP7osbTBjM1dQO4B1MLaVZ17xDQoOXRIR66Zl57Q9p/MotGMXsbyc0IlR/KG6pgeToeBELC6aYpcCEtvqON0HwiGb3zOuhUKrkAox7HUSuQXjv0SUU5CrF/Nwrbyaln+ClBYm/4dUSBg+a1T2vhcGDZmVu7bOFwaNmdy++w5NW5wKe40XkSRy/5HWYWjO9OPbD/kXv0HFo1HPvyEXLPfBq8NLNAZrdvZ4zavYPvaNm/qS5x9LCT/NuJ1Hey4HwHW/ALchTvAk2ltwQtideDi8Gmhm9asCLTdLAYrql4B94rSaXJ5ZCGPdKQU+chPeVxK/wWTebDkYytcyu3CCd1KGzV7bxbI/lDrb5cuF4YlWHa7IT16RV9endf52bm+JYD2FEL35fQIiJSIhg5znpK/ddcVOsQEz7ERVDJcdXvHdbIkbEQEUQSZViCrRfNCJuRR9s41u9kDC18XnvFX2j3bHLR/A2zSqzAzpzGh/tYdKy29xFhH9cPsZkxwho5wRbLBaLxWKxWCx+I/8ANf2/u2NhQhAAAAAASUVORK5CYII=",ex="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAIVBMVEUAAAD////////////////////////////////////////PIev5AAAACnRSTlMA7zC/QN+fgCAQTQcGNgAAAMRJREFUOMvd0jEKwkAURdFPBEkdsLFKyAYk2UIqO1uXYOUSXIJbCCiCqzTDe8Ei3qmDrz3caebH+7tHLLZ6fvZpHfFYhwaPV8jOiZ0zn5QTd3vlwIdGOXGhnDiUIytHdk7sHNk5sXNi53dg5a9lPQxDHc6vQUu5YlqjmFbGv++W1W2V5ctY5+L534vpt37E89lspr9eaKmzIfbVIfvqzJSbKTdjLsZczLkYczHmrZjyXWLKtaDcTLkZc+K2TzsTH/Xu2vkDlC8AMDsTJN8AAAAASUVORK5CYII=",ix="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAG1BMVEUAAAD////////////////////////////////rTT7CAAAACHRSTlMAgL9g36+fQGFJCmkAAADFSURBVDjL3dS7DcJAEIRhniJ1SIgEBSAqQFRARguEJBTgxJqy7cDeX7ZGmtwX+fbu8+t2d7Pqsb99lqHH617XX6mZr26lrrCkdr58ljTxnTRxsHQZJwfBwXqWhoP1rmfDwfrVFA5mO3Ozm4DHRCwmZDExjwlaDPcYDrYcbDnYcrDlYM/BnoM9b+Jyvnl+tfxh+beA4elIwoGmdAjJlFIxJHIqg1hEuQRzAZ9c+dN6jmB4bj2hcYW2F5omLfe6PMH/0HLXPHpWgenjpk040QAAAABJRU5ErkJggg==",sx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAMAAAANIilAAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA32CAIEAQ779wz4+fUDCvilaH/gAAAZdJREFUSMftltuOxCAIhsWiVqst7/+0m5jsEIUqm72d/64M33BSWvfVP9WgzKZ4wqRyayhWojwbMwlVhfVAdAnrIeHmVK/TGWAvfOJDRAn3cGqSLURc8AJOSrcqcdIrGBT26r8EFd4FbsSBN2kDzgUnnsAOJohKwZSiBZ6PQpBG+5xP6gpWGGRgiksYDhGax0TFrWBAVzn03GqqK7igcwgces46L+DSS/IfuHDWopBBvrNdHBrdaAnuRdlH/p8xzfj7fLutkLr4JN+cyV7P535MqQQDzHnff4eRRu+DZ2dQ4Y4N8GGBK3sPa/mxwJnhoWawwG2EAxlnNXpnbqC5Yzg5Jz41VpgHe3LeVpg3hxebLV7HDgZ+Hi1YiNqmYZX339B/hNXlnpvrOTR2dgFfYlnCh66dXcCPGIwnThxoCSd5A4FYSzhwYLZZ4UO7+pcRTupRBBMciLQPFwQLfL68HTDt4fD2Jr4N8Ply91oSaeuBS9SO7BaOoLMHGeCq15tJwppTyk6qGuBG9KC6Hk6Y9ERRGXj31f/0A2zyPsVxnMRtAAAAAElFTkSuQmCC",nx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAJFBMVEUAAAD///////////////////////////////////////////+0CY3pAAAAC3RSTlMAYIDvMBDPv4+fcLUOqFYAAAEWSURBVDjLvZW9isJAFIXHkLCw1S5ss9ikt00h2ETyAqn0CaxsbHwCSyvfwN7KEUQ8L2dilJPE4Z5GPFXgy5efOzP3um6i1FkZeYtGQGrJgDflSrfkSjdk6kGZekimHpTHwIZ6Xz5Ngb9JWB8C2QD4KYBrAM9wymscT7AI4GSZuRq74ly6QOZ5g+O1C6fBzHvwd9nHSfu20aKPZ75dsHPZxckSKWVg1cVfgG9XO+/iuK485az/7uKpUyamTpmYOmVi6o18+X3kH9g9r7d3PYKRtJKNeIHFw8WniR8TZRFFFUsiFlRsB7mZ9FZ0g9eNvP/AIdIHWB9/3TwObD1H0bhE2xNNU7Rc0bAN3ethoUeNHlR6zIkheQMcOzccp+sDkgAAAABJRU5ErkJggg==",rx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGBAMAAACDAP+3AAAALVBMVEUAAAD///////////////////////////////////////////////////////+hSKubAAAADnRSTlMAEN+AIO/Pn2AwUI+/cOwbbqMAAAEBSURBVEjH7dJBTsJAFMbxj0Ci4GZCjF7AdeMJTHXjBdy4afQCRC9gOEHjxj1H8AiewCOwKGmBEL4zwLSEB0x5bweb/nZdzL+vb4pG43w6MSy3LEbQtQbkErobkpkzM+TIzJBDaL5odi7o5c7OzKC4Yun+4DseseOB3gR7elH+KU/t2kxKZk7PtBKSf3qmx7WFmsHl9qBkfhF05GRKbxrcYERvKE1+4NCY3vxoRmbI4m3mHZVws3fAD73CHb3ozHUTyQQG9N4kU6NfjZps3lmrE7G0mb3eEyuSCXWNTCnVM6W2lZE98sX+0/NvaP659gpVX83IHmcwPCdFDMu1Q6NxeivVcQUNhbcOPQAAAABJRU5ErkJggg==",ox="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAUCAYAAACTQC2+AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEYSURBVEiJpZVRccMwEERvgsAMagiBYAiBEAgpAzEwBEEIhEAQBKUIUgavH4pnXM2tJTv7qdm7XelWkpkAMAIJeAF3YHA4AxApeACj6qdEBiDzH8HhhYqTPUNmZiehNZtZ7e7L4dVr47u2DcflgovDvQpuaIlMolC6BOZeY0vBSBl8jdRxCtmpy9ThoAw/dZG1SSU2rIlRbH9qiax6nEWPeSHcBOHWK7ISU0EKhj+Xvoj6Yl448snMfo823YFhe7s70RyD2C7AeYeIuoNxTfLeNvg83on67dsidwh5d/AlTQIXsf0jT9DUcqfCcd1hLLROYWkQneJ4lGem/6NvM3tWaz8Or157vmv7QQnHY3GJ/srvlMEnNhL6B6cIZVSNSYqvAAAAAElFTkSuQmCC",ax="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAaCAYAAAC3g3x9AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEPSURBVEiJ7ZVdbcMwFIWPGYRBA6EMFgYthEEIBDPIGGQMuiGohiAQrCEIhG8PSdTKtW/srY87Ul6i60++5/5Y2hHQAzMQAL8Xb4EaYORRA9DUwlpgSsA2BaAthXVrinsKwHkP5gtAsXyNX5uG9ctpZPOVxa9gBPeFGQSgFXnzA9AlsjkaF7iKdAEmjCpidIGAS/RvKGqHBRz7OjoWM3tJB0mfzrmPUuAKfZX0Iulb0lvN2X+lFRflyzn3XgNgmeeTtqLwOHJ/aZuLMh0fftnYs4CrAT0mYB350ZtKloO/g/VG3C0rnrm+onSes2Aj6Bnbgk0zifVmVdGCmustB21I+zZS+4xGYL/edubuOcjpBwCFxkKYDWbkAAAAAElFTkSuQmCC",hx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAMAAAC8EZcfAAAAqFBMVEUAAAD////////////////////////////////////////////////09P////+vt//Kzv/f4f/z9P/y8//o6P/HzP/////z9P/i5P/////v8f/t7//k5P/m6P/w8v/q6//o6f/S1f/X2v9gbP/b3/+vs/+Vmv9daP7///+us/+aof7r7P9xe/719f+Fjv7W2f9ncv7Cxv+4vf+kqv57hP7h4/+Ql/7M0P8zzBhqAAAAJ3RSTlMAn4Ag3xC/70Bgz3Aw748gMJ/iv3BeUM+/r5+PYHCvgN+FQBWPQDAOL4ZsAAAGb0lEQVR42s2b2XbaMBCGbWzMvmUpJXuatpJteQXM+79ZOTZkKAeiGdlW9F9zlM+zSTNSrEY0vx9NV97SnUScRxP3zVtNn58cywjNn+xhxC8qunl4nlvfKWfwMuESTeznrvUtcu48jpQ30s84uOUURd5AJ6OzcM/+fpL7QRxvhGBMiE1cBOtsdxaZvY4uRMfmp0r8OGUXlRZ+8t9nLP5aJNXHC7MC4K5A5iEH/Wy79swWJ3T+hqEk/BNvP7bq6DuIvV3BCIoTiMU7qy05N+BawYhKwYxe32pFnU+8gIGUEH9bzct54wf5DKSKuGw8WZ6Oexo4VwkxO0bifTvuDQWrqfhYdaZNFpclr5SnrLbS/Jgr3cbCz8UkB92IN06TfBB99ZXueCm3kdPieALJ25j8w2Fx3ABfj5cKWKMKoiqZaxPOK75wwxrW5kA4r8k3gerSsERYedmplx/A1zzhtsqUGoTdAx9UvzZs6M6UAT2K/dQJPVW+3+3yAWFHje++aiTo+UvP5XulDbhK4Ji1qlg9UTz6/qG+p9zS+UZVT8laV6IWhk6PkiD1EyWiOvkWArBtFVXHrJLBOdOi6gT7RN9CopS1LnCyS29BAqZJATVPuj3IYC3aQZ4QDCiYNonyDy5oBvSZRmVlUfugGJCeIfVN+E4xYMa0KiMk8kh3BIIJB/hTwk6t4d3ExUaom/AGw/dLbZMT6ySE8WGQqpkQ0+M9qtTAYMvPlKxThVPNAwKwTJE16eP9kF9QtKZ9IzJN+uXiKWXlkF9RGJN9LJ8OT6kezjmoN/RWQ5eDcup+Z+M8XFC674OG0/6nF6afkFvRsI//0HYRcXSv7ZzNnGzOqVOdssP7JQF8JXlYRIB3rr53yBVBymPZLcpPSg6nB/uNrtyI9mid/xrT3/UoVTqRNLXjKhR3lB55Ihm3lU4h5a/rSKdjPiUIvx5pPhNCMK4qi4OY3wmCR0byKugjl8NU1nE1fydMGabydjggGHCEax9wUV3Ih3HlwGiDMyBy7yydvMXNuqRHrg/8RhwfHCzVAG/CtPzphyyJQ1wKgzswJsybSeMf+CSO4IiOMeEWHzY/ZGtleA93MYAOvtJksq9+RwOuwcO4JidAx82r7Ljvo791hGwT0UHoy2Y0CzTg7jxaZJG9QwHKJiA22hlbyDdcF5GgA8duBLA8aDk4QAddvILmAMvMtJAqf6wZMIIqo82CkCT0GKwPCDH4ULfMQM3va8/iTht1EPan+nXwmbbUCgdo0z77TvatO/Re3CMMRONG9uI++uCRcnQQ9vGN2FbWus9gLdwkBe3hDH+Gm1lfqPyFwF++ONjTVoEecEXWV1riO5wQaUIPP+0p5GPgFX7y4eNM2OewJMorL/ImMaNcATqYlzchYVTxKC/6W8Kshw8lDqZcS4byQ+aMMqkI5S8pp5SHBSmmzxlCymGnl/bVJbtT0vwtwFyVPFCuwTaH4a9zLf5oL29yzEXEEwQhOgy5O7i4b5Z8hCuNEF4G1A5CqDWVhv2LeKRrXQEhKA3CnPKSspLXOWEcd454UcGw8nGt9h3ULXSmHNSzp53BoDNdlXSQHxQPvyK3zpihlSb8qjJBfcU1s6Rakq+z4yuICeA1OS4bgI9rISYxoyiN4DQtyeNI5c2M8P9j3AVC5e1Mr4s+YIYq1+3B2s8yf13EjK4QTjIyzfU9O6JPlOE6LGRalVBe297rNiEYEKk3zSYEA5pqwjUYECcXtikdSiOKASGRM6ZJOcmAUAv5hmlRrPCI1Znoy5N0W24iM4ukd32vbHO4NqXI1ZHJMENZWlQ5ETzZaFMiUv3fpleuIwzTLTiYqhcdYZhBBpM1gycbrcmv9U9DDm+TEPiisaWoEbHzpm/BqgEI07g2i03A4Ym8qh6BsC2+hVVLD0DYDp9t1dQtELbBd2vVVXcIhM3zDbuWmYQnfEYSnvAZSSjjoxPaB0JD+fY6EppUXy4TmsoHhKbyAaGpfEBoKt8noV/zfAV8xhH653yGEV7gM4rwIp9BhFf4jCG8ymcI4Rd8RhB+yWcAoYTv2wl18wGhqXxAaCofEJrKB4Sm8gGhqXxAaCqfZXWkhD5tftUaoal8QGgqHxCaygeEpvIBoal8QGgqHxCaygeEpvIBoal8QGgqHxCaygeEpvIBoal8n4TG8u0JDefbExrOtyc0nG9PaDjfntBwvj1h03z/ABD9FUIpArU6AAAAAElFTkSuQmCC",lx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAACMCAMAAACZHrEMAAAAeFBMVEUAAAD///////////////////////////////////////////////////////////////////+Kior///+ZmZmRkZHw8PDFxcXT09Onp6fq6uq2trb4+Pjx8fG9vb2goKDi4uLMzMyvr6/39/fg4OC+vr7b29uYmJjRFtxTAAAAEnRSTlMAIN+A778QcGDPMJ9AkKCwUH/CxK06AAAEhUlEQVR42u2biZLaMAyGc5BACEcrxXEOjgW2u+//hjUsRdPJDLEti810+j3BP9Kvw04ccVgu0nKbJDM0zJIiK9Mfy+gbyBfr4iZiQLb+kUcvJP6Z4VOyeRy9hHyeoQXFQl7PqpyhLaWsnNXfQakb3Z8/PxUY1Oex7fVH93e6VhEhJ2X3fmgVEER7eEcik4lOXpKSxgh5xrnZiSZr/vDK+0HBKKp/JCyZR2GJs4eUFixpm4ecWCAsJMWO6o+cWbjg5Gv8Yt+CI+c9frEOlaLiblsNHuigqVomeKOrwItqH07N8m6XExB+wZmxJ/rinqIeGPQXvLEIomVPKWKkiqlmSVrCqGFkKv7yS6eAjeqYvokT0hJADa+mSEtANYXfTrr+8ouCQKi9fy+eD7wbyMVzX/PuKghIdbmZOPY0TA9B6fFK5pckDYE5UaJcq3oPweluiXKrqBKvkGEC26Z0CoxMkmiEuxxhMkpScPaOHl7hlTOI0FJo7APTgBBvTqGJ7d0rH5pSLjAUmtIlMC2I0VKvsVs1OxDkzb4NFzSUhDiQhW2ytFMgiLq14dh2RDYgSoOG1LbJnEGU1jJPOV4BOShP4/X0Aw3vIAfV08JuDT+AMAe71TyT6nhD0xTRGGQZSdStCVudrjsQp6aT94h/P0CcxsbBKe2bomibtreRG0zDE1Q5iWICOKNhazOyjyBOhYbE5lT7CTbIi5mhQYEo1Ggm0fMMeOW/mH9BzKSqKbHvM/I7xFZ+A6YOnE1i0fuz6k3goHLlgw6VI1czNYjT2dxE5PiSeaDQ6qxSSDuY/FvYHVVOIExD/h01zQ6Eqe0ur/LZC3a9Iy0Qz8lkV3LK0tbq4ko+T/X9oDKFPDlc6m3Ez3GN/XXnSrrvVS4XwYWwhTXtMuOk/CtGvn3JwqJ7RO/2oTIVHd21vX1pdPcgQo90CWzFRig0FBjnz4K/wPDtgTGhkSoodQ/MJL6YatfAUK+pIDAVugaGek0DgWn8/qFJJb7HHZHuFV3IE4Eb4Zqmkhur8OWt/X9Jy4J6mP6DYPyL9hbQvVTW7qRhE9WTe30oQiaqGrjXx8NvE0jSlXW4RB0YSaJmEyZR1eWRpO9PVE1J4ibqBEw0JYlDEWJGtchPErW+WrEMQ0liMufb5oN+FeSy5da3HmxUnPrm2eY4+CuZX991xTLMMuLDt01HVR2GzL/baBxcmbFt42viw8AwoR6J7I5+RxOMo6DMvUxc1SMdhjWkOiVkXnkTn3DsEwHzfYZ2LSQyb3gTY++2gM/iSIQFupRUdSHzSpA6lFRVk3ll2KDtcqNqepgiRF7YTqlOqpCGJdWMFrVcIQ0fg+mARc1/JqfHteAyEmeBY+2mRypqaVJ8voYekYpanvRp8ztePLTw2031pNltopdRkJqBlkGDkSb/S81QS5JHXPjvPVXNaTB8NQFfkfLf5QIQTC38XashLQ37jThfzRS0PAZDQ1rYr9X5ak60NLC18NVoAM0YjoGHptY+w1FKzSS0GDUT0mLUTEiLUTMhLUbNhLQYNRPSYtSE0fIbFg3xTdS8kE8AAAAASUVORK5CYII=",cx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAACMCAMAAACZHrEMAAAAdVBMVEUAAAD/////////////////////////////////////////////////////////////////RET/////W1v/6Oj/oqL/ubn/c3P/UFD/8/P/3Nz/ior/0ND/5+f/ra3/f3//T0//lZX/lpb/Z2f/xcX/9PT/aGguCk8uAAAAEXRSTlMAIN+A77+fEHDPMEBgkLBfUGJvpxAAAASDSURBVHja7ZyJkpswDIa5Cbla2WAI5Gqyu+//iCUhjaYzmdhGEst0+j3BP9KvwyZOQGG5jrNtFCWqJ4mKNIt/LoNvIF9vikS9It38zIMJCeNUvSVdhMEk5ItUOVCs5fWsskS5ksnKWf0dlNJU3UnrM/Sc9bXuqo/273StAkROym5/qc/wivqyV0gqE508QyUGhbzkZHaiyVo8vbK/nMHKuXsmLFoEvITpU0oNjtTmKScUCAtKcUP/kZPwBSffqIFDDZ6cDmpgw5Wi4mHbCkZQsaZqGak7rYZR6AOfmuXDLke4QwhOQp7oPx4p6oBA9+g6P1i0HDSQ0AcGNUvUwqOGkKlw8Et7BjJNS/RNGKEWBjW0mkItjGqKcTvpZvDLGZhoDuN78eKNd0kuXow1704DI3p3N3E40jAdsNIN29+4JFXAzBET5VvVB2CnvSfKr6KGfRcNw2ybzCswMknCEe5zhEkxSewcPD28UjdOIEKNoXEPjAEh9l6hCd3dKx+aTC4wGJrMJzA1iFF79Jq16mlBkL17Gy5wKAlxQQu7ZGnXgCDNvQ2HriPSgChG9cSuTeYEotSOecrVDZAD82Svp5+qZw9yYD2t3dbwXyDMxW01T107Ht00RWADLSNJc2/CTqfrFsQp8eRt8e8HiGNcHBzjvilK5dL2MvfBRD9BZbMoJoCT6tm6jOwriKNVT+RyqtXggryYRPU0IAo2mln0vB5147+Yf0HMrKopcu8z8jvEVn4Dxg6czmLR+7PqzeCgcuMDD5WWq5kSxGldbiJyNck8aJTTWaWYxMEnLCarg48gjEH/Wk2zA2FKt8urPJlg17sOC4SddIKV3AxLp531BHkqHweVOeTJ41IvEz/HGffrzpV039M+F8GFsIUr3GXsxPQrRrp90cKie0Tn96EyFh3dpbt9cXR3IEKn8BLYiYwaGnpgkFA9XfPtgelDI1VQzSMws/hiWvkGBnuNBma08g0M9hoDzJhxv6GJJb7HXRXeK/qQRwI3wqVlKlmG9y9+966DEaTcHtaf6F5fwoT5a4/BsvYn5k1Uh+4dQ8GZKG1xr5uH9zNI0o0NX6IuhCRhs+FJlP58Jun7E1VikqiJOgKRCpNEoeCYUbWiJwlbX9mQDINJIrKg2+YDfypIZUut7wo3KjJ5RLPNF9sv/bG+S00yzDKgQ7dNi1XNQ4rdZpxhtgEfeTTWxJc3hqE9Etld/Y8m2GH4WIwysS4tHYY0pNpGyLzyJj4q/ETASxj5nr8ri3npJlad3wKehIEIa+VTUvoTzStB7FFSukTzypAp1+WmGbRsAjnywnVKta6FRC8pYy1qj0IiPwarGIua/kyusmtRy0CctbK1m05hUUsTq/dr6JfCopYnftv8vj4n1ILtRr9pdlkwGQWqea2lCKYjRzUvtUTT/mdG9HLXakpKg6GrYXxFSn+XC4AQtdB3LYNaDPmNOF3NHLQ8B4NBLR6X8VJqjrg0kLXQ1VQAFWE4Mg/NqiIMR3Y1s9DSq5mRll7NjLT0amakpVczIy29mhlp6dXwaPkN5W7InuRCZwAAAAAASUVORK5CYII=",dx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAPElEQVR4AezXMQoAMAgDwND//9n2B51EhxNcQ7gtJ7NX0wWiAAECBAgQIECAAAECBAgQWCFQb6G3/Sc7FwAA//+f4+OPAAAABklEQVQDAI04ICFaxIVcAAAAAElFTkSuQmCC",ux="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwAgMAAACTeJdcAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAiSURBVDjLY2hgwA5GJUYliJBYhQMwOAwWF45KDEUJXOkKAA7xNyG+w0wTAAAAAElFTkSuQmCC",px="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAABgAgMAAAAm4hnjAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAjSURBVDjLY1gFBg4MQMAExGBqlDPKoS0HkuoGjXNGOcOVAwDBxwm1N3ts8gAAAABJRU5ErkJggg==",fx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAOklEQVR4AeySSQoAMAgDp/3/n9v4ABc8eRCSUyAwmgu8xIp9WYGfFpItgBk3OPpW5HAnMxBE0NciwAcAAP//bVPdOAAAAAZJREFUAwDM4hAZDjaEjwAAAABJRU5ErkJggg==",gx="/assets/doubleBed.CzextF6m.png",mx="/assets/sleep.C_YKDk6M.json",yx="/assets/sleep.CRKZ3XeQ.png",xx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3%2014H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2011V14C3%2015.1046%203.89543%2016%205%2016H19C20.1046%2016%2021%2015.1046%2021%2014V11'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M6%2016V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M18%2016V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M4%2011C4%209.34315%205.34315%208%207%208H17C18.6569%208%2020%209.34315%2020%2011'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Sx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='12'%20cy='12'%20r='5'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M5%2010V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M19%2010V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2012H7'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M17%2012H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",vx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3%2018V7C3%205.89543%203.89543%205%205%205H19C20.1046%205%2021%205.89543%2021%207V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2014H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M7%2010H10V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M14%2010H17V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M2%2018H22'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",bx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2018V7C4%205.89543%204.89543%205%206%205H18C19.1046%205%2020%205.89543%2020%207V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M4%2014H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M9%2010H15V14'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M3%2018H21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",wx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2019.5C4%2018.1193%205.11929%2017%206.5%2017H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M6.5%202H20V22H6.5C5.11929%2022%204%2020.8807%204%2019.5V4.5C4%203.11929%205.11929%202%206.5%202Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M8%206H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M8%2010H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Cx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6%208V18C6%2019.6569%207.34315%2021%209%2021H15C16.6569%2021%2018%2019.6569%2018%2018V8H6Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M4%208H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M9%205V8'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M15%205V8'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M12%203V8'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Ax="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%207C7%204.23858%209.23858%202%2012%202C14.7614%202%2017%204.23858%2017%207V17H7V7Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M7%2013H17'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3ccircle%20cx='12'%20cy='10'%20r='1'%20fill='white'/%3e%3cpath%20d='M5%2017H19V20C19%2021.1046%2018.1046%2022%2017%2022H7C5.89543%2022%205%2021.1046%205%2020V17Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Px="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='5'%20y='4'%20width='14'%20height='16'%20rx='2'%20stroke='white'%20stroke-width='1.5'/%3e%3ccircle%20cx='12'%20cy='12'%20r='3'%20stroke='white'%20stroke-width='1.5'/%3e%3ccircle%20cx='12'%20cy='7'%20r='1'%20fill='white'/%3e%3c/svg%3e",Mx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%2010H17V15C17%2016.1046%2016.1046%2017%2015%2017H9C7.89543%2017%207%2016.1046%207%2015V10Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linejoin='round'/%3e%3cpath%20d='M5%2010V14C5%2015.1046%205.89543%2016%207%2016'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M19%2010V14C19%2015.1046%2018.1046%2016%2017%2016'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M8%2017V19'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M16%2017V19'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3c/svg%3e",_x="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%206H20V18H4V6Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linejoin='round'/%3e%3cpath%20d='M10%206V18'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M4%2012H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3c/svg%3e",Tx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='12'%20cy='8'%20r='4'%20stroke='white'%20stroke-width='1.5'/%3e%3cpath%20d='M8%2012L5%2018H19L16%2012'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3ccircle%20cx='9'%20cy='8'%20r='0.5'%20fill='white'/%3e%3ccircle%20cx='15'%20cy='8'%20r='0.5'%20fill='white'/%3e%3c/svg%3e",kx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%203V5M12%2019V21M21%2012H19M5%2012H3M18.36%205.64L16.95%207.05M7.05%2016.95L5.64%2018.36M18.36%2018.36L16.95%2016.95M7.05%207.05L5.64%205.64M16%2012C16%2014.2091%2014.2091%2016%2012%2016C9.79086%2016%208%2014.2091%208%2012C8%209.79086%209.79086%208%2012%208C14.2091%208%2016%209.79086%2016%2012Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Rx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6%203V21M18%203V21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M6%2012H18'%20stroke='white'%20stroke-width='1.5'%20stroke-dasharray='2%202'/%3e%3c/svg%3e",Ex="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2011V17H20V11'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M8%2011V17M12%2011V17M16%2011V17'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M4%2011H20'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M6%207L18%207'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3c/svg%3e",Ix="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6%207H4V17H6V7Z'%20fill='white'/%3e%3cpath%20d='M20%207H18V17H20V7Z'%20fill='white'/%3e%3crect%20x='6'%20y='11'%20width='12'%20height='2'%20fill='white'/%3e%3crect%20x='16'%20y='8'%20width='2'%20height='8'%20fill='white'/%3e%3crect%20x='6'%20y='8'%20width='2'%20height='8'%20fill='white'/%3e%3c/svg%3e",Bx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%205V19'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M8%208H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M8%2012H16'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M10%205L12%203L14%205'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Dx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3%209.5L12%203L21%209.5V20C21%2020.5523%2020.5523%2021%2020%2021H4C3.44772%2021%203%2020.5523%203%2020V9.5Z'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M9%2021V12H15V21'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",vi="system-ui, -apple-system, sans-serif",Fx=["#a8c8f5","#9de5c7","#d4b9f7","#ffd399"],zx=["#d6e7fc","#d1f4e5","#ece0fb","#fff0d9"],_n=["#2563b8","#26966b","#7c3fb8","#d97706"],Na={global:{containerTop:"0px",containerLeft:"0px",containerWidth:"100%",containerHeight:"100%",backgroundColor:"#f6f6f6",backgroundAlpha:1,performanceMode:!1,resolution:window.devicePixelRatio||1,enableLogger:!1,rendererPreference:"webgpu"},map:{autoPaddingHorizontalPercent:.05,autoPaddingVerticalPercent:.05,adjacencyThreshold:3,originChangeAutoFitThreshold:2,sizeChangeAutoFitThreshold:10,obstacleColor:"#999999",freeColor:"#ebebeb",autoFitOffset:{x:0,y:0}},room:{colors:{sortBy:"index",strategy:"priority",active:[...Fx],inactive:[...zx],name:[..._n],propertyTheme:[..._n],selectionIndicatorBackground:[..._n],selectionIndicatorIcon:["#ffffff","#ffffff","#ffffff","#ffffff"],[re.NO_ROOM_DATA]:"#ebebeb",[re.ROOM_GAP]:"#ebebeb",[re.OBSTACLE_ROOM]:"#ebebeb",[re.UNKNOWN_ROOM]:"#ebebeb",[re.VERSION0_ROOM]:""},nameLabel:{fontSize:12,fontFamily:vi,fontWeight:"500"},type:{assets:[Dx,xx,Sx,vx,bx,wx,Cx,Ax,Px,Mx,_x,Tx,kx,Rx,Ex,Ix,Bx],iconSize:12,gap:4,position:"left",container:{visible:!0,size:16,borderRadius:16}},property:{displayOrders:["cleanMode","suction","cistern","cleanTimes"],iconWidth:14,iconHeight:14,foldable:!0,offsetX:0,offsetY:6,iconGap:0,container:{backgroundColor:"#ffffff",paddingVertical:2,paddingHorizontal:2,borderRadius:16,tailHeight:2,tailWidth:8},suction:{assets:[Gy,Uy,Hy,Vy,Ny]},cistern:{assets:[jy,Yy,Xy,Zy]},cleanMode:{assets:[qy,Ky,$y,Qy]},cleanTimes:{assets:[Jy,tx]},cleanOrder:{color:"#ffffff",fontFamily:vi,fontWeight:"400",fontSize:10,gapRight:2}},selectionIndicator:{iconSrc:rx,iconWidth:14,iconHeight:14,containerWidth:16,containerHeight:16,strokeWidth:2,strokeColor:"#ffffff",borderRadius:16,offsetY:4,offsetX:0,tailHeight:2,tailWidth:6},floorType:{assets:["",dx,ux,px],opacity:.1,scale:.2},enableElasticScale:!1,elasticMinScale:.6,elasticMaxScale:1.5},path:{lineWidthFixed:!1,incrementalThreshold:5,commonPath:{visible:!0,color:"#ffffff",width:.5},transitionPath:{visible:!1,color:"#ffffff",width:.5},chargePath:{visible:!1,color:"#ffffff",width:.5},mopPath:{lineVisible:!0,lineColor:"#ffffff",lineWidth:.5,trackVisible:!0,trackColor:"#ffffff",trackAlpha:.4,trackWidth:4}},carpet:{src:fx,opacity:.5,scale:.2},robot:{icon:{sizeFixed:!1,width:8,height:8,src:Wy},speed:0,rotationCorrection:0,sleepAnimation:{jsonSrc:mx,imageSrc:yx,framePrefix:"sleep_",width:16,height:16,sizeFixed:!1,frameCount:96,offsetX:8,offsetY:-8},ring:{size:1,color:"rgba(255, 68, 68, 0.2)",strokeWidth:1,strokeColor:"#ffffff",strokeDashed:!0,strokeDashArray:[4,4]},pulseCircle:{size:12,color:"#4cd964",strokeWidth:0,strokeColor:"#ffffff",duration:1e3,sizeFixed:!1,minScale:.5,maxScale:1,minAlpha:.5,maxAlpha:1}},chargingStation:{icon:{sizeFixed:!1,width:8,height:8,src:Oy},rotationCorrection:0,ring:{size:1,color:"rgba(255, 68, 68, 0.2)",strokeWidth:1,strokeColor:"#ffffff",strokeDashed:!0,strokeDashArray:[4,4]}},interaction:{zoomRange:{min:.5,max:8},fitMinScale:1,fitMaxScale:4,enable:!0,enableDoubleTapZoom:!0,enableRobotClick:!1,enableChargingStationClick:!1},controls:{iconWrapperWidth:24,iconWrapperHeight:24,iconWrapperBorderRadius:16,iconWidth:12,iconHeight:12,deleteIconSrc:ix,rotateIconSrc:sx,scaleIconSrc:ex,moveIconSrc:nx,horizontalScaleIconSrc:ox,verticalScaleIconSrc:ax,moveButtonOffset:30,textFontSize:12,textFontFamily:vi,textFontWeight:"400",renderOrder:["forbiddenSweepZone","forbiddenMopZone","cleanZone","virtualWall","spot","wayPoint","divider"],forbiddenSweepZone:Ei.forbiddenSweepZone,forbiddenMopZone:Ei.forbiddenMopZone,carpet:{minSize:1,iconWrapperFillColor:"#5d68fe",fillColor:"rgba(93, 104, 254, 0.1)",outlineOffset:30,outlineStrokeColor:"rgba(0, 0, 0, 0.7)",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(93, 104, 254, 0.05)",showRotateButton:!0,textColor:"#5d68fe",textPosition:"bottom",textOffset:20,editing:{isDashed:!0,dashArray:[4,3]},normal:{isDashed:!1,dashArray:[0,0]}},cleanZone:Ei.cleanZone,virtualWall:{iconWrapperFillColor:"#ff4444",lineWidth:2,lineColor:"#ff4444",hitAreaThickness:30,outlineOffset:16,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",minWidth:1,textColor:"#ff4444",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},spot:{iconSrc:hx,iconSize:8,iconSizeFixed:!1,size:1,strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",showText:!0,textColor:"#5d68fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0],showIcon:!0,showFrame:!0},normal:{isDashed:!1,dashArray:[0,0],showIcon:!1,showFrame:!0}},wayPoint:{showOrder:!0,normal:{iconSrc:lx,iconSize:32,orderText:{fontSize:10,fontFamily:vi,fontWeight:"600",color:"#8a8a8a"},orderContainer:{size:12,backgroundColor:"#ffffff",offsetY:20,offsetX:0}},editing:{iconSrc:cx,iconSize:38,orderText:{fontSize:14,fontFamily:vi,fontWeight:"600",color:"#ff4444"},orderContainer:{size:16,backgroundColor:"#ffffff",offsetY:23,offsetX:0}}}},furniture:{assets:[{type:1,src:gx,width:1.8,height:2}],opacity:1,iconWrapperFillColor:"#26a69a",outlineOffset:16,outlineStrokeColor:"#26a69a",outlineStrokeWidth:1.5,outlineFillColor:"rgba(38, 166, 154, 0.05)",outlineDashed:!0,outlineDashArray:[4,3],showSizeText:!0,textColor:"#26a69a",textPosition:"bottom",textOffset:8,minScaleRatio:.5,maxScaleRatio:2,rotateDirection:"cw",lockAspectRatio:!1},divider:{lineColor:"#ff4444",dashLineWidth:2,dashLineDashArray:[4,3],solidLineWidth:2,endPointSize:12,endPointColor:"#ff4444",endPointStrokeColor:"#ffffff",endPointStrokeWidth:2,hitAreaThickness:30,resetDividerWhenOutOfRoom:!1,defaultExtension:20,defaultDirection:"horizontal"},detectedObject:{height:43,width:38,interactive:!1,anchor:{x:.5,y:.5}},heatmap:{cellSize:2,maxDistance:14,smoothIterations:10,heatmapAlpha:.8,useGradient:!0,colorGradients:["#FF3B30","#FF7A00","#FFA100","#FFD700","#99DD70","#2EC070","#40E0D0","#88D0E9"]},snapshot:{format:"png",quality:1,antialias:!0,resolution:4}},Lx={dividingRoomId:-1,enableRoomSelection:!1,enableInteraction:!0,enableMapClickCapture:!1,editingForbiddenSweepZoneIds:[],editingForbiddenMopZoneIds:[],editingCleanZoneIds:[],editingCustomZoneIds:{},editingVirtualWallIds:[],editingSpotIds:[],editingWayPointIds:[],editingCarpetIds:[],editingFurnitureIds:[],roomPropertyFoldIds:[],roomSelectionMode:"checkmark",mapRotation:0,selectRoomIds:[],showRoomProperty:!1,showRoomOrder:!0,showRoomName:!0,showRoomType:!0,showPath:!0,showRobot:!0,showChargingStation:!0,showRoomFloorType:!0,showCarpet:!0,showDetectedObjects:!0,showFurnitures:!0,showCustomCarpets:!0,showChargingStationRing:!1,showRobotRing:!1,showRobotSleepAnimation:!1,showRobotPulseCircle:!1,unit:"meter",unitLabel:"m",selectedCarpetIds:[]},ja="MAIN",ne=5e3;function Ox(r){return{all:r=r||new Map,on:function(e,t){var i=r.get(e);i?i.push(t):r.set(e,[t])},off:function(e,t){var i=r.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):r.set(e,[]))},emit:function(e,t){var i=r.get(e);i&&i.slice().map(function(s){s(t)}),(i=r.get("*"))&&i.slice().map(function(s){s(e,t)})}}}class rc{constructor(e){this.app=e}getApp(){return this.app}getConfig(){return this.getApp().config}getDebuggerMode(){return!1}getRoomData(e){return this.getApp().managers.roomsManager.getRoomPropertyById(e)}metersToPixels(e){return this.getApp().metersToPixels(e)}pixelsToMeters(e){return this.getApp().pixelsToMeters(e)}metersToDisplayUnit(e){const{unit:t}=this.runtimeSnapshot;switch(t){case"feet":return e*3.28084;case"centimeter":return e*100;case"meter":default:return e}}get ticker(){return this.getApp().ticker}get mapState(){return this.getApp().mapState}get isMapDrawn(){return this.getApp().isMapDrawn}get config(){return this.getConfig()}get gloalConfig(){return this.getConfig().global}get mapConfig(){return this.getConfig().map}get roomConfig(){return this.getConfig().room}get heatMapConfig(){return this.getConfig().heatmap}get pathConfig(){return this.getConfig().path}get carpetConfig(){return this.getConfig().carpet}get robotConfig(){return this.getConfig().robot}get chargingStationConfig(){return this.getConfig().chargingStation}get interactionConfig(){return this.getConfig().interaction}get controlsConfig(){return this.getConfig().controls}get furnitureConfig(){return this.getConfig().furniture}get dividerConfig(){return this.getConfig().divider}get detectedObjectConfig(){return this.getConfig().detectedObject}get snapshotConfig(){return this.getConfig().snapshot}get appContainer(){return this.getApp().components.appContainer}get interaction(){return this.getApp().components.interaction}get viewportContainer(){return this.getApp().components.viewportContainer}get mapManager(){return this.getApp().managers.mapManager}get pathManager(){return this.getApp().managers.pathManager}get heatmapManager(){return this.getApp().managers.heatmapManager}get controlsManager(){return this.getApp().managers.controlsManager}get detectedObjectManager(){return this.getApp().managers.detectedObjectManager}get customElementsManager(){return this.getApp().managers.customElementsManager}get roomsManager(){return this.getApp().managers.roomsManager}get editControlManager(){return this.getApp().managers.editControlManager}get furnitureManager(){return this.getApp().managers.furnitureManager}get runtime(){return this.getApp().runtime}get runtimeSnapshot(){return Fy(this.getApp().runtime)}isInteractionEnabled(){return this.runtimeSnapshot.enableInteraction}fixPrecision(e,t){return Kl(e,t)}get events(){return this.getApp().events}get baseScale(){return this.getApp().components.interaction.targetScale.x}get currentScale(){return this.getApp().components.appContainer.scale.x}get emitter(){return this.getApp().emitter}getChargerPosition(){const e=this.mapState;return e?this.fixPrecision({x:e.charger.x-e.origin.x,y:e.charger.y-e.origin.y}):null}getRobotPosition(){const e=this.pathManager.robot;return e?e.getCurrentPosition():null}}let Wx="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Gx=(r=21)=>{let e="",t=r|0;for(;t--;)e+=Wx[Math.random()*64|0];return e};class Ux extends L{constructor(t,i){super();g(this,"viewportBounds",{x:0,y:0,width:0,height:0});g(this,"maskGraphics",null);g(this,"containerElement",null);this.containerElement=i||window,this.calculateViewportBounds(t.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),this.createMask()}calculateViewportBounds(t){const{containerTop:i,containerLeft:s,containerWidth:n,containerHeight:o}=t,{width:a,height:h}=this.getContainerSize(),l=this.parseSize(s,a),c=this.parseSize(i,h),d=this.parseSize(n,a),u=this.parseSize(o,h);this.viewportBounds={x:l,y:c,width:d,height:u}}getContainerSize(){if(!this.containerElement)return{width:window.innerWidth,height:window.innerHeight};if(this.containerElement===window)return{width:window.innerWidth,height:window.innerHeight};const t=this.containerElement;return{width:t.clientWidth||window.innerWidth,height:t.clientHeight||window.innerHeight}}createMask(){this.maskGraphics=new H,this.maskGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215),this.addChild(this.maskGraphics),this.mask=this.maskGraphics}parseSize(t,i){if(!isNaN(Number(t)))return Number(t);if(t=t.trim(),t.endsWith("%")){const s=parseFloat(t)/100;return i*s}if(t.endsWith("vw")){const s=parseFloat(t)/100;return window.innerWidth*s}if(t.endsWith("vh")){const s=parseFloat(t)/100;return window.innerHeight*s}if(t.endsWith("rpx")){const s=parseFloat(t),n=window.innerWidth/750;return s*n}return t.endsWith("px")||!isNaN(parseFloat(t))?parseFloat(t):(w.warn(`Cannot parse size value: ${t}`),0)}getViewportBounds(){return{...this.viewportBounds}}updateViewport(t){var i,s;this.calculateViewportBounds(t.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),(i=this.maskGraphics)==null||i.clear(),(s=this.maskGraphics)==null||s.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215)}addContent(t){this.addChild(t)}}const Hx="interaction",oc="roomFill",ac="free",Or="roomFloorType",hc="carpet",lc="obstacle",cc="heatmap",dc="path",je="furniture",Ke="controls",uc="roomInfo",Ye="detectedObject",Ii="customElement",Bi="customElementGif",pc="chargingStation",fc="robot",$e="customCarpet",ke="editControls",Vx=[Hx,oc,ac,Or,hc,$e,lc,cc,dc,je,uc,Ye,Ii,Bi,pc,fc,Ke,ke],Nx=[Ke,ke,$e,Ii,Bi,Ye,je];class jx extends L{constructor(t){super();g(this,"layers",new Map);g(this,"mapRotation",0);g(this,"backgroundGraphics");g(this,"lastBackgroundState",null);this.appService=t;const s=this.appService.getApp().getViewportBounds();this.position.set(Math.round(s.width/2),Math.round(s.height/2)),this.pivot.set(0,0),this.backgroundGraphics=new H,this.backgroundGraphics.label="snapshotBackground",this.backgroundGraphics.visible=!1,this.addChild(this.backgroundGraphics),this.initializeLayers()}initializeLayers(){Object.values(Vx).forEach(i=>{const s=new L;s.label=i,i===Ke&&(s.isRenderGroup=!0),i===ke&&(s.isRenderGroup=!0),i===Or&&(s.eventMode="none"),this.layers.set(i,s),this.addChild(s)})}getLayer(t){return this.layers.get(t)}addToLayer(t,i,s){const n=this.layers.get(t);return n?(s!==void 0&&(i.zIndex=s),n.addChild(i),!0):(w.warn("[AppContainer Debug] Layer not found:",t),!1)}removeFromLayer(t,i){const s=this.layers.get(t);return s&&i.parent===s?(s.removeChild(i),!0):!1}clearLayer(t){const i=this.layers.get(t);return i?(i.removeChildren(),!0):!1}setLayerVisibility(t,i){const s=this.layers.get(t);return s?(s.visible=i,!0):!1}updateOriginTrackedLayers(t,i){Nx.forEach(s=>{const n=this.layers.get(s);n&&n.position.set(t,i)})}getLayerVisibility(t){const i=this.layers.get(t);return i?i.visible:!1}setMapRotation(t){this.mapRotation=t*Math.PI/180,this.rotation=this.mapRotation}getMapRotation(){return this.mapRotation*180/Math.PI}getMapRotationRadians(){return this.mapRotation}getSnapshotBounds(){this.layers.forEach(s=>{});const t=this.backgroundGraphics.visible;this.backgroundGraphics.visible=!1;const i=this.getLocalBounds();return this.backgroundGraphics.visible=t,new et(i.x,i.y,i.width,i.height)}updateBackground(t,i){if(!i){this.backgroundGraphics.visible=!1,this.lastBackgroundState=null;return}const s=this.getSnapshotBounds(),{x:n,y:o,width:a,height:h}=s;if(this.lastBackgroundState&&this.lastBackgroundState.color===t&&this.lastBackgroundState.width===a&&this.lastBackgroundState.height===h&&this.lastBackgroundState.x===n&&this.lastBackgroundState.y===o){this.backgroundGraphics.visible=!0;return}this.backgroundGraphics.clear(),this.backgroundGraphics.rect(n,o,a,h).fill(t),this.backgroundGraphics.visible=!0,this.lastBackgroundState={color:t,x:n,y:o,width:a,height:h}}}class Xt extends jt{constructor(t,i){super(i);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"sizeFixed",!0);g(this,"baselineScale",1);this.appService=t,this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ct(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,i){this.fixedWidth=t,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,t&&this.isFixedSizeSet?this.applySize():!t&&this.isFixedSizeSet&&this.applySize()}set width(t){if(this.isFixedSizeSet){w.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置宽度");return}this.setFixedSize(t,this.fixedHeight||t)}set height(t){if(this.isFixedSizeSet){w.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置高度");return}this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(this.destroyed||!this.scale||!this.isFixedSizeSet||!this.texture||this.texture.width===0||this.texture.height===0)return;const t=this.appService,i=this.fixedWidth/this.texture.width,s=this.fixedHeight/this.texture.height;if(this.sizeFixed){const n=t.currentScale;if(n===0)return;const o=i/n,a=s/n;this.scale&&super.scale.set(o,a)}else this.scale&&super.scale.set(i/this.baselineScale,s/this.baselineScale)}updateScale(t){this.destroyed||!this.scale||this.sizeFixed&&(this.isFixedSizeSet?this.applySize():t!==0&&super.scale.set(1/t))}async loadTextureAndSetSize(t,i){try{const s=this.appService,n=await N.load(t);if(this.destroyed||(this.texture=n,this.destroyed)||(i.sizeFixed!==void 0&&this.setSizeFixed(i.sizeFixed),this.setFixedSize(i.width,i.height),this.destroyed))return;s.getApp().renderOnceNextFrame()}catch(s){w.error(`Failed to load texture "${t}":`,s)}}draw(t,i){const{x:s,y:n,rotation:o=0}=t;i&&!this.visible?this.visible=i():!i&&!this.visible&&(this.visible=!0),this.rotation=o,this.position.set(s,n)}set texture(t){super.texture=t,this.isFixedSizeSet&&t&&t.width>0&&t.height>0&&this.applySize()}get texture(){return super.texture}destroy(t){this.appService.emitter.off("antiScale",this.throttledUpdateScale),this.throttledUpdateScale.cancel(),super.destroy(t)}}class Yx extends Xt{constructor(e){super(e),this.appService=e,this.initializeSprite()}async initializeSprite(){const e=this.appService;await this.loadTextureAndSetSize("chargingStation",e.chargingStationConfig.icon)}async draw({x:e,y:t,rotation:i}){const s=this.appService;super.draw({x:e,y:t,rotation:i},()=>s.runtimeSnapshot.showChargingStation)}}class gc extends H{constructor(t,i){super();g(this,"currentPosition",null);g(this,"config");g(this,"handleScaleChange",()=>{this.redraw()});this.appService=t,this.setupAntiScaleListener(),this.config=i.config}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.handleScaleChange)}draw(t){const i=this.appService;this.currentPosition=t;const{size:s,color:n,strokeWidth:o,strokeColor:a,strokeDashed:h,strokeDashArray:l}=this.config;this.clear();const c=i.metersToPixels(s),d=i.getApp().toFixedSize(o);this.setFillStyle({color:n}),h&&l.length>=2?this.drawDashedCircle(t,c,a,d,l):this.circle(t.x,t.y,c).fill().stroke({color:a,width:d,cap:"round",join:"round"})}drawDashedCircle(t,i,s,n,o){const a=this.appService;this.circle(t.x,t.y,i).fill();const h=a.getApp().toFixedSize(o[0]),l=a.getApp().toFixedSize(o[1]),c=2*Math.PI*i,d=h+l,u=Math.floor(c/d);if(u===0){this.circle(t.x,t.y,i).stroke({color:s,width:n,cap:"round",join:"round"});return}const p=c/u,f=p*(h/d);for(let y=0;y<u;y++){const m=y*p/i,x=(y*p+f)/i,S=Math.max(4,Math.ceil(Math.abs(x-m)*i/2)),v=(x-m)/S;for(let b=0;b<=S;b++){const P=m+v*b,C=t.x+i*Math.cos(P),A=t.y+i*Math.sin(P);b===0?this.moveTo(C,A):this.lineTo(C,A)}}this.stroke({color:s,width:n,cap:"round",join:"round"})}redraw(){this.currentPosition&&this.draw(this.currentPosition)}destroy(){this.appService.emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class vt{constructor(e,t={}){g(this,"target");g(this,"isPointerDown",!1);g(this,"pointerDownPos",null);g(this,"clickThreshold");g(this,"stopPropagation");g(this,"clickCallback",null);this.target=e,this.clickThreshold=t.clickThreshold??10,this.stopPropagation=t.stopPropagation??!1,this.clickCallback=t.onClick||null,this.setup()}setup(){this.target.interactive=!0,this.target.eventMode="static",this.target.on("pointerdown",this.handlePointerDown.bind(this)),this.target.on("pointermove",this.handlePointerMove.bind(this)),this.target.on("pointerup",this.handlePointerUp.bind(this)),this.target.on("pointerupoutside",this.handlePointerUpOutside.bind(this))}handlePointerDown(e){this.stopPropagation&&e.stopPropagation(),this.isPointerDown=!0,this.pointerDownPos={x:e.globalX,y:e.globalY}}handlePointerMove(e){if(this.stopPropagation&&e.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const t=e.globalX-this.pointerDownPos.x,i=e.globalY-this.pointerDownPos.y;Math.sqrt(t*t+i*i)>this.clickThreshold&&(this.isPointerDown=!1,this.pointerDownPos=null)}}handlePointerUp(e){if(this.stopPropagation&&e.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const t=e.globalX-this.pointerDownPos.x,i=e.globalY-this.pointerDownPos.y;Math.sqrt(t*t+i*i)<=this.clickThreshold&&this.clickCallback&&this.clickCallback(e,this.target)}this.isPointerDown=!1,this.pointerDownPos=null}handlePointerUpOutside(){this.isPointerDown=!1,this.pointerDownPos=null}setClickCallback(e){return this.clickCallback=e,this}setClickThreshold(e){return this.clickThreshold=e,this}getTarget(){return this.target}isInteracting(){return this.isPointerDown}destroy(){this.target.off("pointerdown",this.handlePointerDown),this.target.off("pointermove",this.handlePointerMove),this.target.off("pointerup",this.handlePointerUp),this.target.off("pointerupoutside",this.handlePointerUpOutside),this.clickCallback=null}}class Xx extends L{constructor(t){super();g(this,"chargingStation");g(this,"ring");g(this,"unsubscribeFns",[]);g(this,"clickHandler");this.appService=t,t.appContainer.addToLayer(pc,this),this.ring=new gc(this.appService,{config:this.appService.chargingStationConfig.ring}),this.ring.visible=this.appService.runtimeSnapshot.showChargingStationRing,this.addChild(this.ring),this.chargingStation=new Yx(this.appService),this.addChild(this.chargingStation);const i=G(this.appService.runtime,"showChargingStationRing",s=>{w.log(`[runtime] showChargingStationRing: ${s}`),this.ring.visible=s});this.unsubscribeFns.push(i),this.initClickInteraction()}async draw({x:t,y:i,rotation:s}){if(t===0&&i===0){this.visible=!1;return}this.visible=!0,this.ring.draw({x:t,y:i}),await this.chargingStation.draw({x:t,y:i,rotation:s})}initClickInteraction(){const{enableChargingStationClick:t}=this.appService.interactionConfig;t&&(this.clickHandler||(this.clickHandler=new vt(this.chargingStation,{onClick:()=>{var i;if((i=this.appService.events)!=null&&i.onClickChargingStation){const s=this.appService.getChargerPosition()??{x:0,y:0};this.appService.events.onClickChargingStation({rotation:this.chargingStation.rotation,...s})}}})))}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.ring.destroy(),this.clickHandler&&this.clickHandler.destroy(),super.destroy()}}class Zx extends L{constructor(t){super({isRenderGroup:!0});g(this,"carpetSprite",null);g(this,"carpetMask",null);this.appService=t,this.appService.appContainer.addToLayer(hc,this)}async createCarpetFromRasterData(t,i){const s=this.appService;if(!s.runtimeSnapshot.showCarpet||(this.clearCarpet(),t.length===0))return;const{src:n,opacity:o,scale:a}=s.carpetConfig,h=await N.load(n);if(!h){w.warn(`Carpet texture not found: ${n}`);return}const l=this.createCarpetGraphics(t,i),c=l.getLocalBounds();if(c.width===0||c.height===0)return;const d=new bs({texture:h,width:c.width,height:c.height});d.x=c.x,d.y=c.y,d.alpha=o,d.tileScale.set(a);const u=new L;u.addChild(l),d.mask=u,this.addChild(d),this.carpetSprite=d,this.carpetMask=u,s.getApp().renderOnceNextFrame()}createCarpetGraphics(t,i){const s=new H;for(let n=0;n<t.length;n++){const o=t[n],a=o%i,h=Math.floor(o/i);s.rect(a,h,1,1)}return s.fill(16777215),s}clearCarpet(){this.carpetSprite&&(this.removeChild(this.carpetSprite),this.carpetSprite.destroy(),this.carpetSprite=null),this.carpetMask&&(this.carpetMask.destroy({children:!0}),this.carpetMask=null)}async createCarpetFromStructuredData(t){const i=this.appService;if(!i.runtimeSnapshot.showCarpet||!t||(this.clearCarpet(),t.length===0))return;const{src:s,opacity:n,scale:o}=i.carpetConfig,a=await N.load(s);if(!a){w.warn(`Carpet texture not found: ${s}`);return}const h=this.createCarpetGraphicsFromStructuredData(t),l=h.getLocalBounds();if(l.width===0||l.height===0)return;const c=new bs({texture:a,width:l.width,height:l.height});c.x=l.x,c.y=l.y,c.alpha=n,c.tileScale.set(o);const d=new L;d.addChild(h),c.mask=d,this.addChild(c),this.carpetSprite=c,this.carpetMask=d,i.getApp().renderOnceNextFrame()}createCarpetGraphicsFromStructuredData(t){const i=new H;for(const s of t){const n=s.coordinates;for(let o=0;o<n.length;o+=2){const a=n[o],h=n[o+1];i.rect(a,h,1,1)}}return i.fill(16777215),i}destroy(){this.clearCarpet(),super.destroy()}}class Ya extends H{constructor(e){super(),this.appService=e,this.appService.appContainer.addToLayer(ac,this)}draw(e){const t=this.appService;this.clear(),this.setFillStyle({color:t.mapConfig.freeColor});for(const i of e){const s=i.coordinates;for(let n=0;n<s.length;n+=2){const o=s[n],a=s[n+1];this.rect(o,a,1,1)}}this.fill()}destroy(e){super.destroy(e)}}class Xa extends H{constructor(e){super(),this.appService=e,this.appService.appContainer.addToLayer(lc,this)}draw(e){const t=this.appService;this.clear(),this.setFillStyle({color:t.mapConfig.obstacleColor});for(const i of e){const s=i.coordinates;for(let n=0;n<s.length;n+=2){const o=s[n],a=s[n+1];this.rect(o,a,1,1)}}this.fill()}drawRaster(e,t){const i=this.appService;if(this.clear(),e.length!==0){this.setFillStyle({color:i.mapConfig.obstacleColor});for(let s=0;s<e.length;s+=ne){const n=Math.min(s+ne,e.length);for(let o=s;o<n;o++){const a=e[o],h=a%t,l=Math.floor(a/t);this.rect(h,l,1,1)}this.fill(),n<e.length&&this.setFillStyle({color:i.mapConfig.obstacleColor})}}}destroy(e){super.destroy(e)}}class Za extends L{constructor(t){super({isRenderGroup:!0});g(this,"roomGraphicsMap",new Map);g(this,"roomContextMap",new Map);g(this,"roomClickHandlerMap",new Map);g(this,"unsubscribeFns",[]);g(this,"mapWidth",0);g(this,"rasterRoomDataMap",new Map);g(this,"structuredRoomGeometry",new Map);this.appService=t,this.appService.appContainer.addToLayer(oc,this);const i=Fs(this.appService.config.room.colors,()=>{this.refreshRoomColors()});this.unsubscribeFns.push(i)}draw(t){const i=this.appService;this.clearRooms();const s=i.roomConfig,{selectRoomIds:n,enableRoomSelection:o}=i.runtimeSnapshot;t.forEach(a=>{const h=a.id>=255,l=new H,c=new mt,d=new mt,u=new mt;if(h)c.setFillStyle({color:a.color}),d.setFillStyle({color:a.color}),u.setFillStyle({color:a.color});else{const p=a.colorIndex??0,f=s.colors.active[p%s.colors.active.length],y=s.colors.inactive[p%s.colors.inactive.length],m=(s.colors.normal||s.colors.active)[p%(s.colors.normal||s.colors.active).length];c.setFillStyle({color:f}),d.setFillStyle({color:y}),u.setFillStyle({color:m})}if(c.poly(a.polyPoints).fill(),d.poly(a.polyPoints).fill(),u.poly(a.polyPoints).fill(),a.outlinePoints.forEach(p=>{c.rect(p.x,p.y,1,1).fill(),d.rect(p.x,p.y,1,1).fill(),u.rect(p.x,p.y,1,1).fill()}),h?l.context=c:l.context=o?n.includes(a.id)?c:d:u,!h){const p=new vt(l,{clickThreshold:10,onClick:()=>{this.handleRoomClick(a.id)}});this.roomClickHandlerMap.set(a.id,p),this.structuredRoomGeometry.set(a.id,{polyPoints:a.polyPoints,outlinePoints:a.outlinePoints,colorIndex:a.colorIndex??0})}this.roomGraphicsMap.set(a.id,l),this.roomContextMap.set(a.id,{activeContext:c,inactiveContext:d,normalContext:u}),this.addChild(l)})}drawRaster(t){const i=this.appService;if(this.clearRooms(),this.mapWidth=t.width,t.sortedRooms.length===0)return;const{selectRoomIds:s,enableRoomSelection:n}=i.runtimeSnapshot;t.sortedRooms.forEach(o=>{this.drawRasterRoom(o,n,s)})}drawRasterRoom(t,i,s){const{roomId:n,pixelIndices:o,activeColor:a,inactiveColor:h}=t,c=this.appService.roomConfig;let d=a;const u=typeof n=="number";if(u){const S=t.colorIndex??0;d=(c.colors.normal||c.colors.active)[S%(c.colors.normal||c.colors.active).length]}const p=new H,f=new mt,y=new mt,m=new mt;f.setFillStyle({color:a}),y.setFillStyle({color:h}),m.setFillStyle({color:d}),this.drawPixelPointsInBatches(f,o,ne,this.mapWidth),this.drawPixelPointsInBatches(y,o,ne,this.mapWidth),this.drawPixelPointsInBatches(m,o,ne,this.mapWidth);const x=u&&s.includes(n);if(p.context=i?u&&x?f:y:m,u){const S=new vt(p,{clickThreshold:10,onClick:()=>{this.handleRoomClick(n)}});this.roomClickHandlerMap.set(n,S)}this.roomGraphicsMap.set(n,p),this.roomContextMap.set(n,{activeContext:f,inactiveContext:y,normalContext:m}),this.rasterRoomDataMap.set(n,t),this.addChild(p)}drawPixelPointsInBatches(t,i,s,n){for(let o=0;o<i.length;o+=s){const a=Math.min(o+s,i.length);for(let h=o;h<a;h++){const l=i[h],c=l%n,d=Math.floor(l/n);t.rect(c,d,1,1)}t.fill()}}handleRoomClick(t){var s,n;const i=this.appService;(n=(s=i.events)==null?void 0:s.onClickRoom)==null||n.call(s,i.getRoomData(t)??{id:t})}setRoomStateBySelectIds(t){const i=this.appService,{enableRoomSelection:s}=i.runtimeSnapshot;this.roomGraphicsMap.forEach((n,o)=>{if(typeof o=="number"){const a=this.roomContextMap.get(o);if(a)if(s){const h=t.includes(o);n.context=h?a.activeContext:a.inactiveContext}else n.context=a.normalContext}})}setRoomState(t,i){const s=this.roomGraphicsMap.get(t),n=this.roomContextMap.get(t);if(!s||!n){w.warn(`Room ${t} not found`);return}typeof t=="number"&&(s.context=i?n.activeContext:n.inactiveContext)}setAllRoomsState(t){this.roomGraphicsMap.forEach((i,s)=>{typeof s=="number"&&this.setRoomState(s,t)})}getRoomGraphicsMap(){const t=new Map;return this.roomGraphicsMap.forEach((i,s)=>{typeof s=="number"&&t.set(s,i)}),t}getRasterRoomData(t){return this.rasterRoomDataMap.get(t)||null}getMapWidth(){return this.mapWidth}isWallIntersectsAnyRoom(t){const s=this.appService.getApp().mapState;if(!s)return w.warn("[RoomFill] Map state not available"),!1;if(!t||t.length!==2)return w.warn("[RoomFill] Invalid wall points provided"),!1;const[n,o]=t,a={x:n.x+s.origin.x,y:n.y+s.origin.y},h={x:o.x+s.origin.x,y:o.y+s.origin.y};return s.mapType==="raster"?this.isWallIntersectsAnyRoomRaster(a,h):this.isWallIntersectsAnyRoomStructured(a,h)}isZoneIntersectsAnyRoom(t){const s=this.appService.getApp().mapState;if(!s)return w.warn("[RoomFill] Map state not available"),!1;if(!t||t.length!==4)return w.warn("[RoomFill] Invalid zone points provided"),!1;const n=t.map(o=>({x:o.x+s.origin.x,y:o.y+s.origin.y}));return s.mapType==="raster"?this.isZoneIntersectsAnyRoomRaster(n):this.isZoneIntersectsAnyRoomStructured(n)}isWallIntersectsAnyRoomRaster(t,i){if(this.mapWidth===0||this.rasterRoomDataMap.size===0)return!1;const s=this.getLinePixels(t,i);for(const n of this.rasterRoomDataMap.values())for(const o of s)if($l(n.pixelIndices,o))return!0;return!1}isWallIntersectsAnyRoomStructured(t,i){const n=this.appService.mapManager.getAllRooms();for(const o of n)if(!(!o.outlinePoints||o.outlinePoints.length<3)){if(Et(t,o.outlinePoints,!0)||Et(i,o.outlinePoints,!0))return!0;for(let a=0;a<o.outlinePoints.length;a++){const h=o.outlinePoints[a],l=o.outlinePoints[(a+1)%o.outlinePoints.length];if(Ui(t,i,h,l))return!0}}return!1}isZoneIntersectsAnyRoomRaster(t){if(this.mapWidth===0||this.rasterRoomDataMap.size===0)return!1;const i=[[t[0],t[1]],[t[1],t[2]],[t[2],t[3]],[t[3],t[0]]];for(const[n,o]of i)if(this.isWallIntersectsAnyRoomRaster(n,o))return!0;const s=this.rasterRoomDataMap.values().next().value;if(s&&s.pixelIndices.length>0){const n=s.pixelIndices[0],o=n%this.mapWidth,a=Math.floor(n/this.mapWidth);if(Et({x:o,y:a},t,!0))return!0}return!1}isZoneIntersectsAnyRoomStructured(t){const s=this.appService.mapManager.getAllRooms(),n=[[t[0],t[1]],[t[1],t[2]],[t[2],t[3]],[t[3],t[0]]];for(const o of s)if(!(!o.outlinePoints||o.outlinePoints.length<3)){for(const a of t)if(Et(a,o.outlinePoints,!0))return!0;for(const a of o.outlinePoints)if(Et(a,t,!0))return!0;for(const[a,h]of n)for(let l=0;l<o.outlinePoints.length;l++){const c=o.outlinePoints[l],d=o.outlinePoints[(l+1)%o.outlinePoints.length];if(Ui(a,h,c,d))return!0}}return!1}getLinePixels(t,i){const n=this.appService.getApp().mapState;if(!n)return[];const o=n.height,a=[],h=Math.round(t.x),l=Math.round(t.y),c=Math.round(i.x),d=Math.round(i.y),u=Math.abs(c-h),p=Math.abs(d-l),f=h<c?1:-1,y=l<d?1:-1;let m=u-p,x=h,S=l;for(;;){if(x>=0&&x<this.mapWidth&&S>=0&&S<o){const b=S*this.mapWidth+x;a.push(b)}if(x===c&&S===d)break;const v=2*m;v>-p&&(m-=p,x+=f),v<u&&(m+=u,S+=y)}return a}getZonePixels(t,i,s,n){const a=this.appService.getApp().mapState;if(!a)return[];const h=a.height,l=[],c=Math.max(0,Math.floor(t)),d=Math.min(this.mapWidth-1,Math.ceil(s)),u=Math.max(0,Math.floor(i)),p=Math.min(h-1,Math.ceil(n));for(let f=u;f<=p;f++)for(let y=c;y<=d;y++){const m=f*this.mapWidth+y;l.push(m)}return l}refreshRoomColors(){const{selectRoomIds:t,enableRoomSelection:i}=this.appService.runtimeSnapshot,s=this.appService.roomConfig;this.roomGraphicsMap.forEach((n,o)=>{if(typeof o!="number")return;const a=this.roomContextMap.get(o),h=this.structuredRoomGeometry.get(o);if(a&&h){const l=h.colorIndex,c=s.colors.active[l%s.colors.active.length],d=s.colors.inactive[l%s.colors.inactive.length],u=(s.colors.normal||s.colors.active)[l%(s.colors.normal||s.colors.active).length];a.activeContext.clear(),a.activeContext.setFillStyle({color:c}),a.activeContext.poly(h.polyPoints).fill(),h.outlinePoints.forEach(p=>{a.activeContext.rect(p.x,p.y,1,1).fill()}),a.inactiveContext.clear(),a.inactiveContext.setFillStyle({color:d}),a.inactiveContext.poly(h.polyPoints).fill(),h.outlinePoints.forEach(p=>{a.inactiveContext.rect(p.x,p.y,1,1).fill()}),a.normalContext.clear(),a.normalContext.setFillStyle({color:u}),a.normalContext.poly(h.polyPoints).fill(),h.outlinePoints.forEach(p=>{a.normalContext.rect(p.x,p.y,1,1).fill()}),n.context=i?t.includes(o)?a.activeContext:a.inactiveContext:a.normalContext}else if(a){const l=this.rasterRoomDataMap.get(o);if(l){const c=l.colorIndex??0,d=s.colors.active[c%s.colors.active.length],u=s.colors.inactive[c%s.colors.inactive.length],p=(s.colors.normal||s.colors.active)[c%(s.colors.normal||s.colors.active).length];a.activeContext.clear(),a.activeContext.setFillStyle({color:d}),this.drawPixelPointsInBatches(a.activeContext,l.pixelIndices,ne,this.mapWidth),a.inactiveContext.clear(),a.inactiveContext.setFillStyle({color:u}),this.drawPixelPointsInBatches(a.inactiveContext,l.pixelIndices,ne,this.mapWidth),a.normalContext.clear(),a.normalContext.setFillStyle({color:p}),this.drawPixelPointsInBatches(a.normalContext,l.pixelIndices,ne,this.mapWidth),n.context=i?t.includes(o)?a.activeContext:a.inactiveContext:a.normalContext}}}),this.appService.getApp().renderOnceNextFrame()}clearRooms(){this.children.length===0&&this.roomGraphicsMap.size===0||(this.roomGraphicsMap.forEach(t=>{try{t.destroy()}catch(i){w.warn("Error destroying room graphics:",i)}}),this.roomGraphicsMap.clear(),this.roomContextMap.forEach(t=>{try{t.activeContext.destroy(),t.inactiveContext.destroy(),t.normalContext.destroy()}catch(i){w.warn("Error destroying graphics context:",i)}}),this.roomContextMap.clear(),this.roomClickHandlerMap.forEach(t=>{try{t.destroy()}catch(i){w.warn("Error destroying click handler:",i)}}),this.roomClickHandlerMap.clear(),this.removeChildren(),this.rasterRoomDataMap.clear(),this.structuredRoomGeometry.clear())}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.clearRooms(),super.destroy()}}class qx{constructor(e){g(this,"obstacle");g(this,"free");g(this,"roomFill");g(this,"carpet");g(this,"chargingStation");g(this,"mapBounds",{minX:0,minY:0,maxX:0,maxY:0});g(this,"lastMapId",null);g(this,"lastOrigin",null);g(this,"lastSize",null);g(this,"lastStatus",null);g(this,"roomGeometryMap",new Map);g(this,"rasterRoomPixelsMap",new Map);g(this,"fourColorCache",null);g(this,"carpetData",null);g(this,"unsubscribeFns",[]);this.appService=e,this.obstacle=new Xa(this.appService),this.free=new Ya(this.appService),this.roomFill=new Za(this.appService),this.carpet=new Zx(this.appService),this.chargingStation=new Xx(this.appService),this.validateColorConfig();const t=G(e.runtime,"enableRoomSelection",o=>{if(w.log(`[runtime] enableRoomSelection: ${o}`),o){this.roomFill.setAllRoomsState(!1);const a=this.appService.runtimeSnapshot.selectRoomIds;this.roomFill.setRoomStateBySelectIds(a)}else this.roomFill.setAllRoomsState(!0)}),i=G(e.runtime,"selectRoomIds",o=>{w.log(`[runtime] selectRoomIds: ${o}`),this.roomFill.setRoomStateBySelectIds(o)}),s=G(e.runtime,"showChargingStation",o=>{w.log(`[runtime] showChargingStation: ${o}`),this.chargingStation.visible=o}),n=G(e.runtime,"showCarpet",o=>{w.log(`[runtime] showCarpet: ${o}`),o?e.getApp().managers.customCarpetManager.getCustomCarpets().length===0&&this.createCarpet():this.carpet.clearCarpet()});this.unsubscribeFns.push(t,i,s,n)}async drawMap(e){const t=this.appService,{id:i,obstacles:s,free:n,rooms:o,charger:a,carpet:h,status:l,origin:c,size:d}=e;this.clearComponents(),this.resetGeometryData();const u=this.processRoomsGeometry(o);this.roomFill.draw(u),n&&this.free.draw(n),s&&this.obstacle.draw(s),this.carpetData=h,this.createCarpet();const p=this.mergeLayerBounds();Qr(p,this.mapBounds)||(w.debug("[Map] Map bounds updated:",p),this.mapBounds=p,this.shouldFitMapToView(i,l===1,{x:c[0],y:c[1]},{x:d[0],y:d[1]})&&(t.getApp().fitMapToView(this.mapBounds),this.lastMapId=i,this.lastOrigin={x:c[0],y:c[1]},this.lastSize={x:d[0],y:d[1]},this.lastStatus=l===1));const f=((e.charger.angle??0)+t.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:a.coordinate[0],y:a.coordinate[1],rotation:f}),await t.roomsManager.refresh(),!0}async drawRasterMap(e,t){const i=this.appService;this.clearComponents();const{id:s,width:n,height:o,charger:a,chargerDirection:h,status:l,origin:c}=t;w.debug("[Map] Parsed Raster Map Data",e),this.obstacle.drawRaster(e.obstacles,n),this.carpetData=this.convertRasterToStructuredData(e.carpet,n),i.getApp().managers.customCarpetManager.getCustomCarpets().length===0&&this.createCarpet();const u=this.processRasterData(e);this.roomFill.drawRaster(u);const p=by(e,n,o);Qr(p,this.mapBounds)||(w.debug("[Map] Raster map bounds updated:",p),this.mapBounds=p,this.shouldFitMapToView(s,l,c,{x:n,y:o})&&(i.getApp().fitMapToView(this.mapBounds),this.lastMapId=s,this.lastOrigin={...c},this.lastSize={x:n,y:o},this.lastStatus=l));const f=(h+i.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:a.x,y:a.y,rotation:f}),this.generateRoomGeometryFromRaster(e),await i.roomsManager.refresh(),!0}resetGeometryData(){this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear(),this.fourColorCache=null,this.mapBounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}shouldFitMapToView(e,t,i,s){const n=this.appService,{originChangeAutoFitThreshold:o,sizeChangeAutoFitThreshold:a}=n.getApp().config.map;if(this.lastMapId!==e)return w.debug("[Map] Map ID changed, triggering fitMapToView"),!0;if(this.lastStatus!==null&&this.lastStatus!==t)return w.debug(`[Map] Map status changed (${this.lastStatus} -> ${t}), triggering fitMapToView`),!0;if(this.lastOrigin&&i){const h=Math.abs(i.x-this.lastOrigin.x),l=Math.abs(i.y-this.lastOrigin.y);if(h>o||l>o)return w.debug(`[Map] Origin change exceeded threshold (deltaX: ${h}, deltaY: ${l}, threshold: ${o}), triggering fitMapToView`),!0}if(this.lastSize&&s){const h=Math.abs(s.x-this.lastSize.x),l=Math.abs(s.y-this.lastSize.y);if(h>a||l>a)return w.debug(`[Map] Size change exceeded threshold (deltaX: ${h}, deltaY: ${l}, threshold: ${a}), triggering fitMapToView`),!0}return!1}convertRasterToStructuredData(e,t){if(e.length===0)return[];const i=[];for(let s=0;s<e.length;s++){const n=e[s],o=n%t,a=Math.floor(n/t);i.push(o,a)}return[{coordinates:i}]}async createCarpet(){!this.appService.runtimeSnapshot.showCarpet||!this.carpetData||await this.carpet.createCarpetFromStructuredData(this.carpetData)}processRoomsGeometry(e){if(!e)return[];const t=this.appService,{active:i}=t.roomConfig.colors,s=t.roomConfig.colors[re.UNKNOWN_ROOM];if(Object.keys(e).length===0)return this.mapBounds={minX:0,minY:0,maxX:0,maxY:0},[];const n=Object.keys(e).sort((u,p)=>Number(u)-Number(p)),o=n.filter(u=>Number(u)<255),a=n.filter(u=>Number(u)>=255),h=[],l=[];o.forEach(u=>{const{coordinates:p}=e[u];if(p.length<4)return;const f=p.filter(_=>!isFinite(_));if(f.length>0){w.error(`[Room ${u}] Contains ${f.length} invalid coordinates (NaN/Infinity)`);return}const y=Number(u);let m=1/0,x=1/0,S=-1/0,v=-1/0;const b=[];for(let _=0;_<p.length;_+=2){const E=p[_],B=p[_+1];m=Math.min(m,E),x=Math.min(x,B),S=Math.max(S,E),v=Math.max(v,B),b.push({x:E,y:B})}const P=S-m,C=v-x;if(P===0||C===0){w.error(`[Room ${u}] Degenerate polygon (${P}x${C}). Skipping.`);return}if(P<2||C<2){w.warn(`[Room ${u}] Room too small (${P}x${C}), skipping`);return}const A=new et(m,x,S-m+1,v-x+1),k=Ba(b),M=k.flatMap(_=>[_.x+.5,_.y+.5]),T=Da(k,m,x,S,v);l.push({id:y,points:b,outlinePoints:k,polyPoints:M,centerPoint:T,boundingBox:A}),this.mapBounds.minX=Math.min(this.mapBounds.minX,m),this.mapBounds.minY=Math.min(this.mapBounds.minY,x),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,S),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,v)});const c=[...l].sort((u,p)=>{if(t.roomConfig.colors.sortBy==="area"){const f=u.outlinePoints.length;return p.outlinePoints.length-f}else return u.id-p.id}),d=this.assignColorsUsingFourColorAlgorithm(c,i.length,"structured");return l.forEach(u=>{const p=d.get(u.id)||0,f=i[p],y={id:u.id,color:f,colorIndex:p,boundingBox:u.boundingBox,points:u.points,outlinePoints:u.outlinePoints,polyPoints:u.polyPoints,centerPoint:u.centerPoint};this.roomGeometryMap.set(u.id,y),h.push(y)}),a.forEach(u=>{const{coordinates:p}=e[u];if(p.length<4)return;const f=Number(u);let y=1/0,m=1/0,x=-1/0,S=-1/0;const v=[];for(let _=0;_<p.length;_+=2){const E=p[_],B=p[_+1];y=Math.min(y,E),m=Math.min(m,B),x=Math.max(x,E),S=Math.max(S,B),v.push({x:E,y:B})}const b=x-y,P=S-m;if(b===0||P===0){w.error(`[Unknown Room ${u}] Degenerate polygon (${b}x${P}). Skipping.`);return}if(b<2||P<2){w.warn(`[Unknown Room ${u}] Room too small (${b}x${P}), skipping`);return}const C=new et(y,m,x-y+1,S-m+1),A=Ba(v),k=A.flatMap(_=>[_.x+.5,_.y+.5]),M=Da(A,y,m,x,S),T={id:f,color:s,boundingBox:C,points:v,outlinePoints:A,polyPoints:k,centerPoint:M};h.push(T),this.mapBounds.minX=Math.min(this.mapBounds.minX,y),this.mapBounds.minY=Math.min(this.mapBounds.minY,m),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,x),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,S)}),h}mergeLayerBounds(){let e={...this.mapBounds};if(this.obstacle.bounds&&(e=Pn(e,this.obstacle.bounds)),this.free.bounds&&(e=Pn(e,this.free.bounds)),this.roomFill.children.length>0){const t=this.roomFill.getLocalBounds();t.width>0&&t.height>0&&(e=Pn(e,{minX:t.x,minY:t.y,maxX:t.x+t.width,maxY:t.y+t.height}))}return e}getRoomById(e){return this.roomGeometryMap.get(e)}getAllRooms(){return Array.from(this.roomGeometryMap.values())}isWallIntersectsAnyRoom(e){return this.roomFill.isWallIntersectsAnyRoom(e)}isZoneIntersectsAnyRoom(e){return this.roomFill.isZoneIntersectsAnyRoom(e)}areRoomsAdjacent(e){const t=this.appService,i=t.mapConfig.adjacencyThreshold;if(!e||e.length===0)return w.warn("[MapManager] No room IDs provided"),!1;if(e.length===1)return!0;const s=Array.from(new Set(e));if(s.length===1)return!0;const n=t.getApp().mapState;return((n==null?void 0:n.mapType)??"structured")==="raster"?this.areRasterRoomsAdjacentInternal(s,i):this.areStructuredRoomsAdjacentInternal(s,i)}areStructuredRoomsAdjacentInternal(e,t){const i=[];for(const n of e){const o=this.getRoomById(n);if(!o)return w.warn(`[MapManager] Room ${n} not found in map`),!1;if(!o.outlinePoints||o.outlinePoints.length===0)return w.warn(`[MapManager] Room ${n} has no outline points`),!1;i.push({id:n,points:o.outlinePoints})}const s=[];for(let n=0;n<i.length;n++)for(let o=n+1;o<i.length;o++){const a=i[n],h=i[o];La(a.points,h.points,t)&&s.push([n,o])}return Wa(i.length,s)}areRasterRoomsAdjacentInternal(e,t){const s=this.appService.getApp().mapState;if(!s)return w.warn("[MapManager] Map state not available"),!1;const n=s.width,o=[];for(const h of e){const l=this.getRasterRoomPixels(h);if(!l)return w.warn(`[MapManager] Room ${h} pixel data not found in raster map`),!1;o.push({id:h,pixels:l})}const a=[];for(let h=0;h<o.length;h++)for(let l=h+1;l<o.length;l++){const c=o[h],d=o[l];Oa(c.pixels,d.pixels,n,t)&&a.push([h,l])}return Wa(o.length,a)}isPointInAnyRoom(e){const i=this.appService.getApp().mapState;return i?(i.mapType??"structured")==="raster"?this.isPointInAnyRoomRasterInternal(e,i):this.isPointInAnyRoomStructuredInternal(e,i):(w.warn("[MapManager] Map state not available"),null)}isPointInAnyRoomStructuredInternal(e,t){const i=e.x+t.origin.x,s=e.y+t.origin.y,n={x:i,y:s},o=this.getAllRooms();for(const a of o)if(a.outlinePoints&&a.outlinePoints.length>=3&&Et(n,a.outlinePoints)){const l=this.appService.roomsManager.getRoomPropertyById(a.id);return l||(w.warn(`[MapManager] Room ${a.id} found in geometry but not in RoomManager`),null)}return null}isPointInAnyRoomRasterInternal(e,t){const i=t.width,s=t.height,n=e.x+t.origin.x,o=e.y+t.origin.y,a=Math.round(n),h=Math.round(o);if(a<0||a>=i||h<0||h>=s)return w.warn(`[MapManager] Point (${a}, ${h}) is out of map bounds (${i}x${s})`),null;const l=h*i+a,c=this.getAllRooms();for(const d of c){const u=this.getRasterRoomPixels(d.id);if(u&&u.length>0&&$l(u,l)){const f=this.appService.roomsManager.getRoomPropertyById(d.id);return f||(w.warn(`[MapManager] Room ${d.id} found in geometry but not in RoomManager`),null)}}return null}clearComponents(){this.obstacle.clear(),this.obstacle.destroy(),this.obstacle=new Xa(this.appService),this.free.clear(),this.free.destroy(),this.free=new Ya(this.appService),this.carpet.clearCarpet(),this.carpetData=null,this.roomFill.clearRooms(),this.roomFill.isRenderGroup&&(this.roomFill.isRenderGroup=!1),this.roomFill.removeChildren(),this.roomFill.destroy(),this.roomFill=new Za(this.appService)}processRasterData(e){const i=this.appService.roomConfig,s=[],n=[];e.rooms.forEach((d,u)=>{typeof u=="number"?s.push([u,d]):n.push([u,d])}),s.sort(([d],[u])=>d-u);const o=s.map(([d,u])=>({id:d,pixels:u})).sort((d,u)=>i.colors.sortBy==="area"?u.pixels.length-d.pixels.length:d.id-u.id),a=this.assignColorsUsingFourColorAlgorithm(o,i.colors.active.length,"raster"),h=s.map(([d,u])=>{const p=a.get(d)||0;return{roomId:d,pixelIndices:u,activeColor:i.colors.active[p],inactiveColor:i.colors.inactive[p%i.colors.inactive.length],colorIndex:p}}),l=n.map(([d,u])=>{let p=i.colors[d];return d===re.VERSION0_ROOM&&!p&&(p=i.colors[re.NO_ROOM_DATA]),{roomId:d,pixelIndices:u,activeColor:p,inactiveColor:p}}),c=[...h,...l];return{obstacles:e.obstacles,carpet:e.carpet,sortedRooms:c,width:e.width,height:e.height,totalPixels:e.totalPixels}}generateRoomGeometryFromRaster(e){const t=this.appService;this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear();const{active:i}=t.roomConfig.colors,s=[];e.rooms.forEach((h,l)=>{typeof l=="number"&&s.push(l)}),s.sort((h,l)=>h-l);const n=[];s.forEach(h=>{const l=e.rooms.get(h);this.rasterRoomPixelsMap.set(h,l);let c=1/0,d=1/0,u=-1/0,p=-1/0;for(let m=0;m<l.length;m++){const x=l[m],S=x%e.width,v=Math.floor(x/e.width);c=Math.min(c,S),d=Math.min(d,v),u=Math.max(u,S),p=Math.max(p,v)}const f=my(l,e.width,c,d,u,p),y=new et(c,d,u-c+1,p-d+1);n.push({id:h,pixelIndices:l,boundingBox:y,centerPoint:f})});const o=[...n].sort((h,l)=>t.roomConfig.colors.sortBy==="area"?l.pixelIndices.length-h.pixelIndices.length:h.id-l.id),a=this.assignColorsUsingFourColorAlgorithm(o,i.length,"raster");n.forEach(h=>{const l=a.get(h.id)||0,c=i[l],d={id:h.id,color:c,colorIndex:l,boundingBox:h.boundingBox,points:[],outlinePoints:[],polyPoints:[],centerPoint:h.centerPoint};this.roomGeometryMap.set(h.id,d)})}getRasterRoomPixels(e){return this.rasterRoomPixelsMap.get(e)}validateColorConfig(){const t=this.appService.roomConfig.colors,i=t.active.length,s=t.inactive.length,n=t.name.length,o=t.propertyTheme.length,a=t.selectionIndicatorBackground.length,h=t.selectionIndicatorIcon.length;i<4&&w.warn(`[FourColor] room.colors.active requires at least 4 colors for the four-color theorem, but got ${i}. Adjacent rooms may have the same color.`),s!==i&&w.warn(`[FourColor] room.colors.inactive length (${s}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),n!==i&&w.warn(`[FourColor] room.colors.name length (${n}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),o!==i&&w.warn(`[FourColor] room.colors.propertyTheme length (${o}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),a!==i&&w.warn(`[FourColor] room.colors.selectionIndicatorBackground length (${a}) does not match room.colors.active length (${i}). Using modulo for color assignment.`),h!==i&&w.warn(`[FourColor] room.colors.selectionIndicatorIcon length (${h}) does not match room.colors.active length (${i}). Using modulo for color assignment.`)}assignColorsUsingFourColorAlgorithm(e,t,i){var d;const s=this.appService,n=((d=s.mapState)==null?void 0:d.id)??null;if(this.fourColorCache&&this.fourColorCache.mapId===n&&this.fourColorCache.colorMap.size===e.length)return w.debug("[FourColor] Using cached color map"),this.fourColorCache.colorMap;const o=s.getApp().config.map.adjacencyThreshold||3,a=s.roomConfig.colors.strategy,l=Py(e,(u,p)=>{var f;if(i==="structured"){const y=u.outlinePoints,m=p.outlinePoints;return!y||!m?!1:La(y,m,o)}else{const y=u.pixels,m=p.pixels;if(!y||!m)return!1;const x=((f=s.mapState)==null?void 0:f.width)||0;return Oa(y,m,x,o)}},t,a);this.fourColorCache={mapId:n,colorMap:l};const c=new Array(t).fill(0);return l.forEach(u=>{c[u]++}),w.debug("[FourColor] Color distribution:",c),l}destroy(){this.obstacle.destroy(),this.free.destroy(),this.roomFill.destroy(),this.carpet.destroy(),this.chargingStation.destroy(),this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[],this.fourColorCache=null}}class Kx extends L{constructor(t){super({isRenderGroup:!0});g(this,"commonPath");g(this,"chargePath");g(this,"transitionsPath");g(this,"mopPath");g(this,"mopPathTrack");g(this,"mopPathTrackContainer");g(this,"debugPoints");g(this,"pathData",null);g(this,"lastPointCount",0);g(this,"lastDrawnPosition",null);g(this,"isRealTimeDrawing",!1);g(this,"throttledUpdateLineWidth");g(this,"throttledHandleRobotPosition");g(this,"unsubscribeFns",[]);g(this,"handleRobotAnimationComplete",()=>{this.isRealTimeDrawing&&this.stopRealTimeDrawing()});this.appService=t,this.appService.appContainer.addToLayer(dc,this),this.eventMode="none",this.commonPath=new H,this.chargePath=new H,this.transitionsPath=new H,this.mopPathTrackContainer=new L,this.mopPathTrackContainer.filters=[new Vg],this.mopPathTrack=new H,this.mopPath=new H,this.debugPoints=new H,this.mopPathTrackContainer.addChild(this.mopPathTrack),this.addChild(this.mopPathTrackContainer),this.addChild(this.commonPath),this.addChild(this.chargePath),this.addChild(this.transitionsPath),this.addChild(this.mopPath),this.addChild(this.debugPoints),this.visible=t.runtimeSnapshot.showPath,this.commonPath.visible=t.pathConfig.commonPath.visible,this.chargePath.visible=t.pathConfig.chargePath.visible,this.transitionsPath.visible=t.pathConfig.transitionPath.visible,this.mopPathTrackContainer.visible=t.pathConfig.mopPath.trackVisible,this.mopPath.visible=t.pathConfig.mopPath.lineVisible,this.throttledUpdateLineWidth=Ct(()=>{this.updateLineWidth()},50,{leading:!0,trailing:!0}),this.throttledHandleRobotPosition=Ct(this.handleRobotPositionUpdate.bind(this),0),this.registerEventListeners()}registerEventListeners(){const{emitter:t}=this.appService;t.on("antiScale",this.throttledUpdateLineWidth),t.on("robotPositionUpdate",this.throttledHandleRobotPosition),t.on("robotAnimationComplete",this.handleRobotAnimationComplete);const i=Fs(this.appService.config.path,()=>{this.pathData&&(this.redrawPaths(this.pathData),this.appService.getApp().renderOnceNextFrame())});this.unsubscribeFns.push(i)}handleRobotPositionUpdate(t){if(!this.isRealTimeDrawing||!this.lastDrawnPosition)return;const i=t.pathType||"common";let s=[];switch(i){case"common":s=[this.commonPath];break;case"charge":s=[this.chargePath];break;case"transitions":s=[this.transitionsPath];break;case"mop":s=[this.mopPathTrack,this.mopPath];break;default:s=[this.commonPath]}s.forEach(n=>{n.moveTo(this.lastDrawnPosition.x,this.lastDrawnPosition.y),n.lineTo(t.x,t.y),n.stroke()}),this.lastDrawnPosition={x:t.x,y:t.y}}updateLineWidth(){const t=this.appService;this.pathData&&t.pathConfig.lineWidthFixed&&this.redrawPaths(this.pathData)}redrawPaths(t){const{pathPoints:i}=t;if(this.commonPath.clear(),this.chargePath.clear(),this.transitionsPath.clear(),this.mopPathTrack.clear(),this.mopPath.clear(),this.debugPoints.clear(),!i||i.length===0)return;this.setupPathStyles(),this.drawPathSegments(i),this.commonPath.stroke(),this.chargePath.stroke(),this.transitionsPath.stroke(),this.mopPathTrack.stroke(),this.mopPath.stroke(),this.appService.getDebuggerMode()&&this.drawDebugPoints(i)}setupPathStyles(){var n;const t=this.appService,i=t.pathConfig,s=o=>i.lineWidthFixed?t.getApp().toFixedSize(o):o;this.commonPath.setStrokeStyle({width:s(i.commonPath.width),color:i.commonPath.color,join:"round",cap:"round"}),this.chargePath.setStrokeStyle({width:s(i.chargePath.width),color:i.chargePath.color,join:"round",cap:"round"}),this.transitionsPath.setStrokeStyle({width:s(i.transitionPath.width),color:i.transitionPath.color,join:"round",cap:"round"}),this.mopPathTrack.setStrokeStyle({width:s(i.mopPath.trackWidth),color:i.mopPath.trackColor,alpha:1,join:"round",cap:"round"}),(n=this.mopPathTrackContainer.filters)!=null&&n[0]&&(this.mopPathTrackContainer.filters[0].alpha=i.mopPath.trackAlpha),this.mopPathTrackContainer.visible=i.mopPath.trackVisible,this.mopPath.setStrokeStyle({width:s(i.mopPath.lineWidth),color:i.mopPath.lineColor,join:"round",cap:"round"}),this.mopPath.visible=i.mopPath.lineVisible}drawPathSegments(t){let i=null,s=null;for(let n=0;n<t.length;n++){const o=t[n],a=o.type||"common";let h;switch(a){case"common":h=[this.commonPath];break;case"charge":h=[this.chargePath];break;case"transitions":h=[this.transitionsPath];break;case"mop":h=[this.mopPathTrack,this.mopPath];break;default:h=[this.commonPath]}n===0||a!==i?h.forEach(c=>c.moveTo(o.x,o.y)):s&&h.length===s.length&&h.every((c,d)=>c===s[d])&&h.forEach(c=>c.lineTo(o.x,o.y)),i=a,s=h}}drawDebugPoints(t){const i={common:16711935,charge:65535,transitions:16776960,mop:65280},s=1;for(const n of t){const o=n.type||"common",a=i[o];this.debugPoints.rect(n.x-s/2,n.y-s/2,s,s),this.debugPoints.fill(a)}}updatePositionByOrigin(t,i){this.position.set(t,i)}drawFull(t){var i;w.debug("[Path] Draw Full Path",t),this.pathData=t,this.redrawPaths(t),this.lastPointCount=((i=t.pathPoints)==null?void 0:i.length)||0}drawIncremental(t){var o,a,h,l;const i=this.appService,s=this.lastPointCount,n=((o=t.pathPoints)==null?void 0:o.slice(s))||[];if(n.length>0)if(this.setupPathStyles(),w.debug("[Path] Draw Incremental Path",n),i.robotConfig.speed>0){if(this.isRealTimeDrawing=!0,s>0&&((a=this.pathData)!=null&&a.pathPoints)){const u=this.pathData.pathPoints[s-1];this.lastDrawnPosition={x:u.x,y:u.y}}}else this.drawNewPathSegments(n,s,t.pathPoints,(h=this.pathData)==null?void 0:h.pathPoints);this.pathData=t,this.lastPointCount=((l=t.pathPoints)==null?void 0:l.length)||0}drawNewPathSegments(t,i,s,n){if(!s||t.length===0)return;let o=null;i>0&&(n&&n[i-1]?o=n[i-1]:s[i-1]&&(o=s[i-1]));let a=null,h=null,l=!1;for(let c=0;c<t.length;c++){const d=t[c],u=d.type||"common";let p;switch(u){case"common":p=[this.commonPath];break;case"charge":p=[this.chargePath];break;case"transitions":p=[this.transitionsPath];break;case"mop":p=[this.mopPathTrack,this.mopPath];break;default:p=[this.commonPath]}u!==a||c===0?(h&&l&&h.forEach(y=>y.stroke()),a=u,h=p,l=!0,o&&c===0&&o.type===u?p.forEach(y=>{y.moveTo(o.x,o.y),y.lineTo(d.x,d.y)}):p.forEach(y=>y.moveTo(d.x,d.y))):p.forEach(y=>y.lineTo(d.x,d.y))}h&&l&&h.forEach(c=>c.stroke())}stopRealTimeDrawing(){this.isRealTimeDrawing=!1,this.lastDrawnPosition=null}clear(){this.commonPath.clear(),this.chargePath.clear(),this.transitionsPath.clear(),this.mopPathTrack.clear(),this.mopPath.clear(),this.debugPoints.clear(),this.pathData=null,this.lastPointCount=0,this.lastDrawnPosition=null,this.isRealTimeDrawing=!1}destroy(t){const{emitter:i}=this.appService;i.off("antiScale",this.throttledUpdateLineWidth),i.off("robotPositionUpdate",this.throttledHandleRobotPosition),i.off("robotAnimationComplete",this.handleRobotAnimationComplete),this.unsubscribeFns.forEach(s=>s()),this.unsubscribeFns=[],this.stopRealTimeDrawing(),super.destroy(t)}}class $x extends Xt{constructor(e){super(e),this.appService=e,this.initializeSprite()}async initializeSprite(){await this.loadTextureAndSetSize("robot",this.appService.robotConfig.icon)}async draw({x:e,y:t,rotation:i}){super.draw({x:e,y:t,rotation:i})}}const it=class it extends vs{constructor(t,i){super(i||[]);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"sizeFixed",!0);g(this,"baselineScale",1);this.appService=t,this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ct(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,i){this.fixedWidth=t,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,t&&this.isFixedSizeSet?this.applySize():!t&&this.isFixedSizeSet&&this.applySize()}set width(t){this.isFixedSizeSet||this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet||this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.textures||this.textures.length===0||!this.textures[0]||this.textures[0].width===0||this.textures[0].height===0)return;const t=this.textures[0],i=this.fixedWidth/t.width,s=this.fixedHeight/t.height;if(this.sizeFixed){const n=this.appService.currentScale;if(n===0||!isFinite(n)){const h=i,l=s;super.scale.set(h,l);return}const o=i/n,a=s/n;super.scale.set(o,a)}else super.scale.set(i/this.baselineScale,s/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():t!==0&&super.scale.set(1/t))}static async loadAnimationTextures(t,i,s="sleep_",n=96){try{const a=await(await fetch(t)).json();a.meta&&(a.meta.image=i),await N.load(i);const h=W.from(i),l=new On(h.source,a);await l.parse();const c=[];for(let d=0;d<n;d++){const u=d.toString().padStart(3,"0"),p=`${s}${u}.png`,f=l.textures[p];f?c.push(f):w.warn(`[EnhancedAnimatedSprite] Frame not found: ${p}`)}return c}catch(o){return w.error("[EnhancedAnimatedSprite] Failed to load textures:",o),[]}}setupAnimation(t){t.sizeFixed!==void 0&&this.setSizeFixed(t.sizeFixed),this.setFixedSize(t.width,t.height),this.animationSpeed=.5,this.loop=!0,w.log(`Animation setup complete, visible=${this.visible}, scale=(${this.scale.x.toFixed(3)}, ${this.scale.y.toFixed(3)})`)}draw(t,i){const{x:s,y:n}=t;i&&!this.visible?this.visible=i():!i&&!this.visible&&(this.visible=!0),this.position.set(s,n)}play(){this.textures&&this.textures.length>0&&(super.play(),it.animatedSprites.add(this),it.startAnimationTicker())}stop(){super.stop(),it.animatedSprites.delete(this),it.updateAnimationTicker()}set textures(t){super.textures=t,this.isFixedSizeSet&&t&&t.length>0&&t[0]&&t[0].width>0&&t[0].height>0&&this.applySize()}get textures(){return super.textures}static startAnimationTicker(){var t;(t=it.animationTicker)!=null&&t.started||(it.animationTicker||(it.animationTicker=new yt,it.animationTicker.maxFPS=24,it.animationTicker.add(()=>{const i=it.animatedSprites.values().next().value;i&&it.updateAnimations(i.appService)})),it.animationTicker.start(),w.log("🎬 [AnimationTicker] Started animation ticker"))}static updateAnimationTicker(){it.animatedSprites.size>0?it.startAnimationTicker():it.stopAnimationTicker()}static stopAnimationTicker(){var t;(t=it.animationTicker)!=null&&t.started&&(w.log("⏸️ [AnimationTicker] Stopped animation ticker"),it.animationTicker.stop())}static updateAnimations(t){if(it.animatedSprites.size===0)return;const i=t.getApp();i.renderer.render(i.stage)}destroy(t){it.animatedSprites.delete(this),it.updateAnimationTicker(),this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}};g(it,"animationTicker",null),g(it,"animatedSprites",new Set);let Ms=it;class Wr extends Ms{constructor(t,i){super(t,i);g(this,"unsubscribeFns",[]);g(this,"throttledUpdateOffset");g(this,"fixedOffsetX",0);g(this,"fixedOffsetY",0);this.appService=t,this.throttledUpdateOffset=Ct(this.updateOffset.bind(this),30,{leading:!0,trailing:!0}),this.initializeAnimation()}static async create(t){const i=t.robotConfig,s=await Ms.loadAnimationTextures(i.sleepAnimation.jsonSrc,i.sleepAnimation.imageSrc,i.sleepAnimation.framePrefix,i.sleepAnimation.frameCount);s.length===0&&(w.warn("No textures loaded for sleep animation"),s.push(W.EMPTY));const n=new Wr(t,s);return n.setupAnimation({width:i.sleepAnimation.width,height:i.sleepAnimation.height,sizeFixed:i.sleepAnimation.sizeFixed}),n}initializeAnimation(){this.visible=!1,this.fixedOffsetX=this.appService.robotConfig.sleepAnimation.offsetX,this.fixedOffsetY=this.appService.robotConfig.sleepAnimation.offsetY,this.appService.emitter.on("antiScale",this.throttledUpdateOffset);const t=G(this.appService.runtime,"showRobotSleepAnimation",i=>{w.log(`[runtime] showRobotSleepAnimation: ${i}`),this.updateVisibility()});this.unsubscribeFns.push(t)}shouldShow(){const t=this.appService.runtimeSnapshot.showRobotSleepAnimation,i=this.parent,s=i?i.visible:!1,n=i&&(i.x!==0||i.y!==0);return t&&s&&!!n}updateVisibility(){const t=this.shouldShow();t&&!this.visible?(this.visible=!0,this.textures&&this.textures.length>0&&this.play()):!t&&this.visible?(this.visible=!1,this.stop()):!t&&this.playing&&this.stop()}updateOffset(){}draw(t){const i=this.appService.getApp().toFixedSize(this.appService.robotConfig.sleepAnimation.offsetX),s=this.appService.getApp().toFixedSize(this.appService.robotConfig.sleepAnimation.offsetY),n={...t,x:t.x+i,y:t.y+s};super.draw(n,()=>this.shouldShow()),this.updateVisibility()}onRobotVisibilityChanged(){this.updateVisibility()}set visible(t){const i=super.visible;super.visible=t,t&&!i&&this.textures&&this.textures.length>0?this.play():!t&&i&&this.playing&&this.stop()}get visible(){return super.visible}destroy(t){this.appService.emitter.off("antiScale",this.throttledUpdateOffset),this.unsubscribeFns.forEach(i=>i()),this.unsubscribeFns=[],this.stop(),super.destroy(t)}}class Qx extends H{constructor(t){super();g(this,"currentPosition",null);g(this,"animationStartTime",0);g(this,"isAnimating",!1);g(this,"handleScaleChange",()=>{this.redraw()});g(this,"updateAnimation",()=>{if(!this.currentPosition||!this.isAnimating||!this.visible)return;const t=this.appService,i=t.robotConfig.pulseCircle,n=(Date.now()-this.animationStartTime)%i.duration/i.duration,{minScale:o,maxScale:a,minAlpha:h,maxAlpha:l}=i,c=o+(a-o)*(Math.sin(n*Math.PI*2)*.5+.5),d=l-(l-h)*(c-o)/(a-o);super.clear();const{size:u,color:p,strokeWidth:f,strokeColor:y,sizeFixed:m}=i,S=(m?t.getApp().toFixedSize(u/2):u/2)*c,v=t.getApp().toFixedSize(f);this.setFillStyle({color:p,alpha:d}),this.circle(this.currentPosition.x,this.currentPosition.y,S).fill().stroke({color:y,width:v,alpha:d,cap:"round",join:"round"})});this.appService=t,this.setupAntiScaleListener()}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.handleScaleChange)}draw(t){this.currentPosition=t,this.isAnimating||this.startAnimation(),this.redraw()}startAnimation(){const t=this.appService;this.isAnimating||(this.isAnimating=!0,this.animationStartTime=Date.now(),t.getApp().ticker.add(this.updateAnimation,this),t.getApp().requestRender("pulse-circle-animation",!0))}stopAnimation(){const t=this.appService;this.isAnimating&&(this.isAnimating=!1,t.getApp().ticker.remove(this.updateAnimation,this),t.getApp().stopRender("pulse-circle-animation"))}redraw(){this.currentPosition&&this.isAnimating&&this.updateAnimation()}clearCircle(){super.clear()}remove(){this.stopAnimation(),this.clearCircle(),this.currentPosition=null}destroy(){this.stopAnimation(),this.appService.emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class Jx extends L{constructor(t){super();g(this,"robot");g(this,"ring");g(this,"pulseCircle");g(this,"sleepAnimation",null);g(this,"unsubscribeFns",[]);g(this,"clickHandler");g(this,"targetPosition",null);g(this,"targetRotation",null);g(this,"isMoving",!1);g(this,"pathQueue",[]);g(this,"lastPosition",null);g(this,"currentPathType");g(this,"lastUpdateTime",0);g(this,"isCleared",!1);this.appService=t,t.appContainer.addToLayer(fc,this),this.visible=t.runtime.showRobot,this.ring=new gc(this.appService,{config:this.appService.robotConfig.ring}),this.ring.visible=this.appService.runtime.showRobotRing,this.addChild(this.ring),this.pulseCircle=new Qx(this.appService),this.pulseCircle.visible=t.runtime.showRobotPulseCircle,this.addChild(this.pulseCircle),this.robot=new $x(this.appService),this.addChild(this.robot),this.lastUpdateTime=Date.now(),this.appService.robotConfig.speed>0&&this.appService.getApp().ticker.add(this.update,this);const s=G(this.appService.runtime,"showRobotRing",o=>{w.log(`[runtime] showRobotRing: ${o}`),this.ring.visible=o});this.unsubscribeFns.push(s);const n=G(this.appService.runtime,"showRobotPulseCircle",o=>{w.log(`[runtime] showRobotPulseCircle: ${o}`),o?(this.lastPosition&&this.pulseCircle.draw(this.lastPosition),this.pulseCircle.visible=!0):(this.pulseCircle.remove(),this.pulseCircle.visible=!1)});this.unsubscribeFns.push(n),this.initClickInteraction()}async initializeSleepAnimation(){try{this.sleepAnimation=await Wr.create(this.appService),this.addChild(this.sleepAnimation),w.log("Sleep animation added to robot")}catch(t){w.error("Failed to initialize sleep animation:",t)}}updatePositionByOrigin(t,i){this.position.set(t,i)}async draw({x:t,y:i,rotation:s}){this.isCleared&&(this.robot.visible=!0,this.ring.visible=this.appService.runtime.showRobotRing,this.pulseCircle.visible=this.appService.runtime.showRobotPulseCircle,this.sleepAnimation&&(this.sleepAnimation.visible=!0),this.isCleared=!1),this.ring.draw({x:t,y:i}),this.pulseCircle.draw({x:t,y:i}),await this.robot.draw({x:t,y:i,rotation:s}),this.sleepAnimation||await this.initializeSleepAnimation(),this.sleepAnimation.draw({x:t,y:i}),this.lastPosition={x:t,y:i},this.sleepAnimation.draw({x:t,y:i}),this.lastPosition={x:t,y:i}}initClickInteraction(){const{enableRobotClick:t}=this.appService.interactionConfig;t?this.clickHandler||(this.clickHandler=new vt(this.robot,{onClick:()=>{var s;const i=this.getCurrentPosition();i&&((s=this.appService.events)!=null&&s.onClickRobot)&&this.appService.events.onClickRobot({...i,rotation:this.robot.rotation})}})):this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=void 0,this.robot.interactive=!1,this.robot.eventMode="none")}getCurrentPosition(){return this.lastPosition?this.appService.fixPrecision({...this.lastPosition}):null}moveTo(t){this.pathQueue.push(t),this.isMoving||this.processNextPathPoint()}batchProcessQueue(t=!1){if(this.pathQueue.length===0)return;const i=[...this.pathQueue];if(t){const s=i[i.length-1];this.robot.position.set(s.x,s.y),s.rotation!==void 0&&(this.robot.rotation=s.rotation),this.lastPosition={x:s.x,y:s.y},this.pathQueue=[],this.isMoving=!1,this.targetPosition=null}else this.pathQueue.splice(0,i.length),this.pathQueue.length===0?(this.isMoving=!1,this.targetPosition=null):this.processNextPathPoint()}processNextPathPoint(){if(this.pathQueue.length===0){this.isMoving=!1,this.currentPathType=void 0,this.stopRobotAnimation(),this.appService.emitter.emit("robotAnimationComplete");return}this.isMoving||this.startRobotAnimation(),this.isMoving=!0;const t=this.pathQueue[0];this.targetPosition={x:t.x,y:t.y},this.currentPathType=t.type,t.rotation!==void 0&&(this.targetRotation=t.rotation),this.lastPosition||(this.lastPosition={x:this.robot.x,y:this.robot.y})}update(){const t=Date.now();if(this.lastUpdateTime===0){this.lastUpdateTime=t;return}let i=t-this.lastUpdateTime;if(this.lastUpdateTime=t,i>500&&(i=16.67),this.targetPosition){const s=this.targetPosition.x-this.robot.x,n=this.targetPosition.y-this.robot.y,o=Math.sqrt(s*s+n*n),a=this.appService.robotConfig.speed,h=this.appService.getApp().metersToPixels(a);if(a===0){this.robot.position.set(this.targetPosition.x,this.targetPosition.y),this.targetRotation!==null&&(this.robot.rotation=this.targetRotation,this.targetRotation=null),this.targetPosition=null,this.lastPosition={x:this.robot.x,y:this.robot.y},this.pathQueue.shift(),this.processNextPathPoint();return}const l=h*(i/1e3);o<l?(this.robot.position.set(this.targetPosition.x,this.targetPosition.y),this.targetRotation!==null&&(this.robot.rotation=this.targetRotation,this.targetRotation=null),this.targetPosition=null,this.lastPosition={x:this.robot.x,y:this.robot.y},this.pathQueue.shift(),this.processNextPathPoint()):(this.robot.x+=s*(l/o),this.robot.y+=n*(l/o),this.appService.emitter.emit("robotPositionUpdate",{x:this.robot.x,y:this.robot.y,pathType:this.currentPathType}),this.lastPosition={x:this.robot.x,y:this.robot.y})}}startRobotAnimation(){this.appService.getApp().requestRender("robot-animation",!0)}set visible(t){super.visible=t,this.sleepAnimation&&this.sleepAnimation.onRobotVisibilityChanged()}get visible(){return super.visible}stopRobotAnimation(){this.appService.getApp().stopRender("robot-animation")}remove(){this.pathQueue=[],this.isMoving=!1,this.targetPosition=null,this.stopRobotAnimation()}clear(){this.remove(),this.robot.visible=!1,this.ring.visible=!1,this.pulseCircle.remove(),this.sleepAnimation&&(this.sleepAnimation.visible=!1),this.lastPosition=null,this.isCleared=!0}destroy(t){this.unsubscribeFns.forEach(s=>s()),this.unsubscribeFns=[],this.stopRobotAnimation(),this.appService.robotConfig.speed>0&&this.appService.getApp().ticker.remove(this.update,this),this.ring.destroy(),this.pulseCircle.destroy(),this.clickHandler&&this.clickHandler.destroy(),super.destroy(t)}}class tS{constructor(e){g(this,"path");g(this,"robot");g(this,"unsubscribeFns",[]);g(this,"lastDrawnPathData",null);this.appService=e,this.path=new Kx(this.appService),this.robot=new Jx(this.appService);const t=G(e.runtime,"showPath",s=>{w.log(`[runtime] showPath: ${s}`),this.path.visible=s}),i=G(e.runtime,"showRobot",s=>{w.log(`[runtime] showRobot: ${s}`),this.robot.visible=s});this.unsubscribeFns.push(t,i)}draw(e){var s,n,o;const t=(s=e.pathHeader)==null?void 0:s.pathId,i=(o=(n=this.lastDrawnPathData)==null?void 0:n.pathHeader)==null?void 0:o.pathId;this.lastDrawnPathData&&t!==i&&(this.path.clear(),this.lastDrawnPathData=null),this.shouldUseIncrementalDraw(e)?this.incrementalDraw(e):this.fullDraw(e),this.lastDrawnPathData=e}shouldUseIncrementalDraw(e){var h,l,c,d;if(!this.lastDrawnPathData)return!1;const t=(h=e.pathHeader)==null?void 0:h.pathId,i=(l=this.lastDrawnPathData.pathHeader)==null?void 0:l.pathId;if(t!==i)return!1;const s=((c=e.pathPoints)==null?void 0:c.length)||0,n=((d=this.lastDrawnPathData.pathPoints)==null?void 0:d.length)||0,o=s-n,a=this.appService.pathConfig.incrementalThreshold;return!(o<=0||o>a)}fullDraw(e){if(this.path.stopRealTimeDrawing(),this.path.drawFull(e),e.pathPoints&&e.pathPoints.length>0){const t=e.pathPoints[e.pathPoints.length-1];this.moveRobotToPoint(t,e.pathHeader.direction,!1)}else this.robot.clear()}convertToRobotPoint(e,t){const i=t+this.appService.robotConfig.rotationCorrection;return{x:e.x,y:e.y,rotation:i*Math.PI/180,type:e.type}}moveRobotToPoint(e,t,i=!0){const s=this.convertToRobotPoint(e,t);i?this.robot.moveTo(s):(this.robot.remove(),this.robot.draw(s))}incrementalDraw(e){var o;if(!this.lastDrawnPathData||!e.pathPoints)return;this.path.drawIncremental(e);const t=((o=this.lastDrawnPathData.pathPoints)==null?void 0:o.length)||0,i=e.pathPoints.slice(t);if(i.length===0)return;if(this.appService.robotConfig.speed>0)i.forEach(a=>{this.moveRobotToPoint(a,e.pathHeader.direction,!0)});else{const a=i[i.length-1];this.moveRobotToPoint(a,e.pathHeader.direction,!1)}}batchProcessRobotQueue(e=!1){this.robot.batchProcessQueue(e)}updatePositionByOrigin(e,t){this.path.updatePositionByOrigin(e,t),this.robot.updatePositionByOrigin(e,t)}clear(){this.lastDrawnPathData=null,this.path.clear(),this.robot.clear()}destroy(){this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[],this.path.destroy(),this.robot.destroy()}}class eS extends L{constructor(t){super();g(this,"colorGradients",[]);g(this,"cellSize",2);this.appService=t,this.appService.appContainer.addToLayer(cc,this);const i=this.appService.heatMapConfig;this.colorGradients=i.colorGradients.map(s=>new rt(s).toArray().slice(0,3).join(",")),this.cellSize=i.cellSize}draw(t,i=.8){this.removeChildren();const{useGradient:s}=this.appService.heatMapConfig,n=s?this.gradientDrawing(t):this.gridDrawing(t);this.croppingHeatmap(n),n.alpha=i,this.addChild(n)}croppingHeatmap(t){var a;const i=((a=this.appService.mapState)==null?void 0:a.origin)||{x:0,y:0},n=this.appService.mapManager.roomFill.children.filter(h=>h instanceof H),o=new H;for(const h of n)o.context.instructions.push(...h.context.instructions);o.context.dirty=!0,o.position.set(-i.x,-i.y),t.setMask({mask:o}),this.addChild(o)}gridDrawing(t){const i=[],s=[],n=t.length,o=t[0].length;for(let c=0;c<n;c++)for(let d=0;d<o;d++){const u=t[c][d],p=this.cellSize/2,f=u.x-p,y=u.y-p,m=u.x+p,x=u.y+p;i.push(f,y),s.push(u.signal),i.push(m,y),s.push(u.signal),i.push(m,x),s.push(u.signal),i.push(f,y),s.push(u.signal),i.push(m,x),s.push(u.signal),i.push(f,x),s.push(u.signal)}const a=new Wi({attributes:{aPosition:new Float32Array(i),aSignal:new Float32Array(s)}}),h=new Be({glProgram:new si({vertex:`
|
|
503
503
|
in vec2 aPosition;
|
|
504
504
|
in float aSignal;
|
|
505
505
|
uniform mat3 uProjectionMatrix;
|
|
@@ -598,7 +598,7 @@ fn mainFragment(
|
|
|
598
598
|
|
|
599
599
|
return vec4<f32>(color, 1.0);
|
|
600
600
|
}
|
|
601
|
-
`,entryPoint:"main"}})}),l=new
|
|
601
|
+
`,entryPoint:"main"}})}),l=new wa({geometry:a,shader:h});return l.alpha=.8,l}gradientDrawing(t){const i=[],s=[],n=t.length,o=t[0].length;for(let c=0;c<n;c++)for(let d=0;d<o;d++){const u=t[c][d],p=this.cellSize/2,f=(A,k)=>A<0||A>=n||k<0||k>=o?u.signal:t[A][k].signal,y=(f(c-1,d-1)+f(c-1,d)+f(c,d-1)+u.signal)/4,m=(f(c-1,d)+f(c-1,d+1)+u.signal+f(c,d+1))/4,x=(u.signal+f(c,d+1)+f(c+1,d)+f(c+1,d+1))/4,S=(f(c,d-1)+u.signal+f(c+1,d-1)+f(c+1,d))/4,v=u.x-p,b=u.y-p,P=u.x+p,C=u.y+p;i.push(v,b,P,b,P,C),s.push(y,m,x),i.push(v,b,P,C,v,C),s.push(y,x,S)}const a=new Wi({attributes:{aPosition:new Float32Array(i),aSignal:new Float32Array(s)}}),h=new Be({glProgram:new si({vertex:`
|
|
602
602
|
in vec2 aPosition;
|
|
603
603
|
in float aSignal;
|
|
604
604
|
uniform mat3 uProjectionMatrix;
|
|
@@ -741,4 +741,4 @@ fn mainFragment(
|
|
|
741
741
|
|
|
742
742
|
return vec4<f32>(color, 1.0);
|
|
743
743
|
}
|
|
744
|
-
`,entryPoint:"main"}})}),l=new Ca({geometry:a,shader:h});return l.alpha=.8,l}updatePositionByOrigin(t,i){this.position.set(t,i)}destroy(){this.removeChildren(),this.cacheAsTexture(!1)}}class sS{constructor(e){g(this,"heatmap");g(this,"pointsTopLeftOrigin",[]);g(this,"signalGrid",[]);g(this,"cellSize",2);g(this,"maxDistance",14);g(this,"smoothIterations",10);g(this,"heatmapAlpha",.8);g(this,"isHeatmapDrawn",!1);g(this,"loadTimer",null);g(this,"pendingPoints",null);this.appService=e,this.heatmap=new iS(e);const t=e.heatMapConfig;this.cellSize=t.cellSize,this.maxDistance=t.maxDistance,this.smoothIterations=t.smoothIterations,this.heatmapAlpha=t.heatmapAlpha}draw(e){const t=this.appService;if(!t.isMapDrawn){this.pendingPoints=e;return}this.pendingPoints=null;const{minX:i,minY:s}=t.mapManager.mapBounds,n=e.map(o=>({x:+(o.x-i).toFixed(0),y:+(o.y-s).toFixed(0),signal:o.signal}));this.signalGrid=this.calculateInterpolatedSignal(n),this.heatmap.draw(this.signalGrid,this.heatmapAlpha),this.isHeatmapDrawn=!0}onMapLoaded(){this.loadTimer||(this.pendingPoints&&this.draw(this.pendingPoints),this.loadTimer=setTimeout(()=>{this.loadTimer=null},200))}calculateInterpolatedSignal(e){var p;const t=this.appService,i=((p=t.mapState)==null?void 0:p.origin)||{x:0,y:0};let{minX:s,minY:n,maxX:o,maxY:a}=t.mapManager.mapBounds;n=n-i.y,s=s-i.x,a=a-i.y,o=o-i.x;const h=Math.ceil((a-n)/this.cellSize),l=Math.ceil((o-s)/this.cellSize),c=Array(h).fill(null).map(()=>Array(l).fill(null));for(let f=0;f<h;f++){const y=n+f*this.cellSize+this.cellSize/2,m=Math.min(this.cellSize,a-(y-this.cellSize/2));for(let x=0;x<l;x++){const S=s+x*this.cellSize+this.cellSize/2,v=Math.min(this.cellSize,o-(S-this.cellSize/2));let b=0,P=!1;for(let C=0;C<e.length;C++){const A=e[C];if(Math.abs(S-A.x)<=v/2&&Math.abs(y-A.y)<=m/2){const k=1-A.signal/7;b=Math.round(Math.max(b,k)*10)/10,P=!0}}c[f][x]={x:S,y,signal:b,hasPoint:P}}}const d=(f,y)=>{if(e.length===0)return 0;let m=0,x=0;for(const S of e){const v=Math.sqrt((f-S.x)**2+(y-S.y)**2);if(v<=this.maxDistance){const b=1/(1+v),P=1-S.signal/7;x+=b*P,m+=b}}return m===0?0:Math.round(x/m*1e3)/1e3},u=(f,y=1)=>{for(let m=0;m<y;m++){const x=f.map(S=>[...S]);for(let S=1;S<h-1;S++)for(let v=1;v<l-1;v++)if(!f[S][v].hasPoint){let b=0,P=0;const C=4;for(let A=-C;A<=C;A++)for(let k=-C;k<=C;k++){if(A===0&&k===0)continue;const M=S+A,T=v+k;if(M>=0&&M<h&&T>=0&&T<l){const E=1/(1+Math.sqrt(A*A+k*k)*.3);b+=f[M][T].signal*E,P+=E}}if(P>0){const A=b/P,k=.6,M=.4;x[S][v].signal=f[S][v].signal*k+A*M,x[S][v].signal>.1&&(x[S][v].signal=Math.max(x[S][v].signal,.2))}}for(let S=0;S<h;S++)for(let v=0;v<l;v++)f[S][v].signal=x[S][v].signal}};for(let f=0;f<h;f++)for(let y=0;y<l;y++){const m=c[f][y];m.hasPoint||(m.signal=d(m.x,m.y))}return u(c,this.smoothIterations),c}updatePositionByOrigin(e,t){this.heatmap.updatePositionByOrigin(e,t)}destroy(){this.heatmap.destroy()}}class xc extends L{constructor(t){super();g(this,"throttledUpdateScale");this.appService=t,this.throttledUpdateScale=Ct(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.updateScale(this.appService.currentScale),this.registerScaleListener()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}updateScale(t){t!==0&&this.scale.set(1/t)}destroy(t){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Ni extends xc{constructor(t,i){super(t);g(this,"background");g(this,"icon");g(this,"options");this.appService=t,this.options=i,this.background=new H,this.addChild(this.background),this.icon=new Xt(t),this.addChild(this.icon),this.eventMode="static",this.render(),this.setupHitArea(),this.setupEvents()}setupHitArea(){const t=this.appService,i=this.options.config||t.controlsConfig,s=8,n=i.iconWrapperWidth+s*2,o=i.iconWrapperHeight+s*2;this.hitArea=new et(-n/2,-o/2,n,o)}async render(){this.renderBackground(),this.renderIcon()}renderBackground(){const t=this.appService,i=this.options.config||t.controlsConfig;this.background.clear(),this.background.roundRect(-i.iconWrapperWidth/2,-i.iconWrapperHeight/2,i.iconWrapperWidth,i.iconWrapperHeight,i.iconWrapperBorderRadius).fill(this.options.backgroundColor)}async renderIcon(){try{const t=this.appService,i=this.options.config||t.controlsConfig;await this.icon.loadTextureAndSetSize(this.options.iconAlias,{width:i.iconWidth,height:i.iconHeight,sizeFixed:!1}),this.icon.visible=!0}catch(t){w.error(`Failed to load icon: ${this.options.iconAlias}`,t)}}destroy(){super.destroy()}}class Sc extends Ni{constructor(t,i){super(t,i);g(this,"isRotating",!1);g(this,"hasRotated",!1);g(this,"rotationCenter",{x:0,y:0});g(this,"lastAngle",0);g(this,"clickHandler",null);g(this,"handleRotationPointerMove",t=>{var o,a;if(!this.isRotating)return;this.hasRotated=!0;const i=this.parent.toLocal(t.global),s=Math.atan2(i.y-this.rotationCenter.y,i.x-this.rotationCenter.x),n=s-this.lastAngle;(a=(o=this.options).onRotationMove)==null||a.call(o,n),this.lastAngle=s});g(this,"handleRotationPointerUp",()=>{var t,i;this.isRotating&&(this.isRotating=!1,this.hasRotated&&((i=(t=this.options).onRotationEnd)==null||i.call(t)),this.hasRotated=!1)});g(this,"handleRotationCancel",()=>{var t,i;this.isRotating&&(this.isRotating=!1,this.hasRotated&&((i=(t=this.options).onRotationEnd)==null||i.call(t)),this.hasRotated=!1)});this.appService=t,this.setupRotationEventListeners()}setupRotationEventListeners(){const{emitter:t}=this.appService;this.appService.emitter.on("gestureHijackPointerMove",this.handleRotationPointerMove),t.on("gestureHijackPointerUp",this.handleRotationPointerUp),t.on("gestureHijackCancel",this.handleRotationCancel)}cleanupRotationEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.handleRotationPointerMove),t.off("gestureHijackPointerUp",this.handleRotationPointerUp),t.off("gestureHijackCancel",this.handleRotationCancel)}setupEvents(){this.options.onClick&&(this.clickHandler=new vt(this,{onClick:()=>{var t,i;this.hasRotated||(i=(t=this.options).onClick)==null||i.call(t)},stopPropagation:!1})),this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(t){t.stopPropagation(),this.startRotation(t)}startRotation(t){var n,o;this.isRotating=!0,this.hasRotated=!1;const i=this.options.getTargetPoints();this.rotationCenter=de(i);const s=this.parent.toLocal(t.global);this.lastAngle=Math.atan2(s.y-this.rotationCenter.y,s.x-this.rotationCenter.x),(o=(n=this.options).onRotationStart)==null||o.call(n,this.rotationCenter),this.appService.emitter.emit("gestureHijackStart",t)}isCurrentlyRotating(){return this.isRotating}stopRotation(){var t,i;this.isRotating&&(this.isRotating=!1,this.hasRotated&&((i=(t=this.options).onRotationEnd)==null||i.call(t)),this.hasRotated=!1)}destroy(){var t;this.stopRotation(),(t=this.clickHandler)==null||t.destroy(),this.cleanupRotationEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class zs extends Ni{constructor(t,i){super(t,i);g(this,"clickHandler",null);this.appService=t}setupEvents(){this.clickHandler=new vt(this,{onClick:this.options.onClick,stopPropagation:!0})}destroy(){var t;(t=this.clickHandler)==null||t.destroy(),super.destroy()}}class Qe extends Ni{constructor(t,i){super(t,i);g(this,"isScaling",!1);g(this,"initialButtonPosition",null);g(this,"dragStartPosition",null);g(this,"handleScalePointerMove",t=>{var o,a;if(!this.isScaling||!this.initialButtonPosition||!this.dragStartPosition)return;const i=this.parent.toLocal(t.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;(a=(o=this.options).onScaleMove)==null||a.call(o,{deltaX:s,deltaY:n})});g(this,"handleScalePointerUp",()=>{var t,i;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,(i=(t=this.options).onScaleEnd)==null||i.call(t))});g(this,"handleScaleCancel",()=>{var t,i;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,(i=(t=this.options).onScaleEnd)==null||i.call(t))});this.appService=t,this.setupScaleEventListeners()}setupScaleEventListeners(){const{emitter:t}=this.appService;t.on("gestureHijackPointerMove",this.handleScalePointerMove),t.on("gestureHijackPointerUp",this.handleScalePointerUp),t.on("gestureHijackCancel",this.handleScaleCancel)}cleanupScaleEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.handleScalePointerMove),t.off("gestureHijackPointerUp",this.handleScalePointerUp),t.off("gestureHijackCancel",this.handleScaleCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(t){t.stopPropagation(),this.startScaling(t)}startScaling(t){var i,s,n,o;if(this.isScaling=!0,this.dragStartPosition=this.parent.toLocal(t.global),"initialButtonPosition"in this.options)this.initialButtonPosition={x:this.position.x,y:this.position.y},(s=(i=this.options).onScaleStart)==null||s.call(i);else{const a=this.options.getTargetPoints(),h=this.options.getButtonIndex();h>=0&&h<a.length&&(this.initialButtonPosition={...a[h]}),(o=(n=this.options).onScaleStart)==null||o.call(n,h)}this.appService.emitter.emit("gestureHijackStart",t)}isCurrentlyScaling(){return this.isScaling}stopScaling(){var t,i;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,(i=(t=this.options).onScaleEnd)==null||i.call(t))}destroy(){this.stopScaling(),this.cleanupScaleEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Ls extends Ni{constructor(t,i){super(t,i);g(this,"isMoving",!1);g(this,"dragStartPosition",null);g(this,"handleMovePointerMove",t=>{var i,s;!this.isMoving||!this.dragStartPosition||(s=(i=this.options).onMoveMove)==null||s.call(i,t)});g(this,"handleMovePointerUp",()=>{var t,i;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,(i=(t=this.options).onMoveEnd)==null||i.call(t))});g(this,"handleMoveCancel",()=>{var t,i;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,(i=(t=this.options).onMoveEnd)==null||i.call(t))});this.appService=t,this.setupMoveEventListeners()}setupMoveEventListeners(){const{emitter:t}=this.appService;t.on("gestureHijackPointerMove",this.handleMovePointerMove),t.on("gestureHijackPointerUp",this.handleMovePointerUp),t.on("gestureHijackCancel",this.handleMoveCancel)}cleanupMoveEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.handleMovePointerMove),t.off("gestureHijackPointerUp",this.handleMovePointerUp),t.off("gestureHijackCancel",this.handleMoveCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(t){t.stopPropagation(),this.startMoving(t)}startMoving(t){var i,s;this.isMoving=!0,this.dragStartPosition=this.parent.toLocal(t.global),(s=(i=this.options).onMoveStart)==null||s.call(i),this.appService.emitter.emit("gestureHijackStart",t)}isCurrentlyMoving(){return this.isMoving}getDragStartPosition(){return this.dragStartPosition?{...this.dragStartPosition}:null}stopMoving(){var t,i;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,(i=(t=this.options).onMoveEnd)==null||i.call(t))}destroy(){this.stopMoving(),this.cleanupMoveEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Ur extends H{constructor(t,i){super();g(this,"fillOptions");g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"handlePointerDown",t=>{t.stopPropagation(),this.startDragging(t)});g(this,"handleDragPointerMove",t=>{var i,s;!this.isDragging||!this.dragStartPosition||(s=(i=this.fillOptions).onDragMove)==null||s.call(i,t)});g(this,"handleDragPointerUp",()=>{var t,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,(i=(t=this.fillOptions).onDragEnd)==null||i.call(t))});g(this,"handleDragCancel",()=>{var t,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,(i=(t=this.fillOptions).onDragEnd)==null||i.call(t))});this.appService=t,this.fillOptions=i,this.setupInteraction(),this.setupDragEventListeners(),this.draw()}setupInteraction(){this.fillOptions.enableInteraction&&(this.eventMode="static",this.on("pointerdown",this.handlePointerDown))}setupDragEventListeners(){const{emitter:t}=this.appService;t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}startDragging(t){var s,n;this.isDragging=!0;const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},(n=(s=this.fillOptions).onDragStart)==null||n.call(s,t),this.appService.emitter.emit("gestureHijackStart",t)}draw(){const{points:t,fillColor:i}=this.fillOptions;if(t.length<3)return;this.clear();const s=t.flatMap(n=>[n.x,n.y]);this.setFillStyle({color:i}).poly(s).fill()}getDragStartPosition(){return this.dragStartPosition}updateOptions(t){this.fillOptions={...this.fillOptions,...t},t.enableInteraction!==void 0&&(this.off("pointerdown",this.handlePointerDown),this.setupInteraction()),this.draw()}updatePoints(t){this.fillOptions.points=t,this.draw()}updateFillColor(t){this.fillOptions.fillColor=t,this.draw()}stopDragging(){this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null)}isCurrentlyDragging(){return this.isDragging}setInteractionEnabled(t){this.fillOptions.enableInteraction=t,t?(this.eventMode="static",this.on("pointerdown",this.handlePointerDown)):(this.eventMode="auto",this.off("pointerdown",this.handlePointerDown),this.isDragging&&this.stopDragging())}destroy(){this.stopDragging(),this.cleanupDragEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}const Hr=(r,e,t)=>{if(e!=null){if(typeof e!="number"||!Number.isFinite(e)||e<=r){w.warn(`[${t}] maxSize (${String(e)}) must be a finite number greater than minSize (${r}); ignoring.`);return}return e}};class Nt extends L{constructor(t,i){super();g(this,"borderOptions");g(this,"solidLine",null);g(this,"dashGraphics",null);g(this,"fillGraphics",null);g(this,"handleAntiScale",()=>{this.drawBorder()});this.appService=t,this.borderOptions={...i},this.drawBorder(),this.setupAntiScaleListener(),this.eventMode="none"}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.handleAntiScale)}drawBorder(){const{points:t=[],closePath:i=!1,style:s}=this.borderOptions;t.length<2||(this.clearBorder(),s.fillColor!==void 0&&i&&this.drawFill(t,s),s.isDashed?this.drawContinuousDashedBorder(t,i,s):this.drawSolidBorder(t,i,s))}drawFill(t,i){if(!(!i.fillColor||t.length<3)){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy()),this.fillGraphics=new H,this.fillGraphics.setFillStyle({color:i.fillColor}),this.fillGraphics.moveTo(t[0].x,t[0].y);for(let s=1;s<t.length;s++)this.fillGraphics.lineTo(t[s].x,t[s].y);this.fillGraphics.closePath(),this.fillGraphics.fill(),this.addChild(this.fillGraphics)}}drawSolidBorder(t,i,s){const n=this.appService;this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy()),this.solidLine=new H;const o=n.getApp().toFixedSize(s.width);this.solidLine.setStrokeStyle({color:s.color,width:o}),this.solidLine.moveTo(t[0].x,t[0].y);for(let a=1;a<t.length;a++)this.solidLine.lineTo(t[a].x,t[a].y);i&&this.solidLine.lineTo(t[0].x,t[0].y),this.solidLine.stroke(),this.addChild(this.solidLine)}drawContinuousDashedBorder(t,i,s){if(t.length<2)return;if(!s.dashArray||s.dashArray.length!==2||s.dashArray[0]<=0||s.dashArray[1]<=0){w.warn("Invalid dashArray:",s.dashArray);return}const n=this.appService;this.dashGraphics=new H;const o=n.getApp().toFixedSize(s.width);this.dashGraphics.setStrokeStyle({color:s.color,width:o});const a=Math.max(n.getApp().toFixedSize(s.dashArray[0]),1),h=Math.max(n.getApp().toFixedSize(s.dashArray[1]),1),l=i?[...t,t[0]]:t;this.drawContinuousPathDashes(this.dashGraphics,l,a,h),this.dashGraphics.stroke(),this.addChild(this.dashGraphics)}drawContinuousPathDashes(t,i,s,n){if(i.length<2)return;if(s<=0||n<=0){w.warn("Invalid dash parameters:",{dashLength:s,gapLength:n});return}const o=this.calculatePathSegments(i),a=o.reduce((c,d)=>c+d.length,0);if(a===0)return;const h=s+n;let l=0;for(;l<a;){const c=l+s;c<=a?this.drawContinuousDashSegment(t,o,l,c):this.drawContinuousDashSegment(t,o,l,a),l+=h}}calculatePathSegments(t){const i=[];for(let s=0;s<t.length-1;s++){const n=t[s],o=t[s+1],a=o.x-n.x,h=o.y-n.y,l=Math.sqrt(a*a+h*h);i.push({start:n,end:o,length:l})}return i}drawContinuousDashSegment(t,i,s,n){if(s>=n)return;let o=0,a=!1,h=null;for(const l of i){const c=o,d=o+l.length;if(d>s&&c<n){const u=Math.max(s,c),p=Math.min(n,d),f=(u-c)/l.length,y=(p-c)/l.length,m={x:l.start.x+(l.end.x-l.start.x)*f,y:l.start.y+(l.end.y-l.start.y)*f},x={x:l.start.x+(l.end.x-l.start.x)*y,y:l.start.y+(l.end.y-l.start.y)*y};a?h&&Math.sqrt(Math.pow(m.x-h.x,2)+Math.pow(m.y-h.y,2))>.1&&t.lineTo(m.x,m.y):(t.moveTo(m.x,m.y),a=!0),t.lineTo(x.x,x.y),h=x}if(o+=l.length,o>=n)break}}clearBorder(){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy(),this.fillGraphics=null),this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy(),this.solidLine=null),this.dashGraphics&&(this.removeChild(this.dashGraphics),this.dashGraphics.destroy(),this.dashGraphics=null)}updateStyle(t){this.borderOptions.style={...this.borderOptions.style,...t},this.drawBorder()}updatePoints(t){this.borderOptions.points=t,this.drawBorder()}setClosePath(t){this.borderOptions.closePath=t,this.drawBorder()}getOptions(){return{...this.borderOptions}}destroy(){this.appService.emitter.off("antiScale",this.handleAntiScale),this.clearBorder(),super.destroy()}}class ji extends Bs{constructor(t,{text:i,style:s}){super({text:i,style:s});g(this,"throttledUpdateScale");this.appService=t,this.throttledUpdateScale=Ct(this.updateScale.bind(this),20,{leading:!0,trailing:!0}),this.registerScaleListener(),this.updateScale(this.appService.currentScale)}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}updateScale(t){t<=0||this.scale.set(1/t)}setBaseFontSize(t){this.style.fontSize=t}updateText(t){this.text=t}destroy(t){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}const At=class At extends L{constructor(t){super();g(this,"appService");g(this,"zoneData");g(this,"zoneType");g(this,"zoneConfig");g(this,"controlsConfig");g(this,"zoneEvents");g(this,"controlFill");g(this,"zoneBorder");g(this,"outlineBorder");g(this,"moveLine");g(this,"sizeText");g(this,"controlButtons");g(this,"deleteButton",null);g(this,"rotateButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"totalRotationAngle",0);g(this,"rotationCenter",null);g(this,"initialZonePoints",[]);g(this,"initialButtonPosition",null);g(this,"dragStartPosition",null);g(this,"clickHandler",null);g(this,"resolvedMaxSizeCache",null);g(this,"throttledUpdateOutline");g(this,"handleDragStart",t=>{this.isEditingEnabled()&&(this.initialZonePoints=this.zoneData.points.map(i=>({...i})),this.dragStartPosition=this.parent.toLocal(t.global),this.appService.getApp().requestRender("zone-drag",!0))});g(this,"handleDragMove",t=>{if(!this.isEditingEnabled()||this.initialZonePoints.length===0||!this.dragStartPosition)return;const i=this.parent.toLocal(t.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;this.applyTranslation(s,n)});g(this,"handleDragEnd",()=>{var t,i;this.initialZonePoints=[],this.dragStartPosition=null,this.appService.getApp().stopRender("zone-drag"),(i=(t=this.zoneEvents).onUpdate)==null||i.call(t,this.getZoneData())});g(this,"handleRotationStart",t=>{this.totalRotationAngle=0,this.rotationCenter=t,this.initialZonePoints=this.zoneData.points.map(i=>({...i})),this.appService.getApp().requestRender("zone-rotate",!0)});g(this,"handleRotationMove",t=>{this.totalRotationAngle+=t,this.applyRotation(this.totalRotationAngle)});g(this,"handleRotationEnd",()=>{var t,i;this.rotationCenter=null,this.totalRotationAngle=0,this.initialZonePoints=[],this.appService.getApp().stopRender("zone-rotate"),(i=(t=this.zoneEvents).onUpdate)==null||i.call(t,this.getZoneData())});g(this,"handleScaleStart",()=>{this.initialZonePoints=this.zoneData.points.map(i=>({...i}));const t=At.BUTTON_INDICES.SCALE;t<this.zoneData.points.length&&(this.initialButtonPosition={...this.zoneData.points[t]}),this.appService.getApp().requestRender("zone-scale",!0)});g(this,"handleScaleMove",({deltaX:t,deltaY:i})=>{if(this.initialZonePoints.length===0||!this.initialButtonPosition)return;const s={x:this.initialButtonPosition.x+t,y:this.initialButtonPosition.y+i};this.applyEdgeBasedScale(s)});g(this,"handleScaleEnd",()=>{var t,i;this.initialZonePoints=[],this.initialButtonPosition=null,this.appService.getApp().stopRender("zone-scale"),(i=(t=this.zoneEvents).onUpdate)==null||i.call(t,this.getZoneData())});g(this,"handleMoveStart",()=>{this.initialZonePoints=this.zoneData.points.map(t=>({...t})),this.appService.getApp().requestRender("zone-move",!0)});g(this,"handleMove",t=>{var a;if(!this.isEditingEnabled()||this.initialZonePoints.length===0)return;const i=this.parent.toLocal(t.global),s=(a=this.moveButton)==null?void 0:a.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleMoveEnd",()=>{var t,i;this.initialZonePoints=[],this.appService.getApp().stopRender("zone-move"),(i=(t=this.zoneEvents).onUpdate)==null||i.call(t,this.getZoneData())});g(this,"handleDelete",()=>{var t,i;(i=(t=this.zoneEvents).onRemove)==null||i.call(t,this.zoneData.id)});const{appService:i,zoneData:s,zoneType:n,events:o={}}=t;this.appService=i,this.zoneType=n,this.zoneEvents=o,this.zoneConfig=this.getZoneConfig(),this.controlsConfig=this.getControlsConfig();const a=this.validateAndCorrectZoneSize(s.points),h=Cs(a);this.zoneData={...s,points:h},this.throttledUpdateOutline=Ct(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.createControlButtons(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateOutline),this.appService.emitter.on("mapRotationUpdate",this.throttledUpdateOutline)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition())}getZoneConfig(){var i;const t=this.appService.getConfig();if(Ne(this.zoneType)){const s=t.controls[this.zoneType];if(s)return s}else{const s=(i=t.customZoneTypes)==null?void 0:i[this.zoneType];if(s)return s}return Ei.cleanZone}getControlsConfig(){const{controls:t}=this.appService.getConfig();return t}validateAndCorrectZoneSize(t){if(t.length<4)return t;const i=this.appService.metersToPixels(this.zoneConfig.minSize),s=this.getResolvedMaxSize(),n=s!=null?this.appService.metersToPixels(s):void 0;return nr(t,i,n)}getResolvedMaxSize(){const t=this.zoneConfig.maxSize;if(this.resolvedMaxSizeCache&&this.resolvedMaxSizeCache.key===t)return this.resolvedMaxSizeCache.value;const i=Hr(this.zoneConfig.minSize,t,this.zoneType);return this.resolvedMaxSizeCache={key:t,value:i},i}isEditingEnabled(){var s;const t=this.appService.runtimeSnapshot,i=this.zoneData.id;switch(this.zoneType){case"forbiddenSweepZone":return t.editingForbiddenSweepZoneIds.includes(i);case"forbiddenMopZone":return t.editingForbiddenMopZoneIds.includes(i);case"cleanZone":return t.editingCleanZoneIds.includes(i);default:return(((s=t.editingCustomZoneIds)==null?void 0:s[this.zoneType])??[]).includes(i)}}initializeComponents(){this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.controlFill=this.createControlFill(),this.addChild(this.controlFill),this.zoneBorder=this.createBorder(),this.addChild(this.zoneBorder),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.sizeText=this.createSizeText(),this.addChild(this.sizeText),this.controlButtons=new L,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.drawZone()}createControlButtons(){const t=this.calculateOutlinePoints();if(t.length<4)return;this.deleteButton=new zs(this.appService,{iconAlias:"deleteIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onClick:this.handleDelete}),this.deleteButton.position.set(t[At.BUTTON_INDICES.REMOVE].x,t[At.BUTTON_INDICES.REMOVE].y),this.zoneConfig.showRotateButton&&(this.rotateButton=new Sc(this.appService,{iconAlias:"rotateIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,onRotationStart:this.handleRotationStart,onRotationMove:this.handleRotationMove,onRotationEnd:this.handleRotationEnd}),this.rotateButton.position.set(t[At.BUTTON_INDICES.ROTATE].x,t[At.BUTTON_INDICES.ROTATE].y)),this.scaleButton=new Qe(this.appService,{iconAlias:"scaleIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,getButtonIndex:()=>At.BUTTON_INDICES.SCALE,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(t[At.BUTTON_INDICES.SCALE].x,t[At.BUTTON_INDICES.SCALE].y);const i=this.calculateMoveButtonPosition();this.moveButton=new Ls(this.appService,{iconAlias:"moveIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(i.x,i.y),this.controlButtons.addChild(this.deleteButton),this.rotateButton&&this.controlButtons.addChild(this.rotateButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}createControlFill(){const t=this.isEditingEnabled();return new Ur(this.appService,{points:this.zoneData.points,fillColor:this.zoneConfig.fillColor,enableInteraction:t,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(){const i=this.isEditingEnabled()?this.zoneConfig.editing:this.zoneConfig.normal;return new Nt(this.appService,{points:this.zoneData.points,closePath:!0,style:{color:this.zoneConfig.strokeColor,width:this.zoneConfig.strokeWidth,isDashed:i.isDashed,dashArray:i.dashArray}})}createOutlineBorder(){const t=this.calculateOutlinePoints();return new Nt(this.appService,{points:t,closePath:!0,style:{color:this.zoneConfig.outlineStrokeColor,width:this.zoneConfig.outlineStrokeWidth,isDashed:this.zoneConfig.outlineDashed,dashArray:this.zoneConfig.outlineDashArray,fillColor:this.zoneConfig.outlineFillColor}})}createMoveLine(){const t=this.calculateOutlinePoints(),i=this.calculateMoveLinePoints(t);return new Nt(this.appService,{points:i,closePath:!1,style:{color:this.zoneConfig.outlineStrokeColor,width:this.zoneConfig.outlineStrokeWidth,isDashed:this.zoneConfig.outlineDashed,dashArray:this.zoneConfig.outlineDashArray}})}calculateOutlinePoints(){const{points:t}=this.zoneData;if(t.length<4)return t;const i=this.appService.getApp().toFixedSize(this.zoneConfig.outlineOffset);return zr(t,i)}calculateMoveLinePoints(t){if(t.length<4)return[];const i=t[At.BUTTON_INDICES.MOVE],s=this.calculateMoveButtonPosition();return[i,s]}createSizeText(){const t=this.calculateZoneSizeText(),i=new ji(this.appService,{text:t,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.zoneConfig.textColor,align:"center"}});i.anchor.set(.5);const s=this.calculateSizeTextPosition();i.position.set(s.x,s.y);const n=this.calculateSizeTextRotation();return i.rotation=n,i.eventMode="none",i}calculateZoneSizeText(){const{points:t}=this.zoneData;if(t.length<4)return"0m*0m";const[i,s,,n]=t,o=Q(i,s),a=Q(i,n),h=this.appService.pixelsToMeters(o),l=this.appService.pixelsToMeters(a),c=this.appService.metersToDisplayUnit(h),d=this.appService.metersToDisplayUnit(l),u=this.appService.runtimeSnapshot.unitLabel;return`${c.toFixed(1)}${u}*${d.toFixed(1)}${u}`}calculateSizeTextPosition(){const{points:t}=this.zoneData;if(t.length<4)return{x:0,y:0};const[i,s,n,o]=t,{textPosition:a,textOffset:h}=this.zoneConfig,l=this.appService.getApp().toFixedSize(h);let c,d;switch(a){case"top":{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2};const u=gt(K(s,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"right":{c={x:(s.x+n.x)/2,y:(s.y+n.y)/2};const u=gt(K(s,n)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"bottom":{c={x:(o.x+n.x)/2,y:(o.y+n.y)/2};const u=gt(K(o,n)),p={x:-u.y,y:u.x};d={x:p.x*l,y:p.y*l};break}case"left":{c={x:(i.x+o.x)/2,y:(i.y+o.y)/2};const u=gt(K(o,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}default:c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:0,y:l};break}return{x:c.x+d.x,y:c.y+d.y}}calculateSizeTextRotation(){const{points:t}=this.zoneData;if(t.length<4)return 0;const[i,s,n,o]=t,{textPosition:a}=this.zoneConfig;let h,l;switch(a){case"top":h=i,l=s;break;case"right":h=s,l=n;break;case"bottom":h=n,l=o;break;case"left":h=o,l=i;break;default:h=i,l=s;break}const c=this.appService.appContainer.getMapRotationRadians();return qe(h,l,c)}calculateMoveButtonPosition(){const t=this.calculateOutlinePoints();if(t.length<4)return{x:0,y:0};const{controls:i}=this.appService.getConfig(),s=t[At.BUTTON_INDICES.MOVE],n=t[2],o=t[0],a=this.appService.getApp().toFixedSize(i.moveButtonOffset);return Ds(s,n,o,a)}applyTranslation(t,i){this.zoneData.points=this.initialZonePoints.map(s=>({x:s.x+t,y:s.y+i})),this.drawZone(),this.updateControlButtonsPosition()}applyRotation(t){!this.rotationCenter||this.initialZonePoints.length===0||(this.zoneData.points=Fr(this.initialZonePoints,this.rotationCenter,t),this.drawZone(!1),this.updateControlButtonsPosition())}applyEdgeBasedScale(t){if(this.initialZonePoints.length<4)return;const{FIXED:i}=At.BUTTON_INDICES,{x:s,y:n}=this.initialZonePoints[i],[,o,,a]=this.initialZonePoints,h={x:s,y:n},l=K(h,o),c=K(h,a),d=K(h,t),u=ee(l),p=ee(c);if(u===0||p===0)return;const f=this.appService.metersToPixels(this.zoneConfig.minSize),y=this.getResolvedMaxSize(),m=y!=null?this.appService.metersToPixels(y):void 0,[x,S]=[ae(d,l,u,f,m),ae(d,c,p,f,m)];this.zoneData.points=[h,{x:s+l.x*x,y:n+l.y*x},{x:s+l.x*x+c.x*S,y:n+l.y*x+c.y*S},{x:s+c.x*S,y:n+c.y*S}],this.drawZone(),this.updateControlButtonsPosition()}setupClickHandler(){this.clickHandler=new vt(this,{onClick:()=>{var t,i;this.isEditingEnabled()||(i=(t=this.zoneEvents)==null?void 0:t.onClick)==null||i.call(t,this.getZoneData())},stopPropagation:!1})}drawZone(t=!0){const{points:i}=this.zoneData;i.length<4||(this.controlFill.updatePoints(i),this.zoneBorder.updatePoints(i),this.updateOutlineBorder(),this.updateMoveLine(),this.updateSizeText(t))}updateOutlineBorder(){const t=this.calculateOutlinePoints();this.outlineBorder.updatePoints(t)}updateMoveLine(){const t=this.calculateOutlinePoints(),i=this.calculateMoveLinePoints(t);this.moveLine.updatePoints(i)}updateSizeText(t=!0){if(this.sizeText){if(t){const i=this.calculateZoneSizeText();this.sizeText.updateText(i)}this.updateSizeTextPosition()}}updateSizeTextPosition(){if(!this.sizeText)return;const t=this.calculateSizeTextPosition();this.sizeText.position.set(t.x,t.y);const i=this.calculateSizeTextRotation();this.sizeText.rotation=i}updateControlButtonsPosition(){if(!this.deleteButton||!this.scaleButton||!this.moveButton)return;const t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:i,ROTATE:s,SCALE:n}=At.BUTTON_INDICES,o=this.calculateMoveButtonPosition(),a=[{button:this.deleteButton,point:t[i]},{button:this.scaleButton,point:t[n]},{button:this.moveButton,point:o}];this.rotateButton&&a.push({button:this.rotateButton,point:t[s]}),a.forEach(({button:h,point:l})=>h.position.set(l.x,l.y))}updateEditState(){const t=this.isEditingEnabled();this.controlButtons.visible=t,!t&&this.getCurrentOperationState().hasAnyOperation&&this.stopAllOperations(),this.outlineBorder.visible=t,this.moveLine.visible=t,this.sizeText&&(this.sizeText.visible=t),t&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition()),this.controlFill.setInteractionEnabled(t),this.updateBorderStyle(t?this.zoneConfig.editing:this.zoneConfig.normal),this.zIndex=t?1e3:0}updateBorderStyle(t){this.zoneBorder.updateStyle({isDashed:t.isDashed,dashArray:t.dashArray})}getCurrentOperationState(){var o,a,h;const t=this.controlFill.isCurrentlyDragging(),i=((o=this.scaleButton)==null?void 0:o.isCurrentlyScaling())||!1,s=((a=this.rotateButton)==null?void 0:a.isCurrentlyRotating())||!1,n=((h=this.moveButton)==null?void 0:h.isCurrentlyMoving())||!1;return{isDragging:t,isScaling:i,isRotating:s,isMoving:n,hasAnyOperation:t||i||s||n}}stopAllOperations(){var t,i,s;this.controlFill.stopDragging(),(t=this.scaleButton)==null||t.stopScaling(),(i=this.rotateButton)==null||i.stopRotation(),(s=this.moveButton)==null||s.stopMoving()}stopDragging(){this.controlFill.stopDragging()}stopScaling(){var t;(t=this.scaleButton)==null||t.stopScaling()}stopRotating(){var t;(t=this.rotateButton)==null||t.stopRotation()}stopMoving(){var t;(t=this.moveButton)==null||t.stopMoving()}isCurrentlyDragging(){return this.controlFill.isCurrentlyDragging()}isCurrentlyScaling(){var t;return((t=this.scaleButton)==null?void 0:t.isCurrentlyScaling())||!1}isCurrentlyRotating(){var t;return((t=this.rotateButton)==null?void 0:t.isCurrentlyRotating())||!1}isCurrentlyMoving(){var t;return((t=this.moveButton)==null?void 0:t.isCurrentlyMoving())||!1}updateZoneData(t){const i=this.validateAndCorrectZoneSize(t.points),s=Cs(i);this.zoneData={...t,points:s},this.drawZone(),this.updateControlButtonsPosition(),this.updateEditState()}getZoneData(){return{...this.zoneData}}refreshDisplay(){this.drawZone()}destroy(){var t,i,s,n,o,a,h,l,c,d,u;this.appService.emitter.off("antiScale",this.throttledUpdateOutline),this.appService.emitter.off("mapRotationUpdate",this.throttledUpdateOutline),(t=this.clickHandler)==null||t.destroy(),this.clickHandler=null,(i=this.deleteButton)==null||i.destroy(),(s=this.rotateButton)==null||s.destroy(),(n=this.scaleButton)==null||n.destroy(),(o=this.moveButton)==null||o.destroy(),this.deleteButton=null,this.rotateButton=null,this.scaleButton=null,this.moveButton=null,(a=this.zoneBorder)==null||a.destroy(),(h=this.outlineBorder)==null||h.destroy(),(l=this.moveLine)==null||l.destroy(),(c=this.sizeText)==null||c.destroy(),(d=this.controlFill)==null||d.destroy(),(u=this.controlButtons)==null||u.destroy(),super.destroy()}};g(At,"BUTTON_INDICES",{REMOVE:0,ROTATE:1,SCALE:2,MOVE:3,FIXED:0});let oi=At;class Vr extends oi{constructor(e,t){super({appService:e,zoneData:t.zoneData,zoneType:"forbiddenSweepZone",events:{onRemove:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onRemoveForbiddenSweepZone)==null||n.call(s,i)},onUpdate:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onUpdateForbiddenSweepZone)==null||n.call(s,i)},onClick:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onClickForbiddenSweepZone)==null||n.call(s,i)}}})}static create(e,t){return new Vr(e,{zoneData:t})}}class Nr extends oi{constructor(e,t){super({appService:e,zoneData:t.zoneData,zoneType:"forbiddenMopZone",events:{onRemove:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onRemoveForbiddenMopZone)==null||n.call(s,i)},onUpdate:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onUpdateForbiddenMopZone)==null||n.call(s,i)},onClick:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onClickForbiddenMopZone)==null||n.call(s,i)}}})}static create(e,t){return new Nr(e,{zoneData:t})}}class jr extends oi{constructor(e,t){super({appService:e,zoneData:t.zoneData,zoneType:"cleanZone",events:{onRemove:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onRemoveCleanZone)==null||n.call(s,i)},onUpdate:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onUpdateCleanZone)==null||n.call(s,i)},onClick:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onClickCleanZone)==null||n.call(s,i)}}})}static create(e,t){return new jr(e,{zoneData:t})}}class Ue extends H{constructor(t,i){super();g(this,"lineOptions");g(this,"strokeContext",null);g(this,"drawDashLine",()=>{const{start:t,end:i,style:s}=this.lineOptions;this.clear(),this.strokeContext&&this.strokeContext.destroy();const n=this.appService;this.strokeContext=new mt;const o=n.getApp().toFixedSize(s.width);this.strokeContext.setStrokeStyle({color:s.color,width:o}),this.drawDashedLineToContext(this.strokeContext,t.x,t.y,i.x,i.y,s.dashArray[0],s.dashArray[1]),this.strokeContext.stroke(),this.context=this.strokeContext});this.appService=t,this.lineOptions={...i},this.eventMode="static",this.drawDashLine(),this.setupAntiScaleListener()}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.drawDashLine)}drawDashedLineToContext(t,i,s,n,o,a,h){const l=n-i,c=o-s,d=Math.sqrt(l*l+c*c);if(d===0)return;const u=this.appService,p=u.getApp().toFixedSize(a),f=u.getApp().toFixedSize(h),y=p+f,m=d/y,x=Math.round(m);if(x===0){t.moveTo(i,s),t.lineTo(n,o);return}const S=d/x,v=S*(p/y),b=l/d,P=c/d;for(let C=0;C<x;C++){const A=C*S,k=A+v;if(A>=d)break;const M=Math.min(k,d),T=i+A*b,_=s+A*P,E=i+M*b,B=s+M*P;t.moveTo(T,_),t.lineTo(E,B)}}updatePoints(t,i){this.lineOptions.start=t,this.lineOptions.end=i,this.drawDashLine()}updateStyle(t){this.lineOptions.style={...this.lineOptions.style,...t},this.drawDashLine()}getOptions(){return{...this.lineOptions}}destroy(){this.appService.emitter.off("antiScale",this.drawDashLine),this.strokeContext&&this.strokeContext.destroy(),super.destroy()}}const Vt=class Vt extends L{constructor(t){super();g(this,"wallData");g(this,"wallConfig");g(this,"controlsConfig");g(this,"wallEvents");g(this,"appService");g(this,"wallLine");g(this,"outlineBorder");g(this,"moveLine");g(this,"lengthText");g(this,"controlButtons");g(this,"removeButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"initialWallPoints",[]);g(this,"initialButtonPosition",null);g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"resolvedMaxWidthCache",null);g(this,"throttledUpdateOutline");g(this,"throttledHandleScaleChange");g(this,"wallLineClickHandler",null);g(this,"handleRemove",()=>{var t,i;(i=(t=this.wallEvents).onRemove)==null||i.call(t,this.wallData.id)});g(this,"initializeOperation",()=>{this.initialWallPoints=this.wallData.points.map(t=>({...t}))});g(this,"finalizeOperation",()=>{var t,i;this.initialWallPoints=[],(i=(t=this.wallEvents).onUpdate)==null||i.call(t,this.getWallData())});g(this,"handleScaleStart",()=>{this.initializeOperation();const t=this.calculateOutlinePoints();t.length>Vt.BUTTON_INDICES.SCALE&&(this.initialButtonPosition={...t[Vt.BUTTON_INDICES.SCALE]}),this.appService.getApp().requestRender("virtualwall-scale",!0)});g(this,"handleScaleMove",({deltaX:t,deltaY:i})=>{if(this.initialWallPoints.length===0||!this.initialButtonPosition)return;const s={x:this.initialButtonPosition.x+t,y:this.initialButtonPosition.y+i};this.applyScaleAndRotation(s)});g(this,"handleScaleEnd",()=>{this.finalizeOperation(),this.initialButtonPosition=null,this.appService.getApp().stopRender("virtualwall-scale")});g(this,"handleMoveStart",()=>{this.initializeOperation(),this.appService.getApp().requestRender("virtualwall-move",!0)});g(this,"handleMove",t=>{var a;if(this.initialWallPoints.length===0)return;const i=this.parent.toLocal(t.global),s=this.getDragStartPosition()||((a=this.moveButton)==null?void 0:a.getDragStartPosition());if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleMoveEnd",()=>{this.finalizeOperation(),this.appService.getApp().stopRender("virtualwall-move")});g(this,"handleScaleChange",()=>{this.redrawSolidLine(),this.setupWallLineHitArea()});g(this,"handleWallLinePointerDown",t=>{this.isEditingEnabled()&&(t.stopPropagation(),this.startDragging(t))});g(this,"handleDragPointerMove",t=>{!this.isDragging||!this.dragStartPosition||this.handleMove(t)});g(this,"handleDragPointerUp",()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.appService.getApp().stopRender("virtualwall-drag"),this.finalizeOperation())});g(this,"handleDragCancel",()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.appService.getApp().stopRender("virtualwall-drag"),this.handleMoveEnd())});const{appService:i,wallData:s,events:n={}}=t;this.appService=i,this.wallEvents=n,this.wallConfig=this.appService.controlsConfig.virtualWall,this.controlsConfig=this.appService.controlsConfig,this.wallData={...s,points:this.validateAndCorrectWallLength(s.points)},this.throttledHandleScaleChange=Ct(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.throttledUpdateOutline=Ct(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.registerScaleListener(),this.setupDragEventListeners()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateOutline),this.appService.emitter.on("antiScale",this.throttledHandleScaleChange),this.appService.emitter.on("mapRotationUpdate",this.throttledUpdateOutline)}getResolvedMaxWidth(){const t=this.wallConfig.maxWidth;if(this.resolvedMaxWidthCache&&this.resolvedMaxWidthCache.key===t)return this.resolvedMaxWidthCache.value;const i=Hr(this.wallConfig.minWidth,t,"virtualWall");return this.resolvedMaxWidthCache={key:t,value:i},i}validateAndCorrectWallLength(t){if(t.length<2)return t;const[i,s]=t,n=this.appService.metersToPixels(this.wallConfig.minWidth),o=this.getResolvedMaxWidth(),a=o!=null?this.appService.metersToPixels(o):void 0,h=Q(i,s),l=h<n,c=a!=null&&h>a;if(!l&&!c)return t;if(h===0)return[i,{x:i.x+n,y:i.y}];const d=gt(K(i,s));let u=h;return a!=null&&(u=Math.min(u,a)),u=Math.max(u,n),[i,{x:i.x+d.x*u,y:i.y+d.y*u}]}isEditingEnabled(){return this.appService.runtimeSnapshot.editingVirtualWallIds.includes(this.wallData.id)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineComponents(),this.updateControlButtonsPosition(),this.updateLengthTextPosition())}initializeComponents(){this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.createWallLine(!1),this.addChild(this.wallLine),this.lengthText=this.createLengthText(),this.addChild(this.lengthText),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.controlButtons=new L,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.createControlButtons()}createWallLine(t=!0){const{points:i}=this.wallData;if(i.length<2)return;const{lineWidth:s,lineColor:n,editing:o,normal:a}=this.wallConfig,l=this.isEditingEnabled()?o:a;l.isDashed?this.wallLine=new Ue(this.appService,{start:i[0],end:i[1],style:{color:n.toString(),width:s,dashArray:l.dashArray}}):this.wallLine=this.createSolidLine(i[0],i[1],s,n.toString()),t&&this.setupWallLineInteraction()}createLengthText(){const t=this.calculateWallLengthInMeters(),i=this.formatLengthText(t),s=new ji(this.appService,{text:i,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.wallConfig.textColor,align:"center"}});s.anchor.set(.5);const n=this.calculateTextPosition();s.position.set(n.x,n.y);const o=this.calculateTextRotation();return s.rotation=o,s.eventMode="none",s}calculateWallLengthInMeters(){const{points:t}=this.wallData;if(t.length<2)return 0;const i=Q(t[0],t[1]);return this.appService.pixelsToMeters(i)}formatLengthText(t){const i=this.appService.metersToDisplayUnit(t),s=this.appService.runtimeSnapshot.unitLabel;return`${i.toFixed(1)}${s}`}calculateTextPosition(){const{points:t}=this.wallData;if(t.length<2)return{x:0,y:0};const[i,s]=t,n=this.appService.getApp().toFixedSize(this.wallConfig.textOffset);return nc(i,s,n)}calculateTextRotation(){const{points:t}=this.wallData;if(t.length<2)return 0;const[i,s]=t,n=this.appService.appContainer.getMapRotationRadians();return qe(i,s,n)}getOutlineStyle(){return{color:this.wallConfig.outlineStrokeColor,width:this.wallConfig.outlineStrokeWidth,isDashed:this.wallConfig.outlineDashed,dashArray:this.wallConfig.outlineDashArray,fillColor:this.wallConfig.outlineFillColor}}createOutlineBorder(){const t=this.calculateOutlinePoints();return new Nt(this.appService,{points:t,closePath:!0,style:this.getOutlineStyle()})}createMoveLine(){const t=this.calculateOutlinePoints(),i=this.calculateMoveLinePoints(t);return new Nt(this.appService,{points:i,closePath:!1,style:this.getOutlineStyle()})}calculateOutlinePoints(t){const i=t||this.wallData.points;if(i.length<2)return i;const s=this.appService.getApp().toFixedSize(this.wallConfig.outlineOffset),n=my(i[0],i[1],s);return[n[3],n[2],n[1],n[0]]}calculateMoveLinePoints(t){if(t.length<4)return[];const{MOVE:i}=Vt.BUTTON_INDICES,s=t[i],n=this.calculateMoveButtonPosition();return[s,n]}calculateMoveButtonPosition(){const{moveButtonOffset:t}=this.controlsConfig,i=this.calculateOutlinePoints();if(i.length<4)return{x:0,y:0};const{MOVE:s}=Vt.BUTTON_INDICES,n=i[s],o=i[(s+3)%4],a=i[(s+1)%4],h=this.appService.getApp().toFixedSize(t);return Ds(n,a,o,h)}createControlButtons(){const t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:i,SCALE:s}=Vt.BUTTON_INDICES;this.removeButton=new zs(this.appService,{iconAlias:"deleteIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onClick:this.handleRemove}),this.removeButton.position.set(t[i].x,t[i].y),this.scaleButton=new Qe(this.appService,{iconAlias:"scaleIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,getTargetPoints:()=>this.calculateOutlinePoints(),getButtonIndex:()=>s,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(t[s].x,t[s].y);const n=this.calculateMoveButtonPosition();this.moveButton=new Ls(this.appService,{iconAlias:"moveIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(n.x,n.y),this.controlButtons.addChild(this.removeButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}applyScaleAndRotation(t){if(this.initialWallPoints.length<2)return;const[i,s]=this.initialWallPoints,n=i,o=this.calculateOutlinePoints(this.initialWallPoints);if(o.length<4)return;const a=o[Vt.BUTTON_INDICES.SCALE],l=K(s,a),c={x:t.x-l.x,y:t.y-l.y},d=K(n,c),u=Q(n,c),p=this.appService.metersToPixels(this.wallConfig.minWidth),f=this.getResolvedMaxWidth(),y=f!=null?this.appService.metersToPixels(f):void 0;let m;if(u<p)if(u===0)m={x:n.x+p,y:n.y};else{const x=gt(d);m={x:n.x+x.x*p,y:n.y+x.y*p}}else if(y!=null&&u>y){const x=gt(d);m={x:n.x+x.x*y,y:n.y+x.y*y}}else m=c;this.wallData.points=[n,m],this.drawVirtualWall(),this.updateControlButtonsPosition()}applyTranslation(t,i){this.wallData.points=this.initialWallPoints.map(s=>({x:s.x+t,y:s.y+i})),this.drawVirtualWall(),this.updateControlButtonsPosition()}drawVirtualWall(){this.updateWallLine(),this.updateLengthText(),this.updateOutlineComponents()}updateWallLine(){const{points:t}=this.wallData;t.length<2||(this.wallLine instanceof Ue?this.wallLine.updatePoints(t[0],t[1]):this.redrawSolidLine(),this.setupWallLineHitArea())}updateLengthText(){if(!this.lengthText)return;const t=this.calculateWallLengthInMeters(),i=this.formatLengthText(t);this.lengthText.updateText(i),this.updateLengthTextPosition()}updateLengthTextPosition(){if(!this.lengthText)return;const t=this.calculateTextPosition();this.lengthText.position.set(t.x,t.y);const i=this.calculateTextRotation();this.lengthText.rotation=i}updateOutlineComponents(){const t=this.calculateOutlinePoints();this.outlineBorder.updatePoints(t);const i=this.calculateMoveLinePoints(t);this.moveLine.updatePoints(i)}updateControlButtonsPosition(){if(!this.removeButton||!this.scaleButton||!this.moveButton)return;const t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:i,SCALE:s}=Vt.BUTTON_INDICES,n=this.calculateMoveButtonPosition();this.removeButton.position.set(t[i].x,t[i].y),this.scaleButton.position.set(t[s].x,t[s].y),this.moveButton.position.set(n.x,n.y)}updateEditState(){const t=this.isEditingEnabled();this.controlButtons.visible=t,this.outlineBorder.visible=t,this.moveLine.visible=t,this.lengthText&&(this.lengthText.visible=t),t&&(this.updateOutlineComponents(),this.updateControlButtonsPosition(),this.updateLengthTextPosition()),this.updateWallLineStyle(),this.setupWallLineInteraction(),this.zIndex=t?1e3:0}createSolidLine(t,i,s,n){const o=new H;o.eventMode="static";const a=this.appService.getApp().toFixedSize(s);return o.moveTo(t.x,t.y),o.lineTo(i.x,i.y),o.stroke({color:n,width:a}),o}updateWallLineStyle(){const t=this.isEditingEnabled(),{editing:i,normal:s,lineWidth:n,lineColor:o}=this.wallConfig,a=t?i:s;this.wallLine instanceof Ue!==a.isDashed?(this.removeChild(this.wallLine),this.wallLine.destroy(),this.createWallLine(!1),this.addChild(this.wallLine)):this.wallLine instanceof Ue?this.wallLine.updateStyle({color:o.toString(),width:n,dashArray:a.dashArray}):this.redrawSolidLine()}redrawSolidLine(){const t=this.appService;if(!this.wallLine||this.wallLine instanceof Ue)return;const{points:i}=this.wallData;if(i.length<2)return;const{lineWidth:s,lineColor:n}=this.wallConfig,o=t.getApp().toFixedSize(s);this.wallLine.clear(),this.wallLine.setStrokeStyle({color:n.toString(),width:o}).moveTo(i[0].x,i[0].y).lineTo(i[1].x,i[1].y).stroke()}setupWallLineInteraction(){var i;if(!this.wallLine)return;this.setupWallLineHitArea();const t=this.isEditingEnabled();(i=this.wallLineClickHandler)==null||i.destroy(),this.wallLineClickHandler=null,this.wallLine.off("pointerdown",this.handleWallLinePointerDown),t?this.wallLine.on("pointerdown",this.handleWallLinePointerDown):this.wallLineClickHandler=new vt(this.wallLine,{onClick:()=>{var s,n;this.appService.emitter.emit("suppressMapClick"),(n=(s=this.wallEvents)==null?void 0:s.onClick)==null||n.call(s,this.getWallData())},stopPropagation:!1})}setupDragEventListeners(){const{emitter:t}=this.appService;t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}startDragging(t){const i=this.appService;this.isDragging=!0;const s=this.parent.toLocal(t.global);this.dragStartPosition={x:s.x,y:s.y},this.initializeOperation(),i.getApp().requestRender("virtualwall-drag",!0),this.appService.emitter.emit("gestureHijackStart",t)}getDragStartPosition(){return this.dragStartPosition}setupWallLineHitArea(){if(!this.wallLine)return;const{points:t}=this.wallData;if(t.length<2)return;const{hitAreaThickness:i}=this.wallConfig,s=this.appService.getApp().toFixedSize(i),n=rc(t[0],t[1],s);if(n.length===0)return;const o=new Te(n);this.wallLine.hitArea=o}getWallData(){return{...this.wallData}}updateWallData(t){this.wallData={...t,points:this.validateAndCorrectWallLength(t.points)},this.drawVirtualWall(),this.updateControlButtonsPosition()}updateEditingState(){this.updateEditState()}refreshDisplay(){this.drawVirtualWall()}destroy(){var t,i,s,n,o,a,h,l,c;this.appService.emitter.off("antiScale",this.throttledUpdateOutline),this.appService.emitter.off("antiScale",this.throttledHandleScaleChange),this.appService.emitter.off("mapRotationUpdate",this.throttledUpdateOutline),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.wallLine&&this.wallLine.off("pointerdown",this.handleWallLinePointerDown),(t=this.wallLineClickHandler)==null||t.destroy(),this.wallLineClickHandler=null,(i=this.wallLine)==null||i.destroy(),(s=this.lengthText)==null||s.destroy(),(n=this.outlineBorder)==null||n.destroy(),(o=this.moveLine)==null||o.destroy(),(a=this.controlButtons)==null||a.destroy(),(h=this.removeButton)==null||h.destroy(),(l=this.scaleButton)==null||l.destroy(),(c=this.moveButton)==null||c.destroy(),this.removeButton=null,this.scaleButton=null,this.moveButton=null,super.destroy()}};g(Vt,"BUTTON_INDICES",{REMOVE:0,SCALE:2,MOVE:3});let ar=Vt;class Yr extends L{constructor(t){super();g(this,"spotData");g(this,"spotConfig");g(this,"controlsConfig");g(this,"spotEvents");g(this,"appService");g(this,"controlFill");g(this,"spotBorder");g(this,"centerIcon");g(this,"sizeText");g(this,"clickHandler",null);g(this,"initialSpotPoint",null);g(this,"dragStartMousePosition",null);g(this,"throttledUpdateScale");g(this,"unsubscribeMapRotation",null);g(this,"handleDragStart",t=>{this.isEditingEnabled()&&(this.initialSpotPoint={...this.spotData.point},this.dragStartMousePosition=this.parent.toLocal(t.global),this.appService.getApp().requestRender("spot-drag",!0))});g(this,"handleDragMove",t=>{if(!this.isEditingEnabled()||!this.initialSpotPoint||!this.dragStartMousePosition||!this.controlFill)return;const i=this.parent.toLocal(t.global),s=i.x-this.dragStartMousePosition.x,n=i.y-this.dragStartMousePosition.y;this.applyTranslation(s,n)});g(this,"handleDragEnd",()=>{var t,i;this.initialSpotPoint=null,this.dragStartMousePosition=null,this.appService.getApp().stopRender("spot-drag"),(i=(t=this.spotEvents).onUpdate)==null||i.call(t,this.getSpotData())});const{appService:i,spotData:s,events:n={}}=t;this.appService=i,this.spotData=s,this.spotEvents=n,this.controlsConfig=this.appService.controlsConfig,this.spotConfig=this.appService.controlsConfig.spot,this.position.set(s.point.x,s.point.y),this.throttledUpdateScale=Ct(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}updateScale(){this.isEditingEnabled()&&this.sizeText&&this.updateSizeTextPosition()}isEditingEnabled(){return this.appService.runtimeSnapshot.editingSpotIds.includes(this.spotData.id)}shouldShowIcon(){return(this.isEditingEnabled()?this.spotConfig.editing:this.spotConfig.normal).showIcon}calculateRectanglePoints(){const{size:t}=this.spotConfig;if(t===0)return[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];const s=this.appService.metersToPixels(t)/2;return[{x:-s,y:-s},{x:s,y:-s},{x:s,y:s},{x:-s,y:s}]}initializeComponents(){const t=this.calculateRectanglePoints();this.spotConfig.size>0&&(this.controlFill=this.createControlFill(t),this.addChild(this.controlFill),this.spotBorder=this.createBorder(t),this.addChild(this.spotBorder)),this.centerIcon=this.createCenterIcon(),this.addChild(this.centerIcon),this.spotConfig.showText&&(this.sizeText=this.createSizeText(),this.addChild(this.sizeText)),this.drawSpot()}createControlFill(t){const i=this.isEditingEnabled();return new Ur(this.appService,{points:t,fillColor:this.spotConfig.fillColor,enableInteraction:i,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(t){const s=this.isEditingEnabled()?this.spotConfig.editing:this.spotConfig.normal;return new Nt(this.appService,{points:t,closePath:!0,style:{color:this.spotConfig.strokeColor,width:this.spotConfig.strokeWidth,isDashed:s.isDashed,dashArray:s.dashArray}})}createCenterIcon(){const t=new Xt(this.appService);return this.loadIconTexture(t),t.position.set(0,0),t.eventMode="static",this.setupIconDrag(t),t.visible=!1,t}async loadIconTexture(t){const{iconSize:i,iconSizeFixed:s}=this.spotConfig;await t.loadTextureAndSetSize("spotIcon",{width:i,height:i,sizeFixed:s}),this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation||(this.unsubscribeMapRotation=W(this.appService.runtime,"mapRotation",n=>{this.applyAntiRotation(n)})),t.visible=this.shouldShowIcon()}applyAntiRotation(t){const i=-t*Math.PI/180;this.rotation=i}setupIconDrag(t){let i=null,s=!1;const n=h=>{if(!s||!this.initialSpotPoint||!i)return;const l=this.parent.toLocal(h.global),c=l.x-i.x,d=l.y-i.y;this.applyTranslation(c,d)},o=()=>{s&&(s=!1,this.initialSpotPoint=null,i=null,this.appService.getApp().stopRender("spot-drag"),this.appService.emitter.off("gestureHijackPointerMove",n),this.appService.emitter.off("gestureHijackPointerUp",a),this.appService.emitter.off("gestureHijackCancel",o))},a=()=>{var h,l;s&&(s=!1,this.initialSpotPoint=null,i=null,this.appService.getApp().stopRender("spot-drag"),(l=(h=this.spotEvents).onUpdate)==null||l.call(h,this.getSpotData()),this.appService.emitter.off("gestureHijackPointerMove",n),this.appService.emitter.off("gestureHijackPointerUp",a),this.appService.emitter.off("gestureHijackCancel",o))};t.on("pointerdown",h=>{this.isEditingEnabled()&&(h.stopPropagation(),s=!0,this.initialSpotPoint={...this.spotData.point},i=this.parent.toLocal(h.global),this.appService.getApp().requestRender("spot-drag",!0),this.appService.emitter.emit("gestureHijackStart",h),this.appService.emitter.on("gestureHijackPointerMove",n),this.appService.emitter.on("gestureHijackPointerUp",a),this.appService.emitter.on("gestureHijackCancel",o))})}createSizeText(){const t=this.calculateSpotSizeText(),i=new ji(this.appService,{text:t,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.spotConfig.textColor,align:"center"}});i.anchor.set(.5);const s=this.calculateSizeTextPosition();return i.position.set(s.x,s.y),i.eventMode="none",i}calculateSpotSizeText(){const{size:t}=this.spotConfig,i=this.appService.metersToDisplayUnit(t),s=this.appService.runtimeSnapshot.unitLabel;return`${i.toFixed(1)}${s}*${i.toFixed(1)}${s}`}calculateSizeTextPosition(){const t=this.calculateRectanglePoints();if(t.length<4)return{x:0,y:0};const[i,s,n,o]=t,{textPosition:a,textOffset:h}=this.spotConfig,l=this.appService.getApp().toFixedSize(h);let c,d;switch(a){case"top":{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:c.x,y:c.y+l};break}case"right":{c={x:(s.x+n.x)/2,y:(s.y+n.y)/2},d={x:c.x+l,y:c.y};break}case"bottom":{c={x:(o.x+n.x)/2,y:(o.y+n.y)/2},d={x:c.x,y:c.y+l};break}case"left":{c={x:(i.x+o.x)/2,y:(i.y+o.y)/2},d={x:c.x-l,y:c.y};break}default:{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:c.x,y:c.y+l};break}}return d}applyTranslation(t,i){this.initialSpotPoint&&(this.spotData.point={x:this.initialSpotPoint.x+t,y:this.initialSpotPoint.y+i},this.drawSpot())}setupClickHandler(){const t=this.spotConfig.size>0?this:this.centerIcon;this.clickHandler=new vt(t,{onClick:()=>{var i,s;this.isEditingEnabled()||(this.appService.emitter.emit("suppressMapClick"),(s=(i=this.spotEvents)==null?void 0:i.onClick)==null||s.call(i,this.getSpotData()))},stopPropagation:!1}),this.eventMode="static"}drawSpot(){const t=this.calculateRectanglePoints();this.position.set(this.spotData.point.x,this.spotData.point.y),this.spotConfig.size>0&&(this.controlFill&&this.controlFill.updatePoints(t),this.spotBorder&&this.spotBorder.updatePoints(t)),this.spotConfig.showText&&this.sizeText&&this.updateSizeText()}updateSizeText(){if(!this.sizeText)return;const t=this.calculateSpotSizeText();this.sizeText.updateText(t),this.updateSizeTextPosition()}updateSizeTextPosition(){if(!this.sizeText)return;const t=this.calculateSizeTextPosition();this.sizeText.position.set(t.x,t.y)}updateEditState(){const t=this.isEditingEnabled(),i=t?this.spotConfig.editing:this.spotConfig.normal;this.sizeText&&(this.sizeText.visible=t&&this.spotConfig.showText),this.centerIcon&&(this.centerIcon.visible=this.shouldShowIcon()),this.controlFill&&(this.controlFill.setInteractionEnabled(t),this.controlFill.visible=i.showFrame),this.spotBorder&&(this.spotBorder.updateStyle({isDashed:i.isDashed,dashArray:i.dashArray}),this.spotBorder.visible=i.showFrame),this.zIndex=t?1e3:0}updateSpotData(t){this.spotData={...t},this.drawSpot(),this.updateEditState()}getSpotData(){return{...this.spotData}}refreshDisplay(){this.drawSpot()}destroy(){var t,i,s,n,o;this.appService.emitter.off("antiScale",this.throttledUpdateScale),this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),(t=this.clickHandler)==null||t.destroy(),this.clickHandler=null,this.centerIcon&&this.spotConfig.size===0&&this.centerIcon.removeAllListeners(),(i=this.controlFill)==null||i.destroy(),(s=this.spotBorder)==null||s.destroy(),(n=this.centerIcon)==null||n.destroy(),(o=this.sizeText)==null||o.destroy(),super.destroy()}static create(t,i){return new Yr({appService:t,spotData:i,events:{onUpdate:s=>{var n,o;(o=(n=t.events)==null?void 0:n.onUpdateSpot)==null||o.call(n,s)},onClick:s=>{var n,o;(o=(n=t.events)==null?void 0:n.onClickSpot)==null||o.call(n,s)}}})}}class nS extends xc{constructor(t){const{appService:i,wayPointData:s,order:n,events:o={}}=t;super(i);g(this,"wayPointData");g(this,"order");g(this,"wayPointConfig");g(this,"controlsConfig");g(this,"wayPointEvents");g(this,"icon");g(this,"orderContainer");g(this,"orderBackground");g(this,"orderText");g(this,"clickHandler",null);g(this,"initialWayPointPoint",null);g(this,"unsubscribeMapRotation",null);this.wayPointData=s,this.order=n,this.wayPointEvents=o,this.controlsConfig=this.appService.controlsConfig,this.wayPointConfig=this.appService.controlsConfig.wayPoint,this.position.set(s.point.x,s.point.y),this.initializeComponents(),this.updateEditState(),this.setupClickHandler()}isEditingEnabled(){return(this.appService.runtimeSnapshot.editingWayPointIds||[]).includes(this.wayPointData.id)}initializeComponents(){this.icon=this.createIcon(),this.addChild(this.icon),this.wayPointConfig.showOrder&&(this.createOrderContainer(),this.addChild(this.orderContainer))}createIcon(){const t=new Xt(this.appService);return this.loadIconTexture(t),t.position.set(0,0),t.anchor.set(.5,1),t.eventMode="static",this.setupIconDrag(t),t}async loadIconTexture(t){const i=this.isEditingEnabled(),s=i?this.wayPointConfig.editing:this.wayPointConfig.normal,{iconSize:n}=s,o=i?"wayPointActive":"wayPoint";await t.loadTextureAndSetSize(o,{width:n,height:n,sizeFixed:!1}),this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation||(this.unsubscribeMapRotation=W(this.appService.runtime,"mapRotation",a=>{this.applyAntiRotation(a)})),t.visible=!0,this.orderContainer&&this.updateOrderPosition()}applyAntiRotation(t){const i=-t*Math.PI/180;this.rotation=i}createOrderContainer(){const i=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal,{orderContainer:s,orderText:n}=i;this.orderContainer=new L,this.orderBackground=new H,this.orderText=new Bs({text:this.order.toString(),style:new ce({fontSize:n.fontSize,fontFamily:n.fontFamily,fontWeight:n.fontWeight,fill:n.color,align:"center",trim:!0})}),this.orderBackground.clear(),this.orderBackground.circle(0,0,s.size/2),this.orderBackground.fill({color:s.backgroundColor}),this.orderText.anchor.set(.5,.5),this.orderContainer.addChild(this.orderBackground),this.orderContainer.addChild(this.orderText),this.orderContainer.eventMode="none",this.orderContainer.visible=this.wayPointConfig.showOrder,this.updateOrderPosition()}updateOrderPosition(){if(!this.orderContainer)return;const i=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal,{offsetX:s,offsetY:n}=i.orderContainer;this.orderContainer.position.set(s,-n)}setupIconDrag(t){let i=null,s=null,n=!1;const o=h=>{if(!(!n||!i||!s)&&this.parent){const l=this.parent.toLocal(h.global),c=l.x-i.x,d=l.y-i.y,u={x:s.x+c,y:s.y+d};this.wayPointData.point=u,this.position.set(u.x,u.y),this.orderContainer&&this.updateOrderPosition()}},a=()=>{var h,l;n&&(n=!1,i=null,s=null,(l=(h=this.wayPointEvents).onUpdate)==null||l.call(h,this.wayPointData),this.appService.emitter.off("gestureHijackPointerMove",o),this.appService.emitter.off("gestureHijackPointerUp",a),this.appService.emitter.emit("gestureHijackCancel"))};t.on("pointerdown",h=>{this.isEditingEnabled()&&(h.stopPropagation(),s={...this.wayPointData.point},this.parent&&(i=this.parent.toLocal(h.global)),n=!0,this.parent&&(this.appService.emitter.emit("gestureHijackStart",h),this.appService.emitter.on("gestureHijackPointerMove",o),this.appService.emitter.on("gestureHijackPointerUp",a)))})}setupClickHandler(){this.clickHandler=new vt(this.icon,{stopPropagation:!1,onClick:()=>{var t,i;this.appService.emitter.emit("suppressMapClick"),(i=(t=this.wayPointEvents).onClick)==null||i.call(t,this.wayPointData)}})}updateWayPoint(t){this.wayPointData=t,this.drawWayPoint()}updateOrder(t){this.order=t,this.orderText&&(this.orderText.text=t.toString())}getWayPointData(){return{...this.wayPointData}}drawWayPoint(){this.position.set(this.wayPointData.point.x,this.wayPointData.point.y),this.orderContainer&&this.updateOrderPosition()}updateEditState(){if(this.loadIconTexture(this.icon),this.orderContainer&&this.orderText&&this.orderBackground){const i=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal;this.orderText.style=new ce({fontSize:i.orderText.fontSize,fontFamily:i.orderText.fontFamily,fontWeight:i.orderText.fontWeight,fill:i.orderText.color,align:"center",trim:!0});const{size:s,backgroundColor:n}=i.orderContainer;this.orderBackground.clear(),this.orderBackground.circle(0,0,s/2).fill(n),this.orderContainer.visible=this.wayPointConfig.showOrder,this.updateOrderPosition()}}onEditStateChange(){this.updateEditState()}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.icon&&this.icon.removeAllListeners(),super.destroy()}}class Ka extends H{constructor(t,i){super();g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"initialPosition");g(this,"handleDragPointerMove",t=>{var a,h;if(!this.isDragging||!this.dragStartPosition)return;const i=this.parent.toLocal(t.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y,o={x:this.initialPosition.x+s,y:this.initialPosition.y+n};this.position.set(o.x,o.y),(h=(a=this.options).onDragMove)==null||h.call(a,o)});g(this,"handleDragPointerUp",()=>{var i,s;if(!this.isDragging)return;const t=this.appService;this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("endpoint-drag"),(s=(i=this.options).onDragEnd)==null||s.call(i)});g(this,"handleDragCancel",()=>{var i,s;if(!this.isDragging)return;const t=this.appService;this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("endpoint-drag"),(s=(i=this.options).onDragEnd)==null||s.call(i)});this.appService=t,this.options=i,this.initialPosition={...i.position},this.position.set(i.position.x,i.position.y),this.eventMode="static",this.cursor="pointer",this.setupEvents(),this.draw(),this.setupDragEventListeners()}draw(){const t=this.appService,{config:i}=this.options,s=t.getApp().toFixedSize(i.endPointSize),n=t.getApp().toFixedSize(i.endPointStrokeWidth);this.clear(),this.circle(0,0,s/2),this.fill({color:i.endPointColor}),this.stroke({color:i.endPointStrokeColor,width:n}),this.setupHitArea()}setupHitArea(){const t=this.appService,{config:i}=this.options,s=Math.max(i.endPointSize/2+10,20),n=t.getApp().toFixedSize(s);this.hitArea=new Rs(0,0,n)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}setupDragEventListeners(){const{emitter:t}=this.appService;t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handlePointerDown(t){t.stopPropagation(),this.startDragging(t)}startDragging(t){var s,n;const i=this.appService;this.isDragging=!0,this.dragStartPosition=this.parent.toLocal(t.global),this.initialPosition={x:this.x,y:this.y},(n=(s=this.options).onDragStart)==null||n.call(s),i.getApp().requestRender("endpoint-drag",!0),this.appService.emitter.emit("gestureHijackStart",t)}updatePosition(t){this.position.set(t.x,t.y),this.initialPosition={...t}}getPosition(){return{x:this.x,y:this.y}}redraw(){this.draw()}destroy(){this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.cleanupDragEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class rS extends L{constructor(t){super();g(this,"endPoints");g(this,"dividerConfig");g(this,"dividerEvents");g(this,"roomId");g(this,"appService");g(this,"roomGeometry",null);g(this,"dashLine");g(this,"solidLine",null);g(this,"startEndPoint");g(this,"endEndPoint");g(this,"solidLinePoints",null);g(this,"initialDividerPoints",[]);g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"throttledHandleScaleChange");g(this,"handleEndPointDragStart",()=>{this.initialDividerPoints=this.endPoints.map(t=>({...t})),this.clearSolidLine(),this.appService.getApp().requestRender("divider-endpoint-drag",!0)});g(this,"handleEndPointDragMove",(t,i)=>{this.initialDividerPoints.length!==0&&(this.endPoints[t]=i,this.updateDashLine(),this.updateSolidLine(),this.setupDashLineHitArea())});g(this,"handleEndPointDragEnd",()=>{var t,i;this.initialDividerPoints=[],this.appService.getApp().stopRender("divider-endpoint-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),(i=(t=this.dividerEvents).onUpdate)==null||i.call(t,this.getDividerEndPoints())});g(this,"handleDashLinePointerDown",t=>{t.stopPropagation(),this.startDragging(t)});g(this,"handleDragPointerMove",t=>{if(!this.isDragging||!this.dragStartPosition||this.initialDividerPoints.length===0)return;const i=this.parent.toLocal(t.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;this.endPoints=this.initialDividerPoints.map(o=>({x:o.x+s,y:o.y+n})),this.updateAllComponents()});g(this,"handleDragPointerUp",()=>{var t,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],this.appService.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),(i=(t=this.dividerEvents).onUpdate)==null||i.call(t,this.getDividerEndPoints()))});g(this,"handleDragCancel",()=>{var t,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],this.appService.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),(i=(t=this.dividerEvents).onUpdate)==null||i.call(t,this.getDividerEndPoints()))});g(this,"handleScaleChange",()=>{var t,i;(t=this.startEndPoint)==null||t.redraw(),(i=this.endEndPoint)==null||i.redraw(),this.updateSolidLine(),this.setupDashLineHitArea()});const{appService:i,endPoints:s,roomId:n,events:o={}}=t;this.appService=i,this.dividerEvents=o,this.roomId=n,this.dividerConfig=this.appService.dividerConfig,this.roomGeometry=this.appService.mapManager.getRoomById(this.roomId)||null,s?this.endPoints=this.validateDividerPoints(s):this.endPoints=this.createDefaultdividerPoints(),this.throttledHandleScaleChange=Ct(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.calculateAndCreateSolidLine(),this.registerScaleListener(),this.setupDragEventListeners()}validateDividerPoints(t){if(t.length>=2)return t.slice(0,2);const i=t[0]||{x:0,y:0},s={x:i.x+50,y:i.y};return[i,s]}createDefaultdividerPoints(){if(!this.roomGeometry)return w.warn("Room geometry not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const t=this.appService.getApp().mapState;if(!t)return w.warn("Map state not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const{boundingBox:i}=this.roomGeometry,s=this.appService.getApp().toFixedSize(this.dividerConfig.defaultExtension),n=this.dividerConfig.defaultDirection,o=i.x+i.width/2,a=i.y+i.height/2,h=n==="horizontal"?i.width+2*s:i.height+2*s;return Ay(o,a,h,n).map(c=>({x:c.x-t.origin.x,y:c.y-t.origin.y}))}initializeComponents(){this.createDashLine(),this.addChild(this.dashLine),this.createEndPoints(),this.addChild(this.startEndPoint),this.addChild(this.endEndPoint),this.setupDashLineInteraction()}createDashLine(){const t=this.endPoints;if(t.length<2)return;const{dashLineWidth:i,dashLineDashArray:s,lineColor:n}=this.dividerConfig;this.dashLine=new Ue(this.appService,{start:t[0],end:t[1],style:{color:n.toString(),width:i,dashArray:s}})}createEndPoints(){const t=this.endPoints;this.startEndPoint=new Ka(this.appService,{position:t[0],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:i=>this.handleEndPointDragMove(0,i),onDragEnd:this.handleEndPointDragEnd}),this.endEndPoint=new Ka(this.appService,{position:t[1],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:i=>this.handleEndPointDragMove(1,i),onDragEnd:this.handleEndPointDragEnd})}setupDashLineInteraction(){this.dashLine&&(this.setupDashLineHitArea(),this.dashLine.off("pointerdown",this.handleDashLinePointerDown),this.dashLine.on("pointerdown",this.handleDashLinePointerDown))}setupDashLineHitArea(){if(!this.dashLine)return;const t=this.endPoints;if(t.length<2)return;const{hitAreaThickness:i}=this.dividerConfig,s=this.appService.getApp().toFixedSize(i),n=rc(t[0],t[1],s);if(n.length===0)return;const o=new Te(n);this.dashLine.hitArea=o}startDragging(t){this.isDragging=!0;const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},this.initialDividerPoints=this.endPoints.map(s=>({...s})),this.clearSolidLine(),this.appService.getApp().requestRender("divider-drag",!0),this.appService.emitter.emit("gestureHijackStart",t)}setupDragEventListeners(){const{emitter:t}=this.appService;t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}updateAllComponents(){this.updateDashLine(),this.updateSolidLine(),this.updateEndPoints(),this.setupDashLineHitArea()}updateDashLine(){const t=this.endPoints;t.length<2||!this.dashLine||this.dashLine.updatePoints(t[0],t[1])}updateSolidLine(){if(!this.solidLine||!this.solidLinePoints)return;const{solidLineWidth:t,lineColor:i}=this.dividerConfig,s=this.appService.getApp().toFixedSize(t);this.solidLine.clear(),this.solidLine.setStrokeStyle({color:i.toString(),width:s}).moveTo(this.solidLinePoints[0].x,this.solidLinePoints[0].y).lineTo(this.solidLinePoints[1].x,this.solidLinePoints[1].y).stroke()}updateEndPoints(){const t=this.endPoints;this.startEndPoint&&this.startEndPoint.updatePosition(t[0]),this.endEndPoint&&this.endEndPoint.updatePosition(t[1])}registerScaleListener(){const{emitter:t}=this.appService;t.on("antiScale",this.throttledHandleScaleChange)}getDividerEndPoints(){return[...this.endPoints]}getEffectiveDividerPoints(){return this.solidLinePoints?[...this.solidLinePoints]:null}calculateAndCreateSolidLine(){if(this.clearSolidLine(),typeof this.roomId!="number"||!this.getRoomGraphics())return;const i=this.calculateLineRoomIntersection();i&&i.length>=2&&(this.solidLinePoints=[i[0],i[i.length-1]],this.createSolidLine())}getRoomGraphics(){const t=this.appService.mapManager.roomFill;return!t||typeof this.roomId!="number"?null:t.getRoomGraphicsMap().get(this.roomId)||null}calculateLineRoomIntersection(){const t=this.endPoints;if(t.length<2||typeof this.roomId!="number")return null;const[i,s]=t,n=this.isPointInRoomFill(i),o=this.isPointInRoomFill(s);if(n||o)return null;const a=dy(i,s),h=[];for(const p of a)this.isPointInRoomFill(p)&&h.push(p);if(h.length===0)return null;const l=h[0],c=h[h.length-1];return Q(l,c)<3?null:Py(l,c,.5)}isPointInRoomFill(t){if(typeof this.roomId!="number")return!1;const i=this.appService.getApp().mapState;if(!i)return!1;const s={x:t.x+i.origin.x,y:t.y+i.origin.y};return i.mapType==="raster"?this.isPointInRasterRoomFill(s):this.isPointInStructuredRoomFill(s)}isPointInRasterRoomFill(t){t.x-=.5,t.y-=.5;const i=this.appService.getApp().mapState,s=this.appService.mapManager.roomFill;if(!i||!s)return!1;const n=s.getRasterRoomData(this.roomId);if(!n)return!1;const o=s.getMapWidth();if(o===0)return!1;const a=Math.round(t.x),h=Math.round(t.y);if(a<0||h<0||a>=o)return!1;const l=h*o+a;for(let c=0;c<n.pixelIndices.length;c++)if(n.pixelIndices[c]===l)return!0;return!1}isPointInStructuredRoomFill(t){const i={x:Math.round(t.x),y:Math.round(t.y)},s=this.appService.getApp().mapState,n=this.appService.mapManager.getRoomById(this.roomId);return!s||!n||!n.outlinePoints?!1:Et(i,n.outlinePoints,!0)}isDividerCompletelyOutOfRoom(){if(!this.roomGeometry)return!1;const{boundingBox:t}=this.roomGeometry,i=this.endPoints;if(i.length<2)return!1;const s=this.appService.getApp().mapState;if(!s)return!1;const n={x:i[0].x+s.origin.x,y:i[0].y+s.origin.y},o={x:i[1].x+s.origin.x,y:i[1].y+s.origin.y};return!Cy(n,o,t.x,t.y,t.width,t.height)}checkAndResetIfOutOfRoom(){const{resetDividerWhenOutOfRoom:t}=this.appService.dividerConfig;t&&this.isDividerCompletelyOutOfRoom()&&this.resetToDefaultState()}resetToDefaultState(){var t,i;this.endPoints=this.createDefaultdividerPoints(),this.calculateAndCreateSolidLine(),this.updateComponents(),(i=(t=this.dividerEvents).onUpdate)==null||i.call(t,this.endPoints)}updateComponents(){const t=this.endPoints;t.length>=2&&(this.dashLine.updatePoints(t[0],t[1]),this.startEndPoint.position.set(t[0].x,t[0].y),this.endEndPoint.position.set(t[1].x,t[1].y),this.setupDashLineInteraction())}createSolidLine(){if(!this.solidLinePoints)return;const{solidLineWidth:t,lineColor:i}=this.dividerConfig;this.solidLine=new H,this.solidLine.eventMode="none";const s=this.appService.getApp().toFixedSize(t);this.solidLine.setStrokeStyle({color:i.toString(),width:s}).moveTo(this.solidLinePoints[0].x,this.solidLinePoints[0].y).lineTo(this.solidLinePoints[1].x,this.solidLinePoints[1].y).stroke(),this.addChildAt(this.solidLine,0)}clearSolidLine(){this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy(),this.solidLine=null),this.solidLinePoints=null}updatedividerPoints(t){this.endPoints=this.validateDividerPoints(t),this.updateAllComponents(),this.calculateAndCreateSolidLine()}destroy(){var t,i,s;this.appService.emitter.off("antiScale",this.throttledHandleScaleChange),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[]),this.dashLine&&this.dashLine.off("pointerdown",this.handleDashLinePointerDown),this.clearSolidLine(),(t=this.dashLine)==null||t.destroy(),(i=this.startEndPoint)==null||i.destroy(),(s=this.endEndPoint)==null||s.destroy(),super.destroy()}}const hr=["forbiddenSweepZone","forbiddenMopZone","cleanZone","virtualWall","spot","wayPoint","divider"];function oS(r){if(!r||r.length===0)return[...hr];const e=new Set,t=[];for(const i of r)e.has(i)||(e.add(i),t.push(i));for(const i of hr)e.has(i)||t.push(i);return t}class aS{constructor(e){g(this,"zoneMaps",new Map);g(this,"virtualWallMap",new Map);g(this,"spotMap",new Map);g(this,"wayPointMap",new Map);g(this,"divider",null);g(this,"controlContainers",new Map);g(this,"unsubscribeFns",[]);g(this,"builtinZoneFactories",{forbiddenSweepZone:e=>Vr.create(this.appService,e),forbiddenMopZone:e=>Nr.create(this.appService,e),cleanZone:e=>jr.create(this.appService,e)});this.appService=e,this.initializeControlContainers();const t=W(e.runtime,"editingForbiddenSweepZoneIds",u=>{w.log(`[runtime] editingForbiddenSweepZoneIds: ${u}`);const p=this.zoneMaps.get("forbiddenSweepZone");p&&this.updateZonesEditState(p)}),i=W(e.runtime,"editingForbiddenMopZoneIds",u=>{w.log(`[runtime] editingForbiddenMopZoneIds: ${u}`);const p=this.zoneMaps.get("forbiddenMopZone");p&&this.updateZonesEditState(p)}),s=W(e.runtime,"editingCleanZoneIds",u=>{w.log(`[runtime] editingCleanZoneIds: ${u}`);const p=this.zoneMaps.get("cleanZone");p&&this.updateZonesEditState(p)}),n=W(e.runtime,"editingCustomZoneIds",u=>{w.log(`[runtime] editingCustomZoneIds: ${JSON.stringify(u??{})}`);for(const[p,f]of this.zoneMaps)Ne(p)||f.size&&this.updateZonesEditState(f)}),o=W(e.runtime,"editingVirtualWallIds",u=>{w.log(`[runtime] editingVirtualWallIds: ${u}`),this.updateVirtualWallsEditState(this.virtualWallMap)}),a=W(e.runtime,"editingSpotIds",u=>{w.log(`[runtime] editingSpotIds: ${u}`),this.updateSpotsEditState(this.spotMap)}),h=W(e.runtime,"editingWayPointIds",u=>{w.log(`[runtime] editingWayPointIds: ${u}`),this.updateWayPointsEditState(this.wayPointMap)}),l=W(e.runtime,"dividingRoomId",u=>{w.log(`[runtime] dividingRoomId: ${u}`),this.handleDividingRoomIdChange(u)}),c=W(e.runtime,"unit",u=>{w.log(`[runtime] unit changed: ${u}`),this.handleUnitChange()}),d=W(e.runtime,"unitLabel",u=>{w.log(`[runtime] unitLabel changed: ${u}`),this.handleUnitChange()});this.unsubscribeFns.push(t,i,s,n,o,a,h,l,c,d)}updateRenderOrder(){this.applyRenderOrder()}initializeControlContainers(){const e=this.appService.appContainer.getLayer(Ke);if(!e){w.warn("[ControlsManager] LAYER_CONTROLS not found during init");return}for(const t of hr){const i=new L;i.label=`controls:${t}`,this.controlContainers.set(t,i),e.addChild(i)}this.applyRenderOrder()}applyRenderOrder(){const e=this.appService.appContainer.getLayer(Ke);if(!e)return;oS(this.appService.getConfig().controls.renderOrder).forEach((i,s)=>{const n=this.controlContainers.get(i);n&&(n.zIndex=s)}),e.sortableChildren=!0,e.sortChildren()}addToControlLayer(e,t){let i=this.controlContainers.get(e);if(!i){const s=this.appService.appContainer.getLayer(Ke);if(!s){w.warn("[ControlsManager] LAYER_CONTROLS not found");return}i=new L,i.label=`controls:${e}`,this.controlContainers.set(e,i),s.addChild(i),this.applyRenderOrder()}i.addChild(t)}drawForbiddenSweepZones(e){this.drawZonesByType("forbiddenSweepZone",e)}getForbiddenSweepZones(){return this.getZonesDataByType("forbiddenSweepZone")}clearAllForbiddenSweepZones(){this.clearAllZonesByType("forbiddenSweepZone")}drawForbiddenMopZones(e){this.drawZonesByType("forbiddenMopZone",e)}getForbiddenMopZones(){return this.getZonesDataByType("forbiddenMopZone")}clearAllForbiddenMopZones(){this.clearAllZonesByType("forbiddenMopZone")}drawCleanZones(e){this.drawZonesByType("cleanZone",e)}getCleanZones(){return this.getZonesDataByType("cleanZone")}clearAllCleanZones(){this.clearAllZonesByType("cleanZone")}drawVirtualWalls(e){var n;const t=this.appService,i=this.virtualWallMap,s=new Set(e.map(o=>o.id));for(const[o,a]of i)s.has(o)||((n=a.parent)==null||n.removeChild(a),a.destroy(),i.delete(o));e.forEach(o=>{const a=i.get(o.id);if(a)this.isWallDataEqual(a.getWallData(),o)||a.updateWallData(o);else{const h=new ar({appService:t,wallData:o,events:{onRemove:l=>{var c,d;(d=(c=t.events)==null?void 0:c.onRemoveVirtualWall)==null||d.call(c,l)},onUpdate:l=>{var c,d;(d=(c=t.events)==null?void 0:c.onUpdateVirtualWall)==null||d.call(c,l)},onClick:l=>{var c,d;(d=(c=t.events)==null?void 0:c.onClickVirtualWall)==null||d.call(c,l)}}});i.set(o.id,h),this.addToControlLayer("virtualWall",h)}})}getVirtualWalls(){return this.getWallsData(this.virtualWallMap)}clearAllVirtualWalls(){this.clearAllWalls(this.virtualWallMap)}drawSpots(e){const t=this.spotMap;if(!e||e.length===0){this.clearAllSpotsInternal(t);return}const i=new Set(t.keys()),s=new Set(e.map(n=>n.id));for(const n of i)s.has(n)||this.removeSpot(n,t);e.forEach(n=>{const o=t.get(n.id);o?this.isSpotDataEqual(o.getSpotData(),n)||o.updateSpotData(n):this.addNewSpot(n,t)})}getSpots(){return this.getSpotsData(this.spotMap)}clearAllSpots(){this.clearAllSpotsInternal(this.spotMap)}getZoneMap(e){let t=this.zoneMaps.get(e);return t||(t=new Map,this.zoneMaps.set(e,t)),t}resolveZoneFactory(e){var s;const t=this.builtinZoneFactories[e];return t||((s=this.appService.getConfig().customZoneTypes)!=null&&s[e]?n=>new oi({appService:this.appService,zoneData:n,zoneType:e,events:{onRemove:o=>{var a,h;return(h=(a=this.appService.events)==null?void 0:a.onRemoveCustomZone)==null?void 0:h.call(a,e,o)},onUpdate:o=>{var a,h;return(h=(a=this.appService.events)==null?void 0:a.onUpdateCustomZone)==null?void 0:h.call(a,e,o)},onClick:o=>{var a,h;return(h=(a=this.appService.events)==null?void 0:a.onClickCustomZone)==null?void 0:h.call(a,e,o)}}}):null)}drawCustomZones(e,t){this.drawZonesByType(e,t)}getCustomZones(e){return this.getZonesDataByType(e)}clearCustomZones(e){this.clearAllZonesByType(e)}drawZonesByType(e,t){const i=this.resolveZoneFactory(e);if(!i){w.warn(`[ControlsManager] Unknown zone type: ${e}`);return}const s=this.getZoneMap(e);this.drawZonesImpl(t,s,i,e)}getZonesDataByType(e){const t=this.zoneMaps.get(e);return t?this.getZonesData(t):[]}clearAllZonesByType(e){const t=this.zoneMaps.get(e);t&&this.clearAllZones(t)}drawZonesImpl(e,t,i,s){if(!e||e.length===0){this.clearAllZones(t);return}const n=new Set(t.keys()),o=new Set(e.map(a=>a.id));for(const a of n)o.has(a)||this.removeZone(a,t);e.forEach(a=>{const h=t.get(a.id);h?this.isZoneDataEqual(h.getZoneData(),a)||h.updateZoneData(a):this.addNewZone(a,t,i,s)})}addNewZone(e,t,i,s){const n=i(e);t.set(e.id,n),this.addToControlLayer(s,n)}removeZone(e,t){var s;const i=t.get(e);i&&((s=i.parent)==null||s.removeChild(i),i.destroy(),t.delete(e))}getZonesData(e){const t=[];return e.forEach(i=>{t.push(i.getZoneData())}),t}clearAllZones(e){e.forEach((t,i)=>{var n;const s=e.get(i);s&&((n=s.parent)==null||n.removeChild(s),s.destroy())}),e.clear()}updateZonesEditState(e){e.forEach(t=>{t.updateEditState()})}updateVirtualWallsEditState(e){e.forEach(t=>{t.updateEditingState()})}isZoneDataEqual(e,t){if(e.id!==t.id||e.points.length!==t.points.length)return!1;for(let i=0;i<e.points.length;i++){const s=e.points[i],n=t.points[i];if(Math.abs(s.x-n.x)>.1||Math.abs(s.y-n.y)>.1)return!1}return!0}getWallsData(e){return Array.from(e.values()).map(t=>t.getWallData())}clearAllWalls(e){for(const t of e.values())t.destroy();e.clear()}isWallDataEqual(e,t){if(e.id!==t.id||e.points.length!==t.points.length)return!1;for(let i=0;i<e.points.length;i++){const s=e.points[i],n=t.points[i];if(Math.abs(s.x-n.x)>.1||Math.abs(s.y-n.y)>.1)return!1}return!0}addNewSpot(e,t){const i=Yr.create(this.appService,e);t.set(e.id,i),this.addToControlLayer("spot",i)}removeSpot(e,t){var s;const i=t.get(e);i&&((s=i.parent)==null||s.removeChild(i),i.destroy(),t.delete(e))}getSpotsData(e){const t=[];return e.forEach(i=>{t.push(i.getSpotData())}),t}clearAllSpotsInternal(e){e.forEach((t,i)=>{var n;const s=e.get(i);s&&((n=s.parent)==null||n.removeChild(s),s.destroy())}),e.clear()}updateSpotsEditState(e){e.forEach(t=>{t.updateEditState()})}isSpotDataEqual(e,t){if(e.id!==t.id)return!1;const i=e.point,s=t.point;return!(Math.abs(i.x-s.x)>.1||Math.abs(i.y-s.y)>.1)}drawWayPoints(e){w.log("[ControlsManager] drawWayPoints",e);const t=Array.from(this.wayPointMap.keys()),i=e.map(n=>n.id);t.filter(n=>!i.includes(n)).forEach(n=>{this.removeWayPoint(n,this.wayPointMap)}),e.forEach((n,o)=>{const a=o+1,h=this.wayPointMap.get(n.id);h?(this.isWayPointDataEqual(h.getWayPointData(),n)||h.updateWayPoint(n),h.updateOrder(a)):this.addNewWayPoint(n,a,this.wayPointMap)})}clearAllWayPoints(){w.log("[ControlsManager] clearAllWayPoints"),this.clearAllWayPointsInternal(this.wayPointMap)}getWayPoints(){return this.getWayPointsData(this.wayPointMap)}addNewWayPoint(e,t,i){var o,a;const s=this.appService,n=new nS({appService:s,wayPointData:e,order:t,events:{onUpdate:(o=s.events)==null?void 0:o.onUpdateWayPoint,onClick:(a=s.events)==null?void 0:a.onClickWayPoint}});i.set(e.id,n),this.addToControlLayer("wayPoint",n)}removeWayPoint(e,t){var s;const i=t.get(e);i&&((s=i.parent)==null||s.removeChild(i),i.destroy(),t.delete(e))}getWayPointsData(e){const t=[];return e.forEach(i=>{t.push(i.getWayPointData())}),t}clearAllWayPointsInternal(e){e.forEach((t,i)=>{var n;const s=e.get(i);s&&((n=s.parent)==null||n.removeChild(s),s.destroy())}),e.clear()}updateWayPointsEditState(e){e.forEach(t=>{t.onEditStateChange()})}isWayPointDataEqual(e,t){if(e.id!==t.id)return!1;const i=e.point,s=t.point;return!(Math.abs(i.x-s.x)>.1||Math.abs(i.y-s.y)>.1)}handleDividingRoomIdChange(e){if(e==null||e===-1){this.clearDivider();return}if(!this.getRoomGeometry(e)){this.clearDivider();return}this.createDefaultDivider(e)}getRoomGeometry(e){return this.appService.mapManager.getRoomById(e)}createDefaultDivider(e){const t=this.appService;this.clearDivider(),this.divider=new rS({appService:this.appService,roomId:e,events:{onUpdate:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onUpdateDivider)==null||n.call(s,i)}}}),this.addToControlLayer("divider",this.divider)}clearDivider(){var e;this.divider&&((e=this.divider.parent)==null||e.removeChild(this.divider),this.divider.destroy(),this.divider=null)}getDividerEndPoints(){return this.divider?this.divider.getDividerEndPoints():null}getEffectiveDividerPoints(){return this.divider?this.divider.getEffectiveDividerPoints():null}handleUnitChange(){w.debug("[ControlsManager] Unit changed, refreshing all size texts");for(const e of this.zoneMaps.values())e.forEach(t=>{t.refreshDisplay()});this.virtualWallMap.forEach(e=>{e.refreshDisplay()}),this.spotMap.forEach(e=>{e.refreshDisplay()})}destroy(){for(const e of this.zoneMaps.keys())this.clearAllZonesByType(e);this.clearAllVirtualWalls(),this.clearAllSpots(),this.clearDivider(),this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[],this.controlContainers.forEach(e=>{e.removeFromParent(),e.destroy({children:!0})}),this.controlContainers.clear()}}class hS extends Xt{constructor(t,i){super(t);g(this,"objectData");g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);this.appService=t,this.objectData=i}async initializeSprite(){const t=this.appService.detectedObjectConfig,i=this.objectData.width||t.width,s=this.objectData.height||t.height;await this.loadTextureAndSetSize(this.objectData.src,{width:i,height:s}),this.anchor.set(t.anchor.x,t.anchor.y),this.position.set(this.objectData.x,this.objectData.y),this.visible=!0,this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=W(this.appService.runtime,"mapRotation",n=>{this.applyAntiRotation(n)}),t.interactive?this.setupClickHandler():this.eventMode="none"}applyAntiRotation(t){const i=-t*Math.PI/180;this.rotation=i}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new vt(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var t,i;(i=(t=this.appService.events)==null?void 0:t.onClickDetectedObject)==null||i.call(t,this.getObjectData())}getObjectData(){return{...this.objectData}}async updateObjectData(t){const i=this.objectData;this.objectData=t;const s=this.appService.detectedObjectConfig;if(i.src!==t.src){const n=t.width||s.width,o=t.height||s.height;await this.loadTextureAndSetSize(t.src,{width:n,height:o})}if(i.width!==t.width||i.height!==t.height){const n=t.width||s.width,o=t.height||s.height;this.setFixedSize(n,o)}this.position.set(t.x,t.y),s.interactive?this.clickHandler||this.setupClickHandler():this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null)}isSameData(t){return this.objectData.id===t.id&&this.objectData.src===t.src&&this.objectData.x===t.x&&this.objectData.y===t.y&&this.objectData.width===t.width&&this.objectData.height===t.height}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class lS{constructor(e){g(this,"detectedObjectMap",new Map);g(this,"unsubscribeShowDetectedObjects",null);this.appService=e,this.applyLayerVisibility(this.appService.runtime.showDetectedObjects),this.unsubscribeShowDetectedObjects=W(this.appService.runtime,"showDetectedObjects",t=>{this.applyLayerVisibility(t)})}async drawDetectedObjects(e){if(!e||e.length===0){this.clearAllDetectedObjects();return}const t=new Set(e.map(s=>s.id)),i=Array.from(this.detectedObjectMap.keys());for(const s of i)t.has(s)||this.removeDetectedObject(s);for(const s of e){const n=this.detectedObjectMap.get(s.id);n?n.isSameData(s)||await n.updateObjectData(s):await this.addNewDetectedObject(s)}}applyLayerVisibility(e){const t=this.appService.appContainer.getLayer(Ye);t&&(t.visible=e)}clearAllDetectedObjects(){const e=this.appService;this.detectedObjectMap.forEach(t=>{e.appContainer.removeFromLayer(Ye,t),t.destroy()}),this.detectedObjectMap.clear()}async addNewDetectedObject(e){const t=this.appService,i=new hS(this.appService,e);await i.initializeSprite(),this.detectedObjectMap.set(e.id,i),t.appContainer.addToLayer(Ye,i)}removeDetectedObject(e){const t=this.appService,i=this.detectedObjectMap.get(e);i&&(t.appContainer.removeFromLayer(Ye,i),i.destroy(),this.detectedObjectMap.delete(e))}destroy(){this.unsubscribeShowDetectedObjects&&(this.unsubscribeShowDetectedObjects(),this.unsubscribeShowDetectedObjects=null),this.clearAllDetectedObjects()}}var Re={},vc={},te={};Object.defineProperty(te,"__esModule",{value:!0});te.loop=te.conditional=te.parse=void 0;var cS=function r(e,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;if(Array.isArray(t))t.forEach(function(o){return r(e,o,i,s)});else if(typeof t=="function")t(e,i,s,r);else{var n=Object.keys(t)[0];Array.isArray(t[n])?(s[n]={},r(e,t[n],i,s[n])):s[n]=t[n](e,i,s,r)}return i};te.parse=cS;var dS=function(e,t){return function(i,s,n,o){t(i,s,n)&&o(i,e,s,n)}};te.conditional=dS;var uS=function(e,t){return function(i,s,n,o){for(var a=[],h=i.pos;t(i,s,n);){var l={};if(o(i,e,s,l),i.pos===h)break;h=i.pos,a.push(l)}return a}};te.loop=uS;var ut={};Object.defineProperty(ut,"__esModule",{value:!0});ut.readBits=ut.readArray=ut.readUnsigned=ut.readString=ut.peekBytes=ut.readBytes=ut.peekByte=ut.readByte=ut.buildStream=void 0;var pS=function(e){return{data:e,pos:0}};ut.buildStream=pS;var bc=function(){return function(e){return e.data[e.pos++]}};ut.readByte=bc;var fS=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(t){return t.data[t.pos+e]}};ut.peekByte=fS;var Os=function(e){return function(t){return t.data.subarray(t.pos,t.pos+=e)}};ut.readBytes=Os;var gS=function(e){return function(t){return t.data.subarray(t.pos,t.pos+e)}};ut.peekBytes=gS;var mS=function(e){return function(t){return Array.from(Os(e)(t)).map(function(i){return String.fromCharCode(i)}).join("")}};ut.readString=mS;var yS=function(e){return function(t){var i=Os(2)(t);return e?(i[1]<<8)+i[0]:(i[0]<<8)+i[1]}};ut.readUnsigned=yS;var xS=function(e,t){return function(i,s,n){for(var o=typeof t=="function"?t(i,s,n):t,a=Os(e),h=new Array(o),l=0;l<o;l++)h[l]=a(i);return h}};ut.readArray=xS;var SS=function(e,t,i){for(var s=0,n=0;n<i;n++)s+=e[t+n]&&Math.pow(2,i-n-1);return s},vS=function(e){return function(t){for(var i=bc()(t),s=new Array(8),n=0;n<8;n++)s[7-n]=!!(i&1<<n);return Object.keys(e).reduce(function(o,a){var h=e[a];return h.length?o[a]=SS(s,h.index,h.length):o[a]=s[h.index],o},{})}};ut.readBits=vS;(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var e=te,t=ut,i={blocks:function(u){for(var p=0,f=[],y=u.data.length,m=0,x=(0,t.readByte)()(u);x!==p&&x;x=(0,t.readByte)()(u)){if(u.pos+x>=y){var S=y-u.pos;f.push((0,t.readBytes)(S)(u)),m+=S;break}f.push((0,t.readBytes)(x)(u)),m+=x}for(var v=new Uint8Array(m),b=0,P=0;P<f.length;P++)v.set(f[P],b),b+=f[P].length;return v}},s=(0,e.conditional)({gce:[{codes:(0,t.readBytes)(2)},{byteSize:(0,t.readByte)()},{extras:(0,t.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,t.readUnsigned)(!0)},{transparentColorIndex:(0,t.readByte)()},{terminator:(0,t.readByte)()}]},function(d){var u=(0,t.peekBytes)(2)(d);return u[0]===33&&u[1]===249}),n=(0,e.conditional)({image:[{code:(0,t.readByte)()},{descriptor:[{left:(0,t.readUnsigned)(!0)},{top:(0,t.readUnsigned)(!0)},{width:(0,t.readUnsigned)(!0)},{height:(0,t.readUnsigned)(!0)},{lct:(0,t.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,e.conditional)({lct:(0,t.readArray)(3,function(d,u,p){return Math.pow(2,p.descriptor.lct.size+1)})},function(d,u,p){return p.descriptor.lct.exists}),{data:[{minCodeSize:(0,t.readByte)()},i]}]},function(d){return(0,t.peekByte)()(d)===44}),o=(0,e.conditional)({text:[{codes:(0,t.readBytes)(2)},{blockSize:(0,t.readByte)()},{preData:function(u,p,f){return(0,t.readBytes)(f.text.blockSize)(u)}},i]},function(d){var u=(0,t.peekBytes)(2)(d);return u[0]===33&&u[1]===1}),a=(0,e.conditional)({application:[{codes:(0,t.readBytes)(2)},{blockSize:(0,t.readByte)()},{id:function(u,p,f){return(0,t.readString)(f.blockSize)(u)}},i]},function(d){var u=(0,t.peekBytes)(2)(d);return u[0]===33&&u[1]===255}),h=(0,e.conditional)({comment:[{codes:(0,t.readBytes)(2)},i]},function(d){var u=(0,t.peekBytes)(2)(d);return u[0]===33&&u[1]===254}),l=[{header:[{signature:(0,t.readString)(3)},{version:(0,t.readString)(3)}]},{lsd:[{width:(0,t.readUnsigned)(!0)},{height:(0,t.readUnsigned)(!0)},{gct:(0,t.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,t.readByte)()},{pixelAspectRatio:(0,t.readByte)()}]},(0,e.conditional)({gct:(0,t.readArray)(3,function(d,u){return Math.pow(2,u.lsd.gct.size+1)})},function(d,u){return u.lsd.gct.exists}),{frames:(0,e.loop)([s,a,h,n,o],function(d){var u=(0,t.peekByte)()(d);return u===33||u===44})}],c=l;r.default=c})(vc);var Gs={};Object.defineProperty(Gs,"__esModule",{value:!0});Gs.deinterlace=void 0;var bS=function(e,t){for(var i=new Array(e.length),s=e.length/t,n=function(u,p){var f=e.slice(p*t,(p+1)*t);i.splice.apply(i,[u*t,t].concat(f))},o=[0,4,2,1],a=[8,8,4,2],h=0,l=0;l<4;l++)for(var c=o[l];c<s;c+=a[l])n(c,h),h++;return i};Gs.deinterlace=bS;var Ws={};Object.defineProperty(Ws,"__esModule",{value:!0});Ws.lzw=void 0;var wS=function(e,t,i){var s=4096,n=-1,o=i,a,h,l,c,d,u,p,C,f,y,P,m,A,k,T,M,x=new Array(i),S=new Array(s),v=new Array(s),b=new Array(s+1);for(m=e,h=1<<m,d=h+1,a=h+2,p=n,c=m+1,l=(1<<c)-1,f=0;f<h;f++)S[f]=0,v[f]=f;var P,C,A,k,M,T;for(P=C=A=k=M=T=0,y=0;y<o;){if(k===0){if(C<c){P+=t[T]<<C,C+=8,T++;continue}if(f=P&l,P>>=c,C-=c,f>a||f==d)break;if(f==h){c=m+1,l=(1<<c)-1,a=h+2,p=n;continue}if(p==n){b[k++]=v[f],p=f,A=f;continue}for(u=f,f==a&&(b[k++]=A,f=p);f>h;)b[k++]=v[f],f=S[f];A=v[f]&255,b[k++]=A,a<s&&(S[a]=p,v[a]=A,a++,!(a&l)&&a<s&&(c++,l+=a)),p=u}k--,x[M++]=b[k],y++}for(y=M;y<o;y++)x[y]=0;return x};Ws.lzw=wS;Object.defineProperty(Re,"__esModule",{value:!0});var wc=Re.decompressFrames=Re.decompressFrame=Cc=Re.parseGIF=void 0,CS=TS(vc),AS=te,PS=ut,MS=Gs,_S=Ws;function TS(r){return r&&r.__esModule?r:{default:r}}var kS=function(e){var t=new Uint8Array(e);return(0,AS.parse)((0,PS.buildStream)(t),CS.default)},Cc=Re.parseGIF=kS,RS=function(e){for(var t=e.pixels.length,i=new Uint8ClampedArray(t*4),s=0;s<t;s++){var n=s*4,o=e.pixels[s],a=e.colorTable[o]||[0,0,0];i[n]=a[0],i[n+1]=a[1],i[n+2]=a[2],i[n+3]=o!==e.transparentIndex?255:0}return i},Ac=function(e,t,i){if(!e.image){console.warn("gif frame does not have associated image.");return}var s=e.image,n=s.descriptor.width*s.descriptor.height,o=(0,_S.lzw)(s.data.minCodeSize,s.data.blocks,n);s.descriptor.lct.interlaced&&(o=(0,MS.deinterlace)(o,s.descriptor.width));var a={pixels:o,dims:{top:e.image.descriptor.top,left:e.image.descriptor.left,width:e.image.descriptor.width,height:e.image.descriptor.height}};return s.descriptor.lct&&s.descriptor.lct.exists?a.colorTable=s.lct:a.colorTable=t,e.gce&&(a.delay=(e.gce.delay||10)*10,a.disposalType=e.gce.extras.disposal,e.gce.extras.transparentColorGiven&&(a.transparentIndex=e.gce.transparentColorIndex)),i&&(a.patch=RS(a)),a};Re.decompressFrame=Ac;var ES=function(e,t){return e.frames.filter(function(i){return i.image}).map(function(i){return Ac(i,e.gct,t)})};wc=Re.decompressFrames=ES;class Us{constructor(e){if(!e||!e.length)throw new Error("Invalid frames");const[{texture:{width:t,height:i}}]=e;this.width=t,this.height=i,this.frames=e,this.textures=this.frames.map(s=>s.texture),this.totalFrames=this.frames.length,this.duration=this.frames[this.totalFrames-1].end}destroy(){for(const e of this.textures)e.destroy(!0);for(const e of this.frames)e.texture=null;this.frames.length=0,this.textures.length=0,Object.assign(this,{frames:null,textures:null,width:0,height:0,duration:0,totalFrames:0})}static from(e,t){if(!e||e.byteLength===0)throw new Error("Invalid buffer");const i=S=>{let v=null;for(const b of S.frames)v=b.gce??v,"image"in b&&!("gce"in b)&&(b.gce=v)},s=Cc(e);i(s);const n=wc(s,!0),o=[],a=s.lsd.width,h=s.lsd.height,l=j.get().createCanvas(a,h),c=l.getContext("2d",{willReadFrequently:!0}),d=j.get().createCanvas(),u=d.getContext("2d");let p=0,f=null;const{fps:y=30,...m}=t??{},x=1e3/y;for(let S=0;S<n.length;S++){const{disposalType:v=2,delay:b=x,patch:P,dims:{width:C,height:A,left:k,top:M}}=n[S];d.width=C,d.height=A,u.clearRect(0,0,C,A);const T=u.createImageData(C,A);T.data.set(P),u.putImageData(T,0,0),v===3&&(f=c.getImageData(0,0,a,h)),c.drawImage(d,k,M);const _=c.getImageData(0,0,a,h);v===2?c.clearRect(0,0,a,h):v===3&&c.putImageData(f,0,0);const E=j.get().createCanvas(_.width,_.height);E.getContext("2d").putImageData(_,0,0),o.push({start:p,end:p+b,texture:new G({source:new gr({resource:E,...m})})}),p+=b}return l.width=l.height=0,d.width=d.height=0,new Us(o)}}const IS={extension:I.Asset,detection:{test:async()=>!0,add:async r=>[...r,"gif"],remove:async r=>r.filter(e=>e!=="gif")},loader:{name:"gifLoader",id:"gif",test:r=>Mt.extname(r)===".gif"||r.startsWith("data:image/gif"),load:async(r,e)=>{const i=await(await j.get().fetch(r)).arrayBuffer();return Us.from(i,e==null?void 0:e.data)},unload:async r=>{r.destroy()}}},Pc=class lr extends jt{constructor(...e){const t=e[0]instanceof Us?{source:e[0]}:e[0],{source:i,fps:s,loop:n,animationSpeed:o,autoPlay:a,autoUpdate:h,onComplete:l,onFrameChange:c,onLoop:d,...u}=Object.assign({},lr.defaultOptions,t);super({texture:G.EMPTY,...u}),this.animationSpeed=1,this.loop=!0,this.duration=0,this.autoPlay=!0,this.dirty=!1,this._currentFrame=0,this._autoUpdate=!1,this._isConnectedToTicker=!1,this._playing=!1,this._currentTime=0,this.onRender=()=>this._updateFrame(),this.texture=i.textures[0],this.duration=i.frames[i.frames.length-1].end,this._source=i,this._playing=!1,this._currentTime=0,this._isConnectedToTicker=!1,Object.assign(this,{fps:s,loop:n,animationSpeed:o,autoPlay:a,autoUpdate:h,onComplete:l,onFrameChange:c,onLoop:d}),this.currentFrame=0,a&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(yt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(yt.shared.add(this.update,this,Ie.HIGH),this._isConnectedToTicker=!0),!this.loop&&this.currentFrame===this._source.frames.length-1&&(this._currentTime=0))}get progress(){return this._currentTime/this.duration}get playing(){return this._playing}update(e){var o,a;if(!this._playing)return;const t=this.animationSpeed*e.deltaTime/yt.targetFPMS,i=this._currentTime+t,s=i%this.duration,n=this._source.frames.findIndex(h=>h.start<=s&&h.end>s);i>=this.duration?this.loop?(this._currentTime=s,this._updateFrameIndex(n),(o=this.onLoop)==null||o.call(this)):(this._currentTime=this.duration,this._updateFrameIndex(this.totalFrames-1),(a=this.onComplete)==null||a.call(this),this.stop()):(this._currentTime=s,this._updateFrameIndex(n))}_updateFrame(){this.dirty&&(this.texture=this._source.frames[this._currentFrame].texture,this.dirty=!1)}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,!this._autoUpdate&&this._isConnectedToTicker?(yt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(yt.shared.add(this.update,this),this._isConnectedToTicker=!0))}get currentFrame(){return this._currentFrame}set currentFrame(e){this._updateFrameIndex(e),this._currentTime=this._source.frames[e].start}get source(){return this._source}_updateFrameIndex(e){var t;if(e<0||e>=this.totalFrames)throw new Error(`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${e}`);this._currentFrame!==e&&(this._currentFrame=e,this.dirty=!0,(t=this.onFrameChange)==null||t.call(this,e))}get totalFrames(){return this._source.totalFrames}destroy(e=!1){this.stop(),super.destroy(),e&&this._source.destroy();const t=null;this._source=t,this.onComplete=t,this.onFrameChange=t,this.onLoop=t}clone(){const e=new lr({source:this._source,autoUpdate:this._autoUpdate,loop:this.loop,autoPlay:this.autoPlay,animationSpeed:this.animationSpeed,onComplete:this.onComplete,onFrameChange:this.onFrameChange,onLoop:this.onLoop});return e.dirty=!0,e}};Pc.defaultOptions={fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};let BS=Pc;$.add(IS);class Xr extends BS{constructor(t,i){super(i);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"sizeFixed",!0);g(this,"baselineScale",1);this.appService=t,this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ct(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,i){this.fixedWidth=t,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,t&&this.isFixedSizeSet?this.applySize():!t&&this.isFixedSizeSet&&this.applySize()}set width(t){if(this.isFixedSizeSet){w.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置宽度");return}this.setFixedSize(t,this.fixedHeight||t)}set height(t){if(this.isFixedSizeSet){w.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置高度");return}this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||this.texture.width===0||this.texture.height===0)return;const t=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const s=this.appService.currentScale;if(s===0)return;const n=t/s,o=i/s;super.scale.set(n,o)}else super.scale.set(t/this.baselineScale,i/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():t!==0&&super.scale.set(1/t))}static async createFromSrc(t,i,s){try{const n=await N.load(i),o=new Xr(t,{source:n});return s.sizeFixed!==void 0&&o.setSizeFixed(s.sizeFixed),o.setFixedSize(s.width,s.height),o}catch(n){throw w.error(`Failed to load GIF "${i}":`,n),n}}draw(t,i){const{x:s,y:n,rotation:o=0}=t;i&&!this.visible?this.visible=i():!i&&!this.visible&&(this.visible=!0),this.rotation=o,this.position.set(s,n)}destroy(t){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class We extends Xr{constructor(t,i,s){super(t,{source:i});g(this,"elementData");g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);g(this,"userRotation",0);this.elementData=s}async initialize(){this.elementData.sizeFixed!==void 0&&this.setSizeFixed(this.elementData.sizeFixed),this.setFixedSize(this.elementData.width,this.elementData.height);const t=this.elementData.anchor||{x:.5,y:.5};this.anchor.set(t.x,t.y),this.position.set(this.elementData.x,this.elementData.y),this.elementData.rotation!==void 0&&(this.userRotation=this.elementData.rotation),this.elementData.opacity!==void 0&&(this.alpha=this.elementData.opacity),this.applyRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=W(this.appService.runtime,"mapRotation",i=>{this.applyRotation(i)}),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(t){const i=-t*Math.PI/180;this.rotation=this.userRotation+i}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new vt(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var t,i;(i=(t=this.appService.events)==null?void 0:t.onClickCustomElement)==null||i.call(t,this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const i=this.elementData;if(this.elementData=t,i.src!==t.src)throw new Error("GIF source change requires recreation of instance");i.sizeFixed!==t.sizeFixed&&t.sizeFixed!==void 0&&this.setSizeFixed(t.sizeFixed),(i.width!==t.width||i.height!==t.height)&&this.setFixedSize(t.width,t.height);const s=t.anchor||{x:.5,y:.5},n=i.anchor||{x:.5,y:.5};(s.x!==n.x||s.y!==n.y)&&this.anchor.set(s.x,s.y),this.position.set(t.x,t.y),t.rotation!==void 0&&(this.userRotation=t.rotation,this.applyRotation(this.appService.runtime.mapRotation)),t.opacity!==void 0&&(this.alpha=t.opacity),t.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")}isSameData(t){const i=this.elementData.anchor||{x:.5,y:.5},s=t.anchor||{x:.5,y:.5};return this.elementData.id===t.id&&this.elementData.type===t.type&&this.elementData.src===t.src&&this.elementData.x===t.x&&this.elementData.y===t.y&&this.elementData.width===t.width&&this.elementData.height===t.height&&this.elementData.rotation===t.rotation&&this.elementData.opacity===t.opacity&&this.elementData.interactive===t.interactive&&this.elementData.sizeFixed===t.sizeFixed&&i.x===s.x&&i.y===s.y}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class Tn extends Xt{constructor(t,i){super(t);g(this,"elementData");g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);g(this,"userRotation",0);this.appService=t,this.elementData=i}async initialize(){await this.loadTextureAndSetSize(this.elementData.src,{width:this.elementData.width,height:this.elementData.height,sizeFixed:this.elementData.sizeFixed});const t=this.elementData.anchor||{x:.5,y:.5};this.anchor.set(t.x,t.y),this.position.set(this.elementData.x,this.elementData.y),this.elementData.rotation!==void 0&&(this.userRotation=this.elementData.rotation),this.elementData.opacity!==void 0&&(this.alpha=this.elementData.opacity),this.applyRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=W(this.appService.runtime,"mapRotation",i=>{this.applyRotation(i)}),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(t){const i=-t*Math.PI/180;this.rotation=this.userRotation+i}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new vt(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var t,i;(i=(t=this.appService.events)==null?void 0:t.onClickCustomElement)==null||i.call(t,this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const i=this.elementData;this.elementData=t,i.src!==t.src?await this.loadTextureAndSetSize(t.src,{width:t.width,height:t.height,sizeFixed:t.sizeFixed}):(i.sizeFixed!==t.sizeFixed&&t.sizeFixed!==void 0&&this.setSizeFixed(t.sizeFixed),(i.width!==t.width||i.height!==t.height)&&this.setFixedSize(t.width,t.height));const s=t.anchor||{x:.5,y:.5},n=i.anchor||{x:.5,y:.5};(s.x!==n.x||s.y!==n.y)&&this.anchor.set(s.x,s.y),this.position.set(t.x,t.y),t.rotation!==void 0&&(this.userRotation=t.rotation,this.applyRotation(this.appService.runtime.mapRotation)),t.opacity!==void 0&&(this.alpha=t.opacity),t.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")}isSameData(t){const i=this.elementData.anchor||{x:.5,y:.5},s=t.anchor||{x:.5,y:.5};return this.elementData.id===t.id&&this.elementData.type===t.type&&this.elementData.src===t.src&&this.elementData.x===t.x&&this.elementData.y===t.y&&this.elementData.width===t.width&&this.elementData.height===t.height&&this.elementData.rotation===t.rotation&&this.elementData.opacity===t.opacity&&this.elementData.interactive===t.interactive&&this.elementData.sizeFixed===t.sizeFixed&&i.x===s.x&&i.y===s.y}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class DS extends Wg{constructor(t,i){super(i);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"userCenterX",0);g(this,"userCenterY",0);g(this,"sizeFixed",!0);this.appService=t,this.anchor.set(0,0),this.throttledUpdateScale=Ct(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,i){this.fixedWidth=t,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applyFixedSize(),this.updatePositionFromCenter()}setCenterPosition(t,i){this.userCenterX=t,this.userCenterY=i,this.updatePositionFromCenter()}setSizeFixed(t){this.sizeFixed=t,this.isFixedSizeSet&&(this.applyFixedSize(),this.updatePositionFromCenter())}getIsFixedSizeSet(){return this.isFixedSizeSet}updatePositionFromCenter(){if(!this.isFixedSizeSet){this.position.set(this.userCenterX,this.userCenterY);return}const i=this.appService.currentScale;let s,n;this.sizeFixed?(s=this.fixedWidth/2/i,n=this.fixedHeight/2/i):(s=this.fixedWidth/2,n=this.fixedHeight/2),this.position.set(this.userCenterX-s,this.userCenterY-n)}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applyFixedSize(){if(!this.isFixedSizeSet)return;const i=this.appService.currentScale;if(i!==0){if(this.sizeFixed){const s=1/i;this.scale.set(s)}else this.scale.set(1);this.element&&(this.element.style.width=`${this.fixedWidth}px`,this.element.style.height=`${this.fixedHeight}px`)}}updateScale(t){this.isFixedSizeSet&&t!==0&&(this.applyFixedSize(),this.updatePositionFromCenter())}updateTransform(t){return super.updateTransform(t)}destroy(t){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Di extends DS{constructor(t,i){const s=document.createElement("div");Di.setupDefaultStyles(s,i),s.innerHTML=i.htmlContent;super(t,{element:s});g(this,"elementData");g(this,"domClickHandler",null);g(this,"resizeObserver",null);g(this,"debugMarker",null);g(this,"unsubscribeMapRotation",null);g(this,"userRotation",0);this.elementData=i}async initialize(){this.alpha=0,this.elementData.width&&this.elementData.height?(this.setFixedSize(this.elementData.width,this.elementData.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),this.waitForElementInsertion()):(this.position.set(this.elementData.x,this.elementData.y),this.setupAutoSize()),this.elementData.rotation!==void 0&&(this.userRotation=this.elementData.rotation),this.applyRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=W(this.appService.runtime,"mapRotation",t=>{this.applyRotation(t)}),this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(t){const i=-t*Math.PI/180;this.rotation=this.userRotation+i}setupAutoSize(){this.element&&(this.element.style.width="auto",this.element.style.height="auto",this.waitForElementDimensions())}waitForElementInsertion(){if(!this.element)return;const t=()=>{this.element&&(this.element.isConnected?this.showElement():requestAnimationFrame(t))};requestAnimationFrame(t)}waitForElementDimensions(){this.element&&(typeof ResizeObserver<"u"?(this.resizeObserver=new ResizeObserver(t=>{var s;const i=t[0];i&&i.contentRect.width>0&&i.contentRect.height>0&&(this.setFixedSize(i.contentRect.width,i.contentRect.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),this.alpha===0&&this.showElement(),(s=this.resizeObserver)==null||s.disconnect(),this.resizeObserver=null)}),this.resizeObserver.observe(this.element)):this.pollForElementDimensions())}pollForElementDimensions(){if(!this.element)return;const t=()=>{if(!this.element)return;if(!this.element.isConnected){requestAnimationFrame(t);return}const i=this.element.getBoundingClientRect();i.width>0&&i.height>0?(this.setFixedSize(i.width,i.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),this.alpha===0&&this.showElement()):requestAnimationFrame(t)};requestAnimationFrame(t)}showElement(){this.alpha=this.elementData.opacity??1,this.element.style.pointerEvents=this.elementData.interactive?"auto":"none",this.interactive=this.elementData.interactive??!1,this.elementData.interactive&&this.element&&(this.element.style.setProperty("-webkit-tap-highlight-color","transparent"),this.element.style.setProperty("-webkit-touch-callout","none")),this.appService.getApp().renderOnceNextFrame()}setupClickHandler(){this.element&&(this.domClickHandler=t=>{t.preventDefault(),t.stopPropagation(),this.handleClick()},this.element.addEventListener("click",this.domClickHandler))}handleClick(){var t,i;(i=(t=this.appService.events)==null?void 0:t.onClickCustomElement)==null||i.call(t,this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const i=this.elementData;this.elementData=t,i.htmlContent!==t.htmlContent&&this.element&&(this.element.innerHTML=t.htmlContent,(!t.width||!t.height)&&this.waitForElementDimensions()),(i.width!==t.width||i.height!==t.height)&&(t.width&&t.height?(this.setFixedSize(t.width,t.height),this.element&&(this.element.style.width=`${t.width}px`,this.element.style.height=`${t.height}px`)):this.setupAutoSize()),t.width&&t.height?this.setCenterPosition(t.x,t.y):this.getIsFixedSizeSet()?this.setCenterPosition(t.x,t.y):this.position.set(t.x,t.y),i.sizeFixed!==t.sizeFixed&&t.sizeFixed!==void 0&&this.setSizeFixed(t.sizeFixed),this.userRotation=t.rotation??0,this.applyRotation(this.appService.runtime.mapRotation),this.alpha=t.opacity??1,t.interactive?this.domClickHandler||this.setupClickHandler():(this.eventMode="none",this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null))}isSameData(t){return this.elementData.id===t.id&&this.elementData.type===t.type&&this.elementData.htmlContent===t.htmlContent&&this.elementData.x===t.x&&this.elementData.y===t.y&&this.elementData.width===t.width&&this.elementData.height===t.height&&this.elementData.rotation===t.rotation&&this.elementData.opacity===t.opacity&&this.elementData.interactive===t.interactive&&this.elementData.sizeFixed===t.sizeFixed}static setupDefaultStyles(t,i){const s={position:"relative",boxSizing:"border-box",webkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",background:"transparent",userSelect:"auto",webkitUserSelect:"auto"};i.width&&i.height?(s.width=`${i.width}px`,s.height=`${i.height}px`,s.overflow="hidden"):(s.width=i.width?`${i.width}px`:"auto",s.height=i.height?`${i.height}px`:"auto",s.overflow="visible"),Object.assign(t.style,s),t.style.setProperty("-webkit-tap-highlight-color","transparent"),t.style.setProperty("-webkit-touch-callout","none")}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null),this.debugMarker&&(this.debugMarker.destroy(),this.debugMarker=null),super.destroy()}}class FS{constructor(e){g(this,"customElementsMap",new Map);g(this,"gifTicker",null);g(this,"gifElements",new Set);this.appService=e}async drawCustomElements(e){if(!e||e.length===0){this.clearAllCustomElements();return}const t=new Set(e.map(n=>n.id)),i=Array.from(this.customElementsMap.keys());for(const n of i)t.has(n)||this.removeCustomElement(n);const s=e.map(async n=>{const o=this.customElementsMap.get(n.id);o?this.isSameData(o,n)||(n.type==="gif"&&o.getElementData().src!==n.src?(this.removeCustomElement(n.id),await this.addNewCustomElement(n)):await this.updateElementData(o,n)):await this.addNewCustomElement(n)});await Promise.all(s),this.updateGifTicker()}clearAllCustomElements(){const e=this.appService;this.customElementsMap.forEach(t=>{t instanceof We?e.appContainer.removeFromLayer(Bi,t):e.appContainer.removeFromLayer(Ii,t),t.destroy()}),this.customElementsMap.clear(),this.gifElements.clear(),this.stopGifTicker()}async addNewCustomElement(e){const t=this.appService;let i;switch(e.type){case"image":i=new Tn(this.appService,e);break;case"gif":{const s=await N.load(e.src);i=new We(this.appService,s,e);break}case"html":i=new Di(this.appService,e);break;default:throw new Error(`Unsupported custom element type: ${e.type}`)}await i.initialize(),this.customElementsMap.set(e.id,i),i instanceof We?(t.appContainer.addToLayer(Bi,i),this.gifElements.add(i)):t.appContainer.addToLayer(Ii,i)}removeCustomElement(e){const t=this.appService,i=this.customElementsMap.get(e);i&&(i instanceof We?(this.gifElements.delete(i),t.appContainer.removeFromLayer(Bi,i)):t.appContainer.removeFromLayer(Ii,i),i.destroy(),this.customElementsMap.delete(e))}isSameData(e,t){return e.getElementData().type!==t.type?!1:t.type==="image"&&e instanceof Tn||t.type==="gif"&&e instanceof We||t.type==="html"&&e instanceof Di?e.isSameData(t):!1}async updateElementData(e,t){if(t.type==="image"&&e instanceof Tn)await e.updateElementData(t);else if(t.type==="gif"&&e instanceof We)await e.updateElementData(t);else if(t.type==="html"&&e instanceof Di)await e.updateElementData(t);else throw new Error("Element type mismatch during update")}updateGifTicker(){this.gifElements.size>0?this.startGifTicker():this.stopGifTicker()}startGifTicker(){var e;(e=this.gifTicker)!=null&&e.started||(this.gifTicker?this.gifTicker.maxFPS=1:(this.gifTicker=new yt,this.gifTicker.maxFPS=1,this.gifTicker.add(()=>{this.renderGifContainer()})),this.gifTicker.start())}stopGifTicker(){var e;(e=this.gifTicker)!=null&&e.started&&(w.log("⏸️ [GifTicker] 停止 GIF 专用渲染"),this.gifTicker.stop())}renderGifContainer(){const e=this.appService;if(this.gifElements.size===0)return;const t=e.getApp();t.renderer.render(t.stage)}destroy(){this.stopGifTicker(),this.gifTicker&&(this.gifTicker.destroy(),this.gifTicker=null),this.clearAllCustomElements()}}class zS extends L{constructor(t,i){super();g(this,"roomId");g(this,"roomIndex");g(this,"appService");g(this,"nameText");g(this,"iconSprite",null);g(this,"iconWrapper",null);g(this,"iconBg",null);this.appService=t,this.roomId=i.id,this.roomIndex=i.index;const{nameLabel:s,type:n}=t.roomConfig,{showRoomType:o}=t.runtime,a=i.colorIndex??i.index,h=this.getRoomNameColor(a),l=new ce({fontSize:s.fontSize,fontFamily:s.fontFamily,fontWeight:s.fontWeight,fill:h,align:"center"}),c=i.name||"Unknown";this.nameText=new Bs({text:c,style:l}),this.nameText.anchor.set(.5),o&&i.type!=null&&(n!=null&&n.assets)&&n.assets[i.type]&&this.createIcon(i.type,h),this.addChild(this.nameText),this.layout()}createIcon(t,i){const{type:s}=this.appService.roomConfig,n=s.iconSize||14;this.iconWrapper||(this.iconWrapper=new L,this.addChild(this.iconWrapper)),s.container.visible?(this.iconBg||(this.iconBg=new H,this.iconWrapper.addChild(this.iconBg)),this.drawIconBg(i)):this.iconBg&&(this.iconBg.destroy(),this.iconBg=null),this.iconSprite||(this.iconSprite=new Xt(this.appService),this.iconSprite.anchor.set(.5),this.iconWrapper.addChild(this.iconSprite)),this.iconSprite.visible=!0,this.iconSprite.tint=s.container.visible?"#ffffff":i,this.iconSprite.setFixedSize(n,n),this.iconSprite.loadTextureAndSetSize(s.assets[t],{width:n,height:n,sizeFixed:!1}).then(()=>{this.iconSprite&&(this.iconSprite.visible=this.appService.runtime.showRoomType,this.layout())}),s.container&&this.iconSprite.position.set(0,0)}drawIconBg(t){const{type:i}=this.appService.roomConfig;if(!this.iconBg||!i.container.visible)return;const{size:s,borderRadius:n}=i.container;this.iconBg.clear().roundRect(-s/2,-s/2,s,s,n).fill(t)}layout(){if(!this.iconWrapper||!this.iconWrapper.visible){this.nameText.position.set(0,0);return}if(!(this.iconSprite&&this.iconSprite.visible||this.iconBg&&this.iconBg.visible)){this.nameText.position.set(0,0);return}const{gap:i=4,position:s="left"}=this.appService.roomConfig.type,n=this.nameText.width,o=this.iconWrapper.width,h=-(o+i+n)/2;s==="left"?(this.iconWrapper.x=h+o/2,this.nameText.x=h+o+i+n/2):(this.nameText.x=h+n/2,this.iconWrapper.x=h+n+i+o/2),this.iconWrapper.y=0,this.nameText.y=0}updateName(t){this.nameText.text=t,this.layout()}refreshColor(t){const{type:i}=this.appService.roomConfig,s=this.appService.getRoomData(this.roomId),n=(s==null?void 0:s.colorIndex)??this.roomIndex,o=this.getRoomNameColor(n,t);this.nameText.style.fill=o,this.iconBg&&this.drawIconBg(o),this.iconSprite&&(this.iconSprite.tint=i.container.visible?"#ffffff":o)}getRoomNameColor(t,i){const{colors:s}=this.appService.roomConfig,{enableRoomSelection:n,selectRoomIds:o}=this.appService.runtime;if(i)return i;if(n)return!o.includes(this.roomId)&&s.nameInactive?s.nameInactive[t%s.nameInactive.length]:s.name[t%s.name.length];const a=s.nameNormal||s.name;return a[t%a.length]}async updateRoomType(t){const{type:i}=this.appService.roomConfig;if(!this.appService.runtime.showRoomType||t==null||!(i!=null&&i.assets)||!i.assets[t])this.iconWrapper&&(this.iconWrapper.visible=!1);else{const n=this.appService.getRoomData(this.roomId),o=(n==null?void 0:n.colorIndex)??this.roomIndex,a=this.getRoomNameColor(o);this.createIcon(t,a),this.iconWrapper&&(this.iconWrapper.visible=!0)}this.layout()}updateRoomTypeVisibility(t){if(this.iconWrapper)this.iconWrapper.visible=t,this.layout();else if(t){const i=this.appService.getRoomData(this.roomId);i&&this.updateRoomType(i.type??null)}}destroy(t){this.iconBg&&(this.iconBg.destroy(),this.iconBg=null),this.iconSprite&&(this.iconSprite.destroy(),this.iconSprite=null),this.iconWrapper&&(this.iconWrapper.destroy(),this.iconWrapper=null),super.destroy(t)}}class LS extends L{constructor(t,i){super();g(this,"background");g(this,"foldedIndicator");g(this,"propertyIcons",new Map);g(this,"orderContainer");g(this,"orderBackground");g(this,"orderText");g(this,"isFolded",!1);g(this,"roomId");g(this,"roomIndex");g(this,"isDestroyed",!1);this.appService=t;const s=this.appService.roomConfig;this.roomId=i.id,this.roomIndex=i.index,this.background=new H,this.foldedIndicator=new H,this.foldedIndicator.visible=!1;const{property:n}=s,o=i.colorIndex??i.index,a=this.getIconColor(o);this.initializePropertyIcons(n.displayOrders,a);const h=n.cleanOrder.color==="auto"?s.colors.active[o%s.colors.active.length]:n.cleanOrder.color;this.orderContainer=new L,this.orderBackground=new H,this.orderText=new Bs({text:"",style:new ce({fontSize:n.cleanOrder.fontSize,fontFamily:n.cleanOrder.fontFamily,fontWeight:n.cleanOrder.fontWeight,fill:h,align:"center",trim:!0})}),this.orderText.anchor.set(.5,.5),this.orderContainer.addChild(this.orderBackground),this.orderContainer.addChild(this.orderText),this.addChild(this.background),this.addChild(this.foldedIndicator),this.propertyIcons.forEach(({sprite:l})=>{this.addChild(l)}),this.addChild(this.orderContainer),this.visible=this.appService.runtimeSnapshot.showRoomProperty}initializePropertyIcons(t,i){const s=["cleanMode","suction","cistern","cleanTimes"];t.forEach(n=>{const o=s.includes(n),a=new Xt(this.appService);a.tint=i,a.anchor.set(0,0),this.propertyIcons.set(n,{fieldName:n,sprite:a,isBuiltin:o})})}async updateProperty(t){this.isDestroyed||this.destroyed||(await this.updateIcons(t),!(this.isDestroyed||this.destroyed)&&this.updateBackground())}getFieldValue(t,i){if(["cleanMode","suction","cistern","cleanTimes"].includes(i))return t[i]??null;if(t.customData&&i in t.customData){const n=t.customData[i];return typeof n=="number"?n:null}return null}getAssetAlias(t,i){const s={cleanMode:n=>`cleanMode_${n}`,suction:n=>`fan_${n}`,cistern:n=>`water_${n}`,cleanTimes:n=>`cleanTimes${n}`};return t in s?s[t](i):`custom_${t}_${i}`}shouldShowField(t,i,s){const{showRoomProperty:n}=this.appService.runtimeSnapshot;return!(s===null||!n||i==="cleanTimes"&&s<=0)}getDisplayElements(t){const{displayOrders:i}=this.appService.roomConfig.property,{showRoomOrder:s}=this.appService.runtimeSnapshot,n=t.order||0,o=s&&n>0,a=[];return o&&a.push({element:this.orderContainer,show:!0,isOrder:!0,fieldName:"order"}),i.forEach(h=>{const l=this.propertyIcons.get(h);if(!l||!l.sprite)return;const c=this.getFieldValue(t,h);this.shouldShowField(t,h,c)&&c!==null&&a.push({element:l.sprite,show:!0,isOrder:!1,fieldName:h,value:c})}),{elementsToShow:a,orderValue:n}}async updateIcons(t){if(this.isDestroyed||this.destroyed||this.isFolded)return;const{iconWidth:i,iconHeight:s,container:n,cleanOrder:o,iconGap:a}=this.appService.roomConfig.property,{paddingHorizontal:h,paddingVertical:l}=n,{elementsToShow:c,orderValue:d}=this.getDisplayElements(t);this.orderContainer.visible=!1,this.propertyIcons.forEach(({sprite:f})=>{f.visible=!1});const u=[];if(c.forEach(f=>{if(f.isOrder){this.orderContainer.visible=!0,this.orderText.text=d.toString();const y=t.colorIndex??this.roomIndex,m=this.getIconColor(y);this.orderBackground.clear(),this.orderBackground.setFillStyle({color:m}),this.orderBackground.circle(i/2,s/2,i/2).fill();const x=this.resolveOrderTextColor(y);this.orderText.style.fill=x,this.orderText.position.set(i/2,s/2)}else{const y=this.propertyIcons.get(f.fieldName);if(y&&y.sprite){y.sprite.visible=!0;const m=this.getAssetAlias(f.fieldName,f.value);u.push(y.sprite.loadTextureAndSetSize(m,{width:i,height:s,sizeFixed:!1}))}}}),await Promise.all(u),this.isDestroyed||this.destroyed)return;let p=h;c.forEach((f,y)=>{const{element:m,isOrder:x}=f;!m||!m.position||(m.position.set(p,l),p+=i,y<c.length-1&&(x?p+=o.gapRight:p+=a))})}updateBackground(){if(this.isDestroyed||this.destroyed)return;const t=this.appService.roomConfig,{container:i,foldable:s}=t.property,{borderRadius:n,tailHeight:o,tailWidth:a,backgroundColor:h}=i,l=this.calculateContentWidth(),c=this.calculateContentHeight(),d=Math.min(n,l/2,c/2),u=d*.8,p=Math.max(l-u*2,a*.5),f=Math.min(a,l/2,p);if(this.background.clear(),this.background.setFillStyle({color:h}),s){const y=(l-f)/2,m=c+o;this.background.moveTo(d,0),this.background.lineTo(l-d,0),this.background.arcTo(l,0,l,d,d),this.background.lineTo(l,c-d),this.background.arcTo(l,c,l-d,c,d),this.background.lineTo(y+f,c),this.background.lineTo(y+f/2,m),this.background.lineTo(y,c),this.background.lineTo(d,c),this.background.arcTo(0,c,0,c-d,d),this.background.lineTo(0,d),this.background.arcTo(0,0,d,0,d),this.background.closePath()}else this.background.roundRect(0,0,l,c,d);this.background.fill()}calculateContentWidth(){const{iconWidth:t,container:i,cleanOrder:s,iconGap:n}=this.appService.roomConfig.property,{paddingHorizontal:o}=i,a=this.appService.getRoomData(this.roomId);if(!a)return o*2;const{elementsToShow:h}=this.getDisplayElements(a);let l=o;return h.forEach((c,d)=>{const{isOrder:u}=c;l+=t,d<h.length-1&&(u?l+=s.gapRight:l+=n)}),l+=o,l}calculateContentHeight(){const t=this.appService.roomConfig,{iconHeight:i,container:s}=t.property;return s.paddingVertical+i+s.paddingVertical}getTotalHeight(){const{foldable:t,container:i}=this.appService.roomConfig.property,{tailHeight:s}=i;return this.isFolded?s:this.calculateContentHeight()+(t?s:0)}getTotalWidth(){if(this.isFolded){const{tailWidth:i}=this.appService.roomConfig.property.container,s=this.calculateContentWidth();return Math.min(i,s/2)}return this.calculateContentWidth()}async setFolded(t){const{foldable:i}=this.appService.roomConfig.property;if(i)if(this.isFolded=t,t)this.background.visible=!1,this.orderContainer.visible=!1,this.propertyIcons.forEach(({sprite:s})=>{s.visible=!1}),this.foldedIndicator.visible=!0,this.updateFoldedIndicator();else{this.background.visible=!0,this.foldedIndicator.visible=!1,this.foldedIndicator.position.set(0,0),this.updateBackground();const s=this.appService.getRoomData(this.roomId);s&&await this.updateIcons(s)}}isFoldedState(){const{foldable:t}=this.appService.roomConfig.property;return t?this.isFolded:!1}updateFoldedIndicator(){const t=this.appService.roomConfig,{tailHeight:i,tailWidth:s,backgroundColor:n}=t.property.container,o=this.calculateContentWidth(),a=Math.min(s,o/2);this.foldedIndicator.clear(),this.foldedIndicator.setFillStyle({color:n}),this.foldedIndicator.poly([0,i,a,i,a/2,0]).fill(),this.foldedIndicator.position.set(0,0)}resolveOrderTextColor(t){const{property:i,colors:s}=this.appService.roomConfig,{enableRoomSelection:n}=this.appService.runtime;if(i.cleanOrder.color==="auto"){const o=n?s.active:s.normal||s.active;return o[t%o.length]}return i.cleanOrder.color}getIconColor(t){const{colors:i}=this.appService.roomConfig,{propertyTheme:s,propertyThemeInactive:n,propertyThemeNormal:o}=i,{enableRoomSelection:a,selectRoomIds:h}=this.appService.runtime;if(a)return!h.includes(this.roomId)&&n?n[t%n.length]:s[t%s.length];const l=o||s;return l[t%l.length]}refreshColor(){const t=this.appService.getRoomData(this.roomId),i=(t==null?void 0:t.colorIndex)??this.roomIndex,s=this.getIconColor(i);if(this.propertyIcons.forEach(({sprite:n})=>{n.tint=s}),this.orderBackground&&this.orderBackground.visible){const{property:n}=this.appService.roomConfig,o=n.iconWidth,a=n.iconHeight;this.orderBackground.clear(),this.orderBackground.setFillStyle({color:s}),this.orderBackground.circle(o/2,a/2,o/2).fill();const h=this.resolveOrderTextColor(i);this.orderText.style.fill=h}}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.propertyIcons.forEach(({sprite:t})=>{t.destroy()}),this.propertyIcons.clear(),super.destroy({children:!0}))}}class OS extends L{constructor(t,i){super();g(this,"background");g(this,"checkmarkIcon");g(this,"bubble");g(this,"roomIndex");g(this,"roomId");this.appService=t;const s=this.appService.roomConfig;this.roomId=i.id,this.roomIndex=i.index,this.background=new H,this.bubble=new H;const{colors:{selectionIndicatorIcon:n}}=s;this.checkmarkIcon=new Xt(this.appService);const o=i.colorIndex??i.index;this.checkmarkIcon.tint=n[o%n.length],this.checkmarkIcon.anchor.set(0,0),this.addChild(this.background),this.addChild(this.bubble),this.addChild(this.checkmarkIcon)}async updateIndicator(t){const{roomSelectionMode:i,enableRoomSelection:s,selectRoomIds:n}=this.appService.runtimeSnapshot;if(!s||i!=="checkmark"){this.visible=!1;return}const o=n.includes(t.id);await this.showCheckmarkMode(o),this.updateBackground()}async showCheckmarkMode(t){const{selectionIndicator:i}=this.appService.roomConfig,{iconWidth:s,iconHeight:n}=i;if(t){this.visible=!0,this.checkmarkIcon.visible=!0,await this.checkmarkIcon.loadTextureAndSetSize("checkmark",{width:s,height:n,sizeFixed:!1});const o=i.containerWidth/2,a=i.containerHeight/2;this.checkmarkIcon.position.set(o-s/2,a-n/2)}else this.visible=!1}updateBackground(){const{selectionIndicator:t,colors:i}=this.appService.roomConfig,{containerWidth:s,containerHeight:n,strokeWidth:o,strokeColor:a,borderRadius:h,tailHeight:l,tailWidth:c}=t,d=this.appService.getRoomData(this.roomId),u=(d==null?void 0:d.colorIndex)??this.roomIndex,p=i.selectionIndicatorBackground[u%i.selectionIndicatorBackground.length],f=a==="auto"?p:a;if(this.checkmarkIcon.tint=i.selectionIndicatorIcon[u%i.selectionIndicatorIcon.length],this.background.clear(),this.bubble.clear(),this.background.setFillStyle({color:p}).roundRect(0,0,s,n,h).fill().setStrokeStyle({color:f,width:o,alignment:0}).stroke(),l>0&&c>0){const y=(s-c)/2;this.bubble.setFillStyle({color:f});const m=n+o;this.bubble.poly([y,m-1,y+c,m-1,y+c/2,m+l]).fill()}}getTotalHeight(){const{selectionIndicator:t}=this.appService.roomConfig,{containerHeight:i,tailHeight:s,strokeWidth:n}=t;return i+n+(s>0?s:0)}getTotalWidth(){const{selectionIndicator:t}=this.appService.roomConfig;return t.containerWidth}async refreshColor(){const t=this.appService.getRoomData(this.roomId);t&&await this.updateIndicator(t)}destroy(){var t;(t=this.checkmarkIcon)==null||t.destroy(),super.destroy({children:!0})}}class GS extends L{constructor(t,i){super();g(this,"roomId");g(this,"roomName");g(this,"roomProperty",null);g(this,"roomSelectionIndicator",null);g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);g(this,"targetElasticScale",1);g(this,"currentElasticScale",1);g(this,"isAnimatingScale",!1);g(this,"scaleAnimationBound",null);g(this,"updateScaleBound",null);this.appService=t,this.enableRenderGroup(),this.roomId=i.id,this.initializeElasticScale(t.currentScale),this.updateScaleBound=s=>this.updateScale(s),this.appService.emitter.on("antiScale",this.updateScaleBound),this.updateScale(this.appService.currentScale),i.centerPoint&&this.position.set(i.centerPoint.x,i.centerPoint.y),this.roomName=new zS(this.appService,i),this.roomName.visible=this.appService.runtimeSnapshot.showRoomName,this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=W(this.appService.runtime,"mapRotation",s=>{this.applyAntiRotation(s)}),this.clickHandler=new vt(this,{onClick:()=>{var s,n;(n=(s=this.appService.events)==null?void 0:s.onClickRoomProperties)==null||n.call(s,i)}})}async initialize(t){await this.createRoomProperty(t),await this.createRoomSelectionIndicator(t),this.updateLayout()}applyAntiRotation(t){const i=-t*Math.PI/180;this.rotation=i}initializeElasticScale(t){const{enableElasticScale:i,elasticMinScale:s,elasticMaxScale:n}=this.appService.roomConfig;if(!i)return;const o=1,a=5;let h;t<=o?h=s:t>=a?h=n:h=1,this.targetElasticScale=h,this.currentElasticScale=h}updateScale(t){const{enableElasticScale:i,elasticMinScale:s,elasticMaxScale:n}=this.appService.roomConfig;if(!i){t!==0&&this.scale.set(1/t);return}if(t===0)return;const o=1,a=5;let h;t<=o?h=s:t>=a?h=n:h=1;const c=1/t*h;Math.abs(this.targetElasticScale-h)>.01?(this.targetElasticScale=h,this.startScaleAnimation()):this.scale.set(c)}startScaleAnimation(){this.scaleAnimationBound||(this.scaleAnimationBound=this.animateScale.bind(this)),this.isAnimatingScale||(this.isAnimatingScale=!0,this.appService.getApp().ticker.add(this.scaleAnimationBound))}animateScale(){this.currentElasticScale+=(this.targetElasticScale-this.currentElasticScale)*.3;const n=1/this.appService.currentScale*this.currentElasticScale;this.scale.set(n),Math.abs(this.currentElasticScale-this.targetElasticScale)<.001&&(this.currentElasticScale=this.targetElasticScale,this.isAnimatingScale=!1,this.scaleAnimationBound&&this.appService.getApp().ticker.remove(this.scaleAnimationBound))}shouldShowRoomProperty(){const{showRoomOrder:t,showRoomProperty:i,selectRoomIds:s,enableRoomSelection:n,roomSelectionMode:o}=this.appService.runtimeSnapshot,a=this.appService.getRoomData(this.roomId);if(!a||n&&o==="checkmark"&&s.includes(this.roomId))return!1;const h=t&&(a.order||0)>0;let l=!1;if(i){const{displayOrders:c}=this.appService.roomConfig.property;l=c.some(d=>!!(d==="suction"&&a.suction!=null||d==="cistern"&&a.cistern!=null||d==="cleanMode"&&a.cleanMode!=null||d==="cleanTimes"&&a.cleanTimes>0||a.customData&&d in a.customData&&typeof a.customData[d]=="number"&&a.customData[d]!=null))}return h||l}shouldShowRoomSelectionIndicator(){const{enableRoomSelection:t,roomSelectionMode:i}=this.appService.runtimeSnapshot;return t&&i==="checkmark"}async updateRoomPropertyVisibility(){if(!this.roomProperty)return;if(!this.shouldShowRoomProperty())this.roomProperty.visible=!1;else{this.roomProperty.visible=!0;const i=this.appService.runtimeSnapshot.roomPropertyFoldIds.includes(this.roomId);await this.roomProperty.setFolded(i);const s=this.appService.getRoomData(this.roomId);s&&await this.roomProperty.updateProperty(s)}this.updateLayout()}async updateRoomSelectionIndicatorVisibility(){if(!this.roomSelectionIndicator)return;if(this.shouldShowRoomSelectionIndicator()){const i=this.appService.getRoomData(this.roomId);i&&await this.roomSelectionIndicator.updateIndicator(i)}else this.roomSelectionIndicator.visible=!1;this.updateLayout()}async createRoomProperty(t){this.roomProperty&&(this.removeChild(this.roomProperty),this.roomProperty.destroy()),this.roomProperty=new LS(this.appService,t),await this.roomProperty.updateProperty(t),this.addChild(this.roomProperty),this.addChild(this.roomName),await this.updateRoomPropertyVisibility(),this.updateLayout()}async createRoomSelectionIndicator(t){this.roomSelectionIndicator&&(this.removeChild(this.roomSelectionIndicator),this.roomSelectionIndicator.destroy()),this.roomSelectionIndicator=new OS(this.appService,t),await this.updateRoomSelectionIndicatorVisibility(),this.addChild(this.roomSelectionIndicator)}updateLayout(){var l,c,d,u,p,f;if(this.destroyed)return;const{property:{offsetY:t,offsetX:i},selectionIndicator:{offsetY:s,offsetX:n}}=this.appService.roomConfig,o=((l=this.roomProperty)==null?void 0:l.visible)||!1,a=((c=this.roomName)==null?void 0:c.visible)||!1,h=((d=this.roomSelectionIndicator)==null?void 0:d.visible)||!1;if(o&&this.roomProperty){const y=this.roomProperty.getTotalHeight(),m=this.roomProperty.getTotalWidth();if(this.roomProperty.isFoldedState()){const S=-m/2+i,v=-y/2-t;this.roomProperty.position.set(S,v)}else a&&((u=this.roomName)!=null&&u.position)?(this.roomProperty.position.set(-m/2+i,-t-y),this.roomName.position.set(0,0)):this.roomProperty.position.set(-m/2+i,-y/2-t)}if(h&&this.roomSelectionIndicator){const y=this.roomSelectionIndicator.getTotalHeight(),m=this.roomSelectionIndicator.getTotalWidth();a&&((p=this.roomName)!=null&&p.position)?(this.roomSelectionIndicator.position.set(-m/2+n,-s-y),this.roomName.position.set(0,0)):this.roomSelectionIndicator.position.set(-m/2+n,-y/2-s)}a&&!o&&!h&&((f=this.roomName)!=null&&f.position)&&this.roomName.position.set(0,0)}updateName(t){this.roomName.updateName(t)}async updateRoomType(t){await this.roomName.updateRoomType(t),this.updateLayout()}updateRoomNameVisibility(t){this.roomName.visible=t,this.updateLayout()}updateRoomTypeVisibility(t){this.roomName.updateRoomTypeVisibility(t),this.updateLayout()}updatePosition(t){this.position.set(t.x,t.y)}async refreshColor(){this.roomName&&this.roomName.refreshColor(),this.roomProperty&&this.roomProperty.refreshColor(),this.roomSelectionIndicator&&await this.roomSelectionIndicator.refreshColor()}destroy(){var t,i,s,n;(t=this.clickHandler)==null||t.destroy(),this.clickHandler=null,this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.isAnimatingScale&&this.scaleAnimationBound&&(this.appService.getApp().ticker.remove(this.scaleAnimationBound),this.isAnimatingScale=!1),this.scaleAnimationBound=null,this.updateScaleBound&&(this.appService.emitter.off("antiScale",this.updateScaleBound),this.updateScaleBound=null),(i=this.roomProperty)==null||i.destroy(),this.roomProperty=null,(s=this.roomSelectionIndicator)==null||s.destroy(),this.roomSelectionIndicator=null,(n=this.roomName)==null||n.destroy(),super.destroy()}}class WS extends L{constructor(t){super({isRenderGroup:!0});g(this,"floorTypeMap",new Map);g(this,"floorTypeMasks",new Map);g(this,"floorTypeContexts",new Map);g(this,"floorTypeToRooms",new Map);this.appService=t,this.appService.appContainer.addToLayer(Gr,this)}async createFloorTypes(t){if(!this.appService.runtimeSnapshot.showRoomFloorType)return;this.clearFloorTypes();const s=this.groupRoomsByFloorType(t),n=[];for(const[o,a]of s)n.push(this.createMergedFloorType(o,a));await Promise.all(n)}groupRoomsByFloorType(t){const i=new Map,s=this.appService;return t.forEach((n,o)=>{const a=s.getRoomData(o),h=(a==null?void 0:a.floorType)||0;h>=0&&(i.has(h)||i.set(h,[]),i.get(h).push({roomId:o,graphics:n}))}),i}async createMergedFloorType(t,i){const s=this.appService,{assets:n,opacity:o,scale:a}=s.roomConfig.floorType,h=t%n.length,l=`floorType${h}`;if(!n[h]){w.warn(`No texture asset configured for floorType: ${t}`);return}const c=await N.load(l);if(!c){w.warn(`Floor material texture not found: ${l}`);return}const d=i.map(({graphics:m})=>m.getLocalBounds()),u=by(d),p=new bs({texture:c,width:u.width,height:u.height});p.autoGarbageCollect=!1,p.x=u.x,p.y=u.y,p.alpha=o,p.tileScale.set(a);const{maskContainer:f,contexts:y}=this.createMergedMask(i.map(({graphics:m})=>m));p.mask=f,this.addChild(p),this.floorTypeMap.set(t,p),this.floorTypeMasks.set(t,f),this.floorTypeContexts.set(t,y),this.floorTypeToRooms.set(t,new Set(i.map(({roomId:m})=>m)))}createMergedMask(t){const i=new L,s=[];return t.forEach(n=>{const o=new H;o.autoGarbageCollect=!1;const a=n.context.clone();a.autoGarbageCollect=!1,o.context=a,s.push(a),i.addChild(o)}),{maskContainer:i,contexts:s}}clearFloorTypes(){this.floorTypeMasks.forEach(t=>{try{t.destroy({children:!0})}catch(i){w.warn("Error destroying floor mask:",i)}}),this.floorTypeMasks.clear(),this.floorTypeContexts.forEach(t=>{try{t.forEach(i=>{try{i.destroy()}catch(s){w.warn("Error destroying cloned graphics context:",s)}})}catch(i){w.warn("Error destroying graphics contexts:",i)}}),this.floorTypeContexts.clear(),this.floorTypeMap.forEach(t=>{try{this.removeChild(t),t.destroy()}catch(i){w.warn("Error destroying floor material:",i)}}),this.floorTypeMap.clear(),this.floorTypeToRooms.clear()}destroy(){this.clearFloorTypes(),super.destroy()}}class US{constructor(e){g(this,"unsubscribeFns",[]);g(this,"roomInfoContainer",new L);g(this,"roomInfoMap",new Map);g(this,"roomDisplayMap",new Map);g(this,"roomFloorType");this.appService=e,this.roomFloorType=new WS(e),e.appContainer.addToLayer(fc,this.roomInfoContainer);const t=W(e.runtime,"showRoomFloorType",d=>{w.log(`[runtime] showRoomFloorType: ${d}`),d?this.updateFloorTypes():this.roomFloorType.clearFloorTypes()}),i=W(e.runtime,"showRoomProperty",d=>{w.log(`[runtime] showRoomProperty: ${d}`),this.updateAllRoomPropertyVisibility()}),s=W(e.runtime,"showRoomOrder",d=>{w.log(`[runtime] showRoomOrder: ${d}`),this.updateAllRoomPropertyVisibility()}),n=W(e.runtime,"roomPropertyFoldIds",d=>{w.log(`[runtime] roomPropertyFoldIds: ${d}`),this.updateAllRoomPropertyVisibility()}),o=W(e.runtime,"showRoomName",d=>{w.log(`[runtime] showRoomName: ${d}`),this.updateAllRoomNameVisibility(d)}),a=W(e.runtime,"showRoomType",d=>{w.log(`[runtime] showRoomType: ${d}`),this.updateAllRoomTypeVisibility(d)}),h=W(e.runtime,"enableRoomSelection",d=>{w.log(`[runtime] enableRoomSelection: ${d}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility(),this.refreshAllRoomColors()}),l=W(e.runtime,"selectRoomIds",d=>{w.log(`[runtime] selectRoomIds: ${d}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility(),this.refreshAllRoomColors()}),c=W(e.runtime,"roomSelectionMode",d=>{w.log(`[runtime] roomSelectionMode: ${d}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility(),this.refreshAllRoomColors()});this.unsubscribeFns.push(t,i,s,n,o,a,h,l,c)}async drawRoomProperty(e){const t=this.appService;return this.roomDisplayMap.clear(),e.forEach((i,s)=>{const n=t.mapManager.getRoomById(i.id),o={...i,centerPoint:(n==null?void 0:n.centerPoint)||null,index:s,colorIndex:n==null?void 0:n.colorIndex};this.roomDisplayMap.set(i.id,o)}),await this.updateRoomInfoDisplay(),await this.updateFloorTypes(),!0}async updateRoomInfoDisplay(){if(this.roomDisplayMap.size===0){this.appService.mapManager.getAllRooms().length===0&&this.clearRoomInfos();return}const e=Array.from(this.roomDisplayMap.values()).filter(t=>t.centerPoint!==null);this.clearRoomInfos(),await Promise.all(e.map(t=>this.createRoomInfo(t)))}async createRoomInfo(e){const t=new GS(this.appService,e);this.roomInfoContainer.addChild(t),this.roomInfoMap.set(e.id,t),await t.initialize(e)}updateRoomName(e,t){const i=this.roomInfoMap.get(e);i&&i.updateName(t)}async updateRoomType(e,t){const i=this.roomDisplayMap.get(e);i&&(i.type=t);const s=this.roomInfoMap.get(e);s&&await s.updateRoomType(t)}updateRoomPosition(e,t){const i=this.roomDisplayMap.get(e);i&&(i.centerPoint=t);const s=this.roomInfoMap.get(e);s&&s.updatePosition(t)}clearRoomInfos(){if(this.roomInfoMap.size===0)return;const e=Array.from(this.roomInfoMap.values());this.roomInfoContainer.removeChildren(),e.forEach(t=>{try{t.destroy()}catch(i){w.warn(`[RoomManager] Error destroying RoomInfo for room ${t.roomId}:`,i)}}),this.roomInfoMap.clear()}getRoomPropertyById(e){return this.roomDisplayMap.get(e)}async refresh(){const e=this.appService;this.roomFloorType.clearFloorTypes(),this.roomDisplayMap.forEach((t,i)=>{const s=e.mapManager.getRoomById(i),n=(s==null?void 0:s.centerPoint)||null;if(t.centerPoint!==n){t.centerPoint=n;const a=this.roomInfoMap.get(i);a&&n&&a.updatePosition(n)}const o=s==null?void 0:s.colorIndex;if(t.colorIndex!==o&&o!==void 0){t.colorIndex=o;const a=this.roomInfoMap.get(i);a&&a.refreshColor()}}),await this.updateRoomInfoDisplay(),await this.updateFloorTypes()}async updateAllRoomPropertyVisibility(){this.roomInfoMap.size!==0&&await Promise.all(Array.from(this.roomInfoMap.values()).map(async e=>{try{await e.updateRoomPropertyVisibility()}catch(t){console.warn(`[RoomManager] Failed to update room property visibility for room ${e.roomId}`,t)}}))}updateAllRoomNameVisibility(e){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(t=>{t.updateRoomNameVisibility(e)})}updateAllRoomTypeVisibility(e){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(t=>{t.updateRoomTypeVisibility(e)})}updateAllRoomSelectionIndicatorVisibility(){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(e=>{e.updateRoomSelectionIndicatorVisibility()})}refreshAllRoomColors(){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(e=>{e.refreshColor()})}async updateFloorTypes(){const e=this.appService,t=e.mapManager.roomFill.getRoomGraphicsMap();t.size>0?(await this.roomFloorType.createFloorTypes(t),e.getApp().renderOnceNextFrame()):e.mapManager.getAllRooms().length===0&&this.roomFloorType.clearFloorTypes()}clear(){this.clearRoomInfos(),this.roomInfoContainer.removeChildren(),this.roomInfoMap.clear(),this.roomDisplayMap.clear(),this.roomFloorType.clearFloorTypes()}destroy(){this.clearRoomInfos(),this.roomInfoContainer.destroy(),this.roomFloorType.destroy(),this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[]}}var Qa,Ja;(Qa=navigator==null?void 0:navigator.userAgent)!=null&&Qa.includes("tuya-ark-ide")||((Ja=navigator==null?void 0:navigator.userAgent)==null||Ja.includes("miniProgram"));const HS=()=>{var i,s;if(!Gn.any)return!0;const r=navigator.userAgent.toLowerCase(),e=()=>{const n=navigator.deviceMemory;return n?n>=4:!0};let t=!1;if(/iphone|ipad|ipod/.test(r)){const n=(i=r.match(/os (\d+)_/))==null?void 0:i[1];t=(n?parseInt(n):0)>=12}else if(/android/.test(r)){const n=(s=r.match(/android (\d+)/))==null?void 0:s[1];t=(n?parseInt(n):0)>=10}return t&&e()};class VS extends L{constructor(t,i,s){super();g(this,"graphics");g(this,"sprite",null);g(this,"viewportBounds");g(this,"lastConfig",null);g(this,"onImageLoaded");this.label="background",this.viewportBounds=i,this.onImageLoaded=s,this.graphics=new H,this.graphics.label="backgroundGraphics",this.addChild(this.graphics),this.render(t)}async render(t){if(this.lastConfig=t,this.clear(),t.backgroundImage){await this.renderImage(t.backgroundImage,t.backgroundAlpha);return}if(t.backgroundGradient){this.renderGradient(t.backgroundGradient);return}if(t.backgroundColor!==void 0){this.renderSolidColor(t.backgroundColor,t.backgroundAlpha);return}w.warn("[Background] No background configuration provided")}clear(){this.graphics.clear(),this.sprite&&(this.removeChild(this.sprite),this.sprite.destroy(),this.sprite=null)}renderSolidColor(t,i){this.graphics.clear(),this.graphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill({color:t,alpha:i}),w.debug("[Background] Rendered solid color background",{color:t,alpha:i})}renderGradient(t){const{width:i,height:s}=this.viewportBounds;if(this.graphics.clear(),t.type==="linear"){const n=t.x0??0,o=t.y0??0,a=t.x1??1,h=t.y1??1,l=new Ot({type:"linear",start:{x:n,y:o},end:{x:a,y:h},colorStops:t.colorStops});this.graphics.rect(0,0,i,s).fill(l),w.debug("[Background] Rendered linear gradient background",{x0:n,y0:o,x1:a,y1:h,colorStops:t.colorStops.length})}else if(t.type==="radial"){const n=t.cx??.5,o=t.cy??.5,a=t.r??.5,h=new Ot({type:"radial",center:{x:n,y:o},innerRadius:0,outerCenter:{x:n,y:o},outerRadius:a,colorStops:t.colorStops});this.graphics.rect(0,0,i,s).fill(h),w.debug("[Background] Rendered radial gradient background",{cx:n,cy:o,r:a,colorStops:t.colorStops.length})}}async renderImage(t,i){var s,n,o,a;try{const h=await N.load(t.src);if(!h){w.error("[Background] Failed to load image:",t.src),(s=this.lastConfig)!=null&&s.backgroundColor&&this.renderSolidColor(this.lastConfig.backgroundColor,i);return}this.sprite=new jt(h),this.sprite.autoGarbageCollect=!1,this.sprite.label="backgroundSprite",this.sprite.alpha=i;const{width:l,height:c}=this.viewportBounds,d=t.fit||"cover",u=((n=t.position)==null?void 0:n.x)??.5,p=((o=t.position)==null?void 0:o.y)??.5,f=h.width,y=h.height,m=f/y,x=l/c;switch(d){case"fill":this.sprite.width=l,this.sprite.height=c,this.sprite.x=0,this.sprite.y=0;break;case"contain":m>x?(this.sprite.width=l,this.sprite.height=l/m):(this.sprite.height=c,this.sprite.width=c*m),this.sprite.x=(l-this.sprite.width)*u,this.sprite.y=(c-this.sprite.height)*p;break;case"cover":m>x?(this.sprite.height=c,this.sprite.width=c*m):(this.sprite.width=l,this.sprite.height=l/m),this.sprite.x=(l-this.sprite.width)*u,this.sprite.y=(c-this.sprite.height)*p;break;case"none":this.sprite.width=f,this.sprite.height=y,this.sprite.x=(l-f)*u,this.sprite.y=(c-y)*p;break}t.repeat&&w.warn("[Background] Repeat mode not yet implemented"),this.addChild(this.sprite),w.debug("[Background] Rendered image background",{src:t.src,fit:d,position:{x:u,y:p},spriteSize:{width:this.sprite.width,height:this.sprite.height}}),this.onImageLoaded&&this.onImageLoaded()}catch(h){w.error("[Background] Error loading background image:",h),(a=this.lastConfig)!=null&&a.backgroundColor&&this.renderSolidColor(this.lastConfig.backgroundColor,i)}}async update(t){await this.render(t)}destroy(){this.clear(),super.destroy()}}class NS extends L{constructor(t){super();g(this,"carpetData");g(this,"carpetConfig");g(this,"controlsConfig");g(this,"carpetEvents");g(this,"appService");g(this,"controlFill");g(this,"editControlLayer");g(this,"clickHandler",null);g(this,"maskContainer",null);g(this,"maskGraphics",null);g(this,"texture",null);g(this,"textureMap",new Map);g(this,"tilingSprite",null);g(this,"initialZonePoints",[]);g(this,"unsubscribeFns",[]);g(this,"resolvedMaxSizeCache",null);g(this,"handleDragStart",()=>{this.isEditingEnabled()&&(this.carpetData.points&&this.carpetData.points.length>0?this.initialZonePoints=this.carpetData.points.map(t=>({...t})):this.initialZonePoints=[],this.appService.getApp().requestRender("zone-drag",!0))});g(this,"handleDragMove",t=>{if(!this.isEditingEnabled()||this.initialZonePoints.length===0||this.carpetData.shape==="custom")return;const i=this.parent.toLocal(t.global),s=this.controlFill.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleDragEnd",()=>{var t,i;this.initialZonePoints=[],this.appService.getApp().stopRender("zone-drag"),(i=(t=this.carpetEvents).onUpdate)==null||i.call(t,this.getCarpetData())});g(this,"handleMoveStart",()=>{this.carpetData.points&&this.carpetData.points.length>0?this.initialZonePoints=this.carpetData.points.map(t=>({...t})):this.initialZonePoints=[],this.appService.getApp().requestRender("zone-move",!0)});g(this,"handleMove",t=>{var a,h;if(!this.isEditingEnabled()||this.initialZonePoints.length===0)return;const i=this.parent.toLocal(t.global),s=(h=(a=this.editControlLayer)==null?void 0:a.getMoveButton())==null?void 0:h.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleMoveEnd",()=>{var t,i;this.initialZonePoints=[],this.appService.getApp().stopRender("zone-move"),(i=(t=this.carpetEvents).onUpdate)==null||i.call(t,this.getCarpetData())});g(this,"handleRotationStart",()=>{this.appService.getApp().requestRender("zone-rotate",!0)});g(this,"handleRotationMove",t=>{t&&(this.carpetData.points=t,this.drawCarpet())});g(this,"handleRotationEnd",()=>{var t,i;this.appService.getApp().stopRender("zone-rotate"),(i=(t=this.carpetEvents).onUpdate)==null||i.call(t,this.getCarpetData())});g(this,"handleScaleStart",()=>{this.appService.getApp().requestRender("zone-scale",!0)});g(this,"handleScaleMove",t=>{t&&(this.carpetData.points=t,this.drawCarpet())});g(this,"handleScaleMoveHorizontal",t=>{t&&(this.carpetData.points=t,this.drawCarpet())});g(this,"handleScaleMoveVertical",t=>{t&&(this.carpetData.points=t,this.drawCarpet())});g(this,"handleScaleEnd",()=>{var t,i;this.appService.getApp().stopRender("zone-scale"),(i=(t=this.carpetEvents).onUpdate)==null||i.call(t,this.getCarpetData())});g(this,"handleDelete",()=>{var t,i;(i=(t=this.carpetEvents).onRemove)==null||i.call(t,this.carpetData.id)});g(this,"handleClick",()=>{var t,i;this.isEditingEnabled()||(i=(t=this.carpetEvents)==null?void 0:t.onClick)==null||i.call(t,this.getCarpetData())});g(this,"handlePointsUpdate",t=>{this.carpetData.points=t,this.drawCarpet()});const{appService:i,carpetData:s,events:n={},textureMap:o}=t;this.appService=i,this.textureMap=o,this.carpetEvents=n,this.controlsConfig=this.getControlsConfig(),this.carpetConfig=this.controlsConfig.carpet,this.processCarpetData(s),this.initializeComponents(),this.createEditControlLayer(),this.setupClickHandler(),this.setupEnableRoomSelectionListener(),this.updateEditState(),this.loadTexture()}getResolvedMaxSize(){const t=this.carpetConfig.maxSize;if(this.resolvedMaxSizeCache&&this.resolvedMaxSizeCache.key===t)return this.resolvedMaxSizeCache.value;const i=Hr(this.carpetConfig.minSize,t,"carpet");return this.resolvedMaxSizeCache={key:t,value:i},i}processCarpetData(t){if(t.points&&t.points.length>=2)if(t.shape==="custom")this.carpetData={...t,points:t.points};else{const s=this.getResolvedMaxSize(),n=nr(t.points,this.appService.metersToPixels(this.carpetConfig.minSize),s!=null?this.appService.metersToPixels(s):void 0),o=Cs(n);this.carpetData={...t,points:o}}else this.carpetData={...t,points:[],shape:t.shape||"rectangle"}}getControlsConfig(){const{controls:t}=this.appService.getConfig();return t}isEditingEnabled(){return this.appService.runtimeSnapshot.editingCarpetIds.includes(this.carpetData.id)}isSelected(){return this.appService.runtimeSnapshot.selectedCarpetIds.includes(this.carpetData.id)}shouldShowEditControl(){return this.isEditingEnabled()||this.isSelected()}initializeComponents(){this.maskContainer=this.createMaskContainer(),this.controlFill=this.createControlFill(),this.addChild(this.maskContainer),this.addChild(this.controlFill),this.drawCarpet()}createMaskContainer(){const t=new L;return this.maskGraphics=new H,this.maskGraphics.autoGarbageCollect=!1,this.updateMaskShape(),t.addChild(this.maskGraphics),t.mask=this.maskGraphics,t}createControlFill(){const t=this.isEditingEnabled();return new Ur(this.appService,{points:this.carpetData.points||[],fillColor:this.carpetConfig.fillColor,enableInteraction:t,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createEditControlLayer(){const t=this.isEditingEnabled(),i=this.carpetData.shape==="custom",s={...An(this.carpetConfig,["outlineStrokeWidth","outlineDashed","outlineDashArray","outlineFillColor","outlineOffset","outlineStrokeColor"]),...An(this.carpetConfig,["textColor","textPosition","textOffset"]),...An(this.controlsConfig,["textFontSize","textFontFamily","textFontWeight"]),showRotateButton:!!t&&!i&&this.carpetConfig.showRotateButton,showScaleButton:!!t&&!i,showDeleteButton:!!t,showMoveButton:!!t&&!i,showRadialScaleButton:!!t&&!i,iconWrapperFillColor:this.carpetConfig.iconWrapperFillColor,moveButtonOffset:this.controlsConfig.moveButtonOffset},n=i?this.calculateBoundingRectanglePoints():this.carpetData.points||[];this.editControlLayer=this.appService.editControlManager.registerEditControl(this.carpetData.id,{config:s,zonePoints:n,minSize:this.carpetConfig.minSize,maxSize:this.getResolvedMaxSize(),contentLayer:$e,events:{onRemove:this.handleDelete,onRotateStart:this.handleRotationStart,onRotateMove:this.handleRotationMove,onRotateEnd:this.handleRotationEnd,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleMoveHorizontal:this.handleScaleMoveHorizontal,onScaleMoveVertical:this.handleScaleMoveVertical,onScaleEnd:this.handleScaleEnd,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd,onClick:this.handleClick,onPointsUpdate:this.handlePointsUpdate}})}setupClickHandler(){this.interactiveChildren=!0,this.clickHandler=new vt(this,{onClick:()=>{var t,i;this.isEditingEnabled()||(i=(t=this.carpetEvents)==null?void 0:t.onClick)==null||i.call(t,this.getCarpetData())},stopPropagation:!1})}setupEnableRoomSelectionListener(){const t=W(this.appService.runtime,"enableRoomSelection",s=>{this.updateClickHandlerState(s)});this.unsubscribeFns.push(t);const i=this.appService.runtimeSnapshot.enableRoomSelection;this.updateClickHandlerState(i)}isRoomSelectionEnabled(){return this.appService.runtimeSnapshot.enableRoomSelection}updateClickHandlerState(t){if(t){if(this.eventMode="none",this.clickHandler){const i=this.clickHandler.getTarget();i.eventMode="none"}}else if(this.eventMode="static",this.clickHandler){const i=this.clickHandler.getTarget();i.eventMode="static"}}calculateBounds(){const{points:t}=this.carpetData;let i=1/0,s=1/0,n=-1/0,o=-1/0;if(t&&t.length>0)for(const a of t)i=Math.min(i,a.x),s=Math.min(s,a.y),n=Math.max(n,a.x),o=Math.max(o,a.y);return{minX:i,minY:s,maxX:n,maxY:o}}calculateBoundingRectanglePoints(){const{points:t}=this.carpetData;if(!t||t.length===0)return[];const{minX:i,minY:s,maxX:n,maxY:o}=ws(t);return[{x:i,y:s},{x:n,y:s},{x:n,y:o},{x:i,y:o}]}updateMaskShape(){if(!this.maskGraphics)return;this.maskGraphics.clear();const{points:t,shape:i}=this.carpetData;if(!(!t||!Array.isArray(t)||t.length<2)){if(i==="round"){if(t.length<4)return;const n=de(t),[o,a,,h]=t,l=Q(o,a),c=Q(o,h),d=Math.atan2(a.y-o.y,a.x-o.x);this.maskGraphics.position.set(n.x,n.y),this.maskGraphics.rotation=d,this.maskGraphics.ellipse(0,0,l/2,c/2)}else{const n=t.flatMap(o=>[o.x,o.y]);this.maskGraphics.poly(n),this.maskGraphics.position.set(0,0),this.maskGraphics.rotation=0}this.maskGraphics.fill(16777215)}}loadTexture(){const{opacity:t,scale:i}=this.appService.carpetConfig,{type:s}=this.carpetData;try{this.texture=this.textureMap.get(s)||this.textureMap.get(-1)||null,this.texture&&this.maskContainer&&(this.tilingSprite&&(this.maskContainer.removeChild(this.tilingSprite),this.tilingSprite.destroy(),this.tilingSprite=null),this.createTilingSprite(i,t),this.appService.getApp().renderOnce())}catch(n){console.warn("Failed to load carpet texture:",n)}}createTilingSprite(t,i){if(!this.texture||!this.maskContainer)return;const s=this.calculateBounds();this.tilingSprite=new bs({texture:this.texture,width:s.maxX-s.minX+100,height:s.maxY-s.minY+100}),this.tilingSprite.autoGarbageCollect=!1,this.tilingSprite.position.set(s.minX-50,s.minY-50),this.tilingSprite.tileScale.set(t),this.tilingSprite.alpha=i,this.maskContainer.addChild(this.tilingSprite)}updateTilingSprite(){if(!this.tilingSprite)return;const t=this.calculateBounds();this.tilingSprite.position.set(t.minX-50,t.minY-50),this.tilingSprite.width=t.maxX-t.minX+100,this.tilingSprite.height=t.maxY-t.minY+100}applyTranslation(t,i){this.carpetData.points=this.initialZonePoints.map(s=>({x:s.x+t,y:s.y+i})),this.drawCarpet()}drawCarpet(){const{points:t}=this.carpetData;if(!(!t||t.length<2)&&(this.updateMaskShape(),this.updateTilingSprite(),this.controlFill.updatePoints(t),this.editControlLayer)){const n=this.carpetData.shape==="custom"?this.calculateBoundingRectanglePoints():t;this.editControlLayer.updatePoints(n)}}updateEditState(){const t=this.isEditingEnabled(),i=this.isSelected(),s=this.shouldShowEditControl();if(this.controlFill.setInteractionEnabled(t),this.editControlLayer)if(i&&!t)this.appService.editControlManager.updateEditState(this.carpetData.id,{showRotateButton:!1,showScaleButton:!1,showDeleteButton:!1,showMoveButton:!1,showBorder:!0,showSizeText:!1,borderStyle:this.carpetConfig.normal});else if(t){const n=this.carpetData.shape==="custom";this.appService.editControlManager.updateEditState(this.carpetData.id,{showRotateButton:!n&&this.carpetConfig.showRotateButton,showScaleButton:!n,showDeleteButton:!0,showMoveButton:!n,showBorder:!0,showSizeText:!0,borderStyle:this.carpetConfig.editing,showRadialScaleButton:!n})}else this.appService.editControlManager.updateEditState(this.carpetData.id,{showRotateButton:!1,showScaleButton:!1,showDeleteButton:!1,showMoveButton:!1,showBorder:!1,showSizeText:!1});this.zIndex=s?1e3:0}updateCarpetData(t){const s=this.carpetData.type;if(t.points&&t.points.length>=2)if(t.shape==="custom")this.carpetData={...t,points:t.points};else{const n=this.getResolvedMaxSize(),o=nr(t.points,this.appService.metersToPixels(this.carpetConfig.minSize),n!=null?this.appService.metersToPixels(n):void 0),a=Cs(o);this.carpetData={...t,points:a}}else this.carpetData={...t,points:t.points||[]};s!==this.carpetData.type&&this.loadTexture(),this.drawCarpet(),this.updateEditState()}getCarpetData(){return{...this.carpetData}}refreshDisplay(){this.drawCarpet()}destroy(){var t,i,s,n,o;this.appService.editControlManager.unregisterEditControl(this.carpetData.id),this.unsubscribeFns.forEach(a=>a()),this.unsubscribeFns=[],(t=this.tilingSprite)==null||t.destroy(),(i=this.maskGraphics)==null||i.destroy(),(s=this.maskContainer)==null||s.destroy(),this.tilingSprite=null,this.maskGraphics=null,this.maskContainer=null,this.texture=null,(n=this.controlFill)==null||n.destroy(),(o=this.clickHandler)==null||o.destroy(),super.destroy()}}class jS{constructor(e){g(this,"customCarpetMap",new Map);g(this,"unsubscribeFns",[]);g(this,"textureMap",new Map);g(this,"texturesLoaded",!1);g(this,"texturesLoadingPromise",null);this.appService=e,this.applyLayerVisibility(e.runtime.showCustomCarpets);const t=W(e.runtime,"editingCarpetIds",n=>{w.log(`[runtime] editingCarpetIds: ${n}`),this.updateCarpetsEditState()}),i=W(e.runtime,"selectedCarpetIds",n=>{w.log(`[runtime] selectedCarpetIds: ${n}`),this.updateCarpetsEditState()}),s=W(e.runtime,"showCustomCarpets",n=>{w.log(`[runtime] showCustomCarpets: ${n}`),this.applyLayerVisibility(n)});this.unsubscribeFns.push(t,i,s)}async loadTextures(){if(!this.texturesLoaded){if(this.texturesLoadingPromise)return this.texturesLoadingPromise;this.texturesLoadingPromise=this._loadTextures(),await this.texturesLoadingPromise,this.texturesLoaded=!0,this.texturesLoadingPromise=null}}async _loadTextures(){const e=this.appService,{material:t,src:i}=e.carpetConfig;if(t)for(const s of t){const n=await N.load(s.src);this.textureMap.set(s.type,n)}if(i){const s=await N.load(i);this.textureMap.set(-1,s)}}async drawCustomCarpets(e){if(await this.loadTextures(),!e||e.length===0){this.clearAllCustomCarpets();return}const t=new Set(this.customCarpetMap.keys()),i=new Set(e.map(s=>s.id));for(const s of t)i.has(s)||this.removeCustomCarpet(s);e.forEach(s=>{const n=this.customCarpetMap.get(s.id.toString());n?this.isCarpetDataEqual(n.getCarpetData(),s)||n.updateCarpetData(s):this.addNewCustomCarpet(s)})}getCustomCarpets(){const e=[];return this.customCarpetMap.forEach(t=>{e.push(t.getCarpetData())}),e}getCustomCarpetById(e){return this.customCarpetMap.get(e)}clearAllCustomCarpets(){this.customCarpetMap.forEach((e,t)=>{var s;const i=this.customCarpetMap.get(t);i&&((s=i.parent)==null||s.removeChild(i),i.destroy())}),this.customCarpetMap.clear()}addNewCustomCarpet(e){const t=this.appService,i=new NS({appService:t,carpetData:e,textureMap:this.textureMap,events:{onRemove:s=>{var n,o;(o=(n=t.events)==null?void 0:n.onDeleteCustomCarpet)==null||o.call(n,{id:s})},onUpdate:s=>{var n,o;(o=(n=t.events)==null?void 0:n.onUpdateCustomCarpet)==null||o.call(n,s)},onClick:s=>{var n,o;(o=(n=t.events)==null?void 0:n.onClickCarpet)==null||o.call(n,{id:s.id})}}});this.customCarpetMap.set(e.id.toString(),i),t.appContainer.addToLayer($e,i)}removeCustomCarpet(e){const t=this.appService,i=this.customCarpetMap.get(e);i&&(t.appContainer.removeFromLayer($e,i),i.destroy(),this.customCarpetMap.delete(e))}updateCarpetsEditState(){this.customCarpetMap.forEach(e=>{e.updateEditState()})}applyLayerVisibility(e){const t=this.appService.appContainer.getLayer($e);t&&(t.visible=e)}isCarpetDataEqual(e,t){if(e.id!==t.id||e.type!==t.type||e.shape!==t.shape)return!1;const i=e.points||[],s=t.points||[];if(i.length!==s.length)return!1;for(let n=0;n<i.length;n++){const o=i[n],a=s[n];if(Math.abs(o.x-a.x)>.1||Math.abs(o.y-a.y)>.1)return!1}return!0}refreshDisplay(){this.customCarpetMap.forEach(e=>{e.refreshDisplay()})}destroy(){this.clearAllCustomCarpets(),this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[]}}class YS extends Ni{constructor(e,t){super(e,t),this.cursor="pointer"}setupEvents(){this.on("pointerdown",e=>{e.stopPropagation()}),this.on("pointertap",()=>{var e,t;(t=(e=this.options).onClick)==null||t.call(e)})}destroy(){this.removeAllListeners(),super.destroy()}}const Rt={REMOVE:0,ROTATE:1,SCALE:2,MOVE:3,FIXED:0};class XS extends L{constructor(t){super();g(this,"appService");g(this,"data");g(this,"furnitureEvents");g(this,"textureAlias");g(this,"sprite");g(this,"controlButtons");g(this,"outlineBorder");g(this,"moveLine");g(this,"deleteButton",null);g(this,"rotateButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"sizeText",null);g(this,"isEditing",!1);g(this,"dragStartPosition",null);g(this,"initialPoints",[]);g(this,"clickHandler",null);g(this,"isDragging",!1);g(this,"initialScalePoints",[]);g(this,"initialButtonPosition",null);g(this,"rotationCount",0);g(this,"originalEdgeLengths",null);g(this,"onDragStart",t=>{if(!this.isEditing||!this.parent||t.target!==this&&t.target!==this.sprite)return;t.stopPropagation();const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},this.initialPoints=this.data.points.map(s=>({...s})),this.isDragging=!1,this.setupDragEventListeners(),this.appService.emitter.emit("gestureHijackStart",t)});g(this,"onDragMove",t=>{if(!this.dragStartPosition||!this.parent)return;const i=this.parent.toLocal(t.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;!this.isDragging&&Math.abs(s)+Math.abs(n)<3||(this.isDragging||(this.isDragging=!0,this.appService.getApp().requestRender("furniture-drag",!0)),this.data.points=this.initialPoints.map(o=>({x:o.x+s,y:o.y+n})),this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText())});g(this,"onDragEnd",()=>{var t,i;this.dragStartPosition&&(this.cleanupDragEventListeners(),this.isDragging&&((i=(t=this.furnitureEvents).onUpdate)==null||i.call(t,this.getData()),this.appService.getApp().stopRender("furniture-drag")),this.dragStartPosition=null,this.initialPoints=[],this.isDragging=!1)});g(this,"onDragCancel",()=>{this.dragStartPosition&&(this.cleanupDragEventListeners(),this.isDragging&&this.appService.getApp().stopRender("furniture-drag"),this.dragStartPosition=null,this.initialPoints=[],this.isDragging=!1)});g(this,"handleScaleStart",()=>{this.initialScalePoints=this.data.points.map(i=>({...i}));const t=this.getVisualIndex(Rt.SCALE);t>=0&&t<this.data.points.length&&(this.initialButtonPosition={...this.data.points[t]}),this.appService.getApp().requestRender("furniture-scale",!0)});g(this,"handleScaleMove",({deltaX:t,deltaY:i})=>{if(this.initialScalePoints.length===0||!this.initialButtonPosition)return;const s={x:this.initialButtonPosition.x+t,y:this.initialButtonPosition.y+i};this.applyEdgeBasedScale(s)});g(this,"handleScaleEnd",()=>{var t,i;this.initialScalePoints=[],this.initialButtonPosition=null,this.appService.getApp().stopRender("furniture-scale"),(i=(t=this.furnitureEvents).onUpdate)==null||i.call(t,this.getData())});g(this,"handleMoveStart",()=>{this.initialPoints=this.data.points.map(t=>({...t})),this.appService.getApp().requestRender("furniture-move",!0)});g(this,"handleMoveMove",t=>{var a;if(!this.isEditing||this.initialPoints.length===0||!this.parent)return;const i=this.parent.toLocal(t.global),s=(a=this.moveButton)==null?void 0:a.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.data.points=this.initialPoints.map(h=>({x:h.x+n,y:h.y+o})),this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText()});g(this,"handleMoveEnd",()=>{var t,i;this.initialPoints=[],this.appService.getApp().stopRender("furniture-move"),(i=(t=this.furnitureEvents).onUpdate)==null||i.call(t,this.getData())});const{appService:i,data:s,textureAlias:n,events:o={}}=t;this.appService=i,this.data={...s,points:s.points.map(a=>({...a}))},this.textureAlias=n,this.furnitureEvents=o,this.createSprite(),this.updateSpriteTransform(),this.createEditControls(),this.captureOriginalEdgeLengths(),this.eventMode="static",this.cursor="pointer",this.setupInteraction()}get config(){return this.appService.furnitureConfig}captureOriginalEdgeLengths(){const t=this.data.points;if(t.length<4)return;const i=this.getVisualIndex(Rt.FIXED),s=this.getVisualIndex(1),n=this.getVisualIndex(3);this.originalEdgeLengths={edge1:Q(t[i],t[s]),edge2:Q(t[i],t[n])}}getVisualIndex(t){return(t+4-this.rotationCount)%4}getVisualPoints(){const t=this.data.points;return[t[this.getVisualIndex(0)],t[this.getVisualIndex(1)],t[this.getVisualIndex(2)],t[this.getVisualIndex(3)]]}createSprite(){const t=N.get(this.textureAlias);this.sprite=new jt(t),this.sprite.anchor.set(.5),this.sprite.alpha=this.config.opacity,this.sprite.eventMode="passive",this.addChild(this.sprite)}updateSpriteTransform(){const t=this.data.points;if(t.length<4)return;const i=de(t),s=t[1].x-t[0].x,n=t[1].y-t[0].y,o=Math.atan2(n,s),a=Q(t[0],t[1]),h=Q(t[1],t[2]);this.sprite.position.set(i.x,i.y),this.sprite.rotation=o,this.sprite.width=a,this.sprite.height=h}createEditControls(){const t=this.calculateOutlinePoints();this.outlineBorder=new Nt(this.appService,{points:t,closePath:!0,style:{color:this.config.outlineStrokeColor,width:this.config.outlineStrokeWidth,isDashed:this.config.outlineDashed,dashArray:this.config.outlineDashArray,fillColor:this.config.outlineFillColor}}),this.outlineBorder.visible=!1,this.addChild(this.outlineBorder);const i=this.calculateMoveLinePoints(t);this.moveLine=new Nt(this.appService,{points:i,closePath:!1,style:{color:this.config.outlineStrokeColor,width:this.config.outlineStrokeWidth,isDashed:this.config.outlineDashed,dashArray:this.config.outlineDashArray}}),this.moveLine.visible=!1,this.addChild(this.moveLine),this.controlButtons=new L,this.controlButtons.visible=!1,this.addChild(this.controlButtons),this.createControlButtons()}createControlButtons(){const t=this.calculateOutlinePoints();if(t.length<4)return;const{iconWrapperFillColor:i}=this.config,s=this.getVisualIndex(Rt.REMOVE),n=this.getVisualIndex(Rt.ROTATE),o=this.getVisualIndex(Rt.SCALE);this.deleteButton=new zs(this.appService,{iconAlias:"deleteIcon",backgroundColor:i,onClick:()=>{var h,l;return(l=(h=this.furnitureEvents).onRemove)==null?void 0:l.call(h,this.data.id)}}),this.deleteButton.position.set(t[s].x,t[s].y),this.rotateButton=new YS(this.appService,{iconAlias:"rotateIcon",backgroundColor:i,onClick:()=>this.handleTapRotate()}),this.rotateButton.position.set(t[n].x,t[n].y),this.scaleButton=new Qe(this.appService,{iconAlias:"scaleIcon",backgroundColor:i,getTargetPoints:()=>this.data.points,getButtonIndex:()=>this.getVisualIndex(Rt.SCALE),onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(t[o].x,t[o].y);const a=this.calculateMoveButtonPosition(t);this.moveButton=new Ls(this.appService,{iconAlias:"moveIcon",backgroundColor:i,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMoveMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(a.x,a.y),this.controlButtons.addChild(this.deleteButton),this.controlButtons.addChild(this.rotateButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton),this.config.showSizeText&&(this.sizeText=this.createSizeText(),this.controlButtons.addChild(this.sizeText))}calculateOutlinePoints(){const{points:t}=this.data;if(t.length<4)return t;const i=this.appService.getApp().toFixedSize(this.config.outlineOffset);return zr(t,i)}calculateMoveButtonPosition(t){const i=t??this.calculateOutlinePoints();if(i.length<4)return{x:0,y:0};const{controls:s}=this.appService.getConfig(),n=this.getVisualIndex(Rt.MOVE),o=this.getVisualIndex(2),a=this.getVisualIndex(0),h=this.appService.getApp().toFixedSize(s.moveButtonOffset);return Ds(i[n],i[o],i[a],h)}calculateMoveLinePoints(t,i){if(t.length<4)return[];const s=this.getVisualIndex(Rt.MOVE),n=i??this.calculateMoveButtonPosition(t);return[t[s],n]}createSizeText(){const t=this.calculateSizeTextContent(),i=this.appService.controlsConfig,s=new ji(this.appService,{text:t,style:{fontSize:i.textFontSize,fontFamily:i.textFontFamily,fontWeight:i.textFontWeight,fill:this.config.textColor,align:"center"}});s.anchor.set(.5);const n=this.calculateSizeTextPosition();s.position.set(n.x,n.y);const o=this.calculateSizeTextRotation();return s.rotation=o,s.eventMode="none",s}calculateSizeTextContent(){const{points:t}=this.data;if(t.length<4)return"0m*0m";const[i,s,,n]=this.getVisualPoints(),o=Q(i,s),a=Q(i,n),h=this.rotationCount%2!==0,l=h?a:o,c=h?o:a,d=this.appService.pixelsToMeters(l),u=this.appService.pixelsToMeters(c),p=this.appService.metersToDisplayUnit(d),f=this.appService.metersToDisplayUnit(u),y=this.appService.runtimeSnapshot.unitLabel;return`${p.toFixed(1)}${y}*${f.toFixed(1)}${y}`}calculateSizeTextPosition(){const{points:t}=this.data;if(t.length<4)return{x:0,y:0};const[i,s,n,o]=this.getVisualPoints(),{textPosition:a,textOffset:h}=this.config,l=this.appService.getApp().toFixedSize(h);let c,d;switch(a){case"top":{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2};const u=gt(K(s,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"right":{c={x:(s.x+n.x)/2,y:(s.y+n.y)/2};const u=gt(K(s,n)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"bottom":{c={x:(o.x+n.x)/2,y:(o.y+n.y)/2};const u=gt(K(o,n)),p={x:-u.y,y:u.x};d={x:p.x*l,y:p.y*l};break}case"left":{c={x:(i.x+o.x)/2,y:(i.y+o.y)/2};const u=gt(K(o,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}default:c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:0,y:l};break}return{x:c.x+d.x,y:c.y+d.y}}calculateSizeTextRotation(){const{points:t}=this.data;if(t.length<4)return 0;const[i,s,n,o]=this.getVisualPoints(),{textPosition:a}=this.config;let h,l;switch(a){case"top":h=i,l=s;break;case"right":h=s,l=n;break;case"bottom":h=n,l=o;break;case"left":h=o,l=i;break;default:h=i,l=s;break}const c=this.appService.appContainer.getMapRotationRadians();return qe(h,l,c)}setupInteraction(){this.clickHandler=new vt(this,{onClick:t=>{var i,s;!this.isDragging&&((t==null?void 0:t.target)===this||(t==null?void 0:t.target)===this.sprite)&&((s=(i=this.furnitureEvents).onClick)==null||s.call(i,this.getData()))}}),this.on("pointerdown",this.onDragStart,this)}setupDragEventListeners(){const{emitter:t}=this.appService;t.on("gestureHijackPointerMove",this.onDragMove),t.on("gestureHijackPointerUp",this.onDragEnd),t.on("gestureHijackCancel",this.onDragCancel)}cleanupDragEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.onDragMove),t.off("gestureHijackPointerUp",this.onDragEnd),t.off("gestureHijackCancel",this.onDragCancel)}handleTapRotate(){var n,o;const t=this.config.rotateDirection!=="ccw",i=t?Math.PI/2:-Math.PI/2,s=de(this.data.points);this.data.points=Fr(this.data.points,s,i),this.rotationCount=(this.rotationCount+(t?1:3))%4,this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText(),(o=(n=this.furnitureEvents).onUpdate)==null||o.call(n,this.getData())}applyEdgeBasedScale(t){if(this.initialScalePoints.length<4)return;const i=this.getVisualIndex(Rt.FIXED),s=this.getVisualIndex(1),n=this.getVisualIndex(3),{x:o,y:a}=this.initialScalePoints[i],h=this.initialScalePoints[s],l=this.initialScalePoints[n],c={x:o,y:a},d=K(c,h),u=K(c,l),p=K(c,t),f=ee(d),y=ee(u);if(f===0||y===0)return;const{minScaleRatio:m,maxScaleRatio:x}=this.config;let S=ae(p,d,f,0),v=ae(p,u,y,0);if(this.config.lockAspectRatio){const C=Math.min(S,v);S=C,v=C}if(this.originalEdgeLengths){const C=this.rotationCount%2!==0,A=C?this.originalEdgeLengths.edge2:this.originalEdgeLengths.edge1,k=C?this.originalEdgeLengths.edge1:this.originalEdgeLengths.edge2,M=S*f/A,T=v*y/k;let _=Math.max(m,Math.min(x,M)),E=Math.max(m,Math.min(x,T));if(this.config.lockAspectRatio){const B=Math.min(_,E);_=B,E=B}S=_*A/f,v=E*k/y}else if(S=Math.max(m,Math.min(x,S)),v=Math.max(m,Math.min(x,v)),this.config.lockAspectRatio){const C=Math.min(S,v);S=C,v=C}const b=[c,{x:o+d.x*S,y:a+d.y*S},{x:o+d.x*S+u.x*v,y:a+d.y*S+u.y*v},{x:o+u.x*v,y:a+u.y*v}],P=new Array(4);for(let C=0;C<4;C++)P[this.getVisualIndex(C)]=b[C];this.data.points=P,this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText(!0)}updateEditControls(){var h;const t=this.calculateOutlinePoints();if(t.length<4)return;this.outlineBorder.updatePoints(t);const i=this.calculateMoveButtonPosition(t),s=this.calculateMoveLinePoints(t,i);if(this.moveLine.updatePoints(s),!this.deleteButton||!this.rotateButton||!this.scaleButton)return;const n=this.getVisualIndex(Rt.REMOVE),o=this.getVisualIndex(Rt.ROTATE),a=this.getVisualIndex(Rt.SCALE);this.deleteButton.position.set(t[n].x,t[n].y),this.rotateButton.position.set(t[o].x,t[o].y),this.scaleButton.position.set(t[a].x,t[a].y),(h=this.moveButton)==null||h.position.set(i.x,i.y)}updateSizeText(t=!1){if(!this.sizeText)return;if(t){const n=this.calculateSizeTextContent();this.sizeText.updateText(n)}const i=this.calculateSizeTextPosition();this.sizeText.position.set(i.x,i.y);const s=this.calculateSizeTextRotation();this.sizeText.rotation=s}getData(){return{id:this.data.id,furnitureType:this.data.furnitureType,points:this.data.points.map(t=>({...t}))}}updateData(t){this.data={...t,points:t.points.map(i=>({...i}))},this.rotationCount=0,this.captureOriginalEdgeLengths(),this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText(!0)}updateEditState(t){this.isEditing!==t&&(this.isEditing=t,this.outlineBorder.visible=t,this.moveLine.visible=t,this.controlButtons.visible=t,t&&(this.updateEditControls(),this.updateSizeText(!0)))}destroy(){var t;this.cleanupDragEventListeners(),(t=this.clickHandler)==null||t.destroy(),this.clickHandler=null,super.destroy({children:!0})}}class ZS{constructor(e){g(this,"furnitureMap",new Map);g(this,"unsubscribeFns",[]);this.appService=e,this.applyLayerVisibility(e.runtime.showFurnitures);const t=W(e.runtime,"editingFurnitureIds",s=>{w.log(`[runtime] editingFurnitureIds: ${s}`),this.updateEditState()}),i=W(e.runtime,"showFurnitures",s=>{w.log(`[runtime] showFurnitures: ${s}`),this.applyLayerVisibility(s)});this.unsubscribeFns.push(t,i)}async drawFurnitures(e){if(!e||e.length===0){this.clearAll();return}const t=new Set(this.furnitureMap.keys()),i=new Set(e.map(n=>n.id));for(const n of t)i.has(n)||this.removeFurniture(n);const s=[];for(const n of e){const o=this.furnitureMap.get(n.id);o?this.isDataEqual(o.getData(),n)||o.updateData(n):s.push(this.addFurniture(n))}await Promise.all(s)}async addFurniture(e){const t=this.appService;if(!t.furnitureConfig.assets.find(h=>h.type===e.furnitureType)){w.warn(`[FurnitureManager] No asset found for furnitureType: ${e.furnitureType}`);return}const n=`furniture_${e.furnitureType}`;await N.load(n);const o=new XS({appService:t,data:e,textureAlias:n,events:{onRemove:h=>{var l,c;(c=(l=t.events)==null?void 0:l.onRemoveFurniture)==null||c.call(l,h)},onUpdate:h=>{var l,c;(c=(l=t.events)==null?void 0:l.onUpdateFurniture)==null||c.call(l,h)},onClick:h=>{var l,c;(c=(l=t.events)==null?void 0:l.onClickFurniture)==null||c.call(l,h)}}});this.furnitureMap.set(e.id,o),t.appContainer.addToLayer(je,o),t.runtime.editingFurnitureIds.includes(e.id)&&(o.updateEditState(!0),this.moveToEditLayer(o))}removeFurniture(e){var i;const t=this.furnitureMap.get(e);t&&((i=t.parent)==null||i.removeChild(t),t.destroy(),this.furnitureMap.delete(e))}clearAll(){var e;for(const[,t]of this.furnitureMap)(e=t.parent)==null||e.removeChild(t),t.destroy();this.furnitureMap.clear()}applyLayerVisibility(e){const t=this.appService.appContainer.getLayer(je);t&&(t.visible=e),this.furnitureMap.forEach(i=>{i.visible=e})}updateEditState(){const e=this.appService.runtime.editingFurnitureIds,{appContainer:t}=this.appService,i=t.getLayer(je);this.furnitureMap.forEach((s,n)=>{const o=e.includes(n);s.updateEditState(o),o?this.moveToEditLayer(s):s.parent!==i&&this.moveToFurnitureLayer(s)})}moveToEditLayer(e){var t;(t=e.parent)==null||t.removeChild(e),this.appService.appContainer.addToLayer(ke,e)}moveToFurnitureLayer(e){var t;(t=e.parent)==null||t.removeChild(e),this.appService.appContainer.addToLayer(je,e)}getFurnitures(){const e=[];return this.furnitureMap.forEach(t=>{e.push(t.getData())}),e}isDataEqual(e,t){if(e.id!==t.id||e.furnitureType!==t.furnitureType||e.points.length!==t.points.length)return!1;for(let i=0;i<e.points.length;i++)if(Math.abs(e.points[i].x-t.points[i].x)>.1||Math.abs(e.points[i].y-t.points[i].y)>.1)return!1;return!0}destroy(){this.clearAll(),this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[]}}const pt={REMOVE:0,ROTATE:1,SCALE:2,MOVE:3};class qS extends L{constructor(t,i){super();g(this,"config");g(this,"events");g(this,"zonePoints",[]);g(this,"outlinePoints");g(this,"minSize",.1);g(this,"maxSize");g(this,"initialZonePoints",[]);g(this,"scaleCache",null);g(this,"rotationCache",null);g(this,"outlineBorder");g(this,"moveLine");g(this,"sizeText");g(this,"controlButtons");g(this,"deleteButton",null);g(this,"rotateButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"horizontalScaleButton",null);g(this,"verticalScaleButton",null);g(this,"horizontalScaleInitialPosition",null);g(this,"verticalScaleInitialPosition",null);g(this,"clickHandler",null);g(this,"throttledUpdateOutline");this.appService=t,this.zonePoints=i.zonePoints,this.config={...i.config,showScaleButton:i.config.showScaleButton!==void 0?i.config.showScaleButton:!0,showRadialScaleButton:i.config.showRadialScaleButton!==void 0?i.config.showRadialScaleButton:!0,showDeleteButton:i.config.showDeleteButton!==void 0?i.config.showDeleteButton:!0,showMoveButton:i.config.showMoveButton!==void 0?i.config.showMoveButton:!0,showRotateButton:i.config.showRotateButton!==void 0?i.config.showRotateButton:!0},this.events=i.events||{},this.minSize=i.minSize??.1,this.maxSize=i.maxSize,this.throttledUpdateOutline=Ct(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.registerScaleListener()}initializeComponents(){this.outlinePoints=this.calculateOutlinePoints(),this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.moveLine.visible=this.config.showMoveButton||!1,this.sizeText=this.createSizeText(),this.addChild(this.sizeText),this.controlButtons=new L,this.addChild(this.controlButtons),this.createControlButtons(),this.setupClickHandler()}createOutlineBorder(){const{outlineStrokeColor:t,outlineStrokeWidth:i,outlineDashed:s,outlineDashArray:n,outlineFillColor:o}=this.config;return new Nt(this.appService,{points:this.outlinePoints,closePath:!0,style:{color:t,width:i,isDashed:s,dashArray:n,fillColor:o}})}createMoveLine(){const{outlineStrokeColor:t,outlineStrokeWidth:i,outlineDashed:s,outlineDashArray:n}=this.config,o=this.calculateMoveLinePoints();return new Nt(this.appService,{points:o,closePath:!1,style:{color:t,width:i,isDashed:s,dashArray:n}})}createSizeText(){const t=this.calculateSizeText(),i=new ji(this.appService,{text:t,style:{fontSize:this.config.textFontSize,fontFamily:this.config.textFontFamily,fontWeight:this.config.textFontWeight,fill:this.config.textColor,align:"center"}});i.anchor.set(.5);const s=this.calculateSizeTextPosition();i.position.set(s.x,s.y);const n=this.calculateSizeTextRotation();return i.rotation=n,i.eventMode="none",i}createDeleteButton(){const t=new zs(this.appService,{iconAlias:"deleteIcon",backgroundColor:"red",onClick:()=>{var i,s;return(s=(i=this.events).onRemove)==null?void 0:s.call(i)}});return t.position.set(this.outlinePoints[pt.REMOVE].x,this.outlinePoints[pt.REMOVE].y),t}createRotateButton(){const t=new Sc(this.appService,{iconAlias:"rotateIcon",backgroundColor:this.config.iconWrapperFillColor,getTargetPoints:()=>this.zonePoints,onRotationStart:i=>{var s,n;this.initializeRotationCache(i),(n=(s=this.events).onRotateStart)==null||n.call(s,i)},onClick:()=>{var n,o;const i=Math.PI/2,s=this.onClickRotateButton(i);(o=(n=this.events).onRotateMove)==null||o.call(n,s??void 0)},onRotationEnd:()=>{var i,s;this.resetRotationState(),(s=(i=this.events).onRotateEnd)==null||s.call(i)}});return t.position.set(this.outlinePoints[pt.ROTATE].x,this.outlinePoints[pt.ROTATE].y),t}onClickRotateButton(t){const i=this.handleInternalRotationMove(t)??[];return this.resetRotationState(),i}createScaleButton(){const t=new Qe(this.appService,{iconAlias:"scaleIcon",backgroundColor:this.config.iconWrapperFillColor,initialButtonPosition:this.outlinePoints[pt.SCALE],onScaleStart:()=>{var i,s;this.initializeScaleCache(),(s=(i=this.events).onScaleStart)==null||s.call(i)},onScaleMove:({deltaX:i,deltaY:s})=>{var o,a;const n=this.handleInternalScaleMove(i,s);(a=(o=this.events).onScaleMove)==null||a.call(o,n??void 0)},onScaleEnd:()=>{var i,s;this.resetScaleState(),this.initialZonePoints=[],(s=(i=this.events).onScaleEnd)==null||s.call(i)}});return t.position.set(this.outlinePoints[pt.SCALE].x,this.outlinePoints[pt.SCALE].y),t}createHorizontalScaleButton(){const[,t,i]=this.outlinePoints,s=this.getEdgeCenter(t,i),n=new Qe(this.appService,{iconAlias:"horizontalScaleIcon",backgroundColor:this.config.iconWrapperFillColor,config:{iconWrapperWidth:18,iconWrapperHeight:18,iconWrapperBorderRadius:18,iconWidth:10,iconHeight:8},initialButtonPosition:s,onScaleStart:()=>{var h,l;const[,o,a]=this.zonePoints;this.horizontalScaleInitialPosition=this.getEdgeCenter(o,a),this.initializeScaleCache(),(l=(h=this.events).onScaleStart)==null||l.call(h)},onScaleMove:({deltaX:o,deltaY:a})=>{var l,c;const h=this.handleInternalHorizontalScaleMove(o,a);(c=(l=this.events).onScaleMoveHorizontal)==null||c.call(l,h??void 0)},onScaleEnd:()=>{var o,a;this.resetScaleState(),this.initialZonePoints=[],this.horizontalScaleInitialPosition=null,(a=(o=this.events).onScaleEnd)==null||a.call(o)}});return n.position.set(s.x,s.y),n}createVerticalScaleButton(){const[,,t,i]=this.outlinePoints,s=this.getEdgeCenter(t,i),n=new Qe(this.appService,{iconAlias:"verticalScaleIcon",backgroundColor:this.config.iconWrapperFillColor,config:{iconWrapperWidth:18,iconWrapperHeight:18,iconWrapperBorderRadius:18,iconWidth:8,iconHeight:10},initialButtonPosition:s,onScaleStart:()=>{var h,l;const[,,o,a]=this.zonePoints;this.verticalScaleInitialPosition=this.getEdgeCenter(o,a),this.initializeScaleCache(),(l=(h=this.events).onScaleStart)==null||l.call(h)},onScaleMove:({deltaX:o,deltaY:a})=>{var l,c;const h=this.handleInternalVerticalScaleMove(o,a);(c=(l=this.events).onScaleMoveVertical)==null||c.call(l,h??void 0)},onScaleEnd:()=>{var o,a;this.resetScaleState(),this.initialZonePoints=[],this.verticalScaleInitialPosition=null,(a=(o=this.events).onScaleEnd)==null||a.call(o)}});return n.position.set(s.x,s.y),n}createMoveButton(){const t=this.calculateMoveButtonPosition(),i=new Ls(this.appService,{iconAlias:"moveIcon",backgroundColor:this.config.iconWrapperFillColor,onMoveStart:()=>{var s,n;return(n=(s=this.events).onMoveStart)==null?void 0:n.call(s)},onMoveMove:s=>{var n,o;return(o=(n=this.events).onMoveMove)==null?void 0:o.call(n,s)},onMoveEnd:()=>{var s,n;return(n=(s=this.events).onMoveEnd)==null?void 0:n.call(s)}});return i.position.set(t.x,t.y),i}createAndAddButton(t,i){return t.visible=i,this.controlButtons.addChild(t),t}createControlButtons(){this.outlinePoints.length<4||(this.deleteButton=this.createAndAddButton(this.createDeleteButton(),this.config.showDeleteButton??!1),this.moveButton=this.createAndAddButton(this.createMoveButton(),this.config.showMoveButton??!1),this.rotateButton=this.createAndAddButton(this.createRotateButton(),this.config.showRotateButton??!1),this.scaleButton=this.createAndAddButton(this.createScaleButton(),this.config.showScaleButton??!1),console.log("this.config.showRadialScaleButton",this.config.showRadialScaleButton),this.horizontalScaleButton=this.createAndAddButton(this.createHorizontalScaleButton(),this.config.showRadialScaleButton??!1),this.verticalScaleButton=this.createAndAddButton(this.createVerticalScaleButton(),this.config.showRadialScaleButton??!1))}calculateOutlinePoints(){const t=this.zonePoints;if(t.length<4)return t;const s=this.appService.getApp().toFixedSize(this.config.outlineOffset);return zr(t,s)}calculateMoveButtonPosition(){const t=this.calculateOutlinePoints();if(t.length<4)return{x:0,y:0};const s=this.appService.getApp().toFixedSize(this.config.moveButtonOffset),n=t[pt.MOVE],o=t[pt.SCALE],a=t[pt.REMOVE];return Ds(n,o,a,s)}calculateMoveLinePoints(){const t=this.calculateOutlinePoints();if(t.length<4)return[];const i=t[pt.MOVE],s=this.calculateMoveButtonPosition();return[i,s]}calculateSizeText(){const t=this.zonePoints;if(t.length<4)return"0m*0m";const[i,s,,n]=t,o=Q(i,s),a=Q(i,n),h=this.appService,l=h.pixelsToMeters(o),c=h.pixelsToMeters(a),d=h.metersToDisplayUnit(l),u=h.metersToDisplayUnit(c),p=h.runtimeSnapshot.unitLabel;return`${d.toFixed(1)}${p}*${u.toFixed(1)}${p}`}getEdgeCenter(t,i){return{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}calculatePerpendicularOffset(t,i,s,n=!1){const o=gt(K(i,t)),a=n?{x:-o.y,y:o.x}:{x:o.y,y:-o.x};return{x:a.x*s,y:a.y*s}}calculateSizeTextPosition(){if(this.zonePoints.length<4)return{x:0,y:0};const i=this.calculateOutlinePoints(),[s,n,o,a]=i,{textPosition:h,textOffset:l}=this.config,d=this.appService.getApp().toFixedSize(l);let u,p;switch(h){case"top":u=this.getEdgeCenter(s,n),p=this.calculatePerpendicularOffset(n,s,d);break;case"right":u=this.getEdgeCenter(n,o),p=this.calculatePerpendicularOffset(n,o,d);break;case"bottom":u=this.getEdgeCenter(a,o),p=this.calculatePerpendicularOffset(a,o,d,!0);break;case"left":u=this.getEdgeCenter(s,a),p=this.calculatePerpendicularOffset(a,s,d);break;default:u=this.getEdgeCenter(s,n),p={x:0,y:d};break}return{x:u.x+p.x,y:u.y+p.y}}calculateSizeTextRotation(){const t=this.zonePoints;if(t.length<4)return 0;const[i,s,n,o]=t,{textPosition:a}=this.config;let h,l;switch(a){case"top":h=i,l=s;break;case"right":h=s,l=n;break;case"bottom":h=n,l=o;break;case"left":h=o,l=i;break;default:h=i,l=s;break}const c=this.appService.appContainer.getMapRotationRadians();return qe(h,l,c)}calculateHorizontalScaleButtonRotation(){const t=this.zonePoints;if(t.length<4)return 0;const[,i,s]=t,n=this.appService.appContainer.getMapRotationRadians();return qe(i,s,n)+Math.PI/2}calculateVerticalScaleButtonRotation(){const t=this.zonePoints;if(t.length<4)return 0;const[,,i,s]=t,n=this.appService.appContainer.getMapRotationRadians();return qe(s,i,n)}updatePoints(t,i=!0){this.zonePoints=t,this.updateOutlineBorder(),this.moveLine&&this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeText(i)}updateOutlineBorder(){const t=this.calculateOutlinePoints();this.outlinePoints=t,this.outlineBorder.updatePoints(t)}updateMoveLine(){if(!this.moveLine)return;const t=this.calculateMoveLinePoints();this.moveLine.updatePoints(t)}updateSizeText(t=!0){if(this.sizeText){if(t){const i=this.calculateSizeText();this.sizeText.updateText(i)}this.updateSizeTextPosition()}}updateSizeTextPosition(){if(!this.sizeText)return;const t=this.calculateSizeTextPosition();this.sizeText.position.set(t.x,t.y);const i=this.calculateSizeTextRotation();this.sizeText.rotation=i}updateControlButtonsPosition(){if(!this.deleteButton||!this.scaleButton||!this.moveButton)return;const t=this.calculateOutlinePoints();if(t.length<4)return;const i=this.calculateMoveButtonPosition(),s=[{button:this.deleteButton,point:t[pt.REMOVE]},{button:this.scaleButton,point:t[pt.SCALE]},{button:this.moveButton,point:i}];if(this.rotateButton&&s.push({button:this.rotateButton,point:t[pt.ROTATE]}),this.horizontalScaleButton){const n=t[pt.ROTATE],o=t[pt.SCALE],a=nc(n,o,0);s.push({button:this.horizontalScaleButton,point:a})}if(this.verticalScaleButton){const n=t[pt.SCALE],o=t[pt.MOVE],a=this.getEdgeCenter(n,o);s.push({button:this.verticalScaleButton,point:a})}s.forEach(({button:n,point:o})=>n.position.set(o.x,o.y)),this.horizontalScaleButton&&(this.horizontalScaleButton.rotation=this.calculateHorizontalScaleButtonRotation()),this.verticalScaleButton&&(this.verticalScaleButton.rotation=this.calculateVerticalScaleButtonRotation()),this.scaleButton&&this.scaleButton.visible&&(this.scaleButton.rotation=this.calculateVerticalScaleButtonRotation())}setupClickHandler(){this.clickHandler=new vt(this,{onClick:()=>{var t,i;(i=(t=this.events).onClick)==null||i.call(t)},stopPropagation:!1})}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateOutline),this.appService.emitter.on("mapRotationUpdate",this.throttledUpdateOutline)}updateOutlineForScale(){(this.outlineBorder.visible||this.controlButtons.visible)&&(this.updateOutlineBorder(),this.moveLine&&this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition())}initializeScaleCache(){if(this.initialZonePoints.length===0&&(this.initialZonePoints=this.zonePoints.map(p=>({...p}))),this.initialZonePoints.length<4)return;const t={...this.initialZonePoints[pt.SCALE]};if(!t)return;const i=pt.REMOVE,{x:s,y:n}=this.initialZonePoints[i],[,o,,a]=this.initialZonePoints,h={x:s,y:n},l=K(h,o),c=K(h,a),d=ee(l),u=ee(c);d===0||u===0||(this.scaleCache={fixedPoint:h,edge1:l,edge2:c,edge1Len:d,edge2Len:u,initialButtonPosition:t})}handleInternalScaleMove(t,i){if(this.initialZonePoints.length!==4||!this.scaleCache)return null;const s=this.appService.metersToPixels(this.minSize),n=this.maxSize!=null?this.appService.metersToPixels(this.maxSize):void 0,{fixedPoint:o,edge1:a,edge2:h,edge1Len:l,edge2Len:c,initialButtonPosition:d}=this.scaleCache,u={x:d.x+t,y:d.y+i},p=K(o,u),f=ae(p,a,l,s,n),y=ae(p,h,c,s,n);return this.calculatePointsFromScale(o,a,h,f,y)}resetScaleState(){this.scaleCache=null}handleInternalHorizontalScaleMove(t,i){if(this.initialZonePoints.length!==4||!this.scaleCache||!this.horizontalScaleInitialPosition)return null;const{fixedPoint:s,edge1:n,edge2:o,edge1Len:a}=this.scaleCache,h=this.appService.metersToPixels(this.minSize),l=this.maxSize!=null?this.appService.metersToPixels(this.maxSize):void 0,c={x:this.horizontalScaleInitialPosition.x+t,y:this.horizontalScaleInitialPosition.y+i},d=K(s,c),u=ae(d,n,a,h,l);return this.calculatePointsFromScale(s,n,o,u,1)}handleInternalVerticalScaleMove(t,i){if(this.initialZonePoints.length!==4||!this.scaleCache||!this.verticalScaleInitialPosition)return null;const{fixedPoint:s,edge1:n,edge2:o,edge2Len:a}=this.scaleCache,h=this.appService.metersToPixels(this.minSize),l=this.maxSize!=null?this.appService.metersToPixels(this.maxSize):void 0,c={x:this.verticalScaleInitialPosition.x+t,y:this.verticalScaleInitialPosition.y+i},d=K(s,c),u=1,p=ae(d,o,a,h,l);return this.calculatePointsFromScale(s,n,o,u,p)}calculatePointsFromScale(t,i,s,n,o){const{x:a,y:h}=t;return[t,{x:a+i.x*n,y:h+i.y*n},{x:a+i.x*n+s.x*o,y:h+i.y*n+s.y*o},{x:a+s.x*o,y:h+s.y*o}]}initializeRotationCache(t){this.zonePoints.length<3||(this.rotationCache={rotationCenter:t,initialPoints:this.zonePoints.map(i=>({...i})),totalAngle:0})}handleInternalRotationMove(t){if(!this.rotationCache||this.rotationCache.initialPoints.length<3)return null;const{rotationCenter:i,initialPoints:s}=this.rotationCache;return this.rotationCache.totalAngle+=t,Fr(s,i,this.rotationCache.totalAngle)}resetRotationState(){this.rotationCache=null}calculateRotationCenter(){return this.zonePoints.length===0?{x:0,y:0}:de(this.zonePoints)}updateEditState({showRotateButton:t=!1,showScaleButton:i=!1,showRadialScaleButton:s=!1,showDeleteButton:n=!1,showMoveButton:o=!1,showBorder:a=!1,showSizeText:h=!1,borderStyle:l}){this.rotateButton&&(this.rotateButton.visible=t),this.scaleButton&&(this.scaleButton.visible=i),this.horizontalScaleButton&&(this.horizontalScaleButton.visible=s),this.verticalScaleButton&&(this.verticalScaleButton.visible=s),this.deleteButton&&(this.deleteButton.visible=n),this.moveButton&&(this.moveButton.visible=o);const c=t||i||s||n||o;this.controlButtons.visible=c,!c&&this.getOperationState().hasAnyOperation&&this.stopAllOperations(),this.outlineBorder.visible=a,this.moveLine&&(this.moveLine.visible=o),this.sizeText&&(this.sizeText.visible=h),a&&(this.updateOutlineBorder(),c&&(this.moveLine&&o&&this.updateMoveLine(),this.updateControlButtonsPosition()),h&&this.updateSizeTextPosition()),l&&this.outlineBorder.updateStyle({isDashed:l.isDashed,dashArray:l.dashArray})}getOperationState(){var n,o,a;const t=((n=this.scaleButton)==null?void 0:n.isCurrentlyScaling())||!1,i=((o=this.rotateButton)==null?void 0:o.isCurrentlyRotating())||!1,s=((a=this.moveButton)==null?void 0:a.isCurrentlyMoving())||!1;return{isDragging:!1,isScaling:t,isRotating:i,isMoving:s,hasAnyOperation:t||i||s}}stopAllOperations(){var t,i,s;(t=this.scaleButton)==null||t.stopScaling(),(i=this.rotateButton)==null||i.stopRotation(),(s=this.moveButton)==null||s.stopMoving()}getControlButtonsContainer(){return this.controlButtons}getMoveButton(){return this.moveButton}calculateEdgeMidpoint(t,i){const s=this.calculateOutlinePoints();if(s.length<4)return{x:0,y:0};const n=s[t],o=s[i];return{x:(n.x+o.x)/2,y:(n.y+o.y)/2}}destroy(){var t,i,s,n,o,a,h,l,c,d,u;this.appService.emitter.off("antiScale",this.throttledUpdateOutline),this.appService.emitter.off("mapRotationUpdate",this.throttledUpdateOutline),(t=this.clickHandler)==null||t.destroy(),this.clickHandler=null,(i=this.deleteButton)==null||i.destroy(),(s=this.rotateButton)==null||s.destroy(),(n=this.scaleButton)==null||n.destroy(),(o=this.moveButton)==null||o.destroy(),(a=this.horizontalScaleButton)==null||a.destroy(),(h=this.verticalScaleButton)==null||h.destroy(),this.deleteButton=null,this.rotateButton=null,this.scaleButton=null,this.moveButton=null,this.horizontalScaleButton=null,this.verticalScaleButton=null,(l=this.outlineBorder)==null||l.destroy(),(c=this.moveLine)==null||c.destroy(),(d=this.sizeText)==null||d.destroy(),(u=this.controlButtons)==null||u.destroy(),super.destroy()}}class KS{constructor(e){g(this,"editControlLayers",new Map);this.appService=e}registerEditControl(e,t){const i=this.appService;this.editControlLayers.has(e)&&this.unregisterEditControl(e);const s=new qS(i,t);if(!i.appContainer.addToLayer(ke,s))throw w.warn(`[EditControlManager] Failed to add edit control layer for id: ${e}`),s.destroy(),new Error(`Failed to register edit control for id: ${e}`);if(this.editControlLayers.set(e,s),t.contentLayer){const o=i.appContainer.getLayer(ke),a=i.appContainer.getLayer(t.contentLayer);o&&a&&(o.position.x!==a.position.x||o.position.y!==a.position.y)&&w.warn(`[EditControlManager] Edit layer position does not match content layer "${t.contentLayer}" position — edit controls will appear misaligned. Ensure "${t.contentLayer}" is in ORIGIN_TRACKED_LAYERS.`,{edit:o.position,content:a.position})}return s}unregisterEditControl(e){const t=this.editControlLayers.get(e);if(!t)return;this.appService.appContainer.removeFromLayer(ke,t),t.destroy(),this.editControlLayers.delete(e)}getEditControl(e){return this.editControlLayers.get(e)}updateEditState(e,t){const i=this.editControlLayers.get(e);i&&i.updateEditState(t)}clearAll(){Array.from(this.editControlLayers.keys()).forEach(t=>this.unregisterEditControl(t))}getAllEditControls(){return Array.from(this.editControlLayers.values())}hasEditControl(e){return this.editControlLayers.has(e)}}const $S=60;function $a(r){return Math.round(r*1e3/$S)}function ds(r){return r.charAt(0).toUpperCase()+r.slice(1)}class Zr extends il{constructor(t=Ya){super();g(this,"mapState",null);g(this,"components",{});g(this,"managers",{});g(this,"config",ja);g(this,"runtime");g(this,"appService");g(this,"scaleMin",.5);g(this,"scaleMax",5);g(this,"events",{});g(this,"instanceKey");g(this,"containerElement");g(this,"emitter",Gx());g(this,"tickerState",{renderReasons:new Set,renderTimer:null});g(this,"pendingAsyncRender",!1);g(this,"isFirstMapDraw",!0);g(this,"isMapDrawn",!1);g(this,"onVisibilityChange",()=>{var i;document.visibilityState==="visible"||(i=this.components.interaction)==null||i.clearTouches()});this.instanceKey=t,this.appService=new ac(this),globalThis.__PIXI_APP__=this}async initialize(t){const{resizeTo:i,events:s,config:n,runtime:o={},...a}=t;this.config=or(Ea({},ja,n??{},(f,y)=>{if(Array.isArray(y))return y})),this.validateCustomZoneTypes(this.config),hy(()=>this.config.global.enableLogger),w.log("Applying config",this.config,n),this.runtime=or(Object.assign({},Ox,o));const h=this.instanceKey===Ya;this.containerElement=i;const l=h&&this.config.interaction.enable,c=this.config.global.performanceMode||!h,d={gcActive:!0,gcMaxUnusedTime:$a(c?60:Gn.any?180:3600),gcFrequency:$a(c?10:Gn.any?100:50),autoStart:!1,sharedTicker:c,eventFeatures:{move:l,globalMove:!1,click:l,wheel:l}},u={resizeTo:h?i:void 0,resolution:this.config.global.resolution,antialias:c?!1:HS(),depth:!c,autoDensity:!0,backgroundColor:0,backgroundAlpha:0,...d,...a},p=this.config.global.rendererPreference;if(p==="webgpu")try{await this.init({...u,preference:"webgpu"})}catch(f){w.warn("[Pixi] WebGPU initialization failed, falling back to WebGL:",f),await this.init({...u,preference:"webgl"})}else await this.init({...u,preference:p});w.log(`[Pixi] Renderer initialized: ${this.renderer.type===Fi.WEBGPU?"WebGPU":"WebGL"} ${this.renderer.type}`),this.preloadAssets(),this.scaleMax=this.config.interaction.zoomRange.max,this.scaleMin=this.config.interaction.zoomRange.min,this.events=s,this.initializeViewportContainer(),this.initializeInteraction(),this.initializeAppContainer(),this.managers.mapManager=new Kx(this.appService),this.managers.heatmapManager=new sS(this.appService),this.managers.pathManager=new eS(this.appService),this.managers.controlsManager=new aS(this.appService),this.managers.detectedObjectManager=new lS(this.appService),this.managers.customElementsManager=new FS(this.appService),this.managers.roomsManager=new US(this.appService),this.managers.customCarpetManager=new jS(this.appService),this.managers.furnitureManager=new ZS(this.appService),this.managers.editControlManager=new KS(this.appService),this.setupMapRotationListener(),document.addEventListener("visibilitychange",this.onVisibilityChange)}async drawMap(t){var a,h,l,c,d,u,p;this.isMapDrawn=!1,w.log("[Map] drawMap",t);const{size:i,resolution:s,origin:n,id:o}=t;((a=this.mapState)==null?void 0:a.id)!==void 0&&this.mapState.id!==o&&this.managers.pathManager.clear(),(n[0]!==((h=this.mapState)==null?void 0:h.origin.x)||n[1]!==((l=this.mapState)==null?void 0:l.origin.y))&&(this.appService.appContainer.updateOriginTrackedLayers(...n),this.managers.pathManager.updatePositionByOrigin(...n),this.managers.heatmapManager.updatePositionByOrigin(...n)),this.mapState={id:t.id,status:t.status===1,origin:{x:n[0],y:n[1]},charger:{x:t.charger.coordinate[0],y:t.charger.coordinate[1]},chargerDirection:t.charger.angle??0,resolution:s,width:i[0],height:i[1],mapType:"structured"},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,(d=(c=this.events)==null?void 0:c.onMapFirstDrawed)==null||d.call(c,this.mapState)),(p=(u=this.events)==null?void 0:u.onMapDrawed)==null||p.call(u,this.mapState),await this.managers.mapManager.drawMap(t),i[0]===0||i[1]===0?(w.log("[Map] Map cleared, clearing path and room data"),this.managers.pathManager.clear(),this.managers.roomsManager.clear(),this.isMapDrawn=!1):(this.isMapDrawn=!0,this.managers.heatmapManager.onMapLoaded()),this.renderOnce()}async drawRasterMap(t){var a,h,l,c,d,u;this.isMapDrawn=!1,w.log("[Map] drawRasterMap",t);const{mapHeader:i,mapData:s}=t,{originX:n,originY:o}=i;(n!==((a=this.mapState)==null?void 0:a.origin.x)||o!==((h=this.mapState)==null?void 0:h.origin.y))&&(this.appService.appContainer.updateOriginTrackedLayers(n,o),this.managers.pathManager.updatePositionByOrigin(n,o),this.managers.heatmapManager.updatePositionByOrigin(n,o)),this.mapState={id:i.id,status:i.mapStable,origin:{x:n,y:o},charger:{x:i.chargeX,y:i.chargeY},chargerDirection:i.chargeDirection??0,resolution:i.mapResolution*100,width:i.mapWidth,height:i.mapHeight,version:i.version,mapType:"raster"},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,(c=(l=this.events)==null?void 0:l.onMapFirstDrawed)==null||c.call(l,this.mapState)),(u=(d=this.events)==null?void 0:d.onMapDrawed)==null||u.call(d,this.mapState),await this.managers.mapManager.drawRasterMap(s.parsed,this.mapState),i.mapWidth===0||i.mapHeight===0?(w.log("[Map] Map cleared, clearing path and room data"),this.managers.pathManager.clear(),this.managers.roomsManager.clear(),this.isMapDrawn=!1):(this.isMapDrawn=!0,this.managers.heatmapManager.onMapLoaded()),this.renderOnce()}drawPath(t){var i,s;w.log("[Path] drawPath",t),(s=(i=this.events)==null?void 0:i.onPathDrawed)==null||s.call(i,{id:t.pathHeader.pathId,type:t.pathHeader.type,direction:t.pathHeader.direction,count:t.pathHeader.count,initFlag:t.pathHeader.initFlag,robotPosition:t.pathPoints[t.pathPoints.length-1]??null}),this.managers.pathManager.draw(t),this.renderOnce()}async drawRoomProperty(t){var i,s;w.log("[Room] drawRoomProperty",t),(s=(i=this.events)==null?void 0:i.onRoomPropertiesDrawed)==null||s.call(i,t),await this.managers.roomsManager.drawRoomProperty(t),this.renderOnceNextFrame()}async drawCustomCarpets(t){w.log("[CustomCarpets] drawCustomCarpets",t),await this.managers.customCarpetManager.drawCustomCarpets(t),this.renderOnceNextFrame()}async drawFurnitures(t){w.log("[Furniture] drawFurnitures",t),await this.managers.furnitureManager.drawFurnitures(t),this.renderOnceNextFrame()}drawHeatmap(t){w.log("[Heatmap] drawHeatmap",t),this.managers.heatmapManager.draw(t),this.renderOnce()}drawForbiddenSweepZones(t){w.log("[Controls] drawForbiddenSweepZones",t),this.managers.controlsManager.drawForbiddenSweepZones(t),this.renderOnceNextFrame()}drawForbiddenMopZones(t){w.log("[Controls] drawForbiddenMopZones",t),this.managers.controlsManager.drawForbiddenMopZones(t),this.renderOnceNextFrame()}drawCleanZones(t){w.log("[Controls] drawCleanZones",t),this.managers.controlsManager.drawCleanZones(t),this.renderOnceNextFrame()}drawCustomZones(t,i){if(Ne(t)){w.warn(`[MapApplication] drawCustomZones: '${t}' is a built-in type; use draw${ds(t)}s() instead`);return}w.log("[Controls] drawCustomZones",t,i),this.managers.controlsManager.drawCustomZones(t,i),this.renderOnceNextFrame()}getCustomZones(t){return Ne(t)?(w.warn(`[MapApplication] getCustomZones: '${t}' is a built-in type; use get${ds(t)}s() instead`),[]):this.managers.controlsManager.getCustomZones(t)}clearCustomZones(t){if(Ne(t)){w.warn(`[MapApplication] clearCustomZones: '${t}' is a built-in type; use clearAll${ds(t)}s() instead`);return}w.log("[Controls] clearCustomZones",t),this.managers.controlsManager.clearCustomZones(t),this.renderOnceNextFrame()}setEditingCustomZones(t,i){if(Ne(t)){w.warn(`[MapApplication] setEditingCustomZones: '${t}' is a built-in type; use runtime.editing${ds(t)}Ids instead`);return}this.runtime.editingCustomZoneIds={...this.runtime.editingCustomZoneIds??{},[t]:[...i]}}drawVirtualWalls(t){w.log("[Controls] drawVirtualWalls",t),this.managers.controlsManager.drawVirtualWalls(t),this.renderOnceNextFrame()}drawSpots(t){w.log("[Controls] drawSpots",t),this.managers.controlsManager.drawSpots(t),this.renderOnceNextFrame()}drawWayPoints(t){w.log("[Controls] drawWayPoints",t),this.managers.controlsManager.drawWayPoints(t),this.renderOnceNextFrame()}async drawDetectedObjects(t){w.log("[DetectedObject] drawDetectedObjects",t),await this.managers.detectedObjectManager.drawDetectedObjects(t),this.renderOnceNextFrame()}drawCustomCarpet(t){w.log("[CustomCarpet] drawCustomCarpet",t),this.managers.customCarpetManager.drawCustomCarpets(t),this.renderOnceNextFrame()}async drawCustomElements(t){w.log("[CustomElements] drawCustomElements",t),await this.managers.customElementsManager.drawCustomElements(t),this.renderOnceNextFrame()}getForbiddenSweepZones(){return this.managers.controlsManager.getForbiddenSweepZones()}getForbiddenMopZones(){return this.managers.controlsManager.getForbiddenMopZones()}getCleanZones(){return this.managers.controlsManager.getCleanZones()}getVirtualWalls(){return this.managers.controlsManager.getVirtualWalls()}getSpots(){return this.managers.controlsManager.getSpots()}getWayPoints(){return this.managers.controlsManager.getWayPoints()}getEffectiveDividerPoints(){return this.managers.controlsManager.getEffectiveDividerPoints()}getCustomCarpets(){return this.managers.customCarpetManager.getCustomCarpets()}getFurnitures(){return this.managers.furnitureManager.getFurnitures()}getDividerEndPoints(){return this.managers.controlsManager.getDividerEndPoints()}resetPanZoom(){this.components.interaction.setPanZoom()}forceEndGesture(){w.log("[Map] forceEndGesture"),this.components.interaction.forceEndGesture()}fitMapToView(t,i=!1){if(!t||t.minX===t.maxX||t.minY===t.maxY)return;const s=this.config.map.autoPaddingVerticalPercent,n=this.config.map.autoPaddingHorizontalPercent,o=this.getViewportBounds(),a=this.components.appContainer.getMapRotationRadians(),h=this.calculateRotatedBounds(t,a),l=h.maxX-h.minX,c=h.maxY-h.minY,d=o.width,u=o.height,p=d*(1-n*2),f=u*(1-s*2),y=p/l,m=f/c,x=Math.min(y,m),S=this.config.interaction.fitMinScale,v=this.config.interaction.fitMaxScale,b=Math.max(S,Math.min(v,x));this.setScaleBounds(this.config.interaction.zoomRange.min,this.config.interaction.zoomRange.max),b<this.scaleMin&&(this.setScaleBounds(b,this.scaleMax),w.debug("[MapApplication] scaleMin lowered for fit:",{configured:this.config.interaction.zoomRange.min,adjusted:b})),b>this.scaleMax&&(this.setScaleBounds(this.scaleMin,b),w.debug("[MapApplication] scaleMax raised for fit:",{configured:this.config.interaction.zoomRange.max,adjusted:b}));const P=t.minX+(t.maxX-t.minX)/2,C=t.minY+(t.maxY-t.minY)/2,A=this.config.map.autoFitOffset||{x:0,y:0},k=d/2+(A.x||0),M=u/2+(A.y||0),T=Math.cos(a),_=Math.sin(a),E=P*T-C*_,B=P*_+C*T,F=k-E*b,Z=M-B*b;w.debug("[MapApplication] fitMapToView calculated:",{rotation:this.components.appContainer.getMapRotation(),originalBounds:t,rotatedBounds:h,finalScale:b,position:{x:F,y:Z}}),this.components.interaction.setPanZoom({targetPosition:{x:F,y:Z},targetScale:{x:b,y:b},setCenter:!0,setScale:!0},i)}setScaleBounds(t,i){this.scaleMin=t,this.scaleMax=i,this.components.interaction.scaleMin=t,this.components.interaction.scaleMax=i}validateCustomZoneTypes(t){const i=["minSize","strokeColor","strokeWidth","fillColor","outlineOffset","outlineStrokeColor","outlineStrokeWidth","outlineDashed","outlineDashArray","outlineFillColor","iconWrapperFillColor","textColor","textPosition","textOffset","showRotateButton","editing","normal"],s=t.customZoneTypes??{},n=Ei.cleanZone;for(const[,o]of Object.entries(s))for(const a of i)o[a]===void 0&&(o[a]=n[a])}calculateRotatedBounds(t,i){if(i===0)return t;const s=(t.minX+t.maxX)/2,n=(t.minY+t.maxY)/2,o=[{x:t.minX-s,y:t.minY-n},{x:t.maxX-s,y:t.minY-n},{x:t.maxX-s,y:t.maxY-n},{x:t.minX-s,y:t.maxY-n}],a=Math.cos(i),h=Math.sin(i),l=o.map(f=>({x:f.x*a-f.y*h,y:f.x*h+f.y*a}));let c=1/0,d=1/0,u=-1/0,p=-1/0;return l.forEach(f=>{c=Math.min(c,f.x),d=Math.min(d,f.y),u=Math.max(u,f.x),p=Math.max(p,f.y)}),{minX:c+s,minY:d+n,maxX:u+s,maxY:p+n}}getViewportBounds(){var t;return((t=this.components.viewportContainer)==null?void 0:t.getViewportBounds())||{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}updateRuntime(t){Object.assign(this.runtime,t),w.log("[runtime] runtime updated",t),this.renderOnceNextFrame()}updateConfig(t){var i;Ea(this.config,t,(s,n)=>{if(Array.isArray(n))return n}),t.customZoneTypes&&this.validateCustomZoneTypes(this.config),(i=this.managers.controlsManager)==null||i.updateRenderOrder(),w.log("[Config] Configuration updated",t),this.renderOnceNextFrame()}metersToPixels(t){var n;if(!((n=this.mapState)!=null&&n.resolution))return w.warn("Map resolution not available, using default resolution (5cm/pixel)"),t*20;const s=1/(this.mapState.resolution/100);return t*s}pixelsToMeters(t){var s;if(!((s=this.mapState)!=null&&s.resolution))return w.warn("Map resolution not available, using default resolution (5cm/pixel)"),t*.05;const i=this.mapState.resolution/100;return t*i}toFixedSize(t,i){const s=i??this.components.appContainer.scale.x;return t/s}fromFixedSize(t,i){const s=i??this.components.appContainer.scale.x;return t*s}getViewportCenterPoint(){if(!this.mapState)return w.warn("Map state not available, cannot calculate center point"),null;const t=this.getViewportBounds(),i=t.x+t.width/2,s=t.y+t.height/2,n=this.components.appContainer,o=n.scale.x,a=n.getMapRotationRadians(),h=i-n.x,l=s-n.y,c=h/o,d=l/o,u=Math.cos(a),p=Math.sin(a),f=c*u+d*p,y=-c*p+d*u,m=f-this.mapState.origin.x,x=y-this.mapState.origin.y;return{x:m,y:x}}getMapCenterPoint(){if(!this.mapState)return w.warn("Map state not available, cannot calculate map center point"),null;const t=this.managers.mapManager.mapBounds;if(t.minX===1/0||t.minY===1/0||t.maxX===-1/0||t.maxY===-1/0)return w.warn("Invalid map bounds, cannot calculate map center point"),null;const i=(t.minX+t.maxX)/2,s=(t.minY+t.maxY)/2,n=i-this.mapState.origin.x,o=s-this.mapState.origin.y;return{x:n,y:o}}getWallPointsByViewportCenter(t){var f;const{width:i=this.config.controls.virtualWall.minWidth,direction:s="horizontal",offsetX:n=0,offsetY:o=0}=t||{},a=this.getViewportCenterPoint()||{x:0,y:0},l=this.metersToPixels(i)/2,c=((f=this.components.appContainer)==null?void 0:f.getMapRotationRadians())||0,d=Math.cos(c),u=Math.sin(c);let p;return s==="horizontal"?p=[{vx:-l+n,vy:o},{vx:l+n,vy:o}]:p=[{vx:n,vy:-l+o},{vx:n,vy:l+o}],p.map(y=>({x:a.x+y.vx*d+y.vy*u,y:a.y-y.vx*u+y.vy*d}))}getForbiddenSweepZonePointsByViewportCenter(t){const i=this.config.controls.forbiddenSweepZone,{size:s=i.minSize,offsetX:n=0,offsetY:o=0}=t||{};return this.generateZonePoints(s,n,o)}getForbiddenMopZonePointsByViewportCenter(t){const i=this.config.controls.forbiddenMopZone,{size:s=i.minSize,offsetX:n=0,offsetY:o=0}=t||{};return this.generateZonePoints(s,n,o)}getCleanZonePointsByViewportCenter(t){const i=this.config.controls.cleanZone,{size:s=i.minSize,offsetX:n=0,offsetY:o=0}=t||{};return this.generateZonePoints(s,n,o)}getSpotPointByViewportCenter(t){const{offsetX:i=0,offsetY:s=0}=t||{},n=this.getViewportCenterPoint()||{x:0,y:0},o=n.x+i,a=n.y+s;return{x:o,y:a}}getFurniturePointsByViewportCenter(t){var x;const{furnitureType:i=1,offsetX:s=0,offsetY:n=0}=t||{},a=this.config.furniture.assets.find(S=>S.type===i),h=this.metersToPixels((a==null?void 0:a.width)??1.8),l=this.metersToPixels((a==null?void 0:a.height)??2),c=h/2,d=l/2,u=this.getViewportCenterPoint()||{x:0,y:0},p=((x=this.components.appContainer)==null?void 0:x.getMapRotationRadians())||0,f=Math.cos(p),y=Math.sin(p);return[{vx:-c+s,vy:-d+n},{vx:c+s,vy:-d+n},{vx:c+s,vy:d+n},{vx:-c+s,vy:d+n}].map(S=>({x:u.x+S.vx*f+S.vy*y,y:u.y-S.vx*y+S.vy*f}))}areRoomsAdjacent(t){return!t||t.length===0?(w.warn("[Room] No room IDs provided"),!1):this.managers.mapManager.areRoomsAdjacent(t)}isPointInAnyRoom(t){return!t||typeof t.x!="number"||typeof t.y!="number"?(w.warn("[Room] Invalid point provided"),null):this.mapState?this.managers.mapManager.isPointInAnyRoom(t):(w.warn("[Room] Map state not available"),null)}isWallIntersectsAnyRoom(t){return!t||t.length!==2||!t[0]||!t[1]||typeof t[0].x!="number"||typeof t[0].y!="number"||typeof t[1].x!="number"||typeof t[1].y!="number"?(w.warn("[Room] Invalid wall points provided"),!1):this.mapState?this.managers.mapManager.isWallIntersectsAnyRoom(t):(w.warn("[Room] Map state not available"),!1)}isZoneIntersectsAnyRoom(t){return!t||t.length!==4||!t[0]||!t[1]||!t[2]||!t[3]||typeof t[0].x!="number"||typeof t[0].y!="number"||typeof t[1].x!="number"||typeof t[1].y!="number"||typeof t[2].x!="number"||typeof t[2].y!="number"||typeof t[3].x!="number"||typeof t[3].y!="number"?(w.warn("[Room] Invalid zone points provided"),!1):this.mapState?this.managers.mapManager.isZoneIntersectsAnyRoom(t):(w.warn("[Room] Map state not available"),!1)}isNearChargerOrRobot(t,i,s){var h,l;if(!t||t.length<1)return w.warn("[Distance] Invalid points array: must have at least 1 point"),!1;if(t.length!==1&&t.length!==2&&t.length!==4)return w.warn("[Distance] Invalid points array: must have exactly 1 (point), 2 (wall) or 4 (zone) points"),!1;if(i<=0)return w.warn("[Distance] Invalid threshold: must be greater than 0"),!1;if(!this.mapState)return w.warn("[Distance] Map state not available"),!1;const{checkCharger:n=!0,checkRobot:o=!1}=s||{};if(!n&&!o)return w.warn("[Distance] At least one of checkCharger or checkRobot must be true"),!1;const a=this.metersToPixels(i);if(n){const c=this.appService.getChargerPosition();if(c){const d=(h=this.mapState)==null?void 0:h.charger.x,u=(l=this.mapState)==null?void 0:l.charger.y;if(d===0&&u===0)return w.warn("[Distance] Charger position not available"),!1;const p=za(c,t);if(p<=a)return w.log(`[Distance] Too close to charger: ${p.toFixed(2)} pixels (threshold: ${a.toFixed(2)} pixels)`),!0}else w.warn("[Distance] Charger position not available")}if(o){const c=this.appService.getRobotPosition();if(c){const d=za(c,t);if(d<=a)return w.log(`[Distance] Too close to robot: ${d.toFixed(2)} pixels (threshold: ${a.toFixed(2)} pixels)`),!0}else w.warn("[Distance] Robot position not available")}return!1}async snapshot(t){this.render();const{snapshot:i,global:s}=this.config,n=(t==null?void 0:t.backgroundColor)??s.backgroundColor,o=this.components.appContainer,a=o.getSnapshotBounds(),h=Math.floor(a.x),l=Math.floor(a.y),c=Math.ceil(a.x+a.width)-h,d=Math.ceil(a.y+a.height)-l;if(c<=0||d<=0)return w.error("[MapApplication] Snapshot failed: invalid bounds",a),"";const u=i.resolution||window.devicePixelRatio||2,p=Br.create({width:c,height:d,resolution:u}),f=new H;f.rect(0,0,c,d).fill(n);const y=new U;y.translate(-h,-l);try{return this.renderer.render({container:f,target:p}),this.renderer.render({container:o,target:p,transform:y,clear:!1}),await this.renderer.extract.base64({target:p,format:i.format,quality:i.quality,antialias:i.antialias})}catch(m){return w.error("[MapApplication] Snapshot failed:",m),""}finally{f.destroy(),p.destroy(!0)}}async snapshotByData({map:t,path:i,roomProperties:s,customElements:n,forbiddenSweepZones:o,forbiddenMopZones:a,virtualWalls:h,detectedObjects:l,furnitures:c},d={},u){const p=`SNAPSHOT_${Ux()}`;w.log(`[MapApplication] ${p} snapshot start`);const f=new Zr(p);try{if(await f.initialize({config:this.config,runtime:d}),!t)throw new Error("Map data is required");if(t.startsWith("7b22")){const m=id(t);await f.drawMap(m)}else{const m=sd(t,{pointsStructured:!0});if(m)await f.drawRasterMap(m);else throw new Error("Failed to decode raster map data")}if(i){const{decodePath:m}=await _e(async()=>{const{decodePath:S}=await import("./theme.DZz2Y3xc.js").then(v=>v.i);return{decodePath:S}},__vite__mapDeps([4,2])),x=m(i);f.drawPath(x)}s&&s.length>0&&await f.drawRoomProperty(s),o&&o.length>0&&f.drawForbiddenSweepZones(o),a&&a.length>0&&f.drawForbiddenMopZones(a),h&&h.length>0&&f.drawVirtualWalls(h),c&&c.length>0&&await f.drawFurnitures(c),l&&l.length>0&&await f.drawDetectedObjects(l),n&&n.length>0&&await f.drawCustomElements(n);const y=await f.snapshot(u);return w.log(`[MapApplication] ${p} snapshot completed successfully`),y}catch(y){throw w.error(`[MapApplication] ${p} snapshot other map failed:`,y),y}finally{w.log(`[MapApplication] ${p} destroy`),f.destroy()}}renderOnce(){w.log("[Pixi] renderOnce"),this.render()}renderOnceNextFrame(){this.pendingAsyncRender||(this.pendingAsyncRender=!0,requestAnimationFrame(()=>{w.log("[Pixi] renderOnceNextFrame"),this.render(),this.pendingAsyncRender=!1}))}requestRender(t,i=!1){if(!i){this.renderOnceNextFrame();return}this.tickerState.renderReasons.add(t),this.ticker.started||(w.debug(`🎬 [Ticker] START: ${t}`),this.ticker.start())}stopRender(t){this.tickerState.renderReasons.delete(t),this.tickerState.renderReasons.size===0&&this.scheduleStopRender("final",100)}destroy(){var t;w.log("[MapApplication] destroy"),this.tickerState.renderTimer&&(clearTimeout(this.tickerState.renderTimer),this.tickerState.renderTimer=null),this.tickerState.renderReasons.clear(),this.emitter.all.clear(),document.removeEventListener("visibilitychange",this.onVisibilityChange),this.managers.pathManager.destroy(),this.managers.mapManager.destroy(),this.managers.controlsManager.destroy(),this.managers.furnitureManager.destroy(),this.managers.detectedObjectManager.destroy(),this.managers.customElementsManager.destroy(),this.managers.roomsManager.destroy(),this.components.interaction.destroy(),(t=this.components.background)==null||t.destroy(),this.components.viewportContainer.destroy(),this.components.appContainer.destroy(),this.managers.heatmapManager.destroy(),super.destroy()}initializeViewportContainer(){this.components.viewportContainer=new Hx(this.config,this.containerElement),this.stage.addChild(this.components.viewportContainer);const t=this.getViewportBounds();this.components.background=new VS(this.config.global,t,()=>{this.renderOnceNextFrame()}),this.components.viewportContainer.addChild(this.components.background),this.components.viewportContainer.setChildIndex(this.components.background,0),Fs(this.config.global,()=>{var i;(i=this.components.background)==null||i.update(this.config.global)})}initializeAppContainer(){this.components.appContainer=new Yx(this.appService),this.components.interaction.addChild(this.components.appContainer)}initializeInteraction(){this.components.interaction=new Ly(this.appService),this.components.viewportContainer.addChild(this.components.interaction)}scheduleStopRender(t,i){this.tickerState.renderTimer&&clearTimeout(this.tickerState.renderTimer),this.tickerState.renderTimer=setTimeout(()=>{this.tickerState.renderReasons.delete(t),this.tickerState.renderReasons.size===0&&(w.debug("⏸️ [Ticker] STOP"),this.ticker&&this.ticker.stop())},i)}generateZonePoints(t,i,s){var u;const n=this.getViewportCenterPoint()||{x:0,y:0},a=this.metersToPixels(t)/2,h=((u=this.components.appContainer)==null?void 0:u.getMapRotationRadians())||0,l=Math.cos(h),c=Math.sin(h);return[{vx:-a+i,vy:-a+s},{vx:a+i,vy:-a+s},{vx:a+i,vy:a+s},{vx:-a+i,vy:a+s}].map(p=>({x:n.x+p.vx*l+p.vy*c,y:n.y-p.vx*c+p.vy*l}))}preloadAssets(){const t=this.config.robot.icon.src,i=this.config.chargingStation.icon.src,s=[];N.add({alias:"robot",src:t}),s.push("robot"),N.add({alias:"chargingStation",src:i}),s.push("chargingStation"),N.add({alias:"deleteIcon",src:this.config.controls.deleteIconSrc}),s.push("deleteIcon"),N.add({alias:"rotateIcon",src:this.config.controls.rotateIconSrc}),s.push("rotateIcon"),N.add({alias:"scaleIcon",src:this.config.controls.scaleIconSrc}),s.push("scaleIcon"),N.add({alias:"moveIcon",src:this.config.controls.moveIconSrc}),s.push("moveIcon"),N.add({alias:"checkmark",src:this.config.room.selectionIndicator.iconSrc}),s.push("checkmark"),N.add({alias:"spotIcon",src:this.config.controls.spot.iconSrc}),s.push("spotIcon"),N.add({alias:"wayPoint",src:this.config.controls.wayPoint.normal.iconSrc}),s.push("wayPoint"),N.add({alias:"wayPointActive",src:this.config.controls.wayPoint.editing.iconSrc}),s.push("wayPointActive"),N.add({alias:"horizontalScaleIcon",src:this.config.controls.horizontalScaleIconSrc}),s.push("horizontalScaleIcon"),N.add({alias:"verticalScaleIcon",src:this.config.controls.verticalScaleIconSrc}),s.push("verticalScaleIcon"),this.config.room.property.cleanMode.assets.forEach((n,o)=>{const a=`cleanMode_${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.suction.assets.forEach((n,o)=>{const a=`fan_${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.cistern.assets.forEach((n,o)=>{const a=`water_${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.cleanTimes.assets.forEach((n,o)=>{const a=`cleanTimes${o+1}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.floorType.assets.forEach((n,o)=>{if(!n)return;const a=`floorType${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.customAssets&&Object.entries(this.config.room.property.customAssets).forEach(([n,o])=>{o.forEach((a,h)=>{const l=`custom_${n}_${h}`;N.add({alias:l,src:a}),s.push(l)})}),this.config.furniture.assets.forEach(n=>{const o=`furniture_${n.type}`;N.add({alias:o,src:n.src}),s.push(o)}),N.backgroundLoad(s)}setupMapRotationListener(){this.applyMapRotation(this.runtime.mapRotation),W(this.runtime,"mapRotation",t=>{this.applyMapRotation(t)})}applyMapRotation(t){const i=(t%360+360)%360;w.log(`[MapApplication] Applying map rotation: ${i}°`),this.components.appContainer.setMapRotation(i);const s=this.managers.mapManager.mapBounds;s&&s.minX!==1/0&&s.maxX!==-1/0&&this.fitMapToView(s,!1),this.emitter.emit("mapRotationUpdate",i),this.renderOnce()}}const r0=Object.freeze(Object.defineProperty({__proto__:null,AppService:ac,MapApplication:Zr},Symbol.toStringTag,{value:"Module"}));export{Ho as $,Pi as A,he as B,se as C,pr as D,Yt as E,mr as F,H as G,Kg as H,ii as I,Of as J,Es as K,kf as L,U as M,Ot as N,Is as O,tt as P,gr as Q,et as R,Wp as S,G as T,Ie as U,j as V,Kh as W,Fi as X,Vi as Y,Lp as Z,ci as _,ti as a,_i as a0,yr as a1,Xh as a2,Dt as a3,ni as a4,dl as a5,ff as a6,xf as a7,n0 as a8,pl as a9,Gi as aA,Vp as aB,ul as aC,gf as aD,vf as aE,$g as aF,fl as aG,bf as aH,Hg as aI,r0 as aJ,Be as aa,ps as ab,Tu as ac,gd as ad,le as ae,si as af,wf as ag,_t as ah,xh as ai,Bt as aj,_s as ak,fo as al,jt as am,Em as an,Yd as ao,mo as ap,$s as aq,yo as ar,Zd as as,vh as at,Br as au,kr as av,$h as aw,Hi as ax,Ju as ay,Zu as az,Jn as b,rt as c,V as d,ce as e,tr as f,cs as g,xt as h,X as i,xu as j,ft as k,um as l,dt as m,Gn as n,au as o,I as p,yt as q,kd as r,Ug as s,Sa as t,Ru as u,J as v,nt as w,$ as x,L as y,st as z};
|
|
744
|
+
`,entryPoint:"main"}})}),l=new wa({geometry:a,shader:h});return l.alpha=.8,l}updatePositionByOrigin(t,i){this.position.set(t,i)}destroy(){this.removeChildren(),this.cacheAsTexture(!1)}}class iS{constructor(e){g(this,"heatmap");g(this,"pointsTopLeftOrigin",[]);g(this,"signalGrid",[]);g(this,"cellSize",2);g(this,"maxDistance",14);g(this,"smoothIterations",10);g(this,"heatmapAlpha",.8);g(this,"isHeatmapDrawn",!1);g(this,"loadTimer",null);g(this,"pendingPoints",null);this.appService=e,this.heatmap=new eS(e);const t=e.heatMapConfig;this.cellSize=t.cellSize,this.maxDistance=t.maxDistance,this.smoothIterations=t.smoothIterations,this.heatmapAlpha=t.heatmapAlpha}draw(e){const t=this.appService;if(!t.isMapDrawn){this.pendingPoints=e;return}this.pendingPoints=null;const{minX:i,minY:s}=t.mapManager.mapBounds,n=e.map(o=>({x:+(o.x-i).toFixed(0),y:+(o.y-s).toFixed(0),signal:o.signal}));this.signalGrid=this.calculateInterpolatedSignal(n),this.heatmap.draw(this.signalGrid,this.heatmapAlpha),this.isHeatmapDrawn=!0}onMapLoaded(){this.loadTimer||(this.pendingPoints&&this.draw(this.pendingPoints),this.loadTimer=setTimeout(()=>{this.loadTimer=null},200))}calculateInterpolatedSignal(e){var p;const t=this.appService,i=((p=t.mapState)==null?void 0:p.origin)||{x:0,y:0};let{minX:s,minY:n,maxX:o,maxY:a}=t.mapManager.mapBounds;n=n-i.y,s=s-i.x,a=a-i.y,o=o-i.x;const h=Math.ceil((a-n)/this.cellSize),l=Math.ceil((o-s)/this.cellSize),c=Array(h).fill(null).map(()=>Array(l).fill(null));for(let f=0;f<h;f++){const y=n+f*this.cellSize+this.cellSize/2,m=Math.min(this.cellSize,a-(y-this.cellSize/2));for(let x=0;x<l;x++){const S=s+x*this.cellSize+this.cellSize/2,v=Math.min(this.cellSize,o-(S-this.cellSize/2));let b=0,P=!1;for(let C=0;C<e.length;C++){const A=e[C];if(Math.abs(S-A.x)<=v/2&&Math.abs(y-A.y)<=m/2){const k=1-A.signal/7;b=Math.round(Math.max(b,k)*10)/10,P=!0}}c[f][x]={x:S,y,signal:b,hasPoint:P}}}const d=(f,y)=>{if(e.length===0)return 0;let m=0,x=0;for(const S of e){const v=Math.sqrt((f-S.x)**2+(y-S.y)**2);if(v<=this.maxDistance){const b=1/(1+v),P=1-S.signal/7;x+=b*P,m+=b}}return m===0?0:Math.round(x/m*1e3)/1e3},u=(f,y=1)=>{for(let m=0;m<y;m++){const x=f.map(S=>[...S]);for(let S=1;S<h-1;S++)for(let v=1;v<l-1;v++)if(!f[S][v].hasPoint){let b=0,P=0;const C=4;for(let A=-C;A<=C;A++)for(let k=-C;k<=C;k++){if(A===0&&k===0)continue;const M=S+A,T=v+k;if(M>=0&&M<h&&T>=0&&T<l){const E=1/(1+Math.sqrt(A*A+k*k)*.3);b+=f[M][T].signal*E,P+=E}}if(P>0){const A=b/P,k=.6,M=.4;x[S][v].signal=f[S][v].signal*k+A*M,x[S][v].signal>.1&&(x[S][v].signal=Math.max(x[S][v].signal,.2))}}for(let S=0;S<h;S++)for(let v=0;v<l;v++)f[S][v].signal=x[S][v].signal}};for(let f=0;f<h;f++)for(let y=0;y<l;y++){const m=c[f][y];m.hasPoint||(m.signal=d(m.x,m.y))}return u(c,this.smoothIterations),c}updatePositionByOrigin(e,t){this.heatmap.updatePositionByOrigin(e,t)}destroy(){this.heatmap.destroy()}}class mc extends L{constructor(t){super();g(this,"throttledUpdateScale");this.appService=t,this.throttledUpdateScale=Ct(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.updateScale(this.appService.currentScale),this.registerScaleListener()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}updateScale(t){t!==0&&this.scale.set(1/t)}destroy(t){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Ni extends mc{constructor(t,i){super(t);g(this,"background");g(this,"icon");g(this,"options");this.appService=t,this.options=i,this.background=new H,this.addChild(this.background),this.icon=new Xt(t),this.addChild(this.icon),this.eventMode="static",this.render(),this.setupHitArea(),this.setupEvents()}setupHitArea(){const t=this.appService,i=this.options.config||t.controlsConfig,s=8,n=i.iconWrapperWidth+s*2,o=i.iconWrapperHeight+s*2;this.hitArea=new et(-n/2,-o/2,n,o)}async render(){this.renderBackground(),this.renderIcon()}renderBackground(){const t=this.appService,i=this.options.config||t.controlsConfig;this.background.clear(),this.background.roundRect(-i.iconWrapperWidth/2,-i.iconWrapperHeight/2,i.iconWrapperWidth,i.iconWrapperHeight,i.iconWrapperBorderRadius).fill(this.options.backgroundColor)}async renderIcon(){try{const t=this.appService,i=this.options.config||t.controlsConfig;await this.icon.loadTextureAndSetSize(this.options.iconAlias,{width:i.iconWidth,height:i.iconHeight,sizeFixed:!1}),this.icon.visible=!0}catch(t){w.error(`Failed to load icon: ${this.options.iconAlias}`,t)}}destroy(){super.destroy()}}class yc extends Ni{constructor(t,i){super(t,i);g(this,"isRotating",!1);g(this,"hasRotated",!1);g(this,"rotationCenter",{x:0,y:0});g(this,"lastAngle",0);g(this,"clickHandler",null);g(this,"handleRotationPointerMove",t=>{var o,a;if(!this.isRotating)return;this.hasRotated=!0;const i=this.parent.toLocal(t.global),s=Math.atan2(i.y-this.rotationCenter.y,i.x-this.rotationCenter.x),n=s-this.lastAngle;(a=(o=this.options).onRotationMove)==null||a.call(o,n),this.lastAngle=s});g(this,"handleRotationPointerUp",()=>{var t,i;this.isRotating&&(this.isRotating=!1,this.hasRotated&&((i=(t=this.options).onRotationEnd)==null||i.call(t)),this.hasRotated=!1)});g(this,"handleRotationCancel",()=>{var t,i;this.isRotating&&(this.isRotating=!1,this.hasRotated&&((i=(t=this.options).onRotationEnd)==null||i.call(t)),this.hasRotated=!1)});this.appService=t,this.setupRotationEventListeners()}setupRotationEventListeners(){const{emitter:t}=this.appService;this.appService.emitter.on("gestureHijackPointerMove",this.handleRotationPointerMove),t.on("gestureHijackPointerUp",this.handleRotationPointerUp),t.on("gestureHijackCancel",this.handleRotationCancel)}cleanupRotationEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.handleRotationPointerMove),t.off("gestureHijackPointerUp",this.handleRotationPointerUp),t.off("gestureHijackCancel",this.handleRotationCancel)}setupEvents(){this.options.onClick&&(this.clickHandler=new vt(this,{onClick:()=>{var t,i;this.hasRotated||(i=(t=this.options).onClick)==null||i.call(t)},stopPropagation:!1})),this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(t){t.stopPropagation(),this.startRotation(t)}startRotation(t){var n,o;this.isRotating=!0,this.hasRotated=!1;const i=this.options.getTargetPoints();this.rotationCenter=de(i);const s=this.parent.toLocal(t.global);this.lastAngle=Math.atan2(s.y-this.rotationCenter.y,s.x-this.rotationCenter.x),(o=(n=this.options).onRotationStart)==null||o.call(n,this.rotationCenter),this.appService.emitter.emit("gestureHijackStart",t)}isCurrentlyRotating(){return this.isRotating}stopRotation(){var t,i;this.isRotating&&(this.isRotating=!1,this.hasRotated&&((i=(t=this.options).onRotationEnd)==null||i.call(t)),this.hasRotated=!1)}destroy(){var t;this.stopRotation(),(t=this.clickHandler)==null||t.destroy(),this.cleanupRotationEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class zs extends Ni{constructor(t,i){super(t,i);g(this,"clickHandler",null);this.appService=t}setupEvents(){this.clickHandler=new vt(this,{onClick:this.options.onClick,stopPropagation:!0})}destroy(){var t;(t=this.clickHandler)==null||t.destroy(),super.destroy()}}class Qe extends Ni{constructor(t,i){super(t,i);g(this,"isScaling",!1);g(this,"initialButtonPosition",null);g(this,"dragStartPosition",null);g(this,"handleScalePointerMove",t=>{var o,a;if(!this.isScaling||!this.initialButtonPosition||!this.dragStartPosition)return;const i=this.parent.toLocal(t.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;(a=(o=this.options).onScaleMove)==null||a.call(o,{deltaX:s,deltaY:n})});g(this,"handleScalePointerUp",()=>{var t,i;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,(i=(t=this.options).onScaleEnd)==null||i.call(t))});g(this,"handleScaleCancel",()=>{var t,i;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,(i=(t=this.options).onScaleEnd)==null||i.call(t))});this.appService=t,this.setupScaleEventListeners()}setupScaleEventListeners(){const{emitter:t}=this.appService;t.on("gestureHijackPointerMove",this.handleScalePointerMove),t.on("gestureHijackPointerUp",this.handleScalePointerUp),t.on("gestureHijackCancel",this.handleScaleCancel)}cleanupScaleEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.handleScalePointerMove),t.off("gestureHijackPointerUp",this.handleScalePointerUp),t.off("gestureHijackCancel",this.handleScaleCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(t){t.stopPropagation(),this.startScaling(t)}startScaling(t){var i,s,n,o;if(this.isScaling=!0,this.dragStartPosition=this.parent.toLocal(t.global),"initialButtonPosition"in this.options)this.initialButtonPosition={x:this.position.x,y:this.position.y},(s=(i=this.options).onScaleStart)==null||s.call(i);else{const a=this.options.getTargetPoints(),h=this.options.getButtonIndex();h>=0&&h<a.length&&(this.initialButtonPosition={...a[h]}),(o=(n=this.options).onScaleStart)==null||o.call(n,h)}this.appService.emitter.emit("gestureHijackStart",t)}isCurrentlyScaling(){return this.isScaling}stopScaling(){var t,i;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,(i=(t=this.options).onScaleEnd)==null||i.call(t))}destroy(){this.stopScaling(),this.cleanupScaleEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Ls extends Ni{constructor(t,i){super(t,i);g(this,"isMoving",!1);g(this,"dragStartPosition",null);g(this,"handleMovePointerMove",t=>{var i,s;!this.isMoving||!this.dragStartPosition||(s=(i=this.options).onMoveMove)==null||s.call(i,t)});g(this,"handleMovePointerUp",()=>{var t,i;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,(i=(t=this.options).onMoveEnd)==null||i.call(t))});g(this,"handleMoveCancel",()=>{var t,i;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,(i=(t=this.options).onMoveEnd)==null||i.call(t))});this.appService=t,this.setupMoveEventListeners()}setupMoveEventListeners(){const{emitter:t}=this.appService;t.on("gestureHijackPointerMove",this.handleMovePointerMove),t.on("gestureHijackPointerUp",this.handleMovePointerUp),t.on("gestureHijackCancel",this.handleMoveCancel)}cleanupMoveEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.handleMovePointerMove),t.off("gestureHijackPointerUp",this.handleMovePointerUp),t.off("gestureHijackCancel",this.handleMoveCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(t){t.stopPropagation(),this.startMoving(t)}startMoving(t){var i,s;this.isMoving=!0,this.dragStartPosition=this.parent.toLocal(t.global),(s=(i=this.options).onMoveStart)==null||s.call(i),this.appService.emitter.emit("gestureHijackStart",t)}isCurrentlyMoving(){return this.isMoving}getDragStartPosition(){return this.dragStartPosition?{...this.dragStartPosition}:null}stopMoving(){var t,i;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,(i=(t=this.options).onMoveEnd)==null||i.call(t))}destroy(){this.stopMoving(),this.cleanupMoveEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Gr extends H{constructor(t,i){super();g(this,"fillOptions");g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"handlePointerDown",t=>{t.stopPropagation(),this.startDragging(t)});g(this,"handleDragPointerMove",t=>{var i,s;!this.isDragging||!this.dragStartPosition||(s=(i=this.fillOptions).onDragMove)==null||s.call(i,t)});g(this,"handleDragPointerUp",()=>{var t,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,(i=(t=this.fillOptions).onDragEnd)==null||i.call(t))});g(this,"handleDragCancel",()=>{var t,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,(i=(t=this.fillOptions).onDragEnd)==null||i.call(t))});this.appService=t,this.fillOptions=i,this.setupInteraction(),this.setupDragEventListeners(),this.draw()}setupInteraction(){this.fillOptions.enableInteraction&&(this.eventMode="static",this.on("pointerdown",this.handlePointerDown))}setupDragEventListeners(){const{emitter:t}=this.appService;t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}startDragging(t){var s,n;this.isDragging=!0;const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},(n=(s=this.fillOptions).onDragStart)==null||n.call(s,t),this.appService.emitter.emit("gestureHijackStart",t)}draw(){const{points:t,fillColor:i}=this.fillOptions;if(t.length<3)return;this.clear();const s=t.flatMap(n=>[n.x,n.y]);this.setFillStyle({color:i}).poly(s).fill()}getDragStartPosition(){return this.dragStartPosition}updateOptions(t){this.fillOptions={...this.fillOptions,...t},t.enableInteraction!==void 0&&(this.off("pointerdown",this.handlePointerDown),this.setupInteraction()),this.draw()}updatePoints(t){this.fillOptions.points=t,this.draw()}updateFillColor(t){this.fillOptions.fillColor=t,this.draw()}stopDragging(){this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null)}isCurrentlyDragging(){return this.isDragging}setInteractionEnabled(t){this.fillOptions.enableInteraction=t,t?(this.eventMode="static",this.on("pointerdown",this.handlePointerDown)):(this.eventMode="auto",this.off("pointerdown",this.handlePointerDown),this.isDragging&&this.stopDragging())}destroy(){this.stopDragging(),this.cleanupDragEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}const Ur=(r,e,t)=>{if(e!=null){if(typeof e!="number"||!Number.isFinite(e)||e<=r){w.warn(`[${t}] maxSize (${String(e)}) must be a finite number greater than minSize (${r}); ignoring.`);return}return e}};class Nt extends L{constructor(t,i){super();g(this,"borderOptions");g(this,"solidLine",null);g(this,"dashGraphics",null);g(this,"fillGraphics",null);g(this,"handleAntiScale",()=>{this.drawBorder()});this.appService=t,this.borderOptions={...i},this.drawBorder(),this.setupAntiScaleListener(),this.eventMode="none"}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.handleAntiScale)}drawBorder(){const{points:t=[],closePath:i=!1,style:s}=this.borderOptions;t.length<2||(this.clearBorder(),s.fillColor!==void 0&&i&&this.drawFill(t,s),s.isDashed?this.drawContinuousDashedBorder(t,i,s):this.drawSolidBorder(t,i,s))}drawFill(t,i){if(!(!i.fillColor||t.length<3)){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy()),this.fillGraphics=new H,this.fillGraphics.setFillStyle({color:i.fillColor}),this.fillGraphics.moveTo(t[0].x,t[0].y);for(let s=1;s<t.length;s++)this.fillGraphics.lineTo(t[s].x,t[s].y);this.fillGraphics.closePath(),this.fillGraphics.fill(),this.addChild(this.fillGraphics)}}drawSolidBorder(t,i,s){const n=this.appService;this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy()),this.solidLine=new H;const o=n.getApp().toFixedSize(s.width);this.solidLine.setStrokeStyle({color:s.color,width:o}),this.solidLine.moveTo(t[0].x,t[0].y);for(let a=1;a<t.length;a++)this.solidLine.lineTo(t[a].x,t[a].y);i&&this.solidLine.lineTo(t[0].x,t[0].y),this.solidLine.stroke(),this.addChild(this.solidLine)}drawContinuousDashedBorder(t,i,s){if(t.length<2)return;if(!s.dashArray||s.dashArray.length!==2||s.dashArray[0]<=0||s.dashArray[1]<=0){w.warn("Invalid dashArray:",s.dashArray);return}const n=this.appService;this.dashGraphics=new H;const o=n.getApp().toFixedSize(s.width);this.dashGraphics.setStrokeStyle({color:s.color,width:o});const a=Math.max(n.getApp().toFixedSize(s.dashArray[0]),1),h=Math.max(n.getApp().toFixedSize(s.dashArray[1]),1),l=i?[...t,t[0]]:t;this.drawContinuousPathDashes(this.dashGraphics,l,a,h),this.dashGraphics.stroke(),this.addChild(this.dashGraphics)}drawContinuousPathDashes(t,i,s,n){if(i.length<2)return;if(s<=0||n<=0){w.warn("Invalid dash parameters:",{dashLength:s,gapLength:n});return}const o=this.calculatePathSegments(i),a=o.reduce((c,d)=>c+d.length,0);if(a===0)return;const h=s+n;let l=0;for(;l<a;){const c=l+s;c<=a?this.drawContinuousDashSegment(t,o,l,c):this.drawContinuousDashSegment(t,o,l,a),l+=h}}calculatePathSegments(t){const i=[];for(let s=0;s<t.length-1;s++){const n=t[s],o=t[s+1],a=o.x-n.x,h=o.y-n.y,l=Math.sqrt(a*a+h*h);i.push({start:n,end:o,length:l})}return i}drawContinuousDashSegment(t,i,s,n){if(s>=n)return;let o=0,a=!1,h=null;for(const l of i){const c=o,d=o+l.length;if(d>s&&c<n){const u=Math.max(s,c),p=Math.min(n,d),f=(u-c)/l.length,y=(p-c)/l.length,m={x:l.start.x+(l.end.x-l.start.x)*f,y:l.start.y+(l.end.y-l.start.y)*f},x={x:l.start.x+(l.end.x-l.start.x)*y,y:l.start.y+(l.end.y-l.start.y)*y};a?h&&Math.sqrt(Math.pow(m.x-h.x,2)+Math.pow(m.y-h.y,2))>.1&&t.lineTo(m.x,m.y):(t.moveTo(m.x,m.y),a=!0),t.lineTo(x.x,x.y),h=x}if(o+=l.length,o>=n)break}}clearBorder(){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy(),this.fillGraphics=null),this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy(),this.solidLine=null),this.dashGraphics&&(this.removeChild(this.dashGraphics),this.dashGraphics.destroy(),this.dashGraphics=null)}updateStyle(t){this.borderOptions.style={...this.borderOptions.style,...t},this.drawBorder()}updatePoints(t){this.borderOptions.points=t,this.drawBorder()}setClosePath(t){this.borderOptions.closePath=t,this.drawBorder()}getOptions(){return{...this.borderOptions}}destroy(){this.appService.emitter.off("antiScale",this.handleAntiScale),this.clearBorder(),super.destroy()}}class ji extends Bs{constructor(t,{text:i,style:s}){super({text:i,style:s});g(this,"throttledUpdateScale");this.appService=t,this.throttledUpdateScale=Ct(this.updateScale.bind(this),20,{leading:!0,trailing:!0}),this.registerScaleListener(),this.updateScale(this.appService.currentScale)}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}updateScale(t){t<=0||this.scale.set(1/t)}setBaseFontSize(t){this.style.fontSize=t}updateText(t){this.text=t}destroy(t){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}const At=class At extends L{constructor(t){super();g(this,"appService");g(this,"zoneData");g(this,"zoneType");g(this,"zoneConfig");g(this,"controlsConfig");g(this,"zoneEvents");g(this,"controlFill");g(this,"zoneBorder");g(this,"outlineBorder");g(this,"moveLine");g(this,"sizeText");g(this,"controlButtons");g(this,"deleteButton",null);g(this,"rotateButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"totalRotationAngle",0);g(this,"rotationCenter",null);g(this,"initialZonePoints",[]);g(this,"initialButtonPosition",null);g(this,"dragStartPosition",null);g(this,"clickHandler",null);g(this,"resolvedMaxSizeCache",null);g(this,"throttledUpdateOutline");g(this,"handleDragStart",t=>{this.isEditingEnabled()&&(this.initialZonePoints=this.zoneData.points.map(i=>({...i})),this.dragStartPosition=this.parent.toLocal(t.global),this.appService.getApp().requestRender("zone-drag",!0))});g(this,"handleDragMove",t=>{if(!this.isEditingEnabled()||this.initialZonePoints.length===0||!this.dragStartPosition)return;const i=this.parent.toLocal(t.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;this.applyTranslation(s,n)});g(this,"handleDragEnd",()=>{var t,i;this.initialZonePoints=[],this.dragStartPosition=null,this.appService.getApp().stopRender("zone-drag"),(i=(t=this.zoneEvents).onUpdate)==null||i.call(t,this.getZoneData())});g(this,"handleRotationStart",t=>{this.totalRotationAngle=0,this.rotationCenter=t,this.initialZonePoints=this.zoneData.points.map(i=>({...i})),this.appService.getApp().requestRender("zone-rotate",!0)});g(this,"handleRotationMove",t=>{this.totalRotationAngle+=t,this.applyRotation(this.totalRotationAngle)});g(this,"handleRotationEnd",()=>{var t,i;this.rotationCenter=null,this.totalRotationAngle=0,this.initialZonePoints=[],this.appService.getApp().stopRender("zone-rotate"),(i=(t=this.zoneEvents).onUpdate)==null||i.call(t,this.getZoneData())});g(this,"handleScaleStart",()=>{this.initialZonePoints=this.zoneData.points.map(i=>({...i}));const t=At.BUTTON_INDICES.SCALE;t<this.zoneData.points.length&&(this.initialButtonPosition={...this.zoneData.points[t]}),this.appService.getApp().requestRender("zone-scale",!0)});g(this,"handleScaleMove",({deltaX:t,deltaY:i})=>{if(this.initialZonePoints.length===0||!this.initialButtonPosition)return;const s={x:this.initialButtonPosition.x+t,y:this.initialButtonPosition.y+i};this.applyEdgeBasedScale(s)});g(this,"handleScaleEnd",()=>{var t,i;this.initialZonePoints=[],this.initialButtonPosition=null,this.appService.getApp().stopRender("zone-scale"),(i=(t=this.zoneEvents).onUpdate)==null||i.call(t,this.getZoneData())});g(this,"handleMoveStart",()=>{this.initialZonePoints=this.zoneData.points.map(t=>({...t})),this.appService.getApp().requestRender("zone-move",!0)});g(this,"handleMove",t=>{var a;if(!this.isEditingEnabled()||this.initialZonePoints.length===0)return;const i=this.parent.toLocal(t.global),s=(a=this.moveButton)==null?void 0:a.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleMoveEnd",()=>{var t,i;this.initialZonePoints=[],this.appService.getApp().stopRender("zone-move"),(i=(t=this.zoneEvents).onUpdate)==null||i.call(t,this.getZoneData())});g(this,"handleDelete",()=>{var t,i;(i=(t=this.zoneEvents).onRemove)==null||i.call(t,this.zoneData.id)});const{appService:i,zoneData:s,zoneType:n,events:o={}}=t;this.appService=i,this.zoneType=n,this.zoneEvents=o,this.zoneConfig=this.getZoneConfig(),this.controlsConfig=this.getControlsConfig();const a=this.validateAndCorrectZoneSize(s.points),h=Cs(a);this.zoneData={...s,points:h},this.throttledUpdateOutline=Ct(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.createControlButtons(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateOutline),this.appService.emitter.on("mapRotationUpdate",this.throttledUpdateOutline)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition())}getZoneConfig(){var i;const t=this.appService.getConfig();if(Ne(this.zoneType)){const s=t.controls[this.zoneType];if(s)return s}else{const s=(i=t.customZoneTypes)==null?void 0:i[this.zoneType];if(s)return s}return Ei.cleanZone}getControlsConfig(){const{controls:t}=this.appService.getConfig();return t}validateAndCorrectZoneSize(t){if(t.length<4)return t;const i=this.appService.metersToPixels(this.zoneConfig.minSize),s=this.getResolvedMaxSize(),n=s!=null?this.appService.metersToPixels(s):void 0;return sr(t,i,n)}getResolvedMaxSize(){const t=this.zoneConfig.maxSize;if(this.resolvedMaxSizeCache&&this.resolvedMaxSizeCache.key===t)return this.resolvedMaxSizeCache.value;const i=Ur(this.zoneConfig.minSize,t,this.zoneType);return this.resolvedMaxSizeCache={key:t,value:i},i}isEditingEnabled(){var s;const t=this.appService.runtimeSnapshot,i=this.zoneData.id;switch(this.zoneType){case"forbiddenSweepZone":return t.editingForbiddenSweepZoneIds.includes(i);case"forbiddenMopZone":return t.editingForbiddenMopZoneIds.includes(i);case"cleanZone":return t.editingCleanZoneIds.includes(i);default:return(((s=t.editingCustomZoneIds)==null?void 0:s[this.zoneType])??[]).includes(i)}}initializeComponents(){this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.controlFill=this.createControlFill(),this.addChild(this.controlFill),this.zoneBorder=this.createBorder(),this.addChild(this.zoneBorder),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.sizeText=this.createSizeText(),this.addChild(this.sizeText),this.controlButtons=new L,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.drawZone()}createControlButtons(){const t=this.calculateOutlinePoints();if(t.length<4)return;this.deleteButton=new zs(this.appService,{iconAlias:"deleteIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onClick:this.handleDelete}),this.deleteButton.position.set(t[At.BUTTON_INDICES.REMOVE].x,t[At.BUTTON_INDICES.REMOVE].y),this.zoneConfig.showRotateButton&&(this.rotateButton=new yc(this.appService,{iconAlias:"rotateIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,onRotationStart:this.handleRotationStart,onRotationMove:this.handleRotationMove,onRotationEnd:this.handleRotationEnd}),this.rotateButton.position.set(t[At.BUTTON_INDICES.ROTATE].x,t[At.BUTTON_INDICES.ROTATE].y)),this.scaleButton=new Qe(this.appService,{iconAlias:"scaleIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,getButtonIndex:()=>At.BUTTON_INDICES.SCALE,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(t[At.BUTTON_INDICES.SCALE].x,t[At.BUTTON_INDICES.SCALE].y);const i=this.calculateMoveButtonPosition();this.moveButton=new Ls(this.appService,{iconAlias:"moveIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(i.x,i.y),this.controlButtons.addChild(this.deleteButton),this.rotateButton&&this.controlButtons.addChild(this.rotateButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}createControlFill(){const t=this.isEditingEnabled();return new Gr(this.appService,{points:this.zoneData.points,fillColor:this.zoneConfig.fillColor,enableInteraction:t,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(){const i=this.isEditingEnabled()?this.zoneConfig.editing:this.zoneConfig.normal;return new Nt(this.appService,{points:this.zoneData.points,closePath:!0,style:{color:this.zoneConfig.strokeColor,width:this.zoneConfig.strokeWidth,isDashed:i.isDashed,dashArray:i.dashArray}})}createOutlineBorder(){const t=this.calculateOutlinePoints();return new Nt(this.appService,{points:t,closePath:!0,style:{color:this.zoneConfig.outlineStrokeColor,width:this.zoneConfig.outlineStrokeWidth,isDashed:this.zoneConfig.outlineDashed,dashArray:this.zoneConfig.outlineDashArray,fillColor:this.zoneConfig.outlineFillColor}})}createMoveLine(){const t=this.calculateOutlinePoints(),i=this.calculateMoveLinePoints(t);return new Nt(this.appService,{points:i,closePath:!1,style:{color:this.zoneConfig.outlineStrokeColor,width:this.zoneConfig.outlineStrokeWidth,isDashed:this.zoneConfig.outlineDashed,dashArray:this.zoneConfig.outlineDashArray}})}calculateOutlinePoints(){const{points:t}=this.zoneData;if(t.length<4)return t;const i=this.appService.getApp().toFixedSize(this.zoneConfig.outlineOffset);return Fr(t,i)}calculateMoveLinePoints(t){if(t.length<4)return[];const i=t[At.BUTTON_INDICES.MOVE],s=this.calculateMoveButtonPosition();return[i,s]}createSizeText(){const t=this.calculateZoneSizeText(),i=new ji(this.appService,{text:t,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.zoneConfig.textColor,align:"center"}});i.anchor.set(.5);const s=this.calculateSizeTextPosition();i.position.set(s.x,s.y);const n=this.calculateSizeTextRotation();return i.rotation=n,i.eventMode="none",i}calculateZoneSizeText(){const{points:t}=this.zoneData;if(t.length<4)return"0m*0m";const[i,s,,n]=t,o=Q(i,s),a=Q(i,n),h=this.appService.pixelsToMeters(o),l=this.appService.pixelsToMeters(a),c=this.appService.metersToDisplayUnit(h),d=this.appService.metersToDisplayUnit(l),u=this.appService.runtimeSnapshot.unitLabel;return`${c.toFixed(1)}${u}*${d.toFixed(1)}${u}`}calculateSizeTextPosition(){const{points:t}=this.zoneData;if(t.length<4)return{x:0,y:0};const[i,s,n,o]=t,{textPosition:a,textOffset:h}=this.zoneConfig,l=this.appService.getApp().toFixedSize(h);let c,d;switch(a){case"top":{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2};const u=gt(K(s,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"right":{c={x:(s.x+n.x)/2,y:(s.y+n.y)/2};const u=gt(K(s,n)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"bottom":{c={x:(o.x+n.x)/2,y:(o.y+n.y)/2};const u=gt(K(o,n)),p={x:-u.y,y:u.x};d={x:p.x*l,y:p.y*l};break}case"left":{c={x:(i.x+o.x)/2,y:(i.y+o.y)/2};const u=gt(K(o,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}default:c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:0,y:l};break}return{x:c.x+d.x,y:c.y+d.y}}calculateSizeTextRotation(){const{points:t}=this.zoneData;if(t.length<4)return 0;const[i,s,n,o]=t,{textPosition:a}=this.zoneConfig;let h,l;switch(a){case"top":h=i,l=s;break;case"right":h=s,l=n;break;case"bottom":h=n,l=o;break;case"left":h=o,l=i;break;default:h=i,l=s;break}const c=this.appService.appContainer.getMapRotationRadians();return qe(h,l,c)}calculateMoveButtonPosition(){const t=this.calculateOutlinePoints();if(t.length<4)return{x:0,y:0};const{controls:i}=this.appService.getConfig(),s=t[At.BUTTON_INDICES.MOVE],n=t[2],o=t[0],a=this.appService.getApp().toFixedSize(i.moveButtonOffset);return Ds(s,n,o,a)}applyTranslation(t,i){this.zoneData.points=this.initialZonePoints.map(s=>({x:s.x+t,y:s.y+i})),this.drawZone(),this.updateControlButtonsPosition()}applyRotation(t){!this.rotationCenter||this.initialZonePoints.length===0||(this.zoneData.points=Dr(this.initialZonePoints,this.rotationCenter,t),this.drawZone(!1),this.updateControlButtonsPosition())}applyEdgeBasedScale(t){if(this.initialZonePoints.length<4)return;const{FIXED:i}=At.BUTTON_INDICES,{x:s,y:n}=this.initialZonePoints[i],[,o,,a]=this.initialZonePoints,h={x:s,y:n},l=K(h,o),c=K(h,a),d=K(h,t),u=ee(l),p=ee(c);if(u===0||p===0)return;const f=this.appService.metersToPixels(this.zoneConfig.minSize),y=this.getResolvedMaxSize(),m=y!=null?this.appService.metersToPixels(y):void 0,[x,S]=[ae(d,l,u,f,m),ae(d,c,p,f,m)];this.zoneData.points=[h,{x:s+l.x*x,y:n+l.y*x},{x:s+l.x*x+c.x*S,y:n+l.y*x+c.y*S},{x:s+c.x*S,y:n+c.y*S}],this.drawZone(),this.updateControlButtonsPosition()}setupClickHandler(){this.clickHandler=new vt(this,{onClick:()=>{var t,i;this.isEditingEnabled()||(i=(t=this.zoneEvents)==null?void 0:t.onClick)==null||i.call(t,this.getZoneData())},stopPropagation:!1})}drawZone(t=!0){const{points:i}=this.zoneData;i.length<4||(this.controlFill.updatePoints(i),this.zoneBorder.updatePoints(i),this.updateOutlineBorder(),this.updateMoveLine(),this.updateSizeText(t))}updateOutlineBorder(){const t=this.calculateOutlinePoints();this.outlineBorder.updatePoints(t)}updateMoveLine(){const t=this.calculateOutlinePoints(),i=this.calculateMoveLinePoints(t);this.moveLine.updatePoints(i)}updateSizeText(t=!0){if(this.sizeText){if(t){const i=this.calculateZoneSizeText();this.sizeText.updateText(i)}this.updateSizeTextPosition()}}updateSizeTextPosition(){if(!this.sizeText)return;const t=this.calculateSizeTextPosition();this.sizeText.position.set(t.x,t.y);const i=this.calculateSizeTextRotation();this.sizeText.rotation=i}updateControlButtonsPosition(){if(!this.deleteButton||!this.scaleButton||!this.moveButton)return;const t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:i,ROTATE:s,SCALE:n}=At.BUTTON_INDICES,o=this.calculateMoveButtonPosition(),a=[{button:this.deleteButton,point:t[i]},{button:this.scaleButton,point:t[n]},{button:this.moveButton,point:o}];this.rotateButton&&a.push({button:this.rotateButton,point:t[s]}),a.forEach(({button:h,point:l})=>h.position.set(l.x,l.y))}updateEditState(){const t=this.isEditingEnabled();this.controlButtons.visible=t,!t&&this.getCurrentOperationState().hasAnyOperation&&this.stopAllOperations(),this.outlineBorder.visible=t,this.moveLine.visible=t,this.sizeText&&(this.sizeText.visible=t),t&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition()),this.controlFill.setInteractionEnabled(t),this.updateBorderStyle(t?this.zoneConfig.editing:this.zoneConfig.normal),this.zIndex=t?1e3:0}updateBorderStyle(t){this.zoneBorder.updateStyle({isDashed:t.isDashed,dashArray:t.dashArray})}getCurrentOperationState(){var o,a,h;const t=this.controlFill.isCurrentlyDragging(),i=((o=this.scaleButton)==null?void 0:o.isCurrentlyScaling())||!1,s=((a=this.rotateButton)==null?void 0:a.isCurrentlyRotating())||!1,n=((h=this.moveButton)==null?void 0:h.isCurrentlyMoving())||!1;return{isDragging:t,isScaling:i,isRotating:s,isMoving:n,hasAnyOperation:t||i||s||n}}stopAllOperations(){var t,i,s;this.controlFill.stopDragging(),(t=this.scaleButton)==null||t.stopScaling(),(i=this.rotateButton)==null||i.stopRotation(),(s=this.moveButton)==null||s.stopMoving()}stopDragging(){this.controlFill.stopDragging()}stopScaling(){var t;(t=this.scaleButton)==null||t.stopScaling()}stopRotating(){var t;(t=this.rotateButton)==null||t.stopRotation()}stopMoving(){var t;(t=this.moveButton)==null||t.stopMoving()}isCurrentlyDragging(){return this.controlFill.isCurrentlyDragging()}isCurrentlyScaling(){var t;return((t=this.scaleButton)==null?void 0:t.isCurrentlyScaling())||!1}isCurrentlyRotating(){var t;return((t=this.rotateButton)==null?void 0:t.isCurrentlyRotating())||!1}isCurrentlyMoving(){var t;return((t=this.moveButton)==null?void 0:t.isCurrentlyMoving())||!1}updateZoneData(t){const i=this.validateAndCorrectZoneSize(t.points),s=Cs(i);this.zoneData={...t,points:s},this.drawZone(),this.updateControlButtonsPosition(),this.updateEditState()}getZoneData(){return{...this.zoneData}}refreshDisplay(){this.drawZone()}destroy(){var t,i,s,n,o,a,h,l,c,d,u;this.appService.emitter.off("antiScale",this.throttledUpdateOutline),this.appService.emitter.off("mapRotationUpdate",this.throttledUpdateOutline),(t=this.clickHandler)==null||t.destroy(),this.clickHandler=null,(i=this.deleteButton)==null||i.destroy(),(s=this.rotateButton)==null||s.destroy(),(n=this.scaleButton)==null||n.destroy(),(o=this.moveButton)==null||o.destroy(),this.deleteButton=null,this.rotateButton=null,this.scaleButton=null,this.moveButton=null,(a=this.zoneBorder)==null||a.destroy(),(h=this.outlineBorder)==null||h.destroy(),(l=this.moveLine)==null||l.destroy(),(c=this.sizeText)==null||c.destroy(),(d=this.controlFill)==null||d.destroy(),(u=this.controlButtons)==null||u.destroy(),super.destroy()}};g(At,"BUTTON_INDICES",{REMOVE:0,ROTATE:1,SCALE:2,MOVE:3,FIXED:0});let oi=At;class Hr extends oi{constructor(e,t){super({appService:e,zoneData:t.zoneData,zoneType:"forbiddenSweepZone",events:{onRemove:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onRemoveForbiddenSweepZone)==null||n.call(s,i)},onUpdate:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onUpdateForbiddenSweepZone)==null||n.call(s,i)},onClick:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onClickForbiddenSweepZone)==null||n.call(s,i)}}})}static create(e,t){return new Hr(e,{zoneData:t})}}class Vr extends oi{constructor(e,t){super({appService:e,zoneData:t.zoneData,zoneType:"forbiddenMopZone",events:{onRemove:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onRemoveForbiddenMopZone)==null||n.call(s,i)},onUpdate:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onUpdateForbiddenMopZone)==null||n.call(s,i)},onClick:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onClickForbiddenMopZone)==null||n.call(s,i)}}})}static create(e,t){return new Vr(e,{zoneData:t})}}class Nr extends oi{constructor(e,t){super({appService:e,zoneData:t.zoneData,zoneType:"cleanZone",events:{onRemove:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onRemoveCleanZone)==null||n.call(s,i)},onUpdate:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onUpdateCleanZone)==null||n.call(s,i)},onClick:i=>{var s,n;(n=(s=e.events)==null?void 0:s.onClickCleanZone)==null||n.call(s,i)}}})}static create(e,t){return new Nr(e,{zoneData:t})}}class Ue extends H{constructor(t,i){super();g(this,"lineOptions");g(this,"strokeContext",null);g(this,"drawDashLine",()=>{const{start:t,end:i,style:s}=this.lineOptions;this.clear(),this.strokeContext&&this.strokeContext.destroy();const n=this.appService;this.strokeContext=new mt;const o=n.getApp().toFixedSize(s.width);this.strokeContext.setStrokeStyle({color:s.color,width:o}),this.drawDashedLineToContext(this.strokeContext,t.x,t.y,i.x,i.y,s.dashArray[0],s.dashArray[1]),this.strokeContext.stroke(),this.context=this.strokeContext});this.appService=t,this.lineOptions={...i},this.eventMode="static",this.drawDashLine(),this.setupAntiScaleListener()}setupAntiScaleListener(){this.appService.emitter.on("antiScale",this.drawDashLine)}drawDashedLineToContext(t,i,s,n,o,a,h){const l=n-i,c=o-s,d=Math.sqrt(l*l+c*c);if(d===0)return;const u=this.appService,p=u.getApp().toFixedSize(a),f=u.getApp().toFixedSize(h),y=p+f,m=d/y,x=Math.round(m);if(x===0){t.moveTo(i,s),t.lineTo(n,o);return}const S=d/x,v=S*(p/y),b=l/d,P=c/d;for(let C=0;C<x;C++){const A=C*S,k=A+v;if(A>=d)break;const M=Math.min(k,d),T=i+A*b,_=s+A*P,E=i+M*b,B=s+M*P;t.moveTo(T,_),t.lineTo(E,B)}}updatePoints(t,i){this.lineOptions.start=t,this.lineOptions.end=i,this.drawDashLine()}updateStyle(t){this.lineOptions.style={...this.lineOptions.style,...t},this.drawDashLine()}getOptions(){return{...this.lineOptions}}destroy(){this.appService.emitter.off("antiScale",this.drawDashLine),this.strokeContext&&this.strokeContext.destroy(),super.destroy()}}const Vt=class Vt extends L{constructor(t){super();g(this,"wallData");g(this,"wallConfig");g(this,"controlsConfig");g(this,"wallEvents");g(this,"appService");g(this,"wallLine");g(this,"outlineBorder");g(this,"moveLine");g(this,"lengthText");g(this,"controlButtons");g(this,"removeButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"initialWallPoints",[]);g(this,"initialButtonPosition",null);g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"resolvedMaxWidthCache",null);g(this,"throttledUpdateOutline");g(this,"throttledHandleScaleChange");g(this,"wallLineClickHandler",null);g(this,"handleRemove",()=>{var t,i;(i=(t=this.wallEvents).onRemove)==null||i.call(t,this.wallData.id)});g(this,"initializeOperation",()=>{this.initialWallPoints=this.wallData.points.map(t=>({...t}))});g(this,"finalizeOperation",()=>{var t,i;this.initialWallPoints=[],(i=(t=this.wallEvents).onUpdate)==null||i.call(t,this.getWallData())});g(this,"handleScaleStart",()=>{this.initializeOperation();const t=this.calculateOutlinePoints();t.length>Vt.BUTTON_INDICES.SCALE&&(this.initialButtonPosition={...t[Vt.BUTTON_INDICES.SCALE]}),this.appService.getApp().requestRender("virtualwall-scale",!0)});g(this,"handleScaleMove",({deltaX:t,deltaY:i})=>{if(this.initialWallPoints.length===0||!this.initialButtonPosition)return;const s={x:this.initialButtonPosition.x+t,y:this.initialButtonPosition.y+i};this.applyScaleAndRotation(s)});g(this,"handleScaleEnd",()=>{this.finalizeOperation(),this.initialButtonPosition=null,this.appService.getApp().stopRender("virtualwall-scale")});g(this,"handleMoveStart",()=>{this.initializeOperation(),this.appService.getApp().requestRender("virtualwall-move",!0)});g(this,"handleMove",t=>{var a;if(this.initialWallPoints.length===0)return;const i=this.parent.toLocal(t.global),s=this.getDragStartPosition()||((a=this.moveButton)==null?void 0:a.getDragStartPosition());if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleMoveEnd",()=>{this.finalizeOperation(),this.appService.getApp().stopRender("virtualwall-move")});g(this,"handleScaleChange",()=>{this.redrawSolidLine(),this.setupWallLineHitArea()});g(this,"handleWallLinePointerDown",t=>{this.isEditingEnabled()&&(t.stopPropagation(),this.startDragging(t))});g(this,"handleDragPointerMove",t=>{!this.isDragging||!this.dragStartPosition||this.handleMove(t)});g(this,"handleDragPointerUp",()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.appService.getApp().stopRender("virtualwall-drag"),this.finalizeOperation())});g(this,"handleDragCancel",()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.appService.getApp().stopRender("virtualwall-drag"),this.handleMoveEnd())});const{appService:i,wallData:s,events:n={}}=t;this.appService=i,this.wallEvents=n,this.wallConfig=this.appService.controlsConfig.virtualWall,this.controlsConfig=this.appService.controlsConfig,this.wallData={...s,points:this.validateAndCorrectWallLength(s.points)},this.throttledHandleScaleChange=Ct(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.throttledUpdateOutline=Ct(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.registerScaleListener(),this.setupDragEventListeners()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateOutline),this.appService.emitter.on("antiScale",this.throttledHandleScaleChange),this.appService.emitter.on("mapRotationUpdate",this.throttledUpdateOutline)}getResolvedMaxWidth(){const t=this.wallConfig.maxWidth;if(this.resolvedMaxWidthCache&&this.resolvedMaxWidthCache.key===t)return this.resolvedMaxWidthCache.value;const i=Ur(this.wallConfig.minWidth,t,"virtualWall");return this.resolvedMaxWidthCache={key:t,value:i},i}validateAndCorrectWallLength(t){if(t.length<2)return t;const[i,s]=t,n=this.appService.metersToPixels(this.wallConfig.minWidth),o=this.getResolvedMaxWidth(),a=o!=null?this.appService.metersToPixels(o):void 0,h=Q(i,s),l=h<n,c=a!=null&&h>a;if(!l&&!c)return t;if(h===0)return[i,{x:i.x+n,y:i.y}];const d=gt(K(i,s));let u=h;return a!=null&&(u=Math.min(u,a)),u=Math.max(u,n),[i,{x:i.x+d.x*u,y:i.y+d.y*u}]}isEditingEnabled(){return this.appService.runtimeSnapshot.editingVirtualWallIds.includes(this.wallData.id)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineComponents(),this.updateControlButtonsPosition(),this.updateLengthTextPosition())}initializeComponents(){this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.createWallLine(!1),this.addChild(this.wallLine),this.lengthText=this.createLengthText(),this.addChild(this.lengthText),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.controlButtons=new L,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.createControlButtons()}createWallLine(t=!0){const{points:i}=this.wallData;if(i.length<2)return;const{lineWidth:s,lineColor:n,editing:o,normal:a}=this.wallConfig,l=this.isEditingEnabled()?o:a;l.isDashed?this.wallLine=new Ue(this.appService,{start:i[0],end:i[1],style:{color:n.toString(),width:s,dashArray:l.dashArray}}):this.wallLine=this.createSolidLine(i[0],i[1],s,n.toString()),t&&this.setupWallLineInteraction()}createLengthText(){const t=this.calculateWallLengthInMeters(),i=this.formatLengthText(t),s=new ji(this.appService,{text:i,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.wallConfig.textColor,align:"center"}});s.anchor.set(.5);const n=this.calculateTextPosition();s.position.set(n.x,n.y);const o=this.calculateTextRotation();return s.rotation=o,s.eventMode="none",s}calculateWallLengthInMeters(){const{points:t}=this.wallData;if(t.length<2)return 0;const i=Q(t[0],t[1]);return this.appService.pixelsToMeters(i)}formatLengthText(t){const i=this.appService.metersToDisplayUnit(t),s=this.appService.runtimeSnapshot.unitLabel;return`${i.toFixed(1)}${s}`}calculateTextPosition(){const{points:t}=this.wallData;if(t.length<2)return{x:0,y:0};const[i,s]=t,n=this.appService.getApp().toFixedSize(this.wallConfig.textOffset);return ic(i,s,n)}calculateTextRotation(){const{points:t}=this.wallData;if(t.length<2)return 0;const[i,s]=t,n=this.appService.appContainer.getMapRotationRadians();return qe(i,s,n)}getOutlineStyle(){return{color:this.wallConfig.outlineStrokeColor,width:this.wallConfig.outlineStrokeWidth,isDashed:this.wallConfig.outlineDashed,dashArray:this.wallConfig.outlineDashArray,fillColor:this.wallConfig.outlineFillColor}}createOutlineBorder(){const t=this.calculateOutlinePoints();return new Nt(this.appService,{points:t,closePath:!0,style:this.getOutlineStyle()})}createMoveLine(){const t=this.calculateOutlinePoints(),i=this.calculateMoveLinePoints(t);return new Nt(this.appService,{points:i,closePath:!1,style:this.getOutlineStyle()})}calculateOutlinePoints(t){const i=t||this.wallData.points;if(i.length<2)return i;const s=this.appService.getApp().toFixedSize(this.wallConfig.outlineOffset),n=gy(i[0],i[1],s);return[n[3],n[2],n[1],n[0]]}calculateMoveLinePoints(t){if(t.length<4)return[];const{MOVE:i}=Vt.BUTTON_INDICES,s=t[i],n=this.calculateMoveButtonPosition();return[s,n]}calculateMoveButtonPosition(){const{moveButtonOffset:t}=this.controlsConfig,i=this.calculateOutlinePoints();if(i.length<4)return{x:0,y:0};const{MOVE:s}=Vt.BUTTON_INDICES,n=i[s],o=i[(s+3)%4],a=i[(s+1)%4],h=this.appService.getApp().toFixedSize(t);return Ds(n,a,o,h)}createControlButtons(){const t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:i,SCALE:s}=Vt.BUTTON_INDICES;this.removeButton=new zs(this.appService,{iconAlias:"deleteIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onClick:this.handleRemove}),this.removeButton.position.set(t[i].x,t[i].y),this.scaleButton=new Qe(this.appService,{iconAlias:"scaleIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,getTargetPoints:()=>this.calculateOutlinePoints(),getButtonIndex:()=>s,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(t[s].x,t[s].y);const n=this.calculateMoveButtonPosition();this.moveButton=new Ls(this.appService,{iconAlias:"moveIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(n.x,n.y),this.controlButtons.addChild(this.removeButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}applyScaleAndRotation(t){if(this.initialWallPoints.length<2)return;const[i,s]=this.initialWallPoints,n=i,o=this.calculateOutlinePoints(this.initialWallPoints);if(o.length<4)return;const a=o[Vt.BUTTON_INDICES.SCALE],l=K(s,a),c={x:t.x-l.x,y:t.y-l.y},d=K(n,c),u=Q(n,c),p=this.appService.metersToPixels(this.wallConfig.minWidth),f=this.getResolvedMaxWidth(),y=f!=null?this.appService.metersToPixels(f):void 0;let m;if(u<p)if(u===0)m={x:n.x+p,y:n.y};else{const x=gt(d);m={x:n.x+x.x*p,y:n.y+x.y*p}}else if(y!=null&&u>y){const x=gt(d);m={x:n.x+x.x*y,y:n.y+x.y*y}}else m=c;this.wallData.points=[n,m],this.drawVirtualWall(),this.updateControlButtonsPosition()}applyTranslation(t,i){this.wallData.points=this.initialWallPoints.map(s=>({x:s.x+t,y:s.y+i})),this.drawVirtualWall(),this.updateControlButtonsPosition()}drawVirtualWall(){this.updateWallLine(),this.updateLengthText(),this.updateOutlineComponents()}updateWallLine(){const{points:t}=this.wallData;t.length<2||(this.wallLine instanceof Ue?this.wallLine.updatePoints(t[0],t[1]):this.redrawSolidLine(),this.setupWallLineHitArea())}updateLengthText(){if(!this.lengthText)return;const t=this.calculateWallLengthInMeters(),i=this.formatLengthText(t);this.lengthText.updateText(i),this.updateLengthTextPosition()}updateLengthTextPosition(){if(!this.lengthText)return;const t=this.calculateTextPosition();this.lengthText.position.set(t.x,t.y);const i=this.calculateTextRotation();this.lengthText.rotation=i}updateOutlineComponents(){const t=this.calculateOutlinePoints();this.outlineBorder.updatePoints(t);const i=this.calculateMoveLinePoints(t);this.moveLine.updatePoints(i)}updateControlButtonsPosition(){if(!this.removeButton||!this.scaleButton||!this.moveButton)return;const t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:i,SCALE:s}=Vt.BUTTON_INDICES,n=this.calculateMoveButtonPosition();this.removeButton.position.set(t[i].x,t[i].y),this.scaleButton.position.set(t[s].x,t[s].y),this.moveButton.position.set(n.x,n.y)}updateEditState(){const t=this.isEditingEnabled();this.controlButtons.visible=t,this.outlineBorder.visible=t,this.moveLine.visible=t,this.lengthText&&(this.lengthText.visible=t),t&&(this.updateOutlineComponents(),this.updateControlButtonsPosition(),this.updateLengthTextPosition()),this.updateWallLineStyle(),this.setupWallLineInteraction(),this.zIndex=t?1e3:0}createSolidLine(t,i,s,n){const o=new H;o.eventMode="static";const a=this.appService.getApp().toFixedSize(s);return o.moveTo(t.x,t.y),o.lineTo(i.x,i.y),o.stroke({color:n,width:a}),o}updateWallLineStyle(){const t=this.isEditingEnabled(),{editing:i,normal:s,lineWidth:n,lineColor:o}=this.wallConfig,a=t?i:s;this.wallLine instanceof Ue!==a.isDashed?(this.removeChild(this.wallLine),this.wallLine.destroy(),this.createWallLine(!1),this.addChild(this.wallLine)):this.wallLine instanceof Ue?this.wallLine.updateStyle({color:o.toString(),width:n,dashArray:a.dashArray}):this.redrawSolidLine()}redrawSolidLine(){const t=this.appService;if(!this.wallLine||this.wallLine instanceof Ue)return;const{points:i}=this.wallData;if(i.length<2)return;const{lineWidth:s,lineColor:n}=this.wallConfig,o=t.getApp().toFixedSize(s);this.wallLine.clear(),this.wallLine.setStrokeStyle({color:n.toString(),width:o}).moveTo(i[0].x,i[0].y).lineTo(i[1].x,i[1].y).stroke()}setupWallLineInteraction(){var i;if(!this.wallLine)return;this.setupWallLineHitArea();const t=this.isEditingEnabled();(i=this.wallLineClickHandler)==null||i.destroy(),this.wallLineClickHandler=null,this.wallLine.off("pointerdown",this.handleWallLinePointerDown),t?this.wallLine.on("pointerdown",this.handleWallLinePointerDown):this.wallLineClickHandler=new vt(this.wallLine,{onClick:()=>{var s,n;this.appService.emitter.emit("suppressMapClick"),(n=(s=this.wallEvents)==null?void 0:s.onClick)==null||n.call(s,this.getWallData())},stopPropagation:!1})}setupDragEventListeners(){const{emitter:t}=this.appService;t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}startDragging(t){const i=this.appService;this.isDragging=!0;const s=this.parent.toLocal(t.global);this.dragStartPosition={x:s.x,y:s.y},this.initializeOperation(),i.getApp().requestRender("virtualwall-drag",!0),this.appService.emitter.emit("gestureHijackStart",t)}getDragStartPosition(){return this.dragStartPosition}setupWallLineHitArea(){if(!this.wallLine)return;const{points:t}=this.wallData;if(t.length<2)return;const{hitAreaThickness:i}=this.wallConfig,s=this.appService.getApp().toFixedSize(i),n=sc(t[0],t[1],s);if(n.length===0)return;const o=new Te(n);this.wallLine.hitArea=o}getWallData(){return{...this.wallData}}updateWallData(t){this.wallData={...t,points:this.validateAndCorrectWallLength(t.points)},this.drawVirtualWall(),this.updateControlButtonsPosition()}updateEditingState(){this.updateEditState()}refreshDisplay(){this.drawVirtualWall()}destroy(){var t,i,s,n,o,a,h,l,c;this.appService.emitter.off("antiScale",this.throttledUpdateOutline),this.appService.emitter.off("antiScale",this.throttledHandleScaleChange),this.appService.emitter.off("mapRotationUpdate",this.throttledUpdateOutline),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.wallLine&&this.wallLine.off("pointerdown",this.handleWallLinePointerDown),(t=this.wallLineClickHandler)==null||t.destroy(),this.wallLineClickHandler=null,(i=this.wallLine)==null||i.destroy(),(s=this.lengthText)==null||s.destroy(),(n=this.outlineBorder)==null||n.destroy(),(o=this.moveLine)==null||o.destroy(),(a=this.controlButtons)==null||a.destroy(),(h=this.removeButton)==null||h.destroy(),(l=this.scaleButton)==null||l.destroy(),(c=this.moveButton)==null||c.destroy(),this.removeButton=null,this.scaleButton=null,this.moveButton=null,super.destroy()}};g(Vt,"BUTTON_INDICES",{REMOVE:0,SCALE:2,MOVE:3});let or=Vt;class jr extends L{constructor(t){super();g(this,"spotData");g(this,"spotConfig");g(this,"controlsConfig");g(this,"spotEvents");g(this,"appService");g(this,"controlFill");g(this,"spotBorder");g(this,"centerIcon");g(this,"sizeText");g(this,"clickHandler",null);g(this,"initialSpotPoint",null);g(this,"dragStartMousePosition",null);g(this,"throttledUpdateScale");g(this,"unsubscribeMapRotation",null);g(this,"handleDragStart",t=>{this.isEditingEnabled()&&(this.initialSpotPoint={...this.spotData.point},this.dragStartMousePosition=this.parent.toLocal(t.global),this.appService.getApp().requestRender("spot-drag",!0))});g(this,"handleDragMove",t=>{if(!this.isEditingEnabled()||!this.initialSpotPoint||!this.dragStartMousePosition||!this.controlFill)return;const i=this.parent.toLocal(t.global),s=i.x-this.dragStartMousePosition.x,n=i.y-this.dragStartMousePosition.y;this.applyTranslation(s,n)});g(this,"handleDragEnd",()=>{var t,i;this.initialSpotPoint=null,this.dragStartMousePosition=null,this.appService.getApp().stopRender("spot-drag"),(i=(t=this.spotEvents).onUpdate)==null||i.call(t,this.getSpotData())});const{appService:i,spotData:s,events:n={}}=t;this.appService=i,this.spotData=s,this.spotEvents=n,this.controlsConfig=this.appService.controlsConfig,this.spotConfig=this.appService.controlsConfig.spot,this.position.set(s.point.x,s.point.y),this.throttledUpdateScale=Ct(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}updateScale(){this.isEditingEnabled()&&this.sizeText&&this.updateSizeTextPosition()}isEditingEnabled(){return this.appService.runtimeSnapshot.editingSpotIds.includes(this.spotData.id)}shouldShowIcon(){return(this.isEditingEnabled()?this.spotConfig.editing:this.spotConfig.normal).showIcon}calculateRectanglePoints(){const{size:t}=this.spotConfig;if(t===0)return[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];const s=this.appService.metersToPixels(t)/2;return[{x:-s,y:-s},{x:s,y:-s},{x:s,y:s},{x:-s,y:s}]}initializeComponents(){const t=this.calculateRectanglePoints();this.spotConfig.size>0&&(this.controlFill=this.createControlFill(t),this.addChild(this.controlFill),this.spotBorder=this.createBorder(t),this.addChild(this.spotBorder)),this.centerIcon=this.createCenterIcon(),this.addChild(this.centerIcon),this.spotConfig.showText&&(this.sizeText=this.createSizeText(),this.addChild(this.sizeText)),this.drawSpot()}createControlFill(t){const i=this.isEditingEnabled();return new Gr(this.appService,{points:t,fillColor:this.spotConfig.fillColor,enableInteraction:i,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(t){const s=this.isEditingEnabled()?this.spotConfig.editing:this.spotConfig.normal;return new Nt(this.appService,{points:t,closePath:!0,style:{color:this.spotConfig.strokeColor,width:this.spotConfig.strokeWidth,isDashed:s.isDashed,dashArray:s.dashArray}})}createCenterIcon(){const t=new Xt(this.appService);return this.loadIconTexture(t),t.position.set(0,0),t.eventMode="static",this.setupIconDrag(t),t.visible=!1,t}async loadIconTexture(t){const{iconSize:i,iconSizeFixed:s}=this.spotConfig;await t.loadTextureAndSetSize("spotIcon",{width:i,height:i,sizeFixed:s}),this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation||(this.unsubscribeMapRotation=G(this.appService.runtime,"mapRotation",n=>{this.applyAntiRotation(n)})),t.visible=this.shouldShowIcon()}applyAntiRotation(t){const i=-t*Math.PI/180;this.rotation=i}setupIconDrag(t){let i=null,s=!1;const n=h=>{if(!s||!this.initialSpotPoint||!i)return;const l=this.parent.toLocal(h.global),c=l.x-i.x,d=l.y-i.y;this.applyTranslation(c,d)},o=()=>{s&&(s=!1,this.initialSpotPoint=null,i=null,this.appService.getApp().stopRender("spot-drag"),this.appService.emitter.off("gestureHijackPointerMove",n),this.appService.emitter.off("gestureHijackPointerUp",a),this.appService.emitter.off("gestureHijackCancel",o))},a=()=>{var h,l;s&&(s=!1,this.initialSpotPoint=null,i=null,this.appService.getApp().stopRender("spot-drag"),(l=(h=this.spotEvents).onUpdate)==null||l.call(h,this.getSpotData()),this.appService.emitter.off("gestureHijackPointerMove",n),this.appService.emitter.off("gestureHijackPointerUp",a),this.appService.emitter.off("gestureHijackCancel",o))};t.on("pointerdown",h=>{this.isEditingEnabled()&&(h.stopPropagation(),s=!0,this.initialSpotPoint={...this.spotData.point},i=this.parent.toLocal(h.global),this.appService.getApp().requestRender("spot-drag",!0),this.appService.emitter.emit("gestureHijackStart",h),this.appService.emitter.on("gestureHijackPointerMove",n),this.appService.emitter.on("gestureHijackPointerUp",a),this.appService.emitter.on("gestureHijackCancel",o))})}createSizeText(){const t=this.calculateSpotSizeText(),i=new ji(this.appService,{text:t,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.spotConfig.textColor,align:"center"}});i.anchor.set(.5);const s=this.calculateSizeTextPosition();return i.position.set(s.x,s.y),i.eventMode="none",i}calculateSpotSizeText(){const{size:t}=this.spotConfig,i=this.appService.metersToDisplayUnit(t),s=this.appService.runtimeSnapshot.unitLabel;return`${i.toFixed(1)}${s}*${i.toFixed(1)}${s}`}calculateSizeTextPosition(){const t=this.calculateRectanglePoints();if(t.length<4)return{x:0,y:0};const[i,s,n,o]=t,{textPosition:a,textOffset:h}=this.spotConfig,l=this.appService.getApp().toFixedSize(h);let c,d;switch(a){case"top":{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:c.x,y:c.y+l};break}case"right":{c={x:(s.x+n.x)/2,y:(s.y+n.y)/2},d={x:c.x+l,y:c.y};break}case"bottom":{c={x:(o.x+n.x)/2,y:(o.y+n.y)/2},d={x:c.x,y:c.y+l};break}case"left":{c={x:(i.x+o.x)/2,y:(i.y+o.y)/2},d={x:c.x-l,y:c.y};break}default:{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:c.x,y:c.y+l};break}}return d}applyTranslation(t,i){this.initialSpotPoint&&(this.spotData.point={x:this.initialSpotPoint.x+t,y:this.initialSpotPoint.y+i},this.drawSpot())}setupClickHandler(){const t=this.spotConfig.size>0?this:this.centerIcon;this.clickHandler=new vt(t,{onClick:()=>{var i,s;this.isEditingEnabled()||(this.appService.emitter.emit("suppressMapClick"),(s=(i=this.spotEvents)==null?void 0:i.onClick)==null||s.call(i,this.getSpotData()))},stopPropagation:!1}),this.eventMode="static"}drawSpot(){const t=this.calculateRectanglePoints();this.position.set(this.spotData.point.x,this.spotData.point.y),this.spotConfig.size>0&&(this.controlFill&&this.controlFill.updatePoints(t),this.spotBorder&&this.spotBorder.updatePoints(t)),this.spotConfig.showText&&this.sizeText&&this.updateSizeText()}updateSizeText(){if(!this.sizeText)return;const t=this.calculateSpotSizeText();this.sizeText.updateText(t),this.updateSizeTextPosition()}updateSizeTextPosition(){if(!this.sizeText)return;const t=this.calculateSizeTextPosition();this.sizeText.position.set(t.x,t.y)}updateEditState(){const t=this.isEditingEnabled(),i=t?this.spotConfig.editing:this.spotConfig.normal;this.sizeText&&(this.sizeText.visible=t&&this.spotConfig.showText),this.centerIcon&&(this.centerIcon.visible=this.shouldShowIcon()),this.controlFill&&(this.controlFill.setInteractionEnabled(t),this.controlFill.visible=i.showFrame),this.spotBorder&&(this.spotBorder.updateStyle({isDashed:i.isDashed,dashArray:i.dashArray}),this.spotBorder.visible=i.showFrame),this.zIndex=t?1e3:0}updateSpotData(t){this.spotData={...t},this.drawSpot(),this.updateEditState()}getSpotData(){return{...this.spotData}}refreshDisplay(){this.drawSpot()}destroy(){var t,i,s,n,o;this.appService.emitter.off("antiScale",this.throttledUpdateScale),this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),(t=this.clickHandler)==null||t.destroy(),this.clickHandler=null,this.centerIcon&&this.spotConfig.size===0&&this.centerIcon.removeAllListeners(),(i=this.controlFill)==null||i.destroy(),(s=this.spotBorder)==null||s.destroy(),(n=this.centerIcon)==null||n.destroy(),(o=this.sizeText)==null||o.destroy(),super.destroy()}static create(t,i){return new jr({appService:t,spotData:i,events:{onUpdate:s=>{var n,o;(o=(n=t.events)==null?void 0:n.onUpdateSpot)==null||o.call(n,s)},onClick:s=>{var n,o;(o=(n=t.events)==null?void 0:n.onClickSpot)==null||o.call(n,s)}}})}}class sS extends mc{constructor(t){const{appService:i,wayPointData:s,order:n,events:o={}}=t;super(i);g(this,"wayPointData");g(this,"order");g(this,"wayPointConfig");g(this,"controlsConfig");g(this,"wayPointEvents");g(this,"icon");g(this,"orderContainer");g(this,"orderBackground");g(this,"orderText");g(this,"clickHandler",null);g(this,"initialWayPointPoint",null);g(this,"unsubscribeMapRotation",null);this.wayPointData=s,this.order=n,this.wayPointEvents=o,this.controlsConfig=this.appService.controlsConfig,this.wayPointConfig=this.appService.controlsConfig.wayPoint,this.position.set(s.point.x,s.point.y),this.initializeComponents(),this.updateEditState(),this.setupClickHandler()}isEditingEnabled(){return(this.appService.runtimeSnapshot.editingWayPointIds||[]).includes(this.wayPointData.id)}initializeComponents(){this.icon=this.createIcon(),this.addChild(this.icon),this.wayPointConfig.showOrder&&(this.createOrderContainer(),this.addChild(this.orderContainer))}createIcon(){const t=new Xt(this.appService);return this.loadIconTexture(t),t.position.set(0,0),t.anchor.set(.5,1),t.eventMode="static",this.setupIconDrag(t),t}async loadIconTexture(t){const i=this.isEditingEnabled(),s=i?this.wayPointConfig.editing:this.wayPointConfig.normal,{iconSize:n}=s,o=i?"wayPointActive":"wayPoint";await t.loadTextureAndSetSize(o,{width:n,height:n,sizeFixed:!1}),this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation||(this.unsubscribeMapRotation=G(this.appService.runtime,"mapRotation",a=>{this.applyAntiRotation(a)})),t.visible=!0,this.orderContainer&&this.updateOrderPosition()}applyAntiRotation(t){const i=-t*Math.PI/180;this.rotation=i}createOrderContainer(){const i=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal,{orderContainer:s,orderText:n}=i;this.orderContainer=new L,this.orderBackground=new H,this.orderText=new Bs({text:this.order.toString(),style:new ce({fontSize:n.fontSize,fontFamily:n.fontFamily,fontWeight:n.fontWeight,fill:n.color,align:"center",trim:!0})}),this.orderBackground.clear(),this.orderBackground.circle(0,0,s.size/2),this.orderBackground.fill({color:s.backgroundColor}),this.orderText.anchor.set(.5,.5),this.orderContainer.addChild(this.orderBackground),this.orderContainer.addChild(this.orderText),this.orderContainer.eventMode="none",this.orderContainer.visible=this.wayPointConfig.showOrder,this.updateOrderPosition()}updateOrderPosition(){if(!this.orderContainer)return;const i=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal,{offsetX:s,offsetY:n}=i.orderContainer;this.orderContainer.position.set(s,-n)}setupIconDrag(t){let i=null,s=null,n=!1;const o=h=>{if(!(!n||!i||!s)&&this.parent){const l=this.parent.toLocal(h.global),c=l.x-i.x,d=l.y-i.y,u={x:s.x+c,y:s.y+d};this.wayPointData.point=u,this.position.set(u.x,u.y),this.orderContainer&&this.updateOrderPosition()}},a=()=>{var h,l;n&&(n=!1,i=null,s=null,(l=(h=this.wayPointEvents).onUpdate)==null||l.call(h,this.wayPointData),this.appService.emitter.off("gestureHijackPointerMove",o),this.appService.emitter.off("gestureHijackPointerUp",a),this.appService.emitter.emit("gestureHijackCancel"))};t.on("pointerdown",h=>{this.isEditingEnabled()&&(h.stopPropagation(),s={...this.wayPointData.point},this.parent&&(i=this.parent.toLocal(h.global)),n=!0,this.parent&&(this.appService.emitter.emit("gestureHijackStart",h),this.appService.emitter.on("gestureHijackPointerMove",o),this.appService.emitter.on("gestureHijackPointerUp",a)))})}setupClickHandler(){this.clickHandler=new vt(this.icon,{stopPropagation:!1,onClick:()=>{var t,i;this.appService.emitter.emit("suppressMapClick"),(i=(t=this.wayPointEvents).onClick)==null||i.call(t,this.wayPointData)}})}updateWayPoint(t){this.wayPointData=t,this.drawWayPoint()}updateOrder(t){this.order=t,this.orderText&&(this.orderText.text=t.toString())}getWayPointData(){return{...this.wayPointData}}drawWayPoint(){this.position.set(this.wayPointData.point.x,this.wayPointData.point.y),this.orderContainer&&this.updateOrderPosition()}updateEditState(){if(this.loadIconTexture(this.icon),this.orderContainer&&this.orderText&&this.orderBackground){const i=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal;this.orderText.style=new ce({fontSize:i.orderText.fontSize,fontFamily:i.orderText.fontFamily,fontWeight:i.orderText.fontWeight,fill:i.orderText.color,align:"center",trim:!0});const{size:s,backgroundColor:n}=i.orderContainer;this.orderBackground.clear(),this.orderBackground.circle(0,0,s/2).fill(n),this.orderContainer.visible=this.wayPointConfig.showOrder,this.updateOrderPosition()}}onEditStateChange(){this.updateEditState()}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.icon&&this.icon.removeAllListeners(),super.destroy()}}class qa extends H{constructor(t,i){super();g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"initialPosition");g(this,"handleDragPointerMove",t=>{var a,h;if(!this.isDragging||!this.dragStartPosition)return;const i=this.parent.toLocal(t.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y,o={x:this.initialPosition.x+s,y:this.initialPosition.y+n};this.position.set(o.x,o.y),(h=(a=this.options).onDragMove)==null||h.call(a,o)});g(this,"handleDragPointerUp",()=>{var i,s;if(!this.isDragging)return;const t=this.appService;this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("endpoint-drag"),(s=(i=this.options).onDragEnd)==null||s.call(i)});g(this,"handleDragCancel",()=>{var i,s;if(!this.isDragging)return;const t=this.appService;this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("endpoint-drag"),(s=(i=this.options).onDragEnd)==null||s.call(i)});this.appService=t,this.options=i,this.initialPosition={...i.position},this.position.set(i.position.x,i.position.y),this.eventMode="static",this.cursor="pointer",this.setupEvents(),this.draw(),this.setupDragEventListeners()}draw(){const t=this.appService,{config:i}=this.options,s=t.getApp().toFixedSize(i.endPointSize),n=t.getApp().toFixedSize(i.endPointStrokeWidth);this.clear(),this.circle(0,0,s/2),this.fill({color:i.endPointColor}),this.stroke({color:i.endPointStrokeColor,width:n}),this.setupHitArea()}setupHitArea(){const t=this.appService,{config:i}=this.options,s=Math.max(i.endPointSize/2+10,20),n=t.getApp().toFixedSize(s);this.hitArea=new Rs(0,0,n)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}setupDragEventListeners(){const{emitter:t}=this.appService;t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handlePointerDown(t){t.stopPropagation(),this.startDragging(t)}startDragging(t){var s,n;const i=this.appService;this.isDragging=!0,this.dragStartPosition=this.parent.toLocal(t.global),this.initialPosition={x:this.x,y:this.y},(n=(s=this.options).onDragStart)==null||n.call(s),i.getApp().requestRender("endpoint-drag",!0),this.appService.emitter.emit("gestureHijackStart",t)}updatePosition(t){this.position.set(t.x,t.y),this.initialPosition={...t}}getPosition(){return{x:this.x,y:this.y}}redraw(){this.draw()}destroy(){this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.cleanupDragEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class nS extends L{constructor(t){super();g(this,"endPoints");g(this,"dividerConfig");g(this,"dividerEvents");g(this,"roomId");g(this,"appService");g(this,"roomGeometry",null);g(this,"dashLine");g(this,"solidLine",null);g(this,"startEndPoint");g(this,"endEndPoint");g(this,"solidLinePoints",null);g(this,"initialDividerPoints",[]);g(this,"isDragging",!1);g(this,"dragStartPosition",null);g(this,"throttledHandleScaleChange");g(this,"handleEndPointDragStart",()=>{this.initialDividerPoints=this.endPoints.map(t=>({...t})),this.clearSolidLine(),this.appService.getApp().requestRender("divider-endpoint-drag",!0)});g(this,"handleEndPointDragMove",(t,i)=>{this.initialDividerPoints.length!==0&&(this.endPoints[t]=i,this.updateDashLine(),this.updateSolidLine(),this.setupDashLineHitArea())});g(this,"handleEndPointDragEnd",()=>{var t,i;this.initialDividerPoints=[],this.appService.getApp().stopRender("divider-endpoint-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),(i=(t=this.dividerEvents).onUpdate)==null||i.call(t,this.getDividerEndPoints())});g(this,"handleDashLinePointerDown",t=>{t.stopPropagation(),this.startDragging(t)});g(this,"handleDragPointerMove",t=>{if(!this.isDragging||!this.dragStartPosition||this.initialDividerPoints.length===0)return;const i=this.parent.toLocal(t.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;this.endPoints=this.initialDividerPoints.map(o=>({x:o.x+s,y:o.y+n})),this.updateAllComponents()});g(this,"handleDragPointerUp",()=>{var t,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],this.appService.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),(i=(t=this.dividerEvents).onUpdate)==null||i.call(t,this.getDividerEndPoints()))});g(this,"handleDragCancel",()=>{var t,i;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],this.appService.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),(i=(t=this.dividerEvents).onUpdate)==null||i.call(t,this.getDividerEndPoints()))});g(this,"handleScaleChange",()=>{var t,i;(t=this.startEndPoint)==null||t.redraw(),(i=this.endEndPoint)==null||i.redraw(),this.updateSolidLine(),this.setupDashLineHitArea()});const{appService:i,endPoints:s,roomId:n,events:o={}}=t;this.appService=i,this.dividerEvents=o,this.roomId=n,this.dividerConfig=this.appService.dividerConfig,this.roomGeometry=this.appService.mapManager.getRoomById(this.roomId)||null,s?this.endPoints=this.validateDividerPoints(s):this.endPoints=this.createDefaultdividerPoints(),this.throttledHandleScaleChange=Ct(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.calculateAndCreateSolidLine(),this.registerScaleListener(),this.setupDragEventListeners()}validateDividerPoints(t){if(t.length>=2)return t.slice(0,2);const i=t[0]||{x:0,y:0},s={x:i.x+50,y:i.y};return[i,s]}createDefaultdividerPoints(){if(!this.roomGeometry)return w.warn("Room geometry not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const t=this.appService.getApp().mapState;if(!t)return w.warn("Map state not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const{boundingBox:i}=this.roomGeometry,s=this.appService.getApp().toFixedSize(this.dividerConfig.defaultExtension),n=this.dividerConfig.defaultDirection,o=i.x+i.width/2,a=i.y+i.height/2,h=n==="horizontal"?i.width+2*s:i.height+2*s;return Cy(o,a,h,n).map(c=>({x:c.x-t.origin.x,y:c.y-t.origin.y}))}initializeComponents(){this.createDashLine(),this.addChild(this.dashLine),this.createEndPoints(),this.addChild(this.startEndPoint),this.addChild(this.endEndPoint),this.setupDashLineInteraction()}createDashLine(){const t=this.endPoints;if(t.length<2)return;const{dashLineWidth:i,dashLineDashArray:s,lineColor:n}=this.dividerConfig;this.dashLine=new Ue(this.appService,{start:t[0],end:t[1],style:{color:n.toString(),width:i,dashArray:s}})}createEndPoints(){const t=this.endPoints;this.startEndPoint=new qa(this.appService,{position:t[0],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:i=>this.handleEndPointDragMove(0,i),onDragEnd:this.handleEndPointDragEnd}),this.endEndPoint=new qa(this.appService,{position:t[1],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:i=>this.handleEndPointDragMove(1,i),onDragEnd:this.handleEndPointDragEnd})}setupDashLineInteraction(){this.dashLine&&(this.setupDashLineHitArea(),this.dashLine.off("pointerdown",this.handleDashLinePointerDown),this.dashLine.on("pointerdown",this.handleDashLinePointerDown))}setupDashLineHitArea(){if(!this.dashLine)return;const t=this.endPoints;if(t.length<2)return;const{hitAreaThickness:i}=this.dividerConfig,s=this.appService.getApp().toFixedSize(i),n=sc(t[0],t[1],s);if(n.length===0)return;const o=new Te(n);this.dashLine.hitArea=o}startDragging(t){this.isDragging=!0;const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},this.initialDividerPoints=this.endPoints.map(s=>({...s})),this.clearSolidLine(),this.appService.getApp().requestRender("divider-drag",!0),this.appService.emitter.emit("gestureHijackStart",t)}setupDragEventListeners(){const{emitter:t}=this.appService;t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}updateAllComponents(){this.updateDashLine(),this.updateSolidLine(),this.updateEndPoints(),this.setupDashLineHitArea()}updateDashLine(){const t=this.endPoints;t.length<2||!this.dashLine||this.dashLine.updatePoints(t[0],t[1])}updateSolidLine(){if(!this.solidLine||!this.solidLinePoints)return;const{solidLineWidth:t,lineColor:i}=this.dividerConfig,s=this.appService.getApp().toFixedSize(t);this.solidLine.clear(),this.solidLine.setStrokeStyle({color:i.toString(),width:s}).moveTo(this.solidLinePoints[0].x,this.solidLinePoints[0].y).lineTo(this.solidLinePoints[1].x,this.solidLinePoints[1].y).stroke()}updateEndPoints(){const t=this.endPoints;this.startEndPoint&&this.startEndPoint.updatePosition(t[0]),this.endEndPoint&&this.endEndPoint.updatePosition(t[1])}registerScaleListener(){const{emitter:t}=this.appService;t.on("antiScale",this.throttledHandleScaleChange)}getDividerEndPoints(){return[...this.endPoints]}getEffectiveDividerPoints(){return this.solidLinePoints?[...this.solidLinePoints]:null}calculateAndCreateSolidLine(){if(this.clearSolidLine(),typeof this.roomId!="number"||!this.getRoomGraphics())return;const i=this.calculateLineRoomIntersection();i&&i.length>=2&&(this.solidLinePoints=[i[0],i[i.length-1]],this.createSolidLine())}getRoomGraphics(){const t=this.appService.mapManager.roomFill;return!t||typeof this.roomId!="number"?null:t.getRoomGraphicsMap().get(this.roomId)||null}calculateLineRoomIntersection(){const t=this.endPoints;if(t.length<2||typeof this.roomId!="number")return null;const[i,s]=t,n=this.isPointInRoomFill(i),o=this.isPointInRoomFill(s);if(n||o)return null;const a=cy(i,s),h=[];for(const p of a)this.isPointInRoomFill(p)&&h.push(p);if(h.length===0)return null;const l=h[0],c=h[h.length-1];return Q(l,c)<3?null:Ay(l,c,.5)}isPointInRoomFill(t){if(typeof this.roomId!="number")return!1;const i=this.appService.getApp().mapState;if(!i)return!1;const s={x:t.x+i.origin.x,y:t.y+i.origin.y};return i.mapType==="raster"?this.isPointInRasterRoomFill(s):this.isPointInStructuredRoomFill(s)}isPointInRasterRoomFill(t){t.x-=.5,t.y-=.5;const i=this.appService.getApp().mapState,s=this.appService.mapManager.roomFill;if(!i||!s)return!1;const n=s.getRasterRoomData(this.roomId);if(!n)return!1;const o=s.getMapWidth();if(o===0)return!1;const a=Math.round(t.x),h=Math.round(t.y);if(a<0||h<0||a>=o)return!1;const l=h*o+a;for(let c=0;c<n.pixelIndices.length;c++)if(n.pixelIndices[c]===l)return!0;return!1}isPointInStructuredRoomFill(t){const i={x:Math.round(t.x),y:Math.round(t.y)},s=this.appService.getApp().mapState,n=this.appService.mapManager.getRoomById(this.roomId);return!s||!n||!n.outlinePoints?!1:Et(i,n.outlinePoints,!0)}isDividerCompletelyOutOfRoom(){if(!this.roomGeometry)return!1;const{boundingBox:t}=this.roomGeometry,i=this.endPoints;if(i.length<2)return!1;const s=this.appService.getApp().mapState;if(!s)return!1;const n={x:i[0].x+s.origin.x,y:i[0].y+s.origin.y},o={x:i[1].x+s.origin.x,y:i[1].y+s.origin.y};return!wy(n,o,t.x,t.y,t.width,t.height)}checkAndResetIfOutOfRoom(){const{resetDividerWhenOutOfRoom:t}=this.appService.dividerConfig;t&&this.isDividerCompletelyOutOfRoom()&&this.resetToDefaultState()}resetToDefaultState(){var t,i;this.endPoints=this.createDefaultdividerPoints(),this.calculateAndCreateSolidLine(),this.updateComponents(),(i=(t=this.dividerEvents).onUpdate)==null||i.call(t,this.endPoints)}updateComponents(){const t=this.endPoints;t.length>=2&&(this.dashLine.updatePoints(t[0],t[1]),this.startEndPoint.position.set(t[0].x,t[0].y),this.endEndPoint.position.set(t[1].x,t[1].y),this.setupDashLineInteraction())}createSolidLine(){if(!this.solidLinePoints)return;const{solidLineWidth:t,lineColor:i}=this.dividerConfig;this.solidLine=new H,this.solidLine.eventMode="none";const s=this.appService.getApp().toFixedSize(t);this.solidLine.setStrokeStyle({color:i.toString(),width:s}).moveTo(this.solidLinePoints[0].x,this.solidLinePoints[0].y).lineTo(this.solidLinePoints[1].x,this.solidLinePoints[1].y).stroke(),this.addChildAt(this.solidLine,0)}clearSolidLine(){this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy(),this.solidLine=null),this.solidLinePoints=null}updatedividerPoints(t){this.endPoints=this.validateDividerPoints(t),this.updateAllComponents(),this.calculateAndCreateSolidLine()}destroy(){var t,i,s;this.appService.emitter.off("antiScale",this.throttledHandleScaleChange),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[]),this.dashLine&&this.dashLine.off("pointerdown",this.handleDashLinePointerDown),this.clearSolidLine(),(t=this.dashLine)==null||t.destroy(),(i=this.startEndPoint)==null||i.destroy(),(s=this.endEndPoint)==null||s.destroy(),super.destroy()}}const ar=["forbiddenSweepZone","forbiddenMopZone","cleanZone","virtualWall","spot","wayPoint","divider"];function rS(r){if(!r||r.length===0)return[...ar];const e=new Set,t=[];for(const i of r)e.has(i)||(e.add(i),t.push(i));for(const i of ar)e.has(i)||t.push(i);return t}class oS{constructor(e){g(this,"zoneMaps",new Map);g(this,"virtualWallMap",new Map);g(this,"spotMap",new Map);g(this,"wayPointMap",new Map);g(this,"divider",null);g(this,"controlContainers",new Map);g(this,"unsubscribeFns",[]);g(this,"builtinZoneFactories",{forbiddenSweepZone:e=>Hr.create(this.appService,e),forbiddenMopZone:e=>Vr.create(this.appService,e),cleanZone:e=>Nr.create(this.appService,e)});this.appService=e,this.initializeControlContainers();const t=G(e.runtime,"editingForbiddenSweepZoneIds",u=>{w.log(`[runtime] editingForbiddenSweepZoneIds: ${u}`);const p=this.zoneMaps.get("forbiddenSweepZone");p&&this.updateZonesEditState(p)}),i=G(e.runtime,"editingForbiddenMopZoneIds",u=>{w.log(`[runtime] editingForbiddenMopZoneIds: ${u}`);const p=this.zoneMaps.get("forbiddenMopZone");p&&this.updateZonesEditState(p)}),s=G(e.runtime,"editingCleanZoneIds",u=>{w.log(`[runtime] editingCleanZoneIds: ${u}`);const p=this.zoneMaps.get("cleanZone");p&&this.updateZonesEditState(p)}),n=G(e.runtime,"editingCustomZoneIds",u=>{w.log(`[runtime] editingCustomZoneIds: ${JSON.stringify(u??{})}`);for(const[p,f]of this.zoneMaps)Ne(p)||f.size&&this.updateZonesEditState(f)}),o=G(e.runtime,"editingVirtualWallIds",u=>{w.log(`[runtime] editingVirtualWallIds: ${u}`),this.updateVirtualWallsEditState(this.virtualWallMap)}),a=G(e.runtime,"editingSpotIds",u=>{w.log(`[runtime] editingSpotIds: ${u}`),this.updateSpotsEditState(this.spotMap)}),h=G(e.runtime,"editingWayPointIds",u=>{w.log(`[runtime] editingWayPointIds: ${u}`),this.updateWayPointsEditState(this.wayPointMap)}),l=G(e.runtime,"dividingRoomId",u=>{w.log(`[runtime] dividingRoomId: ${u}`),this.handleDividingRoomIdChange(u)}),c=G(e.runtime,"unit",u=>{w.log(`[runtime] unit changed: ${u}`),this.handleUnitChange()}),d=G(e.runtime,"unitLabel",u=>{w.log(`[runtime] unitLabel changed: ${u}`),this.handleUnitChange()});this.unsubscribeFns.push(t,i,s,n,o,a,h,l,c,d)}updateRenderOrder(){this.applyRenderOrder()}initializeControlContainers(){const e=this.appService.appContainer.getLayer(Ke);if(!e){w.warn("[ControlsManager] LAYER_CONTROLS not found during init");return}for(const t of ar){const i=new L;i.label=`controls:${t}`,this.controlContainers.set(t,i),e.addChild(i)}this.applyRenderOrder()}applyRenderOrder(){const e=this.appService.appContainer.getLayer(Ke);if(!e)return;rS(this.appService.getConfig().controls.renderOrder).forEach((i,s)=>{const n=this.controlContainers.get(i);n&&(n.zIndex=s)}),e.sortableChildren=!0,e.sortChildren()}addToControlLayer(e,t){let i=this.controlContainers.get(e);if(!i){const s=this.appService.appContainer.getLayer(Ke);if(!s){w.warn("[ControlsManager] LAYER_CONTROLS not found");return}i=new L,i.label=`controls:${e}`,this.controlContainers.set(e,i),s.addChild(i),this.applyRenderOrder()}i.addChild(t)}drawForbiddenSweepZones(e){this.drawZonesByType("forbiddenSweepZone",e)}getForbiddenSweepZones(){return this.getZonesDataByType("forbiddenSweepZone")}clearAllForbiddenSweepZones(){this.clearAllZonesByType("forbiddenSweepZone")}drawForbiddenMopZones(e){this.drawZonesByType("forbiddenMopZone",e)}getForbiddenMopZones(){return this.getZonesDataByType("forbiddenMopZone")}clearAllForbiddenMopZones(){this.clearAllZonesByType("forbiddenMopZone")}drawCleanZones(e){this.drawZonesByType("cleanZone",e)}getCleanZones(){return this.getZonesDataByType("cleanZone")}clearAllCleanZones(){this.clearAllZonesByType("cleanZone")}drawVirtualWalls(e){var n;const t=this.appService,i=this.virtualWallMap,s=new Set(e.map(o=>o.id));for(const[o,a]of i)s.has(o)||((n=a.parent)==null||n.removeChild(a),a.destroy(),i.delete(o));e.forEach(o=>{const a=i.get(o.id);if(a)this.isWallDataEqual(a.getWallData(),o)||a.updateWallData(o);else{const h=new or({appService:t,wallData:o,events:{onRemove:l=>{var c,d;(d=(c=t.events)==null?void 0:c.onRemoveVirtualWall)==null||d.call(c,l)},onUpdate:l=>{var c,d;(d=(c=t.events)==null?void 0:c.onUpdateVirtualWall)==null||d.call(c,l)},onClick:l=>{var c,d;(d=(c=t.events)==null?void 0:c.onClickVirtualWall)==null||d.call(c,l)}}});i.set(o.id,h),this.addToControlLayer("virtualWall",h)}})}getVirtualWalls(){return this.getWallsData(this.virtualWallMap)}clearAllVirtualWalls(){this.clearAllWalls(this.virtualWallMap)}drawSpots(e){const t=this.spotMap;if(!e||e.length===0){this.clearAllSpotsInternal(t);return}const i=new Set(t.keys()),s=new Set(e.map(n=>n.id));for(const n of i)s.has(n)||this.removeSpot(n,t);e.forEach(n=>{const o=t.get(n.id);o?this.isSpotDataEqual(o.getSpotData(),n)||o.updateSpotData(n):this.addNewSpot(n,t)})}getSpots(){return this.getSpotsData(this.spotMap)}clearAllSpots(){this.clearAllSpotsInternal(this.spotMap)}getZoneMap(e){let t=this.zoneMaps.get(e);return t||(t=new Map,this.zoneMaps.set(e,t)),t}resolveZoneFactory(e){var s;const t=this.builtinZoneFactories[e];return t||((s=this.appService.getConfig().customZoneTypes)!=null&&s[e]?n=>new oi({appService:this.appService,zoneData:n,zoneType:e,events:{onRemove:o=>{var a,h;return(h=(a=this.appService.events)==null?void 0:a.onRemoveCustomZone)==null?void 0:h.call(a,e,o)},onUpdate:o=>{var a,h;return(h=(a=this.appService.events)==null?void 0:a.onUpdateCustomZone)==null?void 0:h.call(a,e,o)},onClick:o=>{var a,h;return(h=(a=this.appService.events)==null?void 0:a.onClickCustomZone)==null?void 0:h.call(a,e,o)}}}):null)}drawCustomZones(e,t){this.drawZonesByType(e,t)}getCustomZones(e){return this.getZonesDataByType(e)}clearCustomZones(e){this.clearAllZonesByType(e)}drawZonesByType(e,t){const i=this.resolveZoneFactory(e);if(!i){w.warn(`[ControlsManager] Unknown zone type: ${e}`);return}const s=this.getZoneMap(e);this.drawZonesImpl(t,s,i,e)}getZonesDataByType(e){const t=this.zoneMaps.get(e);return t?this.getZonesData(t):[]}clearAllZonesByType(e){const t=this.zoneMaps.get(e);t&&this.clearAllZones(t)}drawZonesImpl(e,t,i,s){if(!e||e.length===0){this.clearAllZones(t);return}const n=new Set(t.keys()),o=new Set(e.map(a=>a.id));for(const a of n)o.has(a)||this.removeZone(a,t);e.forEach(a=>{const h=t.get(a.id);h?this.isZoneDataEqual(h.getZoneData(),a)||h.updateZoneData(a):this.addNewZone(a,t,i,s)})}addNewZone(e,t,i,s){const n=i(e);t.set(e.id,n),this.addToControlLayer(s,n)}removeZone(e,t){var s;const i=t.get(e);i&&((s=i.parent)==null||s.removeChild(i),i.destroy(),t.delete(e))}getZonesData(e){const t=[];return e.forEach(i=>{t.push(i.getZoneData())}),t}clearAllZones(e){e.forEach((t,i)=>{var n;const s=e.get(i);s&&((n=s.parent)==null||n.removeChild(s),s.destroy())}),e.clear()}updateZonesEditState(e){e.forEach(t=>{t.updateEditState()})}updateVirtualWallsEditState(e){e.forEach(t=>{t.updateEditingState()})}isZoneDataEqual(e,t){if(e.id!==t.id||e.points.length!==t.points.length)return!1;for(let i=0;i<e.points.length;i++){const s=e.points[i],n=t.points[i];if(Math.abs(s.x-n.x)>.1||Math.abs(s.y-n.y)>.1)return!1}return!0}getWallsData(e){return Array.from(e.values()).map(t=>t.getWallData())}clearAllWalls(e){for(const t of e.values())t.destroy();e.clear()}isWallDataEqual(e,t){if(e.id!==t.id||e.points.length!==t.points.length)return!1;for(let i=0;i<e.points.length;i++){const s=e.points[i],n=t.points[i];if(Math.abs(s.x-n.x)>.1||Math.abs(s.y-n.y)>.1)return!1}return!0}addNewSpot(e,t){const i=jr.create(this.appService,e);t.set(e.id,i),this.addToControlLayer("spot",i)}removeSpot(e,t){var s;const i=t.get(e);i&&((s=i.parent)==null||s.removeChild(i),i.destroy(),t.delete(e))}getSpotsData(e){const t=[];return e.forEach(i=>{t.push(i.getSpotData())}),t}clearAllSpotsInternal(e){e.forEach((t,i)=>{var n;const s=e.get(i);s&&((n=s.parent)==null||n.removeChild(s),s.destroy())}),e.clear()}updateSpotsEditState(e){e.forEach(t=>{t.updateEditState()})}isSpotDataEqual(e,t){if(e.id!==t.id)return!1;const i=e.point,s=t.point;return!(Math.abs(i.x-s.x)>.1||Math.abs(i.y-s.y)>.1)}drawWayPoints(e){w.log("[ControlsManager] drawWayPoints",e);const t=Array.from(this.wayPointMap.keys()),i=e.map(n=>n.id);t.filter(n=>!i.includes(n)).forEach(n=>{this.removeWayPoint(n,this.wayPointMap)}),e.forEach((n,o)=>{const a=o+1,h=this.wayPointMap.get(n.id);h?(this.isWayPointDataEqual(h.getWayPointData(),n)||h.updateWayPoint(n),h.updateOrder(a)):this.addNewWayPoint(n,a,this.wayPointMap)})}clearAllWayPoints(){w.log("[ControlsManager] clearAllWayPoints"),this.clearAllWayPointsInternal(this.wayPointMap)}getWayPoints(){return this.getWayPointsData(this.wayPointMap)}addNewWayPoint(e,t,i){var o,a;const s=this.appService,n=new sS({appService:s,wayPointData:e,order:t,events:{onUpdate:(o=s.events)==null?void 0:o.onUpdateWayPoint,onClick:(a=s.events)==null?void 0:a.onClickWayPoint}});i.set(e.id,n),this.addToControlLayer("wayPoint",n)}removeWayPoint(e,t){var s;const i=t.get(e);i&&((s=i.parent)==null||s.removeChild(i),i.destroy(),t.delete(e))}getWayPointsData(e){const t=[];return e.forEach(i=>{t.push(i.getWayPointData())}),t}clearAllWayPointsInternal(e){e.forEach((t,i)=>{var n;const s=e.get(i);s&&((n=s.parent)==null||n.removeChild(s),s.destroy())}),e.clear()}updateWayPointsEditState(e){e.forEach(t=>{t.onEditStateChange()})}isWayPointDataEqual(e,t){if(e.id!==t.id)return!1;const i=e.point,s=t.point;return!(Math.abs(i.x-s.x)>.1||Math.abs(i.y-s.y)>.1)}handleDividingRoomIdChange(e){if(e==null||e===-1){this.clearDivider();return}if(!this.getRoomGeometry(e)){this.clearDivider();return}this.createDefaultDivider(e)}getRoomGeometry(e){return this.appService.mapManager.getRoomById(e)}createDefaultDivider(e){const t=this.appService;this.clearDivider(),this.divider=new nS({appService:this.appService,roomId:e,events:{onUpdate:i=>{var s,n;(n=(s=t.events)==null?void 0:s.onUpdateDivider)==null||n.call(s,i)}}}),this.addToControlLayer("divider",this.divider)}clearDivider(){var e;this.divider&&((e=this.divider.parent)==null||e.removeChild(this.divider),this.divider.destroy(),this.divider=null)}getDividerEndPoints(){return this.divider?this.divider.getDividerEndPoints():null}getEffectiveDividerPoints(){return this.divider?this.divider.getEffectiveDividerPoints():null}handleUnitChange(){w.debug("[ControlsManager] Unit changed, refreshing all size texts");for(const e of this.zoneMaps.values())e.forEach(t=>{t.refreshDisplay()});this.virtualWallMap.forEach(e=>{e.refreshDisplay()}),this.spotMap.forEach(e=>{e.refreshDisplay()})}destroy(){for(const e of this.zoneMaps.keys())this.clearAllZonesByType(e);this.clearAllVirtualWalls(),this.clearAllSpots(),this.clearDivider(),this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[],this.controlContainers.forEach(e=>{e.removeFromParent(),e.destroy({children:!0})}),this.controlContainers.clear()}}class aS extends Xt{constructor(t,i){super(t);g(this,"objectData");g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);this.appService=t,this.objectData=i}async initializeSprite(){const t=this.appService.detectedObjectConfig,i=this.objectData.width||t.width,s=this.objectData.height||t.height;await this.loadTextureAndSetSize(this.objectData.src,{width:i,height:s}),this.anchor.set(t.anchor.x,t.anchor.y),this.position.set(this.objectData.x,this.objectData.y),this.visible=!0,this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=G(this.appService.runtime,"mapRotation",n=>{this.applyAntiRotation(n)}),t.interactive?this.setupClickHandler():this.eventMode="none"}applyAntiRotation(t){const i=-t*Math.PI/180;this.rotation=i}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new vt(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var t,i;(i=(t=this.appService.events)==null?void 0:t.onClickDetectedObject)==null||i.call(t,this.getObjectData())}getObjectData(){return{...this.objectData}}async updateObjectData(t){const i=this.objectData;this.objectData=t;const s=this.appService.detectedObjectConfig;if(i.src!==t.src){const n=t.width||s.width,o=t.height||s.height;await this.loadTextureAndSetSize(t.src,{width:n,height:o})}if(i.width!==t.width||i.height!==t.height){const n=t.width||s.width,o=t.height||s.height;this.setFixedSize(n,o)}this.position.set(t.x,t.y),s.interactive?this.clickHandler||this.setupClickHandler():this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null)}isSameData(t){return this.objectData.id===t.id&&this.objectData.src===t.src&&this.objectData.x===t.x&&this.objectData.y===t.y&&this.objectData.width===t.width&&this.objectData.height===t.height}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class hS{constructor(e){g(this,"detectedObjectMap",new Map);g(this,"unsubscribeShowDetectedObjects",null);this.appService=e,this.applyLayerVisibility(this.appService.runtime.showDetectedObjects),this.unsubscribeShowDetectedObjects=G(this.appService.runtime,"showDetectedObjects",t=>{this.applyLayerVisibility(t)})}async drawDetectedObjects(e){if(!e||e.length===0){this.clearAllDetectedObjects();return}const t=new Set(e.map(s=>s.id)),i=Array.from(this.detectedObjectMap.keys());for(const s of i)t.has(s)||this.removeDetectedObject(s);for(const s of e){const n=this.detectedObjectMap.get(s.id);n?n.isSameData(s)||await n.updateObjectData(s):await this.addNewDetectedObject(s)}}applyLayerVisibility(e){const t=this.appService.appContainer.getLayer(Ye);t&&(t.visible=e)}clearAllDetectedObjects(){const e=this.appService;this.detectedObjectMap.forEach(t=>{e.appContainer.removeFromLayer(Ye,t),t.destroy()}),this.detectedObjectMap.clear()}async addNewDetectedObject(e){const t=this.appService,i=new aS(this.appService,e);await i.initializeSprite(),this.detectedObjectMap.set(e.id,i),t.appContainer.addToLayer(Ye,i)}removeDetectedObject(e){const t=this.appService,i=this.detectedObjectMap.get(e);i&&(t.appContainer.removeFromLayer(Ye,i),i.destroy(),this.detectedObjectMap.delete(e))}destroy(){this.unsubscribeShowDetectedObjects&&(this.unsubscribeShowDetectedObjects(),this.unsubscribeShowDetectedObjects=null),this.clearAllDetectedObjects()}}var Re={},xc={},te={};Object.defineProperty(te,"__esModule",{value:!0});te.loop=te.conditional=te.parse=void 0;var lS=function r(e,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;if(Array.isArray(t))t.forEach(function(o){return r(e,o,i,s)});else if(typeof t=="function")t(e,i,s,r);else{var n=Object.keys(t)[0];Array.isArray(t[n])?(s[n]={},r(e,t[n],i,s[n])):s[n]=t[n](e,i,s,r)}return i};te.parse=lS;var cS=function(e,t){return function(i,s,n,o){t(i,s,n)&&o(i,e,s,n)}};te.conditional=cS;var dS=function(e,t){return function(i,s,n,o){for(var a=[],h=i.pos;t(i,s,n);){var l={};if(o(i,e,s,l),i.pos===h)break;h=i.pos,a.push(l)}return a}};te.loop=dS;var ut={};Object.defineProperty(ut,"__esModule",{value:!0});ut.readBits=ut.readArray=ut.readUnsigned=ut.readString=ut.peekBytes=ut.readBytes=ut.peekByte=ut.readByte=ut.buildStream=void 0;var uS=function(e){return{data:e,pos:0}};ut.buildStream=uS;var Sc=function(){return function(e){return e.data[e.pos++]}};ut.readByte=Sc;var pS=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(t){return t.data[t.pos+e]}};ut.peekByte=pS;var Os=function(e){return function(t){return t.data.subarray(t.pos,t.pos+=e)}};ut.readBytes=Os;var fS=function(e){return function(t){return t.data.subarray(t.pos,t.pos+e)}};ut.peekBytes=fS;var gS=function(e){return function(t){return Array.from(Os(e)(t)).map(function(i){return String.fromCharCode(i)}).join("")}};ut.readString=gS;var mS=function(e){return function(t){var i=Os(2)(t);return e?(i[1]<<8)+i[0]:(i[0]<<8)+i[1]}};ut.readUnsigned=mS;var yS=function(e,t){return function(i,s,n){for(var o=typeof t=="function"?t(i,s,n):t,a=Os(e),h=new Array(o),l=0;l<o;l++)h[l]=a(i);return h}};ut.readArray=yS;var xS=function(e,t,i){for(var s=0,n=0;n<i;n++)s+=e[t+n]&&Math.pow(2,i-n-1);return s},SS=function(e){return function(t){for(var i=Sc()(t),s=new Array(8),n=0;n<8;n++)s[7-n]=!!(i&1<<n);return Object.keys(e).reduce(function(o,a){var h=e[a];return h.length?o[a]=xS(s,h.index,h.length):o[a]=s[h.index],o},{})}};ut.readBits=SS;(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var e=te,t=ut,i={blocks:function(u){for(var p=0,f=[],y=u.data.length,m=0,x=(0,t.readByte)()(u);x!==p&&x;x=(0,t.readByte)()(u)){if(u.pos+x>=y){var S=y-u.pos;f.push((0,t.readBytes)(S)(u)),m+=S;break}f.push((0,t.readBytes)(x)(u)),m+=x}for(var v=new Uint8Array(m),b=0,P=0;P<f.length;P++)v.set(f[P],b),b+=f[P].length;return v}},s=(0,e.conditional)({gce:[{codes:(0,t.readBytes)(2)},{byteSize:(0,t.readByte)()},{extras:(0,t.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,t.readUnsigned)(!0)},{transparentColorIndex:(0,t.readByte)()},{terminator:(0,t.readByte)()}]},function(d){var u=(0,t.peekBytes)(2)(d);return u[0]===33&&u[1]===249}),n=(0,e.conditional)({image:[{code:(0,t.readByte)()},{descriptor:[{left:(0,t.readUnsigned)(!0)},{top:(0,t.readUnsigned)(!0)},{width:(0,t.readUnsigned)(!0)},{height:(0,t.readUnsigned)(!0)},{lct:(0,t.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,e.conditional)({lct:(0,t.readArray)(3,function(d,u,p){return Math.pow(2,p.descriptor.lct.size+1)})},function(d,u,p){return p.descriptor.lct.exists}),{data:[{minCodeSize:(0,t.readByte)()},i]}]},function(d){return(0,t.peekByte)()(d)===44}),o=(0,e.conditional)({text:[{codes:(0,t.readBytes)(2)},{blockSize:(0,t.readByte)()},{preData:function(u,p,f){return(0,t.readBytes)(f.text.blockSize)(u)}},i]},function(d){var u=(0,t.peekBytes)(2)(d);return u[0]===33&&u[1]===1}),a=(0,e.conditional)({application:[{codes:(0,t.readBytes)(2)},{blockSize:(0,t.readByte)()},{id:function(u,p,f){return(0,t.readString)(f.blockSize)(u)}},i]},function(d){var u=(0,t.peekBytes)(2)(d);return u[0]===33&&u[1]===255}),h=(0,e.conditional)({comment:[{codes:(0,t.readBytes)(2)},i]},function(d){var u=(0,t.peekBytes)(2)(d);return u[0]===33&&u[1]===254}),l=[{header:[{signature:(0,t.readString)(3)},{version:(0,t.readString)(3)}]},{lsd:[{width:(0,t.readUnsigned)(!0)},{height:(0,t.readUnsigned)(!0)},{gct:(0,t.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,t.readByte)()},{pixelAspectRatio:(0,t.readByte)()}]},(0,e.conditional)({gct:(0,t.readArray)(3,function(d,u){return Math.pow(2,u.lsd.gct.size+1)})},function(d,u){return u.lsd.gct.exists}),{frames:(0,e.loop)([s,a,h,n,o],function(d){var u=(0,t.peekByte)()(d);return u===33||u===44})}],c=l;r.default=c})(xc);var Ws={};Object.defineProperty(Ws,"__esModule",{value:!0});Ws.deinterlace=void 0;var vS=function(e,t){for(var i=new Array(e.length),s=e.length/t,n=function(u,p){var f=e.slice(p*t,(p+1)*t);i.splice.apply(i,[u*t,t].concat(f))},o=[0,4,2,1],a=[8,8,4,2],h=0,l=0;l<4;l++)for(var c=o[l];c<s;c+=a[l])n(c,h),h++;return i};Ws.deinterlace=vS;var Gs={};Object.defineProperty(Gs,"__esModule",{value:!0});Gs.lzw=void 0;var bS=function(e,t,i){var s=4096,n=-1,o=i,a,h,l,c,d,u,p,C,f,y,P,m,A,k,T,M,x=new Array(i),S=new Array(s),v=new Array(s),b=new Array(s+1);for(m=e,h=1<<m,d=h+1,a=h+2,p=n,c=m+1,l=(1<<c)-1,f=0;f<h;f++)S[f]=0,v[f]=f;var P,C,A,k,M,T;for(P=C=A=k=M=T=0,y=0;y<o;){if(k===0){if(C<c){P+=t[T]<<C,C+=8,T++;continue}if(f=P&l,P>>=c,C-=c,f>a||f==d)break;if(f==h){c=m+1,l=(1<<c)-1,a=h+2,p=n;continue}if(p==n){b[k++]=v[f],p=f,A=f;continue}for(u=f,f==a&&(b[k++]=A,f=p);f>h;)b[k++]=v[f],f=S[f];A=v[f]&255,b[k++]=A,a<s&&(S[a]=p,v[a]=A,a++,!(a&l)&&a<s&&(c++,l+=a)),p=u}k--,x[M++]=b[k],y++}for(y=M;y<o;y++)x[y]=0;return x};Gs.lzw=bS;Object.defineProperty(Re,"__esModule",{value:!0});var vc=Re.decompressFrames=Re.decompressFrame=bc=Re.parseGIF=void 0,wS=_S(xc),CS=te,AS=ut,PS=Ws,MS=Gs;function _S(r){return r&&r.__esModule?r:{default:r}}var TS=function(e){var t=new Uint8Array(e);return(0,CS.parse)((0,AS.buildStream)(t),wS.default)},bc=Re.parseGIF=TS,kS=function(e){for(var t=e.pixels.length,i=new Uint8ClampedArray(t*4),s=0;s<t;s++){var n=s*4,o=e.pixels[s],a=e.colorTable[o]||[0,0,0];i[n]=a[0],i[n+1]=a[1],i[n+2]=a[2],i[n+3]=o!==e.transparentIndex?255:0}return i},wc=function(e,t,i){if(!e.image){console.warn("gif frame does not have associated image.");return}var s=e.image,n=s.descriptor.width*s.descriptor.height,o=(0,MS.lzw)(s.data.minCodeSize,s.data.blocks,n);s.descriptor.lct.interlaced&&(o=(0,PS.deinterlace)(o,s.descriptor.width));var a={pixels:o,dims:{top:e.image.descriptor.top,left:e.image.descriptor.left,width:e.image.descriptor.width,height:e.image.descriptor.height}};return s.descriptor.lct&&s.descriptor.lct.exists?a.colorTable=s.lct:a.colorTable=t,e.gce&&(a.delay=(e.gce.delay||10)*10,a.disposalType=e.gce.extras.disposal,e.gce.extras.transparentColorGiven&&(a.transparentIndex=e.gce.transparentColorIndex)),i&&(a.patch=kS(a)),a};Re.decompressFrame=wc;var RS=function(e,t){return e.frames.filter(function(i){return i.image}).map(function(i){return wc(i,e.gct,t)})};vc=Re.decompressFrames=RS;class Us{constructor(e){if(!e||!e.length)throw new Error("Invalid frames");const[{texture:{width:t,height:i}}]=e;this.width=t,this.height=i,this.frames=e,this.textures=this.frames.map(s=>s.texture),this.totalFrames=this.frames.length,this.duration=this.frames[this.totalFrames-1].end}destroy(){for(const e of this.textures)e.destroy(!0);for(const e of this.frames)e.texture=null;this.frames.length=0,this.textures.length=0,Object.assign(this,{frames:null,textures:null,width:0,height:0,duration:0,totalFrames:0})}static from(e,t){if(!e||e.byteLength===0)throw new Error("Invalid buffer");const i=S=>{let v=null;for(const b of S.frames)v=b.gce??v,"image"in b&&!("gce"in b)&&(b.gce=v)},s=bc(e);i(s);const n=vc(s,!0),o=[],a=s.lsd.width,h=s.lsd.height,l=j.get().createCanvas(a,h),c=l.getContext("2d",{willReadFrequently:!0}),d=j.get().createCanvas(),u=d.getContext("2d");let p=0,f=null;const{fps:y=30,...m}=t??{},x=1e3/y;for(let S=0;S<n.length;S++){const{disposalType:v=2,delay:b=x,patch:P,dims:{width:C,height:A,left:k,top:M}}=n[S];d.width=C,d.height=A,u.clearRect(0,0,C,A);const T=u.createImageData(C,A);T.data.set(P),u.putImageData(T,0,0),v===3&&(f=c.getImageData(0,0,a,h)),c.drawImage(d,k,M);const _=c.getImageData(0,0,a,h);v===2?c.clearRect(0,0,a,h):v===3&&c.putImageData(f,0,0);const E=j.get().createCanvas(_.width,_.height);E.getContext("2d").putImageData(_,0,0),o.push({start:p,end:p+b,texture:new W({source:new fr({resource:E,...m})})}),p+=b}return l.width=l.height=0,d.width=d.height=0,new Us(o)}}const ES={extension:I.Asset,detection:{test:async()=>!0,add:async r=>[...r,"gif"],remove:async r=>r.filter(e=>e!=="gif")},loader:{name:"gifLoader",id:"gif",test:r=>Mt.extname(r)===".gif"||r.startsWith("data:image/gif"),load:async(r,e)=>{const i=await(await j.get().fetch(r)).arrayBuffer();return Us.from(i,e==null?void 0:e.data)},unload:async r=>{r.destroy()}}},Cc=class hr extends jt{constructor(...e){const t=e[0]instanceof Us?{source:e[0]}:e[0],{source:i,fps:s,loop:n,animationSpeed:o,autoPlay:a,autoUpdate:h,onComplete:l,onFrameChange:c,onLoop:d,...u}=Object.assign({},hr.defaultOptions,t);super({texture:W.EMPTY,...u}),this.animationSpeed=1,this.loop=!0,this.duration=0,this.autoPlay=!0,this.dirty=!1,this._currentFrame=0,this._autoUpdate=!1,this._isConnectedToTicker=!1,this._playing=!1,this._currentTime=0,this.onRender=()=>this._updateFrame(),this.texture=i.textures[0],this.duration=i.frames[i.frames.length-1].end,this._source=i,this._playing=!1,this._currentTime=0,this._isConnectedToTicker=!1,Object.assign(this,{fps:s,loop:n,animationSpeed:o,autoPlay:a,autoUpdate:h,onComplete:l,onFrameChange:c,onLoop:d}),this.currentFrame=0,a&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(yt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(yt.shared.add(this.update,this,Ie.HIGH),this._isConnectedToTicker=!0),!this.loop&&this.currentFrame===this._source.frames.length-1&&(this._currentTime=0))}get progress(){return this._currentTime/this.duration}get playing(){return this._playing}update(e){var o,a;if(!this._playing)return;const t=this.animationSpeed*e.deltaTime/yt.targetFPMS,i=this._currentTime+t,s=i%this.duration,n=this._source.frames.findIndex(h=>h.start<=s&&h.end>s);i>=this.duration?this.loop?(this._currentTime=s,this._updateFrameIndex(n),(o=this.onLoop)==null||o.call(this)):(this._currentTime=this.duration,this._updateFrameIndex(this.totalFrames-1),(a=this.onComplete)==null||a.call(this),this.stop()):(this._currentTime=s,this._updateFrameIndex(n))}_updateFrame(){this.dirty&&(this.texture=this._source.frames[this._currentFrame].texture,this.dirty=!1)}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,!this._autoUpdate&&this._isConnectedToTicker?(yt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(yt.shared.add(this.update,this),this._isConnectedToTicker=!0))}get currentFrame(){return this._currentFrame}set currentFrame(e){this._updateFrameIndex(e),this._currentTime=this._source.frames[e].start}get source(){return this._source}_updateFrameIndex(e){var t;if(e<0||e>=this.totalFrames)throw new Error(`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${e}`);this._currentFrame!==e&&(this._currentFrame=e,this.dirty=!0,(t=this.onFrameChange)==null||t.call(this,e))}get totalFrames(){return this._source.totalFrames}destroy(e=!1){this.stop(),super.destroy(),e&&this._source.destroy();const t=null;this._source=t,this.onComplete=t,this.onFrameChange=t,this.onLoop=t}clone(){const e=new hr({source:this._source,autoUpdate:this._autoUpdate,loop:this.loop,autoPlay:this.autoPlay,animationSpeed:this.animationSpeed,onComplete:this.onComplete,onFrameChange:this.onFrameChange,onLoop:this.onLoop});return e.dirty=!0,e}};Cc.defaultOptions={fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};let IS=Cc;$.add(ES);class Yr extends IS{constructor(t,i){super(i);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"sizeFixed",!0);g(this,"baselineScale",1);this.appService=t,this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ct(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,i){this.fixedWidth=t,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,t&&this.isFixedSizeSet?this.applySize():!t&&this.isFixedSizeSet&&this.applySize()}set width(t){if(this.isFixedSizeSet){w.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置宽度");return}this.setFixedSize(t,this.fixedHeight||t)}set height(t){if(this.isFixedSizeSet){w.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置高度");return}this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||this.texture.width===0||this.texture.height===0)return;const t=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const s=this.appService.currentScale;if(s===0)return;const n=t/s,o=i/s;super.scale.set(n,o)}else super.scale.set(t/this.baselineScale,i/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():t!==0&&super.scale.set(1/t))}static async createFromSrc(t,i,s){try{const n=await N.load(i),o=new Yr(t,{source:n});return s.sizeFixed!==void 0&&o.setSizeFixed(s.sizeFixed),o.setFixedSize(s.width,s.height),o}catch(n){throw w.error(`Failed to load GIF "${i}":`,n),n}}draw(t,i){const{x:s,y:n,rotation:o=0}=t;i&&!this.visible?this.visible=i():!i&&!this.visible&&(this.visible=!0),this.rotation=o,this.position.set(s,n)}destroy(t){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Ge extends Yr{constructor(t,i,s){super(t,{source:i});g(this,"elementData");g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);g(this,"userRotation",0);this.elementData=s}async initialize(){this.elementData.sizeFixed!==void 0&&this.setSizeFixed(this.elementData.sizeFixed),this.setFixedSize(this.elementData.width,this.elementData.height);const t=this.elementData.anchor||{x:.5,y:.5};this.anchor.set(t.x,t.y),this.position.set(this.elementData.x,this.elementData.y),this.elementData.rotation!==void 0&&(this.userRotation=this.elementData.rotation),this.elementData.opacity!==void 0&&(this.alpha=this.elementData.opacity),this.applyRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=G(this.appService.runtime,"mapRotation",i=>{this.applyRotation(i)}),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(t){const i=-t*Math.PI/180;this.rotation=this.userRotation+i}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new vt(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var t,i;(i=(t=this.appService.events)==null?void 0:t.onClickCustomElement)==null||i.call(t,this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const i=this.elementData;if(this.elementData=t,i.src!==t.src)throw new Error("GIF source change requires recreation of instance");i.sizeFixed!==t.sizeFixed&&t.sizeFixed!==void 0&&this.setSizeFixed(t.sizeFixed),(i.width!==t.width||i.height!==t.height)&&this.setFixedSize(t.width,t.height);const s=t.anchor||{x:.5,y:.5},n=i.anchor||{x:.5,y:.5};(s.x!==n.x||s.y!==n.y)&&this.anchor.set(s.x,s.y),this.position.set(t.x,t.y),t.rotation!==void 0&&(this.userRotation=t.rotation,this.applyRotation(this.appService.runtime.mapRotation)),t.opacity!==void 0&&(this.alpha=t.opacity),t.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")}isSameData(t){const i=this.elementData.anchor||{x:.5,y:.5},s=t.anchor||{x:.5,y:.5};return this.elementData.id===t.id&&this.elementData.type===t.type&&this.elementData.src===t.src&&this.elementData.x===t.x&&this.elementData.y===t.y&&this.elementData.width===t.width&&this.elementData.height===t.height&&this.elementData.rotation===t.rotation&&this.elementData.opacity===t.opacity&&this.elementData.interactive===t.interactive&&this.elementData.sizeFixed===t.sizeFixed&&i.x===s.x&&i.y===s.y}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class Tn extends Xt{constructor(t,i){super(t);g(this,"elementData");g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);g(this,"userRotation",0);this.appService=t,this.elementData=i}async initialize(){await this.loadTextureAndSetSize(this.elementData.src,{width:this.elementData.width,height:this.elementData.height,sizeFixed:this.elementData.sizeFixed});const t=this.elementData.anchor||{x:.5,y:.5};this.anchor.set(t.x,t.y),this.position.set(this.elementData.x,this.elementData.y),this.elementData.rotation!==void 0&&(this.userRotation=this.elementData.rotation),this.elementData.opacity!==void 0&&(this.alpha=this.elementData.opacity),this.applyRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=G(this.appService.runtime,"mapRotation",i=>{this.applyRotation(i)}),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(t){const i=-t*Math.PI/180;this.rotation=this.userRotation+i}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new vt(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var t,i;(i=(t=this.appService.events)==null?void 0:t.onClickCustomElement)==null||i.call(t,this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const i=this.elementData;this.elementData=t,i.src!==t.src?await this.loadTextureAndSetSize(t.src,{width:t.width,height:t.height,sizeFixed:t.sizeFixed}):(i.sizeFixed!==t.sizeFixed&&t.sizeFixed!==void 0&&this.setSizeFixed(t.sizeFixed),(i.width!==t.width||i.height!==t.height)&&this.setFixedSize(t.width,t.height));const s=t.anchor||{x:.5,y:.5},n=i.anchor||{x:.5,y:.5};(s.x!==n.x||s.y!==n.y)&&this.anchor.set(s.x,s.y),this.position.set(t.x,t.y),t.rotation!==void 0&&(this.userRotation=t.rotation,this.applyRotation(this.appService.runtime.mapRotation)),t.opacity!==void 0&&(this.alpha=t.opacity),t.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")}isSameData(t){const i=this.elementData.anchor||{x:.5,y:.5},s=t.anchor||{x:.5,y:.5};return this.elementData.id===t.id&&this.elementData.type===t.type&&this.elementData.src===t.src&&this.elementData.x===t.x&&this.elementData.y===t.y&&this.elementData.width===t.width&&this.elementData.height===t.height&&this.elementData.rotation===t.rotation&&this.elementData.opacity===t.opacity&&this.elementData.interactive===t.interactive&&this.elementData.sizeFixed===t.sizeFixed&&i.x===s.x&&i.y===s.y}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class BS extends Wg{constructor(t,i){super(i);g(this,"throttledUpdateScale");g(this,"fixedWidth",0);g(this,"fixedHeight",0);g(this,"isFixedSizeSet",!1);g(this,"userCenterX",0);g(this,"userCenterY",0);g(this,"sizeFixed",!0);this.appService=t,this.anchor.set(0,0),this.throttledUpdateScale=Ct(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,i){this.fixedWidth=t,this.fixedHeight=i,this.isFixedSizeSet=!0,this.applyFixedSize(),this.updatePositionFromCenter()}setCenterPosition(t,i){this.userCenterX=t,this.userCenterY=i,this.updatePositionFromCenter()}setSizeFixed(t){this.sizeFixed=t,this.isFixedSizeSet&&(this.applyFixedSize(),this.updatePositionFromCenter())}getIsFixedSizeSet(){return this.isFixedSizeSet}updatePositionFromCenter(){if(!this.isFixedSizeSet){this.position.set(this.userCenterX,this.userCenterY);return}const i=this.appService.currentScale;let s,n;this.sizeFixed?(s=this.fixedWidth/2/i,n=this.fixedHeight/2/i):(s=this.fixedWidth/2,n=this.fixedHeight/2),this.position.set(this.userCenterX-s,this.userCenterY-n)}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateScale)}applyFixedSize(){if(!this.isFixedSizeSet)return;const i=this.appService.currentScale;if(i!==0){if(this.sizeFixed){const s=1/i;this.scale.set(s)}else this.scale.set(1);this.element&&(this.element.style.width=`${this.fixedWidth}px`,this.element.style.height=`${this.fixedHeight}px`)}}updateScale(t){this.isFixedSizeSet&&t!==0&&(this.applyFixedSize(),this.updatePositionFromCenter())}updateTransform(t){return super.updateTransform(t)}destroy(t){this.appService.emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Di extends BS{constructor(t,i){const s=document.createElement("div");Di.setupDefaultStyles(s,i),s.innerHTML=i.htmlContent;super(t,{element:s});g(this,"elementData");g(this,"domClickHandler",null);g(this,"resizeObserver",null);g(this,"debugMarker",null);g(this,"unsubscribeMapRotation",null);g(this,"userRotation",0);this.elementData=i}async initialize(){this.alpha=0,this.elementData.width&&this.elementData.height?(this.setFixedSize(this.elementData.width,this.elementData.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),this.waitForElementInsertion()):(this.position.set(this.elementData.x,this.elementData.y),this.setupAutoSize()),this.elementData.rotation!==void 0&&(this.userRotation=this.elementData.rotation),this.applyRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=G(this.appService.runtime,"mapRotation",t=>{this.applyRotation(t)}),this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(t){const i=-t*Math.PI/180;this.rotation=this.userRotation+i}setupAutoSize(){this.element&&(this.element.style.width="auto",this.element.style.height="auto",this.waitForElementDimensions())}waitForElementInsertion(){if(!this.element)return;const t=()=>{this.element&&(this.element.isConnected?this.showElement():requestAnimationFrame(t))};requestAnimationFrame(t)}waitForElementDimensions(){this.element&&(typeof ResizeObserver<"u"?(this.resizeObserver=new ResizeObserver(t=>{var s;const i=t[0];i&&i.contentRect.width>0&&i.contentRect.height>0&&(this.setFixedSize(i.contentRect.width,i.contentRect.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),this.alpha===0&&this.showElement(),(s=this.resizeObserver)==null||s.disconnect(),this.resizeObserver=null)}),this.resizeObserver.observe(this.element)):this.pollForElementDimensions())}pollForElementDimensions(){if(!this.element)return;const t=()=>{if(!this.element)return;if(!this.element.isConnected){requestAnimationFrame(t);return}const i=this.element.getBoundingClientRect();i.width>0&&i.height>0?(this.setFixedSize(i.width,i.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),this.alpha===0&&this.showElement()):requestAnimationFrame(t)};requestAnimationFrame(t)}showElement(){this.alpha=this.elementData.opacity??1,this.element.style.pointerEvents=this.elementData.interactive?"auto":"none",this.interactive=this.elementData.interactive??!1,this.elementData.interactive&&this.element&&(this.element.style.setProperty("-webkit-tap-highlight-color","transparent"),this.element.style.setProperty("-webkit-touch-callout","none")),this.appService.getApp().renderOnceNextFrame()}setupClickHandler(){this.element&&(this.domClickHandler=t=>{t.preventDefault(),t.stopPropagation(),this.handleClick()},this.element.addEventListener("click",this.domClickHandler))}handleClick(){var t,i;(i=(t=this.appService.events)==null?void 0:t.onClickCustomElement)==null||i.call(t,this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const i=this.elementData;this.elementData=t,i.htmlContent!==t.htmlContent&&this.element&&(this.element.innerHTML=t.htmlContent,(!t.width||!t.height)&&this.waitForElementDimensions()),(i.width!==t.width||i.height!==t.height)&&(t.width&&t.height?(this.setFixedSize(t.width,t.height),this.element&&(this.element.style.width=`${t.width}px`,this.element.style.height=`${t.height}px`)):this.setupAutoSize()),t.width&&t.height?this.setCenterPosition(t.x,t.y):this.getIsFixedSizeSet()?this.setCenterPosition(t.x,t.y):this.position.set(t.x,t.y),i.sizeFixed!==t.sizeFixed&&t.sizeFixed!==void 0&&this.setSizeFixed(t.sizeFixed),this.userRotation=t.rotation??0,this.applyRotation(this.appService.runtime.mapRotation),this.alpha=t.opacity??1,t.interactive?this.domClickHandler||this.setupClickHandler():(this.eventMode="none",this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null))}isSameData(t){return this.elementData.id===t.id&&this.elementData.type===t.type&&this.elementData.htmlContent===t.htmlContent&&this.elementData.x===t.x&&this.elementData.y===t.y&&this.elementData.width===t.width&&this.elementData.height===t.height&&this.elementData.rotation===t.rotation&&this.elementData.opacity===t.opacity&&this.elementData.interactive===t.interactive&&this.elementData.sizeFixed===t.sizeFixed}static setupDefaultStyles(t,i){const s={position:"relative",boxSizing:"border-box",webkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",background:"transparent",userSelect:"auto",webkitUserSelect:"auto"};i.width&&i.height?(s.width=`${i.width}px`,s.height=`${i.height}px`,s.overflow="hidden"):(s.width=i.width?`${i.width}px`:"auto",s.height=i.height?`${i.height}px`:"auto",s.overflow="visible"),Object.assign(t.style,s),t.style.setProperty("-webkit-tap-highlight-color","transparent"),t.style.setProperty("-webkit-touch-callout","none")}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null),this.debugMarker&&(this.debugMarker.destroy(),this.debugMarker=null),super.destroy()}}class DS{constructor(e){g(this,"customElementsMap",new Map);g(this,"gifTicker",null);g(this,"gifElements",new Set);this.appService=e}async drawCustomElements(e){if(!e||e.length===0){this.clearAllCustomElements();return}const t=new Set(e.map(n=>n.id)),i=Array.from(this.customElementsMap.keys());for(const n of i)t.has(n)||this.removeCustomElement(n);const s=e.map(async n=>{const o=this.customElementsMap.get(n.id);o?this.isSameData(o,n)||(n.type==="gif"&&o.getElementData().src!==n.src?(this.removeCustomElement(n.id),await this.addNewCustomElement(n)):await this.updateElementData(o,n)):await this.addNewCustomElement(n)});await Promise.all(s),this.updateGifTicker()}clearAllCustomElements(){const e=this.appService;this.customElementsMap.forEach(t=>{t instanceof Ge?e.appContainer.removeFromLayer(Bi,t):e.appContainer.removeFromLayer(Ii,t),t.destroy()}),this.customElementsMap.clear(),this.gifElements.clear(),this.stopGifTicker()}async addNewCustomElement(e){const t=this.appService;let i;switch(e.type){case"image":i=new Tn(this.appService,e);break;case"gif":{const s=await N.load(e.src);i=new Ge(this.appService,s,e);break}case"html":i=new Di(this.appService,e);break;default:throw new Error(`Unsupported custom element type: ${e.type}`)}await i.initialize(),this.customElementsMap.set(e.id,i),i instanceof Ge?(t.appContainer.addToLayer(Bi,i),this.gifElements.add(i)):t.appContainer.addToLayer(Ii,i)}removeCustomElement(e){const t=this.appService,i=this.customElementsMap.get(e);i&&(i instanceof Ge?(this.gifElements.delete(i),t.appContainer.removeFromLayer(Bi,i)):t.appContainer.removeFromLayer(Ii,i),i.destroy(),this.customElementsMap.delete(e))}isSameData(e,t){return e.getElementData().type!==t.type?!1:t.type==="image"&&e instanceof Tn||t.type==="gif"&&e instanceof Ge||t.type==="html"&&e instanceof Di?e.isSameData(t):!1}async updateElementData(e,t){if(t.type==="image"&&e instanceof Tn)await e.updateElementData(t);else if(t.type==="gif"&&e instanceof Ge)await e.updateElementData(t);else if(t.type==="html"&&e instanceof Di)await e.updateElementData(t);else throw new Error("Element type mismatch during update")}updateGifTicker(){this.gifElements.size>0?this.startGifTicker():this.stopGifTicker()}startGifTicker(){var e;(e=this.gifTicker)!=null&&e.started||(this.gifTicker?this.gifTicker.maxFPS=1:(this.gifTicker=new yt,this.gifTicker.maxFPS=1,this.gifTicker.add(()=>{this.renderGifContainer()})),this.gifTicker.start())}stopGifTicker(){var e;(e=this.gifTicker)!=null&&e.started&&(w.log("⏸️ [GifTicker] 停止 GIF 专用渲染"),this.gifTicker.stop())}renderGifContainer(){const e=this.appService;if(this.gifElements.size===0)return;const t=e.getApp();t.renderer.render(t.stage)}destroy(){this.stopGifTicker(),this.gifTicker&&(this.gifTicker.destroy(),this.gifTicker=null),this.clearAllCustomElements()}}class FS extends L{constructor(t,i){super();g(this,"roomId");g(this,"roomIndex");g(this,"appService");g(this,"nameText");g(this,"iconSprite",null);g(this,"iconWrapper",null);g(this,"iconBg",null);this.appService=t,this.roomId=i.id,this.roomIndex=i.index;const{nameLabel:s,type:n}=t.roomConfig,{showRoomType:o}=t.runtime,a=i.colorIndex??i.index,h=this.getRoomNameColor(a),l=new ce({fontSize:s.fontSize,fontFamily:s.fontFamily,fontWeight:s.fontWeight,fill:h,align:"center"}),c=i.name||"Unknown";this.nameText=new Bs({text:c,style:l}),this.nameText.anchor.set(.5),o&&i.type!=null&&(n!=null&&n.assets)&&n.assets[i.type]&&this.createIcon(i.type,h),this.addChild(this.nameText),this.layout()}createIcon(t,i){const{type:s}=this.appService.roomConfig,n=s.iconSize||14;this.iconWrapper||(this.iconWrapper=new L,this.addChild(this.iconWrapper)),s.container.visible?(this.iconBg||(this.iconBg=new H,this.iconWrapper.addChild(this.iconBg)),this.drawIconBg(i)):this.iconBg&&(this.iconBg.destroy(),this.iconBg=null),this.iconSprite||(this.iconSprite=new Xt(this.appService),this.iconSprite.anchor.set(.5),this.iconWrapper.addChild(this.iconSprite)),this.iconSprite.visible=!0,this.iconSprite.tint=s.container.visible?"#ffffff":i,this.iconSprite.setFixedSize(n,n),this.iconSprite.loadTextureAndSetSize(s.assets[t],{width:n,height:n,sizeFixed:!1}).then(()=>{this.iconSprite&&(this.iconSprite.visible=this.appService.runtime.showRoomType,this.layout())}),s.container&&this.iconSprite.position.set(0,0)}drawIconBg(t){const{type:i}=this.appService.roomConfig;if(!this.iconBg||!i.container.visible)return;const{size:s,borderRadius:n}=i.container;this.iconBg.clear().roundRect(-s/2,-s/2,s,s,n).fill(t)}layout(){if(!this.iconWrapper||!this.iconWrapper.visible){this.nameText.position.set(0,0);return}if(!(this.iconSprite&&this.iconSprite.visible||this.iconBg&&this.iconBg.visible)){this.nameText.position.set(0,0);return}const{gap:i=4,position:s="left"}=this.appService.roomConfig.type,n=this.nameText.width,o=this.iconWrapper.width,h=-(o+i+n)/2;s==="left"?(this.iconWrapper.x=h+o/2,this.nameText.x=h+o+i+n/2):(this.nameText.x=h+n/2,this.iconWrapper.x=h+n+i+o/2),this.iconWrapper.y=0,this.nameText.y=0}updateName(t){this.nameText.text=t,this.layout()}refreshColor(t){const{type:i}=this.appService.roomConfig,s=this.appService.getRoomData(this.roomId),n=(s==null?void 0:s.colorIndex)??this.roomIndex,o=this.getRoomNameColor(n,t);this.nameText.style.fill=o,this.iconBg&&this.drawIconBg(o),this.iconSprite&&(this.iconSprite.tint=i.container.visible?"#ffffff":o)}getRoomNameColor(t,i){const{colors:s}=this.appService.roomConfig,{enableRoomSelection:n,selectRoomIds:o}=this.appService.runtime;if(i)return i;if(n)return!o.includes(this.roomId)&&s.nameInactive?s.nameInactive[t%s.nameInactive.length]:s.name[t%s.name.length];const a=s.nameNormal||s.name;return a[t%a.length]}async updateRoomType(t){const{type:i}=this.appService.roomConfig;if(!this.appService.runtime.showRoomType||t==null||!(i!=null&&i.assets)||!i.assets[t])this.iconWrapper&&(this.iconWrapper.visible=!1);else{const n=this.appService.getRoomData(this.roomId),o=(n==null?void 0:n.colorIndex)??this.roomIndex,a=this.getRoomNameColor(o);this.createIcon(t,a),this.iconWrapper&&(this.iconWrapper.visible=!0)}this.layout()}updateRoomTypeVisibility(t){if(this.iconWrapper)this.iconWrapper.visible=t,this.layout();else if(t){const i=this.appService.getRoomData(this.roomId);i&&this.updateRoomType(i.type??null)}}destroy(t){this.iconBg&&(this.iconBg.destroy(),this.iconBg=null),this.iconSprite&&(this.iconSprite.destroy(),this.iconSprite=null),this.iconWrapper&&(this.iconWrapper.destroy(),this.iconWrapper=null),super.destroy(t)}}class zS extends L{constructor(t,i){super();g(this,"background");g(this,"foldedIndicator");g(this,"propertyIcons",new Map);g(this,"orderContainer");g(this,"orderBackground");g(this,"orderText");g(this,"isFolded",!1);g(this,"roomId");g(this,"roomIndex");g(this,"isDestroyed",!1);this.appService=t;const s=this.appService.roomConfig;this.roomId=i.id,this.roomIndex=i.index,this.background=new H,this.foldedIndicator=new H,this.foldedIndicator.visible=!1;const{property:n}=s,o=i.colorIndex??i.index,a=this.getIconColor(o);this.initializePropertyIcons(n.displayOrders,a);const h=n.cleanOrder.color==="auto"?s.colors.active[o%s.colors.active.length]:n.cleanOrder.color;this.orderContainer=new L,this.orderBackground=new H,this.orderText=new Bs({text:"",style:new ce({fontSize:n.cleanOrder.fontSize,fontFamily:n.cleanOrder.fontFamily,fontWeight:n.cleanOrder.fontWeight,fill:h,align:"center",trim:!0})}),this.orderText.anchor.set(.5,.5),this.orderContainer.addChild(this.orderBackground),this.orderContainer.addChild(this.orderText),this.addChild(this.background),this.addChild(this.foldedIndicator),this.propertyIcons.forEach(({sprite:l})=>{this.addChild(l)}),this.addChild(this.orderContainer),this.visible=this.appService.runtimeSnapshot.showRoomProperty}initializePropertyIcons(t,i){const s=["cleanMode","suction","cistern","cleanTimes"];t.forEach(n=>{const o=s.includes(n),a=new Xt(this.appService);a.tint=i,a.anchor.set(0,0),this.propertyIcons.set(n,{fieldName:n,sprite:a,isBuiltin:o})})}async updateProperty(t){this.isDestroyed||this.destroyed||(await this.updateIcons(t),!(this.isDestroyed||this.destroyed)&&this.updateBackground())}getFieldValue(t,i){if(["cleanMode","suction","cistern","cleanTimes"].includes(i))return t[i]??null;if(t.customData&&i in t.customData){const n=t.customData[i];return typeof n=="number"?n:null}return null}getAssetAlias(t,i){const s={cleanMode:n=>`cleanMode_${n}`,suction:n=>`fan_${n}`,cistern:n=>`water_${n}`,cleanTimes:n=>`cleanTimes${n}`};return t in s?s[t](i):`custom_${t}_${i}`}shouldShowField(t,i,s){const{showRoomProperty:n}=this.appService.runtimeSnapshot;return!(s===null||!n||i==="cleanTimes"&&s<=0)}getDisplayElements(t){const{displayOrders:i}=this.appService.roomConfig.property,{showRoomOrder:s}=this.appService.runtimeSnapshot,n=t.order||0,o=s&&n>0,a=[];return o&&a.push({element:this.orderContainer,show:!0,isOrder:!0,fieldName:"order"}),i.forEach(h=>{const l=this.propertyIcons.get(h);if(!l||!l.sprite)return;const c=this.getFieldValue(t,h);this.shouldShowField(t,h,c)&&c!==null&&a.push({element:l.sprite,show:!0,isOrder:!1,fieldName:h,value:c})}),{elementsToShow:a,orderValue:n}}async updateIcons(t){if(this.isDestroyed||this.destroyed||this.isFolded)return;const{iconWidth:i,iconHeight:s,container:n,cleanOrder:o,iconGap:a}=this.appService.roomConfig.property,{paddingHorizontal:h,paddingVertical:l}=n,{elementsToShow:c,orderValue:d}=this.getDisplayElements(t);this.orderContainer.visible=!1,this.propertyIcons.forEach(({sprite:f})=>{f.visible=!1});const u=[];if(c.forEach(f=>{if(f.isOrder){this.orderContainer.visible=!0,this.orderText.text=d.toString();const y=t.colorIndex??this.roomIndex,m=this.getIconColor(y);this.orderBackground.clear(),this.orderBackground.setFillStyle({color:m}),this.orderBackground.circle(i/2,s/2,i/2).fill();const x=this.resolveOrderTextColor(y);this.orderText.style.fill=x,this.orderText.position.set(i/2,s/2)}else{const y=this.propertyIcons.get(f.fieldName);if(y&&y.sprite){y.sprite.visible=!0;const m=this.getAssetAlias(f.fieldName,f.value);u.push(y.sprite.loadTextureAndSetSize(m,{width:i,height:s,sizeFixed:!1}))}}}),await Promise.all(u),this.isDestroyed||this.destroyed)return;let p=h;c.forEach((f,y)=>{const{element:m,isOrder:x}=f;!m||!m.position||(m.position.set(p,l),p+=i,y<c.length-1&&(x?p+=o.gapRight:p+=a))})}updateBackground(){if(this.isDestroyed||this.destroyed)return;const t=this.appService.roomConfig,{container:i,foldable:s}=t.property,{borderRadius:n,tailHeight:o,tailWidth:a,backgroundColor:h}=i,l=this.calculateContentWidth(),c=this.calculateContentHeight(),d=Math.min(n,l/2,c/2),u=d*.8,p=Math.max(l-u*2,a*.5),f=Math.min(a,l/2,p);if(this.background.clear(),this.background.setFillStyle({color:h}),s){const y=(l-f)/2,m=c+o;this.background.moveTo(d,0),this.background.lineTo(l-d,0),this.background.arcTo(l,0,l,d,d),this.background.lineTo(l,c-d),this.background.arcTo(l,c,l-d,c,d),this.background.lineTo(y+f,c),this.background.lineTo(y+f/2,m),this.background.lineTo(y,c),this.background.lineTo(d,c),this.background.arcTo(0,c,0,c-d,d),this.background.lineTo(0,d),this.background.arcTo(0,0,d,0,d),this.background.closePath()}else this.background.roundRect(0,0,l,c,d);this.background.fill()}calculateContentWidth(){const{iconWidth:t,container:i,cleanOrder:s,iconGap:n}=this.appService.roomConfig.property,{paddingHorizontal:o}=i,a=this.appService.getRoomData(this.roomId);if(!a)return o*2;const{elementsToShow:h}=this.getDisplayElements(a);let l=o;return h.forEach((c,d)=>{const{isOrder:u}=c;l+=t,d<h.length-1&&(u?l+=s.gapRight:l+=n)}),l+=o,l}calculateContentHeight(){const t=this.appService.roomConfig,{iconHeight:i,container:s}=t.property;return s.paddingVertical+i+s.paddingVertical}getTotalHeight(){const{foldable:t,container:i}=this.appService.roomConfig.property,{tailHeight:s}=i;return this.isFolded?s:this.calculateContentHeight()+(t?s:0)}getTotalWidth(){if(this.isFolded){const{tailWidth:i}=this.appService.roomConfig.property.container,s=this.calculateContentWidth();return Math.min(i,s/2)}return this.calculateContentWidth()}async setFolded(t){const{foldable:i}=this.appService.roomConfig.property;if(i)if(this.isFolded=t,t)this.background.visible=!1,this.orderContainer.visible=!1,this.propertyIcons.forEach(({sprite:s})=>{s.visible=!1}),this.foldedIndicator.visible=!0,this.updateFoldedIndicator();else{this.background.visible=!0,this.foldedIndicator.visible=!1,this.foldedIndicator.position.set(0,0),this.updateBackground();const s=this.appService.getRoomData(this.roomId);s&&await this.updateIcons(s)}}isFoldedState(){const{foldable:t}=this.appService.roomConfig.property;return t?this.isFolded:!1}updateFoldedIndicator(){const t=this.appService.roomConfig,{tailHeight:i,tailWidth:s,backgroundColor:n}=t.property.container,o=this.calculateContentWidth(),a=Math.min(s,o/2);this.foldedIndicator.clear(),this.foldedIndicator.setFillStyle({color:n}),this.foldedIndicator.poly([0,i,a,i,a/2,0]).fill(),this.foldedIndicator.position.set(0,0)}resolveOrderTextColor(t){const{property:i,colors:s}=this.appService.roomConfig,{enableRoomSelection:n}=this.appService.runtime;if(i.cleanOrder.color==="auto"){const o=n?s.active:s.normal||s.active;return o[t%o.length]}return i.cleanOrder.color}getIconColor(t){const{colors:i}=this.appService.roomConfig,{propertyTheme:s,propertyThemeInactive:n,propertyThemeNormal:o}=i,{enableRoomSelection:a,selectRoomIds:h}=this.appService.runtime;if(a)return!h.includes(this.roomId)&&n?n[t%n.length]:s[t%s.length];const l=o||s;return l[t%l.length]}refreshColor(){const t=this.appService.getRoomData(this.roomId),i=(t==null?void 0:t.colorIndex)??this.roomIndex,s=this.getIconColor(i);if(this.propertyIcons.forEach(({sprite:n})=>{n.tint=s}),this.orderBackground&&this.orderBackground.visible){const{property:n}=this.appService.roomConfig,o=n.iconWidth,a=n.iconHeight;this.orderBackground.clear(),this.orderBackground.setFillStyle({color:s}),this.orderBackground.circle(o/2,a/2,o/2).fill();const h=this.resolveOrderTextColor(i);this.orderText.style.fill=h}}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.propertyIcons.forEach(({sprite:t})=>{t.destroy()}),this.propertyIcons.clear(),super.destroy({children:!0}))}}class LS extends L{constructor(t,i){super();g(this,"background");g(this,"checkmarkIcon");g(this,"bubble");g(this,"roomIndex");g(this,"roomId");this.appService=t;const s=this.appService.roomConfig;this.roomId=i.id,this.roomIndex=i.index,this.background=new H,this.bubble=new H;const{colors:{selectionIndicatorIcon:n}}=s;this.checkmarkIcon=new Xt(this.appService);const o=i.colorIndex??i.index;this.checkmarkIcon.tint=n[o%n.length],this.checkmarkIcon.anchor.set(0,0),this.addChild(this.background),this.addChild(this.bubble),this.addChild(this.checkmarkIcon)}async updateIndicator(t){const{roomSelectionMode:i,enableRoomSelection:s,selectRoomIds:n}=this.appService.runtimeSnapshot;if(!s||i!=="checkmark"){this.visible=!1;return}const o=n.includes(t.id);await this.showCheckmarkMode(o),this.updateBackground()}async showCheckmarkMode(t){const{selectionIndicator:i}=this.appService.roomConfig,{iconWidth:s,iconHeight:n}=i;if(t){this.visible=!0,this.checkmarkIcon.visible=!0,await this.checkmarkIcon.loadTextureAndSetSize("checkmark",{width:s,height:n,sizeFixed:!1});const o=i.containerWidth/2,a=i.containerHeight/2;this.checkmarkIcon.position.set(o-s/2,a-n/2)}else this.visible=!1}updateBackground(){const{selectionIndicator:t,colors:i}=this.appService.roomConfig,{containerWidth:s,containerHeight:n,strokeWidth:o,strokeColor:a,borderRadius:h,tailHeight:l,tailWidth:c}=t,d=this.appService.getRoomData(this.roomId),u=(d==null?void 0:d.colorIndex)??this.roomIndex,p=i.selectionIndicatorBackground[u%i.selectionIndicatorBackground.length],f=a==="auto"?p:a;if(this.checkmarkIcon.tint=i.selectionIndicatorIcon[u%i.selectionIndicatorIcon.length],this.background.clear(),this.bubble.clear(),this.background.setFillStyle({color:p}).roundRect(0,0,s,n,h).fill().setStrokeStyle({color:f,width:o,alignment:0}).stroke(),l>0&&c>0){const y=(s-c)/2;this.bubble.setFillStyle({color:f});const m=n+o;this.bubble.poly([y,m-1,y+c,m-1,y+c/2,m+l]).fill()}}getTotalHeight(){const{selectionIndicator:t}=this.appService.roomConfig,{containerHeight:i,tailHeight:s,strokeWidth:n}=t;return i+n+(s>0?s:0)}getTotalWidth(){const{selectionIndicator:t}=this.appService.roomConfig;return t.containerWidth}async refreshColor(){const t=this.appService.getRoomData(this.roomId);t&&await this.updateIndicator(t)}destroy(){var t;(t=this.checkmarkIcon)==null||t.destroy(),super.destroy({children:!0})}}class OS extends L{constructor(t,i){super();g(this,"roomId");g(this,"roomName");g(this,"roomProperty",null);g(this,"roomSelectionIndicator",null);g(this,"clickHandler",null);g(this,"unsubscribeMapRotation",null);g(this,"targetElasticScale",1);g(this,"currentElasticScale",1);g(this,"isAnimatingScale",!1);g(this,"scaleAnimationBound",null);g(this,"updateScaleBound",null);this.appService=t,this.enableRenderGroup(),this.roomId=i.id,this.initializeElasticScale(t.currentScale),this.updateScaleBound=s=>this.updateScale(s),this.appService.emitter.on("antiScale",this.updateScaleBound),this.updateScale(this.appService.currentScale),i.centerPoint&&this.position.set(i.centerPoint.x,i.centerPoint.y),this.roomName=new FS(this.appService,i),this.roomName.visible=this.appService.runtimeSnapshot.showRoomName,this.applyAntiRotation(this.appService.runtime.mapRotation),this.unsubscribeMapRotation=G(this.appService.runtime,"mapRotation",s=>{this.applyAntiRotation(s)}),this.clickHandler=new vt(this,{onClick:()=>{var s,n;(n=(s=this.appService.events)==null?void 0:s.onClickRoomProperties)==null||n.call(s,i)}})}async initialize(t){await this.createRoomProperty(t),await this.createRoomSelectionIndicator(t),this.updateLayout()}applyAntiRotation(t){const i=-t*Math.PI/180;this.rotation=i}initializeElasticScale(t){const{enableElasticScale:i,elasticMinScale:s,elasticMaxScale:n}=this.appService.roomConfig;if(!i)return;const o=1,a=5;let h;t<=o?h=s:t>=a?h=n:h=1,this.targetElasticScale=h,this.currentElasticScale=h}updateScale(t){const{enableElasticScale:i,elasticMinScale:s,elasticMaxScale:n}=this.appService.roomConfig;if(!i){t!==0&&this.scale.set(1/t);return}if(t===0)return;const o=1,a=5;let h;t<=o?h=s:t>=a?h=n:h=1;const c=1/t*h;Math.abs(this.targetElasticScale-h)>.01?(this.targetElasticScale=h,this.startScaleAnimation()):this.scale.set(c)}startScaleAnimation(){this.scaleAnimationBound||(this.scaleAnimationBound=this.animateScale.bind(this)),this.isAnimatingScale||(this.isAnimatingScale=!0,this.appService.getApp().ticker.add(this.scaleAnimationBound))}animateScale(){this.currentElasticScale+=(this.targetElasticScale-this.currentElasticScale)*.3;const n=1/this.appService.currentScale*this.currentElasticScale;this.scale.set(n),Math.abs(this.currentElasticScale-this.targetElasticScale)<.001&&(this.currentElasticScale=this.targetElasticScale,this.isAnimatingScale=!1,this.scaleAnimationBound&&this.appService.getApp().ticker.remove(this.scaleAnimationBound))}shouldShowRoomProperty(){const{showRoomOrder:t,showRoomProperty:i,selectRoomIds:s,enableRoomSelection:n,roomSelectionMode:o}=this.appService.runtimeSnapshot,a=this.appService.getRoomData(this.roomId);if(!a||n&&o==="checkmark"&&s.includes(this.roomId))return!1;const h=t&&(a.order||0)>0;let l=!1;if(i){const{displayOrders:c}=this.appService.roomConfig.property;l=c.some(d=>!!(d==="suction"&&a.suction!=null||d==="cistern"&&a.cistern!=null||d==="cleanMode"&&a.cleanMode!=null||d==="cleanTimes"&&a.cleanTimes>0||a.customData&&d in a.customData&&typeof a.customData[d]=="number"&&a.customData[d]!=null))}return h||l}shouldShowRoomSelectionIndicator(){const{enableRoomSelection:t,roomSelectionMode:i}=this.appService.runtimeSnapshot;return t&&i==="checkmark"}async updateRoomPropertyVisibility(){if(!this.roomProperty)return;if(!this.shouldShowRoomProperty())this.roomProperty.visible=!1;else{this.roomProperty.visible=!0;const i=this.appService.runtimeSnapshot.roomPropertyFoldIds.includes(this.roomId);await this.roomProperty.setFolded(i);const s=this.appService.getRoomData(this.roomId);s&&await this.roomProperty.updateProperty(s)}this.updateLayout()}async updateRoomSelectionIndicatorVisibility(){if(!this.roomSelectionIndicator)return;if(this.shouldShowRoomSelectionIndicator()){const i=this.appService.getRoomData(this.roomId);i&&await this.roomSelectionIndicator.updateIndicator(i)}else this.roomSelectionIndicator.visible=!1;this.updateLayout()}async createRoomProperty(t){this.roomProperty&&(this.removeChild(this.roomProperty),this.roomProperty.destroy()),this.roomProperty=new zS(this.appService,t),await this.roomProperty.updateProperty(t),this.addChild(this.roomProperty),this.addChild(this.roomName),await this.updateRoomPropertyVisibility(),this.updateLayout()}async createRoomSelectionIndicator(t){this.roomSelectionIndicator&&(this.removeChild(this.roomSelectionIndicator),this.roomSelectionIndicator.destroy()),this.roomSelectionIndicator=new LS(this.appService,t),await this.updateRoomSelectionIndicatorVisibility(),this.addChild(this.roomSelectionIndicator)}updateLayout(){var l,c,d,u,p,f;if(this.destroyed)return;const{property:{offsetY:t,offsetX:i},selectionIndicator:{offsetY:s,offsetX:n}}=this.appService.roomConfig,o=((l=this.roomProperty)==null?void 0:l.visible)||!1,a=((c=this.roomName)==null?void 0:c.visible)||!1,h=((d=this.roomSelectionIndicator)==null?void 0:d.visible)||!1;if(o&&this.roomProperty){const y=this.roomProperty.getTotalHeight(),m=this.roomProperty.getTotalWidth();if(this.roomProperty.isFoldedState()){const S=-m/2+i,v=-y/2-t;this.roomProperty.position.set(S,v)}else a&&((u=this.roomName)!=null&&u.position)?(this.roomProperty.position.set(-m/2+i,-t-y),this.roomName.position.set(0,0)):this.roomProperty.position.set(-m/2+i,-y/2-t)}if(h&&this.roomSelectionIndicator){const y=this.roomSelectionIndicator.getTotalHeight(),m=this.roomSelectionIndicator.getTotalWidth();a&&((p=this.roomName)!=null&&p.position)?(this.roomSelectionIndicator.position.set(-m/2+n,-s-y),this.roomName.position.set(0,0)):this.roomSelectionIndicator.position.set(-m/2+n,-y/2-s)}a&&!o&&!h&&((f=this.roomName)!=null&&f.position)&&this.roomName.position.set(0,0)}updateName(t){this.roomName.updateName(t)}async updateRoomType(t){await this.roomName.updateRoomType(t),this.updateLayout()}updateRoomNameVisibility(t){this.roomName.visible=t,this.updateLayout()}updateRoomTypeVisibility(t){this.roomName.updateRoomTypeVisibility(t),this.updateLayout()}updatePosition(t){this.position.set(t.x,t.y)}async refreshColor(){this.roomName&&this.roomName.refreshColor(),this.roomProperty&&this.roomProperty.refreshColor(),this.roomSelectionIndicator&&await this.roomSelectionIndicator.refreshColor()}destroy(){var t,i,s,n;(t=this.clickHandler)==null||t.destroy(),this.clickHandler=null,this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.isAnimatingScale&&this.scaleAnimationBound&&(this.appService.getApp().ticker.remove(this.scaleAnimationBound),this.isAnimatingScale=!1),this.scaleAnimationBound=null,this.updateScaleBound&&(this.appService.emitter.off("antiScale",this.updateScaleBound),this.updateScaleBound=null),(i=this.roomProperty)==null||i.destroy(),this.roomProperty=null,(s=this.roomSelectionIndicator)==null||s.destroy(),this.roomSelectionIndicator=null,(n=this.roomName)==null||n.destroy(),super.destroy()}}class WS extends L{constructor(t){super({isRenderGroup:!0});g(this,"floorTypeMap",new Map);g(this,"floorTypeMasks",new Map);g(this,"floorTypeContexts",new Map);g(this,"floorTypeToRooms",new Map);this.appService=t,this.appService.appContainer.addToLayer(Or,this)}async createFloorTypes(t){if(!this.appService.runtimeSnapshot.showRoomFloorType)return;this.clearFloorTypes();const s=this.groupRoomsByFloorType(t),n=[];for(const[o,a]of s)n.push(this.createMergedFloorType(o,a));await Promise.all(n)}groupRoomsByFloorType(t){const i=new Map,s=this.appService;return t.forEach((n,o)=>{const a=s.getRoomData(o),h=(a==null?void 0:a.floorType)||0;h>=0&&(i.has(h)||i.set(h,[]),i.get(h).push({roomId:o,graphics:n}))}),i}async createMergedFloorType(t,i){const s=this.appService,{assets:n,opacity:o,scale:a}=s.roomConfig.floorType,h=t%n.length,l=`floorType${h}`;if(!n[h]){w.warn(`No texture asset configured for floorType: ${t}`);return}const c=await N.load(l);if(!c){w.warn(`Floor material texture not found: ${l}`);return}const d=i.map(({graphics:m})=>m.getLocalBounds()),u=vy(d),p=new bs({texture:c,width:u.width,height:u.height});p.x=u.x,p.y=u.y,p.alpha=o,p.tileScale.set(a);const{maskContainer:f,contexts:y}=this.createMergedMask(i.map(({graphics:m})=>m));p.mask=f,this.addChild(p),this.floorTypeMap.set(t,p),this.floorTypeMasks.set(t,f),this.floorTypeContexts.set(t,y),this.floorTypeToRooms.set(t,new Set(i.map(({roomId:m})=>m)))}createMergedMask(t){const i=new L,s=[];return t.forEach(n=>{const o=new H,a=n.context.clone();o.context=a,s.push(a),i.addChild(o)}),{maskContainer:i,contexts:s}}clearFloorTypes(){this.floorTypeMasks.forEach(t=>{try{t.destroy({children:!0})}catch(i){w.warn("Error destroying floor mask:",i)}}),this.floorTypeMasks.clear(),this.floorTypeContexts.forEach(t=>{try{t.forEach(i=>{try{i.destroy()}catch(s){w.warn("Error destroying cloned graphics context:",s)}})}catch(i){w.warn("Error destroying graphics contexts:",i)}}),this.floorTypeContexts.clear(),this.floorTypeMap.forEach(t=>{try{this.removeChild(t),t.destroy()}catch(i){w.warn("Error destroying floor material:",i)}}),this.floorTypeMap.clear(),this.floorTypeToRooms.clear()}destroy(){this.clearFloorTypes(),super.destroy()}}class GS{constructor(e){g(this,"unsubscribeFns",[]);g(this,"roomInfoContainer",new L);g(this,"roomInfoMap",new Map);g(this,"roomDisplayMap",new Map);g(this,"roomFloorType");this.appService=e,this.roomFloorType=new WS(e),e.appContainer.addToLayer(uc,this.roomInfoContainer);const t=G(e.runtime,"showRoomFloorType",d=>{w.log(`[runtime] showRoomFloorType: ${d}`),d?this.updateFloorTypes():this.roomFloorType.clearFloorTypes()}),i=G(e.runtime,"showRoomProperty",d=>{w.log(`[runtime] showRoomProperty: ${d}`),this.updateAllRoomPropertyVisibility()}),s=G(e.runtime,"showRoomOrder",d=>{w.log(`[runtime] showRoomOrder: ${d}`),this.updateAllRoomPropertyVisibility()}),n=G(e.runtime,"roomPropertyFoldIds",d=>{w.log(`[runtime] roomPropertyFoldIds: ${d}`),this.updateAllRoomPropertyVisibility()}),o=G(e.runtime,"showRoomName",d=>{w.log(`[runtime] showRoomName: ${d}`),this.updateAllRoomNameVisibility(d)}),a=G(e.runtime,"showRoomType",d=>{w.log(`[runtime] showRoomType: ${d}`),this.updateAllRoomTypeVisibility(d)}),h=G(e.runtime,"enableRoomSelection",d=>{w.log(`[runtime] enableRoomSelection: ${d}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility(),this.refreshAllRoomColors()}),l=G(e.runtime,"selectRoomIds",d=>{w.log(`[runtime] selectRoomIds: ${d}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility(),this.refreshAllRoomColors()}),c=G(e.runtime,"roomSelectionMode",d=>{w.log(`[runtime] roomSelectionMode: ${d}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility(),this.refreshAllRoomColors()});this.unsubscribeFns.push(t,i,s,n,o,a,h,l,c)}async drawRoomProperty(e){const t=this.appService;return this.roomDisplayMap.clear(),e.forEach((i,s)=>{const n=t.mapManager.getRoomById(i.id),o={...i,centerPoint:(n==null?void 0:n.centerPoint)||null,index:s,colorIndex:n==null?void 0:n.colorIndex};this.roomDisplayMap.set(i.id,o)}),await this.updateRoomInfoDisplay(),await this.updateFloorTypes(),!0}async updateRoomInfoDisplay(){if(this.roomDisplayMap.size===0){this.appService.mapManager.getAllRooms().length===0&&this.clearRoomInfos();return}const e=Array.from(this.roomDisplayMap.values()).filter(t=>t.centerPoint!==null);this.clearRoomInfos(),await Promise.all(e.map(t=>this.createRoomInfo(t)))}async createRoomInfo(e){const t=new OS(this.appService,e);this.roomInfoContainer.addChild(t),this.roomInfoMap.set(e.id,t),await t.initialize(e)}updateRoomName(e,t){const i=this.roomInfoMap.get(e);i&&i.updateName(t)}async updateRoomType(e,t){const i=this.roomDisplayMap.get(e);i&&(i.type=t);const s=this.roomInfoMap.get(e);s&&await s.updateRoomType(t)}updateRoomPosition(e,t){const i=this.roomDisplayMap.get(e);i&&(i.centerPoint=t);const s=this.roomInfoMap.get(e);s&&s.updatePosition(t)}clearRoomInfos(){if(this.roomInfoMap.size===0)return;const e=Array.from(this.roomInfoMap.values());this.roomInfoContainer.removeChildren(),e.forEach(t=>{try{t.destroy()}catch(i){w.warn(`[RoomManager] Error destroying RoomInfo for room ${t.roomId}:`,i)}}),this.roomInfoMap.clear()}getRoomPropertyById(e){return this.roomDisplayMap.get(e)}async refresh(){const e=this.appService;this.roomFloorType.clearFloorTypes(),this.roomDisplayMap.forEach((t,i)=>{const s=e.mapManager.getRoomById(i),n=(s==null?void 0:s.centerPoint)||null;if(t.centerPoint!==n){t.centerPoint=n;const a=this.roomInfoMap.get(i);a&&n&&a.updatePosition(n)}const o=s==null?void 0:s.colorIndex;if(t.colorIndex!==o&&o!==void 0){t.colorIndex=o;const a=this.roomInfoMap.get(i);a&&a.refreshColor()}}),await this.updateRoomInfoDisplay(),await this.updateFloorTypes()}async updateAllRoomPropertyVisibility(){this.roomInfoMap.size!==0&&await Promise.all(Array.from(this.roomInfoMap.values()).map(async e=>{try{await e.updateRoomPropertyVisibility()}catch(t){console.warn(`[RoomManager] Failed to update room property visibility for room ${e.roomId}`,t)}}))}updateAllRoomNameVisibility(e){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(t=>{t.updateRoomNameVisibility(e)})}updateAllRoomTypeVisibility(e){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(t=>{t.updateRoomTypeVisibility(e)})}updateAllRoomSelectionIndicatorVisibility(){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(e=>{e.updateRoomSelectionIndicatorVisibility()})}refreshAllRoomColors(){this.roomInfoMap.size!==0&&this.roomInfoMap.forEach(e=>{e.refreshColor()})}async updateFloorTypes(){const e=this.appService,t=e.mapManager.roomFill.getRoomGraphicsMap();t.size>0?(await this.roomFloorType.createFloorTypes(t),e.getApp().renderOnceNextFrame()):e.mapManager.getAllRooms().length===0&&this.roomFloorType.clearFloorTypes()}clear(){this.clearRoomInfos(),this.roomInfoContainer.removeChildren(),this.roomInfoMap.clear(),this.roomDisplayMap.clear(),this.roomFloorType.clearFloorTypes()}destroy(){this.clearRoomInfos(),this.roomInfoContainer.destroy(),this.roomFloorType.destroy(),this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[]}}var Ka,$a;(Ka=navigator==null?void 0:navigator.userAgent)!=null&&Ka.includes("tuya-ark-ide")||(($a=navigator==null?void 0:navigator.userAgent)==null||$a.includes("miniProgram"));const US=()=>{var i,s;if(!hu.any)return!0;const r=navigator.userAgent.toLowerCase(),e=()=>{const n=navigator.deviceMemory;return n?n>=4:!0};let t=!1;if(/iphone|ipad|ipod/.test(r)){const n=(i=r.match(/os (\d+)_/))==null?void 0:i[1];t=(n?parseInt(n):0)>=12}else if(/android/.test(r)){const n=(s=r.match(/android (\d+)/))==null?void 0:s[1];t=(n?parseInt(n):0)>=10}return t&&e()};class HS extends L{constructor(t,i,s){super();g(this,"graphics");g(this,"sprite",null);g(this,"viewportBounds");g(this,"lastConfig",null);g(this,"onImageLoaded");this.label="background",this.viewportBounds=i,this.onImageLoaded=s,this.graphics=new H,this.graphics.label="backgroundGraphics",this.addChild(this.graphics),this.render(t)}async render(t){if(this.lastConfig=t,this.clear(),t.backgroundImage){await this.renderImage(t.backgroundImage,t.backgroundAlpha);return}if(t.backgroundGradient){this.renderGradient(t.backgroundGradient);return}if(t.backgroundColor!==void 0){this.renderSolidColor(t.backgroundColor,t.backgroundAlpha);return}w.warn("[Background] No background configuration provided")}clear(){this.graphics.clear(),this.sprite&&(this.removeChild(this.sprite),this.sprite.destroy(),this.sprite=null)}renderSolidColor(t,i){this.graphics.clear(),this.graphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill({color:t,alpha:i}),w.debug("[Background] Rendered solid color background",{color:t,alpha:i})}renderGradient(t){const{width:i,height:s}=this.viewportBounds;if(this.graphics.clear(),t.type==="linear"){const n=t.x0??0,o=t.y0??0,a=t.x1??1,h=t.y1??1,l=new Ot({type:"linear",start:{x:n,y:o},end:{x:a,y:h},colorStops:t.colorStops});this.graphics.rect(0,0,i,s).fill(l),w.debug("[Background] Rendered linear gradient background",{x0:n,y0:o,x1:a,y1:h,colorStops:t.colorStops.length})}else if(t.type==="radial"){const n=t.cx??.5,o=t.cy??.5,a=t.r??.5,h=new Ot({type:"radial",center:{x:n,y:o},innerRadius:0,outerCenter:{x:n,y:o},outerRadius:a,colorStops:t.colorStops});this.graphics.rect(0,0,i,s).fill(h),w.debug("[Background] Rendered radial gradient background",{cx:n,cy:o,r:a,colorStops:t.colorStops.length})}}async renderImage(t,i){var s,n,o,a;try{const h=await N.load(t.src);if(!h){w.error("[Background] Failed to load image:",t.src),(s=this.lastConfig)!=null&&s.backgroundColor&&this.renderSolidColor(this.lastConfig.backgroundColor,i);return}this.sprite=new jt(h),this.sprite.label="backgroundSprite",this.sprite.alpha=i;const{width:l,height:c}=this.viewportBounds,d=t.fit||"cover",u=((n=t.position)==null?void 0:n.x)??.5,p=((o=t.position)==null?void 0:o.y)??.5,f=h.width,y=h.height,m=f/y,x=l/c;switch(d){case"fill":this.sprite.width=l,this.sprite.height=c,this.sprite.x=0,this.sprite.y=0;break;case"contain":m>x?(this.sprite.width=l,this.sprite.height=l/m):(this.sprite.height=c,this.sprite.width=c*m),this.sprite.x=(l-this.sprite.width)*u,this.sprite.y=(c-this.sprite.height)*p;break;case"cover":m>x?(this.sprite.height=c,this.sprite.width=c*m):(this.sprite.width=l,this.sprite.height=l/m),this.sprite.x=(l-this.sprite.width)*u,this.sprite.y=(c-this.sprite.height)*p;break;case"none":this.sprite.width=f,this.sprite.height=y,this.sprite.x=(l-f)*u,this.sprite.y=(c-y)*p;break}t.repeat&&w.warn("[Background] Repeat mode not yet implemented"),this.addChild(this.sprite),w.debug("[Background] Rendered image background",{src:t.src,fit:d,position:{x:u,y:p},spriteSize:{width:this.sprite.width,height:this.sprite.height}}),this.onImageLoaded&&this.onImageLoaded()}catch(h){w.error("[Background] Error loading background image:",h),(a=this.lastConfig)!=null&&a.backgroundColor&&this.renderSolidColor(this.lastConfig.backgroundColor,i)}}async update(t){await this.render(t)}destroy(){this.clear(),super.destroy()}}class VS extends L{constructor(t){super();g(this,"carpetData");g(this,"carpetConfig");g(this,"controlsConfig");g(this,"carpetEvents");g(this,"appService");g(this,"controlFill");g(this,"editControlLayer");g(this,"clickHandler",null);g(this,"maskContainer",null);g(this,"maskGraphics",null);g(this,"texture",null);g(this,"textureMap",new Map);g(this,"tilingSprite",null);g(this,"initialZonePoints",[]);g(this,"unsubscribeFns",[]);g(this,"resolvedMaxSizeCache",null);g(this,"handleDragStart",()=>{this.isEditingEnabled()&&(this.carpetData.points&&this.carpetData.points.length>0?this.initialZonePoints=this.carpetData.points.map(t=>({...t})):this.initialZonePoints=[],this.appService.getApp().requestRender("zone-drag",!0))});g(this,"handleDragMove",t=>{if(!this.isEditingEnabled()||this.initialZonePoints.length===0||this.carpetData.shape==="custom")return;const i=this.parent.toLocal(t.global),s=this.controlFill.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleDragEnd",()=>{var t,i;this.initialZonePoints=[],this.appService.getApp().stopRender("zone-drag"),(i=(t=this.carpetEvents).onUpdate)==null||i.call(t,this.getCarpetData())});g(this,"handleMoveStart",()=>{this.carpetData.points&&this.carpetData.points.length>0?this.initialZonePoints=this.carpetData.points.map(t=>({...t})):this.initialZonePoints=[],this.appService.getApp().requestRender("zone-move",!0)});g(this,"handleMove",t=>{var a,h;if(!this.isEditingEnabled()||this.initialZonePoints.length===0)return;const i=this.parent.toLocal(t.global),s=(h=(a=this.editControlLayer)==null?void 0:a.getMoveButton())==null?void 0:h.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.applyTranslation(n,o)});g(this,"handleMoveEnd",()=>{var t,i;this.initialZonePoints=[],this.appService.getApp().stopRender("zone-move"),(i=(t=this.carpetEvents).onUpdate)==null||i.call(t,this.getCarpetData())});g(this,"handleRotationStart",()=>{this.appService.getApp().requestRender("zone-rotate",!0)});g(this,"handleRotationMove",t=>{t&&(this.carpetData.points=t,this.drawCarpet())});g(this,"handleRotationEnd",()=>{var t,i;this.appService.getApp().stopRender("zone-rotate"),(i=(t=this.carpetEvents).onUpdate)==null||i.call(t,this.getCarpetData())});g(this,"handleScaleStart",()=>{this.appService.getApp().requestRender("zone-scale",!0)});g(this,"handleScaleMove",t=>{t&&(this.carpetData.points=t,this.drawCarpet())});g(this,"handleScaleMoveHorizontal",t=>{t&&(this.carpetData.points=t,this.drawCarpet())});g(this,"handleScaleMoveVertical",t=>{t&&(this.carpetData.points=t,this.drawCarpet())});g(this,"handleScaleEnd",()=>{var t,i;this.appService.getApp().stopRender("zone-scale"),(i=(t=this.carpetEvents).onUpdate)==null||i.call(t,this.getCarpetData())});g(this,"handleDelete",()=>{var t,i;(i=(t=this.carpetEvents).onRemove)==null||i.call(t,this.carpetData.id)});g(this,"handleClick",()=>{var t,i;this.isEditingEnabled()||(i=(t=this.carpetEvents)==null?void 0:t.onClick)==null||i.call(t,this.getCarpetData())});g(this,"handlePointsUpdate",t=>{this.carpetData.points=t,this.drawCarpet()});const{appService:i,carpetData:s,events:n={},textureMap:o}=t;this.appService=i,this.textureMap=o,this.carpetEvents=n,this.controlsConfig=this.getControlsConfig(),this.carpetConfig=this.controlsConfig.carpet,this.processCarpetData(s),this.initializeComponents(),this.createEditControlLayer(),this.setupClickHandler(),this.setupEnableRoomSelectionListener(),this.updateEditState(),this.loadTexture()}getResolvedMaxSize(){const t=this.carpetConfig.maxSize;if(this.resolvedMaxSizeCache&&this.resolvedMaxSizeCache.key===t)return this.resolvedMaxSizeCache.value;const i=Ur(this.carpetConfig.minSize,t,"carpet");return this.resolvedMaxSizeCache={key:t,value:i},i}processCarpetData(t){if(t.points&&t.points.length>=2)if(t.shape==="custom")this.carpetData={...t,points:t.points};else{const s=this.getResolvedMaxSize(),n=sr(t.points,this.appService.metersToPixels(this.carpetConfig.minSize),s!=null?this.appService.metersToPixels(s):void 0),o=Cs(n);this.carpetData={...t,points:o}}else this.carpetData={...t,points:[],shape:t.shape||"rectangle"}}getControlsConfig(){const{controls:t}=this.appService.getConfig();return t}isEditingEnabled(){return this.appService.runtimeSnapshot.editingCarpetIds.includes(this.carpetData.id)}isSelected(){return this.appService.runtimeSnapshot.selectedCarpetIds.includes(this.carpetData.id)}shouldShowEditControl(){return this.isEditingEnabled()||this.isSelected()}initializeComponents(){this.maskContainer=this.createMaskContainer(),this.controlFill=this.createControlFill(),this.addChild(this.maskContainer),this.addChild(this.controlFill),this.drawCarpet()}createMaskContainer(){const t=new L;return this.maskGraphics=new H,this.updateMaskShape(),t.addChild(this.maskGraphics),t.mask=this.maskGraphics,t}createControlFill(){const t=this.isEditingEnabled();return new Gr(this.appService,{points:this.carpetData.points||[],fillColor:this.carpetConfig.fillColor,enableInteraction:t,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createEditControlLayer(){const t=this.isEditingEnabled(),i=this.carpetData.shape==="custom",s={...An(this.carpetConfig,["outlineStrokeWidth","outlineDashed","outlineDashArray","outlineFillColor","outlineOffset","outlineStrokeColor"]),...An(this.carpetConfig,["textColor","textPosition","textOffset"]),...An(this.controlsConfig,["textFontSize","textFontFamily","textFontWeight"]),showRotateButton:!!t&&!i&&this.carpetConfig.showRotateButton,showScaleButton:!!t&&!i,showDeleteButton:!!t,showMoveButton:!!t&&!i,showRadialScaleButton:!!t&&!i,iconWrapperFillColor:this.carpetConfig.iconWrapperFillColor,moveButtonOffset:this.controlsConfig.moveButtonOffset},n=i?this.calculateBoundingRectanglePoints():this.carpetData.points||[];this.editControlLayer=this.appService.editControlManager.registerEditControl(this.carpetData.id,{config:s,zonePoints:n,minSize:this.carpetConfig.minSize,maxSize:this.getResolvedMaxSize(),contentLayer:$e,events:{onRemove:this.handleDelete,onRotateStart:this.handleRotationStart,onRotateMove:this.handleRotationMove,onRotateEnd:this.handleRotationEnd,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleMoveHorizontal:this.handleScaleMoveHorizontal,onScaleMoveVertical:this.handleScaleMoveVertical,onScaleEnd:this.handleScaleEnd,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd,onClick:this.handleClick,onPointsUpdate:this.handlePointsUpdate}})}setupClickHandler(){this.interactiveChildren=!0,this.clickHandler=new vt(this,{onClick:()=>{var t,i;this.isEditingEnabled()||(i=(t=this.carpetEvents)==null?void 0:t.onClick)==null||i.call(t,this.getCarpetData())},stopPropagation:!1})}setupEnableRoomSelectionListener(){const t=G(this.appService.runtime,"enableRoomSelection",s=>{this.updateClickHandlerState(s)});this.unsubscribeFns.push(t);const i=this.appService.runtimeSnapshot.enableRoomSelection;this.updateClickHandlerState(i)}isRoomSelectionEnabled(){return this.appService.runtimeSnapshot.enableRoomSelection}updateClickHandlerState(t){if(t){if(this.eventMode="none",this.clickHandler){const i=this.clickHandler.getTarget();i.eventMode="none"}}else if(this.eventMode="static",this.clickHandler){const i=this.clickHandler.getTarget();i.eventMode="static"}}calculateBounds(){const{points:t}=this.carpetData;let i=1/0,s=1/0,n=-1/0,o=-1/0;if(t&&t.length>0)for(const a of t)i=Math.min(i,a.x),s=Math.min(s,a.y),n=Math.max(n,a.x),o=Math.max(o,a.y);return{minX:i,minY:s,maxX:n,maxY:o}}calculateBoundingRectanglePoints(){const{points:t}=this.carpetData;if(!t||t.length===0)return[];const{minX:i,minY:s,maxX:n,maxY:o}=ws(t);return[{x:i,y:s},{x:n,y:s},{x:n,y:o},{x:i,y:o}]}updateMaskShape(){if(!this.maskGraphics)return;this.maskGraphics.clear();const{points:t,shape:i}=this.carpetData;if(!(!t||!Array.isArray(t)||t.length<2)){if(i==="round"){if(t.length<4)return;const n=de(t),[o,a,,h]=t,l=Q(o,a),c=Q(o,h),d=Math.atan2(a.y-o.y,a.x-o.x);this.maskGraphics.position.set(n.x,n.y),this.maskGraphics.rotation=d,this.maskGraphics.ellipse(0,0,l/2,c/2)}else{const n=t.flatMap(o=>[o.x,o.y]);this.maskGraphics.poly(n),this.maskGraphics.position.set(0,0),this.maskGraphics.rotation=0}this.maskGraphics.fill(16777215)}}loadTexture(){const{opacity:t,scale:i}=this.appService.carpetConfig,{type:s}=this.carpetData;try{this.texture=this.textureMap.get(s)||this.textureMap.get(-1)||null,this.texture&&this.maskContainer&&(this.tilingSprite&&(this.maskContainer.removeChild(this.tilingSprite),this.tilingSprite.destroy(),this.tilingSprite=null),this.createTilingSprite(i,t),this.appService.getApp().renderOnce())}catch(n){console.warn("Failed to load carpet texture:",n)}}createTilingSprite(t,i){if(!this.texture||!this.maskContainer)return;const s=this.calculateBounds();this.tilingSprite=new bs({texture:this.texture,width:s.maxX-s.minX+100,height:s.maxY-s.minY+100}),this.tilingSprite.position.set(s.minX-50,s.minY-50),this.tilingSprite.tileScale.set(t),this.tilingSprite.alpha=i,this.maskContainer.addChild(this.tilingSprite)}updateTilingSprite(){if(!this.tilingSprite)return;const t=this.calculateBounds();this.tilingSprite.position.set(t.minX-50,t.minY-50),this.tilingSprite.width=t.maxX-t.minX+100,this.tilingSprite.height=t.maxY-t.minY+100}applyTranslation(t,i){this.carpetData.points=this.initialZonePoints.map(s=>({x:s.x+t,y:s.y+i})),this.drawCarpet()}drawCarpet(){const{points:t}=this.carpetData;if(!(!t||t.length<2)&&(this.updateMaskShape(),this.updateTilingSprite(),this.controlFill.updatePoints(t),this.editControlLayer)){const n=this.carpetData.shape==="custom"?this.calculateBoundingRectanglePoints():t;this.editControlLayer.updatePoints(n)}}updateEditState(){const t=this.isEditingEnabled(),i=this.isSelected(),s=this.shouldShowEditControl();if(this.controlFill.setInteractionEnabled(t),this.editControlLayer)if(i&&!t)this.appService.editControlManager.updateEditState(this.carpetData.id,{showRotateButton:!1,showScaleButton:!1,showDeleteButton:!1,showMoveButton:!1,showBorder:!0,showSizeText:!1,borderStyle:this.carpetConfig.normal});else if(t){const n=this.carpetData.shape==="custom";this.appService.editControlManager.updateEditState(this.carpetData.id,{showRotateButton:!n&&this.carpetConfig.showRotateButton,showScaleButton:!n,showDeleteButton:!0,showMoveButton:!n,showBorder:!0,showSizeText:!0,borderStyle:this.carpetConfig.editing,showRadialScaleButton:!n})}else this.appService.editControlManager.updateEditState(this.carpetData.id,{showRotateButton:!1,showScaleButton:!1,showDeleteButton:!1,showMoveButton:!1,showBorder:!1,showSizeText:!1});this.zIndex=s?1e3:0}updateCarpetData(t){const s=this.carpetData.type;if(t.points&&t.points.length>=2)if(t.shape==="custom")this.carpetData={...t,points:t.points};else{const n=this.getResolvedMaxSize(),o=sr(t.points,this.appService.metersToPixels(this.carpetConfig.minSize),n!=null?this.appService.metersToPixels(n):void 0),a=Cs(o);this.carpetData={...t,points:a}}else this.carpetData={...t,points:t.points||[]};s!==this.carpetData.type&&this.loadTexture(),this.drawCarpet(),this.updateEditState()}getCarpetData(){return{...this.carpetData}}refreshDisplay(){this.drawCarpet()}destroy(){var t,i,s,n,o;this.appService.editControlManager.unregisterEditControl(this.carpetData.id),this.unsubscribeFns.forEach(a=>a()),this.unsubscribeFns=[],(t=this.tilingSprite)==null||t.destroy(),(i=this.maskGraphics)==null||i.destroy(),(s=this.maskContainer)==null||s.destroy(),this.tilingSprite=null,this.maskGraphics=null,this.maskContainer=null,this.texture=null,(n=this.controlFill)==null||n.destroy(),(o=this.clickHandler)==null||o.destroy(),super.destroy()}}class NS{constructor(e){g(this,"customCarpetMap",new Map);g(this,"unsubscribeFns",[]);g(this,"textureMap",new Map);g(this,"texturesLoaded",!1);g(this,"texturesLoadingPromise",null);this.appService=e,this.applyLayerVisibility(e.runtime.showCustomCarpets);const t=G(e.runtime,"editingCarpetIds",n=>{w.log(`[runtime] editingCarpetIds: ${n}`),this.updateCarpetsEditState()}),i=G(e.runtime,"selectedCarpetIds",n=>{w.log(`[runtime] selectedCarpetIds: ${n}`),this.updateCarpetsEditState()}),s=G(e.runtime,"showCustomCarpets",n=>{w.log(`[runtime] showCustomCarpets: ${n}`),this.applyLayerVisibility(n)});this.unsubscribeFns.push(t,i,s)}async loadTextures(){if(!this.texturesLoaded){if(this.texturesLoadingPromise)return this.texturesLoadingPromise;this.texturesLoadingPromise=this._loadTextures(),await this.texturesLoadingPromise,this.texturesLoaded=!0,this.texturesLoadingPromise=null}}async _loadTextures(){const e=this.appService,{material:t,src:i}=e.carpetConfig;if(t)for(const s of t){const n=await N.load(s.src);this.textureMap.set(s.type,n)}if(i){const s=await N.load(i);this.textureMap.set(-1,s)}}async drawCustomCarpets(e){if(await this.loadTextures(),!e||e.length===0){this.clearAllCustomCarpets();return}const t=new Set(this.customCarpetMap.keys()),i=new Set(e.map(s=>s.id));for(const s of t)i.has(s)||this.removeCustomCarpet(s);e.forEach(s=>{const n=this.customCarpetMap.get(s.id.toString());n?this.isCarpetDataEqual(n.getCarpetData(),s)||n.updateCarpetData(s):this.addNewCustomCarpet(s)})}getCustomCarpets(){const e=[];return this.customCarpetMap.forEach(t=>{e.push(t.getCarpetData())}),e}getCustomCarpetById(e){return this.customCarpetMap.get(e)}clearAllCustomCarpets(){this.customCarpetMap.forEach((e,t)=>{var s;const i=this.customCarpetMap.get(t);i&&((s=i.parent)==null||s.removeChild(i),i.destroy())}),this.customCarpetMap.clear()}addNewCustomCarpet(e){const t=this.appService,i=new VS({appService:t,carpetData:e,textureMap:this.textureMap,events:{onRemove:s=>{var n,o;(o=(n=t.events)==null?void 0:n.onDeleteCustomCarpet)==null||o.call(n,{id:s})},onUpdate:s=>{var n,o;(o=(n=t.events)==null?void 0:n.onUpdateCustomCarpet)==null||o.call(n,s)},onClick:s=>{var n,o;(o=(n=t.events)==null?void 0:n.onClickCarpet)==null||o.call(n,{id:s.id})}}});this.customCarpetMap.set(e.id.toString(),i),t.appContainer.addToLayer($e,i)}removeCustomCarpet(e){const t=this.appService,i=this.customCarpetMap.get(e);i&&(t.appContainer.removeFromLayer($e,i),i.destroy(),this.customCarpetMap.delete(e))}updateCarpetsEditState(){this.customCarpetMap.forEach(e=>{e.updateEditState()})}applyLayerVisibility(e){const t=this.appService.appContainer.getLayer($e);t&&(t.visible=e)}isCarpetDataEqual(e,t){if(e.id!==t.id||e.type!==t.type||e.shape!==t.shape)return!1;const i=e.points||[],s=t.points||[];if(i.length!==s.length)return!1;for(let n=0;n<i.length;n++){const o=i[n],a=s[n];if(Math.abs(o.x-a.x)>.1||Math.abs(o.y-a.y)>.1)return!1}return!0}refreshDisplay(){this.customCarpetMap.forEach(e=>{e.refreshDisplay()})}destroy(){this.clearAllCustomCarpets(),this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[]}}class jS extends Ni{constructor(e,t){super(e,t),this.cursor="pointer"}setupEvents(){this.on("pointerdown",e=>{e.stopPropagation()}),this.on("pointertap",()=>{var e,t;(t=(e=this.options).onClick)==null||t.call(e)})}destroy(){this.removeAllListeners(),super.destroy()}}const Rt={REMOVE:0,ROTATE:1,SCALE:2,MOVE:3,FIXED:0};class YS extends L{constructor(t){super();g(this,"appService");g(this,"data");g(this,"furnitureEvents");g(this,"textureAlias");g(this,"sprite");g(this,"controlButtons");g(this,"outlineBorder");g(this,"moveLine");g(this,"deleteButton",null);g(this,"rotateButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"sizeText",null);g(this,"isEditing",!1);g(this,"dragStartPosition",null);g(this,"initialPoints",[]);g(this,"clickHandler",null);g(this,"isDragging",!1);g(this,"initialScalePoints",[]);g(this,"initialButtonPosition",null);g(this,"rotationCount",0);g(this,"originalEdgeLengths",null);g(this,"onDragStart",t=>{if(!this.isEditing||!this.parent||t.target!==this&&t.target!==this.sprite)return;t.stopPropagation();const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},this.initialPoints=this.data.points.map(s=>({...s})),this.isDragging=!1,this.setupDragEventListeners(),this.appService.emitter.emit("gestureHijackStart",t)});g(this,"onDragMove",t=>{if(!this.dragStartPosition||!this.parent)return;const i=this.parent.toLocal(t.global),s=i.x-this.dragStartPosition.x,n=i.y-this.dragStartPosition.y;!this.isDragging&&Math.abs(s)+Math.abs(n)<3||(this.isDragging||(this.isDragging=!0,this.appService.getApp().requestRender("furniture-drag",!0)),this.data.points=this.initialPoints.map(o=>({x:o.x+s,y:o.y+n})),this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText())});g(this,"onDragEnd",()=>{var t,i;this.dragStartPosition&&(this.cleanupDragEventListeners(),this.isDragging&&((i=(t=this.furnitureEvents).onUpdate)==null||i.call(t,this.getData()),this.appService.getApp().stopRender("furniture-drag")),this.dragStartPosition=null,this.initialPoints=[],this.isDragging=!1)});g(this,"onDragCancel",()=>{this.dragStartPosition&&(this.cleanupDragEventListeners(),this.isDragging&&this.appService.getApp().stopRender("furniture-drag"),this.dragStartPosition=null,this.initialPoints=[],this.isDragging=!1)});g(this,"handleScaleStart",()=>{this.initialScalePoints=this.data.points.map(i=>({...i}));const t=this.getVisualIndex(Rt.SCALE);t>=0&&t<this.data.points.length&&(this.initialButtonPosition={...this.data.points[t]}),this.appService.getApp().requestRender("furniture-scale",!0)});g(this,"handleScaleMove",({deltaX:t,deltaY:i})=>{if(this.initialScalePoints.length===0||!this.initialButtonPosition)return;const s={x:this.initialButtonPosition.x+t,y:this.initialButtonPosition.y+i};this.applyEdgeBasedScale(s)});g(this,"handleScaleEnd",()=>{var t,i;this.initialScalePoints=[],this.initialButtonPosition=null,this.appService.getApp().stopRender("furniture-scale"),(i=(t=this.furnitureEvents).onUpdate)==null||i.call(t,this.getData())});g(this,"handleMoveStart",()=>{this.initialPoints=this.data.points.map(t=>({...t})),this.appService.getApp().requestRender("furniture-move",!0)});g(this,"handleMoveMove",t=>{var a;if(!this.isEditing||this.initialPoints.length===0||!this.parent)return;const i=this.parent.toLocal(t.global),s=(a=this.moveButton)==null?void 0:a.getDragStartPosition();if(!s)return;const n=i.x-s.x,o=i.y-s.y;this.data.points=this.initialPoints.map(h=>({x:h.x+n,y:h.y+o})),this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText()});g(this,"handleMoveEnd",()=>{var t,i;this.initialPoints=[],this.appService.getApp().stopRender("furniture-move"),(i=(t=this.furnitureEvents).onUpdate)==null||i.call(t,this.getData())});const{appService:i,data:s,textureAlias:n,events:o={}}=t;this.appService=i,this.data={...s,points:s.points.map(a=>({...a}))},this.textureAlias=n,this.furnitureEvents=o,this.createSprite(),this.updateSpriteTransform(),this.createEditControls(),this.captureOriginalEdgeLengths(),this.eventMode="static",this.cursor="pointer",this.setupInteraction()}get config(){return this.appService.furnitureConfig}captureOriginalEdgeLengths(){const t=this.data.points;if(t.length<4)return;const i=this.getVisualIndex(Rt.FIXED),s=this.getVisualIndex(1),n=this.getVisualIndex(3);this.originalEdgeLengths={edge1:Q(t[i],t[s]),edge2:Q(t[i],t[n])}}getVisualIndex(t){return(t+4-this.rotationCount)%4}getVisualPoints(){const t=this.data.points;return[t[this.getVisualIndex(0)],t[this.getVisualIndex(1)],t[this.getVisualIndex(2)],t[this.getVisualIndex(3)]]}createSprite(){const t=N.get(this.textureAlias);this.sprite=new jt(t),this.sprite.anchor.set(.5),this.sprite.alpha=this.config.opacity,this.sprite.eventMode="passive",this.addChild(this.sprite)}updateSpriteTransform(){const t=this.data.points;if(t.length<4)return;const i=de(t),s=t[1].x-t[0].x,n=t[1].y-t[0].y,o=Math.atan2(n,s),a=Q(t[0],t[1]),h=Q(t[1],t[2]);this.sprite.position.set(i.x,i.y),this.sprite.rotation=o,this.sprite.width=a,this.sprite.height=h}createEditControls(){const t=this.calculateOutlinePoints();this.outlineBorder=new Nt(this.appService,{points:t,closePath:!0,style:{color:this.config.outlineStrokeColor,width:this.config.outlineStrokeWidth,isDashed:this.config.outlineDashed,dashArray:this.config.outlineDashArray,fillColor:this.config.outlineFillColor}}),this.outlineBorder.visible=!1,this.addChild(this.outlineBorder);const i=this.calculateMoveLinePoints(t);this.moveLine=new Nt(this.appService,{points:i,closePath:!1,style:{color:this.config.outlineStrokeColor,width:this.config.outlineStrokeWidth,isDashed:this.config.outlineDashed,dashArray:this.config.outlineDashArray}}),this.moveLine.visible=!1,this.addChild(this.moveLine),this.controlButtons=new L,this.controlButtons.visible=!1,this.addChild(this.controlButtons),this.createControlButtons()}createControlButtons(){const t=this.calculateOutlinePoints();if(t.length<4)return;const{iconWrapperFillColor:i}=this.config,s=this.getVisualIndex(Rt.REMOVE),n=this.getVisualIndex(Rt.ROTATE),o=this.getVisualIndex(Rt.SCALE);this.deleteButton=new zs(this.appService,{iconAlias:"deleteIcon",backgroundColor:i,onClick:()=>{var h,l;return(l=(h=this.furnitureEvents).onRemove)==null?void 0:l.call(h,this.data.id)}}),this.deleteButton.position.set(t[s].x,t[s].y),this.rotateButton=new jS(this.appService,{iconAlias:"rotateIcon",backgroundColor:i,onClick:()=>this.handleTapRotate()}),this.rotateButton.position.set(t[n].x,t[n].y),this.scaleButton=new Qe(this.appService,{iconAlias:"scaleIcon",backgroundColor:i,getTargetPoints:()=>this.data.points,getButtonIndex:()=>this.getVisualIndex(Rt.SCALE),onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(t[o].x,t[o].y);const a=this.calculateMoveButtonPosition(t);this.moveButton=new Ls(this.appService,{iconAlias:"moveIcon",backgroundColor:i,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMoveMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(a.x,a.y),this.controlButtons.addChild(this.deleteButton),this.controlButtons.addChild(this.rotateButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton),this.config.showSizeText&&(this.sizeText=this.createSizeText(),this.controlButtons.addChild(this.sizeText))}calculateOutlinePoints(){const{points:t}=this.data;if(t.length<4)return t;const i=this.appService.getApp().toFixedSize(this.config.outlineOffset);return Fr(t,i)}calculateMoveButtonPosition(t){const i=t??this.calculateOutlinePoints();if(i.length<4)return{x:0,y:0};const{controls:s}=this.appService.getConfig(),n=this.getVisualIndex(Rt.MOVE),o=this.getVisualIndex(2),a=this.getVisualIndex(0),h=this.appService.getApp().toFixedSize(s.moveButtonOffset);return Ds(i[n],i[o],i[a],h)}calculateMoveLinePoints(t,i){if(t.length<4)return[];const s=this.getVisualIndex(Rt.MOVE),n=i??this.calculateMoveButtonPosition(t);return[t[s],n]}createSizeText(){const t=this.calculateSizeTextContent(),i=this.appService.controlsConfig,s=new ji(this.appService,{text:t,style:{fontSize:i.textFontSize,fontFamily:i.textFontFamily,fontWeight:i.textFontWeight,fill:this.config.textColor,align:"center"}});s.anchor.set(.5);const n=this.calculateSizeTextPosition();s.position.set(n.x,n.y);const o=this.calculateSizeTextRotation();return s.rotation=o,s.eventMode="none",s}calculateSizeTextContent(){const{points:t}=this.data;if(t.length<4)return"0m*0m";const[i,s,,n]=this.getVisualPoints(),o=Q(i,s),a=Q(i,n),h=this.rotationCount%2!==0,l=h?a:o,c=h?o:a,d=this.appService.pixelsToMeters(l),u=this.appService.pixelsToMeters(c),p=this.appService.metersToDisplayUnit(d),f=this.appService.metersToDisplayUnit(u),y=this.appService.runtimeSnapshot.unitLabel;return`${p.toFixed(1)}${y}*${f.toFixed(1)}${y}`}calculateSizeTextPosition(){const{points:t}=this.data;if(t.length<4)return{x:0,y:0};const[i,s,n,o]=this.getVisualPoints(),{textPosition:a,textOffset:h}=this.config,l=this.appService.getApp().toFixedSize(h);let c,d;switch(a){case"top":{c={x:(i.x+s.x)/2,y:(i.y+s.y)/2};const u=gt(K(s,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"right":{c={x:(s.x+n.x)/2,y:(s.y+n.y)/2};const u=gt(K(s,n)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}case"bottom":{c={x:(o.x+n.x)/2,y:(o.y+n.y)/2};const u=gt(K(o,n)),p={x:-u.y,y:u.x};d={x:p.x*l,y:p.y*l};break}case"left":{c={x:(i.x+o.x)/2,y:(i.y+o.y)/2};const u=gt(K(o,i)),p={x:u.y,y:-u.x};d={x:p.x*l,y:p.y*l};break}default:c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d={x:0,y:l};break}return{x:c.x+d.x,y:c.y+d.y}}calculateSizeTextRotation(){const{points:t}=this.data;if(t.length<4)return 0;const[i,s,n,o]=this.getVisualPoints(),{textPosition:a}=this.config;let h,l;switch(a){case"top":h=i,l=s;break;case"right":h=s,l=n;break;case"bottom":h=n,l=o;break;case"left":h=o,l=i;break;default:h=i,l=s;break}const c=this.appService.appContainer.getMapRotationRadians();return qe(h,l,c)}setupInteraction(){this.clickHandler=new vt(this,{onClick:t=>{var i,s;!this.isDragging&&((t==null?void 0:t.target)===this||(t==null?void 0:t.target)===this.sprite)&&((s=(i=this.furnitureEvents).onClick)==null||s.call(i,this.getData()))}}),this.on("pointerdown",this.onDragStart,this)}setupDragEventListeners(){const{emitter:t}=this.appService;t.on("gestureHijackPointerMove",this.onDragMove),t.on("gestureHijackPointerUp",this.onDragEnd),t.on("gestureHijackCancel",this.onDragCancel)}cleanupDragEventListeners(){const{emitter:t}=this.appService;t.off("gestureHijackPointerMove",this.onDragMove),t.off("gestureHijackPointerUp",this.onDragEnd),t.off("gestureHijackCancel",this.onDragCancel)}handleTapRotate(){var n,o;const t=this.config.rotateDirection!=="ccw",i=t?Math.PI/2:-Math.PI/2,s=de(this.data.points);this.data.points=Dr(this.data.points,s,i),this.rotationCount=(this.rotationCount+(t?1:3))%4,this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText(),(o=(n=this.furnitureEvents).onUpdate)==null||o.call(n,this.getData())}applyEdgeBasedScale(t){if(this.initialScalePoints.length<4)return;const i=this.getVisualIndex(Rt.FIXED),s=this.getVisualIndex(1),n=this.getVisualIndex(3),{x:o,y:a}=this.initialScalePoints[i],h=this.initialScalePoints[s],l=this.initialScalePoints[n],c={x:o,y:a},d=K(c,h),u=K(c,l),p=K(c,t),f=ee(d),y=ee(u);if(f===0||y===0)return;const{minScaleRatio:m,maxScaleRatio:x}=this.config;let S=ae(p,d,f,0),v=ae(p,u,y,0);if(this.config.lockAspectRatio){const C=Math.min(S,v);S=C,v=C}if(this.originalEdgeLengths){const C=this.rotationCount%2!==0,A=C?this.originalEdgeLengths.edge2:this.originalEdgeLengths.edge1,k=C?this.originalEdgeLengths.edge1:this.originalEdgeLengths.edge2,M=S*f/A,T=v*y/k;let _=Math.max(m,Math.min(x,M)),E=Math.max(m,Math.min(x,T));if(this.config.lockAspectRatio){const B=Math.min(_,E);_=B,E=B}S=_*A/f,v=E*k/y}else if(S=Math.max(m,Math.min(x,S)),v=Math.max(m,Math.min(x,v)),this.config.lockAspectRatio){const C=Math.min(S,v);S=C,v=C}const b=[c,{x:o+d.x*S,y:a+d.y*S},{x:o+d.x*S+u.x*v,y:a+d.y*S+u.y*v},{x:o+u.x*v,y:a+u.y*v}],P=new Array(4);for(let C=0;C<4;C++)P[this.getVisualIndex(C)]=b[C];this.data.points=P,this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText(!0)}updateEditControls(){var h;const t=this.calculateOutlinePoints();if(t.length<4)return;this.outlineBorder.updatePoints(t);const i=this.calculateMoveButtonPosition(t),s=this.calculateMoveLinePoints(t,i);if(this.moveLine.updatePoints(s),!this.deleteButton||!this.rotateButton||!this.scaleButton)return;const n=this.getVisualIndex(Rt.REMOVE),o=this.getVisualIndex(Rt.ROTATE),a=this.getVisualIndex(Rt.SCALE);this.deleteButton.position.set(t[n].x,t[n].y),this.rotateButton.position.set(t[o].x,t[o].y),this.scaleButton.position.set(t[a].x,t[a].y),(h=this.moveButton)==null||h.position.set(i.x,i.y)}updateSizeText(t=!1){if(!this.sizeText)return;if(t){const n=this.calculateSizeTextContent();this.sizeText.updateText(n)}const i=this.calculateSizeTextPosition();this.sizeText.position.set(i.x,i.y);const s=this.calculateSizeTextRotation();this.sizeText.rotation=s}getData(){return{id:this.data.id,furnitureType:this.data.furnitureType,points:this.data.points.map(t=>({...t}))}}updateData(t){this.data={...t,points:t.points.map(i=>({...i}))},this.rotationCount=0,this.captureOriginalEdgeLengths(),this.updateSpriteTransform(),this.updateEditControls(),this.updateSizeText(!0)}updateEditState(t){this.isEditing!==t&&(this.isEditing=t,this.outlineBorder.visible=t,this.moveLine.visible=t,this.controlButtons.visible=t,t&&(this.updateEditControls(),this.updateSizeText(!0)))}destroy(){var t;this.cleanupDragEventListeners(),(t=this.clickHandler)==null||t.destroy(),this.clickHandler=null,super.destroy({children:!0})}}class XS{constructor(e){g(this,"furnitureMap",new Map);g(this,"unsubscribeFns",[]);this.appService=e,this.applyLayerVisibility(e.runtime.showFurnitures);const t=G(e.runtime,"editingFurnitureIds",s=>{w.log(`[runtime] editingFurnitureIds: ${s}`),this.updateEditState()}),i=G(e.runtime,"showFurnitures",s=>{w.log(`[runtime] showFurnitures: ${s}`),this.applyLayerVisibility(s)});this.unsubscribeFns.push(t,i)}async drawFurnitures(e){if(!e||e.length===0){this.clearAll();return}const t=new Set(this.furnitureMap.keys()),i=new Set(e.map(n=>n.id));for(const n of t)i.has(n)||this.removeFurniture(n);const s=[];for(const n of e){const o=this.furnitureMap.get(n.id);o?this.isDataEqual(o.getData(),n)||o.updateData(n):s.push(this.addFurniture(n))}await Promise.all(s)}async addFurniture(e){const t=this.appService;if(!t.furnitureConfig.assets.find(h=>h.type===e.furnitureType)){w.warn(`[FurnitureManager] No asset found for furnitureType: ${e.furnitureType}`);return}const n=`furniture_${e.furnitureType}`;await N.load(n);const o=new YS({appService:t,data:e,textureAlias:n,events:{onRemove:h=>{var l,c;(c=(l=t.events)==null?void 0:l.onRemoveFurniture)==null||c.call(l,h)},onUpdate:h=>{var l,c;(c=(l=t.events)==null?void 0:l.onUpdateFurniture)==null||c.call(l,h)},onClick:h=>{var l,c;(c=(l=t.events)==null?void 0:l.onClickFurniture)==null||c.call(l,h)}}});this.furnitureMap.set(e.id,o),t.appContainer.addToLayer(je,o),t.runtime.editingFurnitureIds.includes(e.id)&&(o.updateEditState(!0),this.moveToEditLayer(o))}removeFurniture(e){var i;const t=this.furnitureMap.get(e);t&&((i=t.parent)==null||i.removeChild(t),t.destroy(),this.furnitureMap.delete(e))}clearAll(){var e;for(const[,t]of this.furnitureMap)(e=t.parent)==null||e.removeChild(t),t.destroy();this.furnitureMap.clear()}applyLayerVisibility(e){const t=this.appService.appContainer.getLayer(je);t&&(t.visible=e),this.furnitureMap.forEach(i=>{i.visible=e})}updateEditState(){const e=this.appService.runtime.editingFurnitureIds,{appContainer:t}=this.appService,i=t.getLayer(je);this.furnitureMap.forEach((s,n)=>{const o=e.includes(n);s.updateEditState(o),o?this.moveToEditLayer(s):s.parent!==i&&this.moveToFurnitureLayer(s)})}moveToEditLayer(e){var t;(t=e.parent)==null||t.removeChild(e),this.appService.appContainer.addToLayer(ke,e)}moveToFurnitureLayer(e){var t;(t=e.parent)==null||t.removeChild(e),this.appService.appContainer.addToLayer(je,e)}getFurnitures(){const e=[];return this.furnitureMap.forEach(t=>{e.push(t.getData())}),e}isDataEqual(e,t){if(e.id!==t.id||e.furnitureType!==t.furnitureType||e.points.length!==t.points.length)return!1;for(let i=0;i<e.points.length;i++)if(Math.abs(e.points[i].x-t.points[i].x)>.1||Math.abs(e.points[i].y-t.points[i].y)>.1)return!1;return!0}destroy(){this.clearAll(),this.unsubscribeFns.forEach(e=>e()),this.unsubscribeFns=[]}}const pt={REMOVE:0,ROTATE:1,SCALE:2,MOVE:3};class ZS extends L{constructor(t,i){super();g(this,"config");g(this,"events");g(this,"zonePoints",[]);g(this,"outlinePoints");g(this,"minSize",.1);g(this,"maxSize");g(this,"initialZonePoints",[]);g(this,"scaleCache",null);g(this,"rotationCache",null);g(this,"outlineBorder");g(this,"moveLine");g(this,"sizeText");g(this,"controlButtons");g(this,"deleteButton",null);g(this,"rotateButton",null);g(this,"scaleButton",null);g(this,"moveButton",null);g(this,"horizontalScaleButton",null);g(this,"verticalScaleButton",null);g(this,"horizontalScaleInitialPosition",null);g(this,"verticalScaleInitialPosition",null);g(this,"clickHandler",null);g(this,"throttledUpdateOutline");this.appService=t,this.zonePoints=i.zonePoints,this.config={...i.config,showScaleButton:i.config.showScaleButton!==void 0?i.config.showScaleButton:!0,showRadialScaleButton:i.config.showRadialScaleButton!==void 0?i.config.showRadialScaleButton:!0,showDeleteButton:i.config.showDeleteButton!==void 0?i.config.showDeleteButton:!0,showMoveButton:i.config.showMoveButton!==void 0?i.config.showMoveButton:!0,showRotateButton:i.config.showRotateButton!==void 0?i.config.showRotateButton:!0},this.events=i.events||{},this.minSize=i.minSize??.1,this.maxSize=i.maxSize,this.throttledUpdateOutline=Ct(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.registerScaleListener()}initializeComponents(){this.outlinePoints=this.calculateOutlinePoints(),this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.moveLine.visible=this.config.showMoveButton||!1,this.sizeText=this.createSizeText(),this.addChild(this.sizeText),this.controlButtons=new L,this.addChild(this.controlButtons),this.createControlButtons(),this.setupClickHandler()}createOutlineBorder(){const{outlineStrokeColor:t,outlineStrokeWidth:i,outlineDashed:s,outlineDashArray:n,outlineFillColor:o}=this.config;return new Nt(this.appService,{points:this.outlinePoints,closePath:!0,style:{color:t,width:i,isDashed:s,dashArray:n,fillColor:o}})}createMoveLine(){const{outlineStrokeColor:t,outlineStrokeWidth:i,outlineDashed:s,outlineDashArray:n}=this.config,o=this.calculateMoveLinePoints();return new Nt(this.appService,{points:o,closePath:!1,style:{color:t,width:i,isDashed:s,dashArray:n}})}createSizeText(){const t=this.calculateSizeText(),i=new ji(this.appService,{text:t,style:{fontSize:this.config.textFontSize,fontFamily:this.config.textFontFamily,fontWeight:this.config.textFontWeight,fill:this.config.textColor,align:"center"}});i.anchor.set(.5);const s=this.calculateSizeTextPosition();i.position.set(s.x,s.y);const n=this.calculateSizeTextRotation();return i.rotation=n,i.eventMode="none",i}createDeleteButton(){const t=new zs(this.appService,{iconAlias:"deleteIcon",backgroundColor:"red",onClick:()=>{var i,s;return(s=(i=this.events).onRemove)==null?void 0:s.call(i)}});return t.position.set(this.outlinePoints[pt.REMOVE].x,this.outlinePoints[pt.REMOVE].y),t}createRotateButton(){const t=new yc(this.appService,{iconAlias:"rotateIcon",backgroundColor:this.config.iconWrapperFillColor,getTargetPoints:()=>this.zonePoints,onRotationStart:i=>{var s,n;this.initializeRotationCache(i),(n=(s=this.events).onRotateStart)==null||n.call(s,i)},onClick:()=>{var n,o;const i=Math.PI/2,s=this.onClickRotateButton(i);(o=(n=this.events).onRotateMove)==null||o.call(n,s??void 0)},onRotationEnd:()=>{var i,s;this.resetRotationState(),(s=(i=this.events).onRotateEnd)==null||s.call(i)}});return t.position.set(this.outlinePoints[pt.ROTATE].x,this.outlinePoints[pt.ROTATE].y),t}onClickRotateButton(t){const i=this.handleInternalRotationMove(t)??[];return this.resetRotationState(),i}createScaleButton(){const t=new Qe(this.appService,{iconAlias:"scaleIcon",backgroundColor:this.config.iconWrapperFillColor,initialButtonPosition:this.outlinePoints[pt.SCALE],onScaleStart:()=>{var i,s;this.initializeScaleCache(),(s=(i=this.events).onScaleStart)==null||s.call(i)},onScaleMove:({deltaX:i,deltaY:s})=>{var o,a;const n=this.handleInternalScaleMove(i,s);(a=(o=this.events).onScaleMove)==null||a.call(o,n??void 0)},onScaleEnd:()=>{var i,s;this.resetScaleState(),this.initialZonePoints=[],(s=(i=this.events).onScaleEnd)==null||s.call(i)}});return t.position.set(this.outlinePoints[pt.SCALE].x,this.outlinePoints[pt.SCALE].y),t}createHorizontalScaleButton(){const[,t,i]=this.outlinePoints,s=this.getEdgeCenter(t,i),n=new Qe(this.appService,{iconAlias:"horizontalScaleIcon",backgroundColor:this.config.iconWrapperFillColor,config:{iconWrapperWidth:18,iconWrapperHeight:18,iconWrapperBorderRadius:18,iconWidth:10,iconHeight:8},initialButtonPosition:s,onScaleStart:()=>{var h,l;const[,o,a]=this.zonePoints;this.horizontalScaleInitialPosition=this.getEdgeCenter(o,a),this.initializeScaleCache(),(l=(h=this.events).onScaleStart)==null||l.call(h)},onScaleMove:({deltaX:o,deltaY:a})=>{var l,c;const h=this.handleInternalHorizontalScaleMove(o,a);(c=(l=this.events).onScaleMoveHorizontal)==null||c.call(l,h??void 0)},onScaleEnd:()=>{var o,a;this.resetScaleState(),this.initialZonePoints=[],this.horizontalScaleInitialPosition=null,(a=(o=this.events).onScaleEnd)==null||a.call(o)}});return n.position.set(s.x,s.y),n}createVerticalScaleButton(){const[,,t,i]=this.outlinePoints,s=this.getEdgeCenter(t,i),n=new Qe(this.appService,{iconAlias:"verticalScaleIcon",backgroundColor:this.config.iconWrapperFillColor,config:{iconWrapperWidth:18,iconWrapperHeight:18,iconWrapperBorderRadius:18,iconWidth:8,iconHeight:10},initialButtonPosition:s,onScaleStart:()=>{var h,l;const[,,o,a]=this.zonePoints;this.verticalScaleInitialPosition=this.getEdgeCenter(o,a),this.initializeScaleCache(),(l=(h=this.events).onScaleStart)==null||l.call(h)},onScaleMove:({deltaX:o,deltaY:a})=>{var l,c;const h=this.handleInternalVerticalScaleMove(o,a);(c=(l=this.events).onScaleMoveVertical)==null||c.call(l,h??void 0)},onScaleEnd:()=>{var o,a;this.resetScaleState(),this.initialZonePoints=[],this.verticalScaleInitialPosition=null,(a=(o=this.events).onScaleEnd)==null||a.call(o)}});return n.position.set(s.x,s.y),n}createMoveButton(){const t=this.calculateMoveButtonPosition(),i=new Ls(this.appService,{iconAlias:"moveIcon",backgroundColor:this.config.iconWrapperFillColor,onMoveStart:()=>{var s,n;return(n=(s=this.events).onMoveStart)==null?void 0:n.call(s)},onMoveMove:s=>{var n,o;return(o=(n=this.events).onMoveMove)==null?void 0:o.call(n,s)},onMoveEnd:()=>{var s,n;return(n=(s=this.events).onMoveEnd)==null?void 0:n.call(s)}});return i.position.set(t.x,t.y),i}createAndAddButton(t,i){return t.visible=i,this.controlButtons.addChild(t),t}createControlButtons(){this.outlinePoints.length<4||(this.deleteButton=this.createAndAddButton(this.createDeleteButton(),this.config.showDeleteButton??!1),this.moveButton=this.createAndAddButton(this.createMoveButton(),this.config.showMoveButton??!1),this.rotateButton=this.createAndAddButton(this.createRotateButton(),this.config.showRotateButton??!1),this.scaleButton=this.createAndAddButton(this.createScaleButton(),this.config.showScaleButton??!1),console.log("this.config.showRadialScaleButton",this.config.showRadialScaleButton),this.horizontalScaleButton=this.createAndAddButton(this.createHorizontalScaleButton(),this.config.showRadialScaleButton??!1),this.verticalScaleButton=this.createAndAddButton(this.createVerticalScaleButton(),this.config.showRadialScaleButton??!1))}calculateOutlinePoints(){const t=this.zonePoints;if(t.length<4)return t;const s=this.appService.getApp().toFixedSize(this.config.outlineOffset);return Fr(t,s)}calculateMoveButtonPosition(){const t=this.calculateOutlinePoints();if(t.length<4)return{x:0,y:0};const s=this.appService.getApp().toFixedSize(this.config.moveButtonOffset),n=t[pt.MOVE],o=t[pt.SCALE],a=t[pt.REMOVE];return Ds(n,o,a,s)}calculateMoveLinePoints(){const t=this.calculateOutlinePoints();if(t.length<4)return[];const i=t[pt.MOVE],s=this.calculateMoveButtonPosition();return[i,s]}calculateSizeText(){const t=this.zonePoints;if(t.length<4)return"0m*0m";const[i,s,,n]=t,o=Q(i,s),a=Q(i,n),h=this.appService,l=h.pixelsToMeters(o),c=h.pixelsToMeters(a),d=h.metersToDisplayUnit(l),u=h.metersToDisplayUnit(c),p=h.runtimeSnapshot.unitLabel;return`${d.toFixed(1)}${p}*${u.toFixed(1)}${p}`}getEdgeCenter(t,i){return{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}calculatePerpendicularOffset(t,i,s,n=!1){const o=gt(K(i,t)),a=n?{x:-o.y,y:o.x}:{x:o.y,y:-o.x};return{x:a.x*s,y:a.y*s}}calculateSizeTextPosition(){if(this.zonePoints.length<4)return{x:0,y:0};const i=this.calculateOutlinePoints(),[s,n,o,a]=i,{textPosition:h,textOffset:l}=this.config,d=this.appService.getApp().toFixedSize(l);let u,p;switch(h){case"top":u=this.getEdgeCenter(s,n),p=this.calculatePerpendicularOffset(n,s,d);break;case"right":u=this.getEdgeCenter(n,o),p=this.calculatePerpendicularOffset(n,o,d);break;case"bottom":u=this.getEdgeCenter(a,o),p=this.calculatePerpendicularOffset(a,o,d,!0);break;case"left":u=this.getEdgeCenter(s,a),p=this.calculatePerpendicularOffset(a,s,d);break;default:u=this.getEdgeCenter(s,n),p={x:0,y:d};break}return{x:u.x+p.x,y:u.y+p.y}}calculateSizeTextRotation(){const t=this.zonePoints;if(t.length<4)return 0;const[i,s,n,o]=t,{textPosition:a}=this.config;let h,l;switch(a){case"top":h=i,l=s;break;case"right":h=s,l=n;break;case"bottom":h=n,l=o;break;case"left":h=o,l=i;break;default:h=i,l=s;break}const c=this.appService.appContainer.getMapRotationRadians();return qe(h,l,c)}calculateHorizontalScaleButtonRotation(){const t=this.zonePoints;if(t.length<4)return 0;const[,i,s]=t,n=this.appService.appContainer.getMapRotationRadians();return qe(i,s,n)+Math.PI/2}calculateVerticalScaleButtonRotation(){const t=this.zonePoints;if(t.length<4)return 0;const[,,i,s]=t,n=this.appService.appContainer.getMapRotationRadians();return qe(s,i,n)}updatePoints(t,i=!0){this.zonePoints=t,this.updateOutlineBorder(),this.moveLine&&this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeText(i)}updateOutlineBorder(){const t=this.calculateOutlinePoints();this.outlinePoints=t,this.outlineBorder.updatePoints(t)}updateMoveLine(){if(!this.moveLine)return;const t=this.calculateMoveLinePoints();this.moveLine.updatePoints(t)}updateSizeText(t=!0){if(this.sizeText){if(t){const i=this.calculateSizeText();this.sizeText.updateText(i)}this.updateSizeTextPosition()}}updateSizeTextPosition(){if(!this.sizeText)return;const t=this.calculateSizeTextPosition();this.sizeText.position.set(t.x,t.y);const i=this.calculateSizeTextRotation();this.sizeText.rotation=i}updateControlButtonsPosition(){if(!this.deleteButton||!this.scaleButton||!this.moveButton)return;const t=this.calculateOutlinePoints();if(t.length<4)return;const i=this.calculateMoveButtonPosition(),s=[{button:this.deleteButton,point:t[pt.REMOVE]},{button:this.scaleButton,point:t[pt.SCALE]},{button:this.moveButton,point:i}];if(this.rotateButton&&s.push({button:this.rotateButton,point:t[pt.ROTATE]}),this.horizontalScaleButton){const n=t[pt.ROTATE],o=t[pt.SCALE],a=ic(n,o,0);s.push({button:this.horizontalScaleButton,point:a})}if(this.verticalScaleButton){const n=t[pt.SCALE],o=t[pt.MOVE],a=this.getEdgeCenter(n,o);s.push({button:this.verticalScaleButton,point:a})}s.forEach(({button:n,point:o})=>n.position.set(o.x,o.y)),this.horizontalScaleButton&&(this.horizontalScaleButton.rotation=this.calculateHorizontalScaleButtonRotation()),this.verticalScaleButton&&(this.verticalScaleButton.rotation=this.calculateVerticalScaleButtonRotation()),this.scaleButton&&this.scaleButton.visible&&(this.scaleButton.rotation=this.calculateVerticalScaleButtonRotation())}setupClickHandler(){this.clickHandler=new vt(this,{onClick:()=>{var t,i;(i=(t=this.events).onClick)==null||i.call(t)},stopPropagation:!1})}registerScaleListener(){this.appService.emitter.on("antiScale",this.throttledUpdateOutline),this.appService.emitter.on("mapRotationUpdate",this.throttledUpdateOutline)}updateOutlineForScale(){(this.outlineBorder.visible||this.controlButtons.visible)&&(this.updateOutlineBorder(),this.moveLine&&this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition())}initializeScaleCache(){if(this.initialZonePoints.length===0&&(this.initialZonePoints=this.zonePoints.map(p=>({...p}))),this.initialZonePoints.length<4)return;const t={...this.initialZonePoints[pt.SCALE]};if(!t)return;const i=pt.REMOVE,{x:s,y:n}=this.initialZonePoints[i],[,o,,a]=this.initialZonePoints,h={x:s,y:n},l=K(h,o),c=K(h,a),d=ee(l),u=ee(c);d===0||u===0||(this.scaleCache={fixedPoint:h,edge1:l,edge2:c,edge1Len:d,edge2Len:u,initialButtonPosition:t})}handleInternalScaleMove(t,i){if(this.initialZonePoints.length!==4||!this.scaleCache)return null;const s=this.appService.metersToPixels(this.minSize),n=this.maxSize!=null?this.appService.metersToPixels(this.maxSize):void 0,{fixedPoint:o,edge1:a,edge2:h,edge1Len:l,edge2Len:c,initialButtonPosition:d}=this.scaleCache,u={x:d.x+t,y:d.y+i},p=K(o,u),f=ae(p,a,l,s,n),y=ae(p,h,c,s,n);return this.calculatePointsFromScale(o,a,h,f,y)}resetScaleState(){this.scaleCache=null}handleInternalHorizontalScaleMove(t,i){if(this.initialZonePoints.length!==4||!this.scaleCache||!this.horizontalScaleInitialPosition)return null;const{fixedPoint:s,edge1:n,edge2:o,edge1Len:a}=this.scaleCache,h=this.appService.metersToPixels(this.minSize),l=this.maxSize!=null?this.appService.metersToPixels(this.maxSize):void 0,c={x:this.horizontalScaleInitialPosition.x+t,y:this.horizontalScaleInitialPosition.y+i},d=K(s,c),u=ae(d,n,a,h,l);return this.calculatePointsFromScale(s,n,o,u,1)}handleInternalVerticalScaleMove(t,i){if(this.initialZonePoints.length!==4||!this.scaleCache||!this.verticalScaleInitialPosition)return null;const{fixedPoint:s,edge1:n,edge2:o,edge2Len:a}=this.scaleCache,h=this.appService.metersToPixels(this.minSize),l=this.maxSize!=null?this.appService.metersToPixels(this.maxSize):void 0,c={x:this.verticalScaleInitialPosition.x+t,y:this.verticalScaleInitialPosition.y+i},d=K(s,c),u=1,p=ae(d,o,a,h,l);return this.calculatePointsFromScale(s,n,o,u,p)}calculatePointsFromScale(t,i,s,n,o){const{x:a,y:h}=t;return[t,{x:a+i.x*n,y:h+i.y*n},{x:a+i.x*n+s.x*o,y:h+i.y*n+s.y*o},{x:a+s.x*o,y:h+s.y*o}]}initializeRotationCache(t){this.zonePoints.length<3||(this.rotationCache={rotationCenter:t,initialPoints:this.zonePoints.map(i=>({...i})),totalAngle:0})}handleInternalRotationMove(t){if(!this.rotationCache||this.rotationCache.initialPoints.length<3)return null;const{rotationCenter:i,initialPoints:s}=this.rotationCache;return this.rotationCache.totalAngle+=t,Dr(s,i,this.rotationCache.totalAngle)}resetRotationState(){this.rotationCache=null}calculateRotationCenter(){return this.zonePoints.length===0?{x:0,y:0}:de(this.zonePoints)}updateEditState({showRotateButton:t=!1,showScaleButton:i=!1,showRadialScaleButton:s=!1,showDeleteButton:n=!1,showMoveButton:o=!1,showBorder:a=!1,showSizeText:h=!1,borderStyle:l}){this.rotateButton&&(this.rotateButton.visible=t),this.scaleButton&&(this.scaleButton.visible=i),this.horizontalScaleButton&&(this.horizontalScaleButton.visible=s),this.verticalScaleButton&&(this.verticalScaleButton.visible=s),this.deleteButton&&(this.deleteButton.visible=n),this.moveButton&&(this.moveButton.visible=o);const c=t||i||s||n||o;this.controlButtons.visible=c,!c&&this.getOperationState().hasAnyOperation&&this.stopAllOperations(),this.outlineBorder.visible=a,this.moveLine&&(this.moveLine.visible=o),this.sizeText&&(this.sizeText.visible=h),a&&(this.updateOutlineBorder(),c&&(this.moveLine&&o&&this.updateMoveLine(),this.updateControlButtonsPosition()),h&&this.updateSizeTextPosition()),l&&this.outlineBorder.updateStyle({isDashed:l.isDashed,dashArray:l.dashArray})}getOperationState(){var n,o,a;const t=((n=this.scaleButton)==null?void 0:n.isCurrentlyScaling())||!1,i=((o=this.rotateButton)==null?void 0:o.isCurrentlyRotating())||!1,s=((a=this.moveButton)==null?void 0:a.isCurrentlyMoving())||!1;return{isDragging:!1,isScaling:t,isRotating:i,isMoving:s,hasAnyOperation:t||i||s}}stopAllOperations(){var t,i,s;(t=this.scaleButton)==null||t.stopScaling(),(i=this.rotateButton)==null||i.stopRotation(),(s=this.moveButton)==null||s.stopMoving()}getControlButtonsContainer(){return this.controlButtons}getMoveButton(){return this.moveButton}calculateEdgeMidpoint(t,i){const s=this.calculateOutlinePoints();if(s.length<4)return{x:0,y:0};const n=s[t],o=s[i];return{x:(n.x+o.x)/2,y:(n.y+o.y)/2}}destroy(){var t,i,s,n,o,a,h,l,c,d,u;this.appService.emitter.off("antiScale",this.throttledUpdateOutline),this.appService.emitter.off("mapRotationUpdate",this.throttledUpdateOutline),(t=this.clickHandler)==null||t.destroy(),this.clickHandler=null,(i=this.deleteButton)==null||i.destroy(),(s=this.rotateButton)==null||s.destroy(),(n=this.scaleButton)==null||n.destroy(),(o=this.moveButton)==null||o.destroy(),(a=this.horizontalScaleButton)==null||a.destroy(),(h=this.verticalScaleButton)==null||h.destroy(),this.deleteButton=null,this.rotateButton=null,this.scaleButton=null,this.moveButton=null,this.horizontalScaleButton=null,this.verticalScaleButton=null,(l=this.outlineBorder)==null||l.destroy(),(c=this.moveLine)==null||c.destroy(),(d=this.sizeText)==null||d.destroy(),(u=this.controlButtons)==null||u.destroy(),super.destroy()}}class qS{constructor(e){g(this,"editControlLayers",new Map);this.appService=e}registerEditControl(e,t){const i=this.appService;this.editControlLayers.has(e)&&this.unregisterEditControl(e);const s=new ZS(i,t);if(!i.appContainer.addToLayer(ke,s))throw w.warn(`[EditControlManager] Failed to add edit control layer for id: ${e}`),s.destroy(),new Error(`Failed to register edit control for id: ${e}`);if(this.editControlLayers.set(e,s),t.contentLayer){const o=i.appContainer.getLayer(ke),a=i.appContainer.getLayer(t.contentLayer);o&&a&&(o.position.x!==a.position.x||o.position.y!==a.position.y)&&w.warn(`[EditControlManager] Edit layer position does not match content layer "${t.contentLayer}" position — edit controls will appear misaligned. Ensure "${t.contentLayer}" is in ORIGIN_TRACKED_LAYERS.`,{edit:o.position,content:a.position})}return s}unregisterEditControl(e){const t=this.editControlLayers.get(e);if(!t)return;this.appService.appContainer.removeFromLayer(ke,t),t.destroy(),this.editControlLayers.delete(e)}getEditControl(e){return this.editControlLayers.get(e)}updateEditState(e,t){const i=this.editControlLayers.get(e);i&&i.updateEditState(t)}clearAll(){Array.from(this.editControlLayers.keys()).forEach(t=>this.unregisterEditControl(t))}getAllEditControls(){return Array.from(this.editControlLayers.values())}hasEditControl(e){return this.editControlLayers.has(e)}}function ds(r){return r.charAt(0).toUpperCase()+r.slice(1)}class Xr extends tl{constructor(t=ja){super();g(this,"mapState",null);g(this,"components",{});g(this,"managers",{});g(this,"config",Na);g(this,"runtime");g(this,"appService");g(this,"scaleMin",.5);g(this,"scaleMax",5);g(this,"events",{});g(this,"instanceKey");g(this,"containerElement");g(this,"emitter",Ox());g(this,"tickerState",{renderReasons:new Set,renderTimer:null});g(this,"pendingAsyncRender",!1);g(this,"isFirstMapDraw",!0);g(this,"isMapDrawn",!1);g(this,"onVisibilityChange",()=>{var i;document.visibilityState==="visible"||(i=this.components.interaction)==null||i.clearTouches()});this.instanceKey=t,this.appService=new rc(this),globalThis.__PIXI_APP__=this}async initialize(t){const{resizeTo:i,events:s,config:n,runtime:o={},...a}=t;this.config=rr(Ra({},Na,n??{},(f,y)=>{if(Array.isArray(y))return y})),this.validateCustomZoneTypes(this.config),ay(()=>this.config.global.enableLogger),w.log("Applying config",this.config,n),this.runtime=rr(Object.assign({},Lx,o));const h=this.instanceKey===ja;this.containerElement=i;const l=h&&this.config.interaction.enable,c=this.config.global.performanceMode||!h,d={gcActive:!1,autoStart:!1,sharedTicker:c,eventFeatures:{move:l,globalMove:!1,click:l,wheel:l}},u={resizeTo:h?i:void 0,resolution:this.config.global.resolution,antialias:c?!1:US(),depth:!c,autoDensity:!0,backgroundColor:0,backgroundAlpha:0,...d,...a},p=this.config.global.rendererPreference;if(p==="webgpu")try{await this.init({...u,preference:"webgpu"})}catch(f){w.warn("[Pixi] WebGPU initialization failed, falling back to WebGL:",f),await this.init({...u,preference:"webgl"})}else await this.init({...u,preference:p});w.log(`[Pixi] Renderer initialized: ${this.renderer.type===Fi.WEBGPU?"WebGPU":"WebGL"} ${this.renderer.type}`),this.preloadAssets(),this.scaleMax=this.config.interaction.zoomRange.max,this.scaleMin=this.config.interaction.zoomRange.min,this.events=s,this.initializeViewportContainer(),this.initializeInteraction(),this.initializeAppContainer(),this.managers.mapManager=new qx(this.appService),this.managers.heatmapManager=new iS(this.appService),this.managers.pathManager=new tS(this.appService),this.managers.controlsManager=new oS(this.appService),this.managers.detectedObjectManager=new hS(this.appService),this.managers.customElementsManager=new DS(this.appService),this.managers.roomsManager=new GS(this.appService),this.managers.customCarpetManager=new NS(this.appService),this.managers.furnitureManager=new XS(this.appService),this.managers.editControlManager=new qS(this.appService),this.setupMapRotationListener(),document.addEventListener("visibilitychange",this.onVisibilityChange)}async drawMap(t){var a,h,l,c,d,u,p;this.isMapDrawn=!1,w.log("[Map] drawMap",t);const{size:i,resolution:s,origin:n,id:o}=t;((a=this.mapState)==null?void 0:a.id)!==void 0&&this.mapState.id!==o&&this.managers.pathManager.clear(),(n[0]!==((h=this.mapState)==null?void 0:h.origin.x)||n[1]!==((l=this.mapState)==null?void 0:l.origin.y))&&(this.appService.appContainer.updateOriginTrackedLayers(...n),this.managers.pathManager.updatePositionByOrigin(...n),this.managers.heatmapManager.updatePositionByOrigin(...n)),this.mapState={id:t.id,status:t.status===1,origin:{x:n[0],y:n[1]},charger:{x:t.charger.coordinate[0],y:t.charger.coordinate[1]},chargerDirection:t.charger.angle??0,resolution:s,width:i[0],height:i[1],mapType:"structured"},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,(d=(c=this.events)==null?void 0:c.onMapFirstDrawed)==null||d.call(c,this.mapState)),(p=(u=this.events)==null?void 0:u.onMapDrawed)==null||p.call(u,this.mapState),await this.managers.mapManager.drawMap(t),i[0]===0||i[1]===0?(w.log("[Map] Map cleared, clearing path and room data"),this.managers.pathManager.clear(),this.managers.roomsManager.clear(),this.isMapDrawn=!1):(this.isMapDrawn=!0,this.managers.heatmapManager.onMapLoaded()),this.renderOnce()}async drawRasterMap(t){var a,h,l,c,d,u;this.isMapDrawn=!1,w.log("[Map] drawRasterMap",t);const{mapHeader:i,mapData:s}=t,{originX:n,originY:o}=i;(n!==((a=this.mapState)==null?void 0:a.origin.x)||o!==((h=this.mapState)==null?void 0:h.origin.y))&&(this.appService.appContainer.updateOriginTrackedLayers(n,o),this.managers.pathManager.updatePositionByOrigin(n,o),this.managers.heatmapManager.updatePositionByOrigin(n,o)),this.mapState={id:i.id,status:i.mapStable,origin:{x:n,y:o},charger:{x:i.chargeX,y:i.chargeY},chargerDirection:i.chargeDirection??0,resolution:i.mapResolution*100,width:i.mapWidth,height:i.mapHeight,version:i.version,mapType:"raster"},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,(c=(l=this.events)==null?void 0:l.onMapFirstDrawed)==null||c.call(l,this.mapState)),(u=(d=this.events)==null?void 0:d.onMapDrawed)==null||u.call(d,this.mapState),await this.managers.mapManager.drawRasterMap(s.parsed,this.mapState),i.mapWidth===0||i.mapHeight===0?(w.log("[Map] Map cleared, clearing path and room data"),this.managers.pathManager.clear(),this.managers.roomsManager.clear(),this.isMapDrawn=!1):(this.isMapDrawn=!0,this.managers.heatmapManager.onMapLoaded()),this.renderOnce()}drawPath(t){var i,s;w.log("[Path] drawPath",t),(s=(i=this.events)==null?void 0:i.onPathDrawed)==null||s.call(i,{id:t.pathHeader.pathId,type:t.pathHeader.type,direction:t.pathHeader.direction,count:t.pathHeader.count,initFlag:t.pathHeader.initFlag,robotPosition:t.pathPoints[t.pathPoints.length-1]??null}),this.managers.pathManager.draw(t),this.renderOnce()}async drawRoomProperty(t){var i,s;w.log("[Room] drawRoomProperty",t),(s=(i=this.events)==null?void 0:i.onRoomPropertiesDrawed)==null||s.call(i,t),await this.managers.roomsManager.drawRoomProperty(t),this.renderOnceNextFrame()}async drawCustomCarpets(t){w.log("[CustomCarpets] drawCustomCarpets",t),await this.managers.customCarpetManager.drawCustomCarpets(t),this.renderOnceNextFrame()}async drawFurnitures(t){w.log("[Furniture] drawFurnitures",t),await this.managers.furnitureManager.drawFurnitures(t),this.renderOnceNextFrame()}drawHeatmap(t){w.log("[Heatmap] drawHeatmap",t),this.managers.heatmapManager.draw(t),this.renderOnce()}drawForbiddenSweepZones(t){w.log("[Controls] drawForbiddenSweepZones",t),this.managers.controlsManager.drawForbiddenSweepZones(t),this.renderOnceNextFrame()}drawForbiddenMopZones(t){w.log("[Controls] drawForbiddenMopZones",t),this.managers.controlsManager.drawForbiddenMopZones(t),this.renderOnceNextFrame()}drawCleanZones(t){w.log("[Controls] drawCleanZones",t),this.managers.controlsManager.drawCleanZones(t),this.renderOnceNextFrame()}drawCustomZones(t,i){if(Ne(t)){w.warn(`[MapApplication] drawCustomZones: '${t}' is a built-in type; use draw${ds(t)}s() instead`);return}w.log("[Controls] drawCustomZones",t,i),this.managers.controlsManager.drawCustomZones(t,i),this.renderOnceNextFrame()}getCustomZones(t){return Ne(t)?(w.warn(`[MapApplication] getCustomZones: '${t}' is a built-in type; use get${ds(t)}s() instead`),[]):this.managers.controlsManager.getCustomZones(t)}clearCustomZones(t){if(Ne(t)){w.warn(`[MapApplication] clearCustomZones: '${t}' is a built-in type; use clearAll${ds(t)}s() instead`);return}w.log("[Controls] clearCustomZones",t),this.managers.controlsManager.clearCustomZones(t),this.renderOnceNextFrame()}setEditingCustomZones(t,i){if(Ne(t)){w.warn(`[MapApplication] setEditingCustomZones: '${t}' is a built-in type; use runtime.editing${ds(t)}Ids instead`);return}this.runtime.editingCustomZoneIds={...this.runtime.editingCustomZoneIds??{},[t]:[...i]}}drawVirtualWalls(t){w.log("[Controls] drawVirtualWalls",t),this.managers.controlsManager.drawVirtualWalls(t),this.renderOnceNextFrame()}drawSpots(t){w.log("[Controls] drawSpots",t),this.managers.controlsManager.drawSpots(t),this.renderOnceNextFrame()}drawWayPoints(t){w.log("[Controls] drawWayPoints",t),this.managers.controlsManager.drawWayPoints(t),this.renderOnceNextFrame()}async drawDetectedObjects(t){w.log("[DetectedObject] drawDetectedObjects",t),await this.managers.detectedObjectManager.drawDetectedObjects(t),this.renderOnceNextFrame()}drawCustomCarpet(t){w.log("[CustomCarpet] drawCustomCarpet",t),this.managers.customCarpetManager.drawCustomCarpets(t),this.renderOnceNextFrame()}async drawCustomElements(t){w.log("[CustomElements] drawCustomElements",t),await this.managers.customElementsManager.drawCustomElements(t),this.renderOnceNextFrame()}getForbiddenSweepZones(){return this.managers.controlsManager.getForbiddenSweepZones()}getForbiddenMopZones(){return this.managers.controlsManager.getForbiddenMopZones()}getCleanZones(){return this.managers.controlsManager.getCleanZones()}getVirtualWalls(){return this.managers.controlsManager.getVirtualWalls()}getSpots(){return this.managers.controlsManager.getSpots()}getWayPoints(){return this.managers.controlsManager.getWayPoints()}getEffectiveDividerPoints(){return this.managers.controlsManager.getEffectiveDividerPoints()}getCustomCarpets(){return this.managers.customCarpetManager.getCustomCarpets()}getFurnitures(){return this.managers.furnitureManager.getFurnitures()}getDividerEndPoints(){return this.managers.controlsManager.getDividerEndPoints()}resetPanZoom(){this.components.interaction.setPanZoom()}forceEndGesture(){w.log("[Map] forceEndGesture"),this.components.interaction.forceEndGesture()}fitMapToView(t,i=!1){if(!t||t.minX===t.maxX||t.minY===t.maxY)return;const s=this.config.map.autoPaddingVerticalPercent,n=this.config.map.autoPaddingHorizontalPercent,o=this.getViewportBounds(),a=this.components.appContainer.getMapRotationRadians(),h=this.calculateRotatedBounds(t,a),l=h.maxX-h.minX,c=h.maxY-h.minY,d=o.width,u=o.height,p=d*(1-n*2),f=u*(1-s*2),y=p/l,m=f/c,x=Math.min(y,m),S=this.config.interaction.fitMinScale,v=this.config.interaction.fitMaxScale,b=Math.max(S,Math.min(v,x));this.setScaleBounds(this.config.interaction.zoomRange.min,this.config.interaction.zoomRange.max),b<this.scaleMin&&(this.setScaleBounds(b,this.scaleMax),w.debug("[MapApplication] scaleMin lowered for fit:",{configured:this.config.interaction.zoomRange.min,adjusted:b})),b>this.scaleMax&&(this.setScaleBounds(this.scaleMin,b),w.debug("[MapApplication] scaleMax raised for fit:",{configured:this.config.interaction.zoomRange.max,adjusted:b}));const P=t.minX+(t.maxX-t.minX)/2,C=t.minY+(t.maxY-t.minY)/2,A=this.config.map.autoFitOffset||{x:0,y:0},k=d/2+(A.x||0),M=u/2+(A.y||0),T=Math.cos(a),_=Math.sin(a),E=P*T-C*_,B=P*_+C*T,F=k-E*b,Z=M-B*b;w.debug("[MapApplication] fitMapToView calculated:",{rotation:this.components.appContainer.getMapRotation(),originalBounds:t,rotatedBounds:h,finalScale:b,position:{x:F,y:Z}}),this.components.interaction.setPanZoom({targetPosition:{x:F,y:Z},targetScale:{x:b,y:b},setCenter:!0,setScale:!0},i)}setScaleBounds(t,i){this.scaleMin=t,this.scaleMax=i,this.components.interaction.scaleMin=t,this.components.interaction.scaleMax=i}validateCustomZoneTypes(t){const i=["minSize","strokeColor","strokeWidth","fillColor","outlineOffset","outlineStrokeColor","outlineStrokeWidth","outlineDashed","outlineDashArray","outlineFillColor","iconWrapperFillColor","textColor","textPosition","textOffset","showRotateButton","editing","normal"],s=t.customZoneTypes??{},n=Ei.cleanZone;for(const[,o]of Object.entries(s))for(const a of i)o[a]===void 0&&(o[a]=n[a])}calculateRotatedBounds(t,i){if(i===0)return t;const s=(t.minX+t.maxX)/2,n=(t.minY+t.maxY)/2,o=[{x:t.minX-s,y:t.minY-n},{x:t.maxX-s,y:t.minY-n},{x:t.maxX-s,y:t.maxY-n},{x:t.minX-s,y:t.maxY-n}],a=Math.cos(i),h=Math.sin(i),l=o.map(f=>({x:f.x*a-f.y*h,y:f.x*h+f.y*a}));let c=1/0,d=1/0,u=-1/0,p=-1/0;return l.forEach(f=>{c=Math.min(c,f.x),d=Math.min(d,f.y),u=Math.max(u,f.x),p=Math.max(p,f.y)}),{minX:c+s,minY:d+n,maxX:u+s,maxY:p+n}}getViewportBounds(){var t;return((t=this.components.viewportContainer)==null?void 0:t.getViewportBounds())||{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}updateRuntime(t){Object.assign(this.runtime,t),w.log("[runtime] runtime updated",t),this.renderOnceNextFrame()}updateConfig(t){var i;Ra(this.config,t,(s,n)=>{if(Array.isArray(n))return n}),t.customZoneTypes&&this.validateCustomZoneTypes(this.config),(i=this.managers.controlsManager)==null||i.updateRenderOrder(),w.log("[Config] Configuration updated",t),this.renderOnceNextFrame()}metersToPixels(t){var n;if(!((n=this.mapState)!=null&&n.resolution))return w.warn("Map resolution not available, using default resolution (5cm/pixel)"),t*20;const s=1/(this.mapState.resolution/100);return t*s}pixelsToMeters(t){var s;if(!((s=this.mapState)!=null&&s.resolution))return w.warn("Map resolution not available, using default resolution (5cm/pixel)"),t*.05;const i=this.mapState.resolution/100;return t*i}toFixedSize(t,i){const s=i??this.components.appContainer.scale.x;return t/s}fromFixedSize(t,i){const s=i??this.components.appContainer.scale.x;return t*s}getViewportCenterPoint(){if(!this.mapState)return w.warn("Map state not available, cannot calculate center point"),null;const t=this.getViewportBounds(),i=t.x+t.width/2,s=t.y+t.height/2,n=this.components.appContainer,o=n.scale.x,a=n.getMapRotationRadians(),h=i-n.x,l=s-n.y,c=h/o,d=l/o,u=Math.cos(a),p=Math.sin(a),f=c*u+d*p,y=-c*p+d*u,m=f-this.mapState.origin.x,x=y-this.mapState.origin.y;return{x:m,y:x}}getMapCenterPoint(){if(!this.mapState)return w.warn("Map state not available, cannot calculate map center point"),null;const t=this.managers.mapManager.mapBounds;if(t.minX===1/0||t.minY===1/0||t.maxX===-1/0||t.maxY===-1/0)return w.warn("Invalid map bounds, cannot calculate map center point"),null;const i=(t.minX+t.maxX)/2,s=(t.minY+t.maxY)/2,n=i-this.mapState.origin.x,o=s-this.mapState.origin.y;return{x:n,y:o}}getWallPointsByViewportCenter(t){var f;const{width:i=this.config.controls.virtualWall.minWidth,direction:s="horizontal",offsetX:n=0,offsetY:o=0}=t||{},a=this.getViewportCenterPoint()||{x:0,y:0},l=this.metersToPixels(i)/2,c=((f=this.components.appContainer)==null?void 0:f.getMapRotationRadians())||0,d=Math.cos(c),u=Math.sin(c);let p;return s==="horizontal"?p=[{vx:-l+n,vy:o},{vx:l+n,vy:o}]:p=[{vx:n,vy:-l+o},{vx:n,vy:l+o}],p.map(y=>({x:a.x+y.vx*d+y.vy*u,y:a.y-y.vx*u+y.vy*d}))}getForbiddenSweepZonePointsByViewportCenter(t){const i=this.config.controls.forbiddenSweepZone,{size:s=i.minSize,offsetX:n=0,offsetY:o=0}=t||{};return this.generateZonePoints(s,n,o)}getForbiddenMopZonePointsByViewportCenter(t){const i=this.config.controls.forbiddenMopZone,{size:s=i.minSize,offsetX:n=0,offsetY:o=0}=t||{};return this.generateZonePoints(s,n,o)}getCleanZonePointsByViewportCenter(t){const i=this.config.controls.cleanZone,{size:s=i.minSize,offsetX:n=0,offsetY:o=0}=t||{};return this.generateZonePoints(s,n,o)}getSpotPointByViewportCenter(t){const{offsetX:i=0,offsetY:s=0}=t||{},n=this.getViewportCenterPoint()||{x:0,y:0},o=n.x+i,a=n.y+s;return{x:o,y:a}}getFurniturePointsByViewportCenter(t){const{furnitureType:i=1,offsetX:s=0,offsetY:n=0}=t||{},o=this.config.furniture.assets.find(h=>h.type===i),a=this.getViewportCenterPoint()||{x:0,y:0};return this.buildRectPoints({center:a,widthMeters:(o==null?void 0:o.width)??1.8,heightMeters:(o==null?void 0:o.height)??2,applyMapRotation:!0,visualOffsetX:s,visualOffsetY:n})}getRectPointsByCenter(t){const{center:i,width:s,height:n,applyMapRotation:o=!0}=t;return this.buildRectPoints({center:i,widthMeters:s,heightMeters:n,applyMapRotation:o})}areRoomsAdjacent(t){return!t||t.length===0?(w.warn("[Room] No room IDs provided"),!1):this.managers.mapManager.areRoomsAdjacent(t)}isPointInAnyRoom(t){return!t||typeof t.x!="number"||typeof t.y!="number"?(w.warn("[Room] Invalid point provided"),null):this.mapState?this.managers.mapManager.isPointInAnyRoom(t):(w.warn("[Room] Map state not available"),null)}isWallIntersectsAnyRoom(t){return!t||t.length!==2||!t[0]||!t[1]||typeof t[0].x!="number"||typeof t[0].y!="number"||typeof t[1].x!="number"||typeof t[1].y!="number"?(w.warn("[Room] Invalid wall points provided"),!1):this.mapState?this.managers.mapManager.isWallIntersectsAnyRoom(t):(w.warn("[Room] Map state not available"),!1)}isZoneIntersectsAnyRoom(t){return!t||t.length!==4||!t[0]||!t[1]||!t[2]||!t[3]||typeof t[0].x!="number"||typeof t[0].y!="number"||typeof t[1].x!="number"||typeof t[1].y!="number"||typeof t[2].x!="number"||typeof t[2].y!="number"||typeof t[3].x!="number"||typeof t[3].y!="number"?(w.warn("[Room] Invalid zone points provided"),!1):this.mapState?this.managers.mapManager.isZoneIntersectsAnyRoom(t):(w.warn("[Room] Map state not available"),!1)}isNearChargerOrRobot(t,i,s){var h,l;if(!t||t.length<1)return w.warn("[Distance] Invalid points array: must have at least 1 point"),!1;if(t.length!==1&&t.length!==2&&t.length!==4)return w.warn("[Distance] Invalid points array: must have exactly 1 (point), 2 (wall) or 4 (zone) points"),!1;if(i<=0)return w.warn("[Distance] Invalid threshold: must be greater than 0"),!1;if(!this.mapState)return w.warn("[Distance] Map state not available"),!1;const{checkCharger:n=!0,checkRobot:o=!1}=s||{};if(!n&&!o)return w.warn("[Distance] At least one of checkCharger or checkRobot must be true"),!1;const a=this.metersToPixels(i);if(n){const c=this.appService.getChargerPosition();if(c){const d=(h=this.mapState)==null?void 0:h.charger.x,u=(l=this.mapState)==null?void 0:l.charger.y;if(d===0&&u===0)return w.warn("[Distance] Charger position not available"),!1;const p=Fa(c,t);if(p<=a)return w.log(`[Distance] Too close to charger: ${p.toFixed(2)} pixels (threshold: ${a.toFixed(2)} pixels)`),!0}else w.warn("[Distance] Charger position not available")}if(o){const c=this.appService.getRobotPosition();if(c){const d=Fa(c,t);if(d<=a)return w.log(`[Distance] Too close to robot: ${d.toFixed(2)} pixels (threshold: ${a.toFixed(2)} pixels)`),!0}else w.warn("[Distance] Robot position not available")}return!1}async snapshot(t){this.render();const{snapshot:i,global:s}=this.config,n=(t==null?void 0:t.backgroundColor)??s.backgroundColor,o=this.components.appContainer,a=o.getSnapshotBounds(),h=Math.floor(a.x),l=Math.floor(a.y),c=Math.ceil(a.x+a.width)-h,d=Math.ceil(a.y+a.height)-l;if(c<=0||d<=0)return w.error("[MapApplication] Snapshot failed: invalid bounds",a),"";const u=i.resolution||window.devicePixelRatio||2,p=Ir.create({width:c,height:d,resolution:u}),f=new H;f.rect(0,0,c,d).fill(n);const y=new U;y.translate(-h,-l);try{return this.renderer.render({container:f,target:p}),this.renderer.render({container:o,target:p,transform:y,clear:!1}),await this.renderer.extract.base64({target:p,format:i.format,quality:i.quality,antialias:i.antialias})}catch(m){return w.error("[MapApplication] Snapshot failed:",m),""}finally{f.destroy(),p.destroy(!0)}}async snapshotByData({map:t,path:i,roomProperties:s,customElements:n,forbiddenSweepZones:o,forbiddenMopZones:a,virtualWalls:h,detectedObjects:l,furnitures:c},d={},u){const p=`SNAPSHOT_${Gx()}`;w.log(`[MapApplication] ${p} snapshot start`);const f=new Xr(p);try{if(await f.initialize({config:this.config,runtime:d}),!t)throw new Error("Map data is required");if(t.startsWith("7b22")){const m=td(t);await f.drawMap(m)}else{const m=ed(t,{pointsStructured:!0});if(m)await f.drawRasterMap(m);else throw new Error("Failed to decode raster map data")}if(i){const{decodePath:m}=await _e(async()=>{const{decodePath:S}=await import("./theme.DCRyNh1R.js").then(v=>v.i);return{decodePath:S}},__vite__mapDeps([4,2])),x=m(i);f.drawPath(x)}s&&s.length>0&&await f.drawRoomProperty(s),o&&o.length>0&&f.drawForbiddenSweepZones(o),a&&a.length>0&&f.drawForbiddenMopZones(a),h&&h.length>0&&f.drawVirtualWalls(h),c&&c.length>0&&await f.drawFurnitures(c),l&&l.length>0&&await f.drawDetectedObjects(l),n&&n.length>0&&await f.drawCustomElements(n);const y=await f.snapshot(u);return w.log(`[MapApplication] ${p} snapshot completed successfully`),y}catch(y){throw w.error(`[MapApplication] ${p} snapshot other map failed:`,y),y}finally{w.log(`[MapApplication] ${p} destroy`),f.destroy()}}renderOnce(){w.log("[Pixi] renderOnce"),this.render()}renderOnceNextFrame(){this.pendingAsyncRender||(this.pendingAsyncRender=!0,requestAnimationFrame(()=>{w.log("[Pixi] renderOnceNextFrame"),this.render(),this.pendingAsyncRender=!1}))}requestRender(t,i=!1){if(!i){this.renderOnceNextFrame();return}this.tickerState.renderReasons.add(t),this.ticker.started||(w.debug(`🎬 [Ticker] START: ${t}`),this.ticker.start())}stopRender(t){this.tickerState.renderReasons.delete(t),this.tickerState.renderReasons.size===0&&this.scheduleStopRender("final",100)}destroy(){var t;w.log("[MapApplication] destroy"),this.tickerState.renderTimer&&(clearTimeout(this.tickerState.renderTimer),this.tickerState.renderTimer=null),this.tickerState.renderReasons.clear(),this.emitter.all.clear(),document.removeEventListener("visibilitychange",this.onVisibilityChange),this.managers.pathManager.destroy(),this.managers.mapManager.destroy(),this.managers.controlsManager.destroy(),this.managers.furnitureManager.destroy(),this.managers.detectedObjectManager.destroy(),this.managers.customElementsManager.destroy(),this.managers.roomsManager.destroy(),this.components.interaction.destroy(),(t=this.components.background)==null||t.destroy(),this.components.viewportContainer.destroy(),this.components.appContainer.destroy(),this.managers.heatmapManager.destroy(),super.destroy()}initializeViewportContainer(){this.components.viewportContainer=new Ux(this.config,this.containerElement),this.stage.addChild(this.components.viewportContainer);const t=this.getViewportBounds();this.components.background=new HS(this.config.global,t,()=>{this.renderOnceNextFrame()}),this.components.viewportContainer.addChild(this.components.background),this.components.viewportContainer.setChildIndex(this.components.background,0),Fs(this.config.global,()=>{var i;(i=this.components.background)==null||i.update(this.config.global)})}initializeAppContainer(){this.components.appContainer=new jx(this.appService),this.components.interaction.addChild(this.components.appContainer)}initializeInteraction(){this.components.interaction=new zy(this.appService),this.components.viewportContainer.addChild(this.components.interaction)}scheduleStopRender(t,i){this.tickerState.renderTimer&&clearTimeout(this.tickerState.renderTimer),this.tickerState.renderTimer=setTimeout(()=>{this.tickerState.renderReasons.delete(t),this.tickerState.renderReasons.size===0&&(w.debug("⏸️ [Ticker] STOP"),this.ticker&&this.ticker.stop())},i)}generateZonePoints(t,i,s){const n=this.getViewportCenterPoint()||{x:0,y:0};return this.buildRectPoints({center:n,widthMeters:t,heightMeters:t,applyMapRotation:!0,visualOffsetX:i,visualOffsetY:s})}buildRectPoints(t){var y;const{center:i,widthMeters:s,heightMeters:n,applyMapRotation:o,visualOffsetX:a=0,visualOffsetY:h=0}=t,l=this.metersToPixels(s)/2,c=this.metersToPixels(n)/2,d=o&&((y=this.components.appContainer)==null?void 0:y.getMapRotationRadians())||0,u=Math.cos(d),p=Math.sin(d);return[{vx:-l+a,vy:-c+h},{vx:l+a,vy:-c+h},{vx:l+a,vy:c+h},{vx:-l+a,vy:c+h}].map(m=>({x:i.x+m.vx*u+m.vy*p,y:i.y-m.vx*p+m.vy*u}))}preloadAssets(){const t=this.config.robot.icon.src,i=this.config.chargingStation.icon.src,s=[];N.add({alias:"robot",src:t}),s.push("robot"),N.add({alias:"chargingStation",src:i}),s.push("chargingStation"),N.add({alias:"deleteIcon",src:this.config.controls.deleteIconSrc}),s.push("deleteIcon"),N.add({alias:"rotateIcon",src:this.config.controls.rotateIconSrc}),s.push("rotateIcon"),N.add({alias:"scaleIcon",src:this.config.controls.scaleIconSrc}),s.push("scaleIcon"),N.add({alias:"moveIcon",src:this.config.controls.moveIconSrc}),s.push("moveIcon"),N.add({alias:"checkmark",src:this.config.room.selectionIndicator.iconSrc}),s.push("checkmark"),N.add({alias:"spotIcon",src:this.config.controls.spot.iconSrc}),s.push("spotIcon"),N.add({alias:"wayPoint",src:this.config.controls.wayPoint.normal.iconSrc}),s.push("wayPoint"),N.add({alias:"wayPointActive",src:this.config.controls.wayPoint.editing.iconSrc}),s.push("wayPointActive"),N.add({alias:"horizontalScaleIcon",src:this.config.controls.horizontalScaleIconSrc}),s.push("horizontalScaleIcon"),N.add({alias:"verticalScaleIcon",src:this.config.controls.verticalScaleIconSrc}),s.push("verticalScaleIcon"),this.config.room.property.cleanMode.assets.forEach((n,o)=>{const a=`cleanMode_${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.suction.assets.forEach((n,o)=>{const a=`fan_${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.cistern.assets.forEach((n,o)=>{const a=`water_${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.cleanTimes.assets.forEach((n,o)=>{const a=`cleanTimes${o+1}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.floorType.assets.forEach((n,o)=>{if(!n)return;const a=`floorType${o}`;N.add({alias:a,src:n}),s.push(a)}),this.config.room.property.customAssets&&Object.entries(this.config.room.property.customAssets).forEach(([n,o])=>{o.forEach((a,h)=>{const l=`custom_${n}_${h}`;N.add({alias:l,src:a}),s.push(l)})}),this.config.furniture.assets.forEach(n=>{const o=`furniture_${n.type}`;N.add({alias:o,src:n.src}),s.push(o)}),N.backgroundLoad(s)}setupMapRotationListener(){this.applyMapRotation(this.runtime.mapRotation),G(this.runtime,"mapRotation",t=>{this.applyMapRotation(t)})}applyMapRotation(t){const i=(t%360+360)%360;w.log(`[MapApplication] Applying map rotation: ${i}°`),this.components.appContainer.setMapRotation(i);const s=this.managers.mapManager.mapBounds;s&&s.minX!==1/0&&s.maxX!==-1/0&&this.fitMapToView(s,!1),this.emitter.emit("mapRotationUpdate",i),this.renderOnce()}}const s0=Object.freeze(Object.defineProperty({__proto__:null,AppService:rc,MapApplication:Xr},Symbol.toStringTag,{value:"Module"}));export{Uo as $,Pi as A,he as B,se as C,ur as D,Yt as E,gr as F,H as G,qg as H,ii as I,Lf as J,Es as K,Tf as L,U as M,Ot as N,Is as O,tt as P,fr as Q,et as R,Wp as S,W as T,Ie as U,j as V,Zh as W,Fi as X,Vi as Y,zp as Z,ci as _,ti as a,_i as a0,mr as a1,jh as a2,Dt as a3,ni as a4,ll as a5,pf as a6,yf as a7,i0 as a8,dl as a9,Wi as aA,Hp as aB,cl as aC,ff as aD,Sf as aE,Kg as aF,ul as aG,vf as aH,Ug as aI,s0 as aJ,Be as aa,ps as ab,_u as ac,pd as ad,le as ae,si as af,bf as ag,_t as ah,mh as ai,Bt as aj,_s as ak,po as al,jt as am,Rm as an,Nd as ao,go as ap,$s as aq,mo as ar,Yd as as,xh as at,Ir as au,Tr as av,qh as aw,Hi as ax,Qu as ay,Xu as az,Qn as b,rt as c,V as d,ce as e,Jn as f,cs as g,xt as h,X as i,yu as j,ft as k,dm as l,dt as m,hu as n,ru as o,I as p,yt as q,_d as r,Gg as s,xa as t,ku as u,J as v,nt as w,$ as x,L as y,st as z};
|