@ray-js/robot-map-sdk 0.0.3-beta-19 → 0.0.3-beta-20
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/application/MapApplication.js +1 -1
- package/dist/components/Base/Zone.js +1 -1
- package/dist/components/ChargingStation/index.js +1 -1
- package/dist/components/Controls/Divider.js +1 -1
- package/dist/components/Controls/Spot.js +1 -1
- package/dist/components/Controls/VirtualWall.js +1 -1
- package/dist/components/Robot/index.js +1 -1
- package/dist/components/RoomInfo/RoomProperty.js +1 -1
- package/dist/components/RoomInfo/RoomSelectionIndicator.js +1 -1
- package/dist/constant/config.js +1 -1
- package/dist/constant/methods.js +1 -1
- package/dist/index.d.ts +67 -2
- package/dist/index.js +1 -1
- package/dist/index.rjs.js +1 -1
- package/dist/managers/CustomElementsManager.js +1 -1
- package/dist/managers/MapManager.js +1 -1
- package/dist/utils/algorithm.js +1 -1
- package/dist/utils/index.js +1 -1
- package/dist-app/assets/{index-DFAEtWgf.js → index-CMaxpPPD.js} +1 -1
- package/dist-app/index.html +1 -1
- package/dist-docs/404.html +2 -2
- package/dist-docs/assets/{app.C1hdwNGd.js → app.DP1O8BNS.js} +1 -1
- package/dist-docs/assets/chunks/@localSearchIndexroot.BXv7BdiO.js +1 -0
- package/dist-docs/assets/chunks/{VPLocalSearchBox.D7RLqunb.js → VPLocalSearchBox.UpWCcVfL.js} +1 -1
- package/dist-docs/assets/chunks/{theme.Bgk1r3C0.js → theme.uu9-XYwr.js} +2 -2
- package/dist-docs/assets/{guide_getting-started.md.8wgboX-g.js → guide_getting-started.md.u5zOtdU6.js} +1 -1
- package/dist-docs/assets/{reference_config.md.DKXC2aOe.js → reference_config.md.zb-n1yzx.js} +2 -2
- package/dist-docs/assets/{reference_config.md.DKXC2aOe.lean.js → reference_config.md.zb-n1yzx.lean.js} +1 -1
- package/dist-docs/assets/{reference_methods.md.Cw2UFl8i.js → reference_methods.md.D1VYgciC.js} +10 -4
- package/dist-docs/assets/{reference_methods.md.Cw2UFl8i.lean.js → reference_methods.md.D1VYgciC.lean.js} +1 -1
- package/dist-docs/assets/{reference_types.md.CteNuaxc.js → reference_types.md.g_JJ8gNY.js} +74 -15
- package/dist-docs/assets/{reference_types.md.CteNuaxc.lean.js → reference_types.md.g_JJ8gNY.lean.js} +1 -1
- package/dist-docs/assets/{reference_utils.md.DU5CMWXW.js → reference_utils.md.C5spobZN.js} +6 -2
- package/dist-docs/assets/reference_utils.md.C5spobZN.lean.js +1 -0
- package/dist-docs/guide/advanced-usage.html +3 -3
- package/dist-docs/guide/concepts.html +3 -3
- package/dist-docs/guide/getting-started.html +5 -5
- package/dist-docs/hashmap.json +1 -1
- package/dist-docs/index.html +3 -3
- package/dist-docs/reference/callbacks.html +3 -3
- package/dist-docs/reference/config.html +5 -5
- package/dist-docs/reference/data.html +3 -3
- package/dist-docs/reference/methods.html +13 -7
- package/dist-docs/reference/runtime.html +3 -3
- package/dist-docs/reference/types.html +77 -18
- package/dist-docs/reference/utils.html +9 -5
- package/package.json +1 -1
- package/dist-docs/assets/chunks/@localSearchIndexroot.BNXBBbhn.js +0 -1
- package/dist-docs/assets/reference_utils.md.DU5CMWXW.lean.js +0 -1
- /package/dist-docs/assets/{guide_getting-started.md.8wgboX-g.lean.js → guide_getting-started.md.u5zOtdU6.lean.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__reflectGet=Reflect.get,__pow=Math.pow,__defNormalProp=(t,e,i)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,__spreadValues=(t,e)=>{for(var i in e||(e={}))__hasOwnProp.call(e,i)&&__defNormalProp(t,i,e[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(e))__propIsEnum.call(e,i)&&__defNormalProp(t,i,e[i]);return t},__spreadProps=(t,e)=>__defProps(t,__getOwnPropDescs(e)),__objRest=(t,e)=>{var i={};for(var n in t)__hasOwnProp.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))e.indexOf(n)<0&&__propIsEnum.call(t,n)&&(i[n]=t[n]);return i},__publicField=(t,e,i)=>__defNormalProp(t,"symbol"!=typeof e?e+"":e,i),__superGet=(t,e,i)=>__reflectGet(__getProtoOf(t),i,e),__async=(t,e,i)=>new Promise((n,r)=>{var s=t=>{try{a(i.next(t))}catch(e){r(e)}},o=t=>{try{a(i.throw(t))}catch(e){r(e)}},a=t=>t.done?n(t.value):Promise.resolve(t.value).then(s,o);a((i=i.apply(t,e)).next())});!function(){"use strict";var t,e,i,n=document.createElement("style");n.textContent="/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}:root{--debug-tools-button-height: 20px;--debug-tools-button-width: 82px;--debug-tools-button-font-size: 7px}.debug-tools{position:fixed;bottom:8px;left:8px;display:flex;flex-direction:column-reverse;gap:4px;z-index:999;pointer-events:none}.debug-tools .debug-toggle{width:var(--debug-tools-button-width);height:var(--debug-tools-button-height);background:#4a90e2;border:1px solid #357abd;border-radius:0;font-family:Arial,sans-serif;font-size:var(--debug-tools-button-font-size);color:#fff;cursor:pointer;pointer-events:auto;user-select:none;-webkit-user-select:none;display:flex;align-items:center;justify-content:center;box-sizing:border-box;font-weight:700}.debug-tools .debug-toggle:hover{background:#357abd}.debug-tools .debug-toggle:active{background:#2968a3}.debug-tools .debug-toggle.expanded{background:#e74c3c;border-color:#c0392b}.debug-tools .debug-toggle.expanded:hover{background:#c0392b}.debug-tools .debug-buttons-container{flex-direction:column-reverse;gap:4px}.debug-tools .debug-button{height:var(--debug-tools-button-height);background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:0;font-size:var(--debug-tools-button-font-size);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,PingFang SC,Hiragino Sans GB,Microsoft YaHei,sans-serif;color:#000000e6;cursor:pointer;pointer-events:auto;user-select:none;-webkit-user-select:none;display:flex;align-items:center;justify-content:center;box-sizing:border-box}*{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}body{overflow:hidden}#container{position:fixed;top:0;left:0;height:100%;width:100%}canvas{touch-action:none;-webkit-touch-callout:none;user-select:none;-webkit-user-select:none}\n/*$vite$:1*/",document.head.appendChild(n);var r="undefined"!=typeof document?document.currentScript:null;const s=function(t,e,i){let n=Promise.resolve();function r(t){const e=new Event("vite:preloadError",{cancelable:!0});if(e.payload=t,window.dispatchEvent(e),!e.defaultPrevented)throw t}return n.then(e=>{for(const t of e||[])"rejected"===t.status&&r(t.reason);return t().catch(r)})};var o=(t=>(t.Application="application",t.WebGLPipes="webgl-pipes",t.WebGLPipesAdaptor="webgl-pipes-adaptor",t.WebGLSystem="webgl-system",t.WebGPUPipes="webgpu-pipes",t.WebGPUPipesAdaptor="webgpu-pipes-adaptor",t.WebGPUSystem="webgpu-system",t.CanvasSystem="canvas-system",t.CanvasPipesAdaptor="canvas-pipes-adaptor",t.CanvasPipes="canvas-pipes",t.Asset="asset",t.LoadParser="load-parser",t.ResolveParser="resolve-parser",t.CacheParser="cache-parser",t.DetectionParser="detection-parser",t.MaskEffect="mask-effect",t.BlendMode="blend-mode",t.TextureSource="texture-source",t.Environment="environment",t.ShapeBuilder="shape-builder",t.Batcher="batcher",t))(o||{});const a=t=>{if("function"==typeof t||"object"==typeof t&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");const e="object"!=typeof t.extension?{type:t.extension}:t.extension;t=__spreadProps(__spreadValues({},e),{ref:t})}if("object"!=typeof t)throw new Error("Invalid extension type");return"string"==typeof(t=__spreadValues({},t)).type&&(t.type=[t.type]),t},l=(t,e)=>{var i;return null!=(i=a(t).priority)?i:e},h={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(a).forEach(t=>{t.type.forEach(e=>{var i,n;return null==(n=(i=this._removeHandlers)[e])?void 0:n.call(i,t)})}),this},add(...t){return t.map(a).forEach(t=>{t.type.forEach(e=>{var i,n;const r=this._addHandlers,s=this._queue;r[e]?null==(n=r[e])||n.call(r,t):(s[e]=s[e]||[],null==(i=s[e])||i.push(t))})}),this},handle(t,e,i){var n;const r=this._addHandlers,s=this._removeHandlers;if(r[t]||s[t])throw new Error(`Extension type ${t} already has a handler`);r[t]=e,s[t]=i;const o=this._queue;return o[t]&&(null==(n=o[t])||n.forEach(t=>e(t)),delete o[t]),this},handleByMap(t,e){return this.handle(t,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByNamedList(t,e,i=-1){return this.handle(t,t=>{e.findIndex(e=>e.name===t.name)>=0||(e.push({name:t.name,value:t.ref}),e.sort((t,e)=>l(e.value,i)-l(t.value,i)))},t=>{const i=e.findIndex(e=>e.name===t.name);-1!==i&&e.splice(i,1)})},handleByList(t,e,i=-1){return this.handle(t,t=>{e.includes(t.ref)||(e.push(t.ref),e.sort((t,e)=>l(e,i)-l(t,i)))},t=>{const i=e.indexOf(t.ref);-1!==i&&e.splice(i,1)})},mixin(t,...e){for(const i of e)Object.defineProperties(t.prototype,Object.getOwnPropertyDescriptors(i))}},c={extension:{type:o.Environment,name:"browser",priority:-1},test:()=>!0,load:()=>__async(null,null,function*(){yield s(()=>Promise.resolve().then(()=>Mx),0,r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("assets/index-DFAEtWgf.js",document.baseURI).href)})},u={extension:{type:o.Environment,name:"webworker",priority:0},test:()=>"undefined"!=typeof self&&void 0!==self.WorkerGlobalScope,load:()=>__async(null,null,function*(){yield s(()=>Promise.resolve().then(()=>Ex),0,r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("assets/index-DFAEtWgf.js",document.baseURI).href)})};class d{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new d(null!=t?t:this._observer,this._x,this._y)}set(t=0,e=t){return this._x===t&&this._y===e||(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return this._x===t.x&&this._y===t.y||(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var f,g={exports:{}};var m=(f||(f=1,function(t){var e=Object.prototype.hasOwnProperty,i="~";function n(){}function r(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function s(t,e,n,s,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new r(n,s||t,o),l=i?i+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],a]:t._events[l].push(a):(t._events[l]=a,t._eventsCount++),t}function o(t,e){0===--t._eventsCount?t._events=new n:delete t._events[e]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),a.prototype.eventNames=function(){var t,n,r=[];if(0===this._eventsCount)return r;for(n in t=this._events)e.call(t,n)&&r.push(i?n.slice(1):n);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},a.prototype.listeners=function(t){var e=i?i+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,s=n.length,o=new Array(s);r<s;r++)o[r]=n[r].fn;return o},a.prototype.listenerCount=function(t){var e=i?i+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,r,s,o){var a=i?i+t:t;if(!this._events[a])return!1;var l,h,c=this._events[a],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,n),!0;case 4:return c.fn.call(c.context,e,n,r),!0;case 5:return c.fn.call(c.context,e,n,r,s),!0;case 6:return c.fn.call(c.context,e,n,r,s,o),!0}for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];c.fn.apply(c.context,l)}else{var d,p=c.length;for(h=0;h<p;h++)switch(c[h].once&&this.removeListener(t,c[h].fn,void 0,!0),u){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,e);break;case 3:c[h].fn.call(c[h].context,e,n);break;case 4:c[h].fn.call(c[h].context,e,n,r);break;default:if(!l)for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c[h].fn.apply(c[h].context,l)}}return!0},a.prototype.on=function(t,e,i){return s(this,t,e,i,!1)},a.prototype.once=function(t,e,i){return s(this,t,e,i,!0)},a.prototype.removeListener=function(t,e,n,r){var s=i?i+t:t;if(!this._events[s])return this;if(!e)return o(this,s),this;var a=this._events[s];if(a.fn)a.fn!==e||r&&!a.once||n&&a.context!==n||o(this,s);else{for(var l=0,h=[],c=a.length;l<c;l++)(a[l].fn!==e||r&&!a[l].once||n&&a[l].context!==n)&&h.push(a[l]);h.length?this._events[s]=1===h.length?h[0]:h:o(this,s)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&o(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=i,a.EventEmitter=a,t.exports=a}(g)),g.exports);const _=p(m),y=2*Math.PI,x=180/Math.PI,b=Math.PI/180;class v{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new v(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return w.x=0,w.y=0,w}}const w=new v;class S{constructor(t=1,e=0,i=0,n=1,r=0,s=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,n,r,s){return this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new v;const i=t.x,n=t.y;return e.x=this.a*i+this.c*n+this.tx,e.y=this.b*i+this.d*n+this.ty,e}applyInverse(t,e){e=e||new v;const i=this.a,n=this.b,r=this.c,s=this.d,o=this.tx,a=this.ty,l=1/(i*s+r*-n),h=t.x,c=t.y;return e.x=s*l*h+-r*l*c+(a*r-o*s)*l,e.y=i*l*c+-n*l*h+(-a*i+o*n)*l,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.a,r=this.c,s=this.tx;return this.a=n*e-this.b*i,this.b=n*i+this.b*e,this.c=r*e-this.d*i,this.d=r*i+this.d*e,this.tx=s*e-this.ty*i,this.ty=s*i+this.ty*e,this}append(t){const e=this.a,i=this.b,n=this.c,r=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*i+t.b*r,this.c=t.c*e+t.d*n,this.d=t.c*i+t.d*r,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*i+t.ty*r+this.ty,this}appendFrom(t,e){const i=t.a,n=t.b,r=t.c,s=t.d,o=t.tx,a=t.ty,l=e.a,h=e.b,c=e.c,u=e.d;return this.a=i*l+n*c,this.b=i*h+n*u,this.c=r*l+s*c,this.d=r*h+s*u,this.tx=o*l+a*c+e.tx,this.ty=o*h+a*u+e.ty,this}setTransform(t,e,i,n,r,s,o,a,l){return this.a=Math.cos(o+l)*r,this.b=Math.sin(o+l)*r,this.c=-Math.sin(o-a)*s,this.d=Math.cos(o-a)*s,this.tx=t-(i*this.a+n*this.c),this.ty=e-(i*this.b+n*this.d),this}prepend(t){const e=this.tx;if(1!==t.a||0!==t.b||0!==t.c||1!==t.d){const e=this.a,i=this.c;this.a=e*t.a+this.b*t.c,this.b=e*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,n=this.c,r=this.d,s=t.pivot,o=-Math.atan2(-n,r),a=Math.atan2(i,e),l=Math.abs(o+a);return l<1e-5||Math.abs(y-l)<1e-5?(t.rotation=a,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=a),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(n*n+r*r),t.position.x=this.tx+(s.x*e+s.y*n),t.position.y=this.ty+(s.x*i+s.y*r),t}invert(){const t=this.a,e=this.b,i=this.c,n=this.d,r=this.tx,s=t*n-e*i;return this.a=n/s,this.b=-e/s,this.c=-i/s,this.d=t/s,this.tx=(i*this.ty-n*r)/s,this.ty=-(t*this.ty-e*r)/s,this}isIdentity(){return 1===this.a&&0===this.b&&0===this.c&&1===this.d&&0===this.tx&&0===this.ty}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new S;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}equals(t){return t.a===this.a&&t.b===this.b&&t.c===this.c&&t.d===this.d&&t.tx===this.tx&&t.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return T.identity()}static get shared(){return A.identity()}}const A=new S,T=new S,C=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],P=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],M=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],E=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],R=[],F=[],B=Math.sign;!function(){for(let t=0;t<16;t++){const e=[];R.push(e);for(let i=0;i<16;i++){const n=B(C[t]*C[i]+M[t]*P[i]),r=B(P[t]*C[i]+E[t]*P[i]),s=B(C[t]*M[i]+M[t]*E[i]),o=B(P[t]*M[i]+E[t]*E[i]);for(let t=0;t<16;t++)if(C[t]===n&&P[t]===r&&M[t]===s&&E[t]===o){e.push(t);break}}}for(let t=0;t<16;t++){const e=new S;e.set(C[t],P[t],M[t],E[t],0,0),F.push(e)}}();const k={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:t=>C[t],uY:t=>P[t],vX:t=>M[t],vY:t=>E[t],inv:t=>8&t?15&t:7&-t,add:(t,e)=>R[t][e],sub:(t,e)=>R[t][k.inv(e)],rotate180:t=>4^t,isVertical:t=>2==(3&t),byDirection:(t,e)=>2*Math.abs(t)<=Math.abs(e)?e>=0?k.S:k.N:2*Math.abs(e)<=Math.abs(t)?t>0?k.E:k.W:e>0?t>0?k.SE:k.SW:t>0?k.NE:k.NW,matrixAppendRotationInv:(t,e,i=0,n=0)=>{const r=F[k.inv(e)];r.tx=i,r.ty=n,t.append(r)},transformRectCoords:(t,e,i,n)=>{const{x:r,y:s,width:o,height:a}=t,{x:l,y:h,width:c,height:u}=e;return i===k.E?(n.set(r+l,s+h,o,a),n):i===k.S?n.set(c-s-a+l,r+h,a,o):i===k.W?n.set(c-r-o+l,u-s-a+h,o,a):i===k.N?n.set(s+l,u-r-o+h,a,o):n.set(r+l,s+h,o,a)}},I=[new v,new v,new v,new v];class D{constructor(t=0,e=0,i=0,n=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(n)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new D(0,0,0,0)}clone(){return new D(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return!(this.width<=0||this.height<=0)&&(t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height)}strokeContains(t,e,i,n=.5){const{width:r,height:s}=this;if(r<=0||s<=0)return!1;const o=this.x,a=this.y,l=i*(1-n),h=i-l;return t>=o-l&&t<=o+r+l&&e>=a-l&&e<=a+s+l&&!(t>o+h&&t<o+r-h&&e>a+h&&e<a+s-h)}intersects(t,e){if(!e){const e=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=e)return!1;const i=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>i}const i=this.left,n=this.right,r=this.top,s=this.bottom;if(n<=i||s<=r)return!1;const o=I[0].set(t.left,t.top),a=I[1].set(t.left,t.bottom),l=I[2].set(t.right,t.top),h=I[3].set(t.right,t.bottom);if(l.x<=o.x||a.y<=o.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(0===c)return!1;if(e.apply(o,o),e.apply(a,a),e.apply(l,l),e.apply(h,h),Math.max(o.x,a.x,l.x,h.x)<=i||Math.min(o.x,a.x,l.x,h.x)>=n||Math.max(o.y,a.y,l.y,h.y)<=r||Math.min(o.y,a.y,l.y,h.y)>=s)return!1;const u=c*(a.y-o.y),d=c*(o.x-a.x),p=u*i+d*r,f=u*n+d*r,g=u*i+d*s,m=u*n+d*s;if(Math.max(p,f,g,m)<=u*o.x+d*o.y||Math.min(p,f,g,m)>=u*h.x+d*h.y)return!1;const _=c*(o.y-l.y),y=c*(l.x-o.x),x=_*i+y*r,b=_*n+y*r,v=_*i+y*s,w=_*n+y*s;return!(Math.max(x,b,v,w)<=_*o.x+y*o.y||Math.min(x,b,v,w)>=_*h.x+y*h.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),r=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=n,this.height=Math.max(r-n,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,n=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=n-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),r=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=n,this.height=r-n,this}getBounds(t){return t||(t=new D),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,n=t.x+t.width,r=t.y+t.height;return e>=this.x&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&n>=this.x&&n<this.x+this.width&&r>=this.y&&r<this.y+this.height}set(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const O={default:-1};function U(t="default"){return void 0===O[t]&&(O[t]=-1),++O[t]}const G={},L="8.0.0";function z(t,e,i=3){if(G[e])return;let n=(new Error).stack;void 0===n?console.warn("PixiJS Deprecation Warning: ",`${e}\nDeprecated since v${t}`):(n=n.split("\n").splice(i).join("\n"),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${e}\nDeprecated since v${t}`),console.warn(n),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${e}\nDeprecated since v${t}`),console.warn(n))),G[e]=!0}const N=()=>{};function V(t){return t+=0===t?1:0,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1}function H(t){return!(t&t-1||!t)}function W(t){const e={};for(const i in t)void 0!==t[i]&&(e[i]=t[i]);return e}const j=Object.create(null);const Y=class t extends _{constructor(e={}){var i,n,r,s,o,a,l;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,e=__spreadValues(__spreadValues({},t.defaultOptions),e),this.addressMode=e.addressMode,this.addressModeU=null!=(i=e.addressModeU)?i:this.addressModeU,this.addressModeV=null!=(n=e.addressModeV)?n:this.addressModeV,this.addressModeW=null!=(r=e.addressModeW)?r:this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=null!=(s=e.magFilter)?s:this.magFilter,this.minFilter=null!=(o=e.minFilter)?o:this.minFilter,this.mipmapFilter=null!=(a=e.mipmapFilter)?a:this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=null!=(l=e.maxAnisotropy)?l:1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){z(L,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=function(t){const e=j[t];return void 0===e&&(j[t]=U("resource")),e}(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Y.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let X=Y;const Z=class t extends _{constructor(e={}){var i,n,r;super(),this.options=e,this.uid=U("textureSource"),this._resourceType="textureSource",this._resourceId=U("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.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,e=__spreadValues(__spreadValues({},t.defaultOptions),e),this.label=null!=(i=e.label)?i:"",this.resource=e.resource,this.autoGarbageCollect=e.autoGarbageCollect,this._resolution=e.resolution,e.width?this.pixelWidth=e.width*this._resolution:this.pixelWidth=this.resource&&null!=(n=this.resourceWidth)?n:1,e.height?this.pixelHeight=e.height*this._resolution:this.pixelHeight=this.resource&&null!=(r=this.resourceHeight)?r:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=e.format,this.dimension=e.dimensions,this.mipLevelCount=e.mipLevelCount,this.autoGenerateMipmaps=e.autoGenerateMipmaps,this.sampleCount=e.sampleCount,this.antialias=e.antialias,this.alphaMode=e.alphaMode,this.style=new X(W(e)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&(null==(e=this._style)||e.off("change",this._onStyleChange,this),this._style=t,null==(i=this._style)||i.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=U("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i||(i=this._resolution),t||(t=this.width),e||(e=this.height);const n=Math.round(t*i),r=Math.round(e*i);return this.width=n/i,this.height=r/i,this._resolution=i,(this.pixelWidth!==n||this.pixelHeight!==r)&&(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=r,this.emit("resize",this),this._resourceId=U("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=H(this.pixelWidth)&&H(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Z.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let q=Z;class K extends q{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(i=e instanceof Float32Array?"rgba32float":e instanceof Int32Array||e instanceof Uint32Array?"rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?"rgba16uint":(Int8Array,"bgra8unorm")),super(__spreadProps(__spreadValues({},t),{resource:e,format:i})),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}K.extension=o.TextureSource;const $=new S;class Q{constructor(t,e){this.mapCoord=new S,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=void 0===e?t.width<10?0:.5:e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&(null==(e=this._texture)||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){void 0===e&&(e=t);const i=this.mapCoord;for(let n=0;n<t.length;n+=2){const r=t[n],s=t[n+1];e[n]=r*i.a+s*i.c+i.tx,e[n+1]=r*i.b+s*i.d+i.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const i=t.orig,n=t.trim;n&&($.set(i.width/n.width,0,0,i.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append($));const r=t.source,s=this.uClampFrame,o=this.clampMargin/r._resolution,a=this.clampOffset/r._resolution;return s[0]=(t.frame.x+o+a)/r.width,s[1]=(t.frame.y+o+a)/r.height,s[2]=(t.frame.x+t.frame.width-o+a)/r.width,s[3]=(t.frame.y+t.frame.height-o+a)/r.height,this.uClampOffset[0]=this.clampOffset/r.pixelWidth,this.uClampOffset[1]=this.clampOffset/r.pixelHeight,this.isSimple=t.frame.width===r.width&&t.frame.height===r.height&&0===t.rotate,!0}}class J extends _{constructor({source:t,label:e,frame:i,orig:n,trim:r,defaultAnchor:s,defaultBorders:o,rotate:a,dynamic:l}={}){var h;if(super(),this.uid=U("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new D,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=null!=(h=null==t?void 0:t.source)?h:new q,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:t,height:e}=this._source;this.frame.width=t,this.frame.height=e}this.orig=n||this.frame,this.trim=r,this.rotate=null!=a?a:0,this.defaultAnchor=s,this.defaultBorders=o,this.destroyed=!1,this.dynamic=l||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new Q(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:i,height:n}=this._source,r=e.x/i,s=e.y/n,o=e.width/i,a=e.height/n;let l=this.rotate;if(l){const e=o/2,i=a/2,n=r+e,h=s+i;l=k.add(l,k.NW),t.x0=n+e*k.uX(l),t.y0=h+i*k.uY(l),l=k.add(l,2),t.x1=n+e*k.uX(l),t.y1=h+i*k.uY(l),l=k.add(l,2),t.x2=n+e*k.uX(l),t.y2=h+i*k.uY(l),l=k.add(l,2),t.x3=n+e*k.uX(l),t.y3=h+i*k.uY(l)}else t.x0=r,t.y0=s,t.x1=r+o,t.y1=s,t.x2=r+o,t.y2=s+a,t.x3=r,t.y3=s+a}destroy(t=!1){this._source&&t&&(this._source.destroy(),this._source=null),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return z(L,"Texture.baseTexture is now Texture.source"),this._source}}function tt(t,e,i){const{width:n,height:r}=i.orig,s=i.trim;if(s){const i=s.width,o=s.height;t.minX=s.x-e._x*n,t.maxX=t.minX+i,t.minY=s.y-e._y*r,t.maxY=t.minY+o}else t.minX=-e._x*n,t.maxX=t.minX+n,t.minY=-e._y*r,t.maxY=t.minY+r}J.EMPTY=new J({label:"EMPTY",source:new q({label:"EMPTY"})}),J.EMPTY.destroy=N,J.WHITE=new J({source:new K({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),J.WHITE.destroy=N;const et=new S;class it{constructor(t=1/0,e=1/0,i=-1/0,n=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=et,this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new D);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=et,this}set(t,e,i,n){this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}addFrame(t,e,i,n,r){r||(r=this.matrix);const s=r.a,o=r.b,a=r.c,l=r.d,h=r.tx,c=r.ty;let u=this.minX,d=this.minY,p=this.maxX,f=this.maxY,g=s*t+a*e+h,m=o*t+l*e+c;g<u&&(u=g),m<d&&(d=m),g>p&&(p=g),m>f&&(f=m),g=s*i+a*e+h,m=o*i+l*e+c,g<u&&(u=g),m<d&&(d=m),g>p&&(p=g),m>f&&(f=m),g=s*t+a*n+h,m=o*t+l*n+c,g<u&&(u=g),m<d&&(d=m),g>p&&(p=g),m>f&&(f=m),g=s*i+a*n+h,m=o*i+l*n+c,g<u&&(u=g),m<d&&(d=m),g>p&&(p=g),m>f&&(f=m),this.minX=u,this.minY=d,this.maxX=p,this.maxY=f}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,i=this.minY,n=this.maxX,r=this.maxY,{a:s,b:o,c:a,d:l,tx:h,ty:c}=t;let u=s*e+a*i+h,d=o*e+l*i+c;this.minX=u,this.minY=d,this.maxX=u,this.maxY=d,u=s*n+a*i+h,d=o*n+l*i+c,this.minX=u<this.minX?u:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=d>this.maxY?d:this.maxY,u=s*e+a*r+h,d=o*e+l*r+c,this.minX=u<this.minX?u:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=d>this.maxY?d:this.maxY,u=s*n+a*r+h,d=o*n+l*r+c,this.minX=u<this.minX?u:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=d>this.maxY?d:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,n){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>n&&(this.maxY=n),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new it(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,n){let r=this.minX,s=this.minY,o=this.maxX,a=this.maxY;n||(n=this.matrix);const l=n.a,h=n.b,c=n.c,u=n.d,d=n.tx,p=n.ty;for(let f=e;f<i;f+=2){const e=t[f],i=t[f+1],n=l*e+c*i+d,g=h*e+u*i+p;r=n<r?n:r,s=g<s?g:s,o=n>o?n:o,a=g>a?g:a}this.minX=r,this.minY=s,this.maxX=o,this.maxY=a}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}var nt={grad:.9,turn:360,rad:360/(2*Math.PI)},rt=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},st=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=Math.pow(10,e)),Math.round(i*t)/i+0},ot=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=1),t>i?i:t>e?t:e},at=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},lt=function(t){return{r:ot(t.r,0,255),g:ot(t.g,0,255),b:ot(t.b,0,255),a:ot(t.a)}},ht=function(t){return{r:st(t.r),g:st(t.g),b:st(t.b),a:st(t.a,3)}},ct=/^#([0-9a-f]{3,8})$/i,ut=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},dt=function(t){var e=t.r,i=t.g,n=t.b,r=t.a,s=Math.max(e,i,n),o=s-Math.min(e,i,n),a=o?s===e?(i-n)/o:s===i?2+(n-e)/o:4+(e-i)/o:0;return{h:60*(a<0?a+6:a),s:s?o/s*100:0,v:s/255*100,a:r}},pt=function(t){var e=t.h,i=t.s,n=t.v,r=t.a;e=e/360*6,i/=100,n/=100;var s=Math.floor(e),o=n*(1-i),a=n*(1-(e-s)*i),l=n*(1-(1-e+s)*i),h=s%6;return{r:255*[n,a,o,o,l,n][h],g:255*[l,n,n,a,o,o][h],b:255*[o,o,l,n,n,a][h],a:r}},ft=function(t){return{h:at(t.h),s:ot(t.s,0,100),l:ot(t.l,0,100),a:ot(t.a)}},gt=function(t){return{h:st(t.h),s:st(t.s),l:st(t.l),a:st(t.a,3)}},mt=function(t){return pt((i=(e=t).s,{h:e.h,s:(i*=((n=e.l)<50?n:100-n)/100)>0?2*i/(n+i)*100:0,v:n+i,a:e.a}));var e,i,n},_t=function(t){return{h:(e=dt(t)).h,s:(r=(200-(i=e.s))*(n=e.v)/100)>0&&r<200?i*n/100/(r<=100?r:200-r)*100:0,l:r/2,a:e.a};var e,i,n,r},yt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,xt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,vt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wt={string:[[function(t){var e=ct.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:4===t.length?st(parseInt(t[3]+t[3],16)/255,2):1}:6===t.length||8===t.length?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:8===t.length?st(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=bt.exec(t)||vt.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:lt({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:void 0===e[7]?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=yt.exec(t)||xt.exec(t);if(!e)return null;var i,n,r=ft({h:(i=e[1],n=e[2],void 0===n&&(n="deg"),Number(i)*(nt[n]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return mt(r)},"hsl"]],object:[[function(t){var e=t.r,i=t.g,n=t.b,r=t.a,s=void 0===r?1:r;return rt(e)&&rt(i)&&rt(n)?lt({r:Number(e),g:Number(i),b:Number(n),a:Number(s)}):null},"rgb"],[function(t){var e=t.h,i=t.s,n=t.l,r=t.a,s=void 0===r?1:r;if(!rt(e)||!rt(i)||!rt(n))return null;var o=ft({h:Number(e),s:Number(i),l:Number(n),a:Number(s)});return mt(o)},"hsl"],[function(t){var e=t.h,i=t.s,n=t.v,r=t.a,s=void 0===r?1:r;if(!rt(e)||!rt(i)||!rt(n))return null;var o,a=(o={h:Number(e),s:Number(i),v:Number(n),a:Number(s)},{h:at(o.h),s:ot(o.s,0,100),v:ot(o.v,0,100),a:ot(o.a)});return pt(a)},"hsv"]]},St=function(t,e){for(var i=0;i<e.length;i++){var n=e[i][0](t);if(n)return[n,e[i][1]]}return[null,void 0]},At=function(t,e){var i=_t(t);return{h:i.h,s:ot(i.s+100*e,0,100),l:i.l,a:i.a}},Tt=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},Ct=function(t,e){var i=_t(t);return{h:i.h,s:i.s,l:ot(i.l+100*e,0,100),a:i.a}},Pt=function(){function t(t){this.parsed=function(t){return"string"==typeof t?St(t.trim(),wt.string):"object"==typeof t&&null!==t?St(t,wt.object):[null,void 0]}(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return null!==this.parsed},t.prototype.brightness=function(){return st(Tt(this.rgba),2)},t.prototype.isDark=function(){return Tt(this.rgba)<.5},t.prototype.isLight=function(){return Tt(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=ht(this.rgba)).r,i=t.g,n=t.b,s=(r=t.a)<1?ut(st(255*r)):"","#"+ut(e)+ut(i)+ut(n)+s;var t,e,i,n,r,s},t.prototype.toRgb=function(){return ht(this.rgba)},t.prototype.toRgbString=function(){return e=(t=ht(this.rgba)).r,i=t.g,n=t.b,(r=t.a)<1?"rgba("+e+", "+i+", "+n+", "+r+")":"rgb("+e+", "+i+", "+n+")";var t,e,i,n,r},t.prototype.toHsl=function(){return gt(_t(this.rgba))},t.prototype.toHslString=function(){return e=(t=gt(_t(this.rgba))).h,i=t.s,n=t.l,(r=t.a)<1?"hsla("+e+", "+i+"%, "+n+"%, "+r+")":"hsl("+e+", "+i+"%, "+n+"%)";var t,e,i,n,r},t.prototype.toHsv=function(){return t=dt(this.rgba),{h:st(t.h),s:st(t.s),v:st(t.v),a:st(t.a,3)};var t},t.prototype.invert=function(){return Mt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},t.prototype.saturate=function(t){return void 0===t&&(t=.1),Mt(At(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),Mt(At(this.rgba,-t))},t.prototype.grayscale=function(){return Mt(At(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),Mt(Ct(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),Mt(Ct(this.rgba,-t))},t.prototype.rotate=function(t){return void 0===t&&(t=15),this.hue(this.hue()+t)},t.prototype.alpha=function(t){return"number"==typeof t?Mt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):st(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=_t(this.rgba);return"number"==typeof t?Mt({h:t,s:e.s,l:e.l,a:e.a}):st(e.h)},t.prototype.isEqual=function(t){return this.toHex()===Mt(t).toHex()},t}(),Mt=function(t){return t instanceof Pt?t:new Pt(t)},Et=[];[function(t,e){var i={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"},n={};for(var r in i)n[i[r]]=r;var s={};t.prototype.toName=function(e){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var r,o,a=n[this.toHex()];if(a)return a;if(null==e?void 0:e.closest){var l=this.toRgb(),h=1/0,c="black";if(!s.length)for(var u in i)s[u]=new t(i[u]).toRgb();for(var d in i){var p=(r=l,o=s[d],Math.pow(r.r-o.r,2)+Math.pow(r.g-o.g,2)+Math.pow(r.b-o.b,2));p<h&&(h=p,c=d)}return c}},e.string.push([function(e){var n=e.toLowerCase(),r="transparent"===n?"#0000":i[n];return r?new t(r).toRgb():null},"name"])}].forEach(function(t){Et.indexOf(t)<0&&(t(Pt,wt),Et.push(t))});const Rt=class t{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(e){if(e instanceof t)this._value=this._cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(null===e)throw new Error("Cannot set Color#value to null");null!==this._value&&this._isSourceEqual(this._value,e)||(this._value=this._cloneSource(e),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return"string"==typeof t||"number"==typeof t||t instanceof Number||null===t?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):"object"==typeof t&&null!==t?__spreadValues({},t):t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if("number"===i||"string"===i||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length===e.length&&t.every((t,i)=>t===e[i]);if(null!==t&&null!==e){const i=Object.keys(t),n=Object.keys(e);return i.length===n.length&&i.every(i=>t[i]===e[i])}return t===e}toRgba(){const[t,e,i,n]=this._components;return{r:t,g:e,b:i,a:n}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,n]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(255*e),t[1]=Math.round(255*i),t[2]=Math.round(255*n),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,n,r]=this._components;return t[0]=e,t[1]=i,t[2]=n,t[3]=r,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,n]=this._components;return t[0]=e,t[1]=i,t[2]=n,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(65280&t)+((255&t)<<16)}multiply(e){const[i,n,r,s]=t._temp.setValue(e)._components;return this._components[0]*=i,this._components[1]*=n,this._components[2]*=r,this._components[3]*=s,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(1===t)return(255<<24)+this._int;if(0===t)return e?0:this._int;let i=this._int>>16&255,n=this._int>>8&255,r=255&this._int;return e&&(i=i*t+.5|0,n=n*t+.5|0,r=r*t+.5|0),(255*t<<24)+(i<<16)+(n<<8)+r}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(255*this._components[3]).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(e){let i,n,r,s;if(("number"==typeof e||e instanceof Number)&&e>=0&&e<=16777215){i=(e>>16&255)/255,n=(e>>8&255)/255,r=(255&e)/255,s=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[i,n,r,s=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[i,n,r,s=255]=e,i/=255,n/=255,r/=255,s/=255;else if("string"==typeof e||"object"==typeof e){if("string"==typeof e){const i=t.HEX_PATTERN.exec(e);i&&(e=`#${i[2]}`)}const o=Mt(e);o.isValid()&&(({r:i,g:n,b:r,a:s}=o.rgba),i/=255,n/=255,r/=255)}if(void 0===i)throw new Error(`Unable to convert color ${e}`);this._components[0]=i,this._components[1]=n,this._components[2]=r,this._components[3]=s,this._refreshInt()}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(255*t<<16)+(255*e<<8)+(255*i|0)}_clamp(t,e=0,i=1){return"number"==typeof t?Math.min(Math.max(t,e),i):(t.forEach((n,r)=>{t[r]=Math.min(Math.max(n,e),i)}),t)}static isColorLike(e){return"number"==typeof e||"string"==typeof e||e instanceof Number||e instanceof t||Array.isArray(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||void 0!==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}};Rt.shared=new Rt,Rt._temp=new Rt,Rt.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Ft=Rt;let Bt=0;function kt(...t){500!==Bt&&(Bt++,500===Bt?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...t))}class It{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var e;let i;return i=this._index>0?this._pool[--this._index]:new this._classType,null==(e=i.init)||e.call(i,t),i}return(t){var e;null==(e=t.reset)||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}const Dt=new class{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new It(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}},Ot={get isCachedAsTexture(){var t;return!!(null==(t=this.renderGroup)?void 0:t.isCachedAsTexture)},cacheAsTexture(t){"boolean"==typeof t&&!1===t?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(!0===t?{}:t))},updateCacheTexture(){var t;null==(t=this.renderGroup)||t.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(t){z("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(t)}};function Ut(t,e,i){const n=t.length;let r;if(e>=n||0===i)return;const s=n-(i=e+i>n?n-e:i);for(r=e;r<s;++r)t[r]=t[r+i];t.length=s}const Gt={allowChildren:!0,removeChildren(t=0,e){var i;const n=null!=e?e:this.children.length,r=n-t,s=[];if(r>0&&r<=n){for(let i=n-1;i>=t;i--){const t=this.children[i];t&&(s.push(t),t.parent=null)}Ut(this.children,t,n);const e=this.renderGroup||this.parentRenderGroup;e&&e.removeChildren(s);for(let t=0;t<s.length;++t){const e=s[t];null==(i=e.parentRenderLayer)||i.detach(e),this.emit("childRemoved",e,this,t),s[t].emit("removed",this)}return s.length>0&&this._didViewChangeTick++,s}if(0===r&&0===this.children.length)return s;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(t){const e=this.getChildAt(t);return this.removeChild(e)},getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]},setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(t),this.addChildAt(t,e)},getChildIndex(t){const e=this.children.indexOf(t);if(-1===e)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(t,e){this.allowChildren||z(L,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:i}=this;if(e<0||e>i.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${i.length}`);if(t.parent){const i=t.parent.children.indexOf(t);if(t.parent===this&&i===e)return t;-1!==i&&t.parent.children.splice(i,1)}e===i.length?i.push(t):i.splice(e,0,t),t.parent=this,t.didChange=!0,t._updateFlags=15;const n=this.renderGroup||this.parentRenderGroup;return n&&n.addChild(t),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",t,this,e),t.emit("added",this),t},swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),n=this.getChildIndex(e);this.children[i]=e,this.children[n]=t;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var t;null==(t=this.parent)||t.removeChild(this)},reparentChild(...t){return 1===t.length?this.reparentChildAt(t[0],this.children.length):(t.forEach(t=>this.reparentChildAt(t,this.children.length)),t[0])},reparentChildAt(t,e){if(t.parent===this)return this.setChildIndex(t,e),t;const i=t.worldTransform.clone();t.removeFromParent(),this.addChildAt(t,e);const n=this.worldTransform.clone();return n.invert(),i.prepend(n),t.setFromMatrix(i),t},replaceChild(t,e){t.updateLocalTransform(),this.addChildAt(e,this.getChildIndex(t)),e.setFromMatrix(t.localTransform),e.updateLocalTransform(),this.removeChild(t)}},Lt={collectRenderables(t,e,i){this.parentRenderLayer&&this.parentRenderLayer!==i||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(t,e,i):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,t):this.collectRenderablesWithEffects(t,e,i))},collectRenderablesSimple(t,e,i){const n=this.children,r=n.length;for(let s=0;s<r;s++)n[s].collectRenderables(t,e,i)},collectRenderablesWithEffects(t,e,i){const{renderPipes:n}=e;for(let r=0;r<this.effects.length;r++){const e=this.effects[r];n[e.pipe].push(e,this,t)}this.collectRenderablesSimple(t,e,i);for(let r=this.effects.length-1;r>=0;r--){const e=this.effects[r];n[e.pipe].pop(e,this,t)}}};class zt{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}const Nt=new class{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const i=this._tests[e];if(i.test(t))return Dt.get(i.maskClass,t)}return t}returnMaskEffect(t){Dt.return(t)}};h.handleByList(o.MaskEffect,Nt._effectClasses);const Vt={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const t=this.renderGroup||this.parentRenderGroup;t&&(t.structureDidChange=!0)},addEffect(t){-1===this.effects.indexOf(t)&&(this.effects.push(t),this.effects.sort((t,e)=>t.priority-e.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(t){const e=this.effects.indexOf(t);-1!==e&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(t){const e=this._maskEffect;(null==e?void 0:e.mask)!==t&&(e&&(this.removeEffect(e),Nt.returnMaskEffect(e),this._maskEffect=null),null!=t&&(this._maskEffect=Nt.getMaskEffect(t),this.addEffect(this._maskEffect)))},get mask(){var t;return null==(t=this._maskEffect)?void 0:t.mask},setMask(t){this._maskOptions=__spreadValues(__spreadValues({},this._maskOptions),t),t.mask&&(this.mask=t.mask),this._markStructureAsChanged()},set filters(t){var e;!Array.isArray(t)&&t&&(t=[t]);const i=this._filterEffect||(this._filterEffect=new zt),n=(null==t?void 0:t.length)>0,r=n!==(null==(e=i.filters)?void 0:e.length)>0;t=Array.isArray(t)?t.slice(0):t,i.filters=Object.freeze(t),r&&(n?this.addEffect(i):(this.removeEffect(i),i.filters=null!=t?t:null))},get filters(){var t;return null==(t=this._filterEffect)?void 0:t.filters},set filterArea(t){this._filterEffect||(this._filterEffect=new zt),this._filterEffect.filterArea=t},get filterArea(){var t;return null==(t=this._filterEffect)?void 0:t.filterArea}},Ht={label:null,get name(){return z(L,"Container.name property has been removed, use Container.label instead"),this.label},set name(t){z(L,"Container.name property has been removed, use Container.label instead"),this.label=t},getChildByName(t,e=!1){return this.getChildByLabel(t,e)},getChildByLabel(t,e=!1){const i=this.children;for(let n=0;n<i.length;n++){const e=i[n];if(e.label===t||t instanceof RegExp&&t.test(e.label))return e}if(e)for(let n=0;n<i.length;n++){const e=i[n].getChildByLabel(t,!0);if(e)return e}return null},getChildrenByLabel(t,e=!1,i=[]){const n=this.children;for(let r=0;r<n.length;r++){const e=n[r];(e.label===t||t instanceof RegExp&&t.test(e.label))&&i.push(e)}if(e)for(let r=0;r<n.length;r++)n[r].getChildrenByLabel(t,!0,i);return i}},Wt=new It(S),jt=new It(it),Yt=new S,Xt={getFastGlobalBounds(t,e){e||(e=new it),e.clear(),this._getGlobalBoundsRecursive(!!t,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);const i=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(i.worldTransform),e},_getGlobalBoundsRecursive(t,e,i){let n=e;if(t&&this.parentRenderLayer&&this.parentRenderLayer!==i)return;if(7!==this.localDisplayStatus||!this.measurable)return;const r=!!this.effects.length;if((this.renderGroup||r)&&(n=jt.get().clear()),this.boundsArea)e.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const t=this.bounds;n.addFrame(t.minX,t.minY,t.maxX,t.maxY,this.groupTransform)}const e=this.children;for(let r=0;r<e.length;r++)e[r]._getGlobalBoundsRecursive(t,n,i)}if(r){let t=!1;const i=this.renderGroup||this.parentRenderGroup;for(let e=0;e<this.effects.length;e++)this.effects[e].addBounds&&(t||(t=!0,n.applyMatrix(i.worldTransform)),this.effects[e].addBounds(n,!0));t&&n.applyMatrix(i.worldTransform.copyTo(Yt).invert()),e.addBounds(n),jt.return(n)}else this.renderGroup&&(e.addBounds(n,this.relativeGroupTransform),jt.return(n))}};function Zt(t,e,i){let n,r;return i.clear(),t.parent?e?n=t.parent.worldTransform:(r=Wt.get().identity(),n=Kt(t,r)):n=S.IDENTITY,qt(t,i,n,e),r&&Wt.return(r),i.isValid||i.set(0,0,0,0),i}function qt(t,e,i,n){var r,s;if(!t.visible||!t.measurable)return;let o;n?o=t.worldTransform:(t.updateLocalTransform(),o=Wt.get(),o.appendFrom(t.localTransform,i));const a=e,l=!!t.effects.length;if(l&&(e=jt.get().clear()),t.boundsArea)e.addRect(t.boundsArea,o);else{t.bounds&&(e.matrix=o,e.addBounds(t.bounds));for(let i=0;i<t.children.length;i++)qt(t.children[i],e,o,n)}if(l){for(let i=0;i<t.effects.length;i++)null==(s=(r=t.effects[i]).addBounds)||s.call(r,e);a.addBounds(e,S.IDENTITY),jt.return(e)}n||Wt.return(o)}function Kt(t,e){const i=t.parent;return i&&(Kt(i,e),i.updateLocalTransform(),e.append(i.localTransform)),e}function $t(t,e){if(16777215===t||!e)return e;if(16777215===e||!t)return t;return(((t>>16&255)*(e>>16&255)/255|0)<<16)+(((t>>8&255)*(e>>8&255)/255|0)<<8)+((255&t)*(255&e)/255|0)}const Qt=16777215;function Jt(t,e){return t===Qt?e:e===Qt?t:$t(t,e)}function te(t){return((255&t)<<16)+(65280&t)+(t>>16&255)}const ee={getGlobalAlpha(t){if(t)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let e=this.alpha,i=this.parent;for(;i;)e*=i.alpha,i=i.parent;return e},getGlobalTransform(t=new S,e){if(e)return t.copyFrom(this.worldTransform);this.updateLocalTransform();const i=Kt(this,Wt.get().identity());return t.appendFrom(this.localTransform,i),Wt.return(i),t},getGlobalTint(t){if(t)return this.renderGroup?te(this.renderGroup.worldColor):this.parentRenderGroup?te(Jt(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,i=this.parent;for(;i;)e=Jt(e,i.localColor),i=i.parent;return te(e)}};function ie(t,e,i){return e.clear(),i||(i=S.IDENTITY),ne(t,e,i,t,!0),e.isValid||e.set(0,0,0,0),e}function ne(t,e,i,n,r){var s,o;let a;if(r)a=Wt.get(),a=i.copyTo(a);else{if(!t.visible||!t.measurable)return;t.updateLocalTransform();const e=t.localTransform;a=Wt.get(),a.appendFrom(e,i)}const l=e,h=!!t.effects.length;if(h&&(e=jt.get().clear()),t.boundsArea)e.addRect(t.boundsArea,a);else{t.renderPipeId&&(e.matrix=a,e.addBounds(t.bounds));const i=t.children;for(let t=0;t<i.length;t++)ne(i[t],e,a,n,!1)}if(h){for(let i=0;i<t.effects.length;i++)null==(o=(s=t.effects[i]).addLocalBounds)||o.call(s,e,n);l.addBounds(e,S.IDENTITY),jt.return(e)}Wt.return(a)}function re(t,e){const i=t.children;for(let n=0;n<i.length;n++){const t=i[n],r=t.uid,s=(65535&t._didViewChangeTick)<<16|65535&t._didContainerChangeTick,o=e.index;e.data[o]===r&&e.data[o+1]===s||(e.data[e.index]=r,e.data[e.index+1]=s,e.didChange=!0),e.index=o+2,t.children.length&&re(t,e)}return e.didChange}const se=new S,oe={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(t,e){const i=Math.sign(this.scale.x)||1;this.scale.x=0!==e?t/e*i:i},_setHeight(t,e){const i=Math.sign(this.scale.y)||1;this.scale.y=0!==e?t/e*i:i},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new it});const t=this._localBoundsCacheData;return t.index=1,t.didChange=!1,t.data[0]!==this._didViewChangeTick&&(t.didChange=!0,t.data[0]=this._didViewChangeTick),re(this,t),t.didChange&&ie(this,t.localBounds,se),t.localBounds},getBounds(t,e){return Zt(this,t,e||new it)}},ae={_onRender:null,set onRender(t){const e=this.renderGroup||this.parentRenderGroup;if(!t)return this._onRender&&(null==e||e.removeOnRender(this)),void(this._onRender=null);this._onRender||null==e||e.addOnRender(this),this._onRender=t},get onRender(){return this._onRender}},le={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(t){this._zIndex!==t&&(this._zIndex=t,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(he))}};function he(t,e){return t._zIndex-e._zIndex}const ce={getGlobalPosition(t=new v,e=!1){return this.parent?this.parent.toGlobal(this._position,t,e):(t.x=this._position.x,t.y=this._position.y),t},toGlobal(t,e,i=!1){const n=this.getGlobalTransform(Wt.get(),i);return e=n.apply(t,e),Wt.return(n),e},toLocal(t,e,i,n){e&&(t=e.toGlobal(t,i,n));const r=this.getGlobalTransform(Wt.get(),n);return i=r.applyInverse(t,i),Wt.return(r),i}};class ue{constructor(){this.uid=U("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}let de=0;const pe=new class{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new X(this.textureOptions)}createTexture(t,e,i){const n=new q(__spreadProps(__spreadValues({},this.textureOptions),{width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1}));return new J({source:n,label:"texturePool_"+de++})}getOptimalTexture(t,e,i=1,n){let r=Math.ceil(t*i-1e-6),s=Math.ceil(e*i-1e-6);r=V(r),s=V(s);const o=(r<<17)+(s<<1)+(n?1:0);this._texturePool[o]||(this._texturePool[o]=[]);let a=this._texturePool[o].pop();return a||(a=this.createTexture(r,s,n)),a.source._resolution=i,a.source.width=r/i,a.source.height=s/i,a.source.pixelWidth=r,a.source.pixelHeight=s,a.frame.x=0,a.frame.y=0,a.frame.width=t,a.frame.height=e,a.updateUvs(),this._poolKeyHash[a.uid]=o,a}getSameSizeTexture(t,e=!1){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t,e=!1){const i=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[i].push(t)}clear(t){if(t=!1!==t)for(const e in this._texturePool){const t=this._texturePool[e];if(t)for(let e=0;e<t.length;e++)t[e].destroy(!0)}this._texturePool={}}};class fe{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new S,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 ue,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let i=0;i<e.length;i++){const t=e[i];t._updateFlags=15,this.addChild(t)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(pe.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup)return void this.addRenderGroupChild(t.renderGroup);t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup)return void this._removeRenderGroupChild(t.renderGroup);const e=t.children;for(let i=0;i<e.length;i++)this.removeChild(e[i])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return 7===this.root.localDisplayStatus&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let i=0;i<e.length;i++)this._getChildren(e[i],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const i=t.children;for(let n=0;n<i.length;n++)this._getChildren(i[n],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return 1&this._matrixDirty?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new S),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return 2&this._matrixDirty?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new S),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(4&this._matrixDirty))return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new S),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}const ge=new d(null),me=new d(null),_e=new d(null,1,1),ye=new d(null);class xe extends _{constructor(t={}){var e,i;super(),this.uid=U("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.updateTick=-1,this.localTransform=new S,this.relativeGroupTransform=new S,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new d(this,0,0),this._scale=_e,this._pivot=me,this._origin=ye,this._skew=ge,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=[],function(t,e,i={}){for(const n in e)i[n]||void 0===e[n]||(t[n]=e[n])}(this,t,{children:!0,parent:!0,effects:!0}),null==(e=t.children)||e.forEach(t=>this.addChild(t)),null==(i=t.parent)||i.addChild(this)}static mixin(t){z("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),h.mixin(xe,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=4095&t}get _didChangeId(){return 4095&this._didContainerChangeTick|(4095&this._didViewChangeTick)<<12}addChild(...t){if(this.allowChildren||z(L,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let e=0;e<t.length;e++)this.addChild(t[e]);return t[0]}const e=t[0],i=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),i&&(i.structureDidChange=!0),e):(e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e._updateFlags=15,i&&i.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,0!==e._zIndex&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let e=0;e<t.length;e++)this.removeChild(t[e]);return t[0]}const e=t[0],i=this.children.indexOf(e);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,this.didChange||(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;null==t||t.removeChild(this),this.renderGroup=Dt.get(fe,this),this.groupTransform=S.IDENTITY,null==t||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;null==t||t.removeChild(this),Dt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,null==t||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&0===this.effects.length}get worldTransform(){return this._worldTransform||(this._worldTransform=new S),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*x}set angle(t){this.rotation=t*b}get pivot(){return this._pivot===me&&(this._pivot=new d(this,0,0)),this._pivot}set pivot(t){this._pivot===me&&(this._pivot=new d(this,0,0),this._origin!==ye&&kt("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),"number"==typeof t?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===ge&&(this._skew=new d(this,0,0)),this._skew}set skew(t){this._skew===ge&&(this._skew=new d(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===_e&&(this._scale=new d(this,1,1)),this._scale}set scale(t){this._scale===_e&&(this._scale=new d(this,0,0)),"string"==typeof t&&(t=parseFloat(t)),"number"==typeof t?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===ye&&(this._origin=new d(this,0,0)),this._origin}set origin(t){this._origin===ye&&(this._origin=new d(this,0,0),this._pivot!==me&&kt("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),"number"==typeof t?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){var i;const n=this.getLocalBounds();"object"==typeof t?(e=null!=(i=t.height)?i:t.width,t=t.width):null!=e||(e=t),void 0!==t&&this._setWidth(t,n.width),void 0!==e&&this._setHeight(e,n.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set("number"==typeof t.x?t.x:this.position.x,"number"==typeof t.y?t.y:this.position.y),this.scale.set("number"==typeof t.scaleX?t.scaleX||1:this.scale.x,"number"==typeof t.scaleY?t.scaleY||1:this.scale.y),this.rotation="number"==typeof t.rotation?t.rotation:this.rotation,this.skew.set("number"==typeof t.skewX?t.skewX:this.skew.x,"number"==typeof t.skewY?t.skewY:this.skew.y),this.pivot.set("number"==typeof t.pivotX?t.pivotX:this.pivot.x,"number"==typeof t.pivotY?t.pivotY:this.pivot.y),this.origin.set("number"==typeof t.originX?t.originX:this.origin.x,"number"==typeof t.originY?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,n=this._pivot,r=this._origin,s=this._position,o=i._x,a=i._y,l=n._x,h=n._y,c=-r._x,u=-r._y;e.a=this._cx*o,e.b=this._sx*o,e.c=this._cy*a,e.d=this._sy*a,e.tx=s._x-(l*e.a+h*e.c)+(c*e.a+u*e.c)-c,e.ty=s._y-(l*e.b+h*e.d)+(c*e.b+u*e.d)-u}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=1,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=Ft.shared.setValue(null!=t?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=1,this._onUpdate())}get tint(){return te(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=2,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(2&this.localDisplayStatus)}set visible(t){const e=t?2:0;(2&this.localDisplayStatus)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(4&this.localDisplayStatus)}set culled(t){const e=t?0:4;(4&this.localDisplayStatus)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(1&this.localDisplayStatus)}set renderable(t){const e=t?1:0;(1&this.localDisplayStatus)!==e&&(this._updateFlags|=4,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return 7===this.localDisplayStatus&&this.groupAlpha>0}destroy(t=!1){var e;if(this.destroyed)return;let i;this.destroyed=!0,this.children.length&&(i=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();if(("boolean"==typeof t?t:null==t?void 0:t.children)&&i)for(let n=0;n<i.length;++n)i[n].destroy(t);null==(e=this.renderGroup)||e.destroy(),this.renderGroup=null}}h.mixin(xe,Gt,Xt,ce,ae,oe,Vt,Ht,le,{cullArea:null,cullable:!1,cullableChildren:!0},Ot,ee,Lt);class be extends xe{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this._bounds=new it(0,1,0,0),this._boundsDirty=!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:i,y:n}=t;return i>=e.minX&&i<=e.maxX&&n>=e.minY&&n<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){var e,i;super.destroy(t),this._bounds=null;for(const n in this._gpuData)null==(i=(e=this._gpuData[n]).destroy)||i.call(e);this._gpuData=null}collectRenderablesSimple(t,e,i){const{renderPipes:n}=e;n.blendMode.setBlendMode(this,this.groupBlendMode,t);n[this.renderPipeId].addRenderable(this,t),this.didViewUpdate=!1;const r=this.children,s=r.length;for(let o=0;o<s;o++)r[o].collectRenderables(t,e,i)}}class ve extends be{constructor(t=J.EMPTY){t instanceof J&&(t={texture:t});const e=t,{texture:i=J.EMPTY,anchor:n,roundPixels:r,width:s,height:o}=e,a=__objRest(e,["texture","anchor","roundPixels","width","height"]);super(__spreadValues({label:"Sprite"},a)),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new d({_onUpdate:()=>{this.onViewUpdate()}}),n?this.anchor=n:i.defaultAnchor&&(this.anchor=i.defaultAnchor),this.texture=i,this.allowChildren=!1,this.roundPixels=null!=r&&r,void 0!==s&&(this.width=s),void 0!==o&&(this.height=o)}static from(t,e=!1){return new ve(t instanceof J?t:J.from(t,e))}set texture(t){t||(t=J.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return tt(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return z("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:n,height:r}=e.orig;i.minX=-t._x*n,i.maxX=i.minX+n,i.minY=-t._y*r,i.maxY=i.minY+r}destroy(t=!1){super.destroy(t);if("boolean"==typeof t?t:null==t?void 0:t.texture){const e="boolean"==typeof t?t:null==t?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null,this._gpuData=null}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){var i;"object"==typeof t?(e=null!=(i=t.height)?i:t.width,t=t.width):null!=e||(e=t),void 0!==t&&this._setWidth(t,this._texture.orig.width),void 0!==e&&this._setHeight(e,this._texture.orig.height)}}const we=new it;function Se(t,e,i){const n=we;t.measurable=!0,Zt(t,i,n),e.addBoundsMask(n),t.measurable=!1}function Ae(t,e,i){const n=jt.get();t.measurable=!0;const r=Wt.get().identity();ie(t,n,Te(t,i,r)),t.measurable=!1,e.addBoundsMask(n),Wt.return(r),jt.return(n)}function Te(t,e,i){return t?(t!==e&&(Te(t.parent,e,i),t.updateLocalTransform(),i.append(t.localTransform)),i):(kt("Mask bounds, renderable is not inside the root container"),i)}class Ce{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",(null==t?void 0:t.mask)&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof ve),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){this.inverse||Se(this.mask,t,e)}addLocalBounds(t,e){Ae(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof ve}}Ce.extension=o.MaskEffect;class Pe{constructor(t){this.priority=0,this.pipe="colorMask",(null==t?void 0:t.mask)&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return"number"==typeof t}}Pe.extension=o.MaskEffect;class Me{constructor(t){this.priority=0,this.pipe="stencilMask",(null==t?void 0:t.mask)&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(t,e){Se(this.mask,t,e)}addLocalBounds(t,e){Ae(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof xe}}Me.extension=o.MaskEffect;let Ee={createCanvas:(t,e)=>{const i=document.createElement("canvas");return i.width=t,i.height=e,i},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var t;return null!=(t=document.baseURI)?t:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(t,e)=>fetch(t,e),parseXML:t=>(new DOMParser).parseFromString(t,"text/xml")};const Re={get:()=>Ee,set(t){Ee=t}};class Fe extends q{constructor(t){t.resource||(t.resource=Re.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),this.resource.width===this.pixelWidth&&this.resource.height===this.pixelHeight||(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,i=this._resolution){const n=super.resize(t,e,i);return n&&this.resizeCanvas(),n}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}Fe.extension=o.TextureSource;class Be extends q{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}Be.extension=o.TextureSource;var ke=(t=>(t[t.INTERACTION=50]="INTERACTION",t[t.HIGH=25]="HIGH",t[t.NORMAL=0]="NORMAL",t[t.LOW=-25]="LOW",t[t.UTILITY=-50]="UTILITY",t))(ke||{});class Ie{constructor(t,e=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=n}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const De=class t{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Ie(null,null,1/0),this.deltaMS=1/t.targetFPMS,this.elapsedMS=1/t.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&null===this._requestId&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){null===this._requestId&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=ke.NORMAL){return this._addListener(new Ie(t,e,i))}addOnce(t,e,i=ke.NORMAL){return this._addListener(new Ie(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(e){for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}else t.connect(i);return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i=i.match(t,e)?i.destroy():i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let i;if(e>this.lastTime){if(i=this.elapsedMS=e-this.lastTime,i>this._maxElapsedMS&&(i=this._maxElapsedMS),i*=this.speed,this._minElapsedMS){const t=e-this._lastFrame|0;if(t<this._minElapsedMS)return;this._lastFrame=e-t%this._minElapsedMS}this.deltaMS=i,this.deltaTime=this.deltaMS*t.targetFPMS;const n=this._head;let r=n.next;for(;r;)r=r.emit(this);n.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 i=Math.min(this.maxFPS,e),n=Math.min(Math.max(0,i)/1e3,t.targetFPMS);this._maxElapsedMS=1/n}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(0===t)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!t._shared){const e=t._shared=new t;e.autoStart=!0,e._protected=!0}return t._shared}static get system(){if(!t._system){const e=t._system=new t;e.autoStart=!0,e._protected=!0}return t._system}};De.targetFPMS=.06;let Oe,Ue=De;function Ge(){return __async(this,null,function*(){return null!=Oe||(Oe=__async(null,null,function*(){var t;const e=Re.get().createCanvas(1,1).getContext("webgl");if(!e)return"premultiply-alpha-on-upload";const i=yield new Promise(t=>{const e=document.createElement("video");e.onloadeddata=()=>t(e),e.onerror=()=>t(null),e.autoplay=!1,e.crossOrigin="anonymous",e.preload="auto",e.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",e.load()});if(!i)return"premultiply-alpha-on-upload";const n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,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,i);const s=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,s),e.deleteFramebuffer(r),e.deleteTexture(n),null==(t=e.getExtension("WEBGL_lose_context"))||t.loseContext(),s[0]<=s[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})),Oe})}const Le=class t extends q{constructor(e){var i;super(e),this.isReady=!1,this.uploadMethodId="video",e=__spreadValues(__spreadValues({},t.defaultOptions),e),this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=!1!==e.autoPlay,this.alphaMode=null!=(i=e.alphaMode)?i:"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),!1!==e.autoLoad&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=Ue.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}load(){return __async(this,null,function*(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=yield Ge(),this._load=new Promise((i,n)=>{this.isValid?i(this):(this._resolve=i,this._reject=n,void 0!==e.preloadTimeoutMs&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load})}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(Ue.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),null===this._videoFrameRequestCallbackHandle&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Ue.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Ue.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Le.extension=o.TextureSource,Le.defaultOptions=__spreadProps(__spreadValues({},q.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),Le.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let ze=Le;const Ne=(t,e,i=!1)=>(Array.isArray(t)||(t=[t]),e?t.map(t=>"string"==typeof t||i?e(t):t):t);const Ve=new class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||kt(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=Ne(t);let n;for(let a=0;a<this.parsers.length;a++){const t=this.parsers[a];if(t.test(e)){n=t.getCacheableAssets(i,e);break}}const r=new Map(Object.entries(n||{}));n||i.forEach(t=>{r.set(t,e)});const s=[...r.keys()],o={cacheKeys:s,keys:i};i.forEach(t=>{this._cacheMap.set(t,o)}),s.forEach(t=>{const i=n?n[t]:e;this._cache.has(t)&&this._cache.get(t)!==i&&kt("[Cache] already has key:",t),this._cache.set(t,r.get(t))})}remove(t){if(!this._cacheMap.has(t))return void kt(`[Assets] Asset id ${t} was not found in the Cache`);const e=this._cacheMap.get(t);e.cacheKeys.forEach(t=>{this._cache.delete(t)}),e.keys.forEach(t=>{this._cacheMap.delete(t)})}get parsers(){return this._parsers}},He=[];function We(t={}){const e=t&&t.resource,i=e?t.resource:t,n=e?t:{resource:t};for(let r=0;r<He.length;r++){const t=He[r];if(t.test(i))return new t(n)}throw new Error(`Could not find a source type for resource: ${n.resource}`)}h.handleByList(o.TextureSource,He),J.from=function(t,e=!1){return"string"==typeof t?Ve.get(t):t instanceof q?new J({source:t}):function(t={},e=!1){const i=t&&t.resource,n=i?t.resource:t,r=i?t:{resource:t};if(!e&&Ve.has(n))return Ve.get(n);const s=new J({source:We(r)});return s.on("destroy",()=>{Ve.has(n)&&Ve.remove(n)}),e||Ve.set(n,s),s}(t,e)},q.from=We,h.add(Ce,Pe,Me,ze,Be,Fe,K);var je=(t=>(t[t.Low=0]="Low",t[t.Normal=1]="Normal",t[t.High=2]="High",t))(je||{});function Ye(t){if("string"!=typeof t)throw new TypeError(`Path must be a string. Received ${JSON.stringify(t)}`)}function Xe(t){return t.split("?")[0].split("#")[0]}const Ze={toPosix(t){return e="\\",i="/",t.replace(new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),i);var e,i},isUrl(t){return/^https?:/.test(this.toPosix(t))},isDataUrl:t=>/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(t),isBlobUrl:t=>t.startsWith("blob:"),hasProtocol(t){return/^[^/:]+:/.test(this.toPosix(t))},getProtocol(t){Ye(t),t=this.toPosix(t);const e=/^file:\/\/\//.exec(t);if(e)return e[0];const i=/^[^/:]+:\/{0,2}/.exec(t);return i?i[0]:""},toAbsolute(t,e,i){if(Ye(t),this.isDataUrl(t)||this.isBlobUrl(t))return t;const n=Xe(this.toPosix(null!=e?e:Re.get().getBaseUrl())),r=Xe(this.toPosix(null!=i?i:this.rootname(n)));if((t=this.toPosix(t)).startsWith("/"))return Ze.join(r,t.slice(1));return this.isAbsolute(t)?t:this.join(n,t)},normalize(t){if(Ye(t),0===t.length)return".";if(this.isDataUrl(t)||this.isBlobUrl(t))return t;let e="";const i=(t=this.toPosix(t)).startsWith("/");this.hasProtocol(t)&&(e=this.rootname(t),t=t.slice(e.length));const n=t.endsWith("/");return(t=function(t){let e="",i=0,n=-1,r=0,s=-1;for(let o=0;o<=t.length;++o){if(o<t.length)s=t.charCodeAt(o);else{if(47===s)break;s=47}if(47===s){if(n===o-1||1===r);else if(n!==o-1&&2===r){if(e.length<2||2!==i||46!==e.charCodeAt(e.length-1)||46!==e.charCodeAt(e.length-2))if(e.length>2){const t=e.lastIndexOf("/");if(t!==e.length-1){-1===t?(e="",i=0):(e=e.slice(0,t),i=e.length-1-e.lastIndexOf("/")),n=o,r=0;continue}}else if(2===e.length||1===e.length){e="",i=0,n=o,r=0;continue}}else e.length>0?e+=`/${t.slice(n+1,o)}`:e=t.slice(n+1,o),i=o-n-1;n=o,r=0}else 46===s&&-1!==r?++r:r=-1}return e}(t)).length>0&&n&&(t+="/"),i?`/${t}`:e+t},isAbsolute(t){return Ye(t),t=this.toPosix(t),!!this.hasProtocol(t)||t.startsWith("/")},join(...t){var e;if(0===t.length)return".";let i;for(let n=0;n<t.length;++n){const r=t[n];if(Ye(r),r.length>0)if(void 0===i)i=r;else{const s=null!=(e=t[n-1])?e:"";this.joinExtensions.includes(this.extname(s).toLowerCase())?i+=`/../${r}`:i+=`/${r}`}}return void 0===i?".":this.normalize(i)},dirname(t){if(Ye(t),0===t.length)return".";let e=(t=this.toPosix(t)).charCodeAt(0);const i=47===e;let n=-1,r=!0;const s=this.getProtocol(t),o=t;for(let a=(t=t.slice(s.length)).length-1;a>=1;--a)if(e=t.charCodeAt(a),47===e){if(!r){n=a;break}}else r=!1;return-1===n?i?"/":this.isUrl(o)?s+t:s:i&&1===n?"//":s+t.slice(0,n)},rootname(t){Ye(t);let e="";if(e=(t=this.toPosix(t)).startsWith("/")?"/":this.getProtocol(t),this.isUrl(t)){const i=t.indexOf("/",e.length);e=-1!==i?t.slice(0,i):t,e.endsWith("/")||(e+="/")}return e},basename(t,e){Ye(t),e&&Ye(e),t=Xe(this.toPosix(t));let i,n=0,r=-1,s=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";let o=e.length-1,a=-1;for(i=t.length-1;i>=0;--i){const l=t.charCodeAt(i);if(47===l){if(!s){n=i+1;break}}else-1===a&&(s=!1,a=i+1),o>=0&&(l===e.charCodeAt(o)?-1===--o&&(r=i):(o=-1,r=a))}return n===r?r=a:-1===r&&(r=t.length),t.slice(n,r)}for(i=t.length-1;i>=0;--i)if(47===t.charCodeAt(i)){if(!s){n=i+1;break}}else-1===r&&(s=!1,r=i+1);return-1===r?"":t.slice(n,r)},extname(t){Ye(t);let e=-1,i=0,n=-1,r=!0,s=0;for(let o=(t=Xe(this.toPosix(t))).length-1;o>=0;--o){const a=t.charCodeAt(o);if(47!==a)-1===n&&(r=!1,n=o+1),46===a?-1===e?e=o:1!==s&&(s=1):-1!==e&&(s=-1);else if(!r){i=o+1;break}}return-1===e||-1===n||0===s||1===s&&e===n-1&&e===i+1?"":t.slice(e,n)},parse(t){Ye(t);const e={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return e;let i=(t=Xe(this.toPosix(t))).charCodeAt(0);const n=this.isAbsolute(t);let r;e.root=this.rootname(t),r=n||this.hasProtocol(t)?1:0;let s=-1,o=0,a=-1,l=!0,h=t.length-1,c=0;for(;h>=r;--h)if(i=t.charCodeAt(h),47!==i)-1===a&&(l=!1,a=h+1),46===i?-1===s?s=h:1!==c&&(c=1):-1!==s&&(c=-1);else if(!l){o=h+1;break}return-1===s||-1===a||0===c||1===c&&s===a-1&&s===o+1?-1!==a&&(e.base=e.name=0===o&&n?t.slice(1,a):t.slice(o,a)):(0===o&&n?(e.name=t.slice(1,s),e.base=t.slice(1,a)):(e.name=t.slice(o,s),e.base=t.slice(o,a)),e.ext=t.slice(s,a)),e.dir=this.dirname(t),e},sep:"/",delimiter:":",joinExtensions:[".html"]};function qe(t,e,i,n,r){const s=e[i];for(let o=0;o<s.length;o++){const a=s[o];i<e.length-1?qe(t.replace(n[i],a),e,i+1,n,r):r.push(t.replace(n[i],a))}}function Ke(t){const e=t.match(/\{(.*?)\}/g),i=[];if(e){const n=[];e.forEach(t=>{const e=t.substring(1,t.length-1).split(",");n.push(e)}),qe(t,n,0,e,i)}else i.push(t);return i}const $e=t=>!Array.isArray(t);class Qe{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){var e,i,n;if(this._bundleIdConnector=null!=(e=t.connector)?e:this._bundleIdConnector,this._createBundleAssetId=null!=(i=t.createBundleAssetId)?i:this._createBundleAssetId,this._extractAssetIdFromBundle=null!=(n=t.extractAssetIdFromBundle)?n:this._extractAssetIdFromBundle,"bar"!==this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar")))throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if("string"==typeof t)this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return Ne(e||i,t=>"string"==typeof t?t:Array.isArray(t)?t.map(t=>{var e;return null!=(e=null==t?void 0:t.src)?e:t}):(null==t?void 0:t.src)?t.src:t,!0)}addManifest(t){this._manifest&&kt("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(t,e){const i=[];let n=e;Array.isArray(e)||(n=Object.entries(e).map(([t,e])=>"string"==typeof e||Array.isArray(e)?{alias:t,src:e}:__spreadValues({alias:t},e))),n.forEach(e=>{const n=e.src,r=e.alias;let s;if("string"==typeof r){const e=this._createBundleAssetId(t,r);i.push(e),s=[r,e]}else{const e=r.map(e=>this._createBundleAssetId(t,e));i.push(...e),s=[...r,...e]}this.add(__spreadValues(__spreadValues({},e),{alias:s,src:n}))}),this._bundles[t]=i}add(t){const e=[];let i;Array.isArray(t)?e.push(...t):e.push(t),i=t=>{this.hasKey(t)&&kt(`[Resolver] already has key: ${t} overwriting`)};Ne(e).forEach(t=>{const{src:e}=t;let{data:n,format:r,loadParser:s,parser:o}=t;const a=Ne(e).map(t=>"string"==typeof t?Ke(t):Array.isArray(t)?t:[t]),l=this.getAlias(t);Array.isArray(l)?l.forEach(i):i(l);const h=[];a.forEach(t=>{t.forEach(t=>{var e,i,a,c;let u={};if("object"!=typeof t){u.src=t;for(let e=0;e<this._parsers.length;e++){const i=this._parsers[e];if(i.test(t)){u=i.parse(t);break}}}else n=null!=(e=t.data)?e:n,r=null!=(i=t.format)?i:r,(t.loadParser||t.parser)&&(s=null!=(a=t.loadParser)?a:s,o=null!=(c=t.parser)?c:o),u=__spreadValues(__spreadValues({},u),t);if(!l)throw new Error(`[Resolver] alias is undefined for this asset: ${u.src}`);u=this._buildResolvedAsset(u,{aliases:l,data:n,format:r,loadParser:s,parser:o}),h.push(u)})}),l.forEach(t=>{this._assetMap[t]=h})})}resolveBundle(t){const e=$e(t);t=Ne(t);const i={};return t.forEach(t=>{const e=this._bundles[t];if(e){const n=this.resolve(e),r={};for(const e in n){const i=n[e];r[this._extractAssetIdFromBundle(t,e)]=i}i[t]=r}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if("string"!=typeof t){const t={};for(const i in e)t[i]=e[i].src;return t}return e.src}resolve(t){const e=$e(t);t=Ne(t);const i={};return t.forEach(t=>{if(!this._resolverHash[t])if(this._assetMap[t]){let e=this._assetMap[t];const i=this._getPreferredOrder(e);null==i||i.priority.forEach(t=>{i.params[t].forEach(i=>{const n=e.filter(e=>!!e[t]&&e[t]===i);n.length&&(e=n)})}),this._resolverHash[t]=e[0]}else this._resolverHash[t]=this._buildResolvedAsset({alias:[t],src:t},{});i[t]=this._resolverHash[t]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[e],n=this._preferredOrder.find(t=>t.params.format.includes(i.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;return`${t}${/\?/.test(t)?"&":"?"}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){var i,n;const{aliases:r,data:s,loadParser:o,parser:a,format:l}=e;return(this._basePath||this._rootPath)&&(t.src=Ze.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=null!=(i=null!=r?r:t.alias)?i:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=__spreadValues(__spreadValues({},s||{}),t.data),t.loadParser=null!=o?o:t.loadParser,t.parser=null!=a?a:t.parser,t.format=null!=(n=null!=l?l:t.format)?n:t.src.split(".").pop().split("?").shift().split("#").shift(),t}}Qe.RETINA_PREFIX=/@([0-9\.]+)x/;const Je=(t,e)=>{const i=e.split("?")[1];return i&&(t+=`?${i}`),t},ti=class t{constructor(t,e){this.linkedSheets=[];let i=t;(null==t?void 0:t.source)instanceof q&&(i={texture:t,data:e});const{texture:n,data:r,cachePrefix:s=""}=i;this.cachePrefix=s,this._texture=n instanceof J?n:null,this.textureSource=n.source,this.textures={},this.animations={},this.data=r;const o=parseFloat(r.meta.scale);o?(this.resolution=o,n.source.resolution=this.resolution):this.resolution=n.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=t.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(e){let i=e;const n=t.BATCH_SIZE;for(;i-e<n&&i<this._frameKeys.length;){const t=this._frameKeys[i],e=this._frames[t],n=e.frame;if(n){let i=null,r=null;const s=!1!==e.trimmed&&e.sourceSize?e.sourceSize:e.frame,o=new D(0,0,Math.floor(s.w)/this.resolution,Math.floor(s.h)/this.resolution);i=e.rotated?new D(Math.floor(n.x)/this.resolution,Math.floor(n.y)/this.resolution,Math.floor(n.h)/this.resolution,Math.floor(n.w)/this.resolution):new D(Math.floor(n.x)/this.resolution,Math.floor(n.y)/this.resolution,Math.floor(n.w)/this.resolution,Math.floor(n.h)/this.resolution),!1!==e.trimmed&&e.spriteSourceSize&&(r=new D(Math.floor(e.spriteSourceSize.x)/this.resolution,Math.floor(e.spriteSourceSize.y)/this.resolution,Math.floor(n.w)/this.resolution,Math.floor(n.h)/this.resolution)),this.textures[t]=new J({source:this.textureSource,frame:i,orig:o,trim:r,rotate:e.rotated?2:0,defaultAnchor:e.anchor,defaultBorders:e.borders,label:t.toString()})}i++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const n=t[e][i];this.animations[e].push(this.textures[n])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*t.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*t.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(null==(e=this._texture)||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};ti.BATCH_SIZE=1e3;let ei=ti;const ii=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function ni(t,e,i){const n={};if(t.forEach(t=>{n[t]=e}),Object.keys(e.textures).forEach(t=>{n[`${e.cachePrefix}${t}`]=e.textures[t]}),!i){const i=Ze.dirname(t[0]);e.linkedSheets.forEach((t,r)=>{const s=ni([`${i}/${e.data.meta.related_multi_packs[r]}`],t,!0);Object.assign(n,s)})}return n}const ri={extension:o.Asset,cache:{test:t=>t instanceof ei,getCacheableAssets:(t,e)=>ni(t,e,!1)},resolver:{extension:{type:o.ResolveParser,name:"resolveSpritesheet"},test:t=>{const e=t.split("?")[0].split("."),i=e.pop(),n=e.pop();return"json"===i&&ii.includes(n)},parse:t=>{var e,i;const n=t.split(".");return{resolution:parseFloat(null!=(i=null==(e=Qe.RETINA_PREFIX.exec(t))?void 0:e[1])?i:"1"),format:n[n.length-2],src:t}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:o.LoadParser,priority:je.Normal,name:"spritesheetLoader"},testParse(t,e){return __async(this,null,function*(){return".json"===Ze.extname(e.src).toLowerCase()&&!!t.frames})},parse(t,e,i){return __async(this,null,function*(){var n,r,s;const{texture:o,imageFilename:a,textureOptions:l,cachePrefix:h}=null!=(n=null==e?void 0:e.data)?n:{};let c,u=Ze.dirname(e.src);if(u&&u.lastIndexOf("/")!==u.length-1&&(u+="/"),o instanceof J)c=o;else{const n=Je(u+(null!=a?a:t.meta.image),e.src);c=(yield i.load([{src:n,data:l}]))[n]}const d=new ei({texture:c.source,data:t,cachePrefix:h});yield d.parse();const p=null==(r=null==t?void 0:t.meta)?void 0:r.related_multi_packs;if(Array.isArray(p)){const t=[];for(const r of p){if("string"!=typeof r)continue;let n=u+r;(null==(s=e.data)?void 0:s.ignoreMultiPack)||(n=Je(n,e.src),t.push(i.load({src:n,data:{textureOptions:l,ignoreMultiPack:!0}})))}const n=yield Promise.all(t);d.linkedSheets=n,n.forEach(t=>{t.linkedSheets=[d].concat(d.linkedSheets.filter(e=>e!==t))})}return d})},unload(t,e,i){return __async(this,null,function*(){yield i.unload(t.textureSource._sourceOrigin),t.destroy(!1)})}}};h.add(ri);class si{constructor(t){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),e=this._canvas.width,i=this._canvas.height,n=t.width/e*this._renderer.resolution,r=t.height/i*this._renderer.resolution,s=`translate(${t.left}px, ${t.top}px) scale(${n}, ${r})`;s!==this._lastTransform&&(this._domElement.style.transform=s,this._lastTransform=s)},this._domElement=t.domElement,this._renderer=t.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(t=>{for(const e of t){if(e.target!==this._canvas)continue;const t=this.canvas.width,i=this.canvas.height,n=e.contentRect.width/t*this._renderer.resolution,r=e.contentRect.height/i*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==r)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=r)}}),this._observer.observe(this._canvas)):this._tickerAttached||Ue.shared.add(this.updateTranslation,this,ke.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&Ue.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 oi{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=oi.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new v,this.page=new v,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return!this.manager||this.path&&this.path[this.path.length-1]===this.target||(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,n,r){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 ai=/iPhone/i,li=/iPod/i,hi=/iPad/i,ci=/\biOS-universal(?:.+)Mac\b/i,ui=/\bAndroid(?:.+)Mobile\b/i,di=/Android/i,pi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,fi=/Silk/i,gi=/Windows Phone/i,mi=/\bWindows(?:.+)ARM\b/i,_i=/BlackBerry/i,yi=/BB10/i,xi=/Opera Mini/i,bi=/\b(CriOS|Chrome)(?:.+)Mobile/i,vi=/Mobile(?:.+)Firefox\b/i,wi=function(t){return void 0!==t&&"MacIntel"===t.platform&&"number"==typeof t.maxTouchPoints&&t.maxTouchPoints>1&&"undefined"==typeof MSStream};function Si(t){var e={userAgent:"",platform:"",maxTouchPoints:0};t||"undefined"==typeof navigator?"string"==typeof t?e.userAgent=t:t&&t.userAgent&&(e={userAgent:t.userAgent,platform:t.platform,maxTouchPoints:t.maxTouchPoints||0}):e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};var i=e.userAgent,n=i.split("[FBAN");void 0!==n[1]&&(i=n[0]),void 0!==(n=i.split("Twitter"))[1]&&(i=n[0]);var r=function(t){return function(e){return e.test(t)}}(i),s={apple:{phone:r(ai)&&!r(gi),ipod:r(li),tablet:!r(ai)&&(r(hi)||wi(e))&&!r(gi),universal:r(ci),device:(r(ai)||r(li)||r(hi)||r(ci)||wi(e))&&!r(gi)},amazon:{phone:r(pi),tablet:!r(pi)&&r(fi),device:r(pi)||r(fi)},android:{phone:!r(gi)&&r(pi)||!r(gi)&&r(ui),tablet:!r(gi)&&!r(pi)&&!r(ui)&&(r(fi)||r(di)),device:!r(gi)&&(r(pi)||r(fi)||r(ui)||r(di))||r(/\bokhttp\b/i)},windows:{phone:r(gi),tablet:r(mi),device:r(gi)||r(mi)},other:{blackberry:r(_i),blackberry10:r(yi),opera:r(xi),firefox:r(vi),chrome:r(bi),device:r(_i)||r(yi)||r(xi)||r(vi)||r(bi)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}const Ai=(null!=(t=Si.default)?t:Si)(globalThis.navigator),Ti=class t{constructor(t,e=Ai){this._mobileInfo=e,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pool=[],this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._hookDiv=null,(e.tablet||e.phone)&&this._createTouchHook(),this._renderer=t}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}_createTouchHook(){const t=document.createElement("button");t.style.width="1px",t.style.height="1px",t.style.position="absolute",t.style.top="-1000px",t.style.left="-1000px",t.style.zIndex=2..toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top="0px",this._div.style.left="0px",this._div.style.pointerEvents="none",this._div.style.zIndex=2..toString(),this._canvasObserver=new si({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&(this._onKeyDown=this._onKeyDown.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)),this._deactivateOnMouseMove&&(this._onMouseMove=this._onMouseMove.bind(this),globalThis.document.addEventListener("mousemove",this._onMouseMove,!0));const t=this._renderer.view.canvas;if(t.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const e=new MutationObserver(()=>{t.parentNode&&(e.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});e.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(this._isActive&&!this._isMobileAccessibility){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const t of this._children)t._accessibleDiv&&t._accessibleDiv.parentNode&&(t._accessibleDiv.parentNode.removeChild(t._accessibleDiv),t._accessibleDiv=null),t._accessibleActive=!1;this._pool.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this._div&&this._div.parentNode&&this._div.parentNode.removeChild(this._div),this._pool=[],this._children=[]}}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this._updateAccessibleObjects(e[i])}init(e){const i=t.defaultOptions,n={accessibilityOptions:__spreadValues(__spreadValues({},i),(null==e?void 0:e.accessibilityOptions)||{})};this.debug=n.accessibilityOptions.debug,this._activateOnTab=n.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=n.accessibilityOptions.deactivateOnMouseMove,n.accessibilityOptions.enabledByDefault?this._activate():this._activateOnTab&&(this._onKeyDown=this._onKeyDown.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)),this._renderer.runners.postrender.remove(this)}postrender(){const t=performance.now();if(this._mobileInfo.android.device&&t<this._androidUpdateCount)return;if(this._androidUpdateCount=t+this._androidUpdateFrequency,!this._renderer.renderingToScreen||!this._renderer.view.canvas)return;const e=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const t of this._children)t._renderId===this._renderId&&e.add(this._children.indexOf(t))}for(let i=this._children.length-1;i>=0;i--){const t=this._children[i];e.has(i)||(t._accessibleDiv&&t._accessibleDiv.parentNode&&(t._accessibleDiv.parentNode.removeChild(t._accessibleDiv),this._pool.push(t._accessibleDiv),t._accessibleDiv=null),t._accessibleActive=!1,Ut(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i<this._children.length;i++){const t=this._children[i];if(!t._accessibleActive||!t._accessibleDiv)continue;const e=t._accessibleDiv,n=t.hitArea||t.getBounds().rectangle;if(t.hitArea){const i=t.worldTransform;e.style.left=`${i.tx+n.x*i.a}px`,e.style.top=`${i.ty+n.y*i.d}px`,e.style.width=n.width*i.a+"px",e.style.height=n.height*i.d+"px"}else this._capHitArea(n),e.style.left=`${n.x}px`,e.style.top=`${n.y}px`,e.style.width=`${n.width}px`,e.style.height=`${n.height}px`}this._renderId++}_updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}_capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}_addChild(t){let e=this._pool.pop();e||("button"===t.accessibleType?e=document.createElement("button"):(e=document.createElement(t.accessibleType),e.style.cssText="\n color: transparent;\n pointer-events: none;\n padding: 0;\n margin: 0;\n border: 0;\n outline: 0;\n background: transparent;\n box-sizing: border-box;\n user-select: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n ",t.accessibleText&&(e.innerText=t.accessibleText)),e.style.width="100px",e.style.height="100px",e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=2..toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&null!==t.accessibleTitle?e.title=t.accessibleTitle:t.accessibleHint&&null!==t.accessibleHint||(e.title=`container ${t.tabIndex}`),t.accessibleHint&&null!==t.accessibleHint&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv),t.interactive&&(t._accessibleDiv.tabIndex=t.tabIndex)}_dispatchEvent(t,e){const{container:i}=t.target,n=this._renderer.events.rootBoundary,r=Object.assign(new oi(n),{target:i});n.rootTarget=this._renderer.lastObjectRendered,e.forEach(t=>n.dispatchEvent(r,t))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){9===t.keyCode&&this._activateOnTab&&this._activate()}_onMouseMove(t){0===t.movementX&&0===t.movementY||this._deactivate()}destroy(){var t;this._deactivate(),this._destroyTouchHook(),null==(t=this._canvasObserver)||t.destroy(),this._canvasObserver=null,this._div=null,this._pool=null,this._children=null,this._renderer=null,this._activateOnTab&&globalThis.removeEventListener("keydown",this._onKeyDown)}setAccessibilityEnabled(t){t?this._activate():this._deactivate()}};Ti.extension={type:[o.WebGLSystem,o.WebGPUSystem],name:"accessibility"},Ti.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let Ci=Ti;const Pi=Object.create(null),Mi=Object.create(null);function Ei(t,e){let i=Mi[t];return void 0===i&&(void 0===Pi[e]&&(Pi[e]=1),Mi[t]=i=Pi[e]++),i}let Ri,Fi;function Bi(){if(!Ri||(null==Ri?void 0:Ri.isContextLost())){const t=Re.get().createCanvas();Ri=t.getContext("webgl",{})}return Ri}function ki(){if(!Fi){Fi="mediump";const t=Bi();if(t&&t.getShaderPrecisionFormat){const e=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT);Fi=e.precision?"highp":"mediump"}}return Fi}const Ii={},Di={};const Oi={stripVersion:function(t,e){return e?t.replace("#version 300 es",""):t},ensurePrecision:function(t,e,i){const n=i?e.maxSupportedFragmentPrecision:e.maxSupportedVertexPrecision;if("precision"!==t.substring(0,9)){let r=i?e.requestedFragmentPrecision:e.requestedVertexPrecision;return"highp"===r&&"highp"!==n&&(r="mediump"),`precision ${r} float;\n${t}`}return"highp"!==n&&"precision highp"===t.substring(0,15)?t.replace("precision highp","precision mediump"):t},addProgramDefines:function(t,e,i){return e?t:i?`\n\n #ifdef GL_ES // This checks if it is WebGL1\n #define in varying\n #define finalColor gl_FragColor\n #define texture texture2D\n #endif\n ${t=t.replace("out vec4 finalColor;","")}\n `:`\n\n #ifdef GL_ES // This checks if it is WebGL1\n #define in attribute\n #define out varying\n #endif\n ${t}\n `},setProgramName:function(t,{name:e="pixi-program"},i=!0){e=e.replace(/\s+/g,"-");const n=i?Ii:Di;return n[e+=i?"-fragment":"-vertex"]?(n[e]++,e+=`-${n[e]}`):n[e]=1,-1!==t.indexOf("#define SHADER_NAME")?t:`${`#define SHADER_NAME ${e}`}\n${t}`},insertVersion:function(t,e){return e?`#version 300 es\n${t}`:t}},Ui=Object.create(null),Gi=class t{constructor(e){const i=-1!==(e=__spreadValues(__spreadValues({},t.defaultOptions),e)).fragment.indexOf("#version 300 es"),n={stripVersion:i,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:ki()},setProgramName:{name:e.name},addProgramDefines:i,insertVersion:i};let r=e.fragment,s=e.vertex;Object.keys(Oi).forEach(t=>{const e=n[t];r=Oi[t](r,e,!0),s=Oi[t](s,e,!1)}),this.fragment=r,this.vertex=s,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=Ei(`${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}static from(e){const i=`${e.vertex}:${e.fragment}`;return Ui[i]||(Ui[i]=new t(e)),Ui[i]}};Gi.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Li=Gi;const zi={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 Ni(t){var e;return null!=(e=zi[t])?e:zi.float32}const Vi={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"};function Hi(t){var e,i,n;const r=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,o=/var(<[^>]+>)? (\w+)/,a=/:\s*(\w+)/,l=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,c=null==(e=t.match(/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g))?void 0:e.map(t=>({group:parseInt(t.match(r)[1],10),binding:parseInt(t.match(s)[1],10),name:t.match(o)[2],isUniform:"<uniform>"===t.match(o)[1],type:t.match(a)[1]}));if(!c)return{groups:[],structs:[]};const u=null!=(n=null==(i=t.match(/struct\s+(\w+)\s*{([^}]+)}/g))?void 0:i.map(t=>{const e=t.match(h)[1],i=t.match(l).reduce((t,e)=>{const[i,n]=e.split(":");return t[i.trim()]=n.trim(),t},{});return i?{name:e,members:i}:null}).filter(({name:t})=>c.some(e=>e.type===t)))?n:[];return{groups:c,structs:u}}var Wi=(t=>(t[t.VERTEX=1]="VERTEX",t[t.FRAGMENT=2]="FRAGMENT",t[t.COMPUTE=4]="COMPUTE",t))(Wi||{});const ji=Object.create(null);class Yi{constructor(t){var e,i;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:n,vertex:r,layout:s,gpuLayout:o,name:a}=t;if(this.name=a,this.fragment=n,this.vertex=r,n.source===r.source){const t=Hi(n.source);this.structsAndGroups=t}else{const t=Hi(r.source),e=Hi(n.source);this.structsAndGroups=function(t,e){const i=new Set,n=new Set;return{structs:[...t.structs,...e.structs].filter(t=>!i.has(t.name)&&(i.add(t.name),!0)),groups:[...t.groups,...e.groups].filter(t=>{const e=`${t.name}-${t.binding}`;return!n.has(e)&&(n.add(e),!0)})}}(t,e)}this.layout=null!=s?s:function({groups:t}){const e=[];for(let i=0;i<t.length;i++){const n=t[i];e[n.group]||(e[n.group]={}),e[n.group][n.name]=n.binding}return e}(this.structsAndGroups),this.gpuLayout=null!=o?o:function({groups:t}){const e=[];for(let i=0;i<t.length;i++){const n=t[i];e[n.group]||(e[n.group]=[]),n.isUniform?e[n.group].push({binding:n.binding,visibility:Wi.VERTEX|Wi.FRAGMENT,buffer:{type:"uniform"}}):"sampler"===n.type?e[n.group].push({binding:n.binding,visibility:Wi.FRAGMENT,sampler:{type:"filtering"}}):"texture_2d"===n.type&&e[n.group].push({binding:n.binding,visibility:Wi.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return e}(this.structsAndGroups),this.autoAssignGlobalUniforms=!(void 0===(null==(e=this.layout[0])?void 0:e.globalUniforms)),this.autoAssignLocalUniforms=!(void 0===(null==(i=this.layout[1])?void 0:i.localUniforms)),this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Ei(i,"program")}get attributeData(){return null!=this._attributeData||(this._attributeData=function({source:t,entryPoint:e}){var i;const n={},r=t.indexOf(`fn ${e}`);if(-1!==r){const e=t.indexOf("->",r);if(-1!==e){const s=t.substring(r,e),o=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let a;for(;null!==(a=o.exec(s));){const t=null!=(i=Vi[a[3]])?i:"float32";n[a[2]]={location:parseInt(a[1],10),format:t,stride:Ni(t).stride,offset:0,instance:!1,start:0}}}}return n}(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return ji[e]||(ji[e]=new Yi(t)),ji[e]}}const Xi=["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>"],Zi=Xi.reduce((t,e)=>(t[e]=!0,t),{});function qi(t,e){switch(t){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 Ki=class t{constructor(e,i){var n;this._touched=0,this.uid=U("uniform"),this._resourceType="uniformGroup",this._resourceId=U("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,i=__spreadValues(__spreadValues({},t.defaultOptions),i),this.uniformStructures=e;const r={};for(const t in e){const i=e[t];if(i.name=t,i.size=null!=(n=i.size)?n:1,!Zi[i.type])throw new Error(`Uniform type ${i.type} is not supported. Supported uniform types are: ${Xi.join(", ")}`);null!=i.value||(i.value=qi(i.type,i.size)),r[t]=i.value}this.uniforms=r,this._dirtyId=1,this.ubo=i.ubo,this.isStatic=i.isStatic,this._signature=Ei(Object.keys(r).map(t=>`${t}-${e[t].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Ki.defaultOptions={ubo:!1,isStatic:!1};let $i=Ki;class Qi{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const n=t[i];this.setResource(n,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var i,n;const r=this.resources[e];t!==r&&(r&&(null==(i=t.off)||i.call(t,"change",this.onResourceChange,this)),null==(n=t.on)||n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const i in e)e[i]._touched=t}destroy(){var t;const e=this.resources;for(const i in e){const n=e[i];null==(t=n.off)||t.call(n,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var Ji=(t=>(t[t.WEBGL=1]="WEBGL",t[t.WEBGPU=2]="WEBGPU",t[t.BOTH=3]="BOTH",t))(Ji||{});class tn extends _{constructor(t){super(),this.uid=U("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:i,groups:n,resources:r,compatibleRenderers:s,groupMap:o}=t;this.gpuProgram=e,this.glProgram=i,void 0===s&&(s=0,e&&(s|=Ji.WEBGPU),i&&(s|=Ji.WEBGL)),this.compatibleRenderers=s;const a={};if(r||n||(r={}),r&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&o)for(const l in o)for(const t in o[l]){const e=o[l][t];a[e]={group:l,binding:t,name:e}}else if(e&&n&&!o){const t=e.structsAndGroups.groups;o={},t.forEach(t=>{o[t.group]=o[t.group]||{},o[t.group][t.binding]=t.name,a[t.name]=t})}else if(r){if(n={},o={},e){e.structsAndGroups.groups.forEach(t=>{o[t.group]=o[t.group]||{},o[t.group][t.binding]=t.name,a[t.name]=t})}let t=0;for(const e in r)a[e]||(n[99]||(n[99]=new Qi,this._ownedBindGroups.push(n[99])),a[e]={group:99,binding:t,name:e},o[99]=o[99]||{},o[99][t]=e,t++);for(const e in r){const t=e;let i=r[e];i.source||i._resourceType||(i=new $i(i));const s=a[t];s&&(n[s.group]||(n[s.group]=new Qi,this._ownedBindGroups.push(n[s.group])),n[s.group].setResource(i,s.binding))}}this.groups=n,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(n,a)}addResource(t,e,i){var n,r;(n=this._uniformBindMap)[e]||(n[e]={}),(r=this._uniformBindMap[e])[i]||(r[i]=t),this.groups[e]||(this.groups[e]=new Qi,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const n in e){const r=e[n];Object.defineProperty(i,r.name,{get:()=>t[r.group].getResource(r.binding),set(e){t[r.group].setResource(e,r.binding)}})}return i}destroy(t=!1){var e,i;this.emit("destroy",this),t&&(null==(e=this.gpuProgram)||e.destroy(),null==(i=this.glProgram)||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(t=>{t.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const e=t,{gpu:i,gl:n}=e,r=__objRest(e,["gpu","gl"]);let s,o;return i&&(s=Yi.from(i)),n&&(o=Li.from(n)),new tn(__spreadValues({gpuProgram:s,glProgram:o},r))}}const en={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},nn=class t{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(1&this.data)}set blend(t){!!(1&this.data)!==t&&(this.data^=1)}get offsets(){return!!(2&this.data)}set offsets(t){!!(2&this.data)!==t&&(this.data^=2)}set cullMode(t){"none"!==t?(this.culling=!0,this.clockwiseFrontFace="front"===t):this.culling=!1}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(4&this.data)}set culling(t){!!(4&this.data)!==t&&(this.data^=4)}get depthTest(){return!!(8&this.data)}set depthTest(t){!!(8&this.data)!==t&&(this.data^=8)}get depthMask(){return!!(32&this.data)}set depthMask(t){!!(32&this.data)!==t&&(this.data^=32)}get clockwiseFrontFace(){return!!(16&this.data)}set clockwiseFrontFace(t){!!(16&this.data)!==t&&(this.data^=16)}get blendMode(){return this._blendMode}set blendMode(t){this.blend="none"!==t,this._blendMode=t,this._blendModeId=en[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const e=new t;return e.depthTest=!1,e.blend=!0,e}};nn.default2d=nn.for2d();let rn=nn;const sn=class t extends tn{constructor(e){super(e=__spreadValues(__spreadValues({},t.defaultOptions),e)),this.enabled=!0,this._state=rn.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,"boolean"==typeof e.antialias?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)}apply(t,e,i,n){t.applyFilter(this,e,i,n)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(e){const i=e,{gpu:n,gl:r}=i,s=__objRest(i,["gpu","gl"]);let o,a;return n&&(o=Yi.from(n)),r&&(a=Li.from(r)),new t(__spreadValues({gpuProgram:o,glProgram:a},s))}};sn.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let on=sn;const an=[];let ln;function hn(){if("boolean"==typeof ln)return ln;try{const t=new Function("param1","param2","param3","return param1[param2] === param3;");ln=!0===t({a:"b"},"a","b")}catch(t){ln=!1}return ln}function cn(t,e,i=2){const n=e&&e.length,r=n?e[0]*i:t.length;let s=un(t,0,r,i,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,h;if(n&&(s=function(t,e,i,n){const r=[];for(let s=0,o=e.length;s<o;s++){const i=un(t,e[s]*n,s<o-1?e[s+1]*n:t.length,n,!1);i===i.next&&(i.steiner=!0),r.push(wn(i))}r.sort(yn);for(let s=0;s<r.length;s++)i=xn(r[s],i);return i}(t,e,s,i)),t.length>80*i){a=t[0],l=t[1];let e=a,n=l;for(let s=i;s<r;s+=i){const i=t[s],r=t[s+1];i<a&&(a=i),r<l&&(l=r),i>e&&(e=i),r>n&&(n=r)}h=Math.max(e-a,n-l),h=0!==h?32767/h:0}return pn(s,o,i,a,l,h,0),o}function un(t,e,i,n,r){let s;if(r===function(t,e,i,n){let r=0;for(let s=e,o=i-n;s<i;s+=n)r+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return r}(t,e,i,n)>0)for(let o=e;o<i;o+=n)s=kn(o/n|0,t[o],t[o+1],s);else for(let o=i-n;o>=e;o-=n)s=kn(o/n|0,t[o],t[o+1],s);return s&&Pn(s,s.next)&&(In(s),s=s.next),s}function dn(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!Pn(n,n.next)&&0!==Cn(n.prev,n,n.next))n=n.next;else{if(In(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function pn(t,e,i,n,r,s,o){if(!t)return;!o&&s&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=vn(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let s=null;for(e=0;r;){e++;let o=r,a=0;for(let t=0;t<i&&(a++,o=o.nextZ,o);t++);let l=i;for(;a>0||l>0&&o;)0!==a&&(0===l||!o||r.z<=o.z)?(n=r,r=r.nextZ,a--):(n=o,o=o.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;r=o}s.nextZ=null,i*=2}while(e>1)}(r)}(t,n,r,s);let a=t;for(;t.prev!==t.next;){const l=t.prev,h=t.next;if(s?gn(t,n,r,s):fn(t))e.push(l.i,t.i,h.i),In(t),t=h.next,a=h.next;else if((t=h)===a){o?1===o?pn(t=mn(dn(t),e),e,i,n,r,s,2):2===o&&_n(t,e,i,n,r,s):pn(dn(t),e,i,n,r,s,1);break}}}function fn(t){const e=t.prev,i=t,n=t.next;if(Cn(e,i,n)>=0)return!1;const r=e.x,s=i.x,o=n.x,a=e.y,l=i.y,h=n.y,c=Math.min(r,s,o),u=Math.min(a,l,h),d=Math.max(r,s,o),p=Math.max(a,l,h);let f=n.next;for(;f!==e;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&An(r,a,s,l,o,h,f.x,f.y)&&Cn(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function gn(t,e,i,n){const r=t.prev,s=t,o=t.next;if(Cn(r,s,o)>=0)return!1;const a=r.x,l=s.x,h=o.x,c=r.y,u=s.y,d=o.y,p=Math.min(a,l,h),f=Math.min(c,u,d),g=Math.max(a,l,h),m=Math.max(c,u,d),_=vn(p,f,e,i,n),y=vn(g,m,e,i,n);let x=t.prevZ,b=t.nextZ;for(;x&&x.z>=_&&b&&b.z<=y;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==r&&x!==o&&An(a,c,l,u,h,d,x.x,x.y)&&Cn(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==r&&b!==o&&An(a,c,l,u,h,d,b.x,b.y)&&Cn(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;x&&x.z>=_;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==r&&x!==o&&An(a,c,l,u,h,d,x.x,x.y)&&Cn(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==r&&b!==o&&An(a,c,l,u,h,d,b.x,b.y)&&Cn(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function mn(t,e){let i=t;do{const n=i.prev,r=i.next.next;!Pn(n,r)&&Mn(n,i,i.next,r)&&Fn(n,r)&&Fn(r,n)&&(e.push(n.i,i.i,r.i),In(i),In(i.next),i=t=r),i=i.next}while(i!==t);return dn(i)}function _n(t,e,i,n,r,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&Tn(o,t)){let a=Bn(o,t);return o=dn(o,o.next),a=dn(a,a.next),pn(o,e,i,n,r,s,0),void pn(a,e,i,n,r,s,0)}t=t.next}o=o.next}while(o!==t)}function yn(t,e){let i=t.x-e.x;if(0===i&&(i=t.y-e.y,0===i)){i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return i}function xn(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let s,o=-1/0;if(Pn(t,i))return i;do{if(Pn(t,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>o&&(o=t,s=i.x<i.next.x?i:i.next,t===n))return s}i=i.next}while(i!==e);if(!s)return null;const a=s,l=s.x,h=s.y;let c=1/0;i=s;do{if(n>=i.x&&i.x>=l&&n!==i.x&&Sn(r<h?n:o,r,l,h,r<h?o:n,r,i.x,i.y)){const e=Math.abs(r-i.y)/(n-i.x);Fn(i,t)&&(e<c||e===c&&(i.x>s.x||i.x===s.x&&bn(s,i)))&&(s=i,c=e)}i=i.next}while(i!==a);return s}(t,e);if(!i)return e;const n=Bn(i,t);return dn(n,n.next),dn(i,i.next)}function bn(t,e){return Cn(t.prev,t,e.prev)<0&&Cn(e.next,t,t.next)<0}function vn(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function wn(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function Sn(t,e,i,n,r,s,o,a){return(r-o)*(e-a)>=(t-o)*(s-a)&&(t-o)*(n-a)>=(i-o)*(e-a)&&(i-o)*(s-a)>=(r-o)*(n-a)}function An(t,e,i,n,r,s,o,a){return!(t===o&&e===a)&&Sn(t,e,i,n,r,s,o,a)}function Tn(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Mn(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Fn(t,e)&&Fn(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(Cn(t.prev,t,e.prev)||Cn(t,e.prev,e))||Pn(t,e)&&Cn(t.prev,t,t.next)>0&&Cn(e.prev,e,e.next)>0)}function Cn(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Pn(t,e){return t.x===e.x&&t.y===e.y}function Mn(t,e,i,n){const r=Rn(Cn(t,e,i)),s=Rn(Cn(t,e,n)),o=Rn(Cn(i,n,t)),a=Rn(Cn(i,n,e));return r!==s&&o!==a||(!(0!==r||!En(t,i,e))||(!(0!==s||!En(t,n,e))||(!(0!==o||!En(i,t,n))||!(0!==a||!En(i,e,n)))))}function En(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Rn(t){return t>0?1:t<0?-1:0}function Fn(t,e){return Cn(t.prev,t,t.next)<0?Cn(t,e,t.next)>=0&&Cn(t,t.prev,e)>=0:Cn(t,e,t.prev)<0||Cn(t,t.next,e)<0}function Bn(t,e){const i=Dn(t.i,t.x,t.y),n=Dn(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function kn(t,e,i,n){const r=Dn(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function In(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Dn(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}h.handleByNamedList(o.Environment,an);const On=cn.default||cn;var Un=(t=>(t[t.NONE=0]="NONE",t[t.COLOR=16384]="COLOR",t[t.STENCIL=1024]="STENCIL",t[t.DEPTH=256]="DEPTH",t[t.COLOR_DEPTH=16640]="COLOR_DEPTH",t[t.COLOR_STENCIL=17408]="COLOR_STENCIL",t[t.DEPTH_STENCIL=1280]="DEPTH_STENCIL",t[t.ALL=17664]="ALL",t))(Un||{});class Gn{constructor(t){this.items=[],this._name=t}emit(t,e,i,n,r,s,o,a){const{name:l,items:h}=this;for(let c=0,u=h.length;c<u;c++)h[c][l](t,e,i,n,r,s,o,a);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return-1!==e&&this.items.splice(e,1),this}contains(t){return-1!==this.items.indexOf(t)}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return 0===this.items.length}get name(){return this._name}}const Ln=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],zn=class t extends _{constructor(t){var e;super(),this.uid=U("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const i=[...Ln,...null!=(e=this.config.runners)?e:[]];this._addRunners(...i),this._unsafeEvalCheck()}init(){return __async(this,arguments,function*(e={}){const i=!0===e.skipExtensionImports||!1===e.manageImports;yield function(t){return __async(this,null,function*(){if(!t)for(let t=0;t<an.length;t++){const e=an[t];if(e.value.test())return void(yield e.value.load())}})}(i),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const t in this._systemsHash){const i=this._systemsHash[t].constructor.defaultOptions;e=__spreadValues(__spreadValues({},i),e)}e=__spreadValues(__spreadValues({},t.defaultOptions),e),this._roundPixels=e.roundPixels?1:0;for(let t=0;t<this.runners.init.items.length;t++)yield this.runners.init.items[t].init(e);this._initOptions=e})}render(t,e){let i=t;if(i instanceof xe&&(i={container:i},e&&(z(L,"passing a second argument is deprecated, please use render options instead"),i.target=e.renderTexture)),i.target||(i.target=this.view.renderTarget),i.target===this.view.renderTarget&&(this._lastObjectRendered=i.container,null!=i.clearColor||(i.clearColor=this.background.colorRgba),null!=i.clear||(i.clear=this.background.clearBeforeRender)),i.clearColor){const t=Array.isArray(i.clearColor)&&4===i.clearColor.length;i.clearColor=t?i.clearColor:Ft.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),i.container.enableRenderGroup(),this.runners.prerender.emit(i),this.runners.renderStart.emit(i),this.runners.render.emit(i),this.runners.renderEnd.emit(i),this.runners.postrender.emit(i)}resize(t,e,i){const n=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),void 0!==i&&i!==n&&this.runners.resolutionChange.emit(i)}clear(t={}){t.target||(t.target=this.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),null!=t.clear||(t.clear=Un.ALL);const{clear:e,clearColor:i,target:n}=t;Ft.shared.setValue(null!=i?i:this.background.colorRgba),this.renderTarget.clear(n,e,Ft.shared.toArray())}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(t=>{this.runners[t]=new Gn(t)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const n in this.runners)this.runners[n].add(i);return this}_addPipes(t,e){const i=e.reduce((t,e)=>(t[e.name]=e.value,t),{});t.forEach(t=>{const e=t.value,n=t.name,r=i[n];this.renderPipes[n]=new e(this,r?new r:null)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!hn())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()}};zn.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Nn,Vn,Hn=zn;function Wn(t){return void 0!==Nn||(Nn=(()=>{var e;const i={stencil:!0,failIfMajorPerformanceCaveat:null!=t?t:Hn.defaultOptions.failIfMajorPerformanceCaveat};try{if(!Re.get().getWebGLRenderingContext())return!1;let t=Re.get().createCanvas().getContext("webgl",i);const n=!!(null==(e=null==t?void 0:t.getContextAttributes())?void 0:e.stencil);if(t){const e=t.getExtension("WEBGL_lose_context");e&&e.loseContext()}return t=null,n}catch(n){return!1}})()),Nn}function jn(){return __async(this,arguments,function*(t={}){return void 0!==Vn||(Vn=yield __async(null,null,function*(){const e=Re.get().getNavigator().gpu;if(!e)return!1;try{const i=yield e.requestAdapter(t);return yield i.requestDevice(),!0}catch(i){return!1}})),Vn})}const Yn=["webgl","webgpu","canvas"];const Xn="8.12.0";class Zn{static init(){var t;null==(t=globalThis.__PIXI_APP_INIT__)||t.call(globalThis,this,Xn)}static destroy(){}}Zn.extension=o.Application;class qn{constructor(t){this._renderer=t}init(){var t;null==(t=globalThis.__PIXI_RENDERER_INIT__)||t.call(globalThis,this._renderer,Xn)}destroy(){this._renderer=null}}qn.extension={type:[o.WebGLSystem,o.WebGPUSystem],name:"initHook",priority:-10};const Kn=class t{constructor(...t){this.stage=new xe,void 0!==t[0]&&z(L,"Application constructor options are deprecated, please use Application.init() instead.")}init(e){return __async(this,null,function*(){e=__spreadValues({},e),this.renderer=yield function(t){return __async(this,null,function*(){var e;let i,n=[];t.preference?(n.push(t.preference),Yn.forEach(e=>{e!==t.preference&&n.push(e)})):n=Yn.slice();let o={};for(let l=0;l<n.length;l++){const a=n[l];if("webgpu"===a&&(yield jn())){const{WebGPURenderer:e}=yield s(()=>__async(null,null,function*(){const{WebGPURenderer:t}=yield Promise.resolve().then(()=>Zu);return{WebGPURenderer:t}}),0,r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("assets/index-DFAEtWgf.js",document.baseURI).href);i=e,o=__spreadValues(__spreadValues({},t),t.webgpu);break}if("webgl"===a&&Wn(null!=(e=t.failIfMajorPerformanceCaveat)?e:Hn.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:e}=yield s(()=>__async(null,null,function*(){const{WebGLRenderer:t}=yield Promise.resolve().then(()=>lu);return{WebGLRenderer:t}}),0,r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("assets/index-DFAEtWgf.js",document.baseURI).href);i=e,o=__spreadValues(__spreadValues({},t),t.webgl);break}if("canvas"===a)throw o=__spreadValues({},t),new Error("CanvasRenderer is not yet implemented")}if(delete o.webgpu,delete o.webgl,!i)throw new Error("No available renderer for the current environment");const a=new i;return yield a.init(o),a})}(e),t._plugins.forEach(t=>{t.init.call(this,e)})})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return z(L,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(e=!1,i=!1){const n=t._plugins.slice(0);n.reverse(),n.forEach(t=>{t.destroy.call(this)}),this.stage.destroy(i),this.stage=null,this.renderer.destroy(e),this.renderer=null}};Kn._plugins=[];let $n=Kn;h.handleByList(o.Application,$n._plugins),h.add(Zn);class Qn{static init(t){Object.defineProperty(this,"resizeTo",{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;let t,e;if(this._cancelResize(),this._resizeTo===globalThis.window)t=globalThis.innerWidth,e=globalThis.innerHeight;else{const{clientWidth:i,clientHeight:n}=this._resizeTo;t=i,e=n}this.renderer.resize(t,e),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Qn.extension=o.Application;class Jn{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,ke.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Ue.shared:new Ue,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Jn.extension=o.Application;class tr extends _{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return z(L,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return z(L,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return z(L,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return z(L,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return z(L,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const i in this.chars)null==(e=this.chars[i].texture)||e.destroy();this.chars=null,t&&(this.pages.forEach(t=>t.texture.destroy(!0)),this.pages=null)}}const er=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function ir(t){const e="number"==typeof t.fontSize?`${t.fontSize}px`:t.fontSize;let i=t.fontFamily;Array.isArray(t.fontFamily)||(i=t.fontFamily.split(","));for(let n=i.length-1;n>=0;n--){let t=i[n].trim();/([\"\'])[^\'\"]+\1/.test(t)||er.includes(t)||(t=`"${t}"`),i[n]=t}return`${t.fontStyle} ${t.fontVariant} ${t.fontWeight} ${e} ${i.join(",")}`}const nr={willReadFrequently:!0},rr=class t{static get experimentalLetterSpacingSupported(){let e=t._experimentalLetterSpacingSupported;if(void 0===e){const i=Re.get().getCanvasRenderingContext2D().prototype;e=t._experimentalLetterSpacingSupported="letterSpacing"in i||"textLetterSpacing"in i}return e}constructor(t,e,i,n,r,s,o,a,l){this.text=t,this.style=e,this.width=i,this.height=n,this.lines=r,this.lineWidths=s,this.lineHeight=o,this.maxLineWidth=a,this.fontProperties=l}static measureText(e=" ",i,n=t._canvas,r=i.wordWrap){var s;const o=ir(i),a=t.measureFont(o);0===a.fontSize&&(a.fontSize=i.fontSize,a.ascent=i.fontSize);const l=t.__context;l.font=o;const h=(r?t._wordWrap(e,i,n):e).split(/(?:\r\n|\r|\n)/),c=new Array(h.length);let u=0;for(let m=0;m<h.length;m++){const e=t._measureText(h[m],i.letterSpacing,l);c[m]=e,u=Math.max(u,e)}const d=(null==(s=i._stroke)?void 0:s.width)||0;let p=u+d;i.dropShadow&&(p+=i.dropShadow.distance);const f=i.lineHeight||a.fontSize;let g=Math.max(f,a.fontSize+d)+(h.length-1)*(f+i.leading);i.dropShadow&&(g+=i.dropShadow.distance);return new t(e,i,p,g,h,c,f+i.leading,u,a)}static _measureText(e,i,n){let r=!1;t.experimentalLetterSpacingSupported&&(t.experimentalLetterSpacing?(n.letterSpacing=`${i}px`,n.textLetterSpacing=`${i}px`,r=!0):(n.letterSpacing="0px",n.textLetterSpacing="0px"));const s=n.measureText(e);let o=s.width;const a=-s.actualBoundingBoxLeft;let l=s.actualBoundingBoxRight-a;if(o>0)if(r)o-=i,l-=i;else{const n=(t.graphemeSegmenter(e).length-1)*i;o+=n,l+=n}return Math.max(o,l)}static _wordWrap(e,i,n=t._canvas){const r=n.getContext("2d",nr);let s=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:c}=i,u=t._collapseSpaces(c),d=t._collapseNewlines(c);let p=!u;const f=i.wordWrapWidth+h,g=t._tokenize(e);for(let m=0;m<g.length;m++){let e=g[m];if(t._isNewline(e)){if(!d){a+=t._addLine(o),p=!u,o="",s=0;continue}e=" "}if(u){const i=t.isBreakingSpace(e),n=t.isBreakingSpace(o[o.length-1]);if(i&&n)continue}const n=t._getFromCache(e,h,l,r);if(n>f)if(""!==o&&(a+=t._addLine(o),o="",s=0),t.canBreakWords(e,i.breakWords)){const n=t.wordWrapSplit(e);for(let c=0;c<n.length;c++){let u=n[c],d=u,g=1;for(;n[c+g];){const r=n[c+g];if(t.canBreakChars(d,r,e,c,i.breakWords))break;u+=r,d=r,g++}c+=g-1;const m=t._getFromCache(u,h,l,r);m+s>f&&(a+=t._addLine(o),p=!1,o="",s=0),o+=u,s+=m}}else{o.length>0&&(a+=t._addLine(o),o="",s=0);const i=m===g.length-1;a+=t._addLine(e,!i),p=!1,o="",s=0}else n+s>f&&(p=!1,a+=t._addLine(o),o="",s=0),(o.length>0||!t.isBreakingSpace(e)||p)&&(o+=e,s+=n)}return a+=t._addLine(o,!1),a}static _addLine(e,i=!0){return e=t._trimRight(e),e=i?`${e}\n`:e}static _getFromCache(e,i,n,r){let s=n[e];return"number"!=typeof s&&(s=t._measureText(e,i,r)+i,n[e]=s),s}static _collapseSpaces(t){return"normal"===t||"pre-line"===t}static _collapseNewlines(t){return"normal"===t}static _trimRight(e){if("string"!=typeof e)return"";for(let i=e.length-1;i>=0;i--){const n=e[i];if(!t.isBreakingSpace(n))break;e=e.slice(0,-1)}return e}static _isNewline(e){return"string"==typeof e&&t._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,i){return"string"==typeof e&&t._breakingSpaces.includes(e.charCodeAt(0))}static _tokenize(e){const i=[];let n="";if("string"!=typeof e)return i;for(let r=0;r<e.length;r++){const s=e[r],o=e[r+1];t.isBreakingSpace(s,o)||t._isNewline(s)?(""!==n&&(i.push(n),n=""),"\r"===s&&"\n"===o?(i.push("\r\n"),r++):i.push(s)):n+=s}return""!==n&&i.push(n),i}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,n,r){return!0}static wordWrapSplit(e){return t.graphemeSegmenter(e)}static measureFont(e){if(t._fonts[e])return t._fonts[e];const i=t._context;i.font=e;const n=i.measureText(t.METRICS_STRING+t.BASELINE_SYMBOL),r={ascent:n.actualBoundingBoxAscent,descent:n.actualBoundingBoxDescent,fontSize:n.actualBoundingBoxAscent+n.actualBoundingBoxDescent};return t._fonts[e]=r,r}static clearMetrics(e=""){e?delete t._fonts[e]:t._fonts={}}static get _canvas(){if(!t.__canvas){let i;try{const e=new OffscreenCanvas(0,0),n=e.getContext("2d",nr);if(null==n?void 0:n.measureText)return t.__canvas=e,e;i=Re.get().createCanvas()}catch(e){i=Re.get().createCanvas()}i.width=i.height=10,t.__canvas=i}return t.__canvas}static get _context(){return t.__context||(t.__context=t._canvas.getContext("2d",nr)),t.__context}};rr.METRICS_STRING="|ÉqÅ",rr.BASELINE_SYMBOL="M",rr.BASELINE_MULTIPLIER=1.4,rr.HEIGHT_MULTIPLIER=2,rr.graphemeSegmenter=(()=>t=>[...t])(),rr.experimentalLetterSpacing=!1,rr._fonts={},rr._newlines=[10,13],rr._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let sr=rr;const or=[{offset:0,color:"white"},{offset:1,color:"black"}],ar=class t{constructor(...e){var i;this.uid=U("fillGradient"),this.type="linear",this.colorStops=[];let n=function(t){var e,i;let n=null!=(e=t[0])?e:{};("number"==typeof n||t[1])&&(z("8.5.2","use options object instead"),n={type:"linear",start:{x:t[0],y:t[1]},end:{x:t[2],y:t[3]},textureSpace:t[4],textureSize:null!=(i=t[5])?i:lr.defaultLinearOptions.textureSize});return n}(e);const r="radial"===n.type?t.defaultRadialOptions:t.defaultLinearOptions;n=__spreadValues(__spreadValues({},r),W(n)),this._textureSize=n.textureSize,this._wrapMode=n.wrapMode,"radial"===n.type?(this.center=n.center,this.outerCenter=null!=(i=n.outerCenter)?i:this.center,this.innerRadius=n.innerRadius,this.outerRadius=n.outerRadius,this.scale=n.scale,this.rotation=n.rotation):(this.start=n.start,this.end=n.end),this.textureSpace=n.textureSpace,this.type=n.type,n.colorStops.forEach(t=>{this.addColorStop(t.offset,t.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:Ft.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:n}=this.end,r=i-t,s=n-e;const o=r<0||s<0;if("clamp-to-edge"===this._wrapMode){if(r<0){const e=t;t=i,i=e,r*=-1}if(s<0){const t=e;e=n,n=t,s*=-1}}const a=this.colorStops.length?this.colorStops:or,l=this._textureSize,{canvas:h,context:c}=cr(l,1),u=o?c.createLinearGradient(this._textureSize,0,0,0):c.createLinearGradient(0,0,this._textureSize,0);hr(u,a),c.fillStyle=u,c.fillRect(0,0,l,1),this.texture=new J({source:new Be({resource:h,addressMode:this._wrapMode})});const d=Math.sqrt(r*r+s*s),p=Math.atan2(s,r),f=new S;f.scale(d/l,1),f.rotate(p),f.translate(t,e),"local"===this.textureSpace&&f.scale(l,l),this.transform=f}buildGradient(){"linear"===this.type?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:or,e=this._textureSize,{canvas:i,context:n}=cr(e,e),{x:r,y:s}=this.center,{x:o,y:a}=this.outerCenter,l=this.innerRadius,h=this.outerRadius,c=o-h,u=a-h,d=e/(2*h),p=(r-c)*d,f=(s-u)*d,g=n.createRadialGradient(p,f,l*d,(o-c)*d,(a-u)*d,h*d);hr(g,t),n.fillStyle=t[t.length-1].color,n.fillRect(0,0,e,e),n.fillStyle=g,n.translate(p,f),n.rotate(this.rotation),n.scale(1,this.scale),n.translate(-p,-f),n.fillRect(0,0,e,e),this.texture=new J({source:new Be({resource:i,addressMode:this._wrapMode})});const m=new S;m.scale(1/d,1/d),m.translate(c,u),"local"===this.textureSpace&&m.scale(e,e),this.transform=m}get styleKey(){return this.uid}destroy(){var t;null==(t=this.texture)||t.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}};ar.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},ar.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let lr=ar;function hr(t,e){for(let i=0;i<e.length;i++){const n=e[i];t.addColorStop(n.offset,n.color)}}function cr(t,e){const i=Re.get().createCanvas(t,e),n=i.getContext("2d");return{canvas:i,context:n}}const ur={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 dr{constructor(t,e){this.uid=U("fillPattern"),this.transform=new S,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=ur[e].addressModeU,t.source.style.addressModeV=ur[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._styleKey=null}get styleKey(){return this._styleKey||(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join("-")}`),this._styleKey}destroy(){this.texture.destroy(!0),this.texture=null,this._styleKey=null}}var pr,fr;const gr=p(function(){if(fr)return pr;fr=1,pr=function(n){var r=[];return n.replace(e,function(e,n,s){var o=n.toLowerCase();for(s=function(t){var e=t.match(i);return e?e.map(Number):[]}(s),"m"==o&&s.length>2&&(r.push([n].concat(s.splice(0,2))),o="l",n="m"==n?"l":"L");;){if(s.length==t[o])return s.unshift(n),r.push(s);if(s.length<t[o])throw new Error("malformed path data");r.push([n].concat(s.splice(0,t[o])))}}),r};var t={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},e=/([astvzqmhlc])([^astvzqmhlc]*)/gi,i=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;return pr}());class mr{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new mr(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-t,r=this.y-e;return n*=n,r*=r,n+r<=i}strokeContains(t,e,i,n=.5){if(0===this.radius)return!1;const r=this.x-t,s=this.y-e,o=this.radius,a=(1-n)*i,l=Math.sqrt(r*r+s*s);return l<=o+a&&l>o-(i-a)}getBounds(t){return t||(t=new D),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=2*this.radius,t.height=2*this.radius,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class _r{constructor(t=0,e=0,i=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=n}clone(){return new _r(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,n=(e-this.y)/this.halfHeight;return i*=i,n*=n,i+n<=1}strokeContains(t,e,i,n=.5){const{halfWidth:r,halfHeight:s}=this;if(r<=0||s<=0)return!1;const o=i*(1-n),a=i-o,l=r-a,h=s-a,c=r+o,u=s+o,d=t-this.x,p=e-this.y;return d*d/(l*l)+p*p/(h*h)>1&&d*d/(c*c)+p*p/(u*u)<=1}getBounds(t){return t||(t=new D),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=2*this.halfWidth,t.height=2*this.halfHeight,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function yr(t,e,i,n,r,s){const o=r-i,a=s-n,l=o*o+a*a;let h,c,u=-1;0!==l&&(u=((t-i)*o+(e-n)*a)/l),u<0?(h=i,c=n):u>1?(h=r,c=s):(h=i+u*o,c=n+u*a);const d=t-h,p=e-c;return d*d+p*p}class xr{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if("number"!=typeof e[0]){const t=[];for(let i=0,n=e.length;i<n;i++)t.push(e[i].x,e[i].y);e=t}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,i=e.length;for(let n=0;n<i;n+=2){const r=e[n],s=e[n+1];t+=(e[(n+2)%i]-r)*(e[(n+3)%i]+s)}return t<0}containsPolygon(t){const e=this.getBounds(undefined),i=t.getBounds(undefined);if(!e.containsRect(i))return!1;const n=t.points;for(let r=0;r<n.length;r+=2){const t=n[r],e=n[r+1];if(!this.contains(t,e))return!1}return!0}clone(){const t=this.points.slice(),e=new xr(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const n=this.points.length/2;for(let r=0,s=n-1;r<n;s=r++){const n=this.points[2*r],o=this.points[2*r+1],a=this.points[2*s],l=this.points[2*s+1];o>e!=l>e&&t<(e-o)/(l-o)*(a-n)+n&&(i=!i)}return i}strokeContains(t,e,i,n=.5){const r=i*i,s=r*(1-n),o=r-s,{points:a}=this,l=a.length-(this.closePath?0:2);for(let h=0;h<l;h+=2){const i=a[h],n=a[h+1],r=a[(h+2)%a.length],l=a[(h+3)%a.length];if(yr(t,e,i,n,r,l)<=(Math.sign((r-i)*(e-n)-(l-n)*(t-i))<0?o:s))return!0}return!1}getBounds(t){t||(t=new D);const e=this.points;let i=1/0,n=-1/0,r=1/0,s=-1/0;for(let o=0,a=e.length;o<a;o+=2){const t=e[o],a=e[o+1];i=t<i?t:i,n=t>n?t:n,r=a<r?a:r,s=a>s?a:s}return t.x=i,t.width=n-i,t.y=r,t.height=s-r,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return z("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return z("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 br=(t,e,i,n,r,s,o)=>{const a=t-i,l=e-n,h=Math.sqrt(a*a+l*l);return h>=r-s&&h<=r+o};class vr{constructor(t=0,e=0,i=0,n=0,r=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=n,this.radius=r}getBounds(t){return t||(t=new D),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new vr(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let n=t-(this.x+i),r=e-(this.y+i);const s=i*i;if(n*n+r*r<=s)return!0;if(n=t-(this.x+this.width-i),n*n+r*r<=s)return!0;if(r=e-(this.y+this.height-i),n*n+r*r<=s)return!0;if(n=t-(this.x+i),n*n+r*r<=s)return!0}return!1}strokeContains(t,e,i,n=.5){const{x:r,y:s,width:o,height:a,radius:l}=this,h=i*(1-n),c=i-h,u=r+l,d=s+l,p=r+o,f=s+a;return(t>=r-h&&t<=r+c||t>=p-c&&t<=p+h)&&e>=d&&e<=d+(a-2*l)||((e>=s-h&&e<=s+c||e>=f-c&&e<=f+h)&&t>=u&&t<=u+(o-2*l)||(t<u&&e<d&&br(t,e,u,d,l,c,h)||t>p-l&&e<d&&br(t,e,p-l,d,l,c,h)||t>p-l&&e>f-l&&br(t,e,p-l,f-l,l,c,h)||t<u&&e>f-l&&br(t,e,u,f-l,l,c,h)))}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const wr={};function Sr(t,e,i){let n=2166136261;for(let r=0;r<e;r++)n^=t[r].uid,n=Math.imul(n,16777619),n>>>=0;return wr[n]||function(t,e,i,n){const r={};let s=0;for(let a=0;a<n;a++){const i=a<e?t[a]:J.EMPTY.source;r[s++]=i.source,r[s++]=i.style}const o=new Qi(r);return wr[i]=o,o}(t,e,n,i)}class Ar{constructor(t){"number"==typeof t?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this.uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}function Tr(t,e){const i=t.byteLength/8|0,n=new Float64Array(t,0,i);new Float64Array(e,0,i).set(n);const r=t.byteLength-8*i;if(r>0){const n=new Uint8Array(t,8*i,r);new Uint8Array(e,8*i,r).set(n)}}const Cr={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Pr=(t=>(t[t.DISABLED=0]="DISABLED",t[t.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",t[t.MASK_ACTIVE=2]="MASK_ACTIVE",t[t.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",t[t.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",t[t.NONE=5]="NONE",t))(Pr||{});function Mr(t,e){return"no-premultiply-alpha"===e.alphaMode&&Cr[t]||t}const Er=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join("\n");function Rr(t){let e="";for(let i=0;i<t;++i)i>0&&(e+="\nelse "),i<t-1&&(e+=`if(test == ${i}.0){}`);return e}function Fr(t,e){if(0===t)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const i=e.createShader(e.FRAGMENT_SHADER);try{for(;;){const n=Er.replace(/%forloop%/gi,Rr(t));if(e.shaderSource(i,n),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS))break;t=t/2|0}}finally{e.deleteShader(i)}return t}let Br=null;class kr{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}class Ir{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new kr,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const Dr=[];let Or=0;function Ur(){return Or>0?Dr[--Or]:new Ir}function Gr(t){Dr[Or++]=t}let Lr=0;const zr=class t{constructor(e){this.uid=U("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],(e=__spreadValues(__spreadValues({},t.defaultOptions),e)).maxTextures||(z("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),e.maxTextures=function(){var t;if(Br)return Br;const e=Bi();return Br=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),Br=Fr(Br,e),null==(t=e.getExtension("WEBGL_lose_context"))||t.loseContext(),Br}());const{maxTextures:i,attributesInitialSize:n,indicesInitialSize:r}=e;this.attributeBuffer=new Ar(4*n),this.indexBuffer=new Uint16Array(r),this.maxTextures=i}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)Gr(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const i=t._batch.textures.ids[e._source.uid];return!(!i&&0!==i)&&(t._textureId=i,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let i=Ur(),n=i.textures;n.clear();const r=e[this.elementStart];let s=Mr(r.blendMode,r.texture._source),o=r.topology;4*this.attributeSize>this.attributeBuffer.size&&this._resizeAttributeBuffer(4*this.attributeSize),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const a=this.attributeBuffer.float32View,l=this.attributeBuffer.uint32View,h=this.indexBuffer;let c=this._batchIndexSize,u=this._batchIndexStart,d="startBatch";const p=this.maxTextures;for(let f=this.elementStart;f<this.elementSize;++f){const r=e[f];e[f]=null;const g=r.texture._source,m=Mr(r.blendMode,g),_=s!==m||o!==r.topology;g._batchTick!==Lr||_?(g._batchTick=Lr,(n.count>=p||_)&&(this._finishBatch(i,u,c-u,n,s,o,t,d),d="renderBatch",u=c,s=m,o=r.topology,i=Ur(),n=i.textures,n.clear(),++Lr),r._textureId=g._textureBindLocation=n.count,n.ids[g.uid]=n.count,n.textures[n.count++]=g,r._batch=i,c+=r.indexSize,r.packAsQuad?(this.packQuadAttributes(r,a,l,r._attributeStart,r._textureId),this.packQuadIndex(h,r._indexStart,r._attributeStart/this.vertexSize)):(this.packAttributes(r,a,l,r._attributeStart,r._textureId),this.packIndex(r,h,r._indexStart,r._attributeStart/this.vertexSize))):(r._textureId=g._textureBindLocation,c+=r.indexSize,r.packAsQuad?(this.packQuadAttributes(r,a,l,r._attributeStart,r._textureId),this.packQuadIndex(h,r._indexStart,r._attributeStart/this.vertexSize)):(this.packAttributes(r,a,l,r._attributeStart,r._textureId),this.packIndex(r,h,r._indexStart,r._attributeStart/this.vertexSize)),r._batch=i)}n.count>0&&(this._finishBatch(i,u,c-u,n,s,o,t,d),u=c,++Lr),this.elementStart=this.elementSize,this._batchIndexStart=u,this._batchIndexSize=c}_finishBatch(t,e,i,n,r,s,o,a){t.gpuBindGroup=null,t.bindGroup=null,t.action=a,t.batcher=this,t.textures=n,t.blendMode=r,t.topology=s,t.start=e,t.size=i,++Lr,this.batches[this.batchIndex++]=t,o.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){4*t<=this.attributeBuffer.size||this._resizeAttributeBuffer(4*t)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,2*this.attributeBuffer.size),i=new Ar(e);Tr(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,1.5*e.length);i+=i%2;const n=i>65535?new Uint32Array(i):new Uint16Array(i);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let r=0;r<e.length;r++)n[r]=e[r];else Tr(e.buffer,n.buffer);this.indexBuffer=n}packQuadIndex(t,e,i){t[e]=i+0,t[e+1]=i+1,t[e+2]=i+2,t[e+3]=i+0,t[e+4]=i+2,t[e+5]=i+3}packIndex(t,e,i,n){const r=t.indices,s=t.indexSize,o=t.indexOffset,a=t.attributeOffset;for(let l=0;l<s;l++)e[i++]=n+r[l+o]-a}destroy(){for(let t=0;t<this.batches.length;t++)Gr(this.batches[t]);this.batches=null;for(let t=0;t<this._elements.length;t++)this._elements[t]._batch=null;this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}};zr.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Nr=zr;var Vr=(t=>(t[t.MAP_READ=1]="MAP_READ",t[t.MAP_WRITE=2]="MAP_WRITE",t[t.COPY_SRC=4]="COPY_SRC",t[t.COPY_DST=8]="COPY_DST",t[t.INDEX=16]="INDEX",t[t.VERTEX=32]="VERTEX",t[t.UNIFORM=64]="UNIFORM",t[t.STORAGE=128]="STORAGE",t[t.INDIRECT=256]="INDIRECT",t[t.QUERY_RESOLVE=512]="QUERY_RESOLVE",t[t.STATIC=1024]="STATIC",t))(Vr||{});let Hr=class extends _{constructor(t){let{data:e,size:i}=t;const{usage:n,label:r,shrinkToFit:s}=t;super(),this.uid=U("buffer"),this._resourceType="buffer",this._resourceId=U("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,null!=i||(i=null==e?void 0:e.byteLength);const o=!!e;this.descriptor={size:i,usage:n,mappedAtCreation:o,label:r},this.shrinkToFit=null==s||s}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&Vr.STATIC)}set static(t){t?this.descriptor.usage|=Vr.STATIC:this.descriptor.usage&=~Vr.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t)return void(i&&this.emit("update",this));const n=this._data;this._data=t,this._dataInt32=null,n&&n.length===t.length||!this.shrinkToFit&&n&&t.byteLength<n.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=U("resource"),this.emit("change",this))}update(t){this._updateSize=null!=t?t:this._updateSize,this._updateID++,this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}};function Wr(t,e){if(!(t instanceof Hr)){let i=e?Vr.INDEX:Vr.VERTEX;t instanceof Array&&(e?(t=new Uint32Array(t),i=Vr.INDEX|Vr.COPY_DST):(t=new Float32Array(t),i=Vr.VERTEX|Vr.COPY_DST)),t=new Hr({data:t,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:i})}return t}class jr extends _{constructor(t={}){var e;super(),this.uid=U("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new it,this._boundsDirty=!0;const{attributes:i,indexBuffer:n,topology:r}=t;if(this.buffers=[],this.attributes={},i)for(const s in i)this.addAttribute(s,i[s]);this.instanceCount=null!=(e=t.instanceCount)?e:1,n&&this.addIndex(n),this.topology=r||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){const i=function(t){return(t instanceof Hr||Array.isArray(t)||t.BYTES_PER_ELEMENT)&&(t={buffer:t}),t.buffer=Wr(t.buffer,!1),t}(e);-1===this.buffers.indexOf(i.buffer)&&(this.buffers.push(i.buffer),i.buffer.on("update",this.onBufferUpdate,this),i.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=i}addIndex(t){this.indexBuffer=Wr(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,function(t,e,i){const n=t.getAttribute(e);if(!n)return i.minX=0,i.minY=0,i.maxX=0,i.maxY=0,i;const r=n.buffer.data;let s=1/0,o=1/0,a=-1/0,l=-1/0;const h=r.BYTES_PER_ELEMENT,c=(n.offset||0)/h,u=(n.stride||8)/h;for(let d=c;d<r.length;d+=u){const t=r[d],e=r[d+1];t>a&&(a=t),e>l&&(l=e),t<s&&(s=t),e<o&&(o=e)}return i.minX=s,i.minY=o,i.maxX=a,i.maxY=l,i}(this,"aPosition",this._bounds)):this._bounds}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(t=>t.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Yr=new Float32Array(1),Xr=new Uint32Array(1);class Zr extends jr{constructor(){const t=new Hr({data:Yr,label:"attribute-batch-buffer",usage:Vr.VERTEX|Vr.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:24,offset:0},aUV:{buffer:t,format:"float32x2",stride:24,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:24,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:24,offset:20}},indexBuffer:new Hr({data:Xr,label:"index-batch-buffer",usage:Vr.INDEX|Vr.COPY_DST,shrinkToFit:!1})})}}function qr(t,e,i){if(t)for(const n in t){const r=e[n.toLocaleLowerCase()];if(r){let e=t[n];"header"===n&&(e=e.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),i&&r.push(`//----${i}----//`),r.push(e)}else kt(`${n} placement hook does not exist in shader`)}}const Kr=/\{\{(.*?)\}\}/g;function $r(t){var e,i;const n={};return(null!=(i=null==(e=t.match(Kr))?void 0:e.map(t=>t.replace(/[{()}]/g,"")))?i:[]).forEach(t=>{n[t]=[]}),n}function Qr(t,e){let i;const n=/@in\s+([^;]+);/g;for(;null!==(i=n.exec(t));)e.push(i[1])}function Jr(t,e,i=!1){const n=[];Qr(e,n),t.forEach(t=>{t.header&&Qr(t.header,n)});const r=n;i&&r.sort();const s=r.map((t,e)=>` @location(${e}) ${t},`).join("\n");let o=e.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`\n${s}\n`),o}function ts(t,e){let i;const n=/@out\s+([^;]+);/g;for(;null!==(i=n.exec(t));)e.push(i[1])}function es(t,e){let i=t;for(const n in e){const t=e[n];i=t.join("\n").length?i.replace(`{{${n}}}`,`//-----${n} START-----//\n${t.join("\n")}\n//----${n} FINISH----//`):i.replace(`{{${n}}}`,"")}return i}const is=Object.create(null),ns=new Map;let rs=0;function ss({template:t,bits:e}){const i=os(t,e);if(is[i])return is[i];const{vertex:n,fragment:r}=function(t,e){const i=e.map(t=>t.vertex).filter(t=>!!t),n=e.map(t=>t.fragment).filter(t=>!!t);let r=Jr(i,t.vertex,!0);r=function(t,e){const i=[];ts(e,i),t.forEach(t=>{t.header&&ts(t.header,i)});let n=0;const r=i.sort().map(t=>t.indexOf("builtin")>-1?t:`@location(${n++}) ${t}`).join(",\n"),s=i.sort().map(t=>{return` var ${e=t,e.replace(/@.*?\s+/g,"")};`;var e}).join("\n"),o=`return VSOutput(\n ${i.sort().map(t=>` ${function(t){const e=/\b(\w+)\s*:/g.exec(t);return e?e[1]:""}(t)}`).join(",\n")});`;let a=e.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`\n${r}\n`),a=a.replace("{{start}}",`\n${s}\n`),a=a.replace("{{return}}",`\n${o}\n`),a}(i,r);const s=Jr(n,t.fragment,!0);return{vertex:r,fragment:s}}(t,e);return is[i]=as(n,r,e),is[i]}function os(t,e){return e.map(t=>(ns.has(t)||ns.set(t,rs++),ns.get(t))).sort((t,e)=>t-e).join("-")+t.vertex+t.fragment}function as(t,e,i){const n=$r(t),r=$r(e);return i.forEach(t=>{qr(t.vertex,n,t.name),qr(t.fragment,r,t.name)}),{vertex:es(t,n),fragment:es(e,r)}}const ls={name:"global-uniforms-bit",vertex:{header:"\n struct GlobalUniforms {\n uProjectionMatrix:mat3x3<f32>,\n uWorldTransformMatrix:mat3x3<f32>,\n uWorldColorAlpha: vec4<f32>,\n uResolution: vec2<f32>,\n }\n\n @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;\n "}},hs={name:"global-uniforms-bit",vertex:{header:"\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform vec4 uWorldColorAlpha;\n uniform vec2 uResolution;\n "}};function cs({bits:t,name:e}){const i=ss({template:{fragment:"\n @in vUV : vec2<f32>;\n @in vColor : vec4<f32>;\n\n {{header}}\n\n @fragment\n fn main(\n {{in}}\n ) -> @location(0) vec4<f32> {\n\n {{start}}\n\n var outColor:vec4<f32>;\n\n {{main}}\n\n var finalColor:vec4<f32> = outColor * vColor;\n\n {{end}}\n\n return finalColor;\n };\n",vertex:"\n @in aPosition: vec2<f32>;\n @in aUV: vec2<f32>;\n\n @out @builtin(position) vPosition: vec4<f32>;\n @out vUV : vec2<f32>;\n @out vColor : vec4<f32>;\n\n {{header}}\n\n struct VSOutput {\n {{struct}}\n };\n\n @vertex\n fn main( {{in}} ) -> VSOutput {\n\n var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;\n var modelMatrix = mat3x3<f32>(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n );\n var position = aPosition;\n var uv = aUV;\n\n {{start}}\n\n vColor = vec4<f32>(1., 1., 1., 1.);\n\n {{main}}\n\n vUV = uv;\n\n var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;\n\n vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);\n\n vColor *= globalUniforms.uWorldColorAlpha;\n\n {{end}}\n\n {{return}}\n };\n"},bits:[ls,...t]});return Yi.from({name:e,vertex:{source:i.vertex,entryPoint:"main"},fragment:{source:i.fragment,entryPoint:"main"}})}function us({bits:t,name:e}){return new Li(__spreadValues({name:e},function({template:t,bits:e}){const i=os(t,e);return is[i]||(is[i]=as(t.vertex,t.fragment,e)),is[i]}({template:{vertex:"\n in vec2 aPosition;\n in vec2 aUV;\n\n out vec4 vColor;\n out vec2 vUV;\n\n {{header}}\n\n void main(void){\n\n mat3 worldTransformMatrix = uWorldTransformMatrix;\n mat3 modelMatrix = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n );\n vec2 position = aPosition;\n vec2 uv = aUV;\n\n {{start}}\n\n vColor = vec4(1.);\n\n {{main}}\n\n vUV = uv;\n\n mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;\n\n gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n\n vColor *= uWorldColorAlpha;\n\n {{end}}\n }\n",fragment:"\n\n in vec4 vColor;\n in vec2 vUV;\n\n out vec4 finalColor;\n\n {{header}}\n\n void main(void) {\n\n {{start}}\n\n vec4 outColor;\n\n {{main}}\n\n finalColor = outColor * vColor;\n\n {{end}}\n }\n"},bits:[hs,...t]})))}const ds={name:"color-bit",vertex:{header:"\n @in aColor: vec4<f32>;\n ",main:"\n vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);\n "}},ps={name:"color-bit",vertex:{header:"\n in vec4 aColor;\n ",main:"\n vColor *= vec4(aColor.rgb * aColor.a, aColor.a);\n "}},fs={};function gs(t){const e=[];if(1===t)e.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),e.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let i=0;for(let n=0;n<t;n++)e.push(`@group(1) @binding(${i++}) var textureSource${n+1}: texture_2d<f32>;`),e.push(`@group(1) @binding(${i++}) var textureSampler${n+1}: sampler;`)}return e.join("\n")}function ms(t){const e=[];if(1===t)e.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{e.push("switch vTextureId {");for(let i=0;i<t;i++)i===t-1?e.push(" default:{"):e.push(` case ${i}:{`),e.push(` outColor = textureSampleGrad(textureSource${i+1}, textureSampler${i+1}, vUV, uvDx, uvDy);`),e.push(" break;}");e.push("}")}return e.join("\n")}function _s(t){return fs[t]||(fs[t]={name:"texture-batch-bit",vertex:{header:"\n @in aTextureIdAndRound: vec2<u32>;\n @out @interpolate(flat) vTextureId : u32;\n ",main:"\n vTextureId = aTextureIdAndRound.y;\n ",end:"\n if(aTextureIdAndRound.x == 1)\n {\n vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "},fragment:{header:`\n @in @interpolate(flat) vTextureId: u32;\n\n ${gs(t)}\n `,main:`\n var uvDx = dpdx(vUV);\n var uvDy = dpdy(vUV);\n\n ${ms(t)}\n `}}),fs[t]}const ys={};function xs(t){const e=[];for(let i=0;i<t;i++)i>0&&e.push("else"),i<t-1&&e.push(`if(vTextureId < ${i}.5)`),e.push("{"),e.push(`\toutColor = texture(uTextures[${i}], vUV);`),e.push("}");return e.join("\n")}function bs(t){return ys[t]||(ys[t]={name:"texture-batch-bit",vertex:{header:"\n in vec2 aTextureIdAndRound;\n out float vTextureId;\n\n ",main:"\n vTextureId = aTextureIdAndRound.y;\n ",end:"\n if(aTextureIdAndRound.x == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "},fragment:{header:`\n in float vTextureId;\n\n uniform sampler2D uTextures[${t}];\n\n `,main:`\n\n ${xs(t)}\n `}}),ys[t]}const vs={name:"round-pixels-bit",vertex:{header:"\n fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>\n {\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n }\n "}},ws={name:"round-pixels-bit",vertex:{header:"\n vec2 roundPixels(vec2 position, vec2 targetSize)\n {\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n }\n "}},Ss={};function As(t){let e=Ss[t];if(e)return e;const i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=n;return e=Ss[t]=new $i({uTextures:{value:i,type:"i32",size:t}},{isStatic:!0}),e}class Ts extends tn{constructor(t){super({glProgram:us({name:"batch",bits:[ps,bs(t),ws]}),gpuProgram:cs({name:"batch",bits:[ds,_s(t),vs]}),resources:{batchSamplers:As(t)}})}}let Cs=null;const Ps=class t extends Nr{constructor(e){super(e),this.geometry=new Zr,this.name=t.extension.name,this.vertexSize=6,null!=Cs||(Cs=new Ts(e.maxTextures)),this.shader=Cs}packAttributes(t,e,i,n,r){const s=r<<16|65535&t.roundPixels,o=t.transform,a=o.a,l=o.b,h=o.c,c=o.d,u=o.tx,d=o.ty,{positions:p,uvs:f}=t,g=t.color,m=t.attributeOffset,_=m+t.attributeSize;for(let y=m;y<_;y++){const t=2*y,r=p[t],o=p[t+1];e[n++]=a*r+h*o+u,e[n++]=c*o+l*r+d,e[n++]=f[t],e[n++]=f[t+1],i[n++]=g,i[n++]=s}}packQuadAttributes(t,e,i,n,r){const s=t.texture,o=t.transform,a=o.a,l=o.b,h=o.c,c=o.d,u=o.tx,d=o.ty,p=t.bounds,f=p.maxX,g=p.minX,m=p.maxY,_=p.minY,y=s.uvs,x=t.color,b=r<<16|65535&t.roundPixels;e[n+0]=a*g+h*_+u,e[n+1]=c*_+l*g+d,e[n+2]=y.x0,e[n+3]=y.y0,i[n+4]=x,i[n+5]=b,e[n+6]=a*f+h*_+u,e[n+7]=c*_+l*f+d,e[n+8]=y.x1,e[n+9]=y.y1,i[n+10]=x,i[n+11]=b,e[n+12]=a*f+h*m+u,e[n+13]=c*m+l*f+d,e[n+14]=y.x2,e[n+15]=y.y2,i[n+16]=x,i[n+17]=b,e[n+18]=a*g+h*m+u,e[n+19]=c*m+l*g+d,e[n+20]=y.x3,e[n+21]=y.y3,i[n+22]=x,i[n+23]=b}};Ps.extension={type:[o.Batcher],name:"default"};let Ms=Ps;function Es(t,e,i,n,r){const s=e.a,o=e.b,a=e.c,l=e.d,h=e.tx,c=e.ty;i||(i=0),n||(n=2),r||(r=t.length/n-i);let u=i*n;for(let d=0;d<r;d++){const e=t[u],i=t[u+1];t[u]=s*e+a*i+h,t[u+1]=o*e+l*i+c,u+=n}}const Rs=new S;class Fs{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|65280&t|(255&t)<<16,i=this.renderable;return i?$t(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(255*this.alpha<<24)}get transform(){var t;return(null==(t=this.renderable)?void 0:t.groupTransform)||Rs}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}}const Bs={extension:{type:o.ShapeBuilder,name:"circle"},build(t,e){let i,n,r,s,o,a;if("circle"===t.type){const e=t;if(o=a=e.radius,o<=0)return!1;i=e.x,n=e.y,r=s=0}else if("ellipse"===t.type){const e=t;if(o=e.halfWidth,a=e.halfHeight,o<=0||a<=0)return!1;i=e.x,n=e.y,r=s=0}else{const e=t,l=e.width/2,h=e.height/2;i=e.x+l,n=e.y+h,o=a=Math.max(0,Math.min(e.radius,Math.min(l,h))),r=l-o,s=h-a}if(r<0||s<0)return!1;const l=Math.ceil(2.3*Math.sqrt(o+a)),h=8*l+(r?4:0)+(s?4:0);if(0===h)return!1;if(0===l)return e[0]=e[6]=i+r,e[1]=e[3]=n+s,e[2]=e[4]=i-r,e[5]=e[7]=n-s,!0;let c=0,u=4*l+(r?2:0)+2,d=u,p=h,f=r+o,g=s,m=i+f,_=i-f,y=n+g;if(e[c++]=m,e[c++]=y,e[--u]=y,e[--u]=_,s){const t=n-g;e[d++]=_,e[d++]=t,e[--p]=t,e[--p]=m}for(let b=1;b<l;b++){const t=Math.PI/2*(b/l),h=r+Math.cos(t)*o,f=s+Math.sin(t)*a,g=i+h,m=i-h,_=n+f,y=n-f;e[c++]=g,e[c++]=_,e[--u]=_,e[--u]=m,e[d++]=m,e[d++]=y,e[--p]=y,e[--p]=g}f=r,g=s+a,m=i+f,_=i-f,y=n+g;const x=n-g;return e[c++]=m,e[c++]=y,e[--p]=x,e[--p]=m,r&&(e[c++]=_,e[c++]=y,e[--p]=x,e[--p]=_),!0},triangulate(t,e,i,n,r,s){if(0===t.length)return;let o=0,a=0;for(let c=0;c<t.length;c+=2)o+=t[c],a+=t[c+1];o/=t.length/2,a/=t.length/2;let l=n;e[l*i]=o,e[l*i+1]=a;const h=l++;for(let c=0;c<t.length;c+=2)e[l*i]=t[c],e[l*i+1]=t[c+1],c>0&&(r[s++]=l,r[s++]=h,r[s++]=l-1),l++;r[s++]=h+1,r[s++]=h,r[s++]=l-1}},ks=__spreadProps(__spreadValues({},Bs),{extension:__spreadProps(__spreadValues({},Bs.extension),{name:"ellipse"})}),Is=__spreadProps(__spreadValues({},Bs),{extension:__spreadProps(__spreadValues({},Bs.extension),{name:"roundedRectangle"})}),Ds=1e-4;function Os(t,e,i,n,r,s,o,a){let l,h;o?(l=n,h=-i):(l=-n,h=i);const c=t-i*r+l,u=e-n*r+h,d=t+i*s+l,p=e+n*s+h;return a.push(c,u),a.push(d,p),2}function Us(t,e,i,n,r,s,o,a){const l=i-t,h=n-e;let c=Math.atan2(l,h),u=Math.atan2(r-t,s-e);a&&c<u?c+=2*Math.PI:!a&&c>u&&(u+=2*Math.PI);let d=c;const p=u-c,f=Math.abs(p),g=Math.sqrt(l*l+h*h),m=1+(15*f*Math.sqrt(g)/Math.PI|0),_=p/m;if(d+=_,a){o.push(t,e),o.push(i,n);for(let i=1,n=d;i<m;i++,n+=_)o.push(t,e),o.push(t+Math.sin(n)*g,e+Math.cos(n)*g);o.push(t,e),o.push(r,s)}else{o.push(i,n),o.push(t,e);for(let i=1,n=d;i<m;i++,n+=_)o.push(t+Math.sin(n)*g,e+Math.cos(n)*g),o.push(t,e);o.push(r,s),o.push(t,e)}return 2*m}function Gs(t,e,i,n,r,s,o){const a=On(t,e,2);if(!a)return;for(let h=0;h<a.length;h+=3)s[o++]=a[h]+r,s[o++]=a[h+1]+r,s[o++]=a[h+2]+r;let l=r*n;for(let h=0;h<t.length;h+=2)i[l]=t[h],i[l+1]=t[h+1],l+=n}const Ls=[],zs={extension:{type:o.ShapeBuilder,name:"polygon"},build(t,e){for(let i=0;i<t.points.length;i++)e[i]=t.points[i];return!0},triangulate(t,e,i,n,r,s){Gs(t,Ls,e,i,n,r,s)}},Ns={extension:{type:o.ShapeBuilder,name:"rectangle"},build(t,e){const i=t,n=i.x,r=i.y,s=i.width,o=i.height;return s>0&&o>0&&(e[0]=n,e[1]=r,e[2]=n+s,e[3]=r,e[4]=n+s,e[5]=r+o,e[6]=n,e[7]=r+o,!0)},triangulate(t,e,i,n,r,s){let o=0;e[(n*=i)+o]=t[0],e[n+o+1]=t[1],o+=i,e[n+o]=t[2],e[n+o+1]=t[3],o+=i,e[n+o]=t[6],e[n+o+1]=t[7],o+=i,e[n+o]=t[4],e[n+o+1]=t[5],o+=i;const a=n/i;r[s++]=a,r[s++]=a+1,r[s++]=a+2,r[s++]=a+1,r[s++]=a+3,r[s++]=a+2}},Vs={extension:{type:o.ShapeBuilder,name:"triangle"},build:(t,e)=>(e[0]=t.x,e[1]=t.y,e[2]=t.x2,e[3]=t.y2,e[4]=t.x3,e[5]=t.y3,!0),triangulate(t,e,i,n,r,s){let o=0;e[(n*=i)+o]=t[0],e[n+o+1]=t[1],o+=i,e[n+o]=t[2],e[n+o+1]=t[3],o+=i,e[n+o]=t[4],e[n+o+1]=t[5];const a=n/i;r[s++]=a,r[s++]=a+1,r[s++]=a+2}},Hs=new S,Ws=new D;const js={};h.handleByMap(o.ShapeBuilder,js),h.add(Ns,zs,Vs,Bs,ks,Is);const Ys=new D,Xs=new S;function Zs(t,e,i){const n=[],r=js.rectangle,s=Ys;s.x=t.dx,s.y=t.dy,s.width=t.dw,s.height=t.dh;const o=t.transform;if(!r.build(s,n))return;const{vertices:a,uvs:l,indices:h}=i,c=h.length,u=a.length/2;o&&Es(n,o),r.triangulate(n,a,2,u,h,c);const d=t.image,p=d.uvs;l.push(p.x0,p.y0,p.x1,p.y1,p.x3,p.y3,p.x2,p.y2);const f=Dt.get(Fs);f.indexOffset=c,f.indexSize=h.length-c,f.attributeOffset=u,f.attributeSize=a.length/2-u,f.baseColor=t.style,f.alpha=t.alpha,f.texture=d,f.geometryData=i,e.push(f)}function qs(t,e,i,n,r){const{vertices:s,uvs:o,indices:a}=r;t.shapePrimitives.forEach(({shape:t,transform:l,holes:h})=>{var c;const u=[],d=js[t.type];if(!d.build(t,u))return;const p=a.length,f=s.length/2;let g="triangle-list";if(l&&Es(u,l),i){const i=null==(c=t.closePath)||c,n=e;n.pixelLine?(!function(t,e,i,n){const r=Ds;if(0===t.length)return;const s=t[0],o=t[1],a=t[t.length-2],l=t[t.length-1],h=e||Math.abs(s-a)<r&&Math.abs(o-l)<r,c=i,u=t.length/2,d=c.length/2;for(let p=0;p<u;p++)c.push(t[2*p]),c.push(t[2*p+1]);for(let p=0;p<u-1;p++)n.push(d+p,d+p+1);h&&n.push(d+u-1,d)}(u,i,s,a),g="line-list"):function(t,e,i,n,r,s){const o=Ds;if(0===t.length)return;const a=e;let l=a.alignment;if(.5!==e.alignment){let e=function(t){const e=t.length;if(e<6)return 1;let i=0;for(let n=0,r=t[e-2],s=t[e-1];n<e;n+=2){const e=t[n],o=t[n+1];i+=(e-r)*(o+s),r=e,s=o}return i<0?-1:1}(t);l=(l-.5)*e+.5}const h=new v(t[0],t[1]),c=new v(t[t.length-2],t[t.length-1]),u=n,d=Math.abs(h.x-c.x)<o&&Math.abs(h.y-c.y)<o;if(u){t=t.slice(),d&&(t.pop(),t.pop(),c.set(t[t.length-2],t[t.length-1]));const e=.5*(h.x+c.x),i=.5*(c.y+h.y);t.unshift(e,i),t.push(e,i)}const p=r,f=t.length/2;let g=t.length;const m=p.length/2,_=a.width/2,y=_*_,x=a.miterLimit*a.miterLimit;let b=t[0],w=t[1],S=t[2],A=t[3],T=0,C=0,P=-(w-A),M=b-S,E=0,R=0,F=Math.sqrt(P*P+M*M);P/=F,M/=F,P*=_,M*=_;const B=2*(1-l),k=2*l;u||("round"===a.cap?g+=Us(b-P*(B-k)*.5,w-M*(B-k)*.5,b-P*B,w-M*B,b+P*k,w+M*k,p,!0)+2:"square"===a.cap&&(g+=Os(b,w,P,M,B,k,!0,p))),p.push(b-P*B,w-M*B),p.push(b+P*k,w+M*k);for(let v=1;v<f-1;++v){b=t[2*(v-1)],w=t[2*(v-1)+1],S=t[2*v],A=t[2*v+1],T=t[2*(v+1)],C=t[2*(v+1)+1],P=-(w-A),M=b-S,F=Math.sqrt(P*P+M*M),P/=F,M/=F,P*=_,M*=_,E=-(A-C),R=S-T,F=Math.sqrt(E*E+R*R),E/=F,R/=F,E*=_,R*=_;const e=S-b,i=w-A,n=S-T,r=C-A,s=e*n+i*r,o=i*n-r*e,l=o<0;if(Math.abs(o)<.001*Math.abs(s)){p.push(S-P*B,A-M*B),p.push(S+P*k,A+M*k),s>=0&&("round"===a.join?g+=Us(S,A,S-P*B,A-M*B,S-E*B,A-R*B,p,!1)+4:g+=2,p.push(S-E*k,A-R*k),p.push(S+E*B,A+R*B));continue}const h=(-P+b)*(-M+A)-(-P+S)*(-M+w),c=(-E+T)*(-R+A)-(-E+S)*(-R+C),u=(e*c-n*h)/o,d=(r*h-i*c)/o,f=(u-S)*(u-S)+(d-A)*(d-A),m=S+(u-S)*B,I=A+(d-A)*B,D=S-(u-S)*k,O=A-(d-A)*k,U=l?B:k;f<=Math.min(e*e+i*i,n*n+r*r)+U*U*y?"bevel"===a.join||f/y>x?(l?(p.push(m,I),p.push(S+P*k,A+M*k),p.push(m,I),p.push(S+E*k,A+R*k)):(p.push(S-P*B,A-M*B),p.push(D,O),p.push(S-E*B,A-R*B),p.push(D,O)),g+=2):"round"===a.join?l?(p.push(m,I),p.push(S+P*k,A+M*k),g+=Us(S,A,S+P*k,A+M*k,S+E*k,A+R*k,p,!0)+4,p.push(m,I),p.push(S+E*k,A+R*k)):(p.push(S-P*B,A-M*B),p.push(D,O),g+=Us(S,A,S-P*B,A-M*B,S-E*B,A-R*B,p,!1)+4,p.push(S-E*B,A-R*B),p.push(D,O)):(p.push(m,I),p.push(D,O)):(p.push(S-P*B,A-M*B),p.push(S+P*k,A+M*k),"round"===a.join?g+=l?Us(S,A,S+P*k,A+M*k,S+E*k,A+R*k,p,!0)+2:Us(S,A,S-P*B,A-M*B,S-E*B,A-R*B,p,!1)+2:"miter"===a.join&&f/y<=x&&(l?(p.push(D,O),p.push(D,O)):(p.push(m,I),p.push(m,I)),g+=2),p.push(S-E*B,A-R*B),p.push(S+E*k,A+R*k),g+=2)}b=t[2*(f-2)],w=t[2*(f-2)+1],S=t[2*(f-1)],A=t[2*(f-1)+1],P=-(w-A),M=b-S,F=Math.sqrt(P*P+M*M),P/=F,M/=F,P*=_,M*=_,p.push(S-P*B,A-M*B),p.push(S+P*k,A+M*k),u||("round"===a.cap?g+=Us(S-P*(B-k)*.5,A-M*(B-k)*.5,S-P*B,A-M*B,S+P*k,A+M*k,p,!1)+2:"square"===a.cap&&(g+=Os(S,A,P,M,B,k,!1,p)));for(let v=m;v<g+m-2;++v)b=p[2*v],w=p[2*v+1],S=p[2*(v+1)],A=p[2*(v+1)+1],T=p[2*(v+2)],C=p[2*(v+2)+1],Math.abs(b*(A-C)+S*(C-w)+T*(w-A))<1e-8||s.push(v,v+1,v+2)}(u,n,0,i,s,a)}else if(h){const t=[],e=u.slice();(function(t){const e=[];for(let i=0;i<t.length;i++){const n=t[i].shape,r=[];js[n.type].build(n,r)&&e.push(r)}return e})(h).forEach(i=>{t.push(e.length/2),e.push(...i)}),Gs(e,t,s,2,f,a,p)}else d.triangulate(u,s,2,f,a,p);const m=o.length/2,_=e.texture;if(_!==J.WHITE){const i=function(t,e,i,n){const r=e.matrix?t.copyFrom(e.matrix).invert():t.identity();if("local"===e.textureSpace){const t=i.getBounds(Ws);e.width&&t.pad(e.width);const{x:n,y:s}=t,o=1/t.width,a=1/t.height,l=-n*o,h=-s*a,c=r.a,u=r.b,d=r.c,p=r.d;r.a*=o,r.b*=o,r.c*=a,r.d*=a,r.tx=l*c+h*d+r.tx,r.ty=l*u+h*p+r.ty}else r.translate(e.texture.frame.x,e.texture.frame.y),r.scale(1/e.texture.source.width,1/e.texture.source.height);const s=e.texture.source.style;return e.fill instanceof lr||"clamp-to-edge"!==s.addressMode||(s.addressMode="repeat",s.update()),n&&r.append(Hs.copyFrom(n).invert()),r}(Xs,e,t,l);!function(t,e,i,n,r,s,o,a=null){let l=0;i*=e,r*=s;const h=a.a,c=a.b,u=a.c,d=a.d,p=a.tx,f=a.ty;for(;l<o;){const o=t[i],a=t[i+1];n[r]=h*o+u*a+p,n[r+1]=c*o+d*a+f,r+=s,i+=e,l++}}(s,2,f,o,m,2,s.length/2-f,i)}else!function(t,e,i,n){let r=0;for(e*=i;r<n;)t[e]=0,t[e+1]=0,e+=i,r++}(o,m,2,s.length/2-f);const y=Dt.get(Fs);y.indexOffset=p,y.indexSize=a.length-p,y.attributeOffset=f,y.attributeSize=s.length/2-f,y.baseColor=e.color,y.alpha=e.alpha,y.texture=_,y.geometryData=r,y.topology=g,n.push(y)})}class Ks{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class $s{constructor(){this.instructions=new ue}init(t){this.batcher=new Ms({maxTextures:t}),this.instructions.reset()}get geometry(){return z("8.3.4","GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}}const Qs=class t{constructor(t){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null),this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuContextHash"),t.renderableGC.addManagedHash(this,"_graphicsDataContextHash")}init(e){var i;t.defaultOptions.bezierSmoothness=null!=(i=null==e?void 0:e.bezierSmoothness)?i:t.defaultOptions.bezierSmoothness}getContextRenderData(t){return this._graphicsDataContextHash[t.uid]||this._initContextRenderData(t)}updateGpuContext(t){let e=this._gpuContextHash[t.uid]||this._initContext(t);if(t.dirty){e?this._cleanGraphicsContextData(t):e=this._initContext(t),function(t,e){const{geometryData:i,batches:n}=e;n.length=0,i.indices.length=0,i.vertices.length=0,i.uvs.length=0;for(let r=0;r<t.instructions.length;r++){const e=t.instructions[r];if("texture"===e.action)Zs(e.data,n,i);else if("fill"===e.action||"stroke"===e.action){const t="stroke"===e.action,r=e.data.path.shapePath,s=e.data.style,o=e.data.hole;t&&o&&qs(o.shapePath,s,!0,n,i),o&&(r.shapePrimitives[r.shapePrimitives.length-1].holes=o.shapePath.shapePrimitives),qs(r,s,t,n,i)}}}(t,e);const i=t.batchMode;t.customShader||"no-batch"===i?e.isBatchable=!1:e.isBatchable="auto"!==i||e.geometryData.vertices.length<400,t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_initContextRenderData(t){const e=Dt.get($s,{maxTextures:this._renderer.limits.maxBatchableTextures}),{batches:i,geometryData:n}=this._gpuContextHash[t.uid],r=n.vertices.length,s=n.indices.length;for(let h=0;h<i.length;h++)i[h].applyTransform=!1;const o=e.batcher;o.ensureAttributeBuffer(r),o.ensureIndexBuffer(s),o.begin();for(let h=0;h<i.length;h++){const t=i[h];o.add(t)}o.finish(e.instructions);const a=o.geometry;a.indexBuffer.setDataWithSize(o.indexBuffer,o.indexSize,!0),a.buffers[0].setDataWithSize(o.attributeBuffer.float32View,o.attributeSize,!0);const l=o.batches;for(let h=0;h<l.length;h++){const t=l[h];t.bindGroup=Sr(t.textures.textures,t.textures.count,this._renderer.limits.maxBatchableTextures)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new Ks;return e.context=t,this._gpuContextHash[t.uid]=e,t.on("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]}onGraphicsContextDestroy(t){this._cleanGraphicsContextData(t),t.off("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]=null}_cleanGraphicsContextData(t){const e=this._gpuContextHash[t.uid];e.isBatchable||this._graphicsDataContextHash[t.uid]&&(Dt.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(t=>{Dt.return(t)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};Qs.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"graphicsContext"},Qs.defaultOptions={bezierSmoothness:.5};let Js=Qs;const to=1.1920929e-7;function eo(t,e,i,n,r,s,o,a,l,h){let c=(1-Math.min(.99,Math.max(0,null!=h?h:Js.defaultOptions.bezierSmoothness)))/1;return c*=c,function(t,e,i,n,r,s,o,a,l,h){io(t,e,i,n,r,s,o,a,l,h,0),l.push(o,a)}(e,i,n,r,s,o,a,l,t,c),t}function io(t,e,i,n,r,s,o,a,l,h,c){if(c>8)return;const u=(t+i)/2,d=(e+n)/2,p=(i+r)/2,f=(n+s)/2,g=(r+o)/2,m=(s+a)/2,_=(u+p)/2,y=(d+f)/2,x=(p+g)/2,b=(f+m)/2,v=(_+x)/2,w=(y+b)/2;if(c>0){let c=o-t,u=a-e;const d=Math.abs((i-o)*u-(n-a)*c),p=Math.abs((r-o)*u-(s-a)*c);if(d>to&&p>to){if((d+p)*(d+p)<=h*(c*c+u*u))return void l.push(v,w)}else if(d>to){if(d*d<=h*(c*c+u*u))return void l.push(v,w)}else if(p>to){if(p*p<=h*(c*c+u*u))return void l.push(v,w)}else if(c=v-(t+o)/2,u=w-(e+a)/2,c*c+u*u<=h)return void l.push(v,w)}io(t,e,u,d,_,y,v,w,l,h,c+1),io(v,w,x,b,g,m,o,a,l,h,c+1)}function no(t,e,i,n,r,s,o,a){let l=(1-Math.min(.99,Math.max(0,null!=a?a:Js.defaultOptions.bezierSmoothness)))/1;return l*=l,function(t,e,i,n,r,s,o,a){ro(o,t,e,i,n,r,s,a,0),o.push(r,s)}(e,i,n,r,s,o,t,l),t}function ro(t,e,i,n,r,s,o,a,l){if(l>8)return;const h=(e+n)/2,c=(i+r)/2,u=(n+s)/2,d=(r+o)/2,p=(h+u)/2,f=(c+d)/2;let g=s-e,m=o-i;const _=Math.abs((n-s)*m-(r-o)*g);if(_>1.1920929e-7){if(_*_<=a*(g*g+m*m))return void t.push(p,f)}else if(g=p-(e+s)/2,m=f-(i+o)/2,g*g+m*m<=a)return void t.push(p,f);ro(t,e,i,h,c,p,f,a,l+1),ro(t,p,f,u,d,s,o,a,l+1)}function so(t,e,i,n,r,s,o,a){let l=Math.abs(r-s);(!o&&r>s||o&&s>r)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(n,1/3)*(l/Math.PI))));let h=l/(a=Math.max(a,3)),c=r;h*=o?-1:1;for(let u=0;u<a+1;u++){const r=e+Math.cos(c)*n,s=i+Math.sin(c)*n;t.push(r,s),c+=h}}const oo=2*Math.PI,ao={centerX:0,centerY:0,ang1:0,ang2:0},lo=({x:t,y:e},i,n,r,s,o,a,l)=>{const h=r*(t*=i)-s*(e*=n),c=s*t+r*e;return l.x=h+o,l.y=c+a,l};function ho(t,e){const i=-1.5707963267948966===e?-.551915024494:4/3*Math.tan(e/4),n=1.5707963267948966===e?.551915024494:i,r=Math.cos(t),s=Math.sin(t),o=Math.cos(t+e),a=Math.sin(t+e);return[{x:r-s*n,y:s+r*n},{x:o+a*n,y:a-o*n},{x:o,y:a}]}const co=(t,e,i,n)=>{let r=t*i+e*n;return r>1&&(r=1),r<-1&&(r=-1),(t*n-e*i<0?-1:1)*Math.acos(r)};function uo(t,e,i,n,r,s,o,a=0,l=0,h=0){if(0===s||0===o)return;const c=Math.sin(a*oo/360),u=Math.cos(a*oo/360),d=u*(e-n)/2+c*(i-r)/2,p=-c*(e-n)/2+u*(i-r)/2;if(0===d&&0===p)return;s=Math.abs(s),o=Math.abs(o);const f=Math.pow(d,2)/Math.pow(s,2)+Math.pow(p,2)/Math.pow(o,2);f>1&&(s*=Math.sqrt(f),o*=Math.sqrt(f)),((t,e,i,n,r,s,o,a,l,h,c,u,d)=>{const p=Math.pow(r,2),f=Math.pow(s,2),g=Math.pow(c,2),m=Math.pow(u,2);let _=p*f-p*m-f*g;_<0&&(_=0),_/=p*m+f*g,_=Math.sqrt(_)*(o===a?-1:1);const y=_*r/s*u,x=_*-s/r*c,b=h*y-l*x+(t+i)/2,v=l*y+h*x+(e+n)/2,w=(c-y)/r,S=(u-x)/s,A=(-c-y)/r,T=(-u-x)/s,C=co(1,0,w,S);let P=co(w,S,A,T);0===a&&P>0&&(P-=oo),1===a&&P<0&&(P+=oo),d.centerX=b,d.centerY=v,d.ang1=C,d.ang2=P})(e,i,n,r,s,o,l,h,c,u,d,p,ao);let{ang1:g,ang2:m}=ao;const{centerX:_,centerY:y}=ao;let x=Math.abs(m)/(oo/4);Math.abs(1-x)<1e-7&&(x=1);const b=Math.max(Math.ceil(x),1);m/=b;let v=t[t.length-2],w=t[t.length-1];const S={x:0,y:0};for(let A=0;A<b;A++){const e=ho(g,m),{x:i,y:n}=lo(e[0],s,o,u,c,_,y,S),{x:r,y:a}=lo(e[1],s,o,u,c,_,y,S),{x:l,y:h}=lo(e[2],s,o,u,c,_,y,S);eo(t,v,w,i,n,r,a,l,h),v=l,w=h,g+=m}}const po=new D;class fo{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new it,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const i=this._currentPoly.points,n=i[i.length-2],r=i[i.length-1];return n===t&&r===e||i.push(t,e),this}arc(t,e,i,n,r,s){this._ensurePoly(!1);return so(this._currentPoly.points,t,e,i,n,r,s),this}arcTo(t,e,i,n,r){this._ensurePoly();return function(t,e,i,n,r,s){const o=t[t.length-2],a=t[t.length-1]-i,l=o-e,h=r-i,c=n-e,u=Math.abs(a*c-l*h);if(u<1e-8||0===s)return void(t[t.length-2]===e&&t[t.length-1]===i||t.push(e,i));const d=a*a+l*l,p=h*h+c*c,f=a*h+l*c,g=s*Math.sqrt(d)/u,m=s*Math.sqrt(p)/u,_=g*f/d,y=m*f/p,x=g*c+m*l,b=g*h+m*a,v=l*(m+_),w=a*(m+_),S=c*(g+y),A=h*(g+y);so(t,x+e,b+i,s,Math.atan2(w-b,v-x),Math.atan2(A-b,S-x),l*h>c*a)}(this._currentPoly.points,t,e,i,n,r),this}arcToSvg(t,e,i,n,r,s,o){return uo(this._currentPoly.points,this._currentPoly.lastX,this._currentPoly.lastY,s,o,t,e,i,n,r),this}bezierCurveTo(t,e,i,n,r,s,o){this._ensurePoly();const a=this._currentPoly;return eo(this._currentPoly.points,a.lastX,a.lastY,t,e,i,n,r,s,o),this}quadraticCurveTo(t,e,i,n,r){this._ensurePoly();const s=this._currentPoly;return no(this._currentPoly.points,s.lastX,s.lastY,t,e,i,n,r),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0)).transform(e);const i=this.shapePrimitives,n=i.length;for(let r=0;r<t.instructions.length;r++){const e=t.instructions[r];this[e.action](...e.data)}if(t.checkForHoles&&i.length-n>1){let t=null;for(let e=n;e<i.length;e++){const n=i[e];if("polygon"===n.shape.type){const r=n.shape,s=null==t?void 0:t.shape;s&&s.containsPolygon(r)?(t.holes||(t.holes=[]),t.holes.push(n),i.copyWithin(e,e+1),i.length--,e--):t=n}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,n,r){return this.drawShape(new D(t,e,i,n),r),this}circle(t,e,i,n){return this.drawShape(new mr(t,e,i),n),this}poly(t,e,i){const n=new xr(t);return n.closePath=e,this.drawShape(n,i),this}regularPoly(t,e,i,n,r=0,s){n=Math.max(0|n,3);const o=-1*Math.PI/2+r,a=2*Math.PI/n,l=[];for(let h=0;h<n;h++){const n=o-h*a;l.push(t+i*Math.cos(n),e+i*Math.sin(n))}return this.poly(l,!0,s),this}roundPoly(t,e,i,n,r,s=0,o){if(n=Math.max(0|n,3),r<=0)return this.regularPoly(t,e,i,n,s);const a=i*Math.sin(Math.PI/n)-.001;r=Math.min(r,a);const l=-1*Math.PI/2+s,h=2*Math.PI/n,c=(n-2)*Math.PI/n/2;for(let u=0;u<n;u++){const n=u*h+l,s=t+i*Math.cos(n),a=e+i*Math.sin(n),d=n+Math.PI+c,p=n-Math.PI-c,f=s+r*Math.cos(d),g=a+r*Math.sin(d),m=s+r*Math.cos(p),_=a+r*Math.sin(p);0===u?this.moveTo(f,g):this.lineTo(f,g),this.quadraticCurveTo(s,a,m,_,o)}return this.closePath()}roundShape(t,e,i=!1,n){return t.length<3?this:(i?function(t,e,i,n){var r;const s=(t,e)=>Math.sqrt(__pow(t.x-e.x,2)+__pow(t.y-e.y,2)),o=(t,e,i)=>({x:t.x+(e.x-t.x)*i,y:t.y+(e.y-t.y)*i}),a=e.length;for(let l=0;l<a;l++){const h=e[(l+1)%a],c=null!=(r=h.radius)?r:i;if(c<=0){0===l?t.moveTo(h.x,h.y):t.lineTo(h.x,h.y);continue}const u=e[l],d=e[(l+2)%a],p=s(u,h);let f;f=p<1e-4?h:o(h,u,Math.min(p/2,c)/p);const g=s(d,h);let m;m=g<1e-4?h:o(h,d,Math.min(g/2,c)/g),0===l?t.moveTo(f.x,f.y):t.lineTo(f.x,f.y),t.quadraticCurveTo(h.x,h.y,m.x,m.y,n)}}(this,t,e,n):function(t,e,i){var n;const r=(t,e)=>{const i=e.x-t.x,n=e.y-t.y,r=Math.sqrt(i*i+n*n);return{len:r,nx:i/r,ny:n/r}},s=(e,i)=>{0===e?t.moveTo(i.x,i.y):t.lineTo(i.x,i.y)};let o=e[e.length-1];for(let a=0;a<e.length;a++){const l=e[a%e.length],h=null!=(n=l.radius)?n:i;if(h<=0){s(a,l),o=l;continue}const c=e[(a+1)%e.length],u=r(l,o),d=r(l,c);if(u.len<1e-4||d.len<1e-4){s(a,l),o=l;continue}let p=Math.asin(u.nx*d.ny-u.ny*d.nx),f=1,g=!1;u.nx*d.nx-u.ny*-d.ny<0?p<0?p=Math.PI+p:(p=Math.PI-p,f=-1,g=!0):p>0&&(f=-1,g=!0);const m=p/2;let _,y=Math.abs(Math.cos(m)*h/Math.sin(m));y>Math.min(u.len/2,d.len/2)?(y=Math.min(u.len/2,d.len/2),_=Math.abs(y*Math.sin(m)/Math.cos(m))):_=h;const x=l.x+d.nx*y+-d.ny*_*f,b=l.y+d.ny*y+d.nx*_*f,v=Math.atan2(u.ny,u.nx)+Math.PI/2*f,w=Math.atan2(d.ny,d.nx)-Math.PI/2*f;0===a&&t.moveTo(x+Math.cos(v)*_,b+Math.sin(v)*_),t.arc(x,b,_,v,w,g),o=l}}(this,t,e),this.closePath())}filletRect(t,e,i,n,r){if(0===r)return this.rect(t,e,i,n);const s=Math.min(i,n)/2,o=Math.min(s,Math.max(-s,r)),a=t+i,l=e+n,h=o<0?-o:0,c=Math.abs(o);return this.moveTo(t,e+c).arcTo(t+h,e+h,t+c,e,c).lineTo(a-c,e).arcTo(a-h,e+h,a,e+c,c).lineTo(a,l-c).arcTo(a-h,l-h,t+i-c,l,c).lineTo(t+c,l).arcTo(t+h,l-h,t,l-c,c).closePath()}chamferRect(t,e,i,n,r,s){if(r<=0)return this.rect(t,e,i,n);const o=Math.min(r,Math.min(i,n)/2),a=t+i,l=e+n,h=[t+o,e,a-o,e,a,e+o,a,l-o,a-o,l,t+o,l,t,l-o,t,e+o];for(let c=h.length-1;c>=2;c-=2)h[c]===h[c-2]&&h[c-1]===h[c-3]&&h.splice(c-1,2);return this.poly(h,!0,s)}ellipse(t,e,i,n,r){return this.drawShape(new _r(t,e,i,n),r),this}roundRect(t,e,i,n,r,s){return this.drawShape(new vr(t,e,i,n,r),s),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new xr,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new xr,t)){const t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let e=t.shape.x,i=t.shape.y;if(t.transform&&!t.transform.isIdentity()){const n=t.transform,r=e;e=n.a*e+n.c*i+n.tx,i=n.b*r+n.d*i+n.ty}this._currentPoly.points.push(e,i)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let i=0;i<e.length;i++){const n=e[i],r=n.shape.getBounds(po);n.transform?t.addRect(r,n.transform):t.addRect(r)}return t}}class go{constructor(t,e=!1){var i;this.instructions=[],this.uid=U("graphicsPath"),this._dirty=!0,this.checkForHoles=e,"string"==typeof t?function(t,e){const i=gr(t),n=[];let r=null,s=0,o=0;for(let a=0;a<i.length;a++){const t=i[a],l=t[0],h=t;switch(l){case"M":s=h[1],o=h[2],e.moveTo(s,o);break;case"m":s+=h[1],o+=h[2],e.moveTo(s,o);break;case"H":s=h[1],e.lineTo(s,o);break;case"h":s+=h[1],e.lineTo(s,o);break;case"V":o=h[1],e.lineTo(s,o);break;case"v":o+=h[1],e.lineTo(s,o);break;case"L":s=h[1],o=h[2],e.lineTo(s,o);break;case"l":s+=h[1],o+=h[2],e.lineTo(s,o);break;case"C":s=h[5],o=h[6],e.bezierCurveTo(h[1],h[2],h[3],h[4],s,o);break;case"c":e.bezierCurveTo(s+h[1],o+h[2],s+h[3],o+h[4],s+h[5],o+h[6]),s+=h[5],o+=h[6];break;case"S":s=h[3],o=h[4],e.bezierCurveToShort(h[1],h[2],s,o);break;case"s":e.bezierCurveToShort(s+h[1],o+h[2],s+h[3],o+h[4]),s+=h[3],o+=h[4];break;case"Q":s=h[3],o=h[4],e.quadraticCurveTo(h[1],h[2],s,o);break;case"q":e.quadraticCurveTo(s+h[1],o+h[2],s+h[3],o+h[4]),s+=h[3],o+=h[4];break;case"T":s=h[1],o=h[2],e.quadraticCurveToShort(s,o);break;case"t":s+=h[1],o+=h[2],e.quadraticCurveToShort(s,o);break;case"A":s=h[6],o=h[7],e.arcToSvg(h[1],h[2],h[3],h[4],h[5],s,o);break;case"a":s+=h[6],o+=h[7],e.arcToSvg(h[1],h[2],h[3],h[4],h[5],s,o);break;case"Z":case"z":e.closePath(),n.length>0&&(r=n.pop(),r?(s=r.startX,o=r.startY):(s=0,o=0)),r=null;break;default:kt(`Unknown SVG path command: ${l}`)}"Z"!==l&&"z"!==l&&null===r&&(r={startX:s,startY:o},n.push(r))}}(t,this):this.instructions=null!=(i=null==t?void 0:t.slice())?i:[]}get shapePath(){return this._shapePath||(this._shapePath=new fo(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,i,n,r){const s=this.instructions[this.instructions.length-1],o=this.getLastPoint(v.shared);let a=0,l=0;if(s&&"bezierCurveTo"===s.action){a=s.data[2],l=s.data[3];const t=o.x,e=o.y;a=t+(t-a),l=e+(e-l)}else a=o.x,l=o.y;return this.instructions.push({action:"bezierCurveTo",data:[a,l,t,e,i,n,r]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,i){const n=this.instructions[this.instructions.length-1],r=this.getLastPoint(v.shared);let s=0,o=0;if(n&&"quadraticCurveTo"===n.action){s=n.data[0],o=n.data[1];const t=r.x,e=r.y;s=t+(t-s),o=e+(e-o)}else s=r.x,o=r.y;return this.instructions.push({action:"quadraticCurveTo",data:[s,o,t,e,i]}),this._dirty=!0,this}rect(t,e,i,n,r){return this.instructions.push({action:"rect",data:[t,e,i,n,r]}),this._dirty=!0,this}circle(t,e,i,n){return this.instructions.push({action:"circle",data:[t,e,i,n]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,i,n,r,s,o){r||(r=n/2);const a=-1*Math.PI/2+s,l=2*i,h=2*Math.PI/l,c=[];for(let u=0;u<l;u++){const i=u%2?r:n,s=u*h+a;c.push(t+i*Math.cos(s),e+i*Math.sin(s))}return this.poly(c,!0,o),this}clone(t=!1){const e=new go;if(e.checkForHoles=this.checkForHoles,t)for(let i=0;i<this.instructions.length;i++){const t=this.instructions[i];e.instructions.push({action:t.action,data:t.data.slice()})}else e.instructions=this.instructions.slice();return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,i=t.b,n=t.c,r=t.d,s=t.tx,o=t.ty;let a=0,l=0,h=0,c=0,u=0,d=0,p=0,f=0;for(let g=0;g<this.instructions.length;g++){const m=this.instructions[g],_=m.data;switch(m.action){case"moveTo":case"lineTo":a=_[0],l=_[1],_[0]=e*a+n*l+s,_[1]=i*a+r*l+o;break;case"bezierCurveTo":h=_[0],c=_[1],u=_[2],d=_[3],a=_[4],l=_[5],_[0]=e*h+n*c+s,_[1]=i*h+r*c+o,_[2]=e*u+n*d+s,_[3]=i*u+r*d+o,_[4]=e*a+n*l+s,_[5]=i*a+r*l+o;break;case"quadraticCurveTo":h=_[0],c=_[1],a=_[2],l=_[3],_[0]=e*h+n*c+s,_[1]=i*h+r*c+o,_[2]=e*a+n*l+s,_[3]=i*a+r*l+o;break;case"arcToSvg":a=_[5],l=_[6],p=_[0],f=_[1],_[0]=e*p+n*f,_[1]=i*p+r*f,_[5]=e*a+n*l+s,_[6]=i*a+r*l+o;break;case"circle":_[4]=mo(_[3],t);break;case"rect":_[4]=mo(_[4],t);break;case"ellipse":_[8]=mo(_[8],t);break;case"roundRect":_[5]=mo(_[5],t);break;case"addPath":_[0].transform(t);break;case"poly":_[2]=mo(_[2],t);break;default:kt("unknown transform action",m.action)}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,i=this.instructions[e];if(!i)return t.x=0,t.y=0,t;for(;"closePath"===i.action;){if(e--,e<0)return t.x=0,t.y=0,t;i=this.instructions[e]}switch(i.action){case"moveTo":case"lineTo":t.x=i.data[0],t.y=i.data[1];break;case"quadraticCurveTo":t.x=i.data[2],t.y=i.data[3];break;case"bezierCurveTo":t.x=i.data[4],t.y=i.data[5];break;case"arc":case"arcToSvg":t.x=i.data[5],t.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(t)}return t}}function mo(t,e){return t?t.prepend(e):e.clone()}function _o(t,e,i){const n=t.getAttribute(e);return n?Number(n):i}function yo(t){const e=_o(t,"x1",0),i=_o(t,"y1",0),n=_o(t,"x2",1),r=_o(t,"y2",0),s=t.getAttribute("gradientUnits")||"objectBoundingBox",o=new lr(e,i,n,r,"objectBoundingBox"===s?"local":"global");for(let a=0;a<t.children.length;a++){const e=t.children[a],i=_o(e,"offset",0),n=Ft.shared.setValue(e.getAttribute("stop-color")).toNumber();o.addColorStop(i,n)}return o}function xo(t){return kt("[SVG Parser] Radial gradients are not yet supported"),new lr(0,0,1,0)}function bo(t){const e=t.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}const vo={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 wo(t,e){const i=t.getAttribute("style"),n={},r={},s={strokeStyle:n,fillStyle:r,useFill:!1,useStroke:!1};for(const o in vo){const i=t.getAttribute(o);i&&So(e,s,o,i.trim())}if(i){const t=i.split(";");for(let i=0;i<t.length;i++){const n=t[i].trim(),[r,o]=n.split(":");vo[r]&&So(e,s,r,o.trim())}}return{strokeStyle:s.useStroke?n:null,fillStyle:s.useFill?r:null,useFill:s.useFill,useStroke:s.useStroke}}function So(t,e,i,n){switch(i){case"stroke":if("none"!==n){if(n.startsWith("url(")){const i=bo(n);e.strokeStyle.fill=t.defs[i]}else e.strokeStyle.color=Ft.shared.setValue(n).toNumber();e.useStroke=!0}break;case"stroke-width":e.strokeStyle.width=Number(n);break;case"fill":if("none"!==n){if(n.startsWith("url(")){const i=bo(n);e.fillStyle.fill=t.defs[i]}else e.fillStyle.color=Ft.shared.setValue(n).toNumber();e.useFill=!0}break;case"fill-opacity":e.fillStyle.alpha=Number(n);break;case"stroke-opacity":e.strokeStyle.alpha=Number(n);break;case"opacity":e.fillStyle.alpha=Number(n),e.strokeStyle.alpha=Number(n)}}function Ao(t,e){if("string"==typeof t){const e=document.createElement("div");e.innerHTML=t.trim(),t=e.querySelector("svg")}const i={context:e,defs:{},path:new go};!function(t,e){const i=t.querySelectorAll("defs");for(let n=0;n<i.length;n++){const t=i[n];for(let i=0;i<t.children.length;i++){const n=t.children[i];switch(n.nodeName.toLowerCase()){case"lineargradient":e.defs[n.id]=yo(n);break;case"radialgradient":e.defs[n.id]=xo()}}}}(t,i);const n=t.children,{fillStyle:r,strokeStyle:s}=wo(t,i);for(let o=0;o<n.length;o++){const t=n[o];"defs"!==t.nodeName.toLowerCase()&&To(t,i,r,s)}return e}function To(t,e,i,n){const r=t.children,{fillStyle:s,strokeStyle:o}=wo(t,e);s&&i?i=__spreadValues(__spreadValues({},i),s):s&&(i=s),o&&n?n=__spreadValues(__spreadValues({},n),o):o&&(n=o);const a=!i&&!n;let l,h,c,u,d,p,f,g,m,_,y,x,b,v,w,S,A;switch(a&&(i={color:0}),t.nodeName.toLowerCase()){case"path":v=t.getAttribute("d"),"evenodd"===t.getAttribute("fill-rule")&&kt("SVG Evenodd fill rule not supported, your svg may render incorrectly"),w=new go(v,!0),e.context.path(w),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"circle":f=_o(t,"cx",0),g=_o(t,"cy",0),m=_o(t,"r",0),e.context.ellipse(f,g,m,m),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"rect":l=_o(t,"x",0),h=_o(t,"y",0),S=_o(t,"width",0),A=_o(t,"height",0),_=_o(t,"rx",0),y=_o(t,"ry",0),_||y?e.context.roundRect(l,h,S,A,_||y):e.context.rect(l,h,S,A),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"ellipse":f=_o(t,"cx",0),g=_o(t,"cy",0),_=_o(t,"rx",0),y=_o(t,"ry",0),e.context.beginPath(),e.context.ellipse(f,g,_,y),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"line":c=_o(t,"x1",0),u=_o(t,"y1",0),d=_o(t,"x2",0),p=_o(t,"y2",0),e.context.beginPath(),e.context.moveTo(c,u),e.context.lineTo(d,p),n&&e.context.stroke(n);break;case"polygon":b=t.getAttribute("points"),x=b.match(/\d+/g).map(t=>parseInt(t,10)),e.context.poly(x,!0),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"polyline":b=t.getAttribute("points"),x=b.match(/\d+/g).map(t=>parseInt(t,10)),e.context.poly(x,!1),n&&e.context.stroke(n);break;case"g":case"svg":break;default:kt(`[SVG parser] <${t.nodeName}> elements unsupported`)}a&&(i=null);for(let T=0;T<r.length;T++)To(r[T],e,i,n)}function Co(t){return t instanceof dr}function Po(t){return t instanceof lr}function Mo(t,e,i){return t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,__spreadValues(__spreadValues({},i),t)}function Eo(t,e,i){return e.buildGradient(),t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,t.textureSpace=e.textureSpace,__spreadValues(__spreadValues({},i),t)}function Ro(t,e){if(null==t)return null;const i={},n=t;return function(t){return Ft.isColorLike(t)}(t)?function(t,e,i){const n=Ft.shared.setValue(null!=e?e:0);return t.color=n.toNumber(),t.alpha=1===n.alpha?i.alpha:n.alpha,t.texture=J.WHITE,__spreadValues(__spreadValues({},i),t)}(i,t,e):function(t){return t instanceof J}(t)?function(t,e,i){return t.texture=e,__spreadValues(__spreadValues({},i),t)}(i,t,e):Co(t)?Mo(i,t,e):Po(t)?Eo(i,t,e):n.fill&&Co(n.fill)?Mo(n,n.fill,e):n.fill&&Po(n.fill)?Eo(n,n.fill,e):function(t,e){const i=__spreadValues(__spreadValues({},e),t),n=Ft.shared.setValue(i.color);return i.alpha*=n.alpha,i.color=n.toNumber(),i}(n,e)}function Fo(t,e){const i=e,{width:n,alignment:r,miterLimit:s,cap:o,join:a,pixelLine:l}=i,h=Ro(t,__objRest(i,["width","alignment","miterLimit","cap","join","pixelLine"]));return h?__spreadValues({width:n,alignment:r,miterLimit:s,cap:o,join:a,pixelLine:l},h):null}const Bo=new v,ko=new S,Io=class t extends _{constructor(){super(...arguments),this.uid=U("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new go,this._transform=new S,this._fillStyle=__spreadValues({},t.defaultFillStyle),this._strokeStyle=__spreadValues({},t.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new it,this._boundsDirty=!0}clone(){const e=new t;return e.batchMode=this.batchMode,e.instructions=this.instructions.slice(),e._activePath=this._activePath.clone(),e._transform=this._transform.clone(),e._fillStyle=__spreadValues({},this._fillStyle),e._strokeStyle=__spreadValues({},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=Ro(e,t.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=Fo(e,t.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=Ro(e,t.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=Ro(e,t.defaultStrokeStyle),this}texture(t,e,i,n,r,s){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:n||0,dw:r||t.frame.width,dh:s||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?Ft.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new go,this}fill(e,i){let n;const r=this.instructions[this.instructions.length-1];return n=0===this._tick&&r&&"stroke"===r.action?r.data.path:this._activePath.clone(),n?(null!=e&&(void 0!==i&&"number"==typeof e&&(z(L,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:i}),this._fillStyle=Ro(e,t.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:n}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(v.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(e){let i;const n=this.instructions[this.instructions.length-1];return i=0===this._tick&&n&&"fill"===n.action?n.data.path:this._activePath.clone(),i?(null!=e&&(this._strokeStyle=Fo(e,t.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&("stroke"===e.action||"fill"===e.action)){if(!e.data.hole){e.data.hole=i;break}e.data.hole.addPath(i)}}return this._initNextPathLocation(),this}arc(t,e,i,n,r,s){this._tick++;const o=this._transform;return this._activePath.arc(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,i,n,r,s),this}arcTo(t,e,i,n,r){this._tick++;const s=this._transform;return this._activePath.arcTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty,s.a*i+s.c*n+s.tx,s.b*i+s.d*n+s.ty,r),this}arcToSvg(t,e,i,n,r,s,o){this._tick++;const a=this._transform;return this._activePath.arcToSvg(t,e,i,n,r,a.a*s+a.c*o+a.tx,a.b*s+a.d*o+a.ty),this}bezierCurveTo(t,e,i,n,r,s,o){this._tick++;const a=this._transform;return this._activePath.bezierCurveTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*i+a.c*n+a.tx,a.b*i+a.d*n+a.ty,a.a*r+a.c*s+a.tx,a.b*r+a.d*s+a.ty,o),this}closePath(){var t;return this._tick++,null==(t=this._activePath)||t.closePath(),this}ellipse(t,e,i,n){return this._tick++,this._activePath.ellipse(t,e,i,n,this._transform.clone()),this}circle(t,e,i){return this._tick++,this._activePath.circle(t,e,i,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;const i=this._transform,n=this._activePath.instructions,r=i.a*t+i.c*e+i.tx,s=i.b*t+i.d*e+i.ty;return 1===n.length&&"moveTo"===n[0].action?(n[0].data[0]=r,n[0].data[1]=s,this):(this._activePath.moveTo(r,s),this)}quadraticCurveTo(t,e,i,n,r){this._tick++;const s=this._transform;return this._activePath.quadraticCurveTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty,s.a*i+s.c*n+s.tx,s.b*i+s.d*n+s.ty,r),this}rect(t,e,i,n){return this._tick++,this._activePath.rect(t,e,i,n,this._transform.clone()),this}roundRect(t,e,i,n,r){return this._tick++,this._activePath.roundRect(t,e,i,n,r,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,n,r=0,s){return this._tick++,this._activePath.regularPoly(t,e,i,n,r,s),this}roundPoly(t,e,i,n,r,s){return this._tick++,this._activePath.roundPoly(t,e,i,n,r,s),this}roundShape(t,e,i,n){return this._tick++,this._activePath.roundShape(t,e,i,n),this}filletRect(t,e,i,n,r){return this._tick++,this._activePath.filletRect(t,e,i,n,r),this}chamferRect(t,e,i,n,r,s){return this._tick++,this._activePath.chamferRect(t,e,i,n,r,s),this}star(t,e,i,n,r=0,s=0){return this._tick++,this._activePath.star(t,e,i,n,r,s,this._transform.clone()),this}svg(t){return this._tick++,Ao(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:__spreadValues({},this._fillStyle),strokeStyle:__spreadValues({},this._strokeStyle)}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,n,r,s){return t instanceof S?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,n,r,s),this)}transform(t,e,i,n,r,s){return t instanceof S?(this._transform.append(t),this):(ko.set(t,e,i,n,r,s),this._transform.append(ko),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const i=this.instructions[e],n=i.action;if("fill"===n){const e=i.data;t.addBounds(e.path.bounds)}else if("texture"===n){const e=i.data;t.addFrame(e.dx,e.dy,e.dx+e.dw,e.dy+e.dh,e.transform)}if("stroke"===n){const e=i.data,n=e.style.alignment,r=e.style.width*(1-n),s=e.path.bounds;t.addFrame(s.minX-r,s.minY-r,s.maxX+r,s.maxY+r)}}return t}containsPoint(t){var e;if(!this.bounds.containsPoint(t.x,t.y))return!1;const i=this.instructions;let n=!1;for(let r=0;r<i.length;r++){const s=i[r],o=s.data,a=o.path;if(!s.action||!a)continue;const l=o.style,h=a.shapePath.shapePrimitives;for(let i=0;i<h.length;i++){const r=h[i].shape;if(!l||!r)continue;const a=h[i].transform,c=a?a.applyInverse(t,Bo):t;if("fill"===s.action)n=r.contains(c.x,c.y);else{const t=l;n=r.strokeContains(c.x,c.y,t.width,t.alignment)}const u=o.hole;if(u){const t=null==(e=u.shapePath)?void 0:e.shapePrimitives;if(t)for(let e=0;e<t.length;e++)t[e].shape.contains(c.x,c.y)&&(n=!1)}if(n)return!0}}return n}destroy(t=!1){this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners();if("boolean"==typeof t?t:null==t?void 0:t.texture){const e="boolean"==typeof t?t:null==t?void 0:t.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(e)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(e))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Io.defaultFillStyle={color:16777215,alpha:1,texture:J.WHITE,matrix:null,fill:null,textureSpace:"local"},Io.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:J.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Do=Io;const Oo=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function Uo(t){const e=[];let i=0;for(let n=0;n<Oo.length;n++){const r=`_${Oo[n]}`;e[i++]=t[r]}return i=Go(t._fill,e,i),i=function(t,e,i){return t?(i=Go(t,e,i),e[i++]=t.width,e[i++]=t.alignment,e[i++]=t.cap,e[i++]=t.join,e[i++]=t.miterLimit,i):i}(t._stroke,e,i),i=function(t,e,i){return t?(e[i++]=t.alpha,e[i++]=t.angle,e[i++]=t.blur,e[i++]=t.distance,e[i++]=Ft.shared.setValue(t.color).toNumber(),i):i}(t.dropShadow,e,i),i=function(t,e,i){if(!t)return i;for(const n of t)e[i++]=n.uid;return i}(t.filters,e,i),e.join("-")}function Go(t,e,i){var n;return t?(e[i++]=t.color,e[i++]=t.alpha,e[i++]=null==(n=t.fill)?void 0:n.styleKey,i):i}const Lo=class t extends _{constructor(e={}){super(),function(t){var e,i,n,r,s;const o=t;if("boolean"==typeof o.dropShadow&&o.dropShadow){const a=zo.defaultDropShadow;t.dropShadow={alpha:null!=(e=o.dropShadowAlpha)?e:a.alpha,angle:null!=(i=o.dropShadowAngle)?i:a.angle,blur:null!=(n=o.dropShadowBlur)?n:a.blur,color:null!=(r=o.dropShadowColor)?r:a.color,distance:null!=(s=o.dropShadowDistance)?s:a.distance}}if(void 0!==o.strokeThickness){z(L,"strokeThickness is now a part of stroke");const e=o.stroke;let i={};if(Ft.isColorLike(e))i.color=e;else if(e instanceof lr||e instanceof dr)i.fill=e;else{if(!Object.hasOwnProperty.call(e,"color")&&!Object.hasOwnProperty.call(e,"fill"))throw new Error("Invalid stroke value.");i=e}t.stroke=__spreadProps(__spreadValues({},i),{width:o.strokeThickness})}if(Array.isArray(o.fillGradientStops)){if(z(L,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(o.fill)||0===o.fill.length)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");o.fill.length!==o.fillGradientStops.length&&kt("The number of fill colors must match the number of fill gradient stops.");const e=new lr({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),i=o.fillGradientStops.slice(),n=o.fill.map(t=>Ft.shared.setValue(t).toNumber());i.forEach((t,i)=>{e.addColorStop(t,n[i])}),t.fill={fill:e}}}(e);const i=__spreadValues(__spreadValues({},t.defaultTextStyle),e);for(const t in i){this[t]=i[t]}this.update()}get align(){return this._align}set align(t){this._align=t,this.update()}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords=t,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow=null!==e&&"object"==typeof e?this._createProxy(__spreadValues(__spreadValues({},t.defaultDropShadow),e)):e?this._createProxy(__spreadValues({},t.defaultDropShadow)):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily=t,this.update()}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize="string"==typeof t?parseInt(t,10):t,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t.toLowerCase(),this.update()}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant=t,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight=t,this.update()}get leading(){return this._leading}set leading(t){this._leading=t,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing=t,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight=t,this.update()}get padding(){return this._padding}set padding(t){this._padding=t,this.update()}get filters(){return this._filters}set filters(t){this._filters=t,this.update()}get trim(){return this._trim}set trim(t){this._trim=t,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace=t,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap=t,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth=t,this.update()}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy(__spreadValues(__spreadValues({},Do.defaultFillStyle),t),()=>{this._fill=Ro(__spreadValues({},this._originalFill),Do.defaultFillStyle)})),this._fill=Ro(0===t?"black":t,Do.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy(__spreadValues(__spreadValues({},Do.defaultStrokeStyle),t),()=>{this._stroke=Fo(__spreadValues({},this._originalStroke),Do.defaultStrokeStyle)})),this._stroke=Fo(t,Do.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=Uo(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const e=t.defaultTextStyle;for(const t in e)this[t]=e[t]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new t({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?__spreadValues({},this._dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0})}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){var e,i,n,r;this.removeAllListeners();if("boolean"==typeof t?t:null==t?void 0:t.texture){const s="boolean"==typeof t?t:null==t?void 0:t.textureSource;(null==(e=this._fill)?void 0:e.texture)&&this._fill.texture.destroy(s),(null==(i=this._originalFill)?void 0:i.texture)&&this._originalFill.texture.destroy(s),(null==(n=this._stroke)?void 0:n.texture)&&this._stroke.texture.destroy(s),(null==(r=this._originalStroke)?void 0:r.texture)&&this._originalStroke.texture.destroy(s)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(t,i,n)=>(t[i]=n,null==e||e(i,n),this.update(),!0)})}_isFillStyle(t){return null!==(null!=t?t:null)&&!(Ft.isColorLike(t)||t instanceof lr||t instanceof dr)}};Lo.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},Lo.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 zo=Lo;const No=new class{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=Re.get().createCanvas();i.width=t,i.height=e;const n=i.getContext("2d");return{canvas:i,context:n}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6);const n=((t=V(t))<<17)+((e=V(e))<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let r=this._canvasPool[n].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:n}=e,r=(i<<17)+(n<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,n),this._canvasPool[r].push(t)}clear(){this._canvasPool={}}},Vo=1e5;function Ho(t,e,i,n=0){var r;if(t.texture===J.WHITE&&!t.fill)return Ft.shared.setValue(t.color).setAlpha(null!=(r=t.alpha)?r:1).toHexa();if(!t.fill){const i=e.createPattern(t.texture.source.resource,"repeat"),n=t.matrix.copyTo(S.shared);return n.scale(t.texture.frame.width,t.texture.frame.height),i.setTransform(n),i}if(t.fill instanceof dr){const i=t.fill,n=e.createPattern(i.texture.source.resource,"repeat"),r=i.transform.copyTo(S.shared);return r.scale(i.texture.frame.width,i.texture.frame.height),n.setTransform(r),n}if(t.fill instanceof lr){const r=t.fill,s="linear"===r.type,o="local"===r.textureSpace;let a,l=1,h=1;o&&i&&(l=i.width+n,h=i.height+n);let c=!1;if(s){const{start:t,end:i}=r;a=e.createLinearGradient(t.x*l,t.y*h,i.x*l,i.y*h),c=Math.abs(i.x-t.x)<Math.abs(.1*(i.y-t.y))}else{const{center:t,innerRadius:i,outerCenter:n,outerRadius:s}=r;a=e.createRadialGradient(t.x*l,t.y*h,i*l,n.x*l,n.y*h,s*l)}if(c&&o&&i){const t=i.lineHeight/h;for(let e=0;e<i.lines.length;e++){const s=(e*i.lineHeight+n/2)/h;r.colorStops.forEach(e=>{const i=s+e.offset*t;a.addColorStop(Math.floor(i*Vo)/Vo,Ft.shared.setValue(e.color).toHex())})}}else r.colorStops.forEach(t=>{a.addColorStop(t.offset,Ft.shared.setValue(t.color).toHex())});return a}return kt("FillStyle not recognised",t),"red"}const Wo=class t extends tr{constructor(e){var i,n,r;super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;const s=__spreadValues(__spreadValues({},t.defaultOptions),e);this._textureSize=s.textureSize,this._mipmap=s.mipmap;const o=s.style.clone();s.overrideFill&&(o._fill.color=16777215,o._fill.alpha=1,o._fill.texture=J.WHITE,o._fill.fill=null),this.applyFillAsTint=s.overrideFill;const a=o.fontSize;o.fontSize=this.baseMeasurementFontSize;const l=ir(o);s.overrideSize?o._stroke&&(o._stroke.width*=this.baseRenderedFontSize/a):o.fontSize=this.baseRenderedFontSize=a,this._style=o,this._skipKerning=null!=(i=s.skipKerning)&&i,this.resolution=null!=(n=s.resolution)?n:1,this._padding=null!=(r=s.padding)?r:4,s.textureStyle&&(this._textureStyle=s.textureStyle instanceof X?s.textureStyle:new X(s.textureStyle)),this.fontMetrics=sr.measureFont(l),this.lineHeight=o.lineHeight||this.fontMetrics.fontSize||o.fontSize}ensureCharacters(t){var e,i,n,r;const s=sr.graphemeSegmenter(t).filter(t=>!this._currentChars.includes(t)).filter((t,e,i)=>i.indexOf(t)===e);if(!s.length)return;let o;this._currentChars=[...this._currentChars,...s],o=-1===this._currentPageIndex?this._nextPage():this.pages[this._currentPageIndex];let{canvas:a,context:l}=o.canvasAndContext,h=o.texture.source;const c=this._style;let u=this._currentX,d=this._currentY,p=this._currentMaxCharHeight;const f=this.baseRenderedFontSize/this.baseMeasurementFontSize,g=this._padding*f;let m=!1;const _=a.width/this.resolution,y=a.height/this.resolution;for(let x=0;x<s.length;x++){const t=s[x],o=sr.measureText(t,c,a,!1);o.lineHeight=o.height;const b=o.width*f,v=Math.ceil(("italic"===c.fontStyle?2:1)*b)+2*g,w=o.height*f+2*g;if(m=!1,"\n"!==t&&"\r"!==t&&"\t"!==t&&" "!==t&&(m=!0,p=Math.ceil(Math.max(w,p))),u+v>_&&(d+=p,p=w,u=0,d+p>y)){h.update();const t=this._nextPage();a=t.canvasAndContext.canvas,l=t.canvasAndContext.context,h=t.texture.source,u=0,d=0,p=0}const S=b/f-(null!=(i=null==(e=c.dropShadow)?void 0:e.distance)?i:0)-(null!=(r=null==(n=c._stroke)?void 0:n.width)?r:0);if(this.chars[t]={id:t.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:S,kerning:{}},m){this._drawGlyph(l,o,u+g,d+g,f,c);const e=h.width*f,i=h.height*f,n=new D(u/e*h.width,d/i*h.height,v/e*h.width,w/i*h.height);this.chars[t].texture=new J({source:h,frame:n}),u+=Math.ceil(v)}}h.update(),this._currentX=u,this._currentY=d,this._currentMaxCharHeight=p,this._skipKerning&&this._applyKerning(s,l)}get pageTextures(){return z(L,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const i=this._measureCache;for(let n=0;n<t.length;n++){const r=t[n];for(let t=0;t<this._currentChars.length;t++){const n=this._currentChars[t];let s=i[r];s||(s=i[r]=e.measureText(r).width);let o=i[n];o||(o=i[n]=e.measureText(n).width);let a=e.measureText(r+n).width,l=a-(s+o);l&&(this.chars[r].kerning[n]=l),a=e.measureText(r+n).width,l=a-(s+o),l&&(this.chars[n].kerning[r]=l)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=No.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),n=new J({source:new Be({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(n.source.style=this._textureStyle);const r={canvasAndContext:e,texture:n};return this.pages[this._currentPageIndex]=r,r}_setupContext(t,e,i){var n;e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=ir(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const r=e._stroke,s=null!=(n=null==r?void 0:r.width)?n:0;if(r&&(t.lineWidth=s,t.lineJoin=r.join,t.miterLimit=r.miterLimit,t.strokeStyle=Ho(r,t)),e._fill&&(t.fillStyle=Ho(e._fill,t)),e.dropShadow){const n=e.dropShadow,r=Ft.shared.setValue(n.color).toArray(),s=n.blur*i,o=n.distance*i;t.shadowColor=`rgba(${255*r[0]},${255*r[1]},${255*r[2]},${n.alpha})`,t.shadowBlur=s,t.shadowOffsetX=Math.cos(n.angle)*o,t.shadowOffsetY=Math.sin(n.angle)*o}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,i,n,r,s){var o;const a=e.text,l=e.fontProperties,h=s._stroke,c=(null!=(o=null==h?void 0:h.width)?o:0)*r,u=i+c/2,d=n-c/2,p=l.descent*r,f=e.lineHeight*r;let g=!1;s.stroke&&c&&(g=!0,t.strokeText(a,u,d+f-p));const{shadowBlur:m,shadowOffsetX:_,shadowOffsetY:y}=t;s._fill&&(g&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(a,u,d+f-p)),g&&(t.shadowBlur=m,t.shadowOffsetX=_,t.shadowOffsetY=y)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];No.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}};Wo.defaultOptions={textureSize:512,style:new zo,mipmap:!0};let jo=Wo;function Yo(t,e,i,n){const r={width:0,height:0,offsetY:0,scale:e.fontSize/i.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};r.offsetY=i.baseLineOffset;let s=r.lines[0],o=null,a=!0;const l={width:0,start:0,index:0,positions:[],chars:[]},h=i.baseMeasurementFontSize/e.fontSize,c=e.letterSpacing*h,u=e.wordWrapWidth*h,d=e.lineHeight?e.lineHeight*h:i.lineHeight,p=e.wordWrap&&e.breakWords,f=t=>{const e=s.width;for(let i=0;i<l.index;i++){const n=t.positions[i];s.chars.push(t.chars[i]),s.charPositions.push(n+e)}s.width+=t.width,a=!1,l.width=0,l.index=0,l.chars.length=0},g=()=>{let t=s.chars.length-1;if(n){let e=s.chars[t];for(;" "===e;)s.width-=i.chars[e].xAdvance,e=s.chars[--t]}r.width=Math.max(r.width,s.width),s={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,r.lines.push(s),r.height+=d},m=t=>t-c>u;for(let _=0;_<t.length+1;_++){let n;const r=_===t.length;r||(n=t[_]);const h=i.chars[n]||i.chars[" "];if(/(?:\s)/.test(n)||"\r"===n||"\n"===n||r){if(!a&&e.wordWrap&&m(s.width+l.width)?(g(),f(l),r||s.charPositions.push(0)):(l.start=s.width,f(l),r||s.charPositions.push(0)),"\r"===n||"\n"===n)0!==s.width&&g();else if(!r){const t=h.xAdvance+(h.kerning[o]||0)+c;s.width+=t,s.spaceWidth=t,s.spacesIndex.push(s.charPositions.length),s.chars.push(n)}}else{const t=h.kerning[o]||0,e=h.xAdvance+t+c;p&&m(s.width+l.width+e)&&(f(l),g()),l.positions[l.index++]=l.width+t,l.chars.push(n),l.width+=e}o=n}return g(),"center"===e.align?function(t){for(let e=0;e<t.lines.length;e++){const i=t.lines[e],n=t.width/2-i.width/2;for(let t=0;t<i.charPositions.length;t++)i.charPositions[t]+=n}}(r):"right"===e.align?function(t){for(let e=0;e<t.lines.length;e++){const i=t.lines[e],n=t.width-i.width;for(let t=0;t<i.charPositions.length;t++)i.charPositions[t]+=n}}(r):"justify"===e.align&&function(t){const e=t.width;for(let i=0;i<t.lines.length;i++){const n=t.lines[i];let r=0,s=n.spacesIndex[r++],o=0;const a=n.spacesIndex.length,l=(e-n.width)/a;for(let t=0;t<n.charPositions.length;t++)t===s&&(s=n.spacesIndex[r++],o+=l),n.charPositions[t]+=o}}(r),r}let Xo=0;const Zo=new class{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1,textureStyle:null}}getFont(t,e){var i;let n=`${e.fontFamily}-bitmap`,r=!0;if(e._fill.fill&&!e._stroke)n+=e._fill.fill.styleKey,r=!1;else if(e._stroke||e.dropShadow){let t=e.styleKey;t=t.substring(0,t.lastIndexOf("-")),n=`${t}-bitmap`,r=!1}if(!Ve.has(n)){const t=Object.create(e);t.lineHeight=0;const i=new jo(__spreadValues({style:t,overrideFill:r,overrideSize:!0},this.defaultOptions));Xo++,Xo>50&&kt("BitmapText",`You have dynamically created ${Xo} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),i.once("destroy",()=>{Xo--,Ve.remove(n)}),Ve.set(n,i)}const s=Ve.get(n);return null==(i=s.ensureCharacters)||i.call(s,t),s}getLayout(t,e,i=!0){const n=this.getFont(t,e);return Yo(sr.graphemeSegmenter(t),e,n,i)}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var e,i,n,r,s;let o=t[0];"string"==typeof o&&(o={name:o,style:t[1],chars:null==(e=t[2])?void 0:e.chars,resolution:null==(i=t[2])?void 0:i.resolution,padding:null==(n=t[2])?void 0:n.padding,skipKerning:null==(r=t[2])?void 0:r.skipKerning},z(L,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const a=null==o?void 0:o.name;if(!a)throw new Error("[BitmapFontManager] Property `name` is required.");o=__spreadValues(__spreadValues({},this.defaultOptions),o);const l=o.style,h=l instanceof zo?l:new zo(l),c=null!=(s=o.dynamicFill)?s:this._canUseTintForStyle(h),u=new jo({style:h,overrideFill:c,skipKerning:o.skipKerning,padding:o.padding,resolution:o.resolution,overrideSize:!1,textureStyle:o.textureStyle}),d=function(t){if(""===t)return[];"string"==typeof t&&(t=[t]);const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i];if(Array.isArray(n)){if(2!==n.length)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);if(0===n[0].length||0===n[1].length)throw new Error("[BitmapFont]: Invalid character delimiter.");const t=n[0].charCodeAt(0),i=n[1].charCodeAt(0);if(i<t)throw new Error("[BitmapFont]: Invalid character range.");for(let n=t,r=i;n<=r;n++)e.push(String.fromCharCode(n))}else e.push(...Array.from(n))}if(0===e.length)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}(o.chars);return u.ensureCharacters(d.join("")),Ve.set(`${a}-bitmap`,u),u.once("destroy",()=>Ve.remove(`${a}-bitmap`)),u}uninstall(t){const e=`${t}-bitmap`,i=Ve.get(e);i&&i.destroy()}_canUseTintForStyle(t){return!(t._stroke||t.dropShadow&&0!==t.dropShadow.color||t._fill.fill||16777215!==t._fill.color)}};class qo extends tr{constructor(t,e){var i;super();const{textures:n,data:r}=t;Object.keys(r.pages).forEach(t=>{const e=r.pages[parseInt(t,10)],i=n[e.id];this.pages.push({texture:i})}),Object.keys(r.chars).forEach(t=>{var e;const i=r.chars[t],{frame:s,source:o,rotate:a}=n[i.page],l=k.transformRectCoords(i,s,a,new D),h=new J({frame:l,orig:new D(0,0,i.width,i.height),source:o,rotate:a});this.chars[t]={id:t.codePointAt(0),xOffset:i.xOffset,yOffset:i.yOffset,xAdvance:i.xAdvance,kerning:null!=(e=i.kerning)?e:{},texture:h}}),this.baseRenderedFontSize=r.fontSize,this.baseMeasurementFontSize=r.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:r.fontSize},this.baseLineOffset=r.baseLineOffset,this.lineHeight=r.lineHeight,this.fontFamily=r.fontFamily,this.distanceField=null!=(i=r.distanceField)?i:{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){Zo.install(t)}static uninstall(t){Zo.uninstall(t)}}const Ko={test:t=>"string"==typeof t&&t.startsWith("info face="),parse(t){var e,i,n;const r=t.match(/^[a-z]+\s+.+$/gm),s={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const f in r){const t=r[f].match(/^[a-z]+/gm)[0],e=r[f].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),i={};for(const n in e){const t=e[n].split("="),r=t[0],s=t[1].replace(/"/gm,""),o=parseFloat(s),a=isNaN(o)?s:o;i[r]=a}s[t].push(i)}const o={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[a]=s.info,[l]=s.common,[h]=null!=(e=s.distanceField)?e:[];h&&(o.distanceField={range:parseInt(h.distanceRange,10),type:h.fieldType}),o.fontSize=parseInt(a.size,10),o.fontFamily=a.face,o.lineHeight=parseInt(l.lineHeight,10);const c=s.page;for(let f=0;f<c.length;f++)o.pages.push({id:parseInt(c[f].id,10)||0,file:c[f].file});const u={};o.baseLineOffset=o.lineHeight-parseInt(l.base,10);const d=s.char;for(let f=0;f<d.length;f++){const t=d[f],e=parseInt(t.id,10);let r=null!=(n=null!=(i=t.letter)?i:t.char)?n:String.fromCharCode(e);"space"===r&&(r=" "),u[e]=r,o.chars[r]={id:e,page:parseInt(t.page,10)||0,x:parseInt(t.x,10),y:parseInt(t.y,10),width:parseInt(t.width,10),height:parseInt(t.height,10),xOffset:parseInt(t.xoffset,10),yOffset:parseInt(t.yoffset,10),xAdvance:parseInt(t.xadvance,10),kerning:{}}}const p=s.kerning||[];for(let f=0;f<p.length;f++){const t=parseInt(p[f].first,10),e=parseInt(p[f].second,10),i=parseInt(p[f].amount,10);o.chars[u[e]].kerning[u[t]]=i}return o}},$o={test(t){const e=t;return"string"!=typeof e&&"getElementsByTagName"in e&&e.getElementsByTagName("page").length&&null!==e.getElementsByTagName("info")[0].getAttribute("face")},parse(t){var e,i;const n={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},r=t.getElementsByTagName("info")[0],s=t.getElementsByTagName("common")[0],o=t.getElementsByTagName("distanceField")[0];o&&(n.distanceField={type:o.getAttribute("fieldType"),range:parseInt(o.getAttribute("distanceRange"),10)});const a=t.getElementsByTagName("page"),l=t.getElementsByTagName("char"),h=t.getElementsByTagName("kerning");n.fontSize=parseInt(r.getAttribute("size"),10),n.fontFamily=r.getAttribute("face"),n.lineHeight=parseInt(s.getAttribute("lineHeight"),10);for(let u=0;u<a.length;u++)n.pages.push({id:parseInt(a[u].getAttribute("id"),10)||0,file:a[u].getAttribute("file")});const c={};n.baseLineOffset=n.lineHeight-parseInt(s.getAttribute("base"),10);for(let u=0;u<l.length;u++){const t=l[u],r=parseInt(t.getAttribute("id"),10);let s=null!=(i=null!=(e=t.getAttribute("letter"))?e:t.getAttribute("char"))?i:String.fromCharCode(r);"space"===s&&(s=" "),c[r]=s,n.chars[s]={id:r,page:parseInt(t.getAttribute("page"),10)||0,x:parseInt(t.getAttribute("x"),10),y:parseInt(t.getAttribute("y"),10),width:parseInt(t.getAttribute("width"),10),height:parseInt(t.getAttribute("height"),10),xOffset:parseInt(t.getAttribute("xoffset"),10),yOffset:parseInt(t.getAttribute("yoffset"),10),xAdvance:parseInt(t.getAttribute("xadvance"),10),kerning:{}}}for(let u=0;u<h.length;u++){const t=parseInt(h[u].getAttribute("first"),10),e=parseInt(h[u].getAttribute("second"),10),i=parseInt(h[u].getAttribute("amount"),10);n.chars[c[e]].kerning[c[t]]=i}return n}},Qo={test:t=>!("string"!=typeof t||!t.includes("<font>"))&&$o.test(Re.get().parseXML(t)),parse:t=>$o.parse(Re.get().parseXML(t))},Jo=[".xml",".fnt"],ta={extension:{type:o.CacheParser,name:"cacheBitmapFont"},test:t=>t instanceof qo,getCacheableAssets(t,e){const i={};return t.forEach(t=>{i[t]=e,i[`${t}-bitmap`]=e}),i[`${e.fontFamily}-bitmap`]=e,i}},ea={extension:{type:o.LoadParser,priority:je.Normal},name:"loadBitmapFont",id:"bitmap-font",test:t=>Jo.includes(Ze.extname(t).toLowerCase()),testParse(t){return __async(this,null,function*(){return Ko.test(t)||Qo.test(t)})},parse(t,e,i){return __async(this,null,function*(){const n=Ko.test(t)?Ko.parse(t):Qo.parse(t),{src:r}=e,{pages:s}=n,o=[],a=n.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let t=0;t<s.length;++t){const e=s[t].file;let i=Ze.join(Ze.dirname(r),e);i=Je(i,r),o.push({src:i,data:a})}const l=yield i.load(o),h=o.map(t=>l[t.src]);return new qo({data:n,textures:h},r)})},load(t,e){return __async(this,null,function*(){const e=yield Re.get().fetch(t);return yield e.text()})},unload(t,e,i){return __async(this,null,function*(){yield Promise.all(t.pages.map(t=>i.unload(t.texture.source._sourceOrigin))),t.destroy()})}};class ia{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(t=>{this._assetList.push(t)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}_next(){return __async(this,null,function*(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());yield this._loader.load(t),this._isLoading=!1,this._next()}})}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const na={extension:{type:o.CacheParser,name:"cacheTextureArray"},test:t=>Array.isArray(t)&&t.every(t=>t instanceof J),getCacheableAssets:(t,e)=>{const i={};return t.forEach(t=>{e.forEach((e,n)=>{i[t+(0===n?"":n+1)]=e})}),i}};function ra(t){return __async(this,null,function*(){if("Image"in globalThis)return new Promise(e=>{const i=new Image;i.onload=()=>{e(!0)},i.onerror=()=>{e(!1)},i.src=t});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const e=yield(yield fetch(t)).blob();yield createImageBitmap(e)}catch(e){return!1}return!0}return!1})}const sa={extension:{type:o.DetectionParser,priority:1},test:()=>__async(null,null,function*(){return ra("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=")}),add:t=>__async(null,null,function*(){return[...t,"avif"]}),remove:t=>__async(null,null,function*(){return t.filter(t=>"avif"!==t)})},oa=["png","jpg","jpeg"],aa={extension:{type:o.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:t=>__async(null,null,function*(){return[...t,...oa]}),remove:t=>__async(null,null,function*(){return t.filter(t=>!oa.includes(t))})},la="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function ha(t){if(la)return!1;return""!==document.createElement("video").canPlayType(t)}const ca={extension:{type:o.DetectionParser,priority:0},test:()=>__async(null,null,function*(){return ha("video/mp4")}),add:t=>__async(null,null,function*(){return[...t,"mp4","m4v"]}),remove:t=>__async(null,null,function*(){return t.filter(t=>"mp4"!==t&&"m4v"!==t)})},ua={extension:{type:o.DetectionParser,priority:0},test:()=>__async(null,null,function*(){return ha("video/ogg")}),add:t=>__async(null,null,function*(){return[...t,"ogv"]}),remove:t=>__async(null,null,function*(){return t.filter(t=>"ogv"!==t)})},da={extension:{type:o.DetectionParser,priority:0},test:()=>__async(null,null,function*(){return ha("video/webm")}),add:t=>__async(null,null,function*(){return[...t,"webm"]}),remove:t=>__async(null,null,function*(){return t.filter(t=>"webm"!==t)})},pa={extension:{type:o.DetectionParser,priority:0},test:()=>__async(null,null,function*(){return ra("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=")}),add:t=>__async(null,null,function*(){return[...t,"webp"]}),remove:t=>__async(null,null,function*(){return t.filter(t=>"webp"!==t)})};class fa{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(()=>__async(this,null,function*(){var n,r;let s=null,o=null;if((e.parser||e.loadParser)&&(o=this._parserHash[e.parser||e.loadParser],e.loadParser&&kt(`[Assets] "loadParser" is deprecated, use "parser" instead for ${t}`),o||kt(`[Assets] specified load parser "${e.parser||e.loadParser}" not found while loading ${t}`)),!o){for(let i=0;i<this.parsers.length;i++){const r=this.parsers[i];if(r.load&&(null==(n=r.test)?void 0:n.call(r,t,e,this))){o=r;break}}if(!o)return kt(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=yield o.load(t,e,this),i.parser=o;for(let t=0;t<this.parsers.length;t++){const n=this.parsers[t];n.parse&&n.parse&&(yield null==(r=n.testParse)?void 0:r.call(n,s,e,this))&&(s=(yield n.parse(s,e,this))||s,i.parser=n)}return s}))(),i}load(t,e){return __async(this,null,function*(){this._parsersValidated||this._validateParsers();let i=0;const n={},r=$e(t),s=Ne(t,t=>({alias:[t],src:t,data:{}})),o=s.length,a=s.map(t=>__async(this,null,function*(){const r=Ze.toAbsolute(t.src);if(!n[t.src])try{this.promiseCache[r]||(this.promiseCache[r]=this._getLoadPromiseAndParser(r,t)),n[t.src]=yield this.promiseCache[r].promise,e&&e(++i/o)}catch(s){throw delete this.promiseCache[r],delete n[t.src],new Error(`[Loader.load] Failed to load ${r}.\n${s}`)}}));return yield Promise.all(a),r?n[s[0].src]:n})}unload(t){return __async(this,null,function*(){const e=Ne(t,t=>({alias:[t],src:t})).map(t=>__async(this,null,function*(){var e,i;const n=Ze.toAbsolute(t.src),r=this.promiseCache[n];if(r){const s=yield r.promise;delete this.promiseCache[n],yield null==(i=null==(e=r.parser)?void 0:e.unload)?void 0:i.call(e,s,t,this)}}));yield Promise.all(e)})}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(e.name||e.id?(t[e.name]||t[e.id])&&kt(`[Assets] parser id conflict "${e.id}"`):kt("[Assets] parser should have an id"),t[e.name]=e,e.id&&(t[e.id]=e),t),{})}}function ga(t,e){if(Array.isArray(e)){for(const i of e)if(t.startsWith(`data:${i}`))return!0;return!1}return t.startsWith(`data:${e}`)}function ma(t,e){const i=t.split("?")[0],n=Ze.extname(i).toLowerCase();return Array.isArray(e)?e.includes(n):n===e}const _a={extension:{type:o.LoadParser,priority:je.Low},name:"loadJson",id:"json",test:t=>ga(t,"application/json")||ma(t,".json"),load(t){return __async(this,null,function*(){const e=yield Re.get().fetch(t);return yield e.json()})}},ya={name:"loadTxt",id:"text",extension:{type:o.LoadParser,priority:je.Low,name:"loadTxt"},test:t=>ga(t,"text/plain")||ma(t,".txt"),load(t){return __async(this,null,function*(){const e=yield Re.get().fetch(t);return yield e.text()})}},xa=["normal","bold","100","200","300","400","500","600","700","800","900"],ba=[".ttf",".otf",".woff",".woff2"],va=["font/ttf","font/otf","font/woff","font/woff2"],wa=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;const Sa=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Aa(t){return Sa.test(t)?t:encodeURI(t)}const Ta={extension:{type:o.LoadParser,priority:je.Low},name:"loadWebFont",id:"web-font",test:t=>ga(t,va)||ma(t,ba),load(t,e){return __async(this,null,function*(){var i,n,r,s,o,a;const l=Re.get().getFontFaceSet();if(l){const h=[],c=null!=(n=null==(i=e.data)?void 0:i.family)?n:function(t){const e=Ze.extname(t),i=Ze.basename(t,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1));let n=i.length>0;for(const s of i)if(!s.match(wa)){n=!1;break}let r=i.join(" ");return n||(r=`"${r.replace(/[\\"]/g,"\\$&")}"`),r}(t),u=null!=(o=null==(s=null==(r=e.data)?void 0:r.weights)?void 0:s.filter(t=>xa.includes(t)))?o:["normal"],d=null!=(a=e.data)?a:{};for(let e=0;e<u.length;e++){const i=u[e],n=new FontFace(c,`url(${Aa(t)})`,__spreadProps(__spreadValues({},d),{weight:i}));yield n.load(),l.add(n),h.push(n)}if(Ve.has(`${c}-and-url`)){Ve.get(`${c}-and-url`).entries.push({url:t,faces:h})}else Ve.set(`${c}-and-url`,{entries:[{url:t,faces:h}]});return 1===h.length?h[0]:h}return kt("[loadWebFont] FontFace API is not supported. Skipping loading font"),null})},unload(t){const e=Array.isArray(t)?t:[t],i=e[0].family,n=Ve.get(`${i}-and-url`),r=n.entries.find(t=>t.faces.some(t=>-1!==e.indexOf(t)));r.faces=r.faces.filter(t=>-1===e.indexOf(t)),0===r.faces.length&&(n.entries=n.entries.filter(t=>t!==r)),e.forEach(t=>{Re.get().getFontFaceSet().delete(t)}),0===n.entries.length&&Ve.remove(`${i}-and-url`)}};function Ca(t,e=1){var i;const n=null==(i=Qe.RETINA_PREFIX)?void 0:i.exec(t);return n?parseFloat(n[1]):e}function Pa(t,e,i){t.label=i,t._sourceOrigin=i;const n=new J({source:t,label:i}),r=()=>{delete e.promiseCache[i],Ve.has(i)&&Ve.remove(i)};return n.source.once("destroy",()=>{e.promiseCache[i]&&(kt("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),r())}),n.once("destroy",()=>{t.destroyed||(kt("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),n}const Ma={extension:{type:o.LoadParser,priority:je.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test:t=>ga(t,"image/svg+xml")||ma(t,".svg"),load(t,e,i){return __async(this,null,function*(){var n,r;return(null!=(r=null==(n=e.data)?void 0:n.parseAsGraphicsContext)?r:this.config.parseAsGraphicsContext)?function(t){return __async(this,null,function*(){const e=yield Re.get().fetch(t),i=yield e.text(),n=new Do;return n.svg(i),n})}(t):function(t,e,i,n){return __async(this,null,function*(){var r,s,o,a,l,h;const c=yield Re.get().fetch(t),u=yield c.blob(),d=URL.createObjectURL(u),p=Re.get().createImage();p.src=d,p.crossOrigin=n,yield p.decode(),URL.revokeObjectURL(d);const f=null!=(s=null==(r=e.data)?void 0:r.width)?s:p.width,g=null!=(a=null==(o=e.data)?void 0:o.height)?a:p.height,m=(null==(l=e.data)?void 0:l.resolution)||Ca(t),_=Re.get().createCanvas(f*m,g*m);_.getContext("2d").drawImage(p,0,0,f*m,g*m);const y=null!=(h=e.data)?h:{},{parseAsGraphicsContext:x}=y,b=__objRest(y,["parseAsGraphicsContext"]);return Pa(new Be(__spreadValues({resource:_,alphaMode:"premultiply-alpha-on-upload",resolution:m},b)),i,t)})}(t,e,i,this.config.crossOrigin)})},unload(t){t.destroy(!0)}};let Ea=null,Ra=class{constructor(){Ea||(Ea=URL.createObjectURL(new Blob(['(function () {\n \'use strict\';\n\n const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";\n async function checkImageBitmap() {\n try {\n if (typeof createImageBitmap !== "function")\n return false;\n const response = await fetch(WHITE_PNG);\n const imageBlob = await response.blob();\n const imageBitmap = await createImageBitmap(imageBlob);\n return imageBitmap.width === 1 && imageBitmap.height === 1;\n } catch (_e) {\n return false;\n }\n }\n void checkImageBitmap().then((result) => {\n self.postMessage(result);\n });\n\n})();\n'],{type:"application/javascript"}))),this.worker=new Worker(Ea)}};Ra.revokeObjectURL=function(){Ea&&(URL.revokeObjectURL(Ea),Ea=null)};let Fa=null;class Ba{constructor(){Fa||(Fa=URL.createObjectURL(new Blob(['(function () {\n \'use strict\';\n\n async function loadImageBitmap(url, alphaMode) {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${url}: ${response.status} ${response.statusText}`);\n }\n const imageBlob = await response.blob();\n return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);\n }\n self.onmessage = async (event) => {\n try {\n const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);\n self.postMessage({\n data: imageBitmap,\n uuid: event.data.uuid,\n id: event.data.id\n }, [imageBitmap]);\n } catch (e) {\n self.postMessage({\n error: e,\n uuid: event.data.uuid,\n id: event.data.id\n });\n }\n };\n\n})();\n'],{type:"application/javascript"}))),this.worker=new Worker(Fa)}}Ba.revokeObjectURL=function(){Fa&&(URL.revokeObjectURL(Fa),Fa=null)};let ka,Ia=0;const Da=new class{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return void 0!==this._isImageBitmapSupported||(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new Ra;e.addEventListener("message",i=>{e.terminate(),Ra.revokeObjectURL(),t(i.data)})})),this._isImageBitmapSupported}loadImageBitmap(t,e){var i;return this._run("loadImageBitmap",[t,null==(i=null==e?void 0:e.data)?void 0:i.alphaMode])}_initWorkers(){return __async(this,null,function*(){this._initialized||(this._initialized=!0)})}_getWorker(){void 0===ka&&(ka=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<ka&&(this._createdWorkers++,t=(new Ba).worker,t.addEventListener("message",t=>{this._complete(t.data),this._returnWorker(t.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){void 0!==t.error?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}_run(t,e){return __async(this,null,function*(){yield this._initWorkers();const i=new Promise((i,n)=>{this._queue.push({id:t,arguments:e,resolve:i,reject:n})});return this._next(),i})}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[Ia]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Ia++,id:i})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{null==t||t(new Error("WorkerManager destroyed"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}},Oa=[".jpeg",".jpg",".png",".webp",".avif"],Ua=["image/jpeg","image/png","image/webp","image/avif"];const Ga={name:"loadTextures",id:"texture",extension:{type:o.LoadParser,priority:je.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test:t=>ga(t,Ua)||ma(t,Oa),load(t,e,i){return __async(this,null,function*(){var n;let r=null;r=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&(yield Da.isImageBitmapSupported())?yield Da.loadImageBitmap(t,e):yield function(t,e){return __async(this,null,function*(){var i;const n=yield Re.get().fetch(t);if(!n.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${t}: ${n.status} ${n.statusText}`);const r=yield n.blob();return"premultiplied-alpha"===(null==(i=null==e?void 0:e.data)?void 0:i.alphaMode)?createImageBitmap(r,{premultiplyAlpha:"none"}):createImageBitmap(r)})}(t,e):yield new Promise((e,i)=>{r=Re.get().createImage(),r.crossOrigin=this.config.crossOrigin,r.src=t,r.complete?e(r):(r.onload=()=>{e(r)},r.onerror=i)});return Pa(new Be(__spreadValues({resource:r,alphaMode:"premultiply-alpha-on-upload",resolution:(null==(n=e.data)?void 0:n.resolution)||Ca(t)},e.data)),i,t)})},unload(t){t.destroy(!0)}},La=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let za,Na;function Va(t,e,i){void 0!==i||e.startsWith("data:")?!1!==i&&(t.crossOrigin="string"==typeof i?i:"anonymous"):t.crossOrigin=function(t,e=globalThis.location){if(t.startsWith("data:"))return"";e||(e=globalThis.location);const i=new URL(t,document.baseURI);if(i.hostname!==e.hostname||i.port!==e.port||i.protocol!==e.protocol)return"anonymous";return""}(e)}const Ha={name:"loadVideo",id:"video",extension:{type:o.LoadParser,name:"loadVideo"},test(t){if(!za||!Na){const{validVideoExtensions:t,validVideoMime:e}=function(){const t=[],e=[];for(const i of La){const n=ze.MIME_TYPES[i.substring(1)]||`video/${i.substring(1)}`;ha(n)&&(t.push(i),e.includes(n)||e.push(n))}return{validVideoExtensions:t,validVideoMime:e}}();za=t,Na=e}const e=ga(t,Na),i=ma(t,za);return e||i},load(t,e,i){return __async(this,null,function*(){var n,r;const s=__spreadValues(__spreadProps(__spreadValues({},ze.defaultOptions),{resolution:(null==(n=e.data)?void 0:n.resolution)||Ca(t),alphaMode:(null==(r=e.data)?void 0:r.alphaMode)||(yield Ge())}),e.data),o=document.createElement("video"),a={preload:!1!==s.autoLoad?"auto":void 0,"webkit-playsinline":!1!==s.playsinline?"":void 0,playsinline:!1!==s.playsinline?"":void 0,muted:!0===s.muted?"":void 0,loop:!0===s.loop?"":void 0,autoplay:!1!==s.autoPlay?"":void 0};Object.keys(a).forEach(t=>{const e=a[t];void 0!==e&&o.setAttribute(t,e)}),!0===s.muted&&(o.muted=!0),Va(o,t,s.crossorigin);const l=document.createElement("source");let h;if(s.mime)h=s.mime;else if(t.startsWith("data:"))h=t.slice(5,t.indexOf(";"));else if(!t.startsWith("blob:")){const e=t.split("?")[0].slice(t.lastIndexOf(".")+1).toLowerCase();h=ze.MIME_TYPES[e]||`video/${e}`}return l.src=t,h&&(l.type=h),new Promise(n=>{const r=()=>__async(null,null,function*(){const a=new ze(__spreadProps(__spreadValues({},s),{resource:o}));var l;o.removeEventListener("canplay",r),e.data.preload&&(yield(l=o,new Promise((t,e)=>{function i(){r(),t()}function n(t){r(),e(t)}function r(){l.removeEventListener("canplaythrough",i),l.removeEventListener("error",n)}l.addEventListener("canplaythrough",i),l.addEventListener("error",n),l.load()}))),n(Pa(a,i,t))});s.preload&&!s.autoPlay&&o.load(),o.addEventListener("canplay",r),o.appendChild(l)})})},unload(t){t.destroy(!0)}},Wa={extension:{type:o.ResolveParser,name:"resolveTexture"},test:Ga.test,parse:t=>{var e,i;return{resolution:parseFloat(null!=(i=null==(e=Qe.RETINA_PREFIX.exec(t))?void 0:e[1])?i:"1"),format:t.split(".").pop(),src:t}}},ja={extension:{type:o.ResolveParser,priority:-2,name:"resolveJson"},test:t=>Qe.RETINA_PREFIX.test(t)&&t.endsWith(".json"),parse:Wa.parse};const Ya=new class{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Qe,this.loader=new fa,this.cache=Ve,this._backgroundLoader=new ia(this.loader),this._backgroundLoader.active=!0,this.reset()}init(){return __async(this,arguments,function*(t={}){var e,i,n;if(this._initialized)return void kt("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let e=t.manifest;"string"==typeof e&&(e=yield this.load(e)),this.resolver.addManifest(e)}const r=null!=(i=null==(e=t.texturePreference)?void 0:e.resolution)?i:1,s="number"==typeof r?[r]:r,o=yield this._detectFormats({preferredFormats:null==(n=t.texturePreference)?void 0:n.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:o,resolution:s}}),t.preferences&&this.setPreferences(t.preferences)})}add(t){this.resolver.add(t)}load(t,e){return __async(this,null,function*(){this._initialized||(yield this.init());const i=$e(t),n=Ne(t).map(t=>{if("string"!=typeof t){const e=this.resolver.getAlias(t);return e.some(t=>!this.resolver.hasKey(t))&&this.add(t),Array.isArray(e)?e[0]:e}return this.resolver.hasKey(t)||this.add({alias:t,src:t}),t}),r=this.resolver.resolve(n),s=yield this._mapLoadToResolve(r,e);return i?s[n[0]]:s})}addBundle(t,e){this.resolver.addBundle(t,e)}loadBundle(t,e){return __async(this,null,function*(){this._initialized||(yield this.init());let i=!1;"string"==typeof t&&(i=!0,t=[t]);const n=this.resolver.resolveBundle(t),r={},s=Object.keys(n);let o=0,a=0;const l=()=>{null==e||e(++o/a)},h=s.map(t=>{const e=n[t],i=Object.values(e),s=[...new Set(i.flat())];return a+=s.length,this._mapLoadToResolve(e,l).then(e=>{r[t]=e})});return yield Promise.all(h),i?r[t[0]]:r})}backgroundLoad(t){return __async(this,null,function*(){this._initialized||(yield this.init()),"string"==typeof t&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))})}backgroundLoadBundle(t){return __async(this,null,function*(){this._initialized||(yield this.init()),"string"==typeof t&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(t=>{this._backgroundLoader.add(Object.values(t))})})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if("string"==typeof t)return Ve.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=Ve.get(t[i]);return e}_mapLoadToResolve(t,e){return __async(this,null,function*(){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const n=yield this.loader.load(i,e);this._backgroundLoader.active=!0;const r={};return i.forEach(t=>{const e=n[t.src],i=[t.src];t.alias&&i.push(...t.alias),i.forEach(t=>{r[t]=e}),Ve.set(i,e)}),r})}unload(t){return __async(this,null,function*(){this._initialized||(yield this.init());const e=Ne(t).map(t=>"string"!=typeof t?t.src:t),i=this.resolver.resolve(e);yield this._unloadFromResolved(i)})}unloadBundle(t){return __async(this,null,function*(){this._initialized||(yield this.init()),t=Ne(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(t=>this._unloadFromResolved(e[t]));yield Promise.all(i)})}_unloadFromResolved(t){return __async(this,null,function*(){const e=Object.values(t);e.forEach(t=>{Ve.remove(t.src)}),yield this.loader.unload(e)})}_detectFormats(t){return __async(this,null,function*(){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||(yield i.test())?e=yield i.add(e):t.skipDetections||(e=yield i.remove(e));return e=e.filter((t,i)=>e.indexOf(t)===i),e})}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(e=>e in t).forEach(i=>{e.config[i]=t[i]})})}};h.handleByList(o.LoadParser,Ya.loader.parsers).handleByList(o.ResolveParser,Ya.resolver.parsers).handleByList(o.CacheParser,Ya.cache.parsers).handleByList(o.DetectionParser,Ya.detections),h.add(na,aa,sa,pa,ca,ua,da,_a,ya,Ta,Ma,Ga,Ha,ea,ta,Wa,ja);const Xa={loader:o.LoadParser,resolver:o.ResolveParser,cache:o.CacheParser,detection:o.DetectionParser};h.handle(o.Asset,t=>{const e=t.ref;Object.entries(Xa).filter(([t])=>!!e[t]).forEach(([t,i])=>{var n;return h.add(Object.assign(e[t],{extension:null!=(n=e[t].extension)?n:i}))})},t=>{const e=t.ref;Object.keys(Xa).filter(t=>!!e[t]).forEach(t=>h.remove(e[t]))});class Za extends be{constructor(t={}){const e=t,{element:i,anchor:n}=e,r=__objRest(e,["element","anchor"]);super(__spreadValues({label:"DOMContainer"},r)),this.renderPipeId="dom",this.batched=!1,this._anchor=new v(0,0),n&&(this.anchor=n),this.element=t.element||document.createElement("div")}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}set element(t){this._element!==t&&(this._element=t,this.onViewUpdate())}get element(){return this._element}updateBounds(){const t=this._bounds,e=this._element;if(!e)return t.minX=0,t.minY=0,t.maxX=0,void(t.maxY=0);const{offsetWidth:i,offsetHeight:n}=e;t.minX=0,t.maxX=i,t.minY=0,t.maxY=n}destroy(t=!1){var e,i;super.destroy(t),null==(i=null==(e=this._element)?void 0:e.parentNode)||i.removeChild(this._element),this._element=null,this._anchor=null}}class qa{constructor(t){this._attachedDomElements=[],this._renderer=t,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 si({domElement:this._domElement,renderer:this._renderer})}addRenderable(t,e){this._attachedDomElements.includes(t)||this._attachedDomElements.push(t)}updateRenderable(t){}validateRenderable(t){return!0}postrender(){const t=this._attachedDomElements;if(0!==t.length){this._canvasObserver.ensureAttached();for(let e=0;e<t.length;e++){const i=t[e],n=i.element;if(!i.parent||i.globalDisplayStatus<7)null==n||n.remove(),t.splice(e,1),e--;else{this._domElement.contains(n)||(n.style.position="absolute",n.style.pointerEvents="auto",this._domElement.appendChild(n));const t=i.worldTransform,e=i._anchor,r=i.width*e.x,s=i.height*e.y;n.style.transformOrigin=`${r}px ${s}px`,n.style.transform=`matrix(${t.a}, ${t.b}, ${t.c}, ${t.d}, ${t.tx-r}, ${t.ty-s})`,n.style.opacity=i.groupAlpha.toString()}}}else this._domElement.remove()}destroy(){var t;this._renderer.runners.postrender.remove(this);for(let e=0;e<this._attachedDomElements.length;e++){null==(t=this._attachedDomElements[e].element)||t.remove()}this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}qa.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"dom"};const Ka=new class{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){!this._tickerAdded&&this.domElement&&(Ue.system.add(this._tickerUpdate,this,ke.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(Ue.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove)return void(this._didMove=!1);const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&"touch"===t.pointerType||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}):new MouseEvent("mousemove",{clientX:t.clientX,clientY:t.clientY}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,this._deltaTime<this.interactionFrequency||(this._deltaTime=0,this._update())}};class $a extends oi{constructor(){super(...arguments),this.client=new v,this.movement=new v,this.offset=new v,this.global=new v,this.screen=new v}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,n,r,s,o,a,l,h,c,u,d,p,f){throw new Error("Method not implemented.")}}class Qa extends $a{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Ja extends $a{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Ja.DOM_DELTA_PIXEL=0,Ja.DOM_DELTA_LINE=1,Ja.DOM_DELTA_PAGE=2;const tl=new v,el=new v;class il{constructor(t){this.dispatch=new _,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((t,e)=>t.priority-e.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,n=e.length;i<n;i++)e[i].fn(t);else kt(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){Ka.pauseUpdate=!0;const i=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,tl.set(t,e),this.hitTestFn,this.hitPruneFn);return i&&i[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let n=0,r=i.length-1;n<r;n++)if(t.currentTarget=i[n],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!t.propagationStopped&&!t.propagationImmediatelyStopped){t.eventPhase=t.BUBBLING_PHASE;for(let n=i.length-2;n>=0;n--)if(t.currentTarget=i[n],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(0===i.length)return;t.eventPhase=t.BUBBLING_PHASE;const n=Array.isArray(e)?e:[e];for(let r=i.length-1;r>=0;r--)n.forEach(e=>{t.currentTarget=i[r],this.notifyTarget(t,e)})}propagationPath(t){const e=[t];for(let i=0;i<2048&&t!==this.rootTarget&&t.parent;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,n,r,s=!1){let o=!1;if(this._interactivePrune(t))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(Ka.pauseUpdate=!1),t.interactiveChildren&&t.children){const a=t.children;for(let l=a.length-1;l>=0;l--){const h=a[l],c=this.hitTestMoveRecursive(h,this._isInteractive(e)?e:h.eventMode,i,n,r,s||r(t,i));if(c){if(c.length>0&&!c[c.length-1].parent)continue;const e=t.isInteractive();(c.length>0||e)&&(e&&this._allInteractiveElements.push(t),c.push(t)),0===this._hitElements.length&&(this._hitElements=c),o=!0}}}const a=this._isInteractive(e),l=t.isInteractive();return l&&l&&this._allInteractiveElements.push(t),s||this._hitElements.length>0?null:o?this._hitElements:a&&!r(t,i)&&n(t,i)?l?[t]:[]:null}hitTestRecursive(t,e,i,n,r){if(this._interactivePrune(t)||r(t,i))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(Ka.pauseUpdate=!1),t.interactiveChildren&&t.children){const s=t.children,o=i;for(let i=s.length-1;i>=0;i--){const a=s[i],l=this.hitTestRecursive(a,this._isInteractive(e)?e:a.eventMode,o,n,r);if(l){if(l.length>0&&!l[l.length-1].parent)continue;const e=t.isInteractive();return(l.length>0||e)&&l.push(t),l}}}const s=this._isInteractive(e),o=t.isInteractive();return s&&n(t,i)?o?[t]:[]:null}_isInteractive(t){return"static"===t||"dynamic"===t}_interactivePrune(t){return!(t&&t.visible&&t.renderable&&t.measurable)||("none"===t.eventMode||"passive"===t.eventMode&&!t.interactiveChildren)}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,el),!t.hitArea.contains(el.x,el.y)))return!0;if(t.effects&&t.effects.length)for(let i=0;i<t.effects.length;i++){const n=t.effects[i];if(n.containsPoint){if(!n.containsPoint(e,this.hitTestFn))return!0}}return!1}hitTestFn(t,e){return!!t.hitArea||!!(null==t?void 0:t.containsPoint)&&(t.worldTransform.applyInverse(e,el),t.containsPoint(el))}notifyTarget(t,e){var i,n;if(!t.currentTarget.isInteractive())return;null!=e||(e=t.type);const r=`on${e}`;null==(n=(i=t.currentTarget)[r])||n.call(i,t);const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof Qa))return void kt("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType)this.dispatchEvent(e,"touchstart");else if("mouse"===e.pointerType||"pen"===e.pointerType){const t=2===e.button;this.dispatchEvent(e,t?"rightdown":"mousedown")}this.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,i,n;if(!(t instanceof Qa))return void kt("EventBoundary cannot map a non-pointer event as a pointer event");this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const r=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const s="mouse"===r.pointerType||"pen"===r.pointerType,o=this.trackingData(t.pointerId),a=this.findMountedTarget(o.overTargets);if((null==(e=o.overTargets)?void 0:e.length)>0&&a!==r.target){const e="mousemove"===t.type?"mouseout":"pointerout",i=this.createPointerEvent(t,e,a);if(this.dispatchEvent(i,"pointerout"),s&&this.dispatchEvent(i,"mouseout"),!r.composedPath().includes(a)){const e=this.createPointerEvent(t,"pointerleave",a);for(e.eventPhase=e.AT_TARGET;e.target&&!r.composedPath().includes(e.target);)e.currentTarget=e.target,this.notifyTarget(e),s&&this.notifyTarget(e,"mouseleave"),e.target=e.target.parent;this.freeEvent(e)}this.freeEvent(i)}if(a!==r.target){const e="mousemove"===t.type?"mouseover":"pointerover",i=this.clonePointerEvent(r,e);this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover");let n=null==a?void 0:a.parent;for(;n&&n!==this.rootTarget.parent&&n!==r.target;)n=n.parent;if(!n||n===this.rootTarget.parent){const t=this.clonePointerEvent(r,"pointerenter");for(t.eventPhase=t.AT_TARGET;t.target&&t.target!==a&&t.target!==this.rootTarget.parent;)t.currentTarget=t.target,this.notifyTarget(t),s&&this.notifyTarget(t,"mouseenter"),t.target=t.target.parent;this.freeEvent(t)}this.freeEvent(i)}const l=[],h=null==(i=this.enableGlobalMoveEvents)||i;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(r,"pointermove"),h&&l.push("globalpointermove"),"touch"===r.pointerType&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(r,"touchmove"),h&&l.push("globaltouchmove")),s&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(r,"mousemove"),h&&l.push("globalmousemove"),this.cursor=null==(n=r.target)?void 0:n.cursor),l.length>0&&this.all(r,l),this._allInteractiveElements.length=0,this._hitElements.length=0,o.overTargets=r.composedPath(),this.freeEvent(r)}mapPointerOver(t){var e;if(!(t instanceof Qa))return void kt("EventBoundary cannot map a non-pointer event as a pointer event");const i=this.trackingData(t.pointerId),n=this.createPointerEvent(t),r="mouse"===n.pointerType||"pen"===n.pointerType;this.dispatchEvent(n,"pointerover"),r&&this.dispatchEvent(n,"mouseover"),"mouse"===n.pointerType&&(this.cursor=null==(e=n.target)?void 0:e.cursor);const s=this.clonePointerEvent(n,"pointerenter");for(s.eventPhase=s.AT_TARGET;s.target&&s.target!==this.rootTarget.parent;)s.currentTarget=s.target,this.notifyTarget(s),r&&this.notifyTarget(s,"mouseenter"),s.target=s.target.parent;i.overTargets=n.composedPath(),this.freeEvent(n),this.freeEvent(s)}mapPointerOut(t){if(!(t instanceof Qa))return void kt("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId);if(e.overTargets){const i="mouse"===t.pointerType||"pen"===t.pointerType,n=this.findMountedTarget(e.overTargets),r=this.createPointerEvent(t,"pointerout",n);this.dispatchEvent(r),i&&this.dispatchEvent(r,"mouseout");const s=this.createPointerEvent(t,"pointerleave",n);for(s.eventPhase=s.AT_TARGET;s.target&&s.target!==this.rootTarget.parent;)s.currentTarget=s.target,this.notifyTarget(s),i&&this.notifyTarget(s,"mouseleave"),s.target=s.target.parent;e.overTargets=null,this.freeEvent(r),this.freeEvent(s)}this.cursor=null}mapPointerUp(t){if(!(t instanceof Qa))return void kt("EventBoundary cannot map a non-pointer event as a pointer event");const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),"touch"===i.pointerType)this.dispatchEvent(i,"touchend");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.dispatchEvent(i,t?"rightup":"mouseup")}const n=this.trackingData(t.pointerId),r=this.findMountedTarget(n.pressTargetsByButton[t.button]);let s=r;if(r&&!i.composedPath().includes(r)){let e=r;for(;e&&!i.composedPath().includes(e);){if(i.currentTarget=e,this.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType)this.notifyTarget(i,"touchendoutside");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.notifyTarget(i,t?"rightupoutside":"mouseupoutside")}e=e.parent}delete n.pressTargetsByButton[t.button],s=e}if(s){const r=this.clonePointerEvent(i,"click");r.target=s,r.path=null,n.clicksByButton[t.button]||(n.clicksByButton[t.button]={clickCount:0,target:r.target,timeStamp:e});const o=n.clicksByButton[t.button];if(o.target===r.target&&e-o.timeStamp<200?++o.clickCount:o.clickCount=1,o.target=r.target,o.timeStamp=e,r.detail=o.clickCount,"mouse"===r.pointerType){const t=2===r.button;this.dispatchEvent(r,t?"rightclick":"click")}else"touch"===r.pointerType&&this.dispatchEvent(r,"tap");this.dispatchEvent(r,"pointertap"),this.freeEvent(r)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof Qa))return void kt("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),n=this.createPointerEvent(t);if(i){let r=i;for(;r;)n.currentTarget=r,this.notifyTarget(n,"pointerupoutside"),"touch"===n.pointerType?this.notifyTarget(n,"touchendoutside"):"mouse"!==n.pointerType&&"pen"!==n.pointerType||this.notifyTarget(n,2===n.button?"rightupoutside":"mouseupoutside"),r=r.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(n)}mapWheel(t){if(!(t instanceof Ja))return void kt("EventBoundary cannot map a non-wheel event as a wheel event");const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){var n;const r=this.allocateEvent(Qa);return this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=null!=(n=null!=i?i:this.hitTest(r.global.x,r.global.y))?n:this._hitElements[0],"string"==typeof e&&(r.type=e),r}createWheelEvent(t){const e=this.allocateEvent(Ja);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(Qa);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=null!=e?e:i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Qa&&e instanceof Qa&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof $a&&e instanceof $a&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.defaultPrevented=!1,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}_notifyListeners(t,e){const i=t.currentTarget._events[e];if(i)if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let n=0,r=i.length;n<r&&!t.propagationImmediatelyStopped;n++)i[n].once&&t.currentTarget.removeListener(e,i[n].fn,void 0,!0),i[n].fn.call(i[n].context,t)}}const nl={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},rl=class t{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new il(null),Ka.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Qa(null),this._rootWheelEvent=new Ja(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(__spreadValues({},t.defaultEventFeatures),{set:(t,e,i)=>("globalMove"===e&&(this.rootBoundary.enableGlobalMoveEvents=i),t[e]=i,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){var i,n;const{canvas:r,resolution:s}=this.renderer;this.setTargetElement(r),this.resolution=s,t._defaultEventMode=null!=(i=e.eventMode)?i:"passive",Object.assign(this.features,null!=(n=e.eventFeatures)?n:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t||(t="default");let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i)}else e&&"string"==typeof t&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);if(this.autoPreventDefault&&e[0].isNormalized){(t.cancelable||!("cancelable"in t))&&t.preventDefault()}for(let i=0,n=e.length;i<n;i++){const t=e[i],n=this._bootstrapEvent(this._rootPointerEvent,t);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Ka.pointerMoved();const e=this._normalizeToPointerData(t);for(let i=0,n=e.length;i<n;i++){const t=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",n=this._normalizeToPointerData(t);for(let r=0,s=n.length;r<s;r++){const t=this._bootstrapEvent(this._rootPointerEvent,n[r]);t.type+=i,this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);for(let i=0,n=e.length;i<n;i++){const t=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this._removeEvents(),this.domElement=t,Ka.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;Ka.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;Ka.removeTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(t,e,i){const n=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},r=1/this.resolution;t.x=(e-n.left)*(this.domElement.width/n.width)*r,t.y=(i-n.top)*(this.domElement.height/n.height)*r}_normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,n=t.changedTouches.length;i<n;i++){const n=t.changedTouches[i];void 0===n.button&&(n.button=0),void 0===n.buttons&&(n.buttons=1),void 0===n.isPrimary&&(n.isPrimary=1===t.touches.length&&"touchstart"===t.type),void 0===n.width&&(n.width=n.radiusX||1),void 0===n.height&&(n.height=n.radiusY||1),void 0===n.tiltX&&(n.tiltX=0),void 0===n.tiltY&&(n.tiltY=0),void 0===n.pointerType&&(n.pointerType="touch"),void 0===n.pointerId&&(n.pointerId=n.identifier||0),void 0===n.pressure&&(n.pressure=n.force||.5),void 0===n.twist&&(n.twist=0),void 0===n.tangentialPressure&&(n.tangentialPressure=0),void 0===n.layerX&&(n.layerX=n.offsetX=n.clientX),void 0===n.layerY&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(globalThis.MouseEvent&&(!(t instanceof MouseEvent)||this.supportsPointerEvents&&t instanceof globalThis.PointerEvent))e.push(t);else{const i=t;void 0===i.isPrimary&&(i.isPrimary=!0),void 0===i.width&&(i.width=1),void 0===i.height&&(i.height=1),void 0===i.tiltX&&(i.tiltX=0),void 0===i.tiltY&&(i.tiltY=0),void 0===i.pointerType&&(i.pointerType="mouse"),void 0===i.pointerId&&(i.pointerId=1),void 0===i.pressure&&(i.pressure=.5),void 0===i.twist&&(i.twist=0),void 0===i.tangentialPressure&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}return e}normalizeWheelEvent(t){const e=this._rootWheelEvent;return this._transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}_bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this._transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=nl[t.type]||t.type),t}_transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};rl.extension={name:"events",type:[o.WebGLSystem,o.CanvasSystem,o.WebGPUSystem],priority:-1},rl.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let sl=rl;const ol={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return"dynamic"===this.eventMode||"static"===this.eventMode},set interactive(t){this.eventMode=t?"static":"passive"},_internalEventMode:void 0,get eventMode(){var t;return null!=(t=this._internalEventMode)?t:sl.defaultEventMode},set eventMode(t){this._internalEventMode=t},isInteractive(){return"static"===this.eventMode||"dynamic"===this.eventMode},interactiveChildren:!0,hitArea:null,addEventListener(t,e,i){const n="boolean"==typeof i&&i||"object"==typeof i&&i.capture,r="object"==typeof i?i.signal:void 0,s="object"==typeof i&&!0===i.once,o="function"==typeof e?void 0:e;t=n?`${t}capture`:t;const a="function"==typeof e?e:e.handleEvent,l=this;r&&r.addEventListener("abort",()=>{l.off(t,a,o)}),s?l.once(t,a,o):l.on(t,a,o)},removeEventListener(t,e,i){const n="function"==typeof e?void 0:e;t="boolean"==typeof i&&i||"object"==typeof i&&i.capture?`${t}capture`:t,e="function"==typeof e?e:e.handleEvent,this.off(t,e,n)},dispatchEvent(t){if(!(t instanceof oi))throw new Error("Container cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=null,t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}};class al{constructor(t){this._renderer=t}push(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){"pushFilter"===t.action?this._renderer.filter.push(t):"popFilter"===t.action&&this._renderer.filter.pop()}destroy(){this._renderer=null}}al.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"filter"};const ll=new jr({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class hl{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new it,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0}}}class cl{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new $i({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new Qi({}),this.renderer=t}get activeBackTexture(){var t;return null==(t=this._activeFilterData)?void 0:t.backTexture}push(t){const e=this.renderer,i=t.filterEffect.filters,n=this._pushFilterData();n.skip=!1,n.filters=i,n.container=t.container,n.outputRenderSurface=e.renderTarget.renderSurface;const r=e.renderTarget.renderTarget.colorTexture.source,s=r.resolution,o=r.antialias;if(0===i.length)return void(n.skip=!0);const a=n.bounds;if(this._calculateFilterArea(t,a),this._calculateFilterBounds(n,e.renderTarget.rootViewPort,o,s,1),n.skip)return;const l=this._getPreviousFilterData(),h=this._findFilterResolution(s);let c=0,u=0;l&&(c=l.bounds.minX,u=l.bounds.minY),this._calculateGlobalFrame(n,c,u,h,r.width,r.height),this._setupFilterTextures(n,a,e,l)}generateFilteredTexture({texture:t,filters:e}){const i=this._pushFilterData();this._activeFilterData=i,i.skip=!1,i.filters=e;const n=t.source,r=n.resolution,s=n.antialias;if(0===e.length)return i.skip=!0,t;const o=i.bounds;if(o.addRect(t.frame),this._calculateFilterBounds(i,o.rectangle,s,r,0),i.skip)return t;const a=r;this._calculateGlobalFrame(i,0,0,a,n.width,n.height),i.outputRenderSurface=pe.getOptimalTexture(o.width,o.height,i.resolution,i.antialias),i.backTexture=J.EMPTY,i.inputTexture=t;this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(i,!0);const l=i.outputRenderSurface;return l.source.alphaMode="premultiplied-alpha",l}pop(){const t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&pe.returnTexture(e.backTexture),pe.returnTexture(e.inputTexture))}getBackTexture(t,e,i){const n=t.colorTexture.source._resolution,r=pe.getOptimalTexture(e.width,e.height,n,!1);let s=e.minX,o=e.minY;i&&(s-=i.minX,o-=i.minY),s=Math.floor(s*n),o=Math.floor(o*n);const a=Math.ceil(e.width*n),l=Math.ceil(e.height*n);return this.renderer.renderTarget.copyToTexture(t,r,{x:s,y:o},{width:a,height:l},{x:0,y:0}),r}applyFilter(t,e,i,n){const r=this.renderer,s=this._activeFilterData,o=s.outputRenderSurface===i,a=r.renderTarget.rootRenderTarget.colorTexture.source._resolution,l=this._findFilterResolution(a);let h=0,c=0;if(o){const t=this._findPreviousFilterOffset();h=t.x,c=t.y}this._updateFilterUniforms(e,i,s,h,c,l,o,n),this._setupBindGroupsAndRender(t,e,r)}calculateSpriteMatrix(t,e){const i=this._activeFilterData,n=t.set(i.inputTexture._source.width,0,0,i.inputTexture._source.height,i.bounds.minX,i.bounds.minY),r=e.worldTransform.copyTo(S.shared),s=e.renderGroup||e.parentRenderGroup;return s&&s.cacheToLocalTransform&&r.prepend(s.cacheToLocalTransform),r.invert(),n.prepend(r),n.scale(1/e.texture.orig.width,1/e.texture.orig.height),n.translate(e.anchor.x,e.anchor.y),n}destroy(){}_setupBindGroupsAndRender(t,e,i){if(i.renderPipes.uniformBatch){const t=i.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(t,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,i.encoder.draw({geometry:ll,shader:t,state:t._state,topology:"triangle-list"}),i.type===Ji.WEBGL&&i.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,i,n){if(t.backTexture=J.EMPTY,t.blendRequired){i.renderTarget.finishRenderPass();const r=i.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(r,e,null==n?void 0:n.bounds)}t.inputTexture=pe.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),i.renderTarget.bind(t.inputTexture,!0),i.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,i,n,r,s){const o=t.globalFrame;o.x=e*n,o.y=i*n,o.width=r*n,o.height=s*n}_updateFilterUniforms(t,e,i,n,r,s,o,a){const l=this._filterGlobalUniforms.uniforms,h=l.uOutputFrame,c=l.uInputSize,u=l.uInputPixel,d=l.uInputClamp,p=l.uGlobalFrame,f=l.uOutputTexture;o?(h[0]=i.bounds.minX-n,h[1]=i.bounds.minY-r):(h[0]=0,h[1]=0),h[2]=t.frame.width,h[3]=t.frame.height,c[0]=t.source.width,c[1]=t.source.height,c[2]=1/c[0],c[3]=1/c[1],u[0]=t.source.pixelWidth,u[1]=t.source.pixelHeight,u[2]=1/u[0],u[3]=1/u[1],d[0]=.5*u[2],d[1]=.5*u[3],d[2]=t.frame.width*c[2]-.5*u[2],d[3]=t.frame.height*c[3]-.5*u[3];const g=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=n*s,p[1]=r*s,p[2]=g.source.width*s,p[3]=g.source.height*s,e instanceof J&&(e.source.resource=null);const m=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!a),e instanceof J?(f[0]=e.frame.width,f[1]=e.frame.height):(f[0]=m.width,f[1]=m.height),f[2]=m.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,i=this._filterStackIndex;for(;i>0;){i--;const n=this._filterStack[i];if(!n.skip){t=n.bounds.minX,e=n.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?function(t,e){e.clear();const i=e.matrix;for(let n=0;n<t.length;n++){const i=t[n];i.globalDisplayStatus<7||(e.matrix=i.worldTransform,e.addBounds(i.bounds))}e.matrix=i}(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){const i=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;i&&e.applyMatrix(i)}}_applyFiltersToTexture(t,e){const i=t.inputTexture,n=t.bounds,r=t.filters;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),1===r.length)r[0].apply(this,i,t.outputRenderSurface,e);else{let i=t.inputTexture;const s=pe.getOptimalTexture(n.width,n.height,i.source._resolution,!1);let o=s,a=0;for(a=0;a<r.length-1;++a){r[a].apply(this,i,o,!0);const t=i;i=o,o=t}r[a].apply(this,i,t.outputRenderSurface,e),pe.returnTexture(s)}}_calculateFilterBounds(t,e,i,n,r){var s,o;const a=this.renderer,l=t.bounds,h=t.filters;let c=1/0,u=0,d=!0,p=!1,f=!1,g=!0;for(let m=0;m<h.length;m++){const t=h[m];c=Math.min(c,"inherit"===t.resolution?n:t.resolution),u+=t.padding,"off"===t.antialias?d=!1:"inherit"===t.antialias&&d&&(d=i),t.clipToViewport||(g=!1);if(!!!(t.compatibleRenderers&a.type)){f=!1;break}if(t.blendRequired&&null!=(o=null==(s=a.backBuffer)?void 0:s.useBackBuffer)&&!o){kt("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),f=!1;break}f=t.enabled||f,p||(p=t.blendRequired)}f?(g&&l.fitBounds(0,e.width/n,0,e.height/n),l.scale(c).ceil().scale(1/c).pad((0|u)*r),l.isPositive?(t.antialias=d,t.resolution=c,t.blendRequired=p):t.skip=!0):t.skip=!0}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>1&&(e--,t=this._filterStack[e],t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new hl),this._filterStackIndex++,t}}cl.extension={type:[o.WebGLSystem,o.WebGPUSystem],name:"filter"};var ul="struct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\nstruct MaskUniforms {\n uFilterMatrix:mat3x3<f32>,\n uMaskClamp:vec4<f32>,\n uAlpha:f32,\n uInverse:f32,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n@group(0) @binding(1) var uTexture: texture_2d<f32>;\n@group(0) @binding(2) var uSampler : sampler;\n\n@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;\n@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>,\n @location(1) filterUv : vec2<f32>,\n};\n\nfn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>\n{\n var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;\n\n position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nfn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);\n}\n\nfn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);\n}\n\nfn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>\n{\n return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;\n}\n\nfn getSize() -> vec2<f32>\n{\n return gfu.uGlobalFrame.zw;\n}\n\n@vertex\nfn mainVertex(\n @location(0) aPosition : vec2<f32>,\n) -> VSOutput {\n return VSOutput(\n filterVertexPosition(aPosition),\n filterTextureCoord(aPosition),\n getFilterCoord(aPosition)\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @location(1) filterUv: vec2<f32>,\n @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n\n var maskClamp = filterUniforms.uMaskClamp;\n var uAlpha = filterUniforms.uAlpha;\n\n var clip = step(3.5,\n step(maskClamp.x, filterUv.x) +\n step(maskClamp.y, filterUv.y) +\n step(filterUv.x, maskClamp.z) +\n step(filterUv.y, maskClamp.w));\n\n var mask = textureSample(uMaskTexture, uSampler, filterUv);\n var source = textureSample(uTexture, uSampler, uv);\n var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);\n\n var a: f32 = alphaMul * mask.r * uAlpha * clip;\n\n if (filterUniforms.uInverse == 1.0) {\n a = 1.0 - a;\n }\n\n return source * a;\n}\n";class dl extends on{constructor(t){const e=t,{sprite:i}=e,n=__objRest(e,["sprite"]),r=new Q(i.texture),s=new $i({uFilterMatrix:{value:new S,type:"mat3x3<f32>"},uMaskClamp:{value:r.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"}}),o=Yi.from({vertex:{source:ul,entryPoint:"mainVertex"},fragment:{source:ul,entryPoint:"mainFragment"}}),a=Li.from({vertex:"in vec2 aPosition;\n\nout vec2 vTextureCoord;\nout vec2 vMaskCoord;\n\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\nuniform mat3 uFilterMatrix;\n\nvec4 filterVertexPosition( vec2 aPosition )\n{\n vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n \n position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( vec2 aPosition )\n{\n return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvec2 getFilterCoord( vec2 aPosition )\n{\n return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;\n} \n\nvoid main(void)\n{\n gl_Position = filterVertexPosition(aPosition);\n vTextureCoord = filterTextureCoord(aPosition);\n vMaskCoord = getFilterCoord(aPosition);\n}\n",fragment:"in vec2 vMaskCoord;\nin vec2 vTextureCoord;\n\nuniform sampler2D uTexture;\nuniform sampler2D uMaskTexture;\n\nuniform float uAlpha;\nuniform vec4 uMaskClamp;\nuniform float uInverse;\n\nout vec4 finalColor;\n\nvoid main(void)\n{\n float clip = step(3.5,\n step(uMaskClamp.x, vMaskCoord.x) +\n step(uMaskClamp.y, vMaskCoord.y) +\n step(vMaskCoord.x, uMaskClamp.z) +\n step(vMaskCoord.y, uMaskClamp.w));\n\n // TODO look into why this is needed\n float npmAlpha = uAlpha;\n vec4 original = texture(uTexture, vTextureCoord);\n vec4 masky = texture(uMaskTexture, vMaskCoord);\n float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);\n\n float a = alphaMul * masky.r * npmAlpha * clip;\n\n if (uInverse == 1.0) {\n a = 1.0 - a;\n }\n\n finalColor = original * a;\n}\n",name:"mask-filter"});super(__spreadProps(__spreadValues({},n),{gpuProgram:o,glProgram:a,clipToViewport:!1,resources:{filterUniforms:s,uMaskTexture:i.texture.source}})),this.sprite=i,this._textureMatrix=r}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return 1===this.resources.filterUniforms.uniforms.uInverse}apply(t,e,i,n){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,i,n)}}function pl(t,e,i,n,r,s,o,a){const l=o-i,h=a-n,c=r-i,u=s-n,d=t-i,p=e-n,f=l*l+h*h,g=l*c+h*u,m=l*d+h*p,_=c*c+u*u,y=c*d+u*p,x=1/(f*_-g*g),b=(_*m-g*y)*x,v=(f*y-g*m)*x;return b>=0&&v>=0&&b+v<1}class fl extends be{constructor(t){t instanceof Do&&(t={context:t});const e=t||{},{context:i,roundPixels:n}=e,r=__objRest(e,["context","roundPixels"]);super(__spreadValues({label:"Graphics"},r)),this.renderPipeId="graphics",this._context=i||(this._ownedContext=new Do),this._context.on("update",this.onViewUpdate,this),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=null!=n&&n}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):!0!==t&&!0!==(null==t?void 0:t.context)||this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){if(t)return new fl(this._context.clone());this._ownedContext=null;return new fl(this._context)}lineStyle(t,e,i){z(L,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const n={};return t&&(n.width=t),e&&(n.color=e),i&&(n.alpha=i),this.context.strokeStyle=n,this}beginFill(t,e){z(L,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return void 0!==t&&(i.color=t),void 0!==e&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){z(L,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return t.width===Do.defaultStrokeStyle.width&&t.color===Do.defaultStrokeStyle.color&&t.alpha===Do.defaultStrokeStyle.alpha||this.context.stroke(),this}drawCircle(...t){return z(L,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return z(L,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return z(L,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return z(L,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return z(L,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return z(L,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const gl=class t extends jr{constructor(...e){var i;let n=null!=(i=e[0])?i:{};n instanceof Float32Array&&(z(L,"use new MeshGeometry({ positions, uvs, indices }) instead"),n={positions:n,uvs:e[1],indices:e[2]}),n=__spreadValues(__spreadValues({},t.defaultOptions),n);const r=n.positions||new Float32Array([0,0,1,0,1,1,0,1]);let s=n.uvs;s||(s=n.positions?new Float32Array(r.length):new Float32Array([0,0,1,0,1,1,0,1]));const o=n.indices||new Uint32Array([0,1,2,0,2,3]),a=n.shrinkBuffersToFit;super({attributes:{aPosition:{buffer:new Hr({data:r,label:"attribute-mesh-positions",shrinkToFit:a,usage:Vr.VERTEX|Vr.COPY_DST}),format:"float32x2",stride:8,offset:0},aUV:{buffer:new Hr({data:s,label:"attribute-mesh-uvs",shrinkToFit:a,usage:Vr.VERTEX|Vr.COPY_DST}),format:"float32x2",stride:8,offset:0}},indexBuffer:new Hr({data:o,label:"index-mesh-buffer",shrinkToFit:a,usage:Vr.INDEX|Vr.COPY_DST}),topology:n.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};gl.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let ml=gl;class _l extends be{constructor(...t){var e;let i=t[0];i instanceof jr&&(z(L,"Mesh: use new Mesh({ geometry, shader }) instead"),i={geometry:i,shader:t[1]},t[3]&&(z(L,"Mesh: drawMode argument has been removed, use geometry.topology instead"),i.geometry.topology=t[3]));const n=i,{geometry:r,shader:s,texture:o,roundPixels:a,state:l}=n,h=__objRest(n,["geometry","shader","texture","roundPixels","state"]);super(__spreadValues({label:"Mesh"},h)),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=null!=s?s:null,this.texture=null!=(e=null!=o?o:null==s?void 0:s.texture)?e:J.WHITE,this.state=null!=l?l:rn.for2d(),this._geometry=r,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=null!=a&&a}get material(){return z(L,"mesh.material property has been removed, use mesh.shader instead"),this._shader}set shader(t){this._shader!==t&&(this._shader=t,this.onViewUpdate())}get shader(){return this._shader}set geometry(t){var e;this._geometry!==t&&(null==(e=this._geometry)||e.off("update",this.onViewUpdate,this),t.on("update",this.onViewUpdate,this),this._geometry=t,this.onViewUpdate())}get geometry(){return this._geometry}set texture(t){t||(t=J.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this.shader&&(this.shader.texture=t),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get batched(){return!this._shader&&(!(12&this.state.data)&&(this._geometry instanceof ml&&("auto"===this._geometry.batchMode?this._geometry.positions.length/2<=100:"batch"===this._geometry.batchMode)))}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(t){const{x:e,y:i}=t;if(!this.bounds.containsPoint(e,i))return!1;const n=this.geometry.getBuffer("aPosition").data,r="triangle-strip"===this.geometry.topology?3:1;if(this.geometry.getIndex()){const t=this.geometry.getIndex().data,s=t.length;for(let o=0;o+2<s;o+=r){const r=2*t[o],s=2*t[o+1],a=2*t[o+2];if(pl(e,i,n[r],n[r+1],n[s],n[s+1],n[a],n[a+1]))return!0}}else{const t=n.length/2;for(let s=0;s+2<t;s+=r){const t=2*s,r=2*(s+1),o=2*(s+2);if(pl(e,i,n[t],n[t+1],n[r],n[r+1],n[o],n[o+1]))return!0}}return!1}destroy(t){var e;super.destroy(t);if("boolean"==typeof t?t:null==t?void 0:t.texture){const e="boolean"==typeof t?t:null==t?void 0:t.textureSource;this._texture.destroy(e)}null==(e=this._geometry)||e.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null,this._gpuData=null}}class yl extends ve{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const i=e,{animationSpeed:n=1,autoPlay:r=!1,autoUpdate:s=!0,loop:o=!0,onComplete:a=null,onFrameChange:l=null,onLoop:h=null,textures:c,updateAnchor:u=!1}=i,d=__objRest(i,["animationSpeed","autoPlay","autoUpdate","loop","onComplete","onFrameChange","onLoop","textures","updateAnchor"]),[p]=c;super(__spreadProps(__spreadValues({},d),{texture:p instanceof J?p:p.texture})),this._textures=null,this._durations=null,this._autoUpdate=s,this._isConnectedToTicker=!1,this.animationSpeed=n,this.loop=o,this.updateAnchor=u,this.onComplete=a,this.onFrameChange=l,this.onLoop=h,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=c,r&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(Ue.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Ue.shared.add(this.update,this,ke.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,i=this.animationSpeed*e,n=this.currentFrame;if(null!==this._durations){let t=this._currentTime%1*this._durations[this.currentFrame];for(t+=i/60*1e3;t<0;)this._currentTime--,t+=this._durations[this.currentFrame];const n=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);t>=this._durations[this.currentFrame];)t-=this._durations[this.currentFrame]*n,this._currentTime+=n;this._currentTime+=t/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()):n!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<n||this.animationSpeed<0&&this.currentFrame>n)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.texture.defaultAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t=!1){if("boolean"==typeof t?t:null==t?void 0:t.texture){const e="boolean"==typeof t?t:null==t?void 0:t.textureSource;this._textures.forEach(t=>{this.texture!==t&&t.destroy(e)})}this._textures=[],this._durations=null,this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;i<t.length;++i)e.push(J.from(t[i]));return new yl(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(J.from(t[i]));return new yl(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof J)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(let e=0;e<t.length;e++)this._textures.push(t[e].texture),this._durations.push(t[e].time)}this._previousFrame=null,this.gotoAndStop(0),this._updateTexture()}get currentFrame(){let t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}set currentFrame(t){if(t<0||t>this.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(Ue.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Ue.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class xl{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=null!=t?t:new S,this.observer=e,this.position=new d(this,0,0),this.scale=new d(this,1,1),this.pivot=new d(this,0,0),this.skew=new d(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){const t=this._matrix;return this.dirty?(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this.dirty=!1,t):t}_onUpdate(t){var e;this.dirty=!0,t===this.skew&&this.updateSkew(),null==(e=this.observer)||e._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(t){t.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this.skew))}}const bl=class t extends be{constructor(...e){let i=e[0]||{};i instanceof J&&(i={texture:i}),e.length>1&&(z(L,"use new TilingSprite({ texture, width:100, height:100 }) instead"),i.width=e[1],i.height=e[2]),i=__spreadValues(__spreadValues({},t.defaultOptions),i);const n=null!=i?i:{},{texture:r,anchor:s,tilePosition:o,tileScale:a,tileRotation:l,width:h,height:c,applyAnchorToTexture:u,roundPixels:p}=n,f=__objRest(n,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(__spreadValues({label:"TilingSprite"},f)),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new d({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=u,this.texture=r,this._width=null!=h?h:r.width,this._height=null!=c?c:r.height,this._tileTransform=new xl({observer:{_onUpdate:()=>this.onViewUpdate()}}),s&&(this.anchor=s),this.tilePosition=o,this.tileScale=a,this.tileRotation=l,this.roundPixels=null!=p&&p}static from(e,i={}){return new t(__spreadValues("string"==typeof e?{texture:Ve.get(e)}:{texture:e},i))}get uvRespectAnchor(){return kt("uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(t){kt("uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture=t}get clampMargin(){return this._texture.textureMatrix.clampMargin}set clampMargin(t){this._texture.textureMatrix.clampMargin=t}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}get tilePosition(){return this._tileTransform.position}set tilePosition(t){this._tileTransform.position.copyFrom(t)}get tileScale(){return this._tileTransform.scale}set tileScale(t){"number"==typeof t?this._tileTransform.scale.set(t):this._tileTransform.scale.copyFrom(t)}set tileRotation(t){this._tileTransform.rotation=t}get tileRotation(){return this._tileTransform.rotation}get tileTransform(){return this._tileTransform}set texture(t){t||(t=J.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}set width(t){this._width=t,this.onViewUpdate()}get width(){return this._width}set height(t){this._height=t,this.onViewUpdate()}get height(){return this._height}setSize(t,e){var i;"object"==typeof t&&(e=null!=(i=t.height)?i:t.width,t=t.width),this._width=t,this._height=null!=e?e:t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}updateBounds(){const t=this._bounds,e=this._anchor,i=this._width,n=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}containsPoint(t){const e=this._width,i=this._height,n=-e*this._anchor._x;let r=0;return t.x>=n&&t.x<=n+e&&(r=-i*this._anchor._y,t.y>=r&&t.y<=r+i)}destroy(t=!1){super.destroy(t),this._anchor=null,this._tileTransform=null,this._bounds=null;if("boolean"==typeof t?t:null==t?void 0:t.texture){const e="boolean"==typeof t?t:null==t?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}};bl.defaultOptions={texture:J.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let vl=bl;class wl extends be{constructor(t,e){const i=t,{text:n,resolution:r,style:s,anchor:o,width:a,height:l,roundPixels:h}=i,c=__objRest(i,["text","resolution","style","anchor","width","height","roundPixels"]);super(__spreadValues({},c)),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=null!=n?n:"",this.style=s,this.resolution=null!=r?r:null,this.allowChildren=!1,this._anchor=new d({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),this.roundPixels=null!=h&&h,void 0!==a&&(this.width=a),void 0!==l&&(this.height=l)}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=null===t,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t||(t={}),null==(e=this._style)||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){var i;"object"==typeof t?(e=null!=(i=t.height)?i:t.width,t=t.width):null!=e||(e=t),void 0!==t&&this._setWidth(t,this.bounds.width),void 0!==e&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,n=-e*this.anchor.x;let r=0;return t.x>=n&&t.x<=n+e&&(r=-i*this.anchor.y,t.y>=r&&t.y<=r+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,("boolean"==typeof t?t:null==t?void 0:t.style)&&this._style.destroy(t),this._style=null,this._text=null}}let Sl=null,Al=null;function Tl(t,e,i){for(let n=0,r=4*i*e;n<e;++n,r+=4)if(0!==t[r+3])return!1;return!0}function Cl(t,e,i,n,r){const s=4*e;for(let o=n,a=n*s+4*i;o<=r;++o,a+=s)if(0!==t[a+3])return!1;return!0}function Pl(...t){var e,i,n;let r=t[0];r.canvas||(r={canvas:t[0],resolution:t[1]});const{canvas:s}=r,o=Math.min(null!=(e=r.resolution)?e:1,1),a=null!=(i=r.width)?i:s.width,l=null!=(n=r.height)?n:s.height;let h=r.output;if(function(t,e){Sl||(Sl=Re.get().createCanvas(256,128),Al=Sl.getContext("2d",{willReadFrequently:!0}),Al.globalCompositeOperation="copy",Al.globalAlpha=1),(Sl.width<t||Sl.height<e)&&(Sl.width=V(t),Sl.height=V(e))}(a,l),!Al)throw new TypeError("Failed to get canvas 2D context");Al.drawImage(s,0,0,a,l,0,0,a*o,l*o);const c=Al.getImageData(0,0,a,l).data;let u=0,d=0,p=a-1,f=l-1;for(;d<l&&Tl(c,a,d);)++d;if(d===l)return D.EMPTY;for(;Tl(c,a,f);)--f;for(;Cl(c,a,u,d,f);)++u;for(;Cl(c,a,p,d,f);)--p;return++p,++f,Al.globalCompositeOperation="source-over",Al.strokeRect(u,d,p-u,f-d),Al.globalCompositeOperation="copy",null!=h||(h=new D),h.set(u/o,d/o,(p-u)/o,(f-d)/o),h}const Ml=new D;const El=new class{getCanvasAndContext(t){const{text:e,style:i,resolution:n=1}=t,r=i._getFinalPadding(),s=sr.measureText(e||" ",i),o=Math.ceil(Math.ceil(Math.max(1,s.width)+2*r)*n),a=Math.ceil(Math.ceil(Math.max(1,s.height)+2*r)*n),l=No.getOptimalCanvasAndContext(o,a);this._renderTextToCanvas(e,i,r,n,l);return{canvasAndContext:l,frame:i.trim?Pl({canvas:l.canvas,width:o,height:a,resolution:1,output:Ml}):Ml.set(0,0,o,a)}}returnCanvasAndContext(t){No.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,i,n,r){var s,o,a,l,h;const{canvas:c,context:u}=r,d=ir(e),p=sr.measureText(t||" ",e),f=p.lines,g=p.lineHeight,m=p.lineWidths,_=p.maxLineWidth,y=p.fontProperties,x=c.height;if(u.resetTransform(),u.scale(n,n),u.textBaseline=e.textBaseline,null==(s=e._stroke)?void 0:s.width){const t=e._stroke;u.lineWidth=t.width,u.miterLimit=t.miterLimit,u.lineJoin=t.join,u.lineCap=t.cap}let b,v;u.font=d;const w=e.dropShadow?2:1;for(let S=0;S<w;++S){const t=e.dropShadow&&0===S,s=t?Math.ceil(Math.max(1,x)+2*i):0,c=s*n;if(t){u.fillStyle="black",u.strokeStyle="black";const t=e.dropShadow,i=t.color,r=t.alpha;u.shadowColor=Ft.shared.setValue(i).setAlpha(r).toRgbaString();const s=t.blur*n,o=t.distance*n;u.shadowBlur=s,u.shadowOffsetX=Math.cos(t.angle)*o,u.shadowOffsetY=Math.sin(t.angle)*o+c}else{if(u.fillStyle=e._fill?Ho(e._fill,u,p,2*i):null,null==(o=e._stroke)?void 0:o.width){const t=.5*e._stroke.width+2*i;u.strokeStyle=Ho(e._stroke,u,p,t)}u.shadowColor="black"}let d=(g-y.fontSize)/2;g-y.fontSize<0&&(d=0);const w=null!=(l=null==(a=e._stroke)?void 0:a.width)?l:0;for(let n=0;n<f.length;n++)b=w/2,v=w/2+n*g+y.ascent+d,"right"===e.align?b+=_-m[n]:"center"===e.align&&(b+=(_-m[n])/2),(null==(h=e._stroke)?void 0:h.width)&&this._drawLetterSpacing(f[n],e,r,b+i,v+i-s,!0),void 0!==e._fill&&this._drawLetterSpacing(f[n],e,r,b+i,v+i-s)}}_drawLetterSpacing(t,e,i,n,r,s=!1){const{context:o}=i,a=e.letterSpacing;let l=!1;if(sr.experimentalLetterSpacingSupported&&(sr.experimentalLetterSpacing?(o.letterSpacing=`${a}px`,o.textLetterSpacing=`${a}px`,l=!0):(o.letterSpacing="0px",o.textLetterSpacing="0px")),0===a||l)return void(s?o.strokeText(t,n,r):o.fillText(t,n,r));let h=n;const c=sr.graphemeSegmenter(t);let u=o.measureText(t).width,d=0;for(let p=0;p<c.length;++p){const t=c[p];s?o.strokeText(t,h,r):o.fillText(t,h,r);let e="";for(let i=p+1;i<c.length;++i)e+=c[i];d=o.measureText(e).width,h+=u-d+a,u=d}}};class Rl extends wl{constructor(...t){const e=function(t,e){var i;let n=null!=(i=t[0])?i:{};return("string"==typeof n||t[1])&&(z(L,`use new ${e}({ text: "hi!", style }) instead`),n={text:n,style:t[1]}),n}(t,"Text");super(e,zo),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof X?e.textureStyle:new X(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,n=0;if(this._style.trim){const{frame:t,canvasAndContext:e}=El.getCanvasAndContext({text:this.text,style:this._style,resolution:1});El.returnCanvasAndContext(e),i=t.width,n=t.height}else{const t=sr.measureText(this._text,this._style);i=t.width,n=t.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}}const Fl="http://www.w3.org/2000/svg",Bl="http://www.w3.org/1999/xhtml";class kl{constructor(){this.svgRoot=document.createElementNS(Fl,"svg"),this.foreignObject=document.createElementNS(Fl,"foreignObject"),this.domElement=document.createElementNS(Bl,"div"),this.styleElement=document.createElementNS(Bl,"style");const{foreignObject:t,svgRoot:e,styleElement:i,domElement:n}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(i),t.appendChild(n),this.image=Re.get().createImage()}}let Il;class Dl{constructor(){this._tempState=rn.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,i){const n=t.renderer,r=this._didUploadHash[i.uid];n.shader.bind(i,r),r||(this._didUploadHash[i.uid]=!0),n.shader.updateUniformGroup(n.globalUniforms.uniformGroup),n.geometry.bind(e,i.glProgram)}execute(t,e){const i=t.renderer;this._tempState.blendMode=e.blendMode,i.state.set(this._tempState);const n=e.textures.textures;for(let r=0;r<e.textures.count;r++)i.texture.bind(n[r],r);i.geometry.draw(e.topology,e.size,e.start)}}Dl.extension={type:[o.WebGLPipesAdaptor],name:"batch"};const Ol=rn.for2d();class Ul{start(t,e,i){const n=t.renderer,r=n.encoder,s=i.gpuProgram;this._shader=i,this._geometry=e,r.setGeometry(e,s),Ol.blendMode="normal",n.pipeline.getPipeline(e,s,Ol);const o=n.globalUniforms.bindGroup;r.resetBindGroup(1),r.setBindGroup(0,o,s)}execute(t,e){const i=this._shader.gpuProgram,n=t.renderer,r=n.encoder;if(!e.bindGroup){const t=e.textures;e.bindGroup=Sr(t.textures,t.count,n.limits.maxBatchableTextures)}Ol.blendMode=e.blendMode;const s=n.bindGroup.getBindGroup(e.bindGroup,i,1),o=n.pipeline.getPipeline(this._geometry,i,Ol,e.topology);e.bindGroup._touch(n.textureGC.count),r.setPipeline(o),r.renderPassEncoder.setBindGroup(1,s),r.renderPassEncoder.drawIndexed(e.size,1,e.start)}}Ul.extension={type:[o.WebGPUPipesAdaptor],name:"batch"};const Gl=class t{constructor(t,e){var i,n;this.state=rn.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=t,this._adaptor=e,null==(n=(i=this._adaptor).init)||n.call(i,this)}static getBatcher(t){return new this._availableBatchers[t]}buildStart(t){let e=this._batchersByInstructionSet[t.uid];e||(e=this._batchersByInstructionSet[t.uid]=Object.create(null),e.default||(e.default=new Ms({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=e,this._activeBatch=this._activeBatches.default;for(const i in this._activeBatches)this._activeBatches[i].begin()}addToBatch(e,i){if(this._activeBatch.name!==e.batcherName){this._activeBatch.break(i);let n=this._activeBatches[e.batcherName];n||(n=this._activeBatches[e.batcherName]=t.getBatcher(e.batcherName),n.begin()),this._activeBatch=n}this._activeBatch.add(e)}break(t){this._activeBatch.break(t)}buildEnd(t){this._activeBatch.break(t);const e=this._activeBatches;for(const i in e){const t=e[i],n=t.geometry;n.indexBuffer.setDataWithSize(t.indexBuffer,t.indexSize,!0),n.buffers[0].setDataWithSize(t.attributeBuffer.float32View,t.attributeSize,!1)}}upload(t){const e=this._batchersByInstructionSet[t.uid];for(const i in e){const t=e[i],n=t.geometry;t.dirty&&(t.dirty=!1,n.buffers[0].update(4*t.attributeSize))}}execute(t){if("startBatch"===t.action){const e=t.batcher,i=e.geometry,n=e.shader;this._adaptor.start(this,i,n)}this._adaptor.execute(this,t)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const t in this._activeBatches)this._activeBatches[t].destroy();this._activeBatches=null}};Gl.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"batch"},Gl._availableBatchers=Object.create(null);let Ll=Gl;h.handleByMap(o.Batcher,Ll._availableBatchers),h.add(Ms);const zl={name:"local-uniform-bit",vertex:{header:"\n\n struct LocalUniforms {\n uTransformMatrix:mat3x3<f32>,\n uColor:vec4<f32>,\n uRound:f32,\n }\n\n @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "}},Nl=__spreadProps(__spreadValues({},zl),{vertex:__spreadProps(__spreadValues({},zl.vertex),{header:zl.vertex.header.replace("group(1)","group(2)")})}),Vl={name:"local-uniform-bit",vertex:{header:"\n\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix = uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "}},Hl={name:"texture-bit",vertex:{header:"\n\n struct TextureUniforms {\n uTextureMatrix:mat3x3<f32>,\n }\n\n @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;\n ",main:"\n uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;\n "},fragment:{header:"\n @group(2) @binding(0) var uTexture: texture_2d<f32>;\n @group(2) @binding(1) var uSampler: sampler;\n\n\n ",main:"\n outColor = textureSample(uTexture, uSampler, vUV);\n "}},Wl={name:"texture-bit",vertex:{header:"\n uniform mat3 uTextureMatrix;\n ",main:"\n uv = (uTextureMatrix * vec3(uv, 1.0)).xy;\n "},fragment:{header:"\n uniform sampler2D uTexture;\n\n\n ",main:"\n outColor = texture(uTexture, vUV);\n "}},jl=new it;class Yl extends zt{constructor(){super(),this.filters=[new dl({sprite:new ve(J.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}get inverse(){return this.filters[0].inverse}set inverse(t){this.filters[0].inverse=t}}class Xl{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,i){const n=this._renderer;if(n.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1,maskedContainer:e}),t.inverse=e._maskOptions.inverse,t.renderMaskToTexture){const e=t.mask;e.includeInBuild=!0,e.collectRenderables(i,n,null),e.includeInBuild=!1}n.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){const e=this._renderer,i=t.mask.renderMaskToTexture;if("pushMaskBegin"===t.action){const n=Dt.get(Yl);if(n.inverse=t.inverse,i){t.mask.mask.measurable=!0;const i=Zt(t.mask.mask,!0,jl);t.mask.mask.measurable=!1,i.ceil();const r=e.renderTarget.renderTarget.colorTexture.source,s=pe.getOptimalTexture(i.width,i.height,r._resolution,r.antialias);e.renderTarget.push(s,!0),e.globalUniforms.push({offset:i,worldColor:4294967295});const o=n.sprite;o.texture=s,o.worldTransform.tx=i.minX,o.worldTransform.ty=i.minY,this._activeMaskStage.push({filterEffect:n,maskedContainer:t.maskedContainer,filterTexture:s})}else n.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:n,maskedContainer:t.maskedContainer})}else if("pushMaskEnd"===t.action){const t=this._activeMaskStage[this._activeMaskStage.length-1];i&&(e.type===Ji.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:t.maskedContainer,filterEffect:t.filterEffect,canBundle:!1})}else if("popMaskEnd"===t.action){e.filter.pop();const t=this._activeMaskStage.pop();i&&pe.returnTexture(t.filterTexture),Dt.return(t.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}Xl.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"alphaMask"};class Zl{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&t.mask;const r=this._colorStack[this._colorStackIndex];r!==this._currentColor&&(this._currentColor=r,i.add({renderPipeId:"colorMask",colorMask:r,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;this._colorStackIndex--;const r=n[this._colorStackIndex-1];r!==this._currentColor&&(this._currentColor=r,i.add({renderPipeId:"colorMask",colorMask:r,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._colorStack=null}}Zl.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"colorMask"};class ql{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,i){var n;const r=t,s=this._renderer;s.renderPipes.batch.break(i),s.renderPipes.blendMode.setBlendMode(r.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const o=r.mask;o.includeInBuild=!0,this._maskHash.has(r)||this._maskHash.set(r,{instructionsStart:0,instructionsLength:0});const a=this._maskHash.get(r);a.instructionsStart=i.instructionSize,o.collectRenderables(i,s,null),o.includeInBuild=!1,s.renderPipes.batch.break(i),i.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const l=i.instructionSize-a.instructionsStart-1;a.instructionsLength=l;const h=s.renderTarget.renderTarget.uid;null!=(n=this._maskStackHash)[h]||(n[h]=0)}pop(t,e,i){const n=t,r=this._renderer;r.renderPipes.batch.break(i),r.renderPipes.blendMode.setBlendMode(n.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1});const s=this._maskHash.get(t);for(let o=0;o<s.instructionsLength;o++)i.instructions[i.instructionSize++]=i.instructions[s.instructionsStart++];i.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e,i;const n=this._renderer,r=n.renderTarget.renderTarget.uid;let s=null!=(e=(i=this._maskStackHash)[r])?e:i[r]=0;"pushMaskBegin"===t.action?(n.renderTarget.ensureDepthStencil(),n.stencil.setStencilMode(Pr.RENDERING_MASK_ADD,s),s++,n.colorMask.setMask(0)):"pushMaskEnd"===t.action?(t.inverse?n.stencil.setStencilMode(Pr.INVERSE_MASK_ACTIVE,s):n.stencil.setStencilMode(Pr.MASK_ACTIVE,s),n.colorMask.setMask(15)):"popMaskBegin"===t.action?(n.colorMask.setMask(0),0!==s?n.stencil.setStencilMode(Pr.RENDERING_MASK_REMOVE,s):(n.renderTarget.clear(null,Un.STENCIL),n.stencil.setStencilMode(Pr.DISABLED,s)),s--):"popMaskEnd"===t.action&&(t.inverse?n.stencil.setStencilMode(Pr.INVERSE_MASK_ACTIVE,s):n.stencil.setStencilMode(Pr.MASK_ACTIVE,s),n.colorMask.setMask(15)),this._maskStackHash[r]=s}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}ql.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"stencilMask"};var Kl=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(Kl||{});class $l{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class Ql{constructor(t){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuBuffers")}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gl=this._renderer.gl,this._gpuBuffers=Object.create(null),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(t){return this._gpuBuffers[t.uid]||this.createGLBuffer(t)}bind(t){const{_gl:e}=this,i=this.getGlBuffer(t);e.bindBuffer(i.type,i.buffer)}bindBufferBase(t,e){const{_gl:i}=this;this._boundBufferBases[e]!==t&&(this._boundBufferBases[e]=t,t._lastBindBaseLocation=e,i.bindBufferBase(i.UNIFORM_BUFFER,e,t.buffer))}nextBindBase(t){this._bindCallId++,this._minBaseLocation=0,t&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(t){let e=this.getLastBindBaseLocation(t);if(e>=this._minBaseLocation)return t._lastBindCallId=this._bindCallId,e;let i=0,n=this._nextBindBaseIndex;for(;i<2;){n>=this._maxBindings&&(n=this._minBaseLocation,i++);const t=this._boundBufferBases[n];if(!t||t._lastBindCallId!==this._bindCallId)break;n++}return e=n,this._nextBindBaseIndex=n+1,i>=2?-1:(t._lastBindCallId=this._bindCallId,this._boundBufferBases[e]=null,e)}getLastBindBaseLocation(t){const e=t._lastBindBaseLocation;return this._boundBufferBases[e]===t?e:-1}bindBufferRange(t,e,i,n){const{_gl:r}=this;i||(i=0),e||(e=0),this._boundBufferBases[e]=null,r.bindBufferRange(r.UNIFORM_BUFFER,e||0,t.buffer,256*i,n||256)}updateBuffer(t){const{_gl:e}=this,i=this.getGlBuffer(t);if(t._updateID===i.updateID)return i;i.updateID=t._updateID,e.bindBuffer(i.type,i.buffer);const n=t.data,r=t.descriptor.usage&Vr.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return n?i.byteLength>=n.byteLength?e.bufferSubData(i.type,0,n,0,t._updateSize/n.BYTES_PER_ELEMENT):(i.byteLength=n.byteLength,e.bufferData(i.type,n,r)):(i.byteLength=t.descriptor.size,e.bufferData(i.type,i.byteLength,r)),i}destroyAll(){const t=this._gl;for(const e in this._gpuBuffers)t.deleteBuffer(this._gpuBuffers[e].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(t,e){const i=this._gpuBuffers[t.uid],n=this._gl;e||n.deleteBuffer(i.buffer),this._gpuBuffers[t.uid]=null}createGLBuffer(t){const{_gl:e}=this;let i=Kl.ARRAY_BUFFER;t.descriptor.usage&Vr.INDEX?i=Kl.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&Vr.UNIFORM&&(i=Kl.UNIFORM_BUFFER);const n=new $l(e.createBuffer(),i);return this._gpuBuffers[t.uid]=n,t.on("destroy",this.onBufferDestroy,this),n}resetState(){this._boundBufferBases=Object.create(null)}}Ql.extension={type:[o.WebGLSystem],name:"buffer"};const Jl=class t{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(e){var i,n;e=__spreadValues(__spreadValues({},t.defaultOptions),e);let r=this.multiView=e.multiView;if(e.context&&r&&(kt("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),r=!1),this.canvas=r?Re.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const t=this._renderer.background.alpha<1,r=null==(i=e.premultipliedAlpha)||i,s=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:t,premultipliedAlpha:r,antialias:s,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:null!=(n=e.powerPreference)?n:"default"})}}ensureCanvasSize(t){if(!this.multiView)return void(t!==this.canvas&&kt("multiView is disabled, but targetCanvas is not the main canvas"));const{canvas:e}=this;(e.width<t.width||e.height<t.height)&&(e.width=Math.max(t.width,t.width),e.height=Math.max(t.height,t.height))}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof Re.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let i;const n=this.canvas;if(2===t&&(i=n.getContext("webgl2",e)),!i&&(i=n.getContext("webgl",e),!i))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=i,this.initFromContext(this.gl)}getExtensions(){const{gl:t}=this,e={anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc"),rgtc:t.getExtension("EXT_texture_compression_rgtc"),loseContext:t.getExtension("WEBGL_lose_context")};if(1===this.webGLVersion)this.extensions=__spreadProps(__spreadValues({},e),{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:t.getExtension("ANGLE_instanced_arrays"),srgb:t.getExtension("EXT_sRGB")});else{this.extensions=__spreadProps(__spreadValues({},e),{colorBufferFloat:t.getExtension("EXT_color_buffer_float")});const i=t.getExtension("WEBGL_provoking_vertex");i&&i.provokingVertexWEBGL(i.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var t;this.gl.isContextLost()&&(null==(t=this.extensions.loseContext)||t.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),null==(t=this.extensions.loseContext)||t.loseContext()}forceContextLoss(){var t;null==(t=this.extensions.loseContext)||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&!e.stencil&&kt("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const i=this.supports,n=2===this.webGLVersion,r=this.extensions;i.uint32Indices=n||!!r.uint32ElementIndex,i.uniformBufferObject=n,i.vertexArrayObject=n||!!r.vertexArrayObject,i.srgbTextures=n||!!r.srgb,i.nonPowOf2wrapping=n,i.nonPowOf2mipmaps=n,i.msaa=n,i.uint32Indices||kt("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};Jl.extension={type:[o.WebGLSystem],name:"context"},Jl.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let th=Jl;function eh(t,e){for(const i in t.attributes){const n=t.attributes[i],r=e[i];r?(null!=n.format||(n.format=r.format),null!=n.offset||(n.offset=r.offset),null!=n.instance||(n.instance=r.instance)):kt(`Attribute ${i} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}!function(t){const{buffers:e,attributes:i}=t,n={},r={};for(const s in e){const t=e[s];n[t.uid]=0,r[t.uid]=0}for(const s in i){const t=i[s];n[t.buffer.uid]+=Ni(t.format).stride}for(const s in i){const t=i[s];null!=t.stride||(t.stride=n[t.buffer.uid]),null!=t.start||(t.start=r[t.buffer.uid]),r[t.buffer.uid]+=Ni(t.format).stride}}(t)}var ih=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(ih||{}),nh=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(nh||{}),rh=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(rh||{});const sh={uint8x2:rh.UNSIGNED_BYTE,uint8x4:rh.UNSIGNED_BYTE,sint8x2:rh.BYTE,sint8x4:rh.BYTE,unorm8x2:rh.UNSIGNED_BYTE,unorm8x4:rh.UNSIGNED_BYTE,snorm8x2:rh.BYTE,snorm8x4:rh.BYTE,uint16x2:rh.UNSIGNED_SHORT,uint16x4:rh.UNSIGNED_SHORT,sint16x2:rh.SHORT,sint16x4:rh.SHORT,unorm16x2:rh.UNSIGNED_SHORT,unorm16x4:rh.UNSIGNED_SHORT,snorm16x2:rh.SHORT,snorm16x4:rh.SHORT,float16x2:rh.HALF_FLOAT,float16x4:rh.HALF_FLOAT,float32:rh.FLOAT,float32x2:rh.FLOAT,float32x3:rh.FLOAT,float32x4:rh.FLOAT,uint32:rh.UNSIGNED_INT,uint32x2:rh.UNSIGNED_INT,uint32x3:rh.UNSIGNED_INT,uint32x4:rh.UNSIGNED_INT,sint32:rh.INT,sint32x2:rh.INT,sint32x3:rh.INT,sint32x4:rh.INT};function oh(t){var e;return null!=(e=sh[t])?e:sh.float32}const ah={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class lh{constructor(t){this._geometryVaoHash=Object.create(null),this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._renderer.renderableGC.addManagedHash(this,"_geometryVaoHash")}contextChange(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=t=>e.bindVertexArrayOES(t),t.deleteVertexArray=t=>e.deleteVertexArrayOES(t));const i=this._renderer.context.extensions.vertexAttribDivisorANGLE;i&&(t.drawArraysInstanced=(t,e,n,r)=>{i.drawArraysInstancedANGLE(t,e,n,r)},t.drawElementsInstanced=(t,e,n,r,s)=>{i.drawElementsInstancedANGLE(t,e,n,r,s)},t.vertexAttribDivisor=(t,e)=>i.vertexAttribDivisorANGLE(t,e)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(t,e){const i=this.gl;this._activeGeometry=t;const n=this.getVao(t,e);this._activeVao!==n&&(this._activeVao=n,i.bindVertexArray(n)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let i=0;i<t.buffers.length;i++){const n=t.buffers[i];e.updateBuffer(n)}}checkCompatibility(t,e){const i=t.attributes,n=e._attributeData;for(const r in n)if(!i[r])throw new Error(`shader and geometry incompatible, geometry missing the "${r}" attribute`)}getSignature(t,e){const i=t.attributes,n=e._attributeData,r=["g",t.uid];for(const s in i)n[s]&&r.push(s,n[s].location);return r.join("-")}getVao(t,e){var i;return(null==(i=this._geometryVaoHash[t.uid])?void 0:i[e._key])||this.initGeometryVao(t,e)}initGeometryVao(t,e,i=!0){const n=this._renderer.gl,r=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const s=this.getSignature(t,e);this._geometryVaoHash[t.uid]||(this._geometryVaoHash[t.uid]=Object.create(null),t.on("destroy",this.onGeometryDestroy,this));const o=this._geometryVaoHash[t.uid];let a=o[s];if(a)return o[e._key]=a,a;eh(t,e._attributeData);const l=t.buffers;a=n.createVertexArray(),n.bindVertexArray(a);for(let h=0;h<l.length;h++){const t=l[h];r.bind(t)}return this.activateVao(t,e),o[e._key]=a,o[s]=a,n.bindVertexArray(null),a}onGeometryDestroy(t,e){const i=this._geometryVaoHash[t.uid],n=this.gl;if(i){if(e)for(const t in i)this._activeVao!==i[t]&&this.unbind(),n.deleteVertexArray(i[t]);this._geometryVaoHash[t.uid]=null}}destroyAll(t=!1){const e=this.gl;for(const i in this._geometryVaoHash){if(t)for(const t in this._geometryVaoHash[i]){const n=this._geometryVaoHash[i];this._activeVao!==n&&this.unbind(),e.deleteVertexArray(n[t])}this._geometryVaoHash[i]=null}}activateVao(t,e){var i,n;const r=this._renderer.gl,s=this._renderer.buffer,o=t.attributes;t.indexBuffer&&s.bind(t.indexBuffer);let a=null;for(const l in o){const t=o[l],h=t.buffer,c=s.getGlBuffer(h),u=e._attributeData[l];if(u){a!==c&&(s.bind(h),a=c);const e=u.location;r.enableVertexAttribArray(e);const o=Ni(t.format),l=oh(t.format);if("int"===(null==(i=u.format)?void 0:i.substring(1,4))?r.vertexAttribIPointer(e,o.size,l,t.stride,t.offset):r.vertexAttribPointer(e,o.size,l,o.normalised,t.stride,t.offset),t.instance){if(!this.hasInstance)throw new Error("geometry error, GPU Instancing is not supported on this device");{const i=null!=(n=t.divisor)?n:1;r.vertexAttribDivisor(e,i)}}}}}draw(t,e,i,n){const{gl:r}=this._renderer,s=this._activeGeometry,o=ah[t||s.topology];if(null!=n||(n=s.instanceCount),s.indexBuffer){const t=s.indexBuffer.data.BYTES_PER_ELEMENT,a=2===t?r.UNSIGNED_SHORT:r.UNSIGNED_INT;n>1?r.drawElementsInstanced(o,e||s.indexBuffer.data.length,a,(i||0)*t,n):r.drawElements(o,e||s.indexBuffer.data.length,a,(i||0)*t)}else n>1?r.drawArraysInstanced(o,i||0,e||s.getSize(),n):r.drawArrays(o,i||0,e||s.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}lh.extension={type:[o.WebGLSystem],name:"geometry"};const hh=new jr({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),ch=class t{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(e={}){const{useBackBuffer:i,antialias:n}=__spreadValues(__spreadValues({},t.defaultOptions),e);this.useBackBuffer=i,this._antialias=n,this._renderer.context.supports.msaa||(kt("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=rn.for2d();const r=new Li({vertex:"\n attribute vec2 aPosition;\n out vec2 vUv;\n\n void main() {\n gl_Position = vec4(aPosition, 0.0, 1.0);\n\n vUv = (aPosition + 1.0) / 2.0;\n\n // flip dem UVs\n vUv.y = 1.0 - vUv.y;\n }",fragment:"\n in vec2 vUv;\n out vec4 finalColor;\n\n uniform sampler2D uTexture;\n\n void main() {\n finalColor = texture(uTexture, vUv);\n }",name:"big-triangle"});this._bigTriangleShader=new tn({glProgram:r,resources:{uTexture:J.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const e=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=e.colorTexture,t.target=this._getBackBufferTexture(e.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:hh,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new J({source:new q({width:t.width,height:t.height,resolution:t._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(t.width,t.height,t._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};ch.extension={type:[o.WebGLSystem],name:"backBuffer",priority:1},ch.defaultOptions={useBackBuffer:!1};let uh=ch;class dh{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(8&t),!!(4&t),!!(2&t),!!(1&t)))}}dh.extension={type:[o.WebGLSystem],name:"colorMask"};class ph{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){const e=this._renderer,{geometry:i,shader:n,state:r,skipSync:s,topology:o,size:a,start:l,instanceCount:h}=t;e.shader.bind(n,s),e.geometry.bind(i,e.shader._activeProgram),r&&e.state.set(r),e.geometry.draw(o,a,l,null!=h?h:i.instanceCount)}destroy(){this._renderer=null}}ph.extension={type:[o.WebGLSystem],name:"encoder"};class fh{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=Fr(this.maxTextures,t),this.maxUniformBindings=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS)}destroy(){}}fh.extension={type:[o.WebGLSystem],name:"limits"};class gh{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const mh=[];mh[Pr.NONE]=void 0,mh[Pr.DISABLED]={stencilWriteMask:0,stencilReadMask:0},mh[Pr.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},mh[Pr.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},mh[Pr.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},mh[Pr.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class _h{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:Pr.NONE},this._renderTargetStencilState=Object.create(null),t.renderTarget.onRenderTargetChange.add(this)}contextChange(t){this._gl=t,this._comparisonFuncMapping={always:t.ALWAYS,never:t.NEVER,equal:t.EQUAL,"not-equal":t.NOTEQUAL,less:t.LESS,"less-equal":t.LEQUAL,greater:t.GREATER,"greater-equal":t.GEQUAL},this._stencilOpsMapping={keep:t.KEEP,zero:t.ZERO,replace:t.REPLACE,invert:t.INVERT,"increment-clamp":t.INCR,"decrement-clamp":t.DECR,"increment-wrap":t.INCR_WRAP,"decrement-wrap":t.DECR_WRAP},this.resetState()}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:Pr.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=Pr.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],n=this._gl,r=mh[t],s=this._stencilCache;i.stencilMode=t,i.stencilReference=e,t!==Pr.DISABLED?(this._stencilCache.enabled||(this._stencilCache.enabled=!0,n.enable(n.STENCIL_TEST)),t===s.stencilMode&&s.stencilReference===e||(s.stencilMode=t,s.stencilReference=e,n.stencilFunc(this._comparisonFuncMapping[r.stencilBack.compare],e,255),n.stencilOp(n.KEEP,n.KEEP,this._stencilOpsMapping[r.stencilBack.passOp]))):this._stencilCache.enabled&&(this._stencilCache.enabled=!1,n.disable(n.STENCIL_TEST))}}_h.extension={type:[o.WebGLSystem],name:"stencil"};class yh{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!hn())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const e=this.getUniformGroupData(t);t.buffer||(t.buffer=new Hr({data:new Float32Array(e.layout.size/4),usage:Vr.UNIFORM|Vr.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let i=this._syncFunctionHash[e];if(!i){const n=Object.keys(t.uniformStructures).map(e=>t.uniformStructures[e]),r=this._adaptor.createUboElements(n),s=this._generateUboSync(r.uboElements);i=this._syncFunctionHash[e]={layout:r,syncFunction:s}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,i){const n=this.getUniformGroupData(t);t.buffer||(t.buffer=new Hr({data:new Float32Array(n.layout.size/4),usage:Vr.UNIFORM|Vr.COPY_DST}));let r=null;return e||(e=t.buffer.data,r=t.buffer.dataInt32),i||(i=0),n.syncFunction(t.uniforms,e,r,i),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}const xh={f32:4,i32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"vec2<i32>":8,"vec3<i32>":12,"vec4<i32>":16,"mat2x2<f32>":32,"mat3x3<f32>":48,"mat4x4<f32>":64};function bh(t){const e=t.map(t=>({data:t,offset:0,size:0}));let i=0,n=0;for(let r=0;r<e.length;r++){const t=e[r];if(i=xh[t.data.type],!i)throw new Error(`Unknown type ${t.data.type}`);t.data.size>1&&(i=Math.max(i,16)*t.data.size);const s=12===i?16:i;t.size=i;const o=n%16;n+=o>0&&16-o<s?(16-o)%16:(i-o%i)%i,t.offset=n,n+=i}return n=16*Math.ceil(n/16),{uboElements:e,size:n}}const vh=[{type:"mat3x3<f32>",test:t=>void 0!==t.value.a,ubo:"\n var matrix = uv[name].toArray(true);\n data[offset] = matrix[0];\n data[offset + 1] = matrix[1];\n data[offset + 2] = matrix[2];\n data[offset + 4] = matrix[3];\n data[offset + 5] = matrix[4];\n data[offset + 6] = matrix[5];\n data[offset + 8] = matrix[6];\n data[offset + 9] = matrix[7];\n data[offset + 10] = matrix[8];\n ",uniform:"\n gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));\n "},{type:"vec4<f32>",test:t=>"vec4<f32>"===t.type&&1===t.size&&void 0!==t.value.width,ubo:"\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n data[offset + 2] = v.width;\n data[offset + 3] = v.height;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {\n cv[0] = v.x;\n cv[1] = v.y;\n cv[2] = v.width;\n cv[3] = v.height;\n gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);\n }\n "},{type:"vec2<f32>",test:t=>"vec2<f32>"===t.type&&1===t.size&&void 0!==t.value.x,ubo:"\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y) {\n cv[0] = v.x;\n cv[1] = v.y;\n gl.uniform2f(ud[name].location, v.x, v.y);\n }\n "},{type:"vec4<f32>",test:t=>"vec4<f32>"===t.type&&1===t.size&&void 0!==t.value.red,ubo:"\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n data[offset + 3] = v.alpha;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n cv[3] = v.alpha;\n gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);\n }\n "},{type:"vec3<f32>",test:t=>"vec3<f32>"===t.type&&1===t.size&&void 0!==t.value.red,ubo:"\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n gl.uniform3f(ud[name].location, v.red, v.green, v.blue);\n }\n "}];function wh(t,e,i,n){const r=["\n var v = null;\n var v2 = null;\n var t = 0;\n var index = 0;\n var name = null;\n var arrayOffset = null;\n "];let s=0;for(let a=0;a<t.length;a++){const o=t[a],l=o.data.name;let h=!1,c=0;for(let t=0;t<vh.length;t++){if(vh[t].test(o.data)){c=o.offset/4,r.push(`name = "${l}";`,`offset += ${c-s};`,vh[t][e]||vh[t].ubo),h=!0;break}}if(!h)if(o.data.size>1)c=o.offset/4,r.push(i(o,c-s));else{const t=n[o.data.type];c=o.offset/4,r.push(`\n v = uv.${l};\n offset += ${c-s};\n ${t};\n `)}s=c}const o=r.join("\n");return new Function("uv","data","dataInt32","offset",o)}function Sh(t,e){return`\n for (let i = 0; i < ${t*e}; i++) {\n data[offset + (((i / ${t})|0) * 4) + (i % ${t})] = v[i];\n }\n `}const Ah={f32:"\n data[offset] = v;",i32:"\n dataInt32[offset] = v;","vec2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];","vec3<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];","vec4<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];","vec2<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];","vec3<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];","vec4<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];\n dataInt32[offset + 3] = v[3];","mat2x2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 4] = v[2];\n data[offset + 5] = v[3];","mat3x3<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 4] = v[3];\n data[offset + 5] = v[4];\n data[offset + 6] = v[5];\n data[offset + 8] = v[6];\n data[offset + 9] = v[7];\n data[offset + 10] = v[8];","mat4x4<f32>":"\n for (let i = 0; i < 16; i++) {\n data[offset + i] = v[i];\n }","mat3x2<f32>":Sh(3,2),"mat4x2<f32>":Sh(4,2),"mat2x3<f32>":Sh(2,3),"mat4x3<f32>":Sh(4,3),"mat2x4<f32>":Sh(2,4),"mat3x4<f32>":Sh(3,4)},Th=__spreadProps(__spreadValues({},Ah),{"mat2x2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];\n "});function Ch(t,e){const i=Math.max(xh[t.data.type]/16,1),n=t.data.value.length/t.data.size,r=(4-n%4)%4,s=t.data.type.indexOf("i32")>=0?"dataInt32":"data";return`\n v = uv.${t.data.name};\n offset += ${e};\n\n arrayOffset = offset;\n\n t = 0;\n\n for(var i=0; i < ${t.data.size*i}; i++)\n {\n for(var j = 0; j < ${n}; j++)\n {\n ${s}[arrayOffset++] = v[t++];\n }\n ${0!==r?`arrayOffset += ${r};`:""}\n }\n `}function Ph(t){return wh(t,"uboStd40",Ch,Ah)}class Mh extends yh{constructor(){super({createUboElements:bh,generateUboSync:Ph})}}Mh.extension={type:[o.WebGLSystem],name:"ubo"};class Eh{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new D}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new D}copyToTexture(t,e,i,n,r){const s=this._renderTargetSystem,o=this._renderer,a=s.getGpuRenderTarget(t),l=o.gl;return this.finishRenderPass(t),l.bindFramebuffer(l.FRAMEBUFFER,a.resolveTargetFramebuffer),o.texture.bind(e,0),l.copyTexSubImage2D(l.TEXTURE_2D,0,r.x,r.y,i.x,i.y,n.width,n.height),e}startRenderPass(t,e=!0,i,n){const r=this._renderTargetSystem,s=t.colorTexture,o=r.getGpuRenderTarget(t);let a=n.y;t.isRoot&&(a=s.pixelHeight-n.height),t.colorTextures.forEach(t=>{this._renderer.texture.unbind(t)});const l=this._renderer.gl;l.bindFramebuffer(l.FRAMEBUFFER,o.framebuffer);const h=this._viewPortCache;h.x===n.x&&h.y===a&&h.width===n.width&&h.height===n.height||(h.x=n.x,h.y=a,h.width=n.width,h.height=n.height,l.viewport(n.x,a,n.width,n.height)),o.depthStencilRenderBuffer||!t.stencil&&!t.depth||this._initStencil(o),this.clear(t,e,i)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)return;const i=this._renderer.gl;i.bindFramebuffer(i.FRAMEBUFFER,e.resolveTargetFramebuffer),i.bindFramebuffer(i.READ_FRAMEBUFFER,e.framebuffer),i.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,i.COLOR_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.FRAMEBUFFER,e.framebuffer)}initGpuRenderTarget(t){const e=this._renderer.gl,i=new gh;return t.colorTexture instanceof Fe?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),i.framebuffer=null,i):(this._initColor(t,i),e.bindFramebuffer(e.FRAMEBUFFER,null),i)}destroyGpuRenderTarget(t){const e=this._renderer.gl;t.framebuffer&&(e.deleteFramebuffer(t.framebuffer),t.framebuffer=null),t.resolveTargetFramebuffer&&(e.deleteFramebuffer(t.resolveTargetFramebuffer),t.resolveTargetFramebuffer=null),t.depthStencilRenderBuffer&&(e.deleteRenderbuffer(t.depthStencilRenderBuffer),t.depthStencilRenderBuffer=null),t.msaaRenderBuffer.forEach(t=>{e.deleteRenderbuffer(t)}),t.msaaRenderBuffer=null}clear(t,e,i){if(!e)return;const n=this._renderTargetSystem;"boolean"==typeof e&&(e=e?Un.ALL:Un.NONE);const r=this._renderer.gl;if(e&Un.COLOR){null!=i||(i=n.defaultClearColor);const t=this._clearColorCache,e=i;t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]||(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],r.clearColor(e[0],e[1],e[2],e[3]))}r.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const i=this._renderer,n=i.gl,r=n.createFramebuffer();if(e.resolveTargetFramebuffer=r,n.bindFramebuffer(n.FRAMEBUFFER,r),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((t,r)=>{const s=t.source;s.antialias&&(i.context.supports.msaa?e.msaa=!0:kt("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),i.texture.bindSource(s,0);const o=i.texture.getGlSource(s).texture;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+r,3553,o,0)}),e.msaa){const i=n.createFramebuffer();e.framebuffer=i,n.bindFramebuffer(n.FRAMEBUFFER,i),t.colorTextures.forEach((t,i)=>{const r=n.createRenderbuffer();e.msaaRenderBuffer[i]=r})}else e.framebuffer=r;this._resizeColor(t,e)}_resizeColor(t,e){const i=t.colorTexture.source;if(e.width=i.pixelWidth,e.height=i.pixelHeight,t.colorTextures.forEach((t,e)=>{0!==e&&t.source.resize(i.width,i.height,i._resolution)}),e.msaa){const i=this._renderer,n=i.gl,r=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,r),t.colorTextures.forEach((t,r)=>{const s=t.source;i.texture.bindSource(s,0);const o=i.texture.getGlSource(s).internalFormat,a=e.msaaRenderBuffer[r];n.bindRenderbuffer(n.RENDERBUFFER,a),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,o,s.pixelWidth,s.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+r,n.RENDERBUFFER,a)})}}_initStencil(t){if(null===t.framebuffer)return;const e=this._renderer.gl,i=e.createRenderbuffer();t.depthStencilRenderBuffer=i,e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,i),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,2===this._renderer.context.webGLVersion?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}prerender(t){const e=t.colorTexture.resource;this._renderer.context.multiView&&Fe.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&Fe.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,i=t.colorTexture;i.context2D.drawImage(e,0,i.pixelHeight-e.height)}}}const Rh=new Map;function Fh(t,e){if(!Rh.has(t)){const i=new J({source:new Fe(__spreadValues({resource:t},e))}),n=()=>{Rh.get(t)===i&&Rh.delete(t)};i.once("destroy",n),i.source.once("destroy",n),Rh.set(t,i)}return Rh.get(t)}const Bh=class t{constructor(e={}){if(this.uid=U("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,e=__spreadValues(__spreadValues({},t.defaultOptions),e),this.stencil=e.stencil,this.depth=e.depth,this.isRoot=e.isRoot,"number"==typeof e.colorTextures){this._managedColorTextures=!0;for(let t=0;t<e.colorTextures;t++)this.colorTextures.push(new q({width:e.width,height:e.height,resolution:e.resolution,antialias:e.antialias}))}else{this.colorTextures=[...e.colorTextures.map(t=>t.source)];const t=this.colorTexture.source;this.resize(t.width,t.height,t._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(e.depthStencilTexture||this.stencil)&&(e.depthStencilTexture instanceof J||e.depthStencilTexture instanceof q?this.depthStencilTexture=e.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new q({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,i=this.resolution,n=!1){this.dirtyId++,this.colorTextures.forEach((r,s)=>{n&&0===s||r.source.resize(t,e,i)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,i)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(t=>{t.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};Bh.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let kh=Bh;class Ih{constructor(t){this.rootViewPort=new D,this.viewport=new D,this.onRenderTargetChange=new Gn("onRenderTargetChange"),this.projectionMatrix=new S,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuRenderTargetHash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:i,frame:n}){var r,s;this._renderTargetStack.length=0,this.push(t,e,i,n),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=function(t){const e=t.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement&&document.body.contains(e)}(this.rootRenderTarget),null==(s=(r=this.adaptor).prerender)||s.call(r,this.rootRenderTarget)}postrender(){var t,e;null==(e=(t=this.adaptor).postrender)||e.call(t,this.rootRenderTarget)}bind(t,e=!0,i,n){const r=this.getRenderTarget(t),s=this.renderTarget!==r;this.renderTarget=r,this.renderSurface=t;const o=this.getGpuRenderTarget(r);r.pixelWidth===o.width&&r.pixelHeight===o.height||(this.adaptor.resizeGpuRenderTarget(r),o.width=r.pixelWidth,o.height=r.pixelHeight);const a=r.colorTexture,l=this.viewport,h=a.pixelWidth,c=a.pixelHeight;if(!n&&t instanceof J&&(n=t.frame),n){const t=a._resolution;l.x=n.x*t+.5|0,l.y=n.y*t+.5|0,l.width=n.width*t+.5|0,l.height=n.height*t+.5|0}else l.x=0,l.y=0,l.width=h,l.height=c;return function(t,e,i,n,r,s){const o=s?1:-1;t.identity(),t.a=1/n*2,t.d=o*(1/r*2),t.tx=-1-e*t.a,t.ty=-o-i*t.d}(this.projectionMatrix,0,0,l.width/a.resolution,l.height/a.resolution,!r.isRoot),this.adaptor.startRenderPass(r,e,i,l),s&&this.onRenderTargetChange.emit(r),r}clear(t,e=Un.ALL,i){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,i,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=Un.ALL,i,n){const r=this.bind(t,e,i,n);return this._renderTargetStack.push({renderTarget:r,frame:n}),r}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame)}getRenderTarget(t){var e;return t.isTexture&&(t=t.source),null!=(e=this._renderSurfaceToRenderTargetHash.get(t))?e:this._initRenderTarget(t)}copyToTexture(t,e,i,n,r){i.x<0&&(n.width+=i.x,r.x-=i.x,i.x=0),i.y<0&&(n.height+=i.y,r.y-=i.y,i.y=0);const{pixelWidth:s,pixelHeight:o}=t;return n.width=Math.min(n.width,s-i.x),n.height=Math.min(n.height,o-i.y),this.adaptor.copyToTexture(t,e,i,n,r)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((t,e)=>{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return Fe.test(t)&&(t=Fh(t).source),t instanceof kh?e=t:t instanceof q&&(e=new kh({colorTextures:[t]}),t.source instanceof Fe&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);const i=this._gpuRenderTargetHash[e.uid];i&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(i))})),this._renderSurfaceToRenderTargetHash.set(t,e),e}getGpuRenderTarget(t){return this._gpuRenderTargetHash[t.uid]||(this._gpuRenderTargetHash[t.uid]=this.adaptor.initGpuRenderTarget(t))}resetState(){this.renderTarget=null,this.renderSurface=null}}class Dh extends Ih{constructor(t){super(t),this.adaptor=new Eh,this.adaptor.init(t,this)}}Dh.extension={type:[o.WebGLSystem],name:"renderTarget"};class Oh extends _{constructor({buffer:t,offset:e,size:i}){super(),this.uid=U("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=U("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=0|e,this.size=i,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=U("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}class Uh{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function Gh(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}function Lh(t){const e=new Array(t);for(let i=0;i<e.length;i++)e[i]=!1;return e}function zh(t,e){switch(t){case"float":case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return Lh(2*e);case"bvec3":return Lh(3*e);case"bvec4":return Lh(4*e);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}let Nh=null;const Vh={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"},Hh={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"};function Wh(t,e){if(!Nh){const e=Object.keys(Vh);Nh={};for(let i=0;i<e.length;++i){const n=e[i];Nh[t[n]]=Vh[n]}}return Nh[e]}function jh(t,e){const i=Wh(t,e);return Hh[i]||"float32"}function Yh(t,e){const i=t.getShaderSource(e).split("\n").map((t,e)=>`${e}: ${t}`),n=t.getShaderInfoLog(e),r=n.split("\n"),s={},o=r.map(t=>parseFloat(t.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(t=>!(!t||s[t])&&(s[t]=!0,!0)),a=[""];o.forEach(t=>{i[t-1]=`%c${i[t-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=i.join("\n");a[0]=l,console.error(n),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Xh(t,e){const i=Gh(t,t.VERTEX_SHADER,e.vertex),n=Gh(t,t.FRAGMENT_SHADER,e.fragment),r=t.createProgram();t.attachShader(r,i),t.attachShader(r,n);const s=e.transformFeedbackVaryings;s&&("function"!=typeof t.transformFeedbackVaryings?kt("TransformFeedback is not supported but TransformFeedbackVaryings are given."):t.transformFeedbackVaryings(r,s.names,"separate"===s.bufferMode?t.SEPARATE_ATTRIBS:t.INTERLEAVED_ATTRIBS)),t.linkProgram(r),t.getProgramParameter(r,t.LINK_STATUS)||function(t,e,i,n){t.getProgramParameter(e,t.LINK_STATUS)||(t.getShaderParameter(i,t.COMPILE_STATUS)||Yh(t,i),t.getShaderParameter(n,t.COMPILE_STATUS)||Yh(t,n),console.error("PixiJS Error: Could not initialize shader."),""!==t.getProgramInfoLog(e)&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",t.getProgramInfoLog(e)))}(t,r,i,n),e._attributeData=function(t,e,i=!1){const n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let o=0;o<r;o++){const i=e.getActiveAttrib(t,o);if(i.name.startsWith("gl_"))continue;const r=jh(e,i.type);n[i.name]={location:0,format:r,stride:Ni(r).stride,offset:0,instance:!1,start:0}}const s=Object.keys(n);if(i){s.sort((t,e)=>t>e?1:-1);for(let i=0;i<s.length;i++)n[s[i]].location=i,e.bindAttribLocation(t,i,s[i]);e.linkProgram(t)}else for(let o=0;o<s.length;o++)n[s[o]].location=e.getAttribLocation(t,s[o]);return n}(r,t,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertex)),e._uniformData=function(t,e){const i={},n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;r++){const n=e.getActiveUniform(t,r),s=n.name.replace(/\[.*?\]$/,""),o=!!n.name.match(/\[.*?\]$/),a=Wh(e,n.type);i[s]={name:s,index:r,type:a,size:n.size,isArray:o,value:zh(a,n.size)}}return i}(r,t),e._uniformBlockData=function(t,e){if(!e.ACTIVE_UNIFORM_BLOCKS)return{};const i={},n=e.getProgramParameter(t,e.ACTIVE_UNIFORM_BLOCKS);for(let r=0;r<n;r++){const n=e.getActiveUniformBlockName(t,r),s=e.getUniformBlockIndex(t,n),o=e.getActiveUniformBlockParameter(t,r,e.UNIFORM_BLOCK_DATA_SIZE);i[n]={name:n,index:s,size:o}}return i}(r,t),t.deleteShader(i),t.deleteShader(n);const o={};for(const a in e._uniformData){const i=e._uniformData[a];o[a]={location:t.getUniformLocation(r,a),value:zh(i.type,i.size)}}return new Uh(r,o)}const Zh={textureCount:0,blockIndex:0};class qh{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_programDataHash")}contextChange(t){this._gl=t,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;Zh.textureCount=0,Zh.blockIndex=0;let i=this._shaderSyncFunctions[t.glProgram._key];i||(i=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),i(this._renderer,t,Zh)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,Zh)}bindUniformBlock(t,e,i=0){const n=this._renderer.buffer,r=this._getProgramData(this._activeProgram),s=t._bufferResource;s||this._renderer.ubo.updateUniformGroup(t);const o=t.buffer,a=n.updateBuffer(o),l=n.freeLocationForBufferBase(a);if(s){const{offset:e,size:i}=t;0===e&&i===o.data.byteLength?n.bindBufferBase(a,l):n.bindBufferRange(a,l,e)}else n.getLastBindBaseLocation(a)!==l&&n.bindBufferBase(a,l);const h=this._activeProgram._uniformBlockData[e].index;r.uniformBlockBindings[i]!==l&&(r.uniformBlockBindings[i]=l,this._renderer.gl.uniformBlockBinding(r.program,h,l))}_setProgram(t){if(this._activeProgram===t)return;this._activeProgram=t;const e=this._getProgramData(t);this._gl.useProgram(e.program)}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){const e=t._key;return this._programDataHash[e]=Xh(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash)){this._programDataHash[t].destroy(),this._programDataHash[t]=null}this._programDataHash=null}_generateShaderSync(t,e){return function(t,e){const i=[],n=["\n var g = s.groups;\n var sS = r.shader;\n var p = s.glProgram;\n var ugS = r.uniformGroup;\n var resources;\n "];let r=!1,s=0;const o=e._getProgramData(t.glProgram);for(const l in t.groups){const a=t.groups[l];i.push(`\n resources = g[${l}].resources;\n `);for(const h in a.resources){const c=a.resources[h];if(c instanceof $i)if(c.ubo){const e=t._uniformBindMap[l][Number(h)];i.push(`\n sS.bindUniformBlock(\n resources[${h}],\n '${e}',\n ${t.glProgram._uniformBlockData[e].index}\n );\n `)}else i.push(`\n ugS.updateUniformGroup(resources[${h}], p, sD);\n `);else if(c instanceof Oh){const e=t._uniformBindMap[l][Number(h)];i.push(`\n sS.bindUniformBlock(\n resources[${h}],\n '${e}',\n ${t.glProgram._uniformBlockData[e].index}\n );\n `)}else if(c instanceof q){const a=t._uniformBindMap[l][h],c=o.uniformData[a];c&&(r||(r=!0,n.push("\n var tS = r.texture;\n ")),e._gl.uniform1i(c.location,s),i.push(`\n tS.bind(resources[${h}], ${s});\n `),s++)}}}const a=[...n,...i].join("\n");return new Function("r","s","sD",a)}(t,e)}resetState(){this._activeProgram=null}}qh.extension={type:[o.WebGLSystem],name:"shader"};const Kh={f32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1f(location, v);\n }","vec2<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2f(location, v[0], v[1]);\n }","vec3<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3f(location, v[0], v[1], v[2]);\n }","vec4<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4f(location, v[0], v[1], v[2], v[3]);\n }",i32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1i(location, v);\n }","vec2<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2i(location, v[0], v[1]);\n }","vec3<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3i(location, v[0], v[1], v[2]);\n }","vec4<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }",u32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1ui(location, v);\n }","vec2<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2ui(location, v[0], v[1]);\n }","vec3<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3ui(location, v[0], v[1], v[2]);\n }","vec4<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4ui(location, v[0], v[1], v[2], v[3]);\n }",bool:"if (cv !== v) {\n cu.value = v;\n gl.uniform1i(location, v);\n }","vec2<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2i(location, v[0], v[1]);\n }","vec3<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3i(location, v[0], v[1], v[2]);\n }","vec4<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},$h={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"};class Qh{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,i){const n=this._renderer.shader._getProgramData(e);if(!t.isStatic||t._dirtyId!==n.uniformDirtyGroups[t.uid]){n.uniformDirtyGroups[t.uid]=t._dirtyId;this._getUniformSyncFunction(t,e)(n.uniformData,t.uniforms,this._renderer,i)}}_getUniformSyncFunction(t,e){var i;return(null==(i=this._uniformGroupSyncHash[t._signature])?void 0:i[e._key])||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){const i=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),n=this._getSignature(t,e._uniformData,"u");return this._cache[n]||(this._cache[n]=this._generateUniformsSync(t,e._uniformData)),i[e._key]=this._cache[n],i[e._key]}_generateUniformsSync(t,e){return function(t,e){const i=["\n var v = null;\n var cv = null;\n var cu = null;\n var t = 0;\n var gl = renderer.gl;\n var name = null;\n "];for(const n in t.uniforms){if(!e[n]){t.uniforms[n]instanceof $i?t.uniforms[n].ubo?i.push(`\n renderer.shader.bindUniformBlock(uv.${n}, "${n}");\n `):i.push(`\n renderer.shader.updateUniformGroup(uv.${n});\n `):t.uniforms[n]instanceof Oh&&i.push(`\n renderer.shader.bindBufferResource(uv.${n}, "${n}");\n `);continue}const r=t.uniformStructures[n];let s=!1;for(let t=0;t<vh.length;t++){const e=vh[t];if(r.type===e.type&&e.test(r)){i.push(`name = "${n}";`,vh[t].uniform),s=!0;break}}if(!s){const t=(1===r.size?Kh:$h)[r.type].replace("location",`ud["${n}"].location`);i.push(`\n cu = ud["${n}"];\n cv = cu.value;\n v = uv["${n}"];\n ${t};`)}}return new Function("ud","uv","renderer","syncData",i.join("\n"))}(t,e)}_getSignature(t,e,i){const n=t.uniforms,r=[`${i}-`];for(const s in n)r.push(s),e[s]&&r.push(e[s].type);return r.join("-")}destroy(){this._renderer=null,this._cache=null}}Qh.extension={type:[o.WebGLSystem],name:"uniformGroup"};const Jh=class t{constructor(t){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[0]=this.setBlend,this.map[1]=this.setOffset,this.map[2]=this.setCullFace,this.map[3]=this.setDepthTest,this.map[4]=this.setFrontFace,this.map[5]=this.setDepthMask,this.checks=[],this.defaultState=rn.for2d(),t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){this._invertFrontFace=!t.isRoot,this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(t){this.gl=t,this.blendModesMap=function(t){const e={};if(e.normal=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e.add=[t.ONE,t.ONE],e.multiply=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.screen=[t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.none=[0,0],e["normal-npm"]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e["add-npm"]=[t.SRC_ALPHA,t.ONE,t.ONE,t.ONE],e["screen-npm"]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.erase=[t.ZERO,t.ONE_MINUS_SRC_ALPHA],t instanceof Re.get().getWebGLRenderingContext()){const i=t.getExtension("EXT_blend_minmax");i&&(e.min=[t.ONE,t.ONE,t.ONE,t.ONE,i.MIN_EXT,i.MIN_EXT],e.max=[t.ONE,t.ONE,t.ONE,t.ONE,i.MAX_EXT,i.MAX_EXT])}else e.min=[t.ONE,t.ONE,t.ONE,t.ONE,t.MIN,t.MIN],e.max=[t.ONE,t.ONE,t.ONE,t.ONE,t.MAX,t.MAX];return e}(t),this.resetState()}set(t){if(t||(t=this.defaultState),this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)1&e&&this.map[i].call(this,!!(t.data&1<<i)),e>>=1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t||(t=this.defaultState);for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(e){this._updateCheck(t._checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this._updateCheck(t._checkPolygonOffset,e),this.gl[e?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this._cullFace=t,this.gl[t?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(t){this._frontFace=t,this._frontFaceDirty=!1;const e=this._invertFrontFace?!t:t;this._glFrontFace!==e&&(this._glFrontFace=e,this.gl.frontFace(this.gl[e?"CW":"CCW"]))}setBlendMode(t){if(this.blendModesMap[t]||(t="normal"),t===this.blendMode)return;this.blendMode=t;const e=this.blendModesMap[t],i=this.gl;2===e.length?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),6===e.length?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}resetState(){this._glFrontFace=!1,this._frontFace=!1,this._cullFace=!1,this._frontFaceDirty=!1,this._invertFrontFace=!1,this.gl.frontFace(this.gl.CCW),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode="",this.setBlendMode("normal")}_updateCheck(t,e){const i=this.checks.indexOf(t);e&&-1===i?this.checks.push(t):e||-1===i||this.checks.splice(i,1)}static _checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static _checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};Jh.extension={type:[o.WebGLSystem],name:"state"};let tc=Jh;class ec{constructor(t){this.target=nh.TEXTURE_2D,this.texture=t,this.width=-1,this.height=-1,this.type=rh.UNSIGNED_BYTE,this.internalFormat=ih.RGBA,this.format=ih.RGBA,this.samplerType=0}}const ic={id:"buffer",upload(t,e,i){e.width===t.width||e.height===t.height?i.texSubImage2D(i.TEXTURE_2D,0,0,0,t.width,t.height,e.format,e.type,t.resource):i.texImage2D(e.target,0,e.internalFormat,t.width,t.height,0,e.format,e.type,t.resource),e.width=t.width,e.height=t.height}},nc={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},rc={id:"compressed",upload(t,e,i){i.pixelStorei(i.UNPACK_ALIGNMENT,4);let n=t.pixelWidth,r=t.pixelHeight;const s=!!nc[t.format];for(let o=0;o<t.resource.length;o++){const a=t.resource[o];s?i.compressedTexImage2D(i.TEXTURE_2D,o,e.internalFormat,n,r,0,a):i.texImage2D(i.TEXTURE_2D,o,e.internalFormat,n,r,0,e.format,e.type,a),n=Math.max(n>>1,1),r=Math.max(r>>1,1)}}},sc={id:"image",upload(t,e,i,n){const r=e.width,s=e.height,o=t.pixelWidth,a=t.pixelHeight,l=t.resourceWidth,h=t.resourceHeight;l<o||h<a?(r===o&&s===a||i.texImage2D(e.target,0,e.internalFormat,o,a,0,e.format,e.type,null),2===n?i.texSubImage2D(i.TEXTURE_2D,0,0,0,l,h,e.format,e.type,t.resource):i.texSubImage2D(i.TEXTURE_2D,0,0,0,e.format,e.type,t.resource)):r===o&&s===a?i.texSubImage2D(i.TEXTURE_2D,0,0,0,e.format,e.type,t.resource):2===n?i.texImage2D(e.target,0,e.internalFormat,o,a,0,e.format,e.type,t.resource):i.texImage2D(e.target,0,e.internalFormat,e.format,e.type,t.resource),e.width=o,e.height=a}},oc={id:"video",upload(t,e,i,n){t.isValid?sc.upload(t,e,i,n):i.texImage2D(e.target,0,e.internalFormat,1,1,0,e.format,e.type,null)}},ac={linear:9729,nearest:9728},lc={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},hc={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},cc={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function uc(t,e,i,n,r,s,o,a){const l=s;if(!a||"repeat"!==t.addressModeU||"repeat"!==t.addressModeV||"repeat"!==t.addressModeW){const i=hc[o?"clamp-to-edge":t.addressModeU],n=hc[o?"clamp-to-edge":t.addressModeV],s=hc[o?"clamp-to-edge":t.addressModeW];e[r](l,e.TEXTURE_WRAP_S,i),e[r](l,e.TEXTURE_WRAP_T,n),e.TEXTURE_WRAP_R&&e[r](l,e.TEXTURE_WRAP_R,s)}if(a&&"linear"===t.magFilter||e[r](l,e.TEXTURE_MAG_FILTER,ac[t.magFilter]),i){if(!a||"linear"!==t.mipmapFilter){const i=lc[t.minFilter][t.mipmapFilter];e[r](l,e.TEXTURE_MIN_FILTER,i)}}else e[r](l,e.TEXTURE_MIN_FILTER,ac[t.minFilter]);if(n&&t.maxAnisotropy>1){const i=Math.min(t.maxAnisotropy,e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));e[r](l,n.TEXTURE_MAX_ANISOTROPY_EXT,i)}t.compare&&e[r](l,e.TEXTURE_COMPARE_FUNC,cc[t.compare])}class dc{constructor(t){this.managedTextures=[],this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._uploads={image:sc,buffer:ic,video:oc,compressed:rc},this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_glTextures"),this._renderer.renderableGC.addManagedHash(this,"_glSamplers")}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=function(t,e){let i={},n=t.RGBA;return t instanceof Re.get().getWebGLRenderingContext()?e.srgb&&(i={"rgba8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT}):(i={"rgba8unorm-srgb":t.SRGB8_ALPHA8,"bgra8unorm-srgb":t.SRGB8_ALPHA8},n=t.RGBA8),__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({r8unorm:t.R8,r8snorm:t.R8_SNORM,r8uint:t.R8UI,r8sint:t.R8I,r16uint:t.R16UI,r16sint:t.R16I,r16float:t.R16F,rg8unorm:t.RG8,rg8snorm:t.RG8_SNORM,rg8uint:t.RG8UI,rg8sint:t.RG8I,r32uint:t.R32UI,r32sint:t.R32I,r32float:t.R32F,rg16uint:t.RG16UI,rg16sint:t.RG16I,rg16float:t.RG16F,rgba8unorm:t.RGBA},i),{rgba8snorm:t.RGBA8_SNORM,rgba8uint:t.RGBA8UI,rgba8sint:t.RGBA8I,bgra8unorm:n,rgb9e5ufloat:t.RGB9_E5,rgb10a2unorm:t.RGB10_A2,rg11b10ufloat:t.R11F_G11F_B10F,rg32uint:t.RG32UI,rg32sint:t.RG32I,rg32float:t.RG32F,rgba16uint:t.RGBA16UI,rgba16sint:t.RGBA16I,rgba16float:t.RGBA16F,rgba32uint:t.RGBA32UI,rgba32sint:t.RGBA32I,rgba32float:t.RGBA32F,stencil8:t.STENCIL_INDEX8,depth16unorm:t.DEPTH_COMPONENT16,depth24plus:t.DEPTH_COMPONENT24,"depth24plus-stencil8":t.DEPTH24_STENCIL8,depth32float:t.DEPTH_COMPONENT32F,"depth32float-stencil8":t.DEPTH32F_STENCIL8}),e.s3tc?{"bc1-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{}),e.s3tc_sRGB?{"bc1-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{}),e.rgtc?{"bc4-r-unorm":e.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":e.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":e.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":e.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{}),e.bptc?{"bc6h-rgb-float":e.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":e.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":e.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":e.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{}),e.etc?{"etc2-rgb8unorm":e.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":e.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":e.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":e.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":e.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":e.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":e.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":e.etc.COMPRESSED_SIGNED_RG11_EAC}:{}),e.astc?{"astc-4x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{})}(t,this._renderer.context.extensions),this._mapFormatToType=function(t){return{r8unorm:t.UNSIGNED_BYTE,r8snorm:t.BYTE,r8uint:t.UNSIGNED_BYTE,r8sint:t.BYTE,r16uint:t.UNSIGNED_SHORT,r16sint:t.SHORT,r16float:t.HALF_FLOAT,rg8unorm:t.UNSIGNED_BYTE,rg8snorm:t.BYTE,rg8uint:t.UNSIGNED_BYTE,rg8sint:t.BYTE,r32uint:t.UNSIGNED_INT,r32sint:t.INT,r32float:t.FLOAT,rg16uint:t.UNSIGNED_SHORT,rg16sint:t.SHORT,rg16float:t.HALF_FLOAT,rgba8unorm:t.UNSIGNED_BYTE,"rgba8unorm-srgb":t.UNSIGNED_BYTE,rgba8snorm:t.BYTE,rgba8uint:t.UNSIGNED_BYTE,rgba8sint:t.BYTE,bgra8unorm:t.UNSIGNED_BYTE,"bgra8unorm-srgb":t.UNSIGNED_BYTE,rgb9e5ufloat:t.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:t.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:t.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:t.UNSIGNED_INT,rg32sint:t.INT,rg32float:t.FLOAT,rgba16uint:t.UNSIGNED_SHORT,rgba16sint:t.SHORT,rgba16float:t.HALF_FLOAT,rgba32uint:t.UNSIGNED_INT,rgba32sint:t.INT,rgba32float:t.FLOAT,stencil8:t.UNSIGNED_BYTE,depth16unorm:t.UNSIGNED_SHORT,depth24plus:t.UNSIGNED_INT,"depth24plus-stencil8":t.UNSIGNED_INT_24_8,depth32float:t.FLOAT,"depth32float-stencil8":t.FLOAT_32_UNSIGNED_INT_24_8_REV}}(t),this._mapFormatToFormat=function(t){return{r8unorm:t.RED,r8snorm:t.RED,r8uint:t.RED,r8sint:t.RED,r16uint:t.RED,r16sint:t.RED,r16float:t.RED,rg8unorm:t.RG,rg8snorm:t.RG,rg8uint:t.RG,rg8sint:t.RG,r32uint:t.RED,r32sint:t.RED,r32float:t.RED,rg16uint:t.RG,rg16sint:t.RG,rg16float:t.RG,rgba8unorm:t.RGBA,"rgba8unorm-srgb":t.RGBA,rgba8snorm:t.RGBA,rgba8uint:t.RGBA,rgba8sint:t.RGBA,bgra8unorm:t.RGBA,"bgra8unorm-srgb":t.RGBA,rgb9e5ufloat:t.RGB,rgb10a2unorm:t.RGBA,rg11b10ufloat:t.RGB,rg32uint:t.RG,rg32sint:t.RG,rg32float:t.RG,rgba16uint:t.RGBA,rgba16sint:t.RGBA,rgba16float:t.RGBA,rgba32uint:t.RGBA,rgba32sint:t.RGBA,rgba32float:t.RGBA,stencil8:t.STENCIL_INDEX8,depth16unorm:t.DEPTH_COMPONENT,depth24plus:t.DEPTH_COMPONENT,"depth24plus-stencil8":t.DEPTH_STENCIL,depth32float:t.DEPTH_COMPONENT,"depth32float-stencil8":t.DEPTH_STENCIL}}(t)),this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let e=0;e<16;e++)this.bind(J.EMPTY,e)}initSource(t){this.bind(t)}bind(t,e=0){const i=t.source;t?(this.bindSource(i,e),this._useSeparateSamplers&&this._bindSampler(i.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){const i=this._gl;if(t._touched=this._renderer.textureGC.count,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t||(t=J.EMPTY.source);const n=this.getGlSource(t);i.bindTexture(n.target,n.texture)}}_bindSampler(t,e=0){const i=this._gl;if(!t)return this._boundSamplers[e]=null,void i.bindSampler(e,null);const n=this._getGlSampler(t);this._boundSamplers[e]!==n&&(this._boundSamplers[e]=n,i.bindSampler(e,n))}unbind(t){const e=t.source,i=this._boundTextures,n=this._gl;for(let r=0;r<i.length;r++)if(i[r]===e){this._activateLocation(r);const t=this.getGlSource(e);n.bindTexture(t.target,null),i[r]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,i=new ec(e.createTexture());if(i.type=this._mapFormatToType[t.format],i.internalFormat=this._mapFormatToInternalFormat[t.format],i.format=this._mapFormatToFormat[t.format],t.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||t.isPowerOfTwo)){const e=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(e))+1}return this._glTextures[t.uid]=i,this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceUpdate,this),t.on("styleChange",this.onStyleChange,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),this.updateStyle(t,!1),i}onStyleChange(t){this.updateStyle(t,!1)}updateStyle(t,e){const i=this._gl,n=this.getGlSource(t);i.bindTexture(i.TEXTURE_2D,n.texture),this._boundTextures[this._activeTextureLocation]=t,uc(t.style,i,t.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t){const e=this._glTextures[t.uid];e&&(this.unbind(t),this._glTextures[t.uid]=null,this._gl.deleteTexture(e.texture))}onSourceUpdate(t){const e=this._gl,i=this.getGlSource(t);e.bindTexture(e.TEXTURE_2D,i.texture),this._boundTextures[this._activeTextureLocation]=t;const n="premultiply-alpha-on-upload"===t.alphaMode;this._premultiplyAlpha!==n&&(this._premultiplyAlpha=n,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n)),this._uploads[t.uploadMethodId]?this._uploads[t.uploadMethodId].upload(t,i,e,this._renderer.context.webGLVersion):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t.pixelWidth,t.pixelHeight,0,e.RGBA,e.UNSIGNED_BYTE,null),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const i=this.getGlSource(t);this._gl.generateMipmap(i.target)}onSourceDestroy(t){t.off("destroy",this.onSourceDestroy,this),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}_initSampler(t){const e=this._gl,i=this._gl.createSampler();return this._glSamplers[t._resourceId]=i,uc(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",i,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return this._glTextures[t.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:i,height:n}=this.getPixels(t),r=Re.get().createCanvas();r.width=i,r.height=n;const s=r.getContext("2d");if(s){const t=s.createImageData(i,n);t.data.set(e),s.putImageData(t,0,0)}return r}getPixels(t){const e=t.source.resolution,i=t.frame,n=Math.max(Math.round(i.width*e),1),r=Math.max(Math.round(i.height*e),1),s=new Uint8Array(4*n*r),o=this._renderer,a=o.renderTarget.getRenderTarget(t),l=o.renderTarget.getGpuRenderTarget(a),h=o.gl;return h.bindFramebuffer(h.FRAMEBUFFER,l.resolveTargetFramebuffer),h.readPixels(Math.round(i.x*e),Math.round(i.y*e),n,r,h.RGBA,h.UNSIGNED_BYTE,s),{pixels:new Uint8ClampedArray(s.buffer),width:n,height:r}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(J.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}dc.extension={type:[o.WebGLSystem],name:"texture"};class pc{contextChange(t){const e=new $i({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new S,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),i=t.limits.maxBatchableTextures,n=us({name:"graphics",bits:[ps,bs(i),Vl,ws]});this.shader=new tn({glProgram:n,resources:{localUniforms:e,batchSamplers:As(i)}})}execute(t,e){const i=e.context,n=i.customShader||this.shader,r=t.renderer,s=r.graphicsContext,{batcher:o,instructions:a}=s.getContextRenderData(i);n.groups[0]=r.globalUniforms.bindGroup,r.state.set(t.state),r.shader.bind(n),r.geometry.bind(o.geometry,n.glProgram);const l=a.instructions;for(let h=0;h<a.instructionSize;h++){const t=l[h];if(t.size){for(let e=0;e<t.textures.count;e++)r.texture.bind(t.textures.textures[e],e);r.geometry.draw(t.topology,t.size,t.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}pc.extension={type:[o.WebGLPipesAdaptor],name:"graphics"};class fc{init(){const t=us({name:"mesh",bits:[Vl,Wl,ws]});this._shader=new tn({glProgram:t,resources:{uTexture:J.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new S}}}})}execute(t,e){const i=t.renderer;let n=e._shader;if(n){if(!n.glProgram)return void kt("Mesh shader has no glProgram",e.shader)}else{n=this._shader;const t=e.texture,i=t.source;n.resources.uTexture=i,n.resources.uSampler=i.style,n.resources.textureUniforms.uniforms.uTextureMatrix=t.textureMatrix.mapCoord}n.groups[100]=i.globalUniforms.bindGroup,n.groups[101]=t.localUniformsBindGroup,i.encoder.draw({geometry:e._geometry,shader:n,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}fc.extension={type:[o.WebGLPipesAdaptor],name:"mesh"};class gc{constructor(t){this._renderer=t}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}gc.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"customRender"};class mc{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(){}}function _c(t,e){const i=t.instructionSet,n=i.instructions;for(let r=0;r<i.instructionSize;r++){const t=n[r];e[t.renderPipeId].execute(t)}}const yc=new S;class xc{constructor(t){this._renderer=t}addRenderGroup(t,e){t.isCachedAsTexture?this._addRenderableCacheAsTexture(t,e):this._addRenderableDirect(t,e)}execute(t){t.isRenderable&&(t.isCachedAsTexture?this._executeCacheAsTexture(t):this._executeDirect(t))}destroy(){this._renderer=null}_addRenderableDirect(t,e){this._renderer.renderPipes.batch.break(e),t._batchableRenderGroup&&(Dt.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){var i;const n=null!=(i=t._batchableRenderGroup)?i:t._batchableRenderGroup=Dt.get(mc);n.renderable=t.root,n.transform=t.root.relativeGroupTransform,n.texture=t.texture,n.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.batch.addToBatch(n,e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;const e=yc.identity().translate(-t._textureBounds.x,-t._textureBounds.y);this._renderer.renderTarget.push(t.texture,!0,null,t.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:e,worldColor:4294967295}),_c(t,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}t._batchableRenderGroup._batcher.updateElement(t._batchableRenderGroup),t._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(t){this._renderer.globalUniforms.push({worldTransformMatrix:t.inverseParentTextureTransform,worldColor:t.worldColorAlpha}),_c(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}function bc(t,e){e||(e=0);for(let i=e;i<t.length&&t[i];i++)t[i]=null}xc.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"renderGroup"};const vc=new xe;function wc(t,e=!1){!function(t){const e=t.root;let i;if(t.renderGroupParent){const n=t.renderGroupParent;t.worldTransform.appendFrom(e.relativeGroupTransform,n.worldTransform),t.worldColor=Jt(e.groupColor,n.worldColor),i=e.groupAlpha*n.worldAlpha}else t.worldTransform.copyFrom(e.localTransform),t.worldColor=e.localColor,i=e.localAlpha;i=i<0?0:i>1?1:i,t.worldAlpha=i,t.worldColorAlpha=t.worldColor+(255*i<<24)}(t);const i=t.childrenToUpdate,n=t.updateTick++;for(const r in i){const e=Number(r),s=i[r],o=s.list,a=s.index;for(let i=0;i<a;i++){const r=o[i];r.parentRenderGroup===t&&r.relativeRenderGroupDepth===e&&Sc(r,n,0)}bc(o,a),s.index=0}if(e)for(let r=0;r<t.renderGroupChildren.length;r++)wc(t.renderGroupChildren[r],e)}function Sc(t,e,i){if(e===t.updateTick)return;t.updateTick=e,t.didChange=!1;const n=t.localTransform;t.updateLocalTransform();const r=t.parent;if(r&&!r.renderGroup?(i|=t._updateFlags,t.relativeGroupTransform.appendFrom(n,r.relativeGroupTransform),7&i&&Ac(t,r,i)):(i=t._updateFlags,t.relativeGroupTransform.copyFrom(n),7&i&&Ac(t,vc,i)),!t.renderGroup){const n=t.children,r=n.length;for(let t=0;t<r;t++)Sc(n[t],e,i);const s=t.parentRenderGroup,o=t;o.renderPipeId&&!s.structureDidChange&&s.updateRenderable(o)}}function Ac(t,e,i){if(1&i){t.groupColor=Jt(t.localColor,e.groupColor);let i=t.localAlpha*e.groupAlpha;i=i<0?0:i>1?1:i,t.groupAlpha=i,t.groupColorAlpha=t.groupColor+(255*i<<24)}2&i&&(t.groupBlendMode="inherit"===t.localBlendMode?e.groupBlendMode:t.localBlendMode),4&i&&(t.globalDisplayStatus=t.localDisplayStatus&e.globalDisplayStatus),t._updateFlags=0}const Tc=new S;class Cc{constructor(t){this._renderer=t}render({container:t,transform:e}){const i=t.parent,n=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;const r=this._renderer;let s=Tc;e&&(s=s.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const o=r.renderPipes;this._updateCachedRenderGroups(t.renderGroup,null),this._updateRenderGroups(t.renderGroup),r.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),_c(t.renderGroup,o),o.uniformBatch&&o.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(s),t.parent=i,t.renderGroup.renderGroupParent=n}destroy(){this._renderer=null}_updateCachedRenderGroups(t,e){var i,n;if(t.isCachedAsTexture){if(!t.updateCacheTexture)return;e=t}t._parentCacheAsTextureRenderGroup=e;for(let r=t.renderGroupChildren.length-1;r>=0;r--)this._updateCachedRenderGroups(t.renderGroupChildren[r],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const e=t.root.getLocalBounds();e.ceil();const r=t.texture;t.texture&&pe.returnTexture(t.texture,!0);const s=this._renderer,o=t.textureOptions.resolution||s.view.resolution,a=null!=(i=t.textureOptions.antialias)?i:s.view.antialias,l=null!=(n=t.textureOptions.scaleMode)?n:"linear",h=pe.getOptimalTexture(e.width,e.height,o,a);h._source.style=new X({scaleMode:l}),t.texture=h,t._textureBounds||(t._textureBounds=new it),t._textureBounds.copyFrom(e),r!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(pe.returnTexture(t.texture,!0),t.texture=null)}_updateRenderGroups(t){const e=this._renderer,i=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=i,t.structureDidChange?bc(t.childrenRenderablesToUpdate.list,0):function(t,e){const{list:i,index:n}=t.childrenRenderablesToUpdate;let r=!1;for(let s=0;s<n;s++){const t=i[s];if(r=e[t.renderPipeId].validateRenderable(t),r)break}t.structureDidChange=r}(t,i),wc(t),t.structureDidChange?(t.structureDidChange=!1,this._buildInstructions(t,e)):this._updateRenderables(t),t.childrenRenderablesToUpdate.index=0,e.renderPipes.batch.upload(t.instructionSet),!t.isCachedAsTexture||t.textureNeedsUpdate)for(let n=0;n<t.renderGroupChildren.length;n++)this._updateRenderGroups(t.renderGroupChildren[n])}_updateRenderables(t){const{list:e,index:i}=t.childrenRenderablesToUpdate;for(let n=0;n<i;n++){const i=e[n];i.didViewUpdate&&t.updateRenderable(i)}bc(e,i)}_buildInstructions(t,e){const i=t.root,n=t.instructionSet;n.reset();const r=e.renderPipes?e:e.batch.renderer,s=r.renderPipes;s.batch.buildStart(n),s.blendMode.buildStart(),s.colorMask.buildStart(),i.sortableChildren&&i.sortChildren(),i.collectRenderablesWithEffects(n,r,null),s.batch.buildEnd(n),s.blendMode.buildEnd(n)}}Cc.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"renderGroup"};class Pc{constructor(t){this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.bounds=t.visualBounds,e.texture=t._texture}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=new mc;return e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.bounds=t.visualBounds,e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Pc.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"sprite"};const Mc=class t{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Ft(0),this.color=this._backgroundColor,this.alpha=1}init(e){e=__spreadValues(__spreadValues({},t.defaultOptions),e),this.clearBeforeRender=e.clearBeforeRender,this.color=e.background||e.backgroundColor||this._backgroundColor,this.alpha=e.backgroundAlpha,this._backgroundColor.setAlpha(e.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){Ft.shared.setValue(t).alpha<1&&1===this._backgroundColor.alpha&&kt("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."),this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};Mc.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"background",priority:0},Mc.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let Ec=Mc;const Rc={};h.handle(o.BlendMode,t=>{if(!t.name)throw new Error("BlendMode extension must have a name property");Rc[t.name]=t.ref},t=>{delete Rc[t.name]});class Fc{constructor(t){this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}setBlendMode(t,e,i){this._activeBlendMode!==e?(this._activeBlendMode=e,this._isAdvanced&&this._endAdvancedBlendMode(i),this._isAdvanced=!!Rc[e],this._isAdvanced&&(this._beginAdvancedBlendMode(i),this._renderableList.push(t))):this._isAdvanced&&this._renderableList.push(t)}_beginAdvancedBlendMode(t){this._renderer.renderPipes.batch.break(t);const e=this._activeBlendMode;if(!Rc[e])return void kt(`Unable to assign BlendMode: '${e}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);let i=this._filterHash[e];i||(i=this._filterHash[e]=new zt,i.filters=[new Rc[e]]);const n={renderPipeId:"filter",action:"pushFilter",renderables:[],filterEffect:i,canBundle:!1};this._renderableList=n.renderables,t.add(n)}_endAdvancedBlendMode(t){this._renderableList=null,this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(t){this._isAdvanced&&this._endAdvancedBlendMode(t)}destroy(){this._renderer=null,this._renderableList=null;for(const t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}}Fc.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"blendMode"};const Bc={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},kc=class t{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof xe||t instanceof J?__spreadValues({target:t},e):__spreadValues(__spreadValues({},e),t)}image(t){return __async(this,null,function*(){const e=Re.get().createImage();return e.src=yield this.base64(t),e})}base64(e){return __async(this,null,function*(){e=this._normalizeOptions(e,t.defaultImageOptions);const{format:i,quality:n}=e,r=this.canvas(e);if(void 0!==r.toBlob)return new Promise((t,e)=>{r.toBlob(i=>{if(!i)return void e(new Error("ICanvas.toBlob failed!"));const n=new FileReader;n.onload=()=>t(n.result),n.onerror=e,n.readAsDataURL(i)},Bc[i],n)});if(void 0!==r.toDataURL)return r.toDataURL(Bc[i],n);if(void 0!==r.convertToBlob){const t=yield r.convertToBlob({type:Bc[i],quality:n});return new Promise((e,i)=>{const n=new FileReader;n.onload=()=>e(n.result),n.onerror=i,n.readAsDataURL(t)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")})}canvas(t){const e=(t=this._normalizeOptions(t)).target,i=this._renderer;if(e instanceof J)return i.texture.generateCanvas(e);const n=i.textureGenerator.generateTexture(t),r=i.texture.generateCanvas(n);return n.destroy(!0),r}pixels(t){const e=(t=this._normalizeOptions(t)).target,i=this._renderer,n=e instanceof J?e:i.textureGenerator.generateTexture(t),r=i.texture.getPixels(n);return e instanceof xe&&n.destroy(!0),r}texture(t){return(t=this._normalizeOptions(t)).target instanceof J?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){var e;t=this._normalizeOptions(t);const i=this.canvas(t),n=document.createElement("a");n.download=null!=(e=t.filename)?e:"image.png",n.href=i.toDataURL("image/png"),document.body.appendChild(n),n.click(),document.body.removeChild(n)}log(t){var e;const i=null!=(e=t.width)?e:200;t=this._normalizeOptions(t);const n=this.canvas(t),r=n.toDataURL();console.log(`[Pixi Texture] ${n.width}px ${n.height}px`);const s=["font-size: 1px;",`padding: ${i}px 300px;`,`background: url(${r}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",s)}destroy(){this._renderer=null}};kc.extension={type:[o.WebGLSystem,o.WebGPUSystem],name:"extract"},kc.defaultImageOptions={format:"png",quality:1};let Ic=kc;class Dc extends J{static create(t){return new Dc({source:new q(t)})}resize(t,e,i){return this.source.resize(t,e,i),this}}const Oc=new D,Uc=new it,Gc=[0,0,0,0];class Lc{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof xe&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const i=t.resolution||this._renderer.resolution,n=t.antialias||this._renderer.view.antialias,r=t.target;let s=t.clearColor;if(s){s=Array.isArray(s)&&4===s.length?s:Ft.shared.setValue(s).toArray()}else s=Gc;const o=(null==(e=t.frame)?void 0:e.copyTo(Oc))||ie(r,Uc).rectangle;o.width=0|Math.max(o.width,1/i),o.height=0|Math.max(o.height,1/i);const a=Dc.create(__spreadProps(__spreadValues({},t.textureSourceOptions),{width:o.width,height:o.height,resolution:i,antialias:n})),l=S.shared.translate(-o.x,-o.y);return this._renderer.render({container:r,transform:l,target:a,clearColor:s}),a.source.updateMipmaps(),a}destroy(){this._renderer=null}}function zc(t,e,i){const n=(t>>24&255)/255;e[i++]=(255&t)/255*n,e[i++]=(t>>8&255)/255*n,e[i++]=(t>>16&255)/255*n,e[i++]=n}Lc.extension={type:[o.WebGLSystem,o.WebGPUSystem],name:"textureGenerator"};class Nc{constructor(t){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=t}reset(){this._stackIndex=0;for(let t=0;t<this._activeUniforms.length;t++)this._uniformsPool.push(this._activeUniforms[t]);for(let t=0;t<this._activeBindGroups.length;t++)this._bindGroupPool.push(this._activeBindGroups[t]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(t){this.reset(),this.push(t)}bind({size:t,projectionMatrix:e,worldTransformMatrix:i,worldColor:n,offset:r}){const s=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{worldTransformMatrix:new S,worldColor:4294967295,offset:new v},a={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||s.size,worldTransformMatrix:i||o.worldTransformMatrix,worldColor:n||o.worldColor,offset:r||o.offset,bindGroup:null},l=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(l);const h=l.uniforms;let c;h.uProjectionMatrix=a.projectionMatrix,h.uResolution=a.resolution,h.uWorldTransformMatrix.copyFrom(a.worldTransformMatrix),h.uWorldTransformMatrix.tx-=a.offset.x,h.uWorldTransformMatrix.ty-=a.offset.y,zc(a.worldColor,h.uWorldColorAlpha,0),l.update(),this._renderer.renderPipes.uniformBatch?c=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(l,!1):(c=this._bindGroupPool.pop()||new Qi,this._activeBindGroups.push(c),c.setResource(l,0)),a.bindGroup=c,this._currentGlobalUniformData=a}push(t){this.bind(t),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===Ji.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new $i({uProjectionMatrix:{value:new S,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new S,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null}}Nc.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"globalUniforms"};let Vc=1;class Hc{constructor(){this._tasks=[],this._offset=0}init(){Ue.system.add(this._update,this)}repeat(t,e,i=!0){const n=Vc++;let r=0;return i&&(this._offset+=1e3,r=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:r,last:performance.now(),repeat:!0,id:n}),n}cancel(t){for(let e=0;e<this._tasks.length;e++)if(this._tasks[e].id===t)return void this._tasks.splice(e,1)}_update(){const t=performance.now();for(let e=0;e<this._tasks.length;e++){const i=this._tasks[e];if(t-i.offset-i.last>=i.duration){const e=t-i.start;i.func(e),i.last=t}}}destroy(){Ue.system.remove(this._update,this),this._tasks.length=0}}Hc.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"scheduler",priority:0};let Wc=!1;class jc{constructor(t){this._renderer=t}init(t){if(t.hello){let t=this._renderer.name;this._renderer.type===Ji.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),function(t){if(!Wc){if(Re.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${Xn} (${t}) http://www.pixijs.com/\n\n`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...e)}else globalThis.console&&globalThis.console.log(`PixiJS ${Xn} - ${t} - http://www.pixijs.com/`);Wc=!0}}(t)}}}function Yc(t){let e=!1;for(const n in t)if(null==t[n]){e=!0;break}if(!e)return t;const i=Object.create(null);for(const n in t){const e=t[n];e&&(i[n]=e)}return i}function Xc(t){let e=0;for(let i=0;i<t.length;i++)null==t[i]?e++:t[i-e]=t[i];return t.length-=e,t}jc.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"hello",priority:-2},jc.defaultOptions={hello:!1};let Zc=0;const qc=class t{constructor(t){this._managedRenderables=[],this._managedHashes=[],this._managedArrays=[],this._renderer=t}init(e){e=__spreadValues(__spreadValues({},t.defaultOptions),e),this.maxUnusedTime=e.renderableGCMaxUnusedTime,this._frequency=e.renderableGCFrequency,this.enabled=e.renderableGCActive}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>this.run(),this._frequency,!1),this._hashHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedHashes)t.context[t.hash]=Yc(t.context[t.hash])},this._frequency),this._arrayHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedArrays)Xc(t.context[t.hash])},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._hashHandler),this._renderer.scheduler.cancel(this._arrayHandler)))}addManagedHash(t,e){this._managedHashes.push({context:t,hash:e})}addManagedArray(t,e){this._managedArrays.push({context:t,hash:e})}prerender({container:t}){this._now=performance.now(),t.renderGroup.gcTick=Zc++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}addRenderable(t){this.enabled&&(-1===t._lastUsed&&(this._managedRenderables.push(t),t.once("destroyed",this._removeRenderable,this)),t._lastUsed=this._now)}run(){var t,e,i,n;const r=this._now,s=this._managedRenderables,o=this._renderer.renderPipes;let a=0;for(let l=0;l<s.length;l++){const h=s[l];if(null===h){a++;continue}const c=null!=(t=h.renderGroup)?t:h.parentRenderGroup,u=null!=(i=null==(e=null==c?void 0:c.instructionSet)?void 0:e.gcTick)?i:-1;if((null!=(n=null==c?void 0:c.gcTick)?n:0)===u&&(h._lastUsed=r),r-h._lastUsed>this.maxUnusedTime){if(!h.destroyed){const t=o;c&&(c.structureDidChange=!0),t[h.renderPipeId].destroyRenderable(h)}h._lastUsed=-1,a++,h.off("destroyed",this._removeRenderable,this)}else s[l-a]=h}s.length-=a}destroy(){this.enabled=!1,this._renderer=null,this._managedRenderables.length=0,this._managedHashes.length=0,this._managedArrays.length=0}_removeRenderable(t){const e=this._managedRenderables.indexOf(t);e>=0&&(t.off("destroyed",this._removeRenderable,this),this._managedRenderables[e]=null)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e;for(const i of t.renderGroupChildren)this._updateInstructionGCTick(i,e)}};qc.extension={type:[o.WebGLSystem,o.WebGPUSystem],name:"renderableGC",priority:0},qc.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let Kc=qc;const $c=class t{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(e){var i;e=__spreadValues(__spreadValues({},t.defaultOptions),e),this.checkCountMax=e.textureGCCheckCountMax,this.maxIdle=null!=(i=e.textureGCAMaxIdle)?i:e.textureGCMaxIdle,this.active=e.textureGCActive}postrender(){this._renderer.renderingToScreen&&(this.count++,this.active&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this._renderer.texture.managedTextures;for(let e=0;e<t.length;e++){const i=t[e];i.autoGarbageCollect&&i.resource&&i._touched>-1&&this.count-i._touched>this.maxIdle&&(i._touched=-1,i.unload())}}destroy(){this._renderer=null}};$c.extension={type:[o.WebGLSystem,o.WebGPUSystem],name:"textureGC"},$c.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Qc=$c;const Jc=class t{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(t){this.texture.source.autoDensity=t}get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}init(e){(e=__spreadValues(__spreadValues({},t.defaultOptions),e)).view&&(z(L,"ViewSystem.view has been renamed to ViewSystem.canvas"),e.canvas=e.view),this.screen=new D(0,0,e.width,e.height),this.canvas=e.canvas||Re.get().createCanvas(),this.antialias=!!e.antialias,this.texture=Fh(this.canvas,e),this.renderTarget=new kh({colorTextures:[this.texture],depth:!!e.depth,isRoot:!0}),this.texture.source.transparent=e.backgroundAlpha<1,this.resolution=e.resolution}resize(t,e,i){this.texture.source.resize(t,e,i),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){("boolean"==typeof t?t:!!(null==t?void 0:t.removeView))&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}};Jc.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"view",priority:0},Jc.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};const tu=[Ec,Nc,jc,Jc,Cc,Qc,Lc,Ic,qn,Kc,Hc],eu=[Fc,Ll,Pc,xc,Xl,ql,Zl,gc],iu=[...tu,Mh,uh,th,fh,Ql,dc,Dh,lh,Qh,qh,ph,tc,_h,dh],nu=[...eu],ru=[Dl,fc,pc],su=[],ou=[],au=[];h.handleByNamedList(o.WebGLSystem,su),h.handleByNamedList(o.WebGLPipes,ou),h.handleByNamedList(o.WebGLPipesAdaptor,au),h.add(...iu,...nu,...ru);const lu=Object.freeze(Object.defineProperty({__proto__:null,WebGLRenderer:class extends Hn{constructor(){super({name:"webgl",type:Ji.WEBGL,systems:su,renderPipes:ou,renderPipeAdaptors:au})}}},Symbol.toStringTag,{value:"Module"}));class hu{constructor(t){this._hash=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_hash")}contextChange(t){this._gpu=t}getBindGroup(t,e,i){t._updateKey();return this._hash[t._key]||this._createBindGroup(t,e,i)}_createBindGroup(t,e,i){var n;const r=this._gpu.device,s=e.layout[i],o=[],a=this._renderer;for(const c in s){const e=null!=(n=t.resources[c])?n:t.resources[s[c]];let i;if("uniformGroup"===e._resourceType){const t=e;a.ubo.updateUniformGroup(t);const n=t.buffer;i={buffer:a.buffer.getGPUBuffer(n),offset:0,size:n.descriptor.size}}else if("buffer"===e._resourceType){const t=e;i={buffer:a.buffer.getGPUBuffer(t),offset:0,size:t.descriptor.size}}else if("bufferResource"===e._resourceType){const t=e;i={buffer:a.buffer.getGPUBuffer(t.buffer),offset:t.offset,size:t.size}}else if("textureSampler"===e._resourceType){const t=e;i=a.texture.getGpuSampler(t)}else if("textureSource"===e._resourceType){const t=e;i=a.texture.getGpuSource(t).createView({})}o.push({binding:s[c],resource:i})}const l=a.shader.getProgramData(e).bindGroups[i],h=r.createBindGroup({layout:l,entries:o});return this._hash[t._key]=h,h}destroy(){for(const t of Object.keys(this._hash))this._hash[t]=null;this._hash=null,this._renderer=null}}hu.extension={type:[o.WebGPUSystem],name:"bindGroup"};class cu{constructor(t){this._gpuBuffers=Object.create(null),this._managedBuffers=[],t.renderableGC.addManagedHash(this,"_gpuBuffers")}contextChange(t){this._gpu=t}getGPUBuffer(t){return this._gpuBuffers[t.uid]||this.createGPUBuffer(t)}updateBuffer(t){const e=this._gpuBuffers[t.uid]||this.createGPUBuffer(t),i=t.data;return t._updateID&&i&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,i.buffer,0,(t._updateSize||i.byteLength)+3&-4)),e}destroyAll(){for(const t in this._gpuBuffers)this._gpuBuffers[t].destroy();this._gpuBuffers={}}createGPUBuffer(t){this._gpuBuffers[t.uid]||(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this),t.on("destroy",this.onBufferDestroy,this),this._managedBuffers.push(t));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(Tr(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e,e}onBufferChange(t){this._gpuBuffers[t.uid].destroy(),t._updateID=0,this._gpuBuffers[t.uid]=this.createGPUBuffer(t)}onBufferDestroy(t){this._managedBuffers.splice(this._managedBuffers.indexOf(t),1),this._destroyBuffer(t)}destroy(){this._managedBuffers.forEach(t=>this._destroyBuffer(t)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(t){this._gpuBuffers[t.uid].destroy(),t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this),t.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[t.uid]=null}}cu.extension={type:[o.WebGPUSystem],name:"buffer"};class uu{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error("UniformBufferBatch: array is too large: "+4*t);const e=this.byteIndex;let i=e+4*t;if(i=Math.ceil(i/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,i>4*this.data.length)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=i,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let i=0;i<t.length;i++)this.data[e/4+i]=t[i];return e}destroy(){this.data=null}}class du{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.pipeline.setColorMask(t))}destroy(){this._renderer=null,this._colorMaskCache=null}}du.extension={type:[o.WebGPUSystem],name:"colorMask"};class pu{constructor(t){this._renderer=t}init(t){return __async(this,null,function*(){return this._initPromise||(this._initPromise=(t.gpu?Promise.resolve(t.gpu):this._createDeviceAndAdaptor(t)).then(t=>{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)})),this._initPromise})}contextChange(t){this._renderer.gpu=t}_createDeviceAndAdaptor(t){return __async(this,null,function*(){const e=yield Re.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),i=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(t=>e.features.has(t)),n=yield e.requestDevice({requiredFeatures:i});return{adapter:e,device:n}})}destroy(){this.gpu=null,this._renderer=null}}pu.extension={type:[o.WebGPUSystem],name:"device"},pu.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class fu{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(t.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(t){this.renderPassEncoder.setViewport(t.x,t.y,t.width,t.height,0,1)}setPipelineFromGeometryProgramAndState(t,e,i,n){const r=this._renderer.pipeline.getPipeline(t,e,i,n);this.setPipeline(r)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=2===t.data.BYTES_PER_ELEMENT?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,i){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.textureGC.count);const n=this._renderer.bindGroup.getBindGroup(e,i,t);this.renderPassEncoder.setBindGroup(t,n)}setGeometry(t,e){const i=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const n in i)this._setVertexBuffer(n,t.attributes[i[n]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const i in t.groups){const n=t.groups[i];e||this._syncBindGroup(n),this.setBindGroup(i,n,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const i=t.resources[e];i.isUniformGroup&&this._renderer.ubo.updateUniformGroup(i)}}draw(t){const{geometry:e,shader:i,state:n,topology:r,size:s,start:o,instanceCount:a,skipSync:l}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,n,r),this.setGeometry(e,i.gpuProgram),this._setShaderBindGroups(i,l),e.indexBuffer?this.renderPassEncoder.drawIndexed(s||e.indexBuffer.data.length,null!=a?a:e.instanceCount,o||0):this.renderPassEncoder.draw(s||e.getSize(),null!=a?a:e.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,i=__spreadValues({},this._boundVertexBuffer),n=this._boundIndexBuffer,r=__spreadValues({},this._boundBindGroup);this._clearCache();const s=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(s.x,s.y,s.width,s.height,0,1),this.setPipeline(e);for(const o in i)this._setVertexBuffer(o,i[o]);for(const o in r)this.setBindGroup(o,r[o],null);this._setIndexBuffer(n)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}}fu.extension={type:[o.WebGPUSystem],name:"encoder",priority:1};class gu{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}gu.extension={type:[o.WebGPUSystem],name:"limits"};class mu{constructor(t){this._renderTargetStencilState=Object.create(null),this._renderer=t,t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:Pr.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid];i.stencilMode=t,i.stencilReference=e;const n=this._renderer;n.pipeline.setStencilMode(t),n.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}mu.extension={type:[o.WebGPUSystem],name:"stencil"};const _u={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function yu(t){const e=t.map(t=>({data:t,offset:0,size:0}));let i=0;for(let n=0;n<e.length;n++){const t=e[n];let r=_u[t.data.type].size;const s=_u[t.data.type].align;if(!_u[t.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${t.data.type}`);t.data.size>1&&(r=Math.max(r,s)*t.data.size),i=Math.ceil(i/s)*s,t.size=r,t.offset=i,i+=r}return i=16*Math.ceil(i/16),{uboElements:e,size:i}}function xu(t,e){const{size:i,align:n}=_u[t.data.type],r=(n-i)/4,s=t.data.type.indexOf("i32")>=0?"dataInt32":"data";return`\n v = uv.${t.data.name};\n ${0!==e?`offset += ${e};`:""}\n\n arrayOffset = offset;\n\n t = 0;\n\n for(var i=0; i < ${t.data.size*(i/4)}; i++)\n {\n for(var j = 0; j < ${i/4}; j++)\n {\n ${s}[arrayOffset++] = v[t++];\n }\n ${0!==r?`arrayOffset += ${r};`:""}\n }\n `}function bu(t){return wh(t,"uboWgsl",xu,Th)}class vu extends yh{constructor(){super({createUboElements:yu,generateUboSync:bu})}}vu.extension={type:[o.WebGPUSystem],name:"ubo"};const wu=128;class Su{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_bindGroupHash"),this._batchBuffer=new uu({minUniformOffsetAlignment:wu});for(let e=0;e<2;e++){let t=Vr.UNIFORM|Vr.COPY_DST;0===e&&(t|=Vr.COPY_SRC),this._buffers.push(new Hr({data:this._batchBuffer.data,usage:t}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){for(const t in this._bindGroupHash)this._bindGroupHash[t]=null;this._batchBuffer.clear()}getUniformBindGroup(t,e){if(!e&&this._bindGroupHash[t.uid])return this._bindGroupHash[t.uid];this._renderer.ubo.ensureUniformGroup(t);const i=t.buffer.data,n=this._batchBuffer.addEmptyGroup(i.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,n/4),this._bindGroupHash[t.uid]=this._getBindGroup(n/wu),this._bindGroupHash[t.uid]}getUboResource(t){this._renderer.ubo.updateUniformGroup(t);const e=t.buffer.data,i=this._batchBuffer.addGroup(e);return this._getBufferResource(i/wu)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/wu)}getArrayBufferResource(t){const e=this._batchBuffer.addGroup(t)/wu;return this._getBufferResource(e)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new Oh({buffer:e,offset:256*(t/2|0),size:wu})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new Qi({0:this._getBufferResource(t)});this._bindGroups[t]=e}return this._bindGroups[t]}_uploadBindGroups(){const t=this._renderer.buffer,e=this._buffers[0];e.update(this._batchBuffer.byteIndex),t.updateBuffer(e);const i=this._renderer.gpu.device.createCommandEncoder();for(let n=1;n<this._buffers.length;n++){const r=this._buffers[n];i.copyBufferToBuffer(t.getGPUBuffer(e),wu,t.getGPUBuffer(r),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([i.finish()])}destroy(){for(let t=0;t<this._bindGroups.length;t++)this._bindGroups[t].destroy();this._bindGroups=null,this._bindGroupHash=null;for(let t=0;t<this._buffers.length;t++)this._buffers[t].destroy();this._buffers=null;for(let t=0;t<this._bufferResources.length;t++)this._bufferResources[t].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._bindGroupHash=null,this._renderer=null}}Su.extension={type:[o.WebGPUPipes],name:"uniformBatch"};const Au={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};class Tu{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(Pr.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=mh[t],this._updatePipeHash())}setPipeline(t,e,i,n){const r=this.getPipeline(t,e,i);n.setPipeline(r)}getPipeline(t,e,i,n){t._layoutKey||(eh(t,e.attributeData),this._generateBufferKey(t)),n||(n=t.topology);const r=function(t,e,i,n,r){return t<<24|e<<16|i<<10|n<<5|r}(t._layoutKey,e._layoutKey,i.data,i._blendModeId,Au[n]);return this._pipeCache[r]||(this._pipeCache[r]=this._createPipeline(t,e,i,n)),this._pipeCache[r]}_createPipeline(t,e,i,n){const r=this._gpu.device,s=this._createVertexBufferLayouts(t,e),o=this._renderer.state.getColorTargets(i);o[0].writeMask=this._stencilMode===Pr.RENDERING_MASK_ADD?0:this._colorMask;const a=this._renderer.shader.getProgramData(e).pipeline,l={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:s},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:o},primitive:{topology:n,cullMode:i.cullMode},layout:a,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};this._depthStencilAttachment&&(l.depthStencil=__spreadProps(__spreadValues({},this._stencilState),{format:"depth24plus-stencil8",depthWriteEnabled:i.depthTest,depthCompare:i.depthTest?"less":"always"}));return r.createRenderPipeline(l)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){const e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){const e=[];let i=0;const n=Object.keys(t.attributes).sort();for(let s=0;s<n.length;s++){const r=t.attributes[n[s]];e[i++]=r.offset,e[i++]=r.format,e[i++]=r.stride,e[i++]=r.instance}const r=e.join("|");return t._layoutKey=Ei(r,"geometry"),t._layoutKey}_generateAttributeLocationsKey(t){const e=[];let i=0;const n=Object.keys(t.attributeData).sort();for(let s=0;s<n.length;s++){const r=t.attributeData[n[s]];e[i++]=r.location}const r=e.join("|");return t._attributeLocationsKey=Ei(r,"programAttributes"),t._attributeLocationsKey}getBufferNamesToBind(t,e){const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bindingNamesCache[i])return this._bindingNamesCache[i];const n=this._createVertexBufferLayouts(t,e),r=Object.create(null),s=e.attributeData;for(let o=0;o<n.length;o++){const t=Object.values(n[o].attributes)[0].shaderLocation;for(const e in s)if(s[e].location===t){r[o]=e;break}}return this._bindingNamesCache[i]=r,r}_createVertexBufferLayouts(t,e){e._attributeLocationsKey||this._generateAttributeLocationsKey(e);const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bufferLayoutsCache[i])return this._bufferLayoutsCache[i];const n=[];return t.buffers.forEach(i=>{var r;const s={arrayStride:0,stepMode:"vertex",attributes:[]},o=s.attributes;for(const n in e.attributeData){const a=t.attributes[n];1!==(null!=(r=a.divisor)?r:1)&&kt(`Attribute ${n} has an invalid divisor value of '${a.divisor}'. WebGPU only supports a divisor value of 1`),a.buffer===i&&(s.arrayStride=a.stride,s.stepMode=a.instance?"instance":"vertex",o.push({shaderLocation:e.attributeData[n].location,offset:a.offset,format:a.format}))}o.length&&n.push(s)}),this._bufferLayoutsCache[i]=n,n}_updatePipeHash(){const t=(e=this._stencilMode,i=this._multisampleCount,n=this._colorMask,r=this._depthStencilAttachment,n<<6|e<<3|r<<1|i);var e,i,n,r;this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}Tu.extension={type:[o.WebGPUSystem],name:"pipeline"};class Cu{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class Pu{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,n,r){const s=this._renderer,o=this._getGpuColorTexture(t),a=s.texture.getGpuSource(e.source);return s.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:i},{texture:a,origin:r},n),e}startRenderPass(t,e=!0,i,n){const r=this._renderTargetSystem.getGpuRenderTarget(t),s=this.getDescriptor(t,e,i);r.descriptor=s,this._renderer.pipeline.setRenderTarget(r),this._renderer.encoder.beginRenderPass(r),this._renderer.encoder.setViewport(n)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,i){"boolean"==typeof e&&(e=e?Un.ALL:Un.NONE);const n=this._renderTargetSystem,r=n.getGpuRenderTarget(t),s=t.colorTextures.map((t,s)=>{const o=r.contexts[s];let a,l;if(o){a=o.getCurrentTexture().createView()}else a=this._renderer.texture.getGpuSource(t).createView({mipLevelCount:1});r.msaaTextures[s]&&(l=a,a=this._renderer.texture.getTextureView(r.msaaTextures[s]));const h=e&Un.COLOR?"clear":"load";return null!=i||(i=n.defaultClearColor),{view:a,resolveTarget:l,clearValue:i,storeOp:"store",loadOp:h}});let o;if(!t.stencil&&!t.depth||t.depthStencilTexture||(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=r.msaa?4:1),t.depthStencilTexture){const i=e&Un.STENCIL?"clear":"load",n=e&Un.DEPTH?"clear":"load";o={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:i,depthClearValue:1,depthLoadOp:n,depthStoreOp:"store"}}return{colorAttachments:s,depthStencilAttachment:o}}clear(t,e=!0,i,n){if(!e)return;const{gpu:r,encoder:s}=this._renderer,o=r.device;if(null===s.commandEncoder){const r=o.createCommandEncoder(),s=this.getDescriptor(t,e,i),a=r.beginRenderPass(s);a.setViewport(n.x,n.y,n.width,n.height,0,1),a.end();const l=r.finish();o.queue.submit([l])}else this.startRenderPass(t,e,i,n)}initGpuRenderTarget(t){t.isRoot=!0;const e=new Cu;return t.colorTextures.forEach((t,i)=>{if(t instanceof Fe){const r=t.resource.getContext("webgpu"),s=t.transparent?"premultiplied":"opaque";try{r.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:s})}catch(n){console.error(n)}e.contexts[i]=r}if(e.msaa=t.source.antialias,t.source.antialias){const t=new q({width:0,height:0,sampleCount:4});e.msaaTextures[i]=t}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(t=>{t.unconfigure()}),t.msaaTextures.forEach(t=>{t.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((t,i)=>{const n=e.msaaTextures[i];null==n||n.resize(t.source.width,t.source.height,t.source._resolution)})}}class Mu extends Ih{constructor(t){super(t),this.adaptor=new Pu,this.adaptor.init(t,this)}}Mu.extension={type:[o.WebGPUSystem],name:"renderTarget"};class Eu{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,i=t.gpuLayout.map(t=>e.createBindGroupLayout({entries:t})),n={bindGroupLayouts:i};return this._gpuProgramData[t._layoutKey]={bindGroups:i,pipeline:e.createPipelineLayout(n)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}Eu.extension={type:[o.WebGPUSystem],name:"shader"};const Ru={normal:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},add:{alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},multiply:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},screen:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},overlay:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},none:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},"normal-npm":{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},"add-npm":{alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},"screen-npm":{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},erase:{alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},min:{alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},max:{alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}}};class Fu{constructor(){this.defaultState=new rn,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:Ru[t.blendMode]||Ru.normal}]}destroy(){this.gpu=null}}Fu.extension={type:[o.WebGPUSystem],name:"state"};const Bu={type:"image",upload(t,e,i){const n=t.resource,r=(0|t.pixelWidth)*(0|t.pixelHeight),s=n.byteLength/r;i.device.queue.writeTexture({texture:e},n,{offset:0,rowsPerImage:t.pixelHeight,bytesPerRow:t.pixelHeight*s},{width:t.pixelWidth,height:t.pixelHeight,depthOrArrayLayers:1})}},ku={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},Iu={blockBytes:4,blockWidth:1,blockHeight:1},Du={type:"compressed",upload(t,e,i){let n=t.pixelWidth,r=t.pixelHeight;const s=ku[t.format]||Iu;for(let o=0;o<t.resource.length;o++){const a=t.resource[o],l=Math.ceil(n/s.blockWidth)*s.blockBytes;i.device.queue.writeTexture({texture:e,mipLevel:o},a,{offset:0,bytesPerRow:l},{width:Math.ceil(n/s.blockWidth)*s.blockWidth,height:Math.ceil(r/s.blockHeight)*s.blockHeight,depthOrArrayLayers:1}),n=Math.max(n>>1,1),r=Math.max(r>>1,1)}}},Ou={type:"image",upload(t,e,i){const n=t.resource;if(!n)return;if(globalThis.HTMLImageElement&&n instanceof HTMLImageElement){const e=Re.get().createCanvas(n.width,n.height);e.getContext("2d").drawImage(n,0,0,n.width,n.height),t.resource=e,kt("ImageSource: Image element passed, converting to canvas and replacing resource.")}const r=Math.min(e.width,t.resourceWidth||t.pixelWidth),s=Math.min(e.height,t.resourceHeight||t.pixelHeight),o="premultiply-alpha-on-upload"===t.alphaMode;i.device.queue.copyExternalImageToTexture({source:n},{texture:e,premultipliedAlpha:o},{width:r,height:s})}},Uu={type:"video",upload(t,e,i){Ou.upload(t,e,i)}};class Gu{constructor(t){this.device=t,this.sampler=t.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(t){let e=this.pipelines[t];return e||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:"\n var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(\n vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));\n\n struct VertexOutput {\n @builtin(position) position : vec4<f32>,\n @location(0) texCoord : vec2<f32>,\n };\n\n @vertex\n fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {\n var output : VertexOutput;\n output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);\n output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);\n return output;\n }\n\n @group(0) @binding(0) var imgSampler : sampler;\n @group(0) @binding(1) var img : texture_2d<f32>;\n\n @fragment\n fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {\n return textureSample(img, imgSampler, texCoord);\n }\n "})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){const e=this._getMipmapPipeline(t.format);if("3d"===t.dimension||"1d"===t.dimension)throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let i=t;const n=t.depthOrArrayLayers||1,r=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!r){const e={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:n},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};i=this.device.createTexture(e)}const s=this.device.createCommandEncoder({}),o=e.getBindGroupLayout(0);for(let a=0;a<n;++a){let n=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:a,arrayLayerCount:1}),l=r?1:0;for(let r=1;r<t.mipLevelCount;++r){const t=i.createView({baseMipLevel:l++,mipLevelCount:1,dimension:"2d",baseArrayLayer:a,arrayLayerCount:1}),r=s.beginRenderPass({colorAttachments:[{view:t,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),h=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.sampler},{binding:1,resource:n}]});r.setPipeline(e),r.setBindGroup(0,h),r.draw(3,1,0,0),r.end(),n=t}}if(!r){const e={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:n};for(let n=1;n<t.mipLevelCount;++n)s.copyTextureToTexture({texture:i,mipLevel:n-1},{texture:t,mipLevel:n},e),e.width=Math.ceil(e.width/2),e.height=Math.ceil(e.height/2)}return this.device.queue.submit([s.finish()]),r||i.destroy(),t}}class Lu{constructor(t){this.managedTextures=[],this._gpuSources=Object.create(null),this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._textureViewHash=Object.create(null),this._uploads={image:Ou,buffer:Bu,video:Uu,compressed:Du},this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuSources"),t.renderableGC.addManagedHash(this,"_gpuSamplers"),t.renderableGC.addManagedHash(this,"_bindGroupHash"),t.renderableGC.addManagedHash(this,"_textureViewHash")}contextChange(t){this._gpu=t}initSource(t){return this._gpuSources[t.uid]?this._gpuSources[t.uid]:this._initSource(t)}_initSource(t){if(t.autoGenerateMipmaps){const e=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(e))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;"compressed"!==t.uploadMethodId&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const i=ku[t.format]||{blockWidth:1,blockHeight:1},n=Math.ceil(t.pixelWidth/i.blockWidth)*i.blockWidth,r=Math.ceil(t.pixelHeight/i.blockHeight)*i.blockHeight,s={label:t.label,size:{width:n,height:r},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},o=this._gpuSources[t.uid]=this._gpu.device.createTexture(s);return this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),o}onSourceUpdate(t){const e=this.getGpuSource(t);e&&(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t))}onSourceUnload(t){const e=this._gpuSources[t.uid];e&&(this._gpuSources[t.uid]=null,e.destroy())}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new Gu(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceDestroy(t){t.off("update",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("destroy",this.onSourceDestroy,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}onSourceResize(t){const e=this._gpuSources[t.uid];e?e.width===t.pixelWidth&&e.height===t.pixelHeight||(this._textureViewHash[t.uid]=null,this._bindGroupHash[t.uid]=null,this.onSourceUnload(t),this.initSource(t)):this.initSource(t)}_initSampler(t){return this._gpuSamplers[t._resourceId]=this._gpu.device.createSampler(t),this._gpuSamplers[t._resourceId]}getGpuSampler(t){return this._gpuSamplers[t._resourceId]||this._initSampler(t)}getGpuSource(t){return this._gpuSources[t.uid]||this.initSource(t)}getTextureBindGroup(t){var e;return null!=(e=this._bindGroupHash[t.uid])?e:this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source;return this._bindGroupHash[t.uid]=new Qi({0:e,1:e.style,2:new $i({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){var e;const i=t.source;return null!=(e=this._textureViewHash[i.uid])?e:this._createTextureView(i)}_createTextureView(t){return this._textureViewHash[t.uid]=this.getGpuSource(t).createView(),this._textureViewHash[t.uid]}generateCanvas(t){const e=this._renderer,i=e.gpu.device.createCommandEncoder(),n=Re.get().createCanvas();n.width=t.source.pixelWidth,n.height=t.source.pixelHeight;const r=n.getContext("webgpu");return r.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:Re.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:r.getCurrentTexture()},{width:n.width,height:n.height}),e.gpu.device.queue.submit([i.finish()]),n}getPixels(t){const e=this.generateCanvas(t),i=No.getOptimalCanvasAndContext(e.width,e.height),n=i.context;n.drawImage(e,0,0);const{width:r,height:s}=e,o=n.getImageData(0,0,r,s),a=new Uint8ClampedArray(o.data.buffer);return No.returnCanvasAndContext(i),{pixels:a,width:r,height:s}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null;for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),i=this._bindGroupHash[e];null==i||i.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}Lu.extension={type:[o.WebGPUSystem],name:"texture"};class zu{constructor(){this._maxTextures=0}contextChange(t){const e=new $i({uTransformMatrix:{value:new S,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;const i=cs({name:"graphics",bits:[ds,_s(this._maxTextures),Nl,vs]});this.shader=new tn({gpuProgram:i,resources:{localUniforms:e}})}execute(t,e){const i=e.context,n=i.customShader||this.shader,r=t.renderer,s=r.graphicsContext,{batcher:o,instructions:a}=s.getContextRenderData(i),l=r.encoder;l.setGeometry(o.geometry,n.gpuProgram);const h=r.globalUniforms.bindGroup;l.setBindGroup(0,h,n.gpuProgram);const c=r.renderPipes.uniformBatch.getUniformBindGroup(n.resources.localUniforms,!0);l.setBindGroup(2,c,n.gpuProgram);const u=a.instructions;let d=null;for(let p=0;p<a.instructionSize;p++){const e=u[p];if(e.topology!==d&&(d=e.topology,l.setPipelineFromGeometryProgramAndState(o.geometry,n.gpuProgram,t.state,e.topology)),n.groups[1]=e.bindGroup,!e.gpuBindGroup){const t=e.textures;e.bindGroup=Sr(t.textures,t.count,this._maxTextures),e.gpuBindGroup=r.bindGroup.getBindGroup(e.bindGroup,n.gpuProgram,1)}l.setBindGroup(1,e.bindGroup,n.gpuProgram),l.renderPassEncoder.drawIndexed(e.size,1,e.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}zu.extension={type:[o.WebGPUPipesAdaptor],name:"graphics"};class Nu{init(){const t=cs({name:"mesh",bits:[zl,Hl,vs]});this._shader=new tn({gpuProgram:t,resources:{uTexture:J.EMPTY._source,uSampler:J.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new S}}}})}execute(t,e){const i=t.renderer;let n=e._shader;if(n){if(!n.gpuProgram)return void kt("Mesh shader has no gpuProgram",e.shader)}else n=this._shader,n.groups[2]=i.texture.getTextureBindGroup(e.texture);const r=n.gpuProgram;if(r.autoAssignGlobalUniforms&&(n.groups[0]=i.globalUniforms.bindGroup),r.autoAssignLocalUniforms){const e=t.localUniforms;n.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(e,!0)}i.encoder.draw({geometry:e._geometry,shader:n,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Nu.extension={type:[o.WebGPUPipesAdaptor],name:"mesh"};const Vu=[...tu,vu,fu,pu,gu,cu,Lu,Mu,Eu,Fu,Tu,du,mu,hu],Hu=[...eu,Su],Wu=[Ul,Nu,zu],ju=[],Yu=[],Xu=[];h.handleByNamedList(o.WebGPUSystem,ju),h.handleByNamedList(o.WebGPUPipes,Yu),h.handleByNamedList(o.WebGPUPipesAdaptor,Xu),h.add(...Vu,...Hu,...Wu);const Zu=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:class extends Hn{constructor(){super({name:"webgpu",type:Ji.WEBGPU,systems:ju,renderPipes:Yu,renderPipeAdaptors:Xu})}}},Symbol.toStringTag,{value:"Module"}));class qu{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{Dt.return(t)}),this.batches.length=0}}class Ku{constructor(t,e){this.state=rn.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this)}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,i=!!t._gpuData,n=this.renderer.graphicsContext.updateGpuContext(e);return!(!n.isBatchable&&i===n.isBatchable)}addRenderable(t,e){const i=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),i.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._getGpuDataForRenderable(t).batches;for(let i=0;i<e.length;i++){const t=e[i];t._batcher.updateElement(t)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,i=t.context;if(!e.graphicsContext.getGpuContext(i).batches.length)return;const n=i.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const r=n.resources.localUniforms.uniforms;r.uTransformMatrix=t.groupTransform,r.uRound=e._roundPixels|t._roundPixels,zc(t.groupColorAlpha,r.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),i=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),i.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const i=this.renderer.renderPipes.batch,n=this._getGpuDataForRenderable(t).batches;for(let r=0;r<n.length;r++){const t=n[r];i.addToBatch(t,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new qu;return t._gpuData[this.renderer.uid]=e,e}_updateBatchesForRenderable(t,e){const i=t.context,n=this.renderer.graphicsContext.getGpuContext(i),r=this.renderer._roundPixels|t._roundPixels;e.batches=n.batches.map(e=>{const i=Dt.get(Fs);return e.copyTo(i),i.renderable=t,i.roundPixels=r,i})}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}Ku.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"graphics"};const $u=class t extends ml{constructor(...t){var e;super({});let i=null!=(e=t[0])?e:{};"number"==typeof i&&(z(L,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),i={width:i,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(i)}build(e){var i,n,r,s;e=__spreadValues(__spreadValues({},t.defaultOptions),e),this.verticesX=null!=(i=this.verticesX)?i:e.verticesX,this.verticesY=null!=(n=this.verticesY)?n:e.verticesY,this.width=null!=(r=this.width)?r:e.width,this.height=null!=(s=this.height)?s:e.height;const o=this.verticesX*this.verticesY,a=[],l=[],h=[],c=this.verticesX-1,u=this.verticesY-1,d=this.width/c,p=this.height/u;for(let t=0;t<o;t++){const e=t%this.verticesX,i=t/this.verticesX|0;a.push(e*d,i*p),l.push(e/c,i/u)}const f=c*u;for(let t=0;t<f;t++){const e=t%c,i=t/c|0,n=i*this.verticesX+e,r=i*this.verticesX+e+1,s=(i+1)*this.verticesX+e,o=(i+1)*this.verticesX+e+1;h.push(n,r,s,r,o,s)}this.buffers[0].data=new Float32Array(a),this.buffers[1].data=new Float32Array(l),this.indexBuffer.data=new Uint32Array(h),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};$u.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let Qu=$u;class Ju{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(t){this._topology=t}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(t){this.texture!==t&&(this.texture=t,this._textureMatrixUpdateId=-1)}get uvs(){const t=this.geometry.getBuffer("aUV"),e=t.data;let i=e;const n=this.texture.textureMatrix;return n.isSimple||(i=this._transformedUvs,this._textureMatrixUpdateId===n._updateID&&this._uvUpdateId===t._updateID||((!i||i.length<e.length)&&(i=this._transformedUvs=new Float32Array(e.length)),this._textureMatrixUpdateId=n._updateID,this._uvUpdateId=t._updateID,n.multiplyUvs(e,i))),i}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 td{destroy(){}}class ed{constructor(t,e){this.localUniforms=new $i({uTransformMatrix:{value:new S,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Qi({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),i=e.batched,n=t.batched;if(e.batched=n,i!==n)return!0;if(n){const i=t._geometry;if(i.indices.length!==e.indexSize||i.positions.length!==e.vertexSize)return e.indexSize=i.indices.length,e.vertexSize=i.positions.length,!0;const n=this._getBatchableMesh(t);return n.texture.uid!==t._texture.uid&&(n._textureMatrixUpdateId=-1),!n._batcher.checkAndUpdateTexture(n,t._texture)}return!1}addRenderable(t,e){var i,n;const r=this.renderer.renderPipes.batch,s=this._getMeshData(t);if(t.didViewUpdate&&(s.indexSize=null==(i=t._geometry.indices)?void 0:i.length,s.vertexSize=null==(n=t._geometry.positions)?void 0:n.length),s.batched){const i=this._getBatchableMesh(t);i.setTexture(t._texture),i.geometry=t._geometry,r.addToBatch(i,e)}else r.break(e),e.add(t)}updateRenderable(t){if(t.batched){const e=this._getBatchableMesh(t);e.setTexture(t._texture),e.geometry=t._geometry,e._batcher.updateElement(e)}}execute(t){if(!t.isRenderable)return;t.state.blendMode=Mr(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),zc(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new td),t._gpuData[this.renderer.uid].meshData||this._initMeshData(t)}_initMeshData(t){return t._gpuData[this.renderer.uid].meshData={batched:t.batched,indexSize:0,vertexSize:0},t._gpuData[this.renderer.uid].meshData}_getBatchableMesh(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new td),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new Ju;return e.renderable=t,e.setTexture(t._texture),e.transform=t.groupTransform,e.roundPixels=this.renderer._roundPixels|t._roundPixels,t._gpuData[this.renderer.uid].batchableMesh=e,e}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}ed.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"mesh"};class id{execute(t,e){const i=t.state,n=t.renderer,r=e.shader||t.defaultShader;r.resources.uTexture=e.texture._source,r.resources.uniforms=t.localUniforms;const s=n.gl,o=t.getBuffers(e);n.shader.bind(r),n.state.set(i),n.geometry.bind(o.geometry,r.glProgram);const a=2===o.geometry.indexBuffer.data.BYTES_PER_ELEMENT?s.UNSIGNED_SHORT:s.UNSIGNED_INT;s.drawElements(s.TRIANGLES,6*e.particleChildren.length,a,0)}}class nd{execute(t,e){const i=t.renderer,n=e.shader||t.defaultShader;n.groups[0]=i.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),n.groups[1]=i.texture.getTextureBindGroup(e.texture);const r=t.state,s=t.getBuffers(e);i.encoder.draw({geometry:s.geometry,shader:e.shader||t.defaultShader,state:r,size:6*e.particleChildren.length})}}function rd(t,e=null){const i=6*t;if(i>65535?e||(e=new Uint32Array(i)):e||(e=new Uint16Array(i)),e.length!==i)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${i}`);for(let n=0,r=0;n<i;n+=6,r+=4)e[n+0]=r+0,e[n+1]=r+1,e[n+2]=r+2,e[n+3]=r+0,e[n+4]=r+2,e[n+5]=r+3;return e}function sd(t,e){const i=[];i.push("\n\n var index = 0;\n\n for (let i = 0; i < ps.length; ++i)\n {\n const p = ps[i];\n\n ");let n=0;for(const s in t){const r=t[s];if(e!==r.dynamic)continue;i.push(`offset = index + ${n}`),i.push(r.code);n+=Ni(r.format).stride/4}i.push("\n index += stride * 4;\n }\n "),i.unshift(`\n var stride = ${n};\n `);const r=i.join("\n");return new Function("ps","f32v","u32v",r)}class od{constructor(t){var e;this._size=0,this._generateParticleUpdateCache={};const i=this._size=null!=(e=t.size)?e:1e3,n=t.properties;let r=0,s=0;for(const c in n){const t=n[c],e=Ni(t.format);t.dynamic?s+=e.stride:r+=e.stride}this._dynamicStride=s/4,this._staticStride=r/4,this.staticAttributeBuffer=new Ar(4*i*r),this.dynamicAttributeBuffer=new Ar(4*i*s),this.indexBuffer=rd(i);const o=new jr;let a=0,l=0;this._staticBuffer=new Hr({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:Vr.VERTEX|Vr.COPY_DST}),this._dynamicBuffer=new Hr({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:Vr.VERTEX|Vr.COPY_DST});for(const c in n){const t=n[c],e=Ni(t.format);t.dynamic?(o.addAttribute(t.attributeName,{buffer:this._dynamicBuffer,stride:4*this._dynamicStride,offset:4*a,format:t.format}),a+=e.size):(o.addAttribute(t.attributeName,{buffer:this._staticBuffer,stride:4*this._staticStride,offset:4*l,format:t.format}),l+=e.size)}o.addIndex(this.indexBuffer);const h=this.getParticleUpdate(n);this._dynamicUpload=h.dynamicUpdate,this._staticUpload=h.staticUpdate,this.geometry=o}getParticleUpdate(t){const e=function(t){const e=[];for(const i in t){const n=t[i];e.push(i,n.code,n.dynamic?"d":"s")}return e.join("_")}(t);return this._generateParticleUpdateCache[e]||(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t)),this._generateParticleUpdateCache[e]}generateParticleUpdate(t){return function(t){return{dynamicUpdate:sd(t,!0),staticUpdate:sd(t,!1)}}(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,1.5*this._size|0),this.staticAttributeBuffer=new Ar(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new Ar(this._size*this._dynamicStride*4*4),this.indexBuffer=rd(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const i=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,i.float32View,i.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){const e=this.staticAttributeBuffer;this._staticUpload(t,e.float32View,e.uint32View),this._staticBuffer.setDataWithSize(e.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}var ad="\nstruct ParticleUniforms {\n uProjectionMatrix:mat3x3<f32>,\n uColor:vec4<f32>,\n uResolution:vec2<f32>,\n uRoundPixels:f32,\n};\n\n@group(0) @binding(0) var<uniform> uniforms: ParticleUniforms;\n\n@group(1) @binding(0) var uTexture: texture_2d<f32>;\n@group(1) @binding(1) var uSampler : sampler;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>,\n @location(1) color : vec4<f32>,\n };\n@vertex\nfn mainVertex(\n @location(0) aVertex: vec2<f32>,\n @location(1) aPosition: vec2<f32>,\n @location(2) aUV: vec2<f32>,\n @location(3) aColor: vec4<f32>,\n @location(4) aRotation: f32,\n) -> VSOutput {\n \n let v = vec2(\n aVertex.x * cos(aRotation) - aVertex.y * sin(aRotation),\n aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation)\n ) + aPosition;\n\n let position = vec4((uniforms.uProjectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);\n\n let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor;\n\n return VSOutput(\n position,\n aUV,\n vColor,\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @location(1) color: vec4<f32>,\n @builtin(position) position: vec4<f32>,\n) -> @location(0) vec4<f32> {\n\n var sample = textureSample(uTexture, uSampler, uv) * color;\n \n return sample;\n}";class ld extends tn{constructor(){super({glProgram:Li.from({vertex:"attribute vec2 aVertex;\nattribute vec2 aUV;\nattribute vec4 aColor;\n\nattribute vec2 aPosition;\nattribute float aRotation;\n\nuniform mat3 uTranslationMatrix;\nuniform float uRound;\nuniform vec2 uResolution;\nuniform vec4 uColor;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n\nvec2 roundPixels(vec2 position, vec2 targetSize)\n{ \n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n}\n\nvoid main(void){\n float cosRotation = cos(aRotation);\n float sinRotation = sin(aRotation);\n float x = aVertex.x * cosRotation - aVertex.y * sinRotation;\n float y = aVertex.x * sinRotation + aVertex.y * cosRotation;\n\n vec2 v = vec2(x, y);\n v = v + aPosition;\n\n gl_Position = vec4((uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);\n\n if(uRound == 1.0)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n\n vUV = aUV;\n vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor;\n}\n",fragment:"varying vec2 vUV;\nvarying vec4 vColor;\n\nuniform sampler2D uTexture;\n\nvoid main(void){\n vec4 color = texture2D(uTexture, vUV) * vColor;\n gl_FragColor = color;\n}"}),gpuProgram:Yi.from({fragment:{source:ad,entryPoint:"mainFragment"},vertex:{source:ad,entryPoint:"mainVertex"}}),resources:{uTexture:J.WHITE.source,uSampler:new X({}),uniforms:{uTranslationMatrix:{value:new S,type:"mat3x3<f32>"},uColor:{value:new Ft(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}}class hd{constructor(t,e){this.state=rn.for2d(),this.localUniforms=new $i({uTranslationMatrix:{value:new S,type:"mat3x3<f32>"},uColor:{value:new Float32Array(4),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new ld,this.state=rn.for2d()}validateRenderable(t){return!1}addRenderable(t,e){this.renderer.renderPipes.batch.break(e),e.add(t)}getBuffers(t){return t._gpuData[this.renderer.uid]||this._initBuffer(t)}_initBuffer(t){return t._gpuData[this.renderer.uid]=new od({size:t.particleChildren.length,properties:t._properties}),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){const e=t.particleChildren;if(0===e.length)return;const i=this.renderer,n=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const r=this.state;n.update(e,t._childrenDirty),t._childrenDirty=!1,r.blendMode=Mr(t.blendMode,t.texture._source);const s=this.localUniforms.uniforms,o=s.uTranslationMatrix;t.worldTransform.copyTo(o),o.prepend(i.globalUniforms.globalUniformData.projectionMatrix),s.uResolution=i.globalUniforms.globalUniformData.resolution,s.uRound=i._roundPixels|t._roundPixels,zc(t.groupColorAlpha,s.uColor,0),this.adaptor.execute(this,t)}destroy(){this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}class cd extends hd{constructor(t){super(t,new id)}}cd.extension={type:[o.WebGLPipes],name:"particle"};class ud extends hd{constructor(t){super(t,new nd)}}ud.extension={type:[o.WebGPUPipes],name:"particle"};const dd=class t extends Qu{constructor(e={}){super({width:(e=__spreadValues(__spreadValues({},t.defaultOptions),e)).width,height:e.height,verticesX:4,verticesY:4}),this.update(e)}update(t){var e,i,n,r,s,o,a,l,h,c;this.width=null!=(e=t.width)?e:this.width,this.height=null!=(i=t.height)?i:this.height,this._originalWidth=null!=(n=t.originalWidth)?n:this._originalWidth,this._originalHeight=null!=(r=t.originalHeight)?r:this._originalHeight,this._leftWidth=null!=(s=t.leftWidth)?s:this._leftWidth,this._rightWidth=null!=(o=t.rightWidth)?o:this._rightWidth,this._topHeight=null!=(a=t.topHeight)?a:this._topHeight,this._bottomHeight=null!=(l=t.bottomHeight)?l:this._bottomHeight,this._anchorX=null==(h=t.anchor)?void 0:h.x,this._anchorY=null==(c=t.anchor)?void 0:c.y,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:i,_leftWidth:n,_rightWidth:r,_topHeight:s,_bottomHeight:o,_anchorX:a,_anchorY:l}=this,h=n+r,c=e>h?1:e/h,u=s+o,d=i>u?1:i/u,p=Math.min(c,d),f=a*e,g=l*i;t[0]=t[8]=t[16]=t[24]=-f,t[2]=t[10]=t[18]=t[26]=n*p-f,t[4]=t[12]=t[20]=t[28]=e-r*p-f,t[6]=t[14]=t[22]=t[30]=e-f,t[1]=t[3]=t[5]=t[7]=-g,t[9]=t[11]=t[13]=t[15]=s*p-g,t[17]=t[19]=t[21]=t[23]=i-o*p-g,t[25]=t[27]=t[29]=t[31]=i-g,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}};dd.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let pd=dd;class fd extends Ju{constructor(){super(),this.geometry=new pd}destroy(){this.geometry.destroy()}}class gd{constructor(t){this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture)}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=t._gpuData[this._renderer.uid]=new fd,i=e;return i.renderable=t,i.transform=t.groupTransform,i.texture=t._texture,i.roundPixels=this._renderer._roundPixels|t._roundPixels,t.didViewUpdate||this._updateBatchableSprite(t,i),e}destroy(){this._renderer=null}}gd.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"nineSliceSprite"};const md={name:"tiling-bit",vertex:{header:"\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n ",main:"\n uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;\n\n position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;\n "},fragment:{header:"\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n ",main:"\n\n var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);\n coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;\n var unclamped = coord;\n coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);\n\n var bias = 0.;\n\n if(unclamped.x == coord.x && unclamped.y == coord.y)\n {\n bias = -32.;\n }\n\n outColor = textureSampleBias(uTexture, uSampler, coord, bias);\n "}},_d={name:"tiling-bit",vertex:{header:"\n uniform mat3 uTextureTransform;\n uniform vec4 uSizeAnchor;\n\n ",main:"\n uv = (uTextureTransform * vec3(aUV, 1.0)).xy;\n\n position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;\n "},fragment:{header:"\n uniform sampler2D uTexture;\n uniform mat3 uMapCoord;\n uniform vec4 uClampFrame;\n uniform vec2 uClampOffset;\n ",main:"\n\n vec2 coord = vUV + ceil(uClampOffset - vUV);\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n vec2 unclamped = coord;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0\n\n "}};let yd,xd;class bd extends tn{constructor(){null!=yd||(yd=cs({name:"tiling-sprite-shader",bits:[zl,md,vs]})),null!=xd||(xd=us({name:"tiling-sprite-shader",bits:[Vl,_d,ws]}));const t=new $i({uMapCoord:{value:new S,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 S,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:xd,gpuProgram:yd,resources:{localUniforms:new $i({uTransformMatrix:{value:new S,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:J.EMPTY.source,uSampler:J.EMPTY.source.style}})}updateUniforms(t,e,i,n,r,s){const o=this.resources.tilingUniforms,a=s.width,l=s.height,h=s.textureMatrix,c=o.uniforms.uTextureTransform;c.set(i.a*a/t,i.b*a/e,i.c*l/t,i.d*l/e,i.tx/t,i.ty/e),c.invert(),o.uniforms.uMapCoord=h.mapCoord,o.uniforms.uClampFrame=h.uClampFrame,o.uniforms.uClampOffset=h.uClampOffset,o.uniforms.uTextureTransform=c,o.uniforms.uSizeAnchor[0]=t,o.uniforms.uSizeAnchor[1]=e,o.uniforms.uSizeAnchor[2]=n,o.uniforms.uSizeAnchor[3]=r,s&&(this.resources.uTexture=s.source,this.resources.uSampler=s.source.style)}}const vd=new class extends ml{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])})}};class wd{constructor(){this.canBatch=!0,this.geometry=new ml({indices:vd.indices.slice(),positions:vd.positions.slice(),uvs:vd.uvs.slice()})}destroy(){var t;this.geometry.destroy(),null==(t=this.shader)||t.destroy()}}class Sd{constructor(t){this._state=rn.default2d,this._renderer=t}validateRenderable(t){const e=this._getTilingSpriteData(t),i=e.canBatch;this._updateCanBatch(t);const n=e.canBatch;if(n&&n===i){const{batchableMesh:i}=e;return!i._batcher.checkAndUpdateTexture(i,t.texture)}return i!==n}addRenderable(t,e){const i=this._renderer.renderPipes.batch;this._updateCanBatch(t);const n=this._getTilingSpriteData(t),{geometry:r,canBatch:s}=n;if(s){n.batchableMesh||(n.batchableMesh=new Ju);const s=n.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),s.geometry=r,s.renderable=t,s.transform=t.groupTransform,s.setTexture(t._texture)),s.roundPixels=this._renderer._roundPixels|t._roundPixels,i.addToBatch(s,e)}else i.break(e),n.shader||(n.shader=new bd),this.updateRenderable(t),e.add(t)}execute(t){const{shader:e}=this._getTilingSpriteData(t);e.groups[0]=this._renderer.globalUniforms.bindGroup;const i=e.resources.localUniforms.uniforms;i.uTransformMatrix=t.groupTransform,i.uRound=this._renderer._roundPixels|t._roundPixels,zc(t.groupColorAlpha,i.uColor,0),this._state.blendMode=Mr(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:vd,shader:e,state:this._state})}updateRenderable(t){const e=this._getTilingSpriteData(t),{canBatch:i}=e;if(i){const{batchableMesh:i}=e;t.didViewUpdate&&this._updateBatchableMesh(t),i._batcher.updateElement(i)}else if(t.didViewUpdate){const{shader:i}=e;i.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}}_getTilingSpriteData(t){return t._gpuData[this._renderer.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){const e=new wd;return e.renderable=t,t._gpuData[this._renderer.uid]=e,e}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:i}=e,n=t.texture.source.style;"repeat"!==n.addressMode&&(n.addressMode="repeat",n.update()),function(t,e){const i=t.texture,n=i.frame.width,r=i.frame.height;let s=0,o=0;t.applyAnchorToTexture&&(s=t.anchor.x,o=t.anchor.y),e[0]=e[6]=-s,e[2]=e[4]=1-s,e[1]=e[3]=-o,e[5]=e[7]=1-o;const a=S.shared;a.copyFrom(t._tileTransform.matrix),a.tx/=t.width,a.ty/=t.height,a.invert(),a.scale(t.width/n,t.height/r),function(t,e,i,n){let r=0;const s=t.length/e,o=n.a,a=n.b,l=n.c,h=n.d,c=n.tx,u=n.ty;for(i*=e;r<s;){const n=t[i],s=t[i+1];t[i]=o*n+l*s+c,t[i+1]=a*n+h*s+u,i+=e,r++}}(e,2,0,a)}(t,i.uvs),function(t,e){const i=t.anchor.x,n=t.anchor.y;e[0]=-i*t.width,e[1]=-n*t.height,e[2]=(1-i)*t.width,e[3]=-n*t.height,e[4]=(1-i)*t.width,e[5]=(1-n)*t.height,e[6]=-i*t.width,e[7]=(1-n)*t.height}(t,i.positions)}destroy(){this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),i=t.texture;let n=!0;return this._renderer.type===Ji.WEBGL&&(n=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=i.textureMatrix.isSimple&&(n||i.source.isPowerOfTwo),e.canBatch}}Sd.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"tilingSprite"};const Ad={name:"local-uniform-msdf-bit",vertex:{header:"\n struct LocalUniforms {\n uColor:vec4<f32>,\n uTransformMatrix:mat3x3<f32>,\n uDistance: f32,\n uRound:f32,\n }\n\n @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "},fragment:{header:"\n struct LocalUniforms {\n uColor:vec4<f32>,\n uTransformMatrix:mat3x3<f32>,\n uDistance: f32\n }\n\n @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));\n "}},Td={name:"local-uniform-msdf-bit",vertex:{header:"\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix *= uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "},fragment:{header:"\n uniform float uDistance;\n ",main:"\n outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));\n "}},Cd={name:"msdf-bit",fragment:{header:"\n fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {\n\n // MSDF\n var median = msdfColor.r + msdfColor.g + msdfColor.b -\n min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -\n max(msdfColor.r, max(msdfColor.g, msdfColor.b));\n\n // SDF\n median = min(median, msdfColor.a);\n\n var screenPxDistance = distance * (median - 0.5);\n var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n if (median < 0.01) {\n alpha = 0.0;\n } else if (median > 0.99) {\n alpha = 1.0;\n }\n\n // Gamma correction for coverage-like alpha\n var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));\n var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);\n var coverage: f32 = pow(shapeColor.a * alpha, gamma);\n\n return coverage;\n\n }\n "}},Pd={name:"msdf-bit",fragment:{header:"\n float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {\n\n // MSDF\n float median = msdfColor.r + msdfColor.g + msdfColor.b -\n min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -\n max(msdfColor.r, max(msdfColor.g, msdfColor.b));\n\n // SDF\n median = min(median, msdfColor.a);\n\n float screenPxDistance = distance * (median - 0.5);\n float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n\n if (median < 0.01) {\n alpha = 0.0;\n } else if (median > 0.99) {\n alpha = 1.0;\n }\n\n // Gamma correction for coverage-like alpha\n float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));\n float gamma = mix(1.0, 1.0 / 2.2, luma);\n float coverage = pow(shapeColor.a * alpha, gamma);\n\n return coverage;\n }\n "}};let Md,Ed;class Rd extends tn{constructor(t){const e=new $i({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new S,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});null!=Md||(Md=cs({name:"sdf-shader",bits:[ds,_s(t),Ad,Cd,vs]})),null!=Ed||(Ed=us({name:"sdf-shader",bits:[ps,bs(t),Td,Pd,ws]})),super({glProgram:Ed,gpuProgram:Md,resources:{localUniforms:e,batchSamplers:As(t)}})}}class Fd extends fl{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class Bd{constructor(t){this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuBitmapText")}validateRenderable(t){const e=this._getGpuBitmapText(t);return this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const i=this._getGpuBitmapText(t);kd(t,i),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,i)),this._renderer.renderPipes.graphics.addRenderable(i,e),i.context.customShader&&this._updateDistanceField(t)}updateRenderable(t){const e=this._getGpuBitmapText(t);kd(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:i}=e,n=Zo.getFont(t.text,t._style);i.clear(),"none"!==n.distanceField.type&&(i.customShader||(i.customShader=new Rd(this._renderer.limits.maxBatchableTextures)));const r=sr.graphemeSegmenter(t.text),s=t._style;let o=n.baseLineOffset;const a=Yo(r,s,n,!0),l=s.padding,h=a.scale;let c=a.width,u=a.height+a.offsetY;s._stroke&&(c+=s._stroke.width/h,u+=s._stroke.width/h),i.translate(-t._anchor._x*c-l,-t._anchor._y*u-l).scale(h,h);const d=n.applyFillAsTint?s._fill.color:16777215;let p=n.fontMetrics.fontSize,f=n.lineHeight;s.lineHeight&&(p=s.fontSize/h,f=s.lineHeight/h);let g=(f-p)/2;g-n.baseLineOffset<0&&(g=0);for(let m=0;m<a.lines.length;m++){const t=a.lines[m];for(let e=0;e<t.charPositions.length;e++){const r=t.chars[e],s=n.chars[r];if(null==s?void 0:s.texture){const n=s.texture;i.texture(n,d||"black",Math.round(t.charPositions[e]+s.xOffset),Math.round(o+s.yOffset+g),n.orig.width,n.orig.height)}}o+=f}}_getGpuBitmapText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Fd;return t._gpuData[this._renderer.uid]=e,this._updateContext(t,e),e}_updateDistanceField(t){const e=this._getGpuBitmapText(t).context,i=t._style.fontFamily,n=Ve.get(`${i}-bitmap`),{a:r,b:s,c:o,d:a}=t.groupTransform,l=Math.sqrt(r*r+s*s),h=Math.sqrt(o*o+a*a),c=(Math.abs(l)+Math.abs(h))/2,u=n.baseRenderedFontSize/t._style.fontSize,d=c*n.distanceField.range*(1/u);e.customShader.resources.localUniforms.uniforms.uDistance=d}destroy(){this._renderer=null}}function kd(t,e){e.groupTransform=t.groupTransform,e.groupColorAlpha=t.groupColorAlpha,e.groupColor=t.groupColor,e.groupBlendMode=t.groupBlendMode,e.globalDisplayStatus=t.globalDisplayStatus,e.groupTransform=t.groupTransform,e.localDisplayStatus=t.localDisplayStatus,e.groupAlpha=t.groupAlpha,e._roundPixels=t._roundPixels}Bd.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"bitmapText"};class Id extends mc{constructor(t){super(),this.generatingTexture=!1,this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){this._renderer.htmlText.returnTexturePromise(this.texturePromise),this.texturePromise=null,this._renderer=null}}function Dd(t,e){const{texture:i,bounds:n}=t,r=e._style._getFinalPadding();tt(n,e._anchor,i);const s=e._anchor._x*r*2,o=e._anchor._y*r*2;n.minX-=r-s,n.minY-=r-o,n.maxX-=r-s,n.maxY-=r-o}class Od{constructor(t){this._renderer=t}validateRenderable(t){return t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);t._didTextUpdate&&(this._updateGpuText(t).catch(t=>{console.error(t)}),t._didTextUpdate=!1,Dd(i,t)),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){return __async(this,null,function*(){t._didTextUpdate=!1;const e=this._getGpuText(t);if(e.generatingTexture)return;e.texturePromise&&(this._renderer.htmlText.returnTexturePromise(e.texturePromise),e.texturePromise=null),e.generatingTexture=!0,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const i=this._renderer.htmlText.getTexturePromise(t);e.texturePromise=i,e.texture=yield i;const n=t.renderGroup||t.parentRenderGroup;n&&(n.structureDidChange=!0),e.generatingTexture=!1,Dd(e,t)})}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Id(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.texture=J.EMPTY,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Od.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"htmlText"};const Ud=new it;function Gd(t,e,i,n){const r=Ud;r.minX=0,r.minY=0,r.maxX=t.width/n|0,r.maxY=t.height/n|0;const s=pe.getOptimalTexture(r.width,r.height,n,!1);return s.source.uploadMethodId="image",s.source.resource=t,s.source.alphaMode="premultiply-alpha-on-upload",s.frame.width=e/n,s.frame.height=i/n,s.source.emit("update",s.source),s.updateUvs(),s}function Ld(t,e){return __async(this,null,function*(){const i=yield function(t){return __async(this,null,function*(){const e=yield Re.get().fetch(t),i=yield e.blob(),n=new FileReader;return yield new Promise((t,e)=>{n.onloadend=()=>t(n.result),n.onerror=e,n.readAsDataURL(i)})})}(e);return`@font-face {\n font-family: "${t.fontFamily}";\n font-weight: ${t.fontWeight};\n font-style: ${t.fontStyle};\n src: url('${i}');\n }`})}const zd=new Map;class Nd{constructor(t){this._renderer=t,this._createCanvas=t.type===Ji.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getTexturePromise(t){return this._buildTexturePromise(t)}_buildTexturePromise(t){return __async(this,null,function*(){const{text:e,style:i,resolution:n,textureStyle:r}=t,s=Dt.get(kl),o=function(t,e){const i=e.fontFamily,n=[],r={},s=t.match(/font-family:([^;"\s]+)/g);function o(t){r[t]||(n.push(t),r[t]=!0)}if(Array.isArray(i))for(let a=0;a<i.length;a++)o(i[a]);else o(i);s&&s.forEach(t=>{o(t.split(":")[1].trim())});for(const a in e.tagStyles)o(e.tagStyles[a].fontFamily);return n}(e,i),a=yield function(t){return __async(this,null,function*(){const e=t.filter(t=>Ve.has(`${t}-and-url`)).map(t=>{if(!zd.has(t)){const{entries:e}=Ve.get(`${t}-and-url`),i=[];e.forEach(e=>{const n=e.url,r=e.faces.map(t=>({weight:t.weight,style:t.style}));i.push(...r.map(e=>Ld({fontWeight:e.weight,fontStyle:e.style,fontFamily:t},n)))}),zd.set(t,Promise.all(i).then(t=>t.join("\n")))}return zd.get(t)});return(yield Promise.all(e)).join("\n")})}(o),l=function(t,e,i,n){n||(n=Il||(Il=new kl));const{domElement:r,styleElement:s,svgRoot:o}=n;r.innerHTML=`<style>${e.cssStyle};</style><div style='padding:0'>${t}</div>`,r.setAttribute("style","transform-origin: top left; display: inline-block"),i&&(s.textContent=i),document.body.appendChild(o);const a=r.getBoundingClientRect();o.remove();const l=2*e.padding;return{width:a.width-l,height:a.height-l}}(e,i,a,s),h=Math.ceil(Math.ceil(Math.max(1,l.width)+2*i.padding)*n),c=Math.ceil(Math.ceil(Math.max(1,l.height)+2*i.padding)*n),u=s.image;u.width=2+(0|h),u.height=2+(0|c);const d=function(t,e,i,n,r){const{domElement:s,styleElement:o,svgRoot:a}=r;s.innerHTML=`<style>${e.cssStyle}</style><div style='padding:0;'>${t}</div>`,s.setAttribute("style",`transform: scale(${i});transform-origin: top left; display: inline-block`),o.textContent=n;const{width:l,height:h}=r.image;return a.setAttribute("width",l.toString()),a.setAttribute("height",h.toString()),(new XMLSerializer).serializeToString(a)}(e,i,n,a,s);yield function(t,e,i){return new Promise(n=>__async(null,null,function*(){i&&(yield new Promise(t=>setTimeout(t,100))),t.onload=()=>{n()},t.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(e)}`,t.crossOrigin="anonymous"}))}(u,d,function(){const{userAgent:t}=Re.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}()&&o.length>0);const p=u;let f;this._createCanvas&&(f=function(t,e){const i=No.getOptimalCanvasAndContext(t.width,t.height,e),{context:n}=i;return n.clearRect(0,0,t.width,t.height),n.drawImage(t,0,0),i}(u,n));const g=Gd(f?f.canvas:p,u.width-2,u.height-2,n);return r&&(g.source.style=r),this._createCanvas&&(this._renderer.texture.initSource(g.source),No.returnCanvasAndContext(f)),Dt.return(s),g})}returnTexturePromise(t){t.then(t=>{this._cleanUp(t)}).catch(()=>{kt("HTMLTextSystem: Failed to clean texture")})}_cleanUp(t){pe.returnTexture(t,!0),t.source.resource=null,t.source.uploadMethodId="unknown"}destroy(){this._renderer=null}}Nd.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"htmlText"};class Vd extends mc{constructor(t){super(),this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){this._renderer.canvasText.returnTexture(this.texture),this._renderer=null}}class Hd{constructor(t){this._renderer=t}validateRenderable(t){return t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);t._didTextUpdate&&(this._updateGpuText(t),t._didTextUpdate=!1),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.returnTexture(e.texture),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getTexture(t),Dd(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Vd(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Hd.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"text"};class Wd{constructor(t){this._renderer=t}getTexture(t,e,i,n){var r;"string"==typeof t&&(z("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:i,resolution:e}),t.style instanceof zo||(t.style=new zo(t.style)),t.textureStyle instanceof X||(t.textureStyle=new X(t.textureStyle)),"string"!=typeof t.text&&(t.text=t.text.toString());const{text:s,style:o,textureStyle:a}=t,l=null!=(r=t.resolution)?r:this._renderer.resolution,{frame:h,canvasAndContext:c}=El.getCanvasAndContext({text:s,style:o,resolution:l}),u=Gd(c.canvas,h.width,h.height,l);if(a&&(u.source.style=a),o.trim&&(h.pad(o.padding),u.frame.copyFrom(h),u.frame.scale(1/l),u.updateUvs()),o.filters){const t=this._applyFilters(u,o.filters);return this.returnTexture(u),El.returnCanvasAndContext(c),t}return this._renderer.texture.initSource(u._source),El.returnCanvasAndContext(c),u}returnTexture(t){const e=t.source;e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",pe.returnTexture(t,!0)}renderTextToCanvas(){z("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}_applyFilters(t,e){const i=this._renderer.renderTarget.renderTarget,n=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(i,!1),n}destroy(){this._renderer=null}}Wd.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"canvasText"},h.add(c,u);var jd="object"==typeof global&&global&&global.Object===Object&&global,Yd="object"==typeof self&&self&&self.Object===Object&&self,Xd=jd||Yd||Function("return this")(),Zd=Xd.Symbol,qd=Object.prototype,Kd=qd.hasOwnProperty,$d=qd.toString,Qd=Zd?Zd.toStringTag:void 0;var Jd=Object.prototype.toString;var tp=Zd?Zd.toStringTag:void 0;function ep(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":tp&&tp in Object(t)?function(t){var e=Kd.call(t,Qd),i=t[Qd];try{t[Qd]=void 0;var n=!0}catch(s){}var r=$d.call(t);return n&&(e?t[Qd]=i:delete t[Qd]),r}(t):function(t){return Jd.call(t)}(t)}function ip(t){return null!=t&&"object"==typeof t}var np=Array.isArray,rp=/\s/;var sp=/^\s+/;function op(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&rp.test(t.charAt(e)););return e}(t)+1).replace(sp,""):t}function ap(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}var lp=/^[-+]0x[0-9a-f]+$/i,hp=/^0b[01]+$/i,cp=/^0o[0-7]+$/i,up=parseInt;function dp(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||ip(t)&&"[object Symbol]"==ep(t)}(t))return NaN;if(ap(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ap(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=op(t);var i=hp.test(t);return i||cp.test(t)?up(t.slice(2),i?2:8):lp.test(t)?NaN:+t}var pp=1/0;function fp(t){var e=function(t){return t?(t=dp(t))===pp||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}(t),i=e%1;return e==e?i?e-i:e:0}function gp(t){return t}function mp(t){if(!ap(t))return!1;var e=ep(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var _p,yp=Xd["__core-js_shared__"],xp=(_p=/[^.]+$/.exec(yp&&yp.keys&&yp.keys.IE_PROTO||""))?"Symbol(src)_1."+_p:"";var bp=Function.prototype.toString;function vp(t){if(null!=t){try{return bp.call(t)}catch(e){}try{return t+""}catch(e){}}return""}var wp=/^\[object .+?Constructor\]$/,Sp=Function.prototype,Ap=Object.prototype,Tp=Sp.toString,Cp=Ap.hasOwnProperty,Pp=RegExp("^"+Tp.call(Cp).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Mp(t){return!(!ap(t)||(e=t,xp&&xp in e))&&(mp(t)?Pp:wp).test(vp(t));var e}function Ep(t,e){var i=function(t,e){return null==t?void 0:t[e]}(t,e);return Mp(i)?i:void 0}var Rp=Ep(Xd,"WeakMap"),Fp=Object.create,Bp=function(){function t(){}return function(e){if(!ap(e))return{};if(Fp)return Fp(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}();var kp=Date.now;var Ip,Dp,Op,Up=function(){try{var t=Ep(Object,"defineProperty");return t({},"",{}),t}catch(e){}}(),Gp=Up?function(t,e){return Up(t,"toString",{configurable:!0,enumerable:!1,value:(i=e,function(){return i}),writable:!0});var i}:gp,Lp=(Ip=Gp,Dp=0,Op=0,function(){var t=kp(),e=16-(t-Op);if(Op=t,e>0){if(++Dp>=800)return arguments[0]}else Dp=0;return Ip.apply(void 0,arguments)}),zp=/^(?:0|[1-9]\d*)$/;function Np(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&zp.test(t))&&t>-1&&t%1==0&&t<e}function Vp(t,e,i){"__proto__"==e&&Up?Up(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}function Hp(t,e){return t===e||t!=t&&e!=e}var Wp=Object.prototype.hasOwnProperty;function jp(t,e,i){var n=t[e];Wp.call(t,e)&&Hp(n,i)&&(void 0!==i||e in t)||Vp(t,e,i)}var Yp=Math.max;function Xp(t,e){return Lp(function(t,e,i){return e=Yp(void 0===e?t.length-1:e,0),function(){for(var n=arguments,r=-1,s=Yp(n.length-e,0),o=Array(s);++r<s;)o[r]=n[e+r];r=-1;for(var a=Array(e+1);++r<e;)a[r]=n[r];return a[e]=i(o),function(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)}(t,this,a)}}(t,e,gp),t+"")}function Zp(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function qp(t){return null!=t&&Zp(t.length)&&!mp(t)}var Kp=Object.prototype;function $p(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Kp)}function Qp(t){return ip(t)&&"[object Arguments]"==ep(t)}var Jp=Object.prototype,tf=Jp.hasOwnProperty,ef=Jp.propertyIsEnumerable,nf=Qp(function(){return arguments}())?Qp:function(t){return ip(t)&&tf.call(t,"callee")&&!ef.call(t,"callee")};var rf="object"==typeof exports&&exports&&!exports.nodeType&&exports,sf=rf&&"object"==typeof module&&module&&!module.nodeType&&module,of=sf&&sf.exports===rf?Xd.Buffer:void 0,af=(of?of.isBuffer:void 0)||function(){return!1},lf={};lf["[object Float32Array]"]=lf["[object Float64Array]"]=lf["[object Int8Array]"]=lf["[object Int16Array]"]=lf["[object Int32Array]"]=lf["[object Uint8Array]"]=lf["[object Uint8ClampedArray]"]=lf["[object Uint16Array]"]=lf["[object Uint32Array]"]=!0,lf["[object Arguments]"]=lf["[object Array]"]=lf["[object ArrayBuffer]"]=lf["[object Boolean]"]=lf["[object DataView]"]=lf["[object Date]"]=lf["[object Error]"]=lf["[object Function]"]=lf["[object Map]"]=lf["[object Number]"]=lf["[object Object]"]=lf["[object RegExp]"]=lf["[object Set]"]=lf["[object String]"]=lf["[object WeakMap]"]=!1;var hf="object"==typeof exports&&exports&&!exports.nodeType&&exports,cf=hf&&"object"==typeof module&&module&&!module.nodeType&&module,uf=cf&&cf.exports===hf&&jd.process,df=function(){try{var t=cf&&cf.require&&cf.require("util").types;return t||uf&&uf.binding&&uf.binding("util")}catch(e){}}(),pf=df&&df.isTypedArray,ff=pf?function(t){return function(e){return t(e)}}(pf):function(t){return ip(t)&&Zp(t.length)&&!!lf[ep(t)]},gf=Object.prototype.hasOwnProperty;function mf(t,e){var i=np(t),n=!i&&nf(t),r=!i&&!n&&af(t),s=!i&&!n&&!r&&ff(t),o=i||n||r||s,a=o?function(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n}(t.length,String):[],l=a.length;for(var h in t)!e&&!gf.call(t,h)||o&&("length"==h||r&&("offset"==h||"parent"==h)||s&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||Np(h,l))||a.push(h);return a}function _f(t,e){return function(i){return t(e(i))}}var yf=_f(Object.keys,Object),xf=Object.prototype.hasOwnProperty;function bf(t){return qp(t)?mf(t):function(t){if(!$p(t))return yf(t);var e=[];for(var i in Object(t))xf.call(t,i)&&"constructor"!=i&&e.push(i);return e}(t)}var vf=Object.prototype.hasOwnProperty;function wf(t){if(!ap(t))return function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e}(t);var e=$p(t),i=[];for(var n in t)("constructor"!=n||!e&&vf.call(t,n))&&i.push(n);return i}function Sf(t){return qp(t)?mf(t,!0):wf(t)}var Af=Ep(Object,"create");var Tf=Object.prototype.hasOwnProperty;var Cf=Object.prototype.hasOwnProperty;function Pf(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}function Mf(t,e){for(var i=t.length;i--;)if(Hp(t[i][0],e))return i;return-1}Pf.prototype.clear=function(){this.__data__=Af?Af(null):{},this.size=0},Pf.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Pf.prototype.get=function(t){var e=this.__data__;if(Af){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return Tf.call(e,t)?e[t]:void 0},Pf.prototype.has=function(t){var e=this.__data__;return Af?void 0!==e[t]:Cf.call(e,t)},Pf.prototype.set=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Af&&void 0===e?"__lodash_hash_undefined__":e,this};var Ef=Array.prototype.splice;function Rf(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Rf.prototype.clear=function(){this.__data__=[],this.size=0},Rf.prototype.delete=function(t){var e=this.__data__,i=Mf(e,t);return!(i<0)&&(i==e.length-1?e.pop():Ef.call(e,i,1),--this.size,!0)},Rf.prototype.get=function(t){var e=this.__data__,i=Mf(e,t);return i<0?void 0:e[i][1]},Rf.prototype.has=function(t){return Mf(this.__data__,t)>-1},Rf.prototype.set=function(t,e){var i=this.__data__,n=Mf(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this};var Ff=Ep(Xd,"Map");function Bf(t,e){var i,n,r=t.__data__;return("string"==(n=typeof(i=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==i:null===i)?r["string"==typeof e?"string":"hash"]:r.map}function kf(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}kf.prototype.clear=function(){this.size=0,this.__data__={hash:new Pf,map:new(Ff||Rf),string:new Pf}},kf.prototype.delete=function(t){var e=Bf(this,t).delete(t);return this.size-=e?1:0,e},kf.prototype.get=function(t){return Bf(this,t).get(t)},kf.prototype.has=function(t){return Bf(this,t).has(t)},kf.prototype.set=function(t,e){var i=Bf(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this};var If=_f(Object.getPrototypeOf,Object),Df=Function.prototype,Of=Object.prototype,Uf=Df.toString,Gf=Of.hasOwnProperty,Lf=Uf.call(Object);function zf(t,e,i){var n=-1,r=t.length;e<0&&(e=-e>r?0:r+e),(i=i>r?r:i)<0&&(i+=r),r=e>i?0:i-e>>>0,e>>>=0;for(var s=Array(r);++n<r;)s[n]=t[n+e];return s}var Nf=Math.ceil,Vf=Math.max;function Hf(t){var e=this.__data__=new Rf(t);this.size=e.size}Hf.prototype.clear=function(){this.__data__=new Rf,this.size=0},Hf.prototype.delete=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i},Hf.prototype.get=function(t){return this.__data__.get(t)},Hf.prototype.has=function(t){return this.__data__.has(t)},Hf.prototype.set=function(t,e){var i=this.__data__;if(i instanceof Rf){var n=i.__data__;if(!Ff||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new kf(n)}return i.set(t,e),this.size=i.size,this};var Wf="object"==typeof exports&&exports&&!exports.nodeType&&exports,jf=Wf&&"object"==typeof module&&module&&!module.nodeType&&module,Yf=jf&&jf.exports===Wf?Xd.Buffer:void 0;Yf&&Yf.allocUnsafe;var Xf=Object.prototype.propertyIsEnumerable,Zf=Object.getOwnPropertySymbols,qf=Zf?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var i=-1,n=null==t?0:t.length,r=0,s=[];++i<n;){var o=t[i];e(o,i,t)&&(s[r++]=o)}return s}(Zf(t),function(e){return Xf.call(t,e)}))}:function(){return[]};function Kf(t){return function(t,e,i){var n=e(t);return np(t)?n:function(t,e){for(var i=-1,n=e.length,r=t.length;++i<n;)t[r+i]=e[i];return t}(n,i(t))}(t,bf,qf)}var $f=Ep(Xd,"DataView"),Qf=Ep(Xd,"Promise"),Jf=Ep(Xd,"Set"),tg="[object Map]",eg="[object Promise]",ig="[object Set]",ng="[object WeakMap]",rg="[object DataView]",sg=vp($f),og=vp(Ff),ag=vp(Qf),lg=vp(Jf),hg=vp(Rp),cg=ep;($f&&cg(new $f(new ArrayBuffer(1)))!=rg||Ff&&cg(new Ff)!=tg||Qf&&cg(Qf.resolve())!=eg||Jf&&cg(new Jf)!=ig||Rp&&cg(new Rp)!=ng)&&(cg=function(t){var e=ep(t),i="[object Object]"==e?t.constructor:void 0,n=i?vp(i):"";if(n)switch(n){case sg:return rg;case og:return tg;case ag:return eg;case lg:return ig;case hg:return ng}return e});var ug=Xd.Uint8Array;function dg(t,e){var i,n,r=(i=t.buffer,n=new i.constructor(i.byteLength),new ug(n).set(new ug(i)),n);return new t.constructor(r,t.byteOffset,t.length)}function pg(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new kf;++e<i;)this.add(t[e])}function fg(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(e(t[i],i,t))return!0;return!1}pg.prototype.add=pg.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},pg.prototype.has=function(t){return this.__data__.has(t)};function gg(t,e,i,n,r,s){var o=1&i,a=t.length,l=e.length;if(a!=l&&!(o&&l>a))return!1;var h=s.get(t),c=s.get(e);if(h&&c)return h==e&&c==t;var u=-1,d=!0,p=2&i?new pg:void 0;for(s.set(t,e),s.set(e,t);++u<a;){var f=t[u],g=e[u];if(n)var m=o?n(g,f,u,e,t,s):n(f,g,u,t,e,s);if(void 0!==m){if(m)continue;d=!1;break}if(p){if(!fg(e,function(t,e){if(o=e,!p.has(o)&&(f===t||r(f,t,i,n,s)))return p.push(e);var o})){d=!1;break}}else if(f!==g&&!r(f,g,i,n,s)){d=!1;break}}return s.delete(t),s.delete(e),d}function mg(t){var e=-1,i=Array(t.size);return t.forEach(function(t,n){i[++e]=[n,t]}),i}function _g(t){var e=-1,i=Array(t.size);return t.forEach(function(t){i[++e]=t}),i}var yg=Zd?Zd.prototype:void 0,xg=yg?yg.valueOf:void 0;var bg=Object.prototype.hasOwnProperty;var vg="[object Arguments]",wg="[object Array]",Sg="[object Object]",Ag=Object.prototype.hasOwnProperty;function Tg(t,e,i,n,r,s){var o=np(t),a=np(e),l=o?wg:cg(t),h=a?wg:cg(e),c=(l=l==vg?Sg:l)==Sg,u=(h=h==vg?Sg:h)==Sg,d=l==h;if(d&&af(t)){if(!af(e))return!1;o=!0,c=!1}if(d&&!c)return s||(s=new Hf),o||ff(t)?gg(t,e,i,n,r,s):function(t,e,i,n,r,s,o){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!s(new ug(t),new ug(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Hp(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=mg;case"[object Set]":var l=1&n;if(a||(a=_g),t.size!=e.size&&!l)return!1;var h=o.get(t);if(h)return h==e;n|=2,o.set(t,e);var c=gg(a(t),a(e),n,r,s,o);return o.delete(t),c;case"[object Symbol]":if(xg)return xg.call(t)==xg.call(e)}return!1}(t,e,l,i,n,r,s);if(!(1&i)){var p=c&&Ag.call(t,"__wrapped__"),f=u&&Ag.call(e,"__wrapped__");if(p||f){var g=p?t.value():t,m=f?e.value():e;return s||(s=new Hf),r(g,m,i,n,s)}}return!!d&&(s||(s=new Hf),function(t,e,i,n,r,s){var o=1&i,a=Kf(t),l=a.length;if(l!=Kf(e).length&&!o)return!1;for(var h=l;h--;){var c=a[h];if(!(o?c in e:bg.call(e,c)))return!1}var u=s.get(t),d=s.get(e);if(u&&d)return u==e&&d==t;var p=!0;s.set(t,e),s.set(e,t);for(var f=o;++h<l;){var g=t[c=a[h]],m=e[c];if(n)var _=o?n(m,g,c,e,t,s):n(g,m,c,t,e,s);if(!(void 0===_?g===m||r(g,m,i,n,s):_)){p=!1;break}f||(f="constructor"==c)}if(p&&!f){var y=t.constructor,x=e.constructor;y==x||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof x&&x instanceof x||(p=!1)}return s.delete(t),s.delete(e),p}(t,e,i,n,r,s))}function Cg(t,e,i,n,r){return t===e||(null==t||null==e||!ip(t)&&!ip(e)?t!=t&&e!=e:Tg(t,e,i,n,Cg,r))}var Pg=function(t,e,i){for(var n=-1,r=Object(t),s=i(t),o=s.length;o--;){var a=s[++n];if(!1===e(r[a],a,r))break}return t},Mg=function(){return Xd.Date.now()},Eg=Math.max,Rg=Math.min;function Fg(t,e,i){var n,r,s,o,a,l,h=0,c=!1,u=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){var i=n,s=r;return n=r=void 0,h=e,o=t.apply(s,i)}function f(t){var i=t-l;return void 0===l||i>=e||i<0||u&&t-h>=s}function g(){var t=Mg();if(f(t))return m(t);a=setTimeout(g,function(t){var i=e-(t-l);return u?Rg(i,s-(t-h)):i}(t))}function m(t){return a=void 0,d&&n?p(t):(n=r=void 0,o)}function _(){var t=Mg(),i=f(t);if(n=arguments,r=this,l=t,i){if(void 0===a)return function(t){return h=t,a=setTimeout(g,e),c?p(t):o}(l);if(u)return clearTimeout(a),a=setTimeout(g,e),p(l)}return void 0===a&&(a=setTimeout(g,e)),o}return e=dp(e)||0,ap(i)&&(c=!!i.leading,s=(u="maxWait"in i)?Eg(dp(i.maxWait)||0,e):s,d="trailing"in i?!!i.trailing:d),_.cancel=function(){void 0!==a&&clearTimeout(a),h=0,n=l=r=a=void 0},_.flush=function(){return void 0===a?o:m(Mg())},_}function Bg(t,e,i){(void 0!==i&&!Hp(t[e],i)||void 0===i&&!(e in t))&&Vp(t,e,i)}function kg(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Ig(t){return function(t,e,i){var n=!i;i||(i={});for(var r=-1,s=e.length;++r<s;){var o=e[r],a=void 0;void 0===a&&(a=t[o]),n?Vp(i,o,a):jp(i,o,a)}return i}(t,Sf(t))}function Dg(t,e,i,n,r,s,o){var a=kg(t,i),l=kg(e,i),h=o.get(l);if(h)Bg(t,i,h);else{var c,u=s?s(a,l,i+"",t,e,o):void 0,d=void 0===u;if(d){var p=np(l),f=!p&&af(l),g=!p&&!f&&ff(l);u=l,p||f||g?np(a)?u=a:ip(c=a)&&qp(c)?u=function(t,e){var i=-1,n=t.length;for(e||(e=Array(n));++i<n;)e[i]=t[i];return e}(a):f?(d=!1,u=l.slice()):g?(d=!1,u=dg(l)):u=[]:function(t){if(!ip(t)||"[object Object]"!=ep(t))return!1;var e=If(t);if(null===e)return!0;var i=Gf.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&Uf.call(i)==Lf}(l)||nf(l)?(u=a,nf(a)?u=Ig(a):ap(a)&&!mp(a)||(u=function(t){return"function"!=typeof t.constructor||$p(t)?{}:Bp(If(t))}(l))):d=!1}d&&(o.set(l,u),r(u,l,n,s,o),o.delete(l)),Bg(t,i,u)}}function Og(t,e,i,n,r){t!==e&&Pg(e,function(s,o){if(r||(r=new Hf),ap(s))Dg(t,e,o,i,Og,n,r);else{var a=n?n(kg(t,o),s,o+"",t,e,r):void 0;void 0===a&&(a=s),Bg(t,o,a)}},Sf)}function Ug(t,e){return Cg(t,e)}var Gg,Lg=(Gg=function(t,e,i){Og(t,e,i)},Xp(function(t,e){var i=-1,n=e.length,r=n>1?e[n-1]:void 0,s=n>2?e[2]:void 0;for(r=Gg.length>3&&"function"==typeof r?(n--,r):void 0,s&&function(t,e,i){if(!ap(i))return!1;var n=typeof e;return!!("number"==n?qp(i)&&Np(e,i.length):"string"==n&&e in i)&&Hp(i[e],t)}(e[0],e[1],s)&&(r=n<3?void 0:r,n=1),t=Object(t);++i<n;){var o=e[i];o&&Gg(t,o,i,r)}return t}));function zg(t,e,i){var n=!0,r=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return ap(i)&&(n="leading"in i?!!i.leading:n,r="trailing"in i?!!i.trailing:r),Fg(t,e,{leading:n,maxWait:e,trailing:r})}!function(t){var e={};for(var i in t)t.hasOwnProperty(i)&&(e[t[i]]=i)}({aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"});var Ng,Vg={},Hg={};var Wg,jg,Yg={};var Xg=(jg||(jg=1,function(t){const e=function(){if(Ng)return Hg;Ng=1,Hg.byteLength=function(t){var e=s(t),i=e[0],n=e[1];return 3*(i+n)/4-n},Hg.toByteArray=function(t){var n,r,o=s(t),a=o[0],l=o[1],h=new i(function(t,e,i){return 3*(e+i)/4-i}(0,a,l)),c=0,u=l>0?a-4:a;for(r=0;r<u;r+=4)n=e[t.charCodeAt(r)]<<18|e[t.charCodeAt(r+1)]<<12|e[t.charCodeAt(r+2)]<<6|e[t.charCodeAt(r+3)],h[c++]=n>>16&255,h[c++]=n>>8&255,h[c++]=255&n;return 2===l&&(n=e[t.charCodeAt(r)]<<2|e[t.charCodeAt(r+1)]>>4,h[c++]=255&n),1===l&&(n=e[t.charCodeAt(r)]<<10|e[t.charCodeAt(r+1)]<<4|e[t.charCodeAt(r+2)]>>2,h[c++]=n>>8&255,h[c++]=255&n),h},Hg.fromByteArray=function(e){for(var i,n=e.length,r=n%3,s=[],o=16383,l=0,h=n-r;l<h;l+=o)s.push(a(e,l,l+o>h?h:l+o));return 1===r?(i=e[n-1],s.push(t[i>>2]+t[i<<4&63]+"==")):2===r&&(i=(e[n-2]<<8)+e[n-1],s.push(t[i>>10]+t[i>>4&63]+t[i<<2&63]+"=")),s.join("")};for(var t=[],e=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0;r<64;++r)t[r]=n[r],e[n.charCodeAt(r)]=r;function s(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function o(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[63&e]}function a(t,e,i){for(var n,r=[],s=e;s<i;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),r.push(o(n));return r.join("")}return e["-".charCodeAt(0)]=62,e["_".charCodeAt(0)]=63,Hg}(),i=(Wg||(Wg=1,Yg.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,l=(1<<a)-1,h=l>>1,c=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,s=p&(1<<-c)-1,p>>=-c,c+=a;c>0;s=256*s+t[e+u],u+=d,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+u],u+=d,c-=8);if(0===s)s=1-h;else{if(s===l)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),s-=h}return(p?-1:1)*o*Math.pow(2,s-n)},Yg.write=function(t,e,i,n,r,s){var o,a,l,h=8*s-r-1,c=(1<<h)-1,u=c>>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,f=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+u>=1?d/l:d*Math.pow(2,1-u))*l>=2&&(o++,l/=2),o+u>=c?(a=0,o=c):o+u>=1?(a=(e*l-1)*Math.pow(2,r),o+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),o=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(o=o<<r|a,h+=r;h>0;t[i+p]=255&o,p+=f,o/=256,h-=8);t[i+p-f]|=128*g}),Yg),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=o,t.SlowBuffer=function(t){return+t!=t&&(t=0),o.alloc(+t)},t.INSPECT_MAX_BYTES=50;const r=2147483647;function s(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,o.prototype),e}function o(t,e,i){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return a(t,e,i)}function a(t,e,i){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const i=0|p(t,e);let n=s(i);const r=n.write(t,e);return r!==i&&(n=n.slice(0,r)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return u(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return u(t,e,i);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return u(t,e,i);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return o.from(n,e,i);const r=function(t){if(o.isBuffer(t)){const e=0|d(t.length),i=s(e);return 0===i.length||t.copy(i,0,0,e),i}return void 0!==t.length?"number"!=typeof t.length||Z(t.length)?s(0):c(t):"Buffer"===t.type&&Array.isArray(t.data)?c(t.data):void 0}(t);if(r)return r;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return o.from(t[Symbol.toPrimitive]("string"),e,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return l(t),s(t<0?0:0|d(t))}function c(t){const e=t.length<0?0:0|d(t.length),i=s(e);for(let n=0;n<e;n+=1)i[n]=255&t[n];return i}function u(t,e,i){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(i||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===i?new Uint8Array(t):void 0===i?new Uint8Array(t,e):new Uint8Array(t,e,i),Object.setPrototypeOf(n,o.prototype),n}function d(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function p(t,e){if(o.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const i=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===i)return 0;let r=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return j(t).length;default:if(r)return n?-1:W(t).length;e=(""+e).toLowerCase(),r=!0}}function f(t,e,i){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return M(this,e,i);case"utf8":case"utf-8":return A(this,e,i);case"ascii":return C(this,e,i);case"latin1":case"binary":return P(this,e,i);case"base64":return S(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function m(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),Z(i=+i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=o.from(e,n)),o.isBuffer(e))return 0===e.length?-1:_(t,e,i,n,r);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):_(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function _(t,e,i,n,r){let s,o=1,a=t.length,l=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,l/=2,i/=2}function h(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){let n=-1;for(s=i;s<a;s++)if(h(t,s)===h(e,-1===n?0:s-n)){if(-1===n&&(n=s),s-n+1===l)return n*o}else-1!==n&&(s-=s-n),n=-1}else for(i+l>a&&(i=a-l),s=i;s>=0;s--){let i=!0;for(let n=0;n<l;n++)if(h(t,s+n)!==h(e,n)){i=!1;break}if(i)return s}return-1}function y(t,e,i,n){i=Number(i)||0;const r=t.length-i;n?(n=Number(n))>r&&(n=r):n=r;const s=e.length;let o;for(n>s/2&&(n=s/2),o=0;o<n;++o){const n=parseInt(e.substr(2*o,2),16);if(Z(n))return o;t[i+o]=n}return o}function x(t,e,i,n){return Y(W(e,t.length-i),t,i,n)}function b(t,e,i,n){return Y(function(t){const e=[];for(let i=0;i<t.length;++i)e.push(255&t.charCodeAt(i));return e}(e),t,i,n)}function v(t,e,i,n){return Y(j(e),t,i,n)}function w(t,e,i,n){return Y(function(t,e){let i,n,r;const s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)i=t.charCodeAt(o),n=i>>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function S(t,i,n){return 0===i&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(i,n))}function A(t,e,i){i=Math.min(t.length,i);const n=[];let r=e;for(;r<i;){const e=t[r];let s=null,o=e>239?4:e>223?3:e>191?2:1;if(r+o<=i){let i,n,a,l;switch(o){case 1:e<128&&(s=e);break;case 2:i=t[r+1],128==(192&i)&&(l=(31&e)<<6|63&i,l>127&&(s=l));break;case 3:i=t[r+1],n=t[r+2],128==(192&i)&&128==(192&n)&&(l=(15&e)<<12|(63&i)<<6|63&n,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:i=t[r+1],n=t[r+2],a=t[r+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(l=(15&e)<<18|(63&i)<<12|(63&n)<<6|63&a,l>65535&&l<1114112&&(s=l))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),r+=o}return function(t){const e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let i="",n=0;for(;n<e;)i+=String.fromCharCode.apply(String,t.slice(n,n+=T));return i}(n)}t.kMaxLength=r,o.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),o.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(t,e,i){return a(t,e,i)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(t,e,i){return function(t,e,i){return l(t),t<=0?s(t):void 0!==e?"string"==typeof i?s(t).fill(e,i):s(t).fill(e):s(t)}(t,e,i)},o.allocUnsafe=function(t){return h(t)},o.allocUnsafeSlow=function(t){return h(t)},o.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==o.prototype},o.compare=function(t,e){if(X(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),X(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let i=t.length,n=e.length;for(let r=0,s=Math.min(i,n);r<s;++r)if(t[r]!==e[r]){i=t[r],n=e[r];break}return i<n?-1:n<i?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return o.alloc(0);let i;if(void 0===e)for(e=0,i=0;i<t.length;++i)e+=t[i].length;const n=o.allocUnsafe(e);let r=0;for(i=0;i<t.length;++i){let e=t[i];if(X(e,Uint8Array))r+e.length>n.length?(o.isBuffer(e)||(e=o.from(e)),e.copy(n,r)):Uint8Array.prototype.set.call(n,e,r);else{if(!o.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,r)}r+=e.length}return n},o.byteLength=p,o.prototype._isBuffer=!0,o.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)g(this,e,e+1);return this},o.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},o.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},o.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):f.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===o.compare(this,t)},o.prototype.inspect=function(){let e="";const i=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(e+=" ... "),"<Buffer "+e+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(t,e,i,n,r){if(X(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;let s=(r>>>=0)-(n>>>=0),a=(i>>>=0)-(e>>>=0);const l=Math.min(s,a),h=this.slice(n,r),c=t.slice(e,i);for(let o=0;o<l;++o)if(h[o]!==c[o]){s=h[o],a=c[o];break}return s<a?-1:a<s?1:0},o.prototype.includes=function(t,e,i){return-1!==this.indexOf(t,e,i)},o.prototype.indexOf=function(t,e,i){return m(this,t,e,i,!0)},o.prototype.lastIndexOf=function(t,e,i){return m(this,t,e,i,!1)},o.prototype.write=function(t,e,i,n){if(void 0===e)n="utf8",i=this.length,e=0;else if(void 0===i&&"string"==typeof e)n=e,i=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(i)?(i>>>=0,void 0===n&&(n="utf8")):(n=i,i=void 0)}const r=this.length-e;if((void 0===i||i>r)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let s=!1;for(;;)switch(n){case"hex":return y(this,t,e,i);case"utf8":case"utf-8":return x(this,t,e,i);case"ascii":case"latin1":case"binary":return b(this,t,e,i);case"base64":return v(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function C(t,e,i){let n="";i=Math.min(t.length,i);for(let r=e;r<i;++r)n+=String.fromCharCode(127&t[r]);return n}function P(t,e,i){let n="";i=Math.min(t.length,i);for(let r=e;r<i;++r)n+=String.fromCharCode(t[r]);return n}function M(t,e,i){const n=t.length;(!e||e<0)&&(e=0),(!i||i<0||i>n)&&(i=n);let r="";for(let s=e;s<i;++s)r+=q[t[s]];return r}function E(t,e,i){const n=t.slice(e,i);let r="";for(let s=0;s<n.length-1;s+=2)r+=String.fromCharCode(n[s]+256*n[s+1]);return r}function R(t,e,i){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>i)throw new RangeError("Trying to access beyond buffer length")}function F(t,e,i,n,r,s){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||e<s)throw new RangeError('"value" argument is out of bounds');if(i+n>t.length)throw new RangeError("Index out of range")}function B(t,e,i,n,r){z(e,n,r,t,i,7);let s=Number(e&BigInt(4294967295));t[i++]=s,s>>=8,t[i++]=s,s>>=8,t[i++]=s,s>>=8,t[i++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[i++]=o,o>>=8,t[i++]=o,o>>=8,t[i++]=o,o>>=8,t[i++]=o,i}function k(t,e,i,n,r){z(e,n,r,t,i,7);let s=Number(e&BigInt(4294967295));t[i+7]=s,s>>=8,t[i+6]=s,s>>=8,t[i+5]=s,s>>=8,t[i+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[i+3]=o,o>>=8,t[i+2]=o,o>>=8,t[i+1]=o,o>>=8,t[i]=o,i+8}function I(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function D(t,e,n,r,s){return e=+e,n>>>=0,s||I(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function O(t,e,n,r,s){return e=+e,n>>>=0,s||I(t,0,n,8),i.write(t,e,n,r,52,8),n+8}o.prototype.slice=function(t,e){const i=this.length;(t=~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),(e=void 0===e?i:~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,o.prototype),n},o.prototype.readUintLE=o.prototype.readUIntLE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);let n=this[t],r=1,s=0;for(;++s<e&&(r*=256);)n+=this[t+s]*r;return n},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);let n=this[t+--e],r=1;for(;e>0&&(r*=256);)n+=this[t+--e]*r;return n},o.prototype.readUint8=o.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readBigUInt64LE=K(function(t){N(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||V(t,this.length-8);const n=e+this[++t]*__pow(2,8)+this[++t]*__pow(2,16)+this[++t]*__pow(2,24),r=this[++t]+this[++t]*__pow(2,8)+this[++t]*__pow(2,16)+i*__pow(2,24);return BigInt(n)+(BigInt(r)<<BigInt(32))}),o.prototype.readBigUInt64BE=K(function(t){N(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||V(t,this.length-8);const n=e*__pow(2,24)+this[++t]*__pow(2,16)+this[++t]*__pow(2,8)+this[++t],r=this[++t]*__pow(2,24)+this[++t]*__pow(2,16)+this[++t]*__pow(2,8)+i;return(BigInt(n)<<BigInt(32))+BigInt(r)}),o.prototype.readIntLE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);let n=this[t],r=1,s=0;for(;++s<e&&(r*=256);)n+=this[t+s]*r;return r*=128,n>=r&&(n-=Math.pow(2,8*e)),n},o.prototype.readIntBE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);let n=e,r=1,s=this[t+--n];for(;n>0&&(r*=256);)s+=this[t+--n]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*e)),s},o.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);const i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},o.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);const i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},o.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readBigInt64LE=K(function(t){N(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||V(t,this.length-8);const n=this[t+4]+this[t+5]*__pow(2,8)+this[t+6]*__pow(2,16)+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+this[++t]*__pow(2,8)+this[++t]*__pow(2,16)+this[++t]*__pow(2,24))}),o.prototype.readBigInt64BE=K(function(t){N(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||V(t,this.length-8);const n=(e<<24)+this[++t]*__pow(2,16)+this[++t]*__pow(2,8)+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*__pow(2,24)+this[++t]*__pow(2,16)+this[++t]*__pow(2,8)+i)}),o.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!1,52,8)},o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,e,i,n){t=+t,e>>>=0,i>>>=0,n||F(this,t,e,i,Math.pow(2,8*i)-1,0);let r=1,s=0;for(this[e]=255&t;++s<i&&(r*=256);)this[e+s]=t/r&255;return e+i},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,e,i,n){t=+t,e>>>=0,i>>>=0,n||F(this,t,e,i,Math.pow(2,8*i)-1,0);let r=i-1,s=1;for(this[e+r]=255&t;--r>=0&&(s*=256);)this[e+r]=t/s&255;return e+i},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,e,i){return t=+t,e>>>=0,i||F(this,t,e,1,255,0),this[e]=255&t,e+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,e,i){return t=+t,e>>>=0,i||F(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,e,i){return t=+t,e>>>=0,i||F(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,e,i){return t=+t,e>>>=0,i||F(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,e,i){return t=+t,e>>>=0,i||F(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigUInt64LE=K(function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=K(function(t,e=0){return k(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*i-1);F(this,t,e,i,n-1,-n)}let r=0,s=1,o=0;for(this[e]=255&t;++r<i&&(s*=256);)t<0&&0===o&&0!==this[e+r-1]&&(o=1),this[e+r]=(t/s|0)-o&255;return e+i},o.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*i-1);F(this,t,e,i,n-1,-n)}let r=i-1,s=1,o=0;for(this[e+r]=255&t;--r>=0&&(s*=256);)t<0&&0===o&&0!==this[e+r+1]&&(o=1),this[e+r]=(t/s|0)-o&255;return e+i},o.prototype.writeInt8=function(t,e,i){return t=+t,e>>>=0,i||F(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,i){return t=+t,e>>>=0,i||F(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeInt16BE=function(t,e,i){return t=+t,e>>>=0,i||F(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeInt32LE=function(t,e,i){return t=+t,e>>>=0,i||F(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},o.prototype.writeInt32BE=function(t,e,i){return t=+t,e>>>=0,i||F(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigInt64LE=K(function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=K(function(t,e=0){return k(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeFloatLE=function(t,e,i){return D(this,t,e,!0,i)},o.prototype.writeFloatBE=function(t,e,i){return D(this,t,e,!1,i)},o.prototype.writeDoubleLE=function(t,e,i){return O(this,t,e,!0,i)},o.prototype.writeDoubleBE=function(t,e,i){return O(this,t,e,!1,i)},o.prototype.copy=function(t,e,i,n){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<i&&(n=i),n===i)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-i&&(n=t.length-e+i);const r=n-i;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,i,n):Uint8Array.prototype.set.call(t,this.subarray(i,n),e),r},o.prototype.fill=function(t,e,i,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,i=this.length):"string"==typeof i&&(n=i,i=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!o.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<i)throw new RangeError("Out of range index");if(i<=e)return this;let r;if(e>>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(r=e;r<i;++r)this[r]=t;else{const s=o.isBuffer(t)?t:o.from(t,n),a=s.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(r=0;r<i-e;++r)this[r+e]=s[r%a]}return this};const U={};function G(t,e,i){U[t]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function L(t){let e="",i=t.length;const n="-"===t[0]?1:0;for(;i>=n+4;i-=3)e=`_${t.slice(i-3,i)}${e}`;return`${t.slice(0,i)}${e}`}function z(t,e,i,n,r,s){if(t>i||t<e){const i="bigint"==typeof e?"n":"";let n;throw n=0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(s+1)}${i}`:`>= -(2${i} ** ${8*(s+1)-1}${i}) and < 2 ** ${8*(s+1)-1}${i}`,new U.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,i){N(e,"offset"),void 0!==t[e]&&void 0!==t[e+i]||V(e,t.length-(i+1))}(n,r,s)}function N(t,e){if("number"!=typeof t)throw new U.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,i){if(Math.floor(t)!==t)throw N(t,i),new U.ERR_OUT_OF_RANGE("offset","an integer",t);if(e<0)throw new U.ERR_BUFFER_OUT_OF_BOUNDS;throw new U.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}G("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),G("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),G("ERR_OUT_OF_RANGE",function(t,e,i){let n=`The value of "${t}" is out of range.`,r=i;return Number.isInteger(i)&&Math.abs(i)>__pow(2,32)?r=L(String(i)):"bigint"==typeof i&&(r=String(i),(i>__pow(BigInt(2),BigInt(32))||i<-__pow(BigInt(2),BigInt(32)))&&(r=L(r)),r+="n"),n+=` It must be ${e}. Received ${r}`,n},RangeError);const H=/[^+/0-9A-Za-z-_]/g;function W(t,e){let i;e=e||1/0;const n=t.length;let r=null;const s=[];for(let o=0;o<n;++o){if(i=t.charCodeAt(o),i>55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function j(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(H,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,i,n){let r;for(r=0;r<n&&!(r+i>=e.length||r>=t.length);++r)e[r+i]=t[r];return r}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Z(t){return t!=t}const q=function(){const t="0123456789abcdef",e=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let r=0;r<16;++r)e[n+r]=t[i]+t[r]}return e}();function K(t){return"undefined"==typeof BigInt?$:t}function $(){throw new Error("BigInt not supported")}}(Vg)),Vg),Zg=(t,e)=>Number((e/__pow(10,t)).toFixed(t)),qg=t=>t>32767?t-65535:t,Kg=(t,e)=>e+(t<<8),$g=(t,e)=>Zg(t,qg(e)),Qg=t=>{try{let e=t.match(/.{1,2}/g);if(!e||0===e.length)return"";let i=new Uint8Array(e.length),n=0;for(let t=0;t<e.length;t++){let r=parseInt(e[t],16);r>31&&127!==r&&(i[n++]=r)}let r=i.slice(0,n);return Array.from(r).map(t=>String.fromCharCode(t)).join("")}catch(e){return console.error(e),""}},Jg=t=>{if(!t)return"";try{let e=t.match(/.{1,2}/g);if(!e)return"";let i=e.filter(t=>{let e=parseInt(t,16);return e>31&&127!==e});return 0===i.length?"":decodeURIComponent("%"+i.join("%"))}catch(e){return console.error("传入的房间名称数据有误",t),""}},tm=(t,e=1)=>{let i=[];for(let n=0;n<t.length;n+=2*e){let r=t.slice(n,n+2*e),s=parseInt(r,16);i.push(s)}return i},em=({chargeX:t,chargeY:e},{originX:i,originY:n})=>{if(t<=0&&e<=0)return null;return{x:t-i,y:e-n}},im=(t,e)=>parseInt((t+e).slice(-8),2).toString(16).padStart(2,"0"),nm=t=>{let e=parseInt(t.slice(0,2),16),i=t.slice(0,3===e?52:48),n=2,r=parseInt(i.slice(n,n+4),16);n+=4;let s=1===parseInt(i.slice(n,n+2),16);n+=2;let o=parseInt(i.slice(n,n+4),16);n+=4;let a=parseInt(i.slice(n,n+4),16);n+=4;let l=Zg(1,parseInt(i.slice(n,n+4),16));n+=4;let h=Zg(1,parseInt(i.slice(n,n+4),16));n+=4;let c=Zg(2,parseInt(i.slice(n,n+4),16));n+=4;let u=Zg(1,parseInt(i.slice(n,n+4),16));n+=4;let d,p=Zg(1,parseInt(i.slice(n,n+4),16));3===e&&(n+=4,d=parseInt(i.slice(n,n+4),16)),n+=4;let f=parseInt(i.slice(n,n+8),16);n+=8;let g=parseInt(i.slice(n,n+4),16);return{mapHeaderStr:i,version:e,id:r,mapStable:s,mapWidth:o,mapHeight:a,originX:l,originY:h,mapResolution:c,chargeX:u,chargeY:p,chargeDirection:d,chargePositionTransformed:em({chargeX:u,chargeY:p},{originX:l,originY:h}),dataLengthBeforeCompress:f,dataLengthAfterCompress:g}},rm={"00":"00","01":"f1",10:"f2",11:"ff"},sm={sweep:"00",barrier:"01",battery:"10",unknown:"11"},om={sweep:"111",barrier:"001",carpet:"010",unknown:"000"},am={0:{typeMap:sm},1:{typeMap:sm},2:{typeMap:om},3:{typeMap:om}},lm={NO_ROOM_DATA:"NO_ROOM_DATA",ROOM_GAP:"ROOM_GAP",OBSTACLE_ROOM:"OBSTACLE_ROOM",UNKNOWN_ROOM:"UNKNOWN_ROOM"};Math.imul||(Math.imul=function(t,e){let i=65535&t,n=65535&e;return i*n+((t>>>16)*n+i*(e>>>16)<<16)|0});var hm=(t,e=1048576)=>{let i=Xg.Buffer.from(t),n=1073741824,r=e;if(e>n)return r=n,console.warn("uncompress所需空间过大,强制设定为1G",e),null;let s=Xg.Buffer.alloc(r),o=function(t,e,i,n){for(var r=i=i||0,s=n=n||t.length-i,o=0;r<s;){let i=t[r++],n=i>>4;if(n>0){for(var a=n+240;255===a;)n+=a=t[r++];for(var l=r+n;r<l;)e[o++]=t[r++];if(r===s)return o}let h=t[r++]|t[r++]<<8;if(0===h||h>o)return-(r-2);let c=15&i;for(a=c+240;255===a;)c+=a=t[r++];let u=o-h;for(l=o+c+4;o<l;)e[o++]=e[u++]}return o}(i,s);return s=s.slice(0,o),s};function cm(t,e,i,n){let r=3&t,s=t>>2&63;if(1===r||62===s)i.push(e);else if(0===r&&s<=31)n.has(s)||n.set(s,[]),n.get(s).push(e);else if(0===r){let t;switch(s){case 60:t=lm.NO_ROOM_DATA;break;case 61:t=lm.ROOM_GAP;break;case 62:t=lm.OBSTACLE_ROOM;break;case 63:t=lm.UNKNOWN_ROOM}void 0!==t&&(n.has(t)||n.set(t,[]),n.get(t).push(e))}}function um(t){switch(t){case 28:return lm.NO_ROOM_DATA;case 29:return lm.ROOM_GAP;case 30:return lm.OBSTACLE_ROOM;case 31:return lm.UNKNOWN_ROOM;default:return}}function dm(t,e,i,n,r){let s=7&t,o=t>>3&31;if(1===s||30===o)i.push(e);else if(2===s)if(n.push(e),o<=27)r.has(o)||r.set(o,[]),r.get(o).push(e);else{let t=um(o);void 0!==t&&(r.has(t)||r.set(t,[]),r.get(t).push(e))}else if(7===s)if(o<=27)r.has(o)||r.set(o,[]),r.get(o).push(e);else{let t=um(o);void 0!==t&&(r.has(t)||r.set(t,[]),r.get(t).push(e))}}var pm=(t,e)=>{let{mapWidth:i,mapHeight:n,dataLengthAfterCompress:r,dataLengthBeforeCompress:s,mapHeaderStr:o,version:a}=e,l=o.length,h="",c="",u=i*n,d=[],p=[],f=new Map;if(r>0){let e=4*s,r=tm(t.slice(l,l+2*s)),o=hm(r,e);if(!o)return{mapRooms:[],mapPointsStr:"",parsed:{obstacles:new Uint32Array,carpet:new Uint32Array,rooms:new Map,width:i,height:n,totalPixels:u}};let g=Array.from(o);if(0===a){let t=[];f.set(lm.NO_ROOM_DATA,[]);for(let e=0;e<g.length;e++){let i=g[e].toString(2).padStart(8,"0");for(let n=0;n<8;n+=2){let r=i.substring(n,n+2),s=rm[r];t.push(s);let o=4*e+n/2;if(o>=u)break;switch(parseInt(r,2)){case 0:f.get(lm.NO_ROOM_DATA).push(o);break;case 1:d.push(o)}}}h=t.join("").slice(0,2*u),c=""}else{let t=g.slice(0,u),e=[];for(let i=0;i<t.length;i++){let n=t[i];e.push(n.toString(16).padStart(2,"0")),1===a?cm(n,i,d,f):dm(n,i,d,p,f)}h=e.join(""),c=g.slice(u).map(t=>t.toString(16).padStart(2,"0")).join("")}}else if(0===a){let e=[],i=t.slice(l).match(/.{2}/g)||[];f.set(lm.NO_ROOM_DATA,[]);for(let t=0;t<i.length;t++){let n=parseInt(i[t],16).toString(2).padStart(8,"0");for(let i=0;i<8;i+=2){let r=n.substring(i,i+2);e.push(rm[r]);let s=4*t+i/2;if(s>=u)break;switch(parseInt(r,2)){case 0:f.get(lm.NO_ROOM_DATA).push(s);break;case 1:d.push(s)}}}h=e.join(""),c=""}else{let e=t.slice(l,l+2*u),i=[];for(let t=0;t<u;t++){let n=e.slice(2*t,2*t+2);i.push(n);let r=parseInt(n,16);1===a?cm(r,t,d,f):dm(r,t,d,p,f)}h=i.join(""),c=t.slice(l+2*u)}h=h.toLowerCase(),i*n*2>h.length&&(h=h.padStart(i*n*2,"f")),i*n*2<h.length&&(h=h.slice(h.length-i*n*2));let g=((t,e=1)=>{if(!t)return[];let i=parseInt(t.slice(2,4),16),n=t.slice(4),r=[],s=0;for(let o=0;o<i;o++){let t=n.slice(s,s+94),i=parseInt(t.slice(0,4),16),o=parseInt(t.slice(4,8),16),a=parseInt(t.slice(8,12),16),l=parseInt(t.slice(12,16),16),h=parseInt(t.slice(16,18),16),c=1===parseInt(t.slice(18,20),16),u=1===parseInt(t.slice(20,22),16),d=parseInt(t.slice(22,24),16),p=parseInt(t.slice(24,26),16),f=1===parseInt(t.slice(26,28),16),g=parseInt(t.slice(28,30),16),m=parseInt(t.slice(52,54),16),_=t.slice(54,54+2*m),y=m>0?Jg(_):"";s+=2*(47+4*parseInt(t.slice(92,94),16));let x=im(i.toString(2),am[e].typeMap.sweep);r.push({roomId:i,pointHex:x,name:y,order:o,suction:d,cistern:p,colorOrder:h,sweepTimes:a,mopTimes:l,sweepForbidden:c,mopForbidden:u,yMop:f,floorMaterial:g,originStr:t,reservedStr:t.slice(30,52)})}return r})(c,a),m=new Map;return f.forEach((t,e)=>{t.length>0&&m.set(e,new Uint32Array(t))}),{mapRooms:g,mapPointsStr:h,parsed:{obstacles:new Uint32Array(d),carpet:new Uint32Array(p),rooms:m,width:i,height:n,totalPixels:u}}},fm=t=>{try{return JSON.parse(Qg(t))}catch(e){return console.error(e),{}}},gm=t=>{try{if(!t)return console.error("<ray-robot-protocol> decodeMap: map data is empty"),null;let e=nm(t);return{mapHeader:e,mapData:pm(t,e)}}catch(e){return console.error("<ray-robot-protocol> decodeMap:",e),null}},mm={"00":"common",10:"charge","01":"transitions",11:"mop"},_m=t=>{let e=t.slice(0,26);return{version:parseInt(e.slice(0,2),16),pathId:parseInt(e.slice(2,6),16),initFlag:parseInt(e.slice(6,8),16),type:parseInt(e.slice(8,10),16),count:parseInt(e.slice(10,18),16),direction:parseInt(e.slice(18,22),16),dataLengthAfterCompress:parseInt(e.slice(22,26),16)}},ym=(t,e)=>{let{dataLengthAfterCompress:i,count:n}=e,r=[];if(i>0){let e=4*n,i=tm(t.slice(26)),s=hm(i,e);if(!s)return[];let o=Array.from(s);for(let t=0;t<o.length;t+=4){let e=Kg(o[t],o[t+1]),i=Kg(o[t+2],o[t+3]);r.push([e,i])}}else r=function(t,e){e=void 0===e?1:Vf(fp(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var n=0,r=0,s=Array(Nf(i/e));n<i;)s[r++]=zf(t,n,n+=e);return s}(tm(t.slice(26),2),2);let s=[];for(let o=0;o<r.length;o++){let[t,e]=r[o],i=`${1&t}${1&e}`;s.push({x:$g(1,-2&t),y:-$g(1,-2&e),type:mm[i]})}return s},xm=t=>{let e=_m(t);return{pathHeader:e,pathPoints:ym(t,e)}};const bm=Object.freeze(Object.defineProperty({__proto__:null,BITMAP_TYPE_HEX_MAP:rm,BITMAP_TYPE_MAP:sm,BITMAP_TYPE_MAP_V2:om,MAP_VERSION_MAP:am,PATH_HEADER_LENGTH:13,PATH_POINT_TYPE_MAP:mm,SPECIAL_ROOM_IDS:lm,combineTwoBinaryToHex:im,dealPL:qg,decodeMap:gm,decodeMapData:pm,decodeMapHeader:nm,decodeMapStructured:fm,decodePath:xm,decodePathData:ym,decodePathHeader:_m,hexStringToNumber:tm,hexToUTF8:Qg,hexToUriDecodedString:Jg,highLowToInt:Kg,scaleNumber:Zg,transformChargeXY:em,transformXY:$g},Symbol.toStringTag,{value:"Module"}));const vm={log(t,...e){console.log(`%c[ray-2d-laser-map-sdk]%c ${t}`,"background: #2196F3; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #2196F3;",...e)},warn(t,...e){console.warn(`%c[ray-2d-laser-map-sdk]%c ${t}`,"background: #FF9800; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #FF9800;",...e)},error(t,...e){console.error(`%c[ray-2d-laser-map-sdk]%c ${t}`,"background: #F44336; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #F44336;",...e)},debug(t,...e){console.log(`%c[ray-2d-laser-map-sdk:DEBUG]%c ${t}`,"background: #9C27B0; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #9C27B0;",...e)},success(t,...e){console.log(`%c[ray-2d-laser-map-sdk]%c ${t}`,"background: #4CAF50; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #4CAF50;",...e)}},wm=t=>{if(t.length<=1)return[...t];const e=Sm(t),i=e.slice(1).map((t,i)=>({prev:e[i],current:t})),n=new Map;return i.forEach(({prev:t,current:e})=>{Am(t,e).forEach(t=>{const e=`${t.x},${t.y}`;n.has(e)||n.set(e,t)})}),Array.from(n.values())},Sm=t=>{if(t.length<=1)return[...t];const e=t[0],i=t[t.length-1];return e.x===i.x&&e.y===i.y?[...t]:[...t,e]},Am=(t,e)=>{const i=[],n=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y),s=t.x<e.x?1:-1,o=t.y<e.y?1:-1;let a=n-r,l=t.x,h=t.y;for(;i.push({x:l,y:h}),l!==e.x||h!==e.y;){const t=2*a;t>-r&&(a-=r,l+=s),t<n&&(a+=n,h+=o)}return i},Tm=(t,e,i,n,r,s=8)=>{const o={x:(e+n)/2,y:(i+r)/2},a=n-e,l=r-i,h=Math.min(s,.2*Math.min(a,l));if(Em(o,t)){if(Pm(o,t)>=h)return o}return Cm(t,o,h)},Cm=(t,e,i)=>{const{minX:n,minY:r,maxX:s,maxY:o}=Bm(t),a=s-n,l=o-r,h=e.x,c=e.y,u=Math.min(.5,.05*Math.min(a,l)),d=[];if(Em({x:h,y:c},t)){const e=Pm({x:h,y:c},t);d.push({point:{x:h,y:c},distance:e,centerDistance:0})}const p=.6*Math.max(a,l),f=Math.PI/16;for(let g=u;g<=p;g+=u){const e=f*(1+g/p);for(let a=0;a<2*Math.PI;a+=e){const e=h+g*Math.cos(a),l=c+g*Math.sin(a);if(e>=n&&e<=s&&l>=r&&l<=o){const n={x:e,y:l};if(Em(n,t)){const r=Pm(n,t),s=Om({x:e,y:l},{x:h,y:c});r>=i&&d.push({point:n,distance:r,centerDistance:s})}}}if(d.length>=15)break}if(d.length>0){const t=d.map(t=>__spreadProps(__spreadValues({},t),{score:1.5*t.distance-.5*t.centerDistance}));return t.sort((t,e)=>e.score-t.score),t[0].point}if(0===d.length){let e={x:h,y:c},i=0;const a=2*u;for(let l=n;l<=s;l+=a)for(let n=r;n<=o;n+=a){const r={x:l,y:n};if(Em(r,t)){const n=Pm(r,t);n>i&&(i=n,e=r)}}return e}return{x:h,y:c}},Pm=(t,e)=>{let i=1/0;for(let n=0,r=e.length-1;n<e.length;r=n++){const s=e[r],o=e[n],a=Mm(t,s,o);i=Math.min(i,a)}return i},Mm=(t,e,i)=>{const n=__pow(e.x-i.x,2)+__pow(e.y-i.y,2);if(0===n)return Om(t,e);const r=Math.max(0,Math.min(1,((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/n)),s=e.x+r*(i.x-e.x),o=e.y+r*(i.y-e.y);return Om(t,{x:s,y:o})},Em=(t,e,i=!1)=>{if(e.length<3)return!1;if(i&&Rm(t,e))return!0;let n=!1;for(let r=0,s=e.length-1;r<e.length;s=r++){const i=e[r].x,o=e[r].y,a=e[s].x,l=e[s].y;o>t.y!=l>t.y&&t.x<(a-i)*(t.y-o)/(l-o)+i&&(n=!n)}return n},Rm=(t,e)=>{if(e.length<2)return!1;for(let i=0;i<e.length;i++){const n=(i+1)%e.length;if(Fm(t,e[i],e[n]))return!0}return!1},Fm=(t,e,i,n=.5)=>{if(Mm(t,e,i)>n)return!1;const r=Math.min(e.x,i.x)-n,s=Math.max(e.x,i.x)+n,o=Math.min(e.y,i.y)-n,a=Math.max(e.y,i.y)+n;return t.x>=r&&t.x<=s&&t.y>=o&&t.y<=a},Bm=t=>{if(0===t.length)return{minX:0,minY:0,maxX:0,maxY:0};let e=1/0,i=1/0,n=-1/0,r=-1/0;for(const s of t)e=Math.min(e,s.x),i=Math.min(i,s.y),n=Math.max(n,s.x),r=Math.max(r,s.y);return{minX:e,minY:i,maxX:n,maxY:r}},km=t=>{const e=t.reduce((t,e)=>({x:t.x+e.x,y:t.y+e.y}),{x:0,y:0});return{x:e.x/t.length,y:e.y/t.length}},Im=t=>{if(4!==t.length)return t;const e=km(t),i=Om(t[0],t[1]),n=Om(t[1],t[2]),r=Math.atan2(t[1].y-t[0].y,t[1].x-t[0].x),s=[{x:-i/2,y:-n/2},{x:i/2,y:-n/2},{x:i/2,y:n/2},{x:-i/2,y:n/2}],o=Math.cos(r),a=Math.sin(r);return s.map(t=>({x:t.x*o-t.y*a+e.x,y:t.x*a+t.y*o+e.y}))},Dm=(t,e,i,n=10)=>{if(0===i)return 1;const r=(t.x*e.x+t.y*e.y)/i/i,s=n/i;return r<=0?s:Math.max(r,s)},Om=(t,e)=>{const i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},Um=t=>Math.sqrt(t.x*t.x+t.y*t.y),Gm=(t,e)=>({x:e.x-t.x,y:e.y-t.y}),Lm=t=>{const e=Um(t);return 0===e?{x:0,y:0}:{x:t.x/e,y:t.y/e}},zm=(t,e)=>{const i=Gm(t,e);return Lm(i)},Nm=t=>({x:-t.y,y:t.x}),Vm=(t,e)=>{const i=zm(t,e);return Nm(i)},Hm=(t,e)=>{const i=Lm(t),n=Lm(e),r={x:(i.x+n.x)/2,y:(i.y+n.y)/2};return Lm(r)},Wm=(t,e)=>{const i=Gm(t,e);let n=Math.atan2(i.y,i.x);return(n>Math.PI/2||n<-Math.PI/2)&&(n+=Math.PI),n},jm=(t,e,i)=>t.map(t=>((t,e,i)=>{const n=Math.cos(i),r=Math.sin(i),s=t.x-e.x,o=t.y-e.y;return{x:s*n-o*r+e.x,y:s*r+o*n+e.y}})(t,e,i)),Ym=(t,e,i)=>{if(0===Om(t,e))return[];const n=Vm(t,e),r=i/2;return[t.x+n.x*r,t.y+n.y*r,e.x+n.x*r,e.y+n.y*r,e.x-n.x*r,e.y-n.y*r,t.x-n.x*r,t.y-n.y*r]},Xm=(t,e,i,n)=>{const r=Gm(t,e),s=Gm(t,i),o=Hm(r,s),a=-o.x,l=-o.y;return{x:t.x+a*n,y:t.y+l*n}},Zm=(t,e)=>{let i=0,n=0;for(let r=0;r<t.length;r++){const s=t[r];i+=s%e,n+=Math.floor(s/e)}return{x:i/t.length,y:n/t.length}},qm=(t,e,i,n,r,s,o)=>{const a={x:n-10,y:t.y},l={x:s+10,y:t.y},h={x:s,y:r},c={x:s,y:o},u=Km(a,l,{x:n,y:r},{x:n,y:o}),d=Km(a,l,h,c);if(!u||!d)return null;const p=[],f=Math.max(n,Math.min(u.x,d.x)),g=Math.min(s,Math.max(u.x,d.x)),m=Math.round(t.y);for(let _=Math.round(f);_<=Math.round(g);_++){const t=m*i+_;e.has(t)&&p.push({x:_,y:m})}if(p.length>=2){const t=$m(p),n={x:(t.min.x+t.max.x)/2,y:(t.min.y+t.max.y)/2},r=Math.round(n.y)*i+Math.round(n.x);if(e.has(r))return n}return null},Km=(t,e,i,n)=>{const r=(t.x-i.x)*(e.y-i.y)-(t.y-i.y)*(e.x-i.x),s=(t.x-n.x)*(e.y-n.y)-(t.y-n.y)*(e.x-n.x);if(r*s>=0)return null;const o=(i.x-t.x)*(n.y-t.y)-(i.y-t.y)*(n.x-t.x);if(o*(o+r-s)>=0)return null;const a=o/(s-r),l=a*(e.x-t.x),h=a*(e.y-t.y);return{x:t.x+l,y:t.y+h}},$m=t=>{if(!t||0===t.length)return{min:{x:0,y:0},max:{x:0,y:0}};let e=t[0],i=t[0];const n=t=>t.x-t.y;for(let r=1;r<t.length;r++){const s=t[r];n(s)<n(e)&&(e=s),n(s)>n(i)&&(i=s)}return{min:e,max:i}},Qm=(t,e)=>({minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}),Jm=(t,e,i,n,r)=>t.x>=e&&t.x<=e+n&&t.y>=i&&t.y<=i+r,t_=(t,e,i,n)=>{const r=i/2;return"horizontal"===n?[{x:t-r,y:e},{x:t+r,y:e}]:[{x:t,y:e-r},{x:t,y:e+r}]},e_=(t,e,i)=>{const n=Bm(t),r=Bm(e),s=Math.max(0,Math.max(n.minX,r.minX)-Math.min(n.maxX,r.maxX)),o=Math.max(0,Math.max(n.minY,r.minY)-Math.min(n.maxY,r.maxY));if(s>i||o>i)return!1;let[a,l]=[t,e];e.length>t.length&&([a,l]=[e,t]);const h=Math.max(1,Math.floor(i)),c=new Map;for(const d of a){const t=`${Math.floor(d.x/h)},${Math.floor(d.y/h)}`;c.has(t)||c.set(t,[]),c.get(t).push(d)}const u=i*i;for(const d of l){const t=Math.floor(d.x/h),e=Math.floor(d.y/h);for(let i=-1;i<=1;i++)for(let n=-1;n<=1;n++){const r=`${t+i},${e+n}`,s=c.get(r);if(s)for(const t of s){const e=d.x-t.x,i=d.y-t.y;if(e*e+i*i<=u)return!0}}}return!1},i_=(t,e,i,n)=>{let[r,s]=[t,e];e.length>t.length&&([r,s]=[e,t]);const o=new Set(r),a=n*n;for(let l=0;l<s.length;l++){const t=s[l],e=t%i,r=Math.floor(t/i);for(let s=-n;s<=n;s++)for(let t=-n;t<=n;t++){const n=(r+t)*i+(e+s);if(o.has(n)){if(s*s+t*t<=a)return!0}}}return!1},n_=(t,e)=>{if(t<=1)return!0;if(0===e.length)return!1;const i=Array.from({length:t},(t,e)=>e),n=Array(t).fill(0),r=t=>(i[t]!==t&&(i[t]=r(i[t])),i[t]),s=(t,e)=>{const s=r(t),o=r(e);s!==o&&(n[s]<n[o]?i[s]=o:n[s]>n[o]?i[o]=s:(i[o]=s,n[s]++))};for(const[a,l]of e)s(a,l);const o=r(0);for(let a=1;a<t;a++)if(r(a)!==o)return!1;return!0};class r_ extends xe{constructor(){super(),__publicField(this,"dragStart",null),__publicField(this,"initialTouchDistance",null),__publicField(this,"initialScale",null),__publicField(this,"activeTouches",new Map),__publicField(this,"firstTouchId",null),__publicField(this,"secondTouchId",null),__publicField(this,"zoomFactor",.8),__publicField(this,"scaleMin",.2),__publicField(this,"scaleMax",5),__publicField(this,"originalPosition",{x:0,y:0}),__publicField(this,"targetPosition",{x:0,y:0}),__publicField(this,"centerPosition",{x:0,y:0}),__publicField(this,"originalScale",{x:1,y:1}),__publicField(this,"targetScale",{x:1,y:1}),__publicField(this,"defaultScale",{x:1,y:1}),__publicField(this,"transitionDuration",500),__publicField(this,"transitionStartTime",null),__publicField(this,"initialPinchCenter",null),__publicField(this,"isGestureValid",!0),__publicField(this,"lastTapTime",0),__publicField(this,"doubleTapDelay",300),__publicField(this,"doubleTapZoomFactor",1.5),__publicField(this,"lastTapPosition",null),__publicField(this,"tapDistanceThreshold",20),__publicField(this,"tapDetectionEnabled",!0),__publicField(this,"isGestureHijacked",!1),__publicField(this,"hijackedPointerId",null),__publicField(this,"isHijackPaused",!1),__publicField(this,"interactionGraphics"),__publicField(this,"viewportBounds"),__publicField(this,"boundResetAnimation"),__publicField(this,"debouncedStopWheelRender"),__publicField(this,"interactionState",{isInteracting:!1,isAnimating:!1,interactionTimer:null,renderReasons:new Set}),__publicField(this,"throttledAntiScale"),__publicField(this,"handleGestureHijacked",t=>{this.isGestureHijacked=!0,this.hijackedPointerId=t.pointerId,this.isHijackPaused=!1,this.clearTouches();const e=t.global.x-this.viewportBounds.x,i=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:e,y:i}),this.firstTouchId=t.pointerId,this.dragStart={x:e,y:i}});const t=O_().getApp();this.viewportBounds=t.getViewportBounds(),this.eventMode="static",this.interactionGraphics=new fl,this.interactionGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill({color:"#ffffff",alpha:0}),this.addChild(this.interactionGraphics),this.scaleMax=t.scaleMax,this.scaleMin=t.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=zg(t=>{O_().emitter.emit("antiScale",t)},16,{leading:!0,trailing:!0}),this.boundResetAnimation=this.resetAnimation.bind(this),this.debouncedStopWheelRender=Fg(()=>{t.stopRender("wheel")},300),this.setupInteraction()}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)),O_().emitter.on("gestureHijackStart",this.handleGestureHijacked),document.addEventListener("pointercancel",()=>{this.clearTouches()})}resetPan(t){const e=O_(),i=e.getApp(),n=e.appContainer;null!==this.transitionStartTime&&(i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null);const r=this.centerPosition.x-t.x*n.scale.x,s=this.centerPosition.y-t.y*n.scale.y;this.originalPosition={x:n.x,y:n.y},this.targetPosition={x:r,y:s},this.originalScale={x:n.scale.x,y:n.scale.y},this.targetScale={x:n.scale.x,y:n.scale.y};const o=Math.sqrt(__pow(n.x-r,2)+__pow(n.y-s,2)),a=(l=o,Math.pow(Math.min(1,l/1e3),.5));var l;this.transitionDuration=500+1e3*Math.min(1,Math.pow(a,2)),this.transitionStartTime=i.ticker.lastTime,i.ticker.add(this.boundResetAnimation)}setPanZoom({targetPosition:t,targetScale:e,setCenter:i=!1,setScale:n=!1}={},r=!0){const s=O_(),o=s.getApp(),a=s.appContainer;if(i&&t&&(this.centerPosition={x:t.x,y:t.y},vm.debug("[Interaction] Set center position:",this.centerPosition)),n&&e&&(this.defaultScale={x:e.x,y:e.y},vm.debug("[Interaction] Set scale:",this.defaultScale)),this.originalPosition={x:a.x,y:a.y},this.originalScale={x:a.scale.x,y:a.scale.y},this.targetPosition=t||{x:this.centerPosition.x,y:this.centerPosition.y},this.targetScale=e||this.defaultScale,!r)return a.position.set(this.targetPosition.x,this.targetPosition.y),a.scale.set(this.targetScale.x,this.targetScale.y),this.antiScale(this.targetScale.x),void(null!==this.transitionStartTime&&(o.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null));const l=Math.sqrt(__pow(a.x-this.targetPosition.x,2)+__pow(a.y-this.targetPosition.y,2));var h;var c,u;const d=.8*(h=l,Math.pow(Math.min(1,h/1e3),.5))+.2*(c=a.scale.x,u=this.targetScale.x,Math.pow(Math.min(1,Math.abs(c-u)/Math.abs(-.8)),.5));this.transitionDuration=500+1e3*Math.min(1,Math.pow(d,2)),null!==this.transitionStartTime&&(o.ticker.remove(this.boundResetAnimation),this.interactionState.isAnimating=!1,o.stopRender("animation")),this.interactionState.isAnimating=!0,o.requestRender("animation",!0),this.transitionStartTime=o.ticker.lastTime,o.ticker.add(this.boundResetAnimation)}clearTouches(){const t=O_().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,null!==this.transitionStartTime&&(t.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),this.interactionState.isInteracting=!1,t.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(),O_().emitter.off("gestureHijackStart",this.handleGestureHijacked),super.destroy()}exitGestureHijacked(){null===this.hijackedPointerId||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}pauseGestureHijack(){this.isHijackPaused=!0}resumeGestureHijack(){this.isHijackPaused=!1}antiScale(t){this.throttledAntiScale(t)}resetAnimation(){const t=O_(),e=t.getApp(),i=t.appContainer;if(null===this.transitionStartTime)return;const{targetPosition:n,targetScale:r}=this,s=e.ticker.lastTime,o=Math.min(1,(s-this.transitionStartTime)/this.transitionDuration);if(o>=1)i.position.set(n.x,n.y),i.scale.set(r.x,r.y),this.antiScale(r.x),e.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null,this.interactionState.isAnimating=!1,e.stopRender("animation");else{const t=(a=o)<.5?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1,e=this.originalPosition.x+(n.x-this.originalPosition.x)*t,s=this.originalPosition.y+(n.y-this.originalPosition.y)*t,l=this.originalScale.x+(r.x-this.originalScale.x)*t,h=this.originalScale.y+(r.y-this.originalScale.y)*t;i.position.set(e,s),i.scale.set(l,h),this.antiScale(l)}var a}onWheel(t){const e=O_();if(this.isGestureHijacked)return void vm.warn("⚠️ [onWheel] 被手势劫持阻止执行",{isGestureHijacked:this.isGestureHijacked,hijackedPointerId:this.hijackedPointerId,isHijackPaused:this.isHijackPaused});e.getApp().requestRender("wheel",!0),this.debouncedStopWheelRender();const{scaleMin:i,scaleMax:n}=this,r=e.appContainer;t.preventDefault();const s=t.global.x-this.viewportBounds.x,o=t.global.y-this.viewportBounds.y,a=(s-r.x)/r.scale.x,l=(o-r.y)/r.scale.y,h=t.deltaY>0?.95:1.05;let c=r.scale.x*h,u=r.scale.y*h;c=Math.max(i,Math.min(n,c)),u=Math.max(i,Math.min(n,u));if(!(c!==r.scale.x||u!==r.scale.y))return;const d=s-a*c,p=o-l*u;try{r.scale.set(c,u),r.position.set(d,p),this.antiScale(c)}catch(f){vm.error("❌ [onWheel] 应用缩放时发生错误:",f)}}onPointerDown(t){const e=O_();this.interactionState.isInteracting=!0,e.getApp().requestRender("interaction",!0),this.isGestureHijacked&&(t.pointerId===this.hijackedPointerId||this.isHijackPaused||this.pauseGestureHijack());const i=e.getApp(),n=e.appContainer;null!==this.transitionStartTime&&(i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),this.activeTouches.has(t.pointerId-2)&&this.activeTouches.delete(t.pointerId-2),0===this.activeTouches.size&&(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)&&1===this.activeTouches.size&&(this.isGestureValid=!0);const r=t.global.x-this.viewportBounds.x,s=t.global.y-this.viewportBounds.y;if(this.activeTouches.set(t.pointerId,{x:r,y:s}),1===this.activeTouches.size)this.firstTouchId=t.pointerId,this.dragStart={x:r,y:s};else if(2===this.activeTouches.size){const e=Array.from(this.activeTouches.keys());this.secondTouchId=e.find(t=>t!==this.firstTouchId)||t.pointerId,this.setInitialScaleAndDistance(n),this.tapDetectionEnabled=!1}}onPointerUp(t){const e=O_();if(this.isGestureHijacked){if(t.pointerId===this.hijackedPointerId)return e.emitter.emit("gestureHijackPointerUp",t),void this.exitGestureHijacked();this.isHijackPaused}if(!this.activeTouches.has(t.pointerId))return;const i=null!==this.initialTouchDistance&&null!==this.initialScale;if(this.activeTouches.delete(t.pointerId),i&&1===this.activeTouches.size&&(this.isGestureValid=!1,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null),t.pointerId===this.firstTouchId?(this.firstTouchId=null,this.dragStart=null,0===this.activeTouches.size&&this.tapDetectionEnabled&&this.detectDoubleTap(t)):t.pointerId===this.secondTouchId&&(this.secondTouchId=null),this.isGestureHijacked&&this.isHijackPaused&&1===this.activeTouches.size){Array.from(this.activeTouches.keys())[0]===this.hijackedPointerId&&this.resumeGestureHijack()}0===this.activeTouches.size&&(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=!1,e.getApp().stopRender("interaction"))}detectDoubleTap(t){const e=O_(),{interactionConfig:i}=e;if(!i.enableDoubleTapZoom)return;const n=performance.now(),r={x:t.global.x-this.viewportBounds.x,y:t.global.y-this.viewportBounds.y};n-this.lastTapTime<this.doubleTapDelay&&this.lastTapPosition&&Om(r,this.lastTapPosition)<this.tapDistanceThreshold?(this.handleDoubleTap(r),this.lastTapTime=0,this.lastTapPosition=null):(this.lastTapTime=n,this.lastTapPosition=r)}handleDoubleTap(t){const e=O_(),i=e.getApp(),n=e.appContainer,{scaleMin:r,scaleMax:s,doubleTapZoomFactor:o}=this,a=t.x,l=t.y,h=(a-n.x)/n.scale.x,c=(l-n.y)/n.scale.y;let u=n.scale.x*o,d=n.scale.y*o;u=Math.max(r,Math.min(s,u)),d=Math.max(r,Math.min(s,d)),this.originalPosition={x:n.x,y:n.y},this.originalScale={x:n.scale.x,y:n.scale.y};const p=a-h*u,f=l-c*d;this.targetPosition={x:p,y:f},this.targetScale={x:u,y:d},this.interactionState.isAnimating=!0,i.requestRender("animation",!0),this.transitionDuration=300,this.transitionStartTime=i.ticker.lastTime,i.ticker.add(this.boundResetAnimation)}onPointerMove(t){if(this.isGestureHijacked&&!this.isHijackPaused){if(t.pointerId===this.hijackedPointerId){const e=t.global.x-this.viewportBounds.x,i=t.global.y-this.viewportBounds.y;return this.activeTouches.set(t.pointerId,{x:e,y:i}),void O_().emitter.emit("gestureHijackPointerMove",t)}return}if(!this.activeTouches.has(t.pointerId)||!this.isGestureValid)return;const e=t.global.x-this.viewportBounds.x,i=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:e,y:i}),2===this.activeTouches.size&&null!==this.initialTouchDistance&&null!==this.initialScale&&this.applyPinchZoom(),1!==this.activeTouches.size||null===this.initialTouchDistance&&null===this.initialScale||(this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.secondTouchId=null),1===this.activeTouches.size&&t.pointerId===this.firstTouchId&&null!==this.dragStart&&this.applyPan(t)}applyPan(t){const e=O_(),i=this.activeTouches.get(t.pointerId),n=e.appContainer,{x:r,y:s}=this.dragStart;n.position.set(n.x+i.x-r,n.y+i.y-s),this.dragStart={x:i.x,y:i.y}}applyPinchZoom(){const t=O_().appContainer,e=Array.from(this.activeTouches.values());if(e.length<2||!this.initialTouchDistance||!this.initialScale||!this.initialPinchCenter)return;const i=Om(e[0],e[1]),n={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},r=(n.x-t.position.x)/t.scale.x,s=(n.y-t.position.y)/t.scale.y,o=__pow(i/this.initialTouchDistance,this.zoomFactor),a=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.x*o)),l=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.y*o));t.scale.set(a,l);let h=n.x-r*a,c=n.y-s*l;h+=n.x-this.initialPinchCenter.x,c+=n.y-this.initialPinchCenter.y,t.position.set(h,c),this.antiScale(a),this.initialPinchCenter=n}setInitialScaleAndDistance(t){const e=Array.from(this.activeTouches.values());e.length<2||(this.initialTouchDistance=Om(e[0],e[1]),this.initialScale={x:t.scale.x,y:t.scale.y},this.initialPinchCenter={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2})}}const s_=Symbol(),o_=Object.getPrototypeOf,a_=new WeakMap,l_=t=>(t=>t&&(a_.has(t)?a_.get(t):o_(t)===Object.prototype||o_(t)===Array.prototype))(t)&&t[s_]||null,h_=(t,e=!0)=>{a_.set(t,e)},c_={},u_=t=>"object"==typeof t&&null!==t,d_=(t,e)=>{const i=g_.get(t);if((null==i?void 0:i[0])===e)return i[1];const n=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return h_(n,!0),g_.set(t,[e,n]),Reflect.ownKeys(t).forEach(e=>{if(Object.getOwnPropertyDescriptor(n,e))return;const i=Reflect.get(t,e),{enumerable:r}=Reflect.getOwnPropertyDescriptor(t,e),s={value:i,enumerable:r,configurable:!0};if(f_.has(i))h_(i,!1);else if(p_.has(i)){const[t,e]=p_.get(i);s.value=d_(t,e())}Object.defineProperty(n,e,s)}),Object.preventExtensions(n)},p_=new WeakMap,f_=new WeakSet,g_=new WeakMap,m_=[1],__=new WeakMap;let y_=Object.is,x_=(t,e)=>new Proxy(t,e),b_=t=>u_(t)&&!f_.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer)&&!(t instanceof Promise),v_=d_,w_=(t,e,i,n)=>({deleteProperty(t,e){const r=Reflect.get(t,e);i(e);const s=Reflect.deleteProperty(t,e);return s&&n(["delete",[e],r]),s},set(r,s,o,a){const l=!t()&&Reflect.has(r,s),h=Reflect.get(r,s,a);if(l&&(y_(h,o)||__.has(o)&&y_(h,__.get(o))))return!0;i(s),u_(o)&&(o=l_(o)||o);const c=!p_.has(o)&&b_(o)?S_(o):o;return e(s,c),Reflect.set(r,s,c,a),n(["set",[s],o,h]),!0}});function S_(t={}){if(!u_(t))throw new Error("object required");const e=__.get(t);if(e)return e;let i=m_[0];const n=new Set,r=(t,e=++m_[0])=>{i!==e&&(s=i=e,n.forEach(i=>i(t,e)))};let s=i;const o=t=>(e,i)=>{const n=[...e];n[1]=[t,...n[1]],r(n,i)},a=new Map;let l=!0;const h=w_(()=>l,(t,e)=>{const i=!f_.has(e)&&p_.get(e);if(i){if("production"!==(c_?"production":void 0)&&a.has(t))throw new Error("prop listener already exists");if(n.size){const e=i[2](o(t));a.set(t,[i,e])}else a.set(t,[i])}},t=>{var e;const i=a.get(t);i&&(a.delete(t),null==(e=i[1])||e.call(i))},r),c=x_(t,h);__.set(t,c);const u=[t,(t=m_[0])=>(s!==t&&(s=t,a.forEach(([e])=>{const n=e[1](t);n>i&&(i=n)})),i),t=>{n.add(t),1===n.size&&a.forEach(([t,e],i)=>{if("production"!==(c_?"production":void 0)&&e)throw new Error("remove already exists");const n=t[2](o(i));a.set(i,[t,n])});return()=>{n.delete(t),0===n.size&&a.forEach(([t,e],i)=>{e&&(e(),a.set(i,[t]))})}}];return p_.set(c,u),Reflect.ownKeys(t).forEach(e=>{const i=Object.getOwnPropertyDescriptor(t,e);"value"in i&&i.writable&&(c[e]=t[e])}),l=!1,c}const A_=""+new URL("robot-C6x7WFAQ.png",document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||document.baseURI).href,T_=""+new URL("sleep-C_YKDk6M.json",document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||document.baseURI).href,C_="system-ui, -apple-system, sans-serif",P_=["#2563b8","#26966b","#7c3fb8","#d97706"],M_={global:{containerTop:"0px",containerLeft:"0px",containerWidth:"100%",containerHeight:"100%",backgroundColor:"#f6f6f6"},map:{autoPaddingPercent:.05,adjacencyThreshold:3,obstacleColor:"#999999",freeColor:"#ebebeb"},room:{colors:{active:["#a8c8f5","#9de5c7","#d4b9f7","#ffd399"],inactive:["#d6e7fc","#d1f4e5","#ece0fb","#fff0d9"],name:[...P_],propertyTheme:[...P_],selectionIndicatorBackground:[...P_],selectionIndicatorIcon:["#ffffff","#ffffff","#ffffff","#ffffff"],[lm.NO_ROOM_DATA]:"#ebebeb",[lm.ROOM_GAP]:"#ebebeb",[lm.OBSTACLE_ROOM]:"#ebebeb",[lm.UNKNOWN_ROOM]:"#ebebeb"},nameLabel:{fontSize:10,fontFamily:C_,fontWeight:"500"},property:{displayOrders:["cleanMode","suction","cistern","cleanTimes"],iconWidth:12,iconHeight:12,foldable:!0,offsetX:0,offsetY:4,iconGap:0,container:{backgroundColor:"#ffffff",paddingVertical:1.5,paddingHorizontal:1.5,borderRadius:16,tailHeight:2,tailWidth:10},suction:{assets:["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","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","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","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","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=="]},cistern:{assets:["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","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=","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgN8g7xBgcECfj6+/zzBQ4swJLwAAAaxJREFUaN7t2lluwzAMBFBq9SLbnfuftigQYD5SZLGpaQPoXWBgiqQdKDYMwzAMw3Wp5dySyVX8yNXEAm5kycy9CabAXG0yc7XJzNUmM1ebzFxtMnPVyczVJzP33mQdVRD132EHHjqsk5TxUE7WRYp4InZJLhFPxWL+Gl7QjPoMkmycK0DCoToySNjabCxxgzW8YTE3E94yeW8s+THveFNUTrD/NB84IWkLTdG9o2ULrGSc4PCGXAESrpEZJO2vDact4gempH1gWsS7g5K2pWkRzzAV7dKiqm0t2k5WGpclbaWpOlRaWOuMy7J4e9ChPWKatGuL1vO/HvTdFeFg9whWfW3CxQj+z2f8Z8G7Y7B+gbRPWpkTHFTtrwiatZ9cVOyEXfuOoFXbW/QlPmLKuCgXO2XRVppmcaUpahc1VfG3LUWX1lLv62AXRO0JU3VoafEsN9cLReVdzCEuNAWcMH3ynQRfzPorr1X8vBTEuTRlvChP5ojzrP+bQAl4QSjmL214oiXrY34Yvc3Wz7xm/Couyfoq8xLvU6tJpBqWPUYgx72Fr2TDMAzDMFzxDf7xFoVjSQNhAAAAAElFTkSuQmCC","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=="]},cleanMode:{assets:["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==","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAYJ+Av0Df7xBwIJBQz68wzE7woAAAAVNJREFUaN7t2d1ugzAMhmHHSUj4Kfj+r3asmxrIClKYlwzpe8446XuQgi0gAAAAgNuIxj4ZqmsI8s1RVSwvnmpyKWzpBMIII4zwWdjQCYQRRhhhhBE+hDDCCCOMMHX/IOzpxG3D0fJeSGHHe0b35VKBntSMUqLTvHlKhFZhGUiLsVu9ecNvENxP9MlkfurtzkRaeml0I89SJpKSIGUM6fBSaCQdVgo99J6YTQ45SjFPGiYpNtaexrofox5SLGgc8iDS5pCNJFX3LpYLnOIKXXvvWuSSRWMktjnkWS5hjZHY5JC9XDTUHYmJqTsSE1YciczcycbMHCRxlvU2vin7Kc4eyJ0klrzeMsBZ2GVhdxw2eiPxTXg+Do8KIzGFuyzMWVhr41vycMjCYxZW+3e5LCxZ2B6Gw0S/Mbjuk3tar3lrDfvXhbWeol2ZL5EAAAAAAOCvfQALwYE8tktFzgAAAABJRU5ErkJggg==","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","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=="]},cleanTimes:{assets:["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==","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="]},cleanOrder:{color:"#ffffff",fontFamily:C_,fontWeight:"400",fontSize:8,gapRight:2}},selectionIndicator:{iconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAANlBMVEUAAAD////////////////////////////////////////////////////////////////////xY8b8AAAAEXRSTlMA3yB/YL9Az5+QEK/vj3BQMNgNE0EAAAEySURBVGje7dnLbsJAFIPhk2RmcoO2ef+X7SJSvaJe2VWF/7UPn1AEC6iUUkoppZRS+q2x9d6XucyN6brbvPRy/TR5ZLiQjzIEFz3LEFz0sLxluKiVIbhoL0Nw0VbC4LrfMVz+jLUumksXXP6Ite7r78y4ceNK3K/20Ybfbes9XLzucZKtyK2VrFXuQvYqdyYXKrcauVG5dZIrlVud3KncOsmlyq2d3KrcGuRa5dbxeHEvctEneQXiuj6L/EYj8wuNzPcama81Mt9qZL7UyHynkflKI/ONRuYLpcxdhcxdjcxcnUxcnfwkrkzWuZDdLmS3C9ntQna7kN0uZLcL2e1CdruQ/S7kf/e7mUDWupDdLmS3C9nvQv77/4LhWmrTddfheppbX6d1H5VSSimllFJ6674BgnCK71i7vw8AAAAASUVORK5CYII=",iconWidth:12,iconHeight:12,containerWidth:16,containerHeight:16,strokeWidth:2,strokeColor:"#ffffff",borderRadius:16,offsetY:4,offsetX:0,tailHeight:2,tailWidth:6},floorType:{assets:["","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAPElEQVR4AezXMQoAMAgDwND//9n2B51EhxNcQ7gtJ7NX0wWiAAECBAgQIECAAAECBAgQWCFQb6G3/Sc7FwAA//+f4+OPAAAABklEQVQDAI04ICFaxIVcAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwAgMAAACTeJdcAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAiSURBVDjLY2hgwA5GJUYliJBYhQMwOAwWF45KDEUJXOkKAA7xNyG+w0wTAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAABgAgMAAAAm4hnjAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAjSURBVDjLY1gFBg4MQMAExGBqlDPKoS0HkuoGjXNGOcOVAwDBxwm1N3ts8gAAAABJRU5ErkJggg=="],opacity:.1,scale:.2}},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}},carpet:{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAOklEQVR4AeySSQoAMAgDp/3/n9v4ABc8eRCSUyAwmgu8xIp9WYGfFpItgBk3OPpW5HAnMxBE0NciwAcAAP//bVPdOAAAAAZJREFUAwDM4hAZDjaEjwAAAABJRU5ErkJggg==",opacity:.5,scale:.2},robot:{icon:{sizeFixed:!1,width:8,height:8,src:A_},speed:0,rotationCorrection:0,sleepAnimation:{jsonSrc:T_,framePrefix:"sleep_",width:16,height:16,sizeFixed:!1,frameCount:96,offsetX:8,offsetY:-8},ringSize:1,ringColor:"rgba(255, 68, 68, 0.2)",ringStrokeWidth:1,ringStrokeColor:"#ffffff",ringStrokeDashed:!0,ringStrokeDashArray:[4,4]},chargingStation:{icon:{sizeFixed:!1,width:8,height:8,src:"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=="},rotationCorrection:0,ringSize:1,ringColor:"rgba(255, 68, 68, 0.2)",ringStrokeWidth:1,ringStrokeColor:"#ffffff",ringStrokeDashed:!0,ringStrokeDashArray:[4,4]},interaction:{zoomRange:{min:.5,max:8},fitMinScale:1,fitMaxScale:4,enableDoubleTapZoom:!0},controls:{iconWrapperWidth:24,iconWrapperHeight:24,iconWrapperBorderRadius:16,iconWidth:12,iconHeight:12,deleteIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAG1BMVEUAAAD////////////////////////////////rTT7CAAAACHRSTlMAgL9g36+fQGFJCmkAAADFSURBVDjL3dS7DcJAEIRhniJ1SIgEBSAqQFRARguEJBTgxJqy7cDeX7ZGmtwX+fbu8+t2d7Pqsb99lqHH617XX6mZr26lrrCkdr58ljTxnTRxsHQZJwfBwXqWhoP1rmfDwfrVFA5mO3Ozm4DHRCwmZDExjwlaDPcYDrYcbDnYcrDlYM/BnoM9b+Jyvnl+tfxh+beA4elIwoGmdAjJlFIxJHIqg1hEuQRzAZ9c+dN6jmB4bj2hcYW2F5omLfe6PMH/0HLXPHpWgenjpk040QAAAABJRU5ErkJggg==",rotateIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAMAAAANIilAAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA32CAIEAQ779wz4+fUDCvilaH/gAAAZdJREFUSMftltuOxCAIhsWiVqst7/+0m5jsEIUqm72d/64M33BSWvfVP9WgzKZ4wqRyayhWojwbMwlVhfVAdAnrIeHmVK/TGWAvfOJDRAn3cGqSLURc8AJOSrcqcdIrGBT26r8EFd4FbsSBN2kDzgUnnsAOJohKwZSiBZ6PQpBG+5xP6gpWGGRgiksYDhGax0TFrWBAVzn03GqqK7igcwgces46L+DSS/IfuHDWopBBvrNdHBrdaAnuRdlH/p8xzfj7fLutkLr4JN+cyV7P535MqQQDzHnff4eRRu+DZ2dQ4Y4N8GGBK3sPa/mxwJnhoWawwG2EAxlnNXpnbqC5Yzg5Jz41VpgHe3LeVpg3hxebLV7HDgZ+Hi1YiNqmYZX339B/hNXlnpvrOTR2dgFfYlnCh66dXcCPGIwnThxoCSd5A4FYSzhwYLZZ4UO7+pcRTupRBBMciLQPFwQLfL68HTDt4fD2Jr4N8Ply91oSaeuBS9SO7BaOoLMHGeCq15tJwppTyk6qGuBG9KC6Hk6Y9ERRGXj31f/0A2zyPsVxnMRtAAAAAElFTkSuQmCC",scaleIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAIVBMVEUAAAD////////////////////////////////////////PIev5AAAACnRSTlMA7zC/QN+fgCAQTQcGNgAAAMRJREFUOMvd0jEKwkAURdFPBEkdsLFKyAYk2UIqO1uXYOUSXIJbCCiCqzTDe8Ei3qmDrz3caebH+7tHLLZ6fvZpHfFYhwaPV8jOiZ0zn5QTd3vlwIdGOXGhnDiUIytHdk7sHNk5sXNi53dg5a9lPQxDHc6vQUu5YlqjmFbGv++W1W2V5ctY5+L534vpt37E89lspr9eaKmzIfbVIfvqzJSbKTdjLsZczLkYczHmrZjyXWLKtaDcTLkZc+K2TzsTH/Xu2vkDlC8AMDsTJN8AAAAASUVORK5CYII=",moveIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAJFBMVEUAAAD///////////////////////////////////////////+0CY3pAAAAC3RSTlMAYIDvMBDPv4+fcLUOqFYAAAEWSURBVDjLvZW9isJAFIXHkLCw1S5ss9ikt00h2ETyAqn0CaxsbHwCSyvfwN7KEUQ8L2dilJPE4Z5GPFXgy5efOzP3um6i1FkZeYtGQGrJgDflSrfkSjdk6kGZekimHpTHwIZ6Xz5Ngb9JWB8C2QD4KYBrAM9wymscT7AI4GSZuRq74ly6QOZ5g+O1C6fBzHvwd9nHSfu20aKPZ75dsHPZxckSKWVg1cVfgG9XO+/iuK485az/7uKpUyamTpmYOmVi6o18+X3kH9g9r7d3PYKRtJKNeIHFw8WniR8TZRFFFUsiFlRsB7mZ9FZ0g9eNvP/AIdIHWB9/3TwObD1H0bhE2xNNU7Rc0bAN3ethoUeNHlR6zIkheQMcOzccp+sDkgAAAABJRU5ErkJggg==",moveButtonOffset:30,textFontSize:12,textFontFamily:C_,textFontWeight:"400",unitLabel:"m",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)",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)",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)",textColor:"#5d68fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},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:"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",iconSize:8,size:1,strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",textColor:"#5d68fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}}},divider:{lineColor:"#ff4444",dashLineWidth:2,dashLineDashArray:[4,3],solidLineWidth:2,endPointSize:12,endPointColor:"#ff4444",endPointStrokeColor:"#ffffff",endPointStrokeWidth:2,hitAreaThickness:30,resetDividerWhenOutOfRoom:!0,defaultExtension:20,defaultDirection:"horizontal"},detectedObject:{height:43,width:38,interactive:!1},heatmap:{cellSize:2,maxDistance:14,smoothIterations:10,heatmapAlpha:.8,colorGradients:["#FF3B30","#FF7A00","#FFA100","#FFD700","#99DD70","#2EC070","#40E0D0","#88D0E9"]},snapshot:{format:"png",quality:1,antialias:!0,resolution:(null==window?void 0:window.devicePixelRatio)||1}},E_={dividingRoomId:null,enableRoomSelection:!1,editingForbiddenSweepZoneIds:[],editingForbiddenMopZoneIds:[],editingCleanZoneIds:[],editingVirtualWallIds:[],editingSpotIds:[],roomPropertyFoldIds:[],roomSelectionMode:"checkmark",selectRoomIds:[],showRoomProperty:!1,showRoomOrder:!0,showRoomName:!0,showPath:!0,showChargingStation:!0,showRoomFloorType:!0,showCarpet:!0,showChargingStationRing:!1,showRobotRing:!1,showRobotSleepAnimation:!1},R_=["areRoomsAdjacent","resetPanZoom","getForbiddenSweepZones","getForbiddenMopZones","getCleanZones","getVirtualWalls","getSpots","getViewportCenterPoint","getMapCenterPoint","getWallPointsByViewportCenter","getForbiddenSweepZonePointsByViewportCenter","getForbiddenMopZonePointsByViewportCenter","getCleanZonePointsByViewportCenter","getSpotPointByViewportCenter","getEffectiveDividerPoints","getDividerEndPoints","snapshot","snapshotByData"],F_=["onMapFirstDrawed","onMapDrawed","onPathDrawed","onRoomPropertiesDrawed","onClickRoom","onClickRoomProperties","onRemoveForbiddenSweepZone","onRemoveForbiddenMopZone","onRemoveCleanZone","onRemoveVirtualWall","onUpdateForbiddenSweepZone","onUpdateForbiddenMopZone","onUpdateCleanZone","onUpdateVirtualWall","onUpdateSpot","onUpdateDivider","onClickForbiddenSweepZone","onClickForbiddenMopZone","onClickCleanZone","onClickVirtualWall","onClickSpot","onClickDetectedObject","onClickCustomElement"],B_="MAIN",k_=5e3;class I_{static registerInstance(t,e){this.instanceMap.set(t,e)}static unregisterInstance(t){this.instanceMap.delete(t)}static getService(){const t=this.useContext();let e=this.serviceCache.get(t);return e||(e=new D_,this.serviceCache.set(t,e)),e}static provide(t,e){this.contextStack.push(t);try{return e()}finally{this.contextStack.pop()}}static provideAsync(t,e){return __async(this,null,function*(){this.contextStack.push(t);try{return yield e()}finally{this.contextStack.pop()}})}static useContext(){const t=this.contextStack[this.contextStack.length-1];if(!t){const t=this.instanceMap.get(B_);if(!t)throw new Error("No MapApplication context found. Make sure you are calling useAppService() within a MapApplication context.");return t}return t}static hasContext(){return this.contextStack.length>0||this.instanceMap.has(B_)}static clear(){this.contextStack.length=0,this.instanceMap.clear()}}__publicField(I_,"contextStack",[]),__publicField(I_,"instanceMap",new Map),__publicField(I_,"serviceCache",new WeakMap);class D_{getApp(){return I_.useContext()}getConfig(){return this.getApp().config}getRoomData(t){return this.getApp().managers.roomsManager.getRoomPropertyById(t)}metersToPixels(t){return this.getApp().metersToPixels(t)}pixelsToMeters(t){return this.getApp().pixelsToMeters(t)}get ticker(){return this.getApp().ticker}get mapState(){return this.getApp().mapState}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 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 runtime(){return this.getApp().runtime}get runtimeSnapshot(){return function(t){const e=p_.get(t);"production"===(c_?"production":void 0)||e||console.warn("Please use proxy object");const[i,n]=e;return v_(i,n())}(this.getApp().runtime)}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}}function O_(){return I_.getService()}class U_ extends xe{constructor(t,e){super(),__publicField(this,"viewportBounds",{x:0,y:0,width:0,height:0}),__publicField(this,"maskGraphics",null),__publicField(this,"containerElement",null),this.containerElement=e||window,this.calculateViewportBounds(t.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),this.createMask()}calculateViewportBounds(t){const{containerTop:e,containerLeft:i,containerWidth:n,containerHeight:r}=t,{width:s,height:o}=this.getContainerSize(),a=this.parseSize(i,s),l=this.parseSize(e,o),h=this.parseSize(n,s),c=this.parseSize(r,o);this.viewportBounds={x:a,y:l,width:h,height:c}}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 fl,this.maskGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215),this.addChild(this.maskGraphics),this.mask=this.maskGraphics}parseSize(t,e){if(!isNaN(Number(t)))return Number(t);if((t=t.trim()).endsWith("%")){return e*(parseFloat(t)/100)}if(t.endsWith("vw")){const e=parseFloat(t)/100;return window.innerWidth*e}if(t.endsWith("vh")){const e=parseFloat(t)/100;return window.innerHeight*e}if(t.endsWith("rpx")){return parseFloat(t)*(window.innerWidth/750)}return t.endsWith("px")||!isNaN(parseFloat(t))?parseFloat(t):(vm.warn(`Cannot parse size value: ${t}`),0)}getViewportBounds(){return __spreadValues({},this.viewportBounds)}updateViewport(t){var e,i;this.calculateViewportBounds(t.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),null==(e=this.maskGraphics)||e.clear(),null==(i=this.maskGraphics)||i.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215)}addContent(t){this.addChild(t)}}const G_="roomFill",L_="free",z_="roomFloorType",N_="carpet",V_="obstacle",H_="heatmap",W_="path",j_="controls",Y_="roomInfo",X_="detectedObject",Z_="customElement",q_="customElementGif",K_="chargingStation",$_="robot",Q_=["interaction",G_,L_,z_,N_,V_,H_,W_,Y_,X_,Z_,q_,K_,$_,j_];class J_ extends xe{constructor(){super(),__publicField(this,"layers",new Map);const t=O_().getApp().getViewportBounds();this.position.set(Math.round(t.width/2),Math.round(t.height/2)),this.initializeLayers()}initializeLayers(){Object.values(Q_).forEach(t=>{const e=new xe;e.label=t,t===j_&&(e.isRenderGroup=!0),t!==z_&&t!==N_||(e.eventMode="none"),this.layers.set(t,e),this.addChild(e)})}getLayer(t){return this.layers.get(t)}addToLayer(t,e,i){const n=this.layers.get(t);return n?(void 0!==i&&(e.zIndex=i),n.addChild(e),!0):(vm.warn("[AppContainer Debug] Layer not found:",t),!1)}removeFromLayer(t,e){const i=this.layers.get(t);return!!i&&(e.parent===i&&(i.removeChild(e),!0))}clearLayer(t){const e=this.layers.get(t);return!!e&&(e.removeChildren(),!0)}setLayerVisibility(t,e){const i=this.layers.get(t);return!!i&&(i.visible=e,!0)}getLayerVisibility(t){const e=this.layers.get(t);return!!e&&e.visible}}class ty extends fl{constructor(){super();O_().appContainer.addToLayer(V_,this)}draw(t){const e=O_();this.clear(),this.setFillStyle({color:e.mapConfig.obstacleColor});for(const i of t){const t=i.coordinates;for(let e=0;e<t.length;e+=2){const i=t[e],n=t[e+1];this.rect(i,n,1,1)}}this.fill()}drawRaster(t,e){const i=O_();if(this.clear(),0!==t.length){this.setFillStyle({color:i.mapConfig.obstacleColor});for(let n=0;n<t.length;n+=k_){const r=Math.min(n+k_,t.length);for(let i=n;i<r;i++){const n=t[i],r=n%e,s=Math.floor(n/e);this.rect(r,s,1,1)}this.fill(),r<t.length&&this.setFillStyle({color:i.mapConfig.obstacleColor})}}}destroy(t){super.destroy(t)}}class ey extends fl{constructor(){super();O_().appContainer.addToLayer(L_,this)}draw(t){const e=O_();this.clear(),this.setFillStyle({color:e.mapConfig.freeColor});for(const i of t){const t=i.coordinates;for(let e=0;e<t.length;e+=2){const i=t[e],n=t[e+1];this.rect(i,n,1,1)}}this.fill()}destroy(t){super.destroy(t)}}class iy{constructor(t,e={}){var i,n;__publicField(this,"target"),__publicField(this,"isPointerDown",!1),__publicField(this,"pointerDownPos",null),__publicField(this,"clickThreshold"),__publicField(this,"stopPropagation"),__publicField(this,"clickCallback",null),this.target=t,this.clickThreshold=null!=(i=e.clickThreshold)?i:10,this.stopPropagation=null!=(n=e.stopPropagation)&&n,this.clickCallback=e.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(t){this.stopPropagation&&t.stopPropagation(),this.isPointerDown=!0,this.pointerDownPos={x:t.globalX,y:t.globalY}}handlePointerMove(t){if(this.stopPropagation&&t.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const e=t.globalX-this.pointerDownPos.x,i=t.globalY-this.pointerDownPos.y;Math.sqrt(e*e+i*i)>this.clickThreshold&&(this.isPointerDown=!1,this.pointerDownPos=null)}}handlePointerUp(t){if(this.stopPropagation&&t.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const e=t.globalX-this.pointerDownPos.x,i=t.globalY-this.pointerDownPos.y;Math.sqrt(e*e+i*i)<=this.clickThreshold&&this.clickCallback&&this.clickCallback(t,this.target)}this.isPointerDown=!1,this.pointerDownPos=null}handlePointerUpOutside(){this.isPointerDown=!1,this.pointerDownPos=null}setClickCallback(t){return this.clickCallback=t,this}setClickThreshold(t){return this.clickThreshold=t,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 ny extends xe{constructor(){super({isRenderGroup:!0}),__publicField(this,"roomGraphicsMap",new Map),__publicField(this,"roomContextMap",new Map),__publicField(this,"roomClickHandlerMap",new Map),__publicField(this,"unsubscribeFns",[]),__publicField(this,"mapWidth",0),__publicField(this,"rasterRoomDataMap",new Map);O_().appContainer.addToLayer(G_,this)}draw(t){const e=O_();this.clearRooms();const i=e.roomConfig,{selectRoomIds:n,enableRoomSelection:r}=e.runtimeSnapshot;t.forEach(t=>{var e;const s=t.id>=255,o=new fl,a=new Do,l=new Do;if(s)a.setFillStyle({color:t.color}),l.setFillStyle({color:t.color});else{const n=null!=(e=t.colorIndex)?e:0,r=i.colors.active[n%i.colors.active.length],s=i.colors.inactive[n%i.colors.inactive.length];a.setFillStyle({color:r}),l.setFillStyle({color:s})}if(a.poly(t.polyPoints).fill(),l.poly(t.polyPoints).fill(),t.outlinePoints.forEach(t=>{a.rect(t.x,t.y,1,1).fill(),l.rect(t.x,t.y,1,1).fill()}),o.context=s?a:r&&!n.includes(t.id)?l:a,!s){const e=new iy(o,{clickThreshold:10,onClick:()=>{this.handleRoomClick(t.id)}});this.roomClickHandlerMap.set(t.id,e)}this.roomGraphicsMap.set(t.id,o),this.roomContextMap.set(t.id,{activeContext:a,inactiveContext:l}),this.addChild(o)})}drawRaster(t){const e=O_();if(this.clearRooms(),this.mapWidth=t.width,0===t.sortedRooms.length)return;const{selectRoomIds:i,enableRoomSelection:n}=e.runtimeSnapshot;t.sortedRooms.forEach(t=>{this.drawRasterRoom(t,n,i)})}drawRasterRoom(t,e,i){const{roomId:n,pixelIndices:r,activeColor:s,inactiveColor:o}=t,a=new fl,l=new Do,h=new Do;l.setFillStyle({color:s}),h.setFillStyle({color:o}),this.drawPixelPointsInBatches(l,r,k_,this.mapWidth),this.drawPixelPointsInBatches(h,r,k_,this.mapWidth);const c="number"==typeof n,u=!e||c&&i.includes(n);if(a.context=e&&c&&!u?h:l,c){const t=new iy(a,{clickThreshold:10,onClick:()=>{this.handleRoomClick(n)}});this.roomClickHandlerMap.set(n,t)}this.roomGraphicsMap.set(n,a),this.roomContextMap.set(n,{activeContext:l,inactiveContext:h}),this.rasterRoomDataMap.set(n,t),this.addChild(a)}drawPixelPointsInBatches(t,e,i,n){for(let r=0;r<e.length;r+=i){const s=Math.min(r+i,e.length);for(let i=r;i<s;i++){const r=e[i],s=r%n,o=Math.floor(r/n);t.rect(s,o,1,1)}t.fill()}}handleRoomClick(t){var e,i,n;const r=O_();null==(n=null==(e=r.events)?void 0:e.onClickRoom)||n.call(e,null!=(i=r.getRoomData(t))?i:{id:t})}setRoomStateBySelectIds(t){const e=O_(),{enableRoomSelection:i}=e.runtimeSnapshot;this.roomGraphicsMap.forEach((e,n)=>{if("number"==typeof n){const r=!i||t.includes(n),s=this.roomContextMap.get(n);s&&(e.context=r?s.activeContext:s.inactiveContext)}})}setRoomState(t,e){const i=this.roomGraphicsMap.get(t),n=this.roomContextMap.get(t);i&&n?"number"==typeof t&&(i.context=e?n.activeContext:n.inactiveContext):vm.warn(`Room ${t} not found`)}setAllRoomsState(t){this.roomGraphicsMap.forEach((e,i)=>{"number"==typeof i&&this.setRoomState(i,t)})}getRoomGraphicsMap(){const t=new Map;return this.roomGraphicsMap.forEach((e,i)=>{"number"==typeof i&&t.set(i,e)}),t}getRasterRoomData(t){return this.rasterRoomDataMap.get(t)||null}getMapWidth(){return this.mapWidth}clearRooms(){0===this.children.length&&0===this.roomGraphicsMap.size||(this.removeChildren(),this.roomClickHandlerMap.forEach(t=>{try{t.destroy()}catch(e){vm.warn("Error destroying click handler:",e)}}),this.roomClickHandlerMap.clear(),this.roomGraphicsMap.clear(),this.roomContextMap.clear(),this.rasterRoomDataMap.clear())}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.clearRooms(),super.destroy()}}class ry extends xe{constructor(){super({isRenderGroup:!0}),__publicField(this,"carpetSprite",null),__publicField(this,"carpetMask",null);O_().appContainer.addToLayer(N_,this)}createCarpetFromRasterData(t,e){return __async(this,null,function*(){const i=O_();if(!i.runtimeSnapshot.showCarpet)return;if(this.clearCarpet(),0===t.length)return;const{src:n,opacity:r,scale:s}=i.carpetConfig,o=yield Ya.load(n);if(!o)return void vm.warn(`Carpet texture not found: ${n}`);const a=this.createCarpetGraphics(t,e),l=a.getLocalBounds();if(0===l.width||0===l.height)return;const h=new vl({texture:o,width:l.width,height:l.height});h.x=l.x,h.y=l.y,h.alpha=r,h.tileScale.set(s);const c=new xe;c.addChild(a),h.mask=c,this.addChild(h),this.carpetSprite=h,this.carpetMask=c,i.getApp().renderOnceNextFrame()})}createCarpetGraphics(t,e){const i=new fl;for(let n=0;n<t.length;n++){const r=t[n],s=r%e,o=Math.floor(r/e);i.rect(s,o,1,1)}return i.fill(16777215),i}clearCarpet(){if(this.carpetSprite){try{this.removeChild(this.carpetSprite),this.carpetSprite.destroy()}catch(t){vm.warn("Error destroying carpet sprite:",t)}this.carpetSprite=null}if(this.carpetMask){try{this.carpetMask.destroy()}catch(t){vm.warn("Error destroying carpet mask:",t)}this.carpetMask=null}}createCarpetFromStructuredData(t){return __async(this,null,function*(){const e=O_();if(!e.runtimeSnapshot.showCarpet)return;if(this.clearCarpet(),0===t.length)return;const{src:i,opacity:n,scale:r}=e.carpetConfig,s=yield Ya.load(i);if(!s)return void vm.warn(`Carpet texture not found: ${i}`);const o=this.createCarpetGraphicsFromStructuredData(t),a=o.getLocalBounds();if(0===a.width||0===a.height)return;const l=new vl({texture:s,width:a.width,height:a.height});l.x=a.x,l.y=a.y,l.alpha=n,l.tileScale.set(r);const h=new xe;h.addChild(o),l.mask=h,this.addChild(l),this.carpetSprite=l,this.carpetMask=h,e.getApp().renderOnceNextFrame()})}createCarpetGraphicsFromStructuredData(t){const e=new fl;for(const i of t){const t=i.coordinates;for(let i=0;i<t.length;i+=2){const n=t[i],r=t[i+1];e.rect(n,r,1,1)}}return e.fill(16777215),e}destroy(){this.clearCarpet(),super.destroy()}}class sy extends xe{constructor(){super(),__publicField(this,"throttledUpdateScale"),this.throttledUpdateScale=zg(this.updateScale.bind(this),30,{leading:!0,trailing:!0});const t=O_();this.updateScale(t.currentScale),this.registerScaleListener()}registerScaleListener(){O_().emitter.on("antiScale",this.throttledUpdateScale)}updateScale(t){0!==t&&this.scale.set(1/t)}destroy(t){O_().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class oy extends ve{constructor(t){super(t),__publicField(this,"throttledUpdateScale"),__publicField(this,"fixedWidth",0),__publicField(this,"fixedHeight",0),__publicField(this,"isFixedSizeSet",!1),__publicField(this,"sizeFixed",!0),__publicField(this,"baselineScale",1),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=zg(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,(t&&this.isFixedSizeSet||!t&&this.isFixedSizeSet)&&this.applySize()}set width(t){this.isFixedSizeSet?vm.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置宽度"):this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet?vm.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置高度"):this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){O_().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||0===this.texture.width||0===this.texture.height)return;const t=O_(),e=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const n=t.currentScale;if(0===n)return;const r=e/n,s=i/n;super.scale.set(r,s)}else super.scale.set(e/this.baselineScale,i/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():0!==t&&super.scale.set(1/t))}loadTextureAndSetSize(t,e){return __async(this,null,function*(){try{const i=O_(),n=yield Ya.load(t);this.texture=n,void 0!==e.sizeFixed&&this.setSizeFixed(e.sizeFixed),this.setFixedSize(e.width,e.height),i.getApp().renderOnceNextFrame()}catch(i){vm.error(`Failed to load texture "${t}":`,i)}})}draw(t,e){const{x:i,y:n,rotation:r=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=r,this.position.set(i,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){O_().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class ay extends sy{constructor(t){super(),__publicField(this,"background"),__publicField(this,"icon"),__publicField(this,"options"),this.options=t,this.background=new fl,this.addChild(this.background),this.icon=new oy,this.addChild(this.icon),this.eventMode="static",this.render(),this.setupHitArea(),this.setupEvents()}setupHitArea(){const t=O_().controlsConfig,e=t.iconWrapperWidth+16,i=t.iconWrapperHeight+16;this.hitArea=new D(-e/2,-i/2,e,i)}render(){return __async(this,null,function*(){this.renderBackground(),this.renderIcon()})}renderBackground(){const t=O_().controlsConfig;this.background.clear(),this.background.roundRect(-t.iconWrapperWidth/2,-t.iconWrapperHeight/2,t.iconWrapperWidth,t.iconWrapperHeight,t.iconWrapperBorderRadius).fill(this.options.backgroundColor)}renderIcon(){return __async(this,null,function*(){try{const t=O_().controlsConfig;yield this.icon.loadTextureAndSetSize(this.options.iconAlias,{width:t.iconWidth,height:t.iconHeight,sizeFixed:!1}),this.icon.visible=!0}catch(t){vm.error(`Failed to load icon: ${this.options.iconAlias}`,t)}})}destroy(){super.destroy()}}class ly extends xe{constructor(t){super(),__publicField(this,"borderOptions"),__publicField(this,"solidLine",null),__publicField(this,"dashGraphics",null),__publicField(this,"fillGraphics",null),__publicField(this,"handleAntiScale",()=>{this.drawBorder()}),this.borderOptions=__spreadValues({},t),this.drawBorder(),this.setupAntiScaleListener(),this.eventMode="none"}setupAntiScaleListener(){O_().emitter.on("antiScale",this.handleAntiScale)}drawBorder(){const{points:t=[],closePath:e=!1,style:i}=this.borderOptions;t.length<2||(this.clearBorder(),void 0!==i.fillColor&&e&&this.drawFill(t,i),i.isDashed?this.drawContinuousDashedBorder(t,e,i):this.drawSolidBorder(t,e,i))}drawFill(t,e){if(e.fillColor&&!(t.length<3)){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy()),this.fillGraphics=new fl,this.fillGraphics.setFillStyle({color:e.fillColor}),this.fillGraphics.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)this.fillGraphics.lineTo(t[e].x,t[e].y);this.fillGraphics.closePath(),this.fillGraphics.fill(),this.addChild(this.fillGraphics)}}drawSolidBorder(t,e,i){const n=O_();this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy()),this.solidLine=new fl;const r=n.getApp().toFixedSize(i.width);this.solidLine.setStrokeStyle({color:i.color,width:r}),this.solidLine.moveTo(t[0].x,t[0].y);for(let s=1;s<t.length;s++)this.solidLine.lineTo(t[s].x,t[s].y);e&&this.solidLine.lineTo(t[0].x,t[0].y),this.solidLine.stroke(),this.addChild(this.solidLine)}drawContinuousDashedBorder(t,e,i){if(t.length<2)return;if(!i.dashArray||2!==i.dashArray.length||i.dashArray[0]<=0||i.dashArray[1]<=0)return void vm.warn("Invalid dashArray:",i.dashArray);const n=O_();this.dashGraphics=new fl;const r=n.getApp().toFixedSize(i.width);this.dashGraphics.setStrokeStyle({color:i.color,width:r});const s=Math.max(n.getApp().toFixedSize(i.dashArray[0]),1),o=Math.max(n.getApp().toFixedSize(i.dashArray[1]),1),a=e?[...t,t[0]]:t;this.drawContinuousPathDashes(this.dashGraphics,a,s,o),this.dashGraphics.stroke(),this.addChild(this.dashGraphics)}drawContinuousPathDashes(t,e,i,n){if(e.length<2)return;if(i<=0||n<=0)return void vm.warn("Invalid dash parameters:",{dashLength:i,gapLength:n});const r=this.calculatePathSegments(e),s=r.reduce((t,e)=>t+e.length,0);if(0===s)return;const o=i+n;let a=0;for(;a<s;){const e=a+i;e<=s?this.drawContinuousDashSegment(t,r,a,e):this.drawContinuousDashSegment(t,r,a,s),a+=o}}calculatePathSegments(t){const e=[];for(let i=0;i<t.length-1;i++){const n=t[i],r=t[i+1],s=r.x-n.x,o=r.y-n.y,a=Math.sqrt(s*s+o*o);e.push({start:n,end:r,length:a})}return e}drawContinuousDashSegment(t,e,i,n){if(i>=n)return;let r=0,s=!1,o=null;for(const a of e){const e=r,l=r+a.length;if(l>i&&e<n){const r=Math.max(i,e),h=Math.min(n,l),c=(r-e)/a.length,u=(h-e)/a.length,d={x:a.start.x+(a.end.x-a.start.x)*c,y:a.start.y+(a.end.y-a.start.y)*c},p={x:a.start.x+(a.end.x-a.start.x)*u,y:a.start.y+(a.end.y-a.start.y)*u};if(s){if(o){Math.sqrt(Math.pow(d.x-o.x,2)+Math.pow(d.y-o.y,2))>.1&&t.lineTo(d.x,d.y)}}else t.moveTo(d.x,d.y),s=!0;t.lineTo(p.x,p.y),o=p}if(r+=a.length,r>=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=__spreadValues(__spreadValues({},this.borderOptions.style),t),this.drawBorder()}updatePoints(t){this.borderOptions.points=t,this.drawBorder()}setClosePath(t){this.borderOptions.closePath=t,this.drawBorder()}getOptions(){return __spreadValues({},this.borderOptions)}destroy(){O_().emitter.off("antiScale",this.handleAntiScale),this.clearBorder(),super.destroy()}}class hy extends fl{constructor(t){super(),__publicField(this,"fillOptions"),__publicField(this,"isDragging",!1),__publicField(this,"dragStartPosition",null),__publicField(this,"handlePointerDown",t=>{t.stopPropagation(),this.startDragging(t)}),__publicField(this,"handleDragPointerMove",t=>{var e,i;this.isDragging&&this.dragStartPosition&&(null==(i=(e=this.fillOptions).onDragMove)||i.call(e,t))}),__publicField(this,"handleDragPointerUp",()=>{var t,e;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,null==(e=(t=this.fillOptions).onDragEnd)||e.call(t))}),__publicField(this,"handleDragCancel",()=>{var t,e;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,null==(e=(t=this.fillOptions).onDragEnd)||e.call(t))}),this.fillOptions=t,this.setupInteraction(),this.setupDragEventListeners(),this.draw()}setupInteraction(){this.fillOptions.enableInteraction&&(this.eventMode="static",this.on("pointerdown",this.handlePointerDown))}setupDragEventListeners(){const{emitter:t}=O_();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=O_();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}startDragging(t){var e,i;this.isDragging=!0;const n=this.parent.toLocal(t.global);this.dragStartPosition={x:n.x,y:n.y},null==(i=(e=this.fillOptions).onDragStart)||i.call(e,t),O_().emitter.emit("gestureHijackStart",t)}draw(){const{points:t,fillColor:e}=this.fillOptions;if(t.length<3)return;this.clear();const i=t.flatMap(t=>[t.x,t.y]);this.setFillStyle({color:e}).poly(i).fill()}getDragStartPosition(){return this.dragStartPosition}updateOptions(t){this.fillOptions=__spreadValues(__spreadValues({},this.fillOptions),t),void 0!==t.enableInteraction&&(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()}}class cy extends fl{constructor(t){super(),__publicField(this,"lineOptions"),__publicField(this,"strokeContext",null),__publicField(this,"drawDashLine",()=>{const{start:t,end:e,style:i}=this.lineOptions;this.clear(),this.strokeContext&&this.strokeContext.destroy();const n=O_();this.strokeContext=new Do;const r=n.getApp().toFixedSize(i.width);this.strokeContext.setStrokeStyle({color:i.color,width:r}),this.drawDashedLineToContext(this.strokeContext,t.x,t.y,e.x,e.y,i.dashArray[0],i.dashArray[1]),this.strokeContext.stroke(),this.context=this.strokeContext}),this.lineOptions=__spreadValues({},t),this.eventMode="static",this.drawDashLine(),this.setupAntiScaleListener()}setupAntiScaleListener(){O_().emitter.on("antiScale",this.drawDashLine)}drawDashedLineToContext(t,e,i,n,r,s,o){const a=n-e,l=r-i,h=Math.sqrt(a*a+l*l);if(0===h)return;const c=O_(),u=c.getApp().toFixedSize(s),d=u+c.getApp().toFixedSize(o),p=h/d,f=Math.round(p);if(0===f)return t.moveTo(e,i),void t.lineTo(n,r);const g=h/f,m=g*(u/d),_=a/h,y=l/h;for(let x=0;x<f;x++){const n=x*g,r=n+m;if(n>=h)break;const s=Math.min(r,h),o=e+n*_,a=i+n*y,l=e+s*_,c=i+s*y;t.moveTo(o,a),t.lineTo(l,c)}}updatePoints(t,e){this.lineOptions.start=t,this.lineOptions.end=e,this.drawDashLine()}updateStyle(t){this.lineOptions.style=__spreadValues(__spreadValues({},this.lineOptions.style),t),this.drawDashLine()}getOptions(){return __spreadValues({},this.lineOptions)}destroy(){O_().emitter.off("antiScale",this.drawDashLine),this.strokeContext&&this.strokeContext.destroy(),super.destroy()}}class uy extends fl{constructor(t){super(),__publicField(this,"isDragging",!1),__publicField(this,"dragStartPosition",null),__publicField(this,"initialPosition"),__publicField(this,"handleDragPointerMove",t=>{var e,i;if(!this.isDragging||!this.dragStartPosition)return;const n=this.parent.toLocal(t.global),r=n.x-this.dragStartPosition.x,s=n.y-this.dragStartPosition.y,o={x:this.initialPosition.x+r,y:this.initialPosition.y+s};this.position.set(o.x,o.y),null==(i=(e=this.options).onDragMove)||i.call(e,o)}),__publicField(this,"handleDragPointerUp",()=>{var t,e;if(!this.isDragging)return;const i=O_();this.isDragging=!1,this.dragStartPosition=null,i.getApp().stopRender("endpoint-drag"),null==(e=(t=this.options).onDragEnd)||e.call(t)}),__publicField(this,"handleDragCancel",()=>{var t,e;if(!this.isDragging)return;const i=O_();this.isDragging=!1,this.dragStartPosition=null,i.getApp().stopRender("endpoint-drag"),null==(e=(t=this.options).onDragEnd)||e.call(t)}),this.options=t,this.initialPosition=__spreadValues({},t.position),this.position.set(t.position.x,t.position.y),this.eventMode="static",this.cursor="pointer",this.setupEvents(),this.draw(),this.setupDragEventListeners()}draw(){const t=O_(),{config:e}=this.options,i=t.getApp().toFixedSize(e.endPointSize),n=t.getApp().toFixedSize(e.endPointStrokeWidth);this.clear(),this.circle(0,0,i/2),this.fill({color:e.endPointColor}),this.stroke({color:e.endPointStrokeColor,width:n}),this.setupHitArea()}setupHitArea(){const t=O_(),{config:e}=this.options,i=Math.max(e.endPointSize/2+10,20),n=t.getApp().toFixedSize(i);this.hitArea=new mr(0,0,n)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}setupDragEventListeners(){const{emitter:t}=O_();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=O_();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 e,i;const n=O_();this.isDragging=!0,this.dragStartPosition=this.parent.toLocal(t.global),this.initialPosition={x:this.x,y:this.y},null==(i=(e=this.options).onDragStart)||i.call(e),n.getApp().requestRender("endpoint-drag",!0),O_().emitter.emit("gestureHijackStart",t)}updatePosition(t){this.position.set(t.x,t.y),this.initialPosition=__spreadValues({},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 dy extends Za{constructor(t){super(t),__publicField(this,"throttledUpdateScale"),__publicField(this,"fixedWidth",0),__publicField(this,"fixedHeight",0),__publicField(this,"isFixedSizeSet",!1),this.anchor.set(.5),this.throttledUpdateScale=zg(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applyFixedSize()}registerScaleListener(){O_().emitter.on("antiScale",this.throttledUpdateScale)}applyFixedSize(){if(!this.isFixedSizeSet)return;const t=O_().currentScale;if(0===t)return;const e=1/t;this.scale.set(e),this.element&&(this.element.style.width=`${this.fixedWidth}px`,this.element.style.height=`${this.fixedHeight}px`)}updateScale(t){this.isFixedSizeSet&&0!==t&&this.applyFixedSize()}destroy(t){O_().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}var py,fy={},gy={},my={};function _y(){if(py)return my;py=1,Object.defineProperty(my,"__esModule",{value:!0}),my.loop=my.conditional=my.parse=void 0;my.parse=function t(e,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n;if(Array.isArray(i))i.forEach(function(i){return t(e,i,n,r)});else if("function"==typeof i)i(e,n,r,t);else{var s=Object.keys(i)[0];Array.isArray(i[s])?(r[s]={},t(e,i[s],n,r[s])):r[s]=i[s](e,n,r,t)}return n};my.conditional=function(t,e){return function(i,n,r,s){e(i,n,r)&&s(i,t,n,r)}};return my.loop=function(t,e){return function(i,n,r,s){for(var o=[],a=i.pos;e(i,n,r);){var l={};if(s(i,t,n,l),i.pos===a)break;a=i.pos,o.push(l)}return o}},my}var yy,xy,by={};function vy(){if(yy)return by;yy=1,Object.defineProperty(by,"__esModule",{value:!0}),by.readBits=by.readArray=by.readUnsigned=by.readString=by.peekBytes=by.readBytes=by.peekByte=by.readByte=by.buildStream=void 0;by.buildStream=function(t){return{data:t,pos:0}};var t=function(){return function(t){return t.data[t.pos++]}};by.readByte=t;by.peekByte=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function(e){return e.data[e.pos+t]}};var e=function(t){return function(e){return e.data.subarray(e.pos,e.pos+=t)}};by.readBytes=e;by.peekBytes=function(t){return function(e){return e.data.subarray(e.pos,e.pos+t)}};by.readString=function(t){return function(i){return Array.from(e(t)(i)).map(function(t){return String.fromCharCode(t)}).join("")}};by.readUnsigned=function(t){return function(i){var n=e(2)(i);return t?(n[1]<<8)+n[0]:(n[0]<<8)+n[1]}};by.readArray=function(t,i){return function(n,r,s){for(var o="function"==typeof i?i(n,r,s):i,a=e(t),l=new Array(o),h=0;h<o;h++)l[h]=a(n);return l}};return by.readBits=function(t){return function(e){for(var i=function(t){return t.data[t.pos++]}(e),n=new Array(8),r=0;r<8;r++)n[7-r]=!!(i&1<<r);return Object.keys(t).reduce(function(e,i){var r=t[i];return r.length?e[i]=function(t,e,i){for(var n=0,r=0;r<i;r++)n+=t[e+r]&&Math.pow(2,i-r-1);return n}(n,r.index,r.length):e[i]=n[r.index],e},{})}},by}var wy,Sy={};var Ay,Ty,Cy={};var Py=function(){if(Ty)return fy;Ty=1,Object.defineProperty(fy,"__esModule",{value:!0}),fy.decompressFrames=fy.decompressFrame=fy.parseGIF=void 0;var t,e=(xy||(xy=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var e=_y(),i=vy(),n={blocks:function(t){for(var e=[],n=t.data.length,r=0,s=(0,i.readByte)()(t);0!==s&&s;s=(0,i.readByte)()(t)){if(t.pos+s>=n){var o=n-t.pos;e.push((0,i.readBytes)(o)(t)),r+=o;break}e.push((0,i.readBytes)(s)(t)),r+=s}for(var a=new Uint8Array(r),l=0,h=0;h<e.length;h++)a.set(e[h],l),l+=e[h].length;return a}},r=(0,e.conditional)({gce:[{codes:(0,i.readBytes)(2)},{byteSize:(0,i.readByte)()},{extras:(0,i.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,i.readUnsigned)(!0)},{transparentColorIndex:(0,i.readByte)()},{terminator:(0,i.readByte)()}]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&249===e[1]}),s=(0,e.conditional)({image:[{code:(0,i.readByte)()},{descriptor:[{left:(0,i.readUnsigned)(!0)},{top:(0,i.readUnsigned)(!0)},{width:(0,i.readUnsigned)(!0)},{height:(0,i.readUnsigned)(!0)},{lct:(0,i.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,i.readArray)(3,function(t,e,i){return Math.pow(2,i.descriptor.lct.size+1)})},function(t,e,i){return i.descriptor.lct.exists}),{data:[{minCodeSize:(0,i.readByte)()},n]}]},function(t){return 44===(0,i.peekByte)()(t)}),o=(0,e.conditional)({text:[{codes:(0,i.readBytes)(2)},{blockSize:(0,i.readByte)()},{preData:function(t,e,n){return(0,i.readBytes)(n.text.blockSize)(t)}},n]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&1===e[1]}),a=(0,e.conditional)({application:[{codes:(0,i.readBytes)(2)},{blockSize:(0,i.readByte)()},{id:function(t,e,n){return(0,i.readString)(n.blockSize)(t)}},n]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&255===e[1]}),l=(0,e.conditional)({comment:[{codes:(0,i.readBytes)(2)},n]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&254===e[1]}),h=[{header:[{signature:(0,i.readString)(3)},{version:(0,i.readString)(3)}]},{lsd:[{width:(0,i.readUnsigned)(!0)},{height:(0,i.readUnsigned)(!0)},{gct:(0,i.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,i.readByte)()},{pixelAspectRatio:(0,i.readByte)()}]},(0,e.conditional)({gct:(0,i.readArray)(3,function(t,e){return Math.pow(2,e.lsd.gct.size+1)})},function(t,e){return e.lsd.gct.exists}),{frames:(0,e.loop)([r,a,l,s,o],function(t){var e=(0,i.peekByte)()(t);return 33===e||44===e})}];t.default=h}(gy)),(t=gy)&&t.__esModule?t:{default:t}),i=_y(),n=vy(),r=(wy||(wy=1,Object.defineProperty(Sy,"__esModule",{value:!0}),Sy.deinterlace=void 0,Sy.deinterlace=function(t,e){for(var i=new Array(t.length),n=t.length/e,r=function(n,r){var s=t.slice(r*e,(r+1)*e);i.splice.apply(i,[n*e,e].concat(s))},s=[0,4,2,1],o=[8,8,4,2],a=0,l=0;l<4;l++)for(var h=s[l];h<n;h+=o[l])r(h,a),a++;return i}),Sy),s=(Ay||(Ay=1,Object.defineProperty(Cy,"__esModule",{value:!0}),Cy.lzw=void 0,Cy.lzw=function(t,e,i){var n,r,s,o,a,l,h,c,u,d,p,f,g,m,_,y,x=4096,b=i,v=new Array(i),w=new Array(x),S=new Array(x),A=new Array(4097);for(a=1+(r=1<<(d=t)),n=r+2,h=-1,s=(1<<(o=d+1))-1,c=0;c<r;c++)w[c]=0,S[c]=c;for(p=f=g=m=_=y=0,u=0;u<b;){if(0===m){if(f<o){p+=e[y]<<f,f+=8,y++;continue}if(c=p&s,p>>=o,f-=o,c>n||c==a)break;if(c==r){s=(1<<(o=d+1))-1,n=r+2,h=-1;continue}if(-1==h){A[m++]=S[c],h=c,g=c;continue}for(l=c,c==n&&(A[m++]=g,c=h);c>r;)A[m++]=S[c],c=w[c];g=255&S[c],A[m++]=g,n<x&&(w[n]=h,S[n]=g,0===(++n&s)&&n<x&&(o++,s+=n)),h=l}m--,v[_++]=A[m],u++}for(u=_;u<b;u++)v[u]=0;return v}),Cy);fy.parseGIF=function(t){var r=new Uint8Array(t);return(0,i.parse)((0,n.buildStream)(r),e.default)};var o=function(t,e,i){if(t.image){var n=t.image,o=n.descriptor.width*n.descriptor.height,a=(0,s.lzw)(n.data.minCodeSize,n.data.blocks,o);n.descriptor.lct.interlaced&&(a=(0,r.deinterlace)(a,n.descriptor.width));var l={pixels:a,dims:{top:t.image.descriptor.top,left:t.image.descriptor.left,width:t.image.descriptor.width,height:t.image.descriptor.height}};return n.descriptor.lct&&n.descriptor.lct.exists?l.colorTable=n.lct:l.colorTable=e,t.gce&&(l.delay=10*(t.gce.delay||10),l.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(l.transparentIndex=t.gce.transparentColorIndex)),i&&(l.patch=function(t){for(var e=t.pixels.length,i=new Uint8ClampedArray(4*e),n=0;n<e;n++){var r=4*n,s=t.pixels[n],o=t.colorTable[s]||[0,0,0];i[r]=o[0],i[r+1]=o[1],i[r+2]=o[2],i[r+3]=s!==t.transparentIndex?255:0}return i}(l)),l}console.warn("gif frame does not have associated image.")};return fy.decompressFrame=o,fy.decompressFrames=function(t,e){return t.frames.filter(function(t){return t.image}).map(function(i){return o(i,t.gct,e)})},fy}();class My{constructor(t){if(!t||!t.length)throw new Error("Invalid frames");const[{texture:{width:e,height:i}}]=t;this.width=e,this.height=i,this.frames=t,this.textures=this.frames.map(t=>t.texture),this.totalFrames=this.frames.length,this.duration=this.frames[this.totalFrames-1].end}destroy(){for(const t of this.textures)t.destroy(!0);for(const t of this.frames)t.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(t,e){var i;if(!t||0===t.byteLength)throw new Error("Invalid buffer");const n=Py.parseGIF(t);(t=>{var e;let i=null;for(const n of t.frames)i=null!=(e=n.gce)?e:i,"image"in n&&!("gce"in n)&&(n.gce=i)})(n);const r=Py.decompressFrames(n,!0),s=[],o=n.lsd.width,a=n.lsd.height,l=Re.get().createCanvas(o,a),h=l.getContext("2d",{willReadFrequently:!0}),c=Re.get().createCanvas(),u=c.getContext("2d");let d=0,p=null;const f=1e3/(null!=(i=null==e?void 0:e.fps)?i:30);for(let g=0;g<r.length;g++){const{disposalType:t=2,delay:e=f,patch:i,dims:{width:n,height:l,left:m,top:_}}=r[g];c.width=n,c.height=l,u.clearRect(0,0,n,l);const y=u.createImageData(n,l);y.data.set(i),u.putImageData(y,0,0),3===t&&(p=h.getImageData(0,0,o,a)),h.drawImage(c,m,_);const x=h.getImageData(0,0,o,a);2===t?h.clearRect(0,0,o,a):3===t&&h.putImageData(p,0,0);const b=Re.get().createCanvas(x.width,x.height);b.getContext("2d").putImageData(x,0,0),s.push({start:d,end:d+e,texture:new J({source:new Fe({resource:b})})}),d+=e}return l.width=l.height=0,c.width=c.height=0,new My(s)}}const Ey={extension:o.Asset,detection:{test:()=>__async(null,null,function*(){return!0}),add:t=>__async(null,null,function*(){return[...t,"gif"]}),remove:t=>__async(null,null,function*(){return t.filter(t=>"gif"!==t)})},loader:{name:"gifLoader",id:"gif",test:t=>".gif"===Ze.extname(t)||t.startsWith("data:image/gif"),load:(t,e)=>__async(null,null,function*(){const i=yield Re.get().fetch(t),n=yield i.arrayBuffer();return My.from(n,null==e?void 0:e.data)}),unload:t=>__async(null,null,function*(){t.destroy()})}},Ry=class t extends ve{constructor(...e){const i=e[0]instanceof My?{source:e[0]}:e[0],n=Object.assign({},t.defaultOptions,i),{scaleMode:r,source:s,fps:o,loop:a,animationSpeed:l,autoPlay:h,autoUpdate:c,onComplete:u,onFrameChange:d,onLoop:p}=n,f=__objRest(n,["scaleMode","source","fps","loop","animationSpeed","autoPlay","autoUpdate","onComplete","onFrameChange","onLoop"]);super(__spreadValues({texture:J.EMPTY},f)),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=s.textures[0],this.duration=s.frames[s.frames.length-1].end,this._source=s,this._playing=!1,this._currentTime=0,this._isConnectedToTicker=!1,Object.assign(this,{fps:o,loop:a,animationSpeed:l,autoPlay:h,autoUpdate:c,onComplete:u,onFrameChange:d,onLoop:p}),this.currentFrame=0,h&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(Ue.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Ue.shared.add(this.update,this,ke.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(t){var e,i;if(!this._playing)return;const n=this.animationSpeed*t.deltaTime/Ue.targetFPMS,r=this._currentTime+n,s=r%this.duration,o=this._source.frames.findIndex(t=>t.start<=s&&t.end>s);r>=this.duration?this.loop?(this._currentTime=s,this._updateFrameIndex(o),null==(e=this.onLoop)||e.call(this)):(this._currentTime=this.duration,this._updateFrameIndex(this.totalFrames-1),null==(i=this.onComplete)||i.call(this),this.stop()):(this._currentTime=s,this._updateFrameIndex(o))}_updateFrame(){this.dirty&&(this.texture=this._source.frames[this._currentFrame].texture,this.dirty=!1)}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(Ue.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Ue.shared.add(this.update,this),this._isConnectedToTicker=!0))}get currentFrame(){return this._currentFrame}set currentFrame(t){this._updateFrameIndex(t),this._currentTime=this._source.frames[t].start}get source(){return this._source}_updateFrameIndex(t){var e;if(t<0||t>=this.totalFrames)throw new Error(`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${t}`);this._currentFrame!==t&&(this._currentFrame=t,this.dirty=!0,null==(e=this.onFrameChange)||e.call(this,t))}get totalFrames(){return this._source.totalFrames}destroy(t=!1){this.stop(),super.destroy(),t&&this._source.destroy();const e=null;this._source=e,this.onComplete=e,this.onFrameChange=e,this.onLoop=e}clone(){const e=new t({source:this._source,autoUpdate:this._autoUpdate,loop:this.loop,autoPlay:this.autoPlay,scaleMode:this.texture.source.scaleMode,animationSpeed:this.animationSpeed,onComplete:this.onComplete,onFrameChange:this.onFrameChange,onLoop:this.onLoop});return e.dirty=!0,e}};Ry.defaultOptions={scaleMode:"linear",fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};let Fy=Ry;h.add(Ey);class By extends Fy{constructor(t){super(t),__publicField(this,"throttledUpdateScale"),__publicField(this,"fixedWidth",0),__publicField(this,"fixedHeight",0),__publicField(this,"isFixedSizeSet",!1),__publicField(this,"sizeFixed",!0),__publicField(this,"baselineScale",1),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=zg(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,(t&&this.isFixedSizeSet||!t&&this.isFixedSizeSet)&&this.applySize()}set width(t){this.isFixedSizeSet?vm.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置宽度"):this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet?vm.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置高度"):this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){O_().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||0===this.texture.width||0===this.texture.height)return;const t=O_(),e=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const n=t.currentScale;if(0===n)return;const r=e/n,s=i/n;super.scale.set(r,s)}else super.scale.set(e/this.baselineScale,i/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():0!==t&&super.scale.set(1/t))}static createFromSrc(t,e){return __async(this,null,function*(){try{const i=yield Ya.load(t),n=new By({source:i});return void 0!==e.sizeFixed&&n.setSizeFixed(e.sizeFixed),n.setFixedSize(e.width,e.height),n}catch(i){throw vm.error(`Failed to load GIF "${t}":`,i),i}})}draw(t,e){const{x:i,y:n,rotation:r=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=r,this.position.set(i,n)}destroy(t){O_().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}const ky=class t extends yl{constructor(t){super(t||[]),__publicField(this,"throttledUpdateScale"),__publicField(this,"fixedWidth",0),__publicField(this,"fixedHeight",0),__publicField(this,"isFixedSizeSet",!1),__publicField(this,"sizeFixed",!0),__publicField(this,"baselineScale",1),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=zg(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,(t&&this.isFixedSizeSet||!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(){O_().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.textures||0===this.textures.length||!this.textures[0]||0===this.textures[0].width||0===this.textures[0].height)return;const t=O_(),e=this.textures[0],i=this.fixedWidth/e.width,n=this.fixedHeight/e.height;if(this.sizeFixed){const e=t.currentScale;if(0===e||!isFinite(e)){const t=i,e=n;return void super.scale.set(t,e)}const r=i/e,s=n/e;super.scale.set(r,s)}else super.scale.set(i/this.baselineScale,n/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():0!==t&&super.scale.set(1/t))}static loadAnimationTextures(t,e="sleep_",i=96){return __async(this,null,function*(){try{yield Ya.load(t);const n=[];for(let t=0;t<i;t++){const i=t.toString().padStart(3,"0"),r=`${e}${i}.png`,s=J.from(r);s&&n.push(s)}return n}catch(n){return[]}})}setupAnimation(t){void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),this.setFixedSize(t.width,t.height),this.animationSpeed=.5,this.loop=!0,vm.log(`Animation setup complete, visible=${this.visible}, scale=(${this.scale.x.toFixed(3)}, ${this.scale.y.toFixed(3)})`)}draw(t,e){const{x:i,y:n,rotation:r=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=r,this.position.set(i,n)}play(){this.textures&&this.textures.length>0&&(super.play(),t.animatedSprites.add(this),t.startAnimationTicker())}stop(){super.stop(),t.animatedSprites.delete(this),t.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 e;(null==(e=t.animationTicker)?void 0:e.started)||(t.animationTicker||(t.animationTicker=new Ue,t.animationTicker.maxFPS=24,t.animationTicker.add(()=>{t.updateAnimations()})),t.animationTicker.start(),vm.log("🎬 [AnimationTicker] Started animation ticker"))}static updateAnimationTicker(){t.animatedSprites.size>0?t.startAnimationTicker():t.stopAnimationTicker()}static stopAnimationTicker(){var e;(null==(e=t.animationTicker)?void 0:e.started)&&(vm.log("⏸️ [AnimationTicker] Stopped animation ticker"),t.animationTicker.stop())}static updateAnimations(){if(0===t.animatedSprites.size)return;const e=O_().getApp();e.renderer.render(e.stage)}destroy(e){t.animatedSprites.delete(this),t.updateAnimationTicker(),O_().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(e)}};__publicField(ky,"animationTicker",null),__publicField(ky,"animatedSprites",new Set);let Iy=ky;class Dy extends Rl{constructor({text:t,style:e}){super({text:t,style:e}),__publicField(this,"throttledUpdateScale"),this.throttledUpdateScale=zg(this.updateScale.bind(this),20,{leading:!0,trailing:!0}),this.registerScaleListener(),this.updateScale(O_().currentScale)}registerScaleListener(){O_().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){O_().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Oy extends ay{constructor(t){super(t),__publicField(this,"isMoving",!1),__publicField(this,"dragStartPosition",null),__publicField(this,"handleMovePointerMove",t=>{var e,i;this.isMoving&&this.dragStartPosition&&(null==(i=(e=this.options).onMoveMove)||i.call(e,t))}),__publicField(this,"handleMovePointerUp",()=>{var t,e;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,null==(e=(t=this.options).onMoveEnd)||e.call(t))}),__publicField(this,"handleMoveCancel",()=>{var t,e;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,null==(e=(t=this.options).onMoveEnd)||e.call(t))}),this.setupMoveEventListeners()}setupMoveEventListeners(){const{emitter:t}=O_();t.on("gestureHijackPointerMove",this.handleMovePointerMove),t.on("gestureHijackPointerUp",this.handleMovePointerUp),t.on("gestureHijackCancel",this.handleMoveCancel)}cleanupMoveEventListeners(){const{emitter:t}=O_();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 e,i;this.isMoving=!0,this.dragStartPosition=this.parent.toLocal(t.global),null==(i=(e=this.options).onMoveStart)||i.call(e),O_().emitter.emit("gestureHijackStart",t)}isCurrentlyMoving(){return this.isMoving}getDragStartPosition(){return this.dragStartPosition?__spreadValues({},this.dragStartPosition):null}stopMoving(){var t,e;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,null==(e=(t=this.options).onMoveEnd)||e.call(t))}destroy(){this.stopMoving(),this.cleanupMoveEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Uy extends ay{constructor(t){super(t),__publicField(this,"clickHandler",null)}setupEvents(){this.clickHandler=new iy(this,{onClick:this.options.onClick,stopPropagation:!0})}destroy(){var t;null==(t=this.clickHandler)||t.destroy(),super.destroy()}}class Gy extends ay{constructor(t){super(t),__publicField(this,"isRotating",!1),__publicField(this,"rotationCenter",{x:0,y:0}),__publicField(this,"lastAngle",0),__publicField(this,"handleRotationPointerMove",t=>{var e,i;if(!this.isRotating)return;const n=this.parent.toLocal(t.global),r=Math.atan2(n.y-this.rotationCenter.y,n.x-this.rotationCenter.x),s=r-this.lastAngle;null==(i=(e=this.options).onRotationMove)||i.call(e,s),this.lastAngle=r}),__publicField(this,"handleRotationPointerUp",()=>{var t,e;this.isRotating&&(this.isRotating=!1,null==(e=(t=this.options).onRotationEnd)||e.call(t))}),__publicField(this,"handleRotationCancel",()=>{var t,e;this.isRotating&&(this.isRotating=!1,null==(e=(t=this.options).onRotationEnd)||e.call(t))}),this.setupRotationEventListeners()}setupRotationEventListeners(){const{emitter:t}=O_();O_().emitter.on("gestureHijackPointerMove",this.handleRotationPointerMove),t.on("gestureHijackPointerUp",this.handleRotationPointerUp),t.on("gestureHijackCancel",this.handleRotationCancel)}cleanupRotationEventListeners(){const{emitter:t}=O_();t.off("gestureHijackPointerMove",this.handleRotationPointerMove),t.off("gestureHijackPointerUp",this.handleRotationPointerUp),t.off("gestureHijackCancel",this.handleRotationCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(t){t.stopPropagation(),this.startRotation(t)}startRotation(t){var e,i;this.isRotating=!0;const n=this.options.getTargetPoints();this.rotationCenter=km(n);const r=this.parent.toLocal(t.global);this.lastAngle=Math.atan2(r.y-this.rotationCenter.y,r.x-this.rotationCenter.x),null==(i=(e=this.options).onRotationStart)||i.call(e,this.rotationCenter),O_().emitter.emit("gestureHijackStart",t)}isCurrentlyRotating(){return this.isRotating}stopRotation(){var t,e;this.isRotating&&(this.isRotating=!1,null==(e=(t=this.options).onRotationEnd)||e.call(t))}destroy(){this.stopRotation(),this.cleanupRotationEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Ly extends ay{constructor(t){super(t),__publicField(this,"isScaling",!1),__publicField(this,"initialButtonPosition",null),__publicField(this,"dragStartPosition",null),__publicField(this,"handleScalePointerMove",t=>{var e,i;if(!this.isScaling||!this.initialButtonPosition||!this.dragStartPosition)return;const n=this.parent.toLocal(t.global),r=n.x-this.dragStartPosition.x,s=n.y-this.dragStartPosition.y,o={x:this.initialButtonPosition.x+r,y:this.initialButtonPosition.y+s};null==(i=(e=this.options).onScaleMove)||i.call(e,o)}),__publicField(this,"handleScalePointerUp",()=>{var t,e;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,null==(e=(t=this.options).onScaleEnd)||e.call(t))}),__publicField(this,"handleScaleCancel",()=>{var t,e;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,null==(e=(t=this.options).onScaleEnd)||e.call(t))}),this.setupScaleEventListeners()}setupScaleEventListeners(){const{emitter:t}=O_();t.on("gestureHijackPointerMove",this.handleScalePointerMove),t.on("gestureHijackPointerUp",this.handleScalePointerUp),t.on("gestureHijackCancel",this.handleScaleCancel)}cleanupScaleEventListeners(){const{emitter:t}=O_();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 e,i;this.isScaling=!0,this.dragStartPosition=this.parent.toLocal(t.global);const n=this.options.getTargetPoints(),r=this.options.getButtonIndex();r>=0&&r<n.length&&(this.initialButtonPosition=__spreadValues({},n[r])),null==(i=(e=this.options).onScaleStart)||i.call(e,r),O_().emitter.emit("gestureHijackStart",t)}isCurrentlyScaling(){return this.isScaling}stopScaling(){var t,e;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,null==(e=(t=this.options).onScaleEnd)||e.call(t))}destroy(){this.stopScaling(),this.cleanupScaleEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}const zy=class t extends xe{constructor(t){super(),__publicField(this,"zoneData"),__publicField(this,"zoneType"),__publicField(this,"zoneConfig"),__publicField(this,"controlsConfig"),__publicField(this,"zoneEvents"),__publicField(this,"controlFill"),__publicField(this,"zoneBorder"),__publicField(this,"outlineBorder"),__publicField(this,"moveLine"),__publicField(this,"sizeText"),__publicField(this,"controlButtons"),__publicField(this,"deleteButton",null),__publicField(this,"rotateButton",null),__publicField(this,"scaleButton",null),__publicField(this,"moveButton",null),__publicField(this,"totalRotationAngle",0),__publicField(this,"rotationCenter",null),__publicField(this,"initialZonePoints",[]),__publicField(this,"clickHandler",null),__publicField(this,"throttledUpdateOutline"),__publicField(this,"handleDragStart",()=>{if(!this.isEditingEnabled())return;const t=O_();this.initialZonePoints=this.zoneData.points.map(t=>__spreadValues({},t)),t.getApp().requestRender("zone-drag",!0)}),__publicField(this,"handleDragMove",t=>{if(!this.isEditingEnabled()||0===this.initialZonePoints.length)return;const e=this.parent.toLocal(t.global),i=this.controlFill.getDragStartPosition();if(!i)return;const n=e.x-i.x,r=e.y-i.y;this.applyTranslation(n,r)}),__publicField(this,"handleDragEnd",()=>{var t,e;const i=O_();this.initialZonePoints=[],i.getApp().stopRender("zone-drag"),null==(e=(t=this.zoneEvents).onUpdate)||e.call(t,this.getZoneData())}),__publicField(this,"handleRotationStart",t=>{const e=O_();this.totalRotationAngle=0,this.rotationCenter=t,this.initialZonePoints=this.zoneData.points.map(t=>__spreadValues({},t)),e.getApp().requestRender("zone-rotate",!0)}),__publicField(this,"handleRotationMove",t=>{this.totalRotationAngle+=t,this.applyRotation(t)}),__publicField(this,"handleRotationEnd",()=>{var t,e;const i=O_();this.rotationCenter=null,this.totalRotationAngle=0,this.initialZonePoints=[],i.getApp().stopRender("zone-rotate"),null==(e=(t=this.zoneEvents).onUpdate)||e.call(t,this.getZoneData())}),__publicField(this,"handleScaleStart",()=>{const t=O_();this.initialZonePoints=this.zoneData.points.map(t=>__spreadValues({},t)),t.getApp().requestRender("zone-scale",!0)}),__publicField(this,"handleScaleMove",t=>{0!==this.initialZonePoints.length&&this.applyEdgeBasedScale(t)}),__publicField(this,"handleScaleEnd",()=>{var t,e;const i=O_();this.initialZonePoints=[],i.getApp().stopRender("zone-scale"),null==(e=(t=this.zoneEvents).onUpdate)||e.call(t,this.getZoneData())}),__publicField(this,"handleMoveStart",()=>{const t=O_();this.initialZonePoints=this.zoneData.points.map(t=>__spreadValues({},t)),t.getApp().requestRender("zone-move",!0)}),__publicField(this,"handleMove",t=>{var e;if(!this.isEditingEnabled()||0===this.initialZonePoints.length)return;const i=this.parent.toLocal(t.global),n=null==(e=this.moveButton)?void 0:e.getDragStartPosition();if(!n)return;const r=i.x-n.x,s=i.y-n.y;this.applyTranslation(r,s)}),__publicField(this,"handleMoveEnd",()=>{var t,e;const i=O_();this.initialZonePoints=[],i.getApp().stopRender("zone-move"),null==(e=(t=this.zoneEvents).onUpdate)||e.call(t,this.getZoneData())}),__publicField(this,"handleDelete",()=>{var t,e;null==(e=(t=this.zoneEvents).onRemove)||e.call(t,this.zoneData.id)});const{zoneData:e,zoneType:i,events:n={}}=t;this.zoneType=i,this.zoneEvents=n,this.zoneConfig=this.getZoneConfig(),this.controlsConfig=this.getControlsConfig();const r=this.validateAndCorrectZoneSize(e.points),s=Im(r);this.zoneData=__spreadProps(__spreadValues({},e),{points:s}),this.throttledUpdateOutline=zg(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.createControlButtons(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){O_().emitter.on("antiScale",this.throttledUpdateOutline)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition())}getZoneConfig(){const t=O_(),{controls:e}=t.getConfig();return e[this.zoneType]}getControlsConfig(){const t=O_(),{controls:e}=t.getConfig();return e}validateAndCorrectZoneSize(t){const e=O_();if(t.length<4)return t;const i=e.metersToPixels(this.zoneConfig.minSize),[n,r,,s]=t,o=Om(n,r),a=Om(n,s);if(o>=i&&a>=i)return t;const l=km(t),h=Lm(Gm(n,r)),c=Lm(Gm(n,s)),u=Math.max(o,i)/2,d=Math.max(a,i)/2;return[{x:l.x-h.x*u-c.x*d,y:l.y-h.y*u-c.y*d},{x:l.x+h.x*u-c.x*d,y:l.y+h.y*u-c.y*d},{x:l.x+h.x*u+c.x*d,y:l.y+h.y*u+c.y*d},{x:l.x-h.x*u+c.x*d,y:l.y-h.y*u+c.y*d}]}getEditingIdsKey(){switch(this.zoneType){case"forbiddenSweepZone":default:return"editingForbiddenSweepZoneIds";case"forbiddenMopZone":return"editingForbiddenMopZoneIds";case"cleanZone":return"editingCleanZoneIds"}}isEditingEnabled(){const t=this.getEditingIdsKey();return O_().runtimeSnapshot[t].includes(this.zoneData.id)}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 xe,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.drawZone()}createControlButtons(){const e=this.calculateOutlinePoints();if(e.length<4)return;this.deleteButton=new Uy({iconAlias:"deleteIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onClick:this.handleDelete}),this.deleteButton.position.set(e[t.BUTTON_INDICES.REMOVE].x,e[t.BUTTON_INDICES.REMOVE].y),this.rotateButton=new Gy({iconAlias:"rotateIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,onRotationStart:this.handleRotationStart,onRotationMove:this.handleRotationMove,onRotationEnd:this.handleRotationEnd}),this.rotateButton.position.set(e[t.BUTTON_INDICES.ROTATE].x,e[t.BUTTON_INDICES.ROTATE].y),this.scaleButton=new Ly({iconAlias:"scaleIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,getButtonIndex:()=>t.BUTTON_INDICES.SCALE,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(e[t.BUTTON_INDICES.SCALE].x,e[t.BUTTON_INDICES.SCALE].y);const i=this.calculateMoveButtonPosition();this.moveButton=new Oy({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.controlButtons.addChild(this.rotateButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}createControlFill(){const t=this.isEditingEnabled();return new hy({points:this.zoneData.points,fillColor:this.zoneConfig.fillColor,enableInteraction:t,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(){const t=this.isEditingEnabled()?this.zoneConfig.editing:this.zoneConfig.normal;return new ly({points:this.zoneData.points,closePath:!0,style:{color:this.zoneConfig.strokeColor,width:this.zoneConfig.strokeWidth,isDashed:t.isDashed,dashArray:t.dashArray}})}createOutlineBorder(){const t=this.calculateOutlinePoints();return new ly({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(),e=this.calculateMoveLinePoints(t);return new ly({points:e,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;return((t,e)=>{if(t.length<3)return t;const i=[];for(let n=0;n<t.length;n++){const r=t[n],s=t[(n+1)%t.length],o=t[(n-1+t.length)%t.length],a=Gm(r,s);if(0===Um(a)){i.push(r);continue}const l=Lm(a),h={x:l.y,y:-l.x},c=Gm(o,r);let u={x:0,y:0};if(Um(c)>0){const t=Lm(c);u={x:t.y,y:-t.x}}const d=Hm(u,h),p=u.x*h.x+u.y*h.y,f=1/Math.max(.1,Math.sqrt((1+p)/2)),g={x:r.x+d.x*e*f,y:r.y+d.y*e*f};i.push(g)}return i})(t,O_().getApp().toFixedSize(this.zoneConfig.outlineOffset))}calculateMoveLinePoints(e){if(e.length<4)return[];return[e[t.BUTTON_INDICES.MOVE],this.calculateMoveButtonPosition()]}createSizeText(){const t=this.calculateZoneSizeText(),e=new Dy({text:t,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.zoneConfig.textColor,align:"center"}});e.anchor.set(.5);const i=this.calculateSizeTextPosition();e.position.set(i.x,i.y);const n=this.calculateSizeTextRotation();return e.rotation=n,e.eventMode="none",e}calculateZoneSizeText(){const{points:t}=this.zoneData;if(t.length<4)return"0m*0m";const[e,i,,n]=t,r=Om(e,i),s=Om(e,n),o=O_(),a=o.pixelsToMeters(r),l=o.pixelsToMeters(s);return`${a.toFixed(1)}${this.controlsConfig.unitLabel}*${l.toFixed(1)}${this.controlsConfig.unitLabel}`}calculateSizeTextPosition(){const{points:t}=this.zoneData;if(t.length<4)return{x:0,y:0};const[e,i,n,r]=t,{textPosition:s,textOffset:o}=this.zoneConfig,a=O_().getApp().toFixedSize(o);let l,h;switch(s){case"top":{l={x:(e.x+i.x)/2,y:(e.y+i.y)/2};const t=Lm(Gm(i,e)),n={x:t.y,y:-t.x};h={x:n.x*a,y:n.y*a};break}case"right":{l={x:(i.x+n.x)/2,y:(i.y+n.y)/2};const t=Lm(Gm(i,n)),e={x:t.y,y:-t.x};h={x:e.x*a,y:e.y*a};break}case"bottom":{l={x:(r.x+n.x)/2,y:(r.y+n.y)/2};const t=Lm(Gm(r,n)),e={x:-t.y,y:t.x};h={x:e.x*a,y:e.y*a};break}case"left":{l={x:(e.x+r.x)/2,y:(e.y+r.y)/2};const t=Lm(Gm(r,e)),i={x:t.y,y:-t.x};h={x:i.x*a,y:i.y*a};break}default:l={x:(e.x+i.x)/2,y:(e.y+i.y)/2},h={x:0,y:a}}return{x:l.x+h.x,y:l.y+h.y}}calculateSizeTextRotation(){const{points:t}=this.zoneData;if(t.length<4)return 0;const[e,i,n,r]=t,{textPosition:s}=this.zoneConfig;let o,a;switch(s){case"top":default:o=e,a=i;break;case"right":o=i,a=n;break;case"bottom":o=n,a=r;break;case"left":o=r,a=e}return Wm(o,a)}calculateMoveButtonPosition(){const e=this.calculateOutlinePoints();if(e.length<4)return{x:0,y:0};const i=O_(),{controls:n}=i.getConfig(),r=e[t.BUTTON_INDICES.MOVE],s=e[2],o=e[0],a=i.getApp().toFixedSize(n.moveButtonOffset);return Xm(r,s,o,a)}applyTranslation(t,e){this.zoneData.points=this.initialZonePoints.map(i=>({x:i.x+t,y:i.y+e})),this.drawZone(),this.updateControlButtonsPosition()}applyRotation(t){this.rotationCenter&&(this.zoneData.points=jm(this.zoneData.points,this.rotationCenter,t),this.drawZone(),this.updateControlButtonsPosition())}applyEdgeBasedScale(e){if(this.initialZonePoints.length<4)return;const i=O_(),{FIXED:n}=t.BUTTON_INDICES,{x:r,y:s}=this.initialZonePoints[n],[,o,,a]=this.initialZonePoints,l={x:r,y:s},h=Gm(l,o),c=Gm(l,a),u=Gm(l,e),d=Um(h),p=Um(c);if(0===d||0===p)return;const f=i.metersToPixels(this.zoneConfig.minSize),[g,m]=[Dm(u,h,d,f),Dm(u,c,p,f)];this.zoneData.points=[l,{x:r+h.x*g,y:s+h.y*g},{x:r+h.x*g+c.x*m,y:s+h.y*g+c.y*m},{x:r+c.x*m,y:s+c.y*m}],this.drawZone(),this.updateControlButtonsPosition()}setupClickHandler(){this.clickHandler=new iy(this,{onClick:()=>{var t,e;this.isEditingEnabled()||null==(e=null==(t=this.zoneEvents)?void 0:t.onClick)||e.call(t,this.getZoneData())},stopPropagation:!1})}drawZone(){const{points:t}=this.zoneData;t.length<4||(this.controlFill.updatePoints(t),this.zoneBorder.updatePoints(t),this.updateOutlineBorder(),this.updateMoveLine(),this.updateSizeText())}updateOutlineBorder(){const t=this.calculateOutlinePoints();this.outlineBorder.updatePoints(t)}updateMoveLine(){const t=this.calculateOutlinePoints(),e=this.calculateMoveLinePoints(t);this.moveLine.updatePoints(e)}updateSizeText(){if(!this.sizeText)return;const t=this.calculateZoneSizeText();this.sizeText.updateText(t),this.updateSizeTextPosition()}updateSizeTextPosition(){if(!this.sizeText)return;const t=this.calculateSizeTextPosition();this.sizeText.position.set(t.x,t.y);const e=this.calculateSizeTextRotation();this.sizeText.rotation=e}updateControlButtonsPosition(){if(!(this.deleteButton&&this.rotateButton&&this.scaleButton&&this.moveButton))return;const e=this.calculateOutlinePoints();if(e.length<4)return;const{REMOVE:i,ROTATE:n,SCALE:r}=t.BUTTON_INDICES,s=this.calculateMoveButtonPosition();[{button:this.deleteButton,point:e[i]},{button:this.rotateButton,point:e[n]},{button:this.scaleButton,point:e[r]},{button:this.moveButton,point:s}].forEach(({button:t,point:e})=>t.position.set(e.x,e.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 t,e,i;const n=this.controlFill.isCurrentlyDragging(),r=(null==(t=this.scaleButton)?void 0:t.isCurrentlyScaling())||!1,s=(null==(e=this.rotateButton)?void 0:e.isCurrentlyRotating())||!1,o=(null==(i=this.moveButton)?void 0:i.isCurrentlyMoving())||!1;return{isDragging:n,isScaling:r,isRotating:s,isMoving:o,hasAnyOperation:n||r||s||o}}stopAllOperations(){var t,e,i;this.controlFill.stopDragging(),null==(t=this.scaleButton)||t.stopScaling(),null==(e=this.rotateButton)||e.stopRotation(),null==(i=this.moveButton)||i.stopMoving()}stopDragging(){this.controlFill.stopDragging()}stopScaling(){var t;null==(t=this.scaleButton)||t.stopScaling()}stopRotating(){var t;null==(t=this.rotateButton)||t.stopRotation()}stopMoving(){var t;null==(t=this.moveButton)||t.stopMoving()}isCurrentlyDragging(){return this.controlFill.isCurrentlyDragging()}isCurrentlyScaling(){var t;return(null==(t=this.scaleButton)?void 0:t.isCurrentlyScaling())||!1}isCurrentlyRotating(){var t;return(null==(t=this.rotateButton)?void 0:t.isCurrentlyRotating())||!1}isCurrentlyMoving(){var t;return(null==(t=this.moveButton)?void 0:t.isCurrentlyMoving())||!1}updateZoneData(t){const e=this.validateAndCorrectZoneSize(t.points),i=Im(e);this.zoneData=__spreadProps(__spreadValues({},t),{points:i}),this.drawZone(),this.updateControlButtonsPosition(),this.updateEditState()}getZoneData(){return __spreadValues({},this.zoneData)}destroy(){var t,e,i,n,r,s,o,a,l,h,c;O_().emitter.off("antiScale",this.throttledUpdateOutline),null==(t=this.clickHandler)||t.destroy(),this.clickHandler=null,null==(e=this.deleteButton)||e.destroy(),null==(i=this.rotateButton)||i.destroy(),null==(n=this.scaleButton)||n.destroy(),null==(r=this.moveButton)||r.destroy(),this.deleteButton=null,this.rotateButton=null,this.scaleButton=null,this.moveButton=null,null==(s=this.zoneBorder)||s.destroy(),null==(o=this.outlineBorder)||o.destroy(),null==(a=this.moveLine)||a.destroy(),null==(l=this.sizeText)||l.destroy(),null==(h=this.controlFill)||h.destroy(),null==(c=this.controlButtons)||c.destroy(),super.destroy()}};__publicField(zy,"BUTTON_INDICES",{REMOVE:0,ROTATE:1,SCALE:2,MOVE:3,FIXED:0});let Ny=zy;class Vy extends fl{constructor(t){super(),__publicField(this,"currentPosition",null),__publicField(this,"config"),__publicField(this,"handleScaleChange",()=>{this.redraw()}),this.setupAntiScaleListener(),this.config=t.config}setupAntiScaleListener(){O_().emitter.on("antiScale",this.handleScaleChange)}draw(t){const e=O_();this.currentPosition=t;const{ringSize:i,ringColor:n,ringStrokeWidth:r,ringStrokeColor:s,ringStrokeDashed:o,ringStrokeDashArray:a}=this.config;this.clear();const l=e.metersToPixels(i),h=e.getApp().toFixedSize(r);this.setFillStyle({color:n}),o&&a.length>=2?this.drawDashedCircle(t,l,s,h,a):this.circle(t.x,t.y,l).fill().stroke({color:s,width:h,cap:"round",join:"round"})}drawDashedCircle(t,e,i,n,r){const s=O_();this.circle(t.x,t.y,e).fill();const o=s.getApp().toFixedSize(r[0]),a=s.getApp().toFixedSize(r[1]),l=2*Math.PI*e,h=o+a,c=Math.floor(l/h);if(0===c)return void this.circle(t.x,t.y,e).stroke({color:i,width:n,cap:"round",join:"round"});const u=l/c,d=u*(o/h);for(let p=0;p<c;p++){const i=p*u/e,n=(p*u+d)/e,r=Math.max(4,Math.ceil(Math.abs(n-i)*e/2)),s=(n-i)/r;for(let o=0;o<=r;o++){const n=i+s*o,r=t.x+e*Math.cos(n),a=t.y+e*Math.sin(n);0===o?this.moveTo(r,a):this.lineTo(r,a)}}this.stroke({color:i,width:n,cap:"round",join:"round"})}redraw(){this.currentPosition&&this.draw(this.currentPosition)}destroy(){O_().emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class Hy extends oy{constructor(){super(),this.initializeSprite()}initializeSprite(){return __async(this,null,function*(){const t=O_();yield this.loadTextureAndSetSize("chargingStation",t.chargingStationConfig.icon)})}draw(t){return __async(this,arguments,function*({x:t,y:e,rotation:i}){const n=O_();__superGet(Hy.prototype,this,"draw").call(this,{x:t,y:e,rotation:i},()=>n.runtimeSnapshot.showChargingStation)})}}function Wy(t,e,i,n){let r=t[e];return function(t,e){const i=p_.get(t);let n;"production"===(c_?"production":void 0)||i||console.warn("Please use proxy object");const r=[],s=i[2];let o=!1;const a=s(t=>{r.push(t),n||(n=Promise.resolve().then(()=>{n=void 0,o&&e(r.splice(0))}))});return o=!0,()=>{o=!1,a()}}(t,()=>{const n=t[e];Object.is(r,n)||i(r=n)})}class jy extends xe{constructor(){super(),__publicField(this,"chargingStation"),__publicField(this,"ring"),__publicField(this,"unsubscribeFns",[]);const t=O_();t.appContainer.addToLayer(K_,this),this.ring=new Vy({config:t.chargingStationConfig}),this.ring.visible=t.runtimeSnapshot.showChargingStationRing,this.addChild(this.ring),this.chargingStation=new Hy,this.addChild(this.chargingStation);const e=Wy(t.runtime,"showChargingStationRing",t=>{vm.log(`[runtime] showChargingStationRing: ${t}`),this.ring.visible=t});this.unsubscribeFns.push(e)}draw(t){return __async(this,arguments,function*({x:t,y:e,rotation:i}){0===t&&0===e||(this.ring.draw({x:t,y:e}),yield this.chargingStation.draw({x:t,y:e,rotation:i}))})}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.ring.destroy(),super.destroy()}}class Yy{constructor(){__publicField(this,"obstacle",new ty),__publicField(this,"free",new ey),__publicField(this,"roomFill",new ny),__publicField(this,"carpet",new ry),__publicField(this,"chargingStation",new jy),__publicField(this,"mapBounds",{minX:0,minY:0,maxX:0,maxY:0}),__publicField(this,"lastMapId",null),__publicField(this,"roomGeometryMap",new Map),__publicField(this,"rasterRoomPixelsMap",new Map),__publicField(this,"fourColorCache",null),__publicField(this,"carpetData",null),__publicField(this,"unsubscribeFns",[]);const t=O_();this.validateColorConfig();const e=Wy(t.runtime,"enableRoomSelection",e=>{if(vm.log(`[runtime] enableRoomSelection: ${e}`),e){this.roomFill.setAllRoomsState(!1);const e=t.runtimeSnapshot.selectRoomIds;this.roomFill.setRoomStateBySelectIds(e)}else this.roomFill.setAllRoomsState(!0)}),i=Wy(t.runtime,"selectRoomIds",t=>{vm.log(`[runtime] selectRoomIds: ${t}`),this.roomFill.setRoomStateBySelectIds(t)}),n=Wy(t.runtime,"showChargingStation",t=>{vm.log(`[runtime] showChargingStation: ${t}`),this.chargingStation.visible=t}),r=Wy(t.runtime,"showCarpet",t=>{vm.log(`[runtime] showCarpet: ${t}`),t?this.createCarpet():this.carpet.clearCarpet()});this.unsubscribeFns.push(e,i,n,r)}drawMap(t){return __async(this,null,function*(){var e;const i=O_(),{id:n,obstacles:r,free:s,rooms:o,charger:a,carpet:l}=t;this.clearComponents(),this.resetGeometryData();const h=this.processRoomsGeometry(o);this.roomFill.draw(h),this.free.draw(s),this.obstacle.draw(r),this.carpetData={type:"structured",carpetData:l},this.createCarpet();const c=this.mergeLayerBounds();Ug(c,this.mapBounds)||(vm.debug("[Map] Map bounds updated:",c),this.mapBounds=c,this.lastMapId!==n&&(i.getApp().fitMapToView(this.mapBounds),this.lastMapId=n));const u=((null!=(e=t.charger.angle)?e:0)+i.chargingStationConfig.rotationCorrection)*Math.PI/180;return yield this.chargingStation.draw({x:a.coordinate[0],y:a.coordinate[1],rotation:u}),i.roomsManager.refresh(),!0})}drawRasterMap(t,e){return __async(this,null,function*(){const i=O_();this.clearComponents();const{id:n,width:r,height:s,charger:o,chargerDirection:a}=e;vm.debug("[Map] Parsed Raster Map Data",t),this.obstacle.drawRaster(t.obstacles,r),this.carpetData={type:"raster",carpetPixels:t.carpet,mapWidth:r},this.createCarpet();const l=this.processRasterData(t);this.roomFill.drawRaster(l);const h=((t,e,i)=>{let n=1/0,r=1/0,s=-1/0,o=-1/0;for(let a=0;a<t.obstacles.length;a++){const i=t.obstacles[a],l=i%e,h=Math.floor(i/e);n=Math.min(n,l),r=Math.min(r,h),s=Math.max(s,l),o=Math.max(o,h)}return t.rooms.forEach(t=>{for(let i=0;i<t.length;i++){const a=t[i],l=a%e,h=Math.floor(a/e);n=Math.min(n,l),r=Math.min(r,h),s=Math.max(s,l),o=Math.max(o,h)}}),n===1/0?{minX:0,minY:0,maxX:e,maxY:i}:{minX:Math.max(0,n),minY:Math.max(0,r),maxX:Math.min(e,s),maxY:Math.min(i,o)}})(t,r,s);Ug(h,this.mapBounds)||(vm.debug("[Map] Raster map bounds updated:",h),this.mapBounds=h,this.lastMapId!==n&&(i.getApp().fitMapToView(this.mapBounds),this.lastMapId=n));const c=(a+i.chargingStationConfig.rotationCorrection)*Math.PI/180;return yield this.chargingStation.draw({x:o.x,y:o.y,rotation:c}),this.generateRoomGeometryFromRaster(t),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}}createCarpet(){return __async(this,null,function*(){if(O_().runtimeSnapshot.showCarpet&&this.carpetData)if("raster"===this.carpetData.type){const{carpetPixels:t,mapWidth:e}=this.carpetData;yield this.carpet.createCarpetFromRasterData(t,e)}else if("structured"===this.carpetData.type){const{carpetData:t}=this.carpetData;yield this.carpet.createCarpetFromStructuredData(t)}})}processRoomsGeometry(t){if(!t)return[];const e=O_(),{active:i}=e.roomConfig.colors,n=e.roomConfig.colors[lm.UNKNOWN_ROOM];if(0===Object.keys(t).length)return this.mapBounds={minX:0,minY:0,maxX:0,maxY:0},[];const r=Object.keys(t).sort((t,e)=>Number(t)-Number(e)),s=r.filter(t=>Number(t)<255),o=r.filter(t=>Number(t)>=255),a=[],l=[];s.forEach(e=>{const{coordinates:i}=t[e];if(i.length<4)return;const n=Number(e);let r=1/0,s=1/0,o=-1/0,a=-1/0;const h=[];for(let t=0;t<i.length;t+=2){const e=i[t],n=i[t+1];r=Math.min(r,e),s=Math.min(s,n),o=Math.max(o,e),a=Math.max(a,n),h.push({x:e,y:n})}const c=new D(r,s,o-r+1,a-s+1),u=wm(h),d=u.flatMap(t=>[t.x+.5,t.y+.5]),p=Tm(u,r,s,o,a);l.push({id:n,points:h,outlinePoints:u,polyPoints:d,centerPoint:p,boundingBox:c}),this.mapBounds.minX=Math.min(this.mapBounds.minX,r),this.mapBounds.minY=Math.min(this.mapBounds.minY,s),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,o),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,a)});const h=[...l].sort((t,e)=>{const i=t.outlinePoints.length;return e.outlinePoints.length-i}),c=this.assignColorsUsingFourColorAlgorithm(h,i.length,"structured");return l.forEach(t=>{const e=c.get(t.id)||0,n=i[e],r={id:t.id,color:n,colorIndex:e,boundingBox:t.boundingBox,points:t.points,outlinePoints:t.outlinePoints,polyPoints:t.polyPoints,centerPoint:t.centerPoint};this.roomGeometryMap.set(t.id,r),a.push(r)}),o.forEach(e=>{const{coordinates:i}=t[e];if(i.length<4)return;const r=Number(e);let s=1/0,o=1/0,l=-1/0,h=-1/0;const c=[];for(let t=0;t<i.length;t+=2){const e=i[t],n=i[t+1];s=Math.min(s,e),o=Math.min(o,n),l=Math.max(l,e),h=Math.max(h,n),c.push({x:e,y:n})}const u=new D(s,o,l-s+1,h-o+1),d=wm(c),p=d.flatMap(t=>[t.x+.5,t.y+.5]),f=Tm(d,s,o,l,h),g={id:r,color:n,boundingBox:u,points:c,outlinePoints:d,polyPoints:p,centerPoint:f};a.push(g),this.mapBounds.minX=Math.min(this.mapBounds.minX,s),this.mapBounds.minY=Math.min(this.mapBounds.minY,o),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,l),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,h)}),a}mergeLayerBounds(){let t=__spreadValues({},this.mapBounds);if(this.obstacle.bounds&&(t=Qm(t,this.obstacle.bounds)),this.roomFill.children.length>0){const e=this.roomFill.getLocalBounds();e.width>0&&e.height>0&&(t=Qm(t,{minX:e.x,minY:e.y,maxX:e.x+e.width,maxY:e.y+e.height}))}return t}getRoomById(t){return this.roomGeometryMap.get(t)}clearComponents(){this.obstacle.clear(),this.obstacle.destroy(),this.obstacle=new ty,this.free.clear(),this.free.destroy(),this.free=new ey,this.carpet.clearCarpet(),this.carpetData=null,this.roomFill.removeChildren(),this.roomFill.destroy(),this.roomFill=new ny}processRasterData(t){const e=O_().roomConfig,i=[],n=[];t.rooms.forEach((t,e)=>{"number"==typeof e?i.push([e,t]):n.push([e,t])}),i.sort(([t],[e])=>t-e);const r=i.map(([t,e])=>({id:t,pixels:e})).sort((t,e)=>e.pixels.length-t.pixels.length),s=this.assignColorsUsingFourColorAlgorithm(r,e.colors.active.length,"raster"),o=[...i.map(([t,i])=>{const n=s.get(t)||0;return{roomId:t,pixelIndices:i,activeColor:e.colors.active[n],inactiveColor:e.colors.inactive[n%e.colors.inactive.length],colorIndex:n}}),...n.map(([t,i])=>{const n=e.colors[t]||"#ebebeb";return{roomId:t,pixelIndices:i,activeColor:n,inactiveColor:n}})];return{obstacles:t.obstacles,carpet:t.carpet,sortedRooms:o,width:t.width,height:t.height,totalPixels:t.totalPixels}}generateRoomGeometryFromRaster(t){const e=O_();this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear();const{active:i}=e.roomConfig.colors,n=[];t.rooms.forEach((t,e)=>{"number"==typeof e&&n.push(e)}),n.sort((t,e)=>t-e);const r=[];n.forEach(e=>{const i=t.rooms.get(e);this.rasterRoomPixelsMap.set(e,i);let n=1/0,s=1/0,o=-1/0,a=-1/0;for(let r=0;r<i.length;r++){const e=i[r],l=e%t.width,h=Math.floor(e/t.width);n=Math.min(n,l),s=Math.min(s,h),o=Math.max(o,l),a=Math.max(a,h)}const l=((t,e,i,n,r,s)=>{const o=new Set(t),a=Zm(t,e),l=qm(a,o,e,i,n,r,s);return l||a})(i,t.width,n,s,o,a),h=new D(n,s,o-n+1,a-s+1);r.push({id:e,pixelIndices:i,boundingBox:h,centerPoint:l})});const s=[...r].sort((t,e)=>e.pixelIndices.length-t.pixelIndices.length),o=this.assignColorsUsingFourColorAlgorithm(s,i.length,"raster");r.forEach(t=>{const e=o.get(t.id)||0,n=i[e],r={id:t.id,color:n,colorIndex:e,boundingBox:t.boundingBox,points:[],outlinePoints:[],polyPoints:[],centerPoint:t.centerPoint};this.roomGeometryMap.set(t.id,r)})}getRasterRoomPixels(t){return this.rasterRoomPixelsMap.get(t)}validateColorConfig(){const t=O_().roomConfig.colors,e=t.active.length,i=t.inactive.length,n=t.name.length,r=t.propertyTheme.length,s=t.selectionIndicatorBackground.length,o=t.selectionIndicatorIcon.length;e<4&&vm.warn(`[FourColor] room.colors.active requires at least 4 colors for the four-color theorem, but got ${e}. Adjacent rooms may have the same color.`),i!==e&&vm.warn(`[FourColor] room.colors.inactive length (${i}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),n!==e&&vm.warn(`[FourColor] room.colors.name length (${n}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),r!==e&&vm.warn(`[FourColor] room.colors.propertyTheme length (${r}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),s!==e&&vm.warn(`[FourColor] room.colors.selectionIndicatorBackground length (${s}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),o!==e&&vm.warn(`[FourColor] room.colors.selectionIndicatorIcon length (${o}) does not match room.colors.active length (${e}). Using modulo for color assignment.`)}assignColorsUsingFourColorAlgorithm(t,e,i){var n,r;const s=O_(),o=null!=(r=null==(n=s.mapState)?void 0:n.id)?r:null;if(this.fourColorCache&&this.fourColorCache.mapId===o&&this.fourColorCache.colorMap.size===t.length)return vm.debug("[FourColor] Using cached color map"),this.fourColorCache.colorMap;const a=s.getApp().config.map.adjacencyThreshold||3;vm.debug(`[FourColor] Starting algorithm for ${t.length} rooms with ${e} colors`);const l=((t,e,i)=>{const n=new Map;if(0===t.length)return n;if(1===t.length)return n.set(t[0].id,0),n;const r=new Map;for(let o=0;o<t.length;o++){const i=t[o];r.has(i.id)||r.set(i.id,new Set);for(let n=o+1;n<t.length;n++){const s=t[n];e(i,s)&&(r.get(i.id).add(s.id),r.has(s.id)||r.set(s.id,new Set),r.get(s.id).add(i.id))}}const s=new Array(i).fill(0);for(const o of t){const t=r.get(o.id)||new Set,e=new Set;for(const i of t){const t=n.get(i);void 0!==t&&e.add(t)}const a=[];for(let n=0;n<i;n++)e.has(n)||a.push(n);let l=a[0],h=s[l];for(const i of a)s[i]<h&&(l=i,h=s[i]);n.set(o.id,l),s[l]++}return n})(t,(t,e)=>{var n;if("structured"===i){const i=t.outlinePoints,n=e.outlinePoints;return!(!i||!n)&&e_(i,n,a)}{const i=t.pixels,r=e.pixels;if(!i||!r)return!1;const o=(null==(n=s.mapState)?void 0:n.width)||0;return i_(i,r,o,a)}},e);this.fourColorCache={mapId:o,colorMap:l};const h=new Array(e).fill(0);return l.forEach(t=>{h[t]++}),vm.debug("[FourColor] Color distribution:",h),l}destroy(){this.obstacle.destroy(),this.free.destroy(),this.roomFill.destroy(),this.carpet.destroy(),this.chargingStation.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.fourColorCache=null}}class Xy extends xe{constructor(){super({isRenderGroup:!0}),__publicField(this,"commonPath"),__publicField(this,"chargePath"),__publicField(this,"transitionsPath"),__publicField(this,"mopPath"),__publicField(this,"pathData",null),__publicField(this,"lastPointCount",0),__publicField(this,"lastDrawnPosition",null),__publicField(this,"isRealTimeDrawing",!1),__publicField(this,"throttledUpdateLineWidth"),__publicField(this,"throttledHandleRobotPosition"),__publicField(this,"handleRobotAnimationComplete",()=>{this.isRealTimeDrawing&&this.stopRealTimeDrawing()});const t=O_();t.appContainer.addToLayer(W_,this),this.eventMode="none",this.commonPath=new fl,this.chargePath=new fl,this.transitionsPath=new fl,this.mopPath=new fl,this.addChild(this.commonPath),this.addChild(this.chargePath),this.addChild(this.transitionsPath),this.addChild(this.mopPath),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.mopPath.visible=!1,this.throttledUpdateLineWidth=zg(()=>{this.updateLineWidth()},50,{leading:!0,trailing:!0}),this.throttledHandleRobotPosition=zg(this.handleRobotPositionUpdate.bind(this),0),this.registerEventListeners()}registerEventListeners(){const{emitter:t}=O_();t.on("antiScale",this.throttledUpdateLineWidth),t.on("robotPositionUpdate",this.throttledHandleRobotPosition),t.on("robotAnimationComplete",this.handleRobotAnimationComplete)}handleRobotPositionUpdate(t){if(!this.isRealTimeDrawing||!this.lastDrawnPosition)return;let e;switch(t.pathType||"common"){case"common":default:e=this.commonPath;break;case"charge":e=this.chargePath;break;case"transitions":e=this.transitionsPath;break;case"mop":e=this.mopPath}e.moveTo(this.lastDrawnPosition.x,this.lastDrawnPosition.y),e.lineTo(t.x,t.y),e.stroke(),this.lastDrawnPosition={x:t.x,y:t.y}}updateLineWidth(){const t=O_();this.pathData&&t.pathConfig.lineWidthFixed&&this.redrawPaths(this.pathData)}redrawPaths(t){const{pathPoints:e}=t;e&&0!==e.length&&(this.commonPath.clear(),this.chargePath.clear(),this.transitionsPath.clear(),this.mopPath.clear(),this.setupPathStyles(),this.drawPathSegments(e),this.commonPath.stroke(),this.chargePath.stroke(),this.transitionsPath.stroke(),this.mopPath.stroke())}setupPathStyles(){const t=O_(),e=t.pathConfig,i=i=>e.lineWidthFixed?t.getApp().toFixedSize(i):i;this.commonPath.setStrokeStyle({width:i(e.commonPath.width),color:e.commonPath.color,join:"round",cap:"round"}),this.chargePath.setStrokeStyle({width:i(e.chargePath.width),color:e.chargePath.color,join:"round",cap:"round"}),this.transitionsPath.setStrokeStyle({width:i(e.transitionPath.width),color:e.transitionPath.color,join:"round",cap:"round"}),this.mopPath.setStrokeStyle({width:0,color:0,alpha:0,join:"round",cap:"round"})}drawPathSegments(t){let e=null,i=null;for(let n=0;n<t.length;n++){const r=t[n],s=r.type||"common";let o;switch(s){case"common":default:o=this.commonPath;break;case"charge":o=this.chargePath;break;case"transitions":o=this.transitionsPath;break;case"mop":o=this.mopPath}0===n||s!==e?o.moveTo(r.x,r.y):o===i&&o.lineTo(r.x,r.y),e=s,i=o}}updatePositionByOrigin(t,e){this.position.set(t,e)}drawFull(t){var e;vm.debug("[Path] Draw Full Path",t),this.pathData=t,this.redrawPaths(t),this.lastPointCount=(null==(e=t.pathPoints)?void 0:e.length)||0}drawIncremental(t){var e,i,n,r;const s=O_(),o=this.lastPointCount,a=(null==(e=t.pathPoints)?void 0:e.slice(o))||[];if(a.length>0){this.setupPathStyles(),vm.debug("[Path] Draw Incremental Path",a);if(s.robotConfig.speed>0){if(this.isRealTimeDrawing=!0,o>0&&(null==(i=this.pathData)?void 0:i.pathPoints)){const t=this.pathData.pathPoints[o-1];this.lastDrawnPosition={x:t.x,y:t.y}}}else this.drawNewPathSegments(a,o,t.pathPoints,null==(n=this.pathData)?void 0:n.pathPoints)}this.pathData=t,this.lastPointCount=(null==(r=t.pathPoints)?void 0:r.length)||0}drawNewPathSegments(t,e,i,n){if(!i||0===t.length)return;let r=null;e>0&&(n&&n[e-1]?r=n[e-1]:i[e-1]&&(r=i[e-1]));let s=null,o=null,a=!1;for(let l=0;l<t.length;l++){const e=t[l],i=e.type||"common";let n;switch(i){case"common":default:n=this.commonPath;break;case"charge":n=this.chargePath;break;case"transitions":n=this.transitionsPath;break;case"mop":n=this.mopPath}i!==s||0===l?(o&&a&&o.stroke(),s=i,o=n,a=!0,r&&0===l&&r.type===i?(n.moveTo(r.x,r.y),n.lineTo(e.x,e.y)):n.moveTo(e.x,e.y)):n.lineTo(e.x,e.y)}o&&a&&o.stroke()}stopRealTimeDrawing(){this.isRealTimeDrawing=!1,this.lastDrawnPosition=null}destroy(t){const{emitter:e}=O_();e.off("antiScale",this.throttledUpdateLineWidth),e.off("robotPositionUpdate",this.throttledHandleRobotPosition),e.off("robotAnimationComplete",this.handleRobotAnimationComplete),this.stopRealTimeDrawing(),super.destroy(t)}}class Zy extends oy{constructor(){super(),this.initializeSprite()}initializeSprite(){return __async(this,null,function*(){const t=O_();yield this.loadTextureAndSetSize("robot",t.robotConfig.icon)})}draw(t){return __async(this,arguments,function*({x:t,y:e,rotation:i}){__superGet(Zy.prototype,this,"draw").call(this,{x:t,y:e,rotation:i})})}}class qy extends Iy{constructor(t){super(t),__publicField(this,"unsubscribeFns",[]),__publicField(this,"throttledUpdateOffset"),__publicField(this,"fixedOffsetX",0),__publicField(this,"fixedOffsetY",0),this.throttledUpdateOffset=zg(this.updateOffset.bind(this),30,{leading:!0,trailing:!0}),this.initializeAnimation()}static create(){return __async(this,null,function*(){const t=O_().robotConfig,e=yield Iy.loadAnimationTextures(t.sleepAnimation.jsonSrc,t.sleepAnimation.framePrefix,t.sleepAnimation.frameCount);0===e.length&&(vm.warn("No textures loaded for sleep animation"),e.push(J.EMPTY));const i=new qy(e);return i.setupAnimation({width:t.sleepAnimation.width,height:t.sleepAnimation.height,sizeFixed:t.sleepAnimation.sizeFixed}),i})}initializeAnimation(){const t=O_();this.visible=!1,this.fixedOffsetX=t.robotConfig.sleepAnimation.offsetX,this.fixedOffsetY=t.robotConfig.sleepAnimation.offsetY,t.emitter.on("antiScale",this.throttledUpdateOffset);const e=Wy(t.runtime,"showRobotSleepAnimation",t=>{vm.log(`[runtime] showRobotSleepAnimation: ${t}`),this.updateVisibility()});this.unsubscribeFns.push(e)}shouldShow(){const t=O_().runtimeSnapshot.showRobotSleepAnimation,e=this.parent,i=!!e&&e.visible,n=e&&(0!==e.x||0!==e.y);return t&&i&&!!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(t){}draw(t){const e=O_(),i=e.getApp().toFixedSize(e.robotConfig.sleepAnimation.offsetX),n=e.getApp().toFixedSize(e.robotConfig.sleepAnimation.offsetY),r=__spreadProps(__spreadValues({},t),{x:t.x+i,y:t.y+n});super.draw(r,()=>this.shouldShow()),this.updateVisibility()}onRobotVisibilityChanged(){this.updateVisibility()}set visible(t){const e=super.visible;super.visible=t,t&&!e&&this.textures&&this.textures.length>0?this.play():!t&&e&&this.playing&&this.stop()}get visible(){return super.visible}destroy(t){O_().emitter.off("antiScale",this.throttledUpdateOffset),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.stop(),super.destroy(t)}}class Ky extends xe{constructor(){super(),__publicField(this,"robot"),__publicField(this,"ring"),__publicField(this,"sleepAnimation",null),__publicField(this,"unsubscribeFns",[]),__publicField(this,"targetPosition",null),__publicField(this,"targetRotation",null),__publicField(this,"isMoving",!1),__publicField(this,"pathQueue",[]),__publicField(this,"lastPosition",null),__publicField(this,"currentPathType"),__publicField(this,"lastUpdateTime",0);const t=O_();t.appContainer.addToLayer($_,this),this.visible=t.runtimeSnapshot.showPath,this.ring=new Vy({config:t.robotConfig}),this.ring.visible=t.runtimeSnapshot.showRobotRing,this.addChild(this.ring),this.robot=new Zy,this.addChild(this.robot),this.lastUpdateTime=Date.now();t.robotConfig.speed>0&&t.getApp().ticker.add(this.update,this);const e=Wy(t.runtime,"showRobotRing",t=>{vm.log(`[runtime] showRobotRing: ${t}`),this.ring.visible=t});this.unsubscribeFns.push(e)}initializeSleepAnimation(){return __async(this,null,function*(){try{this.sleepAnimation=yield qy.create(),this.addChild(this.sleepAnimation),vm.log("Sleep animation added to robot")}catch(t){vm.error("Failed to initialize sleep animation:",t)}})}updatePositionByOrigin(t,e){this.position.set(t,e)}draw(t){return __async(this,arguments,function*({x:t,y:e,rotation:i}){this.ring.draw({x:t,y:e}),yield this.robot.draw({x:t,y:e,rotation:i}),this.sleepAnimation||(yield this.initializeSleepAnimation()),this.sleepAnimation.draw({x:t,y:e,rotation:i}),this.lastPosition={x:t,y:e}})}moveTo(t){this.pathQueue.push(t),this.isMoving||this.processNextPathPoint()}batchProcessQueue(t=!1){if(0===this.pathQueue.length)return;const e=[...this.pathQueue];if(t){const t=e[e.length-1];this.robot.position.set(t.x,t.y),void 0!==t.rotation&&(this.robot.rotation=t.rotation),this.lastPosition={x:t.x,y:t.y},this.pathQueue=[],this.isMoving=!1,this.targetPosition=null}else this.pathQueue.splice(0,e.length),0===this.pathQueue.length?(this.isMoving=!1,this.targetPosition=null):this.processNextPathPoint()}processNextPathPoint(){if(0===this.pathQueue.length)return this.isMoving=!1,this.currentPathType=void 0,this.stopRobotAnimation(),void O_().emitter.emit("robotAnimationComplete");this.isMoving||this.startRobotAnimation(),this.isMoving=!0;const t=this.pathQueue[0];this.targetPosition={x:t.x,y:t.y},this.currentPathType=t.type,void 0!==t.rotation&&(this.targetRotation=t.rotation),this.lastPosition||(this.lastPosition={x:this.robot.x,y:this.robot.y})}update(){const t=O_(),e=Date.now();if(0===this.lastUpdateTime)return void(this.lastUpdateTime=e);let i=e-this.lastUpdateTime;if(this.lastUpdateTime=e,i>500&&(i=16.67),this.targetPosition){const e=this.targetPosition.x-this.robot.x,n=this.targetPosition.y-this.robot.y,r=Math.sqrt(e*e+n*n),s=t.robotConfig.speed,o=t.getApp().metersToPixels(s);if(0===s)return this.robot.position.set(this.targetPosition.x,this.targetPosition.y),null!==this.targetRotation&&(this.robot.rotation=this.targetRotation,this.targetRotation=null),this.targetPosition=null,this.lastPosition={x:this.robot.x,y:this.robot.y},this.pathQueue.shift(),void this.processNextPathPoint();const a=o*(i/1e3);r<a?(this.robot.position.set(this.targetPosition.x,this.targetPosition.y),null!==this.targetRotation&&(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+=e*(a/r),this.robot.y+=n*(a/r),O_().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(){O_().getApp().requestRender("robot-animation",!0)}set visible(t){super.visible=t,this.sleepAnimation&&this.sleepAnimation.onRobotVisibilityChanged()}get visible(){return super.visible}stopRobotAnimation(){O_().getApp().stopRender("robot-animation")}remove(){this.pathQueue=[],this.isMoving=!1,this.targetPosition=null,this.stopRobotAnimation()}destroy(t){const e=O_();this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.stopRobotAnimation();e.robotConfig.speed>0&&e.getApp().ticker.remove(this.update,this),this.ring.destroy(),super.destroy(t)}}class $y{constructor(){__publicField(this,"path"),__publicField(this,"robot"),__publicField(this,"unsubscribeFns",[]),__publicField(this,"lastDrawnPathData",null);const t=O_();this.path=new Xy,this.robot=new Ky;const e=Wy(t.runtime,"showPath",t=>{vm.log(`[runtime] showPath: ${t}`),this.path.visible=t,this.robot.visible=t});this.unsubscribeFns.push(e)}draw(t){this.shouldUseIncrementalDraw(t)?this.incrementalDraw(t):this.fullDraw(t),this.lastDrawnPathData=t}shouldUseIncrementalDraw(t){var e,i,n,r;const s=O_();if(!this.lastDrawnPathData)return!1;if((null==(e=t.pathHeader)?void 0:e.pathId)!==(null==(i=this.lastDrawnPathData.pathHeader)?void 0:i.pathId))return!1;const o=((null==(n=t.pathPoints)?void 0:n.length)||0)-((null==(r=this.lastDrawnPathData.pathPoints)?void 0:r.length)||0),a=s.pathConfig.incrementalThreshold;return!(o<=0||o>a)}fullDraw(t){if(this.path.stopRealTimeDrawing(),this.path.drawFull(t),t.pathPoints&&t.pathPoints.length>0){const e=t.pathPoints[t.pathPoints.length-1];this.moveRobotToPoint(e,t.pathHeader.direction,!1)}}convertToRobotPoint(t,e){const i=e+O_().robotConfig.rotationCorrection;return{x:t.x,y:t.y,rotation:i*Math.PI/180,type:t.type}}moveRobotToPoint(t,e,i=!0){const n=this.convertToRobotPoint(t,e);i?this.robot.moveTo(n):(this.robot.remove(),this.robot.draw(n))}incrementalDraw(t){var e;const i=O_();if(!this.lastDrawnPathData||!t.pathPoints)return;this.path.drawIncremental(t);const n=(null==(e=this.lastDrawnPathData.pathPoints)?void 0:e.length)||0,r=t.pathPoints.slice(n);if(0===r.length)return;if(i.robotConfig.speed>0)r.forEach(e=>{this.moveRobotToPoint(e,t.pathHeader.direction,!0)});else{const e=r[r.length-1];this.moveRobotToPoint(e,t.pathHeader.direction,!1)}}batchProcessRobotQueue(t=!1){this.robot.batchProcessQueue(t)}updatePositionByOrigin(t,e){this.path.updatePositionByOrigin(t,e),this.robot.updatePositionByOrigin(t,e)}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.path.destroy(),this.robot.destroy()}}class Qy extends xe{constructor(){super(),__publicField(this,"colorGradients",[]),__publicField(this,"cellSize",2);const t=O_();t.appContainer.addToLayer(H_,this);const e=t.heatMapConfig;this.colorGradients=e.colorGradients.map(t=>new Ft(t).toArray().slice(0,3).join(",")),this.cellSize=e.cellSize}draw(t,e=!0,i=.8){this.removeChildren();const n=e?this.gradientDrawing(t):this.gridDrawing(t);this.croppingHeatmap(n),n.alpha=i,this.addChild(n)}croppingHeatmap(t){const e=O_().mapManager.roomFill.children.filter(t=>t instanceof fl),i=new fl;for(const n of e)i.context.instructions.push(...n.context.instructions);i.context.dirty=!0,t.setMask({mask:i}),this.addChild(i)}gridDrawing(t){const e=[],i=[],n=t.length,r=t[0].length;for(let l=0;l<n;l++)for(let n=0;n<r;n++){const r=t[l][n],s=this.cellSize/2,o=r.x-s,a=r.y-s,h=r.x+s,c=r.y+s;e.push(o,a),i.push(r.signal),e.push(h,a),i.push(r.signal),e.push(h,c),i.push(r.signal),e.push(o,a),i.push(r.signal),e.push(h,c),i.push(r.signal),e.push(o,c),i.push(r.signal)}const s=new jr({attributes:{aPosition:new Float32Array(e),aSignal:new Float32Array(i)}}),o=new tn({glProgram:new Li({vertex:"\n in vec2 aPosition;\n in float aSignal;\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform mat3 uTransformMatrix;\n \n out float vSignal;\n \n void main() {\n mat3 mvp = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;\n gl_Position = vec4((mvp * vec3(aPosition, 1.0)).xy, 0.0, 1.0);\n vSignal = aSignal;\n }\n ",fragment:`\n precision mediump float;\n \n in float vSignal;\n \n void main() {\n vec3 color;\n \n if (vSignal > 0.875) {\n color = vec3(${this.colorGradients[0]});\n } else if (vSignal > 0.75) {\n color = vec3(${this.colorGradients[1]});\n } else if (vSignal > 0.625) {\n color = vec3(${this.colorGradients[2]});\n } else if (vSignal > 0.5) {\n color = vec3(${this.colorGradients[3]});\n } else if (vSignal > 0.375) {\n color = vec3(${this.colorGradients[4]});\n } else if (vSignal > 0.25) {\n color = vec3(${this.colorGradients[5]});\n } else if (vSignal > 0.125) {\n color = vec3(${this.colorGradients[6]});\n } else {\n color = vec3(${this.colorGradients[7]});\n }\n gl_FragColor = vec4(color, 1.0);\n }\n `})}),a=new _l({geometry:s,shader:o});return a.alpha=.8,a}gradientDrawing(t){const e=[],i=[],n=t.length,r=t[0].length;for(let l=0;l<n;l++)for(let s=0;s<r;s++){const o=t[l][s],a=this.cellSize/2,h=(e,i)=>e<0||e>=n||i<0||i>=r?o.signal:t[e][i].signal,c=(h(l-1,s-1)+h(l-1,s)+h(l,s-1)+o.signal)/4,u=(h(l-1,s)+h(l-1,s+1)+o.signal+h(l,s+1))/4,d=(o.signal+h(l,s+1)+h(l+1,s)+h(l+1,s+1))/4,p=(h(l,s-1)+o.signal+h(l+1,s-1)+h(l+1,s))/4,f=o.x-a,g=o.y-a,m=o.x+a,_=o.y+a;e.push(f,g,m,g,m,_),i.push(c,u,d),e.push(f,g,m,_,f,_),i.push(c,d,p)}const s=new jr({attributes:{aPosition:new Float32Array(e),aSignal:new Float32Array(i)}}),o=new tn({glProgram:new Li({vertex:"\n in vec2 aPosition;\n in float aSignal;\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform mat3 uTransformMatrix;\n \n out float vSignal;\n \n void main() {\n mat3 mvp = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;\n gl_Position = vec4((mvp * vec3(aPosition, 1.0)).xy, 0.0, 1.0);\n vSignal = aSignal;\n }\n ",fragment:`\n precision mediump float;\n \n in float vSignal;\n \n // 颜色插值函数\n vec3 interpolateColor(vec3 color1, vec3 color2, float t) {\n return mix(color1, color2, t);\n }\n \n void main() {\n vec3 color;\n float signal = clamp(vSignal, 0.0, 1.0);\n \n vec3 color1 = vec3(${this.colorGradients[7]});\n vec3 color2 = vec3(${this.colorGradients[6]});\n vec3 color3 = vec3(${this.colorGradients[5]});\n vec3 color4 = vec3(${this.colorGradients[4]});\n vec3 color5 = vec3(${this.colorGradients[3]});\n vec3 color6 = vec3(${this.colorGradients[2]});\n vec3 color7 = vec3(${this.colorGradients[1]});\n vec3 color8 = vec3(${this.colorGradients[0]});\n \n if (signal <= 0.125) {\n float t = signal / 0.125;\n color = interpolateColor(color1, color2, t);\n } else if (signal <= 0.25) {\n float t = (signal - 0.125) / 0.125;\n color = interpolateColor(color2, color3, t);\n } else if (signal <= 0.375) {\n float t = (signal - 0.25) / 0.125;\n color = interpolateColor(color3, color4, t);\n } else if (signal <= 0.5) {\n float t = (signal - 0.375) / 0.125;\n color = interpolateColor(color4, color5, t);\n } else if (signal <= 0.625) {\n float t = (signal - 0.5) / 0.125;\n color = interpolateColor(color5, color6, t);\n } else if (signal <= 0.75) {\n float t = (signal - 0.625) / 0.125;\n color = interpolateColor(color6, color7, t);\n } else if (signal <= 0.875) {\n float t = (signal - 0.75) / 0.125;\n color = interpolateColor(color7, color8, t);\n } else {\n color = color8;\n }\n \n gl_FragColor = vec4(color, 1.0);\n }\n `})}),a=new _l({geometry:s,shader:o});return a.alpha=.8,a}}class Jy{constructor(){__publicField(this,"heatmap",new Qy),__publicField(this,"pointsTopLeftOrigin",[]),__publicField(this,"signalGrid",[]),__publicField(this,"cellSize",2),__publicField(this,"maxDistance",14),__publicField(this,"smoothIterations",10),__publicField(this,"heatmapAlpha",.8);const t=O_().heatMapConfig;this.cellSize=t.cellSize,this.maxDistance=t.maxDistance,this.smoothIterations=t.smoothIterations,this.heatmapAlpha=t.heatmapAlpha}draw({mapData:t,heatmapPoints:e,useGradient:i=!0}){const n=O_(),r=t.origin[0],s=t.origin[1],{minX:o,minY:a}=n.mapManager.mapBounds,l=e.map(t=>({x:+(r+t.x-o).toFixed(0),y:+(s+t.y-a).toFixed(0),signal:t.signal}));this.signalGrid=this.calculateInterpolatedSignal(l),this.heatmap.draw(this.signalGrid,i,this.heatmapAlpha)}calculateInterpolatedSignal(t){const e=O_(),{minX:i,minY:n,maxX:r,maxY:s}=e.mapManager.mapBounds,o=Math.ceil((s-n)/this.cellSize),a=Math.ceil((r-i)/this.cellSize),l=Array(o).fill(null).map(()=>Array(a).fill(null));for(let c=0;c<o;c++){const e=n+c*this.cellSize+this.cellSize/2,o=Math.min(this.cellSize,s-(e-this.cellSize/2));for(let n=0;n<a;n++){const s=i+n*this.cellSize+this.cellSize/2,a=Math.min(this.cellSize,r-(s-this.cellSize/2));let h=0,u=!1;for(let i=0;i<t.length;i++){const n=t[i];if(Math.abs(s-n.x)<=a/2&&Math.abs(e-n.y)<=o/2){const t=1-n.signal/7;h=Math.round(10*Math.max(h,t))/10,u=!0}}l[c][n]={x:s,y:e,signal:h,hasPoint:u}}}const h=(e,i)=>{if(0===t.length)return 0;let n=0,r=0;for(const s of t){const t=Math.sqrt(__pow(e-s.x,2)+__pow(i-s.y,2));if(t<=this.maxDistance){const e=1/(1+t);r+=e*(1-s.signal/7),n+=e}}return 0===n?0:Math.round(r/n*1e3)/1e3};for(let c=0;c<o;c++)for(let t=0;t<a;t++){const e=l[c][t];e.hasPoint||(e.signal=h(e.x,e.y))}return((t,e=1)=>{for(let i=0;i<e;i++){const e=t.map(t=>[...t]);for(let i=1;i<o-1;i++)for(let n=1;n<a-1;n++)if(!t[i][n].hasPoint){let r=0,s=0;const l=4;for(let e=-l;e<=l;e++)for(let h=-l;h<=l;h++){if(0===e&&0===h)continue;const l=i+e,c=n+h;if(l>=0&&l<o&&c>=0&&c<a){const i=1/(1+.3*Math.sqrt(e*e+h*h));r+=t[l][c].signal*i,s+=i}}if(s>0){const o=r/s,a=.6,l=.4;e[i][n].signal=t[i][n].signal*a+o*l,e[i][n].signal>.1&&(e[i][n].signal=Math.max(e[i][n].signal,.2))}}for(let i=0;i<o;i++)for(let n=0;n<a;n++)t[i][n].signal=e[i][n].signal}})(l,this.smoothIterations),l}}class tx extends Ny{constructor(t){const e=O_();super({zoneData:t.zoneData,zoneType:"forbiddenSweepZone",events:{onRemove:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onRemoveForbiddenSweepZone)||n.call(i,t)},onUpdate:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onUpdateForbiddenSweepZone)||n.call(i,t)},onClick:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onClickForbiddenSweepZone)||n.call(i,t)}}})}static create(t){return new tx({zoneData:t})}}class ex extends Ny{constructor(t){const e=O_();super({zoneData:t.zoneData,zoneType:"forbiddenMopZone",events:{onRemove:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onRemoveForbiddenMopZone)||n.call(i,t)},onUpdate:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onUpdateForbiddenMopZone)||n.call(i,t)},onClick:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onClickForbiddenMopZone)||n.call(i,t)}}})}static create(t){return new ex({zoneData:t})}}class ix extends Ny{constructor(t){const e=O_();super({zoneData:t.zoneData,zoneType:"cleanZone",events:{onRemove:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onRemoveCleanZone)||n.call(i,t)},onUpdate:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onUpdateCleanZone)||n.call(i,t)},onClick:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onClickCleanZone)||n.call(i,t)}}})}static create(t){return new ix({zoneData:t})}}const nx=class t extends xe{constructor(t){super(),__publicField(this,"wallData"),__publicField(this,"wallConfig"),__publicField(this,"controlsConfig"),__publicField(this,"wallEvents"),__publicField(this,"wallLine"),__publicField(this,"outlineBorder"),__publicField(this,"moveLine"),__publicField(this,"lengthText"),__publicField(this,"controlButtons"),__publicField(this,"removeButton",null),__publicField(this,"scaleButton",null),__publicField(this,"moveButton",null),__publicField(this,"initialWallPoints",[]),__publicField(this,"isDragging",!1),__publicField(this,"dragStartPosition",null),__publicField(this,"throttledUpdateOutline"),__publicField(this,"throttledHandleScaleChange"),__publicField(this,"wallLineClickHandler",null),__publicField(this,"handleRemove",()=>{var t,e;null==(e=(t=this.wallEvents).onRemove)||e.call(t,this.wallData.id)}),__publicField(this,"initializeOperation",()=>{this.initialWallPoints=this.wallData.points.map(t=>__spreadValues({},t))}),__publicField(this,"finalizeOperation",()=>{var t,e;this.initialWallPoints=[],null==(e=(t=this.wallEvents).onUpdate)||e.call(t,this.getWallData())}),__publicField(this,"handleScaleStart",()=>{const t=O_();this.initializeOperation(),t.getApp().requestRender("virtualwall-scale",!0)}),__publicField(this,"handleScaleMove",t=>{0!==this.initialWallPoints.length&&this.applyScaleAndRotation(t)}),__publicField(this,"handleScaleEnd",()=>{const t=O_();this.finalizeOperation(),t.getApp().stopRender("virtualwall-scale")}),__publicField(this,"handleMoveStart",()=>{const t=O_();this.initializeOperation(),t.getApp().requestRender("virtualwall-move",!0)}),__publicField(this,"handleMove",t=>{var e;if(0===this.initialWallPoints.length)return;const i=this.parent.toLocal(t.global),n=this.getDragStartPosition()||(null==(e=this.moveButton)?void 0:e.getDragStartPosition());if(!n)return;const r=i.x-n.x,s=i.y-n.y;this.applyTranslation(r,s)}),__publicField(this,"handleMoveEnd",()=>{const t=O_();this.finalizeOperation(),t.getApp().stopRender("virtualwall-move")}),__publicField(this,"handleScaleChange",()=>{this.redrawSolidLine(),this.setupWallLineHitArea()}),__publicField(this,"handleWallLinePointerDown",t=>{this.isEditingEnabled()&&(t.stopPropagation(),this.startDragging(t))}),__publicField(this,"handleDragPointerMove",t=>{this.isDragging&&this.dragStartPosition&&this.handleMove(t)}),__publicField(this,"handleDragPointerUp",()=>{const t=O_();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("virtualwall-drag"),this.finalizeOperation())}),__publicField(this,"handleDragCancel",()=>{const t=O_();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("virtualwall-drag"),this.handleMoveEnd())});const{wallData:e,events:i={}}=t;this.wallEvents=i;const n=O_();this.wallConfig=n.controlsConfig.virtualWall,this.controlsConfig=n.controlsConfig,this.wallData=__spreadProps(__spreadValues({},e),{points:this.validateAndCorrectWallLength(e.points)}),this.throttledHandleScaleChange=zg(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.throttledUpdateOutline=zg(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.registerScaleListener(),this.setupDragEventListeners()}validateAndCorrectWallLength(t){const e=O_();if(t.length<2)return t;const[i,n]=t,r=e.metersToPixels(this.wallConfig.minWidth),s=Om(i,n);if(s>=r)return t;if(0===s)return[i,{x:i.x+r,y:i.y}];const o=Lm(Gm(i,n));return[i,{x:i.x+o.x*r,y:i.y+o.y*r}]}isEditingEnabled(){return O_().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 xe,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.createControlButtons()}createWallLine(t=!0){const{points:e}=this.wallData;if(e.length<2)return;const{lineWidth:i,lineColor:n,editing:r,normal:s}=this.wallConfig,o=this.isEditingEnabled()?r:s;o.isDashed?this.wallLine=new cy({start:e[0],end:e[1],style:{color:n.toString(),width:i,dashArray:o.dashArray}}):this.wallLine=this.createSolidLine(e[0],e[1],i,n.toString()),t&&this.setupWallLineInteraction()}createLengthText(){const t=this.calculateWallLengthInMeters(),e=this.formatLengthText(t),i=new Dy({text:e,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.wallConfig.textColor,align:"center"}});i.anchor.set(.5);const n=this.calculateTextPosition();i.position.set(n.x,n.y);const r=this.calculateTextRotation();return i.rotation=r,i.eventMode="none",i}calculateWallLengthInMeters(){const t=O_(),{points:e}=this.wallData;if(e.length<2)return 0;const i=Om(e[0],e[1]);return t.pixelsToMeters(i)}formatLengthText(t){return`${t.toFixed(1)}${this.controlsConfig.unitLabel}`}calculateTextPosition(){const t=O_(),{points:e}=this.wallData;if(e.length<2)return{x:0,y:0};const[i,n]=e;return((t,e,i)=>{const n=km([t,e]),r=Vm(t,e);return{x:n.x+r.x*i,y:n.y+r.y*i}})(i,n,t.getApp().toFixedSize(this.wallConfig.textOffset))}calculateTextRotation(){const{points:t}=this.wallData;if(t.length<2)return 0;const[e,i]=t;return Wm(e,i)}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 ly({points:t,closePath:!0,style:this.getOutlineStyle()})}createMoveLine(){const t=this.calculateOutlinePoints(),e=this.calculateMoveLinePoints(t);return new ly({points:e,closePath:!1,style:this.getOutlineStyle()})}calculateOutlinePoints(t){const e=O_(),i=t||this.wallData.points;if(i.length<2)return i;const n=e.getApp().toFixedSize(this.wallConfig.outlineOffset),r=((t,e,i)=>{if(0===Om(t,e))return[t,t,t,t];const n=zm(t,e),r=Nm(n),s=t.x-n.x*i,o=t.y-n.y*i,a=e.x+n.x*i,l=e.y+n.y*i;return[{x:s+r.x*i,y:o+r.y*i},{x:a+r.x*i,y:l+r.y*i},{x:a-r.x*i,y:l-r.y*i},{x:s-r.x*i,y:o-r.y*i}]})(i[0],i[1],n);return[r[3],r[2],r[1],r[0]]}calculateMoveLinePoints(e){if(e.length<4)return[];const{MOVE:i}=t.BUTTON_INDICES;return[e[i],this.calculateMoveButtonPosition()]}calculateMoveButtonPosition(){const e=O_(),{moveButtonOffset:i}=this.controlsConfig,n=this.calculateOutlinePoints();if(n.length<4)return{x:0,y:0};const{MOVE:r}=t.BUTTON_INDICES,s=n[r],o=n[(r+3)%4],a=n[(r+1)%4],l=e.getApp().toFixedSize(i);return Xm(s,a,o,l)}createControlButtons(){const e=this.calculateOutlinePoints();if(e.length<4)return;const{REMOVE:i,SCALE:n}=t.BUTTON_INDICES;this.removeButton=new Uy({iconAlias:"deleteIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onClick:this.handleRemove}),this.removeButton.position.set(e[i].x,e[i].y),this.scaleButton=new Ly({iconAlias:"scaleIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,getTargetPoints:()=>this.calculateOutlinePoints(),getButtonIndex:()=>n,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(e[n].x,e[n].y);const r=this.calculateMoveButtonPosition();this.moveButton=new Oy({iconAlias:"moveIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(r.x,r.y),this.controlButtons.addChild(this.removeButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}applyScaleAndRotation(e){const i=O_();if(this.initialWallPoints.length<2)return;const[n,r]=this.initialWallPoints,s=n,o=this.calculateOutlinePoints(this.initialWallPoints);if(o.length<4)return;const a=o[t.BUTTON_INDICES.SCALE],l=Gm(r,a),h={x:e.x-l.x,y:e.y-l.y},c=Gm(s,h),u=Om(s,h),d=i.metersToPixels(this.wallConfig.minWidth);let p;if(u<d)if(0===u)p={x:s.x+d,y:s.y};else{const t=Lm(c);p={x:s.x+t.x*d,y:s.y+t.y*d}}else p=h;this.wallData.points=[s,p],this.updateAllComponents(),this.updateControlButtonsPosition()}applyTranslation(t,e){this.wallData.points=this.initialWallPoints.map(i=>({x:i.x+t,y:i.y+e})),this.updateAllComponents(),this.updateControlButtonsPosition()}updateAllComponents(){this.updateWallLine(),this.updateLengthText(),this.updateOutlineComponents()}updateWallLine(){const{points:t}=this.wallData;t.length<2||(this.wallLine instanceof cy?this.wallLine.updatePoints(t[0],t[1]):this.redrawSolidLine(),this.setupWallLineHitArea())}updateLengthText(){if(!this.lengthText)return;const t=this.calculateWallLengthInMeters(),e=this.formatLengthText(t);this.lengthText.updateText(e),this.updateLengthTextPosition()}updateLengthTextPosition(){if(!this.lengthText)return;const t=this.calculateTextPosition();this.lengthText.position.set(t.x,t.y);const e=this.calculateTextRotation();this.lengthText.rotation=e}updateOutlineComponents(){const t=this.calculateOutlinePoints();this.outlineBorder.updatePoints(t);const e=this.calculateMoveLinePoints(t);this.moveLine.updatePoints(e)}updateControlButtonsPosition(){if(!this.removeButton||!this.scaleButton||!this.moveButton)return;const e=this.calculateOutlinePoints();if(e.length<4)return;const{REMOVE:i,SCALE:n}=t.BUTTON_INDICES,r=this.calculateMoveButtonPosition();this.removeButton.position.set(e[i].x,e[i].y),this.scaleButton.position.set(e[n].x,e[n].y),this.moveButton.position.set(r.x,r.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,e,i,n){const r=O_(),s=new fl;s.eventMode="static";const o=r.getApp().toFixedSize(i);return s.moveTo(t.x,t.y),s.lineTo(e.x,e.y),s.stroke({color:n,width:o}),s}updateWallLineStyle(){const t=this.isEditingEnabled(),{editing:e,normal:i,lineWidth:n,lineColor:r}=this.wallConfig,s=t?e:i;this.wallLine instanceof cy!==s.isDashed?(this.removeChild(this.wallLine),this.wallLine.destroy(),this.createWallLine(!1),this.addChild(this.wallLine)):this.wallLine instanceof cy?this.wallLine.updateStyle({color:r.toString(),width:n,dashArray:s.dashArray}):this.redrawSolidLine()}registerScaleListener(){const{emitter:t}=O_();t.on("antiScale",this.throttledUpdateOutline),t.on("antiScale",this.throttledHandleScaleChange)}redrawSolidLine(){const t=O_();if(!this.wallLine||this.wallLine instanceof cy)return;const{points:e}=this.wallData;if(e.length<2)return;const{lineWidth:i,lineColor:n}=this.wallConfig,r=t.getApp().toFixedSize(i);this.wallLine.clear(),this.wallLine.setStrokeStyle({color:n.toString(),width:r}).moveTo(e[0].x,e[0].y).lineTo(e[1].x,e[1].y).stroke()}setupWallLineInteraction(){var t;if(!this.wallLine)return;this.setupWallLineHitArea();const e=this.isEditingEnabled();null==(t=this.wallLineClickHandler)||t.destroy(),this.wallLineClickHandler=null,this.wallLine.off("pointerdown",this.handleWallLinePointerDown),e?this.wallLine.on("pointerdown",this.handleWallLinePointerDown):this.wallLineClickHandler=new iy(this.wallLine,{onClick:()=>{var t,e;null==(e=null==(t=this.wallEvents)?void 0:t.onClick)||e.call(t,this.getWallData())},stopPropagation:!1})}setupDragEventListeners(){const{emitter:t}=O_();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=O_();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}startDragging(t){const e=O_();this.isDragging=!0;const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},this.initializeOperation(),e.getApp().requestRender("virtualwall-drag",!0),O_().emitter.emit("gestureHijackStart",t)}getDragStartPosition(){return this.dragStartPosition}setupWallLineHitArea(){const t=O_();if(!this.wallLine)return;const{points:e}=this.wallData;if(e.length<2)return;const{hitAreaThickness:i}=this.wallConfig,n=t.getApp().toFixedSize(i),r=Ym(e[0],e[1],n);if(0===r.length)return;const s=new xr(r);this.wallLine.hitArea=s}getWallData(){return __spreadValues({},this.wallData)}updateWallData(t){this.wallData=__spreadProps(__spreadValues({},t),{points:this.validateAndCorrectWallLength(t.points)}),this.updateAllComponents(),this.updateControlButtonsPosition()}updateEditingState(){this.updateEditState()}destroy(){var t,e,i,n,r,s,o,a,l;O_().emitter.off("antiScale",this.throttledUpdateOutline),O_().emitter.off("antiScale",this.throttledHandleScaleChange),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.wallLine&&this.wallLine.off("pointerdown",this.handleWallLinePointerDown),null==(t=this.wallLineClickHandler)||t.destroy(),this.wallLineClickHandler=null,null==(e=this.wallLine)||e.destroy(),null==(i=this.lengthText)||i.destroy(),null==(n=this.outlineBorder)||n.destroy(),null==(r=this.moveLine)||r.destroy(),null==(s=this.controlButtons)||s.destroy(),null==(o=this.removeButton)||o.destroy(),null==(a=this.scaleButton)||a.destroy(),null==(l=this.moveButton)||l.destroy(),this.removeButton=null,this.scaleButton=null,this.moveButton=null,super.destroy()}};__publicField(nx,"BUTTON_INDICES",{REMOVE:0,SCALE:2,MOVE:3});let rx=nx;class sx extends xe{constructor(t){super(),__publicField(this,"spotData"),__publicField(this,"spotConfig"),__publicField(this,"controlsConfig"),__publicField(this,"spotEvents"),__publicField(this,"controlFill"),__publicField(this,"spotBorder"),__publicField(this,"centerIcon"),__publicField(this,"sizeText"),__publicField(this,"clickHandler",null),__publicField(this,"initialSpotPoint",null),__publicField(this,"throttledUpdateScale"),__publicField(this,"handleDragStart",()=>{const t=O_();this.isEditingEnabled()&&(this.initialSpotPoint=__spreadValues({},this.spotData.point),t.getApp().requestRender("spot-drag",!0))}),__publicField(this,"handleDragMove",t=>{if(!this.isEditingEnabled()||!this.initialSpotPoint)return;const e=this.parent.toLocal(t.global),i=this.controlFill.getDragStartPosition();if(!i)return;const n=e.x-i.x,r=e.y-i.y;this.applyTranslation(n,r)}),__publicField(this,"handleDragEnd",()=>{var t,e;const i=O_();this.initialSpotPoint=null,i.getApp().stopRender("spot-drag"),null==(e=(t=this.spotEvents).onUpdate)||e.call(t,this.getSpotData())});const{spotData:e,events:i={}}=t,n=O_();this.spotData=e,this.spotEvents=i,this.controlsConfig=n.controlsConfig,this.spotConfig=n.controlsConfig.spot,this.throttledUpdateScale=zg(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){O_().emitter.on("antiScale",this.throttledUpdateScale)}updateScale(){this.isEditingEnabled()&&this.updateSizeTextPosition()}isEditingEnabled(){return O_().runtimeSnapshot.editingSpotIds.includes(this.spotData.id)}calculateRectanglePoints(){const t=O_(),{point:e}=this.spotData,{size:i}=this.spotConfig,n=t.metersToPixels(i)/2;return[{x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n},{x:e.x-n,y:e.y+n}]}initializeComponents(){const t=this.calculateRectanglePoints();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.sizeText=this.createSizeText(),this.addChild(this.sizeText),this.drawSpot()}createControlFill(t){const e=this.isEditingEnabled();return new hy({points:t,fillColor:this.spotConfig.fillColor,enableInteraction:e,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(t){const e=this.isEditingEnabled()?this.spotConfig.editing:this.spotConfig.normal;return new ly({points:t,closePath:!0,style:{color:this.spotConfig.strokeColor,width:this.spotConfig.strokeWidth,isDashed:e.isDashed,dashArray:e.dashArray}})}createCenterIcon(){const t=new oy;return this.loadIconTexture(t),t.position.set(this.spotData.point.x,this.spotData.point.y),t.eventMode="none",t.visible=!1,t}loadIconTexture(t){return __async(this,null,function*(){const{iconSize:e}=this.spotConfig;yield t.loadTextureAndSetSize("spotIcon",{width:e,height:e,sizeFixed:!1}),t.visible=this.isEditingEnabled()})}createSizeText(){const t=this.calculateSpotSizeText(),e=new Dy({text:t,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.spotConfig.textColor,align:"center"}});e.anchor.set(.5);const i=this.calculateSizeTextPosition();return e.position.set(i.x,i.y),e.eventMode="none",e}calculateSpotSizeText(){const{size:t}=this.spotConfig;return`${t.toFixed(1)}${this.controlsConfig.unitLabel}*${t.toFixed(1)}${this.controlsConfig.unitLabel}`}calculateSizeTextPosition(){const t=O_(),e=this.calculateRectanglePoints();if(e.length<4)return{x:0,y:0};const[i,n,r,s]=e,{textPosition:o,textOffset:a}=this.spotConfig,l=t.getApp().toFixedSize(a);let h,c;switch(o){case"top":default:h={x:(i.x+n.x)/2,y:(i.y+n.y)/2},c={x:h.x,y:h.y+l};break;case"right":h={x:(n.x+r.x)/2,y:(n.y+r.y)/2},c={x:h.x+l,y:h.y};break;case"bottom":h={x:(s.x+r.x)/2,y:(s.y+r.y)/2},c={x:h.x,y:h.y+l};break;case"left":h={x:(i.x+s.x)/2,y:(i.y+s.y)/2},c={x:h.x-l,y:h.y}}return c}applyTranslation(t,e){this.initialSpotPoint&&(this.spotData.point={x:this.initialSpotPoint.x+t,y:this.initialSpotPoint.y+e},this.drawSpot())}setupClickHandler(){this.clickHandler=new iy(this,{onClick:()=>{var t,e;this.isEditingEnabled()||null==(e=null==(t=this.spotEvents)?void 0:t.onClick)||e.call(t,this.getSpotData())},stopPropagation:!1})}drawSpot(){const t=this.calculateRectanglePoints();this.controlFill.updatePoints(t),this.spotBorder.updatePoints(t),this.centerIcon.position.set(this.spotData.point.x,this.spotData.point.y),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();if(this.sizeText&&(this.sizeText.visible=t),this.centerIcon&&(this.centerIcon.visible=t),this.controlFill&&this.controlFill.setInteractionEnabled(t),this.spotBorder){const e=t?this.spotConfig.editing:this.spotConfig.normal;this.spotBorder.updateStyle({isDashed:e.isDashed,dashArray:e.dashArray})}this.zIndex=t?1e3:0}updateSpotData(t){this.spotData=__spreadValues({},t),this.drawSpot(),this.updateEditState()}getSpotData(){return __spreadValues({},this.spotData)}destroy(){var t,e,i,n,r;O_().emitter.off("antiScale",this.throttledUpdateScale),null==(t=this.clickHandler)||t.destroy(),this.clickHandler=null,null==(e=this.controlFill)||e.destroy(),null==(i=this.spotBorder)||i.destroy(),null==(n=this.centerIcon)||n.destroy(),null==(r=this.sizeText)||r.destroy(),super.destroy()}static create(t){const e=O_();return new sx({spotData:t,events:{onUpdate:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onUpdateSpot)||n.call(i,t)},onClick:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onClickSpot)||n.call(i,t)}}})}}class ox extends xe{constructor(t){super(),__publicField(this,"endPoints"),__publicField(this,"dividerConfig"),__publicField(this,"dividerEvents"),__publicField(this,"roomId"),__publicField(this,"roomGeometry",null),__publicField(this,"dashLine"),__publicField(this,"solidLine",null),__publicField(this,"startEndPoint"),__publicField(this,"endEndPoint"),__publicField(this,"solidLinePoints",null),__publicField(this,"initialDividerPoints",[]),__publicField(this,"isDragging",!1),__publicField(this,"dragStartPosition",null),__publicField(this,"throttledHandleScaleChange"),__publicField(this,"handleEndPointDragStart",()=>{const t=O_();this.initialDividerPoints=this.endPoints.map(t=>__spreadValues({},t)),this.clearSolidLine(),t.getApp().requestRender("divider-endpoint-drag",!0)}),__publicField(this,"handleEndPointDragMove",(t,e)=>{0!==this.initialDividerPoints.length&&(this.endPoints[t]=e,this.updateDashLine(),this.updateSolidLine(),this.setupDashLineHitArea())}),__publicField(this,"handleEndPointDragEnd",()=>{var t,e;const i=O_();this.initialDividerPoints=[],i.getApp().stopRender("divider-endpoint-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),null==(e=(t=this.dividerEvents).onUpdate)||e.call(t,this.getDividerEndPoints())}),__publicField(this,"handleDashLinePointerDown",t=>{t.stopPropagation(),this.startDragging(t)}),__publicField(this,"handleDragPointerMove",t=>{if(!this.isDragging||!this.dragStartPosition||0===this.initialDividerPoints.length)return;const e=this.parent.toLocal(t.global),i=e.x-this.dragStartPosition.x,n=e.y-this.dragStartPosition.y;this.endPoints=this.initialDividerPoints.map(t=>({x:t.x+i,y:t.y+n})),this.updateAllComponents()}),__publicField(this,"handleDragPointerUp",()=>{var t,e;const i=O_();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],i.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),null==(e=(t=this.dividerEvents).onUpdate)||e.call(t,this.getDividerEndPoints()))}),__publicField(this,"handleDragCancel",()=>{var t,e;const i=O_();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],i.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),null==(e=(t=this.dividerEvents).onUpdate)||e.call(t,this.getDividerEndPoints()))}),__publicField(this,"handleScaleChange",()=>{var t,e;null==(t=this.startEndPoint)||t.redraw(),null==(e=this.endEndPoint)||e.redraw(),this.updateSolidLine(),this.setupDashLineHitArea()});const{endPoints:e,roomId:i,events:n={}}=t;this.dividerEvents=n,this.roomId=i;const r=O_();this.dividerConfig=r.dividerConfig,this.roomGeometry=r.mapManager.getRoomById(this.roomId)||null,this.endPoints=e?this.validateDividerPoints(e):this.createDefaultdividerPoints(),this.throttledHandleScaleChange=zg(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 e=t[0]||{x:0,y:0};return[e,{x:e.x+50,y:e.y}]}createDefaultdividerPoints(){if(!this.roomGeometry)return vm.warn("Room geometry not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const t=O_(),e=t.getApp().mapState;if(!e)return vm.warn("Map state not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const{boundingBox:i}=this.roomGeometry,n=t.getApp().toFixedSize(this.dividerConfig.defaultExtension),r=this.dividerConfig.defaultDirection,s=i.x+i.width/2,o=i.y+i.height/2,a="horizontal"===r?i.width+2*n:i.height+2*n;return t_(s,o,a,r).map(t=>({x:t.x-e.origin.x,y:t.y-e.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:e,dashLineDashArray:i,lineColor:n}=this.dividerConfig;this.dashLine=new cy({start:t[0],end:t[1],style:{color:n.toString(),width:e,dashArray:i}})}createEndPoints(){const t=this.endPoints;this.startEndPoint=new uy({position:t[0],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:t=>this.handleEndPointDragMove(0,t),onDragEnd:this.handleEndPointDragEnd}),this.endEndPoint=new uy({position:t[1],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:t=>this.handleEndPointDragMove(1,t),onDragEnd:this.handleEndPointDragEnd})}setupDashLineInteraction(){this.dashLine&&(this.setupDashLineHitArea(),this.dashLine.off("pointerdown",this.handleDashLinePointerDown),this.dashLine.on("pointerdown",this.handleDashLinePointerDown))}setupDashLineHitArea(){const t=O_();if(!this.dashLine)return;const e=this.endPoints;if(e.length<2)return;const{hitAreaThickness:i}=this.dividerConfig,n=t.getApp().toFixedSize(i),r=Ym(e[0],e[1],n);if(0===r.length)return;const s=new xr(r);this.dashLine.hitArea=s}startDragging(t){const e=O_();this.isDragging=!0;const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},this.initialDividerPoints=this.endPoints.map(t=>__spreadValues({},t)),this.clearSolidLine(),e.getApp().requestRender("divider-drag",!0),O_().emitter.emit("gestureHijackStart",t)}setupDragEventListeners(){const{emitter:t}=O_();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=O_();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:e}=this.dividerConfig,i=O_().getApp().toFixedSize(t);this.solidLine.clear(),this.solidLine.setStrokeStyle({color:e.toString(),width:i}).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}=O_();t.on("antiScale",this.throttledHandleScaleChange)}getDividerEndPoints(){return[...this.endPoints]}getEffectiveDividerPoints(){return this.solidLinePoints?[...this.solidLinePoints]:null}calculateAndCreateSolidLine(){if(this.clearSolidLine(),!this.roomId)return;if(!this.getRoomGraphics())return;const t=this.calculateLineRoomIntersection();t&&t.length>=2&&(this.solidLinePoints=[t[0],t[t.length-1]],this.createSolidLine())}getRoomGraphics(){const t=O_().mapManager.roomFill;if(!t||!this.roomId)return null;return t.getRoomGraphicsMap().get(this.roomId)||null}calculateLineRoomIntersection(){const t=this.endPoints;if(t.length<2)return null;if(!this.roomId)return null;const[e,i]=t,n=this.isPointInRoomFill(e),r=this.isPointInRoomFill(i);if(n||r)return null;const s=((t,e,i=1,n=2e3)=>{const r=[],s=e.x-t.x,o=e.y-t.y,a=Math.sqrt(s*s+o*o);if(0===a)return[t];const l=Math.min(Math.max(Math.ceil(a/i),2),n);for(let h=0;h<=l;h++){const e=h/l,i={x:t.x+e*s,y:t.y+e*o};r.push(i)}return r})(e,i),o=[];for(const c of s)this.isPointInRoomFill(c)&&o.push(c);if(0===o.length)return null;const a=o[0],l=o[o.length-1];if(Om(a,l)<3)return null;const h=((t,e,i)=>{const n=e.x-t.x,r=e.y-t.y,s=Math.sqrt(n*n+r*r);if(0===s)return[t,e];const o=n/s,a=r/s;return[{x:t.x-o*i,y:t.y-a*i},{x:e.x+o*i,y:e.y+a*i}]})(a,l,.5);return h}isPointInRoomFill(t){if(!this.roomId)return!1;const e=O_().getApp().mapState;if(!e)return!1;const i={x:t.x+e.origin.x,y:t.y+e.origin.y};return this.isRasterData()?this.isPointInRasterRoomFill(i):this.isPointInStructuredRoomFill(i)}isPointInRasterRoomFill(t){t.x-=.5,t.y-=.5;const e=O_(),i=e.getApp().mapState,n=e.mapManager.roomFill;if(!i||!n)return!1;const r=n.getRasterRoomData(this.roomId);if(!r)return!1;const s=n.getMapWidth();if(0===s)return!1;const o=Math.round(t.y)*s+Math.round(t.x);for(let a=0;a<r.pixelIndices.length;a++)if(r.pixelIndices[a]===o)return!0;return!1}isPointInStructuredRoomFill(t){const e={x:Math.round(t.x),y:Math.round(t.y)},i=O_(),n=i.getApp().mapState,r=i.mapManager.getRoomById(this.roomId);return!!(n&&r&&r.outlinePoints)&&Em(e,r.outlinePoints,!0)}isRasterData(){const t=O_().mapManager.getRoomById(this.roomId);return!t||!t.outlinePoints||0===t.outlinePoints.length}isDividerCompletelyOutOfRoom(){if(!this.roomGeometry)return!1;const{boundingBox:t}=this.roomGeometry,e=this.endPoints;if(e.length<2)return!1;const i=O_().getApp().mapState;if(!i)return!1;return!((t,e,i,n,r,s)=>{const o=i+r,a=n+s,l=Math.min(t.x,e.x),h=Math.max(t.x,e.x),c=Math.min(t.y,e.y),u=Math.max(t.y,e.y);if(h<i||l>o||u<n||c>a)return!1;if(Jm(t,i,n,r,s)||Jm(e,i,n,r,s))return!0;const d=[{x:i,y:n},{x:o,y:n},{x:o,y:a},{x:i,y:a}];for(let p=0;p<4;p++)if(Km(t,e,d[p],d[(p+1)%4]))return!0;return!1})({x:e[0].x+i.origin.x,y:e[0].y+i.origin.y},{x:e[1].x+i.origin.x,y:e[1].y+i.origin.y},t.x,t.y,t.width,t.height)}checkAndResetIfOutOfRoom(){const t=O_(),{resetDividerWhenOutOfRoom:e}=t.dividerConfig;e&&this.isDividerCompletelyOutOfRoom()&&this.resetToDefaultState()}resetToDefaultState(){var t,e;this.endPoints=this.createDefaultdividerPoints(),this.calculateAndCreateSolidLine(),this.updateComponents(),null==(e=(t=this.dividerEvents).onUpdate)||e.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:e}=this.dividerConfig,i=O_();this.solidLine=new fl,this.solidLine.eventMode="none";const n=i.getApp().toFixedSize(t);this.solidLine.setStrokeStyle({color:e.toString(),width:n}).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,e,i;O_().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(),null==(t=this.dashLine)||t.destroy(),null==(e=this.startEndPoint)||e.destroy(),null==(i=this.endEndPoint)||i.destroy(),super.destroy()}}class ax{constructor(){__publicField(this,"forbiddenSweepZoneMap",new Map),__publicField(this,"forbiddenMopZoneMap",new Map),__publicField(this,"cleanZoneMap",new Map),__publicField(this,"virtualWallMap",new Map),__publicField(this,"spotMap",new Map),__publicField(this,"divider",null),__publicField(this,"unsubscribeFns",[]);const t=O_(),e=Wy(t.runtime,"editingForbiddenSweepZoneIds",t=>{vm.log(`[runtime] editingForbiddenSweepZoneIds: ${t}`),this.updateZonesEditState(this.forbiddenSweepZoneMap)}),i=Wy(t.runtime,"editingForbiddenMopZoneIds",t=>{vm.log(`[runtime] editingForbiddenMopZoneIds: ${t}`),this.updateZonesEditState(this.forbiddenMopZoneMap)}),n=Wy(t.runtime,"editingCleanZoneIds",t=>{vm.log(`[runtime] editingCleanZoneIds: ${t}`),this.updateZonesEditState(this.cleanZoneMap)}),r=Wy(t.runtime,"editingVirtualWallIds",t=>{vm.log(`[runtime] editingVirtualWallIds: ${t}`),this.updateVirtualWallsEditState(this.virtualWallMap)}),s=Wy(t.runtime,"editingSpotIds",t=>{vm.log(`[runtime] editingSpotIds: ${t}`),this.updateSpotsEditState(this.spotMap)}),o=Wy(t.runtime,"dividingRoomId",t=>{vm.log(`[runtime] dividingRoomId: ${t}`),this.handleDividingRoomIdChange(t)});this.unsubscribeFns.push(e,i,n,r,s,o)}updatePositionByOrigin(t,e){const i=O_().appContainer.getLayer(j_);i&&i.position.set(t,e)}drawForbiddenSweepZones(t){this.drawZones(t,this.forbiddenSweepZoneMap,t=>tx.create(t))}getForbiddenSweepZones(){return this.getZonesData(this.forbiddenSweepZoneMap)}clearAllForbiddenSweepZones(){this.clearAllZones(this.forbiddenSweepZoneMap)}drawForbiddenMopZones(t){this.drawZones(t,this.forbiddenMopZoneMap,t=>ex.create(t))}getForbiddenMopZones(){return this.getZonesData(this.forbiddenMopZoneMap)}clearAllForbiddenMopZones(){this.clearAllZones(this.forbiddenMopZoneMap)}drawCleanZones(t){this.drawZones(t,this.cleanZoneMap,t=>ix.create(t))}getCleanZones(){return this.getZonesData(this.cleanZoneMap)}clearAllCleanZones(){this.clearAllZones(this.cleanZoneMap)}drawVirtualWalls(t){const e=O_(),i=this.virtualWallMap,n=new Set(t.map(t=>t.id));for(const[r,s]of i)n.has(r)||(e.appContainer.removeFromLayer(j_,s),s.destroy(),i.delete(r));t.forEach(t=>{const n=i.get(t.id);if(n)this.isWallDataEqual(n.getWallData(),t)||n.updateWallData(t);else{const n=new rx({wallData:t,events:{onRemove:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onRemoveVirtualWall)||n.call(i,t)},onUpdate:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onUpdateVirtualWall)||n.call(i,t)},onClick:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onClickVirtualWall)||n.call(i,t)}}});i.set(t.id,n),e.appContainer.addToLayer(j_,n)}})}getVirtualWalls(){return this.getWallsData(this.virtualWallMap)}clearAllVirtualWalls(){this.clearAllWalls(this.virtualWallMap)}drawSpots(t){const e=this.spotMap;if(!t||0===t.length)return void this.clearAllSpotsInternal(e);const i=new Set(e.keys()),n=new Set(t.map(t=>t.id));for(const r of i)n.has(r)||this.removeSpot(r,e);t.forEach(t=>{const i=e.get(t.id);i?this.isSpotDataEqual(i.getSpotData(),t)||i.updateSpotData(t):this.addNewSpot(t,e)})}getSpots(){return this.getSpotsData(this.spotMap)}clearAllSpots(){this.clearAllSpotsInternal(this.spotMap)}drawZones(t,e,i){if(!t||0===t.length)return void this.clearAllZones(e);const n=new Set(e.keys()),r=new Set(t.map(t=>t.id));for(const s of n)r.has(s)||this.removeZone(s,e);t.forEach(t=>{const n=e.get(t.id);n?this.isZoneDataEqual(n.getZoneData(),t)||n.updateZoneData(t):this.addNewZone(t,e,i)})}addNewZone(t,e,i){const n=O_(),r=i(t);e.set(t.id,r),n.appContainer.addToLayer(j_,r)}removeZone(t,e){const i=O_(),n=e.get(t);n&&(i.appContainer.removeFromLayer(j_,n),n.destroy(),e.delete(t))}getZonesData(t){const e=[];return t.forEach(t=>{e.push(t.getZoneData())}),e}clearAllZones(t){t.forEach((e,i)=>{var n;const r=t.get(i);r&&(null==(n=r.parent)||n.removeChild(r),r.destroy())}),t.clear()}updateZonesEditState(t){t.forEach(t=>{t.updateEditState()})}updateVirtualWallsEditState(t){t.forEach(t=>{t.updateEditingState()})}isZoneDataEqual(t,e){if(t.id!==e.id)return!1;if(t.points.length!==e.points.length)return!1;for(let i=0;i<t.points.length;i++){const n=t.points[i],r=e.points[i];if(Math.abs(n.x-r.x)>.1||Math.abs(n.y-r.y)>.1)return!1}return!0}getWallsData(t){return Array.from(t.values()).map(t=>t.getWallData())}clearAllWalls(t){for(const e of t.values())e.destroy();t.clear()}isWallDataEqual(t,e){if(t.id!==e.id)return!1;if(t.points.length!==e.points.length)return!1;for(let i=0;i<t.points.length;i++){const n=t.points[i],r=e.points[i];if(Math.abs(n.x-r.x)>.1||Math.abs(n.y-r.y)>.1)return!1}return!0}addNewSpot(t,e){const i=O_(),n=sx.create(t);e.set(t.id,n),i.appContainer.addToLayer(j_,n)}removeSpot(t,e){const i=O_(),n=e.get(t);n&&(i.appContainer.removeFromLayer(j_,n),n.destroy(),e.delete(t))}getSpotsData(t){const e=[];return t.forEach(t=>{e.push(t.getSpotData())}),e}clearAllSpotsInternal(t){t.forEach((e,i)=>{var n;const r=t.get(i);r&&(null==(n=r.parent)||n.removeChild(r),r.destroy())}),t.clear()}updateSpotsEditState(t){t.forEach(t=>{t.updateEditState()})}isSpotDataEqual(t,e){if(t.id!==e.id)return!1;const i=t.point,n=e.point;return!(Math.abs(i.x-n.x)>.1||Math.abs(i.y-n.y)>.1)}handleDividingRoomIdChange(t){if(null==t)return void this.clearDivider();this.getRoomGeometry(t)?this.createDefaultDivider(t):this.clearDivider()}getRoomGeometry(t){return O_().mapManager.getRoomById(t)}createDefaultDivider(t){const e=O_();this.clearDivider(),this.divider=new ox({roomId:t,events:{onUpdate:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onUpdateDivider)||n.call(i,t)}}}),e.appContainer.addToLayer(j_,this.divider)}clearDivider(){if(this.divider){O_().appContainer.removeFromLayer(j_,this.divider),this.divider.destroy(),this.divider=null}}getDividerEndPoints(){return this.divider?this.divider.getDividerEndPoints():null}getEffectiveDividerPoints(){return this.divider?this.divider.getEffectiveDividerPoints():null}destroy(){this.clearAllForbiddenSweepZones(),this.clearAllForbiddenMopZones(),this.clearAllCleanZones(),this.clearAllVirtualWalls(),this.clearAllSpots(),this.clearDivider(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}class lx extends oy{constructor(t){super(),__publicField(this,"objectData"),__publicField(this,"clickHandler",null),this.objectData=t}initializeSprite(){return __async(this,null,function*(){const t=O_().detectedObjectConfig,e=this.objectData.width||t.width,i=this.objectData.height||t.height;yield this.loadTextureAndSetSize(this.objectData.src,{width:e,height:i}),this.position.set(this.objectData.x,this.objectData.y),this.visible=!0,t.interactive?this.setupClickHandler():this.eventMode="none"})}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new iy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var t,e;null==(e=null==(t=O_().events)?void 0:t.onClickDetectedObject)||e.call(t,this.getObjectData())}getObjectData(){return __spreadValues({},this.objectData)}updateObjectData(t){return __async(this,null,function*(){const e=O_(),i=this.objectData;this.objectData=t;const n=e.detectedObjectConfig;if(i.src!==t.src){const e=t.width||n.width,i=t.height||n.height;yield this.loadTextureAndSetSize(t.src,{width:e,height:i})}if(i.width!==t.width||i.height!==t.height){const e=t.width||n.width,i=t.height||n.height;this.setFixedSize(e,i)}this.position.set(t.x,t.y),n.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.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class hx{constructor(){__publicField(this,"detectedObjectMap",new Map)}updatePositionByOrigin(t,e){const i=O_().appContainer.getLayer(X_);i&&i.position.set(t,e)}drawDetectedObjects(t){return __async(this,null,function*(){if(!t||0===t.length)return void this.clearAllDetectedObjects();const e=new Set(t.map(t=>t.id)),i=Array.from(this.detectedObjectMap.keys());for(const t of i)e.has(t)||this.removeDetectedObject(t);for(const n of t){const t=this.detectedObjectMap.get(n.id);t?t.isSameData(n)||(yield t.updateObjectData(n)):yield this.addNewDetectedObject(n)}})}clearAllDetectedObjects(){const t=O_();this.detectedObjectMap.forEach(e=>{t.appContainer.removeFromLayer(X_,e),e.destroy()}),this.detectedObjectMap.clear()}addNewDetectedObject(t){return __async(this,null,function*(){const e=O_(),i=new lx(t);yield i.initializeSprite(),this.detectedObjectMap.set(t.id,i),e.appContainer.addToLayer(X_,i)})}removeDetectedObject(t){const e=O_(),i=this.detectedObjectMap.get(t);i&&(e.appContainer.removeFromLayer(X_,i),i.destroy(),this.detectedObjectMap.delete(t))}destroy(){this.clearAllDetectedObjects()}}class cx extends oy{constructor(t){super(),__publicField(this,"elementData"),__publicField(this,"clickHandler",null),this.elementData=t}initialize(){return __async(this,null,function*(){yield this.loadTextureAndSetSize(this.elementData.src,{width:this.elementData.width,height:this.elementData.height,sizeFixed:this.elementData.sizeFixed}),this.position.set(this.elementData.x,this.elementData.y),void 0!==this.elementData.rotation&&(this.rotation=this.elementData.rotation),void 0!==this.elementData.opacity&&(this.alpha=this.elementData.opacity),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"})}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new iy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var t,e;null==(e=null==(t=O_().events)?void 0:t.onClickCustomElement)||e.call(t,this.getElementData())}getElementData(){return __spreadValues({},this.elementData)}updateElementData(t){return __async(this,null,function*(){const e=this.elementData;this.elementData=t,e.src!==t.src?yield this.loadTextureAndSetSize(t.src,{width:t.width,height:t.height,sizeFixed:t.sizeFixed}):(e.sizeFixed!==t.sizeFixed&&void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),e.width===t.width&&e.height===t.height||this.setFixedSize(t.width,t.height)),this.position.set(t.x,t.y),void 0!==t.rotation&&(this.rotation=t.rotation),void 0!==t.opacity&&(this.alpha=t.opacity),t.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")})}isSameData(t){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}destroy(){this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class ux extends By{constructor(t,e){super({source:t}),__publicField(this,"elementData"),__publicField(this,"clickHandler",null),this.elementData=e}initialize(){return __async(this,null,function*(){void 0!==this.elementData.sizeFixed&&this.setSizeFixed(this.elementData.sizeFixed),this.setFixedSize(this.elementData.width,this.elementData.height),this.position.set(this.elementData.x,this.elementData.y),void 0!==this.elementData.rotation&&(this.rotation=this.elementData.rotation),void 0!==this.elementData.opacity&&(this.alpha=this.elementData.opacity),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"})}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new iy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var t,e;null==(e=null==(t=O_().events)?void 0:t.onClickCustomElement)||e.call(t,this.getElementData())}getElementData(){return __spreadValues({},this.elementData)}updateElementData(t){return __async(this,null,function*(){const e=this.elementData;if(this.elementData=t,e.src!==t.src)throw new Error("GIF source change requires recreation of instance");e.sizeFixed!==t.sizeFixed&&void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),e.width===t.width&&e.height===t.height||this.setFixedSize(t.width,t.height),this.position.set(t.x,t.y),void 0!==t.rotation&&(this.rotation=t.rotation),void 0!==t.opacity&&(this.alpha=t.opacity),t.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")})}isSameData(t){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}destroy(){this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class dx extends dy{constructor(t){const e=document.createElement("div");dx.setupDefaultStyles(e,t),e.innerHTML=t.htmlContent,super({element:e}),__publicField(this,"elementData"),__publicField(this,"domClickHandler",null),__publicField(this,"resizeObserver",null),this.elementData=t}initialize(){return __async(this,null,function*(){this.alpha=0,this.position.set(this.elementData.x,this.elementData.y),void 0!==this.elementData.rotation&&(this.rotation=this.elementData.rotation),this.elementData.width&&this.elementData.height?(this.setFixedSize(this.elementData.width,this.elementData.height),this.waitForElementInsertion()):this.setupAutoSize(),this.elementData.interactive?this.setupClickHandler():this.eventMode="none"})}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&&("undefined"!=typeof ResizeObserver?(this.resizeObserver=new ResizeObserver(t=>{var e;const i=t[0];i&&i.contentRect.width>0&&i.contentRect.height>0&&(this.setFixedSize(i.contentRect.width,i.contentRect.height),0===this.alpha&&this.showElement(),null==(e=this.resizeObserver)||e.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)return void requestAnimationFrame(t);const e=this.element.getBoundingClientRect();e.width>0&&e.height>0?(this.setFixedSize(e.width,e.height),0===this.alpha&&this.showElement()):requestAnimationFrame(t)};requestAnimationFrame(t)}showElement(){var t,e;this.alpha=null!=(t=this.elementData.opacity)?t:1,this.element.style.pointerEvents=this.elementData.interactive?"auto":"none",this.interactive=null!=(e=this.elementData.interactive)&&e,this.elementData.interactive&&this.element&&(this.element.style.setProperty("-webkit-tap-highlight-color","transparent"),this.element.style.setProperty("-webkit-touch-callout","none"))}setupClickHandler(){this.element&&(this.domClickHandler=t=>{t.preventDefault(),t.stopPropagation(),this.handleClick()},this.element.addEventListener("click",this.domClickHandler))}handleClick(){var t,e;null==(e=null==(t=O_().events)?void 0:t.onClickCustomElement)||e.call(t,this.getElementData())}getElementData(){return __spreadValues({},this.elementData)}updateElementData(t){return __async(this,null,function*(){var e,i;const n=this.elementData;this.elementData=t,n.htmlContent!==t.htmlContent&&this.element&&(this.element.innerHTML=t.htmlContent,t.width&&t.height||this.waitForElementDimensions()),n.width===t.width&&n.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()),this.position.set(t.x,t.y),this.rotation=null!=(e=t.rotation)?e:0,this.alpha=null!=(i=t.opacity)?i: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}static setupDefaultStyles(t,e){const i={position:"relative",boxSizing:"border-box",webkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",background:"transparent",userSelect:"auto",webkitUserSelect:"auto",transformOrigin:"50% 50%"};e.width&&e.height?(i.width=`${e.width}px`,i.height=`${e.height}px`,i.overflow="hidden"):(i.width=e.width?`${e.width}px`:"auto",i.height=e.height?`${e.height}px`:"auto",i.overflow="visible"),Object.assign(t.style,i),t.style.setProperty("-webkit-tap-highlight-color","transparent"),t.style.setProperty("-webkit-touch-callout","none")}destroy(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null),super.destroy()}}class px{constructor(){__publicField(this,"customElementsMap",new Map),__publicField(this,"gifTicker",null),__publicField(this,"gifElements",new Set)}updatePositionByOrigin(t,e){const i=O_(),n=i.appContainer.getLayer(Z_),r=i.appContainer.getLayer(q_);n&&n.position.set(t,e),r&&r.position.set(t,e)}drawCustomElements(t){return __async(this,null,function*(){if(!t||0===t.length)return void this.clearAllCustomElements();const e=new Set(t.map(t=>t.id)),i=Array.from(this.customElementsMap.keys());for(const t of i)e.has(t)||this.removeCustomElement(t);const n=t.map(t=>__async(this,null,function*(){const e=this.customElementsMap.get(t.id);e?this.isSameData(e,t)||("gif"===t.type&&e.getElementData().src!==t.src?(this.removeCustomElement(t.id),yield this.addNewCustomElement(t)):yield this.updateElementData(e,t)):yield this.addNewCustomElement(t)}));yield Promise.all(n),this.updateGifTicker()})}clearAllCustomElements(){const t=O_();this.customElementsMap.forEach(e=>{e instanceof ux?t.appContainer.removeFromLayer(q_,e):t.appContainer.removeFromLayer(Z_,e),e.destroy()}),this.customElementsMap.clear(),this.gifElements.clear(),this.stopGifTicker()}addNewCustomElement(t){return __async(this,null,function*(){const e=O_();let i;switch(t.type){case"image":i=new cx(t);break;case"gif":{const e=yield Ya.load(t.src);i=new ux(e,t);break}case"html":i=new dx(t);break;default:throw new Error(`Unsupported custom element type: ${t.type}`)}yield i.initialize(),this.customElementsMap.set(t.id,i),i instanceof ux?(e.appContainer.addToLayer(q_,i),this.gifElements.add(i)):e.appContainer.addToLayer(Z_,i)})}removeCustomElement(t){const e=O_(),i=this.customElementsMap.get(t);i&&(i instanceof ux?(this.gifElements.delete(i),e.appContainer.removeFromLayer(q_,i)):e.appContainer.removeFromLayer(Z_,i),i.destroy(),this.customElementsMap.delete(t))}isSameData(t,e){return t.getElementData().type===e.type&&(("image"===e.type&&t instanceof cx||"gif"===e.type&&t instanceof ux||"html"===e.type&&t instanceof dx)&&t.isSameData(e))}updateElementData(t,e){return __async(this,null,function*(){if("image"===e.type&&t instanceof cx)yield t.updateElementData(e);else if("gif"===e.type&&t instanceof ux)yield t.updateElementData(e);else{if(!("html"===e.type&&t instanceof dx))throw new Error("Element type mismatch during update");yield t.updateElementData(e)}})}updateGifTicker(){this.gifElements.size>0?this.startGifTicker():this.stopGifTicker()}startGifTicker(){var t;(null==(t=this.gifTicker)?void 0:t.started)||(this.gifTicker?this.gifTicker.maxFPS=1:(this.gifTicker=new Ue,this.gifTicker.maxFPS=1,this.gifTicker.add(()=>{this.renderGifContainer()})),this.gifTicker.start())}stopGifTicker(){var t;(null==(t=this.gifTicker)?void 0:t.started)&&(vm.log("⏸️ [GifTicker] 停止 GIF 专用渲染"),this.gifTicker.stop())}renderGifContainer(){const t=O_();if(0===this.gifElements.size)return;const e=t.getApp();e.renderer.render(e.stage)}destroy(){this.stopGifTicker(),this.gifTicker&&(this.gifTicker.destroy(),this.gifTicker=null),this.clearAllCustomElements()}}class fx extends Rl{constructor(t){var e;const i=O_(),{nameLabel:n,colors:r}=i.roomConfig,s=null!=(e=t.colorIndex)?e:t.index,o=r.name[s%r.name.length],a=new zo({fontSize:n.fontSize,fontFamily:n.fontFamily,fontWeight:n.fontWeight,fill:o,align:"center"});super({text:t.name||"Unknown",style:a}),__publicField(this,"roomId"),__publicField(this,"roomIndex"),this.roomId=t.id,this.roomIndex=t.index,this.anchor.set(.5)}updateName(t){this.text=t}refreshColor(t){var e;const i=O_(),{colors:n}=i.roomConfig,r=i.getRoomData(this.roomId),s=null!=(e=null==r?void 0:r.colorIndex)?e:this.roomIndex,o=null!=t?t:n.name[s%n.name.length];this.style.fill=o}}class gx extends xe{constructor(t){var e;super(),__publicField(this,"background"),__publicField(this,"cleanModeIcon"),__publicField(this,"suctionIcon"),__publicField(this,"cisternIcon"),__publicField(this,"cleanTimesIcon"),__publicField(this,"orderContainer"),__publicField(this,"orderBackground"),__publicField(this,"orderText"),__publicField(this,"bubble",null),__publicField(this,"isFolded",!1),__publicField(this,"roomId"),__publicField(this,"roomIndex");const i=O_(),n=i.roomConfig;this.roomId=t.id,this.roomIndex=t.index,this.background=new fl;const{property:r,colors:{propertyTheme:s}}=n;n.property.foldable&&(this.bubble=new fl);const o=s[(null!=(e=t.colorIndex)?e:t.index)%s.length];this.cleanModeIcon=new oy,this.cleanModeIcon.tint=o,this.cleanModeIcon.anchor.set(0,0),this.suctionIcon=new oy,this.suctionIcon.tint=o,this.suctionIcon.anchor.set(0,0),this.cisternIcon=new oy,this.cisternIcon.tint=o,this.cisternIcon.anchor.set(0,0),this.cleanTimesIcon=new oy,this.cleanTimesIcon.tint=o,this.cleanTimesIcon.anchor.set(0,0),this.orderContainer=new xe,this.orderBackground=new fl,this.orderText=new Rl({text:"",style:new zo({fontSize:r.cleanOrder.fontSize,fontFamily:r.cleanOrder.fontFamily,fontWeight:r.cleanOrder.fontWeight,fill:r.cleanOrder.color,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.bubble&&this.addChild(this.bubble),this.addChild(this.cleanModeIcon),this.addChild(this.suctionIcon),this.addChild(this.cisternIcon),this.addChild(this.cleanTimesIcon),this.addChild(this.orderContainer),this.visible=i.runtimeSnapshot.showRoomProperty,this.updateProperty(t)}updateProperty(t){return __async(this,null,function*(){yield this.updateIcons(t),this.updateBackground()})}getDisplayElements(t){const e=O_(),{displayOrders:i}=e.roomConfig.property,{showRoomOrder:n,showRoomProperty:r}=e.runtimeSnapshot,s=t.order||0,o=n&&s>0,a=r&&i.includes("cleanMode"),l=r&&i.includes("suction"),h=r&&i.includes("cistern"),c=r&&i.includes("cleanTimes")&&t.cleanTimes>0,u={cleanMode:{element:this.cleanModeIcon,show:a,isOrder:!1},suction:{element:this.suctionIcon,show:l,isOrder:!1},cistern:{element:this.cisternIcon,show:h,isOrder:!1},cleanTimes:{element:this.cleanTimesIcon,show:c,isOrder:!1}},d=[];return o&&d.push({element:this.orderContainer,show:!0,isOrder:!0}),i.forEach(t=>{const e=u[t];e&&e.show&&d.push(e)}),{shouldShowOrder:o,shouldShowCleanMode:a,shouldShowSuction:l,shouldShowCistern:h,shouldShowCleanTimes:c,elementsToShow:d,orderValue:s}}updateIcons(t){return __async(this,null,function*(){var e;const i=O_(),{iconWidth:n,iconHeight:r,container:s,cleanOrder:o,foldable:a,iconGap:l}=i.roomConfig.property,{propertyTheme:h}=i.roomConfig.colors,{paddingHorizontal:c,paddingVertical:u}=s,{shouldShowOrder:d,shouldShowCleanMode:p,shouldShowSuction:f,shouldShowCistern:g,shouldShowCleanTimes:m,elementsToShow:_,orderValue:y}=this.getDisplayElements(t);this.orderContainer.visible=d,this.cleanModeIcon.visible=p,this.suctionIcon.visible=f,this.cisternIcon.visible=g,this.cleanTimesIcon.visible=m,a&&this.isFolded&&(this.orderContainer.visible=!1,this.cleanModeIcon.visible=!1,this.suctionIcon.visible=!1,this.cisternIcon.visible=!1,this.cleanTimesIcon.visible=!1);const x=[];if(p&&x.push(this.cleanModeIcon.loadTextureAndSetSize(`cleanMode_${t.cleanMode}`,{width:n,height:r,sizeFixed:!1})),f&&x.push(this.suctionIcon.loadTextureAndSetSize(`fan_${t.suction}`,{width:n,height:r,sizeFixed:!1})),g&&x.push(this.cisternIcon.loadTextureAndSetSize(`water_${t.cistern}`,{width:n,height:r,sizeFixed:!1})),m){const e=t.cleanTimes||1;x.push(this.cleanTimesIcon.loadTextureAndSetSize(`cleanTimes${e}`,{width:n,height:r,sizeFixed:!1}))}if(yield Promise.all(x),d){this.orderText.text=y.toString();const t=i.getRoomData(this.roomId),s=null!=(e=null==t?void 0:t.colorIndex)?e:this.roomIndex;this.orderBackground.clear(),this.orderBackground.setFillStyle({color:h[s%h.length]}),this.orderBackground.circle(n/2,r/2,n/2).fill(),this.orderText.position.set(n/2,r/2)}let b=c;_.forEach((t,e)=>{const{element:i,isOrder:r}=t;i.position.set(b,u),b+=n,e<_.length-1&&(b+=r?o.gapRight:l)})})}updateBackground(){const t=O_().roomConfig,{container:e,foldable:i}=t.property,{borderRadius:n,tailHeight:r,tailWidth:s,backgroundColor:o}=e,a=this.calculateContentWidth(),l=this.calculateContentHeight(),h=Math.min(s,a/2);if(this.background.clear(),this.bubble&&this.bubble.clear(),this.background.setFillStyle({color:o}),this.background.roundRect(0,0,a,l,n).fill(),i&&this.bubble){const t=(a-h)/2;this.bubble.setFillStyle({color:o}),this.bubble.poly([t,l-1,t+h,l-1,t+h/2,l+r]).fill()}}calculateContentWidth(){const t=O_(),{iconWidth:e,container:i,cleanOrder:n,iconGap:r}=t.roomConfig.property,{paddingHorizontal:s}=i,o=t.getRoomData(this.roomId);if(!o)return 2*s;const{elementsToShow:a}=this.getDisplayElements(o);let l=s;return a.forEach((t,i)=>{const{isOrder:s}=t;l+=e,i<a.length-1&&(l+=s?n.gapRight:r)}),l+=s,l}calculateContentHeight(){const t=O_().roomConfig,{iconHeight:e,container:i}=t.property;return i.paddingVertical+e+i.paddingVertical}getTotalHeight(){const t=O_(),{foldable:e,container:i}=t.roomConfig.property,{tailHeight:n}=i;return this.calculateContentHeight()+(e?n:0)}getTotalWidth(){return this.calculateContentWidth()}setFolded(t){const e=O_(),{foldable:i}=e.roomConfig.property;if(i)if(this.isFolded=t,t)this.background.visible=!1,this.cleanModeIcon.visible=!1,this.suctionIcon.visible=!1,this.cisternIcon.visible=!1,this.cleanTimesIcon.visible=!1,this.orderContainer.visible=!1,this.bubble&&(this.bubble.visible=!0,this.bubble.rotation=Math.PI,this.repositionFoldedBubble());else{this.background.visible=!0,this.bubble&&(this.bubble.visible=!0,this.bubble.rotation=0,this.bubble.position.set(0,0)),this.updateBackground();const t=e.getRoomData(this.roomId);t&&this.updateIcons(t)}}isFoldedState(){const t=O_(),{foldable:e}=t.roomConfig.property;return!!e&&this.isFolded}repositionFoldedBubble(){const t=O_(),{foldable:e}=t.roomConfig.property;if(!e||!this.bubble)return;const i=t.roomConfig,{tailHeight:n}=i.property.container,r=this.calculateContentWidth(),s=this.calculateContentHeight(),o=r/2;this.bubble.position.set(o,s+n/2)}refreshColor(){var t;const e=O_(),{propertyTheme:i}=e.roomConfig.colors,n=e.getRoomData(this.roomId),r=null!=(t=null==n?void 0:n.colorIndex)?t:this.roomIndex,s=i[r%i.length];if(this.cleanModeIcon&&(this.cleanModeIcon.tint=s),this.suctionIcon&&(this.suctionIcon.tint=s),this.cisternIcon&&(this.cisternIcon.tint=s),this.cleanTimesIcon&&(this.cleanTimesIcon.tint=s),this.orderBackground&&this.orderBackground.visible){const{property:t}=e.roomConfig,n=t.iconWidth,s=t.iconHeight;this.orderBackground.clear(),this.orderBackground.setFillStyle({color:i[r%i.length]}),this.orderBackground.circle(n/2,s/2,n/2).fill()}}destroy(){var t,e,i,n;null==(t=this.cleanModeIcon)||t.destroy(),null==(e=this.suctionIcon)||e.destroy(),null==(i=this.cisternIcon)||i.destroy(),null==(n=this.cleanTimesIcon)||n.destroy(),super.destroy()}}class mx extends xe{constructor(t){super(),__publicField(this,"background"),__publicField(this,"checkmarkIcon"),__publicField(this,"bubble"),__publicField(this,"roomIndex"),__publicField(this,"roomId");const e=O_().roomConfig;this.roomId=t.id,this.roomIndex=t.index,this.background=new fl,this.bubble=new fl;const{colors:{selectionIndicatorIcon:i}}=e;this.checkmarkIcon=new oy,this.checkmarkIcon.tint=i[t.index%i.length],this.checkmarkIcon.anchor.set(0,0),this.addChild(this.background),this.addChild(this.bubble),this.addChild(this.checkmarkIcon),this.updateIndicator(t)}updateIndicator(t){return __async(this,null,function*(){const e=O_(),{roomSelectionMode:i,enableRoomSelection:n,selectRoomIds:r}=e.runtimeSnapshot;if(!n||"checkmark"!==i)return void(this.visible=!1);const s=r.includes(t.id);yield this.showCheckmarkMode(s),this.updateBackground()})}showCheckmarkMode(t){return __async(this,null,function*(){const e=O_(),{selectionIndicator:i}=e.roomConfig,{iconWidth:n,iconHeight:r}=i;if(t){this.visible=!0,this.checkmarkIcon.visible=!0,yield this.checkmarkIcon.loadTextureAndSetSize("checkmark",{width:n,height:r,sizeFixed:!1});const t=i.containerWidth/2,e=i.containerHeight/2;this.checkmarkIcon.position.set(t-n/2,e-r/2)}else this.visible=!1})}updateBackground(){var t;const e=O_(),{selectionIndicator:i,colors:n}=e.roomConfig,{containerWidth:r,containerHeight:s,strokeWidth:o,strokeColor:a,borderRadius:l,tailHeight:h,tailWidth:c}=i,u=e.getRoomData(this.roomId),d=null!=(t=null==u?void 0:u.colorIndex)?t:this.roomIndex,p=n.selectionIndicatorBackground[d%n.selectionIndicatorBackground.length];if(this.background.clear(),this.bubble.clear(),this.background.setFillStyle({color:p}).roundRect(0,0,r,s,l).fill().setStrokeStyle({color:a,width:o,alignment:0}).stroke(),h>0&&c>0){const t=(r-c)/2;this.bubble.setFillStyle({color:a});const e=s+o;this.bubble.poly([t,e-1,t+c,e-1,t+c/2,e+h]).fill()}}getTotalHeight(){const t=O_(),{selectionIndicator:e}=t.roomConfig,{containerHeight:i,tailHeight:n,strokeWidth:r}=e;return i+r+(n>0?n:0)}getTotalWidth(){const t=O_(),{selectionIndicator:e}=t.roomConfig;return e.containerWidth}refreshColor(){return __async(this,null,function*(){const t=O_().getRoomData(this.roomId);t&&(yield this.updateIndicator(t))})}destroy(){var t;null==(t=this.checkmarkIcon)||t.destroy(),super.destroy()}}class _x extends sy{constructor(t){super(),__publicField(this,"roomId"),__publicField(this,"roomName"),__publicField(this,"roomProperty",null),__publicField(this,"roomSelectionIndicator",null),__publicField(this,"clickHandler",null);const e=O_();this.enableRenderGroup(),this.roomId=t.id,t.centerPoint&&this.position.set(t.centerPoint.x,t.centerPoint.y),this.roomName=new fx(t),this.roomName.visible=e.runtimeSnapshot.showRoomName,this.createRoomProperty(t),this.createRoomSelectionIndicator(t),this.updateLayout(),this.clickHandler=new iy(this,{onClick:()=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onClickRoomProperties)||n.call(i,t)}})}shouldShowRoomProperty(){const t=O_(),{showRoomOrder:e,showRoomProperty:i,selectRoomIds:n,enableRoomSelection:r,roomSelectionMode:s}=t.runtimeSnapshot,o=t.getRoomData(this.roomId);if(!o)return!1;if(r&&"checkmark"===s&&n.includes(this.roomId))return!1;const a=e&&(o.order||0)>0,l=i&&(o.suction&&t.roomConfig.property.displayOrders.includes("suction")||o.cistern&&t.roomConfig.property.displayOrders.includes("cistern")||o.cleanTimes>0&&t.roomConfig.property.displayOrders.includes("cleanTimes"));return a||l}shouldShowRoomSelectionIndicator(){const t=O_(),{enableRoomSelection:e,roomSelectionMode:i}=t.runtimeSnapshot;return e&&"checkmark"===i}updateRoomPropertyVisibility(){const t=O_();if(!this.roomProperty)return;if(this.shouldShowRoomProperty()){this.roomProperty.visible=!0;const e=t.runtimeSnapshot.roomPropertyFoldIds.includes(this.roomId);this.roomProperty.setFolded(e);const i=t.getRoomData(this.roomId);i&&this.roomProperty.updateProperty(i)}else this.roomProperty.visible=!1;this.updateLayout()}updateRoomSelectionIndicatorVisibility(){return __async(this,null,function*(){const t=O_();if(!this.roomSelectionIndicator)return;if(this.shouldShowRoomSelectionIndicator()){const e=t.getRoomData(this.roomId);e&&(yield this.roomSelectionIndicator.updateIndicator(e))}else this.roomSelectionIndicator.visible=!1;this.updateLayout()})}createRoomProperty(t){return __async(this,null,function*(){const e=O_();this.roomProperty&&(this.removeChild(this.roomProperty),this.roomProperty.destroy()),this.roomProperty=new gx(t),yield this.roomProperty.updateProperty(t),this.addChild(this.roomProperty),this.addChild(this.roomName),this.roomName.visible=e.runtimeSnapshot.showRoomName,this.updateRoomPropertyVisibility()})}createRoomSelectionIndicator(t){return __async(this,null,function*(){this.roomSelectionIndicator&&(this.removeChild(this.roomSelectionIndicator),this.roomSelectionIndicator.destroy()),this.roomSelectionIndicator=new mx(t),this.addChild(this.roomSelectionIndicator),yield this.updateRoomSelectionIndicatorVisibility()})}updateLayout(){var t,e;const i=O_(),{property:{offsetY:n,offsetX:r},selectionIndicator:{offsetY:s,offsetX:o}}=i.roomConfig,a=(null==(t=this.roomProperty)?void 0:t.visible)||!1,l=this.roomName.visible,h=(null==(e=this.roomSelectionIndicator)?void 0:e.visible)||!1;if(a&&this.roomProperty)if(this.roomProperty.isFoldedState())this.roomProperty.position.set(r,-n);else{const t=this.roomProperty.getTotalHeight(),e=this.roomProperty.getTotalWidth();l?(this.roomProperty.position.set(-e/2+r,-n-t),this.roomName.position.set(0,0)):this.roomProperty.position.set(-e/2+r,-t/2-n)}if(h&&this.roomSelectionIndicator){const t=this.roomSelectionIndicator.getTotalHeight(),e=this.roomSelectionIndicator.getTotalWidth();l?(this.roomSelectionIndicator.position.set(-e/2+o,-s-t),this.roomName.position.set(0,0)):this.roomSelectionIndicator.position.set(-e/2+o,-t/2-s)}!l||a||h||this.roomName.position.set(0,0)}updateName(t){this.roomName.updateName(t)}updateRoomNameVisibility(t){this.roomName.visible=t,this.updateLayout()}updatePosition(t){this.position.set(t.x,t.y)}refreshColor(){return __async(this,null,function*(){this.roomName&&this.roomName.refreshColor(),this.roomProperty&&this.roomProperty.refreshColor(),this.roomSelectionIndicator&&(yield this.roomSelectionIndicator.refreshColor())})}destroy(){var t,e,i,n;null==(t=this.clickHandler)||t.destroy(),this.clickHandler=null,null==(e=this.roomProperty)||e.destroy(),this.roomProperty=null,null==(i=this.roomSelectionIndicator)||i.destroy(),this.roomSelectionIndicator=null,null==(n=this.roomName)||n.destroy(),super.destroy()}}class yx extends xe{constructor(){super({isRenderGroup:!0}),__publicField(this,"floorTypeMap",new Map),__publicField(this,"floorTypeMasks",new Map),__publicField(this,"floorTypeToRooms",new Map);O_().appContainer.addToLayer(z_,this)}createFloorTypes(t){return __async(this,null,function*(){if(!O_().runtimeSnapshot.showRoomFloorType)return;this.clearFloorTypes();const e=this.groupRoomsByFloorType(t),i=[];for(const[t,n]of e)i.push(this.createMergedFloorType(t,n));yield Promise.all(i)})}groupRoomsByFloorType(t){const e=new Map,i=O_();return t.forEach((t,n)=>{const r=i.getRoomData(n),s=(null==r?void 0:r.floorType)||0;s>=0&&(e.has(s)||e.set(s,[]),e.get(s).push({roomId:n,graphics:t}))}),e}createMergedFloorType(t,e){return __async(this,null,function*(){const i=O_(),{assets:n,opacity:r,scale:s}=i.roomConfig.floorType,o=t%n.length,a=`floorType${o}`;if(!n[o])return void vm.warn(`No texture asset configured for floorType: ${t}`);const l=yield Ya.load(a);if(!l)return void vm.warn(`Floor material texture not found: ${a}`);const h=(t=>{if(0===t.length)return{x:0,y:0,width:0,height:0};let e=t[0].x,i=t[0].y,n=t[0].x+t[0].width,r=t[0].y+t[0].height;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.min(i,t.y),n=Math.max(n,t.x+t.width),r=Math.max(r,t.y+t.height)}),{x:e,y:i,width:n-e,height:r-i}})(e.map(({graphics:t})=>t.getLocalBounds())),c=new vl({texture:l,width:h.width,height:h.height});c.x=h.x,c.y=h.y,c.alpha=r,c.tileScale.set(s);const u=this.createMergedMask(e.map(({graphics:t})=>t));c.mask=u,this.addChild(c),this.floorTypeMap.set(t,c),this.floorTypeMasks.set(t,u),this.floorTypeToRooms.set(t,new Set(e.map(({roomId:t})=>t)))})}createMergedMask(t){const e=new xe;return t.forEach(t=>{const i=new fl;i.context=t.context.clone(),e.addChild(i)}),e}clearFloorTypes(){this.floorTypeMap.forEach(t=>{try{this.removeChild(t),t.destroy()}catch(e){vm.warn("Error destroying floor material:",e)}}),this.floorTypeMap.clear(),this.floorTypeMasks.forEach(t=>{try{t.destroy()}catch(e){vm.warn("Error destroying floor mask:",e)}}),this.floorTypeMasks.clear(),this.floorTypeToRooms.clear()}destroy(){this.clearFloorTypes(),super.destroy()}}class xx{constructor(){__publicField(this,"unsubscribeFns",[]),__publicField(this,"roomInfoContainer",new xe),__publicField(this,"roomInfoMap",new Map),__publicField(this,"roomDisplayMap",new Map),__publicField(this,"roomFloorType",new yx);const t=O_();t.appContainer.addToLayer(Y_,this.roomInfoContainer);const e=Wy(t.runtime,"showRoomFloorType",t=>{vm.log(`[runtime] showRoomFloorType: ${t}`),t?this.updateFloorTypes():this.roomFloorType.clearFloorTypes()}),i=Wy(t.runtime,"showRoomProperty",t=>{vm.log(`[runtime] showRoomProperty: ${t}`),this.updateAllRoomPropertyVisibility()}),n=Wy(t.runtime,"showRoomOrder",t=>{vm.log(`[runtime] showRoomOrder: ${t}`),this.updateAllRoomPropertyVisibility()}),r=Wy(t.runtime,"roomPropertyFoldIds",t=>{vm.log(`[runtime] roomPropertyFoldIds: ${t}`),this.updateAllRoomPropertyVisibility()}),s=Wy(t.runtime,"showRoomName",t=>{vm.log(`[runtime] showRoomName: ${t}`),this.updateAllRoomNameVisibility(t)}),o=Wy(t.runtime,"enableRoomSelection",t=>{vm.log(`[runtime] enableRoomSelection: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),a=Wy(t.runtime,"selectRoomIds",t=>{vm.log(`[runtime] selectRoomIds: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),l=Wy(t.runtime,"roomSelectionMode",t=>{vm.log(`[runtime] roomSelectionMode: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()});this.unsubscribeFns.push(e,i,n,r,s,o,a,l)}drawRoomProperty(t){const e=O_();return this.roomDisplayMap.clear(),t.forEach((t,i)=>{const n=e.mapManager.getRoomById(t.id),r=__spreadProps(__spreadValues({},t),{centerPoint:(null==n?void 0:n.centerPoint)||null,index:i,colorIndex:null==n?void 0:n.colorIndex});this.roomDisplayMap.set(t.id,r)}),this.updateRoomInfoDisplay(),this.updateFloorTypes(),!0}updateRoomInfoDisplay(){if(0===this.roomDisplayMap.size)return;const t=Array.from(this.roomDisplayMap.values()).filter(t=>null!==t.centerPoint);this.clearRoomInfos(),t.forEach(t=>{this.createRoomInfo(t)})}createRoomInfo(t){const e=new _x(t);this.roomInfoContainer.addChild(e),this.roomInfoMap.set(t.id,e)}updateRoomName(t,e){const i=this.roomInfoMap.get(t);i&&i.updateName(e)}updateRoomPosition(t,e){const i=this.roomDisplayMap.get(t);i&&(i.centerPoint=e);const n=this.roomInfoMap.get(t);n&&n.updatePosition(e)}clearRoomInfos(){this.roomInfoMap.forEach(t=>{t.destroy()}),this.roomInfoMap.clear(),this.roomInfoContainer.removeChildren()}getRoomPropertyById(t){return this.roomDisplayMap.get(t)}refresh(){const t=O_();this.roomFloorType.clearFloorTypes(),this.roomDisplayMap.forEach((e,i)=>{const n=t.mapManager.getRoomById(i),r=(null==n?void 0:n.centerPoint)||null;if(e.centerPoint!==r){e.centerPoint=r;const t=this.roomInfoMap.get(i);t&&r&&t.updatePosition(r)}const s=null==n?void 0:n.colorIndex;if(e.colorIndex!==s&&void 0!==s){e.colorIndex=s;const t=this.roomInfoMap.get(i);t&&t.refreshColor()}}),this.updateRoomInfoDisplay(),this.updateFloorTypes()}updateAllRoomPropertyVisibility(){this.roomInfoMap.forEach(t=>{t.updateRoomPropertyVisibility()})}updateAllRoomNameVisibility(t){this.roomInfoMap.forEach(e=>{e.updateRoomNameVisibility(t)})}updateAllRoomSelectionIndicatorVisibility(){this.roomInfoMap.forEach(t=>{t.updateRoomSelectionIndicatorVisibility()})}updateFloorTypes(){return __async(this,null,function*(){const t=O_(),e=t.mapManager.roomFill.getRoomGraphicsMap();e.size>0&&(yield this.roomFloorType.createFloorTypes(e),t.getApp().renderOnceNextFrame())})}destroy(){this.clearRoomInfos(),this.roomInfoContainer.destroy(),this.roomFloorType.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}(null==(e=null==navigator?void 0:navigator.userAgent)?void 0:e.includes("tuya-ark-ide"))||null==(i=null==navigator?void 0:navigator.userAgent)||i.includes("miniProgram");const bx=()=>{var t,e;if(!Ai.any)return!0;const i=navigator.userAgent.toLowerCase();let n=!1;if(/iphone|ipad|ipod/.test(i)){const e=null==(t=i.match(/os (\d+)_/))?void 0:t[1];n=(e?parseInt(e):0)>=12}else if(/android/.test(i)){const t=null==(e=i.match(/android (\d+)/))?void 0:e[1];n=(t?parseInt(t):0)>=10}return n&&(()=>{const t=navigator.deviceMemory;return!t||t>=4})()};class vx extends $n{constructor(t=B_){var e;super(),__publicField(this,"mapState",null),__publicField(this,"components",{}),__publicField(this,"managers",{}),__publicField(this,"config",M_),__publicField(this,"runtime"),__publicField(this,"scaleMin",.5),__publicField(this,"scaleMax",5),__publicField(this,"events",{}),__publicField(this,"instanceKey"),__publicField(this,"containerElement"),__publicField(this,"emitter",{all:e=e||new Map,on:function(t,i){var n=e.get(t);n?n.push(i):e.set(t,[i])},off:function(t,i){var n=e.get(t);n&&(i?n.splice(n.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var n=e.get(t);n&&n.slice().map(function(t){t(i)}),(n=e.get("*"))&&n.slice().map(function(e){e(t,i)})}}),__publicField(this,"tickerState",{renderReasons:new Set,renderTimer:null}),__publicField(this,"pendingAsyncRender",!1),__publicField(this,"isFirstMapDraw",!0),__publicField(this,"onVisibilityChange",()=>{var t;"visible"===document.visibilityState||null==(t=this.components.interaction)||t.clearTouches()}),this.instanceKey=t,I_.registerInstance(t,this),globalThis.__PIXI_APP__=this}initialize(t){return __async(this,null,function*(){return I_.provideAsync(this,()=>__async(this,null,function*(){const e=t,{resizeTo:i,events:n,config:r,runtime:s={}}=e,o=__objRest(e,["resizeTo","events","config","runtime"]);this.config=Lg(this.config,null!=r?r:{}),vm.log("Applying config",this.config,r),this.runtime=S_(Object.assign({},E_,s));const a=this.instanceKey===B_;this.containerElement=i;const l=a?{textureGCMaxIdle:Ai.any?180:3600,textureGCCheckCountMax:Ai.any?100:50,autoStart:!1,eventFeatures:{move:!0,globalMove:!1,click:!0,wheel:!0}}:{textureGCMaxIdle:60,textureGCCheckCountMax:10,autoStart:!1,eventFeatures:{move:!1,globalMove:!1,click:!1,wheel:!1}};yield this.init(__spreadValues(__spreadValues({resizeTo:a?i:void 0,preferWebGLVersion:2,resolution:window.devicePixelRatio||1,antialias:bx(),autoDensity:!0,backgroundColor:this.config.global.backgroundColor},l),o)),this.preloadAssets(),this.scaleMax=this.config.interaction.zoomRange.max,this.scaleMin=this.config.interaction.zoomRange.min,this.events=n,this.initializeViewportContainer(),this.initializeInteraction(),this.initializeAppContainer(),this.managers.mapManager=new Yy,this.managers.heatmapManager=new Jy,this.managers.pathManager=new $y,this.managers.controlsManager=new ax,this.managers.detectedObjectManager=new hx,this.managers.customElementsManager=new px,this.managers.roomsManager=new xx,document.addEventListener("visibilitychange",this.onVisibilityChange)}))})}drawMap(t){return __async(this,null,function*(){return I_.provideAsync(this,()=>__async(this,null,function*(){var e,i,n,r,s,o,a;vm.log("[Map] drawMap",t);const{size:l,resolution:h,origin:c}=t;c[0]===(null==(e=this.mapState)?void 0:e.origin.x)&&c[1]===(null==(i=this.mapState)?void 0:i.origin.y)||(this.managers.pathManager.updatePositionByOrigin(...c),this.managers.controlsManager.updatePositionByOrigin(...c),this.managers.detectedObjectManager.updatePositionByOrigin(...c),this.managers.customElementsManager.updatePositionByOrigin(...c)),this.mapState={id:t.id,status:1===t.status,origin:{x:c[0],y:c[1]},charger:{x:t.charger.coordinate[0],y:t.charger.coordinate[1]},chargerDirection:null!=(n=t.charger.angle)?n:0,resolution:h,width:l[0],height:l[1]},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,null==(s=null==(r=this.events)?void 0:r.onMapFirstDrawed)||s.call(r,this.mapState)),null==(a=null==(o=this.events)?void 0:o.onMapDrawed)||a.call(o,this.mapState),yield this.managers.mapManager.drawMap(t),this.renderOnce()}))})}drawRasterMap(t){return __async(this,null,function*(){return I_.provideAsync(this,()=>__async(this,null,function*(){var e,i,n,r,s,o,a;vm.log("[Map] drawRasterMap",t);const{mapHeader:l,mapData:h}=t,{originX:c,originY:u}=l;c===(null==(e=this.mapState)?void 0:e.origin.x)&&u===(null==(i=this.mapState)?void 0:i.origin.y)||(this.managers.pathManager.updatePositionByOrigin(c,u),this.managers.controlsManager.updatePositionByOrigin(c,u),this.managers.detectedObjectManager.updatePositionByOrigin(c,u),this.managers.customElementsManager.updatePositionByOrigin(c,u)),this.mapState={id:l.id,status:l.mapStable,origin:{x:c,y:u},charger:{x:l.chargeX,y:l.chargeY},chargerDirection:null!=(n=l.chargeDirection)?n:0,resolution:100*l.mapResolution,width:l.mapWidth,height:l.mapHeight,version:l.version},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,null==(s=null==(r=this.events)?void 0:r.onMapFirstDrawed)||s.call(r,this.mapState)),null==(a=null==(o=this.events)?void 0:o.onMapDrawed)||a.call(o,this.mapState),yield this.managers.mapManager.drawRasterMap(h.parsed,this.mapState),this.renderOnce()}))})}drawPath(t){return I_.provide(this,()=>{var e,i,n;vm.log("[Path] drawPath",t),null==(n=null==(e=this.events)?void 0:e.onPathDrawed)||n.call(e,{id:t.pathHeader.pathId,type:t.pathHeader.type,direction:t.pathHeader.direction,count:t.pathHeader.count,initFlag:t.pathHeader.initFlag,robotPosition:null!=(i=t.pathPoints[t.pathPoints.length-1])?i:null}),this.managers.pathManager.draw(t),this.renderOnce()})}drawRoomProperty(t){return __async(this,null,function*(){return I_.provide(this,()=>{var e,i;vm.log("[Room] drawRoomProperty",t),null==(i=null==(e=this.events)?void 0:e.onRoomPropertiesDrawed)||i.call(e,t),this.managers.roomsManager.drawRoomProperty(t),this.renderOnceNextFrame()})})}drawHeatmap({mapData:t,heatmapPoints:e,useGradient:i=!0}){return I_.provide(this,()=>{vm.log("[Heatmap] drawHeatmap",e),this.managers.heatmapManager.draw({mapData:t,heatmapPoints:e,useGradient:i}),this.renderOnce()})}drawForbiddenSweepZones(t){return I_.provide(this,()=>{vm.log("[Controls] drawForbiddenSweepZones",t),this.managers.controlsManager.drawForbiddenSweepZones(t),this.renderOnceNextFrame()})}drawForbiddenMopZones(t){return I_.provide(this,()=>{vm.log("[Controls] drawForbiddenMopZones",t),this.managers.controlsManager.drawForbiddenMopZones(t),this.renderOnceNextFrame()})}drawCleanZones(t){return I_.provide(this,()=>{vm.log("[Controls] drawCleanZones",t),this.managers.controlsManager.drawCleanZones(t),this.renderOnceNextFrame()})}drawVirtualWalls(t){return I_.provide(this,()=>{vm.log("[Controls] drawVirtualWalls",t),this.managers.controlsManager.drawVirtualWalls(t),this.renderOnceNextFrame()})}drawSpots(t){return I_.provide(this,()=>{vm.log("[Controls] drawSpots",t),this.managers.controlsManager.drawSpots(t),this.renderOnceNextFrame()})}drawDetectedObjects(t){return __async(this,null,function*(){return I_.provideAsync(this,()=>__async(this,null,function*(){vm.log("[DetectedObject] drawDetectedObjects",t),yield this.managers.detectedObjectManager.drawDetectedObjects(t),this.renderOnceNextFrame()}))})}drawCustomElements(t){return __async(this,null,function*(){return I_.provideAsync(this,()=>__async(this,null,function*(){vm.log("[CustomElements] drawCustomElements",t),yield 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()}getEffectiveDividerPoints(){return this.managers.controlsManager.getEffectiveDividerPoints()}getDividerEndPoints(){return this.managers.controlsManager.getDividerEndPoints()}resetPanZoom(){this.components.interaction.setPanZoom()}fitMapToView(t,e=!1){return I_.provide(this,()=>{if(!t||t.minX===t.maxX||t.minY===t.maxY)return void vm.warn("地图边界无效,无法自动适配视图");const i=this.config.map.autoPaddingPercent||.1,n=this.getViewportBounds(),r=t.maxX-t.minX,s=t.maxY-t.minY,o=n.width,a=n.height,l=o*(1-2*i)/r,h=a*(1-2*i)/s,c=Math.min(l,h),u=Math.max(this.config.interaction.fitMinScale,this.scaleMin),d=Math.min(this.config.interaction.fitMaxScale,this.scaleMax),p=Math.max(u,Math.min(d,c)),f=o/2-(t.minX+r/2)*p,g=a/2-(t.minY+s/2)*p;this.components.interaction.setPanZoom({targetPosition:{x:f,y:g},targetScale:{x:p,y:p},setCenter:!0,setScale:!0},e)})}getViewportBounds(){var t;return(null==(t=this.components.viewportContainer)?void 0:t.getViewportBounds())||{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}updateRuntime(t){Object.assign(this.runtime,t),this.renderOnceNextFrame()}metersToPixels(t){var e;if(!(null==(e=this.mapState)?void 0:e.resolution))return vm.warn("Map resolution not available, using default resolution (5cm/pixel)"),20*t;return t*(1/(this.mapState.resolution/100))}pixelsToMeters(t){var e;if(!(null==(e=this.mapState)?void 0:e.resolution))return vm.warn("Map resolution not available, using default resolution (5cm/pixel)"),.05*t;return t*(this.mapState.resolution/100)}toFixedSize(t,e){return t/(null!=e?e:this.components.appContainer.scale.x)}fromFixedSize(t,e){return t*(null!=e?e:this.components.appContainer.scale.x)}getViewportCenterPoint(){if(!this.mapState)return vm.warn("Map state not available, cannot calculate center point"),null;const t=this.getViewportBounds(),e=t.x+t.width/2,i=t.y+t.height/2,n=this.components.appContainer,r=n.scale.x,s=(e-n.x)/r,o=(i-n.y)/r;return{x:s-this.mapState.origin.x,y:o-this.mapState.origin.y}}getMapCenterPoint(){if(!this.mapState)return vm.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 vm.warn("Invalid map bounds, cannot calculate map center point"),null;const e=(t.minX+t.maxX)/2,i=(t.minY+t.maxY)/2;return{x:e-this.mapState.origin.x,y:i-this.mapState.origin.y}}getWallPointsByViewportCenter(t){const{width:e=this.config.controls.virtualWall.minWidth,direction:i="horizontal",offsetX:n=0,offsetY:r=0}=t||{},s=this.getViewportCenterPoint()||{x:0,y:0},o=this.metersToPixels(e);return t_(s.x,s.y,o,i).map(t=>({x:t.x+n,y:t.y+r}))}getForbiddenSweepZonePointsByViewportCenter(t){const e=this.config.controls.forbiddenSweepZone,{size:i=e.minSize,offsetX:n=0,offsetY:r=0}=t||{};return this.generateZonePoints(i,n,r)}getForbiddenMopZonePointsByViewportCenter(t){const e=this.config.controls.forbiddenMopZone,{size:i=e.minSize,offsetX:n=0,offsetY:r=0}=t||{};return this.generateZonePoints(i,n,r)}getCleanZonePointsByViewportCenter(t){const e=this.config.controls.cleanZone,{size:i=e.minSize,offsetX:n=0,offsetY:r=0}=t||{};return this.generateZonePoints(i,n,r)}getSpotPointByViewportCenter(t){const{offsetX:e=0,offsetY:i=0}=t||{},n=this.getViewportCenterPoint()||{x:0,y:0};return{x:n.x+e,y:n.y+i}}areRoomsAdjacent(t){const e=this.config.map.adjacencyThreshold;return I_.provide(this,()=>{var i;if(!t||0===t.length)return vm.warn("[Room] No room IDs provided"),!1;if(1===t.length)return!0;const n=Array.from(new Set(t));if(1===n.length)return!0;return void 0!==(null==(i=this.mapState)?void 0:i.version)?this.areRasterRoomsAdjacentInternal(n,e):this.areStructuredRoomsAdjacentInternal(n,e)})}areStructuredRoomsAdjacentInternal(t,e){const i=[];for(const r of t){const t=this.managers.mapManager.getRoomById(r);if(!t)return vm.warn(`[Room] Room ${r} not found in map`),!1;if(!t.outlinePoints||0===t.outlinePoints.length)return vm.warn(`[Room] Room ${r} has no outline points`),!1;i.push({id:r,points:t.outlinePoints})}const n=[];for(let r=0;r<i.length;r++)for(let t=r+1;t<i.length;t++){const s=i[r],o=i[t];e_(s.points,o.points,e)&&n.push([r,t])}return n_(i.length,n)}areRasterRoomsAdjacentInternal(t,e){if(!this.mapState)return vm.warn("[Room] Map state not available"),!1;const i=this.mapState.width,n=[];for(const s of t){const t=this.managers.mapManager.getRasterRoomPixels(s);if(!t)return vm.warn(`[Room] Room ${s} pixel data not found in raster map`),!1;n.push({id:s,pixels:t})}const r=[];for(let s=0;s<n.length;s++)for(let t=s+1;t<n.length;t++){const o=n[s],a=n[t];i_(o.pixels,a.pixels,i,e)&&r.push([s,t])}return n_(n.length,r)}snapshot(){return __async(this,null,function*(){this.render(),yield new Promise(t=>setTimeout(t,0));const{snapshot:t}=this.config;return yield this.renderer.extract.base64({target:this.components.appContainer,format:t.format,quality:t.quality,resolution:t.resolution,antialias:t.antialias})})}snapshotByData(t){return __async(this,arguments,function*({map:t,path:e,roomProperties:i,customElements:n,forbiddenSweepZones:o,forbiddenMopZones:a,virtualWalls:l,detectedObjects:h},c={}){const u=`SNAPSHOT_${((t=21)=>{let e="",i=0|t;for(;i--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return e})()}`;vm.log(`[MapApplication] ${u} snapshot start`);const d=new vx(u);try{if(yield d.initialize({config:this.config,runtime:c}),!t)throw new Error("Map data is required");if(t.startsWith("7b22")){const{decodeMapStructured:e}=yield s(()=>__async(this,null,function*(){const{decodeMapStructured:t}=yield Promise.resolve().then(()=>bm);return{decodeMapStructured:t}}),0,r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("assets/index-DFAEtWgf.js",document.baseURI).href),i=e(t);yield d.drawMap(i)}else{const{decodeMap:e}=yield s(()=>__async(this,null,function*(){const{decodeMap:t}=yield Promise.resolve().then(()=>bm);return{decodeMap:t}}),0,r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("assets/index-DFAEtWgf.js",document.baseURI).href),i=e(t);if(!i)throw new Error("Failed to decode raster map data");yield d.drawRasterMap(i)}if(e){const{decodePath:t}=yield s(()=>__async(this,null,function*(){const{decodePath:t}=yield Promise.resolve().then(()=>bm);return{decodePath:t}}),0,r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("assets/index-DFAEtWgf.js",document.baseURI).href),i=t(e);d.drawPath(i)}i&&i.length>0&&d.drawRoomProperty(i),o&&o.length>0&&d.drawForbiddenSweepZones(o),a&&a.length>0&&d.drawForbiddenMopZones(a),l&&l.length>0&&d.drawVirtualWalls(l),h&&h.length>0&&(yield d.drawDetectedObjects(h)),n&&n.length>0&&(yield d.drawCustomElements(n));const p=yield d.snapshot();return vm.log(`[MapApplication] ${u} snapshot completed successfully`),p}catch(p){throw vm.error(`[MapApplication] ${u} snapshot other map failed:`,p),p}finally{vm.log(`[MapApplication] ${u} destroy`),d.destroy()}})}renderOnce(){vm.log("[Pixi] renderOnce"),this.render()}renderOnceNextFrame(){this.pendingAsyncRender||(this.pendingAsyncRender=!0,requestAnimationFrame(()=>{vm.log("[Pixi] renderOnceNextFrame"),this.render(),this.pendingAsyncRender=!1}))}requestRender(t,e=!1){e?(this.tickerState.renderReasons.add(t),this.ticker.started||(vm.debug(`🎬 [Ticker] START: ${t}`),this.ticker.start())):this.renderOnceNextFrame()}stopRender(t){this.tickerState.renderReasons.delete(t),0===this.tickerState.renderReasons.size&&this.scheduleStopRender("final",100)}destroy(){I_.unregisterInstance(this.instanceKey),this.tickerState.renderTimer&&clearTimeout(this.tickerState.renderTimer),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.detectedObjectManager.destroy(),this.managers.customElementsManager.destroy(),this.managers.roomsManager.destroy(),this.components.interaction.destroy(),this.components.viewportContainer.destroy(),this.components.appContainer.destroy(),super.destroy()}initializeViewportContainer(){this.components.viewportContainer=new U_(this.config,this.containerElement),this.stage.addChild(this.components.viewportContainer)}initializeAppContainer(){this.components.appContainer=new J_,this.components.interaction.addChild(this.components.appContainer)}initializeInteraction(){this.components.interaction=new r_,this.components.viewportContainer.addChild(this.components.interaction)}scheduleStopRender(t,e){this.tickerState.renderTimer&&clearTimeout(this.tickerState.renderTimer),this.tickerState.renderTimer=setTimeout(()=>{this.tickerState.renderReasons.delete(t),0===this.tickerState.renderReasons.size&&(vm.debug("⏸️ [Ticker] STOP"),this.ticker.stop())},e)}generateZonePoints(t,e,i){const n=this.getViewportCenterPoint()||{x:0,y:0},r=this.metersToPixels(t)/2,s=n.x+e,o=n.y+i;return[{x:s-r,y:o-r},{x:s+r,y:o-r},{x:s+r,y:o+r},{x:s-r,y:o+r}]}preloadAssets(){const t=this.config.robot.icon.src,e=this.config.chargingStation.icon.src,i=[];Ya.add({alias:"robot",src:t}),i.push("robot"),Ya.add({alias:"chargingStation",src:e}),i.push("chargingStation"),Ya.add({alias:"deleteIcon",src:this.config.controls.deleteIconSrc}),i.push("deleteIcon"),Ya.add({alias:"rotateIcon",src:this.config.controls.rotateIconSrc}),i.push("rotateIcon"),Ya.add({alias:"scaleIcon",src:this.config.controls.scaleIconSrc}),i.push("scaleIcon"),Ya.add({alias:"moveIcon",src:this.config.controls.moveIconSrc}),i.push("moveIcon"),Ya.add({alias:"checkmark",src:this.config.room.selectionIndicator.iconSrc}),i.push("checkmark"),Ya.add({alias:"spotIcon",src:this.config.controls.spot.iconSrc}),i.push("spotIcon"),this.config.room.property.cleanMode.assets.forEach((t,e)=>{const n=`cleanMode_${e}`;Ya.add({alias:n,src:t}),i.push(n)}),this.config.room.property.suction.assets.forEach((t,e)=>{const n=`fan_${e}`;Ya.add({alias:n,src:t}),i.push(n)}),this.config.room.property.cistern.assets.forEach((t,e)=>{const n=`water_${e}`;Ya.add({alias:n,src:t}),i.push(n)}),this.config.room.property.cleanTimes.assets.forEach((t,e)=>{const n=`cleanTimes${e+1}`;Ya.add({alias:n,src:t}),i.push(n)}),this.config.room.floorType.assets.forEach((t,e)=>{if(!t)return;const n=`floorType${e}`;Ya.add({alias:n,src:t}),i.push(n)}),Ya.backgroundLoad(i)}}var wx,Sx,Ax,Tx={exports:{}};function Cx(){if(Sx)return wx;function t(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,n)}return i}function e(e){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?t(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e,i){return Object.defineProperty(t,"prototype",{writable:!1}),t}function r(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function s(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return o(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}Sx=1;var a="RNWV:sync",l="success",h="fail",c=0,u=n(function t(){var e=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.promise=new Promise(function(t,i){e.resolve=t,e.reject=i})});function d(t){return"".concat(t.command,"(").concat(t.id,")")}var p=null,f="undefined"!=typeof window,g=function(t){var e,i=[],n=(e={send:[],receive:[],ready:[]},{addEventListener:function(t,i){if(t in e){var n=e[t];n.indexOf(i)<0&&n.push(i)}},removeEventListener:function(t,i){if(t in e){var n=e[t],r=n.indexOf(i);r>=0&&n.splice(r,1)}},emitEvent:function(t,i){t in e&&e[t].forEach(function(t){return t(i)})}}),r={},o={},p={};function f(t){return function(){for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return s=function(t,e){return{id:c++,command:t,data:e,reply:!1,status:l}}(t,i),o=new u,r[d(s)]=o,m(s),o.promise;var s,o}}function g(t,e){return o[t]=function(t){return e.apply(void 0,s(t))},!i&&b(),{define:g,bind:f}}function m(e){!(e.command===a)&&i?i.push(e):t(e),n.emitEvent("send",e)}function _(t,e,i){t.reply=!0,t.data=e,t.status=i,m(t)}var y=f(a);function x(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(t){return!p[t]}).map(function(t){p[t]=f(t)}),function(){if(i){var t=i;i=null,t.forEach(function(t){m(t)}),n.emitEvent("ready")}}(),Object.keys(o)}function b(){y(Object.keys(o)).then(x)}return g(a,x),{bind:f,define:g,listener:function(t){var e=t.detail&&JSON.parse(t.detail.data[0])||t;if(e.reply){var i=d(e);r[i]&&(e.status===h?r[i].reject(e.data):r[i].resolve(e.data))}else if(o[e.command]){var s=o[e.command](e.data);s&&s.then?s.then(function(t){_(e,t,l)}).catch(function(t){_(e,t,h)}):_(e,s,l)}else _(e,"function ".concat(e.command," is not defined"),h);n.emitEvent("receive",e)},ready:b,fn:p,addEventListener:n.addEventListener,removeEventListener:n.removeEventListener,isConnect:function(){return!i}}}(function(t){var e="string"==typeof t?t:JSON.stringify(t);f&&p&&p(e)}),m=g.bind,_=g.define,y=g.listener,x=g.ready,b=g.fn,v=g.addEventListener,w=g.removeEventListener,S=g.isConnect,A=function(t){var e;if("object"===i(t))e=t;else if("string"==typeof t)try{e=JSON.parse(t)}catch(n){}e&&(e.command||e.reply)&&y(e)},T=function(t){var e=new MessageEvent("message",{data:t});A(e.data)};if(f){var C=window.originalPostMessage;if(C)p=function(){var t;window&&"function"==typeof window.postMessage&&(t=window).postMessage.apply(t,arguments)},x();else{var P={get:function(){return C},set:function(t){(C=t)&&(p=function(){var t;window&&"function"==typeof window.postMessage&&(t=window).postMessage.apply(t,arguments)},setTimeout(x,50))}};Object.defineProperty(window,"originalPostMessage",P)}var M=window.ReactNativeWebView;if(M)p=function(){var t;window&&window.ReactNativeWebView&&"function"==typeof window.ReactNativeWebView.postMessage?(t=window.ReactNativeWebView).postMessage.apply(t,arguments):console.error("ReactNativeWebView has been dispose")},x();else{var E={get:function(){return M},set:function(t){(M=t)&&(p=function(){var t;window&&window.ReactNativeWebView&&"function"==typeof window.ReactNativeWebView.postMessage?(t=window.ReactNativeWebView).postMessage.apply(t,arguments):console.error("ReactNativeWebView has been dispose")},setTimeout(x,50))}};Object.defineProperty(window,"ReactNativeWebView",E)}var R=window.gzlJSBridge;if(R)p=function(){try{if(window&&window.gzlJSBridge&&"function"==typeof window.gzlJSBridge.webviewMessage){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];var r={data:e({},i)};window.gzlJSBridge.webviewMessage("postMessage",JSON.stringify(r))}else console.error("gzlJSBridge has been dispose")}catch(s){console.error("gzlJSBridge postMessage error ==>",s)}window.gzlJSBridge.receiveMessageHandler=function(t){T(t.data)}},x();else{var F={get:function(){return R},set:function(t){(R=t)&&(p=function(){try{if(window&&window.gzlJSBridge&&"function"==typeof window.gzlJSBridge.webviewMessage){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];var r={data:e({},i)};window.gzlJSBridge.webviewMessage("postMessage",JSON.stringify(r))}else console.error("gzlJSBridge has been dispose")}catch(s){console.error("gzlJSBridge postMessage error ==>",s)}},window.gzlJSBridge.receiveMessageHandler=function(t){T(t.data)},setTimeout(x,50))}};Object.defineProperty(window,"gzlJSBridge",F)}C||M||R||(p=function(){if(window&&"function"==typeof window.postMessage){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];var r={data:e({},i)};window.parent.postMessage(r,"*")}else console.error("browser mini program has been dispose")},x()),window.document.addEventListener("message",function(t){return C&&A(t.data)}),window.addEventListener("message",function(t){return M&&A(t.data)}),window.document.addEventListener("message",function(t){return M&&A(t.data)}),window.addEventListener("message",function(t){return!M&&T(t.data)})}return wx={bind:m,define:_,fn:b,addEventListener:v,removeEventListener:w,isConnect:S}}const Px=p(function(){if(Ax)return Tx.exports;Ax=1;var t=Cx();return Tx.exports=t,Tx.exports.default=t,Tx.exports}());document.addEventListener("DOMContentLoaded",()=>__async(null,null,function*(){let t=null;document.addEventListener("beforeunload",()=>{null==t||t.destroy()});try{Px.bind("onDocumentReady")();const e=e=>__async(null,[e],function*({options:e,runtime:i}){t=new vx;const n=__objRest(e,[]),r=document.getElementById("container");var s,o;yield t.initialize({resizeTo:null!=r?r:window,events:F_.reduce((t,e)=>((t=null!=t?t:{})[e]=function(t,e){return(...i)=>(vm.log(`[Event] ${t}`,...i),e(...i))}(e,Px.bind(e)),t),{}),config:n,runtime:i}),r?r.appendChild(t.canvas):document.body.appendChild(t.canvas),Px.define("onUpdateRuntime",e=>{null==t||t.updateRuntime(e)}),Px.define("onReceiveMap",e=>{if(e)if(e.startsWith("7b22"))null==t||t.drawMap(fm(e));else{const i=gm(e);i?null==t||t.drawRasterMap(i):vm.error("Failed to decode raster map data")}}),Px.define("onReceivePath",e=>{e&&(null==t||t.drawPath(xm(e)))}),Px.define("onReceiveRoomProperties",e=>{e&&(null==t||t.drawRoomProperty(e))}),Px.define("onReceiveForbiddenSweepZones",e=>{e&&(null==t||t.drawForbiddenSweepZones(e))}),Px.define("onReceiveForbiddenMopZones",e=>{e&&(null==t||t.drawForbiddenMopZones(e))}),Px.define("onReceiveCleanZones",e=>{e&&(null==t||t.drawCleanZones(e))}),Px.define("onReceiveVirtualWalls",e=>{e&&(null==t||t.drawVirtualWalls(e))}),Px.define("onReceiveSpots",e=>{e&&(null==t||t.drawSpots(e))}),Px.define("onReceiveDetectedObjects",e=>{e&&(null==t||t.drawDetectedObjects(e))}),Px.define("onReceiveCustomElements",e=>{e&&(null==t||t.drawCustomElements(e))}),s=t,o=Px,R_.forEach(t=>{"function"==typeof s[t]?o.define(t,s[t].bind(s)):vm.warn(`Method ${t} not found on target object`)}),yield Px.bind("onInitialized")()});document.body?Px.define("initApp",e):vm.error("document.body is null")}catch(e){console.error(e)}})),h.add(Ci),h.mixin(xe,{accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1}),h.add(Qn),h.add(Jn),h.add(sl),h.mixin(xe,ol),h.add(qa),h.add(Ku),h.add(Js),h.add(ed),h.add(cd),h.add(ud),h.add(Wd),h.add(Hd),h.add(Bd),h.add(Nd),h.add(Od),h.add(Sd),h.add(gd),h.add(cl),h.add(al);const Mx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Ex=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));Symbol.toStringTag}();
|
|
1
|
+
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__reflectGet=Reflect.get,__pow=Math.pow,__defNormalProp=(t,e,i)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,__spreadValues=(t,e)=>{for(var i in e||(e={}))__hasOwnProp.call(e,i)&&__defNormalProp(t,i,e[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(e))__propIsEnum.call(e,i)&&__defNormalProp(t,i,e[i]);return t},__spreadProps=(t,e)=>__defProps(t,__getOwnPropDescs(e)),__objRest=(t,e)=>{var i={};for(var n in t)__hasOwnProp.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))e.indexOf(n)<0&&__propIsEnum.call(t,n)&&(i[n]=t[n]);return i},__publicField=(t,e,i)=>__defNormalProp(t,"symbol"!=typeof e?e+"":e,i),__superGet=(t,e,i)=>__reflectGet(__getProtoOf(t),i,e),__async=(t,e,i)=>new Promise((n,r)=>{var s=t=>{try{a(i.next(t))}catch(e){r(e)}},o=t=>{try{a(i.throw(t))}catch(e){r(e)}},a=t=>t.done?n(t.value):Promise.resolve(t.value).then(s,o);a((i=i.apply(t,e)).next())});!function(){"use strict";var t,e,i,n=document.createElement("style");n.textContent="/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}:root{--debug-tools-button-height: 20px;--debug-tools-button-width: 82px;--debug-tools-button-font-size: 7px}.debug-tools{position:fixed;bottom:8px;left:8px;display:flex;flex-direction:column-reverse;gap:4px;z-index:999;pointer-events:none}.debug-tools .debug-toggle{width:var(--debug-tools-button-width);height:var(--debug-tools-button-height);background:#4a90e2;border:1px solid #357abd;border-radius:0;font-family:Arial,sans-serif;font-size:var(--debug-tools-button-font-size);color:#fff;cursor:pointer;pointer-events:auto;user-select:none;-webkit-user-select:none;display:flex;align-items:center;justify-content:center;box-sizing:border-box;font-weight:700}.debug-tools .debug-toggle:hover{background:#357abd}.debug-tools .debug-toggle:active{background:#2968a3}.debug-tools .debug-toggle.expanded{background:#e74c3c;border-color:#c0392b}.debug-tools .debug-toggle.expanded:hover{background:#c0392b}.debug-tools .debug-buttons-container{flex-direction:column-reverse;gap:4px}.debug-tools .debug-button{height:var(--debug-tools-button-height);background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:0;font-size:var(--debug-tools-button-font-size);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,PingFang SC,Hiragino Sans GB,Microsoft YaHei,sans-serif;color:#000000e6;cursor:pointer;pointer-events:auto;user-select:none;-webkit-user-select:none;display:flex;align-items:center;justify-content:center;box-sizing:border-box}*{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}body{overflow:hidden}#container{position:fixed;top:0;left:0;height:100%;width:100%}canvas{touch-action:none;-webkit-touch-callout:none;user-select:none;-webkit-user-select:none}\n/*$vite$:1*/",document.head.appendChild(n);var r="undefined"!=typeof document?document.currentScript:null;const s=function(t,e,i){let n=Promise.resolve();function r(t){const e=new Event("vite:preloadError",{cancelable:!0});if(e.payload=t,window.dispatchEvent(e),!e.defaultPrevented)throw t}return n.then(e=>{for(const t of e||[])"rejected"===t.status&&r(t.reason);return t().catch(r)})};var o=(t=>(t.Application="application",t.WebGLPipes="webgl-pipes",t.WebGLPipesAdaptor="webgl-pipes-adaptor",t.WebGLSystem="webgl-system",t.WebGPUPipes="webgpu-pipes",t.WebGPUPipesAdaptor="webgpu-pipes-adaptor",t.WebGPUSystem="webgpu-system",t.CanvasSystem="canvas-system",t.CanvasPipesAdaptor="canvas-pipes-adaptor",t.CanvasPipes="canvas-pipes",t.Asset="asset",t.LoadParser="load-parser",t.ResolveParser="resolve-parser",t.CacheParser="cache-parser",t.DetectionParser="detection-parser",t.MaskEffect="mask-effect",t.BlendMode="blend-mode",t.TextureSource="texture-source",t.Environment="environment",t.ShapeBuilder="shape-builder",t.Batcher="batcher",t))(o||{});const a=t=>{if("function"==typeof t||"object"==typeof t&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");const e="object"!=typeof t.extension?{type:t.extension}:t.extension;t=__spreadProps(__spreadValues({},e),{ref:t})}if("object"!=typeof t)throw new Error("Invalid extension type");return"string"==typeof(t=__spreadValues({},t)).type&&(t.type=[t.type]),t},l=(t,e)=>{var i;return null!=(i=a(t).priority)?i:e},h={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(a).forEach(t=>{t.type.forEach(e=>{var i,n;return null==(n=(i=this._removeHandlers)[e])?void 0:n.call(i,t)})}),this},add(...t){return t.map(a).forEach(t=>{t.type.forEach(e=>{var i,n;const r=this._addHandlers,s=this._queue;r[e]?null==(n=r[e])||n.call(r,t):(s[e]=s[e]||[],null==(i=s[e])||i.push(t))})}),this},handle(t,e,i){var n;const r=this._addHandlers,s=this._removeHandlers;if(r[t]||s[t])throw new Error(`Extension type ${t} already has a handler`);r[t]=e,s[t]=i;const o=this._queue;return o[t]&&(null==(n=o[t])||n.forEach(t=>e(t)),delete o[t]),this},handleByMap(t,e){return this.handle(t,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByNamedList(t,e,i=-1){return this.handle(t,t=>{e.findIndex(e=>e.name===t.name)>=0||(e.push({name:t.name,value:t.ref}),e.sort((t,e)=>l(e.value,i)-l(t.value,i)))},t=>{const i=e.findIndex(e=>e.name===t.name);-1!==i&&e.splice(i,1)})},handleByList(t,e,i=-1){return this.handle(t,t=>{e.includes(t.ref)||(e.push(t.ref),e.sort((t,e)=>l(e,i)-l(t,i)))},t=>{const i=e.indexOf(t.ref);-1!==i&&e.splice(i,1)})},mixin(t,...e){for(const i of e)Object.defineProperties(t.prototype,Object.getOwnPropertyDescriptors(i))}},c={extension:{type:o.Environment,name:"browser",priority:-1},test:()=>!0,load:()=>__async(null,null,function*(){yield s(()=>Promise.resolve().then(()=>Ex),0,r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("assets/index-CMaxpPPD.js",document.baseURI).href)})},u={extension:{type:o.Environment,name:"webworker",priority:0},test:()=>"undefined"!=typeof self&&void 0!==self.WorkerGlobalScope,load:()=>__async(null,null,function*(){yield s(()=>Promise.resolve().then(()=>Rx),0,r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("assets/index-CMaxpPPD.js",document.baseURI).href)})};class d{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new d(null!=t?t:this._observer,this._x,this._y)}set(t=0,e=t){return this._x===t&&this._y===e||(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return this._x===t.x&&this._y===t.y||(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var f,g={exports:{}};var m=(f||(f=1,function(t){var e=Object.prototype.hasOwnProperty,i="~";function n(){}function r(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function s(t,e,n,s,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new r(n,s||t,o),l=i?i+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],a]:t._events[l].push(a):(t._events[l]=a,t._eventsCount++),t}function o(t,e){0===--t._eventsCount?t._events=new n:delete t._events[e]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),a.prototype.eventNames=function(){var t,n,r=[];if(0===this._eventsCount)return r;for(n in t=this._events)e.call(t,n)&&r.push(i?n.slice(1):n);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},a.prototype.listeners=function(t){var e=i?i+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,s=n.length,o=new Array(s);r<s;r++)o[r]=n[r].fn;return o},a.prototype.listenerCount=function(t){var e=i?i+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,r,s,o){var a=i?i+t:t;if(!this._events[a])return!1;var l,h,c=this._events[a],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,n),!0;case 4:return c.fn.call(c.context,e,n,r),!0;case 5:return c.fn.call(c.context,e,n,r,s),!0;case 6:return c.fn.call(c.context,e,n,r,s,o),!0}for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];c.fn.apply(c.context,l)}else{var d,p=c.length;for(h=0;h<p;h++)switch(c[h].once&&this.removeListener(t,c[h].fn,void 0,!0),u){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,e);break;case 3:c[h].fn.call(c[h].context,e,n);break;case 4:c[h].fn.call(c[h].context,e,n,r);break;default:if(!l)for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c[h].fn.apply(c[h].context,l)}}return!0},a.prototype.on=function(t,e,i){return s(this,t,e,i,!1)},a.prototype.once=function(t,e,i){return s(this,t,e,i,!0)},a.prototype.removeListener=function(t,e,n,r){var s=i?i+t:t;if(!this._events[s])return this;if(!e)return o(this,s),this;var a=this._events[s];if(a.fn)a.fn!==e||r&&!a.once||n&&a.context!==n||o(this,s);else{for(var l=0,h=[],c=a.length;l<c;l++)(a[l].fn!==e||r&&!a[l].once||n&&a[l].context!==n)&&h.push(a[l]);h.length?this._events[s]=1===h.length?h[0]:h:o(this,s)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&o(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=i,a.EventEmitter=a,t.exports=a}(g)),g.exports);const _=p(m),y=2*Math.PI,x=180/Math.PI,b=Math.PI/180;class v{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new v(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return w.x=0,w.y=0,w}}const w=new v;class S{constructor(t=1,e=0,i=0,n=1,r=0,s=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,n,r,s){return this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new v;const i=t.x,n=t.y;return e.x=this.a*i+this.c*n+this.tx,e.y=this.b*i+this.d*n+this.ty,e}applyInverse(t,e){e=e||new v;const i=this.a,n=this.b,r=this.c,s=this.d,o=this.tx,a=this.ty,l=1/(i*s+r*-n),h=t.x,c=t.y;return e.x=s*l*h+-r*l*c+(a*r-o*s)*l,e.y=i*l*c+-n*l*h+(-a*i+o*n)*l,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.a,r=this.c,s=this.tx;return this.a=n*e-this.b*i,this.b=n*i+this.b*e,this.c=r*e-this.d*i,this.d=r*i+this.d*e,this.tx=s*e-this.ty*i,this.ty=s*i+this.ty*e,this}append(t){const e=this.a,i=this.b,n=this.c,r=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*i+t.b*r,this.c=t.c*e+t.d*n,this.d=t.c*i+t.d*r,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*i+t.ty*r+this.ty,this}appendFrom(t,e){const i=t.a,n=t.b,r=t.c,s=t.d,o=t.tx,a=t.ty,l=e.a,h=e.b,c=e.c,u=e.d;return this.a=i*l+n*c,this.b=i*h+n*u,this.c=r*l+s*c,this.d=r*h+s*u,this.tx=o*l+a*c+e.tx,this.ty=o*h+a*u+e.ty,this}setTransform(t,e,i,n,r,s,o,a,l){return this.a=Math.cos(o+l)*r,this.b=Math.sin(o+l)*r,this.c=-Math.sin(o-a)*s,this.d=Math.cos(o-a)*s,this.tx=t-(i*this.a+n*this.c),this.ty=e-(i*this.b+n*this.d),this}prepend(t){const e=this.tx;if(1!==t.a||0!==t.b||0!==t.c||1!==t.d){const e=this.a,i=this.c;this.a=e*t.a+this.b*t.c,this.b=e*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,n=this.c,r=this.d,s=t.pivot,o=-Math.atan2(-n,r),a=Math.atan2(i,e),l=Math.abs(o+a);return l<1e-5||Math.abs(y-l)<1e-5?(t.rotation=a,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=a),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(n*n+r*r),t.position.x=this.tx+(s.x*e+s.y*n),t.position.y=this.ty+(s.x*i+s.y*r),t}invert(){const t=this.a,e=this.b,i=this.c,n=this.d,r=this.tx,s=t*n-e*i;return this.a=n/s,this.b=-e/s,this.c=-i/s,this.d=t/s,this.tx=(i*this.ty-n*r)/s,this.ty=-(t*this.ty-e*r)/s,this}isIdentity(){return 1===this.a&&0===this.b&&0===this.c&&1===this.d&&0===this.tx&&0===this.ty}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new S;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}equals(t){return t.a===this.a&&t.b===this.b&&t.c===this.c&&t.d===this.d&&t.tx===this.tx&&t.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return T.identity()}static get shared(){return A.identity()}}const A=new S,T=new S,C=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],P=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],M=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],E=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],R=[],B=[],F=Math.sign;!function(){for(let t=0;t<16;t++){const e=[];R.push(e);for(let i=0;i<16;i++){const n=F(C[t]*C[i]+M[t]*P[i]),r=F(P[t]*C[i]+E[t]*P[i]),s=F(C[t]*M[i]+M[t]*E[i]),o=F(P[t]*M[i]+E[t]*E[i]);for(let t=0;t<16;t++)if(C[t]===n&&P[t]===r&&M[t]===s&&E[t]===o){e.push(t);break}}}for(let t=0;t<16;t++){const e=new S;e.set(C[t],P[t],M[t],E[t],0,0),B.push(e)}}();const k={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:t=>C[t],uY:t=>P[t],vX:t=>M[t],vY:t=>E[t],inv:t=>8&t?15&t:7&-t,add:(t,e)=>R[t][e],sub:(t,e)=>R[t][k.inv(e)],rotate180:t=>4^t,isVertical:t=>2==(3&t),byDirection:(t,e)=>2*Math.abs(t)<=Math.abs(e)?e>=0?k.S:k.N:2*Math.abs(e)<=Math.abs(t)?t>0?k.E:k.W:e>0?t>0?k.SE:k.SW:t>0?k.NE:k.NW,matrixAppendRotationInv:(t,e,i=0,n=0)=>{const r=B[k.inv(e)];r.tx=i,r.ty=n,t.append(r)},transformRectCoords:(t,e,i,n)=>{const{x:r,y:s,width:o,height:a}=t,{x:l,y:h,width:c,height:u}=e;return i===k.E?(n.set(r+l,s+h,o,a),n):i===k.S?n.set(c-s-a+l,r+h,a,o):i===k.W?n.set(c-r-o+l,u-s-a+h,o,a):i===k.N?n.set(s+l,u-r-o+h,a,o):n.set(r+l,s+h,o,a)}},I=[new v,new v,new v,new v];class D{constructor(t=0,e=0,i=0,n=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(n)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new D(0,0,0,0)}clone(){return new D(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return!(this.width<=0||this.height<=0)&&(t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height)}strokeContains(t,e,i,n=.5){const{width:r,height:s}=this;if(r<=0||s<=0)return!1;const o=this.x,a=this.y,l=i*(1-n),h=i-l;return t>=o-l&&t<=o+r+l&&e>=a-l&&e<=a+s+l&&!(t>o+h&&t<o+r-h&&e>a+h&&e<a+s-h)}intersects(t,e){if(!e){const e=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=e)return!1;const i=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>i}const i=this.left,n=this.right,r=this.top,s=this.bottom;if(n<=i||s<=r)return!1;const o=I[0].set(t.left,t.top),a=I[1].set(t.left,t.bottom),l=I[2].set(t.right,t.top),h=I[3].set(t.right,t.bottom);if(l.x<=o.x||a.y<=o.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(0===c)return!1;if(e.apply(o,o),e.apply(a,a),e.apply(l,l),e.apply(h,h),Math.max(o.x,a.x,l.x,h.x)<=i||Math.min(o.x,a.x,l.x,h.x)>=n||Math.max(o.y,a.y,l.y,h.y)<=r||Math.min(o.y,a.y,l.y,h.y)>=s)return!1;const u=c*(a.y-o.y),d=c*(o.x-a.x),p=u*i+d*r,f=u*n+d*r,g=u*i+d*s,m=u*n+d*s;if(Math.max(p,f,g,m)<=u*o.x+d*o.y||Math.min(p,f,g,m)>=u*h.x+d*h.y)return!1;const _=c*(o.y-l.y),y=c*(l.x-o.x),x=_*i+y*r,b=_*n+y*r,v=_*i+y*s,w=_*n+y*s;return!(Math.max(x,b,v,w)<=_*o.x+y*o.y||Math.min(x,b,v,w)>=_*h.x+y*h.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),r=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=n,this.height=Math.max(r-n,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,n=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=n-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),r=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=n,this.height=r-n,this}getBounds(t){return t||(t=new D),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,n=t.x+t.width,r=t.y+t.height;return e>=this.x&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&n>=this.x&&n<this.x+this.width&&r>=this.y&&r<this.y+this.height}set(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const O={default:-1};function U(t="default"){return void 0===O[t]&&(O[t]=-1),++O[t]}const G={},L="8.0.0";function z(t,e,i=3){if(G[e])return;let n=(new Error).stack;void 0===n?console.warn("PixiJS Deprecation Warning: ",`${e}\nDeprecated since v${t}`):(n=n.split("\n").splice(i).join("\n"),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${e}\nDeprecated since v${t}`),console.warn(n),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${e}\nDeprecated since v${t}`),console.warn(n))),G[e]=!0}const N=()=>{};function V(t){return t+=0===t?1:0,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1}function H(t){return!(t&t-1||!t)}function W(t){const e={};for(const i in t)void 0!==t[i]&&(e[i]=t[i]);return e}const j=Object.create(null);const Y=class t extends _{constructor(e={}){var i,n,r,s,o,a,l;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,e=__spreadValues(__spreadValues({},t.defaultOptions),e),this.addressMode=e.addressMode,this.addressModeU=null!=(i=e.addressModeU)?i:this.addressModeU,this.addressModeV=null!=(n=e.addressModeV)?n:this.addressModeV,this.addressModeW=null!=(r=e.addressModeW)?r:this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=null!=(s=e.magFilter)?s:this.magFilter,this.minFilter=null!=(o=e.minFilter)?o:this.minFilter,this.mipmapFilter=null!=(a=e.mipmapFilter)?a:this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=null!=(l=e.maxAnisotropy)?l:1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){z(L,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=function(t){const e=j[t];return void 0===e&&(j[t]=U("resource")),e}(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Y.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let X=Y;const Z=class t extends _{constructor(e={}){var i,n,r;super(),this.options=e,this.uid=U("textureSource"),this._resourceType="textureSource",this._resourceId=U("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.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,e=__spreadValues(__spreadValues({},t.defaultOptions),e),this.label=null!=(i=e.label)?i:"",this.resource=e.resource,this.autoGarbageCollect=e.autoGarbageCollect,this._resolution=e.resolution,e.width?this.pixelWidth=e.width*this._resolution:this.pixelWidth=this.resource&&null!=(n=this.resourceWidth)?n:1,e.height?this.pixelHeight=e.height*this._resolution:this.pixelHeight=this.resource&&null!=(r=this.resourceHeight)?r:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=e.format,this.dimension=e.dimensions,this.mipLevelCount=e.mipLevelCount,this.autoGenerateMipmaps=e.autoGenerateMipmaps,this.sampleCount=e.sampleCount,this.antialias=e.antialias,this.alphaMode=e.alphaMode,this.style=new X(W(e)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&(null==(e=this._style)||e.off("change",this._onStyleChange,this),this._style=t,null==(i=this._style)||i.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=U("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i||(i=this._resolution),t||(t=this.width),e||(e=this.height);const n=Math.round(t*i),r=Math.round(e*i);return this.width=n/i,this.height=r/i,this._resolution=i,(this.pixelWidth!==n||this.pixelHeight!==r)&&(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=r,this.emit("resize",this),this._resourceId=U("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=H(this.pixelWidth)&&H(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Z.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let q=Z;class $ extends q{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(i=e instanceof Float32Array?"rgba32float":e instanceof Int32Array||e instanceof Uint32Array?"rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?"rgba16uint":(Int8Array,"bgra8unorm")),super(__spreadProps(__spreadValues({},t),{resource:e,format:i})),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}$.extension=o.TextureSource;const K=new S;class Q{constructor(t,e){this.mapCoord=new S,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=void 0===e?t.width<10?0:.5:e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&(null==(e=this._texture)||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){void 0===e&&(e=t);const i=this.mapCoord;for(let n=0;n<t.length;n+=2){const r=t[n],s=t[n+1];e[n]=r*i.a+s*i.c+i.tx,e[n+1]=r*i.b+s*i.d+i.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const i=t.orig,n=t.trim;n&&(K.set(i.width/n.width,0,0,i.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(K));const r=t.source,s=this.uClampFrame,o=this.clampMargin/r._resolution,a=this.clampOffset/r._resolution;return s[0]=(t.frame.x+o+a)/r.width,s[1]=(t.frame.y+o+a)/r.height,s[2]=(t.frame.x+t.frame.width-o+a)/r.width,s[3]=(t.frame.y+t.frame.height-o+a)/r.height,this.uClampOffset[0]=this.clampOffset/r.pixelWidth,this.uClampOffset[1]=this.clampOffset/r.pixelHeight,this.isSimple=t.frame.width===r.width&&t.frame.height===r.height&&0===t.rotate,!0}}class J extends _{constructor({source:t,label:e,frame:i,orig:n,trim:r,defaultAnchor:s,defaultBorders:o,rotate:a,dynamic:l}={}){var h;if(super(),this.uid=U("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new D,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=null!=(h=null==t?void 0:t.source)?h:new q,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:t,height:e}=this._source;this.frame.width=t,this.frame.height=e}this.orig=n||this.frame,this.trim=r,this.rotate=null!=a?a:0,this.defaultAnchor=s,this.defaultBorders=o,this.destroyed=!1,this.dynamic=l||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new Q(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:i,height:n}=this._source,r=e.x/i,s=e.y/n,o=e.width/i,a=e.height/n;let l=this.rotate;if(l){const e=o/2,i=a/2,n=r+e,h=s+i;l=k.add(l,k.NW),t.x0=n+e*k.uX(l),t.y0=h+i*k.uY(l),l=k.add(l,2),t.x1=n+e*k.uX(l),t.y1=h+i*k.uY(l),l=k.add(l,2),t.x2=n+e*k.uX(l),t.y2=h+i*k.uY(l),l=k.add(l,2),t.x3=n+e*k.uX(l),t.y3=h+i*k.uY(l)}else t.x0=r,t.y0=s,t.x1=r+o,t.y1=s,t.x2=r+o,t.y2=s+a,t.x3=r,t.y3=s+a}destroy(t=!1){this._source&&t&&(this._source.destroy(),this._source=null),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return z(L,"Texture.baseTexture is now Texture.source"),this._source}}function tt(t,e,i){const{width:n,height:r}=i.orig,s=i.trim;if(s){const i=s.width,o=s.height;t.minX=s.x-e._x*n,t.maxX=t.minX+i,t.minY=s.y-e._y*r,t.maxY=t.minY+o}else t.minX=-e._x*n,t.maxX=t.minX+n,t.minY=-e._y*r,t.maxY=t.minY+r}J.EMPTY=new J({label:"EMPTY",source:new q({label:"EMPTY"})}),J.EMPTY.destroy=N,J.WHITE=new J({source:new $({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),J.WHITE.destroy=N;const et=new S;class it{constructor(t=1/0,e=1/0,i=-1/0,n=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=et,this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new D);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=et,this}set(t,e,i,n){this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}addFrame(t,e,i,n,r){r||(r=this.matrix);const s=r.a,o=r.b,a=r.c,l=r.d,h=r.tx,c=r.ty;let u=this.minX,d=this.minY,p=this.maxX,f=this.maxY,g=s*t+a*e+h,m=o*t+l*e+c;g<u&&(u=g),m<d&&(d=m),g>p&&(p=g),m>f&&(f=m),g=s*i+a*e+h,m=o*i+l*e+c,g<u&&(u=g),m<d&&(d=m),g>p&&(p=g),m>f&&(f=m),g=s*t+a*n+h,m=o*t+l*n+c,g<u&&(u=g),m<d&&(d=m),g>p&&(p=g),m>f&&(f=m),g=s*i+a*n+h,m=o*i+l*n+c,g<u&&(u=g),m<d&&(d=m),g>p&&(p=g),m>f&&(f=m),this.minX=u,this.minY=d,this.maxX=p,this.maxY=f}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,i=this.minY,n=this.maxX,r=this.maxY,{a:s,b:o,c:a,d:l,tx:h,ty:c}=t;let u=s*e+a*i+h,d=o*e+l*i+c;this.minX=u,this.minY=d,this.maxX=u,this.maxY=d,u=s*n+a*i+h,d=o*n+l*i+c,this.minX=u<this.minX?u:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=d>this.maxY?d:this.maxY,u=s*e+a*r+h,d=o*e+l*r+c,this.minX=u<this.minX?u:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=d>this.maxY?d:this.maxY,u=s*n+a*r+h,d=o*n+l*r+c,this.minX=u<this.minX?u:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=d>this.maxY?d:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,n){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>n&&(this.maxY=n),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new it(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,n){let r=this.minX,s=this.minY,o=this.maxX,a=this.maxY;n||(n=this.matrix);const l=n.a,h=n.b,c=n.c,u=n.d,d=n.tx,p=n.ty;for(let f=e;f<i;f+=2){const e=t[f],i=t[f+1],n=l*e+c*i+d,g=h*e+u*i+p;r=n<r?n:r,s=g<s?g:s,o=n>o?n:o,a=g>a?g:a}this.minX=r,this.minY=s,this.maxX=o,this.maxY=a}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}var nt={grad:.9,turn:360,rad:360/(2*Math.PI)},rt=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},st=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=Math.pow(10,e)),Math.round(i*t)/i+0},ot=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=1),t>i?i:t>e?t:e},at=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},lt=function(t){return{r:ot(t.r,0,255),g:ot(t.g,0,255),b:ot(t.b,0,255),a:ot(t.a)}},ht=function(t){return{r:st(t.r),g:st(t.g),b:st(t.b),a:st(t.a,3)}},ct=/^#([0-9a-f]{3,8})$/i,ut=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},dt=function(t){var e=t.r,i=t.g,n=t.b,r=t.a,s=Math.max(e,i,n),o=s-Math.min(e,i,n),a=o?s===e?(i-n)/o:s===i?2+(n-e)/o:4+(e-i)/o:0;return{h:60*(a<0?a+6:a),s:s?o/s*100:0,v:s/255*100,a:r}},pt=function(t){var e=t.h,i=t.s,n=t.v,r=t.a;e=e/360*6,i/=100,n/=100;var s=Math.floor(e),o=n*(1-i),a=n*(1-(e-s)*i),l=n*(1-(1-e+s)*i),h=s%6;return{r:255*[n,a,o,o,l,n][h],g:255*[l,n,n,a,o,o][h],b:255*[o,o,l,n,n,a][h],a:r}},ft=function(t){return{h:at(t.h),s:ot(t.s,0,100),l:ot(t.l,0,100),a:ot(t.a)}},gt=function(t){return{h:st(t.h),s:st(t.s),l:st(t.l),a:st(t.a,3)}},mt=function(t){return pt((i=(e=t).s,{h:e.h,s:(i*=((n=e.l)<50?n:100-n)/100)>0?2*i/(n+i)*100:0,v:n+i,a:e.a}));var e,i,n},_t=function(t){return{h:(e=dt(t)).h,s:(r=(200-(i=e.s))*(n=e.v)/100)>0&&r<200?i*n/100/(r<=100?r:200-r)*100:0,l:r/2,a:e.a};var e,i,n,r},yt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,xt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,vt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wt={string:[[function(t){var e=ct.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:4===t.length?st(parseInt(t[3]+t[3],16)/255,2):1}:6===t.length||8===t.length?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:8===t.length?st(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=bt.exec(t)||vt.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:lt({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:void 0===e[7]?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=yt.exec(t)||xt.exec(t);if(!e)return null;var i,n,r=ft({h:(i=e[1],n=e[2],void 0===n&&(n="deg"),Number(i)*(nt[n]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return mt(r)},"hsl"]],object:[[function(t){var e=t.r,i=t.g,n=t.b,r=t.a,s=void 0===r?1:r;return rt(e)&&rt(i)&&rt(n)?lt({r:Number(e),g:Number(i),b:Number(n),a:Number(s)}):null},"rgb"],[function(t){var e=t.h,i=t.s,n=t.l,r=t.a,s=void 0===r?1:r;if(!rt(e)||!rt(i)||!rt(n))return null;var o=ft({h:Number(e),s:Number(i),l:Number(n),a:Number(s)});return mt(o)},"hsl"],[function(t){var e=t.h,i=t.s,n=t.v,r=t.a,s=void 0===r?1:r;if(!rt(e)||!rt(i)||!rt(n))return null;var o,a=(o={h:Number(e),s:Number(i),v:Number(n),a:Number(s)},{h:at(o.h),s:ot(o.s,0,100),v:ot(o.v,0,100),a:ot(o.a)});return pt(a)},"hsv"]]},St=function(t,e){for(var i=0;i<e.length;i++){var n=e[i][0](t);if(n)return[n,e[i][1]]}return[null,void 0]},At=function(t,e){var i=_t(t);return{h:i.h,s:ot(i.s+100*e,0,100),l:i.l,a:i.a}},Tt=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},Ct=function(t,e){var i=_t(t);return{h:i.h,s:i.s,l:ot(i.l+100*e,0,100),a:i.a}},Pt=function(){function t(t){this.parsed=function(t){return"string"==typeof t?St(t.trim(),wt.string):"object"==typeof t&&null!==t?St(t,wt.object):[null,void 0]}(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return null!==this.parsed},t.prototype.brightness=function(){return st(Tt(this.rgba),2)},t.prototype.isDark=function(){return Tt(this.rgba)<.5},t.prototype.isLight=function(){return Tt(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=ht(this.rgba)).r,i=t.g,n=t.b,s=(r=t.a)<1?ut(st(255*r)):"","#"+ut(e)+ut(i)+ut(n)+s;var t,e,i,n,r,s},t.prototype.toRgb=function(){return ht(this.rgba)},t.prototype.toRgbString=function(){return e=(t=ht(this.rgba)).r,i=t.g,n=t.b,(r=t.a)<1?"rgba("+e+", "+i+", "+n+", "+r+")":"rgb("+e+", "+i+", "+n+")";var t,e,i,n,r},t.prototype.toHsl=function(){return gt(_t(this.rgba))},t.prototype.toHslString=function(){return e=(t=gt(_t(this.rgba))).h,i=t.s,n=t.l,(r=t.a)<1?"hsla("+e+", "+i+"%, "+n+"%, "+r+")":"hsl("+e+", "+i+"%, "+n+"%)";var t,e,i,n,r},t.prototype.toHsv=function(){return t=dt(this.rgba),{h:st(t.h),s:st(t.s),v:st(t.v),a:st(t.a,3)};var t},t.prototype.invert=function(){return Mt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},t.prototype.saturate=function(t){return void 0===t&&(t=.1),Mt(At(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),Mt(At(this.rgba,-t))},t.prototype.grayscale=function(){return Mt(At(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),Mt(Ct(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),Mt(Ct(this.rgba,-t))},t.prototype.rotate=function(t){return void 0===t&&(t=15),this.hue(this.hue()+t)},t.prototype.alpha=function(t){return"number"==typeof t?Mt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):st(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=_t(this.rgba);return"number"==typeof t?Mt({h:t,s:e.s,l:e.l,a:e.a}):st(e.h)},t.prototype.isEqual=function(t){return this.toHex()===Mt(t).toHex()},t}(),Mt=function(t){return t instanceof Pt?t:new Pt(t)},Et=[];[function(t,e){var i={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"},n={};for(var r in i)n[i[r]]=r;var s={};t.prototype.toName=function(e){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var r,o,a=n[this.toHex()];if(a)return a;if(null==e?void 0:e.closest){var l=this.toRgb(),h=1/0,c="black";if(!s.length)for(var u in i)s[u]=new t(i[u]).toRgb();for(var d in i){var p=(r=l,o=s[d],Math.pow(r.r-o.r,2)+Math.pow(r.g-o.g,2)+Math.pow(r.b-o.b,2));p<h&&(h=p,c=d)}return c}},e.string.push([function(e){var n=e.toLowerCase(),r="transparent"===n?"#0000":i[n];return r?new t(r).toRgb():null},"name"])}].forEach(function(t){Et.indexOf(t)<0&&(t(Pt,wt),Et.push(t))});const Rt=class t{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(e){if(e instanceof t)this._value=this._cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(null===e)throw new Error("Cannot set Color#value to null");null!==this._value&&this._isSourceEqual(this._value,e)||(this._value=this._cloneSource(e),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return"string"==typeof t||"number"==typeof t||t instanceof Number||null===t?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):"object"==typeof t&&null!==t?__spreadValues({},t):t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if("number"===i||"string"===i||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length===e.length&&t.every((t,i)=>t===e[i]);if(null!==t&&null!==e){const i=Object.keys(t),n=Object.keys(e);return i.length===n.length&&i.every(i=>t[i]===e[i])}return t===e}toRgba(){const[t,e,i,n]=this._components;return{r:t,g:e,b:i,a:n}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,n]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(255*e),t[1]=Math.round(255*i),t[2]=Math.round(255*n),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,n,r]=this._components;return t[0]=e,t[1]=i,t[2]=n,t[3]=r,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,n]=this._components;return t[0]=e,t[1]=i,t[2]=n,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(65280&t)+((255&t)<<16)}multiply(e){const[i,n,r,s]=t._temp.setValue(e)._components;return this._components[0]*=i,this._components[1]*=n,this._components[2]*=r,this._components[3]*=s,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(1===t)return(255<<24)+this._int;if(0===t)return e?0:this._int;let i=this._int>>16&255,n=this._int>>8&255,r=255&this._int;return e&&(i=i*t+.5|0,n=n*t+.5|0,r=r*t+.5|0),(255*t<<24)+(i<<16)+(n<<8)+r}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(255*this._components[3]).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(e){let i,n,r,s;if(("number"==typeof e||e instanceof Number)&&e>=0&&e<=16777215){i=(e>>16&255)/255,n=(e>>8&255)/255,r=(255&e)/255,s=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[i,n,r,s=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[i,n,r,s=255]=e,i/=255,n/=255,r/=255,s/=255;else if("string"==typeof e||"object"==typeof e){if("string"==typeof e){const i=t.HEX_PATTERN.exec(e);i&&(e=`#${i[2]}`)}const o=Mt(e);o.isValid()&&(({r:i,g:n,b:r,a:s}=o.rgba),i/=255,n/=255,r/=255)}if(void 0===i)throw new Error(`Unable to convert color ${e}`);this._components[0]=i,this._components[1]=n,this._components[2]=r,this._components[3]=s,this._refreshInt()}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(255*t<<16)+(255*e<<8)+(255*i|0)}_clamp(t,e=0,i=1){return"number"==typeof t?Math.min(Math.max(t,e),i):(t.forEach((n,r)=>{t[r]=Math.min(Math.max(n,e),i)}),t)}static isColorLike(e){return"number"==typeof e||"string"==typeof e||e instanceof Number||e instanceof t||Array.isArray(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||void 0!==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}};Rt.shared=new Rt,Rt._temp=new Rt,Rt.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Bt=Rt;let Ft=0;function kt(...t){500!==Ft&&(Ft++,500===Ft?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...t))}class It{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var e;let i;return i=this._index>0?this._pool[--this._index]:new this._classType,null==(e=i.init)||e.call(i,t),i}return(t){var e;null==(e=t.reset)||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}const Dt=new class{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new It(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}},Ot={get isCachedAsTexture(){var t;return!!(null==(t=this.renderGroup)?void 0:t.isCachedAsTexture)},cacheAsTexture(t){"boolean"==typeof t&&!1===t?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(!0===t?{}:t))},updateCacheTexture(){var t;null==(t=this.renderGroup)||t.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(t){z("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(t)}};function Ut(t,e,i){const n=t.length;let r;if(e>=n||0===i)return;const s=n-(i=e+i>n?n-e:i);for(r=e;r<s;++r)t[r]=t[r+i];t.length=s}const Gt={allowChildren:!0,removeChildren(t=0,e){var i;const n=null!=e?e:this.children.length,r=n-t,s=[];if(r>0&&r<=n){for(let i=n-1;i>=t;i--){const t=this.children[i];t&&(s.push(t),t.parent=null)}Ut(this.children,t,n);const e=this.renderGroup||this.parentRenderGroup;e&&e.removeChildren(s);for(let t=0;t<s.length;++t){const e=s[t];null==(i=e.parentRenderLayer)||i.detach(e),this.emit("childRemoved",e,this,t),s[t].emit("removed",this)}return s.length>0&&this._didViewChangeTick++,s}if(0===r&&0===this.children.length)return s;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(t){const e=this.getChildAt(t);return this.removeChild(e)},getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]},setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(t),this.addChildAt(t,e)},getChildIndex(t){const e=this.children.indexOf(t);if(-1===e)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(t,e){this.allowChildren||z(L,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:i}=this;if(e<0||e>i.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${i.length}`);if(t.parent){const i=t.parent.children.indexOf(t);if(t.parent===this&&i===e)return t;-1!==i&&t.parent.children.splice(i,1)}e===i.length?i.push(t):i.splice(e,0,t),t.parent=this,t.didChange=!0,t._updateFlags=15;const n=this.renderGroup||this.parentRenderGroup;return n&&n.addChild(t),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",t,this,e),t.emit("added",this),t},swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),n=this.getChildIndex(e);this.children[i]=e,this.children[n]=t;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var t;null==(t=this.parent)||t.removeChild(this)},reparentChild(...t){return 1===t.length?this.reparentChildAt(t[0],this.children.length):(t.forEach(t=>this.reparentChildAt(t,this.children.length)),t[0])},reparentChildAt(t,e){if(t.parent===this)return this.setChildIndex(t,e),t;const i=t.worldTransform.clone();t.removeFromParent(),this.addChildAt(t,e);const n=this.worldTransform.clone();return n.invert(),i.prepend(n),t.setFromMatrix(i),t},replaceChild(t,e){t.updateLocalTransform(),this.addChildAt(e,this.getChildIndex(t)),e.setFromMatrix(t.localTransform),e.updateLocalTransform(),this.removeChild(t)}},Lt={collectRenderables(t,e,i){this.parentRenderLayer&&this.parentRenderLayer!==i||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(t,e,i):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,t):this.collectRenderablesWithEffects(t,e,i))},collectRenderablesSimple(t,e,i){const n=this.children,r=n.length;for(let s=0;s<r;s++)n[s].collectRenderables(t,e,i)},collectRenderablesWithEffects(t,e,i){const{renderPipes:n}=e;for(let r=0;r<this.effects.length;r++){const e=this.effects[r];n[e.pipe].push(e,this,t)}this.collectRenderablesSimple(t,e,i);for(let r=this.effects.length-1;r>=0;r--){const e=this.effects[r];n[e.pipe].pop(e,this,t)}}};class zt{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}const Nt=new class{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const i=this._tests[e];if(i.test(t))return Dt.get(i.maskClass,t)}return t}returnMaskEffect(t){Dt.return(t)}};h.handleByList(o.MaskEffect,Nt._effectClasses);const Vt={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const t=this.renderGroup||this.parentRenderGroup;t&&(t.structureDidChange=!0)},addEffect(t){-1===this.effects.indexOf(t)&&(this.effects.push(t),this.effects.sort((t,e)=>t.priority-e.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(t){const e=this.effects.indexOf(t);-1!==e&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(t){const e=this._maskEffect;(null==e?void 0:e.mask)!==t&&(e&&(this.removeEffect(e),Nt.returnMaskEffect(e),this._maskEffect=null),null!=t&&(this._maskEffect=Nt.getMaskEffect(t),this.addEffect(this._maskEffect)))},get mask(){var t;return null==(t=this._maskEffect)?void 0:t.mask},setMask(t){this._maskOptions=__spreadValues(__spreadValues({},this._maskOptions),t),t.mask&&(this.mask=t.mask),this._markStructureAsChanged()},set filters(t){var e;!Array.isArray(t)&&t&&(t=[t]);const i=this._filterEffect||(this._filterEffect=new zt),n=(null==t?void 0:t.length)>0,r=n!==(null==(e=i.filters)?void 0:e.length)>0;t=Array.isArray(t)?t.slice(0):t,i.filters=Object.freeze(t),r&&(n?this.addEffect(i):(this.removeEffect(i),i.filters=null!=t?t:null))},get filters(){var t;return null==(t=this._filterEffect)?void 0:t.filters},set filterArea(t){this._filterEffect||(this._filterEffect=new zt),this._filterEffect.filterArea=t},get filterArea(){var t;return null==(t=this._filterEffect)?void 0:t.filterArea}},Ht={label:null,get name(){return z(L,"Container.name property has been removed, use Container.label instead"),this.label},set name(t){z(L,"Container.name property has been removed, use Container.label instead"),this.label=t},getChildByName(t,e=!1){return this.getChildByLabel(t,e)},getChildByLabel(t,e=!1){const i=this.children;for(let n=0;n<i.length;n++){const e=i[n];if(e.label===t||t instanceof RegExp&&t.test(e.label))return e}if(e)for(let n=0;n<i.length;n++){const e=i[n].getChildByLabel(t,!0);if(e)return e}return null},getChildrenByLabel(t,e=!1,i=[]){const n=this.children;for(let r=0;r<n.length;r++){const e=n[r];(e.label===t||t instanceof RegExp&&t.test(e.label))&&i.push(e)}if(e)for(let r=0;r<n.length;r++)n[r].getChildrenByLabel(t,!0,i);return i}},Wt=new It(S),jt=new It(it),Yt=new S,Xt={getFastGlobalBounds(t,e){e||(e=new it),e.clear(),this._getGlobalBoundsRecursive(!!t,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);const i=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(i.worldTransform),e},_getGlobalBoundsRecursive(t,e,i){let n=e;if(t&&this.parentRenderLayer&&this.parentRenderLayer!==i)return;if(7!==this.localDisplayStatus||!this.measurable)return;const r=!!this.effects.length;if((this.renderGroup||r)&&(n=jt.get().clear()),this.boundsArea)e.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const t=this.bounds;n.addFrame(t.minX,t.minY,t.maxX,t.maxY,this.groupTransform)}const e=this.children;for(let r=0;r<e.length;r++)e[r]._getGlobalBoundsRecursive(t,n,i)}if(r){let t=!1;const i=this.renderGroup||this.parentRenderGroup;for(let e=0;e<this.effects.length;e++)this.effects[e].addBounds&&(t||(t=!0,n.applyMatrix(i.worldTransform)),this.effects[e].addBounds(n,!0));t&&n.applyMatrix(i.worldTransform.copyTo(Yt).invert()),e.addBounds(n),jt.return(n)}else this.renderGroup&&(e.addBounds(n,this.relativeGroupTransform),jt.return(n))}};function Zt(t,e,i){let n,r;return i.clear(),t.parent?e?n=t.parent.worldTransform:(r=Wt.get().identity(),n=$t(t,r)):n=S.IDENTITY,qt(t,i,n,e),r&&Wt.return(r),i.isValid||i.set(0,0,0,0),i}function qt(t,e,i,n){var r,s;if(!t.visible||!t.measurable)return;let o;n?o=t.worldTransform:(t.updateLocalTransform(),o=Wt.get(),o.appendFrom(t.localTransform,i));const a=e,l=!!t.effects.length;if(l&&(e=jt.get().clear()),t.boundsArea)e.addRect(t.boundsArea,o);else{t.bounds&&(e.matrix=o,e.addBounds(t.bounds));for(let i=0;i<t.children.length;i++)qt(t.children[i],e,o,n)}if(l){for(let i=0;i<t.effects.length;i++)null==(s=(r=t.effects[i]).addBounds)||s.call(r,e);a.addBounds(e,S.IDENTITY),jt.return(e)}n||Wt.return(o)}function $t(t,e){const i=t.parent;return i&&($t(i,e),i.updateLocalTransform(),e.append(i.localTransform)),e}function Kt(t,e){if(16777215===t||!e)return e;if(16777215===e||!t)return t;return(((t>>16&255)*(e>>16&255)/255|0)<<16)+(((t>>8&255)*(e>>8&255)/255|0)<<8)+((255&t)*(255&e)/255|0)}const Qt=16777215;function Jt(t,e){return t===Qt?e:e===Qt?t:Kt(t,e)}function te(t){return((255&t)<<16)+(65280&t)+(t>>16&255)}const ee={getGlobalAlpha(t){if(t)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let e=this.alpha,i=this.parent;for(;i;)e*=i.alpha,i=i.parent;return e},getGlobalTransform(t=new S,e){if(e)return t.copyFrom(this.worldTransform);this.updateLocalTransform();const i=$t(this,Wt.get().identity());return t.appendFrom(this.localTransform,i),Wt.return(i),t},getGlobalTint(t){if(t)return this.renderGroup?te(this.renderGroup.worldColor):this.parentRenderGroup?te(Jt(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,i=this.parent;for(;i;)e=Jt(e,i.localColor),i=i.parent;return te(e)}};function ie(t,e,i){return e.clear(),i||(i=S.IDENTITY),ne(t,e,i,t,!0),e.isValid||e.set(0,0,0,0),e}function ne(t,e,i,n,r){var s,o;let a;if(r)a=Wt.get(),a=i.copyTo(a);else{if(!t.visible||!t.measurable)return;t.updateLocalTransform();const e=t.localTransform;a=Wt.get(),a.appendFrom(e,i)}const l=e,h=!!t.effects.length;if(h&&(e=jt.get().clear()),t.boundsArea)e.addRect(t.boundsArea,a);else{t.renderPipeId&&(e.matrix=a,e.addBounds(t.bounds));const i=t.children;for(let t=0;t<i.length;t++)ne(i[t],e,a,n,!1)}if(h){for(let i=0;i<t.effects.length;i++)null==(o=(s=t.effects[i]).addLocalBounds)||o.call(s,e,n);l.addBounds(e,S.IDENTITY),jt.return(e)}Wt.return(a)}function re(t,e){const i=t.children;for(let n=0;n<i.length;n++){const t=i[n],r=t.uid,s=(65535&t._didViewChangeTick)<<16|65535&t._didContainerChangeTick,o=e.index;e.data[o]===r&&e.data[o+1]===s||(e.data[e.index]=r,e.data[e.index+1]=s,e.didChange=!0),e.index=o+2,t.children.length&&re(t,e)}return e.didChange}const se=new S,oe={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(t,e){const i=Math.sign(this.scale.x)||1;this.scale.x=0!==e?t/e*i:i},_setHeight(t,e){const i=Math.sign(this.scale.y)||1;this.scale.y=0!==e?t/e*i:i},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new it});const t=this._localBoundsCacheData;return t.index=1,t.didChange=!1,t.data[0]!==this._didViewChangeTick&&(t.didChange=!0,t.data[0]=this._didViewChangeTick),re(this,t),t.didChange&&ie(this,t.localBounds,se),t.localBounds},getBounds(t,e){return Zt(this,t,e||new it)}},ae={_onRender:null,set onRender(t){const e=this.renderGroup||this.parentRenderGroup;if(!t)return this._onRender&&(null==e||e.removeOnRender(this)),void(this._onRender=null);this._onRender||null==e||e.addOnRender(this),this._onRender=t},get onRender(){return this._onRender}},le={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(t){this._zIndex!==t&&(this._zIndex=t,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(he))}};function he(t,e){return t._zIndex-e._zIndex}const ce={getGlobalPosition(t=new v,e=!1){return this.parent?this.parent.toGlobal(this._position,t,e):(t.x=this._position.x,t.y=this._position.y),t},toGlobal(t,e,i=!1){const n=this.getGlobalTransform(Wt.get(),i);return e=n.apply(t,e),Wt.return(n),e},toLocal(t,e,i,n){e&&(t=e.toGlobal(t,i,n));const r=this.getGlobalTransform(Wt.get(),n);return i=r.applyInverse(t,i),Wt.return(r),i}};class ue{constructor(){this.uid=U("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}let de=0;const pe=new class{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new X(this.textureOptions)}createTexture(t,e,i){const n=new q(__spreadProps(__spreadValues({},this.textureOptions),{width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1}));return new J({source:n,label:"texturePool_"+de++})}getOptimalTexture(t,e,i=1,n){let r=Math.ceil(t*i-1e-6),s=Math.ceil(e*i-1e-6);r=V(r),s=V(s);const o=(r<<17)+(s<<1)+(n?1:0);this._texturePool[o]||(this._texturePool[o]=[]);let a=this._texturePool[o].pop();return a||(a=this.createTexture(r,s,n)),a.source._resolution=i,a.source.width=r/i,a.source.height=s/i,a.source.pixelWidth=r,a.source.pixelHeight=s,a.frame.x=0,a.frame.y=0,a.frame.width=t,a.frame.height=e,a.updateUvs(),this._poolKeyHash[a.uid]=o,a}getSameSizeTexture(t,e=!1){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t,e=!1){const i=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[i].push(t)}clear(t){if(t=!1!==t)for(const e in this._texturePool){const t=this._texturePool[e];if(t)for(let e=0;e<t.length;e++)t[e].destroy(!0)}this._texturePool={}}};class fe{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new S,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 ue,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let i=0;i<e.length;i++){const t=e[i];t._updateFlags=15,this.addChild(t)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(pe.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup)return void this.addRenderGroupChild(t.renderGroup);t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup)return void this._removeRenderGroupChild(t.renderGroup);const e=t.children;for(let i=0;i<e.length;i++)this.removeChild(e[i])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return 7===this.root.localDisplayStatus&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let i=0;i<e.length;i++)this._getChildren(e[i],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const i=t.children;for(let n=0;n<i.length;n++)this._getChildren(i[n],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return 1&this._matrixDirty?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new S),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return 2&this._matrixDirty?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new S),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(4&this._matrixDirty))return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new S),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}const ge=new d(null),me=new d(null),_e=new d(null,1,1),ye=new d(null);class xe extends _{constructor(t={}){var e,i;super(),this.uid=U("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.updateTick=-1,this.localTransform=new S,this.relativeGroupTransform=new S,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new d(this,0,0),this._scale=_e,this._pivot=me,this._origin=ye,this._skew=ge,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=[],function(t,e,i={}){for(const n in e)i[n]||void 0===e[n]||(t[n]=e[n])}(this,t,{children:!0,parent:!0,effects:!0}),null==(e=t.children)||e.forEach(t=>this.addChild(t)),null==(i=t.parent)||i.addChild(this)}static mixin(t){z("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),h.mixin(xe,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=4095&t}get _didChangeId(){return 4095&this._didContainerChangeTick|(4095&this._didViewChangeTick)<<12}addChild(...t){if(this.allowChildren||z(L,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let e=0;e<t.length;e++)this.addChild(t[e]);return t[0]}const e=t[0],i=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),i&&(i.structureDidChange=!0),e):(e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e._updateFlags=15,i&&i.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,0!==e._zIndex&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let e=0;e<t.length;e++)this.removeChild(t[e]);return t[0]}const e=t[0],i=this.children.indexOf(e);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,this.didChange||(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;null==t||t.removeChild(this),this.renderGroup=Dt.get(fe,this),this.groupTransform=S.IDENTITY,null==t||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;null==t||t.removeChild(this),Dt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,null==t||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&0===this.effects.length}get worldTransform(){return this._worldTransform||(this._worldTransform=new S),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*x}set angle(t){this.rotation=t*b}get pivot(){return this._pivot===me&&(this._pivot=new d(this,0,0)),this._pivot}set pivot(t){this._pivot===me&&(this._pivot=new d(this,0,0),this._origin!==ye&&kt("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),"number"==typeof t?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===ge&&(this._skew=new d(this,0,0)),this._skew}set skew(t){this._skew===ge&&(this._skew=new d(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===_e&&(this._scale=new d(this,1,1)),this._scale}set scale(t){this._scale===_e&&(this._scale=new d(this,0,0)),"string"==typeof t&&(t=parseFloat(t)),"number"==typeof t?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===ye&&(this._origin=new d(this,0,0)),this._origin}set origin(t){this._origin===ye&&(this._origin=new d(this,0,0),this._pivot!==me&&kt("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),"number"==typeof t?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){var i;const n=this.getLocalBounds();"object"==typeof t?(e=null!=(i=t.height)?i:t.width,t=t.width):null!=e||(e=t),void 0!==t&&this._setWidth(t,n.width),void 0!==e&&this._setHeight(e,n.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set("number"==typeof t.x?t.x:this.position.x,"number"==typeof t.y?t.y:this.position.y),this.scale.set("number"==typeof t.scaleX?t.scaleX||1:this.scale.x,"number"==typeof t.scaleY?t.scaleY||1:this.scale.y),this.rotation="number"==typeof t.rotation?t.rotation:this.rotation,this.skew.set("number"==typeof t.skewX?t.skewX:this.skew.x,"number"==typeof t.skewY?t.skewY:this.skew.y),this.pivot.set("number"==typeof t.pivotX?t.pivotX:this.pivot.x,"number"==typeof t.pivotY?t.pivotY:this.pivot.y),this.origin.set("number"==typeof t.originX?t.originX:this.origin.x,"number"==typeof t.originY?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,n=this._pivot,r=this._origin,s=this._position,o=i._x,a=i._y,l=n._x,h=n._y,c=-r._x,u=-r._y;e.a=this._cx*o,e.b=this._sx*o,e.c=this._cy*a,e.d=this._sy*a,e.tx=s._x-(l*e.a+h*e.c)+(c*e.a+u*e.c)-c,e.ty=s._y-(l*e.b+h*e.d)+(c*e.b+u*e.d)-u}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=1,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=Bt.shared.setValue(null!=t?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=1,this._onUpdate())}get tint(){return te(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=2,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(2&this.localDisplayStatus)}set visible(t){const e=t?2:0;(2&this.localDisplayStatus)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(4&this.localDisplayStatus)}set culled(t){const e=t?0:4;(4&this.localDisplayStatus)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(1&this.localDisplayStatus)}set renderable(t){const e=t?1:0;(1&this.localDisplayStatus)!==e&&(this._updateFlags|=4,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return 7===this.localDisplayStatus&&this.groupAlpha>0}destroy(t=!1){var e;if(this.destroyed)return;let i;this.destroyed=!0,this.children.length&&(i=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();if(("boolean"==typeof t?t:null==t?void 0:t.children)&&i)for(let n=0;n<i.length;++n)i[n].destroy(t);null==(e=this.renderGroup)||e.destroy(),this.renderGroup=null}}h.mixin(xe,Gt,Xt,ce,ae,oe,Vt,Ht,le,{cullArea:null,cullable:!1,cullableChildren:!0},Ot,ee,Lt);class be extends xe{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this._bounds=new it(0,1,0,0),this._boundsDirty=!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:i,y:n}=t;return i>=e.minX&&i<=e.maxX&&n>=e.minY&&n<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){var e,i;super.destroy(t),this._bounds=null;for(const n in this._gpuData)null==(i=(e=this._gpuData[n]).destroy)||i.call(e);this._gpuData=null}collectRenderablesSimple(t,e,i){const{renderPipes:n}=e;n.blendMode.setBlendMode(this,this.groupBlendMode,t);n[this.renderPipeId].addRenderable(this,t),this.didViewUpdate=!1;const r=this.children,s=r.length;for(let o=0;o<s;o++)r[o].collectRenderables(t,e,i)}}class ve extends be{constructor(t=J.EMPTY){t instanceof J&&(t={texture:t});const e=t,{texture:i=J.EMPTY,anchor:n,roundPixels:r,width:s,height:o}=e,a=__objRest(e,["texture","anchor","roundPixels","width","height"]);super(__spreadValues({label:"Sprite"},a)),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new d({_onUpdate:()=>{this.onViewUpdate()}}),n?this.anchor=n:i.defaultAnchor&&(this.anchor=i.defaultAnchor),this.texture=i,this.allowChildren=!1,this.roundPixels=null!=r&&r,void 0!==s&&(this.width=s),void 0!==o&&(this.height=o)}static from(t,e=!1){return new ve(t instanceof J?t:J.from(t,e))}set texture(t){t||(t=J.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return tt(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return z("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:n,height:r}=e.orig;i.minX=-t._x*n,i.maxX=i.minX+n,i.minY=-t._y*r,i.maxY=i.minY+r}destroy(t=!1){super.destroy(t);if("boolean"==typeof t?t:null==t?void 0:t.texture){const e="boolean"==typeof t?t:null==t?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null,this._gpuData=null}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){var i;"object"==typeof t?(e=null!=(i=t.height)?i:t.width,t=t.width):null!=e||(e=t),void 0!==t&&this._setWidth(t,this._texture.orig.width),void 0!==e&&this._setHeight(e,this._texture.orig.height)}}const we=new it;function Se(t,e,i){const n=we;t.measurable=!0,Zt(t,i,n),e.addBoundsMask(n),t.measurable=!1}function Ae(t,e,i){const n=jt.get();t.measurable=!0;const r=Wt.get().identity();ie(t,n,Te(t,i,r)),t.measurable=!1,e.addBoundsMask(n),Wt.return(r),jt.return(n)}function Te(t,e,i){return t?(t!==e&&(Te(t.parent,e,i),t.updateLocalTransform(),i.append(t.localTransform)),i):(kt("Mask bounds, renderable is not inside the root container"),i)}class Ce{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",(null==t?void 0:t.mask)&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof ve),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){this.inverse||Se(this.mask,t,e)}addLocalBounds(t,e){Ae(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof ve}}Ce.extension=o.MaskEffect;class Pe{constructor(t){this.priority=0,this.pipe="colorMask",(null==t?void 0:t.mask)&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return"number"==typeof t}}Pe.extension=o.MaskEffect;class Me{constructor(t){this.priority=0,this.pipe="stencilMask",(null==t?void 0:t.mask)&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(t,e){Se(this.mask,t,e)}addLocalBounds(t,e){Ae(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof xe}}Me.extension=o.MaskEffect;let Ee={createCanvas:(t,e)=>{const i=document.createElement("canvas");return i.width=t,i.height=e,i},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var t;return null!=(t=document.baseURI)?t:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(t,e)=>fetch(t,e),parseXML:t=>(new DOMParser).parseFromString(t,"text/xml")};const Re={get:()=>Ee,set(t){Ee=t}};class Be extends q{constructor(t){t.resource||(t.resource=Re.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),this.resource.width===this.pixelWidth&&this.resource.height===this.pixelHeight||(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,i=this._resolution){const n=super.resize(t,e,i);return n&&this.resizeCanvas(),n}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}Be.extension=o.TextureSource;class Fe extends q{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}Fe.extension=o.TextureSource;var ke=(t=>(t[t.INTERACTION=50]="INTERACTION",t[t.HIGH=25]="HIGH",t[t.NORMAL=0]="NORMAL",t[t.LOW=-25]="LOW",t[t.UTILITY=-50]="UTILITY",t))(ke||{});class Ie{constructor(t,e=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=n}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const De=class t{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Ie(null,null,1/0),this.deltaMS=1/t.targetFPMS,this.elapsedMS=1/t.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&null===this._requestId&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){null===this._requestId&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=ke.NORMAL){return this._addListener(new Ie(t,e,i))}addOnce(t,e,i=ke.NORMAL){return this._addListener(new Ie(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(e){for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}else t.connect(i);return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i=i.match(t,e)?i.destroy():i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let i;if(e>this.lastTime){if(i=this.elapsedMS=e-this.lastTime,i>this._maxElapsedMS&&(i=this._maxElapsedMS),i*=this.speed,this._minElapsedMS){const t=e-this._lastFrame|0;if(t<this._minElapsedMS)return;this._lastFrame=e-t%this._minElapsedMS}this.deltaMS=i,this.deltaTime=this.deltaMS*t.targetFPMS;const n=this._head;let r=n.next;for(;r;)r=r.emit(this);n.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 i=Math.min(this.maxFPS,e),n=Math.min(Math.max(0,i)/1e3,t.targetFPMS);this._maxElapsedMS=1/n}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(0===t)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!t._shared){const e=t._shared=new t;e.autoStart=!0,e._protected=!0}return t._shared}static get system(){if(!t._system){const e=t._system=new t;e.autoStart=!0,e._protected=!0}return t._system}};De.targetFPMS=.06;let Oe,Ue=De;function Ge(){return __async(this,null,function*(){return null!=Oe||(Oe=__async(null,null,function*(){var t;const e=Re.get().createCanvas(1,1).getContext("webgl");if(!e)return"premultiply-alpha-on-upload";const i=yield new Promise(t=>{const e=document.createElement("video");e.onloadeddata=()=>t(e),e.onerror=()=>t(null),e.autoplay=!1,e.crossOrigin="anonymous",e.preload="auto",e.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",e.load()});if(!i)return"premultiply-alpha-on-upload";const n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,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,i);const s=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,s),e.deleteFramebuffer(r),e.deleteTexture(n),null==(t=e.getExtension("WEBGL_lose_context"))||t.loseContext(),s[0]<=s[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})),Oe})}const Le=class t extends q{constructor(e){var i;super(e),this.isReady=!1,this.uploadMethodId="video",e=__spreadValues(__spreadValues({},t.defaultOptions),e),this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=!1!==e.autoPlay,this.alphaMode=null!=(i=e.alphaMode)?i:"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),!1!==e.autoLoad&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=Ue.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}load(){return __async(this,null,function*(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=yield Ge(),this._load=new Promise((i,n)=>{this.isValid?i(this):(this._resolve=i,this._reject=n,void 0!==e.preloadTimeoutMs&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load})}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(Ue.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),null===this._videoFrameRequestCallbackHandle&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Ue.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Ue.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Le.extension=o.TextureSource,Le.defaultOptions=__spreadProps(__spreadValues({},q.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),Le.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let ze=Le;const Ne=(t,e,i=!1)=>(Array.isArray(t)||(t=[t]),e?t.map(t=>"string"==typeof t||i?e(t):t):t);const Ve=new class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||kt(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=Ne(t);let n;for(let a=0;a<this.parsers.length;a++){const t=this.parsers[a];if(t.test(e)){n=t.getCacheableAssets(i,e);break}}const r=new Map(Object.entries(n||{}));n||i.forEach(t=>{r.set(t,e)});const s=[...r.keys()],o={cacheKeys:s,keys:i};i.forEach(t=>{this._cacheMap.set(t,o)}),s.forEach(t=>{const i=n?n[t]:e;this._cache.has(t)&&this._cache.get(t)!==i&&kt("[Cache] already has key:",t),this._cache.set(t,r.get(t))})}remove(t){if(!this._cacheMap.has(t))return void kt(`[Assets] Asset id ${t} was not found in the Cache`);const e=this._cacheMap.get(t);e.cacheKeys.forEach(t=>{this._cache.delete(t)}),e.keys.forEach(t=>{this._cacheMap.delete(t)})}get parsers(){return this._parsers}},He=[];function We(t={}){const e=t&&t.resource,i=e?t.resource:t,n=e?t:{resource:t};for(let r=0;r<He.length;r++){const t=He[r];if(t.test(i))return new t(n)}throw new Error(`Could not find a source type for resource: ${n.resource}`)}h.handleByList(o.TextureSource,He),J.from=function(t,e=!1){return"string"==typeof t?Ve.get(t):t instanceof q?new J({source:t}):function(t={},e=!1){const i=t&&t.resource,n=i?t.resource:t,r=i?t:{resource:t};if(!e&&Ve.has(n))return Ve.get(n);const s=new J({source:We(r)});return s.on("destroy",()=>{Ve.has(n)&&Ve.remove(n)}),e||Ve.set(n,s),s}(t,e)},q.from=We,h.add(Ce,Pe,Me,ze,Fe,Be,$);var je=(t=>(t[t.Low=0]="Low",t[t.Normal=1]="Normal",t[t.High=2]="High",t))(je||{});function Ye(t){if("string"!=typeof t)throw new TypeError(`Path must be a string. Received ${JSON.stringify(t)}`)}function Xe(t){return t.split("?")[0].split("#")[0]}const Ze={toPosix(t){return e="\\",i="/",t.replace(new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),i);var e,i},isUrl(t){return/^https?:/.test(this.toPosix(t))},isDataUrl:t=>/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(t),isBlobUrl:t=>t.startsWith("blob:"),hasProtocol(t){return/^[^/:]+:/.test(this.toPosix(t))},getProtocol(t){Ye(t),t=this.toPosix(t);const e=/^file:\/\/\//.exec(t);if(e)return e[0];const i=/^[^/:]+:\/{0,2}/.exec(t);return i?i[0]:""},toAbsolute(t,e,i){if(Ye(t),this.isDataUrl(t)||this.isBlobUrl(t))return t;const n=Xe(this.toPosix(null!=e?e:Re.get().getBaseUrl())),r=Xe(this.toPosix(null!=i?i:this.rootname(n)));if((t=this.toPosix(t)).startsWith("/"))return Ze.join(r,t.slice(1));return this.isAbsolute(t)?t:this.join(n,t)},normalize(t){if(Ye(t),0===t.length)return".";if(this.isDataUrl(t)||this.isBlobUrl(t))return t;let e="";const i=(t=this.toPosix(t)).startsWith("/");this.hasProtocol(t)&&(e=this.rootname(t),t=t.slice(e.length));const n=t.endsWith("/");return(t=function(t){let e="",i=0,n=-1,r=0,s=-1;for(let o=0;o<=t.length;++o){if(o<t.length)s=t.charCodeAt(o);else{if(47===s)break;s=47}if(47===s){if(n===o-1||1===r);else if(n!==o-1&&2===r){if(e.length<2||2!==i||46!==e.charCodeAt(e.length-1)||46!==e.charCodeAt(e.length-2))if(e.length>2){const t=e.lastIndexOf("/");if(t!==e.length-1){-1===t?(e="",i=0):(e=e.slice(0,t),i=e.length-1-e.lastIndexOf("/")),n=o,r=0;continue}}else if(2===e.length||1===e.length){e="",i=0,n=o,r=0;continue}}else e.length>0?e+=`/${t.slice(n+1,o)}`:e=t.slice(n+1,o),i=o-n-1;n=o,r=0}else 46===s&&-1!==r?++r:r=-1}return e}(t)).length>0&&n&&(t+="/"),i?`/${t}`:e+t},isAbsolute(t){return Ye(t),t=this.toPosix(t),!!this.hasProtocol(t)||t.startsWith("/")},join(...t){var e;if(0===t.length)return".";let i;for(let n=0;n<t.length;++n){const r=t[n];if(Ye(r),r.length>0)if(void 0===i)i=r;else{const s=null!=(e=t[n-1])?e:"";this.joinExtensions.includes(this.extname(s).toLowerCase())?i+=`/../${r}`:i+=`/${r}`}}return void 0===i?".":this.normalize(i)},dirname(t){if(Ye(t),0===t.length)return".";let e=(t=this.toPosix(t)).charCodeAt(0);const i=47===e;let n=-1,r=!0;const s=this.getProtocol(t),o=t;for(let a=(t=t.slice(s.length)).length-1;a>=1;--a)if(e=t.charCodeAt(a),47===e){if(!r){n=a;break}}else r=!1;return-1===n?i?"/":this.isUrl(o)?s+t:s:i&&1===n?"//":s+t.slice(0,n)},rootname(t){Ye(t);let e="";if(e=(t=this.toPosix(t)).startsWith("/")?"/":this.getProtocol(t),this.isUrl(t)){const i=t.indexOf("/",e.length);e=-1!==i?t.slice(0,i):t,e.endsWith("/")||(e+="/")}return e},basename(t,e){Ye(t),e&&Ye(e),t=Xe(this.toPosix(t));let i,n=0,r=-1,s=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";let o=e.length-1,a=-1;for(i=t.length-1;i>=0;--i){const l=t.charCodeAt(i);if(47===l){if(!s){n=i+1;break}}else-1===a&&(s=!1,a=i+1),o>=0&&(l===e.charCodeAt(o)?-1===--o&&(r=i):(o=-1,r=a))}return n===r?r=a:-1===r&&(r=t.length),t.slice(n,r)}for(i=t.length-1;i>=0;--i)if(47===t.charCodeAt(i)){if(!s){n=i+1;break}}else-1===r&&(s=!1,r=i+1);return-1===r?"":t.slice(n,r)},extname(t){Ye(t);let e=-1,i=0,n=-1,r=!0,s=0;for(let o=(t=Xe(this.toPosix(t))).length-1;o>=0;--o){const a=t.charCodeAt(o);if(47!==a)-1===n&&(r=!1,n=o+1),46===a?-1===e?e=o:1!==s&&(s=1):-1!==e&&(s=-1);else if(!r){i=o+1;break}}return-1===e||-1===n||0===s||1===s&&e===n-1&&e===i+1?"":t.slice(e,n)},parse(t){Ye(t);const e={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return e;let i=(t=Xe(this.toPosix(t))).charCodeAt(0);const n=this.isAbsolute(t);let r;e.root=this.rootname(t),r=n||this.hasProtocol(t)?1:0;let s=-1,o=0,a=-1,l=!0,h=t.length-1,c=0;for(;h>=r;--h)if(i=t.charCodeAt(h),47!==i)-1===a&&(l=!1,a=h+1),46===i?-1===s?s=h:1!==c&&(c=1):-1!==s&&(c=-1);else if(!l){o=h+1;break}return-1===s||-1===a||0===c||1===c&&s===a-1&&s===o+1?-1!==a&&(e.base=e.name=0===o&&n?t.slice(1,a):t.slice(o,a)):(0===o&&n?(e.name=t.slice(1,s),e.base=t.slice(1,a)):(e.name=t.slice(o,s),e.base=t.slice(o,a)),e.ext=t.slice(s,a)),e.dir=this.dirname(t),e},sep:"/",delimiter:":",joinExtensions:[".html"]};function qe(t,e,i,n,r){const s=e[i];for(let o=0;o<s.length;o++){const a=s[o];i<e.length-1?qe(t.replace(n[i],a),e,i+1,n,r):r.push(t.replace(n[i],a))}}function $e(t){const e=t.match(/\{(.*?)\}/g),i=[];if(e){const n=[];e.forEach(t=>{const e=t.substring(1,t.length-1).split(",");n.push(e)}),qe(t,n,0,e,i)}else i.push(t);return i}const Ke=t=>!Array.isArray(t);class Qe{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){var e,i,n;if(this._bundleIdConnector=null!=(e=t.connector)?e:this._bundleIdConnector,this._createBundleAssetId=null!=(i=t.createBundleAssetId)?i:this._createBundleAssetId,this._extractAssetIdFromBundle=null!=(n=t.extractAssetIdFromBundle)?n:this._extractAssetIdFromBundle,"bar"!==this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar")))throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if("string"==typeof t)this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return Ne(e||i,t=>"string"==typeof t?t:Array.isArray(t)?t.map(t=>{var e;return null!=(e=null==t?void 0:t.src)?e:t}):(null==t?void 0:t.src)?t.src:t,!0)}addManifest(t){this._manifest&&kt("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(t,e){const i=[];let n=e;Array.isArray(e)||(n=Object.entries(e).map(([t,e])=>"string"==typeof e||Array.isArray(e)?{alias:t,src:e}:__spreadValues({alias:t},e))),n.forEach(e=>{const n=e.src,r=e.alias;let s;if("string"==typeof r){const e=this._createBundleAssetId(t,r);i.push(e),s=[r,e]}else{const e=r.map(e=>this._createBundleAssetId(t,e));i.push(...e),s=[...r,...e]}this.add(__spreadValues(__spreadValues({},e),{alias:s,src:n}))}),this._bundles[t]=i}add(t){const e=[];let i;Array.isArray(t)?e.push(...t):e.push(t),i=t=>{this.hasKey(t)&&kt(`[Resolver] already has key: ${t} overwriting`)};Ne(e).forEach(t=>{const{src:e}=t;let{data:n,format:r,loadParser:s,parser:o}=t;const a=Ne(e).map(t=>"string"==typeof t?$e(t):Array.isArray(t)?t:[t]),l=this.getAlias(t);Array.isArray(l)?l.forEach(i):i(l);const h=[];a.forEach(t=>{t.forEach(t=>{var e,i,a,c;let u={};if("object"!=typeof t){u.src=t;for(let e=0;e<this._parsers.length;e++){const i=this._parsers[e];if(i.test(t)){u=i.parse(t);break}}}else n=null!=(e=t.data)?e:n,r=null!=(i=t.format)?i:r,(t.loadParser||t.parser)&&(s=null!=(a=t.loadParser)?a:s,o=null!=(c=t.parser)?c:o),u=__spreadValues(__spreadValues({},u),t);if(!l)throw new Error(`[Resolver] alias is undefined for this asset: ${u.src}`);u=this._buildResolvedAsset(u,{aliases:l,data:n,format:r,loadParser:s,parser:o}),h.push(u)})}),l.forEach(t=>{this._assetMap[t]=h})})}resolveBundle(t){const e=Ke(t);t=Ne(t);const i={};return t.forEach(t=>{const e=this._bundles[t];if(e){const n=this.resolve(e),r={};for(const e in n){const i=n[e];r[this._extractAssetIdFromBundle(t,e)]=i}i[t]=r}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if("string"!=typeof t){const t={};for(const i in e)t[i]=e[i].src;return t}return e.src}resolve(t){const e=Ke(t);t=Ne(t);const i={};return t.forEach(t=>{if(!this._resolverHash[t])if(this._assetMap[t]){let e=this._assetMap[t];const i=this._getPreferredOrder(e);null==i||i.priority.forEach(t=>{i.params[t].forEach(i=>{const n=e.filter(e=>!!e[t]&&e[t]===i);n.length&&(e=n)})}),this._resolverHash[t]=e[0]}else this._resolverHash[t]=this._buildResolvedAsset({alias:[t],src:t},{});i[t]=this._resolverHash[t]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[e],n=this._preferredOrder.find(t=>t.params.format.includes(i.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;return`${t}${/\?/.test(t)?"&":"?"}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){var i,n;const{aliases:r,data:s,loadParser:o,parser:a,format:l}=e;return(this._basePath||this._rootPath)&&(t.src=Ze.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=null!=(i=null!=r?r:t.alias)?i:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=__spreadValues(__spreadValues({},s||{}),t.data),t.loadParser=null!=o?o:t.loadParser,t.parser=null!=a?a:t.parser,t.format=null!=(n=null!=l?l:t.format)?n:t.src.split(".").pop().split("?").shift().split("#").shift(),t}}Qe.RETINA_PREFIX=/@([0-9\.]+)x/;const Je=(t,e)=>{const i=e.split("?")[1];return i&&(t+=`?${i}`),t},ti=class t{constructor(t,e){this.linkedSheets=[];let i=t;(null==t?void 0:t.source)instanceof q&&(i={texture:t,data:e});const{texture:n,data:r,cachePrefix:s=""}=i;this.cachePrefix=s,this._texture=n instanceof J?n:null,this.textureSource=n.source,this.textures={},this.animations={},this.data=r;const o=parseFloat(r.meta.scale);o?(this.resolution=o,n.source.resolution=this.resolution):this.resolution=n.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=t.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(e){let i=e;const n=t.BATCH_SIZE;for(;i-e<n&&i<this._frameKeys.length;){const t=this._frameKeys[i],e=this._frames[t],n=e.frame;if(n){let i=null,r=null;const s=!1!==e.trimmed&&e.sourceSize?e.sourceSize:e.frame,o=new D(0,0,Math.floor(s.w)/this.resolution,Math.floor(s.h)/this.resolution);i=e.rotated?new D(Math.floor(n.x)/this.resolution,Math.floor(n.y)/this.resolution,Math.floor(n.h)/this.resolution,Math.floor(n.w)/this.resolution):new D(Math.floor(n.x)/this.resolution,Math.floor(n.y)/this.resolution,Math.floor(n.w)/this.resolution,Math.floor(n.h)/this.resolution),!1!==e.trimmed&&e.spriteSourceSize&&(r=new D(Math.floor(e.spriteSourceSize.x)/this.resolution,Math.floor(e.spriteSourceSize.y)/this.resolution,Math.floor(n.w)/this.resolution,Math.floor(n.h)/this.resolution)),this.textures[t]=new J({source:this.textureSource,frame:i,orig:o,trim:r,rotate:e.rotated?2:0,defaultAnchor:e.anchor,defaultBorders:e.borders,label:t.toString()})}i++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const n=t[e][i];this.animations[e].push(this.textures[n])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*t.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*t.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(null==(e=this._texture)||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};ti.BATCH_SIZE=1e3;let ei=ti;const ii=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function ni(t,e,i){const n={};if(t.forEach(t=>{n[t]=e}),Object.keys(e.textures).forEach(t=>{n[`${e.cachePrefix}${t}`]=e.textures[t]}),!i){const i=Ze.dirname(t[0]);e.linkedSheets.forEach((t,r)=>{const s=ni([`${i}/${e.data.meta.related_multi_packs[r]}`],t,!0);Object.assign(n,s)})}return n}const ri={extension:o.Asset,cache:{test:t=>t instanceof ei,getCacheableAssets:(t,e)=>ni(t,e,!1)},resolver:{extension:{type:o.ResolveParser,name:"resolveSpritesheet"},test:t=>{const e=t.split("?")[0].split("."),i=e.pop(),n=e.pop();return"json"===i&&ii.includes(n)},parse:t=>{var e,i;const n=t.split(".");return{resolution:parseFloat(null!=(i=null==(e=Qe.RETINA_PREFIX.exec(t))?void 0:e[1])?i:"1"),format:n[n.length-2],src:t}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:o.LoadParser,priority:je.Normal,name:"spritesheetLoader"},testParse(t,e){return __async(this,null,function*(){return".json"===Ze.extname(e.src).toLowerCase()&&!!t.frames})},parse(t,e,i){return __async(this,null,function*(){var n,r,s;const{texture:o,imageFilename:a,textureOptions:l,cachePrefix:h}=null!=(n=null==e?void 0:e.data)?n:{};let c,u=Ze.dirname(e.src);if(u&&u.lastIndexOf("/")!==u.length-1&&(u+="/"),o instanceof J)c=o;else{const n=Je(u+(null!=a?a:t.meta.image),e.src);c=(yield i.load([{src:n,data:l}]))[n]}const d=new ei({texture:c.source,data:t,cachePrefix:h});yield d.parse();const p=null==(r=null==t?void 0:t.meta)?void 0:r.related_multi_packs;if(Array.isArray(p)){const t=[];for(const r of p){if("string"!=typeof r)continue;let n=u+r;(null==(s=e.data)?void 0:s.ignoreMultiPack)||(n=Je(n,e.src),t.push(i.load({src:n,data:{textureOptions:l,ignoreMultiPack:!0}})))}const n=yield Promise.all(t);d.linkedSheets=n,n.forEach(t=>{t.linkedSheets=[d].concat(d.linkedSheets.filter(e=>e!==t))})}return d})},unload(t,e,i){return __async(this,null,function*(){yield i.unload(t.textureSource._sourceOrigin),t.destroy(!1)})}}};h.add(ri);class si{constructor(t){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),e=this._canvas.width,i=this._canvas.height,n=t.width/e*this._renderer.resolution,r=t.height/i*this._renderer.resolution,s=`translate(${t.left}px, ${t.top}px) scale(${n}, ${r})`;s!==this._lastTransform&&(this._domElement.style.transform=s,this._lastTransform=s)},this._domElement=t.domElement,this._renderer=t.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(t=>{for(const e of t){if(e.target!==this._canvas)continue;const t=this.canvas.width,i=this.canvas.height,n=e.contentRect.width/t*this._renderer.resolution,r=e.contentRect.height/i*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==r)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=r)}}),this._observer.observe(this._canvas)):this._tickerAttached||Ue.shared.add(this.updateTranslation,this,ke.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&Ue.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 oi{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=oi.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new v,this.page=new v,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return!this.manager||this.path&&this.path[this.path.length-1]===this.target||(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,n,r){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 ai=/iPhone/i,li=/iPod/i,hi=/iPad/i,ci=/\biOS-universal(?:.+)Mac\b/i,ui=/\bAndroid(?:.+)Mobile\b/i,di=/Android/i,pi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,fi=/Silk/i,gi=/Windows Phone/i,mi=/\bWindows(?:.+)ARM\b/i,_i=/BlackBerry/i,yi=/BB10/i,xi=/Opera Mini/i,bi=/\b(CriOS|Chrome)(?:.+)Mobile/i,vi=/Mobile(?:.+)Firefox\b/i,wi=function(t){return void 0!==t&&"MacIntel"===t.platform&&"number"==typeof t.maxTouchPoints&&t.maxTouchPoints>1&&"undefined"==typeof MSStream};function Si(t){var e={userAgent:"",platform:"",maxTouchPoints:0};t||"undefined"==typeof navigator?"string"==typeof t?e.userAgent=t:t&&t.userAgent&&(e={userAgent:t.userAgent,platform:t.platform,maxTouchPoints:t.maxTouchPoints||0}):e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};var i=e.userAgent,n=i.split("[FBAN");void 0!==n[1]&&(i=n[0]),void 0!==(n=i.split("Twitter"))[1]&&(i=n[0]);var r=function(t){return function(e){return e.test(t)}}(i),s={apple:{phone:r(ai)&&!r(gi),ipod:r(li),tablet:!r(ai)&&(r(hi)||wi(e))&&!r(gi),universal:r(ci),device:(r(ai)||r(li)||r(hi)||r(ci)||wi(e))&&!r(gi)},amazon:{phone:r(pi),tablet:!r(pi)&&r(fi),device:r(pi)||r(fi)},android:{phone:!r(gi)&&r(pi)||!r(gi)&&r(ui),tablet:!r(gi)&&!r(pi)&&!r(ui)&&(r(fi)||r(di)),device:!r(gi)&&(r(pi)||r(fi)||r(ui)||r(di))||r(/\bokhttp\b/i)},windows:{phone:r(gi),tablet:r(mi),device:r(gi)||r(mi)},other:{blackberry:r(_i),blackberry10:r(yi),opera:r(xi),firefox:r(vi),chrome:r(bi),device:r(_i)||r(yi)||r(xi)||r(vi)||r(bi)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}const Ai=(null!=(t=Si.default)?t:Si)(globalThis.navigator),Ti=class t{constructor(t,e=Ai){this._mobileInfo=e,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pool=[],this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._hookDiv=null,(e.tablet||e.phone)&&this._createTouchHook(),this._renderer=t}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}_createTouchHook(){const t=document.createElement("button");t.style.width="1px",t.style.height="1px",t.style.position="absolute",t.style.top="-1000px",t.style.left="-1000px",t.style.zIndex=2..toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top="0px",this._div.style.left="0px",this._div.style.pointerEvents="none",this._div.style.zIndex=2..toString(),this._canvasObserver=new si({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&(this._onKeyDown=this._onKeyDown.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)),this._deactivateOnMouseMove&&(this._onMouseMove=this._onMouseMove.bind(this),globalThis.document.addEventListener("mousemove",this._onMouseMove,!0));const t=this._renderer.view.canvas;if(t.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const e=new MutationObserver(()=>{t.parentNode&&(e.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});e.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(this._isActive&&!this._isMobileAccessibility){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const t of this._children)t._accessibleDiv&&t._accessibleDiv.parentNode&&(t._accessibleDiv.parentNode.removeChild(t._accessibleDiv),t._accessibleDiv=null),t._accessibleActive=!1;this._pool.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this._div&&this._div.parentNode&&this._div.parentNode.removeChild(this._div),this._pool=[],this._children=[]}}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this._updateAccessibleObjects(e[i])}init(e){const i=t.defaultOptions,n={accessibilityOptions:__spreadValues(__spreadValues({},i),(null==e?void 0:e.accessibilityOptions)||{})};this.debug=n.accessibilityOptions.debug,this._activateOnTab=n.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=n.accessibilityOptions.deactivateOnMouseMove,n.accessibilityOptions.enabledByDefault?this._activate():this._activateOnTab&&(this._onKeyDown=this._onKeyDown.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)),this._renderer.runners.postrender.remove(this)}postrender(){const t=performance.now();if(this._mobileInfo.android.device&&t<this._androidUpdateCount)return;if(this._androidUpdateCount=t+this._androidUpdateFrequency,!this._renderer.renderingToScreen||!this._renderer.view.canvas)return;const e=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const t of this._children)t._renderId===this._renderId&&e.add(this._children.indexOf(t))}for(let i=this._children.length-1;i>=0;i--){const t=this._children[i];e.has(i)||(t._accessibleDiv&&t._accessibleDiv.parentNode&&(t._accessibleDiv.parentNode.removeChild(t._accessibleDiv),this._pool.push(t._accessibleDiv),t._accessibleDiv=null),t._accessibleActive=!1,Ut(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i<this._children.length;i++){const t=this._children[i];if(!t._accessibleActive||!t._accessibleDiv)continue;const e=t._accessibleDiv,n=t.hitArea||t.getBounds().rectangle;if(t.hitArea){const i=t.worldTransform;e.style.left=`${i.tx+n.x*i.a}px`,e.style.top=`${i.ty+n.y*i.d}px`,e.style.width=n.width*i.a+"px",e.style.height=n.height*i.d+"px"}else this._capHitArea(n),e.style.left=`${n.x}px`,e.style.top=`${n.y}px`,e.style.width=`${n.width}px`,e.style.height=`${n.height}px`}this._renderId++}_updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}_capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}_addChild(t){let e=this._pool.pop();e||("button"===t.accessibleType?e=document.createElement("button"):(e=document.createElement(t.accessibleType),e.style.cssText="\n color: transparent;\n pointer-events: none;\n padding: 0;\n margin: 0;\n border: 0;\n outline: 0;\n background: transparent;\n box-sizing: border-box;\n user-select: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n ",t.accessibleText&&(e.innerText=t.accessibleText)),e.style.width="100px",e.style.height="100px",e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=2..toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&null!==t.accessibleTitle?e.title=t.accessibleTitle:t.accessibleHint&&null!==t.accessibleHint||(e.title=`container ${t.tabIndex}`),t.accessibleHint&&null!==t.accessibleHint&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv),t.interactive&&(t._accessibleDiv.tabIndex=t.tabIndex)}_dispatchEvent(t,e){const{container:i}=t.target,n=this._renderer.events.rootBoundary,r=Object.assign(new oi(n),{target:i});n.rootTarget=this._renderer.lastObjectRendered,e.forEach(t=>n.dispatchEvent(r,t))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){9===t.keyCode&&this._activateOnTab&&this._activate()}_onMouseMove(t){0===t.movementX&&0===t.movementY||this._deactivate()}destroy(){var t;this._deactivate(),this._destroyTouchHook(),null==(t=this._canvasObserver)||t.destroy(),this._canvasObserver=null,this._div=null,this._pool=null,this._children=null,this._renderer=null,this._activateOnTab&&globalThis.removeEventListener("keydown",this._onKeyDown)}setAccessibilityEnabled(t){t?this._activate():this._deactivate()}};Ti.extension={type:[o.WebGLSystem,o.WebGPUSystem],name:"accessibility"},Ti.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let Ci=Ti;const Pi=Object.create(null),Mi=Object.create(null);function Ei(t,e){let i=Mi[t];return void 0===i&&(void 0===Pi[e]&&(Pi[e]=1),Mi[t]=i=Pi[e]++),i}let Ri,Bi;function Fi(){if(!Ri||(null==Ri?void 0:Ri.isContextLost())){const t=Re.get().createCanvas();Ri=t.getContext("webgl",{})}return Ri}function ki(){if(!Bi){Bi="mediump";const t=Fi();if(t&&t.getShaderPrecisionFormat){const e=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT);Bi=e.precision?"highp":"mediump"}}return Bi}const Ii={},Di={};const Oi={stripVersion:function(t,e){return e?t.replace("#version 300 es",""):t},ensurePrecision:function(t,e,i){const n=i?e.maxSupportedFragmentPrecision:e.maxSupportedVertexPrecision;if("precision"!==t.substring(0,9)){let r=i?e.requestedFragmentPrecision:e.requestedVertexPrecision;return"highp"===r&&"highp"!==n&&(r="mediump"),`precision ${r} float;\n${t}`}return"highp"!==n&&"precision highp"===t.substring(0,15)?t.replace("precision highp","precision mediump"):t},addProgramDefines:function(t,e,i){return e?t:i?`\n\n #ifdef GL_ES // This checks if it is WebGL1\n #define in varying\n #define finalColor gl_FragColor\n #define texture texture2D\n #endif\n ${t=t.replace("out vec4 finalColor;","")}\n `:`\n\n #ifdef GL_ES // This checks if it is WebGL1\n #define in attribute\n #define out varying\n #endif\n ${t}\n `},setProgramName:function(t,{name:e="pixi-program"},i=!0){e=e.replace(/\s+/g,"-");const n=i?Ii:Di;return n[e+=i?"-fragment":"-vertex"]?(n[e]++,e+=`-${n[e]}`):n[e]=1,-1!==t.indexOf("#define SHADER_NAME")?t:`${`#define SHADER_NAME ${e}`}\n${t}`},insertVersion:function(t,e){return e?`#version 300 es\n${t}`:t}},Ui=Object.create(null),Gi=class t{constructor(e){const i=-1!==(e=__spreadValues(__spreadValues({},t.defaultOptions),e)).fragment.indexOf("#version 300 es"),n={stripVersion:i,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:ki()},setProgramName:{name:e.name},addProgramDefines:i,insertVersion:i};let r=e.fragment,s=e.vertex;Object.keys(Oi).forEach(t=>{const e=n[t];r=Oi[t](r,e,!0),s=Oi[t](s,e,!1)}),this.fragment=r,this.vertex=s,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=Ei(`${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}static from(e){const i=`${e.vertex}:${e.fragment}`;return Ui[i]||(Ui[i]=new t(e)),Ui[i]}};Gi.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Li=Gi;const zi={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 Ni(t){var e;return null!=(e=zi[t])?e:zi.float32}const Vi={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"};function Hi(t){var e,i,n;const r=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,o=/var(<[^>]+>)? (\w+)/,a=/:\s*(\w+)/,l=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,c=null==(e=t.match(/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g))?void 0:e.map(t=>({group:parseInt(t.match(r)[1],10),binding:parseInt(t.match(s)[1],10),name:t.match(o)[2],isUniform:"<uniform>"===t.match(o)[1],type:t.match(a)[1]}));if(!c)return{groups:[],structs:[]};const u=null!=(n=null==(i=t.match(/struct\s+(\w+)\s*{([^}]+)}/g))?void 0:i.map(t=>{const e=t.match(h)[1],i=t.match(l).reduce((t,e)=>{const[i,n]=e.split(":");return t[i.trim()]=n.trim(),t},{});return i?{name:e,members:i}:null}).filter(({name:t})=>c.some(e=>e.type===t)))?n:[];return{groups:c,structs:u}}var Wi=(t=>(t[t.VERTEX=1]="VERTEX",t[t.FRAGMENT=2]="FRAGMENT",t[t.COMPUTE=4]="COMPUTE",t))(Wi||{});const ji=Object.create(null);class Yi{constructor(t){var e,i;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:n,vertex:r,layout:s,gpuLayout:o,name:a}=t;if(this.name=a,this.fragment=n,this.vertex=r,n.source===r.source){const t=Hi(n.source);this.structsAndGroups=t}else{const t=Hi(r.source),e=Hi(n.source);this.structsAndGroups=function(t,e){const i=new Set,n=new Set;return{structs:[...t.structs,...e.structs].filter(t=>!i.has(t.name)&&(i.add(t.name),!0)),groups:[...t.groups,...e.groups].filter(t=>{const e=`${t.name}-${t.binding}`;return!n.has(e)&&(n.add(e),!0)})}}(t,e)}this.layout=null!=s?s:function({groups:t}){const e=[];for(let i=0;i<t.length;i++){const n=t[i];e[n.group]||(e[n.group]={}),e[n.group][n.name]=n.binding}return e}(this.structsAndGroups),this.gpuLayout=null!=o?o:function({groups:t}){const e=[];for(let i=0;i<t.length;i++){const n=t[i];e[n.group]||(e[n.group]=[]),n.isUniform?e[n.group].push({binding:n.binding,visibility:Wi.VERTEX|Wi.FRAGMENT,buffer:{type:"uniform"}}):"sampler"===n.type?e[n.group].push({binding:n.binding,visibility:Wi.FRAGMENT,sampler:{type:"filtering"}}):"texture_2d"===n.type&&e[n.group].push({binding:n.binding,visibility:Wi.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return e}(this.structsAndGroups),this.autoAssignGlobalUniforms=!(void 0===(null==(e=this.layout[0])?void 0:e.globalUniforms)),this.autoAssignLocalUniforms=!(void 0===(null==(i=this.layout[1])?void 0:i.localUniforms)),this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Ei(i,"program")}get attributeData(){return null!=this._attributeData||(this._attributeData=function({source:t,entryPoint:e}){var i;const n={},r=t.indexOf(`fn ${e}`);if(-1!==r){const e=t.indexOf("->",r);if(-1!==e){const s=t.substring(r,e),o=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let a;for(;null!==(a=o.exec(s));){const t=null!=(i=Vi[a[3]])?i:"float32";n[a[2]]={location:parseInt(a[1],10),format:t,stride:Ni(t).stride,offset:0,instance:!1,start:0}}}}return n}(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return ji[e]||(ji[e]=new Yi(t)),ji[e]}}const Xi=["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>"],Zi=Xi.reduce((t,e)=>(t[e]=!0,t),{});function qi(t,e){switch(t){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 $i=class t{constructor(e,i){var n;this._touched=0,this.uid=U("uniform"),this._resourceType="uniformGroup",this._resourceId=U("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,i=__spreadValues(__spreadValues({},t.defaultOptions),i),this.uniformStructures=e;const r={};for(const t in e){const i=e[t];if(i.name=t,i.size=null!=(n=i.size)?n:1,!Zi[i.type])throw new Error(`Uniform type ${i.type} is not supported. Supported uniform types are: ${Xi.join(", ")}`);null!=i.value||(i.value=qi(i.type,i.size)),r[t]=i.value}this.uniforms=r,this._dirtyId=1,this.ubo=i.ubo,this.isStatic=i.isStatic,this._signature=Ei(Object.keys(r).map(t=>`${t}-${e[t].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};$i.defaultOptions={ubo:!1,isStatic:!1};let Ki=$i;class Qi{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const n=t[i];this.setResource(n,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var i,n;const r=this.resources[e];t!==r&&(r&&(null==(i=t.off)||i.call(t,"change",this.onResourceChange,this)),null==(n=t.on)||n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const i in e)e[i]._touched=t}destroy(){var t;const e=this.resources;for(const i in e){const n=e[i];null==(t=n.off)||t.call(n,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var Ji=(t=>(t[t.WEBGL=1]="WEBGL",t[t.WEBGPU=2]="WEBGPU",t[t.BOTH=3]="BOTH",t))(Ji||{});class tn extends _{constructor(t){super(),this.uid=U("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:i,groups:n,resources:r,compatibleRenderers:s,groupMap:o}=t;this.gpuProgram=e,this.glProgram=i,void 0===s&&(s=0,e&&(s|=Ji.WEBGPU),i&&(s|=Ji.WEBGL)),this.compatibleRenderers=s;const a={};if(r||n||(r={}),r&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&o)for(const l in o)for(const t in o[l]){const e=o[l][t];a[e]={group:l,binding:t,name:e}}else if(e&&n&&!o){const t=e.structsAndGroups.groups;o={},t.forEach(t=>{o[t.group]=o[t.group]||{},o[t.group][t.binding]=t.name,a[t.name]=t})}else if(r){if(n={},o={},e){e.structsAndGroups.groups.forEach(t=>{o[t.group]=o[t.group]||{},o[t.group][t.binding]=t.name,a[t.name]=t})}let t=0;for(const e in r)a[e]||(n[99]||(n[99]=new Qi,this._ownedBindGroups.push(n[99])),a[e]={group:99,binding:t,name:e},o[99]=o[99]||{},o[99][t]=e,t++);for(const e in r){const t=e;let i=r[e];i.source||i._resourceType||(i=new Ki(i));const s=a[t];s&&(n[s.group]||(n[s.group]=new Qi,this._ownedBindGroups.push(n[s.group])),n[s.group].setResource(i,s.binding))}}this.groups=n,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(n,a)}addResource(t,e,i){var n,r;(n=this._uniformBindMap)[e]||(n[e]={}),(r=this._uniformBindMap[e])[i]||(r[i]=t),this.groups[e]||(this.groups[e]=new Qi,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const n in e){const r=e[n];Object.defineProperty(i,r.name,{get:()=>t[r.group].getResource(r.binding),set(e){t[r.group].setResource(e,r.binding)}})}return i}destroy(t=!1){var e,i;this.emit("destroy",this),t&&(null==(e=this.gpuProgram)||e.destroy(),null==(i=this.glProgram)||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(t=>{t.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const e=t,{gpu:i,gl:n}=e,r=__objRest(e,["gpu","gl"]);let s,o;return i&&(s=Yi.from(i)),n&&(o=Li.from(n)),new tn(__spreadValues({gpuProgram:s,glProgram:o},r))}}const en={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},nn=class t{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(1&this.data)}set blend(t){!!(1&this.data)!==t&&(this.data^=1)}get offsets(){return!!(2&this.data)}set offsets(t){!!(2&this.data)!==t&&(this.data^=2)}set cullMode(t){"none"!==t?(this.culling=!0,this.clockwiseFrontFace="front"===t):this.culling=!1}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(4&this.data)}set culling(t){!!(4&this.data)!==t&&(this.data^=4)}get depthTest(){return!!(8&this.data)}set depthTest(t){!!(8&this.data)!==t&&(this.data^=8)}get depthMask(){return!!(32&this.data)}set depthMask(t){!!(32&this.data)!==t&&(this.data^=32)}get clockwiseFrontFace(){return!!(16&this.data)}set clockwiseFrontFace(t){!!(16&this.data)!==t&&(this.data^=16)}get blendMode(){return this._blendMode}set blendMode(t){this.blend="none"!==t,this._blendMode=t,this._blendModeId=en[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const e=new t;return e.depthTest=!1,e.blend=!0,e}};nn.default2d=nn.for2d();let rn=nn;const sn=class t extends tn{constructor(e){super(e=__spreadValues(__spreadValues({},t.defaultOptions),e)),this.enabled=!0,this._state=rn.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,"boolean"==typeof e.antialias?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)}apply(t,e,i,n){t.applyFilter(this,e,i,n)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(e){const i=e,{gpu:n,gl:r}=i,s=__objRest(i,["gpu","gl"]);let o,a;return n&&(o=Yi.from(n)),r&&(a=Li.from(r)),new t(__spreadValues({gpuProgram:o,glProgram:a},s))}};sn.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let on=sn;const an=[];let ln;function hn(){if("boolean"==typeof ln)return ln;try{const t=new Function("param1","param2","param3","return param1[param2] === param3;");ln=!0===t({a:"b"},"a","b")}catch(t){ln=!1}return ln}function cn(t,e,i=2){const n=e&&e.length,r=n?e[0]*i:t.length;let s=un(t,0,r,i,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,h;if(n&&(s=function(t,e,i,n){const r=[];for(let s=0,o=e.length;s<o;s++){const i=un(t,e[s]*n,s<o-1?e[s+1]*n:t.length,n,!1);i===i.next&&(i.steiner=!0),r.push(wn(i))}r.sort(yn);for(let s=0;s<r.length;s++)i=xn(r[s],i);return i}(t,e,s,i)),t.length>80*i){a=t[0],l=t[1];let e=a,n=l;for(let s=i;s<r;s+=i){const i=t[s],r=t[s+1];i<a&&(a=i),r<l&&(l=r),i>e&&(e=i),r>n&&(n=r)}h=Math.max(e-a,n-l),h=0!==h?32767/h:0}return pn(s,o,i,a,l,h,0),o}function un(t,e,i,n,r){let s;if(r===function(t,e,i,n){let r=0;for(let s=e,o=i-n;s<i;s+=n)r+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return r}(t,e,i,n)>0)for(let o=e;o<i;o+=n)s=kn(o/n|0,t[o],t[o+1],s);else for(let o=i-n;o>=e;o-=n)s=kn(o/n|0,t[o],t[o+1],s);return s&&Pn(s,s.next)&&(In(s),s=s.next),s}function dn(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!Pn(n,n.next)&&0!==Cn(n.prev,n,n.next))n=n.next;else{if(In(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function pn(t,e,i,n,r,s,o){if(!t)return;!o&&s&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=vn(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let s=null;for(e=0;r;){e++;let o=r,a=0;for(let t=0;t<i&&(a++,o=o.nextZ,o);t++);let l=i;for(;a>0||l>0&&o;)0!==a&&(0===l||!o||r.z<=o.z)?(n=r,r=r.nextZ,a--):(n=o,o=o.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;r=o}s.nextZ=null,i*=2}while(e>1)}(r)}(t,n,r,s);let a=t;for(;t.prev!==t.next;){const l=t.prev,h=t.next;if(s?gn(t,n,r,s):fn(t))e.push(l.i,t.i,h.i),In(t),t=h.next,a=h.next;else if((t=h)===a){o?1===o?pn(t=mn(dn(t),e),e,i,n,r,s,2):2===o&&_n(t,e,i,n,r,s):pn(dn(t),e,i,n,r,s,1);break}}}function fn(t){const e=t.prev,i=t,n=t.next;if(Cn(e,i,n)>=0)return!1;const r=e.x,s=i.x,o=n.x,a=e.y,l=i.y,h=n.y,c=Math.min(r,s,o),u=Math.min(a,l,h),d=Math.max(r,s,o),p=Math.max(a,l,h);let f=n.next;for(;f!==e;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&An(r,a,s,l,o,h,f.x,f.y)&&Cn(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function gn(t,e,i,n){const r=t.prev,s=t,o=t.next;if(Cn(r,s,o)>=0)return!1;const a=r.x,l=s.x,h=o.x,c=r.y,u=s.y,d=o.y,p=Math.min(a,l,h),f=Math.min(c,u,d),g=Math.max(a,l,h),m=Math.max(c,u,d),_=vn(p,f,e,i,n),y=vn(g,m,e,i,n);let x=t.prevZ,b=t.nextZ;for(;x&&x.z>=_&&b&&b.z<=y;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==r&&x!==o&&An(a,c,l,u,h,d,x.x,x.y)&&Cn(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==r&&b!==o&&An(a,c,l,u,h,d,b.x,b.y)&&Cn(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;x&&x.z>=_;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==r&&x!==o&&An(a,c,l,u,h,d,x.x,x.y)&&Cn(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==r&&b!==o&&An(a,c,l,u,h,d,b.x,b.y)&&Cn(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function mn(t,e){let i=t;do{const n=i.prev,r=i.next.next;!Pn(n,r)&&Mn(n,i,i.next,r)&&Bn(n,r)&&Bn(r,n)&&(e.push(n.i,i.i,r.i),In(i),In(i.next),i=t=r),i=i.next}while(i!==t);return dn(i)}function _n(t,e,i,n,r,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&Tn(o,t)){let a=Fn(o,t);return o=dn(o,o.next),a=dn(a,a.next),pn(o,e,i,n,r,s,0),void pn(a,e,i,n,r,s,0)}t=t.next}o=o.next}while(o!==t)}function yn(t,e){let i=t.x-e.x;if(0===i&&(i=t.y-e.y,0===i)){i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return i}function xn(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let s,o=-1/0;if(Pn(t,i))return i;do{if(Pn(t,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>o&&(o=t,s=i.x<i.next.x?i:i.next,t===n))return s}i=i.next}while(i!==e);if(!s)return null;const a=s,l=s.x,h=s.y;let c=1/0;i=s;do{if(n>=i.x&&i.x>=l&&n!==i.x&&Sn(r<h?n:o,r,l,h,r<h?o:n,r,i.x,i.y)){const e=Math.abs(r-i.y)/(n-i.x);Bn(i,t)&&(e<c||e===c&&(i.x>s.x||i.x===s.x&&bn(s,i)))&&(s=i,c=e)}i=i.next}while(i!==a);return s}(t,e);if(!i)return e;const n=Fn(i,t);return dn(n,n.next),dn(i,i.next)}function bn(t,e){return Cn(t.prev,t,e.prev)<0&&Cn(e.next,t,t.next)<0}function vn(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function wn(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function Sn(t,e,i,n,r,s,o,a){return(r-o)*(e-a)>=(t-o)*(s-a)&&(t-o)*(n-a)>=(i-o)*(e-a)&&(i-o)*(s-a)>=(r-o)*(n-a)}function An(t,e,i,n,r,s,o,a){return!(t===o&&e===a)&&Sn(t,e,i,n,r,s,o,a)}function Tn(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Mn(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Bn(t,e)&&Bn(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(Cn(t.prev,t,e.prev)||Cn(t,e.prev,e))||Pn(t,e)&&Cn(t.prev,t,t.next)>0&&Cn(e.prev,e,e.next)>0)}function Cn(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Pn(t,e){return t.x===e.x&&t.y===e.y}function Mn(t,e,i,n){const r=Rn(Cn(t,e,i)),s=Rn(Cn(t,e,n)),o=Rn(Cn(i,n,t)),a=Rn(Cn(i,n,e));return r!==s&&o!==a||(!(0!==r||!En(t,i,e))||(!(0!==s||!En(t,n,e))||(!(0!==o||!En(i,t,n))||!(0!==a||!En(i,e,n)))))}function En(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Rn(t){return t>0?1:t<0?-1:0}function Bn(t,e){return Cn(t.prev,t,t.next)<0?Cn(t,e,t.next)>=0&&Cn(t,t.prev,e)>=0:Cn(t,e,t.prev)<0||Cn(t,t.next,e)<0}function Fn(t,e){const i=Dn(t.i,t.x,t.y),n=Dn(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function kn(t,e,i,n){const r=Dn(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function In(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Dn(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}h.handleByNamedList(o.Environment,an);const On=cn.default||cn;var Un=(t=>(t[t.NONE=0]="NONE",t[t.COLOR=16384]="COLOR",t[t.STENCIL=1024]="STENCIL",t[t.DEPTH=256]="DEPTH",t[t.COLOR_DEPTH=16640]="COLOR_DEPTH",t[t.COLOR_STENCIL=17408]="COLOR_STENCIL",t[t.DEPTH_STENCIL=1280]="DEPTH_STENCIL",t[t.ALL=17664]="ALL",t))(Un||{});class Gn{constructor(t){this.items=[],this._name=t}emit(t,e,i,n,r,s,o,a){const{name:l,items:h}=this;for(let c=0,u=h.length;c<u;c++)h[c][l](t,e,i,n,r,s,o,a);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return-1!==e&&this.items.splice(e,1),this}contains(t){return-1!==this.items.indexOf(t)}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return 0===this.items.length}get name(){return this._name}}const Ln=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],zn=class t extends _{constructor(t){var e;super(),this.uid=U("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const i=[...Ln,...null!=(e=this.config.runners)?e:[]];this._addRunners(...i),this._unsafeEvalCheck()}init(){return __async(this,arguments,function*(e={}){const i=!0===e.skipExtensionImports||!1===e.manageImports;yield function(t){return __async(this,null,function*(){if(!t)for(let t=0;t<an.length;t++){const e=an[t];if(e.value.test())return void(yield e.value.load())}})}(i),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const t in this._systemsHash){const i=this._systemsHash[t].constructor.defaultOptions;e=__spreadValues(__spreadValues({},i),e)}e=__spreadValues(__spreadValues({},t.defaultOptions),e),this._roundPixels=e.roundPixels?1:0;for(let t=0;t<this.runners.init.items.length;t++)yield this.runners.init.items[t].init(e);this._initOptions=e})}render(t,e){let i=t;if(i instanceof xe&&(i={container:i},e&&(z(L,"passing a second argument is deprecated, please use render options instead"),i.target=e.renderTexture)),i.target||(i.target=this.view.renderTarget),i.target===this.view.renderTarget&&(this._lastObjectRendered=i.container,null!=i.clearColor||(i.clearColor=this.background.colorRgba),null!=i.clear||(i.clear=this.background.clearBeforeRender)),i.clearColor){const t=Array.isArray(i.clearColor)&&4===i.clearColor.length;i.clearColor=t?i.clearColor:Bt.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),i.container.enableRenderGroup(),this.runners.prerender.emit(i),this.runners.renderStart.emit(i),this.runners.render.emit(i),this.runners.renderEnd.emit(i),this.runners.postrender.emit(i)}resize(t,e,i){const n=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),void 0!==i&&i!==n&&this.runners.resolutionChange.emit(i)}clear(t={}){t.target||(t.target=this.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),null!=t.clear||(t.clear=Un.ALL);const{clear:e,clearColor:i,target:n}=t;Bt.shared.setValue(null!=i?i:this.background.colorRgba),this.renderTarget.clear(n,e,Bt.shared.toArray())}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(t=>{this.runners[t]=new Gn(t)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const n in this.runners)this.runners[n].add(i);return this}_addPipes(t,e){const i=e.reduce((t,e)=>(t[e.name]=e.value,t),{});t.forEach(t=>{const e=t.value,n=t.name,r=i[n];this.renderPipes[n]=new e(this,r?new r:null)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!hn())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()}};zn.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Nn,Vn,Hn=zn;function Wn(t){return void 0!==Nn||(Nn=(()=>{var e;const i={stencil:!0,failIfMajorPerformanceCaveat:null!=t?t:Hn.defaultOptions.failIfMajorPerformanceCaveat};try{if(!Re.get().getWebGLRenderingContext())return!1;let t=Re.get().createCanvas().getContext("webgl",i);const n=!!(null==(e=null==t?void 0:t.getContextAttributes())?void 0:e.stencil);if(t){const e=t.getExtension("WEBGL_lose_context");e&&e.loseContext()}return t=null,n}catch(n){return!1}})()),Nn}function jn(){return __async(this,arguments,function*(t={}){return void 0!==Vn||(Vn=yield __async(null,null,function*(){const e=Re.get().getNavigator().gpu;if(!e)return!1;try{const i=yield e.requestAdapter(t);return yield i.requestDevice(),!0}catch(i){return!1}})),Vn})}const Yn=["webgl","webgpu","canvas"];const Xn="8.12.0";class Zn{static init(){var t;null==(t=globalThis.__PIXI_APP_INIT__)||t.call(globalThis,this,Xn)}static destroy(){}}Zn.extension=o.Application;class qn{constructor(t){this._renderer=t}init(){var t;null==(t=globalThis.__PIXI_RENDERER_INIT__)||t.call(globalThis,this._renderer,Xn)}destroy(){this._renderer=null}}qn.extension={type:[o.WebGLSystem,o.WebGPUSystem],name:"initHook",priority:-10};const $n=class t{constructor(...t){this.stage=new xe,void 0!==t[0]&&z(L,"Application constructor options are deprecated, please use Application.init() instead.")}init(e){return __async(this,null,function*(){e=__spreadValues({},e),this.renderer=yield function(t){return __async(this,null,function*(){var e;let i,n=[];t.preference?(n.push(t.preference),Yn.forEach(e=>{e!==t.preference&&n.push(e)})):n=Yn.slice();let o={};for(let l=0;l<n.length;l++){const a=n[l];if("webgpu"===a&&(yield jn())){const{WebGPURenderer:e}=yield s(()=>__async(null,null,function*(){const{WebGPURenderer:t}=yield Promise.resolve().then(()=>Zu);return{WebGPURenderer:t}}),0,r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("assets/index-CMaxpPPD.js",document.baseURI).href);i=e,o=__spreadValues(__spreadValues({},t),t.webgpu);break}if("webgl"===a&&Wn(null!=(e=t.failIfMajorPerformanceCaveat)?e:Hn.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:e}=yield s(()=>__async(null,null,function*(){const{WebGLRenderer:t}=yield Promise.resolve().then(()=>lu);return{WebGLRenderer:t}}),0,r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("assets/index-CMaxpPPD.js",document.baseURI).href);i=e,o=__spreadValues(__spreadValues({},t),t.webgl);break}if("canvas"===a)throw o=__spreadValues({},t),new Error("CanvasRenderer is not yet implemented")}if(delete o.webgpu,delete o.webgl,!i)throw new Error("No available renderer for the current environment");const a=new i;return yield a.init(o),a})}(e),t._plugins.forEach(t=>{t.init.call(this,e)})})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return z(L,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(e=!1,i=!1){const n=t._plugins.slice(0);n.reverse(),n.forEach(t=>{t.destroy.call(this)}),this.stage.destroy(i),this.stage=null,this.renderer.destroy(e),this.renderer=null}};$n._plugins=[];let Kn=$n;h.handleByList(o.Application,Kn._plugins),h.add(Zn);class Qn{static init(t){Object.defineProperty(this,"resizeTo",{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;let t,e;if(this._cancelResize(),this._resizeTo===globalThis.window)t=globalThis.innerWidth,e=globalThis.innerHeight;else{const{clientWidth:i,clientHeight:n}=this._resizeTo;t=i,e=n}this.renderer.resize(t,e),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Qn.extension=o.Application;class Jn{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,ke.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Ue.shared:new Ue,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Jn.extension=o.Application;class tr extends _{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return z(L,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return z(L,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return z(L,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return z(L,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return z(L,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const i in this.chars)null==(e=this.chars[i].texture)||e.destroy();this.chars=null,t&&(this.pages.forEach(t=>t.texture.destroy(!0)),this.pages=null)}}const er=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function ir(t){const e="number"==typeof t.fontSize?`${t.fontSize}px`:t.fontSize;let i=t.fontFamily;Array.isArray(t.fontFamily)||(i=t.fontFamily.split(","));for(let n=i.length-1;n>=0;n--){let t=i[n].trim();/([\"\'])[^\'\"]+\1/.test(t)||er.includes(t)||(t=`"${t}"`),i[n]=t}return`${t.fontStyle} ${t.fontVariant} ${t.fontWeight} ${e} ${i.join(",")}`}const nr={willReadFrequently:!0},rr=class t{static get experimentalLetterSpacingSupported(){let e=t._experimentalLetterSpacingSupported;if(void 0===e){const i=Re.get().getCanvasRenderingContext2D().prototype;e=t._experimentalLetterSpacingSupported="letterSpacing"in i||"textLetterSpacing"in i}return e}constructor(t,e,i,n,r,s,o,a,l){this.text=t,this.style=e,this.width=i,this.height=n,this.lines=r,this.lineWidths=s,this.lineHeight=o,this.maxLineWidth=a,this.fontProperties=l}static measureText(e=" ",i,n=t._canvas,r=i.wordWrap){var s;const o=ir(i),a=t.measureFont(o);0===a.fontSize&&(a.fontSize=i.fontSize,a.ascent=i.fontSize);const l=t.__context;l.font=o;const h=(r?t._wordWrap(e,i,n):e).split(/(?:\r\n|\r|\n)/),c=new Array(h.length);let u=0;for(let m=0;m<h.length;m++){const e=t._measureText(h[m],i.letterSpacing,l);c[m]=e,u=Math.max(u,e)}const d=(null==(s=i._stroke)?void 0:s.width)||0;let p=u+d;i.dropShadow&&(p+=i.dropShadow.distance);const f=i.lineHeight||a.fontSize;let g=Math.max(f,a.fontSize+d)+(h.length-1)*(f+i.leading);i.dropShadow&&(g+=i.dropShadow.distance);return new t(e,i,p,g,h,c,f+i.leading,u,a)}static _measureText(e,i,n){let r=!1;t.experimentalLetterSpacingSupported&&(t.experimentalLetterSpacing?(n.letterSpacing=`${i}px`,n.textLetterSpacing=`${i}px`,r=!0):(n.letterSpacing="0px",n.textLetterSpacing="0px"));const s=n.measureText(e);let o=s.width;const a=-s.actualBoundingBoxLeft;let l=s.actualBoundingBoxRight-a;if(o>0)if(r)o-=i,l-=i;else{const n=(t.graphemeSegmenter(e).length-1)*i;o+=n,l+=n}return Math.max(o,l)}static _wordWrap(e,i,n=t._canvas){const r=n.getContext("2d",nr);let s=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:c}=i,u=t._collapseSpaces(c),d=t._collapseNewlines(c);let p=!u;const f=i.wordWrapWidth+h,g=t._tokenize(e);for(let m=0;m<g.length;m++){let e=g[m];if(t._isNewline(e)){if(!d){a+=t._addLine(o),p=!u,o="",s=0;continue}e=" "}if(u){const i=t.isBreakingSpace(e),n=t.isBreakingSpace(o[o.length-1]);if(i&&n)continue}const n=t._getFromCache(e,h,l,r);if(n>f)if(""!==o&&(a+=t._addLine(o),o="",s=0),t.canBreakWords(e,i.breakWords)){const n=t.wordWrapSplit(e);for(let c=0;c<n.length;c++){let u=n[c],d=u,g=1;for(;n[c+g];){const r=n[c+g];if(t.canBreakChars(d,r,e,c,i.breakWords))break;u+=r,d=r,g++}c+=g-1;const m=t._getFromCache(u,h,l,r);m+s>f&&(a+=t._addLine(o),p=!1,o="",s=0),o+=u,s+=m}}else{o.length>0&&(a+=t._addLine(o),o="",s=0);const i=m===g.length-1;a+=t._addLine(e,!i),p=!1,o="",s=0}else n+s>f&&(p=!1,a+=t._addLine(o),o="",s=0),(o.length>0||!t.isBreakingSpace(e)||p)&&(o+=e,s+=n)}return a+=t._addLine(o,!1),a}static _addLine(e,i=!0){return e=t._trimRight(e),e=i?`${e}\n`:e}static _getFromCache(e,i,n,r){let s=n[e];return"number"!=typeof s&&(s=t._measureText(e,i,r)+i,n[e]=s),s}static _collapseSpaces(t){return"normal"===t||"pre-line"===t}static _collapseNewlines(t){return"normal"===t}static _trimRight(e){if("string"!=typeof e)return"";for(let i=e.length-1;i>=0;i--){const n=e[i];if(!t.isBreakingSpace(n))break;e=e.slice(0,-1)}return e}static _isNewline(e){return"string"==typeof e&&t._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,i){return"string"==typeof e&&t._breakingSpaces.includes(e.charCodeAt(0))}static _tokenize(e){const i=[];let n="";if("string"!=typeof e)return i;for(let r=0;r<e.length;r++){const s=e[r],o=e[r+1];t.isBreakingSpace(s,o)||t._isNewline(s)?(""!==n&&(i.push(n),n=""),"\r"===s&&"\n"===o?(i.push("\r\n"),r++):i.push(s)):n+=s}return""!==n&&i.push(n),i}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,n,r){return!0}static wordWrapSplit(e){return t.graphemeSegmenter(e)}static measureFont(e){if(t._fonts[e])return t._fonts[e];const i=t._context;i.font=e;const n=i.measureText(t.METRICS_STRING+t.BASELINE_SYMBOL),r={ascent:n.actualBoundingBoxAscent,descent:n.actualBoundingBoxDescent,fontSize:n.actualBoundingBoxAscent+n.actualBoundingBoxDescent};return t._fonts[e]=r,r}static clearMetrics(e=""){e?delete t._fonts[e]:t._fonts={}}static get _canvas(){if(!t.__canvas){let i;try{const e=new OffscreenCanvas(0,0),n=e.getContext("2d",nr);if(null==n?void 0:n.measureText)return t.__canvas=e,e;i=Re.get().createCanvas()}catch(e){i=Re.get().createCanvas()}i.width=i.height=10,t.__canvas=i}return t.__canvas}static get _context(){return t.__context||(t.__context=t._canvas.getContext("2d",nr)),t.__context}};rr.METRICS_STRING="|ÉqÅ",rr.BASELINE_SYMBOL="M",rr.BASELINE_MULTIPLIER=1.4,rr.HEIGHT_MULTIPLIER=2,rr.graphemeSegmenter=(()=>t=>[...t])(),rr.experimentalLetterSpacing=!1,rr._fonts={},rr._newlines=[10,13],rr._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let sr=rr;const or=[{offset:0,color:"white"},{offset:1,color:"black"}],ar=class t{constructor(...e){var i;this.uid=U("fillGradient"),this.type="linear",this.colorStops=[];let n=function(t){var e,i;let n=null!=(e=t[0])?e:{};("number"==typeof n||t[1])&&(z("8.5.2","use options object instead"),n={type:"linear",start:{x:t[0],y:t[1]},end:{x:t[2],y:t[3]},textureSpace:t[4],textureSize:null!=(i=t[5])?i:lr.defaultLinearOptions.textureSize});return n}(e);const r="radial"===n.type?t.defaultRadialOptions:t.defaultLinearOptions;n=__spreadValues(__spreadValues({},r),W(n)),this._textureSize=n.textureSize,this._wrapMode=n.wrapMode,"radial"===n.type?(this.center=n.center,this.outerCenter=null!=(i=n.outerCenter)?i:this.center,this.innerRadius=n.innerRadius,this.outerRadius=n.outerRadius,this.scale=n.scale,this.rotation=n.rotation):(this.start=n.start,this.end=n.end),this.textureSpace=n.textureSpace,this.type=n.type,n.colorStops.forEach(t=>{this.addColorStop(t.offset,t.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:Bt.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:n}=this.end,r=i-t,s=n-e;const o=r<0||s<0;if("clamp-to-edge"===this._wrapMode){if(r<0){const e=t;t=i,i=e,r*=-1}if(s<0){const t=e;e=n,n=t,s*=-1}}const a=this.colorStops.length?this.colorStops:or,l=this._textureSize,{canvas:h,context:c}=cr(l,1),u=o?c.createLinearGradient(this._textureSize,0,0,0):c.createLinearGradient(0,0,this._textureSize,0);hr(u,a),c.fillStyle=u,c.fillRect(0,0,l,1),this.texture=new J({source:new Fe({resource:h,addressMode:this._wrapMode})});const d=Math.sqrt(r*r+s*s),p=Math.atan2(s,r),f=new S;f.scale(d/l,1),f.rotate(p),f.translate(t,e),"local"===this.textureSpace&&f.scale(l,l),this.transform=f}buildGradient(){"linear"===this.type?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:or,e=this._textureSize,{canvas:i,context:n}=cr(e,e),{x:r,y:s}=this.center,{x:o,y:a}=this.outerCenter,l=this.innerRadius,h=this.outerRadius,c=o-h,u=a-h,d=e/(2*h),p=(r-c)*d,f=(s-u)*d,g=n.createRadialGradient(p,f,l*d,(o-c)*d,(a-u)*d,h*d);hr(g,t),n.fillStyle=t[t.length-1].color,n.fillRect(0,0,e,e),n.fillStyle=g,n.translate(p,f),n.rotate(this.rotation),n.scale(1,this.scale),n.translate(-p,-f),n.fillRect(0,0,e,e),this.texture=new J({source:new Fe({resource:i,addressMode:this._wrapMode})});const m=new S;m.scale(1/d,1/d),m.translate(c,u),"local"===this.textureSpace&&m.scale(e,e),this.transform=m}get styleKey(){return this.uid}destroy(){var t;null==(t=this.texture)||t.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}};ar.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},ar.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let lr=ar;function hr(t,e){for(let i=0;i<e.length;i++){const n=e[i];t.addColorStop(n.offset,n.color)}}function cr(t,e){const i=Re.get().createCanvas(t,e),n=i.getContext("2d");return{canvas:i,context:n}}const ur={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 dr{constructor(t,e){this.uid=U("fillPattern"),this.transform=new S,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=ur[e].addressModeU,t.source.style.addressModeV=ur[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._styleKey=null}get styleKey(){return this._styleKey||(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join("-")}`),this._styleKey}destroy(){this.texture.destroy(!0),this.texture=null,this._styleKey=null}}var pr,fr;const gr=p(function(){if(fr)return pr;fr=1,pr=function(n){var r=[];return n.replace(e,function(e,n,s){var o=n.toLowerCase();for(s=function(t){var e=t.match(i);return e?e.map(Number):[]}(s),"m"==o&&s.length>2&&(r.push([n].concat(s.splice(0,2))),o="l",n="m"==n?"l":"L");;){if(s.length==t[o])return s.unshift(n),r.push(s);if(s.length<t[o])throw new Error("malformed path data");r.push([n].concat(s.splice(0,t[o])))}}),r};var t={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},e=/([astvzqmhlc])([^astvzqmhlc]*)/gi,i=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;return pr}());class mr{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new mr(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-t,r=this.y-e;return n*=n,r*=r,n+r<=i}strokeContains(t,e,i,n=.5){if(0===this.radius)return!1;const r=this.x-t,s=this.y-e,o=this.radius,a=(1-n)*i,l=Math.sqrt(r*r+s*s);return l<=o+a&&l>o-(i-a)}getBounds(t){return t||(t=new D),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=2*this.radius,t.height=2*this.radius,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class _r{constructor(t=0,e=0,i=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=n}clone(){return new _r(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,n=(e-this.y)/this.halfHeight;return i*=i,n*=n,i+n<=1}strokeContains(t,e,i,n=.5){const{halfWidth:r,halfHeight:s}=this;if(r<=0||s<=0)return!1;const o=i*(1-n),a=i-o,l=r-a,h=s-a,c=r+o,u=s+o,d=t-this.x,p=e-this.y;return d*d/(l*l)+p*p/(h*h)>1&&d*d/(c*c)+p*p/(u*u)<=1}getBounds(t){return t||(t=new D),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=2*this.halfWidth,t.height=2*this.halfHeight,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function yr(t,e,i,n,r,s){const o=r-i,a=s-n,l=o*o+a*a;let h,c,u=-1;0!==l&&(u=((t-i)*o+(e-n)*a)/l),u<0?(h=i,c=n):u>1?(h=r,c=s):(h=i+u*o,c=n+u*a);const d=t-h,p=e-c;return d*d+p*p}class xr{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if("number"!=typeof e[0]){const t=[];for(let i=0,n=e.length;i<n;i++)t.push(e[i].x,e[i].y);e=t}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,i=e.length;for(let n=0;n<i;n+=2){const r=e[n],s=e[n+1];t+=(e[(n+2)%i]-r)*(e[(n+3)%i]+s)}return t<0}containsPolygon(t){const e=this.getBounds(undefined),i=t.getBounds(undefined);if(!e.containsRect(i))return!1;const n=t.points;for(let r=0;r<n.length;r+=2){const t=n[r],e=n[r+1];if(!this.contains(t,e))return!1}return!0}clone(){const t=this.points.slice(),e=new xr(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const n=this.points.length/2;for(let r=0,s=n-1;r<n;s=r++){const n=this.points[2*r],o=this.points[2*r+1],a=this.points[2*s],l=this.points[2*s+1];o>e!=l>e&&t<(e-o)/(l-o)*(a-n)+n&&(i=!i)}return i}strokeContains(t,e,i,n=.5){const r=i*i,s=r*(1-n),o=r-s,{points:a}=this,l=a.length-(this.closePath?0:2);for(let h=0;h<l;h+=2){const i=a[h],n=a[h+1],r=a[(h+2)%a.length],l=a[(h+3)%a.length];if(yr(t,e,i,n,r,l)<=(Math.sign((r-i)*(e-n)-(l-n)*(t-i))<0?o:s))return!0}return!1}getBounds(t){t||(t=new D);const e=this.points;let i=1/0,n=-1/0,r=1/0,s=-1/0;for(let o=0,a=e.length;o<a;o+=2){const t=e[o],a=e[o+1];i=t<i?t:i,n=t>n?t:n,r=a<r?a:r,s=a>s?a:s}return t.x=i,t.width=n-i,t.y=r,t.height=s-r,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return z("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return z("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 br=(t,e,i,n,r,s,o)=>{const a=t-i,l=e-n,h=Math.sqrt(a*a+l*l);return h>=r-s&&h<=r+o};class vr{constructor(t=0,e=0,i=0,n=0,r=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=n,this.radius=r}getBounds(t){return t||(t=new D),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new vr(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let n=t-(this.x+i),r=e-(this.y+i);const s=i*i;if(n*n+r*r<=s)return!0;if(n=t-(this.x+this.width-i),n*n+r*r<=s)return!0;if(r=e-(this.y+this.height-i),n*n+r*r<=s)return!0;if(n=t-(this.x+i),n*n+r*r<=s)return!0}return!1}strokeContains(t,e,i,n=.5){const{x:r,y:s,width:o,height:a,radius:l}=this,h=i*(1-n),c=i-h,u=r+l,d=s+l,p=r+o,f=s+a;return(t>=r-h&&t<=r+c||t>=p-c&&t<=p+h)&&e>=d&&e<=d+(a-2*l)||((e>=s-h&&e<=s+c||e>=f-c&&e<=f+h)&&t>=u&&t<=u+(o-2*l)||(t<u&&e<d&&br(t,e,u,d,l,c,h)||t>p-l&&e<d&&br(t,e,p-l,d,l,c,h)||t>p-l&&e>f-l&&br(t,e,p-l,f-l,l,c,h)||t<u&&e>f-l&&br(t,e,u,f-l,l,c,h)))}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const wr={};function Sr(t,e,i){let n=2166136261;for(let r=0;r<e;r++)n^=t[r].uid,n=Math.imul(n,16777619),n>>>=0;return wr[n]||function(t,e,i,n){const r={};let s=0;for(let a=0;a<n;a++){const i=a<e?t[a]:J.EMPTY.source;r[s++]=i.source,r[s++]=i.style}const o=new Qi(r);return wr[i]=o,o}(t,e,n,i)}class Ar{constructor(t){"number"==typeof t?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this.uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}function Tr(t,e){const i=t.byteLength/8|0,n=new Float64Array(t,0,i);new Float64Array(e,0,i).set(n);const r=t.byteLength-8*i;if(r>0){const n=new Uint8Array(t,8*i,r);new Uint8Array(e,8*i,r).set(n)}}const Cr={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Pr=(t=>(t[t.DISABLED=0]="DISABLED",t[t.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",t[t.MASK_ACTIVE=2]="MASK_ACTIVE",t[t.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",t[t.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",t[t.NONE=5]="NONE",t))(Pr||{});function Mr(t,e){return"no-premultiply-alpha"===e.alphaMode&&Cr[t]||t}const Er=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join("\n");function Rr(t){let e="";for(let i=0;i<t;++i)i>0&&(e+="\nelse "),i<t-1&&(e+=`if(test == ${i}.0){}`);return e}function Br(t,e){if(0===t)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const i=e.createShader(e.FRAGMENT_SHADER);try{for(;;){const n=Er.replace(/%forloop%/gi,Rr(t));if(e.shaderSource(i,n),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS))break;t=t/2|0}}finally{e.deleteShader(i)}return t}let Fr=null;class kr{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}class Ir{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new kr,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const Dr=[];let Or=0;function Ur(){return Or>0?Dr[--Or]:new Ir}function Gr(t){Dr[Or++]=t}let Lr=0;const zr=class t{constructor(e){this.uid=U("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],(e=__spreadValues(__spreadValues({},t.defaultOptions),e)).maxTextures||(z("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),e.maxTextures=function(){var t;if(Fr)return Fr;const e=Fi();return Fr=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),Fr=Br(Fr,e),null==(t=e.getExtension("WEBGL_lose_context"))||t.loseContext(),Fr}());const{maxTextures:i,attributesInitialSize:n,indicesInitialSize:r}=e;this.attributeBuffer=new Ar(4*n),this.indexBuffer=new Uint16Array(r),this.maxTextures=i}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)Gr(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const i=t._batch.textures.ids[e._source.uid];return!(!i&&0!==i)&&(t._textureId=i,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let i=Ur(),n=i.textures;n.clear();const r=e[this.elementStart];let s=Mr(r.blendMode,r.texture._source),o=r.topology;4*this.attributeSize>this.attributeBuffer.size&&this._resizeAttributeBuffer(4*this.attributeSize),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const a=this.attributeBuffer.float32View,l=this.attributeBuffer.uint32View,h=this.indexBuffer;let c=this._batchIndexSize,u=this._batchIndexStart,d="startBatch";const p=this.maxTextures;for(let f=this.elementStart;f<this.elementSize;++f){const r=e[f];e[f]=null;const g=r.texture._source,m=Mr(r.blendMode,g),_=s!==m||o!==r.topology;g._batchTick!==Lr||_?(g._batchTick=Lr,(n.count>=p||_)&&(this._finishBatch(i,u,c-u,n,s,o,t,d),d="renderBatch",u=c,s=m,o=r.topology,i=Ur(),n=i.textures,n.clear(),++Lr),r._textureId=g._textureBindLocation=n.count,n.ids[g.uid]=n.count,n.textures[n.count++]=g,r._batch=i,c+=r.indexSize,r.packAsQuad?(this.packQuadAttributes(r,a,l,r._attributeStart,r._textureId),this.packQuadIndex(h,r._indexStart,r._attributeStart/this.vertexSize)):(this.packAttributes(r,a,l,r._attributeStart,r._textureId),this.packIndex(r,h,r._indexStart,r._attributeStart/this.vertexSize))):(r._textureId=g._textureBindLocation,c+=r.indexSize,r.packAsQuad?(this.packQuadAttributes(r,a,l,r._attributeStart,r._textureId),this.packQuadIndex(h,r._indexStart,r._attributeStart/this.vertexSize)):(this.packAttributes(r,a,l,r._attributeStart,r._textureId),this.packIndex(r,h,r._indexStart,r._attributeStart/this.vertexSize)),r._batch=i)}n.count>0&&(this._finishBatch(i,u,c-u,n,s,o,t,d),u=c,++Lr),this.elementStart=this.elementSize,this._batchIndexStart=u,this._batchIndexSize=c}_finishBatch(t,e,i,n,r,s,o,a){t.gpuBindGroup=null,t.bindGroup=null,t.action=a,t.batcher=this,t.textures=n,t.blendMode=r,t.topology=s,t.start=e,t.size=i,++Lr,this.batches[this.batchIndex++]=t,o.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){4*t<=this.attributeBuffer.size||this._resizeAttributeBuffer(4*t)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,2*this.attributeBuffer.size),i=new Ar(e);Tr(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,1.5*e.length);i+=i%2;const n=i>65535?new Uint32Array(i):new Uint16Array(i);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let r=0;r<e.length;r++)n[r]=e[r];else Tr(e.buffer,n.buffer);this.indexBuffer=n}packQuadIndex(t,e,i){t[e]=i+0,t[e+1]=i+1,t[e+2]=i+2,t[e+3]=i+0,t[e+4]=i+2,t[e+5]=i+3}packIndex(t,e,i,n){const r=t.indices,s=t.indexSize,o=t.indexOffset,a=t.attributeOffset;for(let l=0;l<s;l++)e[i++]=n+r[l+o]-a}destroy(){for(let t=0;t<this.batches.length;t++)Gr(this.batches[t]);this.batches=null;for(let t=0;t<this._elements.length;t++)this._elements[t]._batch=null;this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}};zr.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Nr=zr;var Vr=(t=>(t[t.MAP_READ=1]="MAP_READ",t[t.MAP_WRITE=2]="MAP_WRITE",t[t.COPY_SRC=4]="COPY_SRC",t[t.COPY_DST=8]="COPY_DST",t[t.INDEX=16]="INDEX",t[t.VERTEX=32]="VERTEX",t[t.UNIFORM=64]="UNIFORM",t[t.STORAGE=128]="STORAGE",t[t.INDIRECT=256]="INDIRECT",t[t.QUERY_RESOLVE=512]="QUERY_RESOLVE",t[t.STATIC=1024]="STATIC",t))(Vr||{});let Hr=class extends _{constructor(t){let{data:e,size:i}=t;const{usage:n,label:r,shrinkToFit:s}=t;super(),this.uid=U("buffer"),this._resourceType="buffer",this._resourceId=U("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,null!=i||(i=null==e?void 0:e.byteLength);const o=!!e;this.descriptor={size:i,usage:n,mappedAtCreation:o,label:r},this.shrinkToFit=null==s||s}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&Vr.STATIC)}set static(t){t?this.descriptor.usage|=Vr.STATIC:this.descriptor.usage&=~Vr.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t)return void(i&&this.emit("update",this));const n=this._data;this._data=t,this._dataInt32=null,n&&n.length===t.length||!this.shrinkToFit&&n&&t.byteLength<n.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=U("resource"),this.emit("change",this))}update(t){this._updateSize=null!=t?t:this._updateSize,this._updateID++,this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}};function Wr(t,e){if(!(t instanceof Hr)){let i=e?Vr.INDEX:Vr.VERTEX;t instanceof Array&&(e?(t=new Uint32Array(t),i=Vr.INDEX|Vr.COPY_DST):(t=new Float32Array(t),i=Vr.VERTEX|Vr.COPY_DST)),t=new Hr({data:t,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:i})}return t}class jr extends _{constructor(t={}){var e;super(),this.uid=U("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new it,this._boundsDirty=!0;const{attributes:i,indexBuffer:n,topology:r}=t;if(this.buffers=[],this.attributes={},i)for(const s in i)this.addAttribute(s,i[s]);this.instanceCount=null!=(e=t.instanceCount)?e:1,n&&this.addIndex(n),this.topology=r||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){const i=function(t){return(t instanceof Hr||Array.isArray(t)||t.BYTES_PER_ELEMENT)&&(t={buffer:t}),t.buffer=Wr(t.buffer,!1),t}(e);-1===this.buffers.indexOf(i.buffer)&&(this.buffers.push(i.buffer),i.buffer.on("update",this.onBufferUpdate,this),i.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=i}addIndex(t){this.indexBuffer=Wr(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,function(t,e,i){const n=t.getAttribute(e);if(!n)return i.minX=0,i.minY=0,i.maxX=0,i.maxY=0,i;const r=n.buffer.data;let s=1/0,o=1/0,a=-1/0,l=-1/0;const h=r.BYTES_PER_ELEMENT,c=(n.offset||0)/h,u=(n.stride||8)/h;for(let d=c;d<r.length;d+=u){const t=r[d],e=r[d+1];t>a&&(a=t),e>l&&(l=e),t<s&&(s=t),e<o&&(o=e)}return i.minX=s,i.minY=o,i.maxX=a,i.maxY=l,i}(this,"aPosition",this._bounds)):this._bounds}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(t=>t.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Yr=new Float32Array(1),Xr=new Uint32Array(1);class Zr extends jr{constructor(){const t=new Hr({data:Yr,label:"attribute-batch-buffer",usage:Vr.VERTEX|Vr.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:24,offset:0},aUV:{buffer:t,format:"float32x2",stride:24,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:24,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:24,offset:20}},indexBuffer:new Hr({data:Xr,label:"index-batch-buffer",usage:Vr.INDEX|Vr.COPY_DST,shrinkToFit:!1})})}}function qr(t,e,i){if(t)for(const n in t){const r=e[n.toLocaleLowerCase()];if(r){let e=t[n];"header"===n&&(e=e.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),i&&r.push(`//----${i}----//`),r.push(e)}else kt(`${n} placement hook does not exist in shader`)}}const $r=/\{\{(.*?)\}\}/g;function Kr(t){var e,i;const n={};return(null!=(i=null==(e=t.match($r))?void 0:e.map(t=>t.replace(/[{()}]/g,"")))?i:[]).forEach(t=>{n[t]=[]}),n}function Qr(t,e){let i;const n=/@in\s+([^;]+);/g;for(;null!==(i=n.exec(t));)e.push(i[1])}function Jr(t,e,i=!1){const n=[];Qr(e,n),t.forEach(t=>{t.header&&Qr(t.header,n)});const r=n;i&&r.sort();const s=r.map((t,e)=>` @location(${e}) ${t},`).join("\n");let o=e.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`\n${s}\n`),o}function ts(t,e){let i;const n=/@out\s+([^;]+);/g;for(;null!==(i=n.exec(t));)e.push(i[1])}function es(t,e){let i=t;for(const n in e){const t=e[n];i=t.join("\n").length?i.replace(`{{${n}}}`,`//-----${n} START-----//\n${t.join("\n")}\n//----${n} FINISH----//`):i.replace(`{{${n}}}`,"")}return i}const is=Object.create(null),ns=new Map;let rs=0;function ss({template:t,bits:e}){const i=os(t,e);if(is[i])return is[i];const{vertex:n,fragment:r}=function(t,e){const i=e.map(t=>t.vertex).filter(t=>!!t),n=e.map(t=>t.fragment).filter(t=>!!t);let r=Jr(i,t.vertex,!0);r=function(t,e){const i=[];ts(e,i),t.forEach(t=>{t.header&&ts(t.header,i)});let n=0;const r=i.sort().map(t=>t.indexOf("builtin")>-1?t:`@location(${n++}) ${t}`).join(",\n"),s=i.sort().map(t=>{return` var ${e=t,e.replace(/@.*?\s+/g,"")};`;var e}).join("\n"),o=`return VSOutput(\n ${i.sort().map(t=>` ${function(t){const e=/\b(\w+)\s*:/g.exec(t);return e?e[1]:""}(t)}`).join(",\n")});`;let a=e.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`\n${r}\n`),a=a.replace("{{start}}",`\n${s}\n`),a=a.replace("{{return}}",`\n${o}\n`),a}(i,r);const s=Jr(n,t.fragment,!0);return{vertex:r,fragment:s}}(t,e);return is[i]=as(n,r,e),is[i]}function os(t,e){return e.map(t=>(ns.has(t)||ns.set(t,rs++),ns.get(t))).sort((t,e)=>t-e).join("-")+t.vertex+t.fragment}function as(t,e,i){const n=Kr(t),r=Kr(e);return i.forEach(t=>{qr(t.vertex,n,t.name),qr(t.fragment,r,t.name)}),{vertex:es(t,n),fragment:es(e,r)}}const ls={name:"global-uniforms-bit",vertex:{header:"\n struct GlobalUniforms {\n uProjectionMatrix:mat3x3<f32>,\n uWorldTransformMatrix:mat3x3<f32>,\n uWorldColorAlpha: vec4<f32>,\n uResolution: vec2<f32>,\n }\n\n @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;\n "}},hs={name:"global-uniforms-bit",vertex:{header:"\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform vec4 uWorldColorAlpha;\n uniform vec2 uResolution;\n "}};function cs({bits:t,name:e}){const i=ss({template:{fragment:"\n @in vUV : vec2<f32>;\n @in vColor : vec4<f32>;\n\n {{header}}\n\n @fragment\n fn main(\n {{in}}\n ) -> @location(0) vec4<f32> {\n\n {{start}}\n\n var outColor:vec4<f32>;\n\n {{main}}\n\n var finalColor:vec4<f32> = outColor * vColor;\n\n {{end}}\n\n return finalColor;\n };\n",vertex:"\n @in aPosition: vec2<f32>;\n @in aUV: vec2<f32>;\n\n @out @builtin(position) vPosition: vec4<f32>;\n @out vUV : vec2<f32>;\n @out vColor : vec4<f32>;\n\n {{header}}\n\n struct VSOutput {\n {{struct}}\n };\n\n @vertex\n fn main( {{in}} ) -> VSOutput {\n\n var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;\n var modelMatrix = mat3x3<f32>(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n );\n var position = aPosition;\n var uv = aUV;\n\n {{start}}\n\n vColor = vec4<f32>(1., 1., 1., 1.);\n\n {{main}}\n\n vUV = uv;\n\n var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;\n\n vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);\n\n vColor *= globalUniforms.uWorldColorAlpha;\n\n {{end}}\n\n {{return}}\n };\n"},bits:[ls,...t]});return Yi.from({name:e,vertex:{source:i.vertex,entryPoint:"main"},fragment:{source:i.fragment,entryPoint:"main"}})}function us({bits:t,name:e}){return new Li(__spreadValues({name:e},function({template:t,bits:e}){const i=os(t,e);return is[i]||(is[i]=as(t.vertex,t.fragment,e)),is[i]}({template:{vertex:"\n in vec2 aPosition;\n in vec2 aUV;\n\n out vec4 vColor;\n out vec2 vUV;\n\n {{header}}\n\n void main(void){\n\n mat3 worldTransformMatrix = uWorldTransformMatrix;\n mat3 modelMatrix = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n );\n vec2 position = aPosition;\n vec2 uv = aUV;\n\n {{start}}\n\n vColor = vec4(1.);\n\n {{main}}\n\n vUV = uv;\n\n mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;\n\n gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n\n vColor *= uWorldColorAlpha;\n\n {{end}}\n }\n",fragment:"\n\n in vec4 vColor;\n in vec2 vUV;\n\n out vec4 finalColor;\n\n {{header}}\n\n void main(void) {\n\n {{start}}\n\n vec4 outColor;\n\n {{main}}\n\n finalColor = outColor * vColor;\n\n {{end}}\n }\n"},bits:[hs,...t]})))}const ds={name:"color-bit",vertex:{header:"\n @in aColor: vec4<f32>;\n ",main:"\n vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);\n "}},ps={name:"color-bit",vertex:{header:"\n in vec4 aColor;\n ",main:"\n vColor *= vec4(aColor.rgb * aColor.a, aColor.a);\n "}},fs={};function gs(t){const e=[];if(1===t)e.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),e.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let i=0;for(let n=0;n<t;n++)e.push(`@group(1) @binding(${i++}) var textureSource${n+1}: texture_2d<f32>;`),e.push(`@group(1) @binding(${i++}) var textureSampler${n+1}: sampler;`)}return e.join("\n")}function ms(t){const e=[];if(1===t)e.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{e.push("switch vTextureId {");for(let i=0;i<t;i++)i===t-1?e.push(" default:{"):e.push(` case ${i}:{`),e.push(` outColor = textureSampleGrad(textureSource${i+1}, textureSampler${i+1}, vUV, uvDx, uvDy);`),e.push(" break;}");e.push("}")}return e.join("\n")}function _s(t){return fs[t]||(fs[t]={name:"texture-batch-bit",vertex:{header:"\n @in aTextureIdAndRound: vec2<u32>;\n @out @interpolate(flat) vTextureId : u32;\n ",main:"\n vTextureId = aTextureIdAndRound.y;\n ",end:"\n if(aTextureIdAndRound.x == 1)\n {\n vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "},fragment:{header:`\n @in @interpolate(flat) vTextureId: u32;\n\n ${gs(t)}\n `,main:`\n var uvDx = dpdx(vUV);\n var uvDy = dpdy(vUV);\n\n ${ms(t)}\n `}}),fs[t]}const ys={};function xs(t){const e=[];for(let i=0;i<t;i++)i>0&&e.push("else"),i<t-1&&e.push(`if(vTextureId < ${i}.5)`),e.push("{"),e.push(`\toutColor = texture(uTextures[${i}], vUV);`),e.push("}");return e.join("\n")}function bs(t){return ys[t]||(ys[t]={name:"texture-batch-bit",vertex:{header:"\n in vec2 aTextureIdAndRound;\n out float vTextureId;\n\n ",main:"\n vTextureId = aTextureIdAndRound.y;\n ",end:"\n if(aTextureIdAndRound.x == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "},fragment:{header:`\n in float vTextureId;\n\n uniform sampler2D uTextures[${t}];\n\n `,main:`\n\n ${xs(t)}\n `}}),ys[t]}const vs={name:"round-pixels-bit",vertex:{header:"\n fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>\n {\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n }\n "}},ws={name:"round-pixels-bit",vertex:{header:"\n vec2 roundPixels(vec2 position, vec2 targetSize)\n {\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n }\n "}},Ss={};function As(t){let e=Ss[t];if(e)return e;const i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=n;return e=Ss[t]=new Ki({uTextures:{value:i,type:"i32",size:t}},{isStatic:!0}),e}class Ts extends tn{constructor(t){super({glProgram:us({name:"batch",bits:[ps,bs(t),ws]}),gpuProgram:cs({name:"batch",bits:[ds,_s(t),vs]}),resources:{batchSamplers:As(t)}})}}let Cs=null;const Ps=class t extends Nr{constructor(e){super(e),this.geometry=new Zr,this.name=t.extension.name,this.vertexSize=6,null!=Cs||(Cs=new Ts(e.maxTextures)),this.shader=Cs}packAttributes(t,e,i,n,r){const s=r<<16|65535&t.roundPixels,o=t.transform,a=o.a,l=o.b,h=o.c,c=o.d,u=o.tx,d=o.ty,{positions:p,uvs:f}=t,g=t.color,m=t.attributeOffset,_=m+t.attributeSize;for(let y=m;y<_;y++){const t=2*y,r=p[t],o=p[t+1];e[n++]=a*r+h*o+u,e[n++]=c*o+l*r+d,e[n++]=f[t],e[n++]=f[t+1],i[n++]=g,i[n++]=s}}packQuadAttributes(t,e,i,n,r){const s=t.texture,o=t.transform,a=o.a,l=o.b,h=o.c,c=o.d,u=o.tx,d=o.ty,p=t.bounds,f=p.maxX,g=p.minX,m=p.maxY,_=p.minY,y=s.uvs,x=t.color,b=r<<16|65535&t.roundPixels;e[n+0]=a*g+h*_+u,e[n+1]=c*_+l*g+d,e[n+2]=y.x0,e[n+3]=y.y0,i[n+4]=x,i[n+5]=b,e[n+6]=a*f+h*_+u,e[n+7]=c*_+l*f+d,e[n+8]=y.x1,e[n+9]=y.y1,i[n+10]=x,i[n+11]=b,e[n+12]=a*f+h*m+u,e[n+13]=c*m+l*f+d,e[n+14]=y.x2,e[n+15]=y.y2,i[n+16]=x,i[n+17]=b,e[n+18]=a*g+h*m+u,e[n+19]=c*m+l*g+d,e[n+20]=y.x3,e[n+21]=y.y3,i[n+22]=x,i[n+23]=b}};Ps.extension={type:[o.Batcher],name:"default"};let Ms=Ps;function Es(t,e,i,n,r){const s=e.a,o=e.b,a=e.c,l=e.d,h=e.tx,c=e.ty;i||(i=0),n||(n=2),r||(r=t.length/n-i);let u=i*n;for(let d=0;d<r;d++){const e=t[u],i=t[u+1];t[u]=s*e+a*i+h,t[u+1]=o*e+l*i+c,u+=n}}const Rs=new S;class Bs{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|65280&t|(255&t)<<16,i=this.renderable;return i?Kt(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(255*this.alpha<<24)}get transform(){var t;return(null==(t=this.renderable)?void 0:t.groupTransform)||Rs}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}}const Fs={extension:{type:o.ShapeBuilder,name:"circle"},build(t,e){let i,n,r,s,o,a;if("circle"===t.type){const e=t;if(o=a=e.radius,o<=0)return!1;i=e.x,n=e.y,r=s=0}else if("ellipse"===t.type){const e=t;if(o=e.halfWidth,a=e.halfHeight,o<=0||a<=0)return!1;i=e.x,n=e.y,r=s=0}else{const e=t,l=e.width/2,h=e.height/2;i=e.x+l,n=e.y+h,o=a=Math.max(0,Math.min(e.radius,Math.min(l,h))),r=l-o,s=h-a}if(r<0||s<0)return!1;const l=Math.ceil(2.3*Math.sqrt(o+a)),h=8*l+(r?4:0)+(s?4:0);if(0===h)return!1;if(0===l)return e[0]=e[6]=i+r,e[1]=e[3]=n+s,e[2]=e[4]=i-r,e[5]=e[7]=n-s,!0;let c=0,u=4*l+(r?2:0)+2,d=u,p=h,f=r+o,g=s,m=i+f,_=i-f,y=n+g;if(e[c++]=m,e[c++]=y,e[--u]=y,e[--u]=_,s){const t=n-g;e[d++]=_,e[d++]=t,e[--p]=t,e[--p]=m}for(let b=1;b<l;b++){const t=Math.PI/2*(b/l),h=r+Math.cos(t)*o,f=s+Math.sin(t)*a,g=i+h,m=i-h,_=n+f,y=n-f;e[c++]=g,e[c++]=_,e[--u]=_,e[--u]=m,e[d++]=m,e[d++]=y,e[--p]=y,e[--p]=g}f=r,g=s+a,m=i+f,_=i-f,y=n+g;const x=n-g;return e[c++]=m,e[c++]=y,e[--p]=x,e[--p]=m,r&&(e[c++]=_,e[c++]=y,e[--p]=x,e[--p]=_),!0},triangulate(t,e,i,n,r,s){if(0===t.length)return;let o=0,a=0;for(let c=0;c<t.length;c+=2)o+=t[c],a+=t[c+1];o/=t.length/2,a/=t.length/2;let l=n;e[l*i]=o,e[l*i+1]=a;const h=l++;for(let c=0;c<t.length;c+=2)e[l*i]=t[c],e[l*i+1]=t[c+1],c>0&&(r[s++]=l,r[s++]=h,r[s++]=l-1),l++;r[s++]=h+1,r[s++]=h,r[s++]=l-1}},ks=__spreadProps(__spreadValues({},Fs),{extension:__spreadProps(__spreadValues({},Fs.extension),{name:"ellipse"})}),Is=__spreadProps(__spreadValues({},Fs),{extension:__spreadProps(__spreadValues({},Fs.extension),{name:"roundedRectangle"})}),Ds=1e-4;function Os(t,e,i,n,r,s,o,a){let l,h;o?(l=n,h=-i):(l=-n,h=i);const c=t-i*r+l,u=e-n*r+h,d=t+i*s+l,p=e+n*s+h;return a.push(c,u),a.push(d,p),2}function Us(t,e,i,n,r,s,o,a){const l=i-t,h=n-e;let c=Math.atan2(l,h),u=Math.atan2(r-t,s-e);a&&c<u?c+=2*Math.PI:!a&&c>u&&(u+=2*Math.PI);let d=c;const p=u-c,f=Math.abs(p),g=Math.sqrt(l*l+h*h),m=1+(15*f*Math.sqrt(g)/Math.PI|0),_=p/m;if(d+=_,a){o.push(t,e),o.push(i,n);for(let i=1,n=d;i<m;i++,n+=_)o.push(t,e),o.push(t+Math.sin(n)*g,e+Math.cos(n)*g);o.push(t,e),o.push(r,s)}else{o.push(i,n),o.push(t,e);for(let i=1,n=d;i<m;i++,n+=_)o.push(t+Math.sin(n)*g,e+Math.cos(n)*g),o.push(t,e);o.push(r,s),o.push(t,e)}return 2*m}function Gs(t,e,i,n,r,s,o){const a=On(t,e,2);if(!a)return;for(let h=0;h<a.length;h+=3)s[o++]=a[h]+r,s[o++]=a[h+1]+r,s[o++]=a[h+2]+r;let l=r*n;for(let h=0;h<t.length;h+=2)i[l]=t[h],i[l+1]=t[h+1],l+=n}const Ls=[],zs={extension:{type:o.ShapeBuilder,name:"polygon"},build(t,e){for(let i=0;i<t.points.length;i++)e[i]=t.points[i];return!0},triangulate(t,e,i,n,r,s){Gs(t,Ls,e,i,n,r,s)}},Ns={extension:{type:o.ShapeBuilder,name:"rectangle"},build(t,e){const i=t,n=i.x,r=i.y,s=i.width,o=i.height;return s>0&&o>0&&(e[0]=n,e[1]=r,e[2]=n+s,e[3]=r,e[4]=n+s,e[5]=r+o,e[6]=n,e[7]=r+o,!0)},triangulate(t,e,i,n,r,s){let o=0;e[(n*=i)+o]=t[0],e[n+o+1]=t[1],o+=i,e[n+o]=t[2],e[n+o+1]=t[3],o+=i,e[n+o]=t[6],e[n+o+1]=t[7],o+=i,e[n+o]=t[4],e[n+o+1]=t[5],o+=i;const a=n/i;r[s++]=a,r[s++]=a+1,r[s++]=a+2,r[s++]=a+1,r[s++]=a+3,r[s++]=a+2}},Vs={extension:{type:o.ShapeBuilder,name:"triangle"},build:(t,e)=>(e[0]=t.x,e[1]=t.y,e[2]=t.x2,e[3]=t.y2,e[4]=t.x3,e[5]=t.y3,!0),triangulate(t,e,i,n,r,s){let o=0;e[(n*=i)+o]=t[0],e[n+o+1]=t[1],o+=i,e[n+o]=t[2],e[n+o+1]=t[3],o+=i,e[n+o]=t[4],e[n+o+1]=t[5];const a=n/i;r[s++]=a,r[s++]=a+1,r[s++]=a+2}},Hs=new S,Ws=new D;const js={};h.handleByMap(o.ShapeBuilder,js),h.add(Ns,zs,Vs,Fs,ks,Is);const Ys=new D,Xs=new S;function Zs(t,e,i){const n=[],r=js.rectangle,s=Ys;s.x=t.dx,s.y=t.dy,s.width=t.dw,s.height=t.dh;const o=t.transform;if(!r.build(s,n))return;const{vertices:a,uvs:l,indices:h}=i,c=h.length,u=a.length/2;o&&Es(n,o),r.triangulate(n,a,2,u,h,c);const d=t.image,p=d.uvs;l.push(p.x0,p.y0,p.x1,p.y1,p.x3,p.y3,p.x2,p.y2);const f=Dt.get(Bs);f.indexOffset=c,f.indexSize=h.length-c,f.attributeOffset=u,f.attributeSize=a.length/2-u,f.baseColor=t.style,f.alpha=t.alpha,f.texture=d,f.geometryData=i,e.push(f)}function qs(t,e,i,n,r){const{vertices:s,uvs:o,indices:a}=r;t.shapePrimitives.forEach(({shape:t,transform:l,holes:h})=>{var c;const u=[],d=js[t.type];if(!d.build(t,u))return;const p=a.length,f=s.length/2;let g="triangle-list";if(l&&Es(u,l),i){const i=null==(c=t.closePath)||c,n=e;n.pixelLine?(!function(t,e,i,n){const r=Ds;if(0===t.length)return;const s=t[0],o=t[1],a=t[t.length-2],l=t[t.length-1],h=e||Math.abs(s-a)<r&&Math.abs(o-l)<r,c=i,u=t.length/2,d=c.length/2;for(let p=0;p<u;p++)c.push(t[2*p]),c.push(t[2*p+1]);for(let p=0;p<u-1;p++)n.push(d+p,d+p+1);h&&n.push(d+u-1,d)}(u,i,s,a),g="line-list"):function(t,e,i,n,r,s){const o=Ds;if(0===t.length)return;const a=e;let l=a.alignment;if(.5!==e.alignment){let e=function(t){const e=t.length;if(e<6)return 1;let i=0;for(let n=0,r=t[e-2],s=t[e-1];n<e;n+=2){const e=t[n],o=t[n+1];i+=(e-r)*(o+s),r=e,s=o}return i<0?-1:1}(t);l=(l-.5)*e+.5}const h=new v(t[0],t[1]),c=new v(t[t.length-2],t[t.length-1]),u=n,d=Math.abs(h.x-c.x)<o&&Math.abs(h.y-c.y)<o;if(u){t=t.slice(),d&&(t.pop(),t.pop(),c.set(t[t.length-2],t[t.length-1]));const e=.5*(h.x+c.x),i=.5*(c.y+h.y);t.unshift(e,i),t.push(e,i)}const p=r,f=t.length/2;let g=t.length;const m=p.length/2,_=a.width/2,y=_*_,x=a.miterLimit*a.miterLimit;let b=t[0],w=t[1],S=t[2],A=t[3],T=0,C=0,P=-(w-A),M=b-S,E=0,R=0,B=Math.sqrt(P*P+M*M);P/=B,M/=B,P*=_,M*=_;const F=2*(1-l),k=2*l;u||("round"===a.cap?g+=Us(b-P*(F-k)*.5,w-M*(F-k)*.5,b-P*F,w-M*F,b+P*k,w+M*k,p,!0)+2:"square"===a.cap&&(g+=Os(b,w,P,M,F,k,!0,p))),p.push(b-P*F,w-M*F),p.push(b+P*k,w+M*k);for(let v=1;v<f-1;++v){b=t[2*(v-1)],w=t[2*(v-1)+1],S=t[2*v],A=t[2*v+1],T=t[2*(v+1)],C=t[2*(v+1)+1],P=-(w-A),M=b-S,B=Math.sqrt(P*P+M*M),P/=B,M/=B,P*=_,M*=_,E=-(A-C),R=S-T,B=Math.sqrt(E*E+R*R),E/=B,R/=B,E*=_,R*=_;const e=S-b,i=w-A,n=S-T,r=C-A,s=e*n+i*r,o=i*n-r*e,l=o<0;if(Math.abs(o)<.001*Math.abs(s)){p.push(S-P*F,A-M*F),p.push(S+P*k,A+M*k),s>=0&&("round"===a.join?g+=Us(S,A,S-P*F,A-M*F,S-E*F,A-R*F,p,!1)+4:g+=2,p.push(S-E*k,A-R*k),p.push(S+E*F,A+R*F));continue}const h=(-P+b)*(-M+A)-(-P+S)*(-M+w),c=(-E+T)*(-R+A)-(-E+S)*(-R+C),u=(e*c-n*h)/o,d=(r*h-i*c)/o,f=(u-S)*(u-S)+(d-A)*(d-A),m=S+(u-S)*F,I=A+(d-A)*F,D=S-(u-S)*k,O=A-(d-A)*k,U=l?F:k;f<=Math.min(e*e+i*i,n*n+r*r)+U*U*y?"bevel"===a.join||f/y>x?(l?(p.push(m,I),p.push(S+P*k,A+M*k),p.push(m,I),p.push(S+E*k,A+R*k)):(p.push(S-P*F,A-M*F),p.push(D,O),p.push(S-E*F,A-R*F),p.push(D,O)),g+=2):"round"===a.join?l?(p.push(m,I),p.push(S+P*k,A+M*k),g+=Us(S,A,S+P*k,A+M*k,S+E*k,A+R*k,p,!0)+4,p.push(m,I),p.push(S+E*k,A+R*k)):(p.push(S-P*F,A-M*F),p.push(D,O),g+=Us(S,A,S-P*F,A-M*F,S-E*F,A-R*F,p,!1)+4,p.push(S-E*F,A-R*F),p.push(D,O)):(p.push(m,I),p.push(D,O)):(p.push(S-P*F,A-M*F),p.push(S+P*k,A+M*k),"round"===a.join?g+=l?Us(S,A,S+P*k,A+M*k,S+E*k,A+R*k,p,!0)+2:Us(S,A,S-P*F,A-M*F,S-E*F,A-R*F,p,!1)+2:"miter"===a.join&&f/y<=x&&(l?(p.push(D,O),p.push(D,O)):(p.push(m,I),p.push(m,I)),g+=2),p.push(S-E*F,A-R*F),p.push(S+E*k,A+R*k),g+=2)}b=t[2*(f-2)],w=t[2*(f-2)+1],S=t[2*(f-1)],A=t[2*(f-1)+1],P=-(w-A),M=b-S,B=Math.sqrt(P*P+M*M),P/=B,M/=B,P*=_,M*=_,p.push(S-P*F,A-M*F),p.push(S+P*k,A+M*k),u||("round"===a.cap?g+=Us(S-P*(F-k)*.5,A-M*(F-k)*.5,S-P*F,A-M*F,S+P*k,A+M*k,p,!1)+2:"square"===a.cap&&(g+=Os(S,A,P,M,F,k,!1,p)));for(let v=m;v<g+m-2;++v)b=p[2*v],w=p[2*v+1],S=p[2*(v+1)],A=p[2*(v+1)+1],T=p[2*(v+2)],C=p[2*(v+2)+1],Math.abs(b*(A-C)+S*(C-w)+T*(w-A))<1e-8||s.push(v,v+1,v+2)}(u,n,0,i,s,a)}else if(h){const t=[],e=u.slice();(function(t){const e=[];for(let i=0;i<t.length;i++){const n=t[i].shape,r=[];js[n.type].build(n,r)&&e.push(r)}return e})(h).forEach(i=>{t.push(e.length/2),e.push(...i)}),Gs(e,t,s,2,f,a,p)}else d.triangulate(u,s,2,f,a,p);const m=o.length/2,_=e.texture;if(_!==J.WHITE){const i=function(t,e,i,n){const r=e.matrix?t.copyFrom(e.matrix).invert():t.identity();if("local"===e.textureSpace){const t=i.getBounds(Ws);e.width&&t.pad(e.width);const{x:n,y:s}=t,o=1/t.width,a=1/t.height,l=-n*o,h=-s*a,c=r.a,u=r.b,d=r.c,p=r.d;r.a*=o,r.b*=o,r.c*=a,r.d*=a,r.tx=l*c+h*d+r.tx,r.ty=l*u+h*p+r.ty}else r.translate(e.texture.frame.x,e.texture.frame.y),r.scale(1/e.texture.source.width,1/e.texture.source.height);const s=e.texture.source.style;return e.fill instanceof lr||"clamp-to-edge"!==s.addressMode||(s.addressMode="repeat",s.update()),n&&r.append(Hs.copyFrom(n).invert()),r}(Xs,e,t,l);!function(t,e,i,n,r,s,o,a=null){let l=0;i*=e,r*=s;const h=a.a,c=a.b,u=a.c,d=a.d,p=a.tx,f=a.ty;for(;l<o;){const o=t[i],a=t[i+1];n[r]=h*o+u*a+p,n[r+1]=c*o+d*a+f,r+=s,i+=e,l++}}(s,2,f,o,m,2,s.length/2-f,i)}else!function(t,e,i,n){let r=0;for(e*=i;r<n;)t[e]=0,t[e+1]=0,e+=i,r++}(o,m,2,s.length/2-f);const y=Dt.get(Bs);y.indexOffset=p,y.indexSize=a.length-p,y.attributeOffset=f,y.attributeSize=s.length/2-f,y.baseColor=e.color,y.alpha=e.alpha,y.texture=_,y.geometryData=r,y.topology=g,n.push(y)})}class $s{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class Ks{constructor(){this.instructions=new ue}init(t){this.batcher=new Ms({maxTextures:t}),this.instructions.reset()}get geometry(){return z("8.3.4","GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}}const Qs=class t{constructor(t){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null),this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuContextHash"),t.renderableGC.addManagedHash(this,"_graphicsDataContextHash")}init(e){var i;t.defaultOptions.bezierSmoothness=null!=(i=null==e?void 0:e.bezierSmoothness)?i:t.defaultOptions.bezierSmoothness}getContextRenderData(t){return this._graphicsDataContextHash[t.uid]||this._initContextRenderData(t)}updateGpuContext(t){let e=this._gpuContextHash[t.uid]||this._initContext(t);if(t.dirty){e?this._cleanGraphicsContextData(t):e=this._initContext(t),function(t,e){const{geometryData:i,batches:n}=e;n.length=0,i.indices.length=0,i.vertices.length=0,i.uvs.length=0;for(let r=0;r<t.instructions.length;r++){const e=t.instructions[r];if("texture"===e.action)Zs(e.data,n,i);else if("fill"===e.action||"stroke"===e.action){const t="stroke"===e.action,r=e.data.path.shapePath,s=e.data.style,o=e.data.hole;t&&o&&qs(o.shapePath,s,!0,n,i),o&&(r.shapePrimitives[r.shapePrimitives.length-1].holes=o.shapePath.shapePrimitives),qs(r,s,t,n,i)}}}(t,e);const i=t.batchMode;t.customShader||"no-batch"===i?e.isBatchable=!1:e.isBatchable="auto"!==i||e.geometryData.vertices.length<400,t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_initContextRenderData(t){const e=Dt.get(Ks,{maxTextures:this._renderer.limits.maxBatchableTextures}),{batches:i,geometryData:n}=this._gpuContextHash[t.uid],r=n.vertices.length,s=n.indices.length;for(let h=0;h<i.length;h++)i[h].applyTransform=!1;const o=e.batcher;o.ensureAttributeBuffer(r),o.ensureIndexBuffer(s),o.begin();for(let h=0;h<i.length;h++){const t=i[h];o.add(t)}o.finish(e.instructions);const a=o.geometry;a.indexBuffer.setDataWithSize(o.indexBuffer,o.indexSize,!0),a.buffers[0].setDataWithSize(o.attributeBuffer.float32View,o.attributeSize,!0);const l=o.batches;for(let h=0;h<l.length;h++){const t=l[h];t.bindGroup=Sr(t.textures.textures,t.textures.count,this._renderer.limits.maxBatchableTextures)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new $s;return e.context=t,this._gpuContextHash[t.uid]=e,t.on("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]}onGraphicsContextDestroy(t){this._cleanGraphicsContextData(t),t.off("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]=null}_cleanGraphicsContextData(t){const e=this._gpuContextHash[t.uid];e.isBatchable||this._graphicsDataContextHash[t.uid]&&(Dt.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(t=>{Dt.return(t)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};Qs.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"graphicsContext"},Qs.defaultOptions={bezierSmoothness:.5};let Js=Qs;const to=1.1920929e-7;function eo(t,e,i,n,r,s,o,a,l,h){let c=(1-Math.min(.99,Math.max(0,null!=h?h:Js.defaultOptions.bezierSmoothness)))/1;return c*=c,function(t,e,i,n,r,s,o,a,l,h){io(t,e,i,n,r,s,o,a,l,h,0),l.push(o,a)}(e,i,n,r,s,o,a,l,t,c),t}function io(t,e,i,n,r,s,o,a,l,h,c){if(c>8)return;const u=(t+i)/2,d=(e+n)/2,p=(i+r)/2,f=(n+s)/2,g=(r+o)/2,m=(s+a)/2,_=(u+p)/2,y=(d+f)/2,x=(p+g)/2,b=(f+m)/2,v=(_+x)/2,w=(y+b)/2;if(c>0){let c=o-t,u=a-e;const d=Math.abs((i-o)*u-(n-a)*c),p=Math.abs((r-o)*u-(s-a)*c);if(d>to&&p>to){if((d+p)*(d+p)<=h*(c*c+u*u))return void l.push(v,w)}else if(d>to){if(d*d<=h*(c*c+u*u))return void l.push(v,w)}else if(p>to){if(p*p<=h*(c*c+u*u))return void l.push(v,w)}else if(c=v-(t+o)/2,u=w-(e+a)/2,c*c+u*u<=h)return void l.push(v,w)}io(t,e,u,d,_,y,v,w,l,h,c+1),io(v,w,x,b,g,m,o,a,l,h,c+1)}function no(t,e,i,n,r,s,o,a){let l=(1-Math.min(.99,Math.max(0,null!=a?a:Js.defaultOptions.bezierSmoothness)))/1;return l*=l,function(t,e,i,n,r,s,o,a){ro(o,t,e,i,n,r,s,a,0),o.push(r,s)}(e,i,n,r,s,o,t,l),t}function ro(t,e,i,n,r,s,o,a,l){if(l>8)return;const h=(e+n)/2,c=(i+r)/2,u=(n+s)/2,d=(r+o)/2,p=(h+u)/2,f=(c+d)/2;let g=s-e,m=o-i;const _=Math.abs((n-s)*m-(r-o)*g);if(_>1.1920929e-7){if(_*_<=a*(g*g+m*m))return void t.push(p,f)}else if(g=p-(e+s)/2,m=f-(i+o)/2,g*g+m*m<=a)return void t.push(p,f);ro(t,e,i,h,c,p,f,a,l+1),ro(t,p,f,u,d,s,o,a,l+1)}function so(t,e,i,n,r,s,o,a){let l=Math.abs(r-s);(!o&&r>s||o&&s>r)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(n,1/3)*(l/Math.PI))));let h=l/(a=Math.max(a,3)),c=r;h*=o?-1:1;for(let u=0;u<a+1;u++){const r=e+Math.cos(c)*n,s=i+Math.sin(c)*n;t.push(r,s),c+=h}}const oo=2*Math.PI,ao={centerX:0,centerY:0,ang1:0,ang2:0},lo=({x:t,y:e},i,n,r,s,o,a,l)=>{const h=r*(t*=i)-s*(e*=n),c=s*t+r*e;return l.x=h+o,l.y=c+a,l};function ho(t,e){const i=-1.5707963267948966===e?-.551915024494:4/3*Math.tan(e/4),n=1.5707963267948966===e?.551915024494:i,r=Math.cos(t),s=Math.sin(t),o=Math.cos(t+e),a=Math.sin(t+e);return[{x:r-s*n,y:s+r*n},{x:o+a*n,y:a-o*n},{x:o,y:a}]}const co=(t,e,i,n)=>{let r=t*i+e*n;return r>1&&(r=1),r<-1&&(r=-1),(t*n-e*i<0?-1:1)*Math.acos(r)};function uo(t,e,i,n,r,s,o,a=0,l=0,h=0){if(0===s||0===o)return;const c=Math.sin(a*oo/360),u=Math.cos(a*oo/360),d=u*(e-n)/2+c*(i-r)/2,p=-c*(e-n)/2+u*(i-r)/2;if(0===d&&0===p)return;s=Math.abs(s),o=Math.abs(o);const f=Math.pow(d,2)/Math.pow(s,2)+Math.pow(p,2)/Math.pow(o,2);f>1&&(s*=Math.sqrt(f),o*=Math.sqrt(f)),((t,e,i,n,r,s,o,a,l,h,c,u,d)=>{const p=Math.pow(r,2),f=Math.pow(s,2),g=Math.pow(c,2),m=Math.pow(u,2);let _=p*f-p*m-f*g;_<0&&(_=0),_/=p*m+f*g,_=Math.sqrt(_)*(o===a?-1:1);const y=_*r/s*u,x=_*-s/r*c,b=h*y-l*x+(t+i)/2,v=l*y+h*x+(e+n)/2,w=(c-y)/r,S=(u-x)/s,A=(-c-y)/r,T=(-u-x)/s,C=co(1,0,w,S);let P=co(w,S,A,T);0===a&&P>0&&(P-=oo),1===a&&P<0&&(P+=oo),d.centerX=b,d.centerY=v,d.ang1=C,d.ang2=P})(e,i,n,r,s,o,l,h,c,u,d,p,ao);let{ang1:g,ang2:m}=ao;const{centerX:_,centerY:y}=ao;let x=Math.abs(m)/(oo/4);Math.abs(1-x)<1e-7&&(x=1);const b=Math.max(Math.ceil(x),1);m/=b;let v=t[t.length-2],w=t[t.length-1];const S={x:0,y:0};for(let A=0;A<b;A++){const e=ho(g,m),{x:i,y:n}=lo(e[0],s,o,u,c,_,y,S),{x:r,y:a}=lo(e[1],s,o,u,c,_,y,S),{x:l,y:h}=lo(e[2],s,o,u,c,_,y,S);eo(t,v,w,i,n,r,a,l,h),v=l,w=h,g+=m}}const po=new D;class fo{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new it,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const i=this._currentPoly.points,n=i[i.length-2],r=i[i.length-1];return n===t&&r===e||i.push(t,e),this}arc(t,e,i,n,r,s){this._ensurePoly(!1);return so(this._currentPoly.points,t,e,i,n,r,s),this}arcTo(t,e,i,n,r){this._ensurePoly();return function(t,e,i,n,r,s){const o=t[t.length-2],a=t[t.length-1]-i,l=o-e,h=r-i,c=n-e,u=Math.abs(a*c-l*h);if(u<1e-8||0===s)return void(t[t.length-2]===e&&t[t.length-1]===i||t.push(e,i));const d=a*a+l*l,p=h*h+c*c,f=a*h+l*c,g=s*Math.sqrt(d)/u,m=s*Math.sqrt(p)/u,_=g*f/d,y=m*f/p,x=g*c+m*l,b=g*h+m*a,v=l*(m+_),w=a*(m+_),S=c*(g+y),A=h*(g+y);so(t,x+e,b+i,s,Math.atan2(w-b,v-x),Math.atan2(A-b,S-x),l*h>c*a)}(this._currentPoly.points,t,e,i,n,r),this}arcToSvg(t,e,i,n,r,s,o){return uo(this._currentPoly.points,this._currentPoly.lastX,this._currentPoly.lastY,s,o,t,e,i,n,r),this}bezierCurveTo(t,e,i,n,r,s,o){this._ensurePoly();const a=this._currentPoly;return eo(this._currentPoly.points,a.lastX,a.lastY,t,e,i,n,r,s,o),this}quadraticCurveTo(t,e,i,n,r){this._ensurePoly();const s=this._currentPoly;return no(this._currentPoly.points,s.lastX,s.lastY,t,e,i,n,r),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0)).transform(e);const i=this.shapePrimitives,n=i.length;for(let r=0;r<t.instructions.length;r++){const e=t.instructions[r];this[e.action](...e.data)}if(t.checkForHoles&&i.length-n>1){let t=null;for(let e=n;e<i.length;e++){const n=i[e];if("polygon"===n.shape.type){const r=n.shape,s=null==t?void 0:t.shape;s&&s.containsPolygon(r)?(t.holes||(t.holes=[]),t.holes.push(n),i.copyWithin(e,e+1),i.length--,e--):t=n}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,n,r){return this.drawShape(new D(t,e,i,n),r),this}circle(t,e,i,n){return this.drawShape(new mr(t,e,i),n),this}poly(t,e,i){const n=new xr(t);return n.closePath=e,this.drawShape(n,i),this}regularPoly(t,e,i,n,r=0,s){n=Math.max(0|n,3);const o=-1*Math.PI/2+r,a=2*Math.PI/n,l=[];for(let h=0;h<n;h++){const n=o-h*a;l.push(t+i*Math.cos(n),e+i*Math.sin(n))}return this.poly(l,!0,s),this}roundPoly(t,e,i,n,r,s=0,o){if(n=Math.max(0|n,3),r<=0)return this.regularPoly(t,e,i,n,s);const a=i*Math.sin(Math.PI/n)-.001;r=Math.min(r,a);const l=-1*Math.PI/2+s,h=2*Math.PI/n,c=(n-2)*Math.PI/n/2;for(let u=0;u<n;u++){const n=u*h+l,s=t+i*Math.cos(n),a=e+i*Math.sin(n),d=n+Math.PI+c,p=n-Math.PI-c,f=s+r*Math.cos(d),g=a+r*Math.sin(d),m=s+r*Math.cos(p),_=a+r*Math.sin(p);0===u?this.moveTo(f,g):this.lineTo(f,g),this.quadraticCurveTo(s,a,m,_,o)}return this.closePath()}roundShape(t,e,i=!1,n){return t.length<3?this:(i?function(t,e,i,n){var r;const s=(t,e)=>Math.sqrt(__pow(t.x-e.x,2)+__pow(t.y-e.y,2)),o=(t,e,i)=>({x:t.x+(e.x-t.x)*i,y:t.y+(e.y-t.y)*i}),a=e.length;for(let l=0;l<a;l++){const h=e[(l+1)%a],c=null!=(r=h.radius)?r:i;if(c<=0){0===l?t.moveTo(h.x,h.y):t.lineTo(h.x,h.y);continue}const u=e[l],d=e[(l+2)%a],p=s(u,h);let f;f=p<1e-4?h:o(h,u,Math.min(p/2,c)/p);const g=s(d,h);let m;m=g<1e-4?h:o(h,d,Math.min(g/2,c)/g),0===l?t.moveTo(f.x,f.y):t.lineTo(f.x,f.y),t.quadraticCurveTo(h.x,h.y,m.x,m.y,n)}}(this,t,e,n):function(t,e,i){var n;const r=(t,e)=>{const i=e.x-t.x,n=e.y-t.y,r=Math.sqrt(i*i+n*n);return{len:r,nx:i/r,ny:n/r}},s=(e,i)=>{0===e?t.moveTo(i.x,i.y):t.lineTo(i.x,i.y)};let o=e[e.length-1];for(let a=0;a<e.length;a++){const l=e[a%e.length],h=null!=(n=l.radius)?n:i;if(h<=0){s(a,l),o=l;continue}const c=e[(a+1)%e.length],u=r(l,o),d=r(l,c);if(u.len<1e-4||d.len<1e-4){s(a,l),o=l;continue}let p=Math.asin(u.nx*d.ny-u.ny*d.nx),f=1,g=!1;u.nx*d.nx-u.ny*-d.ny<0?p<0?p=Math.PI+p:(p=Math.PI-p,f=-1,g=!0):p>0&&(f=-1,g=!0);const m=p/2;let _,y=Math.abs(Math.cos(m)*h/Math.sin(m));y>Math.min(u.len/2,d.len/2)?(y=Math.min(u.len/2,d.len/2),_=Math.abs(y*Math.sin(m)/Math.cos(m))):_=h;const x=l.x+d.nx*y+-d.ny*_*f,b=l.y+d.ny*y+d.nx*_*f,v=Math.atan2(u.ny,u.nx)+Math.PI/2*f,w=Math.atan2(d.ny,d.nx)-Math.PI/2*f;0===a&&t.moveTo(x+Math.cos(v)*_,b+Math.sin(v)*_),t.arc(x,b,_,v,w,g),o=l}}(this,t,e),this.closePath())}filletRect(t,e,i,n,r){if(0===r)return this.rect(t,e,i,n);const s=Math.min(i,n)/2,o=Math.min(s,Math.max(-s,r)),a=t+i,l=e+n,h=o<0?-o:0,c=Math.abs(o);return this.moveTo(t,e+c).arcTo(t+h,e+h,t+c,e,c).lineTo(a-c,e).arcTo(a-h,e+h,a,e+c,c).lineTo(a,l-c).arcTo(a-h,l-h,t+i-c,l,c).lineTo(t+c,l).arcTo(t+h,l-h,t,l-c,c).closePath()}chamferRect(t,e,i,n,r,s){if(r<=0)return this.rect(t,e,i,n);const o=Math.min(r,Math.min(i,n)/2),a=t+i,l=e+n,h=[t+o,e,a-o,e,a,e+o,a,l-o,a-o,l,t+o,l,t,l-o,t,e+o];for(let c=h.length-1;c>=2;c-=2)h[c]===h[c-2]&&h[c-1]===h[c-3]&&h.splice(c-1,2);return this.poly(h,!0,s)}ellipse(t,e,i,n,r){return this.drawShape(new _r(t,e,i,n),r),this}roundRect(t,e,i,n,r,s){return this.drawShape(new vr(t,e,i,n,r),s),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new xr,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new xr,t)){const t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let e=t.shape.x,i=t.shape.y;if(t.transform&&!t.transform.isIdentity()){const n=t.transform,r=e;e=n.a*e+n.c*i+n.tx,i=n.b*r+n.d*i+n.ty}this._currentPoly.points.push(e,i)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let i=0;i<e.length;i++){const n=e[i],r=n.shape.getBounds(po);n.transform?t.addRect(r,n.transform):t.addRect(r)}return t}}class go{constructor(t,e=!1){var i;this.instructions=[],this.uid=U("graphicsPath"),this._dirty=!0,this.checkForHoles=e,"string"==typeof t?function(t,e){const i=gr(t),n=[];let r=null,s=0,o=0;for(let a=0;a<i.length;a++){const t=i[a],l=t[0],h=t;switch(l){case"M":s=h[1],o=h[2],e.moveTo(s,o);break;case"m":s+=h[1],o+=h[2],e.moveTo(s,o);break;case"H":s=h[1],e.lineTo(s,o);break;case"h":s+=h[1],e.lineTo(s,o);break;case"V":o=h[1],e.lineTo(s,o);break;case"v":o+=h[1],e.lineTo(s,o);break;case"L":s=h[1],o=h[2],e.lineTo(s,o);break;case"l":s+=h[1],o+=h[2],e.lineTo(s,o);break;case"C":s=h[5],o=h[6],e.bezierCurveTo(h[1],h[2],h[3],h[4],s,o);break;case"c":e.bezierCurveTo(s+h[1],o+h[2],s+h[3],o+h[4],s+h[5],o+h[6]),s+=h[5],o+=h[6];break;case"S":s=h[3],o=h[4],e.bezierCurveToShort(h[1],h[2],s,o);break;case"s":e.bezierCurveToShort(s+h[1],o+h[2],s+h[3],o+h[4]),s+=h[3],o+=h[4];break;case"Q":s=h[3],o=h[4],e.quadraticCurveTo(h[1],h[2],s,o);break;case"q":e.quadraticCurveTo(s+h[1],o+h[2],s+h[3],o+h[4]),s+=h[3],o+=h[4];break;case"T":s=h[1],o=h[2],e.quadraticCurveToShort(s,o);break;case"t":s+=h[1],o+=h[2],e.quadraticCurveToShort(s,o);break;case"A":s=h[6],o=h[7],e.arcToSvg(h[1],h[2],h[3],h[4],h[5],s,o);break;case"a":s+=h[6],o+=h[7],e.arcToSvg(h[1],h[2],h[3],h[4],h[5],s,o);break;case"Z":case"z":e.closePath(),n.length>0&&(r=n.pop(),r?(s=r.startX,o=r.startY):(s=0,o=0)),r=null;break;default:kt(`Unknown SVG path command: ${l}`)}"Z"!==l&&"z"!==l&&null===r&&(r={startX:s,startY:o},n.push(r))}}(t,this):this.instructions=null!=(i=null==t?void 0:t.slice())?i:[]}get shapePath(){return this._shapePath||(this._shapePath=new fo(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,i,n,r){const s=this.instructions[this.instructions.length-1],o=this.getLastPoint(v.shared);let a=0,l=0;if(s&&"bezierCurveTo"===s.action){a=s.data[2],l=s.data[3];const t=o.x,e=o.y;a=t+(t-a),l=e+(e-l)}else a=o.x,l=o.y;return this.instructions.push({action:"bezierCurveTo",data:[a,l,t,e,i,n,r]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,i){const n=this.instructions[this.instructions.length-1],r=this.getLastPoint(v.shared);let s=0,o=0;if(n&&"quadraticCurveTo"===n.action){s=n.data[0],o=n.data[1];const t=r.x,e=r.y;s=t+(t-s),o=e+(e-o)}else s=r.x,o=r.y;return this.instructions.push({action:"quadraticCurveTo",data:[s,o,t,e,i]}),this._dirty=!0,this}rect(t,e,i,n,r){return this.instructions.push({action:"rect",data:[t,e,i,n,r]}),this._dirty=!0,this}circle(t,e,i,n){return this.instructions.push({action:"circle",data:[t,e,i,n]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,i,n,r,s,o){r||(r=n/2);const a=-1*Math.PI/2+s,l=2*i,h=2*Math.PI/l,c=[];for(let u=0;u<l;u++){const i=u%2?r:n,s=u*h+a;c.push(t+i*Math.cos(s),e+i*Math.sin(s))}return this.poly(c,!0,o),this}clone(t=!1){const e=new go;if(e.checkForHoles=this.checkForHoles,t)for(let i=0;i<this.instructions.length;i++){const t=this.instructions[i];e.instructions.push({action:t.action,data:t.data.slice()})}else e.instructions=this.instructions.slice();return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,i=t.b,n=t.c,r=t.d,s=t.tx,o=t.ty;let a=0,l=0,h=0,c=0,u=0,d=0,p=0,f=0;for(let g=0;g<this.instructions.length;g++){const m=this.instructions[g],_=m.data;switch(m.action){case"moveTo":case"lineTo":a=_[0],l=_[1],_[0]=e*a+n*l+s,_[1]=i*a+r*l+o;break;case"bezierCurveTo":h=_[0],c=_[1],u=_[2],d=_[3],a=_[4],l=_[5],_[0]=e*h+n*c+s,_[1]=i*h+r*c+o,_[2]=e*u+n*d+s,_[3]=i*u+r*d+o,_[4]=e*a+n*l+s,_[5]=i*a+r*l+o;break;case"quadraticCurveTo":h=_[0],c=_[1],a=_[2],l=_[3],_[0]=e*h+n*c+s,_[1]=i*h+r*c+o,_[2]=e*a+n*l+s,_[3]=i*a+r*l+o;break;case"arcToSvg":a=_[5],l=_[6],p=_[0],f=_[1],_[0]=e*p+n*f,_[1]=i*p+r*f,_[5]=e*a+n*l+s,_[6]=i*a+r*l+o;break;case"circle":_[4]=mo(_[3],t);break;case"rect":_[4]=mo(_[4],t);break;case"ellipse":_[8]=mo(_[8],t);break;case"roundRect":_[5]=mo(_[5],t);break;case"addPath":_[0].transform(t);break;case"poly":_[2]=mo(_[2],t);break;default:kt("unknown transform action",m.action)}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,i=this.instructions[e];if(!i)return t.x=0,t.y=0,t;for(;"closePath"===i.action;){if(e--,e<0)return t.x=0,t.y=0,t;i=this.instructions[e]}switch(i.action){case"moveTo":case"lineTo":t.x=i.data[0],t.y=i.data[1];break;case"quadraticCurveTo":t.x=i.data[2],t.y=i.data[3];break;case"bezierCurveTo":t.x=i.data[4],t.y=i.data[5];break;case"arc":case"arcToSvg":t.x=i.data[5],t.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(t)}return t}}function mo(t,e){return t?t.prepend(e):e.clone()}function _o(t,e,i){const n=t.getAttribute(e);return n?Number(n):i}function yo(t){const e=_o(t,"x1",0),i=_o(t,"y1",0),n=_o(t,"x2",1),r=_o(t,"y2",0),s=t.getAttribute("gradientUnits")||"objectBoundingBox",o=new lr(e,i,n,r,"objectBoundingBox"===s?"local":"global");for(let a=0;a<t.children.length;a++){const e=t.children[a],i=_o(e,"offset",0),n=Bt.shared.setValue(e.getAttribute("stop-color")).toNumber();o.addColorStop(i,n)}return o}function xo(t){return kt("[SVG Parser] Radial gradients are not yet supported"),new lr(0,0,1,0)}function bo(t){const e=t.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}const vo={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 wo(t,e){const i=t.getAttribute("style"),n={},r={},s={strokeStyle:n,fillStyle:r,useFill:!1,useStroke:!1};for(const o in vo){const i=t.getAttribute(o);i&&So(e,s,o,i.trim())}if(i){const t=i.split(";");for(let i=0;i<t.length;i++){const n=t[i].trim(),[r,o]=n.split(":");vo[r]&&So(e,s,r,o.trim())}}return{strokeStyle:s.useStroke?n:null,fillStyle:s.useFill?r:null,useFill:s.useFill,useStroke:s.useStroke}}function So(t,e,i,n){switch(i){case"stroke":if("none"!==n){if(n.startsWith("url(")){const i=bo(n);e.strokeStyle.fill=t.defs[i]}else e.strokeStyle.color=Bt.shared.setValue(n).toNumber();e.useStroke=!0}break;case"stroke-width":e.strokeStyle.width=Number(n);break;case"fill":if("none"!==n){if(n.startsWith("url(")){const i=bo(n);e.fillStyle.fill=t.defs[i]}else e.fillStyle.color=Bt.shared.setValue(n).toNumber();e.useFill=!0}break;case"fill-opacity":e.fillStyle.alpha=Number(n);break;case"stroke-opacity":e.strokeStyle.alpha=Number(n);break;case"opacity":e.fillStyle.alpha=Number(n),e.strokeStyle.alpha=Number(n)}}function Ao(t,e){if("string"==typeof t){const e=document.createElement("div");e.innerHTML=t.trim(),t=e.querySelector("svg")}const i={context:e,defs:{},path:new go};!function(t,e){const i=t.querySelectorAll("defs");for(let n=0;n<i.length;n++){const t=i[n];for(let i=0;i<t.children.length;i++){const n=t.children[i];switch(n.nodeName.toLowerCase()){case"lineargradient":e.defs[n.id]=yo(n);break;case"radialgradient":e.defs[n.id]=xo()}}}}(t,i);const n=t.children,{fillStyle:r,strokeStyle:s}=wo(t,i);for(let o=0;o<n.length;o++){const t=n[o];"defs"!==t.nodeName.toLowerCase()&&To(t,i,r,s)}return e}function To(t,e,i,n){const r=t.children,{fillStyle:s,strokeStyle:o}=wo(t,e);s&&i?i=__spreadValues(__spreadValues({},i),s):s&&(i=s),o&&n?n=__spreadValues(__spreadValues({},n),o):o&&(n=o);const a=!i&&!n;let l,h,c,u,d,p,f,g,m,_,y,x,b,v,w,S,A;switch(a&&(i={color:0}),t.nodeName.toLowerCase()){case"path":v=t.getAttribute("d"),"evenodd"===t.getAttribute("fill-rule")&&kt("SVG Evenodd fill rule not supported, your svg may render incorrectly"),w=new go(v,!0),e.context.path(w),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"circle":f=_o(t,"cx",0),g=_o(t,"cy",0),m=_o(t,"r",0),e.context.ellipse(f,g,m,m),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"rect":l=_o(t,"x",0),h=_o(t,"y",0),S=_o(t,"width",0),A=_o(t,"height",0),_=_o(t,"rx",0),y=_o(t,"ry",0),_||y?e.context.roundRect(l,h,S,A,_||y):e.context.rect(l,h,S,A),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"ellipse":f=_o(t,"cx",0),g=_o(t,"cy",0),_=_o(t,"rx",0),y=_o(t,"ry",0),e.context.beginPath(),e.context.ellipse(f,g,_,y),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"line":c=_o(t,"x1",0),u=_o(t,"y1",0),d=_o(t,"x2",0),p=_o(t,"y2",0),e.context.beginPath(),e.context.moveTo(c,u),e.context.lineTo(d,p),n&&e.context.stroke(n);break;case"polygon":b=t.getAttribute("points"),x=b.match(/\d+/g).map(t=>parseInt(t,10)),e.context.poly(x,!0),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"polyline":b=t.getAttribute("points"),x=b.match(/\d+/g).map(t=>parseInt(t,10)),e.context.poly(x,!1),n&&e.context.stroke(n);break;case"g":case"svg":break;default:kt(`[SVG parser] <${t.nodeName}> elements unsupported`)}a&&(i=null);for(let T=0;T<r.length;T++)To(r[T],e,i,n)}function Co(t){return t instanceof dr}function Po(t){return t instanceof lr}function Mo(t,e,i){return t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,__spreadValues(__spreadValues({},i),t)}function Eo(t,e,i){return e.buildGradient(),t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,t.textureSpace=e.textureSpace,__spreadValues(__spreadValues({},i),t)}function Ro(t,e){if(null==t)return null;const i={},n=t;return function(t){return Bt.isColorLike(t)}(t)?function(t,e,i){const n=Bt.shared.setValue(null!=e?e:0);return t.color=n.toNumber(),t.alpha=1===n.alpha?i.alpha:n.alpha,t.texture=J.WHITE,__spreadValues(__spreadValues({},i),t)}(i,t,e):function(t){return t instanceof J}(t)?function(t,e,i){return t.texture=e,__spreadValues(__spreadValues({},i),t)}(i,t,e):Co(t)?Mo(i,t,e):Po(t)?Eo(i,t,e):n.fill&&Co(n.fill)?Mo(n,n.fill,e):n.fill&&Po(n.fill)?Eo(n,n.fill,e):function(t,e){const i=__spreadValues(__spreadValues({},e),t),n=Bt.shared.setValue(i.color);return i.alpha*=n.alpha,i.color=n.toNumber(),i}(n,e)}function Bo(t,e){const i=e,{width:n,alignment:r,miterLimit:s,cap:o,join:a,pixelLine:l}=i,h=Ro(t,__objRest(i,["width","alignment","miterLimit","cap","join","pixelLine"]));return h?__spreadValues({width:n,alignment:r,miterLimit:s,cap:o,join:a,pixelLine:l},h):null}const Fo=new v,ko=new S,Io=class t extends _{constructor(){super(...arguments),this.uid=U("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new go,this._transform=new S,this._fillStyle=__spreadValues({},t.defaultFillStyle),this._strokeStyle=__spreadValues({},t.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new it,this._boundsDirty=!0}clone(){const e=new t;return e.batchMode=this.batchMode,e.instructions=this.instructions.slice(),e._activePath=this._activePath.clone(),e._transform=this._transform.clone(),e._fillStyle=__spreadValues({},this._fillStyle),e._strokeStyle=__spreadValues({},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=Ro(e,t.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=Bo(e,t.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=Ro(e,t.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=Ro(e,t.defaultStrokeStyle),this}texture(t,e,i,n,r,s){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:n||0,dw:r||t.frame.width,dh:s||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?Bt.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new go,this}fill(e,i){let n;const r=this.instructions[this.instructions.length-1];return n=0===this._tick&&r&&"stroke"===r.action?r.data.path:this._activePath.clone(),n?(null!=e&&(void 0!==i&&"number"==typeof e&&(z(L,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:i}),this._fillStyle=Ro(e,t.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:n}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(v.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(e){let i;const n=this.instructions[this.instructions.length-1];return i=0===this._tick&&n&&"fill"===n.action?n.data.path:this._activePath.clone(),i?(null!=e&&(this._strokeStyle=Bo(e,t.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&("stroke"===e.action||"fill"===e.action)){if(!e.data.hole){e.data.hole=i;break}e.data.hole.addPath(i)}}return this._initNextPathLocation(),this}arc(t,e,i,n,r,s){this._tick++;const o=this._transform;return this._activePath.arc(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,i,n,r,s),this}arcTo(t,e,i,n,r){this._tick++;const s=this._transform;return this._activePath.arcTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty,s.a*i+s.c*n+s.tx,s.b*i+s.d*n+s.ty,r),this}arcToSvg(t,e,i,n,r,s,o){this._tick++;const a=this._transform;return this._activePath.arcToSvg(t,e,i,n,r,a.a*s+a.c*o+a.tx,a.b*s+a.d*o+a.ty),this}bezierCurveTo(t,e,i,n,r,s,o){this._tick++;const a=this._transform;return this._activePath.bezierCurveTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*i+a.c*n+a.tx,a.b*i+a.d*n+a.ty,a.a*r+a.c*s+a.tx,a.b*r+a.d*s+a.ty,o),this}closePath(){var t;return this._tick++,null==(t=this._activePath)||t.closePath(),this}ellipse(t,e,i,n){return this._tick++,this._activePath.ellipse(t,e,i,n,this._transform.clone()),this}circle(t,e,i){return this._tick++,this._activePath.circle(t,e,i,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;const i=this._transform,n=this._activePath.instructions,r=i.a*t+i.c*e+i.tx,s=i.b*t+i.d*e+i.ty;return 1===n.length&&"moveTo"===n[0].action?(n[0].data[0]=r,n[0].data[1]=s,this):(this._activePath.moveTo(r,s),this)}quadraticCurveTo(t,e,i,n,r){this._tick++;const s=this._transform;return this._activePath.quadraticCurveTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty,s.a*i+s.c*n+s.tx,s.b*i+s.d*n+s.ty,r),this}rect(t,e,i,n){return this._tick++,this._activePath.rect(t,e,i,n,this._transform.clone()),this}roundRect(t,e,i,n,r){return this._tick++,this._activePath.roundRect(t,e,i,n,r,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,n,r=0,s){return this._tick++,this._activePath.regularPoly(t,e,i,n,r,s),this}roundPoly(t,e,i,n,r,s){return this._tick++,this._activePath.roundPoly(t,e,i,n,r,s),this}roundShape(t,e,i,n){return this._tick++,this._activePath.roundShape(t,e,i,n),this}filletRect(t,e,i,n,r){return this._tick++,this._activePath.filletRect(t,e,i,n,r),this}chamferRect(t,e,i,n,r,s){return this._tick++,this._activePath.chamferRect(t,e,i,n,r,s),this}star(t,e,i,n,r=0,s=0){return this._tick++,this._activePath.star(t,e,i,n,r,s,this._transform.clone()),this}svg(t){return this._tick++,Ao(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:__spreadValues({},this._fillStyle),strokeStyle:__spreadValues({},this._strokeStyle)}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,n,r,s){return t instanceof S?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,n,r,s),this)}transform(t,e,i,n,r,s){return t instanceof S?(this._transform.append(t),this):(ko.set(t,e,i,n,r,s),this._transform.append(ko),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const i=this.instructions[e],n=i.action;if("fill"===n){const e=i.data;t.addBounds(e.path.bounds)}else if("texture"===n){const e=i.data;t.addFrame(e.dx,e.dy,e.dx+e.dw,e.dy+e.dh,e.transform)}if("stroke"===n){const e=i.data,n=e.style.alignment,r=e.style.width*(1-n),s=e.path.bounds;t.addFrame(s.minX-r,s.minY-r,s.maxX+r,s.maxY+r)}}return t}containsPoint(t){var e;if(!this.bounds.containsPoint(t.x,t.y))return!1;const i=this.instructions;let n=!1;for(let r=0;r<i.length;r++){const s=i[r],o=s.data,a=o.path;if(!s.action||!a)continue;const l=o.style,h=a.shapePath.shapePrimitives;for(let i=0;i<h.length;i++){const r=h[i].shape;if(!l||!r)continue;const a=h[i].transform,c=a?a.applyInverse(t,Fo):t;if("fill"===s.action)n=r.contains(c.x,c.y);else{const t=l;n=r.strokeContains(c.x,c.y,t.width,t.alignment)}const u=o.hole;if(u){const t=null==(e=u.shapePath)?void 0:e.shapePrimitives;if(t)for(let e=0;e<t.length;e++)t[e].shape.contains(c.x,c.y)&&(n=!1)}if(n)return!0}}return n}destroy(t=!1){this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners();if("boolean"==typeof t?t:null==t?void 0:t.texture){const e="boolean"==typeof t?t:null==t?void 0:t.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(e)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(e))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Io.defaultFillStyle={color:16777215,alpha:1,texture:J.WHITE,matrix:null,fill:null,textureSpace:"local"},Io.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:J.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Do=Io;const Oo=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function Uo(t){const e=[];let i=0;for(let n=0;n<Oo.length;n++){const r=`_${Oo[n]}`;e[i++]=t[r]}return i=Go(t._fill,e,i),i=function(t,e,i){return t?(i=Go(t,e,i),e[i++]=t.width,e[i++]=t.alignment,e[i++]=t.cap,e[i++]=t.join,e[i++]=t.miterLimit,i):i}(t._stroke,e,i),i=function(t,e,i){return t?(e[i++]=t.alpha,e[i++]=t.angle,e[i++]=t.blur,e[i++]=t.distance,e[i++]=Bt.shared.setValue(t.color).toNumber(),i):i}(t.dropShadow,e,i),i=function(t,e,i){if(!t)return i;for(const n of t)e[i++]=n.uid;return i}(t.filters,e,i),e.join("-")}function Go(t,e,i){var n;return t?(e[i++]=t.color,e[i++]=t.alpha,e[i++]=null==(n=t.fill)?void 0:n.styleKey,i):i}const Lo=class t extends _{constructor(e={}){super(),function(t){var e,i,n,r,s;const o=t;if("boolean"==typeof o.dropShadow&&o.dropShadow){const a=zo.defaultDropShadow;t.dropShadow={alpha:null!=(e=o.dropShadowAlpha)?e:a.alpha,angle:null!=(i=o.dropShadowAngle)?i:a.angle,blur:null!=(n=o.dropShadowBlur)?n:a.blur,color:null!=(r=o.dropShadowColor)?r:a.color,distance:null!=(s=o.dropShadowDistance)?s:a.distance}}if(void 0!==o.strokeThickness){z(L,"strokeThickness is now a part of stroke");const e=o.stroke;let i={};if(Bt.isColorLike(e))i.color=e;else if(e instanceof lr||e instanceof dr)i.fill=e;else{if(!Object.hasOwnProperty.call(e,"color")&&!Object.hasOwnProperty.call(e,"fill"))throw new Error("Invalid stroke value.");i=e}t.stroke=__spreadProps(__spreadValues({},i),{width:o.strokeThickness})}if(Array.isArray(o.fillGradientStops)){if(z(L,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(o.fill)||0===o.fill.length)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");o.fill.length!==o.fillGradientStops.length&&kt("The number of fill colors must match the number of fill gradient stops.");const e=new lr({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),i=o.fillGradientStops.slice(),n=o.fill.map(t=>Bt.shared.setValue(t).toNumber());i.forEach((t,i)=>{e.addColorStop(t,n[i])}),t.fill={fill:e}}}(e);const i=__spreadValues(__spreadValues({},t.defaultTextStyle),e);for(const t in i){this[t]=i[t]}this.update()}get align(){return this._align}set align(t){this._align=t,this.update()}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords=t,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow=null!==e&&"object"==typeof e?this._createProxy(__spreadValues(__spreadValues({},t.defaultDropShadow),e)):e?this._createProxy(__spreadValues({},t.defaultDropShadow)):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily=t,this.update()}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize="string"==typeof t?parseInt(t,10):t,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t.toLowerCase(),this.update()}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant=t,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight=t,this.update()}get leading(){return this._leading}set leading(t){this._leading=t,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing=t,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight=t,this.update()}get padding(){return this._padding}set padding(t){this._padding=t,this.update()}get filters(){return this._filters}set filters(t){this._filters=t,this.update()}get trim(){return this._trim}set trim(t){this._trim=t,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace=t,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap=t,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth=t,this.update()}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy(__spreadValues(__spreadValues({},Do.defaultFillStyle),t),()=>{this._fill=Ro(__spreadValues({},this._originalFill),Do.defaultFillStyle)})),this._fill=Ro(0===t?"black":t,Do.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy(__spreadValues(__spreadValues({},Do.defaultStrokeStyle),t),()=>{this._stroke=Bo(__spreadValues({},this._originalStroke),Do.defaultStrokeStyle)})),this._stroke=Bo(t,Do.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=Uo(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const e=t.defaultTextStyle;for(const t in e)this[t]=e[t]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new t({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?__spreadValues({},this._dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0})}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){var e,i,n,r;this.removeAllListeners();if("boolean"==typeof t?t:null==t?void 0:t.texture){const s="boolean"==typeof t?t:null==t?void 0:t.textureSource;(null==(e=this._fill)?void 0:e.texture)&&this._fill.texture.destroy(s),(null==(i=this._originalFill)?void 0:i.texture)&&this._originalFill.texture.destroy(s),(null==(n=this._stroke)?void 0:n.texture)&&this._stroke.texture.destroy(s),(null==(r=this._originalStroke)?void 0:r.texture)&&this._originalStroke.texture.destroy(s)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(t,i,n)=>(t[i]=n,null==e||e(i,n),this.update(),!0)})}_isFillStyle(t){return null!==(null!=t?t:null)&&!(Bt.isColorLike(t)||t instanceof lr||t instanceof dr)}};Lo.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},Lo.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 zo=Lo;const No=new class{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=Re.get().createCanvas();i.width=t,i.height=e;const n=i.getContext("2d");return{canvas:i,context:n}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6);const n=((t=V(t))<<17)+((e=V(e))<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let r=this._canvasPool[n].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:n}=e,r=(i<<17)+(n<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,n),this._canvasPool[r].push(t)}clear(){this._canvasPool={}}},Vo=1e5;function Ho(t,e,i,n=0){var r;if(t.texture===J.WHITE&&!t.fill)return Bt.shared.setValue(t.color).setAlpha(null!=(r=t.alpha)?r:1).toHexa();if(!t.fill){const i=e.createPattern(t.texture.source.resource,"repeat"),n=t.matrix.copyTo(S.shared);return n.scale(t.texture.frame.width,t.texture.frame.height),i.setTransform(n),i}if(t.fill instanceof dr){const i=t.fill,n=e.createPattern(i.texture.source.resource,"repeat"),r=i.transform.copyTo(S.shared);return r.scale(i.texture.frame.width,i.texture.frame.height),n.setTransform(r),n}if(t.fill instanceof lr){const r=t.fill,s="linear"===r.type,o="local"===r.textureSpace;let a,l=1,h=1;o&&i&&(l=i.width+n,h=i.height+n);let c=!1;if(s){const{start:t,end:i}=r;a=e.createLinearGradient(t.x*l,t.y*h,i.x*l,i.y*h),c=Math.abs(i.x-t.x)<Math.abs(.1*(i.y-t.y))}else{const{center:t,innerRadius:i,outerCenter:n,outerRadius:s}=r;a=e.createRadialGradient(t.x*l,t.y*h,i*l,n.x*l,n.y*h,s*l)}if(c&&o&&i){const t=i.lineHeight/h;for(let e=0;e<i.lines.length;e++){const s=(e*i.lineHeight+n/2)/h;r.colorStops.forEach(e=>{const i=s+e.offset*t;a.addColorStop(Math.floor(i*Vo)/Vo,Bt.shared.setValue(e.color).toHex())})}}else r.colorStops.forEach(t=>{a.addColorStop(t.offset,Bt.shared.setValue(t.color).toHex())});return a}return kt("FillStyle not recognised",t),"red"}const Wo=class t extends tr{constructor(e){var i,n,r;super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;const s=__spreadValues(__spreadValues({},t.defaultOptions),e);this._textureSize=s.textureSize,this._mipmap=s.mipmap;const o=s.style.clone();s.overrideFill&&(o._fill.color=16777215,o._fill.alpha=1,o._fill.texture=J.WHITE,o._fill.fill=null),this.applyFillAsTint=s.overrideFill;const a=o.fontSize;o.fontSize=this.baseMeasurementFontSize;const l=ir(o);s.overrideSize?o._stroke&&(o._stroke.width*=this.baseRenderedFontSize/a):o.fontSize=this.baseRenderedFontSize=a,this._style=o,this._skipKerning=null!=(i=s.skipKerning)&&i,this.resolution=null!=(n=s.resolution)?n:1,this._padding=null!=(r=s.padding)?r:4,s.textureStyle&&(this._textureStyle=s.textureStyle instanceof X?s.textureStyle:new X(s.textureStyle)),this.fontMetrics=sr.measureFont(l),this.lineHeight=o.lineHeight||this.fontMetrics.fontSize||o.fontSize}ensureCharacters(t){var e,i,n,r;const s=sr.graphemeSegmenter(t).filter(t=>!this._currentChars.includes(t)).filter((t,e,i)=>i.indexOf(t)===e);if(!s.length)return;let o;this._currentChars=[...this._currentChars,...s],o=-1===this._currentPageIndex?this._nextPage():this.pages[this._currentPageIndex];let{canvas:a,context:l}=o.canvasAndContext,h=o.texture.source;const c=this._style;let u=this._currentX,d=this._currentY,p=this._currentMaxCharHeight;const f=this.baseRenderedFontSize/this.baseMeasurementFontSize,g=this._padding*f;let m=!1;const _=a.width/this.resolution,y=a.height/this.resolution;for(let x=0;x<s.length;x++){const t=s[x],o=sr.measureText(t,c,a,!1);o.lineHeight=o.height;const b=o.width*f,v=Math.ceil(("italic"===c.fontStyle?2:1)*b)+2*g,w=o.height*f+2*g;if(m=!1,"\n"!==t&&"\r"!==t&&"\t"!==t&&" "!==t&&(m=!0,p=Math.ceil(Math.max(w,p))),u+v>_&&(d+=p,p=w,u=0,d+p>y)){h.update();const t=this._nextPage();a=t.canvasAndContext.canvas,l=t.canvasAndContext.context,h=t.texture.source,u=0,d=0,p=0}const S=b/f-(null!=(i=null==(e=c.dropShadow)?void 0:e.distance)?i:0)-(null!=(r=null==(n=c._stroke)?void 0:n.width)?r:0);if(this.chars[t]={id:t.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:S,kerning:{}},m){this._drawGlyph(l,o,u+g,d+g,f,c);const e=h.width*f,i=h.height*f,n=new D(u/e*h.width,d/i*h.height,v/e*h.width,w/i*h.height);this.chars[t].texture=new J({source:h,frame:n}),u+=Math.ceil(v)}}h.update(),this._currentX=u,this._currentY=d,this._currentMaxCharHeight=p,this._skipKerning&&this._applyKerning(s,l)}get pageTextures(){return z(L,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const i=this._measureCache;for(let n=0;n<t.length;n++){const r=t[n];for(let t=0;t<this._currentChars.length;t++){const n=this._currentChars[t];let s=i[r];s||(s=i[r]=e.measureText(r).width);let o=i[n];o||(o=i[n]=e.measureText(n).width);let a=e.measureText(r+n).width,l=a-(s+o);l&&(this.chars[r].kerning[n]=l),a=e.measureText(r+n).width,l=a-(s+o),l&&(this.chars[n].kerning[r]=l)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=No.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),n=new J({source:new Fe({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(n.source.style=this._textureStyle);const r={canvasAndContext:e,texture:n};return this.pages[this._currentPageIndex]=r,r}_setupContext(t,e,i){var n;e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=ir(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const r=e._stroke,s=null!=(n=null==r?void 0:r.width)?n:0;if(r&&(t.lineWidth=s,t.lineJoin=r.join,t.miterLimit=r.miterLimit,t.strokeStyle=Ho(r,t)),e._fill&&(t.fillStyle=Ho(e._fill,t)),e.dropShadow){const n=e.dropShadow,r=Bt.shared.setValue(n.color).toArray(),s=n.blur*i,o=n.distance*i;t.shadowColor=`rgba(${255*r[0]},${255*r[1]},${255*r[2]},${n.alpha})`,t.shadowBlur=s,t.shadowOffsetX=Math.cos(n.angle)*o,t.shadowOffsetY=Math.sin(n.angle)*o}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,i,n,r,s){var o;const a=e.text,l=e.fontProperties,h=s._stroke,c=(null!=(o=null==h?void 0:h.width)?o:0)*r,u=i+c/2,d=n-c/2,p=l.descent*r,f=e.lineHeight*r;let g=!1;s.stroke&&c&&(g=!0,t.strokeText(a,u,d+f-p));const{shadowBlur:m,shadowOffsetX:_,shadowOffsetY:y}=t;s._fill&&(g&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(a,u,d+f-p)),g&&(t.shadowBlur=m,t.shadowOffsetX=_,t.shadowOffsetY=y)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];No.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}};Wo.defaultOptions={textureSize:512,style:new zo,mipmap:!0};let jo=Wo;function Yo(t,e,i,n){const r={width:0,height:0,offsetY:0,scale:e.fontSize/i.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};r.offsetY=i.baseLineOffset;let s=r.lines[0],o=null,a=!0;const l={width:0,start:0,index:0,positions:[],chars:[]},h=i.baseMeasurementFontSize/e.fontSize,c=e.letterSpacing*h,u=e.wordWrapWidth*h,d=e.lineHeight?e.lineHeight*h:i.lineHeight,p=e.wordWrap&&e.breakWords,f=t=>{const e=s.width;for(let i=0;i<l.index;i++){const n=t.positions[i];s.chars.push(t.chars[i]),s.charPositions.push(n+e)}s.width+=t.width,a=!1,l.width=0,l.index=0,l.chars.length=0},g=()=>{let t=s.chars.length-1;if(n){let e=s.chars[t];for(;" "===e;)s.width-=i.chars[e].xAdvance,e=s.chars[--t]}r.width=Math.max(r.width,s.width),s={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,r.lines.push(s),r.height+=d},m=t=>t-c>u;for(let _=0;_<t.length+1;_++){let n;const r=_===t.length;r||(n=t[_]);const h=i.chars[n]||i.chars[" "];if(/(?:\s)/.test(n)||"\r"===n||"\n"===n||r){if(!a&&e.wordWrap&&m(s.width+l.width)?(g(),f(l),r||s.charPositions.push(0)):(l.start=s.width,f(l),r||s.charPositions.push(0)),"\r"===n||"\n"===n)0!==s.width&&g();else if(!r){const t=h.xAdvance+(h.kerning[o]||0)+c;s.width+=t,s.spaceWidth=t,s.spacesIndex.push(s.charPositions.length),s.chars.push(n)}}else{const t=h.kerning[o]||0,e=h.xAdvance+t+c;p&&m(s.width+l.width+e)&&(f(l),g()),l.positions[l.index++]=l.width+t,l.chars.push(n),l.width+=e}o=n}return g(),"center"===e.align?function(t){for(let e=0;e<t.lines.length;e++){const i=t.lines[e],n=t.width/2-i.width/2;for(let t=0;t<i.charPositions.length;t++)i.charPositions[t]+=n}}(r):"right"===e.align?function(t){for(let e=0;e<t.lines.length;e++){const i=t.lines[e],n=t.width-i.width;for(let t=0;t<i.charPositions.length;t++)i.charPositions[t]+=n}}(r):"justify"===e.align&&function(t){const e=t.width;for(let i=0;i<t.lines.length;i++){const n=t.lines[i];let r=0,s=n.spacesIndex[r++],o=0;const a=n.spacesIndex.length,l=(e-n.width)/a;for(let t=0;t<n.charPositions.length;t++)t===s&&(s=n.spacesIndex[r++],o+=l),n.charPositions[t]+=o}}(r),r}let Xo=0;const Zo=new class{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1,textureStyle:null}}getFont(t,e){var i;let n=`${e.fontFamily}-bitmap`,r=!0;if(e._fill.fill&&!e._stroke)n+=e._fill.fill.styleKey,r=!1;else if(e._stroke||e.dropShadow){let t=e.styleKey;t=t.substring(0,t.lastIndexOf("-")),n=`${t}-bitmap`,r=!1}if(!Ve.has(n)){const t=Object.create(e);t.lineHeight=0;const i=new jo(__spreadValues({style:t,overrideFill:r,overrideSize:!0},this.defaultOptions));Xo++,Xo>50&&kt("BitmapText",`You have dynamically created ${Xo} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),i.once("destroy",()=>{Xo--,Ve.remove(n)}),Ve.set(n,i)}const s=Ve.get(n);return null==(i=s.ensureCharacters)||i.call(s,t),s}getLayout(t,e,i=!0){const n=this.getFont(t,e);return Yo(sr.graphemeSegmenter(t),e,n,i)}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var e,i,n,r,s;let o=t[0];"string"==typeof o&&(o={name:o,style:t[1],chars:null==(e=t[2])?void 0:e.chars,resolution:null==(i=t[2])?void 0:i.resolution,padding:null==(n=t[2])?void 0:n.padding,skipKerning:null==(r=t[2])?void 0:r.skipKerning},z(L,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const a=null==o?void 0:o.name;if(!a)throw new Error("[BitmapFontManager] Property `name` is required.");o=__spreadValues(__spreadValues({},this.defaultOptions),o);const l=o.style,h=l instanceof zo?l:new zo(l),c=null!=(s=o.dynamicFill)?s:this._canUseTintForStyle(h),u=new jo({style:h,overrideFill:c,skipKerning:o.skipKerning,padding:o.padding,resolution:o.resolution,overrideSize:!1,textureStyle:o.textureStyle}),d=function(t){if(""===t)return[];"string"==typeof t&&(t=[t]);const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i];if(Array.isArray(n)){if(2!==n.length)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);if(0===n[0].length||0===n[1].length)throw new Error("[BitmapFont]: Invalid character delimiter.");const t=n[0].charCodeAt(0),i=n[1].charCodeAt(0);if(i<t)throw new Error("[BitmapFont]: Invalid character range.");for(let n=t,r=i;n<=r;n++)e.push(String.fromCharCode(n))}else e.push(...Array.from(n))}if(0===e.length)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}(o.chars);return u.ensureCharacters(d.join("")),Ve.set(`${a}-bitmap`,u),u.once("destroy",()=>Ve.remove(`${a}-bitmap`)),u}uninstall(t){const e=`${t}-bitmap`,i=Ve.get(e);i&&i.destroy()}_canUseTintForStyle(t){return!(t._stroke||t.dropShadow&&0!==t.dropShadow.color||t._fill.fill||16777215!==t._fill.color)}};class qo extends tr{constructor(t,e){var i;super();const{textures:n,data:r}=t;Object.keys(r.pages).forEach(t=>{const e=r.pages[parseInt(t,10)],i=n[e.id];this.pages.push({texture:i})}),Object.keys(r.chars).forEach(t=>{var e;const i=r.chars[t],{frame:s,source:o,rotate:a}=n[i.page],l=k.transformRectCoords(i,s,a,new D),h=new J({frame:l,orig:new D(0,0,i.width,i.height),source:o,rotate:a});this.chars[t]={id:t.codePointAt(0),xOffset:i.xOffset,yOffset:i.yOffset,xAdvance:i.xAdvance,kerning:null!=(e=i.kerning)?e:{},texture:h}}),this.baseRenderedFontSize=r.fontSize,this.baseMeasurementFontSize=r.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:r.fontSize},this.baseLineOffset=r.baseLineOffset,this.lineHeight=r.lineHeight,this.fontFamily=r.fontFamily,this.distanceField=null!=(i=r.distanceField)?i:{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){Zo.install(t)}static uninstall(t){Zo.uninstall(t)}}const $o={test:t=>"string"==typeof t&&t.startsWith("info face="),parse(t){var e,i,n;const r=t.match(/^[a-z]+\s+.+$/gm),s={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const f in r){const t=r[f].match(/^[a-z]+/gm)[0],e=r[f].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),i={};for(const n in e){const t=e[n].split("="),r=t[0],s=t[1].replace(/"/gm,""),o=parseFloat(s),a=isNaN(o)?s:o;i[r]=a}s[t].push(i)}const o={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[a]=s.info,[l]=s.common,[h]=null!=(e=s.distanceField)?e:[];h&&(o.distanceField={range:parseInt(h.distanceRange,10),type:h.fieldType}),o.fontSize=parseInt(a.size,10),o.fontFamily=a.face,o.lineHeight=parseInt(l.lineHeight,10);const c=s.page;for(let f=0;f<c.length;f++)o.pages.push({id:parseInt(c[f].id,10)||0,file:c[f].file});const u={};o.baseLineOffset=o.lineHeight-parseInt(l.base,10);const d=s.char;for(let f=0;f<d.length;f++){const t=d[f],e=parseInt(t.id,10);let r=null!=(n=null!=(i=t.letter)?i:t.char)?n:String.fromCharCode(e);"space"===r&&(r=" "),u[e]=r,o.chars[r]={id:e,page:parseInt(t.page,10)||0,x:parseInt(t.x,10),y:parseInt(t.y,10),width:parseInt(t.width,10),height:parseInt(t.height,10),xOffset:parseInt(t.xoffset,10),yOffset:parseInt(t.yoffset,10),xAdvance:parseInt(t.xadvance,10),kerning:{}}}const p=s.kerning||[];for(let f=0;f<p.length;f++){const t=parseInt(p[f].first,10),e=parseInt(p[f].second,10),i=parseInt(p[f].amount,10);o.chars[u[e]].kerning[u[t]]=i}return o}},Ko={test(t){const e=t;return"string"!=typeof e&&"getElementsByTagName"in e&&e.getElementsByTagName("page").length&&null!==e.getElementsByTagName("info")[0].getAttribute("face")},parse(t){var e,i;const n={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},r=t.getElementsByTagName("info")[0],s=t.getElementsByTagName("common")[0],o=t.getElementsByTagName("distanceField")[0];o&&(n.distanceField={type:o.getAttribute("fieldType"),range:parseInt(o.getAttribute("distanceRange"),10)});const a=t.getElementsByTagName("page"),l=t.getElementsByTagName("char"),h=t.getElementsByTagName("kerning");n.fontSize=parseInt(r.getAttribute("size"),10),n.fontFamily=r.getAttribute("face"),n.lineHeight=parseInt(s.getAttribute("lineHeight"),10);for(let u=0;u<a.length;u++)n.pages.push({id:parseInt(a[u].getAttribute("id"),10)||0,file:a[u].getAttribute("file")});const c={};n.baseLineOffset=n.lineHeight-parseInt(s.getAttribute("base"),10);for(let u=0;u<l.length;u++){const t=l[u],r=parseInt(t.getAttribute("id"),10);let s=null!=(i=null!=(e=t.getAttribute("letter"))?e:t.getAttribute("char"))?i:String.fromCharCode(r);"space"===s&&(s=" "),c[r]=s,n.chars[s]={id:r,page:parseInt(t.getAttribute("page"),10)||0,x:parseInt(t.getAttribute("x"),10),y:parseInt(t.getAttribute("y"),10),width:parseInt(t.getAttribute("width"),10),height:parseInt(t.getAttribute("height"),10),xOffset:parseInt(t.getAttribute("xoffset"),10),yOffset:parseInt(t.getAttribute("yoffset"),10),xAdvance:parseInt(t.getAttribute("xadvance"),10),kerning:{}}}for(let u=0;u<h.length;u++){const t=parseInt(h[u].getAttribute("first"),10),e=parseInt(h[u].getAttribute("second"),10),i=parseInt(h[u].getAttribute("amount"),10);n.chars[c[e]].kerning[c[t]]=i}return n}},Qo={test:t=>!("string"!=typeof t||!t.includes("<font>"))&&Ko.test(Re.get().parseXML(t)),parse:t=>Ko.parse(Re.get().parseXML(t))},Jo=[".xml",".fnt"],ta={extension:{type:o.CacheParser,name:"cacheBitmapFont"},test:t=>t instanceof qo,getCacheableAssets(t,e){const i={};return t.forEach(t=>{i[t]=e,i[`${t}-bitmap`]=e}),i[`${e.fontFamily}-bitmap`]=e,i}},ea={extension:{type:o.LoadParser,priority:je.Normal},name:"loadBitmapFont",id:"bitmap-font",test:t=>Jo.includes(Ze.extname(t).toLowerCase()),testParse(t){return __async(this,null,function*(){return $o.test(t)||Qo.test(t)})},parse(t,e,i){return __async(this,null,function*(){const n=$o.test(t)?$o.parse(t):Qo.parse(t),{src:r}=e,{pages:s}=n,o=[],a=n.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let t=0;t<s.length;++t){const e=s[t].file;let i=Ze.join(Ze.dirname(r),e);i=Je(i,r),o.push({src:i,data:a})}const l=yield i.load(o),h=o.map(t=>l[t.src]);return new qo({data:n,textures:h},r)})},load(t,e){return __async(this,null,function*(){const e=yield Re.get().fetch(t);return yield e.text()})},unload(t,e,i){return __async(this,null,function*(){yield Promise.all(t.pages.map(t=>i.unload(t.texture.source._sourceOrigin))),t.destroy()})}};class ia{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(t=>{this._assetList.push(t)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}_next(){return __async(this,null,function*(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());yield this._loader.load(t),this._isLoading=!1,this._next()}})}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const na={extension:{type:o.CacheParser,name:"cacheTextureArray"},test:t=>Array.isArray(t)&&t.every(t=>t instanceof J),getCacheableAssets:(t,e)=>{const i={};return t.forEach(t=>{e.forEach((e,n)=>{i[t+(0===n?"":n+1)]=e})}),i}};function ra(t){return __async(this,null,function*(){if("Image"in globalThis)return new Promise(e=>{const i=new Image;i.onload=()=>{e(!0)},i.onerror=()=>{e(!1)},i.src=t});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const e=yield(yield fetch(t)).blob();yield createImageBitmap(e)}catch(e){return!1}return!0}return!1})}const sa={extension:{type:o.DetectionParser,priority:1},test:()=>__async(null,null,function*(){return ra("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=")}),add:t=>__async(null,null,function*(){return[...t,"avif"]}),remove:t=>__async(null,null,function*(){return t.filter(t=>"avif"!==t)})},oa=["png","jpg","jpeg"],aa={extension:{type:o.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:t=>__async(null,null,function*(){return[...t,...oa]}),remove:t=>__async(null,null,function*(){return t.filter(t=>!oa.includes(t))})},la="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function ha(t){if(la)return!1;return""!==document.createElement("video").canPlayType(t)}const ca={extension:{type:o.DetectionParser,priority:0},test:()=>__async(null,null,function*(){return ha("video/mp4")}),add:t=>__async(null,null,function*(){return[...t,"mp4","m4v"]}),remove:t=>__async(null,null,function*(){return t.filter(t=>"mp4"!==t&&"m4v"!==t)})},ua={extension:{type:o.DetectionParser,priority:0},test:()=>__async(null,null,function*(){return ha("video/ogg")}),add:t=>__async(null,null,function*(){return[...t,"ogv"]}),remove:t=>__async(null,null,function*(){return t.filter(t=>"ogv"!==t)})},da={extension:{type:o.DetectionParser,priority:0},test:()=>__async(null,null,function*(){return ha("video/webm")}),add:t=>__async(null,null,function*(){return[...t,"webm"]}),remove:t=>__async(null,null,function*(){return t.filter(t=>"webm"!==t)})},pa={extension:{type:o.DetectionParser,priority:0},test:()=>__async(null,null,function*(){return ra("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=")}),add:t=>__async(null,null,function*(){return[...t,"webp"]}),remove:t=>__async(null,null,function*(){return t.filter(t=>"webp"!==t)})};class fa{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(()=>__async(this,null,function*(){var n,r;let s=null,o=null;if((e.parser||e.loadParser)&&(o=this._parserHash[e.parser||e.loadParser],e.loadParser&&kt(`[Assets] "loadParser" is deprecated, use "parser" instead for ${t}`),o||kt(`[Assets] specified load parser "${e.parser||e.loadParser}" not found while loading ${t}`)),!o){for(let i=0;i<this.parsers.length;i++){const r=this.parsers[i];if(r.load&&(null==(n=r.test)?void 0:n.call(r,t,e,this))){o=r;break}}if(!o)return kt(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=yield o.load(t,e,this),i.parser=o;for(let t=0;t<this.parsers.length;t++){const n=this.parsers[t];n.parse&&n.parse&&(yield null==(r=n.testParse)?void 0:r.call(n,s,e,this))&&(s=(yield n.parse(s,e,this))||s,i.parser=n)}return s}))(),i}load(t,e){return __async(this,null,function*(){this._parsersValidated||this._validateParsers();let i=0;const n={},r=Ke(t),s=Ne(t,t=>({alias:[t],src:t,data:{}})),o=s.length,a=s.map(t=>__async(this,null,function*(){const r=Ze.toAbsolute(t.src);if(!n[t.src])try{this.promiseCache[r]||(this.promiseCache[r]=this._getLoadPromiseAndParser(r,t)),n[t.src]=yield this.promiseCache[r].promise,e&&e(++i/o)}catch(s){throw delete this.promiseCache[r],delete n[t.src],new Error(`[Loader.load] Failed to load ${r}.\n${s}`)}}));return yield Promise.all(a),r?n[s[0].src]:n})}unload(t){return __async(this,null,function*(){const e=Ne(t,t=>({alias:[t],src:t})).map(t=>__async(this,null,function*(){var e,i;const n=Ze.toAbsolute(t.src),r=this.promiseCache[n];if(r){const s=yield r.promise;delete this.promiseCache[n],yield null==(i=null==(e=r.parser)?void 0:e.unload)?void 0:i.call(e,s,t,this)}}));yield Promise.all(e)})}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(e.name||e.id?(t[e.name]||t[e.id])&&kt(`[Assets] parser id conflict "${e.id}"`):kt("[Assets] parser should have an id"),t[e.name]=e,e.id&&(t[e.id]=e),t),{})}}function ga(t,e){if(Array.isArray(e)){for(const i of e)if(t.startsWith(`data:${i}`))return!0;return!1}return t.startsWith(`data:${e}`)}function ma(t,e){const i=t.split("?")[0],n=Ze.extname(i).toLowerCase();return Array.isArray(e)?e.includes(n):n===e}const _a={extension:{type:o.LoadParser,priority:je.Low},name:"loadJson",id:"json",test:t=>ga(t,"application/json")||ma(t,".json"),load(t){return __async(this,null,function*(){const e=yield Re.get().fetch(t);return yield e.json()})}},ya={name:"loadTxt",id:"text",extension:{type:o.LoadParser,priority:je.Low,name:"loadTxt"},test:t=>ga(t,"text/plain")||ma(t,".txt"),load(t){return __async(this,null,function*(){const e=yield Re.get().fetch(t);return yield e.text()})}},xa=["normal","bold","100","200","300","400","500","600","700","800","900"],ba=[".ttf",".otf",".woff",".woff2"],va=["font/ttf","font/otf","font/woff","font/woff2"],wa=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;const Sa=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Aa(t){return Sa.test(t)?t:encodeURI(t)}const Ta={extension:{type:o.LoadParser,priority:je.Low},name:"loadWebFont",id:"web-font",test:t=>ga(t,va)||ma(t,ba),load(t,e){return __async(this,null,function*(){var i,n,r,s,o,a;const l=Re.get().getFontFaceSet();if(l){const h=[],c=null!=(n=null==(i=e.data)?void 0:i.family)?n:function(t){const e=Ze.extname(t),i=Ze.basename(t,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1));let n=i.length>0;for(const s of i)if(!s.match(wa)){n=!1;break}let r=i.join(" ");return n||(r=`"${r.replace(/[\\"]/g,"\\$&")}"`),r}(t),u=null!=(o=null==(s=null==(r=e.data)?void 0:r.weights)?void 0:s.filter(t=>xa.includes(t)))?o:["normal"],d=null!=(a=e.data)?a:{};for(let e=0;e<u.length;e++){const i=u[e],n=new FontFace(c,`url(${Aa(t)})`,__spreadProps(__spreadValues({},d),{weight:i}));yield n.load(),l.add(n),h.push(n)}if(Ve.has(`${c}-and-url`)){Ve.get(`${c}-and-url`).entries.push({url:t,faces:h})}else Ve.set(`${c}-and-url`,{entries:[{url:t,faces:h}]});return 1===h.length?h[0]:h}return kt("[loadWebFont] FontFace API is not supported. Skipping loading font"),null})},unload(t){const e=Array.isArray(t)?t:[t],i=e[0].family,n=Ve.get(`${i}-and-url`),r=n.entries.find(t=>t.faces.some(t=>-1!==e.indexOf(t)));r.faces=r.faces.filter(t=>-1===e.indexOf(t)),0===r.faces.length&&(n.entries=n.entries.filter(t=>t!==r)),e.forEach(t=>{Re.get().getFontFaceSet().delete(t)}),0===n.entries.length&&Ve.remove(`${i}-and-url`)}};function Ca(t,e=1){var i;const n=null==(i=Qe.RETINA_PREFIX)?void 0:i.exec(t);return n?parseFloat(n[1]):e}function Pa(t,e,i){t.label=i,t._sourceOrigin=i;const n=new J({source:t,label:i}),r=()=>{delete e.promiseCache[i],Ve.has(i)&&Ve.remove(i)};return n.source.once("destroy",()=>{e.promiseCache[i]&&(kt("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),r())}),n.once("destroy",()=>{t.destroyed||(kt("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),n}const Ma={extension:{type:o.LoadParser,priority:je.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test:t=>ga(t,"image/svg+xml")||ma(t,".svg"),load(t,e,i){return __async(this,null,function*(){var n,r;return(null!=(r=null==(n=e.data)?void 0:n.parseAsGraphicsContext)?r:this.config.parseAsGraphicsContext)?function(t){return __async(this,null,function*(){const e=yield Re.get().fetch(t),i=yield e.text(),n=new Do;return n.svg(i),n})}(t):function(t,e,i,n){return __async(this,null,function*(){var r,s,o,a,l,h;const c=yield Re.get().fetch(t),u=yield c.blob(),d=URL.createObjectURL(u),p=Re.get().createImage();p.src=d,p.crossOrigin=n,yield p.decode(),URL.revokeObjectURL(d);const f=null!=(s=null==(r=e.data)?void 0:r.width)?s:p.width,g=null!=(a=null==(o=e.data)?void 0:o.height)?a:p.height,m=(null==(l=e.data)?void 0:l.resolution)||Ca(t),_=Re.get().createCanvas(f*m,g*m);_.getContext("2d").drawImage(p,0,0,f*m,g*m);const y=null!=(h=e.data)?h:{},{parseAsGraphicsContext:x}=y,b=__objRest(y,["parseAsGraphicsContext"]);return Pa(new Fe(__spreadValues({resource:_,alphaMode:"premultiply-alpha-on-upload",resolution:m},b)),i,t)})}(t,e,i,this.config.crossOrigin)})},unload(t){t.destroy(!0)}};let Ea=null,Ra=class{constructor(){Ea||(Ea=URL.createObjectURL(new Blob(['(function () {\n \'use strict\';\n\n const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";\n async function checkImageBitmap() {\n try {\n if (typeof createImageBitmap !== "function")\n return false;\n const response = await fetch(WHITE_PNG);\n const imageBlob = await response.blob();\n const imageBitmap = await createImageBitmap(imageBlob);\n return imageBitmap.width === 1 && imageBitmap.height === 1;\n } catch (_e) {\n return false;\n }\n }\n void checkImageBitmap().then((result) => {\n self.postMessage(result);\n });\n\n})();\n'],{type:"application/javascript"}))),this.worker=new Worker(Ea)}};Ra.revokeObjectURL=function(){Ea&&(URL.revokeObjectURL(Ea),Ea=null)};let Ba=null;class Fa{constructor(){Ba||(Ba=URL.createObjectURL(new Blob(['(function () {\n \'use strict\';\n\n async function loadImageBitmap(url, alphaMode) {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${url}: ${response.status} ${response.statusText}`);\n }\n const imageBlob = await response.blob();\n return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);\n }\n self.onmessage = async (event) => {\n try {\n const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);\n self.postMessage({\n data: imageBitmap,\n uuid: event.data.uuid,\n id: event.data.id\n }, [imageBitmap]);\n } catch (e) {\n self.postMessage({\n error: e,\n uuid: event.data.uuid,\n id: event.data.id\n });\n }\n };\n\n})();\n'],{type:"application/javascript"}))),this.worker=new Worker(Ba)}}Fa.revokeObjectURL=function(){Ba&&(URL.revokeObjectURL(Ba),Ba=null)};let ka,Ia=0;const Da=new class{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return void 0!==this._isImageBitmapSupported||(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new Ra;e.addEventListener("message",i=>{e.terminate(),Ra.revokeObjectURL(),t(i.data)})})),this._isImageBitmapSupported}loadImageBitmap(t,e){var i;return this._run("loadImageBitmap",[t,null==(i=null==e?void 0:e.data)?void 0:i.alphaMode])}_initWorkers(){return __async(this,null,function*(){this._initialized||(this._initialized=!0)})}_getWorker(){void 0===ka&&(ka=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<ka&&(this._createdWorkers++,t=(new Fa).worker,t.addEventListener("message",t=>{this._complete(t.data),this._returnWorker(t.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){void 0!==t.error?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}_run(t,e){return __async(this,null,function*(){yield this._initWorkers();const i=new Promise((i,n)=>{this._queue.push({id:t,arguments:e,resolve:i,reject:n})});return this._next(),i})}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[Ia]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Ia++,id:i})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{null==t||t(new Error("WorkerManager destroyed"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}},Oa=[".jpeg",".jpg",".png",".webp",".avif"],Ua=["image/jpeg","image/png","image/webp","image/avif"];const Ga={name:"loadTextures",id:"texture",extension:{type:o.LoadParser,priority:je.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test:t=>ga(t,Ua)||ma(t,Oa),load(t,e,i){return __async(this,null,function*(){var n;let r=null;r=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&(yield Da.isImageBitmapSupported())?yield Da.loadImageBitmap(t,e):yield function(t,e){return __async(this,null,function*(){var i;const n=yield Re.get().fetch(t);if(!n.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${t}: ${n.status} ${n.statusText}`);const r=yield n.blob();return"premultiplied-alpha"===(null==(i=null==e?void 0:e.data)?void 0:i.alphaMode)?createImageBitmap(r,{premultiplyAlpha:"none"}):createImageBitmap(r)})}(t,e):yield new Promise((e,i)=>{r=Re.get().createImage(),r.crossOrigin=this.config.crossOrigin,r.src=t,r.complete?e(r):(r.onload=()=>{e(r)},r.onerror=i)});return Pa(new Fe(__spreadValues({resource:r,alphaMode:"premultiply-alpha-on-upload",resolution:(null==(n=e.data)?void 0:n.resolution)||Ca(t)},e.data)),i,t)})},unload(t){t.destroy(!0)}},La=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let za,Na;function Va(t,e,i){void 0!==i||e.startsWith("data:")?!1!==i&&(t.crossOrigin="string"==typeof i?i:"anonymous"):t.crossOrigin=function(t,e=globalThis.location){if(t.startsWith("data:"))return"";e||(e=globalThis.location);const i=new URL(t,document.baseURI);if(i.hostname!==e.hostname||i.port!==e.port||i.protocol!==e.protocol)return"anonymous";return""}(e)}const Ha={name:"loadVideo",id:"video",extension:{type:o.LoadParser,name:"loadVideo"},test(t){if(!za||!Na){const{validVideoExtensions:t,validVideoMime:e}=function(){const t=[],e=[];for(const i of La){const n=ze.MIME_TYPES[i.substring(1)]||`video/${i.substring(1)}`;ha(n)&&(t.push(i),e.includes(n)||e.push(n))}return{validVideoExtensions:t,validVideoMime:e}}();za=t,Na=e}const e=ga(t,Na),i=ma(t,za);return e||i},load(t,e,i){return __async(this,null,function*(){var n,r;const s=__spreadValues(__spreadProps(__spreadValues({},ze.defaultOptions),{resolution:(null==(n=e.data)?void 0:n.resolution)||Ca(t),alphaMode:(null==(r=e.data)?void 0:r.alphaMode)||(yield Ge())}),e.data),o=document.createElement("video"),a={preload:!1!==s.autoLoad?"auto":void 0,"webkit-playsinline":!1!==s.playsinline?"":void 0,playsinline:!1!==s.playsinline?"":void 0,muted:!0===s.muted?"":void 0,loop:!0===s.loop?"":void 0,autoplay:!1!==s.autoPlay?"":void 0};Object.keys(a).forEach(t=>{const e=a[t];void 0!==e&&o.setAttribute(t,e)}),!0===s.muted&&(o.muted=!0),Va(o,t,s.crossorigin);const l=document.createElement("source");let h;if(s.mime)h=s.mime;else if(t.startsWith("data:"))h=t.slice(5,t.indexOf(";"));else if(!t.startsWith("blob:")){const e=t.split("?")[0].slice(t.lastIndexOf(".")+1).toLowerCase();h=ze.MIME_TYPES[e]||`video/${e}`}return l.src=t,h&&(l.type=h),new Promise(n=>{const r=()=>__async(null,null,function*(){const a=new ze(__spreadProps(__spreadValues({},s),{resource:o}));var l;o.removeEventListener("canplay",r),e.data.preload&&(yield(l=o,new Promise((t,e)=>{function i(){r(),t()}function n(t){r(),e(t)}function r(){l.removeEventListener("canplaythrough",i),l.removeEventListener("error",n)}l.addEventListener("canplaythrough",i),l.addEventListener("error",n),l.load()}))),n(Pa(a,i,t))});s.preload&&!s.autoPlay&&o.load(),o.addEventListener("canplay",r),o.appendChild(l)})})},unload(t){t.destroy(!0)}},Wa={extension:{type:o.ResolveParser,name:"resolveTexture"},test:Ga.test,parse:t=>{var e,i;return{resolution:parseFloat(null!=(i=null==(e=Qe.RETINA_PREFIX.exec(t))?void 0:e[1])?i:"1"),format:t.split(".").pop(),src:t}}},ja={extension:{type:o.ResolveParser,priority:-2,name:"resolveJson"},test:t=>Qe.RETINA_PREFIX.test(t)&&t.endsWith(".json"),parse:Wa.parse};const Ya=new class{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Qe,this.loader=new fa,this.cache=Ve,this._backgroundLoader=new ia(this.loader),this._backgroundLoader.active=!0,this.reset()}init(){return __async(this,arguments,function*(t={}){var e,i,n;if(this._initialized)return void kt("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let e=t.manifest;"string"==typeof e&&(e=yield this.load(e)),this.resolver.addManifest(e)}const r=null!=(i=null==(e=t.texturePreference)?void 0:e.resolution)?i:1,s="number"==typeof r?[r]:r,o=yield this._detectFormats({preferredFormats:null==(n=t.texturePreference)?void 0:n.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:o,resolution:s}}),t.preferences&&this.setPreferences(t.preferences)})}add(t){this.resolver.add(t)}load(t,e){return __async(this,null,function*(){this._initialized||(yield this.init());const i=Ke(t),n=Ne(t).map(t=>{if("string"!=typeof t){const e=this.resolver.getAlias(t);return e.some(t=>!this.resolver.hasKey(t))&&this.add(t),Array.isArray(e)?e[0]:e}return this.resolver.hasKey(t)||this.add({alias:t,src:t}),t}),r=this.resolver.resolve(n),s=yield this._mapLoadToResolve(r,e);return i?s[n[0]]:s})}addBundle(t,e){this.resolver.addBundle(t,e)}loadBundle(t,e){return __async(this,null,function*(){this._initialized||(yield this.init());let i=!1;"string"==typeof t&&(i=!0,t=[t]);const n=this.resolver.resolveBundle(t),r={},s=Object.keys(n);let o=0,a=0;const l=()=>{null==e||e(++o/a)},h=s.map(t=>{const e=n[t],i=Object.values(e),s=[...new Set(i.flat())];return a+=s.length,this._mapLoadToResolve(e,l).then(e=>{r[t]=e})});return yield Promise.all(h),i?r[t[0]]:r})}backgroundLoad(t){return __async(this,null,function*(){this._initialized||(yield this.init()),"string"==typeof t&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))})}backgroundLoadBundle(t){return __async(this,null,function*(){this._initialized||(yield this.init()),"string"==typeof t&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(t=>{this._backgroundLoader.add(Object.values(t))})})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if("string"==typeof t)return Ve.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=Ve.get(t[i]);return e}_mapLoadToResolve(t,e){return __async(this,null,function*(){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const n=yield this.loader.load(i,e);this._backgroundLoader.active=!0;const r={};return i.forEach(t=>{const e=n[t.src],i=[t.src];t.alias&&i.push(...t.alias),i.forEach(t=>{r[t]=e}),Ve.set(i,e)}),r})}unload(t){return __async(this,null,function*(){this._initialized||(yield this.init());const e=Ne(t).map(t=>"string"!=typeof t?t.src:t),i=this.resolver.resolve(e);yield this._unloadFromResolved(i)})}unloadBundle(t){return __async(this,null,function*(){this._initialized||(yield this.init()),t=Ne(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(t=>this._unloadFromResolved(e[t]));yield Promise.all(i)})}_unloadFromResolved(t){return __async(this,null,function*(){const e=Object.values(t);e.forEach(t=>{Ve.remove(t.src)}),yield this.loader.unload(e)})}_detectFormats(t){return __async(this,null,function*(){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||(yield i.test())?e=yield i.add(e):t.skipDetections||(e=yield i.remove(e));return e=e.filter((t,i)=>e.indexOf(t)===i),e})}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(e=>e in t).forEach(i=>{e.config[i]=t[i]})})}};h.handleByList(o.LoadParser,Ya.loader.parsers).handleByList(o.ResolveParser,Ya.resolver.parsers).handleByList(o.CacheParser,Ya.cache.parsers).handleByList(o.DetectionParser,Ya.detections),h.add(na,aa,sa,pa,ca,ua,da,_a,ya,Ta,Ma,Ga,Ha,ea,ta,Wa,ja);const Xa={loader:o.LoadParser,resolver:o.ResolveParser,cache:o.CacheParser,detection:o.DetectionParser};h.handle(o.Asset,t=>{const e=t.ref;Object.entries(Xa).filter(([t])=>!!e[t]).forEach(([t,i])=>{var n;return h.add(Object.assign(e[t],{extension:null!=(n=e[t].extension)?n:i}))})},t=>{const e=t.ref;Object.keys(Xa).filter(t=>!!e[t]).forEach(t=>h.remove(e[t]))});class Za extends be{constructor(t={}){const e=t,{element:i,anchor:n}=e,r=__objRest(e,["element","anchor"]);super(__spreadValues({label:"DOMContainer"},r)),this.renderPipeId="dom",this.batched=!1,this._anchor=new v(0,0),n&&(this.anchor=n),this.element=t.element||document.createElement("div")}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}set element(t){this._element!==t&&(this._element=t,this.onViewUpdate())}get element(){return this._element}updateBounds(){const t=this._bounds,e=this._element;if(!e)return t.minX=0,t.minY=0,t.maxX=0,void(t.maxY=0);const{offsetWidth:i,offsetHeight:n}=e;t.minX=0,t.maxX=i,t.minY=0,t.maxY=n}destroy(t=!1){var e,i;super.destroy(t),null==(i=null==(e=this._element)?void 0:e.parentNode)||i.removeChild(this._element),this._element=null,this._anchor=null}}class qa{constructor(t){this._attachedDomElements=[],this._renderer=t,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 si({domElement:this._domElement,renderer:this._renderer})}addRenderable(t,e){this._attachedDomElements.includes(t)||this._attachedDomElements.push(t)}updateRenderable(t){}validateRenderable(t){return!0}postrender(){const t=this._attachedDomElements;if(0!==t.length){this._canvasObserver.ensureAttached();for(let e=0;e<t.length;e++){const i=t[e],n=i.element;if(!i.parent||i.globalDisplayStatus<7)null==n||n.remove(),t.splice(e,1),e--;else{this._domElement.contains(n)||(n.style.position="absolute",n.style.pointerEvents="auto",this._domElement.appendChild(n));const t=i.worldTransform,e=i._anchor,r=i.width*e.x,s=i.height*e.y;n.style.transformOrigin=`${r}px ${s}px`,n.style.transform=`matrix(${t.a}, ${t.b}, ${t.c}, ${t.d}, ${t.tx-r}, ${t.ty-s})`,n.style.opacity=i.groupAlpha.toString()}}}else this._domElement.remove()}destroy(){var t;this._renderer.runners.postrender.remove(this);for(let e=0;e<this._attachedDomElements.length;e++){null==(t=this._attachedDomElements[e].element)||t.remove()}this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}qa.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"dom"};const $a=new class{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){!this._tickerAdded&&this.domElement&&(Ue.system.add(this._tickerUpdate,this,ke.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(Ue.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove)return void(this._didMove=!1);const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&"touch"===t.pointerType||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}):new MouseEvent("mousemove",{clientX:t.clientX,clientY:t.clientY}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,this._deltaTime<this.interactionFrequency||(this._deltaTime=0,this._update())}};class Ka extends oi{constructor(){super(...arguments),this.client=new v,this.movement=new v,this.offset=new v,this.global=new v,this.screen=new v}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,n,r,s,o,a,l,h,c,u,d,p,f){throw new Error("Method not implemented.")}}class Qa extends Ka{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Ja extends Ka{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Ja.DOM_DELTA_PIXEL=0,Ja.DOM_DELTA_LINE=1,Ja.DOM_DELTA_PAGE=2;const tl=new v,el=new v;class il{constructor(t){this.dispatch=new _,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((t,e)=>t.priority-e.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,n=e.length;i<n;i++)e[i].fn(t);else kt(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){$a.pauseUpdate=!0;const i=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,tl.set(t,e),this.hitTestFn,this.hitPruneFn);return i&&i[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let n=0,r=i.length-1;n<r;n++)if(t.currentTarget=i[n],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!t.propagationStopped&&!t.propagationImmediatelyStopped){t.eventPhase=t.BUBBLING_PHASE;for(let n=i.length-2;n>=0;n--)if(t.currentTarget=i[n],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(0===i.length)return;t.eventPhase=t.BUBBLING_PHASE;const n=Array.isArray(e)?e:[e];for(let r=i.length-1;r>=0;r--)n.forEach(e=>{t.currentTarget=i[r],this.notifyTarget(t,e)})}propagationPath(t){const e=[t];for(let i=0;i<2048&&t!==this.rootTarget&&t.parent;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,n,r,s=!1){let o=!1;if(this._interactivePrune(t))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||($a.pauseUpdate=!1),t.interactiveChildren&&t.children){const a=t.children;for(let l=a.length-1;l>=0;l--){const h=a[l],c=this.hitTestMoveRecursive(h,this._isInteractive(e)?e:h.eventMode,i,n,r,s||r(t,i));if(c){if(c.length>0&&!c[c.length-1].parent)continue;const e=t.isInteractive();(c.length>0||e)&&(e&&this._allInteractiveElements.push(t),c.push(t)),0===this._hitElements.length&&(this._hitElements=c),o=!0}}}const a=this._isInteractive(e),l=t.isInteractive();return l&&l&&this._allInteractiveElements.push(t),s||this._hitElements.length>0?null:o?this._hitElements:a&&!r(t,i)&&n(t,i)?l?[t]:[]:null}hitTestRecursive(t,e,i,n,r){if(this._interactivePrune(t)||r(t,i))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||($a.pauseUpdate=!1),t.interactiveChildren&&t.children){const s=t.children,o=i;for(let i=s.length-1;i>=0;i--){const a=s[i],l=this.hitTestRecursive(a,this._isInteractive(e)?e:a.eventMode,o,n,r);if(l){if(l.length>0&&!l[l.length-1].parent)continue;const e=t.isInteractive();return(l.length>0||e)&&l.push(t),l}}}const s=this._isInteractive(e),o=t.isInteractive();return s&&n(t,i)?o?[t]:[]:null}_isInteractive(t){return"static"===t||"dynamic"===t}_interactivePrune(t){return!(t&&t.visible&&t.renderable&&t.measurable)||("none"===t.eventMode||"passive"===t.eventMode&&!t.interactiveChildren)}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,el),!t.hitArea.contains(el.x,el.y)))return!0;if(t.effects&&t.effects.length)for(let i=0;i<t.effects.length;i++){const n=t.effects[i];if(n.containsPoint){if(!n.containsPoint(e,this.hitTestFn))return!0}}return!1}hitTestFn(t,e){return!!t.hitArea||!!(null==t?void 0:t.containsPoint)&&(t.worldTransform.applyInverse(e,el),t.containsPoint(el))}notifyTarget(t,e){var i,n;if(!t.currentTarget.isInteractive())return;null!=e||(e=t.type);const r=`on${e}`;null==(n=(i=t.currentTarget)[r])||n.call(i,t);const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof Qa))return void kt("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType)this.dispatchEvent(e,"touchstart");else if("mouse"===e.pointerType||"pen"===e.pointerType){const t=2===e.button;this.dispatchEvent(e,t?"rightdown":"mousedown")}this.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,i,n;if(!(t instanceof Qa))return void kt("EventBoundary cannot map a non-pointer event as a pointer event");this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const r=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const s="mouse"===r.pointerType||"pen"===r.pointerType,o=this.trackingData(t.pointerId),a=this.findMountedTarget(o.overTargets);if((null==(e=o.overTargets)?void 0:e.length)>0&&a!==r.target){const e="mousemove"===t.type?"mouseout":"pointerout",i=this.createPointerEvent(t,e,a);if(this.dispatchEvent(i,"pointerout"),s&&this.dispatchEvent(i,"mouseout"),!r.composedPath().includes(a)){const e=this.createPointerEvent(t,"pointerleave",a);for(e.eventPhase=e.AT_TARGET;e.target&&!r.composedPath().includes(e.target);)e.currentTarget=e.target,this.notifyTarget(e),s&&this.notifyTarget(e,"mouseleave"),e.target=e.target.parent;this.freeEvent(e)}this.freeEvent(i)}if(a!==r.target){const e="mousemove"===t.type?"mouseover":"pointerover",i=this.clonePointerEvent(r,e);this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover");let n=null==a?void 0:a.parent;for(;n&&n!==this.rootTarget.parent&&n!==r.target;)n=n.parent;if(!n||n===this.rootTarget.parent){const t=this.clonePointerEvent(r,"pointerenter");for(t.eventPhase=t.AT_TARGET;t.target&&t.target!==a&&t.target!==this.rootTarget.parent;)t.currentTarget=t.target,this.notifyTarget(t),s&&this.notifyTarget(t,"mouseenter"),t.target=t.target.parent;this.freeEvent(t)}this.freeEvent(i)}const l=[],h=null==(i=this.enableGlobalMoveEvents)||i;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(r,"pointermove"),h&&l.push("globalpointermove"),"touch"===r.pointerType&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(r,"touchmove"),h&&l.push("globaltouchmove")),s&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(r,"mousemove"),h&&l.push("globalmousemove"),this.cursor=null==(n=r.target)?void 0:n.cursor),l.length>0&&this.all(r,l),this._allInteractiveElements.length=0,this._hitElements.length=0,o.overTargets=r.composedPath(),this.freeEvent(r)}mapPointerOver(t){var e;if(!(t instanceof Qa))return void kt("EventBoundary cannot map a non-pointer event as a pointer event");const i=this.trackingData(t.pointerId),n=this.createPointerEvent(t),r="mouse"===n.pointerType||"pen"===n.pointerType;this.dispatchEvent(n,"pointerover"),r&&this.dispatchEvent(n,"mouseover"),"mouse"===n.pointerType&&(this.cursor=null==(e=n.target)?void 0:e.cursor);const s=this.clonePointerEvent(n,"pointerenter");for(s.eventPhase=s.AT_TARGET;s.target&&s.target!==this.rootTarget.parent;)s.currentTarget=s.target,this.notifyTarget(s),r&&this.notifyTarget(s,"mouseenter"),s.target=s.target.parent;i.overTargets=n.composedPath(),this.freeEvent(n),this.freeEvent(s)}mapPointerOut(t){if(!(t instanceof Qa))return void kt("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId);if(e.overTargets){const i="mouse"===t.pointerType||"pen"===t.pointerType,n=this.findMountedTarget(e.overTargets),r=this.createPointerEvent(t,"pointerout",n);this.dispatchEvent(r),i&&this.dispatchEvent(r,"mouseout");const s=this.createPointerEvent(t,"pointerleave",n);for(s.eventPhase=s.AT_TARGET;s.target&&s.target!==this.rootTarget.parent;)s.currentTarget=s.target,this.notifyTarget(s),i&&this.notifyTarget(s,"mouseleave"),s.target=s.target.parent;e.overTargets=null,this.freeEvent(r),this.freeEvent(s)}this.cursor=null}mapPointerUp(t){if(!(t instanceof Qa))return void kt("EventBoundary cannot map a non-pointer event as a pointer event");const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),"touch"===i.pointerType)this.dispatchEvent(i,"touchend");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.dispatchEvent(i,t?"rightup":"mouseup")}const n=this.trackingData(t.pointerId),r=this.findMountedTarget(n.pressTargetsByButton[t.button]);let s=r;if(r&&!i.composedPath().includes(r)){let e=r;for(;e&&!i.composedPath().includes(e);){if(i.currentTarget=e,this.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType)this.notifyTarget(i,"touchendoutside");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.notifyTarget(i,t?"rightupoutside":"mouseupoutside")}e=e.parent}delete n.pressTargetsByButton[t.button],s=e}if(s){const r=this.clonePointerEvent(i,"click");r.target=s,r.path=null,n.clicksByButton[t.button]||(n.clicksByButton[t.button]={clickCount:0,target:r.target,timeStamp:e});const o=n.clicksByButton[t.button];if(o.target===r.target&&e-o.timeStamp<200?++o.clickCount:o.clickCount=1,o.target=r.target,o.timeStamp=e,r.detail=o.clickCount,"mouse"===r.pointerType){const t=2===r.button;this.dispatchEvent(r,t?"rightclick":"click")}else"touch"===r.pointerType&&this.dispatchEvent(r,"tap");this.dispatchEvent(r,"pointertap"),this.freeEvent(r)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof Qa))return void kt("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),n=this.createPointerEvent(t);if(i){let r=i;for(;r;)n.currentTarget=r,this.notifyTarget(n,"pointerupoutside"),"touch"===n.pointerType?this.notifyTarget(n,"touchendoutside"):"mouse"!==n.pointerType&&"pen"!==n.pointerType||this.notifyTarget(n,2===n.button?"rightupoutside":"mouseupoutside"),r=r.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(n)}mapWheel(t){if(!(t instanceof Ja))return void kt("EventBoundary cannot map a non-wheel event as a wheel event");const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){var n;const r=this.allocateEvent(Qa);return this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=null!=(n=null!=i?i:this.hitTest(r.global.x,r.global.y))?n:this._hitElements[0],"string"==typeof e&&(r.type=e),r}createWheelEvent(t){const e=this.allocateEvent(Ja);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(Qa);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=null!=e?e:i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Qa&&e instanceof Qa&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof Ka&&e instanceof Ka&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.defaultPrevented=!1,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}_notifyListeners(t,e){const i=t.currentTarget._events[e];if(i)if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let n=0,r=i.length;n<r&&!t.propagationImmediatelyStopped;n++)i[n].once&&t.currentTarget.removeListener(e,i[n].fn,void 0,!0),i[n].fn.call(i[n].context,t)}}const nl={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},rl=class t{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new il(null),$a.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Qa(null),this._rootWheelEvent=new Ja(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(__spreadValues({},t.defaultEventFeatures),{set:(t,e,i)=>("globalMove"===e&&(this.rootBoundary.enableGlobalMoveEvents=i),t[e]=i,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){var i,n;const{canvas:r,resolution:s}=this.renderer;this.setTargetElement(r),this.resolution=s,t._defaultEventMode=null!=(i=e.eventMode)?i:"passive",Object.assign(this.features,null!=(n=e.eventFeatures)?n:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t||(t="default");let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i)}else e&&"string"==typeof t&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);if(this.autoPreventDefault&&e[0].isNormalized){(t.cancelable||!("cancelable"in t))&&t.preventDefault()}for(let i=0,n=e.length;i<n;i++){const t=e[i],n=this._bootstrapEvent(this._rootPointerEvent,t);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,$a.pointerMoved();const e=this._normalizeToPointerData(t);for(let i=0,n=e.length;i<n;i++){const t=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",n=this._normalizeToPointerData(t);for(let r=0,s=n.length;r<s;r++){const t=this._bootstrapEvent(this._rootPointerEvent,n[r]);t.type+=i,this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);for(let i=0,n=e.length;i<n;i++){const t=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this._removeEvents(),this.domElement=t,$a.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;$a.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;$a.removeTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(t,e,i){const n=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},r=1/this.resolution;t.x=(e-n.left)*(this.domElement.width/n.width)*r,t.y=(i-n.top)*(this.domElement.height/n.height)*r}_normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,n=t.changedTouches.length;i<n;i++){const n=t.changedTouches[i];void 0===n.button&&(n.button=0),void 0===n.buttons&&(n.buttons=1),void 0===n.isPrimary&&(n.isPrimary=1===t.touches.length&&"touchstart"===t.type),void 0===n.width&&(n.width=n.radiusX||1),void 0===n.height&&(n.height=n.radiusY||1),void 0===n.tiltX&&(n.tiltX=0),void 0===n.tiltY&&(n.tiltY=0),void 0===n.pointerType&&(n.pointerType="touch"),void 0===n.pointerId&&(n.pointerId=n.identifier||0),void 0===n.pressure&&(n.pressure=n.force||.5),void 0===n.twist&&(n.twist=0),void 0===n.tangentialPressure&&(n.tangentialPressure=0),void 0===n.layerX&&(n.layerX=n.offsetX=n.clientX),void 0===n.layerY&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(globalThis.MouseEvent&&(!(t instanceof MouseEvent)||this.supportsPointerEvents&&t instanceof globalThis.PointerEvent))e.push(t);else{const i=t;void 0===i.isPrimary&&(i.isPrimary=!0),void 0===i.width&&(i.width=1),void 0===i.height&&(i.height=1),void 0===i.tiltX&&(i.tiltX=0),void 0===i.tiltY&&(i.tiltY=0),void 0===i.pointerType&&(i.pointerType="mouse"),void 0===i.pointerId&&(i.pointerId=1),void 0===i.pressure&&(i.pressure=.5),void 0===i.twist&&(i.twist=0),void 0===i.tangentialPressure&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}return e}normalizeWheelEvent(t){const e=this._rootWheelEvent;return this._transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}_bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this._transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=nl[t.type]||t.type),t}_transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};rl.extension={name:"events",type:[o.WebGLSystem,o.CanvasSystem,o.WebGPUSystem],priority:-1},rl.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let sl=rl;const ol={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return"dynamic"===this.eventMode||"static"===this.eventMode},set interactive(t){this.eventMode=t?"static":"passive"},_internalEventMode:void 0,get eventMode(){var t;return null!=(t=this._internalEventMode)?t:sl.defaultEventMode},set eventMode(t){this._internalEventMode=t},isInteractive(){return"static"===this.eventMode||"dynamic"===this.eventMode},interactiveChildren:!0,hitArea:null,addEventListener(t,e,i){const n="boolean"==typeof i&&i||"object"==typeof i&&i.capture,r="object"==typeof i?i.signal:void 0,s="object"==typeof i&&!0===i.once,o="function"==typeof e?void 0:e;t=n?`${t}capture`:t;const a="function"==typeof e?e:e.handleEvent,l=this;r&&r.addEventListener("abort",()=>{l.off(t,a,o)}),s?l.once(t,a,o):l.on(t,a,o)},removeEventListener(t,e,i){const n="function"==typeof e?void 0:e;t="boolean"==typeof i&&i||"object"==typeof i&&i.capture?`${t}capture`:t,e="function"==typeof e?e:e.handleEvent,this.off(t,e,n)},dispatchEvent(t){if(!(t instanceof oi))throw new Error("Container cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=null,t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}};class al{constructor(t){this._renderer=t}push(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){"pushFilter"===t.action?this._renderer.filter.push(t):"popFilter"===t.action&&this._renderer.filter.pop()}destroy(){this._renderer=null}}al.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"filter"};const ll=new jr({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class hl{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new it,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0}}}class cl{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new Ki({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new Qi({}),this.renderer=t}get activeBackTexture(){var t;return null==(t=this._activeFilterData)?void 0:t.backTexture}push(t){const e=this.renderer,i=t.filterEffect.filters,n=this._pushFilterData();n.skip=!1,n.filters=i,n.container=t.container,n.outputRenderSurface=e.renderTarget.renderSurface;const r=e.renderTarget.renderTarget.colorTexture.source,s=r.resolution,o=r.antialias;if(0===i.length)return void(n.skip=!0);const a=n.bounds;if(this._calculateFilterArea(t,a),this._calculateFilterBounds(n,e.renderTarget.rootViewPort,o,s,1),n.skip)return;const l=this._getPreviousFilterData(),h=this._findFilterResolution(s);let c=0,u=0;l&&(c=l.bounds.minX,u=l.bounds.minY),this._calculateGlobalFrame(n,c,u,h,r.width,r.height),this._setupFilterTextures(n,a,e,l)}generateFilteredTexture({texture:t,filters:e}){const i=this._pushFilterData();this._activeFilterData=i,i.skip=!1,i.filters=e;const n=t.source,r=n.resolution,s=n.antialias;if(0===e.length)return i.skip=!0,t;const o=i.bounds;if(o.addRect(t.frame),this._calculateFilterBounds(i,o.rectangle,s,r,0),i.skip)return t;const a=r;this._calculateGlobalFrame(i,0,0,a,n.width,n.height),i.outputRenderSurface=pe.getOptimalTexture(o.width,o.height,i.resolution,i.antialias),i.backTexture=J.EMPTY,i.inputTexture=t;this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(i,!0);const l=i.outputRenderSurface;return l.source.alphaMode="premultiplied-alpha",l}pop(){const t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&pe.returnTexture(e.backTexture),pe.returnTexture(e.inputTexture))}getBackTexture(t,e,i){const n=t.colorTexture.source._resolution,r=pe.getOptimalTexture(e.width,e.height,n,!1);let s=e.minX,o=e.minY;i&&(s-=i.minX,o-=i.minY),s=Math.floor(s*n),o=Math.floor(o*n);const a=Math.ceil(e.width*n),l=Math.ceil(e.height*n);return this.renderer.renderTarget.copyToTexture(t,r,{x:s,y:o},{width:a,height:l},{x:0,y:0}),r}applyFilter(t,e,i,n){const r=this.renderer,s=this._activeFilterData,o=s.outputRenderSurface===i,a=r.renderTarget.rootRenderTarget.colorTexture.source._resolution,l=this._findFilterResolution(a);let h=0,c=0;if(o){const t=this._findPreviousFilterOffset();h=t.x,c=t.y}this._updateFilterUniforms(e,i,s,h,c,l,o,n),this._setupBindGroupsAndRender(t,e,r)}calculateSpriteMatrix(t,e){const i=this._activeFilterData,n=t.set(i.inputTexture._source.width,0,0,i.inputTexture._source.height,i.bounds.minX,i.bounds.minY),r=e.worldTransform.copyTo(S.shared),s=e.renderGroup||e.parentRenderGroup;return s&&s.cacheToLocalTransform&&r.prepend(s.cacheToLocalTransform),r.invert(),n.prepend(r),n.scale(1/e.texture.orig.width,1/e.texture.orig.height),n.translate(e.anchor.x,e.anchor.y),n}destroy(){}_setupBindGroupsAndRender(t,e,i){if(i.renderPipes.uniformBatch){const t=i.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(t,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,i.encoder.draw({geometry:ll,shader:t,state:t._state,topology:"triangle-list"}),i.type===Ji.WEBGL&&i.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,i,n){if(t.backTexture=J.EMPTY,t.blendRequired){i.renderTarget.finishRenderPass();const r=i.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(r,e,null==n?void 0:n.bounds)}t.inputTexture=pe.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),i.renderTarget.bind(t.inputTexture,!0),i.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,i,n,r,s){const o=t.globalFrame;o.x=e*n,o.y=i*n,o.width=r*n,o.height=s*n}_updateFilterUniforms(t,e,i,n,r,s,o,a){const l=this._filterGlobalUniforms.uniforms,h=l.uOutputFrame,c=l.uInputSize,u=l.uInputPixel,d=l.uInputClamp,p=l.uGlobalFrame,f=l.uOutputTexture;o?(h[0]=i.bounds.minX-n,h[1]=i.bounds.minY-r):(h[0]=0,h[1]=0),h[2]=t.frame.width,h[3]=t.frame.height,c[0]=t.source.width,c[1]=t.source.height,c[2]=1/c[0],c[3]=1/c[1],u[0]=t.source.pixelWidth,u[1]=t.source.pixelHeight,u[2]=1/u[0],u[3]=1/u[1],d[0]=.5*u[2],d[1]=.5*u[3],d[2]=t.frame.width*c[2]-.5*u[2],d[3]=t.frame.height*c[3]-.5*u[3];const g=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=n*s,p[1]=r*s,p[2]=g.source.width*s,p[3]=g.source.height*s,e instanceof J&&(e.source.resource=null);const m=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!a),e instanceof J?(f[0]=e.frame.width,f[1]=e.frame.height):(f[0]=m.width,f[1]=m.height),f[2]=m.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,i=this._filterStackIndex;for(;i>0;){i--;const n=this._filterStack[i];if(!n.skip){t=n.bounds.minX,e=n.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?function(t,e){e.clear();const i=e.matrix;for(let n=0;n<t.length;n++){const i=t[n];i.globalDisplayStatus<7||(e.matrix=i.worldTransform,e.addBounds(i.bounds))}e.matrix=i}(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){const i=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;i&&e.applyMatrix(i)}}_applyFiltersToTexture(t,e){const i=t.inputTexture,n=t.bounds,r=t.filters;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),1===r.length)r[0].apply(this,i,t.outputRenderSurface,e);else{let i=t.inputTexture;const s=pe.getOptimalTexture(n.width,n.height,i.source._resolution,!1);let o=s,a=0;for(a=0;a<r.length-1;++a){r[a].apply(this,i,o,!0);const t=i;i=o,o=t}r[a].apply(this,i,t.outputRenderSurface,e),pe.returnTexture(s)}}_calculateFilterBounds(t,e,i,n,r){var s,o;const a=this.renderer,l=t.bounds,h=t.filters;let c=1/0,u=0,d=!0,p=!1,f=!1,g=!0;for(let m=0;m<h.length;m++){const t=h[m];c=Math.min(c,"inherit"===t.resolution?n:t.resolution),u+=t.padding,"off"===t.antialias?d=!1:"inherit"===t.antialias&&d&&(d=i),t.clipToViewport||(g=!1);if(!!!(t.compatibleRenderers&a.type)){f=!1;break}if(t.blendRequired&&null!=(o=null==(s=a.backBuffer)?void 0:s.useBackBuffer)&&!o){kt("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),f=!1;break}f=t.enabled||f,p||(p=t.blendRequired)}f?(g&&l.fitBounds(0,e.width/n,0,e.height/n),l.scale(c).ceil().scale(1/c).pad((0|u)*r),l.isPositive?(t.antialias=d,t.resolution=c,t.blendRequired=p):t.skip=!0):t.skip=!0}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>1&&(e--,t=this._filterStack[e],t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new hl),this._filterStackIndex++,t}}cl.extension={type:[o.WebGLSystem,o.WebGPUSystem],name:"filter"};var ul="struct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\nstruct MaskUniforms {\n uFilterMatrix:mat3x3<f32>,\n uMaskClamp:vec4<f32>,\n uAlpha:f32,\n uInverse:f32,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n@group(0) @binding(1) var uTexture: texture_2d<f32>;\n@group(0) @binding(2) var uSampler : sampler;\n\n@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;\n@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>,\n @location(1) filterUv : vec2<f32>,\n};\n\nfn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>\n{\n var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;\n\n position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nfn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);\n}\n\nfn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);\n}\n\nfn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>\n{\n return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;\n}\n\nfn getSize() -> vec2<f32>\n{\n return gfu.uGlobalFrame.zw;\n}\n\n@vertex\nfn mainVertex(\n @location(0) aPosition : vec2<f32>,\n) -> VSOutput {\n return VSOutput(\n filterVertexPosition(aPosition),\n filterTextureCoord(aPosition),\n getFilterCoord(aPosition)\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @location(1) filterUv: vec2<f32>,\n @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n\n var maskClamp = filterUniforms.uMaskClamp;\n var uAlpha = filterUniforms.uAlpha;\n\n var clip = step(3.5,\n step(maskClamp.x, filterUv.x) +\n step(maskClamp.y, filterUv.y) +\n step(filterUv.x, maskClamp.z) +\n step(filterUv.y, maskClamp.w));\n\n var mask = textureSample(uMaskTexture, uSampler, filterUv);\n var source = textureSample(uTexture, uSampler, uv);\n var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);\n\n var a: f32 = alphaMul * mask.r * uAlpha * clip;\n\n if (filterUniforms.uInverse == 1.0) {\n a = 1.0 - a;\n }\n\n return source * a;\n}\n";class dl extends on{constructor(t){const e=t,{sprite:i}=e,n=__objRest(e,["sprite"]),r=new Q(i.texture),s=new Ki({uFilterMatrix:{value:new S,type:"mat3x3<f32>"},uMaskClamp:{value:r.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"}}),o=Yi.from({vertex:{source:ul,entryPoint:"mainVertex"},fragment:{source:ul,entryPoint:"mainFragment"}}),a=Li.from({vertex:"in vec2 aPosition;\n\nout vec2 vTextureCoord;\nout vec2 vMaskCoord;\n\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\nuniform mat3 uFilterMatrix;\n\nvec4 filterVertexPosition( vec2 aPosition )\n{\n vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n \n position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( vec2 aPosition )\n{\n return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvec2 getFilterCoord( vec2 aPosition )\n{\n return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;\n} \n\nvoid main(void)\n{\n gl_Position = filterVertexPosition(aPosition);\n vTextureCoord = filterTextureCoord(aPosition);\n vMaskCoord = getFilterCoord(aPosition);\n}\n",fragment:"in vec2 vMaskCoord;\nin vec2 vTextureCoord;\n\nuniform sampler2D uTexture;\nuniform sampler2D uMaskTexture;\n\nuniform float uAlpha;\nuniform vec4 uMaskClamp;\nuniform float uInverse;\n\nout vec4 finalColor;\n\nvoid main(void)\n{\n float clip = step(3.5,\n step(uMaskClamp.x, vMaskCoord.x) +\n step(uMaskClamp.y, vMaskCoord.y) +\n step(vMaskCoord.x, uMaskClamp.z) +\n step(vMaskCoord.y, uMaskClamp.w));\n\n // TODO look into why this is needed\n float npmAlpha = uAlpha;\n vec4 original = texture(uTexture, vTextureCoord);\n vec4 masky = texture(uMaskTexture, vMaskCoord);\n float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);\n\n float a = alphaMul * masky.r * npmAlpha * clip;\n\n if (uInverse == 1.0) {\n a = 1.0 - a;\n }\n\n finalColor = original * a;\n}\n",name:"mask-filter"});super(__spreadProps(__spreadValues({},n),{gpuProgram:o,glProgram:a,clipToViewport:!1,resources:{filterUniforms:s,uMaskTexture:i.texture.source}})),this.sprite=i,this._textureMatrix=r}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return 1===this.resources.filterUniforms.uniforms.uInverse}apply(t,e,i,n){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,i,n)}}function pl(t,e,i,n,r,s,o,a){const l=o-i,h=a-n,c=r-i,u=s-n,d=t-i,p=e-n,f=l*l+h*h,g=l*c+h*u,m=l*d+h*p,_=c*c+u*u,y=c*d+u*p,x=1/(f*_-g*g),b=(_*m-g*y)*x,v=(f*y-g*m)*x;return b>=0&&v>=0&&b+v<1}class fl extends be{constructor(t){t instanceof Do&&(t={context:t});const e=t||{},{context:i,roundPixels:n}=e,r=__objRest(e,["context","roundPixels"]);super(__spreadValues({label:"Graphics"},r)),this.renderPipeId="graphics",this._context=i||(this._ownedContext=new Do),this._context.on("update",this.onViewUpdate,this),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=null!=n&&n}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):!0!==t&&!0!==(null==t?void 0:t.context)||this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){if(t)return new fl(this._context.clone());this._ownedContext=null;return new fl(this._context)}lineStyle(t,e,i){z(L,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const n={};return t&&(n.width=t),e&&(n.color=e),i&&(n.alpha=i),this.context.strokeStyle=n,this}beginFill(t,e){z(L,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return void 0!==t&&(i.color=t),void 0!==e&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){z(L,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return t.width===Do.defaultStrokeStyle.width&&t.color===Do.defaultStrokeStyle.color&&t.alpha===Do.defaultStrokeStyle.alpha||this.context.stroke(),this}drawCircle(...t){return z(L,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return z(L,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return z(L,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return z(L,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return z(L,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return z(L,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const gl=class t extends jr{constructor(...e){var i;let n=null!=(i=e[0])?i:{};n instanceof Float32Array&&(z(L,"use new MeshGeometry({ positions, uvs, indices }) instead"),n={positions:n,uvs:e[1],indices:e[2]}),n=__spreadValues(__spreadValues({},t.defaultOptions),n);const r=n.positions||new Float32Array([0,0,1,0,1,1,0,1]);let s=n.uvs;s||(s=n.positions?new Float32Array(r.length):new Float32Array([0,0,1,0,1,1,0,1]));const o=n.indices||new Uint32Array([0,1,2,0,2,3]),a=n.shrinkBuffersToFit;super({attributes:{aPosition:{buffer:new Hr({data:r,label:"attribute-mesh-positions",shrinkToFit:a,usage:Vr.VERTEX|Vr.COPY_DST}),format:"float32x2",stride:8,offset:0},aUV:{buffer:new Hr({data:s,label:"attribute-mesh-uvs",shrinkToFit:a,usage:Vr.VERTEX|Vr.COPY_DST}),format:"float32x2",stride:8,offset:0}},indexBuffer:new Hr({data:o,label:"index-mesh-buffer",shrinkToFit:a,usage:Vr.INDEX|Vr.COPY_DST}),topology:n.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};gl.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let ml=gl;class _l extends be{constructor(...t){var e;let i=t[0];i instanceof jr&&(z(L,"Mesh: use new Mesh({ geometry, shader }) instead"),i={geometry:i,shader:t[1]},t[3]&&(z(L,"Mesh: drawMode argument has been removed, use geometry.topology instead"),i.geometry.topology=t[3]));const n=i,{geometry:r,shader:s,texture:o,roundPixels:a,state:l}=n,h=__objRest(n,["geometry","shader","texture","roundPixels","state"]);super(__spreadValues({label:"Mesh"},h)),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=null!=s?s:null,this.texture=null!=(e=null!=o?o:null==s?void 0:s.texture)?e:J.WHITE,this.state=null!=l?l:rn.for2d(),this._geometry=r,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=null!=a&&a}get material(){return z(L,"mesh.material property has been removed, use mesh.shader instead"),this._shader}set shader(t){this._shader!==t&&(this._shader=t,this.onViewUpdate())}get shader(){return this._shader}set geometry(t){var e;this._geometry!==t&&(null==(e=this._geometry)||e.off("update",this.onViewUpdate,this),t.on("update",this.onViewUpdate,this),this._geometry=t,this.onViewUpdate())}get geometry(){return this._geometry}set texture(t){t||(t=J.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this.shader&&(this.shader.texture=t),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get batched(){return!this._shader&&(!(12&this.state.data)&&(this._geometry instanceof ml&&("auto"===this._geometry.batchMode?this._geometry.positions.length/2<=100:"batch"===this._geometry.batchMode)))}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(t){const{x:e,y:i}=t;if(!this.bounds.containsPoint(e,i))return!1;const n=this.geometry.getBuffer("aPosition").data,r="triangle-strip"===this.geometry.topology?3:1;if(this.geometry.getIndex()){const t=this.geometry.getIndex().data,s=t.length;for(let o=0;o+2<s;o+=r){const r=2*t[o],s=2*t[o+1],a=2*t[o+2];if(pl(e,i,n[r],n[r+1],n[s],n[s+1],n[a],n[a+1]))return!0}}else{const t=n.length/2;for(let s=0;s+2<t;s+=r){const t=2*s,r=2*(s+1),o=2*(s+2);if(pl(e,i,n[t],n[t+1],n[r],n[r+1],n[o],n[o+1]))return!0}}return!1}destroy(t){var e;super.destroy(t);if("boolean"==typeof t?t:null==t?void 0:t.texture){const e="boolean"==typeof t?t:null==t?void 0:t.textureSource;this._texture.destroy(e)}null==(e=this._geometry)||e.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null,this._gpuData=null}}class yl extends ve{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const i=e,{animationSpeed:n=1,autoPlay:r=!1,autoUpdate:s=!0,loop:o=!0,onComplete:a=null,onFrameChange:l=null,onLoop:h=null,textures:c,updateAnchor:u=!1}=i,d=__objRest(i,["animationSpeed","autoPlay","autoUpdate","loop","onComplete","onFrameChange","onLoop","textures","updateAnchor"]),[p]=c;super(__spreadProps(__spreadValues({},d),{texture:p instanceof J?p:p.texture})),this._textures=null,this._durations=null,this._autoUpdate=s,this._isConnectedToTicker=!1,this.animationSpeed=n,this.loop=o,this.updateAnchor=u,this.onComplete=a,this.onFrameChange=l,this.onLoop=h,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=c,r&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(Ue.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Ue.shared.add(this.update,this,ke.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,i=this.animationSpeed*e,n=this.currentFrame;if(null!==this._durations){let t=this._currentTime%1*this._durations[this.currentFrame];for(t+=i/60*1e3;t<0;)this._currentTime--,t+=this._durations[this.currentFrame];const n=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);t>=this._durations[this.currentFrame];)t-=this._durations[this.currentFrame]*n,this._currentTime+=n;this._currentTime+=t/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()):n!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<n||this.animationSpeed<0&&this.currentFrame>n)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.texture.defaultAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t=!1){if("boolean"==typeof t?t:null==t?void 0:t.texture){const e="boolean"==typeof t?t:null==t?void 0:t.textureSource;this._textures.forEach(t=>{this.texture!==t&&t.destroy(e)})}this._textures=[],this._durations=null,this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;i<t.length;++i)e.push(J.from(t[i]));return new yl(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(J.from(t[i]));return new yl(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof J)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(let e=0;e<t.length;e++)this._textures.push(t[e].texture),this._durations.push(t[e].time)}this._previousFrame=null,this.gotoAndStop(0),this._updateTexture()}get currentFrame(){let t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}set currentFrame(t){if(t<0||t>this.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(Ue.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Ue.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class xl{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=null!=t?t:new S,this.observer=e,this.position=new d(this,0,0),this.scale=new d(this,1,1),this.pivot=new d(this,0,0),this.skew=new d(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){const t=this._matrix;return this.dirty?(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this.dirty=!1,t):t}_onUpdate(t){var e;this.dirty=!0,t===this.skew&&this.updateSkew(),null==(e=this.observer)||e._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(t){t.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this.skew))}}const bl=class t extends be{constructor(...e){let i=e[0]||{};i instanceof J&&(i={texture:i}),e.length>1&&(z(L,"use new TilingSprite({ texture, width:100, height:100 }) instead"),i.width=e[1],i.height=e[2]),i=__spreadValues(__spreadValues({},t.defaultOptions),i);const n=null!=i?i:{},{texture:r,anchor:s,tilePosition:o,tileScale:a,tileRotation:l,width:h,height:c,applyAnchorToTexture:u,roundPixels:p}=n,f=__objRest(n,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(__spreadValues({label:"TilingSprite"},f)),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new d({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=u,this.texture=r,this._width=null!=h?h:r.width,this._height=null!=c?c:r.height,this._tileTransform=new xl({observer:{_onUpdate:()=>this.onViewUpdate()}}),s&&(this.anchor=s),this.tilePosition=o,this.tileScale=a,this.tileRotation=l,this.roundPixels=null!=p&&p}static from(e,i={}){return new t(__spreadValues("string"==typeof e?{texture:Ve.get(e)}:{texture:e},i))}get uvRespectAnchor(){return kt("uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(t){kt("uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture=t}get clampMargin(){return this._texture.textureMatrix.clampMargin}set clampMargin(t){this._texture.textureMatrix.clampMargin=t}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}get tilePosition(){return this._tileTransform.position}set tilePosition(t){this._tileTransform.position.copyFrom(t)}get tileScale(){return this._tileTransform.scale}set tileScale(t){"number"==typeof t?this._tileTransform.scale.set(t):this._tileTransform.scale.copyFrom(t)}set tileRotation(t){this._tileTransform.rotation=t}get tileRotation(){return this._tileTransform.rotation}get tileTransform(){return this._tileTransform}set texture(t){t||(t=J.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}set width(t){this._width=t,this.onViewUpdate()}get width(){return this._width}set height(t){this._height=t,this.onViewUpdate()}get height(){return this._height}setSize(t,e){var i;"object"==typeof t&&(e=null!=(i=t.height)?i:t.width,t=t.width),this._width=t,this._height=null!=e?e:t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}updateBounds(){const t=this._bounds,e=this._anchor,i=this._width,n=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}containsPoint(t){const e=this._width,i=this._height,n=-e*this._anchor._x;let r=0;return t.x>=n&&t.x<=n+e&&(r=-i*this._anchor._y,t.y>=r&&t.y<=r+i)}destroy(t=!1){super.destroy(t),this._anchor=null,this._tileTransform=null,this._bounds=null;if("boolean"==typeof t?t:null==t?void 0:t.texture){const e="boolean"==typeof t?t:null==t?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}};bl.defaultOptions={texture:J.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let vl=bl;class wl extends be{constructor(t,e){const i=t,{text:n,resolution:r,style:s,anchor:o,width:a,height:l,roundPixels:h}=i,c=__objRest(i,["text","resolution","style","anchor","width","height","roundPixels"]);super(__spreadValues({},c)),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=null!=n?n:"",this.style=s,this.resolution=null!=r?r:null,this.allowChildren=!1,this._anchor=new d({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),this.roundPixels=null!=h&&h,void 0!==a&&(this.width=a),void 0!==l&&(this.height=l)}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=null===t,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t||(t={}),null==(e=this._style)||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){var i;"object"==typeof t?(e=null!=(i=t.height)?i:t.width,t=t.width):null!=e||(e=t),void 0!==t&&this._setWidth(t,this.bounds.width),void 0!==e&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,n=-e*this.anchor.x;let r=0;return t.x>=n&&t.x<=n+e&&(r=-i*this.anchor.y,t.y>=r&&t.y<=r+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,("boolean"==typeof t?t:null==t?void 0:t.style)&&this._style.destroy(t),this._style=null,this._text=null}}let Sl=null,Al=null;function Tl(t,e,i){for(let n=0,r=4*i*e;n<e;++n,r+=4)if(0!==t[r+3])return!1;return!0}function Cl(t,e,i,n,r){const s=4*e;for(let o=n,a=n*s+4*i;o<=r;++o,a+=s)if(0!==t[a+3])return!1;return!0}function Pl(...t){var e,i,n;let r=t[0];r.canvas||(r={canvas:t[0],resolution:t[1]});const{canvas:s}=r,o=Math.min(null!=(e=r.resolution)?e:1,1),a=null!=(i=r.width)?i:s.width,l=null!=(n=r.height)?n:s.height;let h=r.output;if(function(t,e){Sl||(Sl=Re.get().createCanvas(256,128),Al=Sl.getContext("2d",{willReadFrequently:!0}),Al.globalCompositeOperation="copy",Al.globalAlpha=1),(Sl.width<t||Sl.height<e)&&(Sl.width=V(t),Sl.height=V(e))}(a,l),!Al)throw new TypeError("Failed to get canvas 2D context");Al.drawImage(s,0,0,a,l,0,0,a*o,l*o);const c=Al.getImageData(0,0,a,l).data;let u=0,d=0,p=a-1,f=l-1;for(;d<l&&Tl(c,a,d);)++d;if(d===l)return D.EMPTY;for(;Tl(c,a,f);)--f;for(;Cl(c,a,u,d,f);)++u;for(;Cl(c,a,p,d,f);)--p;return++p,++f,Al.globalCompositeOperation="source-over",Al.strokeRect(u,d,p-u,f-d),Al.globalCompositeOperation="copy",null!=h||(h=new D),h.set(u/o,d/o,(p-u)/o,(f-d)/o),h}const Ml=new D;const El=new class{getCanvasAndContext(t){const{text:e,style:i,resolution:n=1}=t,r=i._getFinalPadding(),s=sr.measureText(e||" ",i),o=Math.ceil(Math.ceil(Math.max(1,s.width)+2*r)*n),a=Math.ceil(Math.ceil(Math.max(1,s.height)+2*r)*n),l=No.getOptimalCanvasAndContext(o,a);this._renderTextToCanvas(e,i,r,n,l);return{canvasAndContext:l,frame:i.trim?Pl({canvas:l.canvas,width:o,height:a,resolution:1,output:Ml}):Ml.set(0,0,o,a)}}returnCanvasAndContext(t){No.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,i,n,r){var s,o,a,l,h;const{canvas:c,context:u}=r,d=ir(e),p=sr.measureText(t||" ",e),f=p.lines,g=p.lineHeight,m=p.lineWidths,_=p.maxLineWidth,y=p.fontProperties,x=c.height;if(u.resetTransform(),u.scale(n,n),u.textBaseline=e.textBaseline,null==(s=e._stroke)?void 0:s.width){const t=e._stroke;u.lineWidth=t.width,u.miterLimit=t.miterLimit,u.lineJoin=t.join,u.lineCap=t.cap}let b,v;u.font=d;const w=e.dropShadow?2:1;for(let S=0;S<w;++S){const t=e.dropShadow&&0===S,s=t?Math.ceil(Math.max(1,x)+2*i):0,c=s*n;if(t){u.fillStyle="black",u.strokeStyle="black";const t=e.dropShadow,i=t.color,r=t.alpha;u.shadowColor=Bt.shared.setValue(i).setAlpha(r).toRgbaString();const s=t.blur*n,o=t.distance*n;u.shadowBlur=s,u.shadowOffsetX=Math.cos(t.angle)*o,u.shadowOffsetY=Math.sin(t.angle)*o+c}else{if(u.fillStyle=e._fill?Ho(e._fill,u,p,2*i):null,null==(o=e._stroke)?void 0:o.width){const t=.5*e._stroke.width+2*i;u.strokeStyle=Ho(e._stroke,u,p,t)}u.shadowColor="black"}let d=(g-y.fontSize)/2;g-y.fontSize<0&&(d=0);const w=null!=(l=null==(a=e._stroke)?void 0:a.width)?l:0;for(let n=0;n<f.length;n++)b=w/2,v=w/2+n*g+y.ascent+d,"right"===e.align?b+=_-m[n]:"center"===e.align&&(b+=(_-m[n])/2),(null==(h=e._stroke)?void 0:h.width)&&this._drawLetterSpacing(f[n],e,r,b+i,v+i-s,!0),void 0!==e._fill&&this._drawLetterSpacing(f[n],e,r,b+i,v+i-s)}}_drawLetterSpacing(t,e,i,n,r,s=!1){const{context:o}=i,a=e.letterSpacing;let l=!1;if(sr.experimentalLetterSpacingSupported&&(sr.experimentalLetterSpacing?(o.letterSpacing=`${a}px`,o.textLetterSpacing=`${a}px`,l=!0):(o.letterSpacing="0px",o.textLetterSpacing="0px")),0===a||l)return void(s?o.strokeText(t,n,r):o.fillText(t,n,r));let h=n;const c=sr.graphemeSegmenter(t);let u=o.measureText(t).width,d=0;for(let p=0;p<c.length;++p){const t=c[p];s?o.strokeText(t,h,r):o.fillText(t,h,r);let e="";for(let i=p+1;i<c.length;++i)e+=c[i];d=o.measureText(e).width,h+=u-d+a,u=d}}};class Rl extends wl{constructor(...t){const e=function(t,e){var i;let n=null!=(i=t[0])?i:{};return("string"==typeof n||t[1])&&(z(L,`use new ${e}({ text: "hi!", style }) instead`),n={text:n,style:t[1]}),n}(t,"Text");super(e,zo),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof X?e.textureStyle:new X(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,n=0;if(this._style.trim){const{frame:t,canvasAndContext:e}=El.getCanvasAndContext({text:this.text,style:this._style,resolution:1});El.returnCanvasAndContext(e),i=t.width,n=t.height}else{const t=sr.measureText(this._text,this._style);i=t.width,n=t.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}}const Bl="http://www.w3.org/2000/svg",Fl="http://www.w3.org/1999/xhtml";class kl{constructor(){this.svgRoot=document.createElementNS(Bl,"svg"),this.foreignObject=document.createElementNS(Bl,"foreignObject"),this.domElement=document.createElementNS(Fl,"div"),this.styleElement=document.createElementNS(Fl,"style");const{foreignObject:t,svgRoot:e,styleElement:i,domElement:n}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(i),t.appendChild(n),this.image=Re.get().createImage()}}let Il;class Dl{constructor(){this._tempState=rn.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,i){const n=t.renderer,r=this._didUploadHash[i.uid];n.shader.bind(i,r),r||(this._didUploadHash[i.uid]=!0),n.shader.updateUniformGroup(n.globalUniforms.uniformGroup),n.geometry.bind(e,i.glProgram)}execute(t,e){const i=t.renderer;this._tempState.blendMode=e.blendMode,i.state.set(this._tempState);const n=e.textures.textures;for(let r=0;r<e.textures.count;r++)i.texture.bind(n[r],r);i.geometry.draw(e.topology,e.size,e.start)}}Dl.extension={type:[o.WebGLPipesAdaptor],name:"batch"};const Ol=rn.for2d();class Ul{start(t,e,i){const n=t.renderer,r=n.encoder,s=i.gpuProgram;this._shader=i,this._geometry=e,r.setGeometry(e,s),Ol.blendMode="normal",n.pipeline.getPipeline(e,s,Ol);const o=n.globalUniforms.bindGroup;r.resetBindGroup(1),r.setBindGroup(0,o,s)}execute(t,e){const i=this._shader.gpuProgram,n=t.renderer,r=n.encoder;if(!e.bindGroup){const t=e.textures;e.bindGroup=Sr(t.textures,t.count,n.limits.maxBatchableTextures)}Ol.blendMode=e.blendMode;const s=n.bindGroup.getBindGroup(e.bindGroup,i,1),o=n.pipeline.getPipeline(this._geometry,i,Ol,e.topology);e.bindGroup._touch(n.textureGC.count),r.setPipeline(o),r.renderPassEncoder.setBindGroup(1,s),r.renderPassEncoder.drawIndexed(e.size,1,e.start)}}Ul.extension={type:[o.WebGPUPipesAdaptor],name:"batch"};const Gl=class t{constructor(t,e){var i,n;this.state=rn.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=t,this._adaptor=e,null==(n=(i=this._adaptor).init)||n.call(i,this)}static getBatcher(t){return new this._availableBatchers[t]}buildStart(t){let e=this._batchersByInstructionSet[t.uid];e||(e=this._batchersByInstructionSet[t.uid]=Object.create(null),e.default||(e.default=new Ms({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=e,this._activeBatch=this._activeBatches.default;for(const i in this._activeBatches)this._activeBatches[i].begin()}addToBatch(e,i){if(this._activeBatch.name!==e.batcherName){this._activeBatch.break(i);let n=this._activeBatches[e.batcherName];n||(n=this._activeBatches[e.batcherName]=t.getBatcher(e.batcherName),n.begin()),this._activeBatch=n}this._activeBatch.add(e)}break(t){this._activeBatch.break(t)}buildEnd(t){this._activeBatch.break(t);const e=this._activeBatches;for(const i in e){const t=e[i],n=t.geometry;n.indexBuffer.setDataWithSize(t.indexBuffer,t.indexSize,!0),n.buffers[0].setDataWithSize(t.attributeBuffer.float32View,t.attributeSize,!1)}}upload(t){const e=this._batchersByInstructionSet[t.uid];for(const i in e){const t=e[i],n=t.geometry;t.dirty&&(t.dirty=!1,n.buffers[0].update(4*t.attributeSize))}}execute(t){if("startBatch"===t.action){const e=t.batcher,i=e.geometry,n=e.shader;this._adaptor.start(this,i,n)}this._adaptor.execute(this,t)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const t in this._activeBatches)this._activeBatches[t].destroy();this._activeBatches=null}};Gl.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"batch"},Gl._availableBatchers=Object.create(null);let Ll=Gl;h.handleByMap(o.Batcher,Ll._availableBatchers),h.add(Ms);const zl={name:"local-uniform-bit",vertex:{header:"\n\n struct LocalUniforms {\n uTransformMatrix:mat3x3<f32>,\n uColor:vec4<f32>,\n uRound:f32,\n }\n\n @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "}},Nl=__spreadProps(__spreadValues({},zl),{vertex:__spreadProps(__spreadValues({},zl.vertex),{header:zl.vertex.header.replace("group(1)","group(2)")})}),Vl={name:"local-uniform-bit",vertex:{header:"\n\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix = uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "}},Hl={name:"texture-bit",vertex:{header:"\n\n struct TextureUniforms {\n uTextureMatrix:mat3x3<f32>,\n }\n\n @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;\n ",main:"\n uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;\n "},fragment:{header:"\n @group(2) @binding(0) var uTexture: texture_2d<f32>;\n @group(2) @binding(1) var uSampler: sampler;\n\n\n ",main:"\n outColor = textureSample(uTexture, uSampler, vUV);\n "}},Wl={name:"texture-bit",vertex:{header:"\n uniform mat3 uTextureMatrix;\n ",main:"\n uv = (uTextureMatrix * vec3(uv, 1.0)).xy;\n "},fragment:{header:"\n uniform sampler2D uTexture;\n\n\n ",main:"\n outColor = texture(uTexture, vUV);\n "}},jl=new it;class Yl extends zt{constructor(){super(),this.filters=[new dl({sprite:new ve(J.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}get inverse(){return this.filters[0].inverse}set inverse(t){this.filters[0].inverse=t}}class Xl{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,i){const n=this._renderer;if(n.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1,maskedContainer:e}),t.inverse=e._maskOptions.inverse,t.renderMaskToTexture){const e=t.mask;e.includeInBuild=!0,e.collectRenderables(i,n,null),e.includeInBuild=!1}n.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){const e=this._renderer,i=t.mask.renderMaskToTexture;if("pushMaskBegin"===t.action){const n=Dt.get(Yl);if(n.inverse=t.inverse,i){t.mask.mask.measurable=!0;const i=Zt(t.mask.mask,!0,jl);t.mask.mask.measurable=!1,i.ceil();const r=e.renderTarget.renderTarget.colorTexture.source,s=pe.getOptimalTexture(i.width,i.height,r._resolution,r.antialias);e.renderTarget.push(s,!0),e.globalUniforms.push({offset:i,worldColor:4294967295});const o=n.sprite;o.texture=s,o.worldTransform.tx=i.minX,o.worldTransform.ty=i.minY,this._activeMaskStage.push({filterEffect:n,maskedContainer:t.maskedContainer,filterTexture:s})}else n.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:n,maskedContainer:t.maskedContainer})}else if("pushMaskEnd"===t.action){const t=this._activeMaskStage[this._activeMaskStage.length-1];i&&(e.type===Ji.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:t.maskedContainer,filterEffect:t.filterEffect,canBundle:!1})}else if("popMaskEnd"===t.action){e.filter.pop();const t=this._activeMaskStage.pop();i&&pe.returnTexture(t.filterTexture),Dt.return(t.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}Xl.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"alphaMask"};class Zl{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&t.mask;const r=this._colorStack[this._colorStackIndex];r!==this._currentColor&&(this._currentColor=r,i.add({renderPipeId:"colorMask",colorMask:r,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;this._colorStackIndex--;const r=n[this._colorStackIndex-1];r!==this._currentColor&&(this._currentColor=r,i.add({renderPipeId:"colorMask",colorMask:r,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._colorStack=null}}Zl.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"colorMask"};class ql{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,i){var n;const r=t,s=this._renderer;s.renderPipes.batch.break(i),s.renderPipes.blendMode.setBlendMode(r.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const o=r.mask;o.includeInBuild=!0,this._maskHash.has(r)||this._maskHash.set(r,{instructionsStart:0,instructionsLength:0});const a=this._maskHash.get(r);a.instructionsStart=i.instructionSize,o.collectRenderables(i,s,null),o.includeInBuild=!1,s.renderPipes.batch.break(i),i.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const l=i.instructionSize-a.instructionsStart-1;a.instructionsLength=l;const h=s.renderTarget.renderTarget.uid;null!=(n=this._maskStackHash)[h]||(n[h]=0)}pop(t,e,i){const n=t,r=this._renderer;r.renderPipes.batch.break(i),r.renderPipes.blendMode.setBlendMode(n.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1});const s=this._maskHash.get(t);for(let o=0;o<s.instructionsLength;o++)i.instructions[i.instructionSize++]=i.instructions[s.instructionsStart++];i.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e,i;const n=this._renderer,r=n.renderTarget.renderTarget.uid;let s=null!=(e=(i=this._maskStackHash)[r])?e:i[r]=0;"pushMaskBegin"===t.action?(n.renderTarget.ensureDepthStencil(),n.stencil.setStencilMode(Pr.RENDERING_MASK_ADD,s),s++,n.colorMask.setMask(0)):"pushMaskEnd"===t.action?(t.inverse?n.stencil.setStencilMode(Pr.INVERSE_MASK_ACTIVE,s):n.stencil.setStencilMode(Pr.MASK_ACTIVE,s),n.colorMask.setMask(15)):"popMaskBegin"===t.action?(n.colorMask.setMask(0),0!==s?n.stencil.setStencilMode(Pr.RENDERING_MASK_REMOVE,s):(n.renderTarget.clear(null,Un.STENCIL),n.stencil.setStencilMode(Pr.DISABLED,s)),s--):"popMaskEnd"===t.action&&(t.inverse?n.stencil.setStencilMode(Pr.INVERSE_MASK_ACTIVE,s):n.stencil.setStencilMode(Pr.MASK_ACTIVE,s),n.colorMask.setMask(15)),this._maskStackHash[r]=s}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}ql.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"stencilMask"};var $l=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))($l||{});class Kl{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class Ql{constructor(t){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuBuffers")}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gl=this._renderer.gl,this._gpuBuffers=Object.create(null),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(t){return this._gpuBuffers[t.uid]||this.createGLBuffer(t)}bind(t){const{_gl:e}=this,i=this.getGlBuffer(t);e.bindBuffer(i.type,i.buffer)}bindBufferBase(t,e){const{_gl:i}=this;this._boundBufferBases[e]!==t&&(this._boundBufferBases[e]=t,t._lastBindBaseLocation=e,i.bindBufferBase(i.UNIFORM_BUFFER,e,t.buffer))}nextBindBase(t){this._bindCallId++,this._minBaseLocation=0,t&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(t){let e=this.getLastBindBaseLocation(t);if(e>=this._minBaseLocation)return t._lastBindCallId=this._bindCallId,e;let i=0,n=this._nextBindBaseIndex;for(;i<2;){n>=this._maxBindings&&(n=this._minBaseLocation,i++);const t=this._boundBufferBases[n];if(!t||t._lastBindCallId!==this._bindCallId)break;n++}return e=n,this._nextBindBaseIndex=n+1,i>=2?-1:(t._lastBindCallId=this._bindCallId,this._boundBufferBases[e]=null,e)}getLastBindBaseLocation(t){const e=t._lastBindBaseLocation;return this._boundBufferBases[e]===t?e:-1}bindBufferRange(t,e,i,n){const{_gl:r}=this;i||(i=0),e||(e=0),this._boundBufferBases[e]=null,r.bindBufferRange(r.UNIFORM_BUFFER,e||0,t.buffer,256*i,n||256)}updateBuffer(t){const{_gl:e}=this,i=this.getGlBuffer(t);if(t._updateID===i.updateID)return i;i.updateID=t._updateID,e.bindBuffer(i.type,i.buffer);const n=t.data,r=t.descriptor.usage&Vr.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return n?i.byteLength>=n.byteLength?e.bufferSubData(i.type,0,n,0,t._updateSize/n.BYTES_PER_ELEMENT):(i.byteLength=n.byteLength,e.bufferData(i.type,n,r)):(i.byteLength=t.descriptor.size,e.bufferData(i.type,i.byteLength,r)),i}destroyAll(){const t=this._gl;for(const e in this._gpuBuffers)t.deleteBuffer(this._gpuBuffers[e].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(t,e){const i=this._gpuBuffers[t.uid],n=this._gl;e||n.deleteBuffer(i.buffer),this._gpuBuffers[t.uid]=null}createGLBuffer(t){const{_gl:e}=this;let i=$l.ARRAY_BUFFER;t.descriptor.usage&Vr.INDEX?i=$l.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&Vr.UNIFORM&&(i=$l.UNIFORM_BUFFER);const n=new Kl(e.createBuffer(),i);return this._gpuBuffers[t.uid]=n,t.on("destroy",this.onBufferDestroy,this),n}resetState(){this._boundBufferBases=Object.create(null)}}Ql.extension={type:[o.WebGLSystem],name:"buffer"};const Jl=class t{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(e){var i,n;e=__spreadValues(__spreadValues({},t.defaultOptions),e);let r=this.multiView=e.multiView;if(e.context&&r&&(kt("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),r=!1),this.canvas=r?Re.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const t=this._renderer.background.alpha<1,r=null==(i=e.premultipliedAlpha)||i,s=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:t,premultipliedAlpha:r,antialias:s,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:null!=(n=e.powerPreference)?n:"default"})}}ensureCanvasSize(t){if(!this.multiView)return void(t!==this.canvas&&kt("multiView is disabled, but targetCanvas is not the main canvas"));const{canvas:e}=this;(e.width<t.width||e.height<t.height)&&(e.width=Math.max(t.width,t.width),e.height=Math.max(t.height,t.height))}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof Re.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let i;const n=this.canvas;if(2===t&&(i=n.getContext("webgl2",e)),!i&&(i=n.getContext("webgl",e),!i))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=i,this.initFromContext(this.gl)}getExtensions(){const{gl:t}=this,e={anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc"),rgtc:t.getExtension("EXT_texture_compression_rgtc"),loseContext:t.getExtension("WEBGL_lose_context")};if(1===this.webGLVersion)this.extensions=__spreadProps(__spreadValues({},e),{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:t.getExtension("ANGLE_instanced_arrays"),srgb:t.getExtension("EXT_sRGB")});else{this.extensions=__spreadProps(__spreadValues({},e),{colorBufferFloat:t.getExtension("EXT_color_buffer_float")});const i=t.getExtension("WEBGL_provoking_vertex");i&&i.provokingVertexWEBGL(i.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var t;this.gl.isContextLost()&&(null==(t=this.extensions.loseContext)||t.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),null==(t=this.extensions.loseContext)||t.loseContext()}forceContextLoss(){var t;null==(t=this.extensions.loseContext)||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&!e.stencil&&kt("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const i=this.supports,n=2===this.webGLVersion,r=this.extensions;i.uint32Indices=n||!!r.uint32ElementIndex,i.uniformBufferObject=n,i.vertexArrayObject=n||!!r.vertexArrayObject,i.srgbTextures=n||!!r.srgb,i.nonPowOf2wrapping=n,i.nonPowOf2mipmaps=n,i.msaa=n,i.uint32Indices||kt("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};Jl.extension={type:[o.WebGLSystem],name:"context"},Jl.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let th=Jl;function eh(t,e){for(const i in t.attributes){const n=t.attributes[i],r=e[i];r?(null!=n.format||(n.format=r.format),null!=n.offset||(n.offset=r.offset),null!=n.instance||(n.instance=r.instance)):kt(`Attribute ${i} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}!function(t){const{buffers:e,attributes:i}=t,n={},r={};for(const s in e){const t=e[s];n[t.uid]=0,r[t.uid]=0}for(const s in i){const t=i[s];n[t.buffer.uid]+=Ni(t.format).stride}for(const s in i){const t=i[s];null!=t.stride||(t.stride=n[t.buffer.uid]),null!=t.start||(t.start=r[t.buffer.uid]),r[t.buffer.uid]+=Ni(t.format).stride}}(t)}var ih=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(ih||{}),nh=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(nh||{}),rh=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(rh||{});const sh={uint8x2:rh.UNSIGNED_BYTE,uint8x4:rh.UNSIGNED_BYTE,sint8x2:rh.BYTE,sint8x4:rh.BYTE,unorm8x2:rh.UNSIGNED_BYTE,unorm8x4:rh.UNSIGNED_BYTE,snorm8x2:rh.BYTE,snorm8x4:rh.BYTE,uint16x2:rh.UNSIGNED_SHORT,uint16x4:rh.UNSIGNED_SHORT,sint16x2:rh.SHORT,sint16x4:rh.SHORT,unorm16x2:rh.UNSIGNED_SHORT,unorm16x4:rh.UNSIGNED_SHORT,snorm16x2:rh.SHORT,snorm16x4:rh.SHORT,float16x2:rh.HALF_FLOAT,float16x4:rh.HALF_FLOAT,float32:rh.FLOAT,float32x2:rh.FLOAT,float32x3:rh.FLOAT,float32x4:rh.FLOAT,uint32:rh.UNSIGNED_INT,uint32x2:rh.UNSIGNED_INT,uint32x3:rh.UNSIGNED_INT,uint32x4:rh.UNSIGNED_INT,sint32:rh.INT,sint32x2:rh.INT,sint32x3:rh.INT,sint32x4:rh.INT};function oh(t){var e;return null!=(e=sh[t])?e:sh.float32}const ah={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class lh{constructor(t){this._geometryVaoHash=Object.create(null),this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._renderer.renderableGC.addManagedHash(this,"_geometryVaoHash")}contextChange(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=t=>e.bindVertexArrayOES(t),t.deleteVertexArray=t=>e.deleteVertexArrayOES(t));const i=this._renderer.context.extensions.vertexAttribDivisorANGLE;i&&(t.drawArraysInstanced=(t,e,n,r)=>{i.drawArraysInstancedANGLE(t,e,n,r)},t.drawElementsInstanced=(t,e,n,r,s)=>{i.drawElementsInstancedANGLE(t,e,n,r,s)},t.vertexAttribDivisor=(t,e)=>i.vertexAttribDivisorANGLE(t,e)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(t,e){const i=this.gl;this._activeGeometry=t;const n=this.getVao(t,e);this._activeVao!==n&&(this._activeVao=n,i.bindVertexArray(n)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let i=0;i<t.buffers.length;i++){const n=t.buffers[i];e.updateBuffer(n)}}checkCompatibility(t,e){const i=t.attributes,n=e._attributeData;for(const r in n)if(!i[r])throw new Error(`shader and geometry incompatible, geometry missing the "${r}" attribute`)}getSignature(t,e){const i=t.attributes,n=e._attributeData,r=["g",t.uid];for(const s in i)n[s]&&r.push(s,n[s].location);return r.join("-")}getVao(t,e){var i;return(null==(i=this._geometryVaoHash[t.uid])?void 0:i[e._key])||this.initGeometryVao(t,e)}initGeometryVao(t,e,i=!0){const n=this._renderer.gl,r=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const s=this.getSignature(t,e);this._geometryVaoHash[t.uid]||(this._geometryVaoHash[t.uid]=Object.create(null),t.on("destroy",this.onGeometryDestroy,this));const o=this._geometryVaoHash[t.uid];let a=o[s];if(a)return o[e._key]=a,a;eh(t,e._attributeData);const l=t.buffers;a=n.createVertexArray(),n.bindVertexArray(a);for(let h=0;h<l.length;h++){const t=l[h];r.bind(t)}return this.activateVao(t,e),o[e._key]=a,o[s]=a,n.bindVertexArray(null),a}onGeometryDestroy(t,e){const i=this._geometryVaoHash[t.uid],n=this.gl;if(i){if(e)for(const t in i)this._activeVao!==i[t]&&this.unbind(),n.deleteVertexArray(i[t]);this._geometryVaoHash[t.uid]=null}}destroyAll(t=!1){const e=this.gl;for(const i in this._geometryVaoHash){if(t)for(const t in this._geometryVaoHash[i]){const n=this._geometryVaoHash[i];this._activeVao!==n&&this.unbind(),e.deleteVertexArray(n[t])}this._geometryVaoHash[i]=null}}activateVao(t,e){var i,n;const r=this._renderer.gl,s=this._renderer.buffer,o=t.attributes;t.indexBuffer&&s.bind(t.indexBuffer);let a=null;for(const l in o){const t=o[l],h=t.buffer,c=s.getGlBuffer(h),u=e._attributeData[l];if(u){a!==c&&(s.bind(h),a=c);const e=u.location;r.enableVertexAttribArray(e);const o=Ni(t.format),l=oh(t.format);if("int"===(null==(i=u.format)?void 0:i.substring(1,4))?r.vertexAttribIPointer(e,o.size,l,t.stride,t.offset):r.vertexAttribPointer(e,o.size,l,o.normalised,t.stride,t.offset),t.instance){if(!this.hasInstance)throw new Error("geometry error, GPU Instancing is not supported on this device");{const i=null!=(n=t.divisor)?n:1;r.vertexAttribDivisor(e,i)}}}}}draw(t,e,i,n){const{gl:r}=this._renderer,s=this._activeGeometry,o=ah[t||s.topology];if(null!=n||(n=s.instanceCount),s.indexBuffer){const t=s.indexBuffer.data.BYTES_PER_ELEMENT,a=2===t?r.UNSIGNED_SHORT:r.UNSIGNED_INT;n>1?r.drawElementsInstanced(o,e||s.indexBuffer.data.length,a,(i||0)*t,n):r.drawElements(o,e||s.indexBuffer.data.length,a,(i||0)*t)}else n>1?r.drawArraysInstanced(o,i||0,e||s.getSize(),n):r.drawArrays(o,i||0,e||s.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}lh.extension={type:[o.WebGLSystem],name:"geometry"};const hh=new jr({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),ch=class t{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(e={}){const{useBackBuffer:i,antialias:n}=__spreadValues(__spreadValues({},t.defaultOptions),e);this.useBackBuffer=i,this._antialias=n,this._renderer.context.supports.msaa||(kt("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=rn.for2d();const r=new Li({vertex:"\n attribute vec2 aPosition;\n out vec2 vUv;\n\n void main() {\n gl_Position = vec4(aPosition, 0.0, 1.0);\n\n vUv = (aPosition + 1.0) / 2.0;\n\n // flip dem UVs\n vUv.y = 1.0 - vUv.y;\n }",fragment:"\n in vec2 vUv;\n out vec4 finalColor;\n\n uniform sampler2D uTexture;\n\n void main() {\n finalColor = texture(uTexture, vUv);\n }",name:"big-triangle"});this._bigTriangleShader=new tn({glProgram:r,resources:{uTexture:J.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const e=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=e.colorTexture,t.target=this._getBackBufferTexture(e.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:hh,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new J({source:new q({width:t.width,height:t.height,resolution:t._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(t.width,t.height,t._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};ch.extension={type:[o.WebGLSystem],name:"backBuffer",priority:1},ch.defaultOptions={useBackBuffer:!1};let uh=ch;class dh{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(8&t),!!(4&t),!!(2&t),!!(1&t)))}}dh.extension={type:[o.WebGLSystem],name:"colorMask"};class ph{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){const e=this._renderer,{geometry:i,shader:n,state:r,skipSync:s,topology:o,size:a,start:l,instanceCount:h}=t;e.shader.bind(n,s),e.geometry.bind(i,e.shader._activeProgram),r&&e.state.set(r),e.geometry.draw(o,a,l,null!=h?h:i.instanceCount)}destroy(){this._renderer=null}}ph.extension={type:[o.WebGLSystem],name:"encoder"};class fh{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=Br(this.maxTextures,t),this.maxUniformBindings=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS)}destroy(){}}fh.extension={type:[o.WebGLSystem],name:"limits"};class gh{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const mh=[];mh[Pr.NONE]=void 0,mh[Pr.DISABLED]={stencilWriteMask:0,stencilReadMask:0},mh[Pr.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},mh[Pr.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},mh[Pr.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},mh[Pr.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class _h{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:Pr.NONE},this._renderTargetStencilState=Object.create(null),t.renderTarget.onRenderTargetChange.add(this)}contextChange(t){this._gl=t,this._comparisonFuncMapping={always:t.ALWAYS,never:t.NEVER,equal:t.EQUAL,"not-equal":t.NOTEQUAL,less:t.LESS,"less-equal":t.LEQUAL,greater:t.GREATER,"greater-equal":t.GEQUAL},this._stencilOpsMapping={keep:t.KEEP,zero:t.ZERO,replace:t.REPLACE,invert:t.INVERT,"increment-clamp":t.INCR,"decrement-clamp":t.DECR,"increment-wrap":t.INCR_WRAP,"decrement-wrap":t.DECR_WRAP},this.resetState()}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:Pr.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=Pr.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],n=this._gl,r=mh[t],s=this._stencilCache;i.stencilMode=t,i.stencilReference=e,t!==Pr.DISABLED?(this._stencilCache.enabled||(this._stencilCache.enabled=!0,n.enable(n.STENCIL_TEST)),t===s.stencilMode&&s.stencilReference===e||(s.stencilMode=t,s.stencilReference=e,n.stencilFunc(this._comparisonFuncMapping[r.stencilBack.compare],e,255),n.stencilOp(n.KEEP,n.KEEP,this._stencilOpsMapping[r.stencilBack.passOp]))):this._stencilCache.enabled&&(this._stencilCache.enabled=!1,n.disable(n.STENCIL_TEST))}}_h.extension={type:[o.WebGLSystem],name:"stencil"};class yh{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!hn())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const e=this.getUniformGroupData(t);t.buffer||(t.buffer=new Hr({data:new Float32Array(e.layout.size/4),usage:Vr.UNIFORM|Vr.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let i=this._syncFunctionHash[e];if(!i){const n=Object.keys(t.uniformStructures).map(e=>t.uniformStructures[e]),r=this._adaptor.createUboElements(n),s=this._generateUboSync(r.uboElements);i=this._syncFunctionHash[e]={layout:r,syncFunction:s}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,i){const n=this.getUniformGroupData(t);t.buffer||(t.buffer=new Hr({data:new Float32Array(n.layout.size/4),usage:Vr.UNIFORM|Vr.COPY_DST}));let r=null;return e||(e=t.buffer.data,r=t.buffer.dataInt32),i||(i=0),n.syncFunction(t.uniforms,e,r,i),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}const xh={f32:4,i32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"vec2<i32>":8,"vec3<i32>":12,"vec4<i32>":16,"mat2x2<f32>":32,"mat3x3<f32>":48,"mat4x4<f32>":64};function bh(t){const e=t.map(t=>({data:t,offset:0,size:0}));let i=0,n=0;for(let r=0;r<e.length;r++){const t=e[r];if(i=xh[t.data.type],!i)throw new Error(`Unknown type ${t.data.type}`);t.data.size>1&&(i=Math.max(i,16)*t.data.size);const s=12===i?16:i;t.size=i;const o=n%16;n+=o>0&&16-o<s?(16-o)%16:(i-o%i)%i,t.offset=n,n+=i}return n=16*Math.ceil(n/16),{uboElements:e,size:n}}const vh=[{type:"mat3x3<f32>",test:t=>void 0!==t.value.a,ubo:"\n var matrix = uv[name].toArray(true);\n data[offset] = matrix[0];\n data[offset + 1] = matrix[1];\n data[offset + 2] = matrix[2];\n data[offset + 4] = matrix[3];\n data[offset + 5] = matrix[4];\n data[offset + 6] = matrix[5];\n data[offset + 8] = matrix[6];\n data[offset + 9] = matrix[7];\n data[offset + 10] = matrix[8];\n ",uniform:"\n gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));\n "},{type:"vec4<f32>",test:t=>"vec4<f32>"===t.type&&1===t.size&&void 0!==t.value.width,ubo:"\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n data[offset + 2] = v.width;\n data[offset + 3] = v.height;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {\n cv[0] = v.x;\n cv[1] = v.y;\n cv[2] = v.width;\n cv[3] = v.height;\n gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);\n }\n "},{type:"vec2<f32>",test:t=>"vec2<f32>"===t.type&&1===t.size&&void 0!==t.value.x,ubo:"\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y) {\n cv[0] = v.x;\n cv[1] = v.y;\n gl.uniform2f(ud[name].location, v.x, v.y);\n }\n "},{type:"vec4<f32>",test:t=>"vec4<f32>"===t.type&&1===t.size&&void 0!==t.value.red,ubo:"\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n data[offset + 3] = v.alpha;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n cv[3] = v.alpha;\n gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);\n }\n "},{type:"vec3<f32>",test:t=>"vec3<f32>"===t.type&&1===t.size&&void 0!==t.value.red,ubo:"\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n gl.uniform3f(ud[name].location, v.red, v.green, v.blue);\n }\n "}];function wh(t,e,i,n){const r=["\n var v = null;\n var v2 = null;\n var t = 0;\n var index = 0;\n var name = null;\n var arrayOffset = null;\n "];let s=0;for(let a=0;a<t.length;a++){const o=t[a],l=o.data.name;let h=!1,c=0;for(let t=0;t<vh.length;t++){if(vh[t].test(o.data)){c=o.offset/4,r.push(`name = "${l}";`,`offset += ${c-s};`,vh[t][e]||vh[t].ubo),h=!0;break}}if(!h)if(o.data.size>1)c=o.offset/4,r.push(i(o,c-s));else{const t=n[o.data.type];c=o.offset/4,r.push(`\n v = uv.${l};\n offset += ${c-s};\n ${t};\n `)}s=c}const o=r.join("\n");return new Function("uv","data","dataInt32","offset",o)}function Sh(t,e){return`\n for (let i = 0; i < ${t*e}; i++) {\n data[offset + (((i / ${t})|0) * 4) + (i % ${t})] = v[i];\n }\n `}const Ah={f32:"\n data[offset] = v;",i32:"\n dataInt32[offset] = v;","vec2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];","vec3<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];","vec4<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];","vec2<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];","vec3<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];","vec4<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];\n dataInt32[offset + 3] = v[3];","mat2x2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 4] = v[2];\n data[offset + 5] = v[3];","mat3x3<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 4] = v[3];\n data[offset + 5] = v[4];\n data[offset + 6] = v[5];\n data[offset + 8] = v[6];\n data[offset + 9] = v[7];\n data[offset + 10] = v[8];","mat4x4<f32>":"\n for (let i = 0; i < 16; i++) {\n data[offset + i] = v[i];\n }","mat3x2<f32>":Sh(3,2),"mat4x2<f32>":Sh(4,2),"mat2x3<f32>":Sh(2,3),"mat4x3<f32>":Sh(4,3),"mat2x4<f32>":Sh(2,4),"mat3x4<f32>":Sh(3,4)},Th=__spreadProps(__spreadValues({},Ah),{"mat2x2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];\n "});function Ch(t,e){const i=Math.max(xh[t.data.type]/16,1),n=t.data.value.length/t.data.size,r=(4-n%4)%4,s=t.data.type.indexOf("i32")>=0?"dataInt32":"data";return`\n v = uv.${t.data.name};\n offset += ${e};\n\n arrayOffset = offset;\n\n t = 0;\n\n for(var i=0; i < ${t.data.size*i}; i++)\n {\n for(var j = 0; j < ${n}; j++)\n {\n ${s}[arrayOffset++] = v[t++];\n }\n ${0!==r?`arrayOffset += ${r};`:""}\n }\n `}function Ph(t){return wh(t,"uboStd40",Ch,Ah)}class Mh extends yh{constructor(){super({createUboElements:bh,generateUboSync:Ph})}}Mh.extension={type:[o.WebGLSystem],name:"ubo"};class Eh{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new D}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new D}copyToTexture(t,e,i,n,r){const s=this._renderTargetSystem,o=this._renderer,a=s.getGpuRenderTarget(t),l=o.gl;return this.finishRenderPass(t),l.bindFramebuffer(l.FRAMEBUFFER,a.resolveTargetFramebuffer),o.texture.bind(e,0),l.copyTexSubImage2D(l.TEXTURE_2D,0,r.x,r.y,i.x,i.y,n.width,n.height),e}startRenderPass(t,e=!0,i,n){const r=this._renderTargetSystem,s=t.colorTexture,o=r.getGpuRenderTarget(t);let a=n.y;t.isRoot&&(a=s.pixelHeight-n.height),t.colorTextures.forEach(t=>{this._renderer.texture.unbind(t)});const l=this._renderer.gl;l.bindFramebuffer(l.FRAMEBUFFER,o.framebuffer);const h=this._viewPortCache;h.x===n.x&&h.y===a&&h.width===n.width&&h.height===n.height||(h.x=n.x,h.y=a,h.width=n.width,h.height=n.height,l.viewport(n.x,a,n.width,n.height)),o.depthStencilRenderBuffer||!t.stencil&&!t.depth||this._initStencil(o),this.clear(t,e,i)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)return;const i=this._renderer.gl;i.bindFramebuffer(i.FRAMEBUFFER,e.resolveTargetFramebuffer),i.bindFramebuffer(i.READ_FRAMEBUFFER,e.framebuffer),i.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,i.COLOR_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.FRAMEBUFFER,e.framebuffer)}initGpuRenderTarget(t){const e=this._renderer.gl,i=new gh;return t.colorTexture instanceof Be?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),i.framebuffer=null,i):(this._initColor(t,i),e.bindFramebuffer(e.FRAMEBUFFER,null),i)}destroyGpuRenderTarget(t){const e=this._renderer.gl;t.framebuffer&&(e.deleteFramebuffer(t.framebuffer),t.framebuffer=null),t.resolveTargetFramebuffer&&(e.deleteFramebuffer(t.resolveTargetFramebuffer),t.resolveTargetFramebuffer=null),t.depthStencilRenderBuffer&&(e.deleteRenderbuffer(t.depthStencilRenderBuffer),t.depthStencilRenderBuffer=null),t.msaaRenderBuffer.forEach(t=>{e.deleteRenderbuffer(t)}),t.msaaRenderBuffer=null}clear(t,e,i){if(!e)return;const n=this._renderTargetSystem;"boolean"==typeof e&&(e=e?Un.ALL:Un.NONE);const r=this._renderer.gl;if(e&Un.COLOR){null!=i||(i=n.defaultClearColor);const t=this._clearColorCache,e=i;t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]||(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],r.clearColor(e[0],e[1],e[2],e[3]))}r.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const i=this._renderer,n=i.gl,r=n.createFramebuffer();if(e.resolveTargetFramebuffer=r,n.bindFramebuffer(n.FRAMEBUFFER,r),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((t,r)=>{const s=t.source;s.antialias&&(i.context.supports.msaa?e.msaa=!0:kt("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),i.texture.bindSource(s,0);const o=i.texture.getGlSource(s).texture;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+r,3553,o,0)}),e.msaa){const i=n.createFramebuffer();e.framebuffer=i,n.bindFramebuffer(n.FRAMEBUFFER,i),t.colorTextures.forEach((t,i)=>{const r=n.createRenderbuffer();e.msaaRenderBuffer[i]=r})}else e.framebuffer=r;this._resizeColor(t,e)}_resizeColor(t,e){const i=t.colorTexture.source;if(e.width=i.pixelWidth,e.height=i.pixelHeight,t.colorTextures.forEach((t,e)=>{0!==e&&t.source.resize(i.width,i.height,i._resolution)}),e.msaa){const i=this._renderer,n=i.gl,r=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,r),t.colorTextures.forEach((t,r)=>{const s=t.source;i.texture.bindSource(s,0);const o=i.texture.getGlSource(s).internalFormat,a=e.msaaRenderBuffer[r];n.bindRenderbuffer(n.RENDERBUFFER,a),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,o,s.pixelWidth,s.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+r,n.RENDERBUFFER,a)})}}_initStencil(t){if(null===t.framebuffer)return;const e=this._renderer.gl,i=e.createRenderbuffer();t.depthStencilRenderBuffer=i,e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,i),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,2===this._renderer.context.webGLVersion?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}prerender(t){const e=t.colorTexture.resource;this._renderer.context.multiView&&Be.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&Be.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,i=t.colorTexture;i.context2D.drawImage(e,0,i.pixelHeight-e.height)}}}const Rh=new Map;function Bh(t,e){if(!Rh.has(t)){const i=new J({source:new Be(__spreadValues({resource:t},e))}),n=()=>{Rh.get(t)===i&&Rh.delete(t)};i.once("destroy",n),i.source.once("destroy",n),Rh.set(t,i)}return Rh.get(t)}const Fh=class t{constructor(e={}){if(this.uid=U("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,e=__spreadValues(__spreadValues({},t.defaultOptions),e),this.stencil=e.stencil,this.depth=e.depth,this.isRoot=e.isRoot,"number"==typeof e.colorTextures){this._managedColorTextures=!0;for(let t=0;t<e.colorTextures;t++)this.colorTextures.push(new q({width:e.width,height:e.height,resolution:e.resolution,antialias:e.antialias}))}else{this.colorTextures=[...e.colorTextures.map(t=>t.source)];const t=this.colorTexture.source;this.resize(t.width,t.height,t._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(e.depthStencilTexture||this.stencil)&&(e.depthStencilTexture instanceof J||e.depthStencilTexture instanceof q?this.depthStencilTexture=e.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new q({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,i=this.resolution,n=!1){this.dirtyId++,this.colorTextures.forEach((r,s)=>{n&&0===s||r.source.resize(t,e,i)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,i)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(t=>{t.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};Fh.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let kh=Fh;class Ih{constructor(t){this.rootViewPort=new D,this.viewport=new D,this.onRenderTargetChange=new Gn("onRenderTargetChange"),this.projectionMatrix=new S,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuRenderTargetHash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:i,frame:n}){var r,s;this._renderTargetStack.length=0,this.push(t,e,i,n),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=function(t){const e=t.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement&&document.body.contains(e)}(this.rootRenderTarget),null==(s=(r=this.adaptor).prerender)||s.call(r,this.rootRenderTarget)}postrender(){var t,e;null==(e=(t=this.adaptor).postrender)||e.call(t,this.rootRenderTarget)}bind(t,e=!0,i,n){const r=this.getRenderTarget(t),s=this.renderTarget!==r;this.renderTarget=r,this.renderSurface=t;const o=this.getGpuRenderTarget(r);r.pixelWidth===o.width&&r.pixelHeight===o.height||(this.adaptor.resizeGpuRenderTarget(r),o.width=r.pixelWidth,o.height=r.pixelHeight);const a=r.colorTexture,l=this.viewport,h=a.pixelWidth,c=a.pixelHeight;if(!n&&t instanceof J&&(n=t.frame),n){const t=a._resolution;l.x=n.x*t+.5|0,l.y=n.y*t+.5|0,l.width=n.width*t+.5|0,l.height=n.height*t+.5|0}else l.x=0,l.y=0,l.width=h,l.height=c;return function(t,e,i,n,r,s){const o=s?1:-1;t.identity(),t.a=1/n*2,t.d=o*(1/r*2),t.tx=-1-e*t.a,t.ty=-o-i*t.d}(this.projectionMatrix,0,0,l.width/a.resolution,l.height/a.resolution,!r.isRoot),this.adaptor.startRenderPass(r,e,i,l),s&&this.onRenderTargetChange.emit(r),r}clear(t,e=Un.ALL,i){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,i,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=Un.ALL,i,n){const r=this.bind(t,e,i,n);return this._renderTargetStack.push({renderTarget:r,frame:n}),r}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame)}getRenderTarget(t){var e;return t.isTexture&&(t=t.source),null!=(e=this._renderSurfaceToRenderTargetHash.get(t))?e:this._initRenderTarget(t)}copyToTexture(t,e,i,n,r){i.x<0&&(n.width+=i.x,r.x-=i.x,i.x=0),i.y<0&&(n.height+=i.y,r.y-=i.y,i.y=0);const{pixelWidth:s,pixelHeight:o}=t;return n.width=Math.min(n.width,s-i.x),n.height=Math.min(n.height,o-i.y),this.adaptor.copyToTexture(t,e,i,n,r)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((t,e)=>{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return Be.test(t)&&(t=Bh(t).source),t instanceof kh?e=t:t instanceof q&&(e=new kh({colorTextures:[t]}),t.source instanceof Be&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);const i=this._gpuRenderTargetHash[e.uid];i&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(i))})),this._renderSurfaceToRenderTargetHash.set(t,e),e}getGpuRenderTarget(t){return this._gpuRenderTargetHash[t.uid]||(this._gpuRenderTargetHash[t.uid]=this.adaptor.initGpuRenderTarget(t))}resetState(){this.renderTarget=null,this.renderSurface=null}}class Dh extends Ih{constructor(t){super(t),this.adaptor=new Eh,this.adaptor.init(t,this)}}Dh.extension={type:[o.WebGLSystem],name:"renderTarget"};class Oh extends _{constructor({buffer:t,offset:e,size:i}){super(),this.uid=U("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=U("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=0|e,this.size=i,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=U("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}class Uh{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function Gh(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}function Lh(t){const e=new Array(t);for(let i=0;i<e.length;i++)e[i]=!1;return e}function zh(t,e){switch(t){case"float":case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return Lh(2*e);case"bvec3":return Lh(3*e);case"bvec4":return Lh(4*e);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}let Nh=null;const Vh={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"},Hh={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"};function Wh(t,e){if(!Nh){const e=Object.keys(Vh);Nh={};for(let i=0;i<e.length;++i){const n=e[i];Nh[t[n]]=Vh[n]}}return Nh[e]}function jh(t,e){const i=Wh(t,e);return Hh[i]||"float32"}function Yh(t,e){const i=t.getShaderSource(e).split("\n").map((t,e)=>`${e}: ${t}`),n=t.getShaderInfoLog(e),r=n.split("\n"),s={},o=r.map(t=>parseFloat(t.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(t=>!(!t||s[t])&&(s[t]=!0,!0)),a=[""];o.forEach(t=>{i[t-1]=`%c${i[t-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=i.join("\n");a[0]=l,console.error(n),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Xh(t,e){const i=Gh(t,t.VERTEX_SHADER,e.vertex),n=Gh(t,t.FRAGMENT_SHADER,e.fragment),r=t.createProgram();t.attachShader(r,i),t.attachShader(r,n);const s=e.transformFeedbackVaryings;s&&("function"!=typeof t.transformFeedbackVaryings?kt("TransformFeedback is not supported but TransformFeedbackVaryings are given."):t.transformFeedbackVaryings(r,s.names,"separate"===s.bufferMode?t.SEPARATE_ATTRIBS:t.INTERLEAVED_ATTRIBS)),t.linkProgram(r),t.getProgramParameter(r,t.LINK_STATUS)||function(t,e,i,n){t.getProgramParameter(e,t.LINK_STATUS)||(t.getShaderParameter(i,t.COMPILE_STATUS)||Yh(t,i),t.getShaderParameter(n,t.COMPILE_STATUS)||Yh(t,n),console.error("PixiJS Error: Could not initialize shader."),""!==t.getProgramInfoLog(e)&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",t.getProgramInfoLog(e)))}(t,r,i,n),e._attributeData=function(t,e,i=!1){const n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let o=0;o<r;o++){const i=e.getActiveAttrib(t,o);if(i.name.startsWith("gl_"))continue;const r=jh(e,i.type);n[i.name]={location:0,format:r,stride:Ni(r).stride,offset:0,instance:!1,start:0}}const s=Object.keys(n);if(i){s.sort((t,e)=>t>e?1:-1);for(let i=0;i<s.length;i++)n[s[i]].location=i,e.bindAttribLocation(t,i,s[i]);e.linkProgram(t)}else for(let o=0;o<s.length;o++)n[s[o]].location=e.getAttribLocation(t,s[o]);return n}(r,t,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertex)),e._uniformData=function(t,e){const i={},n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;r++){const n=e.getActiveUniform(t,r),s=n.name.replace(/\[.*?\]$/,""),o=!!n.name.match(/\[.*?\]$/),a=Wh(e,n.type);i[s]={name:s,index:r,type:a,size:n.size,isArray:o,value:zh(a,n.size)}}return i}(r,t),e._uniformBlockData=function(t,e){if(!e.ACTIVE_UNIFORM_BLOCKS)return{};const i={},n=e.getProgramParameter(t,e.ACTIVE_UNIFORM_BLOCKS);for(let r=0;r<n;r++){const n=e.getActiveUniformBlockName(t,r),s=e.getUniformBlockIndex(t,n),o=e.getActiveUniformBlockParameter(t,r,e.UNIFORM_BLOCK_DATA_SIZE);i[n]={name:n,index:s,size:o}}return i}(r,t),t.deleteShader(i),t.deleteShader(n);const o={};for(const a in e._uniformData){const i=e._uniformData[a];o[a]={location:t.getUniformLocation(r,a),value:zh(i.type,i.size)}}return new Uh(r,o)}const Zh={textureCount:0,blockIndex:0};class qh{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_programDataHash")}contextChange(t){this._gl=t,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;Zh.textureCount=0,Zh.blockIndex=0;let i=this._shaderSyncFunctions[t.glProgram._key];i||(i=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),i(this._renderer,t,Zh)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,Zh)}bindUniformBlock(t,e,i=0){const n=this._renderer.buffer,r=this._getProgramData(this._activeProgram),s=t._bufferResource;s||this._renderer.ubo.updateUniformGroup(t);const o=t.buffer,a=n.updateBuffer(o),l=n.freeLocationForBufferBase(a);if(s){const{offset:e,size:i}=t;0===e&&i===o.data.byteLength?n.bindBufferBase(a,l):n.bindBufferRange(a,l,e)}else n.getLastBindBaseLocation(a)!==l&&n.bindBufferBase(a,l);const h=this._activeProgram._uniformBlockData[e].index;r.uniformBlockBindings[i]!==l&&(r.uniformBlockBindings[i]=l,this._renderer.gl.uniformBlockBinding(r.program,h,l))}_setProgram(t){if(this._activeProgram===t)return;this._activeProgram=t;const e=this._getProgramData(t);this._gl.useProgram(e.program)}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){const e=t._key;return this._programDataHash[e]=Xh(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash)){this._programDataHash[t].destroy(),this._programDataHash[t]=null}this._programDataHash=null}_generateShaderSync(t,e){return function(t,e){const i=[],n=["\n var g = s.groups;\n var sS = r.shader;\n var p = s.glProgram;\n var ugS = r.uniformGroup;\n var resources;\n "];let r=!1,s=0;const o=e._getProgramData(t.glProgram);for(const l in t.groups){const a=t.groups[l];i.push(`\n resources = g[${l}].resources;\n `);for(const h in a.resources){const c=a.resources[h];if(c instanceof Ki)if(c.ubo){const e=t._uniformBindMap[l][Number(h)];i.push(`\n sS.bindUniformBlock(\n resources[${h}],\n '${e}',\n ${t.glProgram._uniformBlockData[e].index}\n );\n `)}else i.push(`\n ugS.updateUniformGroup(resources[${h}], p, sD);\n `);else if(c instanceof Oh){const e=t._uniformBindMap[l][Number(h)];i.push(`\n sS.bindUniformBlock(\n resources[${h}],\n '${e}',\n ${t.glProgram._uniformBlockData[e].index}\n );\n `)}else if(c instanceof q){const a=t._uniformBindMap[l][h],c=o.uniformData[a];c&&(r||(r=!0,n.push("\n var tS = r.texture;\n ")),e._gl.uniform1i(c.location,s),i.push(`\n tS.bind(resources[${h}], ${s});\n `),s++)}}}const a=[...n,...i].join("\n");return new Function("r","s","sD",a)}(t,e)}resetState(){this._activeProgram=null}}qh.extension={type:[o.WebGLSystem],name:"shader"};const $h={f32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1f(location, v);\n }","vec2<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2f(location, v[0], v[1]);\n }","vec3<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3f(location, v[0], v[1], v[2]);\n }","vec4<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4f(location, v[0], v[1], v[2], v[3]);\n }",i32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1i(location, v);\n }","vec2<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2i(location, v[0], v[1]);\n }","vec3<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3i(location, v[0], v[1], v[2]);\n }","vec4<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }",u32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1ui(location, v);\n }","vec2<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2ui(location, v[0], v[1]);\n }","vec3<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3ui(location, v[0], v[1], v[2]);\n }","vec4<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4ui(location, v[0], v[1], v[2], v[3]);\n }",bool:"if (cv !== v) {\n cu.value = v;\n gl.uniform1i(location, v);\n }","vec2<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2i(location, v[0], v[1]);\n }","vec3<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3i(location, v[0], v[1], v[2]);\n }","vec4<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},Kh={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"};class Qh{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,i){const n=this._renderer.shader._getProgramData(e);if(!t.isStatic||t._dirtyId!==n.uniformDirtyGroups[t.uid]){n.uniformDirtyGroups[t.uid]=t._dirtyId;this._getUniformSyncFunction(t,e)(n.uniformData,t.uniforms,this._renderer,i)}}_getUniformSyncFunction(t,e){var i;return(null==(i=this._uniformGroupSyncHash[t._signature])?void 0:i[e._key])||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){const i=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),n=this._getSignature(t,e._uniformData,"u");return this._cache[n]||(this._cache[n]=this._generateUniformsSync(t,e._uniformData)),i[e._key]=this._cache[n],i[e._key]}_generateUniformsSync(t,e){return function(t,e){const i=["\n var v = null;\n var cv = null;\n var cu = null;\n var t = 0;\n var gl = renderer.gl;\n var name = null;\n "];for(const n in t.uniforms){if(!e[n]){t.uniforms[n]instanceof Ki?t.uniforms[n].ubo?i.push(`\n renderer.shader.bindUniformBlock(uv.${n}, "${n}");\n `):i.push(`\n renderer.shader.updateUniformGroup(uv.${n});\n `):t.uniforms[n]instanceof Oh&&i.push(`\n renderer.shader.bindBufferResource(uv.${n}, "${n}");\n `);continue}const r=t.uniformStructures[n];let s=!1;for(let t=0;t<vh.length;t++){const e=vh[t];if(r.type===e.type&&e.test(r)){i.push(`name = "${n}";`,vh[t].uniform),s=!0;break}}if(!s){const t=(1===r.size?$h:Kh)[r.type].replace("location",`ud["${n}"].location`);i.push(`\n cu = ud["${n}"];\n cv = cu.value;\n v = uv["${n}"];\n ${t};`)}}return new Function("ud","uv","renderer","syncData",i.join("\n"))}(t,e)}_getSignature(t,e,i){const n=t.uniforms,r=[`${i}-`];for(const s in n)r.push(s),e[s]&&r.push(e[s].type);return r.join("-")}destroy(){this._renderer=null,this._cache=null}}Qh.extension={type:[o.WebGLSystem],name:"uniformGroup"};const Jh=class t{constructor(t){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[0]=this.setBlend,this.map[1]=this.setOffset,this.map[2]=this.setCullFace,this.map[3]=this.setDepthTest,this.map[4]=this.setFrontFace,this.map[5]=this.setDepthMask,this.checks=[],this.defaultState=rn.for2d(),t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){this._invertFrontFace=!t.isRoot,this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(t){this.gl=t,this.blendModesMap=function(t){const e={};if(e.normal=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e.add=[t.ONE,t.ONE],e.multiply=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.screen=[t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.none=[0,0],e["normal-npm"]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e["add-npm"]=[t.SRC_ALPHA,t.ONE,t.ONE,t.ONE],e["screen-npm"]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.erase=[t.ZERO,t.ONE_MINUS_SRC_ALPHA],t instanceof Re.get().getWebGLRenderingContext()){const i=t.getExtension("EXT_blend_minmax");i&&(e.min=[t.ONE,t.ONE,t.ONE,t.ONE,i.MIN_EXT,i.MIN_EXT],e.max=[t.ONE,t.ONE,t.ONE,t.ONE,i.MAX_EXT,i.MAX_EXT])}else e.min=[t.ONE,t.ONE,t.ONE,t.ONE,t.MIN,t.MIN],e.max=[t.ONE,t.ONE,t.ONE,t.ONE,t.MAX,t.MAX];return e}(t),this.resetState()}set(t){if(t||(t=this.defaultState),this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)1&e&&this.map[i].call(this,!!(t.data&1<<i)),e>>=1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t||(t=this.defaultState);for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(e){this._updateCheck(t._checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this._updateCheck(t._checkPolygonOffset,e),this.gl[e?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this._cullFace=t,this.gl[t?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(t){this._frontFace=t,this._frontFaceDirty=!1;const e=this._invertFrontFace?!t:t;this._glFrontFace!==e&&(this._glFrontFace=e,this.gl.frontFace(this.gl[e?"CW":"CCW"]))}setBlendMode(t){if(this.blendModesMap[t]||(t="normal"),t===this.blendMode)return;this.blendMode=t;const e=this.blendModesMap[t],i=this.gl;2===e.length?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),6===e.length?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}resetState(){this._glFrontFace=!1,this._frontFace=!1,this._cullFace=!1,this._frontFaceDirty=!1,this._invertFrontFace=!1,this.gl.frontFace(this.gl.CCW),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode="",this.setBlendMode("normal")}_updateCheck(t,e){const i=this.checks.indexOf(t);e&&-1===i?this.checks.push(t):e||-1===i||this.checks.splice(i,1)}static _checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static _checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};Jh.extension={type:[o.WebGLSystem],name:"state"};let tc=Jh;class ec{constructor(t){this.target=nh.TEXTURE_2D,this.texture=t,this.width=-1,this.height=-1,this.type=rh.UNSIGNED_BYTE,this.internalFormat=ih.RGBA,this.format=ih.RGBA,this.samplerType=0}}const ic={id:"buffer",upload(t,e,i){e.width===t.width||e.height===t.height?i.texSubImage2D(i.TEXTURE_2D,0,0,0,t.width,t.height,e.format,e.type,t.resource):i.texImage2D(e.target,0,e.internalFormat,t.width,t.height,0,e.format,e.type,t.resource),e.width=t.width,e.height=t.height}},nc={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},rc={id:"compressed",upload(t,e,i){i.pixelStorei(i.UNPACK_ALIGNMENT,4);let n=t.pixelWidth,r=t.pixelHeight;const s=!!nc[t.format];for(let o=0;o<t.resource.length;o++){const a=t.resource[o];s?i.compressedTexImage2D(i.TEXTURE_2D,o,e.internalFormat,n,r,0,a):i.texImage2D(i.TEXTURE_2D,o,e.internalFormat,n,r,0,e.format,e.type,a),n=Math.max(n>>1,1),r=Math.max(r>>1,1)}}},sc={id:"image",upload(t,e,i,n){const r=e.width,s=e.height,o=t.pixelWidth,a=t.pixelHeight,l=t.resourceWidth,h=t.resourceHeight;l<o||h<a?(r===o&&s===a||i.texImage2D(e.target,0,e.internalFormat,o,a,0,e.format,e.type,null),2===n?i.texSubImage2D(i.TEXTURE_2D,0,0,0,l,h,e.format,e.type,t.resource):i.texSubImage2D(i.TEXTURE_2D,0,0,0,e.format,e.type,t.resource)):r===o&&s===a?i.texSubImage2D(i.TEXTURE_2D,0,0,0,e.format,e.type,t.resource):2===n?i.texImage2D(e.target,0,e.internalFormat,o,a,0,e.format,e.type,t.resource):i.texImage2D(e.target,0,e.internalFormat,e.format,e.type,t.resource),e.width=o,e.height=a}},oc={id:"video",upload(t,e,i,n){t.isValid?sc.upload(t,e,i,n):i.texImage2D(e.target,0,e.internalFormat,1,1,0,e.format,e.type,null)}},ac={linear:9729,nearest:9728},lc={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},hc={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},cc={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function uc(t,e,i,n,r,s,o,a){const l=s;if(!a||"repeat"!==t.addressModeU||"repeat"!==t.addressModeV||"repeat"!==t.addressModeW){const i=hc[o?"clamp-to-edge":t.addressModeU],n=hc[o?"clamp-to-edge":t.addressModeV],s=hc[o?"clamp-to-edge":t.addressModeW];e[r](l,e.TEXTURE_WRAP_S,i),e[r](l,e.TEXTURE_WRAP_T,n),e.TEXTURE_WRAP_R&&e[r](l,e.TEXTURE_WRAP_R,s)}if(a&&"linear"===t.magFilter||e[r](l,e.TEXTURE_MAG_FILTER,ac[t.magFilter]),i){if(!a||"linear"!==t.mipmapFilter){const i=lc[t.minFilter][t.mipmapFilter];e[r](l,e.TEXTURE_MIN_FILTER,i)}}else e[r](l,e.TEXTURE_MIN_FILTER,ac[t.minFilter]);if(n&&t.maxAnisotropy>1){const i=Math.min(t.maxAnisotropy,e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));e[r](l,n.TEXTURE_MAX_ANISOTROPY_EXT,i)}t.compare&&e[r](l,e.TEXTURE_COMPARE_FUNC,cc[t.compare])}class dc{constructor(t){this.managedTextures=[],this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._uploads={image:sc,buffer:ic,video:oc,compressed:rc},this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_glTextures"),this._renderer.renderableGC.addManagedHash(this,"_glSamplers")}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=function(t,e){let i={},n=t.RGBA;return t instanceof Re.get().getWebGLRenderingContext()?e.srgb&&(i={"rgba8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT}):(i={"rgba8unorm-srgb":t.SRGB8_ALPHA8,"bgra8unorm-srgb":t.SRGB8_ALPHA8},n=t.RGBA8),__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({r8unorm:t.R8,r8snorm:t.R8_SNORM,r8uint:t.R8UI,r8sint:t.R8I,r16uint:t.R16UI,r16sint:t.R16I,r16float:t.R16F,rg8unorm:t.RG8,rg8snorm:t.RG8_SNORM,rg8uint:t.RG8UI,rg8sint:t.RG8I,r32uint:t.R32UI,r32sint:t.R32I,r32float:t.R32F,rg16uint:t.RG16UI,rg16sint:t.RG16I,rg16float:t.RG16F,rgba8unorm:t.RGBA},i),{rgba8snorm:t.RGBA8_SNORM,rgba8uint:t.RGBA8UI,rgba8sint:t.RGBA8I,bgra8unorm:n,rgb9e5ufloat:t.RGB9_E5,rgb10a2unorm:t.RGB10_A2,rg11b10ufloat:t.R11F_G11F_B10F,rg32uint:t.RG32UI,rg32sint:t.RG32I,rg32float:t.RG32F,rgba16uint:t.RGBA16UI,rgba16sint:t.RGBA16I,rgba16float:t.RGBA16F,rgba32uint:t.RGBA32UI,rgba32sint:t.RGBA32I,rgba32float:t.RGBA32F,stencil8:t.STENCIL_INDEX8,depth16unorm:t.DEPTH_COMPONENT16,depth24plus:t.DEPTH_COMPONENT24,"depth24plus-stencil8":t.DEPTH24_STENCIL8,depth32float:t.DEPTH_COMPONENT32F,"depth32float-stencil8":t.DEPTH32F_STENCIL8}),e.s3tc?{"bc1-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{}),e.s3tc_sRGB?{"bc1-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{}),e.rgtc?{"bc4-r-unorm":e.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":e.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":e.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":e.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{}),e.bptc?{"bc6h-rgb-float":e.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":e.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":e.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":e.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{}),e.etc?{"etc2-rgb8unorm":e.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":e.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":e.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":e.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":e.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":e.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":e.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":e.etc.COMPRESSED_SIGNED_RG11_EAC}:{}),e.astc?{"astc-4x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{})}(t,this._renderer.context.extensions),this._mapFormatToType=function(t){return{r8unorm:t.UNSIGNED_BYTE,r8snorm:t.BYTE,r8uint:t.UNSIGNED_BYTE,r8sint:t.BYTE,r16uint:t.UNSIGNED_SHORT,r16sint:t.SHORT,r16float:t.HALF_FLOAT,rg8unorm:t.UNSIGNED_BYTE,rg8snorm:t.BYTE,rg8uint:t.UNSIGNED_BYTE,rg8sint:t.BYTE,r32uint:t.UNSIGNED_INT,r32sint:t.INT,r32float:t.FLOAT,rg16uint:t.UNSIGNED_SHORT,rg16sint:t.SHORT,rg16float:t.HALF_FLOAT,rgba8unorm:t.UNSIGNED_BYTE,"rgba8unorm-srgb":t.UNSIGNED_BYTE,rgba8snorm:t.BYTE,rgba8uint:t.UNSIGNED_BYTE,rgba8sint:t.BYTE,bgra8unorm:t.UNSIGNED_BYTE,"bgra8unorm-srgb":t.UNSIGNED_BYTE,rgb9e5ufloat:t.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:t.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:t.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:t.UNSIGNED_INT,rg32sint:t.INT,rg32float:t.FLOAT,rgba16uint:t.UNSIGNED_SHORT,rgba16sint:t.SHORT,rgba16float:t.HALF_FLOAT,rgba32uint:t.UNSIGNED_INT,rgba32sint:t.INT,rgba32float:t.FLOAT,stencil8:t.UNSIGNED_BYTE,depth16unorm:t.UNSIGNED_SHORT,depth24plus:t.UNSIGNED_INT,"depth24plus-stencil8":t.UNSIGNED_INT_24_8,depth32float:t.FLOAT,"depth32float-stencil8":t.FLOAT_32_UNSIGNED_INT_24_8_REV}}(t),this._mapFormatToFormat=function(t){return{r8unorm:t.RED,r8snorm:t.RED,r8uint:t.RED,r8sint:t.RED,r16uint:t.RED,r16sint:t.RED,r16float:t.RED,rg8unorm:t.RG,rg8snorm:t.RG,rg8uint:t.RG,rg8sint:t.RG,r32uint:t.RED,r32sint:t.RED,r32float:t.RED,rg16uint:t.RG,rg16sint:t.RG,rg16float:t.RG,rgba8unorm:t.RGBA,"rgba8unorm-srgb":t.RGBA,rgba8snorm:t.RGBA,rgba8uint:t.RGBA,rgba8sint:t.RGBA,bgra8unorm:t.RGBA,"bgra8unorm-srgb":t.RGBA,rgb9e5ufloat:t.RGB,rgb10a2unorm:t.RGBA,rg11b10ufloat:t.RGB,rg32uint:t.RG,rg32sint:t.RG,rg32float:t.RG,rgba16uint:t.RGBA,rgba16sint:t.RGBA,rgba16float:t.RGBA,rgba32uint:t.RGBA,rgba32sint:t.RGBA,rgba32float:t.RGBA,stencil8:t.STENCIL_INDEX8,depth16unorm:t.DEPTH_COMPONENT,depth24plus:t.DEPTH_COMPONENT,"depth24plus-stencil8":t.DEPTH_STENCIL,depth32float:t.DEPTH_COMPONENT,"depth32float-stencil8":t.DEPTH_STENCIL}}(t)),this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let e=0;e<16;e++)this.bind(J.EMPTY,e)}initSource(t){this.bind(t)}bind(t,e=0){const i=t.source;t?(this.bindSource(i,e),this._useSeparateSamplers&&this._bindSampler(i.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){const i=this._gl;if(t._touched=this._renderer.textureGC.count,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t||(t=J.EMPTY.source);const n=this.getGlSource(t);i.bindTexture(n.target,n.texture)}}_bindSampler(t,e=0){const i=this._gl;if(!t)return this._boundSamplers[e]=null,void i.bindSampler(e,null);const n=this._getGlSampler(t);this._boundSamplers[e]!==n&&(this._boundSamplers[e]=n,i.bindSampler(e,n))}unbind(t){const e=t.source,i=this._boundTextures,n=this._gl;for(let r=0;r<i.length;r++)if(i[r]===e){this._activateLocation(r);const t=this.getGlSource(e);n.bindTexture(t.target,null),i[r]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,i=new ec(e.createTexture());if(i.type=this._mapFormatToType[t.format],i.internalFormat=this._mapFormatToInternalFormat[t.format],i.format=this._mapFormatToFormat[t.format],t.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||t.isPowerOfTwo)){const e=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(e))+1}return this._glTextures[t.uid]=i,this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceUpdate,this),t.on("styleChange",this.onStyleChange,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),this.updateStyle(t,!1),i}onStyleChange(t){this.updateStyle(t,!1)}updateStyle(t,e){const i=this._gl,n=this.getGlSource(t);i.bindTexture(i.TEXTURE_2D,n.texture),this._boundTextures[this._activeTextureLocation]=t,uc(t.style,i,t.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t){const e=this._glTextures[t.uid];e&&(this.unbind(t),this._glTextures[t.uid]=null,this._gl.deleteTexture(e.texture))}onSourceUpdate(t){const e=this._gl,i=this.getGlSource(t);e.bindTexture(e.TEXTURE_2D,i.texture),this._boundTextures[this._activeTextureLocation]=t;const n="premultiply-alpha-on-upload"===t.alphaMode;this._premultiplyAlpha!==n&&(this._premultiplyAlpha=n,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n)),this._uploads[t.uploadMethodId]?this._uploads[t.uploadMethodId].upload(t,i,e,this._renderer.context.webGLVersion):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t.pixelWidth,t.pixelHeight,0,e.RGBA,e.UNSIGNED_BYTE,null),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const i=this.getGlSource(t);this._gl.generateMipmap(i.target)}onSourceDestroy(t){t.off("destroy",this.onSourceDestroy,this),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}_initSampler(t){const e=this._gl,i=this._gl.createSampler();return this._glSamplers[t._resourceId]=i,uc(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",i,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return this._glTextures[t.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:i,height:n}=this.getPixels(t),r=Re.get().createCanvas();r.width=i,r.height=n;const s=r.getContext("2d");if(s){const t=s.createImageData(i,n);t.data.set(e),s.putImageData(t,0,0)}return r}getPixels(t){const e=t.source.resolution,i=t.frame,n=Math.max(Math.round(i.width*e),1),r=Math.max(Math.round(i.height*e),1),s=new Uint8Array(4*n*r),o=this._renderer,a=o.renderTarget.getRenderTarget(t),l=o.renderTarget.getGpuRenderTarget(a),h=o.gl;return h.bindFramebuffer(h.FRAMEBUFFER,l.resolveTargetFramebuffer),h.readPixels(Math.round(i.x*e),Math.round(i.y*e),n,r,h.RGBA,h.UNSIGNED_BYTE,s),{pixels:new Uint8ClampedArray(s.buffer),width:n,height:r}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(J.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}dc.extension={type:[o.WebGLSystem],name:"texture"};class pc{contextChange(t){const e=new Ki({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new S,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),i=t.limits.maxBatchableTextures,n=us({name:"graphics",bits:[ps,bs(i),Vl,ws]});this.shader=new tn({glProgram:n,resources:{localUniforms:e,batchSamplers:As(i)}})}execute(t,e){const i=e.context,n=i.customShader||this.shader,r=t.renderer,s=r.graphicsContext,{batcher:o,instructions:a}=s.getContextRenderData(i);n.groups[0]=r.globalUniforms.bindGroup,r.state.set(t.state),r.shader.bind(n),r.geometry.bind(o.geometry,n.glProgram);const l=a.instructions;for(let h=0;h<a.instructionSize;h++){const t=l[h];if(t.size){for(let e=0;e<t.textures.count;e++)r.texture.bind(t.textures.textures[e],e);r.geometry.draw(t.topology,t.size,t.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}pc.extension={type:[o.WebGLPipesAdaptor],name:"graphics"};class fc{init(){const t=us({name:"mesh",bits:[Vl,Wl,ws]});this._shader=new tn({glProgram:t,resources:{uTexture:J.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new S}}}})}execute(t,e){const i=t.renderer;let n=e._shader;if(n){if(!n.glProgram)return void kt("Mesh shader has no glProgram",e.shader)}else{n=this._shader;const t=e.texture,i=t.source;n.resources.uTexture=i,n.resources.uSampler=i.style,n.resources.textureUniforms.uniforms.uTextureMatrix=t.textureMatrix.mapCoord}n.groups[100]=i.globalUniforms.bindGroup,n.groups[101]=t.localUniformsBindGroup,i.encoder.draw({geometry:e._geometry,shader:n,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}fc.extension={type:[o.WebGLPipesAdaptor],name:"mesh"};class gc{constructor(t){this._renderer=t}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}gc.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"customRender"};class mc{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(){}}function _c(t,e){const i=t.instructionSet,n=i.instructions;for(let r=0;r<i.instructionSize;r++){const t=n[r];e[t.renderPipeId].execute(t)}}const yc=new S;class xc{constructor(t){this._renderer=t}addRenderGroup(t,e){t.isCachedAsTexture?this._addRenderableCacheAsTexture(t,e):this._addRenderableDirect(t,e)}execute(t){t.isRenderable&&(t.isCachedAsTexture?this._executeCacheAsTexture(t):this._executeDirect(t))}destroy(){this._renderer=null}_addRenderableDirect(t,e){this._renderer.renderPipes.batch.break(e),t._batchableRenderGroup&&(Dt.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){var i;const n=null!=(i=t._batchableRenderGroup)?i:t._batchableRenderGroup=Dt.get(mc);n.renderable=t.root,n.transform=t.root.relativeGroupTransform,n.texture=t.texture,n.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.batch.addToBatch(n,e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;const e=yc.identity().translate(-t._textureBounds.x,-t._textureBounds.y);this._renderer.renderTarget.push(t.texture,!0,null,t.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:e,worldColor:4294967295}),_c(t,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}t._batchableRenderGroup._batcher.updateElement(t._batchableRenderGroup),t._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(t){this._renderer.globalUniforms.push({worldTransformMatrix:t.inverseParentTextureTransform,worldColor:t.worldColorAlpha}),_c(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}function bc(t,e){e||(e=0);for(let i=e;i<t.length&&t[i];i++)t[i]=null}xc.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"renderGroup"};const vc=new xe;function wc(t,e=!1){!function(t){const e=t.root;let i;if(t.renderGroupParent){const n=t.renderGroupParent;t.worldTransform.appendFrom(e.relativeGroupTransform,n.worldTransform),t.worldColor=Jt(e.groupColor,n.worldColor),i=e.groupAlpha*n.worldAlpha}else t.worldTransform.copyFrom(e.localTransform),t.worldColor=e.localColor,i=e.localAlpha;i=i<0?0:i>1?1:i,t.worldAlpha=i,t.worldColorAlpha=t.worldColor+(255*i<<24)}(t);const i=t.childrenToUpdate,n=t.updateTick++;for(const r in i){const e=Number(r),s=i[r],o=s.list,a=s.index;for(let i=0;i<a;i++){const r=o[i];r.parentRenderGroup===t&&r.relativeRenderGroupDepth===e&&Sc(r,n,0)}bc(o,a),s.index=0}if(e)for(let r=0;r<t.renderGroupChildren.length;r++)wc(t.renderGroupChildren[r],e)}function Sc(t,e,i){if(e===t.updateTick)return;t.updateTick=e,t.didChange=!1;const n=t.localTransform;t.updateLocalTransform();const r=t.parent;if(r&&!r.renderGroup?(i|=t._updateFlags,t.relativeGroupTransform.appendFrom(n,r.relativeGroupTransform),7&i&&Ac(t,r,i)):(i=t._updateFlags,t.relativeGroupTransform.copyFrom(n),7&i&&Ac(t,vc,i)),!t.renderGroup){const n=t.children,r=n.length;for(let t=0;t<r;t++)Sc(n[t],e,i);const s=t.parentRenderGroup,o=t;o.renderPipeId&&!s.structureDidChange&&s.updateRenderable(o)}}function Ac(t,e,i){if(1&i){t.groupColor=Jt(t.localColor,e.groupColor);let i=t.localAlpha*e.groupAlpha;i=i<0?0:i>1?1:i,t.groupAlpha=i,t.groupColorAlpha=t.groupColor+(255*i<<24)}2&i&&(t.groupBlendMode="inherit"===t.localBlendMode?e.groupBlendMode:t.localBlendMode),4&i&&(t.globalDisplayStatus=t.localDisplayStatus&e.globalDisplayStatus),t._updateFlags=0}const Tc=new S;class Cc{constructor(t){this._renderer=t}render({container:t,transform:e}){const i=t.parent,n=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;const r=this._renderer;let s=Tc;e&&(s=s.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const o=r.renderPipes;this._updateCachedRenderGroups(t.renderGroup,null),this._updateRenderGroups(t.renderGroup),r.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),_c(t.renderGroup,o),o.uniformBatch&&o.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(s),t.parent=i,t.renderGroup.renderGroupParent=n}destroy(){this._renderer=null}_updateCachedRenderGroups(t,e){var i,n;if(t.isCachedAsTexture){if(!t.updateCacheTexture)return;e=t}t._parentCacheAsTextureRenderGroup=e;for(let r=t.renderGroupChildren.length-1;r>=0;r--)this._updateCachedRenderGroups(t.renderGroupChildren[r],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const e=t.root.getLocalBounds();e.ceil();const r=t.texture;t.texture&&pe.returnTexture(t.texture,!0);const s=this._renderer,o=t.textureOptions.resolution||s.view.resolution,a=null!=(i=t.textureOptions.antialias)?i:s.view.antialias,l=null!=(n=t.textureOptions.scaleMode)?n:"linear",h=pe.getOptimalTexture(e.width,e.height,o,a);h._source.style=new X({scaleMode:l}),t.texture=h,t._textureBounds||(t._textureBounds=new it),t._textureBounds.copyFrom(e),r!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(pe.returnTexture(t.texture,!0),t.texture=null)}_updateRenderGroups(t){const e=this._renderer,i=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=i,t.structureDidChange?bc(t.childrenRenderablesToUpdate.list,0):function(t,e){const{list:i,index:n}=t.childrenRenderablesToUpdate;let r=!1;for(let s=0;s<n;s++){const t=i[s];if(r=e[t.renderPipeId].validateRenderable(t),r)break}t.structureDidChange=r}(t,i),wc(t),t.structureDidChange?(t.structureDidChange=!1,this._buildInstructions(t,e)):this._updateRenderables(t),t.childrenRenderablesToUpdate.index=0,e.renderPipes.batch.upload(t.instructionSet),!t.isCachedAsTexture||t.textureNeedsUpdate)for(let n=0;n<t.renderGroupChildren.length;n++)this._updateRenderGroups(t.renderGroupChildren[n])}_updateRenderables(t){const{list:e,index:i}=t.childrenRenderablesToUpdate;for(let n=0;n<i;n++){const i=e[n];i.didViewUpdate&&t.updateRenderable(i)}bc(e,i)}_buildInstructions(t,e){const i=t.root,n=t.instructionSet;n.reset();const r=e.renderPipes?e:e.batch.renderer,s=r.renderPipes;s.batch.buildStart(n),s.blendMode.buildStart(),s.colorMask.buildStart(),i.sortableChildren&&i.sortChildren(),i.collectRenderablesWithEffects(n,r,null),s.batch.buildEnd(n),s.blendMode.buildEnd(n)}}Cc.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"renderGroup"};class Pc{constructor(t){this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.bounds=t.visualBounds,e.texture=t._texture}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=new mc;return e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.bounds=t.visualBounds,e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Pc.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"sprite"};const Mc=class t{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Bt(0),this.color=this._backgroundColor,this.alpha=1}init(e){e=__spreadValues(__spreadValues({},t.defaultOptions),e),this.clearBeforeRender=e.clearBeforeRender,this.color=e.background||e.backgroundColor||this._backgroundColor,this.alpha=e.backgroundAlpha,this._backgroundColor.setAlpha(e.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){Bt.shared.setValue(t).alpha<1&&1===this._backgroundColor.alpha&&kt("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."),this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};Mc.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"background",priority:0},Mc.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let Ec=Mc;const Rc={};h.handle(o.BlendMode,t=>{if(!t.name)throw new Error("BlendMode extension must have a name property");Rc[t.name]=t.ref},t=>{delete Rc[t.name]});class Bc{constructor(t){this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}setBlendMode(t,e,i){this._activeBlendMode!==e?(this._activeBlendMode=e,this._isAdvanced&&this._endAdvancedBlendMode(i),this._isAdvanced=!!Rc[e],this._isAdvanced&&(this._beginAdvancedBlendMode(i),this._renderableList.push(t))):this._isAdvanced&&this._renderableList.push(t)}_beginAdvancedBlendMode(t){this._renderer.renderPipes.batch.break(t);const e=this._activeBlendMode;if(!Rc[e])return void kt(`Unable to assign BlendMode: '${e}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);let i=this._filterHash[e];i||(i=this._filterHash[e]=new zt,i.filters=[new Rc[e]]);const n={renderPipeId:"filter",action:"pushFilter",renderables:[],filterEffect:i,canBundle:!1};this._renderableList=n.renderables,t.add(n)}_endAdvancedBlendMode(t){this._renderableList=null,this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(t){this._isAdvanced&&this._endAdvancedBlendMode(t)}destroy(){this._renderer=null,this._renderableList=null;for(const t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}}Bc.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"blendMode"};const Fc={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},kc=class t{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof xe||t instanceof J?__spreadValues({target:t},e):__spreadValues(__spreadValues({},e),t)}image(t){return __async(this,null,function*(){const e=Re.get().createImage();return e.src=yield this.base64(t),e})}base64(e){return __async(this,null,function*(){e=this._normalizeOptions(e,t.defaultImageOptions);const{format:i,quality:n}=e,r=this.canvas(e);if(void 0!==r.toBlob)return new Promise((t,e)=>{r.toBlob(i=>{if(!i)return void e(new Error("ICanvas.toBlob failed!"));const n=new FileReader;n.onload=()=>t(n.result),n.onerror=e,n.readAsDataURL(i)},Fc[i],n)});if(void 0!==r.toDataURL)return r.toDataURL(Fc[i],n);if(void 0!==r.convertToBlob){const t=yield r.convertToBlob({type:Fc[i],quality:n});return new Promise((e,i)=>{const n=new FileReader;n.onload=()=>e(n.result),n.onerror=i,n.readAsDataURL(t)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")})}canvas(t){const e=(t=this._normalizeOptions(t)).target,i=this._renderer;if(e instanceof J)return i.texture.generateCanvas(e);const n=i.textureGenerator.generateTexture(t),r=i.texture.generateCanvas(n);return n.destroy(!0),r}pixels(t){const e=(t=this._normalizeOptions(t)).target,i=this._renderer,n=e instanceof J?e:i.textureGenerator.generateTexture(t),r=i.texture.getPixels(n);return e instanceof xe&&n.destroy(!0),r}texture(t){return(t=this._normalizeOptions(t)).target instanceof J?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){var e;t=this._normalizeOptions(t);const i=this.canvas(t),n=document.createElement("a");n.download=null!=(e=t.filename)?e:"image.png",n.href=i.toDataURL("image/png"),document.body.appendChild(n),n.click(),document.body.removeChild(n)}log(t){var e;const i=null!=(e=t.width)?e:200;t=this._normalizeOptions(t);const n=this.canvas(t),r=n.toDataURL();console.log(`[Pixi Texture] ${n.width}px ${n.height}px`);const s=["font-size: 1px;",`padding: ${i}px 300px;`,`background: url(${r}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",s)}destroy(){this._renderer=null}};kc.extension={type:[o.WebGLSystem,o.WebGPUSystem],name:"extract"},kc.defaultImageOptions={format:"png",quality:1};let Ic=kc;class Dc extends J{static create(t){return new Dc({source:new q(t)})}resize(t,e,i){return this.source.resize(t,e,i),this}}const Oc=new D,Uc=new it,Gc=[0,0,0,0];class Lc{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof xe&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const i=t.resolution||this._renderer.resolution,n=t.antialias||this._renderer.view.antialias,r=t.target;let s=t.clearColor;if(s){s=Array.isArray(s)&&4===s.length?s:Bt.shared.setValue(s).toArray()}else s=Gc;const o=(null==(e=t.frame)?void 0:e.copyTo(Oc))||ie(r,Uc).rectangle;o.width=0|Math.max(o.width,1/i),o.height=0|Math.max(o.height,1/i);const a=Dc.create(__spreadProps(__spreadValues({},t.textureSourceOptions),{width:o.width,height:o.height,resolution:i,antialias:n})),l=S.shared.translate(-o.x,-o.y);return this._renderer.render({container:r,transform:l,target:a,clearColor:s}),a.source.updateMipmaps(),a}destroy(){this._renderer=null}}function zc(t,e,i){const n=(t>>24&255)/255;e[i++]=(255&t)/255*n,e[i++]=(t>>8&255)/255*n,e[i++]=(t>>16&255)/255*n,e[i++]=n}Lc.extension={type:[o.WebGLSystem,o.WebGPUSystem],name:"textureGenerator"};class Nc{constructor(t){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=t}reset(){this._stackIndex=0;for(let t=0;t<this._activeUniforms.length;t++)this._uniformsPool.push(this._activeUniforms[t]);for(let t=0;t<this._activeBindGroups.length;t++)this._bindGroupPool.push(this._activeBindGroups[t]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(t){this.reset(),this.push(t)}bind({size:t,projectionMatrix:e,worldTransformMatrix:i,worldColor:n,offset:r}){const s=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{worldTransformMatrix:new S,worldColor:4294967295,offset:new v},a={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||s.size,worldTransformMatrix:i||o.worldTransformMatrix,worldColor:n||o.worldColor,offset:r||o.offset,bindGroup:null},l=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(l);const h=l.uniforms;let c;h.uProjectionMatrix=a.projectionMatrix,h.uResolution=a.resolution,h.uWorldTransformMatrix.copyFrom(a.worldTransformMatrix),h.uWorldTransformMatrix.tx-=a.offset.x,h.uWorldTransformMatrix.ty-=a.offset.y,zc(a.worldColor,h.uWorldColorAlpha,0),l.update(),this._renderer.renderPipes.uniformBatch?c=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(l,!1):(c=this._bindGroupPool.pop()||new Qi,this._activeBindGroups.push(c),c.setResource(l,0)),a.bindGroup=c,this._currentGlobalUniformData=a}push(t){this.bind(t),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===Ji.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new Ki({uProjectionMatrix:{value:new S,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new S,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null}}Nc.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"globalUniforms"};let Vc=1;class Hc{constructor(){this._tasks=[],this._offset=0}init(){Ue.system.add(this._update,this)}repeat(t,e,i=!0){const n=Vc++;let r=0;return i&&(this._offset+=1e3,r=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:r,last:performance.now(),repeat:!0,id:n}),n}cancel(t){for(let e=0;e<this._tasks.length;e++)if(this._tasks[e].id===t)return void this._tasks.splice(e,1)}_update(){const t=performance.now();for(let e=0;e<this._tasks.length;e++){const i=this._tasks[e];if(t-i.offset-i.last>=i.duration){const e=t-i.start;i.func(e),i.last=t}}}destroy(){Ue.system.remove(this._update,this),this._tasks.length=0}}Hc.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"scheduler",priority:0};let Wc=!1;class jc{constructor(t){this._renderer=t}init(t){if(t.hello){let t=this._renderer.name;this._renderer.type===Ji.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),function(t){if(!Wc){if(Re.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${Xn} (${t}) http://www.pixijs.com/\n\n`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...e)}else globalThis.console&&globalThis.console.log(`PixiJS ${Xn} - ${t} - http://www.pixijs.com/`);Wc=!0}}(t)}}}function Yc(t){let e=!1;for(const n in t)if(null==t[n]){e=!0;break}if(!e)return t;const i=Object.create(null);for(const n in t){const e=t[n];e&&(i[n]=e)}return i}function Xc(t){let e=0;for(let i=0;i<t.length;i++)null==t[i]?e++:t[i-e]=t[i];return t.length-=e,t}jc.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"hello",priority:-2},jc.defaultOptions={hello:!1};let Zc=0;const qc=class t{constructor(t){this._managedRenderables=[],this._managedHashes=[],this._managedArrays=[],this._renderer=t}init(e){e=__spreadValues(__spreadValues({},t.defaultOptions),e),this.maxUnusedTime=e.renderableGCMaxUnusedTime,this._frequency=e.renderableGCFrequency,this.enabled=e.renderableGCActive}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>this.run(),this._frequency,!1),this._hashHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedHashes)t.context[t.hash]=Yc(t.context[t.hash])},this._frequency),this._arrayHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedArrays)Xc(t.context[t.hash])},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._hashHandler),this._renderer.scheduler.cancel(this._arrayHandler)))}addManagedHash(t,e){this._managedHashes.push({context:t,hash:e})}addManagedArray(t,e){this._managedArrays.push({context:t,hash:e})}prerender({container:t}){this._now=performance.now(),t.renderGroup.gcTick=Zc++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}addRenderable(t){this.enabled&&(-1===t._lastUsed&&(this._managedRenderables.push(t),t.once("destroyed",this._removeRenderable,this)),t._lastUsed=this._now)}run(){var t,e,i,n;const r=this._now,s=this._managedRenderables,o=this._renderer.renderPipes;let a=0;for(let l=0;l<s.length;l++){const h=s[l];if(null===h){a++;continue}const c=null!=(t=h.renderGroup)?t:h.parentRenderGroup,u=null!=(i=null==(e=null==c?void 0:c.instructionSet)?void 0:e.gcTick)?i:-1;if((null!=(n=null==c?void 0:c.gcTick)?n:0)===u&&(h._lastUsed=r),r-h._lastUsed>this.maxUnusedTime){if(!h.destroyed){const t=o;c&&(c.structureDidChange=!0),t[h.renderPipeId].destroyRenderable(h)}h._lastUsed=-1,a++,h.off("destroyed",this._removeRenderable,this)}else s[l-a]=h}s.length-=a}destroy(){this.enabled=!1,this._renderer=null,this._managedRenderables.length=0,this._managedHashes.length=0,this._managedArrays.length=0}_removeRenderable(t){const e=this._managedRenderables.indexOf(t);e>=0&&(t.off("destroyed",this._removeRenderable,this),this._managedRenderables[e]=null)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e;for(const i of t.renderGroupChildren)this._updateInstructionGCTick(i,e)}};qc.extension={type:[o.WebGLSystem,o.WebGPUSystem],name:"renderableGC",priority:0},qc.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let $c=qc;const Kc=class t{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(e){var i;e=__spreadValues(__spreadValues({},t.defaultOptions),e),this.checkCountMax=e.textureGCCheckCountMax,this.maxIdle=null!=(i=e.textureGCAMaxIdle)?i:e.textureGCMaxIdle,this.active=e.textureGCActive}postrender(){this._renderer.renderingToScreen&&(this.count++,this.active&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this._renderer.texture.managedTextures;for(let e=0;e<t.length;e++){const i=t[e];i.autoGarbageCollect&&i.resource&&i._touched>-1&&this.count-i._touched>this.maxIdle&&(i._touched=-1,i.unload())}}destroy(){this._renderer=null}};Kc.extension={type:[o.WebGLSystem,o.WebGPUSystem],name:"textureGC"},Kc.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Qc=Kc;const Jc=class t{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(t){this.texture.source.autoDensity=t}get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}init(e){(e=__spreadValues(__spreadValues({},t.defaultOptions),e)).view&&(z(L,"ViewSystem.view has been renamed to ViewSystem.canvas"),e.canvas=e.view),this.screen=new D(0,0,e.width,e.height),this.canvas=e.canvas||Re.get().createCanvas(),this.antialias=!!e.antialias,this.texture=Bh(this.canvas,e),this.renderTarget=new kh({colorTextures:[this.texture],depth:!!e.depth,isRoot:!0}),this.texture.source.transparent=e.backgroundAlpha<1,this.resolution=e.resolution}resize(t,e,i){this.texture.source.resize(t,e,i),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){("boolean"==typeof t?t:!!(null==t?void 0:t.removeView))&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}};Jc.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"view",priority:0},Jc.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};const tu=[Ec,Nc,jc,Jc,Cc,Qc,Lc,Ic,qn,$c,Hc],eu=[Bc,Ll,Pc,xc,Xl,ql,Zl,gc],iu=[...tu,Mh,uh,th,fh,Ql,dc,Dh,lh,Qh,qh,ph,tc,_h,dh],nu=[...eu],ru=[Dl,fc,pc],su=[],ou=[],au=[];h.handleByNamedList(o.WebGLSystem,su),h.handleByNamedList(o.WebGLPipes,ou),h.handleByNamedList(o.WebGLPipesAdaptor,au),h.add(...iu,...nu,...ru);const lu=Object.freeze(Object.defineProperty({__proto__:null,WebGLRenderer:class extends Hn{constructor(){super({name:"webgl",type:Ji.WEBGL,systems:su,renderPipes:ou,renderPipeAdaptors:au})}}},Symbol.toStringTag,{value:"Module"}));class hu{constructor(t){this._hash=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_hash")}contextChange(t){this._gpu=t}getBindGroup(t,e,i){t._updateKey();return this._hash[t._key]||this._createBindGroup(t,e,i)}_createBindGroup(t,e,i){var n;const r=this._gpu.device,s=e.layout[i],o=[],a=this._renderer;for(const c in s){const e=null!=(n=t.resources[c])?n:t.resources[s[c]];let i;if("uniformGroup"===e._resourceType){const t=e;a.ubo.updateUniformGroup(t);const n=t.buffer;i={buffer:a.buffer.getGPUBuffer(n),offset:0,size:n.descriptor.size}}else if("buffer"===e._resourceType){const t=e;i={buffer:a.buffer.getGPUBuffer(t),offset:0,size:t.descriptor.size}}else if("bufferResource"===e._resourceType){const t=e;i={buffer:a.buffer.getGPUBuffer(t.buffer),offset:t.offset,size:t.size}}else if("textureSampler"===e._resourceType){const t=e;i=a.texture.getGpuSampler(t)}else if("textureSource"===e._resourceType){const t=e;i=a.texture.getGpuSource(t).createView({})}o.push({binding:s[c],resource:i})}const l=a.shader.getProgramData(e).bindGroups[i],h=r.createBindGroup({layout:l,entries:o});return this._hash[t._key]=h,h}destroy(){for(const t of Object.keys(this._hash))this._hash[t]=null;this._hash=null,this._renderer=null}}hu.extension={type:[o.WebGPUSystem],name:"bindGroup"};class cu{constructor(t){this._gpuBuffers=Object.create(null),this._managedBuffers=[],t.renderableGC.addManagedHash(this,"_gpuBuffers")}contextChange(t){this._gpu=t}getGPUBuffer(t){return this._gpuBuffers[t.uid]||this.createGPUBuffer(t)}updateBuffer(t){const e=this._gpuBuffers[t.uid]||this.createGPUBuffer(t),i=t.data;return t._updateID&&i&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,i.buffer,0,(t._updateSize||i.byteLength)+3&-4)),e}destroyAll(){for(const t in this._gpuBuffers)this._gpuBuffers[t].destroy();this._gpuBuffers={}}createGPUBuffer(t){this._gpuBuffers[t.uid]||(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this),t.on("destroy",this.onBufferDestroy,this),this._managedBuffers.push(t));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(Tr(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e,e}onBufferChange(t){this._gpuBuffers[t.uid].destroy(),t._updateID=0,this._gpuBuffers[t.uid]=this.createGPUBuffer(t)}onBufferDestroy(t){this._managedBuffers.splice(this._managedBuffers.indexOf(t),1),this._destroyBuffer(t)}destroy(){this._managedBuffers.forEach(t=>this._destroyBuffer(t)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(t){this._gpuBuffers[t.uid].destroy(),t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this),t.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[t.uid]=null}}cu.extension={type:[o.WebGPUSystem],name:"buffer"};class uu{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error("UniformBufferBatch: array is too large: "+4*t);const e=this.byteIndex;let i=e+4*t;if(i=Math.ceil(i/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,i>4*this.data.length)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=i,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let i=0;i<t.length;i++)this.data[e/4+i]=t[i];return e}destroy(){this.data=null}}class du{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.pipeline.setColorMask(t))}destroy(){this._renderer=null,this._colorMaskCache=null}}du.extension={type:[o.WebGPUSystem],name:"colorMask"};class pu{constructor(t){this._renderer=t}init(t){return __async(this,null,function*(){return this._initPromise||(this._initPromise=(t.gpu?Promise.resolve(t.gpu):this._createDeviceAndAdaptor(t)).then(t=>{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)})),this._initPromise})}contextChange(t){this._renderer.gpu=t}_createDeviceAndAdaptor(t){return __async(this,null,function*(){const e=yield Re.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),i=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(t=>e.features.has(t)),n=yield e.requestDevice({requiredFeatures:i});return{adapter:e,device:n}})}destroy(){this.gpu=null,this._renderer=null}}pu.extension={type:[o.WebGPUSystem],name:"device"},pu.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class fu{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(t.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(t){this.renderPassEncoder.setViewport(t.x,t.y,t.width,t.height,0,1)}setPipelineFromGeometryProgramAndState(t,e,i,n){const r=this._renderer.pipeline.getPipeline(t,e,i,n);this.setPipeline(r)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=2===t.data.BYTES_PER_ELEMENT?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,i){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.textureGC.count);const n=this._renderer.bindGroup.getBindGroup(e,i,t);this.renderPassEncoder.setBindGroup(t,n)}setGeometry(t,e){const i=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const n in i)this._setVertexBuffer(n,t.attributes[i[n]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const i in t.groups){const n=t.groups[i];e||this._syncBindGroup(n),this.setBindGroup(i,n,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const i=t.resources[e];i.isUniformGroup&&this._renderer.ubo.updateUniformGroup(i)}}draw(t){const{geometry:e,shader:i,state:n,topology:r,size:s,start:o,instanceCount:a,skipSync:l}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,n,r),this.setGeometry(e,i.gpuProgram),this._setShaderBindGroups(i,l),e.indexBuffer?this.renderPassEncoder.drawIndexed(s||e.indexBuffer.data.length,null!=a?a:e.instanceCount,o||0):this.renderPassEncoder.draw(s||e.getSize(),null!=a?a:e.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,i=__spreadValues({},this._boundVertexBuffer),n=this._boundIndexBuffer,r=__spreadValues({},this._boundBindGroup);this._clearCache();const s=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(s.x,s.y,s.width,s.height,0,1),this.setPipeline(e);for(const o in i)this._setVertexBuffer(o,i[o]);for(const o in r)this.setBindGroup(o,r[o],null);this._setIndexBuffer(n)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}}fu.extension={type:[o.WebGPUSystem],name:"encoder",priority:1};class gu{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}gu.extension={type:[o.WebGPUSystem],name:"limits"};class mu{constructor(t){this._renderTargetStencilState=Object.create(null),this._renderer=t,t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:Pr.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid];i.stencilMode=t,i.stencilReference=e;const n=this._renderer;n.pipeline.setStencilMode(t),n.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}mu.extension={type:[o.WebGPUSystem],name:"stencil"};const _u={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function yu(t){const e=t.map(t=>({data:t,offset:0,size:0}));let i=0;for(let n=0;n<e.length;n++){const t=e[n];let r=_u[t.data.type].size;const s=_u[t.data.type].align;if(!_u[t.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${t.data.type}`);t.data.size>1&&(r=Math.max(r,s)*t.data.size),i=Math.ceil(i/s)*s,t.size=r,t.offset=i,i+=r}return i=16*Math.ceil(i/16),{uboElements:e,size:i}}function xu(t,e){const{size:i,align:n}=_u[t.data.type],r=(n-i)/4,s=t.data.type.indexOf("i32")>=0?"dataInt32":"data";return`\n v = uv.${t.data.name};\n ${0!==e?`offset += ${e};`:""}\n\n arrayOffset = offset;\n\n t = 0;\n\n for(var i=0; i < ${t.data.size*(i/4)}; i++)\n {\n for(var j = 0; j < ${i/4}; j++)\n {\n ${s}[arrayOffset++] = v[t++];\n }\n ${0!==r?`arrayOffset += ${r};`:""}\n }\n `}function bu(t){return wh(t,"uboWgsl",xu,Th)}class vu extends yh{constructor(){super({createUboElements:yu,generateUboSync:bu})}}vu.extension={type:[o.WebGPUSystem],name:"ubo"};const wu=128;class Su{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_bindGroupHash"),this._batchBuffer=new uu({minUniformOffsetAlignment:wu});for(let e=0;e<2;e++){let t=Vr.UNIFORM|Vr.COPY_DST;0===e&&(t|=Vr.COPY_SRC),this._buffers.push(new Hr({data:this._batchBuffer.data,usage:t}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){for(const t in this._bindGroupHash)this._bindGroupHash[t]=null;this._batchBuffer.clear()}getUniformBindGroup(t,e){if(!e&&this._bindGroupHash[t.uid])return this._bindGroupHash[t.uid];this._renderer.ubo.ensureUniformGroup(t);const i=t.buffer.data,n=this._batchBuffer.addEmptyGroup(i.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,n/4),this._bindGroupHash[t.uid]=this._getBindGroup(n/wu),this._bindGroupHash[t.uid]}getUboResource(t){this._renderer.ubo.updateUniformGroup(t);const e=t.buffer.data,i=this._batchBuffer.addGroup(e);return this._getBufferResource(i/wu)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/wu)}getArrayBufferResource(t){const e=this._batchBuffer.addGroup(t)/wu;return this._getBufferResource(e)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new Oh({buffer:e,offset:256*(t/2|0),size:wu})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new Qi({0:this._getBufferResource(t)});this._bindGroups[t]=e}return this._bindGroups[t]}_uploadBindGroups(){const t=this._renderer.buffer,e=this._buffers[0];e.update(this._batchBuffer.byteIndex),t.updateBuffer(e);const i=this._renderer.gpu.device.createCommandEncoder();for(let n=1;n<this._buffers.length;n++){const r=this._buffers[n];i.copyBufferToBuffer(t.getGPUBuffer(e),wu,t.getGPUBuffer(r),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([i.finish()])}destroy(){for(let t=0;t<this._bindGroups.length;t++)this._bindGroups[t].destroy();this._bindGroups=null,this._bindGroupHash=null;for(let t=0;t<this._buffers.length;t++)this._buffers[t].destroy();this._buffers=null;for(let t=0;t<this._bufferResources.length;t++)this._bufferResources[t].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._bindGroupHash=null,this._renderer=null}}Su.extension={type:[o.WebGPUPipes],name:"uniformBatch"};const Au={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};class Tu{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(Pr.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=mh[t],this._updatePipeHash())}setPipeline(t,e,i,n){const r=this.getPipeline(t,e,i);n.setPipeline(r)}getPipeline(t,e,i,n){t._layoutKey||(eh(t,e.attributeData),this._generateBufferKey(t)),n||(n=t.topology);const r=function(t,e,i,n,r){return t<<24|e<<16|i<<10|n<<5|r}(t._layoutKey,e._layoutKey,i.data,i._blendModeId,Au[n]);return this._pipeCache[r]||(this._pipeCache[r]=this._createPipeline(t,e,i,n)),this._pipeCache[r]}_createPipeline(t,e,i,n){const r=this._gpu.device,s=this._createVertexBufferLayouts(t,e),o=this._renderer.state.getColorTargets(i);o[0].writeMask=this._stencilMode===Pr.RENDERING_MASK_ADD?0:this._colorMask;const a=this._renderer.shader.getProgramData(e).pipeline,l={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:s},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:o},primitive:{topology:n,cullMode:i.cullMode},layout:a,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};this._depthStencilAttachment&&(l.depthStencil=__spreadProps(__spreadValues({},this._stencilState),{format:"depth24plus-stencil8",depthWriteEnabled:i.depthTest,depthCompare:i.depthTest?"less":"always"}));return r.createRenderPipeline(l)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){const e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){const e=[];let i=0;const n=Object.keys(t.attributes).sort();for(let s=0;s<n.length;s++){const r=t.attributes[n[s]];e[i++]=r.offset,e[i++]=r.format,e[i++]=r.stride,e[i++]=r.instance}const r=e.join("|");return t._layoutKey=Ei(r,"geometry"),t._layoutKey}_generateAttributeLocationsKey(t){const e=[];let i=0;const n=Object.keys(t.attributeData).sort();for(let s=0;s<n.length;s++){const r=t.attributeData[n[s]];e[i++]=r.location}const r=e.join("|");return t._attributeLocationsKey=Ei(r,"programAttributes"),t._attributeLocationsKey}getBufferNamesToBind(t,e){const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bindingNamesCache[i])return this._bindingNamesCache[i];const n=this._createVertexBufferLayouts(t,e),r=Object.create(null),s=e.attributeData;for(let o=0;o<n.length;o++){const t=Object.values(n[o].attributes)[0].shaderLocation;for(const e in s)if(s[e].location===t){r[o]=e;break}}return this._bindingNamesCache[i]=r,r}_createVertexBufferLayouts(t,e){e._attributeLocationsKey||this._generateAttributeLocationsKey(e);const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bufferLayoutsCache[i])return this._bufferLayoutsCache[i];const n=[];return t.buffers.forEach(i=>{var r;const s={arrayStride:0,stepMode:"vertex",attributes:[]},o=s.attributes;for(const n in e.attributeData){const a=t.attributes[n];1!==(null!=(r=a.divisor)?r:1)&&kt(`Attribute ${n} has an invalid divisor value of '${a.divisor}'. WebGPU only supports a divisor value of 1`),a.buffer===i&&(s.arrayStride=a.stride,s.stepMode=a.instance?"instance":"vertex",o.push({shaderLocation:e.attributeData[n].location,offset:a.offset,format:a.format}))}o.length&&n.push(s)}),this._bufferLayoutsCache[i]=n,n}_updatePipeHash(){const t=(e=this._stencilMode,i=this._multisampleCount,n=this._colorMask,r=this._depthStencilAttachment,n<<6|e<<3|r<<1|i);var e,i,n,r;this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}Tu.extension={type:[o.WebGPUSystem],name:"pipeline"};class Cu{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class Pu{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,n,r){const s=this._renderer,o=this._getGpuColorTexture(t),a=s.texture.getGpuSource(e.source);return s.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:i},{texture:a,origin:r},n),e}startRenderPass(t,e=!0,i,n){const r=this._renderTargetSystem.getGpuRenderTarget(t),s=this.getDescriptor(t,e,i);r.descriptor=s,this._renderer.pipeline.setRenderTarget(r),this._renderer.encoder.beginRenderPass(r),this._renderer.encoder.setViewport(n)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,i){"boolean"==typeof e&&(e=e?Un.ALL:Un.NONE);const n=this._renderTargetSystem,r=n.getGpuRenderTarget(t),s=t.colorTextures.map((t,s)=>{const o=r.contexts[s];let a,l;if(o){a=o.getCurrentTexture().createView()}else a=this._renderer.texture.getGpuSource(t).createView({mipLevelCount:1});r.msaaTextures[s]&&(l=a,a=this._renderer.texture.getTextureView(r.msaaTextures[s]));const h=e&Un.COLOR?"clear":"load";return null!=i||(i=n.defaultClearColor),{view:a,resolveTarget:l,clearValue:i,storeOp:"store",loadOp:h}});let o;if(!t.stencil&&!t.depth||t.depthStencilTexture||(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=r.msaa?4:1),t.depthStencilTexture){const i=e&Un.STENCIL?"clear":"load",n=e&Un.DEPTH?"clear":"load";o={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:i,depthClearValue:1,depthLoadOp:n,depthStoreOp:"store"}}return{colorAttachments:s,depthStencilAttachment:o}}clear(t,e=!0,i,n){if(!e)return;const{gpu:r,encoder:s}=this._renderer,o=r.device;if(null===s.commandEncoder){const r=o.createCommandEncoder(),s=this.getDescriptor(t,e,i),a=r.beginRenderPass(s);a.setViewport(n.x,n.y,n.width,n.height,0,1),a.end();const l=r.finish();o.queue.submit([l])}else this.startRenderPass(t,e,i,n)}initGpuRenderTarget(t){t.isRoot=!0;const e=new Cu;return t.colorTextures.forEach((t,i)=>{if(t instanceof Be){const r=t.resource.getContext("webgpu"),s=t.transparent?"premultiplied":"opaque";try{r.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:s})}catch(n){console.error(n)}e.contexts[i]=r}if(e.msaa=t.source.antialias,t.source.antialias){const t=new q({width:0,height:0,sampleCount:4});e.msaaTextures[i]=t}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(t=>{t.unconfigure()}),t.msaaTextures.forEach(t=>{t.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((t,i)=>{const n=e.msaaTextures[i];null==n||n.resize(t.source.width,t.source.height,t.source._resolution)})}}class Mu extends Ih{constructor(t){super(t),this.adaptor=new Pu,this.adaptor.init(t,this)}}Mu.extension={type:[o.WebGPUSystem],name:"renderTarget"};class Eu{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,i=t.gpuLayout.map(t=>e.createBindGroupLayout({entries:t})),n={bindGroupLayouts:i};return this._gpuProgramData[t._layoutKey]={bindGroups:i,pipeline:e.createPipelineLayout(n)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}Eu.extension={type:[o.WebGPUSystem],name:"shader"};const Ru={normal:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},add:{alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},multiply:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},screen:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},overlay:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},none:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},"normal-npm":{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},"add-npm":{alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},"screen-npm":{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},erase:{alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},min:{alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},max:{alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}}};class Bu{constructor(){this.defaultState=new rn,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:Ru[t.blendMode]||Ru.normal}]}destroy(){this.gpu=null}}Bu.extension={type:[o.WebGPUSystem],name:"state"};const Fu={type:"image",upload(t,e,i){const n=t.resource,r=(0|t.pixelWidth)*(0|t.pixelHeight),s=n.byteLength/r;i.device.queue.writeTexture({texture:e},n,{offset:0,rowsPerImage:t.pixelHeight,bytesPerRow:t.pixelHeight*s},{width:t.pixelWidth,height:t.pixelHeight,depthOrArrayLayers:1})}},ku={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},Iu={blockBytes:4,blockWidth:1,blockHeight:1},Du={type:"compressed",upload(t,e,i){let n=t.pixelWidth,r=t.pixelHeight;const s=ku[t.format]||Iu;for(let o=0;o<t.resource.length;o++){const a=t.resource[o],l=Math.ceil(n/s.blockWidth)*s.blockBytes;i.device.queue.writeTexture({texture:e,mipLevel:o},a,{offset:0,bytesPerRow:l},{width:Math.ceil(n/s.blockWidth)*s.blockWidth,height:Math.ceil(r/s.blockHeight)*s.blockHeight,depthOrArrayLayers:1}),n=Math.max(n>>1,1),r=Math.max(r>>1,1)}}},Ou={type:"image",upload(t,e,i){const n=t.resource;if(!n)return;if(globalThis.HTMLImageElement&&n instanceof HTMLImageElement){const e=Re.get().createCanvas(n.width,n.height);e.getContext("2d").drawImage(n,0,0,n.width,n.height),t.resource=e,kt("ImageSource: Image element passed, converting to canvas and replacing resource.")}const r=Math.min(e.width,t.resourceWidth||t.pixelWidth),s=Math.min(e.height,t.resourceHeight||t.pixelHeight),o="premultiply-alpha-on-upload"===t.alphaMode;i.device.queue.copyExternalImageToTexture({source:n},{texture:e,premultipliedAlpha:o},{width:r,height:s})}},Uu={type:"video",upload(t,e,i){Ou.upload(t,e,i)}};class Gu{constructor(t){this.device=t,this.sampler=t.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(t){let e=this.pipelines[t];return e||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:"\n var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(\n vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));\n\n struct VertexOutput {\n @builtin(position) position : vec4<f32>,\n @location(0) texCoord : vec2<f32>,\n };\n\n @vertex\n fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {\n var output : VertexOutput;\n output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);\n output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);\n return output;\n }\n\n @group(0) @binding(0) var imgSampler : sampler;\n @group(0) @binding(1) var img : texture_2d<f32>;\n\n @fragment\n fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {\n return textureSample(img, imgSampler, texCoord);\n }\n "})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){const e=this._getMipmapPipeline(t.format);if("3d"===t.dimension||"1d"===t.dimension)throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let i=t;const n=t.depthOrArrayLayers||1,r=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!r){const e={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:n},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};i=this.device.createTexture(e)}const s=this.device.createCommandEncoder({}),o=e.getBindGroupLayout(0);for(let a=0;a<n;++a){let n=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:a,arrayLayerCount:1}),l=r?1:0;for(let r=1;r<t.mipLevelCount;++r){const t=i.createView({baseMipLevel:l++,mipLevelCount:1,dimension:"2d",baseArrayLayer:a,arrayLayerCount:1}),r=s.beginRenderPass({colorAttachments:[{view:t,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),h=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.sampler},{binding:1,resource:n}]});r.setPipeline(e),r.setBindGroup(0,h),r.draw(3,1,0,0),r.end(),n=t}}if(!r){const e={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:n};for(let n=1;n<t.mipLevelCount;++n)s.copyTextureToTexture({texture:i,mipLevel:n-1},{texture:t,mipLevel:n},e),e.width=Math.ceil(e.width/2),e.height=Math.ceil(e.height/2)}return this.device.queue.submit([s.finish()]),r||i.destroy(),t}}class Lu{constructor(t){this.managedTextures=[],this._gpuSources=Object.create(null),this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._textureViewHash=Object.create(null),this._uploads={image:Ou,buffer:Fu,video:Uu,compressed:Du},this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuSources"),t.renderableGC.addManagedHash(this,"_gpuSamplers"),t.renderableGC.addManagedHash(this,"_bindGroupHash"),t.renderableGC.addManagedHash(this,"_textureViewHash")}contextChange(t){this._gpu=t}initSource(t){return this._gpuSources[t.uid]?this._gpuSources[t.uid]:this._initSource(t)}_initSource(t){if(t.autoGenerateMipmaps){const e=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(e))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;"compressed"!==t.uploadMethodId&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const i=ku[t.format]||{blockWidth:1,blockHeight:1},n=Math.ceil(t.pixelWidth/i.blockWidth)*i.blockWidth,r=Math.ceil(t.pixelHeight/i.blockHeight)*i.blockHeight,s={label:t.label,size:{width:n,height:r},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},o=this._gpuSources[t.uid]=this._gpu.device.createTexture(s);return this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),o}onSourceUpdate(t){const e=this.getGpuSource(t);e&&(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t))}onSourceUnload(t){const e=this._gpuSources[t.uid];e&&(this._gpuSources[t.uid]=null,e.destroy())}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new Gu(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceDestroy(t){t.off("update",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("destroy",this.onSourceDestroy,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}onSourceResize(t){const e=this._gpuSources[t.uid];e?e.width===t.pixelWidth&&e.height===t.pixelHeight||(this._textureViewHash[t.uid]=null,this._bindGroupHash[t.uid]=null,this.onSourceUnload(t),this.initSource(t)):this.initSource(t)}_initSampler(t){return this._gpuSamplers[t._resourceId]=this._gpu.device.createSampler(t),this._gpuSamplers[t._resourceId]}getGpuSampler(t){return this._gpuSamplers[t._resourceId]||this._initSampler(t)}getGpuSource(t){return this._gpuSources[t.uid]||this.initSource(t)}getTextureBindGroup(t){var e;return null!=(e=this._bindGroupHash[t.uid])?e:this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source;return this._bindGroupHash[t.uid]=new Qi({0:e,1:e.style,2:new Ki({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){var e;const i=t.source;return null!=(e=this._textureViewHash[i.uid])?e:this._createTextureView(i)}_createTextureView(t){return this._textureViewHash[t.uid]=this.getGpuSource(t).createView(),this._textureViewHash[t.uid]}generateCanvas(t){const e=this._renderer,i=e.gpu.device.createCommandEncoder(),n=Re.get().createCanvas();n.width=t.source.pixelWidth,n.height=t.source.pixelHeight;const r=n.getContext("webgpu");return r.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:Re.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:r.getCurrentTexture()},{width:n.width,height:n.height}),e.gpu.device.queue.submit([i.finish()]),n}getPixels(t){const e=this.generateCanvas(t),i=No.getOptimalCanvasAndContext(e.width,e.height),n=i.context;n.drawImage(e,0,0);const{width:r,height:s}=e,o=n.getImageData(0,0,r,s),a=new Uint8ClampedArray(o.data.buffer);return No.returnCanvasAndContext(i),{pixels:a,width:r,height:s}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null;for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),i=this._bindGroupHash[e];null==i||i.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}Lu.extension={type:[o.WebGPUSystem],name:"texture"};class zu{constructor(){this._maxTextures=0}contextChange(t){const e=new Ki({uTransformMatrix:{value:new S,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;const i=cs({name:"graphics",bits:[ds,_s(this._maxTextures),Nl,vs]});this.shader=new tn({gpuProgram:i,resources:{localUniforms:e}})}execute(t,e){const i=e.context,n=i.customShader||this.shader,r=t.renderer,s=r.graphicsContext,{batcher:o,instructions:a}=s.getContextRenderData(i),l=r.encoder;l.setGeometry(o.geometry,n.gpuProgram);const h=r.globalUniforms.bindGroup;l.setBindGroup(0,h,n.gpuProgram);const c=r.renderPipes.uniformBatch.getUniformBindGroup(n.resources.localUniforms,!0);l.setBindGroup(2,c,n.gpuProgram);const u=a.instructions;let d=null;for(let p=0;p<a.instructionSize;p++){const e=u[p];if(e.topology!==d&&(d=e.topology,l.setPipelineFromGeometryProgramAndState(o.geometry,n.gpuProgram,t.state,e.topology)),n.groups[1]=e.bindGroup,!e.gpuBindGroup){const t=e.textures;e.bindGroup=Sr(t.textures,t.count,this._maxTextures),e.gpuBindGroup=r.bindGroup.getBindGroup(e.bindGroup,n.gpuProgram,1)}l.setBindGroup(1,e.bindGroup,n.gpuProgram),l.renderPassEncoder.drawIndexed(e.size,1,e.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}zu.extension={type:[o.WebGPUPipesAdaptor],name:"graphics"};class Nu{init(){const t=cs({name:"mesh",bits:[zl,Hl,vs]});this._shader=new tn({gpuProgram:t,resources:{uTexture:J.EMPTY._source,uSampler:J.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new S}}}})}execute(t,e){const i=t.renderer;let n=e._shader;if(n){if(!n.gpuProgram)return void kt("Mesh shader has no gpuProgram",e.shader)}else n=this._shader,n.groups[2]=i.texture.getTextureBindGroup(e.texture);const r=n.gpuProgram;if(r.autoAssignGlobalUniforms&&(n.groups[0]=i.globalUniforms.bindGroup),r.autoAssignLocalUniforms){const e=t.localUniforms;n.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(e,!0)}i.encoder.draw({geometry:e._geometry,shader:n,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Nu.extension={type:[o.WebGPUPipesAdaptor],name:"mesh"};const Vu=[...tu,vu,fu,pu,gu,cu,Lu,Mu,Eu,Bu,Tu,du,mu,hu],Hu=[...eu,Su],Wu=[Ul,Nu,zu],ju=[],Yu=[],Xu=[];h.handleByNamedList(o.WebGPUSystem,ju),h.handleByNamedList(o.WebGPUPipes,Yu),h.handleByNamedList(o.WebGPUPipesAdaptor,Xu),h.add(...Vu,...Hu,...Wu);const Zu=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:class extends Hn{constructor(){super({name:"webgpu",type:Ji.WEBGPU,systems:ju,renderPipes:Yu,renderPipeAdaptors:Xu})}}},Symbol.toStringTag,{value:"Module"}));class qu{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{Dt.return(t)}),this.batches.length=0}}class $u{constructor(t,e){this.state=rn.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this)}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,i=!!t._gpuData,n=this.renderer.graphicsContext.updateGpuContext(e);return!(!n.isBatchable&&i===n.isBatchable)}addRenderable(t,e){const i=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),i.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._getGpuDataForRenderable(t).batches;for(let i=0;i<e.length;i++){const t=e[i];t._batcher.updateElement(t)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,i=t.context;if(!e.graphicsContext.getGpuContext(i).batches.length)return;const n=i.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const r=n.resources.localUniforms.uniforms;r.uTransformMatrix=t.groupTransform,r.uRound=e._roundPixels|t._roundPixels,zc(t.groupColorAlpha,r.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),i=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),i.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const i=this.renderer.renderPipes.batch,n=this._getGpuDataForRenderable(t).batches;for(let r=0;r<n.length;r++){const t=n[r];i.addToBatch(t,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new qu;return t._gpuData[this.renderer.uid]=e,e}_updateBatchesForRenderable(t,e){const i=t.context,n=this.renderer.graphicsContext.getGpuContext(i),r=this.renderer._roundPixels|t._roundPixels;e.batches=n.batches.map(e=>{const i=Dt.get(Bs);return e.copyTo(i),i.renderable=t,i.roundPixels=r,i})}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}$u.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"graphics"};const Ku=class t extends ml{constructor(...t){var e;super({});let i=null!=(e=t[0])?e:{};"number"==typeof i&&(z(L,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),i={width:i,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(i)}build(e){var i,n,r,s;e=__spreadValues(__spreadValues({},t.defaultOptions),e),this.verticesX=null!=(i=this.verticesX)?i:e.verticesX,this.verticesY=null!=(n=this.verticesY)?n:e.verticesY,this.width=null!=(r=this.width)?r:e.width,this.height=null!=(s=this.height)?s:e.height;const o=this.verticesX*this.verticesY,a=[],l=[],h=[],c=this.verticesX-1,u=this.verticesY-1,d=this.width/c,p=this.height/u;for(let t=0;t<o;t++){const e=t%this.verticesX,i=t/this.verticesX|0;a.push(e*d,i*p),l.push(e/c,i/u)}const f=c*u;for(let t=0;t<f;t++){const e=t%c,i=t/c|0,n=i*this.verticesX+e,r=i*this.verticesX+e+1,s=(i+1)*this.verticesX+e,o=(i+1)*this.verticesX+e+1;h.push(n,r,s,r,o,s)}this.buffers[0].data=new Float32Array(a),this.buffers[1].data=new Float32Array(l),this.indexBuffer.data=new Uint32Array(h),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};Ku.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let Qu=Ku;class Ju{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(t){this._topology=t}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(t){this.texture!==t&&(this.texture=t,this._textureMatrixUpdateId=-1)}get uvs(){const t=this.geometry.getBuffer("aUV"),e=t.data;let i=e;const n=this.texture.textureMatrix;return n.isSimple||(i=this._transformedUvs,this._textureMatrixUpdateId===n._updateID&&this._uvUpdateId===t._updateID||((!i||i.length<e.length)&&(i=this._transformedUvs=new Float32Array(e.length)),this._textureMatrixUpdateId=n._updateID,this._uvUpdateId=t._updateID,n.multiplyUvs(e,i))),i}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 td{destroy(){}}class ed{constructor(t,e){this.localUniforms=new Ki({uTransformMatrix:{value:new S,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Qi({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),i=e.batched,n=t.batched;if(e.batched=n,i!==n)return!0;if(n){const i=t._geometry;if(i.indices.length!==e.indexSize||i.positions.length!==e.vertexSize)return e.indexSize=i.indices.length,e.vertexSize=i.positions.length,!0;const n=this._getBatchableMesh(t);return n.texture.uid!==t._texture.uid&&(n._textureMatrixUpdateId=-1),!n._batcher.checkAndUpdateTexture(n,t._texture)}return!1}addRenderable(t,e){var i,n;const r=this.renderer.renderPipes.batch,s=this._getMeshData(t);if(t.didViewUpdate&&(s.indexSize=null==(i=t._geometry.indices)?void 0:i.length,s.vertexSize=null==(n=t._geometry.positions)?void 0:n.length),s.batched){const i=this._getBatchableMesh(t);i.setTexture(t._texture),i.geometry=t._geometry,r.addToBatch(i,e)}else r.break(e),e.add(t)}updateRenderable(t){if(t.batched){const e=this._getBatchableMesh(t);e.setTexture(t._texture),e.geometry=t._geometry,e._batcher.updateElement(e)}}execute(t){if(!t.isRenderable)return;t.state.blendMode=Mr(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),zc(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new td),t._gpuData[this.renderer.uid].meshData||this._initMeshData(t)}_initMeshData(t){return t._gpuData[this.renderer.uid].meshData={batched:t.batched,indexSize:0,vertexSize:0},t._gpuData[this.renderer.uid].meshData}_getBatchableMesh(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new td),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new Ju;return e.renderable=t,e.setTexture(t._texture),e.transform=t.groupTransform,e.roundPixels=this.renderer._roundPixels|t._roundPixels,t._gpuData[this.renderer.uid].batchableMesh=e,e}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}ed.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"mesh"};class id{execute(t,e){const i=t.state,n=t.renderer,r=e.shader||t.defaultShader;r.resources.uTexture=e.texture._source,r.resources.uniforms=t.localUniforms;const s=n.gl,o=t.getBuffers(e);n.shader.bind(r),n.state.set(i),n.geometry.bind(o.geometry,r.glProgram);const a=2===o.geometry.indexBuffer.data.BYTES_PER_ELEMENT?s.UNSIGNED_SHORT:s.UNSIGNED_INT;s.drawElements(s.TRIANGLES,6*e.particleChildren.length,a,0)}}class nd{execute(t,e){const i=t.renderer,n=e.shader||t.defaultShader;n.groups[0]=i.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),n.groups[1]=i.texture.getTextureBindGroup(e.texture);const r=t.state,s=t.getBuffers(e);i.encoder.draw({geometry:s.geometry,shader:e.shader||t.defaultShader,state:r,size:6*e.particleChildren.length})}}function rd(t,e=null){const i=6*t;if(i>65535?e||(e=new Uint32Array(i)):e||(e=new Uint16Array(i)),e.length!==i)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${i}`);for(let n=0,r=0;n<i;n+=6,r+=4)e[n+0]=r+0,e[n+1]=r+1,e[n+2]=r+2,e[n+3]=r+0,e[n+4]=r+2,e[n+5]=r+3;return e}function sd(t,e){const i=[];i.push("\n\n var index = 0;\n\n for (let i = 0; i < ps.length; ++i)\n {\n const p = ps[i];\n\n ");let n=0;for(const s in t){const r=t[s];if(e!==r.dynamic)continue;i.push(`offset = index + ${n}`),i.push(r.code);n+=Ni(r.format).stride/4}i.push("\n index += stride * 4;\n }\n "),i.unshift(`\n var stride = ${n};\n `);const r=i.join("\n");return new Function("ps","f32v","u32v",r)}class od{constructor(t){var e;this._size=0,this._generateParticleUpdateCache={};const i=this._size=null!=(e=t.size)?e:1e3,n=t.properties;let r=0,s=0;for(const c in n){const t=n[c],e=Ni(t.format);t.dynamic?s+=e.stride:r+=e.stride}this._dynamicStride=s/4,this._staticStride=r/4,this.staticAttributeBuffer=new Ar(4*i*r),this.dynamicAttributeBuffer=new Ar(4*i*s),this.indexBuffer=rd(i);const o=new jr;let a=0,l=0;this._staticBuffer=new Hr({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:Vr.VERTEX|Vr.COPY_DST}),this._dynamicBuffer=new Hr({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:Vr.VERTEX|Vr.COPY_DST});for(const c in n){const t=n[c],e=Ni(t.format);t.dynamic?(o.addAttribute(t.attributeName,{buffer:this._dynamicBuffer,stride:4*this._dynamicStride,offset:4*a,format:t.format}),a+=e.size):(o.addAttribute(t.attributeName,{buffer:this._staticBuffer,stride:4*this._staticStride,offset:4*l,format:t.format}),l+=e.size)}o.addIndex(this.indexBuffer);const h=this.getParticleUpdate(n);this._dynamicUpload=h.dynamicUpdate,this._staticUpload=h.staticUpdate,this.geometry=o}getParticleUpdate(t){const e=function(t){const e=[];for(const i in t){const n=t[i];e.push(i,n.code,n.dynamic?"d":"s")}return e.join("_")}(t);return this._generateParticleUpdateCache[e]||(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t)),this._generateParticleUpdateCache[e]}generateParticleUpdate(t){return function(t){return{dynamicUpdate:sd(t,!0),staticUpdate:sd(t,!1)}}(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,1.5*this._size|0),this.staticAttributeBuffer=new Ar(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new Ar(this._size*this._dynamicStride*4*4),this.indexBuffer=rd(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const i=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,i.float32View,i.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){const e=this.staticAttributeBuffer;this._staticUpload(t,e.float32View,e.uint32View),this._staticBuffer.setDataWithSize(e.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}var ad="\nstruct ParticleUniforms {\n uProjectionMatrix:mat3x3<f32>,\n uColor:vec4<f32>,\n uResolution:vec2<f32>,\n uRoundPixels:f32,\n};\n\n@group(0) @binding(0) var<uniform> uniforms: ParticleUniforms;\n\n@group(1) @binding(0) var uTexture: texture_2d<f32>;\n@group(1) @binding(1) var uSampler : sampler;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>,\n @location(1) color : vec4<f32>,\n };\n@vertex\nfn mainVertex(\n @location(0) aVertex: vec2<f32>,\n @location(1) aPosition: vec2<f32>,\n @location(2) aUV: vec2<f32>,\n @location(3) aColor: vec4<f32>,\n @location(4) aRotation: f32,\n) -> VSOutput {\n \n let v = vec2(\n aVertex.x * cos(aRotation) - aVertex.y * sin(aRotation),\n aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation)\n ) + aPosition;\n\n let position = vec4((uniforms.uProjectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);\n\n let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor;\n\n return VSOutput(\n position,\n aUV,\n vColor,\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @location(1) color: vec4<f32>,\n @builtin(position) position: vec4<f32>,\n) -> @location(0) vec4<f32> {\n\n var sample = textureSample(uTexture, uSampler, uv) * color;\n \n return sample;\n}";class ld extends tn{constructor(){super({glProgram:Li.from({vertex:"attribute vec2 aVertex;\nattribute vec2 aUV;\nattribute vec4 aColor;\n\nattribute vec2 aPosition;\nattribute float aRotation;\n\nuniform mat3 uTranslationMatrix;\nuniform float uRound;\nuniform vec2 uResolution;\nuniform vec4 uColor;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n\nvec2 roundPixels(vec2 position, vec2 targetSize)\n{ \n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n}\n\nvoid main(void){\n float cosRotation = cos(aRotation);\n float sinRotation = sin(aRotation);\n float x = aVertex.x * cosRotation - aVertex.y * sinRotation;\n float y = aVertex.x * sinRotation + aVertex.y * cosRotation;\n\n vec2 v = vec2(x, y);\n v = v + aPosition;\n\n gl_Position = vec4((uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);\n\n if(uRound == 1.0)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n\n vUV = aUV;\n vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor;\n}\n",fragment:"varying vec2 vUV;\nvarying vec4 vColor;\n\nuniform sampler2D uTexture;\n\nvoid main(void){\n vec4 color = texture2D(uTexture, vUV) * vColor;\n gl_FragColor = color;\n}"}),gpuProgram:Yi.from({fragment:{source:ad,entryPoint:"mainFragment"},vertex:{source:ad,entryPoint:"mainVertex"}}),resources:{uTexture:J.WHITE.source,uSampler:new X({}),uniforms:{uTranslationMatrix:{value:new S,type:"mat3x3<f32>"},uColor:{value:new Bt(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}}class hd{constructor(t,e){this.state=rn.for2d(),this.localUniforms=new Ki({uTranslationMatrix:{value:new S,type:"mat3x3<f32>"},uColor:{value:new Float32Array(4),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new ld,this.state=rn.for2d()}validateRenderable(t){return!1}addRenderable(t,e){this.renderer.renderPipes.batch.break(e),e.add(t)}getBuffers(t){return t._gpuData[this.renderer.uid]||this._initBuffer(t)}_initBuffer(t){return t._gpuData[this.renderer.uid]=new od({size:t.particleChildren.length,properties:t._properties}),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){const e=t.particleChildren;if(0===e.length)return;const i=this.renderer,n=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const r=this.state;n.update(e,t._childrenDirty),t._childrenDirty=!1,r.blendMode=Mr(t.blendMode,t.texture._source);const s=this.localUniforms.uniforms,o=s.uTranslationMatrix;t.worldTransform.copyTo(o),o.prepend(i.globalUniforms.globalUniformData.projectionMatrix),s.uResolution=i.globalUniforms.globalUniformData.resolution,s.uRound=i._roundPixels|t._roundPixels,zc(t.groupColorAlpha,s.uColor,0),this.adaptor.execute(this,t)}destroy(){this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}class cd extends hd{constructor(t){super(t,new id)}}cd.extension={type:[o.WebGLPipes],name:"particle"};class ud extends hd{constructor(t){super(t,new nd)}}ud.extension={type:[o.WebGPUPipes],name:"particle"};const dd=class t extends Qu{constructor(e={}){super({width:(e=__spreadValues(__spreadValues({},t.defaultOptions),e)).width,height:e.height,verticesX:4,verticesY:4}),this.update(e)}update(t){var e,i,n,r,s,o,a,l,h,c;this.width=null!=(e=t.width)?e:this.width,this.height=null!=(i=t.height)?i:this.height,this._originalWidth=null!=(n=t.originalWidth)?n:this._originalWidth,this._originalHeight=null!=(r=t.originalHeight)?r:this._originalHeight,this._leftWidth=null!=(s=t.leftWidth)?s:this._leftWidth,this._rightWidth=null!=(o=t.rightWidth)?o:this._rightWidth,this._topHeight=null!=(a=t.topHeight)?a:this._topHeight,this._bottomHeight=null!=(l=t.bottomHeight)?l:this._bottomHeight,this._anchorX=null==(h=t.anchor)?void 0:h.x,this._anchorY=null==(c=t.anchor)?void 0:c.y,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:i,_leftWidth:n,_rightWidth:r,_topHeight:s,_bottomHeight:o,_anchorX:a,_anchorY:l}=this,h=n+r,c=e>h?1:e/h,u=s+o,d=i>u?1:i/u,p=Math.min(c,d),f=a*e,g=l*i;t[0]=t[8]=t[16]=t[24]=-f,t[2]=t[10]=t[18]=t[26]=n*p-f,t[4]=t[12]=t[20]=t[28]=e-r*p-f,t[6]=t[14]=t[22]=t[30]=e-f,t[1]=t[3]=t[5]=t[7]=-g,t[9]=t[11]=t[13]=t[15]=s*p-g,t[17]=t[19]=t[21]=t[23]=i-o*p-g,t[25]=t[27]=t[29]=t[31]=i-g,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}};dd.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let pd=dd;class fd extends Ju{constructor(){super(),this.geometry=new pd}destroy(){this.geometry.destroy()}}class gd{constructor(t){this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture)}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=t._gpuData[this._renderer.uid]=new fd,i=e;return i.renderable=t,i.transform=t.groupTransform,i.texture=t._texture,i.roundPixels=this._renderer._roundPixels|t._roundPixels,t.didViewUpdate||this._updateBatchableSprite(t,i),e}destroy(){this._renderer=null}}gd.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"nineSliceSprite"};const md={name:"tiling-bit",vertex:{header:"\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n ",main:"\n uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;\n\n position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;\n "},fragment:{header:"\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n ",main:"\n\n var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);\n coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;\n var unclamped = coord;\n coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);\n\n var bias = 0.;\n\n if(unclamped.x == coord.x && unclamped.y == coord.y)\n {\n bias = -32.;\n }\n\n outColor = textureSampleBias(uTexture, uSampler, coord, bias);\n "}},_d={name:"tiling-bit",vertex:{header:"\n uniform mat3 uTextureTransform;\n uniform vec4 uSizeAnchor;\n\n ",main:"\n uv = (uTextureTransform * vec3(aUV, 1.0)).xy;\n\n position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;\n "},fragment:{header:"\n uniform sampler2D uTexture;\n uniform mat3 uMapCoord;\n uniform vec4 uClampFrame;\n uniform vec2 uClampOffset;\n ",main:"\n\n vec2 coord = vUV + ceil(uClampOffset - vUV);\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n vec2 unclamped = coord;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0\n\n "}};let yd,xd;class bd extends tn{constructor(){null!=yd||(yd=cs({name:"tiling-sprite-shader",bits:[zl,md,vs]})),null!=xd||(xd=us({name:"tiling-sprite-shader",bits:[Vl,_d,ws]}));const t=new Ki({uMapCoord:{value:new S,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 S,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:xd,gpuProgram:yd,resources:{localUniforms:new Ki({uTransformMatrix:{value:new S,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:J.EMPTY.source,uSampler:J.EMPTY.source.style}})}updateUniforms(t,e,i,n,r,s){const o=this.resources.tilingUniforms,a=s.width,l=s.height,h=s.textureMatrix,c=o.uniforms.uTextureTransform;c.set(i.a*a/t,i.b*a/e,i.c*l/t,i.d*l/e,i.tx/t,i.ty/e),c.invert(),o.uniforms.uMapCoord=h.mapCoord,o.uniforms.uClampFrame=h.uClampFrame,o.uniforms.uClampOffset=h.uClampOffset,o.uniforms.uTextureTransform=c,o.uniforms.uSizeAnchor[0]=t,o.uniforms.uSizeAnchor[1]=e,o.uniforms.uSizeAnchor[2]=n,o.uniforms.uSizeAnchor[3]=r,s&&(this.resources.uTexture=s.source,this.resources.uSampler=s.source.style)}}const vd=new class extends ml{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])})}};class wd{constructor(){this.canBatch=!0,this.geometry=new ml({indices:vd.indices.slice(),positions:vd.positions.slice(),uvs:vd.uvs.slice()})}destroy(){var t;this.geometry.destroy(),null==(t=this.shader)||t.destroy()}}class Sd{constructor(t){this._state=rn.default2d,this._renderer=t}validateRenderable(t){const e=this._getTilingSpriteData(t),i=e.canBatch;this._updateCanBatch(t);const n=e.canBatch;if(n&&n===i){const{batchableMesh:i}=e;return!i._batcher.checkAndUpdateTexture(i,t.texture)}return i!==n}addRenderable(t,e){const i=this._renderer.renderPipes.batch;this._updateCanBatch(t);const n=this._getTilingSpriteData(t),{geometry:r,canBatch:s}=n;if(s){n.batchableMesh||(n.batchableMesh=new Ju);const s=n.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),s.geometry=r,s.renderable=t,s.transform=t.groupTransform,s.setTexture(t._texture)),s.roundPixels=this._renderer._roundPixels|t._roundPixels,i.addToBatch(s,e)}else i.break(e),n.shader||(n.shader=new bd),this.updateRenderable(t),e.add(t)}execute(t){const{shader:e}=this._getTilingSpriteData(t);e.groups[0]=this._renderer.globalUniforms.bindGroup;const i=e.resources.localUniforms.uniforms;i.uTransformMatrix=t.groupTransform,i.uRound=this._renderer._roundPixels|t._roundPixels,zc(t.groupColorAlpha,i.uColor,0),this._state.blendMode=Mr(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:vd,shader:e,state:this._state})}updateRenderable(t){const e=this._getTilingSpriteData(t),{canBatch:i}=e;if(i){const{batchableMesh:i}=e;t.didViewUpdate&&this._updateBatchableMesh(t),i._batcher.updateElement(i)}else if(t.didViewUpdate){const{shader:i}=e;i.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}}_getTilingSpriteData(t){return t._gpuData[this._renderer.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){const e=new wd;return e.renderable=t,t._gpuData[this._renderer.uid]=e,e}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:i}=e,n=t.texture.source.style;"repeat"!==n.addressMode&&(n.addressMode="repeat",n.update()),function(t,e){const i=t.texture,n=i.frame.width,r=i.frame.height;let s=0,o=0;t.applyAnchorToTexture&&(s=t.anchor.x,o=t.anchor.y),e[0]=e[6]=-s,e[2]=e[4]=1-s,e[1]=e[3]=-o,e[5]=e[7]=1-o;const a=S.shared;a.copyFrom(t._tileTransform.matrix),a.tx/=t.width,a.ty/=t.height,a.invert(),a.scale(t.width/n,t.height/r),function(t,e,i,n){let r=0;const s=t.length/e,o=n.a,a=n.b,l=n.c,h=n.d,c=n.tx,u=n.ty;for(i*=e;r<s;){const n=t[i],s=t[i+1];t[i]=o*n+l*s+c,t[i+1]=a*n+h*s+u,i+=e,r++}}(e,2,0,a)}(t,i.uvs),function(t,e){const i=t.anchor.x,n=t.anchor.y;e[0]=-i*t.width,e[1]=-n*t.height,e[2]=(1-i)*t.width,e[3]=-n*t.height,e[4]=(1-i)*t.width,e[5]=(1-n)*t.height,e[6]=-i*t.width,e[7]=(1-n)*t.height}(t,i.positions)}destroy(){this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),i=t.texture;let n=!0;return this._renderer.type===Ji.WEBGL&&(n=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=i.textureMatrix.isSimple&&(n||i.source.isPowerOfTwo),e.canBatch}}Sd.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"tilingSprite"};const Ad={name:"local-uniform-msdf-bit",vertex:{header:"\n struct LocalUniforms {\n uColor:vec4<f32>,\n uTransformMatrix:mat3x3<f32>,\n uDistance: f32,\n uRound:f32,\n }\n\n @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "},fragment:{header:"\n struct LocalUniforms {\n uColor:vec4<f32>,\n uTransformMatrix:mat3x3<f32>,\n uDistance: f32\n }\n\n @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));\n "}},Td={name:"local-uniform-msdf-bit",vertex:{header:"\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix *= uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "},fragment:{header:"\n uniform float uDistance;\n ",main:"\n outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));\n "}},Cd={name:"msdf-bit",fragment:{header:"\n fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {\n\n // MSDF\n var median = msdfColor.r + msdfColor.g + msdfColor.b -\n min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -\n max(msdfColor.r, max(msdfColor.g, msdfColor.b));\n\n // SDF\n median = min(median, msdfColor.a);\n\n var screenPxDistance = distance * (median - 0.5);\n var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n if (median < 0.01) {\n alpha = 0.0;\n } else if (median > 0.99) {\n alpha = 1.0;\n }\n\n // Gamma correction for coverage-like alpha\n var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));\n var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);\n var coverage: f32 = pow(shapeColor.a * alpha, gamma);\n\n return coverage;\n\n }\n "}},Pd={name:"msdf-bit",fragment:{header:"\n float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {\n\n // MSDF\n float median = msdfColor.r + msdfColor.g + msdfColor.b -\n min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -\n max(msdfColor.r, max(msdfColor.g, msdfColor.b));\n\n // SDF\n median = min(median, msdfColor.a);\n\n float screenPxDistance = distance * (median - 0.5);\n float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n\n if (median < 0.01) {\n alpha = 0.0;\n } else if (median > 0.99) {\n alpha = 1.0;\n }\n\n // Gamma correction for coverage-like alpha\n float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));\n float gamma = mix(1.0, 1.0 / 2.2, luma);\n float coverage = pow(shapeColor.a * alpha, gamma);\n\n return coverage;\n }\n "}};let Md,Ed;class Rd extends tn{constructor(t){const e=new Ki({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new S,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});null!=Md||(Md=cs({name:"sdf-shader",bits:[ds,_s(t),Ad,Cd,vs]})),null!=Ed||(Ed=us({name:"sdf-shader",bits:[ps,bs(t),Td,Pd,ws]})),super({glProgram:Ed,gpuProgram:Md,resources:{localUniforms:e,batchSamplers:As(t)}})}}class Bd extends fl{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class Fd{constructor(t){this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuBitmapText")}validateRenderable(t){const e=this._getGpuBitmapText(t);return this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const i=this._getGpuBitmapText(t);kd(t,i),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,i)),this._renderer.renderPipes.graphics.addRenderable(i,e),i.context.customShader&&this._updateDistanceField(t)}updateRenderable(t){const e=this._getGpuBitmapText(t);kd(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:i}=e,n=Zo.getFont(t.text,t._style);i.clear(),"none"!==n.distanceField.type&&(i.customShader||(i.customShader=new Rd(this._renderer.limits.maxBatchableTextures)));const r=sr.graphemeSegmenter(t.text),s=t._style;let o=n.baseLineOffset;const a=Yo(r,s,n,!0),l=s.padding,h=a.scale;let c=a.width,u=a.height+a.offsetY;s._stroke&&(c+=s._stroke.width/h,u+=s._stroke.width/h),i.translate(-t._anchor._x*c-l,-t._anchor._y*u-l).scale(h,h);const d=n.applyFillAsTint?s._fill.color:16777215;let p=n.fontMetrics.fontSize,f=n.lineHeight;s.lineHeight&&(p=s.fontSize/h,f=s.lineHeight/h);let g=(f-p)/2;g-n.baseLineOffset<0&&(g=0);for(let m=0;m<a.lines.length;m++){const t=a.lines[m];for(let e=0;e<t.charPositions.length;e++){const r=t.chars[e],s=n.chars[r];if(null==s?void 0:s.texture){const n=s.texture;i.texture(n,d||"black",Math.round(t.charPositions[e]+s.xOffset),Math.round(o+s.yOffset+g),n.orig.width,n.orig.height)}}o+=f}}_getGpuBitmapText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Bd;return t._gpuData[this._renderer.uid]=e,this._updateContext(t,e),e}_updateDistanceField(t){const e=this._getGpuBitmapText(t).context,i=t._style.fontFamily,n=Ve.get(`${i}-bitmap`),{a:r,b:s,c:o,d:a}=t.groupTransform,l=Math.sqrt(r*r+s*s),h=Math.sqrt(o*o+a*a),c=(Math.abs(l)+Math.abs(h))/2,u=n.baseRenderedFontSize/t._style.fontSize,d=c*n.distanceField.range*(1/u);e.customShader.resources.localUniforms.uniforms.uDistance=d}destroy(){this._renderer=null}}function kd(t,e){e.groupTransform=t.groupTransform,e.groupColorAlpha=t.groupColorAlpha,e.groupColor=t.groupColor,e.groupBlendMode=t.groupBlendMode,e.globalDisplayStatus=t.globalDisplayStatus,e.groupTransform=t.groupTransform,e.localDisplayStatus=t.localDisplayStatus,e.groupAlpha=t.groupAlpha,e._roundPixels=t._roundPixels}Fd.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"bitmapText"};class Id extends mc{constructor(t){super(),this.generatingTexture=!1,this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){this._renderer.htmlText.returnTexturePromise(this.texturePromise),this.texturePromise=null,this._renderer=null}}function Dd(t,e){const{texture:i,bounds:n}=t,r=e._style._getFinalPadding();tt(n,e._anchor,i);const s=e._anchor._x*r*2,o=e._anchor._y*r*2;n.minX-=r-s,n.minY-=r-o,n.maxX-=r-s,n.maxY-=r-o}class Od{constructor(t){this._renderer=t}validateRenderable(t){return t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);t._didTextUpdate&&(this._updateGpuText(t).catch(t=>{console.error(t)}),t._didTextUpdate=!1,Dd(i,t)),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){return __async(this,null,function*(){t._didTextUpdate=!1;const e=this._getGpuText(t);if(e.generatingTexture)return;e.texturePromise&&(this._renderer.htmlText.returnTexturePromise(e.texturePromise),e.texturePromise=null),e.generatingTexture=!0,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const i=this._renderer.htmlText.getTexturePromise(t);e.texturePromise=i,e.texture=yield i;const n=t.renderGroup||t.parentRenderGroup;n&&(n.structureDidChange=!0),e.generatingTexture=!1,Dd(e,t)})}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Id(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.texture=J.EMPTY,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Od.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"htmlText"};const Ud=new it;function Gd(t,e,i,n){const r=Ud;r.minX=0,r.minY=0,r.maxX=t.width/n|0,r.maxY=t.height/n|0;const s=pe.getOptimalTexture(r.width,r.height,n,!1);return s.source.uploadMethodId="image",s.source.resource=t,s.source.alphaMode="premultiply-alpha-on-upload",s.frame.width=e/n,s.frame.height=i/n,s.source.emit("update",s.source),s.updateUvs(),s}function Ld(t,e){return __async(this,null,function*(){const i=yield function(t){return __async(this,null,function*(){const e=yield Re.get().fetch(t),i=yield e.blob(),n=new FileReader;return yield new Promise((t,e)=>{n.onloadend=()=>t(n.result),n.onerror=e,n.readAsDataURL(i)})})}(e);return`@font-face {\n font-family: "${t.fontFamily}";\n font-weight: ${t.fontWeight};\n font-style: ${t.fontStyle};\n src: url('${i}');\n }`})}const zd=new Map;class Nd{constructor(t){this._renderer=t,this._createCanvas=t.type===Ji.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getTexturePromise(t){return this._buildTexturePromise(t)}_buildTexturePromise(t){return __async(this,null,function*(){const{text:e,style:i,resolution:n,textureStyle:r}=t,s=Dt.get(kl),o=function(t,e){const i=e.fontFamily,n=[],r={},s=t.match(/font-family:([^;"\s]+)/g);function o(t){r[t]||(n.push(t),r[t]=!0)}if(Array.isArray(i))for(let a=0;a<i.length;a++)o(i[a]);else o(i);s&&s.forEach(t=>{o(t.split(":")[1].trim())});for(const a in e.tagStyles)o(e.tagStyles[a].fontFamily);return n}(e,i),a=yield function(t){return __async(this,null,function*(){const e=t.filter(t=>Ve.has(`${t}-and-url`)).map(t=>{if(!zd.has(t)){const{entries:e}=Ve.get(`${t}-and-url`),i=[];e.forEach(e=>{const n=e.url,r=e.faces.map(t=>({weight:t.weight,style:t.style}));i.push(...r.map(e=>Ld({fontWeight:e.weight,fontStyle:e.style,fontFamily:t},n)))}),zd.set(t,Promise.all(i).then(t=>t.join("\n")))}return zd.get(t)});return(yield Promise.all(e)).join("\n")})}(o),l=function(t,e,i,n){n||(n=Il||(Il=new kl));const{domElement:r,styleElement:s,svgRoot:o}=n;r.innerHTML=`<style>${e.cssStyle};</style><div style='padding:0'>${t}</div>`,r.setAttribute("style","transform-origin: top left; display: inline-block"),i&&(s.textContent=i),document.body.appendChild(o);const a=r.getBoundingClientRect();o.remove();const l=2*e.padding;return{width:a.width-l,height:a.height-l}}(e,i,a,s),h=Math.ceil(Math.ceil(Math.max(1,l.width)+2*i.padding)*n),c=Math.ceil(Math.ceil(Math.max(1,l.height)+2*i.padding)*n),u=s.image;u.width=2+(0|h),u.height=2+(0|c);const d=function(t,e,i,n,r){const{domElement:s,styleElement:o,svgRoot:a}=r;s.innerHTML=`<style>${e.cssStyle}</style><div style='padding:0;'>${t}</div>`,s.setAttribute("style",`transform: scale(${i});transform-origin: top left; display: inline-block`),o.textContent=n;const{width:l,height:h}=r.image;return a.setAttribute("width",l.toString()),a.setAttribute("height",h.toString()),(new XMLSerializer).serializeToString(a)}(e,i,n,a,s);yield function(t,e,i){return new Promise(n=>__async(null,null,function*(){i&&(yield new Promise(t=>setTimeout(t,100))),t.onload=()=>{n()},t.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(e)}`,t.crossOrigin="anonymous"}))}(u,d,function(){const{userAgent:t}=Re.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}()&&o.length>0);const p=u;let f;this._createCanvas&&(f=function(t,e){const i=No.getOptimalCanvasAndContext(t.width,t.height,e),{context:n}=i;return n.clearRect(0,0,t.width,t.height),n.drawImage(t,0,0),i}(u,n));const g=Gd(f?f.canvas:p,u.width-2,u.height-2,n);return r&&(g.source.style=r),this._createCanvas&&(this._renderer.texture.initSource(g.source),No.returnCanvasAndContext(f)),Dt.return(s),g})}returnTexturePromise(t){t.then(t=>{this._cleanUp(t)}).catch(()=>{kt("HTMLTextSystem: Failed to clean texture")})}_cleanUp(t){pe.returnTexture(t,!0),t.source.resource=null,t.source.uploadMethodId="unknown"}destroy(){this._renderer=null}}Nd.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"htmlText"};class Vd extends mc{constructor(t){super(),this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){this._renderer.canvasText.returnTexture(this.texture),this._renderer=null}}class Hd{constructor(t){this._renderer=t}validateRenderable(t){return t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);t._didTextUpdate&&(this._updateGpuText(t),t._didTextUpdate=!1),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.returnTexture(e.texture),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getTexture(t),Dd(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Vd(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Hd.extension={type:[o.WebGLPipes,o.WebGPUPipes,o.CanvasPipes],name:"text"};class Wd{constructor(t){this._renderer=t}getTexture(t,e,i,n){var r;"string"==typeof t&&(z("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:i,resolution:e}),t.style instanceof zo||(t.style=new zo(t.style)),t.textureStyle instanceof X||(t.textureStyle=new X(t.textureStyle)),"string"!=typeof t.text&&(t.text=t.text.toString());const{text:s,style:o,textureStyle:a}=t,l=null!=(r=t.resolution)?r:this._renderer.resolution,{frame:h,canvasAndContext:c}=El.getCanvasAndContext({text:s,style:o,resolution:l}),u=Gd(c.canvas,h.width,h.height,l);if(a&&(u.source.style=a),o.trim&&(h.pad(o.padding),u.frame.copyFrom(h),u.frame.scale(1/l),u.updateUvs()),o.filters){const t=this._applyFilters(u,o.filters);return this.returnTexture(u),El.returnCanvasAndContext(c),t}return this._renderer.texture.initSource(u._source),El.returnCanvasAndContext(c),u}returnTexture(t){const e=t.source;e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",pe.returnTexture(t,!0)}renderTextToCanvas(){z("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}_applyFilters(t,e){const i=this._renderer.renderTarget.renderTarget,n=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(i,!1),n}destroy(){this._renderer=null}}Wd.extension={type:[o.WebGLSystem,o.WebGPUSystem,o.CanvasSystem],name:"canvasText"},h.add(c,u);var jd="object"==typeof global&&global&&global.Object===Object&&global,Yd="object"==typeof self&&self&&self.Object===Object&&self,Xd=jd||Yd||Function("return this")(),Zd=Xd.Symbol,qd=Object.prototype,$d=qd.hasOwnProperty,Kd=qd.toString,Qd=Zd?Zd.toStringTag:void 0;var Jd=Object.prototype.toString;var tp=Zd?Zd.toStringTag:void 0;function ep(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":tp&&tp in Object(t)?function(t){var e=$d.call(t,Qd),i=t[Qd];try{t[Qd]=void 0;var n=!0}catch(s){}var r=Kd.call(t);return n&&(e?t[Qd]=i:delete t[Qd]),r}(t):function(t){return Jd.call(t)}(t)}function ip(t){return null!=t&&"object"==typeof t}var np=Array.isArray,rp=/\s/;var sp=/^\s+/;function op(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&rp.test(t.charAt(e)););return e}(t)+1).replace(sp,""):t}function ap(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}var lp=/^[-+]0x[0-9a-f]+$/i,hp=/^0b[01]+$/i,cp=/^0o[0-7]+$/i,up=parseInt;function dp(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||ip(t)&&"[object Symbol]"==ep(t)}(t))return NaN;if(ap(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ap(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=op(t);var i=hp.test(t);return i||cp.test(t)?up(t.slice(2),i?2:8):lp.test(t)?NaN:+t}var pp=1/0;function fp(t){var e=function(t){return t?(t=dp(t))===pp||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}(t),i=e%1;return e==e?i?e-i:e:0}function gp(t){return t}function mp(t){if(!ap(t))return!1;var e=ep(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var _p,yp=Xd["__core-js_shared__"],xp=(_p=/[^.]+$/.exec(yp&&yp.keys&&yp.keys.IE_PROTO||""))?"Symbol(src)_1."+_p:"";var bp=Function.prototype.toString;function vp(t){if(null!=t){try{return bp.call(t)}catch(e){}try{return t+""}catch(e){}}return""}var wp=/^\[object .+?Constructor\]$/,Sp=Function.prototype,Ap=Object.prototype,Tp=Sp.toString,Cp=Ap.hasOwnProperty,Pp=RegExp("^"+Tp.call(Cp).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Mp(t){return!(!ap(t)||(e=t,xp&&xp in e))&&(mp(t)?Pp:wp).test(vp(t));var e}function Ep(t,e){var i=function(t,e){return null==t?void 0:t[e]}(t,e);return Mp(i)?i:void 0}var Rp=Ep(Xd,"WeakMap"),Bp=Object.create,Fp=function(){function t(){}return function(e){if(!ap(e))return{};if(Bp)return Bp(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}();var kp=Date.now;var Ip,Dp,Op,Up=function(){try{var t=Ep(Object,"defineProperty");return t({},"",{}),t}catch(e){}}(),Gp=Up?function(t,e){return Up(t,"toString",{configurable:!0,enumerable:!1,value:(i=e,function(){return i}),writable:!0});var i}:gp,Lp=(Ip=Gp,Dp=0,Op=0,function(){var t=kp(),e=16-(t-Op);if(Op=t,e>0){if(++Dp>=800)return arguments[0]}else Dp=0;return Ip.apply(void 0,arguments)}),zp=/^(?:0|[1-9]\d*)$/;function Np(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&zp.test(t))&&t>-1&&t%1==0&&t<e}function Vp(t,e,i){"__proto__"==e&&Up?Up(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}function Hp(t,e){return t===e||t!=t&&e!=e}var Wp=Object.prototype.hasOwnProperty;function jp(t,e,i){var n=t[e];Wp.call(t,e)&&Hp(n,i)&&(void 0!==i||e in t)||Vp(t,e,i)}var Yp=Math.max;function Xp(t,e){return Lp(function(t,e,i){return e=Yp(void 0===e?t.length-1:e,0),function(){for(var n=arguments,r=-1,s=Yp(n.length-e,0),o=Array(s);++r<s;)o[r]=n[e+r];r=-1;for(var a=Array(e+1);++r<e;)a[r]=n[r];return a[e]=i(o),function(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)}(t,this,a)}}(t,e,gp),t+"")}function Zp(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function qp(t){return null!=t&&Zp(t.length)&&!mp(t)}var $p=Object.prototype;function Kp(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||$p)}function Qp(t){return ip(t)&&"[object Arguments]"==ep(t)}var Jp=Object.prototype,tf=Jp.hasOwnProperty,ef=Jp.propertyIsEnumerable,nf=Qp(function(){return arguments}())?Qp:function(t){return ip(t)&&tf.call(t,"callee")&&!ef.call(t,"callee")};var rf="object"==typeof exports&&exports&&!exports.nodeType&&exports,sf=rf&&"object"==typeof module&&module&&!module.nodeType&&module,of=sf&&sf.exports===rf?Xd.Buffer:void 0,af=(of?of.isBuffer:void 0)||function(){return!1},lf={};lf["[object Float32Array]"]=lf["[object Float64Array]"]=lf["[object Int8Array]"]=lf["[object Int16Array]"]=lf["[object Int32Array]"]=lf["[object Uint8Array]"]=lf["[object Uint8ClampedArray]"]=lf["[object Uint16Array]"]=lf["[object Uint32Array]"]=!0,lf["[object Arguments]"]=lf["[object Array]"]=lf["[object ArrayBuffer]"]=lf["[object Boolean]"]=lf["[object DataView]"]=lf["[object Date]"]=lf["[object Error]"]=lf["[object Function]"]=lf["[object Map]"]=lf["[object Number]"]=lf["[object Object]"]=lf["[object RegExp]"]=lf["[object Set]"]=lf["[object String]"]=lf["[object WeakMap]"]=!1;var hf="object"==typeof exports&&exports&&!exports.nodeType&&exports,cf=hf&&"object"==typeof module&&module&&!module.nodeType&&module,uf=cf&&cf.exports===hf&&jd.process,df=function(){try{var t=cf&&cf.require&&cf.require("util").types;return t||uf&&uf.binding&&uf.binding("util")}catch(e){}}(),pf=df&&df.isTypedArray,ff=pf?function(t){return function(e){return t(e)}}(pf):function(t){return ip(t)&&Zp(t.length)&&!!lf[ep(t)]},gf=Object.prototype.hasOwnProperty;function mf(t,e){var i=np(t),n=!i&&nf(t),r=!i&&!n&&af(t),s=!i&&!n&&!r&&ff(t),o=i||n||r||s,a=o?function(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n}(t.length,String):[],l=a.length;for(var h in t)!e&&!gf.call(t,h)||o&&("length"==h||r&&("offset"==h||"parent"==h)||s&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||Np(h,l))||a.push(h);return a}function _f(t,e){return function(i){return t(e(i))}}var yf=_f(Object.keys,Object),xf=Object.prototype.hasOwnProperty;function bf(t){return qp(t)?mf(t):function(t){if(!Kp(t))return yf(t);var e=[];for(var i in Object(t))xf.call(t,i)&&"constructor"!=i&&e.push(i);return e}(t)}var vf=Object.prototype.hasOwnProperty;function wf(t){if(!ap(t))return function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e}(t);var e=Kp(t),i=[];for(var n in t)("constructor"!=n||!e&&vf.call(t,n))&&i.push(n);return i}function Sf(t){return qp(t)?mf(t,!0):wf(t)}var Af=Ep(Object,"create");var Tf=Object.prototype.hasOwnProperty;var Cf=Object.prototype.hasOwnProperty;function Pf(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}function Mf(t,e){for(var i=t.length;i--;)if(Hp(t[i][0],e))return i;return-1}Pf.prototype.clear=function(){this.__data__=Af?Af(null):{},this.size=0},Pf.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Pf.prototype.get=function(t){var e=this.__data__;if(Af){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return Tf.call(e,t)?e[t]:void 0},Pf.prototype.has=function(t){var e=this.__data__;return Af?void 0!==e[t]:Cf.call(e,t)},Pf.prototype.set=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Af&&void 0===e?"__lodash_hash_undefined__":e,this};var Ef=Array.prototype.splice;function Rf(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Rf.prototype.clear=function(){this.__data__=[],this.size=0},Rf.prototype.delete=function(t){var e=this.__data__,i=Mf(e,t);return!(i<0)&&(i==e.length-1?e.pop():Ef.call(e,i,1),--this.size,!0)},Rf.prototype.get=function(t){var e=this.__data__,i=Mf(e,t);return i<0?void 0:e[i][1]},Rf.prototype.has=function(t){return Mf(this.__data__,t)>-1},Rf.prototype.set=function(t,e){var i=this.__data__,n=Mf(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this};var Bf=Ep(Xd,"Map");function Ff(t,e){var i,n,r=t.__data__;return("string"==(n=typeof(i=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==i:null===i)?r["string"==typeof e?"string":"hash"]:r.map}function kf(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}kf.prototype.clear=function(){this.size=0,this.__data__={hash:new Pf,map:new(Bf||Rf),string:new Pf}},kf.prototype.delete=function(t){var e=Ff(this,t).delete(t);return this.size-=e?1:0,e},kf.prototype.get=function(t){return Ff(this,t).get(t)},kf.prototype.has=function(t){return Ff(this,t).has(t)},kf.prototype.set=function(t,e){var i=Ff(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this};var If=_f(Object.getPrototypeOf,Object),Df=Function.prototype,Of=Object.prototype,Uf=Df.toString,Gf=Of.hasOwnProperty,Lf=Uf.call(Object);function zf(t,e,i){var n=-1,r=t.length;e<0&&(e=-e>r?0:r+e),(i=i>r?r:i)<0&&(i+=r),r=e>i?0:i-e>>>0,e>>>=0;for(var s=Array(r);++n<r;)s[n]=t[n+e];return s}var Nf=Math.ceil,Vf=Math.max;function Hf(t){var e=this.__data__=new Rf(t);this.size=e.size}Hf.prototype.clear=function(){this.__data__=new Rf,this.size=0},Hf.prototype.delete=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i},Hf.prototype.get=function(t){return this.__data__.get(t)},Hf.prototype.has=function(t){return this.__data__.has(t)},Hf.prototype.set=function(t,e){var i=this.__data__;if(i instanceof Rf){var n=i.__data__;if(!Bf||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new kf(n)}return i.set(t,e),this.size=i.size,this};var Wf="object"==typeof exports&&exports&&!exports.nodeType&&exports,jf=Wf&&"object"==typeof module&&module&&!module.nodeType&&module,Yf=jf&&jf.exports===Wf?Xd.Buffer:void 0;Yf&&Yf.allocUnsafe;var Xf=Object.prototype.propertyIsEnumerable,Zf=Object.getOwnPropertySymbols,qf=Zf?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var i=-1,n=null==t?0:t.length,r=0,s=[];++i<n;){var o=t[i];e(o,i,t)&&(s[r++]=o)}return s}(Zf(t),function(e){return Xf.call(t,e)}))}:function(){return[]};function $f(t){return function(t,e,i){var n=e(t);return np(t)?n:function(t,e){for(var i=-1,n=e.length,r=t.length;++i<n;)t[r+i]=e[i];return t}(n,i(t))}(t,bf,qf)}var Kf=Ep(Xd,"DataView"),Qf=Ep(Xd,"Promise"),Jf=Ep(Xd,"Set"),tg="[object Map]",eg="[object Promise]",ig="[object Set]",ng="[object WeakMap]",rg="[object DataView]",sg=vp(Kf),og=vp(Bf),ag=vp(Qf),lg=vp(Jf),hg=vp(Rp),cg=ep;(Kf&&cg(new Kf(new ArrayBuffer(1)))!=rg||Bf&&cg(new Bf)!=tg||Qf&&cg(Qf.resolve())!=eg||Jf&&cg(new Jf)!=ig||Rp&&cg(new Rp)!=ng)&&(cg=function(t){var e=ep(t),i="[object Object]"==e?t.constructor:void 0,n=i?vp(i):"";if(n)switch(n){case sg:return rg;case og:return tg;case ag:return eg;case lg:return ig;case hg:return ng}return e});var ug=Xd.Uint8Array;function dg(t,e){var i,n,r=(i=t.buffer,n=new i.constructor(i.byteLength),new ug(n).set(new ug(i)),n);return new t.constructor(r,t.byteOffset,t.length)}function pg(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new kf;++e<i;)this.add(t[e])}function fg(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(e(t[i],i,t))return!0;return!1}pg.prototype.add=pg.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},pg.prototype.has=function(t){return this.__data__.has(t)};function gg(t,e,i,n,r,s){var o=1&i,a=t.length,l=e.length;if(a!=l&&!(o&&l>a))return!1;var h=s.get(t),c=s.get(e);if(h&&c)return h==e&&c==t;var u=-1,d=!0,p=2&i?new pg:void 0;for(s.set(t,e),s.set(e,t);++u<a;){var f=t[u],g=e[u];if(n)var m=o?n(g,f,u,e,t,s):n(f,g,u,t,e,s);if(void 0!==m){if(m)continue;d=!1;break}if(p){if(!fg(e,function(t,e){if(o=e,!p.has(o)&&(f===t||r(f,t,i,n,s)))return p.push(e);var o})){d=!1;break}}else if(f!==g&&!r(f,g,i,n,s)){d=!1;break}}return s.delete(t),s.delete(e),d}function mg(t){var e=-1,i=Array(t.size);return t.forEach(function(t,n){i[++e]=[n,t]}),i}function _g(t){var e=-1,i=Array(t.size);return t.forEach(function(t){i[++e]=t}),i}var yg=Zd?Zd.prototype:void 0,xg=yg?yg.valueOf:void 0;var bg=Object.prototype.hasOwnProperty;var vg="[object Arguments]",wg="[object Array]",Sg="[object Object]",Ag=Object.prototype.hasOwnProperty;function Tg(t,e,i,n,r,s){var o=np(t),a=np(e),l=o?wg:cg(t),h=a?wg:cg(e),c=(l=l==vg?Sg:l)==Sg,u=(h=h==vg?Sg:h)==Sg,d=l==h;if(d&&af(t)){if(!af(e))return!1;o=!0,c=!1}if(d&&!c)return s||(s=new Hf),o||ff(t)?gg(t,e,i,n,r,s):function(t,e,i,n,r,s,o){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!s(new ug(t),new ug(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Hp(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=mg;case"[object Set]":var l=1&n;if(a||(a=_g),t.size!=e.size&&!l)return!1;var h=o.get(t);if(h)return h==e;n|=2,o.set(t,e);var c=gg(a(t),a(e),n,r,s,o);return o.delete(t),c;case"[object Symbol]":if(xg)return xg.call(t)==xg.call(e)}return!1}(t,e,l,i,n,r,s);if(!(1&i)){var p=c&&Ag.call(t,"__wrapped__"),f=u&&Ag.call(e,"__wrapped__");if(p||f){var g=p?t.value():t,m=f?e.value():e;return s||(s=new Hf),r(g,m,i,n,s)}}return!!d&&(s||(s=new Hf),function(t,e,i,n,r,s){var o=1&i,a=$f(t),l=a.length;if(l!=$f(e).length&&!o)return!1;for(var h=l;h--;){var c=a[h];if(!(o?c in e:bg.call(e,c)))return!1}var u=s.get(t),d=s.get(e);if(u&&d)return u==e&&d==t;var p=!0;s.set(t,e),s.set(e,t);for(var f=o;++h<l;){var g=t[c=a[h]],m=e[c];if(n)var _=o?n(m,g,c,e,t,s):n(g,m,c,t,e,s);if(!(void 0===_?g===m||r(g,m,i,n,s):_)){p=!1;break}f||(f="constructor"==c)}if(p&&!f){var y=t.constructor,x=e.constructor;y==x||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof x&&x instanceof x||(p=!1)}return s.delete(t),s.delete(e),p}(t,e,i,n,r,s))}function Cg(t,e,i,n,r){return t===e||(null==t||null==e||!ip(t)&&!ip(e)?t!=t&&e!=e:Tg(t,e,i,n,Cg,r))}var Pg=function(t,e,i){for(var n=-1,r=Object(t),s=i(t),o=s.length;o--;){var a=s[++n];if(!1===e(r[a],a,r))break}return t},Mg=function(){return Xd.Date.now()},Eg=Math.max,Rg=Math.min;function Bg(t,e,i){var n,r,s,o,a,l,h=0,c=!1,u=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){var i=n,s=r;return n=r=void 0,h=e,o=t.apply(s,i)}function f(t){var i=t-l;return void 0===l||i>=e||i<0||u&&t-h>=s}function g(){var t=Mg();if(f(t))return m(t);a=setTimeout(g,function(t){var i=e-(t-l);return u?Rg(i,s-(t-h)):i}(t))}function m(t){return a=void 0,d&&n?p(t):(n=r=void 0,o)}function _(){var t=Mg(),i=f(t);if(n=arguments,r=this,l=t,i){if(void 0===a)return function(t){return h=t,a=setTimeout(g,e),c?p(t):o}(l);if(u)return clearTimeout(a),a=setTimeout(g,e),p(l)}return void 0===a&&(a=setTimeout(g,e)),o}return e=dp(e)||0,ap(i)&&(c=!!i.leading,s=(u="maxWait"in i)?Eg(dp(i.maxWait)||0,e):s,d="trailing"in i?!!i.trailing:d),_.cancel=function(){void 0!==a&&clearTimeout(a),h=0,n=l=r=a=void 0},_.flush=function(){return void 0===a?o:m(Mg())},_}function Fg(t,e,i){(void 0!==i&&!Hp(t[e],i)||void 0===i&&!(e in t))&&Vp(t,e,i)}function kg(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Ig(t){return function(t,e,i){var n=!i;i||(i={});for(var r=-1,s=e.length;++r<s;){var o=e[r],a=void 0;void 0===a&&(a=t[o]),n?Vp(i,o,a):jp(i,o,a)}return i}(t,Sf(t))}function Dg(t,e,i,n,r,s,o){var a=kg(t,i),l=kg(e,i),h=o.get(l);if(h)Fg(t,i,h);else{var c,u=s?s(a,l,i+"",t,e,o):void 0,d=void 0===u;if(d){var p=np(l),f=!p&&af(l),g=!p&&!f&&ff(l);u=l,p||f||g?np(a)?u=a:ip(c=a)&&qp(c)?u=function(t,e){var i=-1,n=t.length;for(e||(e=Array(n));++i<n;)e[i]=t[i];return e}(a):f?(d=!1,u=l.slice()):g?(d=!1,u=dg(l)):u=[]:function(t){if(!ip(t)||"[object Object]"!=ep(t))return!1;var e=If(t);if(null===e)return!0;var i=Gf.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&Uf.call(i)==Lf}(l)||nf(l)?(u=a,nf(a)?u=Ig(a):ap(a)&&!mp(a)||(u=function(t){return"function"!=typeof t.constructor||Kp(t)?{}:Fp(If(t))}(l))):d=!1}d&&(o.set(l,u),r(u,l,n,s,o),o.delete(l)),Fg(t,i,u)}}function Og(t,e,i,n,r){t!==e&&Pg(e,function(s,o){if(r||(r=new Hf),ap(s))Dg(t,e,o,i,Og,n,r);else{var a=n?n(kg(t,o),s,o+"",t,e,r):void 0;void 0===a&&(a=s),Fg(t,o,a)}},Sf)}function Ug(t,e){return Cg(t,e)}var Gg,Lg=(Gg=function(t,e,i){Og(t,e,i)},Xp(function(t,e){var i=-1,n=e.length,r=n>1?e[n-1]:void 0,s=n>2?e[2]:void 0;for(r=Gg.length>3&&"function"==typeof r?(n--,r):void 0,s&&function(t,e,i){if(!ap(i))return!1;var n=typeof e;return!!("number"==n?qp(i)&&Np(e,i.length):"string"==n&&e in i)&&Hp(i[e],t)}(e[0],e[1],s)&&(r=n<3?void 0:r,n=1),t=Object(t);++i<n;){var o=e[i];o&&Gg(t,o,i,r)}return t}));function zg(t,e,i){var n=!0,r=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return ap(i)&&(n="leading"in i?!!i.leading:n,r="trailing"in i?!!i.trailing:r),Bg(t,e,{leading:n,maxWait:e,trailing:r})}!function(t){var e={};for(var i in t)t.hasOwnProperty(i)&&(e[t[i]]=i)}({aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"});var Ng,Vg={},Hg={};var Wg,jg,Yg={};var Xg=(jg||(jg=1,function(t){const e=function(){if(Ng)return Hg;Ng=1,Hg.byteLength=function(t){var e=s(t),i=e[0],n=e[1];return 3*(i+n)/4-n},Hg.toByteArray=function(t){var n,r,o=s(t),a=o[0],l=o[1],h=new i(function(t,e,i){return 3*(e+i)/4-i}(0,a,l)),c=0,u=l>0?a-4:a;for(r=0;r<u;r+=4)n=e[t.charCodeAt(r)]<<18|e[t.charCodeAt(r+1)]<<12|e[t.charCodeAt(r+2)]<<6|e[t.charCodeAt(r+3)],h[c++]=n>>16&255,h[c++]=n>>8&255,h[c++]=255&n;return 2===l&&(n=e[t.charCodeAt(r)]<<2|e[t.charCodeAt(r+1)]>>4,h[c++]=255&n),1===l&&(n=e[t.charCodeAt(r)]<<10|e[t.charCodeAt(r+1)]<<4|e[t.charCodeAt(r+2)]>>2,h[c++]=n>>8&255,h[c++]=255&n),h},Hg.fromByteArray=function(e){for(var i,n=e.length,r=n%3,s=[],o=16383,l=0,h=n-r;l<h;l+=o)s.push(a(e,l,l+o>h?h:l+o));return 1===r?(i=e[n-1],s.push(t[i>>2]+t[i<<4&63]+"==")):2===r&&(i=(e[n-2]<<8)+e[n-1],s.push(t[i>>10]+t[i>>4&63]+t[i<<2&63]+"=")),s.join("")};for(var t=[],e=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0;r<64;++r)t[r]=n[r],e[n.charCodeAt(r)]=r;function s(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function o(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[63&e]}function a(t,e,i){for(var n,r=[],s=e;s<i;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),r.push(o(n));return r.join("")}return e["-".charCodeAt(0)]=62,e["_".charCodeAt(0)]=63,Hg}(),i=(Wg||(Wg=1,Yg.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,l=(1<<a)-1,h=l>>1,c=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,s=p&(1<<-c)-1,p>>=-c,c+=a;c>0;s=256*s+t[e+u],u+=d,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+u],u+=d,c-=8);if(0===s)s=1-h;else{if(s===l)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),s-=h}return(p?-1:1)*o*Math.pow(2,s-n)},Yg.write=function(t,e,i,n,r,s){var o,a,l,h=8*s-r-1,c=(1<<h)-1,u=c>>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,f=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+u>=1?d/l:d*Math.pow(2,1-u))*l>=2&&(o++,l/=2),o+u>=c?(a=0,o=c):o+u>=1?(a=(e*l-1)*Math.pow(2,r),o+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),o=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(o=o<<r|a,h+=r;h>0;t[i+p]=255&o,p+=f,o/=256,h-=8);t[i+p-f]|=128*g}),Yg),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=o,t.SlowBuffer=function(t){return+t!=t&&(t=0),o.alloc(+t)},t.INSPECT_MAX_BYTES=50;const r=2147483647;function s(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,o.prototype),e}function o(t,e,i){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return a(t,e,i)}function a(t,e,i){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const i=0|p(t,e);let n=s(i);const r=n.write(t,e);return r!==i&&(n=n.slice(0,r)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return u(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return u(t,e,i);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return u(t,e,i);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return o.from(n,e,i);const r=function(t){if(o.isBuffer(t)){const e=0|d(t.length),i=s(e);return 0===i.length||t.copy(i,0,0,e),i}return void 0!==t.length?"number"!=typeof t.length||Z(t.length)?s(0):c(t):"Buffer"===t.type&&Array.isArray(t.data)?c(t.data):void 0}(t);if(r)return r;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return o.from(t[Symbol.toPrimitive]("string"),e,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return l(t),s(t<0?0:0|d(t))}function c(t){const e=t.length<0?0:0|d(t.length),i=s(e);for(let n=0;n<e;n+=1)i[n]=255&t[n];return i}function u(t,e,i){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(i||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===i?new Uint8Array(t):void 0===i?new Uint8Array(t,e):new Uint8Array(t,e,i),Object.setPrototypeOf(n,o.prototype),n}function d(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function p(t,e){if(o.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const i=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===i)return 0;let r=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return j(t).length;default:if(r)return n?-1:W(t).length;e=(""+e).toLowerCase(),r=!0}}function f(t,e,i){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return M(this,e,i);case"utf8":case"utf-8":return A(this,e,i);case"ascii":return C(this,e,i);case"latin1":case"binary":return P(this,e,i);case"base64":return S(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function m(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),Z(i=+i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=o.from(e,n)),o.isBuffer(e))return 0===e.length?-1:_(t,e,i,n,r);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):_(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function _(t,e,i,n,r){let s,o=1,a=t.length,l=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,l/=2,i/=2}function h(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){let n=-1;for(s=i;s<a;s++)if(h(t,s)===h(e,-1===n?0:s-n)){if(-1===n&&(n=s),s-n+1===l)return n*o}else-1!==n&&(s-=s-n),n=-1}else for(i+l>a&&(i=a-l),s=i;s>=0;s--){let i=!0;for(let n=0;n<l;n++)if(h(t,s+n)!==h(e,n)){i=!1;break}if(i)return s}return-1}function y(t,e,i,n){i=Number(i)||0;const r=t.length-i;n?(n=Number(n))>r&&(n=r):n=r;const s=e.length;let o;for(n>s/2&&(n=s/2),o=0;o<n;++o){const n=parseInt(e.substr(2*o,2),16);if(Z(n))return o;t[i+o]=n}return o}function x(t,e,i,n){return Y(W(e,t.length-i),t,i,n)}function b(t,e,i,n){return Y(function(t){const e=[];for(let i=0;i<t.length;++i)e.push(255&t.charCodeAt(i));return e}(e),t,i,n)}function v(t,e,i,n){return Y(j(e),t,i,n)}function w(t,e,i,n){return Y(function(t,e){let i,n,r;const s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)i=t.charCodeAt(o),n=i>>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function S(t,i,n){return 0===i&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(i,n))}function A(t,e,i){i=Math.min(t.length,i);const n=[];let r=e;for(;r<i;){const e=t[r];let s=null,o=e>239?4:e>223?3:e>191?2:1;if(r+o<=i){let i,n,a,l;switch(o){case 1:e<128&&(s=e);break;case 2:i=t[r+1],128==(192&i)&&(l=(31&e)<<6|63&i,l>127&&(s=l));break;case 3:i=t[r+1],n=t[r+2],128==(192&i)&&128==(192&n)&&(l=(15&e)<<12|(63&i)<<6|63&n,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:i=t[r+1],n=t[r+2],a=t[r+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(l=(15&e)<<18|(63&i)<<12|(63&n)<<6|63&a,l>65535&&l<1114112&&(s=l))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),r+=o}return function(t){const e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let i="",n=0;for(;n<e;)i+=String.fromCharCode.apply(String,t.slice(n,n+=T));return i}(n)}t.kMaxLength=r,o.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),o.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(t,e,i){return a(t,e,i)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(t,e,i){return function(t,e,i){return l(t),t<=0?s(t):void 0!==e?"string"==typeof i?s(t).fill(e,i):s(t).fill(e):s(t)}(t,e,i)},o.allocUnsafe=function(t){return h(t)},o.allocUnsafeSlow=function(t){return h(t)},o.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==o.prototype},o.compare=function(t,e){if(X(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),X(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let i=t.length,n=e.length;for(let r=0,s=Math.min(i,n);r<s;++r)if(t[r]!==e[r]){i=t[r],n=e[r];break}return i<n?-1:n<i?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return o.alloc(0);let i;if(void 0===e)for(e=0,i=0;i<t.length;++i)e+=t[i].length;const n=o.allocUnsafe(e);let r=0;for(i=0;i<t.length;++i){let e=t[i];if(X(e,Uint8Array))r+e.length>n.length?(o.isBuffer(e)||(e=o.from(e)),e.copy(n,r)):Uint8Array.prototype.set.call(n,e,r);else{if(!o.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,r)}r+=e.length}return n},o.byteLength=p,o.prototype._isBuffer=!0,o.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)g(this,e,e+1);return this},o.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},o.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},o.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):f.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===o.compare(this,t)},o.prototype.inspect=function(){let e="";const i=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(e+=" ... "),"<Buffer "+e+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(t,e,i,n,r){if(X(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;let s=(r>>>=0)-(n>>>=0),a=(i>>>=0)-(e>>>=0);const l=Math.min(s,a),h=this.slice(n,r),c=t.slice(e,i);for(let o=0;o<l;++o)if(h[o]!==c[o]){s=h[o],a=c[o];break}return s<a?-1:a<s?1:0},o.prototype.includes=function(t,e,i){return-1!==this.indexOf(t,e,i)},o.prototype.indexOf=function(t,e,i){return m(this,t,e,i,!0)},o.prototype.lastIndexOf=function(t,e,i){return m(this,t,e,i,!1)},o.prototype.write=function(t,e,i,n){if(void 0===e)n="utf8",i=this.length,e=0;else if(void 0===i&&"string"==typeof e)n=e,i=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(i)?(i>>>=0,void 0===n&&(n="utf8")):(n=i,i=void 0)}const r=this.length-e;if((void 0===i||i>r)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let s=!1;for(;;)switch(n){case"hex":return y(this,t,e,i);case"utf8":case"utf-8":return x(this,t,e,i);case"ascii":case"latin1":case"binary":return b(this,t,e,i);case"base64":return v(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function C(t,e,i){let n="";i=Math.min(t.length,i);for(let r=e;r<i;++r)n+=String.fromCharCode(127&t[r]);return n}function P(t,e,i){let n="";i=Math.min(t.length,i);for(let r=e;r<i;++r)n+=String.fromCharCode(t[r]);return n}function M(t,e,i){const n=t.length;(!e||e<0)&&(e=0),(!i||i<0||i>n)&&(i=n);let r="";for(let s=e;s<i;++s)r+=q[t[s]];return r}function E(t,e,i){const n=t.slice(e,i);let r="";for(let s=0;s<n.length-1;s+=2)r+=String.fromCharCode(n[s]+256*n[s+1]);return r}function R(t,e,i){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>i)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,i,n,r,s){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||e<s)throw new RangeError('"value" argument is out of bounds');if(i+n>t.length)throw new RangeError("Index out of range")}function F(t,e,i,n,r){z(e,n,r,t,i,7);let s=Number(e&BigInt(4294967295));t[i++]=s,s>>=8,t[i++]=s,s>>=8,t[i++]=s,s>>=8,t[i++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[i++]=o,o>>=8,t[i++]=o,o>>=8,t[i++]=o,o>>=8,t[i++]=o,i}function k(t,e,i,n,r){z(e,n,r,t,i,7);let s=Number(e&BigInt(4294967295));t[i+7]=s,s>>=8,t[i+6]=s,s>>=8,t[i+5]=s,s>>=8,t[i+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[i+3]=o,o>>=8,t[i+2]=o,o>>=8,t[i+1]=o,o>>=8,t[i]=o,i+8}function I(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function D(t,e,n,r,s){return e=+e,n>>>=0,s||I(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function O(t,e,n,r,s){return e=+e,n>>>=0,s||I(t,0,n,8),i.write(t,e,n,r,52,8),n+8}o.prototype.slice=function(t,e){const i=this.length;(t=~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),(e=void 0===e?i:~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,o.prototype),n},o.prototype.readUintLE=o.prototype.readUIntLE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);let n=this[t],r=1,s=0;for(;++s<e&&(r*=256);)n+=this[t+s]*r;return n},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);let n=this[t+--e],r=1;for(;e>0&&(r*=256);)n+=this[t+--e]*r;return n},o.prototype.readUint8=o.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readBigUInt64LE=$(function(t){N(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||V(t,this.length-8);const n=e+this[++t]*__pow(2,8)+this[++t]*__pow(2,16)+this[++t]*__pow(2,24),r=this[++t]+this[++t]*__pow(2,8)+this[++t]*__pow(2,16)+i*__pow(2,24);return BigInt(n)+(BigInt(r)<<BigInt(32))}),o.prototype.readBigUInt64BE=$(function(t){N(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||V(t,this.length-8);const n=e*__pow(2,24)+this[++t]*__pow(2,16)+this[++t]*__pow(2,8)+this[++t],r=this[++t]*__pow(2,24)+this[++t]*__pow(2,16)+this[++t]*__pow(2,8)+i;return(BigInt(n)<<BigInt(32))+BigInt(r)}),o.prototype.readIntLE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);let n=this[t],r=1,s=0;for(;++s<e&&(r*=256);)n+=this[t+s]*r;return r*=128,n>=r&&(n-=Math.pow(2,8*e)),n},o.prototype.readIntBE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);let n=e,r=1,s=this[t+--n];for(;n>0&&(r*=256);)s+=this[t+--n]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*e)),s},o.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);const i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},o.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);const i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},o.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readBigInt64LE=$(function(t){N(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||V(t,this.length-8);const n=this[t+4]+this[t+5]*__pow(2,8)+this[t+6]*__pow(2,16)+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+this[++t]*__pow(2,8)+this[++t]*__pow(2,16)+this[++t]*__pow(2,24))}),o.prototype.readBigInt64BE=$(function(t){N(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||V(t,this.length-8);const n=(e<<24)+this[++t]*__pow(2,16)+this[++t]*__pow(2,8)+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*__pow(2,24)+this[++t]*__pow(2,16)+this[++t]*__pow(2,8)+i)}),o.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!1,52,8)},o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,e,i,n){t=+t,e>>>=0,i>>>=0,n||B(this,t,e,i,Math.pow(2,8*i)-1,0);let r=1,s=0;for(this[e]=255&t;++s<i&&(r*=256);)this[e+s]=t/r&255;return e+i},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,e,i,n){t=+t,e>>>=0,i>>>=0,n||B(this,t,e,i,Math.pow(2,8*i)-1,0);let r=i-1,s=1;for(this[e+r]=255&t;--r>=0&&(s*=256);)this[e+r]=t/s&255;return e+i},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,1,255,0),this[e]=255&t,e+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigUInt64LE=$(function(t,e=0){return F(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=$(function(t,e=0){return k(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*i-1);B(this,t,e,i,n-1,-n)}let r=0,s=1,o=0;for(this[e]=255&t;++r<i&&(s*=256);)t<0&&0===o&&0!==this[e+r-1]&&(o=1),this[e+r]=(t/s|0)-o&255;return e+i},o.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*i-1);B(this,t,e,i,n-1,-n)}let r=i-1,s=1,o=0;for(this[e+r]=255&t;--r>=0&&(s*=256);)t<0&&0===o&&0!==this[e+r+1]&&(o=1),this[e+r]=(t/s|0)-o&255;return e+i},o.prototype.writeInt8=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeInt16BE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeInt32LE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},o.prototype.writeInt32BE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigInt64LE=$(function(t,e=0){return F(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=$(function(t,e=0){return k(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeFloatLE=function(t,e,i){return D(this,t,e,!0,i)},o.prototype.writeFloatBE=function(t,e,i){return D(this,t,e,!1,i)},o.prototype.writeDoubleLE=function(t,e,i){return O(this,t,e,!0,i)},o.prototype.writeDoubleBE=function(t,e,i){return O(this,t,e,!1,i)},o.prototype.copy=function(t,e,i,n){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<i&&(n=i),n===i)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-i&&(n=t.length-e+i);const r=n-i;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,i,n):Uint8Array.prototype.set.call(t,this.subarray(i,n),e),r},o.prototype.fill=function(t,e,i,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,i=this.length):"string"==typeof i&&(n=i,i=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!o.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<i)throw new RangeError("Out of range index");if(i<=e)return this;let r;if(e>>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(r=e;r<i;++r)this[r]=t;else{const s=o.isBuffer(t)?t:o.from(t,n),a=s.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(r=0;r<i-e;++r)this[r+e]=s[r%a]}return this};const U={};function G(t,e,i){U[t]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function L(t){let e="",i=t.length;const n="-"===t[0]?1:0;for(;i>=n+4;i-=3)e=`_${t.slice(i-3,i)}${e}`;return`${t.slice(0,i)}${e}`}function z(t,e,i,n,r,s){if(t>i||t<e){const i="bigint"==typeof e?"n":"";let n;throw n=0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(s+1)}${i}`:`>= -(2${i} ** ${8*(s+1)-1}${i}) and < 2 ** ${8*(s+1)-1}${i}`,new U.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,i){N(e,"offset"),void 0!==t[e]&&void 0!==t[e+i]||V(e,t.length-(i+1))}(n,r,s)}function N(t,e){if("number"!=typeof t)throw new U.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,i){if(Math.floor(t)!==t)throw N(t,i),new U.ERR_OUT_OF_RANGE("offset","an integer",t);if(e<0)throw new U.ERR_BUFFER_OUT_OF_BOUNDS;throw new U.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}G("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),G("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),G("ERR_OUT_OF_RANGE",function(t,e,i){let n=`The value of "${t}" is out of range.`,r=i;return Number.isInteger(i)&&Math.abs(i)>__pow(2,32)?r=L(String(i)):"bigint"==typeof i&&(r=String(i),(i>__pow(BigInt(2),BigInt(32))||i<-__pow(BigInt(2),BigInt(32)))&&(r=L(r)),r+="n"),n+=` It must be ${e}. Received ${r}`,n},RangeError);const H=/[^+/0-9A-Za-z-_]/g;function W(t,e){let i;e=e||1/0;const n=t.length;let r=null;const s=[];for(let o=0;o<n;++o){if(i=t.charCodeAt(o),i>55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function j(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(H,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,i,n){let r;for(r=0;r<n&&!(r+i>=e.length||r>=t.length);++r)e[r+i]=t[r];return r}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Z(t){return t!=t}const q=function(){const t="0123456789abcdef",e=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let r=0;r<16;++r)e[n+r]=t[i]+t[r]}return e}();function $(t){return"undefined"==typeof BigInt?K:t}function K(){throw new Error("BigInt not supported")}}(Vg)),Vg),Zg=(t,e)=>Number((e/__pow(10,t)).toFixed(t)),qg=t=>t>32767?t-65535:t,$g=(t,e)=>e+(t<<8),Kg=(t,e)=>Zg(t,qg(e)),Qg=t=>{try{let e=t.match(/.{1,2}/g);if(!e||0===e.length)return"";let i=new Uint8Array(e.length),n=0;for(let t=0;t<e.length;t++){let r=parseInt(e[t],16);r>31&&127!==r&&(i[n++]=r)}let r=i.slice(0,n);return Array.from(r).map(t=>String.fromCharCode(t)).join("")}catch(e){return console.error(e),""}},Jg=t=>{if(!t)return"";try{let e=t.match(/.{1,2}/g);if(!e)return"";let i=e.filter(t=>{let e=parseInt(t,16);return e>31&&127!==e});return 0===i.length?"":decodeURIComponent("%"+i.join("%"))}catch(e){return console.error("传入的房间名称数据有误",t),""}},tm=(t,e=1)=>{let i=[];for(let n=0;n<t.length;n+=2*e){let r=t.slice(n,n+2*e),s=parseInt(r,16);i.push(s)}return i},em=({chargeX:t,chargeY:e},{originX:i,originY:n})=>{if(t<=0&&e<=0)return null;return{x:t-i,y:e-n}},im=(t,e)=>parseInt((t+e).slice(-8),2).toString(16).padStart(2,"0"),nm=t=>{let e=parseInt(t.slice(0,2),16),i=t.slice(0,3===e?52:48),n=2,r=parseInt(i.slice(n,n+4),16);n+=4;let s=1===parseInt(i.slice(n,n+2),16);n+=2;let o=parseInt(i.slice(n,n+4),16);n+=4;let a=parseInt(i.slice(n,n+4),16);n+=4;let l=Zg(1,parseInt(i.slice(n,n+4),16));n+=4;let h=Zg(1,parseInt(i.slice(n,n+4),16));n+=4;let c=Zg(2,parseInt(i.slice(n,n+4),16));n+=4;let u=Zg(1,parseInt(i.slice(n,n+4),16));n+=4;let d,p=Zg(1,parseInt(i.slice(n,n+4),16));3===e&&(n+=4,d=parseInt(i.slice(n,n+4),16)),n+=4;let f=parseInt(i.slice(n,n+8),16);n+=8;let g=parseInt(i.slice(n,n+4),16);return{mapHeaderStr:i,version:e,id:r,mapStable:s,mapWidth:o,mapHeight:a,originX:l,originY:h,mapResolution:c,chargeX:u,chargeY:p,chargeDirection:d,chargePositionTransformed:em({chargeX:u,chargeY:p},{originX:l,originY:h}),dataLengthBeforeCompress:f,dataLengthAfterCompress:g}},rm={"00":"00","01":"f1",10:"f2",11:"ff"},sm={sweep:"00",barrier:"01",battery:"10",unknown:"11"},om={sweep:"111",barrier:"001",carpet:"010",unknown:"000"},am={0:{typeMap:sm},1:{typeMap:sm},2:{typeMap:om},3:{typeMap:om}},lm={NO_ROOM_DATA:"NO_ROOM_DATA",ROOM_GAP:"ROOM_GAP",OBSTACLE_ROOM:"OBSTACLE_ROOM",UNKNOWN_ROOM:"UNKNOWN_ROOM"};Math.imul||(Math.imul=function(t,e){let i=65535&t,n=65535&e;return i*n+((t>>>16)*n+i*(e>>>16)<<16)|0});var hm=(t,e=1048576)=>{let i=Xg.Buffer.from(t),n=1073741824,r=e;if(e>n)return r=n,console.warn("uncompress所需空间过大,强制设定为1G",e),null;let s=Xg.Buffer.alloc(r),o=function(t,e,i,n){for(var r=i=i||0,s=n=n||t.length-i,o=0;r<s;){let i=t[r++],n=i>>4;if(n>0){for(var a=n+240;255===a;)n+=a=t[r++];for(var l=r+n;r<l;)e[o++]=t[r++];if(r===s)return o}let h=t[r++]|t[r++]<<8;if(0===h||h>o)return-(r-2);let c=15&i;for(a=c+240;255===a;)c+=a=t[r++];let u=o-h;for(l=o+c+4;o<l;)e[o++]=e[u++]}return o}(i,s);return s=s.slice(0,o),s};function cm(t,e,i,n){let r=3&t,s=t>>2&63;if(1===r||62===s)i.push(e);else if(0===r&&s<=31)n.has(s)||n.set(s,[]),n.get(s).push(e);else if(0===r){let t;switch(s){case 60:t=lm.NO_ROOM_DATA;break;case 61:t=lm.ROOM_GAP;break;case 62:t=lm.OBSTACLE_ROOM;break;case 63:t=lm.UNKNOWN_ROOM}void 0!==t&&(n.has(t)||n.set(t,[]),n.get(t).push(e))}}function um(t){switch(t){case 28:return lm.NO_ROOM_DATA;case 29:return lm.ROOM_GAP;case 30:return lm.OBSTACLE_ROOM;case 31:return lm.UNKNOWN_ROOM;default:return}}function dm(t,e,i,n,r){let s=7&t,o=t>>3&31;if(1===s||30===o)i.push(e);else if(2===s)if(n.push(e),o<=27)r.has(o)||r.set(o,[]),r.get(o).push(e);else{let t=um(o);void 0!==t&&(r.has(t)||r.set(t,[]),r.get(t).push(e))}else if(7===s)if(o<=27)r.has(o)||r.set(o,[]),r.get(o).push(e);else{let t=um(o);void 0!==t&&(r.has(t)||r.set(t,[]),r.get(t).push(e))}}var pm=(t,e)=>{let{mapWidth:i,mapHeight:n,dataLengthAfterCompress:r,dataLengthBeforeCompress:s,mapHeaderStr:o,version:a}=e,l=o.length,h="",c="",u=i*n,d=[],p=[],f=new Map;if(r>0){let e=4*s,r=tm(t.slice(l,l+2*s)),o=hm(r,e);if(!o)return{mapRooms:[],mapPointsStr:"",parsed:{obstacles:new Uint32Array,carpet:new Uint32Array,rooms:new Map,width:i,height:n,totalPixels:u}};let g=Array.from(o);if(0===a){let t=[];f.set(lm.NO_ROOM_DATA,[]);for(let e=0;e<g.length;e++){let i=g[e].toString(2).padStart(8,"0");for(let n=0;n<8;n+=2){let r=i.substring(n,n+2),s=rm[r];t.push(s);let o=4*e+n/2;if(o>=u)break;switch(parseInt(r,2)){case 0:f.get(lm.NO_ROOM_DATA).push(o);break;case 1:d.push(o)}}}h=t.join("").slice(0,2*u),c=""}else{let t=g.slice(0,u),e=[];for(let i=0;i<t.length;i++){let n=t[i];e.push(n.toString(16).padStart(2,"0")),1===a?cm(n,i,d,f):dm(n,i,d,p,f)}h=e.join(""),c=g.slice(u).map(t=>t.toString(16).padStart(2,"0")).join("")}}else if(0===a){let e=[],i=t.slice(l).match(/.{2}/g)||[];f.set(lm.NO_ROOM_DATA,[]);for(let t=0;t<i.length;t++){let n=parseInt(i[t],16).toString(2).padStart(8,"0");for(let i=0;i<8;i+=2){let r=n.substring(i,i+2);e.push(rm[r]);let s=4*t+i/2;if(s>=u)break;switch(parseInt(r,2)){case 0:f.get(lm.NO_ROOM_DATA).push(s);break;case 1:d.push(s)}}}h=e.join(""),c=""}else{let e=t.slice(l,l+2*u),i=[];for(let t=0;t<u;t++){let n=e.slice(2*t,2*t+2);i.push(n);let r=parseInt(n,16);1===a?cm(r,t,d,f):dm(r,t,d,p,f)}h=i.join(""),c=t.slice(l+2*u)}h=h.toLowerCase(),i*n*2>h.length&&(h=h.padStart(i*n*2,"f")),i*n*2<h.length&&(h=h.slice(h.length-i*n*2));let g=((t,e=1)=>{if(!t)return[];let i=parseInt(t.slice(2,4),16),n=t.slice(4),r=[],s=0;for(let o=0;o<i;o++){let t=n.slice(s,s+94),i=parseInt(t.slice(0,4),16),o=parseInt(t.slice(4,8),16),a=parseInt(t.slice(8,12),16),l=parseInt(t.slice(12,16),16),h=parseInt(t.slice(16,18),16),c=1===parseInt(t.slice(18,20),16),u=1===parseInt(t.slice(20,22),16),d=parseInt(t.slice(22,24),16),p=parseInt(t.slice(24,26),16),f=1===parseInt(t.slice(26,28),16),g=parseInt(t.slice(28,30),16),m=parseInt(t.slice(52,54),16),_=t.slice(54,54+2*m),y=m>0?Jg(_):"";s+=2*(47+4*parseInt(t.slice(92,94),16));let x=im(i.toString(2),am[e].typeMap.sweep);r.push({roomId:i,pointHex:x,name:y,order:o,suction:d,cistern:p,colorOrder:h,sweepTimes:a,mopTimes:l,sweepForbidden:c,mopForbidden:u,yMop:f,floorMaterial:g,originStr:t,reservedStr:t.slice(30,52)})}return r})(c,a),m=new Map;return f.forEach((t,e)=>{t.length>0&&m.set(e,new Uint32Array(t))}),{mapRooms:g,mapPointsStr:h,parsed:{obstacles:new Uint32Array(d),carpet:new Uint32Array(p),rooms:m,width:i,height:n,totalPixels:u}}},fm=t=>{try{return JSON.parse(Qg(t))}catch(e){return console.error(e),{}}},gm=t=>{try{if(!t)return console.error("<ray-robot-protocol> decodeMap: map data is empty"),null;let e=nm(t);return{mapHeader:e,mapData:pm(t,e)}}catch(e){return console.error("<ray-robot-protocol> decodeMap:",e),null}},mm={"00":"common",10:"charge","01":"transitions",11:"mop"},_m=t=>{let e=t.slice(0,26);return{version:parseInt(e.slice(0,2),16),pathId:parseInt(e.slice(2,6),16),initFlag:parseInt(e.slice(6,8),16),type:parseInt(e.slice(8,10),16),count:parseInt(e.slice(10,18),16),direction:parseInt(e.slice(18,22),16),dataLengthAfterCompress:parseInt(e.slice(22,26),16)}},ym=(t,e)=>{let{dataLengthAfterCompress:i,count:n}=e,r=[];if(i>0){let e=4*n,i=tm(t.slice(26)),s=hm(i,e);if(!s)return[];let o=Array.from(s);for(let t=0;t<o.length;t+=4){let e=$g(o[t],o[t+1]),i=$g(o[t+2],o[t+3]);r.push([e,i])}}else r=function(t,e){e=void 0===e?1:Vf(fp(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var n=0,r=0,s=Array(Nf(i/e));n<i;)s[r++]=zf(t,n,n+=e);return s}(tm(t.slice(26),2),2);let s=[];for(let o=0;o<r.length;o++){let[t,e]=r[o],i=`${1&t}${1&e}`;s.push({x:Kg(1,-2&t),y:-Kg(1,-2&e),type:mm[i]})}return s},xm=t=>{let e=_m(t);return{pathHeader:e,pathPoints:ym(t,e)}};const bm=Object.freeze(Object.defineProperty({__proto__:null,BITMAP_TYPE_HEX_MAP:rm,BITMAP_TYPE_MAP:sm,BITMAP_TYPE_MAP_V2:om,MAP_VERSION_MAP:am,PATH_HEADER_LENGTH:13,PATH_POINT_TYPE_MAP:mm,SPECIAL_ROOM_IDS:lm,combineTwoBinaryToHex:im,dealPL:qg,decodeMap:gm,decodeMapData:pm,decodeMapHeader:nm,decodeMapStructured:fm,decodePath:xm,decodePathData:ym,decodePathHeader:_m,hexStringToNumber:tm,hexToUTF8:Qg,hexToUriDecodedString:Jg,highLowToInt:$g,scaleNumber:Zg,transformChargeXY:em,transformXY:Kg},Symbol.toStringTag,{value:"Module"}));const vm={log(t,...e){console.log(`%c[ray-2d-laser-map-sdk]%c ${t}`,"background: #2196F3; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #2196F3;",...e)},warn(t,...e){console.warn(`%c[ray-2d-laser-map-sdk]%c ${t}`,"background: #FF9800; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #FF9800;",...e)},error(t,...e){console.error(`%c[ray-2d-laser-map-sdk]%c ${t}`,"background: #F44336; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #F44336;",...e)},debug(t,...e){console.log(`%c[ray-2d-laser-map-sdk:DEBUG]%c ${t}`,"background: #9C27B0; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #9C27B0;",...e)},success(t,...e){console.log(`%c[ray-2d-laser-map-sdk]%c ${t}`,"background: #4CAF50; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;","color: #4CAF50;",...e)}},wm=t=>{if(t.length<=1)return[...t];const e=Sm(t),i=e.slice(1).map((t,i)=>({prev:e[i],current:t})),n=new Map;return i.forEach(({prev:t,current:e})=>{Am(t,e).forEach(t=>{const e=`${t.x},${t.y}`;n.has(e)||n.set(e,t)})}),Array.from(n.values())},Sm=t=>{if(t.length<=1)return[...t];const e=t[0],i=t[t.length-1];return e.x===i.x&&e.y===i.y?[...t]:[...t,e]},Am=(t,e)=>{const i=[],n=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y),s=t.x<e.x?1:-1,o=t.y<e.y?1:-1;let a=n-r,l=t.x,h=t.y;for(;i.push({x:l,y:h}),l!==e.x||h!==e.y;){const t=2*a;t>-r&&(a-=r,l+=s),t<n&&(a+=n,h+=o)}return i},Tm=(t,e)=>{let i=0,n=t.length-1;for(;i<=n;){const r=Math.floor((i+n)/2),s=t[r];if(s===e)return!0;s<e?i=r+1:n=r-1}return!1},Cm=(t,e,i,n,r,s=8)=>{const o={x:(e+n)/2,y:(i+r)/2},a=n-e,l=r-i,h=Math.min(s,.2*Math.min(a,l));if(Rm(o,t)){if(Mm(o,t)>=h)return o}return Pm(t,o,h)},Pm=(t,e,i)=>{const{minX:n,minY:r,maxX:s,maxY:o}=km(t),a=s-n,l=o-r,h=e.x,c=e.y,u=Math.min(.5,.05*Math.min(a,l)),d=[];if(Rm({x:h,y:c},t)){const e=Mm({x:h,y:c},t);d.push({point:{x:h,y:c},distance:e,centerDistance:0})}const p=.6*Math.max(a,l),f=Math.PI/16;for(let g=u;g<=p;g+=u){const e=f*(1+g/p);for(let a=0;a<2*Math.PI;a+=e){const e=h+g*Math.cos(a),l=c+g*Math.sin(a);if(e>=n&&e<=s&&l>=r&&l<=o){const n={x:e,y:l};if(Rm(n,t)){const r=Mm(n,t),s=Um({x:e,y:l},{x:h,y:c});r>=i&&d.push({point:n,distance:r,centerDistance:s})}}}if(d.length>=15)break}if(d.length>0){const t=d.map(t=>__spreadProps(__spreadValues({},t),{score:1.5*t.distance-.5*t.centerDistance}));return t.sort((t,e)=>e.score-t.score),t[0].point}if(0===d.length){let e={x:h,y:c},i=0;const a=2*u;for(let l=n;l<=s;l+=a)for(let n=r;n<=o;n+=a){const r={x:l,y:n};if(Rm(r,t)){const n=Mm(r,t);n>i&&(i=n,e=r)}}return e}return{x:h,y:c}},Mm=(t,e)=>{let i=1/0;for(let n=0,r=e.length-1;n<e.length;r=n++){const s=e[r],o=e[n],a=Em(t,s,o);i=Math.min(i,a)}return i},Em=(t,e,i)=>{const n=__pow(e.x-i.x,2)+__pow(e.y-i.y,2);if(0===n)return Um(t,e);const r=Math.max(0,Math.min(1,((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/n)),s=e.x+r*(i.x-e.x),o=e.y+r*(i.y-e.y);return Um(t,{x:s,y:o})},Rm=(t,e,i=!1)=>{if(e.length<3)return!1;if(i&&Bm(t,e))return!0;let n=!1;for(let r=0,s=e.length-1;r<e.length;s=r++){const i=e[r].x,o=e[r].y,a=e[s].x,l=e[s].y;o>t.y!=l>t.y&&t.x<(a-i)*(t.y-o)/(l-o)+i&&(n=!n)}return n},Bm=(t,e)=>{if(e.length<2)return!1;for(let i=0;i<e.length;i++){const n=(i+1)%e.length;if(Fm(t,e[i],e[n]))return!0}return!1},Fm=(t,e,i,n=.5)=>{if(Em(t,e,i)>n)return!1;const r=Math.min(e.x,i.x)-n,s=Math.max(e.x,i.x)+n,o=Math.min(e.y,i.y)-n,a=Math.max(e.y,i.y)+n;return t.x>=r&&t.x<=s&&t.y>=o&&t.y<=a},km=t=>{if(0===t.length)return{minX:0,minY:0,maxX:0,maxY:0};let e=1/0,i=1/0,n=-1/0,r=-1/0;for(const s of t)e=Math.min(e,s.x),i=Math.min(i,s.y),n=Math.max(n,s.x),r=Math.max(r,s.y);return{minX:e,minY:i,maxX:n,maxY:r}},Im=t=>{const e=t.reduce((t,e)=>({x:t.x+e.x,y:t.y+e.y}),{x:0,y:0});return{x:e.x/t.length,y:e.y/t.length}},Dm=t=>{if(4!==t.length)return t;const e=Im(t),i=Um(t[0],t[1]),n=Um(t[1],t[2]),r=Math.atan2(t[1].y-t[0].y,t[1].x-t[0].x),s=[{x:-i/2,y:-n/2},{x:i/2,y:-n/2},{x:i/2,y:n/2},{x:-i/2,y:n/2}],o=Math.cos(r),a=Math.sin(r);return s.map(t=>({x:t.x*o-t.y*a+e.x,y:t.x*a+t.y*o+e.y}))},Om=(t,e,i,n=10)=>{if(0===i)return 1;const r=(t.x*e.x+t.y*e.y)/i/i,s=n/i;return r<=0?s:Math.max(r,s)},Um=(t,e)=>{const i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},Gm=t=>Math.sqrt(t.x*t.x+t.y*t.y),Lm=(t,e)=>({x:e.x-t.x,y:e.y-t.y}),zm=t=>{const e=Gm(t);return 0===e?{x:0,y:0}:{x:t.x/e,y:t.y/e}},Nm=(t,e)=>{const i=Lm(t,e);return zm(i)},Vm=t=>({x:-t.y,y:t.x}),Hm=(t,e)=>{const i=Nm(t,e);return Vm(i)},Wm=(t,e)=>{const i=zm(t),n=zm(e),r={x:(i.x+n.x)/2,y:(i.y+n.y)/2};return zm(r)},jm=(t,e)=>{const i=Lm(t,e);let n=Math.atan2(i.y,i.x);return(n>Math.PI/2||n<-Math.PI/2)&&(n+=Math.PI),n},Ym=(t,e,i)=>t.map(t=>((t,e,i)=>{const n=Math.cos(i),r=Math.sin(i),s=t.x-e.x,o=t.y-e.y;return{x:s*n-o*r+e.x,y:s*r+o*n+e.y}})(t,e,i)),Xm=(t,e,i)=>{if(0===Um(t,e))return[];const n=Hm(t,e),r=i/2;return[t.x+n.x*r,t.y+n.y*r,e.x+n.x*r,e.y+n.y*r,e.x-n.x*r,e.y-n.y*r,t.x-n.x*r,t.y-n.y*r]},Zm=(t,e,i,n)=>{const r=Lm(t,e),s=Lm(t,i),o=Wm(r,s),a=-o.x,l=-o.y;return{x:t.x+a*n,y:t.y+l*n}},qm=(t,e)=>{let i=0,n=0;for(let r=0;r<t.length;r++){const s=t[r];i+=s%e,n+=Math.floor(s/e)}return{x:i/t.length,y:n/t.length}},$m=(t,e,i,n,r,s,o)=>{const a={x:n-10,y:t.y},l={x:s+10,y:t.y},h={x:s,y:r},c={x:s,y:o},u=Km(a,l,{x:n,y:r},{x:n,y:o}),d=Km(a,l,h,c);if(!u||!d)return null;const p=[],f=Math.max(n,Math.min(u.x,d.x)),g=Math.min(s,Math.max(u.x,d.x)),m=Math.round(t.y);for(let _=Math.round(f);_<=Math.round(g);_++){const t=m*i+_;e.has(t)&&p.push({x:_,y:m})}if(p.length>=2){const t=Qm(p),n={x:(t.min.x+t.max.x)/2,y:(t.min.y+t.max.y)/2},r=Math.round(n.y)*i+Math.round(n.x);if(e.has(r))return n}return null},Km=(t,e,i,n)=>{const r=(t.x-i.x)*(e.y-i.y)-(t.y-i.y)*(e.x-i.x),s=(t.x-n.x)*(e.y-n.y)-(t.y-n.y)*(e.x-n.x);if(r*s>=0)return null;const o=(i.x-t.x)*(n.y-t.y)-(i.y-t.y)*(n.x-t.x);if(o*(o+r-s)>=0)return null;const a=o/(s-r),l=a*(e.x-t.x),h=a*(e.y-t.y);return{x:t.x+l,y:t.y+h}},Qm=t=>{if(!t||0===t.length)return{min:{x:0,y:0},max:{x:0,y:0}};let e=t[0],i=t[0];const n=t=>t.x-t.y;for(let r=1;r<t.length;r++){const s=t[r];n(s)<n(e)&&(e=s),n(s)>n(i)&&(i=s)}return{min:e,max:i}},Jm=(t,e)=>({minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}),t_=(t,e,i,n,r)=>t.x>=e&&t.x<=e+n&&t.y>=i&&t.y<=i+r,e_=(t,e,i,n)=>{const r=i/2;return"horizontal"===n?[{x:t-r,y:e},{x:t+r,y:e}]:[{x:t,y:e-r},{x:t,y:e+r}]},i_=(t,e,i)=>{const n=km(t),r=km(e),s=Math.max(0,Math.max(n.minX,r.minX)-Math.min(n.maxX,r.maxX)),o=Math.max(0,Math.max(n.minY,r.minY)-Math.min(n.maxY,r.maxY));if(s>i||o>i)return!1;let[a,l]=[t,e];e.length>t.length&&([a,l]=[e,t]);const h=Math.max(1,Math.floor(i)),c=new Map;for(const d of a){const t=`${Math.floor(d.x/h)},${Math.floor(d.y/h)}`;c.has(t)||c.set(t,[]),c.get(t).push(d)}const u=i*i;for(const d of l){const t=Math.floor(d.x/h),e=Math.floor(d.y/h);for(let i=-1;i<=1;i++)for(let n=-1;n<=1;n++){const r=`${t+i},${e+n}`,s=c.get(r);if(s)for(const t of s){const e=d.x-t.x,i=d.y-t.y;if(e*e+i*i<=u)return!0}}}return!1},n_=(t,e,i,n)=>{let[r,s]=[t,e];e.length>t.length&&([r,s]=[e,t]);const o=new Set(r),a=n*n;for(let l=0;l<s.length;l++){const t=s[l],e=t%i,r=Math.floor(t/i);for(let s=-n;s<=n;s++)for(let t=-n;t<=n;t++){const n=(r+t)*i+(e+s);if(o.has(n)){if(s*s+t*t<=a)return!0}}}return!1},r_=(t,e)=>{if(t<=1)return!0;if(0===e.length)return!1;const i=Array.from({length:t},(t,e)=>e),n=Array(t).fill(0),r=t=>(i[t]!==t&&(i[t]=r(i[t])),i[t]),s=(t,e)=>{const s=r(t),o=r(e);s!==o&&(n[s]<n[o]?i[s]=o:n[s]>n[o]?i[o]=s:(i[o]=s,n[s]++))};for(const[a,l]of e)s(a,l);const o=r(0);for(let a=1;a<t;a++)if(r(a)!==o)return!1;return!0};class s_ extends xe{constructor(){super(),__publicField(this,"dragStart",null),__publicField(this,"initialTouchDistance",null),__publicField(this,"initialScale",null),__publicField(this,"activeTouches",new Map),__publicField(this,"firstTouchId",null),__publicField(this,"secondTouchId",null),__publicField(this,"zoomFactor",.8),__publicField(this,"scaleMin",.2),__publicField(this,"scaleMax",5),__publicField(this,"originalPosition",{x:0,y:0}),__publicField(this,"targetPosition",{x:0,y:0}),__publicField(this,"centerPosition",{x:0,y:0}),__publicField(this,"originalScale",{x:1,y:1}),__publicField(this,"targetScale",{x:1,y:1}),__publicField(this,"defaultScale",{x:1,y:1}),__publicField(this,"transitionDuration",500),__publicField(this,"transitionStartTime",null),__publicField(this,"initialPinchCenter",null),__publicField(this,"isGestureValid",!0),__publicField(this,"lastTapTime",0),__publicField(this,"doubleTapDelay",300),__publicField(this,"doubleTapZoomFactor",1.5),__publicField(this,"lastTapPosition",null),__publicField(this,"tapDistanceThreshold",20),__publicField(this,"tapDetectionEnabled",!0),__publicField(this,"isGestureHijacked",!1),__publicField(this,"hijackedPointerId",null),__publicField(this,"isHijackPaused",!1),__publicField(this,"interactionGraphics"),__publicField(this,"viewportBounds"),__publicField(this,"boundResetAnimation"),__publicField(this,"debouncedStopWheelRender"),__publicField(this,"interactionState",{isInteracting:!1,isAnimating:!1,interactionTimer:null,renderReasons:new Set}),__publicField(this,"throttledAntiScale"),__publicField(this,"handleGestureHijacked",t=>{this.isGestureHijacked=!0,this.hijackedPointerId=t.pointerId,this.isHijackPaused=!1,this.clearTouches();const e=t.global.x-this.viewportBounds.x,i=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:e,y:i}),this.firstTouchId=t.pointerId,this.dragStart={x:e,y:i}});const t=U_().getApp();this.viewportBounds=t.getViewportBounds(),this.eventMode="static",this.interactionGraphics=new fl,this.interactionGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill({color:"#ffffff",alpha:0}),this.addChild(this.interactionGraphics),this.scaleMax=t.scaleMax,this.scaleMin=t.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=zg(t=>{U_().emitter.emit("antiScale",t)},16,{leading:!0,trailing:!0}),this.boundResetAnimation=this.resetAnimation.bind(this),this.debouncedStopWheelRender=Bg(()=>{t.stopRender("wheel")},300),this.setupInteraction()}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)),U_().emitter.on("gestureHijackStart",this.handleGestureHijacked),document.addEventListener("pointercancel",()=>{this.clearTouches()})}resetPan(t){const e=U_(),i=e.getApp(),n=e.appContainer;null!==this.transitionStartTime&&(i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null);const r=this.centerPosition.x-t.x*n.scale.x,s=this.centerPosition.y-t.y*n.scale.y;this.originalPosition={x:n.x,y:n.y},this.targetPosition={x:r,y:s},this.originalScale={x:n.scale.x,y:n.scale.y},this.targetScale={x:n.scale.x,y:n.scale.y};const o=Math.sqrt(__pow(n.x-r,2)+__pow(n.y-s,2)),a=(l=o,Math.pow(Math.min(1,l/1e3),.5));var l;this.transitionDuration=500+1e3*Math.min(1,Math.pow(a,2)),this.transitionStartTime=i.ticker.lastTime,i.ticker.add(this.boundResetAnimation)}setPanZoom({targetPosition:t,targetScale:e,setCenter:i=!1,setScale:n=!1}={},r=!0){const s=U_(),o=s.getApp(),a=s.appContainer;if(i&&t&&(this.centerPosition={x:t.x,y:t.y},vm.debug("[Interaction] Set center position:",this.centerPosition)),n&&e&&(this.defaultScale={x:e.x,y:e.y},vm.debug("[Interaction] Set scale:",this.defaultScale)),this.originalPosition={x:a.x,y:a.y},this.originalScale={x:a.scale.x,y:a.scale.y},this.targetPosition=t||{x:this.centerPosition.x,y:this.centerPosition.y},this.targetScale=e||this.defaultScale,!r)return a.position.set(this.targetPosition.x,this.targetPosition.y),a.scale.set(this.targetScale.x,this.targetScale.y),this.antiScale(this.targetScale.x),void(null!==this.transitionStartTime&&(o.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null));const l=Math.sqrt(__pow(a.x-this.targetPosition.x,2)+__pow(a.y-this.targetPosition.y,2));var h;var c,u;const d=.8*(h=l,Math.pow(Math.min(1,h/1e3),.5))+.2*(c=a.scale.x,u=this.targetScale.x,Math.pow(Math.min(1,Math.abs(c-u)/Math.abs(-.8)),.5));this.transitionDuration=500+1e3*Math.min(1,Math.pow(d,2)),null!==this.transitionStartTime&&(o.ticker.remove(this.boundResetAnimation),this.interactionState.isAnimating=!1,o.stopRender("animation")),this.interactionState.isAnimating=!0,o.requestRender("animation",!0),this.transitionStartTime=o.ticker.lastTime,o.ticker.add(this.boundResetAnimation)}clearTouches(){const t=U_().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,null!==this.transitionStartTime&&(t.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),this.interactionState.isInteracting=!1,t.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(),U_().emitter.off("gestureHijackStart",this.handleGestureHijacked),super.destroy()}exitGestureHijacked(){null===this.hijackedPointerId||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}pauseGestureHijack(){this.isHijackPaused=!0}resumeGestureHijack(){this.isHijackPaused=!1}antiScale(t){this.throttledAntiScale(t)}resetAnimation(){const t=U_(),e=t.getApp(),i=t.appContainer;if(null===this.transitionStartTime)return;const{targetPosition:n,targetScale:r}=this,s=e.ticker.lastTime,o=Math.min(1,(s-this.transitionStartTime)/this.transitionDuration);if(o>=1)i.position.set(n.x,n.y),i.scale.set(r.x,r.y),this.antiScale(r.x),e.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null,this.interactionState.isAnimating=!1,e.stopRender("animation");else{const t=(a=o)<.5?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1,e=this.originalPosition.x+(n.x-this.originalPosition.x)*t,s=this.originalPosition.y+(n.y-this.originalPosition.y)*t,l=this.originalScale.x+(r.x-this.originalScale.x)*t,h=this.originalScale.y+(r.y-this.originalScale.y)*t;i.position.set(e,s),i.scale.set(l,h),this.antiScale(l)}var a}onWheel(t){const e=U_();if(this.isGestureHijacked)return void vm.warn("⚠️ [onWheel] 被手势劫持阻止执行",{isGestureHijacked:this.isGestureHijacked,hijackedPointerId:this.hijackedPointerId,isHijackPaused:this.isHijackPaused});e.getApp().requestRender("wheel",!0),this.debouncedStopWheelRender();const{scaleMin:i,scaleMax:n}=this,r=e.appContainer;t.preventDefault();const s=t.global.x-this.viewportBounds.x,o=t.global.y-this.viewportBounds.y,a=(s-r.x)/r.scale.x,l=(o-r.y)/r.scale.y,h=t.deltaY>0?.95:1.05;let c=r.scale.x*h,u=r.scale.y*h;c=Math.max(i,Math.min(n,c)),u=Math.max(i,Math.min(n,u));if(!(c!==r.scale.x||u!==r.scale.y))return;const d=s-a*c,p=o-l*u;try{r.scale.set(c,u),r.position.set(d,p),this.antiScale(c)}catch(f){vm.error("❌ [onWheel] 应用缩放时发生错误:",f)}}onPointerDown(t){const e=U_();this.interactionState.isInteracting=!0,e.getApp().requestRender("interaction",!0),this.isGestureHijacked&&(t.pointerId===this.hijackedPointerId||this.isHijackPaused||this.pauseGestureHijack());const i=e.getApp(),n=e.appContainer;null!==this.transitionStartTime&&(i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),this.activeTouches.has(t.pointerId-2)&&this.activeTouches.delete(t.pointerId-2),0===this.activeTouches.size&&(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)&&1===this.activeTouches.size&&(this.isGestureValid=!0);const r=t.global.x-this.viewportBounds.x,s=t.global.y-this.viewportBounds.y;if(this.activeTouches.set(t.pointerId,{x:r,y:s}),1===this.activeTouches.size)this.firstTouchId=t.pointerId,this.dragStart={x:r,y:s};else if(2===this.activeTouches.size){const e=Array.from(this.activeTouches.keys());this.secondTouchId=e.find(t=>t!==this.firstTouchId)||t.pointerId,this.setInitialScaleAndDistance(n),this.tapDetectionEnabled=!1}}onPointerUp(t){const e=U_();if(this.isGestureHijacked){if(t.pointerId===this.hijackedPointerId)return e.emitter.emit("gestureHijackPointerUp",t),void this.exitGestureHijacked();this.isHijackPaused}if(!this.activeTouches.has(t.pointerId))return;const i=null!==this.initialTouchDistance&&null!==this.initialScale;if(this.activeTouches.delete(t.pointerId),i&&1===this.activeTouches.size&&(this.isGestureValid=!1,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null),t.pointerId===this.firstTouchId?(this.firstTouchId=null,this.dragStart=null,0===this.activeTouches.size&&this.tapDetectionEnabled&&this.detectDoubleTap(t)):t.pointerId===this.secondTouchId&&(this.secondTouchId=null),this.isGestureHijacked&&this.isHijackPaused&&1===this.activeTouches.size){Array.from(this.activeTouches.keys())[0]===this.hijackedPointerId&&this.resumeGestureHijack()}0===this.activeTouches.size&&(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=!1,e.getApp().stopRender("interaction"))}detectDoubleTap(t){const e=U_(),{interactionConfig:i}=e;if(!i.enableDoubleTapZoom)return;const n=performance.now(),r={x:t.global.x-this.viewportBounds.x,y:t.global.y-this.viewportBounds.y};n-this.lastTapTime<this.doubleTapDelay&&this.lastTapPosition&&Um(r,this.lastTapPosition)<this.tapDistanceThreshold?(this.handleDoubleTap(r),this.lastTapTime=0,this.lastTapPosition=null):(this.lastTapTime=n,this.lastTapPosition=r)}handleDoubleTap(t){const e=U_(),i=e.getApp(),n=e.appContainer,{scaleMin:r,scaleMax:s,doubleTapZoomFactor:o}=this,a=t.x,l=t.y,h=(a-n.x)/n.scale.x,c=(l-n.y)/n.scale.y;let u=n.scale.x*o,d=n.scale.y*o;u=Math.max(r,Math.min(s,u)),d=Math.max(r,Math.min(s,d)),this.originalPosition={x:n.x,y:n.y},this.originalScale={x:n.scale.x,y:n.scale.y};const p=a-h*u,f=l-c*d;this.targetPosition={x:p,y:f},this.targetScale={x:u,y:d},this.interactionState.isAnimating=!0,i.requestRender("animation",!0),this.transitionDuration=300,this.transitionStartTime=i.ticker.lastTime,i.ticker.add(this.boundResetAnimation)}onPointerMove(t){if(this.isGestureHijacked&&!this.isHijackPaused){if(t.pointerId===this.hijackedPointerId){const e=t.global.x-this.viewportBounds.x,i=t.global.y-this.viewportBounds.y;return this.activeTouches.set(t.pointerId,{x:e,y:i}),void U_().emitter.emit("gestureHijackPointerMove",t)}return}if(!this.activeTouches.has(t.pointerId)||!this.isGestureValid)return;const e=t.global.x-this.viewportBounds.x,i=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:e,y:i}),2===this.activeTouches.size&&null!==this.initialTouchDistance&&null!==this.initialScale&&this.applyPinchZoom(),1!==this.activeTouches.size||null===this.initialTouchDistance&&null===this.initialScale||(this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.secondTouchId=null),1===this.activeTouches.size&&t.pointerId===this.firstTouchId&&null!==this.dragStart&&this.applyPan(t)}applyPan(t){const e=U_(),i=this.activeTouches.get(t.pointerId),n=e.appContainer,{x:r,y:s}=this.dragStart;n.position.set(n.x+i.x-r,n.y+i.y-s),this.dragStart={x:i.x,y:i.y}}applyPinchZoom(){const t=U_().appContainer,e=Array.from(this.activeTouches.values());if(e.length<2||!this.initialTouchDistance||!this.initialScale||!this.initialPinchCenter)return;const i=Um(e[0],e[1]),n={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},r=(n.x-t.position.x)/t.scale.x,s=(n.y-t.position.y)/t.scale.y,o=__pow(i/this.initialTouchDistance,this.zoomFactor),a=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.x*o)),l=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.y*o));t.scale.set(a,l);let h=n.x-r*a,c=n.y-s*l;h+=n.x-this.initialPinchCenter.x,c+=n.y-this.initialPinchCenter.y,t.position.set(h,c),this.antiScale(a),this.initialPinchCenter=n}setInitialScaleAndDistance(t){const e=Array.from(this.activeTouches.values());e.length<2||(this.initialTouchDistance=Um(e[0],e[1]),this.initialScale={x:t.scale.x,y:t.scale.y},this.initialPinchCenter={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2})}}const o_=Symbol(),a_=Object.getPrototypeOf,l_=new WeakMap,h_=t=>(t=>t&&(l_.has(t)?l_.get(t):a_(t)===Object.prototype||a_(t)===Array.prototype))(t)&&t[o_]||null,c_=(t,e=!0)=>{l_.set(t,e)},u_={},d_=t=>"object"==typeof t&&null!==t,p_=(t,e)=>{const i=m_.get(t);if((null==i?void 0:i[0])===e)return i[1];const n=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return c_(n,!0),m_.set(t,[e,n]),Reflect.ownKeys(t).forEach(e=>{if(Object.getOwnPropertyDescriptor(n,e))return;const i=Reflect.get(t,e),{enumerable:r}=Reflect.getOwnPropertyDescriptor(t,e),s={value:i,enumerable:r,configurable:!0};if(g_.has(i))c_(i,!1);else if(f_.has(i)){const[t,e]=f_.get(i);s.value=p_(t,e())}Object.defineProperty(n,e,s)}),Object.preventExtensions(n)},f_=new WeakMap,g_=new WeakSet,m_=new WeakMap,__=[1],y_=new WeakMap;let x_=Object.is,b_=(t,e)=>new Proxy(t,e),v_=t=>d_(t)&&!g_.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer)&&!(t instanceof Promise),w_=p_,S_=(t,e,i,n)=>({deleteProperty(t,e){const r=Reflect.get(t,e);i(e);const s=Reflect.deleteProperty(t,e);return s&&n(["delete",[e],r]),s},set(r,s,o,a){const l=!t()&&Reflect.has(r,s),h=Reflect.get(r,s,a);if(l&&(x_(h,o)||y_.has(o)&&x_(h,y_.get(o))))return!0;i(s),d_(o)&&(o=h_(o)||o);const c=!f_.has(o)&&v_(o)?A_(o):o;return e(s,c),Reflect.set(r,s,c,a),n(["set",[s],o,h]),!0}});function A_(t={}){if(!d_(t))throw new Error("object required");const e=y_.get(t);if(e)return e;let i=__[0];const n=new Set,r=(t,e=++__[0])=>{i!==e&&(s=i=e,n.forEach(i=>i(t,e)))};let s=i;const o=t=>(e,i)=>{const n=[...e];n[1]=[t,...n[1]],r(n,i)},a=new Map;let l=!0;const h=S_(()=>l,(t,e)=>{const i=!g_.has(e)&&f_.get(e);if(i){if("production"!==(u_?"production":void 0)&&a.has(t))throw new Error("prop listener already exists");if(n.size){const e=i[2](o(t));a.set(t,[i,e])}else a.set(t,[i])}},t=>{var e;const i=a.get(t);i&&(a.delete(t),null==(e=i[1])||e.call(i))},r),c=b_(t,h);y_.set(t,c);const u=[t,(t=__[0])=>(s!==t&&(s=t,a.forEach(([e])=>{const n=e[1](t);n>i&&(i=n)})),i),t=>{n.add(t),1===n.size&&a.forEach(([t,e],i)=>{if("production"!==(u_?"production":void 0)&&e)throw new Error("remove already exists");const n=t[2](o(i));a.set(i,[t,n])});return()=>{n.delete(t),0===n.size&&a.forEach(([t,e],i)=>{e&&(e(),a.set(i,[t]))})}}];return f_.set(c,u),Reflect.ownKeys(t).forEach(e=>{const i=Object.getOwnPropertyDescriptor(t,e);"value"in i&&i.writable&&(c[e]=t[e])}),l=!1,c}const T_=""+new URL("robot-C6x7WFAQ.png",document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||document.baseURI).href,C_=""+new URL("sleep-C_YKDk6M.json",document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||document.baseURI).href,P_="system-ui, -apple-system, sans-serif",M_=["#2563b8","#26966b","#7c3fb8","#d97706"],E_={global:{containerTop:"0px",containerLeft:"0px",containerWidth:"100%",containerHeight:"100%",backgroundColor:"#f6f6f6"},map:{autoPaddingPercent:.05,adjacencyThreshold:3,obstacleColor:"#999999",freeColor:"#ebebeb"},room:{colors:{active:["#a8c8f5","#9de5c7","#d4b9f7","#ffd399"],inactive:["#d6e7fc","#d1f4e5","#ece0fb","#fff0d9"],name:[...M_],propertyTheme:[...M_],selectionIndicatorBackground:[...M_],selectionIndicatorIcon:["#ffffff","#ffffff","#ffffff","#ffffff"],[lm.NO_ROOM_DATA]:"#ebebeb",[lm.ROOM_GAP]:"#ebebeb",[lm.OBSTACLE_ROOM]:"#ebebeb",[lm.UNKNOWN_ROOM]:"#ebebeb"},nameLabel:{fontSize:10,fontFamily:P_,fontWeight:"500"},property:{displayOrders:["cleanMode","suction","cistern","cleanTimes"],iconWidth:12,iconHeight:12,foldable:!0,offsetX:0,offsetY:4,iconGap:0,container:{backgroundColor:"#ffffff",paddingVertical:1.5,paddingHorizontal:1.5,borderRadius:16,tailHeight:2,tailWidth:10},suction:{assets:["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","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","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","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","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=="]},cistern:{assets:["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","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=","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgN8g7xBgcECfj6+/zzBQ4swJLwAAAaxJREFUaN7t2lluwzAMBFBq9SLbnfuftigQYD5SZLGpaQPoXWBgiqQdKDYMwzAMw3Wp5dySyVX8yNXEAm5kycy9CabAXG0yc7XJzNUmM1ebzFxtMnPVyczVJzP33mQdVRD132EHHjqsk5TxUE7WRYp4InZJLhFPxWL+Gl7QjPoMkmycK0DCoToySNjabCxxgzW8YTE3E94yeW8s+THveFNUTrD/NB84IWkLTdG9o2ULrGSc4PCGXAESrpEZJO2vDact4gempH1gWsS7g5K2pWkRzzAV7dKiqm0t2k5WGpclbaWpOlRaWOuMy7J4e9ChPWKatGuL1vO/HvTdFeFg9whWfW3CxQj+z2f8Z8G7Y7B+gbRPWpkTHFTtrwiatZ9cVOyEXfuOoFXbW/QlPmLKuCgXO2XRVppmcaUpahc1VfG3LUWX1lLv62AXRO0JU3VoafEsN9cLReVdzCEuNAWcMH3ynQRfzPorr1X8vBTEuTRlvChP5ojzrP+bQAl4QSjmL214oiXrY34Yvc3Wz7xm/Couyfoq8xLvU6tJpBqWPUYgx72Fr2TDMAzDMFzxDf7xFoVjSQNhAAAAAElFTkSuQmCC","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=="]},cleanMode:{assets:["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==","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAYJ+Av0Df7xBwIJBQz68wzE7woAAAAVNJREFUaN7t2d1ugzAMhmHHSUj4Kfj+r3asmxrIClKYlwzpe8446XuQgi0gAAAAgNuIxj4ZqmsI8s1RVSwvnmpyKWzpBMIII4zwWdjQCYQRRhhhhBE+hDDCCCOMMHX/IOzpxG3D0fJeSGHHe0b35VKBntSMUqLTvHlKhFZhGUiLsVu9ecNvENxP9MlkfurtzkRaeml0I89SJpKSIGUM6fBSaCQdVgo99J6YTQ45SjFPGiYpNtaexrofox5SLGgc8iDS5pCNJFX3LpYLnOIKXXvvWuSSRWMktjnkWS5hjZHY5JC9XDTUHYmJqTsSE1YciczcycbMHCRxlvU2vin7Kc4eyJ0klrzeMsBZ2GVhdxw2eiPxTXg+Do8KIzGFuyzMWVhr41vycMjCYxZW+3e5LCxZ2B6Gw0S/Mbjuk3tar3lrDfvXhbWeol2ZL5EAAAAAAOCvfQALwYE8tktFzgAAAABJRU5ErkJggg==","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","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=="]},cleanTimes:{assets:["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==","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="]},cleanOrder:{color:"#ffffff",fontFamily:P_,fontWeight:"400",fontSize:8,gapRight:2}},selectionIndicator:{iconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAANlBMVEUAAAD////////////////////////////////////////////////////////////////////xY8b8AAAAEXRSTlMA3yB/YL9Az5+QEK/vj3BQMNgNE0EAAAEySURBVGje7dnLbsJAFIPhk2RmcoO2ef+X7SJSvaJe2VWF/7UPn1AEC6iUUkoppZRS+q2x9d6XucyN6brbvPRy/TR5ZLiQjzIEFz3LEFz0sLxluKiVIbhoL0Nw0VbC4LrfMVz+jLUumksXXP6Ite7r78y4ceNK3K/20Ybfbes9XLzucZKtyK2VrFXuQvYqdyYXKrcauVG5dZIrlVud3KncOsmlyq2d3KrcGuRa5dbxeHEvctEneQXiuj6L/EYj8wuNzPcama81Mt9qZL7UyHynkflKI/ONRuYLpcxdhcxdjcxcnUxcnfwkrkzWuZDdLmS3C9ntQna7kN0uZLcL2e1CdruQ/S7kf/e7mUDWupDdLmS3C9nvQv77/4LhWmrTddfheppbX6d1H5VSSimllFJ6674BgnCK71i7vw8AAAAASUVORK5CYII=",iconWidth:12,iconHeight:12,containerWidth:16,containerHeight:16,strokeWidth:2,strokeColor:"#ffffff",borderRadius:16,offsetY:4,offsetX:0,tailHeight:2,tailWidth:6},floorType:{assets:["","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAPElEQVR4AezXMQoAMAgDwND//9n2B51EhxNcQ7gtJ7NX0wWiAAECBAgQIECAAAECBAgQWCFQb6G3/Sc7FwAA//+f4+OPAAAABklEQVQDAI04ICFaxIVcAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwAgMAAACTeJdcAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAiSURBVDjLY2hgwA5GJUYliJBYhQMwOAwWF45KDEUJXOkKAA7xNyG+w0wTAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAABgAgMAAAAm4hnjAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAjSURBVDjLY1gFBg4MQMAExGBqlDPKoS0HkuoGjXNGOcOVAwDBxwm1N3ts8gAAAABJRU5ErkJggg=="],opacity:.1,scale:.2}},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}},carpet:{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAOklEQVR4AeySSQoAMAgDp/3/n9v4ABc8eRCSUyAwmgu8xIp9WYGfFpItgBk3OPpW5HAnMxBE0NciwAcAAP//bVPdOAAAAAZJREFUAwDM4hAZDjaEjwAAAABJRU5ErkJggg==",opacity:.5,scale:.2},robot:{icon:{sizeFixed:!1,width:8,height:8,src:T_},speed:0,rotationCorrection:0,sleepAnimation:{jsonSrc:C_,framePrefix:"sleep_",width:16,height:16,sizeFixed:!1,frameCount:96,offsetX:8,offsetY:-8},ringSize:1,ringColor:"rgba(255, 68, 68, 0.2)",ringStrokeWidth:1,ringStrokeColor:"#ffffff",ringStrokeDashed:!0,ringStrokeDashArray:[4,4]},chargingStation:{icon:{sizeFixed:!1,width:8,height:8,src:"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=="},rotationCorrection:0,ringSize:1,ringColor:"rgba(255, 68, 68, 0.2)",ringStrokeWidth:1,ringStrokeColor:"#ffffff",ringStrokeDashed:!0,ringStrokeDashArray:[4,4]},interaction:{zoomRange:{min:.5,max:8},fitMinScale:1,fitMaxScale:4,enableDoubleTapZoom:!0},controls:{iconWrapperWidth:24,iconWrapperHeight:24,iconWrapperBorderRadius:16,iconWidth:12,iconHeight:12,deleteIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAG1BMVEUAAAD////////////////////////////////rTT7CAAAACHRSTlMAgL9g36+fQGFJCmkAAADFSURBVDjL3dS7DcJAEIRhniJ1SIgEBSAqQFRARguEJBTgxJqy7cDeX7ZGmtwX+fbu8+t2d7Pqsb99lqHH617XX6mZr26lrrCkdr58ljTxnTRxsHQZJwfBwXqWhoP1rmfDwfrVFA5mO3Ozm4DHRCwmZDExjwlaDPcYDrYcbDnYcrDlYM/BnoM9b+Jyvnl+tfxh+beA4elIwoGmdAjJlFIxJHIqg1hEuQRzAZ9c+dN6jmB4bj2hcYW2F5omLfe6PMH/0HLXPHpWgenjpk040QAAAABJRU5ErkJggg==",rotateIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAMAAAANIilAAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA32CAIEAQ779wz4+fUDCvilaH/gAAAZdJREFUSMftltuOxCAIhsWiVqst7/+0m5jsEIUqm72d/64M33BSWvfVP9WgzKZ4wqRyayhWojwbMwlVhfVAdAnrIeHmVK/TGWAvfOJDRAn3cGqSLURc8AJOSrcqcdIrGBT26r8EFd4FbsSBN2kDzgUnnsAOJohKwZSiBZ6PQpBG+5xP6gpWGGRgiksYDhGax0TFrWBAVzn03GqqK7igcwgces46L+DSS/IfuHDWopBBvrNdHBrdaAnuRdlH/p8xzfj7fLutkLr4JN+cyV7P535MqQQDzHnff4eRRu+DZ2dQ4Y4N8GGBK3sPa/mxwJnhoWawwG2EAxlnNXpnbqC5Yzg5Jz41VpgHe3LeVpg3hxebLV7HDgZ+Hi1YiNqmYZX339B/hNXlnpvrOTR2dgFfYlnCh66dXcCPGIwnThxoCSd5A4FYSzhwYLZZ4UO7+pcRTupRBBMciLQPFwQLfL68HTDt4fD2Jr4N8Ply91oSaeuBS9SO7BaOoLMHGeCq15tJwppTyk6qGuBG9KC6Hk6Y9ERRGXj31f/0A2zyPsVxnMRtAAAAAElFTkSuQmCC",scaleIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAIVBMVEUAAAD////////////////////////////////////////PIev5AAAACnRSTlMA7zC/QN+fgCAQTQcGNgAAAMRJREFUOMvd0jEKwkAURdFPBEkdsLFKyAYk2UIqO1uXYOUSXIJbCCiCqzTDe8Ei3qmDrz3caebH+7tHLLZ6fvZpHfFYhwaPV8jOiZ0zn5QTd3vlwIdGOXGhnDiUIytHdk7sHNk5sXNi53dg5a9lPQxDHc6vQUu5YlqjmFbGv++W1W2V5ctY5+L534vpt37E89lspr9eaKmzIfbVIfvqzJSbKTdjLsZczLkYczHmrZjyXWLKtaDcTLkZc+K2TzsTH/Xu2vkDlC8AMDsTJN8AAAAASUVORK5CYII=",moveIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAJFBMVEUAAAD///////////////////////////////////////////+0CY3pAAAAC3RSTlMAYIDvMBDPv4+fcLUOqFYAAAEWSURBVDjLvZW9isJAFIXHkLCw1S5ss9ikt00h2ETyAqn0CaxsbHwCSyvfwN7KEUQ8L2dilJPE4Z5GPFXgy5efOzP3um6i1FkZeYtGQGrJgDflSrfkSjdk6kGZekimHpTHwIZ6Xz5Ngb9JWB8C2QD4KYBrAM9wymscT7AI4GSZuRq74ly6QOZ5g+O1C6fBzHvwd9nHSfu20aKPZ75dsHPZxckSKWVg1cVfgG9XO+/iuK485az/7uKpUyamTpmYOmVi6o18+X3kH9g9r7d3PYKRtJKNeIHFw8WniR8TZRFFFUsiFlRsB7mZ9FZ0g9eNvP/AIdIHWB9/3TwObD1H0bhE2xNNU7Rc0bAN3ethoUeNHlR6zIkheQMcOzccp+sDkgAAAABJRU5ErkJggg==",moveButtonOffset:30,textFontSize:12,textFontFamily:P_,textFontWeight:"400",unitLabel:"m",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]}},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:"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",iconSize:8,size:1,strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",textColor:"#5d68fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}}},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},heatmap:{cellSize:2,maxDistance:14,smoothIterations:10,heatmapAlpha:.8,colorGradients:["#FF3B30","#FF7A00","#FFA100","#FFD700","#99DD70","#2EC070","#40E0D0","#88D0E9"]},snapshot:{format:"png",quality:1,antialias:!0,resolution:(null==window?void 0:window.devicePixelRatio)||1}},R_={dividingRoomId:null,enableRoomSelection:!1,editingForbiddenSweepZoneIds:[],editingForbiddenMopZoneIds:[],editingCleanZoneIds:[],editingVirtualWallIds:[],editingSpotIds:[],roomPropertyFoldIds:[],roomSelectionMode:"checkmark",selectRoomIds:[],showRoomProperty:!1,showRoomOrder:!0,showRoomName:!0,showPath:!0,showChargingStation:!0,showRoomFloorType:!0,showCarpet:!0,showChargingStationRing:!1,showRobotRing:!1,showRobotSleepAnimation:!1},B_=["areRoomsAdjacent","getForbiddenSweepZones","getForbiddenMopZones","getCleanZones","getVirtualWalls","getSpots","getViewportCenterPoint","getMapCenterPoint","getWallPointsByViewportCenter","getForbiddenSweepZonePointsByViewportCenter","getForbiddenMopZonePointsByViewportCenter","getCleanZonePointsByViewportCenter","getSpotPointByViewportCenter","getEffectiveDividerPoints","getDividerEndPoints","isPointInAnyRoom","resetPanZoom","snapshot","snapshotByData"],F_=["onMapFirstDrawed","onMapDrawed","onPathDrawed","onRoomPropertiesDrawed","onClickRoom","onClickRoomProperties","onRemoveForbiddenSweepZone","onRemoveForbiddenMopZone","onRemoveCleanZone","onRemoveVirtualWall","onUpdateForbiddenSweepZone","onUpdateForbiddenMopZone","onUpdateCleanZone","onUpdateVirtualWall","onUpdateSpot","onUpdateDivider","onClickForbiddenSweepZone","onClickForbiddenMopZone","onClickCleanZone","onClickVirtualWall","onClickSpot","onClickDetectedObject","onClickCustomElement"],k_="MAIN",I_=5e3;class D_{static registerInstance(t,e){this.instanceMap.set(t,e)}static unregisterInstance(t){this.instanceMap.delete(t)}static getService(){const t=this.useContext();let e=this.serviceCache.get(t);return e||(e=new O_,this.serviceCache.set(t,e)),e}static provide(t,e){this.contextStack.push(t);try{return e()}finally{this.contextStack.pop()}}static provideAsync(t,e){return __async(this,null,function*(){this.contextStack.push(t);try{return yield e()}finally{this.contextStack.pop()}})}static useContext(){const t=this.contextStack[this.contextStack.length-1];if(!t){const t=this.instanceMap.get(k_);if(!t)throw new Error("No MapApplication context found. Make sure you are calling useAppService() within a MapApplication context.");return t}return t}static hasContext(){return this.contextStack.length>0||this.instanceMap.has(k_)}static clear(){this.contextStack.length=0,this.instanceMap.clear()}}__publicField(D_,"contextStack",[]),__publicField(D_,"instanceMap",new Map),__publicField(D_,"serviceCache",new WeakMap);class O_{getApp(){return D_.useContext()}getConfig(){return this.getApp().config}getRoomData(t){return this.getApp().managers.roomsManager.getRoomPropertyById(t)}metersToPixels(t){return this.getApp().metersToPixels(t)}pixelsToMeters(t){return this.getApp().pixelsToMeters(t)}get ticker(){return this.getApp().ticker}get mapState(){return this.getApp().mapState}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 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 runtime(){return this.getApp().runtime}get runtimeSnapshot(){return function(t){const e=f_.get(t);"production"===(u_?"production":void 0)||e||console.warn("Please use proxy object");const[i,n]=e;return w_(i,n())}(this.getApp().runtime)}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}}function U_(){return D_.getService()}class G_ extends xe{constructor(t,e){super(),__publicField(this,"viewportBounds",{x:0,y:0,width:0,height:0}),__publicField(this,"maskGraphics",null),__publicField(this,"containerElement",null),this.containerElement=e||window,this.calculateViewportBounds(t.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),this.createMask()}calculateViewportBounds(t){const{containerTop:e,containerLeft:i,containerWidth:n,containerHeight:r}=t,{width:s,height:o}=this.getContainerSize(),a=this.parseSize(i,s),l=this.parseSize(e,o),h=this.parseSize(n,s),c=this.parseSize(r,o);this.viewportBounds={x:a,y:l,width:h,height:c}}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 fl,this.maskGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215),this.addChild(this.maskGraphics),this.mask=this.maskGraphics}parseSize(t,e){if(!isNaN(Number(t)))return Number(t);if((t=t.trim()).endsWith("%")){return e*(parseFloat(t)/100)}if(t.endsWith("vw")){const e=parseFloat(t)/100;return window.innerWidth*e}if(t.endsWith("vh")){const e=parseFloat(t)/100;return window.innerHeight*e}if(t.endsWith("rpx")){return parseFloat(t)*(window.innerWidth/750)}return t.endsWith("px")||!isNaN(parseFloat(t))?parseFloat(t):(vm.warn(`Cannot parse size value: ${t}`),0)}getViewportBounds(){return __spreadValues({},this.viewportBounds)}updateViewport(t){var e,i;this.calculateViewportBounds(t.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),null==(e=this.maskGraphics)||e.clear(),null==(i=this.maskGraphics)||i.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215)}addContent(t){this.addChild(t)}}const L_="roomFill",z_="free",N_="roomFloorType",V_="carpet",H_="obstacle",W_="heatmap",j_="path",Y_="controls",X_="roomInfo",Z_="detectedObject",q_="customElement",$_="customElementGif",K_="chargingStation",Q_="robot",J_=["interaction",L_,z_,N_,V_,H_,W_,j_,X_,Z_,q_,$_,K_,Q_,Y_];class ty extends xe{constructor(){super(),__publicField(this,"layers",new Map);const t=U_().getApp().getViewportBounds();this.position.set(Math.round(t.width/2),Math.round(t.height/2)),this.initializeLayers()}initializeLayers(){Object.values(J_).forEach(t=>{const e=new xe;e.label=t,t===Y_&&(e.isRenderGroup=!0),t!==N_&&t!==V_||(e.eventMode="none"),this.layers.set(t,e),this.addChild(e)})}getLayer(t){return this.layers.get(t)}addToLayer(t,e,i){const n=this.layers.get(t);return n?(void 0!==i&&(e.zIndex=i),n.addChild(e),!0):(vm.warn("[AppContainer Debug] Layer not found:",t),!1)}removeFromLayer(t,e){const i=this.layers.get(t);return!!i&&(e.parent===i&&(i.removeChild(e),!0))}clearLayer(t){const e=this.layers.get(t);return!!e&&(e.removeChildren(),!0)}setLayerVisibility(t,e){const i=this.layers.get(t);return!!i&&(i.visible=e,!0)}getLayerVisibility(t){const e=this.layers.get(t);return!!e&&e.visible}}class ey extends fl{constructor(){super();U_().appContainer.addToLayer(H_,this)}draw(t){const e=U_();this.clear(),this.setFillStyle({color:e.mapConfig.obstacleColor});for(const i of t){const t=i.coordinates;for(let e=0;e<t.length;e+=2){const i=t[e],n=t[e+1];this.rect(i,n,1,1)}}this.fill()}drawRaster(t,e){const i=U_();if(this.clear(),0!==t.length){this.setFillStyle({color:i.mapConfig.obstacleColor});for(let n=0;n<t.length;n+=I_){const r=Math.min(n+I_,t.length);for(let i=n;i<r;i++){const n=t[i],r=n%e,s=Math.floor(n/e);this.rect(r,s,1,1)}this.fill(),r<t.length&&this.setFillStyle({color:i.mapConfig.obstacleColor})}}}destroy(t){super.destroy(t)}}class iy{constructor(t,e={}){var i,n;__publicField(this,"target"),__publicField(this,"isPointerDown",!1),__publicField(this,"pointerDownPos",null),__publicField(this,"clickThreshold"),__publicField(this,"stopPropagation"),__publicField(this,"clickCallback",null),this.target=t,this.clickThreshold=null!=(i=e.clickThreshold)?i:10,this.stopPropagation=null!=(n=e.stopPropagation)&&n,this.clickCallback=e.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(t){this.stopPropagation&&t.stopPropagation(),this.isPointerDown=!0,this.pointerDownPos={x:t.globalX,y:t.globalY}}handlePointerMove(t){if(this.stopPropagation&&t.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const e=t.globalX-this.pointerDownPos.x,i=t.globalY-this.pointerDownPos.y;Math.sqrt(e*e+i*i)>this.clickThreshold&&(this.isPointerDown=!1,this.pointerDownPos=null)}}handlePointerUp(t){if(this.stopPropagation&&t.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const e=t.globalX-this.pointerDownPos.x,i=t.globalY-this.pointerDownPos.y;Math.sqrt(e*e+i*i)<=this.clickThreshold&&this.clickCallback&&this.clickCallback(t,this.target)}this.isPointerDown=!1,this.pointerDownPos=null}handlePointerUpOutside(){this.isPointerDown=!1,this.pointerDownPos=null}setClickCallback(t){return this.clickCallback=t,this}setClickThreshold(t){return this.clickThreshold=t,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 ny extends xe{constructor(){super({isRenderGroup:!0}),__publicField(this,"roomGraphicsMap",new Map),__publicField(this,"roomContextMap",new Map),__publicField(this,"roomClickHandlerMap",new Map),__publicField(this,"unsubscribeFns",[]),__publicField(this,"mapWidth",0),__publicField(this,"rasterRoomDataMap",new Map);U_().appContainer.addToLayer(L_,this)}draw(t){const e=U_();this.clearRooms();const i=e.roomConfig,{selectRoomIds:n,enableRoomSelection:r}=e.runtimeSnapshot;t.forEach(t=>{var e;const s=t.id>=255,o=new fl,a=new Do,l=new Do;if(s)a.setFillStyle({color:t.color}),l.setFillStyle({color:t.color});else{const n=null!=(e=t.colorIndex)?e:0,r=i.colors.active[n%i.colors.active.length],s=i.colors.inactive[n%i.colors.inactive.length];a.setFillStyle({color:r}),l.setFillStyle({color:s})}if(a.poly(t.polyPoints).fill(),l.poly(t.polyPoints).fill(),t.outlinePoints.forEach(t=>{a.rect(t.x,t.y,1,1).fill(),l.rect(t.x,t.y,1,1).fill()}),o.context=s?a:r&&!n.includes(t.id)?l:a,!s){const e=new iy(o,{clickThreshold:10,onClick:()=>{this.handleRoomClick(t.id)}});this.roomClickHandlerMap.set(t.id,e)}this.roomGraphicsMap.set(t.id,o),this.roomContextMap.set(t.id,{activeContext:a,inactiveContext:l}),this.addChild(o)})}drawRaster(t){const e=U_();if(this.clearRooms(),this.mapWidth=t.width,0===t.sortedRooms.length)return;const{selectRoomIds:i,enableRoomSelection:n}=e.runtimeSnapshot;t.sortedRooms.forEach(t=>{this.drawRasterRoom(t,n,i)})}drawRasterRoom(t,e,i){const{roomId:n,pixelIndices:r,activeColor:s,inactiveColor:o}=t,a=new fl,l=new Do,h=new Do;l.setFillStyle({color:s}),h.setFillStyle({color:o}),this.drawPixelPointsInBatches(l,r,I_,this.mapWidth),this.drawPixelPointsInBatches(h,r,I_,this.mapWidth);const c="number"==typeof n,u=!e||c&&i.includes(n);if(a.context=e&&c&&!u?h:l,c){const t=new iy(a,{clickThreshold:10,onClick:()=>{this.handleRoomClick(n)}});this.roomClickHandlerMap.set(n,t)}this.roomGraphicsMap.set(n,a),this.roomContextMap.set(n,{activeContext:l,inactiveContext:h}),this.rasterRoomDataMap.set(n,t),this.addChild(a)}drawPixelPointsInBatches(t,e,i,n){for(let r=0;r<e.length;r+=i){const s=Math.min(r+i,e.length);for(let i=r;i<s;i++){const r=e[i],s=r%n,o=Math.floor(r/n);t.rect(s,o,1,1)}t.fill()}}handleRoomClick(t){var e,i,n;const r=U_();null==(n=null==(e=r.events)?void 0:e.onClickRoom)||n.call(e,null!=(i=r.getRoomData(t))?i:{id:t})}setRoomStateBySelectIds(t){const e=U_(),{enableRoomSelection:i}=e.runtimeSnapshot;this.roomGraphicsMap.forEach((e,n)=>{if("number"==typeof n){const r=!i||t.includes(n),s=this.roomContextMap.get(n);s&&(e.context=r?s.activeContext:s.inactiveContext)}})}setRoomState(t,e){const i=this.roomGraphicsMap.get(t),n=this.roomContextMap.get(t);i&&n?"number"==typeof t&&(i.context=e?n.activeContext:n.inactiveContext):vm.warn(`Room ${t} not found`)}setAllRoomsState(t){this.roomGraphicsMap.forEach((e,i)=>{"number"==typeof i&&this.setRoomState(i,t)})}getRoomGraphicsMap(){const t=new Map;return this.roomGraphicsMap.forEach((e,i)=>{"number"==typeof i&&t.set(i,e)}),t}getRasterRoomData(t){return this.rasterRoomDataMap.get(t)||null}getMapWidth(){return this.mapWidth}clearRooms(){0===this.children.length&&0===this.roomGraphicsMap.size||(this.removeChildren(),this.roomClickHandlerMap.forEach(t=>{try{t.destroy()}catch(e){vm.warn("Error destroying click handler:",e)}}),this.roomClickHandlerMap.clear(),this.roomGraphicsMap.clear(),this.roomContextMap.clear(),this.rasterRoomDataMap.clear())}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.clearRooms(),super.destroy()}}class ry extends xe{constructor(){super({isRenderGroup:!0}),__publicField(this,"carpetSprite",null),__publicField(this,"carpetMask",null);U_().appContainer.addToLayer(V_,this)}createCarpetFromRasterData(t,e){return __async(this,null,function*(){const i=U_();if(!i.runtimeSnapshot.showCarpet)return;if(this.clearCarpet(),0===t.length)return;const{src:n,opacity:r,scale:s}=i.carpetConfig,o=yield Ya.load(n);if(!o)return void vm.warn(`Carpet texture not found: ${n}`);const a=this.createCarpetGraphics(t,e),l=a.getLocalBounds();if(0===l.width||0===l.height)return;const h=new vl({texture:o,width:l.width,height:l.height});h.x=l.x,h.y=l.y,h.alpha=r,h.tileScale.set(s);const c=new xe;c.addChild(a),h.mask=c,this.addChild(h),this.carpetSprite=h,this.carpetMask=c,i.getApp().renderOnceNextFrame()})}createCarpetGraphics(t,e){const i=new fl;for(let n=0;n<t.length;n++){const r=t[n],s=r%e,o=Math.floor(r/e);i.rect(s,o,1,1)}return i.fill(16777215),i}clearCarpet(){if(this.carpetSprite){try{this.removeChild(this.carpetSprite),this.carpetSprite.destroy()}catch(t){vm.warn("Error destroying carpet sprite:",t)}this.carpetSprite=null}if(this.carpetMask){try{this.carpetMask.destroy()}catch(t){vm.warn("Error destroying carpet mask:",t)}this.carpetMask=null}}createCarpetFromStructuredData(t){return __async(this,null,function*(){const e=U_();if(!e.runtimeSnapshot.showCarpet)return;if(this.clearCarpet(),0===t.length)return;const{src:i,opacity:n,scale:r}=e.carpetConfig,s=yield Ya.load(i);if(!s)return void vm.warn(`Carpet texture not found: ${i}`);const o=this.createCarpetGraphicsFromStructuredData(t),a=o.getLocalBounds();if(0===a.width||0===a.height)return;const l=new vl({texture:s,width:a.width,height:a.height});l.x=a.x,l.y=a.y,l.alpha=n,l.tileScale.set(r);const h=new xe;h.addChild(o),l.mask=h,this.addChild(l),this.carpetSprite=l,this.carpetMask=h,e.getApp().renderOnceNextFrame()})}createCarpetGraphicsFromStructuredData(t){const e=new fl;for(const i of t){const t=i.coordinates;for(let i=0;i<t.length;i+=2){const n=t[i],r=t[i+1];e.rect(n,r,1,1)}}return e.fill(16777215),e}destroy(){this.clearCarpet(),super.destroy()}}class sy extends fl{constructor(){super();U_().appContainer.addToLayer(z_,this)}draw(t){const e=U_();this.clear(),this.setFillStyle({color:e.mapConfig.freeColor});for(const i of t){const t=i.coordinates;for(let e=0;e<t.length;e+=2){const i=t[e],n=t[e+1];this.rect(i,n,1,1)}}this.fill()}destroy(t){super.destroy(t)}}class oy extends ve{constructor(t){super(t),__publicField(this,"throttledUpdateScale"),__publicField(this,"fixedWidth",0),__publicField(this,"fixedHeight",0),__publicField(this,"isFixedSizeSet",!1),__publicField(this,"sizeFixed",!0),__publicField(this,"baselineScale",1),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=zg(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,(t&&this.isFixedSizeSet||!t&&this.isFixedSizeSet)&&this.applySize()}set width(t){this.isFixedSizeSet?vm.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置宽度"):this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet?vm.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置高度"):this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){U_().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||0===this.texture.width||0===this.texture.height)return;const t=U_(),e=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const n=t.currentScale;if(0===n)return;const r=e/n,s=i/n;super.scale.set(r,s)}else super.scale.set(e/this.baselineScale,i/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():0!==t&&super.scale.set(1/t))}loadTextureAndSetSize(t,e){return __async(this,null,function*(){try{const i=U_(),n=yield Ya.load(t);this.texture=n,void 0!==e.sizeFixed&&this.setSizeFixed(e.sizeFixed),this.setFixedSize(e.width,e.height),i.getApp().renderOnceNextFrame()}catch(i){vm.error(`Failed to load texture "${t}":`,i)}})}draw(t,e){const{x:i,y:n,rotation:r=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=r,this.position.set(i,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){U_().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class ay extends oy{constructor(){super(),this.initializeSprite()}initializeSprite(){return __async(this,null,function*(){const t=U_();yield this.loadTextureAndSetSize("chargingStation",t.chargingStationConfig.icon)})}draw(t){return __async(this,arguments,function*({x:t,y:e,rotation:i}){const n=U_();__superGet(ay.prototype,this,"draw").call(this,{x:t,y:e,rotation:i},()=>n.runtimeSnapshot.showChargingStation)})}}function ly(t,e,i,n){let r=t[e];return function(t,e){const i=f_.get(t);let n;"production"===(u_?"production":void 0)||i||console.warn("Please use proxy object");const r=[],s=i[2];let o=!1;const a=s(t=>{r.push(t),n||(n=Promise.resolve().then(()=>{n=void 0,o&&e(r.splice(0))}))});return o=!0,()=>{o=!1,a()}}(t,()=>{const n=t[e];Object.is(r,n)||i(r=n)})}class hy extends fl{constructor(t){super(),__publicField(this,"currentPosition",null),__publicField(this,"config"),__publicField(this,"handleScaleChange",()=>{this.redraw()}),this.setupAntiScaleListener(),this.config=t.config}setupAntiScaleListener(){U_().emitter.on("antiScale",this.handleScaleChange)}draw(t){const e=U_();this.currentPosition=t;const{ringSize:i,ringColor:n,ringStrokeWidth:r,ringStrokeColor:s,ringStrokeDashed:o,ringStrokeDashArray:a}=this.config;this.clear();const l=e.metersToPixels(i),h=e.getApp().toFixedSize(r);this.setFillStyle({color:n}),o&&a.length>=2?this.drawDashedCircle(t,l,s,h,a):this.circle(t.x,t.y,l).fill().stroke({color:s,width:h,cap:"round",join:"round"})}drawDashedCircle(t,e,i,n,r){const s=U_();this.circle(t.x,t.y,e).fill();const o=s.getApp().toFixedSize(r[0]),a=s.getApp().toFixedSize(r[1]),l=2*Math.PI*e,h=o+a,c=Math.floor(l/h);if(0===c)return void this.circle(t.x,t.y,e).stroke({color:i,width:n,cap:"round",join:"round"});const u=l/c,d=u*(o/h);for(let p=0;p<c;p++){const i=p*u/e,n=(p*u+d)/e,r=Math.max(4,Math.ceil(Math.abs(n-i)*e/2)),s=(n-i)/r;for(let o=0;o<=r;o++){const n=i+s*o,r=t.x+e*Math.cos(n),a=t.y+e*Math.sin(n);0===o?this.moveTo(r,a):this.lineTo(r,a)}}this.stroke({color:i,width:n,cap:"round",join:"round"})}redraw(){this.currentPosition&&this.draw(this.currentPosition)}destroy(){U_().emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class cy extends xe{constructor(){super(),__publicField(this,"chargingStation"),__publicField(this,"ring"),__publicField(this,"unsubscribeFns",[]);const t=U_();t.appContainer.addToLayer(K_,this),this.ring=new hy({config:t.chargingStationConfig}),this.ring.visible=t.runtimeSnapshot.showChargingStationRing,this.addChild(this.ring),this.chargingStation=new ay,this.addChild(this.chargingStation);const e=ly(t.runtime,"showChargingStationRing",t=>{vm.log(`[runtime] showChargingStationRing: ${t}`),this.ring.visible=t});this.unsubscribeFns.push(e)}draw(t){return __async(this,arguments,function*({x:t,y:e,rotation:i}){0===t&&0===e||(this.ring.draw({x:t,y:e}),yield this.chargingStation.draw({x:t,y:e,rotation:i}))})}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.ring.destroy(),super.destroy()}}class uy{constructor(){__publicField(this,"obstacle",new ey),__publicField(this,"free",new sy),__publicField(this,"roomFill",new ny),__publicField(this,"carpet",new ry),__publicField(this,"chargingStation",new cy),__publicField(this,"mapBounds",{minX:0,minY:0,maxX:0,maxY:0}),__publicField(this,"lastMapId",null),__publicField(this,"roomGeometryMap",new Map),__publicField(this,"rasterRoomPixelsMap",new Map),__publicField(this,"fourColorCache",null),__publicField(this,"carpetData",null),__publicField(this,"unsubscribeFns",[]);const t=U_();this.validateColorConfig();const e=ly(t.runtime,"enableRoomSelection",e=>{if(vm.log(`[runtime] enableRoomSelection: ${e}`),e){this.roomFill.setAllRoomsState(!1);const e=t.runtimeSnapshot.selectRoomIds;this.roomFill.setRoomStateBySelectIds(e)}else this.roomFill.setAllRoomsState(!0)}),i=ly(t.runtime,"selectRoomIds",t=>{vm.log(`[runtime] selectRoomIds: ${t}`),this.roomFill.setRoomStateBySelectIds(t)}),n=ly(t.runtime,"showChargingStation",t=>{vm.log(`[runtime] showChargingStation: ${t}`),this.chargingStation.visible=t}),r=ly(t.runtime,"showCarpet",t=>{vm.log(`[runtime] showCarpet: ${t}`),t?this.createCarpet():this.carpet.clearCarpet()});this.unsubscribeFns.push(e,i,n,r)}drawMap(t){return __async(this,null,function*(){var e;const i=U_(),{id:n,obstacles:r,free:s,rooms:o,charger:a,carpet:l}=t;this.clearComponents(),this.resetGeometryData();const h=this.processRoomsGeometry(o);this.roomFill.draw(h),this.free.draw(s),this.obstacle.draw(r),this.carpetData={type:"structured",carpetData:l},this.createCarpet();const c=this.mergeLayerBounds();Ug(c,this.mapBounds)||(vm.debug("[Map] Map bounds updated:",c),this.mapBounds=c,this.lastMapId!==n&&(i.getApp().fitMapToView(this.mapBounds),this.lastMapId=n));const u=((null!=(e=t.charger.angle)?e:0)+i.chargingStationConfig.rotationCorrection)*Math.PI/180;return yield this.chargingStation.draw({x:a.coordinate[0],y:a.coordinate[1],rotation:u}),i.roomsManager.refresh(),!0})}drawRasterMap(t,e){return __async(this,null,function*(){const i=U_();this.clearComponents();const{id:n,width:r,height:s,charger:o,chargerDirection:a}=e;vm.debug("[Map] Parsed Raster Map Data",t),this.obstacle.drawRaster(t.obstacles,r),this.carpetData={type:"raster",carpetPixels:t.carpet,mapWidth:r},this.createCarpet();const l=this.processRasterData(t);this.roomFill.drawRaster(l);const h=((t,e,i)=>{let n=1/0,r=1/0,s=-1/0,o=-1/0;for(let a=0;a<t.obstacles.length;a++){const i=t.obstacles[a],l=i%e,h=Math.floor(i/e);n=Math.min(n,l),r=Math.min(r,h),s=Math.max(s,l),o=Math.max(o,h)}return t.rooms.forEach(t=>{for(let i=0;i<t.length;i++){const a=t[i],l=a%e,h=Math.floor(a/e);n=Math.min(n,l),r=Math.min(r,h),s=Math.max(s,l),o=Math.max(o,h)}}),n===1/0?{minX:0,minY:0,maxX:e,maxY:i}:{minX:Math.max(0,n),minY:Math.max(0,r),maxX:Math.min(e,s),maxY:Math.min(i,o)}})(t,r,s);Ug(h,this.mapBounds)||(vm.debug("[Map] Raster map bounds updated:",h),this.mapBounds=h,this.lastMapId!==n&&(i.getApp().fitMapToView(this.mapBounds),this.lastMapId=n));const c=(a+i.chargingStationConfig.rotationCorrection)*Math.PI/180;return yield this.chargingStation.draw({x:o.x,y:o.y,rotation:c}),this.generateRoomGeometryFromRaster(t),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}}createCarpet(){return __async(this,null,function*(){if(U_().runtimeSnapshot.showCarpet&&this.carpetData)if("raster"===this.carpetData.type){const{carpetPixels:t,mapWidth:e}=this.carpetData;yield this.carpet.createCarpetFromRasterData(t,e)}else if("structured"===this.carpetData.type){const{carpetData:t}=this.carpetData;yield this.carpet.createCarpetFromStructuredData(t)}})}processRoomsGeometry(t){if(!t)return[];const e=U_(),{active:i}=e.roomConfig.colors,n=e.roomConfig.colors[lm.UNKNOWN_ROOM];if(0===Object.keys(t).length)return this.mapBounds={minX:0,minY:0,maxX:0,maxY:0},[];const r=Object.keys(t).sort((t,e)=>Number(t)-Number(e)),s=r.filter(t=>Number(t)<255),o=r.filter(t=>Number(t)>=255),a=[],l=[];s.forEach(e=>{const{coordinates:i}=t[e];if(i.length<4)return;const n=Number(e);let r=1/0,s=1/0,o=-1/0,a=-1/0;const h=[];for(let t=0;t<i.length;t+=2){const e=i[t],n=i[t+1];r=Math.min(r,e),s=Math.min(s,n),o=Math.max(o,e),a=Math.max(a,n),h.push({x:e,y:n})}const c=new D(r,s,o-r+1,a-s+1),u=wm(h),d=u.flatMap(t=>[t.x+.5,t.y+.5]),p=Cm(u,r,s,o,a);l.push({id:n,points:h,outlinePoints:u,polyPoints:d,centerPoint:p,boundingBox:c}),this.mapBounds.minX=Math.min(this.mapBounds.minX,r),this.mapBounds.minY=Math.min(this.mapBounds.minY,s),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,o),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,a)});const h=[...l].sort((t,e)=>{const i=t.outlinePoints.length;return e.outlinePoints.length-i}),c=this.assignColorsUsingFourColorAlgorithm(h,i.length,"structured");return l.forEach(t=>{const e=c.get(t.id)||0,n=i[e],r={id:t.id,color:n,colorIndex:e,boundingBox:t.boundingBox,points:t.points,outlinePoints:t.outlinePoints,polyPoints:t.polyPoints,centerPoint:t.centerPoint};this.roomGeometryMap.set(t.id,r),a.push(r)}),o.forEach(e=>{const{coordinates:i}=t[e];if(i.length<4)return;const r=Number(e);let s=1/0,o=1/0,l=-1/0,h=-1/0;const c=[];for(let t=0;t<i.length;t+=2){const e=i[t],n=i[t+1];s=Math.min(s,e),o=Math.min(o,n),l=Math.max(l,e),h=Math.max(h,n),c.push({x:e,y:n})}const u=new D(s,o,l-s+1,h-o+1),d=wm(c),p=d.flatMap(t=>[t.x+.5,t.y+.5]),f=Cm(d,s,o,l,h),g={id:r,color:n,boundingBox:u,points:c,outlinePoints:d,polyPoints:p,centerPoint:f};a.push(g),this.mapBounds.minX=Math.min(this.mapBounds.minX,s),this.mapBounds.minY=Math.min(this.mapBounds.minY,o),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,l),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,h)}),a}mergeLayerBounds(){let t=__spreadValues({},this.mapBounds);if(this.obstacle.bounds&&(t=Jm(t,this.obstacle.bounds)),this.roomFill.children.length>0){const e=this.roomFill.getLocalBounds();e.width>0&&e.height>0&&(t=Jm(t,{minX:e.x,minY:e.y,maxX:e.x+e.width,maxY:e.y+e.height}))}return t}getRoomById(t){return this.roomGeometryMap.get(t)}getAllRooms(){return Array.from(this.roomGeometryMap.values())}clearComponents(){this.obstacle.clear(),this.obstacle.destroy(),this.obstacle=new ey,this.free.clear(),this.free.destroy(),this.free=new sy,this.carpet.clearCarpet(),this.carpetData=null,this.roomFill.removeChildren(),this.roomFill.destroy(),this.roomFill=new ny}processRasterData(t){const e=U_().roomConfig,i=[],n=[];t.rooms.forEach((t,e)=>{"number"==typeof e?i.push([e,t]):n.push([e,t])}),i.sort(([t],[e])=>t-e);const r=i.map(([t,e])=>({id:t,pixels:e})).sort((t,e)=>e.pixels.length-t.pixels.length),s=this.assignColorsUsingFourColorAlgorithm(r,e.colors.active.length,"raster"),o=[...i.map(([t,i])=>{const n=s.get(t)||0;return{roomId:t,pixelIndices:i,activeColor:e.colors.active[n],inactiveColor:e.colors.inactive[n%e.colors.inactive.length],colorIndex:n}}),...n.map(([t,i])=>{const n=e.colors[t]||"#ebebeb";return{roomId:t,pixelIndices:i,activeColor:n,inactiveColor:n}})];return{obstacles:t.obstacles,carpet:t.carpet,sortedRooms:o,width:t.width,height:t.height,totalPixels:t.totalPixels}}generateRoomGeometryFromRaster(t){const e=U_();this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear();const{active:i}=e.roomConfig.colors,n=[];t.rooms.forEach((t,e)=>{"number"==typeof e&&n.push(e)}),n.sort((t,e)=>t-e);const r=[];n.forEach(e=>{const i=t.rooms.get(e);this.rasterRoomPixelsMap.set(e,i);let n=1/0,s=1/0,o=-1/0,a=-1/0;for(let r=0;r<i.length;r++){const e=i[r],l=e%t.width,h=Math.floor(e/t.width);n=Math.min(n,l),s=Math.min(s,h),o=Math.max(o,l),a=Math.max(a,h)}const l=((t,e,i,n,r,s)=>{const o=new Set(t),a=qm(t,e),l=$m(a,o,e,i,n,r,s);return l||a})(i,t.width,n,s,o,a),h=new D(n,s,o-n+1,a-s+1);r.push({id:e,pixelIndices:i,boundingBox:h,centerPoint:l})});const s=[...r].sort((t,e)=>e.pixelIndices.length-t.pixelIndices.length),o=this.assignColorsUsingFourColorAlgorithm(s,i.length,"raster");r.forEach(t=>{const e=o.get(t.id)||0,n=i[e],r={id:t.id,color:n,colorIndex:e,boundingBox:t.boundingBox,points:[],outlinePoints:[],polyPoints:[],centerPoint:t.centerPoint};this.roomGeometryMap.set(t.id,r)})}getRasterRoomPixels(t){return this.rasterRoomPixelsMap.get(t)}validateColorConfig(){const t=U_().roomConfig.colors,e=t.active.length,i=t.inactive.length,n=t.name.length,r=t.propertyTheme.length,s=t.selectionIndicatorBackground.length,o=t.selectionIndicatorIcon.length;e<4&&vm.warn(`[FourColor] room.colors.active requires at least 4 colors for the four-color theorem, but got ${e}. Adjacent rooms may have the same color.`),i!==e&&vm.warn(`[FourColor] room.colors.inactive length (${i}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),n!==e&&vm.warn(`[FourColor] room.colors.name length (${n}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),r!==e&&vm.warn(`[FourColor] room.colors.propertyTheme length (${r}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),s!==e&&vm.warn(`[FourColor] room.colors.selectionIndicatorBackground length (${s}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),o!==e&&vm.warn(`[FourColor] room.colors.selectionIndicatorIcon length (${o}) does not match room.colors.active length (${e}). Using modulo for color assignment.`)}assignColorsUsingFourColorAlgorithm(t,e,i){var n,r;const s=U_(),o=null!=(r=null==(n=s.mapState)?void 0:n.id)?r:null;if(this.fourColorCache&&this.fourColorCache.mapId===o&&this.fourColorCache.colorMap.size===t.length)return vm.debug("[FourColor] Using cached color map"),this.fourColorCache.colorMap;const a=s.getApp().config.map.adjacencyThreshold||3;vm.debug(`[FourColor] Starting algorithm for ${t.length} rooms with ${e} colors`);const l=((t,e,i)=>{const n=new Map;if(0===t.length)return n;if(1===t.length)return n.set(t[0].id,0),n;const r=new Map;for(let a=0;a<t.length;a++){const i=t[a];r.has(i.id)||r.set(i.id,new Set);for(let n=a+1;n<t.length;n++){const s=t[n];e(i,s)&&(r.get(i.id).add(s.id),r.has(s.id)||r.set(s.id,new Set),r.get(s.id).add(i.id))}}const s=new Array(i).fill(0),o=[...t].sort((e,i)=>{const n=(r.get(e.id)||new Set).size,s=(r.get(i.id)||new Set).size,o=t.indexOf(e);return.7*-t.indexOf(i)+.3*s-(.7*-o+.3*n)});for(const a of o){const t=r.get(a.id)||new Set,e=new Set,o=new Set;for(const i of t){const s=n.get(i);if(void 0!==s){e.add(s);const l=r.get(i)||new Set;for(const e of l)if(e!==a.id&&!t.has(e)){const t=n.get(e);void 0!==t&&o.add(t)}}}const l=[];for(let n=0;n<i;n++)e.has(n)||l.push(n);if(0===l.length){let t=1/0,e=0;for(let n=0;n<i;n++)s[n]<t&&(t=s[n],e=n);n.set(a.id,e),s[e]++;continue}const h=l.filter(t=>!o.has(t)),c=h.length>0?h:l;let u=c[0],d=s[u];for(const i of c)(s[i]<d||s[i]===d&&i<u)&&(u=i,d=s[i]);n.set(a.id,u),s[u]++}return n})(t,(t,e)=>{var n;if("structured"===i){const i=t.outlinePoints,n=e.outlinePoints;return!(!i||!n)&&i_(i,n,a)}{const i=t.pixels,r=e.pixels;if(!i||!r)return!1;const o=(null==(n=s.mapState)?void 0:n.width)||0;return n_(i,r,o,a)}},e);this.fourColorCache={mapId:o,colorMap:l};const h=new Array(e).fill(0);return l.forEach(t=>{h[t]++}),vm.debug("[FourColor] Color distribution:",h),l}destroy(){this.obstacle.destroy(),this.free.destroy(),this.roomFill.destroy(),this.carpet.destroy(),this.chargingStation.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.fourColorCache=null}}class dy extends xe{constructor(){super({isRenderGroup:!0}),__publicField(this,"commonPath"),__publicField(this,"chargePath"),__publicField(this,"transitionsPath"),__publicField(this,"mopPath"),__publicField(this,"pathData",null),__publicField(this,"lastPointCount",0),__publicField(this,"lastDrawnPosition",null),__publicField(this,"isRealTimeDrawing",!1),__publicField(this,"throttledUpdateLineWidth"),__publicField(this,"throttledHandleRobotPosition"),__publicField(this,"handleRobotAnimationComplete",()=>{this.isRealTimeDrawing&&this.stopRealTimeDrawing()});const t=U_();t.appContainer.addToLayer(j_,this),this.eventMode="none",this.commonPath=new fl,this.chargePath=new fl,this.transitionsPath=new fl,this.mopPath=new fl,this.addChild(this.commonPath),this.addChild(this.chargePath),this.addChild(this.transitionsPath),this.addChild(this.mopPath),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.mopPath.visible=!1,this.throttledUpdateLineWidth=zg(()=>{this.updateLineWidth()},50,{leading:!0,trailing:!0}),this.throttledHandleRobotPosition=zg(this.handleRobotPositionUpdate.bind(this),0),this.registerEventListeners()}registerEventListeners(){const{emitter:t}=U_();t.on("antiScale",this.throttledUpdateLineWidth),t.on("robotPositionUpdate",this.throttledHandleRobotPosition),t.on("robotAnimationComplete",this.handleRobotAnimationComplete)}handleRobotPositionUpdate(t){if(!this.isRealTimeDrawing||!this.lastDrawnPosition)return;let e;switch(t.pathType||"common"){case"common":default:e=this.commonPath;break;case"charge":e=this.chargePath;break;case"transitions":e=this.transitionsPath;break;case"mop":e=this.mopPath}e.moveTo(this.lastDrawnPosition.x,this.lastDrawnPosition.y),e.lineTo(t.x,t.y),e.stroke(),this.lastDrawnPosition={x:t.x,y:t.y}}updateLineWidth(){const t=U_();this.pathData&&t.pathConfig.lineWidthFixed&&this.redrawPaths(this.pathData)}redrawPaths(t){const{pathPoints:e}=t;e&&0!==e.length&&(this.commonPath.clear(),this.chargePath.clear(),this.transitionsPath.clear(),this.mopPath.clear(),this.setupPathStyles(),this.drawPathSegments(e),this.commonPath.stroke(),this.chargePath.stroke(),this.transitionsPath.stroke(),this.mopPath.stroke())}setupPathStyles(){const t=U_(),e=t.pathConfig,i=i=>e.lineWidthFixed?t.getApp().toFixedSize(i):i;this.commonPath.setStrokeStyle({width:i(e.commonPath.width),color:e.commonPath.color,join:"round",cap:"round"}),this.chargePath.setStrokeStyle({width:i(e.chargePath.width),color:e.chargePath.color,join:"round",cap:"round"}),this.transitionsPath.setStrokeStyle({width:i(e.transitionPath.width),color:e.transitionPath.color,join:"round",cap:"round"}),this.mopPath.setStrokeStyle({width:0,color:0,alpha:0,join:"round",cap:"round"})}drawPathSegments(t){let e=null,i=null;for(let n=0;n<t.length;n++){const r=t[n],s=r.type||"common";let o;switch(s){case"common":default:o=this.commonPath;break;case"charge":o=this.chargePath;break;case"transitions":o=this.transitionsPath;break;case"mop":o=this.mopPath}0===n||s!==e?o.moveTo(r.x,r.y):o===i&&o.lineTo(r.x,r.y),e=s,i=o}}updatePositionByOrigin(t,e){this.position.set(t,e)}drawFull(t){var e;vm.debug("[Path] Draw Full Path",t),this.pathData=t,this.redrawPaths(t),this.lastPointCount=(null==(e=t.pathPoints)?void 0:e.length)||0}drawIncremental(t){var e,i,n,r;const s=U_(),o=this.lastPointCount,a=(null==(e=t.pathPoints)?void 0:e.slice(o))||[];if(a.length>0){this.setupPathStyles(),vm.debug("[Path] Draw Incremental Path",a);if(s.robotConfig.speed>0){if(this.isRealTimeDrawing=!0,o>0&&(null==(i=this.pathData)?void 0:i.pathPoints)){const t=this.pathData.pathPoints[o-1];this.lastDrawnPosition={x:t.x,y:t.y}}}else this.drawNewPathSegments(a,o,t.pathPoints,null==(n=this.pathData)?void 0:n.pathPoints)}this.pathData=t,this.lastPointCount=(null==(r=t.pathPoints)?void 0:r.length)||0}drawNewPathSegments(t,e,i,n){if(!i||0===t.length)return;let r=null;e>0&&(n&&n[e-1]?r=n[e-1]:i[e-1]&&(r=i[e-1]));let s=null,o=null,a=!1;for(let l=0;l<t.length;l++){const e=t[l],i=e.type||"common";let n;switch(i){case"common":default:n=this.commonPath;break;case"charge":n=this.chargePath;break;case"transitions":n=this.transitionsPath;break;case"mop":n=this.mopPath}i!==s||0===l?(o&&a&&o.stroke(),s=i,o=n,a=!0,r&&0===l&&r.type===i?(n.moveTo(r.x,r.y),n.lineTo(e.x,e.y)):n.moveTo(e.x,e.y)):n.lineTo(e.x,e.y)}o&&a&&o.stroke()}stopRealTimeDrawing(){this.isRealTimeDrawing=!1,this.lastDrawnPosition=null}destroy(t){const{emitter:e}=U_();e.off("antiScale",this.throttledUpdateLineWidth),e.off("robotPositionUpdate",this.throttledHandleRobotPosition),e.off("robotAnimationComplete",this.handleRobotAnimationComplete),this.stopRealTimeDrawing(),super.destroy(t)}}class py extends oy{constructor(){super(),this.initializeSprite()}initializeSprite(){return __async(this,null,function*(){const t=U_();yield this.loadTextureAndSetSize("robot",t.robotConfig.icon)})}draw(t){return __async(this,arguments,function*({x:t,y:e,rotation:i}){__superGet(py.prototype,this,"draw").call(this,{x:t,y:e,rotation:i})})}}const fy=class t extends yl{constructor(t){super(t||[]),__publicField(this,"throttledUpdateScale"),__publicField(this,"fixedWidth",0),__publicField(this,"fixedHeight",0),__publicField(this,"isFixedSizeSet",!1),__publicField(this,"sizeFixed",!0),__publicField(this,"baselineScale",1),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=zg(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,(t&&this.isFixedSizeSet||!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(){U_().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.textures||0===this.textures.length||!this.textures[0]||0===this.textures[0].width||0===this.textures[0].height)return;const t=U_(),e=this.textures[0],i=this.fixedWidth/e.width,n=this.fixedHeight/e.height;if(this.sizeFixed){const e=t.currentScale;if(0===e||!isFinite(e)){const t=i,e=n;return void super.scale.set(t,e)}const r=i/e,s=n/e;super.scale.set(r,s)}else super.scale.set(i/this.baselineScale,n/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():0!==t&&super.scale.set(1/t))}static loadAnimationTextures(t,e="sleep_",i=96){return __async(this,null,function*(){try{yield Ya.load(t);const n=[];for(let t=0;t<i;t++){const i=t.toString().padStart(3,"0"),r=`${e}${i}.png`,s=J.from(r);s&&n.push(s)}return n}catch(n){return[]}})}setupAnimation(t){void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),this.setFixedSize(t.width,t.height),this.animationSpeed=.5,this.loop=!0,vm.log(`Animation setup complete, visible=${this.visible}, scale=(${this.scale.x.toFixed(3)}, ${this.scale.y.toFixed(3)})`)}draw(t,e){const{x:i,y:n,rotation:r=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=r,this.position.set(i,n)}play(){this.textures&&this.textures.length>0&&(super.play(),t.animatedSprites.add(this),t.startAnimationTicker())}stop(){super.stop(),t.animatedSprites.delete(this),t.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 e;(null==(e=t.animationTicker)?void 0:e.started)||(t.animationTicker||(t.animationTicker=new Ue,t.animationTicker.maxFPS=24,t.animationTicker.add(()=>{t.updateAnimations()})),t.animationTicker.start(),vm.log("🎬 [AnimationTicker] Started animation ticker"))}static updateAnimationTicker(){t.animatedSprites.size>0?t.startAnimationTicker():t.stopAnimationTicker()}static stopAnimationTicker(){var e;(null==(e=t.animationTicker)?void 0:e.started)&&(vm.log("⏸️ [AnimationTicker] Stopped animation ticker"),t.animationTicker.stop())}static updateAnimations(){if(0===t.animatedSprites.size)return;const e=U_().getApp();e.renderer.render(e.stage)}destroy(e){t.animatedSprites.delete(this),t.updateAnimationTicker(),U_().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(e)}};__publicField(fy,"animationTicker",null),__publicField(fy,"animatedSprites",new Set);let gy=fy;class my extends gy{constructor(t){super(t),__publicField(this,"unsubscribeFns",[]),__publicField(this,"throttledUpdateOffset"),__publicField(this,"fixedOffsetX",0),__publicField(this,"fixedOffsetY",0),this.throttledUpdateOffset=zg(this.updateOffset.bind(this),30,{leading:!0,trailing:!0}),this.initializeAnimation()}static create(){return __async(this,null,function*(){const t=U_().robotConfig,e=yield gy.loadAnimationTextures(t.sleepAnimation.jsonSrc,t.sleepAnimation.framePrefix,t.sleepAnimation.frameCount);0===e.length&&(vm.warn("No textures loaded for sleep animation"),e.push(J.EMPTY));const i=new my(e);return i.setupAnimation({width:t.sleepAnimation.width,height:t.sleepAnimation.height,sizeFixed:t.sleepAnimation.sizeFixed}),i})}initializeAnimation(){const t=U_();this.visible=!1,this.fixedOffsetX=t.robotConfig.sleepAnimation.offsetX,this.fixedOffsetY=t.robotConfig.sleepAnimation.offsetY,t.emitter.on("antiScale",this.throttledUpdateOffset);const e=ly(t.runtime,"showRobotSleepAnimation",t=>{vm.log(`[runtime] showRobotSleepAnimation: ${t}`),this.updateVisibility()});this.unsubscribeFns.push(e)}shouldShow(){const t=U_().runtimeSnapshot.showRobotSleepAnimation,e=this.parent,i=!!e&&e.visible,n=e&&(0!==e.x||0!==e.y);return t&&i&&!!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(t){}draw(t){const e=U_(),i=e.getApp().toFixedSize(e.robotConfig.sleepAnimation.offsetX),n=e.getApp().toFixedSize(e.robotConfig.sleepAnimation.offsetY),r=__spreadProps(__spreadValues({},t),{x:t.x+i,y:t.y+n});super.draw(r,()=>this.shouldShow()),this.updateVisibility()}onRobotVisibilityChanged(){this.updateVisibility()}set visible(t){const e=super.visible;super.visible=t,t&&!e&&this.textures&&this.textures.length>0?this.play():!t&&e&&this.playing&&this.stop()}get visible(){return super.visible}destroy(t){U_().emitter.off("antiScale",this.throttledUpdateOffset),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.stop(),super.destroy(t)}}class _y extends xe{constructor(){super(),__publicField(this,"robot"),__publicField(this,"ring"),__publicField(this,"sleepAnimation",null),__publicField(this,"unsubscribeFns",[]),__publicField(this,"targetPosition",null),__publicField(this,"targetRotation",null),__publicField(this,"isMoving",!1),__publicField(this,"pathQueue",[]),__publicField(this,"lastPosition",null),__publicField(this,"currentPathType"),__publicField(this,"lastUpdateTime",0);const t=U_();t.appContainer.addToLayer(Q_,this),this.visible=t.runtimeSnapshot.showPath,this.ring=new hy({config:t.robotConfig}),this.ring.visible=t.runtimeSnapshot.showRobotRing,this.addChild(this.ring),this.robot=new py,this.addChild(this.robot),this.lastUpdateTime=Date.now();t.robotConfig.speed>0&&t.getApp().ticker.add(this.update,this);const e=ly(t.runtime,"showRobotRing",t=>{vm.log(`[runtime] showRobotRing: ${t}`),this.ring.visible=t});this.unsubscribeFns.push(e)}initializeSleepAnimation(){return __async(this,null,function*(){try{this.sleepAnimation=yield my.create(),this.addChild(this.sleepAnimation),vm.log("Sleep animation added to robot")}catch(t){vm.error("Failed to initialize sleep animation:",t)}})}updatePositionByOrigin(t,e){this.position.set(t,e)}draw(t){return __async(this,arguments,function*({x:t,y:e,rotation:i}){this.ring.draw({x:t,y:e}),yield this.robot.draw({x:t,y:e,rotation:i}),this.sleepAnimation||(yield this.initializeSleepAnimation()),this.sleepAnimation.draw({x:t,y:e,rotation:i}),this.lastPosition={x:t,y:e}})}moveTo(t){this.pathQueue.push(t),this.isMoving||this.processNextPathPoint()}batchProcessQueue(t=!1){if(0===this.pathQueue.length)return;const e=[...this.pathQueue];if(t){const t=e[e.length-1];this.robot.position.set(t.x,t.y),void 0!==t.rotation&&(this.robot.rotation=t.rotation),this.lastPosition={x:t.x,y:t.y},this.pathQueue=[],this.isMoving=!1,this.targetPosition=null}else this.pathQueue.splice(0,e.length),0===this.pathQueue.length?(this.isMoving=!1,this.targetPosition=null):this.processNextPathPoint()}processNextPathPoint(){if(0===this.pathQueue.length)return this.isMoving=!1,this.currentPathType=void 0,this.stopRobotAnimation(),void U_().emitter.emit("robotAnimationComplete");this.isMoving||this.startRobotAnimation(),this.isMoving=!0;const t=this.pathQueue[0];this.targetPosition={x:t.x,y:t.y},this.currentPathType=t.type,void 0!==t.rotation&&(this.targetRotation=t.rotation),this.lastPosition||(this.lastPosition={x:this.robot.x,y:this.robot.y})}update(){const t=U_(),e=Date.now();if(0===this.lastUpdateTime)return void(this.lastUpdateTime=e);let i=e-this.lastUpdateTime;if(this.lastUpdateTime=e,i>500&&(i=16.67),this.targetPosition){const e=this.targetPosition.x-this.robot.x,n=this.targetPosition.y-this.robot.y,r=Math.sqrt(e*e+n*n),s=t.robotConfig.speed,o=t.getApp().metersToPixels(s);if(0===s)return this.robot.position.set(this.targetPosition.x,this.targetPosition.y),null!==this.targetRotation&&(this.robot.rotation=this.targetRotation,this.targetRotation=null),this.targetPosition=null,this.lastPosition={x:this.robot.x,y:this.robot.y},this.pathQueue.shift(),void this.processNextPathPoint();const a=o*(i/1e3);r<a?(this.robot.position.set(this.targetPosition.x,this.targetPosition.y),null!==this.targetRotation&&(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+=e*(a/r),this.robot.y+=n*(a/r),U_().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(){U_().getApp().requestRender("robot-animation",!0)}set visible(t){super.visible=t,this.sleepAnimation&&this.sleepAnimation.onRobotVisibilityChanged()}get visible(){return super.visible}stopRobotAnimation(){U_().getApp().stopRender("robot-animation")}remove(){this.pathQueue=[],this.isMoving=!1,this.targetPosition=null,this.stopRobotAnimation()}destroy(t){const e=U_();this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.stopRobotAnimation();e.robotConfig.speed>0&&e.getApp().ticker.remove(this.update,this),this.ring.destroy(),super.destroy(t)}}class yy{constructor(){__publicField(this,"path"),__publicField(this,"robot"),__publicField(this,"unsubscribeFns",[]),__publicField(this,"lastDrawnPathData",null);const t=U_();this.path=new dy,this.robot=new _y;const e=ly(t.runtime,"showPath",t=>{vm.log(`[runtime] showPath: ${t}`),this.path.visible=t,this.robot.visible=t});this.unsubscribeFns.push(e)}draw(t){this.shouldUseIncrementalDraw(t)?this.incrementalDraw(t):this.fullDraw(t),this.lastDrawnPathData=t}shouldUseIncrementalDraw(t){var e,i,n,r;const s=U_();if(!this.lastDrawnPathData)return!1;if((null==(e=t.pathHeader)?void 0:e.pathId)!==(null==(i=this.lastDrawnPathData.pathHeader)?void 0:i.pathId))return!1;const o=((null==(n=t.pathPoints)?void 0:n.length)||0)-((null==(r=this.lastDrawnPathData.pathPoints)?void 0:r.length)||0),a=s.pathConfig.incrementalThreshold;return!(o<=0||o>a)}fullDraw(t){if(this.path.stopRealTimeDrawing(),this.path.drawFull(t),t.pathPoints&&t.pathPoints.length>0){const e=t.pathPoints[t.pathPoints.length-1];this.moveRobotToPoint(e,t.pathHeader.direction,!1)}}convertToRobotPoint(t,e){const i=e+U_().robotConfig.rotationCorrection;return{x:t.x,y:t.y,rotation:i*Math.PI/180,type:t.type}}moveRobotToPoint(t,e,i=!0){const n=this.convertToRobotPoint(t,e);i?this.robot.moveTo(n):(this.robot.remove(),this.robot.draw(n))}incrementalDraw(t){var e;const i=U_();if(!this.lastDrawnPathData||!t.pathPoints)return;this.path.drawIncremental(t);const n=(null==(e=this.lastDrawnPathData.pathPoints)?void 0:e.length)||0,r=t.pathPoints.slice(n);if(0===r.length)return;if(i.robotConfig.speed>0)r.forEach(e=>{this.moveRobotToPoint(e,t.pathHeader.direction,!0)});else{const e=r[r.length-1];this.moveRobotToPoint(e,t.pathHeader.direction,!1)}}batchProcessRobotQueue(t=!1){this.robot.batchProcessQueue(t)}updatePositionByOrigin(t,e){this.path.updatePositionByOrigin(t,e),this.robot.updatePositionByOrigin(t,e)}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.path.destroy(),this.robot.destroy()}}class xy extends xe{constructor(){super(),__publicField(this,"colorGradients",[]),__publicField(this,"cellSize",2);const t=U_();t.appContainer.addToLayer(W_,this);const e=t.heatMapConfig;this.colorGradients=e.colorGradients.map(t=>new Bt(t).toArray().slice(0,3).join(",")),this.cellSize=e.cellSize}draw(t,e=!0,i=.8){this.removeChildren();const n=e?this.gradientDrawing(t):this.gridDrawing(t);this.croppingHeatmap(n),n.alpha=i,this.addChild(n)}croppingHeatmap(t){const e=U_().mapManager.roomFill.children.filter(t=>t instanceof fl),i=new fl;for(const n of e)i.context.instructions.push(...n.context.instructions);i.context.dirty=!0,t.setMask({mask:i}),this.addChild(i)}gridDrawing(t){const e=[],i=[],n=t.length,r=t[0].length;for(let l=0;l<n;l++)for(let n=0;n<r;n++){const r=t[l][n],s=this.cellSize/2,o=r.x-s,a=r.y-s,h=r.x+s,c=r.y+s;e.push(o,a),i.push(r.signal),e.push(h,a),i.push(r.signal),e.push(h,c),i.push(r.signal),e.push(o,a),i.push(r.signal),e.push(h,c),i.push(r.signal),e.push(o,c),i.push(r.signal)}const s=new jr({attributes:{aPosition:new Float32Array(e),aSignal:new Float32Array(i)}}),o=new tn({glProgram:new Li({vertex:"\n in vec2 aPosition;\n in float aSignal;\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform mat3 uTransformMatrix;\n \n out float vSignal;\n \n void main() {\n mat3 mvp = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;\n gl_Position = vec4((mvp * vec3(aPosition, 1.0)).xy, 0.0, 1.0);\n vSignal = aSignal;\n }\n ",fragment:`\n precision mediump float;\n \n in float vSignal;\n \n void main() {\n vec3 color;\n \n if (vSignal > 0.875) {\n color = vec3(${this.colorGradients[0]});\n } else if (vSignal > 0.75) {\n color = vec3(${this.colorGradients[1]});\n } else if (vSignal > 0.625) {\n color = vec3(${this.colorGradients[2]});\n } else if (vSignal > 0.5) {\n color = vec3(${this.colorGradients[3]});\n } else if (vSignal > 0.375) {\n color = vec3(${this.colorGradients[4]});\n } else if (vSignal > 0.25) {\n color = vec3(${this.colorGradients[5]});\n } else if (vSignal > 0.125) {\n color = vec3(${this.colorGradients[6]});\n } else {\n color = vec3(${this.colorGradients[7]});\n }\n gl_FragColor = vec4(color, 1.0);\n }\n `})}),a=new _l({geometry:s,shader:o});return a.alpha=.8,a}gradientDrawing(t){const e=[],i=[],n=t.length,r=t[0].length;for(let l=0;l<n;l++)for(let s=0;s<r;s++){const o=t[l][s],a=this.cellSize/2,h=(e,i)=>e<0||e>=n||i<0||i>=r?o.signal:t[e][i].signal,c=(h(l-1,s-1)+h(l-1,s)+h(l,s-1)+o.signal)/4,u=(h(l-1,s)+h(l-1,s+1)+o.signal+h(l,s+1))/4,d=(o.signal+h(l,s+1)+h(l+1,s)+h(l+1,s+1))/4,p=(h(l,s-1)+o.signal+h(l+1,s-1)+h(l+1,s))/4,f=o.x-a,g=o.y-a,m=o.x+a,_=o.y+a;e.push(f,g,m,g,m,_),i.push(c,u,d),e.push(f,g,m,_,f,_),i.push(c,d,p)}const s=new jr({attributes:{aPosition:new Float32Array(e),aSignal:new Float32Array(i)}}),o=new tn({glProgram:new Li({vertex:"\n in vec2 aPosition;\n in float aSignal;\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform mat3 uTransformMatrix;\n \n out float vSignal;\n \n void main() {\n mat3 mvp = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;\n gl_Position = vec4((mvp * vec3(aPosition, 1.0)).xy, 0.0, 1.0);\n vSignal = aSignal;\n }\n ",fragment:`\n precision mediump float;\n \n in float vSignal;\n \n // 颜色插值函数\n vec3 interpolateColor(vec3 color1, vec3 color2, float t) {\n return mix(color1, color2, t);\n }\n \n void main() {\n vec3 color;\n float signal = clamp(vSignal, 0.0, 1.0);\n \n vec3 color1 = vec3(${this.colorGradients[7]});\n vec3 color2 = vec3(${this.colorGradients[6]});\n vec3 color3 = vec3(${this.colorGradients[5]});\n vec3 color4 = vec3(${this.colorGradients[4]});\n vec3 color5 = vec3(${this.colorGradients[3]});\n vec3 color6 = vec3(${this.colorGradients[2]});\n vec3 color7 = vec3(${this.colorGradients[1]});\n vec3 color8 = vec3(${this.colorGradients[0]});\n \n if (signal <= 0.125) {\n float t = signal / 0.125;\n color = interpolateColor(color1, color2, t);\n } else if (signal <= 0.25) {\n float t = (signal - 0.125) / 0.125;\n color = interpolateColor(color2, color3, t);\n } else if (signal <= 0.375) {\n float t = (signal - 0.25) / 0.125;\n color = interpolateColor(color3, color4, t);\n } else if (signal <= 0.5) {\n float t = (signal - 0.375) / 0.125;\n color = interpolateColor(color4, color5, t);\n } else if (signal <= 0.625) {\n float t = (signal - 0.5) / 0.125;\n color = interpolateColor(color5, color6, t);\n } else if (signal <= 0.75) {\n float t = (signal - 0.625) / 0.125;\n color = interpolateColor(color6, color7, t);\n } else if (signal <= 0.875) {\n float t = (signal - 0.75) / 0.125;\n color = interpolateColor(color7, color8, t);\n } else {\n color = color8;\n }\n \n gl_FragColor = vec4(color, 1.0);\n }\n `})}),a=new _l({geometry:s,shader:o});return a.alpha=.8,a}}class by{constructor(){__publicField(this,"heatmap",new xy),__publicField(this,"pointsTopLeftOrigin",[]),__publicField(this,"signalGrid",[]),__publicField(this,"cellSize",2),__publicField(this,"maxDistance",14),__publicField(this,"smoothIterations",10),__publicField(this,"heatmapAlpha",.8);const t=U_().heatMapConfig;this.cellSize=t.cellSize,this.maxDistance=t.maxDistance,this.smoothIterations=t.smoothIterations,this.heatmapAlpha=t.heatmapAlpha}draw({mapData:t,heatmapPoints:e,useGradient:i=!0}){const n=U_(),r=t.origin[0],s=t.origin[1],{minX:o,minY:a}=n.mapManager.mapBounds,l=e.map(t=>({x:+(r+t.x-o).toFixed(0),y:+(s+t.y-a).toFixed(0),signal:t.signal}));this.signalGrid=this.calculateInterpolatedSignal(l),this.heatmap.draw(this.signalGrid,i,this.heatmapAlpha)}calculateInterpolatedSignal(t){const e=U_(),{minX:i,minY:n,maxX:r,maxY:s}=e.mapManager.mapBounds,o=Math.ceil((s-n)/this.cellSize),a=Math.ceil((r-i)/this.cellSize),l=Array(o).fill(null).map(()=>Array(a).fill(null));for(let c=0;c<o;c++){const e=n+c*this.cellSize+this.cellSize/2,o=Math.min(this.cellSize,s-(e-this.cellSize/2));for(let n=0;n<a;n++){const s=i+n*this.cellSize+this.cellSize/2,a=Math.min(this.cellSize,r-(s-this.cellSize/2));let h=0,u=!1;for(let i=0;i<t.length;i++){const n=t[i];if(Math.abs(s-n.x)<=a/2&&Math.abs(e-n.y)<=o/2){const t=1-n.signal/7;h=Math.round(10*Math.max(h,t))/10,u=!0}}l[c][n]={x:s,y:e,signal:h,hasPoint:u}}}const h=(e,i)=>{if(0===t.length)return 0;let n=0,r=0;for(const s of t){const t=Math.sqrt(__pow(e-s.x,2)+__pow(i-s.y,2));if(t<=this.maxDistance){const e=1/(1+t);r+=e*(1-s.signal/7),n+=e}}return 0===n?0:Math.round(r/n*1e3)/1e3};for(let c=0;c<o;c++)for(let t=0;t<a;t++){const e=l[c][t];e.hasPoint||(e.signal=h(e.x,e.y))}return((t,e=1)=>{for(let i=0;i<e;i++){const e=t.map(t=>[...t]);for(let i=1;i<o-1;i++)for(let n=1;n<a-1;n++)if(!t[i][n].hasPoint){let r=0,s=0;const l=4;for(let e=-l;e<=l;e++)for(let h=-l;h<=l;h++){if(0===e&&0===h)continue;const l=i+e,c=n+h;if(l>=0&&l<o&&c>=0&&c<a){const i=1/(1+.3*Math.sqrt(e*e+h*h));r+=t[l][c].signal*i,s+=i}}if(s>0){const o=r/s,a=.6,l=.4;e[i][n].signal=t[i][n].signal*a+o*l,e[i][n].signal>.1&&(e[i][n].signal=Math.max(e[i][n].signal,.2))}}for(let i=0;i<o;i++)for(let n=0;n<a;n++)t[i][n].signal=e[i][n].signal}})(l,this.smoothIterations),l}}class vy extends xe{constructor(){super(),__publicField(this,"throttledUpdateScale"),this.throttledUpdateScale=zg(this.updateScale.bind(this),30,{leading:!0,trailing:!0});const t=U_();this.updateScale(t.currentScale),this.registerScaleListener()}registerScaleListener(){U_().emitter.on("antiScale",this.throttledUpdateScale)}updateScale(t){0!==t&&this.scale.set(1/t)}destroy(t){U_().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class wy extends vy{constructor(t){super(),__publicField(this,"background"),__publicField(this,"icon"),__publicField(this,"options"),this.options=t,this.background=new fl,this.addChild(this.background),this.icon=new oy,this.addChild(this.icon),this.eventMode="static",this.render(),this.setupHitArea(),this.setupEvents()}setupHitArea(){const t=U_().controlsConfig,e=t.iconWrapperWidth+16,i=t.iconWrapperHeight+16;this.hitArea=new D(-e/2,-i/2,e,i)}render(){return __async(this,null,function*(){this.renderBackground(),this.renderIcon()})}renderBackground(){const t=U_().controlsConfig;this.background.clear(),this.background.roundRect(-t.iconWrapperWidth/2,-t.iconWrapperHeight/2,t.iconWrapperWidth,t.iconWrapperHeight,t.iconWrapperBorderRadius).fill(this.options.backgroundColor)}renderIcon(){return __async(this,null,function*(){try{const t=U_().controlsConfig;yield this.icon.loadTextureAndSetSize(this.options.iconAlias,{width:t.iconWidth,height:t.iconHeight,sizeFixed:!1}),this.icon.visible=!0}catch(t){vm.error(`Failed to load icon: ${this.options.iconAlias}`,t)}})}destroy(){super.destroy()}}class Sy extends wy{constructor(t){super(t),__publicField(this,"isRotating",!1),__publicField(this,"rotationCenter",{x:0,y:0}),__publicField(this,"lastAngle",0),__publicField(this,"handleRotationPointerMove",t=>{var e,i;if(!this.isRotating)return;const n=this.parent.toLocal(t.global),r=Math.atan2(n.y-this.rotationCenter.y,n.x-this.rotationCenter.x),s=r-this.lastAngle;null==(i=(e=this.options).onRotationMove)||i.call(e,s),this.lastAngle=r}),__publicField(this,"handleRotationPointerUp",()=>{var t,e;this.isRotating&&(this.isRotating=!1,null==(e=(t=this.options).onRotationEnd)||e.call(t))}),__publicField(this,"handleRotationCancel",()=>{var t,e;this.isRotating&&(this.isRotating=!1,null==(e=(t=this.options).onRotationEnd)||e.call(t))}),this.setupRotationEventListeners()}setupRotationEventListeners(){const{emitter:t}=U_();U_().emitter.on("gestureHijackPointerMove",this.handleRotationPointerMove),t.on("gestureHijackPointerUp",this.handleRotationPointerUp),t.on("gestureHijackCancel",this.handleRotationCancel)}cleanupRotationEventListeners(){const{emitter:t}=U_();t.off("gestureHijackPointerMove",this.handleRotationPointerMove),t.off("gestureHijackPointerUp",this.handleRotationPointerUp),t.off("gestureHijackCancel",this.handleRotationCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(t){t.stopPropagation(),this.startRotation(t)}startRotation(t){var e,i;this.isRotating=!0;const n=this.options.getTargetPoints();this.rotationCenter=Im(n);const r=this.parent.toLocal(t.global);this.lastAngle=Math.atan2(r.y-this.rotationCenter.y,r.x-this.rotationCenter.x),null==(i=(e=this.options).onRotationStart)||i.call(e,this.rotationCenter),U_().emitter.emit("gestureHijackStart",t)}isCurrentlyRotating(){return this.isRotating}stopRotation(){var t,e;this.isRotating&&(this.isRotating=!1,null==(e=(t=this.options).onRotationEnd)||e.call(t))}destroy(){this.stopRotation(),this.cleanupRotationEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Ay extends wy{constructor(t){super(t),__publicField(this,"clickHandler",null)}setupEvents(){this.clickHandler=new iy(this,{onClick:this.options.onClick,stopPropagation:!0})}destroy(){var t;null==(t=this.clickHandler)||t.destroy(),super.destroy()}}class Ty extends wy{constructor(t){super(t),__publicField(this,"isScaling",!1),__publicField(this,"initialButtonPosition",null),__publicField(this,"dragStartPosition",null),__publicField(this,"handleScalePointerMove",t=>{var e,i;if(!this.isScaling||!this.initialButtonPosition||!this.dragStartPosition)return;const n=this.parent.toLocal(t.global),r=n.x-this.dragStartPosition.x,s=n.y-this.dragStartPosition.y,o={x:this.initialButtonPosition.x+r,y:this.initialButtonPosition.y+s};null==(i=(e=this.options).onScaleMove)||i.call(e,o)}),__publicField(this,"handleScalePointerUp",()=>{var t,e;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,null==(e=(t=this.options).onScaleEnd)||e.call(t))}),__publicField(this,"handleScaleCancel",()=>{var t,e;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,null==(e=(t=this.options).onScaleEnd)||e.call(t))}),this.setupScaleEventListeners()}setupScaleEventListeners(){const{emitter:t}=U_();t.on("gestureHijackPointerMove",this.handleScalePointerMove),t.on("gestureHijackPointerUp",this.handleScalePointerUp),t.on("gestureHijackCancel",this.handleScaleCancel)}cleanupScaleEventListeners(){const{emitter:t}=U_();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 e,i;this.isScaling=!0,this.dragStartPosition=this.parent.toLocal(t.global);const n=this.options.getTargetPoints(),r=this.options.getButtonIndex();r>=0&&r<n.length&&(this.initialButtonPosition=__spreadValues({},n[r])),null==(i=(e=this.options).onScaleStart)||i.call(e,r),U_().emitter.emit("gestureHijackStart",t)}isCurrentlyScaling(){return this.isScaling}stopScaling(){var t,e;this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,null==(e=(t=this.options).onScaleEnd)||e.call(t))}destroy(){this.stopScaling(),this.cleanupScaleEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Cy extends wy{constructor(t){super(t),__publicField(this,"isMoving",!1),__publicField(this,"dragStartPosition",null),__publicField(this,"handleMovePointerMove",t=>{var e,i;this.isMoving&&this.dragStartPosition&&(null==(i=(e=this.options).onMoveMove)||i.call(e,t))}),__publicField(this,"handleMovePointerUp",()=>{var t,e;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,null==(e=(t=this.options).onMoveEnd)||e.call(t))}),__publicField(this,"handleMoveCancel",()=>{var t,e;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,null==(e=(t=this.options).onMoveEnd)||e.call(t))}),this.setupMoveEventListeners()}setupMoveEventListeners(){const{emitter:t}=U_();t.on("gestureHijackPointerMove",this.handleMovePointerMove),t.on("gestureHijackPointerUp",this.handleMovePointerUp),t.on("gestureHijackCancel",this.handleMoveCancel)}cleanupMoveEventListeners(){const{emitter:t}=U_();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 e,i;this.isMoving=!0,this.dragStartPosition=this.parent.toLocal(t.global),null==(i=(e=this.options).onMoveStart)||i.call(e),U_().emitter.emit("gestureHijackStart",t)}isCurrentlyMoving(){return this.isMoving}getDragStartPosition(){return this.dragStartPosition?__spreadValues({},this.dragStartPosition):null}stopMoving(){var t,e;this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,null==(e=(t=this.options).onMoveEnd)||e.call(t))}destroy(){this.stopMoving(),this.cleanupMoveEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Py extends fl{constructor(t){super(),__publicField(this,"fillOptions"),__publicField(this,"isDragging",!1),__publicField(this,"dragStartPosition",null),__publicField(this,"handlePointerDown",t=>{t.stopPropagation(),this.startDragging(t)}),__publicField(this,"handleDragPointerMove",t=>{var e,i;this.isDragging&&this.dragStartPosition&&(null==(i=(e=this.fillOptions).onDragMove)||i.call(e,t))}),__publicField(this,"handleDragPointerUp",()=>{var t,e;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,null==(e=(t=this.fillOptions).onDragEnd)||e.call(t))}),__publicField(this,"handleDragCancel",()=>{var t,e;this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,null==(e=(t=this.fillOptions).onDragEnd)||e.call(t))}),this.fillOptions=t,this.setupInteraction(),this.setupDragEventListeners(),this.draw()}setupInteraction(){this.fillOptions.enableInteraction&&(this.eventMode="static",this.on("pointerdown",this.handlePointerDown))}setupDragEventListeners(){const{emitter:t}=U_();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=U_();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}startDragging(t){var e,i;this.isDragging=!0;const n=this.parent.toLocal(t.global);this.dragStartPosition={x:n.x,y:n.y},null==(i=(e=this.fillOptions).onDragStart)||i.call(e,t),U_().emitter.emit("gestureHijackStart",t)}draw(){const{points:t,fillColor:e}=this.fillOptions;if(t.length<3)return;this.clear();const i=t.flatMap(t=>[t.x,t.y]);this.setFillStyle({color:e}).poly(i).fill()}getDragStartPosition(){return this.dragStartPosition}updateOptions(t){this.fillOptions=__spreadValues(__spreadValues({},this.fillOptions),t),void 0!==t.enableInteraction&&(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()}}class My extends xe{constructor(t){super(),__publicField(this,"borderOptions"),__publicField(this,"solidLine",null),__publicField(this,"dashGraphics",null),__publicField(this,"fillGraphics",null),__publicField(this,"handleAntiScale",()=>{this.drawBorder()}),this.borderOptions=__spreadValues({},t),this.drawBorder(),this.setupAntiScaleListener(),this.eventMode="none"}setupAntiScaleListener(){U_().emitter.on("antiScale",this.handleAntiScale)}drawBorder(){const{points:t=[],closePath:e=!1,style:i}=this.borderOptions;t.length<2||(this.clearBorder(),void 0!==i.fillColor&&e&&this.drawFill(t,i),i.isDashed?this.drawContinuousDashedBorder(t,e,i):this.drawSolidBorder(t,e,i))}drawFill(t,e){if(e.fillColor&&!(t.length<3)){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy()),this.fillGraphics=new fl,this.fillGraphics.setFillStyle({color:e.fillColor}),this.fillGraphics.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)this.fillGraphics.lineTo(t[e].x,t[e].y);this.fillGraphics.closePath(),this.fillGraphics.fill(),this.addChild(this.fillGraphics)}}drawSolidBorder(t,e,i){const n=U_();this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy()),this.solidLine=new fl;const r=n.getApp().toFixedSize(i.width);this.solidLine.setStrokeStyle({color:i.color,width:r}),this.solidLine.moveTo(t[0].x,t[0].y);for(let s=1;s<t.length;s++)this.solidLine.lineTo(t[s].x,t[s].y);e&&this.solidLine.lineTo(t[0].x,t[0].y),this.solidLine.stroke(),this.addChild(this.solidLine)}drawContinuousDashedBorder(t,e,i){if(t.length<2)return;if(!i.dashArray||2!==i.dashArray.length||i.dashArray[0]<=0||i.dashArray[1]<=0)return void vm.warn("Invalid dashArray:",i.dashArray);const n=U_();this.dashGraphics=new fl;const r=n.getApp().toFixedSize(i.width);this.dashGraphics.setStrokeStyle({color:i.color,width:r});const s=Math.max(n.getApp().toFixedSize(i.dashArray[0]),1),o=Math.max(n.getApp().toFixedSize(i.dashArray[1]),1),a=e?[...t,t[0]]:t;this.drawContinuousPathDashes(this.dashGraphics,a,s,o),this.dashGraphics.stroke(),this.addChild(this.dashGraphics)}drawContinuousPathDashes(t,e,i,n){if(e.length<2)return;if(i<=0||n<=0)return void vm.warn("Invalid dash parameters:",{dashLength:i,gapLength:n});const r=this.calculatePathSegments(e),s=r.reduce((t,e)=>t+e.length,0);if(0===s)return;const o=i+n;let a=0;for(;a<s;){const e=a+i;e<=s?this.drawContinuousDashSegment(t,r,a,e):this.drawContinuousDashSegment(t,r,a,s),a+=o}}calculatePathSegments(t){const e=[];for(let i=0;i<t.length-1;i++){const n=t[i],r=t[i+1],s=r.x-n.x,o=r.y-n.y,a=Math.sqrt(s*s+o*o);e.push({start:n,end:r,length:a})}return e}drawContinuousDashSegment(t,e,i,n){if(i>=n)return;let r=0,s=!1,o=null;for(const a of e){const e=r,l=r+a.length;if(l>i&&e<n){const r=Math.max(i,e),h=Math.min(n,l),c=(r-e)/a.length,u=(h-e)/a.length,d={x:a.start.x+(a.end.x-a.start.x)*c,y:a.start.y+(a.end.y-a.start.y)*c},p={x:a.start.x+(a.end.x-a.start.x)*u,y:a.start.y+(a.end.y-a.start.y)*u};if(s){if(o){Math.sqrt(Math.pow(d.x-o.x,2)+Math.pow(d.y-o.y,2))>.1&&t.lineTo(d.x,d.y)}}else t.moveTo(d.x,d.y),s=!0;t.lineTo(p.x,p.y),o=p}if(r+=a.length,r>=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=__spreadValues(__spreadValues({},this.borderOptions.style),t),this.drawBorder()}updatePoints(t){this.borderOptions.points=t,this.drawBorder()}setClosePath(t){this.borderOptions.closePath=t,this.drawBorder()}getOptions(){return __spreadValues({},this.borderOptions)}destroy(){U_().emitter.off("antiScale",this.handleAntiScale),this.clearBorder(),super.destroy()}}class Ey extends Rl{constructor({text:t,style:e}){super({text:t,style:e}),__publicField(this,"throttledUpdateScale"),this.throttledUpdateScale=zg(this.updateScale.bind(this),20,{leading:!0,trailing:!0}),this.registerScaleListener(),this.updateScale(U_().currentScale)}registerScaleListener(){U_().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){U_().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}const Ry=class t extends xe{constructor(t){super(),__publicField(this,"zoneData"),__publicField(this,"zoneType"),__publicField(this,"zoneConfig"),__publicField(this,"controlsConfig"),__publicField(this,"zoneEvents"),__publicField(this,"controlFill"),__publicField(this,"zoneBorder"),__publicField(this,"outlineBorder"),__publicField(this,"moveLine"),__publicField(this,"sizeText"),__publicField(this,"controlButtons"),__publicField(this,"deleteButton",null),__publicField(this,"rotateButton",null),__publicField(this,"scaleButton",null),__publicField(this,"moveButton",null),__publicField(this,"totalRotationAngle",0),__publicField(this,"rotationCenter",null),__publicField(this,"initialZonePoints",[]),__publicField(this,"clickHandler",null),__publicField(this,"throttledUpdateOutline"),__publicField(this,"handleDragStart",()=>{if(!this.isEditingEnabled())return;const t=U_();this.initialZonePoints=this.zoneData.points.map(t=>__spreadValues({},t)),t.getApp().requestRender("zone-drag",!0)}),__publicField(this,"handleDragMove",t=>{if(!this.isEditingEnabled()||0===this.initialZonePoints.length)return;const e=this.parent.toLocal(t.global),i=this.controlFill.getDragStartPosition();if(!i)return;const n=e.x-i.x,r=e.y-i.y;this.applyTranslation(n,r)}),__publicField(this,"handleDragEnd",()=>{var t,e;const i=U_();this.initialZonePoints=[],i.getApp().stopRender("zone-drag"),null==(e=(t=this.zoneEvents).onUpdate)||e.call(t,this.getZoneData())}),__publicField(this,"handleRotationStart",t=>{const e=U_();this.totalRotationAngle=0,this.rotationCenter=t,this.initialZonePoints=this.zoneData.points.map(t=>__spreadValues({},t)),e.getApp().requestRender("zone-rotate",!0)}),__publicField(this,"handleRotationMove",t=>{this.totalRotationAngle+=t,this.applyRotation(t)}),__publicField(this,"handleRotationEnd",()=>{var t,e;const i=U_();this.rotationCenter=null,this.totalRotationAngle=0,this.initialZonePoints=[],i.getApp().stopRender("zone-rotate"),null==(e=(t=this.zoneEvents).onUpdate)||e.call(t,this.getZoneData())}),__publicField(this,"handleScaleStart",()=>{const t=U_();this.initialZonePoints=this.zoneData.points.map(t=>__spreadValues({},t)),t.getApp().requestRender("zone-scale",!0)}),__publicField(this,"handleScaleMove",t=>{0!==this.initialZonePoints.length&&this.applyEdgeBasedScale(t)}),__publicField(this,"handleScaleEnd",()=>{var t,e;const i=U_();this.initialZonePoints=[],i.getApp().stopRender("zone-scale"),null==(e=(t=this.zoneEvents).onUpdate)||e.call(t,this.getZoneData())}),__publicField(this,"handleMoveStart",()=>{const t=U_();this.initialZonePoints=this.zoneData.points.map(t=>__spreadValues({},t)),t.getApp().requestRender("zone-move",!0)}),__publicField(this,"handleMove",t=>{var e;if(!this.isEditingEnabled()||0===this.initialZonePoints.length)return;const i=this.parent.toLocal(t.global),n=null==(e=this.moveButton)?void 0:e.getDragStartPosition();if(!n)return;const r=i.x-n.x,s=i.y-n.y;this.applyTranslation(r,s)}),__publicField(this,"handleMoveEnd",()=>{var t,e;const i=U_();this.initialZonePoints=[],i.getApp().stopRender("zone-move"),null==(e=(t=this.zoneEvents).onUpdate)||e.call(t,this.getZoneData())}),__publicField(this,"handleDelete",()=>{var t,e;null==(e=(t=this.zoneEvents).onRemove)||e.call(t,this.zoneData.id)});const{zoneData:e,zoneType:i,events:n={}}=t;this.zoneType=i,this.zoneEvents=n,this.zoneConfig=this.getZoneConfig(),this.controlsConfig=this.getControlsConfig();const r=this.validateAndCorrectZoneSize(e.points),s=Dm(r);this.zoneData=__spreadProps(__spreadValues({},e),{points:s}),this.throttledUpdateOutline=zg(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.createControlButtons(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){U_().emitter.on("antiScale",this.throttledUpdateOutline)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition())}getZoneConfig(){const t=U_(),{controls:e}=t.getConfig();return e[this.zoneType]}getControlsConfig(){const t=U_(),{controls:e}=t.getConfig();return e}validateAndCorrectZoneSize(t){const e=U_();if(t.length<4)return t;const i=e.metersToPixels(this.zoneConfig.minSize),[n,r,,s]=t,o=Um(n,r),a=Um(n,s);if(o>=i&&a>=i)return t;const l=Im(t),h=zm(Lm(n,r)),c=zm(Lm(n,s)),u=Math.max(o,i)/2,d=Math.max(a,i)/2;return[{x:l.x-h.x*u-c.x*d,y:l.y-h.y*u-c.y*d},{x:l.x+h.x*u-c.x*d,y:l.y+h.y*u-c.y*d},{x:l.x+h.x*u+c.x*d,y:l.y+h.y*u+c.y*d},{x:l.x-h.x*u+c.x*d,y:l.y-h.y*u+c.y*d}]}getEditingIdsKey(){switch(this.zoneType){case"forbiddenSweepZone":default:return"editingForbiddenSweepZoneIds";case"forbiddenMopZone":return"editingForbiddenMopZoneIds";case"cleanZone":return"editingCleanZoneIds"}}isEditingEnabled(){const t=this.getEditingIdsKey();return U_().runtimeSnapshot[t].includes(this.zoneData.id)}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 xe,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.drawZone()}createControlButtons(){const e=this.calculateOutlinePoints();if(e.length<4)return;this.deleteButton=new Ay({iconAlias:"deleteIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onClick:this.handleDelete}),this.deleteButton.position.set(e[t.BUTTON_INDICES.REMOVE].x,e[t.BUTTON_INDICES.REMOVE].y),this.zoneConfig.showRotateButton&&(this.rotateButton=new Sy({iconAlias:"rotateIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,onRotationStart:this.handleRotationStart,onRotationMove:this.handleRotationMove,onRotationEnd:this.handleRotationEnd}),this.rotateButton.position.set(e[t.BUTTON_INDICES.ROTATE].x,e[t.BUTTON_INDICES.ROTATE].y)),this.scaleButton=new Ty({iconAlias:"scaleIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,getButtonIndex:()=>t.BUTTON_INDICES.SCALE,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(e[t.BUTTON_INDICES.SCALE].x,e[t.BUTTON_INDICES.SCALE].y);const i=this.calculateMoveButtonPosition();this.moveButton=new Cy({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 Py({points:this.zoneData.points,fillColor:this.zoneConfig.fillColor,enableInteraction:t,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(){const t=this.isEditingEnabled()?this.zoneConfig.editing:this.zoneConfig.normal;return new My({points:this.zoneData.points,closePath:!0,style:{color:this.zoneConfig.strokeColor,width:this.zoneConfig.strokeWidth,isDashed:t.isDashed,dashArray:t.dashArray}})}createOutlineBorder(){const t=this.calculateOutlinePoints();return new My({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(),e=this.calculateMoveLinePoints(t);return new My({points:e,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;return((t,e)=>{if(t.length<3)return t;const i=[];for(let n=0;n<t.length;n++){const r=t[n],s=t[(n+1)%t.length],o=t[(n-1+t.length)%t.length],a=Lm(r,s);if(0===Gm(a)){i.push(r);continue}const l=zm(a),h={x:l.y,y:-l.x},c=Lm(o,r);let u={x:0,y:0};if(Gm(c)>0){const t=zm(c);u={x:t.y,y:-t.x}}const d=Wm(u,h),p=u.x*h.x+u.y*h.y,f=1/Math.max(.1,Math.sqrt((1+p)/2)),g={x:r.x+d.x*e*f,y:r.y+d.y*e*f};i.push(g)}return i})(t,U_().getApp().toFixedSize(this.zoneConfig.outlineOffset))}calculateMoveLinePoints(e){if(e.length<4)return[];return[e[t.BUTTON_INDICES.MOVE],this.calculateMoveButtonPosition()]}createSizeText(){const t=this.calculateZoneSizeText(),e=new Ey({text:t,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.zoneConfig.textColor,align:"center"}});e.anchor.set(.5);const i=this.calculateSizeTextPosition();e.position.set(i.x,i.y);const n=this.calculateSizeTextRotation();return e.rotation=n,e.eventMode="none",e}calculateZoneSizeText(){const{points:t}=this.zoneData;if(t.length<4)return"0m*0m";const[e,i,,n]=t,r=Um(e,i),s=Um(e,n),o=U_(),a=o.pixelsToMeters(r),l=o.pixelsToMeters(s);return`${a.toFixed(1)}${this.controlsConfig.unitLabel}*${l.toFixed(1)}${this.controlsConfig.unitLabel}`}calculateSizeTextPosition(){const{points:t}=this.zoneData;if(t.length<4)return{x:0,y:0};const[e,i,n,r]=t,{textPosition:s,textOffset:o}=this.zoneConfig,a=U_().getApp().toFixedSize(o);let l,h;switch(s){case"top":{l={x:(e.x+i.x)/2,y:(e.y+i.y)/2};const t=zm(Lm(i,e)),n={x:t.y,y:-t.x};h={x:n.x*a,y:n.y*a};break}case"right":{l={x:(i.x+n.x)/2,y:(i.y+n.y)/2};const t=zm(Lm(i,n)),e={x:t.y,y:-t.x};h={x:e.x*a,y:e.y*a};break}case"bottom":{l={x:(r.x+n.x)/2,y:(r.y+n.y)/2};const t=zm(Lm(r,n)),e={x:-t.y,y:t.x};h={x:e.x*a,y:e.y*a};break}case"left":{l={x:(e.x+r.x)/2,y:(e.y+r.y)/2};const t=zm(Lm(r,e)),i={x:t.y,y:-t.x};h={x:i.x*a,y:i.y*a};break}default:l={x:(e.x+i.x)/2,y:(e.y+i.y)/2},h={x:0,y:a}}return{x:l.x+h.x,y:l.y+h.y}}calculateSizeTextRotation(){const{points:t}=this.zoneData;if(t.length<4)return 0;const[e,i,n,r]=t,{textPosition:s}=this.zoneConfig;let o,a;switch(s){case"top":default:o=e,a=i;break;case"right":o=i,a=n;break;case"bottom":o=n,a=r;break;case"left":o=r,a=e}return jm(o,a)}calculateMoveButtonPosition(){const e=this.calculateOutlinePoints();if(e.length<4)return{x:0,y:0};const i=U_(),{controls:n}=i.getConfig(),r=e[t.BUTTON_INDICES.MOVE],s=e[2],o=e[0],a=i.getApp().toFixedSize(n.moveButtonOffset);return Zm(r,s,o,a)}applyTranslation(t,e){this.zoneData.points=this.initialZonePoints.map(i=>({x:i.x+t,y:i.y+e})),this.drawZone(),this.updateControlButtonsPosition()}applyRotation(t){this.rotationCenter&&(this.zoneData.points=Ym(this.zoneData.points,this.rotationCenter,t),this.drawZone(),this.updateControlButtonsPosition())}applyEdgeBasedScale(e){if(this.initialZonePoints.length<4)return;const i=U_(),{FIXED:n}=t.BUTTON_INDICES,{x:r,y:s}=this.initialZonePoints[n],[,o,,a]=this.initialZonePoints,l={x:r,y:s},h=Lm(l,o),c=Lm(l,a),u=Lm(l,e),d=Gm(h),p=Gm(c);if(0===d||0===p)return;const f=i.metersToPixels(this.zoneConfig.minSize),[g,m]=[Om(u,h,d,f),Om(u,c,p,f)];this.zoneData.points=[l,{x:r+h.x*g,y:s+h.y*g},{x:r+h.x*g+c.x*m,y:s+h.y*g+c.y*m},{x:r+c.x*m,y:s+c.y*m}],this.drawZone(),this.updateControlButtonsPosition()}setupClickHandler(){this.clickHandler=new iy(this,{onClick:()=>{var t,e;this.isEditingEnabled()||null==(e=null==(t=this.zoneEvents)?void 0:t.onClick)||e.call(t,this.getZoneData())},stopPropagation:!1})}drawZone(){const{points:t}=this.zoneData;t.length<4||(this.controlFill.updatePoints(t),this.zoneBorder.updatePoints(t),this.updateOutlineBorder(),this.updateMoveLine(),this.updateSizeText())}updateOutlineBorder(){const t=this.calculateOutlinePoints();this.outlineBorder.updatePoints(t)}updateMoveLine(){const t=this.calculateOutlinePoints(),e=this.calculateMoveLinePoints(t);this.moveLine.updatePoints(e)}updateSizeText(){if(!this.sizeText)return;const t=this.calculateZoneSizeText();this.sizeText.updateText(t),this.updateSizeTextPosition()}updateSizeTextPosition(){if(!this.sizeText)return;const t=this.calculateSizeTextPosition();this.sizeText.position.set(t.x,t.y);const e=this.calculateSizeTextRotation();this.sizeText.rotation=e}updateControlButtonsPosition(){if(!this.deleteButton||!this.scaleButton||!this.moveButton)return;const e=this.calculateOutlinePoints();if(e.length<4)return;const{REMOVE:i,ROTATE:n,SCALE:r}=t.BUTTON_INDICES,s=this.calculateMoveButtonPosition(),o=[{button:this.deleteButton,point:e[i]},{button:this.scaleButton,point:e[r]},{button:this.moveButton,point:s}];this.rotateButton&&o.push({button:this.rotateButton,point:e[n]}),o.forEach(({button:t,point:e})=>t.position.set(e.x,e.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 t,e,i;const n=this.controlFill.isCurrentlyDragging(),r=(null==(t=this.scaleButton)?void 0:t.isCurrentlyScaling())||!1,s=(null==(e=this.rotateButton)?void 0:e.isCurrentlyRotating())||!1,o=(null==(i=this.moveButton)?void 0:i.isCurrentlyMoving())||!1;return{isDragging:n,isScaling:r,isRotating:s,isMoving:o,hasAnyOperation:n||r||s||o}}stopAllOperations(){var t,e,i;this.controlFill.stopDragging(),null==(t=this.scaleButton)||t.stopScaling(),null==(e=this.rotateButton)||e.stopRotation(),null==(i=this.moveButton)||i.stopMoving()}stopDragging(){this.controlFill.stopDragging()}stopScaling(){var t;null==(t=this.scaleButton)||t.stopScaling()}stopRotating(){var t;null==(t=this.rotateButton)||t.stopRotation()}stopMoving(){var t;null==(t=this.moveButton)||t.stopMoving()}isCurrentlyDragging(){return this.controlFill.isCurrentlyDragging()}isCurrentlyScaling(){var t;return(null==(t=this.scaleButton)?void 0:t.isCurrentlyScaling())||!1}isCurrentlyRotating(){var t;return(null==(t=this.rotateButton)?void 0:t.isCurrentlyRotating())||!1}isCurrentlyMoving(){var t;return(null==(t=this.moveButton)?void 0:t.isCurrentlyMoving())||!1}updateZoneData(t){const e=this.validateAndCorrectZoneSize(t.points),i=Dm(e);this.zoneData=__spreadProps(__spreadValues({},t),{points:i}),this.drawZone(),this.updateControlButtonsPosition(),this.updateEditState()}getZoneData(){return __spreadValues({},this.zoneData)}destroy(){var t,e,i,n,r,s,o,a,l,h,c;U_().emitter.off("antiScale",this.throttledUpdateOutline),null==(t=this.clickHandler)||t.destroy(),this.clickHandler=null,null==(e=this.deleteButton)||e.destroy(),null==(i=this.rotateButton)||i.destroy(),null==(n=this.scaleButton)||n.destroy(),null==(r=this.moveButton)||r.destroy(),this.deleteButton=null,this.rotateButton=null,this.scaleButton=null,this.moveButton=null,null==(s=this.zoneBorder)||s.destroy(),null==(o=this.outlineBorder)||o.destroy(),null==(a=this.moveLine)||a.destroy(),null==(l=this.sizeText)||l.destroy(),null==(h=this.controlFill)||h.destroy(),null==(c=this.controlButtons)||c.destroy(),super.destroy()}};__publicField(Ry,"BUTTON_INDICES",{REMOVE:0,ROTATE:1,SCALE:2,MOVE:3,FIXED:0});let By=Ry;class Fy extends By{constructor(t){const e=U_();super({zoneData:t.zoneData,zoneType:"forbiddenSweepZone",events:{onRemove:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onRemoveForbiddenSweepZone)||n.call(i,t)},onUpdate:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onUpdateForbiddenSweepZone)||n.call(i,t)},onClick:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onClickForbiddenSweepZone)||n.call(i,t)}}})}static create(t){return new Fy({zoneData:t})}}class ky extends By{constructor(t){const e=U_();super({zoneData:t.zoneData,zoneType:"forbiddenMopZone",events:{onRemove:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onRemoveForbiddenMopZone)||n.call(i,t)},onUpdate:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onUpdateForbiddenMopZone)||n.call(i,t)},onClick:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onClickForbiddenMopZone)||n.call(i,t)}}})}static create(t){return new ky({zoneData:t})}}class Iy extends By{constructor(t){const e=U_();super({zoneData:t.zoneData,zoneType:"cleanZone",events:{onRemove:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onRemoveCleanZone)||n.call(i,t)},onUpdate:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onUpdateCleanZone)||n.call(i,t)},onClick:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onClickCleanZone)||n.call(i,t)}}})}static create(t){return new Iy({zoneData:t})}}class Dy extends fl{constructor(t){super(),__publicField(this,"lineOptions"),__publicField(this,"strokeContext",null),__publicField(this,"drawDashLine",()=>{const{start:t,end:e,style:i}=this.lineOptions;this.clear(),this.strokeContext&&this.strokeContext.destroy();const n=U_();this.strokeContext=new Do;const r=n.getApp().toFixedSize(i.width);this.strokeContext.setStrokeStyle({color:i.color,width:r}),this.drawDashedLineToContext(this.strokeContext,t.x,t.y,e.x,e.y,i.dashArray[0],i.dashArray[1]),this.strokeContext.stroke(),this.context=this.strokeContext}),this.lineOptions=__spreadValues({},t),this.eventMode="static",this.drawDashLine(),this.setupAntiScaleListener()}setupAntiScaleListener(){U_().emitter.on("antiScale",this.drawDashLine)}drawDashedLineToContext(t,e,i,n,r,s,o){const a=n-e,l=r-i,h=Math.sqrt(a*a+l*l);if(0===h)return;const c=U_(),u=c.getApp().toFixedSize(s),d=u+c.getApp().toFixedSize(o),p=h/d,f=Math.round(p);if(0===f)return t.moveTo(e,i),void t.lineTo(n,r);const g=h/f,m=g*(u/d),_=a/h,y=l/h;for(let x=0;x<f;x++){const n=x*g,r=n+m;if(n>=h)break;const s=Math.min(r,h),o=e+n*_,a=i+n*y,l=e+s*_,c=i+s*y;t.moveTo(o,a),t.lineTo(l,c)}}updatePoints(t,e){this.lineOptions.start=t,this.lineOptions.end=e,this.drawDashLine()}updateStyle(t){this.lineOptions.style=__spreadValues(__spreadValues({},this.lineOptions.style),t),this.drawDashLine()}getOptions(){return __spreadValues({},this.lineOptions)}destroy(){U_().emitter.off("antiScale",this.drawDashLine),this.strokeContext&&this.strokeContext.destroy(),super.destroy()}}const Oy=class t extends xe{constructor(t){super(),__publicField(this,"wallData"),__publicField(this,"wallConfig"),__publicField(this,"controlsConfig"),__publicField(this,"wallEvents"),__publicField(this,"wallLine"),__publicField(this,"outlineBorder"),__publicField(this,"moveLine"),__publicField(this,"lengthText"),__publicField(this,"controlButtons"),__publicField(this,"removeButton",null),__publicField(this,"scaleButton",null),__publicField(this,"moveButton",null),__publicField(this,"initialWallPoints",[]),__publicField(this,"isDragging",!1),__publicField(this,"dragStartPosition",null),__publicField(this,"throttledUpdateOutline"),__publicField(this,"throttledHandleScaleChange"),__publicField(this,"wallLineClickHandler",null),__publicField(this,"handleRemove",()=>{var t,e;null==(e=(t=this.wallEvents).onRemove)||e.call(t,this.wallData.id)}),__publicField(this,"initializeOperation",()=>{this.initialWallPoints=this.wallData.points.map(t=>__spreadValues({},t))}),__publicField(this,"finalizeOperation",()=>{var t,e;this.initialWallPoints=[],null==(e=(t=this.wallEvents).onUpdate)||e.call(t,this.getWallData())}),__publicField(this,"handleScaleStart",()=>{const t=U_();this.initializeOperation(),t.getApp().requestRender("virtualwall-scale",!0)}),__publicField(this,"handleScaleMove",t=>{0!==this.initialWallPoints.length&&this.applyScaleAndRotation(t)}),__publicField(this,"handleScaleEnd",()=>{const t=U_();this.finalizeOperation(),t.getApp().stopRender("virtualwall-scale")}),__publicField(this,"handleMoveStart",()=>{const t=U_();this.initializeOperation(),t.getApp().requestRender("virtualwall-move",!0)}),__publicField(this,"handleMove",t=>{var e;if(0===this.initialWallPoints.length)return;const i=this.parent.toLocal(t.global),n=this.getDragStartPosition()||(null==(e=this.moveButton)?void 0:e.getDragStartPosition());if(!n)return;const r=i.x-n.x,s=i.y-n.y;this.applyTranslation(r,s)}),__publicField(this,"handleMoveEnd",()=>{const t=U_();this.finalizeOperation(),t.getApp().stopRender("virtualwall-move")}),__publicField(this,"handleScaleChange",()=>{this.redrawSolidLine(),this.setupWallLineHitArea()}),__publicField(this,"handleWallLinePointerDown",t=>{this.isEditingEnabled()&&(t.stopPropagation(),this.startDragging(t))}),__publicField(this,"handleDragPointerMove",t=>{this.isDragging&&this.dragStartPosition&&this.handleMove(t)}),__publicField(this,"handleDragPointerUp",()=>{const t=U_();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("virtualwall-drag"),this.finalizeOperation())}),__publicField(this,"handleDragCancel",()=>{const t=U_();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("virtualwall-drag"),this.handleMoveEnd())});const{wallData:e,events:i={}}=t;this.wallEvents=i;const n=U_();this.wallConfig=n.controlsConfig.virtualWall,this.controlsConfig=n.controlsConfig,this.wallData=__spreadProps(__spreadValues({},e),{points:this.validateAndCorrectWallLength(e.points)}),this.throttledHandleScaleChange=zg(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.throttledUpdateOutline=zg(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.registerScaleListener(),this.setupDragEventListeners()}validateAndCorrectWallLength(t){const e=U_();if(t.length<2)return t;const[i,n]=t,r=e.metersToPixels(this.wallConfig.minWidth),s=Um(i,n);if(s>=r)return t;if(0===s)return[i,{x:i.x+r,y:i.y}];const o=zm(Lm(i,n));return[i,{x:i.x+o.x*r,y:i.y+o.y*r}]}isEditingEnabled(){return U_().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 xe,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.createControlButtons()}createWallLine(t=!0){const{points:e}=this.wallData;if(e.length<2)return;const{lineWidth:i,lineColor:n,editing:r,normal:s}=this.wallConfig,o=this.isEditingEnabled()?r:s;o.isDashed?this.wallLine=new Dy({start:e[0],end:e[1],style:{color:n.toString(),width:i,dashArray:o.dashArray}}):this.wallLine=this.createSolidLine(e[0],e[1],i,n.toString()),t&&this.setupWallLineInteraction()}createLengthText(){const t=this.calculateWallLengthInMeters(),e=this.formatLengthText(t),i=new Ey({text:e,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.wallConfig.textColor,align:"center"}});i.anchor.set(.5);const n=this.calculateTextPosition();i.position.set(n.x,n.y);const r=this.calculateTextRotation();return i.rotation=r,i.eventMode="none",i}calculateWallLengthInMeters(){const t=U_(),{points:e}=this.wallData;if(e.length<2)return 0;const i=Um(e[0],e[1]);return t.pixelsToMeters(i)}formatLengthText(t){return`${t.toFixed(1)}${this.controlsConfig.unitLabel}`}calculateTextPosition(){const t=U_(),{points:e}=this.wallData;if(e.length<2)return{x:0,y:0};const[i,n]=e;return((t,e,i)=>{const n=Im([t,e]),r=Hm(t,e);return{x:n.x+r.x*i,y:n.y+r.y*i}})(i,n,t.getApp().toFixedSize(this.wallConfig.textOffset))}calculateTextRotation(){const{points:t}=this.wallData;if(t.length<2)return 0;const[e,i]=t;return jm(e,i)}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 My({points:t,closePath:!0,style:this.getOutlineStyle()})}createMoveLine(){const t=this.calculateOutlinePoints(),e=this.calculateMoveLinePoints(t);return new My({points:e,closePath:!1,style:this.getOutlineStyle()})}calculateOutlinePoints(t){const e=U_(),i=t||this.wallData.points;if(i.length<2)return i;const n=e.getApp().toFixedSize(this.wallConfig.outlineOffset),r=((t,e,i)=>{if(0===Um(t,e))return[t,t,t,t];const n=Nm(t,e),r=Vm(n),s=t.x-n.x*i,o=t.y-n.y*i,a=e.x+n.x*i,l=e.y+n.y*i;return[{x:s+r.x*i,y:o+r.y*i},{x:a+r.x*i,y:l+r.y*i},{x:a-r.x*i,y:l-r.y*i},{x:s-r.x*i,y:o-r.y*i}]})(i[0],i[1],n);return[r[3],r[2],r[1],r[0]]}calculateMoveLinePoints(e){if(e.length<4)return[];const{MOVE:i}=t.BUTTON_INDICES;return[e[i],this.calculateMoveButtonPosition()]}calculateMoveButtonPosition(){const e=U_(),{moveButtonOffset:i}=this.controlsConfig,n=this.calculateOutlinePoints();if(n.length<4)return{x:0,y:0};const{MOVE:r}=t.BUTTON_INDICES,s=n[r],o=n[(r+3)%4],a=n[(r+1)%4],l=e.getApp().toFixedSize(i);return Zm(s,a,o,l)}createControlButtons(){const e=this.calculateOutlinePoints();if(e.length<4)return;const{REMOVE:i,SCALE:n}=t.BUTTON_INDICES;this.removeButton=new Ay({iconAlias:"deleteIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onClick:this.handleRemove}),this.removeButton.position.set(e[i].x,e[i].y),this.scaleButton=new Ty({iconAlias:"scaleIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,getTargetPoints:()=>this.calculateOutlinePoints(),getButtonIndex:()=>n,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(e[n].x,e[n].y);const r=this.calculateMoveButtonPosition();this.moveButton=new Cy({iconAlias:"moveIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(r.x,r.y),this.controlButtons.addChild(this.removeButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}applyScaleAndRotation(e){const i=U_();if(this.initialWallPoints.length<2)return;const[n,r]=this.initialWallPoints,s=n,o=this.calculateOutlinePoints(this.initialWallPoints);if(o.length<4)return;const a=o[t.BUTTON_INDICES.SCALE],l=Lm(r,a),h={x:e.x-l.x,y:e.y-l.y},c=Lm(s,h),u=Um(s,h),d=i.metersToPixels(this.wallConfig.minWidth);let p;if(u<d)if(0===u)p={x:s.x+d,y:s.y};else{const t=zm(c);p={x:s.x+t.x*d,y:s.y+t.y*d}}else p=h;this.wallData.points=[s,p],this.updateAllComponents(),this.updateControlButtonsPosition()}applyTranslation(t,e){this.wallData.points=this.initialWallPoints.map(i=>({x:i.x+t,y:i.y+e})),this.updateAllComponents(),this.updateControlButtonsPosition()}updateAllComponents(){this.updateWallLine(),this.updateLengthText(),this.updateOutlineComponents()}updateWallLine(){const{points:t}=this.wallData;t.length<2||(this.wallLine instanceof Dy?this.wallLine.updatePoints(t[0],t[1]):this.redrawSolidLine(),this.setupWallLineHitArea())}updateLengthText(){if(!this.lengthText)return;const t=this.calculateWallLengthInMeters(),e=this.formatLengthText(t);this.lengthText.updateText(e),this.updateLengthTextPosition()}updateLengthTextPosition(){if(!this.lengthText)return;const t=this.calculateTextPosition();this.lengthText.position.set(t.x,t.y);const e=this.calculateTextRotation();this.lengthText.rotation=e}updateOutlineComponents(){const t=this.calculateOutlinePoints();this.outlineBorder.updatePoints(t);const e=this.calculateMoveLinePoints(t);this.moveLine.updatePoints(e)}updateControlButtonsPosition(){if(!this.removeButton||!this.scaleButton||!this.moveButton)return;const e=this.calculateOutlinePoints();if(e.length<4)return;const{REMOVE:i,SCALE:n}=t.BUTTON_INDICES,r=this.calculateMoveButtonPosition();this.removeButton.position.set(e[i].x,e[i].y),this.scaleButton.position.set(e[n].x,e[n].y),this.moveButton.position.set(r.x,r.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,e,i,n){const r=U_(),s=new fl;s.eventMode="static";const o=r.getApp().toFixedSize(i);return s.moveTo(t.x,t.y),s.lineTo(e.x,e.y),s.stroke({color:n,width:o}),s}updateWallLineStyle(){const t=this.isEditingEnabled(),{editing:e,normal:i,lineWidth:n,lineColor:r}=this.wallConfig,s=t?e:i;this.wallLine instanceof Dy!==s.isDashed?(this.removeChild(this.wallLine),this.wallLine.destroy(),this.createWallLine(!1),this.addChild(this.wallLine)):this.wallLine instanceof Dy?this.wallLine.updateStyle({color:r.toString(),width:n,dashArray:s.dashArray}):this.redrawSolidLine()}registerScaleListener(){const{emitter:t}=U_();t.on("antiScale",this.throttledUpdateOutline),t.on("antiScale",this.throttledHandleScaleChange)}redrawSolidLine(){const t=U_();if(!this.wallLine||this.wallLine instanceof Dy)return;const{points:e}=this.wallData;if(e.length<2)return;const{lineWidth:i,lineColor:n}=this.wallConfig,r=t.getApp().toFixedSize(i);this.wallLine.clear(),this.wallLine.setStrokeStyle({color:n.toString(),width:r}).moveTo(e[0].x,e[0].y).lineTo(e[1].x,e[1].y).stroke()}setupWallLineInteraction(){var t;if(!this.wallLine)return;this.setupWallLineHitArea();const e=this.isEditingEnabled();null==(t=this.wallLineClickHandler)||t.destroy(),this.wallLineClickHandler=null,this.wallLine.off("pointerdown",this.handleWallLinePointerDown),e?this.wallLine.on("pointerdown",this.handleWallLinePointerDown):this.wallLineClickHandler=new iy(this.wallLine,{onClick:()=>{var t,e;null==(e=null==(t=this.wallEvents)?void 0:t.onClick)||e.call(t,this.getWallData())},stopPropagation:!1})}setupDragEventListeners(){const{emitter:t}=U_();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=U_();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}startDragging(t){const e=U_();this.isDragging=!0;const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},this.initializeOperation(),e.getApp().requestRender("virtualwall-drag",!0),U_().emitter.emit("gestureHijackStart",t)}getDragStartPosition(){return this.dragStartPosition}setupWallLineHitArea(){const t=U_();if(!this.wallLine)return;const{points:e}=this.wallData;if(e.length<2)return;const{hitAreaThickness:i}=this.wallConfig,n=t.getApp().toFixedSize(i),r=Xm(e[0],e[1],n);if(0===r.length)return;const s=new xr(r);this.wallLine.hitArea=s}getWallData(){return __spreadValues({},this.wallData)}updateWallData(t){this.wallData=__spreadProps(__spreadValues({},t),{points:this.validateAndCorrectWallLength(t.points)}),this.updateAllComponents(),this.updateControlButtonsPosition()}updateEditingState(){this.updateEditState()}destroy(){var t,e,i,n,r,s,o,a,l;U_().emitter.off("antiScale",this.throttledUpdateOutline),U_().emitter.off("antiScale",this.throttledHandleScaleChange),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.wallLine&&this.wallLine.off("pointerdown",this.handleWallLinePointerDown),null==(t=this.wallLineClickHandler)||t.destroy(),this.wallLineClickHandler=null,null==(e=this.wallLine)||e.destroy(),null==(i=this.lengthText)||i.destroy(),null==(n=this.outlineBorder)||n.destroy(),null==(r=this.moveLine)||r.destroy(),null==(s=this.controlButtons)||s.destroy(),null==(o=this.removeButton)||o.destroy(),null==(a=this.scaleButton)||a.destroy(),null==(l=this.moveButton)||l.destroy(),this.removeButton=null,this.scaleButton=null,this.moveButton=null,super.destroy()}};__publicField(Oy,"BUTTON_INDICES",{REMOVE:0,SCALE:2,MOVE:3});let Uy=Oy;class Gy extends xe{constructor(t){super(),__publicField(this,"spotData"),__publicField(this,"spotConfig"),__publicField(this,"controlsConfig"),__publicField(this,"spotEvents"),__publicField(this,"controlFill"),__publicField(this,"spotBorder"),__publicField(this,"centerIcon"),__publicField(this,"sizeText"),__publicField(this,"clickHandler",null),__publicField(this,"initialSpotPoint",null),__publicField(this,"throttledUpdateScale"),__publicField(this,"handleDragStart",()=>{const t=U_();this.isEditingEnabled()&&(this.initialSpotPoint=__spreadValues({},this.spotData.point),t.getApp().requestRender("spot-drag",!0))}),__publicField(this,"handleDragMove",t=>{if(!this.isEditingEnabled()||!this.initialSpotPoint)return;const e=this.parent.toLocal(t.global),i=this.controlFill.getDragStartPosition();if(!i)return;const n=e.x-i.x,r=e.y-i.y;this.applyTranslation(n,r)}),__publicField(this,"handleDragEnd",()=>{var t,e;const i=U_();this.initialSpotPoint=null,i.getApp().stopRender("spot-drag"),null==(e=(t=this.spotEvents).onUpdate)||e.call(t,this.getSpotData())});const{spotData:e,events:i={}}=t,n=U_();this.spotData=e,this.spotEvents=i,this.controlsConfig=n.controlsConfig,this.spotConfig=n.controlsConfig.spot,this.throttledUpdateScale=zg(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){U_().emitter.on("antiScale",this.throttledUpdateScale)}updateScale(){this.isEditingEnabled()&&this.updateSizeTextPosition()}isEditingEnabled(){return U_().runtimeSnapshot.editingSpotIds.includes(this.spotData.id)}calculateRectanglePoints(){const t=U_(),{point:e}=this.spotData,{size:i}=this.spotConfig,n=t.metersToPixels(i)/2;return[{x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n},{x:e.x-n,y:e.y+n}]}initializeComponents(){const t=this.calculateRectanglePoints();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.sizeText=this.createSizeText(),this.addChild(this.sizeText),this.drawSpot()}createControlFill(t){const e=this.isEditingEnabled();return new Py({points:t,fillColor:this.spotConfig.fillColor,enableInteraction:e,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(t){const e=this.isEditingEnabled()?this.spotConfig.editing:this.spotConfig.normal;return new My({points:t,closePath:!0,style:{color:this.spotConfig.strokeColor,width:this.spotConfig.strokeWidth,isDashed:e.isDashed,dashArray:e.dashArray}})}createCenterIcon(){const t=new oy;return this.loadIconTexture(t),t.position.set(this.spotData.point.x,this.spotData.point.y),t.eventMode="none",t.visible=!1,t}loadIconTexture(t){return __async(this,null,function*(){const{iconSize:e}=this.spotConfig;yield t.loadTextureAndSetSize("spotIcon",{width:e,height:e,sizeFixed:!1}),t.visible=this.isEditingEnabled()})}createSizeText(){const t=this.calculateSpotSizeText(),e=new Ey({text:t,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.spotConfig.textColor,align:"center"}});e.anchor.set(.5);const i=this.calculateSizeTextPosition();return e.position.set(i.x,i.y),e.eventMode="none",e}calculateSpotSizeText(){const{size:t}=this.spotConfig;return`${t.toFixed(1)}${this.controlsConfig.unitLabel}*${t.toFixed(1)}${this.controlsConfig.unitLabel}`}calculateSizeTextPosition(){const t=U_(),e=this.calculateRectanglePoints();if(e.length<4)return{x:0,y:0};const[i,n,r,s]=e,{textPosition:o,textOffset:a}=this.spotConfig,l=t.getApp().toFixedSize(a);let h,c;switch(o){case"top":default:h={x:(i.x+n.x)/2,y:(i.y+n.y)/2},c={x:h.x,y:h.y+l};break;case"right":h={x:(n.x+r.x)/2,y:(n.y+r.y)/2},c={x:h.x+l,y:h.y};break;case"bottom":h={x:(s.x+r.x)/2,y:(s.y+r.y)/2},c={x:h.x,y:h.y+l};break;case"left":h={x:(i.x+s.x)/2,y:(i.y+s.y)/2},c={x:h.x-l,y:h.y}}return c}applyTranslation(t,e){this.initialSpotPoint&&(this.spotData.point={x:this.initialSpotPoint.x+t,y:this.initialSpotPoint.y+e},this.drawSpot())}setupClickHandler(){this.clickHandler=new iy(this,{onClick:()=>{var t,e;this.isEditingEnabled()||null==(e=null==(t=this.spotEvents)?void 0:t.onClick)||e.call(t,this.getSpotData())},stopPropagation:!1})}drawSpot(){const t=this.calculateRectanglePoints();this.controlFill.updatePoints(t),this.spotBorder.updatePoints(t),this.centerIcon.position.set(this.spotData.point.x,this.spotData.point.y),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();if(this.sizeText&&(this.sizeText.visible=t),this.centerIcon&&(this.centerIcon.visible=t),this.controlFill&&this.controlFill.setInteractionEnabled(t),this.spotBorder){const e=t?this.spotConfig.editing:this.spotConfig.normal;this.spotBorder.updateStyle({isDashed:e.isDashed,dashArray:e.dashArray})}this.zIndex=t?1e3:0}updateSpotData(t){this.spotData=__spreadValues({},t),this.drawSpot(),this.updateEditState()}getSpotData(){return __spreadValues({},this.spotData)}destroy(){var t,e,i,n,r;U_().emitter.off("antiScale",this.throttledUpdateScale),null==(t=this.clickHandler)||t.destroy(),this.clickHandler=null,null==(e=this.controlFill)||e.destroy(),null==(i=this.spotBorder)||i.destroy(),null==(n=this.centerIcon)||n.destroy(),null==(r=this.sizeText)||r.destroy(),super.destroy()}static create(t){const e=U_();return new Gy({spotData:t,events:{onUpdate:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onUpdateSpot)||n.call(i,t)},onClick:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onClickSpot)||n.call(i,t)}}})}}class Ly extends fl{constructor(t){super(),__publicField(this,"isDragging",!1),__publicField(this,"dragStartPosition",null),__publicField(this,"initialPosition"),__publicField(this,"handleDragPointerMove",t=>{var e,i;if(!this.isDragging||!this.dragStartPosition)return;const n=this.parent.toLocal(t.global),r=n.x-this.dragStartPosition.x,s=n.y-this.dragStartPosition.y,o={x:this.initialPosition.x+r,y:this.initialPosition.y+s};this.position.set(o.x,o.y),null==(i=(e=this.options).onDragMove)||i.call(e,o)}),__publicField(this,"handleDragPointerUp",()=>{var t,e;if(!this.isDragging)return;const i=U_();this.isDragging=!1,this.dragStartPosition=null,i.getApp().stopRender("endpoint-drag"),null==(e=(t=this.options).onDragEnd)||e.call(t)}),__publicField(this,"handleDragCancel",()=>{var t,e;if(!this.isDragging)return;const i=U_();this.isDragging=!1,this.dragStartPosition=null,i.getApp().stopRender("endpoint-drag"),null==(e=(t=this.options).onDragEnd)||e.call(t)}),this.options=t,this.initialPosition=__spreadValues({},t.position),this.position.set(t.position.x,t.position.y),this.eventMode="static",this.cursor="pointer",this.setupEvents(),this.draw(),this.setupDragEventListeners()}draw(){const t=U_(),{config:e}=this.options,i=t.getApp().toFixedSize(e.endPointSize),n=t.getApp().toFixedSize(e.endPointStrokeWidth);this.clear(),this.circle(0,0,i/2),this.fill({color:e.endPointColor}),this.stroke({color:e.endPointStrokeColor,width:n}),this.setupHitArea()}setupHitArea(){const t=U_(),{config:e}=this.options,i=Math.max(e.endPointSize/2+10,20),n=t.getApp().toFixedSize(i);this.hitArea=new mr(0,0,n)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}setupDragEventListeners(){const{emitter:t}=U_();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=U_();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 e,i;const n=U_();this.isDragging=!0,this.dragStartPosition=this.parent.toLocal(t.global),this.initialPosition={x:this.x,y:this.y},null==(i=(e=this.options).onDragStart)||i.call(e),n.getApp().requestRender("endpoint-drag",!0),U_().emitter.emit("gestureHijackStart",t)}updatePosition(t){this.position.set(t.x,t.y),this.initialPosition=__spreadValues({},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 zy extends xe{constructor(t){super(),__publicField(this,"endPoints"),__publicField(this,"dividerConfig"),__publicField(this,"dividerEvents"),__publicField(this,"roomId"),__publicField(this,"roomGeometry",null),__publicField(this,"dashLine"),__publicField(this,"solidLine",null),__publicField(this,"startEndPoint"),__publicField(this,"endEndPoint"),__publicField(this,"solidLinePoints",null),__publicField(this,"initialDividerPoints",[]),__publicField(this,"isDragging",!1),__publicField(this,"dragStartPosition",null),__publicField(this,"throttledHandleScaleChange"),__publicField(this,"handleEndPointDragStart",()=>{const t=U_();this.initialDividerPoints=this.endPoints.map(t=>__spreadValues({},t)),this.clearSolidLine(),t.getApp().requestRender("divider-endpoint-drag",!0)}),__publicField(this,"handleEndPointDragMove",(t,e)=>{0!==this.initialDividerPoints.length&&(this.endPoints[t]=e,this.updateDashLine(),this.updateSolidLine(),this.setupDashLineHitArea())}),__publicField(this,"handleEndPointDragEnd",()=>{var t,e;const i=U_();this.initialDividerPoints=[],i.getApp().stopRender("divider-endpoint-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),null==(e=(t=this.dividerEvents).onUpdate)||e.call(t,this.getDividerEndPoints())}),__publicField(this,"handleDashLinePointerDown",t=>{t.stopPropagation(),this.startDragging(t)}),__publicField(this,"handleDragPointerMove",t=>{if(!this.isDragging||!this.dragStartPosition||0===this.initialDividerPoints.length)return;const e=this.parent.toLocal(t.global),i=e.x-this.dragStartPosition.x,n=e.y-this.dragStartPosition.y;this.endPoints=this.initialDividerPoints.map(t=>({x:t.x+i,y:t.y+n})),this.updateAllComponents()}),__publicField(this,"handleDragPointerUp",()=>{var t,e;const i=U_();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],i.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),null==(e=(t=this.dividerEvents).onUpdate)||e.call(t,this.getDividerEndPoints()))}),__publicField(this,"handleDragCancel",()=>{var t,e;const i=U_();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],i.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),null==(e=(t=this.dividerEvents).onUpdate)||e.call(t,this.getDividerEndPoints()))}),__publicField(this,"handleScaleChange",()=>{var t,e;null==(t=this.startEndPoint)||t.redraw(),null==(e=this.endEndPoint)||e.redraw(),this.updateSolidLine(),this.setupDashLineHitArea()});const{endPoints:e,roomId:i,events:n={}}=t;this.dividerEvents=n,this.roomId=i;const r=U_();this.dividerConfig=r.dividerConfig,this.roomGeometry=r.mapManager.getRoomById(this.roomId)||null,this.endPoints=e?this.validateDividerPoints(e):this.createDefaultdividerPoints(),this.throttledHandleScaleChange=zg(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 e=t[0]||{x:0,y:0};return[e,{x:e.x+50,y:e.y}]}createDefaultdividerPoints(){if(!this.roomGeometry)return vm.warn("Room geometry not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const t=U_(),e=t.getApp().mapState;if(!e)return vm.warn("Map state not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const{boundingBox:i}=this.roomGeometry,n=t.getApp().toFixedSize(this.dividerConfig.defaultExtension),r=this.dividerConfig.defaultDirection,s=i.x+i.width/2,o=i.y+i.height/2,a="horizontal"===r?i.width+2*n:i.height+2*n;return e_(s,o,a,r).map(t=>({x:t.x-e.origin.x,y:t.y-e.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:e,dashLineDashArray:i,lineColor:n}=this.dividerConfig;this.dashLine=new Dy({start:t[0],end:t[1],style:{color:n.toString(),width:e,dashArray:i}})}createEndPoints(){const t=this.endPoints;this.startEndPoint=new Ly({position:t[0],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:t=>this.handleEndPointDragMove(0,t),onDragEnd:this.handleEndPointDragEnd}),this.endEndPoint=new Ly({position:t[1],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:t=>this.handleEndPointDragMove(1,t),onDragEnd:this.handleEndPointDragEnd})}setupDashLineInteraction(){this.dashLine&&(this.setupDashLineHitArea(),this.dashLine.off("pointerdown",this.handleDashLinePointerDown),this.dashLine.on("pointerdown",this.handleDashLinePointerDown))}setupDashLineHitArea(){const t=U_();if(!this.dashLine)return;const e=this.endPoints;if(e.length<2)return;const{hitAreaThickness:i}=this.dividerConfig,n=t.getApp().toFixedSize(i),r=Xm(e[0],e[1],n);if(0===r.length)return;const s=new xr(r);this.dashLine.hitArea=s}startDragging(t){const e=U_();this.isDragging=!0;const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},this.initialDividerPoints=this.endPoints.map(t=>__spreadValues({},t)),this.clearSolidLine(),e.getApp().requestRender("divider-drag",!0),U_().emitter.emit("gestureHijackStart",t)}setupDragEventListeners(){const{emitter:t}=U_();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=U_();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:e}=this.dividerConfig,i=U_().getApp().toFixedSize(t);this.solidLine.clear(),this.solidLine.setStrokeStyle({color:e.toString(),width:i}).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}=U_();t.on("antiScale",this.throttledHandleScaleChange)}getDividerEndPoints(){return[...this.endPoints]}getEffectiveDividerPoints(){return this.solidLinePoints?[...this.solidLinePoints]:null}calculateAndCreateSolidLine(){if(this.clearSolidLine(),!this.roomId)return;if(!this.getRoomGraphics())return;const t=this.calculateLineRoomIntersection();t&&t.length>=2&&(this.solidLinePoints=[t[0],t[t.length-1]],this.createSolidLine())}getRoomGraphics(){const t=U_().mapManager.roomFill;if(!t||!this.roomId)return null;return t.getRoomGraphicsMap().get(this.roomId)||null}calculateLineRoomIntersection(){const t=this.endPoints;if(t.length<2)return null;if(!this.roomId)return null;const[e,i]=t,n=this.isPointInRoomFill(e),r=this.isPointInRoomFill(i);if(n||r)return null;const s=((t,e,i=1,n=2e3)=>{const r=[],s=e.x-t.x,o=e.y-t.y,a=Math.sqrt(s*s+o*o);if(0===a)return[t];const l=Math.min(Math.max(Math.ceil(a/i),2),n);for(let h=0;h<=l;h++){const e=h/l,i={x:t.x+e*s,y:t.y+e*o};r.push(i)}return r})(e,i),o=[];for(const c of s)this.isPointInRoomFill(c)&&o.push(c);if(0===o.length)return null;const a=o[0],l=o[o.length-1];if(Um(a,l)<3)return null;const h=((t,e,i)=>{const n=e.x-t.x,r=e.y-t.y,s=Math.sqrt(n*n+r*r);if(0===s)return[t,e];const o=n/s,a=r/s;return[{x:t.x-o*i,y:t.y-a*i},{x:e.x+o*i,y:e.y+a*i}]})(a,l,.5);return h}isPointInRoomFill(t){if(!this.roomId)return!1;const e=U_().getApp().mapState;if(!e)return!1;const i={x:t.x+e.origin.x,y:t.y+e.origin.y};return"raster"===e.mapType?this.isPointInRasterRoomFill(i):this.isPointInStructuredRoomFill(i)}isPointInRasterRoomFill(t){t.x-=.5,t.y-=.5;const e=U_(),i=e.getApp().mapState,n=e.mapManager.roomFill;if(!i||!n)return!1;const r=n.getRasterRoomData(this.roomId);if(!r)return!1;const s=n.getMapWidth();if(0===s)return!1;const o=Math.round(t.y)*s+Math.round(t.x);for(let a=0;a<r.pixelIndices.length;a++)if(r.pixelIndices[a]===o)return!0;return!1}isPointInStructuredRoomFill(t){const e={x:Math.round(t.x),y:Math.round(t.y)},i=U_(),n=i.getApp().mapState,r=i.mapManager.getRoomById(this.roomId);return!!(n&&r&&r.outlinePoints)&&Rm(e,r.outlinePoints,!0)}isDividerCompletelyOutOfRoom(){if(!this.roomGeometry)return!1;const{boundingBox:t}=this.roomGeometry,e=this.endPoints;if(e.length<2)return!1;const i=U_().getApp().mapState;if(!i)return!1;return!((t,e,i,n,r,s)=>{const o=i+r,a=n+s,l=Math.min(t.x,e.x),h=Math.max(t.x,e.x),c=Math.min(t.y,e.y),u=Math.max(t.y,e.y);if(h<i||l>o||u<n||c>a)return!1;if(t_(t,i,n,r,s)||t_(e,i,n,r,s))return!0;const d=[{x:i,y:n},{x:o,y:n},{x:o,y:a},{x:i,y:a}];for(let p=0;p<4;p++)if(Km(t,e,d[p],d[(p+1)%4]))return!0;return!1})({x:e[0].x+i.origin.x,y:e[0].y+i.origin.y},{x:e[1].x+i.origin.x,y:e[1].y+i.origin.y},t.x,t.y,t.width,t.height)}checkAndResetIfOutOfRoom(){const t=U_(),{resetDividerWhenOutOfRoom:e}=t.dividerConfig;e&&this.isDividerCompletelyOutOfRoom()&&this.resetToDefaultState()}resetToDefaultState(){var t,e;this.endPoints=this.createDefaultdividerPoints(),this.calculateAndCreateSolidLine(),this.updateComponents(),null==(e=(t=this.dividerEvents).onUpdate)||e.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:e}=this.dividerConfig,i=U_();this.solidLine=new fl,this.solidLine.eventMode="none";const n=i.getApp().toFixedSize(t);this.solidLine.setStrokeStyle({color:e.toString(),width:n}).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,e,i;U_().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(),null==(t=this.dashLine)||t.destroy(),null==(e=this.startEndPoint)||e.destroy(),null==(i=this.endEndPoint)||i.destroy(),super.destroy()}}class Ny{constructor(){__publicField(this,"forbiddenSweepZoneMap",new Map),__publicField(this,"forbiddenMopZoneMap",new Map),__publicField(this,"cleanZoneMap",new Map),__publicField(this,"virtualWallMap",new Map),__publicField(this,"spotMap",new Map),__publicField(this,"divider",null),__publicField(this,"unsubscribeFns",[]);const t=U_(),e=ly(t.runtime,"editingForbiddenSweepZoneIds",t=>{vm.log(`[runtime] editingForbiddenSweepZoneIds: ${t}`),this.updateZonesEditState(this.forbiddenSweepZoneMap)}),i=ly(t.runtime,"editingForbiddenMopZoneIds",t=>{vm.log(`[runtime] editingForbiddenMopZoneIds: ${t}`),this.updateZonesEditState(this.forbiddenMopZoneMap)}),n=ly(t.runtime,"editingCleanZoneIds",t=>{vm.log(`[runtime] editingCleanZoneIds: ${t}`),this.updateZonesEditState(this.cleanZoneMap)}),r=ly(t.runtime,"editingVirtualWallIds",t=>{vm.log(`[runtime] editingVirtualWallIds: ${t}`),this.updateVirtualWallsEditState(this.virtualWallMap)}),s=ly(t.runtime,"editingSpotIds",t=>{vm.log(`[runtime] editingSpotIds: ${t}`),this.updateSpotsEditState(this.spotMap)}),o=ly(t.runtime,"dividingRoomId",t=>{vm.log(`[runtime] dividingRoomId: ${t}`),this.handleDividingRoomIdChange(t)});this.unsubscribeFns.push(e,i,n,r,s,o)}updatePositionByOrigin(t,e){const i=U_().appContainer.getLayer(Y_);i&&i.position.set(t,e)}drawForbiddenSweepZones(t){this.drawZones(t,this.forbiddenSweepZoneMap,t=>Fy.create(t))}getForbiddenSweepZones(){return this.getZonesData(this.forbiddenSweepZoneMap)}clearAllForbiddenSweepZones(){this.clearAllZones(this.forbiddenSweepZoneMap)}drawForbiddenMopZones(t){this.drawZones(t,this.forbiddenMopZoneMap,t=>ky.create(t))}getForbiddenMopZones(){return this.getZonesData(this.forbiddenMopZoneMap)}clearAllForbiddenMopZones(){this.clearAllZones(this.forbiddenMopZoneMap)}drawCleanZones(t){this.drawZones(t,this.cleanZoneMap,t=>Iy.create(t))}getCleanZones(){return this.getZonesData(this.cleanZoneMap)}clearAllCleanZones(){this.clearAllZones(this.cleanZoneMap)}drawVirtualWalls(t){const e=U_(),i=this.virtualWallMap,n=new Set(t.map(t=>t.id));for(const[r,s]of i)n.has(r)||(e.appContainer.removeFromLayer(Y_,s),s.destroy(),i.delete(r));t.forEach(t=>{const n=i.get(t.id);if(n)this.isWallDataEqual(n.getWallData(),t)||n.updateWallData(t);else{const n=new Uy({wallData:t,events:{onRemove:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onRemoveVirtualWall)||n.call(i,t)},onUpdate:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onUpdateVirtualWall)||n.call(i,t)},onClick:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onClickVirtualWall)||n.call(i,t)}}});i.set(t.id,n),e.appContainer.addToLayer(Y_,n)}})}getVirtualWalls(){return this.getWallsData(this.virtualWallMap)}clearAllVirtualWalls(){this.clearAllWalls(this.virtualWallMap)}drawSpots(t){const e=this.spotMap;if(!t||0===t.length)return void this.clearAllSpotsInternal(e);const i=new Set(e.keys()),n=new Set(t.map(t=>t.id));for(const r of i)n.has(r)||this.removeSpot(r,e);t.forEach(t=>{const i=e.get(t.id);i?this.isSpotDataEqual(i.getSpotData(),t)||i.updateSpotData(t):this.addNewSpot(t,e)})}getSpots(){return this.getSpotsData(this.spotMap)}clearAllSpots(){this.clearAllSpotsInternal(this.spotMap)}drawZones(t,e,i){if(!t||0===t.length)return void this.clearAllZones(e);const n=new Set(e.keys()),r=new Set(t.map(t=>t.id));for(const s of n)r.has(s)||this.removeZone(s,e);t.forEach(t=>{const n=e.get(t.id);n?this.isZoneDataEqual(n.getZoneData(),t)||n.updateZoneData(t):this.addNewZone(t,e,i)})}addNewZone(t,e,i){const n=U_(),r=i(t);e.set(t.id,r),n.appContainer.addToLayer(Y_,r)}removeZone(t,e){const i=U_(),n=e.get(t);n&&(i.appContainer.removeFromLayer(Y_,n),n.destroy(),e.delete(t))}getZonesData(t){const e=[];return t.forEach(t=>{e.push(t.getZoneData())}),e}clearAllZones(t){t.forEach((e,i)=>{var n;const r=t.get(i);r&&(null==(n=r.parent)||n.removeChild(r),r.destroy())}),t.clear()}updateZonesEditState(t){t.forEach(t=>{t.updateEditState()})}updateVirtualWallsEditState(t){t.forEach(t=>{t.updateEditingState()})}isZoneDataEqual(t,e){if(t.id!==e.id)return!1;if(t.points.length!==e.points.length)return!1;for(let i=0;i<t.points.length;i++){const n=t.points[i],r=e.points[i];if(Math.abs(n.x-r.x)>.1||Math.abs(n.y-r.y)>.1)return!1}return!0}getWallsData(t){return Array.from(t.values()).map(t=>t.getWallData())}clearAllWalls(t){for(const e of t.values())e.destroy();t.clear()}isWallDataEqual(t,e){if(t.id!==e.id)return!1;if(t.points.length!==e.points.length)return!1;for(let i=0;i<t.points.length;i++){const n=t.points[i],r=e.points[i];if(Math.abs(n.x-r.x)>.1||Math.abs(n.y-r.y)>.1)return!1}return!0}addNewSpot(t,e){const i=U_(),n=Gy.create(t);e.set(t.id,n),i.appContainer.addToLayer(Y_,n)}removeSpot(t,e){const i=U_(),n=e.get(t);n&&(i.appContainer.removeFromLayer(Y_,n),n.destroy(),e.delete(t))}getSpotsData(t){const e=[];return t.forEach(t=>{e.push(t.getSpotData())}),e}clearAllSpotsInternal(t){t.forEach((e,i)=>{var n;const r=t.get(i);r&&(null==(n=r.parent)||n.removeChild(r),r.destroy())}),t.clear()}updateSpotsEditState(t){t.forEach(t=>{t.updateEditState()})}isSpotDataEqual(t,e){if(t.id!==e.id)return!1;const i=t.point,n=e.point;return!(Math.abs(i.x-n.x)>.1||Math.abs(i.y-n.y)>.1)}handleDividingRoomIdChange(t){if(null==t)return void this.clearDivider();this.getRoomGeometry(t)?this.createDefaultDivider(t):this.clearDivider()}getRoomGeometry(t){return U_().mapManager.getRoomById(t)}createDefaultDivider(t){const e=U_();this.clearDivider(),this.divider=new zy({roomId:t,events:{onUpdate:t=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onUpdateDivider)||n.call(i,t)}}}),e.appContainer.addToLayer(Y_,this.divider)}clearDivider(){if(this.divider){U_().appContainer.removeFromLayer(Y_,this.divider),this.divider.destroy(),this.divider=null}}getDividerEndPoints(){return this.divider?this.divider.getDividerEndPoints():null}getEffectiveDividerPoints(){return this.divider?this.divider.getEffectiveDividerPoints():null}destroy(){this.clearAllForbiddenSweepZones(),this.clearAllForbiddenMopZones(),this.clearAllCleanZones(),this.clearAllVirtualWalls(),this.clearAllSpots(),this.clearDivider(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}class Vy extends oy{constructor(t){super(),__publicField(this,"objectData"),__publicField(this,"clickHandler",null),this.objectData=t}initializeSprite(){return __async(this,null,function*(){const t=U_().detectedObjectConfig,e=this.objectData.width||t.width,i=this.objectData.height||t.height;yield this.loadTextureAndSetSize(this.objectData.src,{width:e,height:i}),this.position.set(this.objectData.x,this.objectData.y),this.visible=!0,t.interactive?this.setupClickHandler():this.eventMode="none"})}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new iy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var t,e;null==(e=null==(t=U_().events)?void 0:t.onClickDetectedObject)||e.call(t,this.getObjectData())}getObjectData(){return __spreadValues({},this.objectData)}updateObjectData(t){return __async(this,null,function*(){const e=U_(),i=this.objectData;this.objectData=t;const n=e.detectedObjectConfig;if(i.src!==t.src){const e=t.width||n.width,i=t.height||n.height;yield this.loadTextureAndSetSize(t.src,{width:e,height:i})}if(i.width!==t.width||i.height!==t.height){const e=t.width||n.width,i=t.height||n.height;this.setFixedSize(e,i)}this.position.set(t.x,t.y),n.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.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class Hy{constructor(){__publicField(this,"detectedObjectMap",new Map)}updatePositionByOrigin(t,e){const i=U_().appContainer.getLayer(Z_);i&&i.position.set(t,e)}drawDetectedObjects(t){return __async(this,null,function*(){if(!t||0===t.length)return void this.clearAllDetectedObjects();const e=new Set(t.map(t=>t.id)),i=Array.from(this.detectedObjectMap.keys());for(const t of i)e.has(t)||this.removeDetectedObject(t);for(const n of t){const t=this.detectedObjectMap.get(n.id);t?t.isSameData(n)||(yield t.updateObjectData(n)):yield this.addNewDetectedObject(n)}})}clearAllDetectedObjects(){const t=U_();this.detectedObjectMap.forEach(e=>{t.appContainer.removeFromLayer(Z_,e),e.destroy()}),this.detectedObjectMap.clear()}addNewDetectedObject(t){return __async(this,null,function*(){const e=U_(),i=new Vy(t);yield i.initializeSprite(),this.detectedObjectMap.set(t.id,i),e.appContainer.addToLayer(Z_,i)})}removeDetectedObject(t){const e=U_(),i=this.detectedObjectMap.get(t);i&&(e.appContainer.removeFromLayer(Z_,i),i.destroy(),this.detectedObjectMap.delete(t))}destroy(){this.clearAllDetectedObjects()}}var Wy,jy={},Yy={},Xy={};function Zy(){if(Wy)return Xy;Wy=1,Object.defineProperty(Xy,"__esModule",{value:!0}),Xy.loop=Xy.conditional=Xy.parse=void 0;Xy.parse=function t(e,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n;if(Array.isArray(i))i.forEach(function(i){return t(e,i,n,r)});else if("function"==typeof i)i(e,n,r,t);else{var s=Object.keys(i)[0];Array.isArray(i[s])?(r[s]={},t(e,i[s],n,r[s])):r[s]=i[s](e,n,r,t)}return n};Xy.conditional=function(t,e){return function(i,n,r,s){e(i,n,r)&&s(i,t,n,r)}};return Xy.loop=function(t,e){return function(i,n,r,s){for(var o=[],a=i.pos;e(i,n,r);){var l={};if(s(i,t,n,l),i.pos===a)break;a=i.pos,o.push(l)}return o}},Xy}var qy,$y,Ky={};function Qy(){if(qy)return Ky;qy=1,Object.defineProperty(Ky,"__esModule",{value:!0}),Ky.readBits=Ky.readArray=Ky.readUnsigned=Ky.readString=Ky.peekBytes=Ky.readBytes=Ky.peekByte=Ky.readByte=Ky.buildStream=void 0;Ky.buildStream=function(t){return{data:t,pos:0}};var t=function(){return function(t){return t.data[t.pos++]}};Ky.readByte=t;Ky.peekByte=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function(e){return e.data[e.pos+t]}};var e=function(t){return function(e){return e.data.subarray(e.pos,e.pos+=t)}};Ky.readBytes=e;Ky.peekBytes=function(t){return function(e){return e.data.subarray(e.pos,e.pos+t)}};Ky.readString=function(t){return function(i){return Array.from(e(t)(i)).map(function(t){return String.fromCharCode(t)}).join("")}};Ky.readUnsigned=function(t){return function(i){var n=e(2)(i);return t?(n[1]<<8)+n[0]:(n[0]<<8)+n[1]}};Ky.readArray=function(t,i){return function(n,r,s){for(var o="function"==typeof i?i(n,r,s):i,a=e(t),l=new Array(o),h=0;h<o;h++)l[h]=a(n);return l}};return Ky.readBits=function(t){return function(e){for(var i=function(t){return t.data[t.pos++]}(e),n=new Array(8),r=0;r<8;r++)n[7-r]=!!(i&1<<r);return Object.keys(t).reduce(function(e,i){var r=t[i];return r.length?e[i]=function(t,e,i){for(var n=0,r=0;r<i;r++)n+=t[e+r]&&Math.pow(2,i-r-1);return n}(n,r.index,r.length):e[i]=n[r.index],e},{})}},Ky}var Jy,tx={};var ex,ix,nx={};var rx=function(){if(ix)return jy;ix=1,Object.defineProperty(jy,"__esModule",{value:!0}),jy.decompressFrames=jy.decompressFrame=jy.parseGIF=void 0;var t,e=($y||($y=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var e=Zy(),i=Qy(),n={blocks:function(t){for(var e=[],n=t.data.length,r=0,s=(0,i.readByte)()(t);0!==s&&s;s=(0,i.readByte)()(t)){if(t.pos+s>=n){var o=n-t.pos;e.push((0,i.readBytes)(o)(t)),r+=o;break}e.push((0,i.readBytes)(s)(t)),r+=s}for(var a=new Uint8Array(r),l=0,h=0;h<e.length;h++)a.set(e[h],l),l+=e[h].length;return a}},r=(0,e.conditional)({gce:[{codes:(0,i.readBytes)(2)},{byteSize:(0,i.readByte)()},{extras:(0,i.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,i.readUnsigned)(!0)},{transparentColorIndex:(0,i.readByte)()},{terminator:(0,i.readByte)()}]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&249===e[1]}),s=(0,e.conditional)({image:[{code:(0,i.readByte)()},{descriptor:[{left:(0,i.readUnsigned)(!0)},{top:(0,i.readUnsigned)(!0)},{width:(0,i.readUnsigned)(!0)},{height:(0,i.readUnsigned)(!0)},{lct:(0,i.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,i.readArray)(3,function(t,e,i){return Math.pow(2,i.descriptor.lct.size+1)})},function(t,e,i){return i.descriptor.lct.exists}),{data:[{minCodeSize:(0,i.readByte)()},n]}]},function(t){return 44===(0,i.peekByte)()(t)}),o=(0,e.conditional)({text:[{codes:(0,i.readBytes)(2)},{blockSize:(0,i.readByte)()},{preData:function(t,e,n){return(0,i.readBytes)(n.text.blockSize)(t)}},n]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&1===e[1]}),a=(0,e.conditional)({application:[{codes:(0,i.readBytes)(2)},{blockSize:(0,i.readByte)()},{id:function(t,e,n){return(0,i.readString)(n.blockSize)(t)}},n]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&255===e[1]}),l=(0,e.conditional)({comment:[{codes:(0,i.readBytes)(2)},n]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&254===e[1]}),h=[{header:[{signature:(0,i.readString)(3)},{version:(0,i.readString)(3)}]},{lsd:[{width:(0,i.readUnsigned)(!0)},{height:(0,i.readUnsigned)(!0)},{gct:(0,i.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,i.readByte)()},{pixelAspectRatio:(0,i.readByte)()}]},(0,e.conditional)({gct:(0,i.readArray)(3,function(t,e){return Math.pow(2,e.lsd.gct.size+1)})},function(t,e){return e.lsd.gct.exists}),{frames:(0,e.loop)([r,a,l,s,o],function(t){var e=(0,i.peekByte)()(t);return 33===e||44===e})}];t.default=h}(Yy)),(t=Yy)&&t.__esModule?t:{default:t}),i=Zy(),n=Qy(),r=(Jy||(Jy=1,Object.defineProperty(tx,"__esModule",{value:!0}),tx.deinterlace=void 0,tx.deinterlace=function(t,e){for(var i=new Array(t.length),n=t.length/e,r=function(n,r){var s=t.slice(r*e,(r+1)*e);i.splice.apply(i,[n*e,e].concat(s))},s=[0,4,2,1],o=[8,8,4,2],a=0,l=0;l<4;l++)for(var h=s[l];h<n;h+=o[l])r(h,a),a++;return i}),tx),s=(ex||(ex=1,Object.defineProperty(nx,"__esModule",{value:!0}),nx.lzw=void 0,nx.lzw=function(t,e,i){var n,r,s,o,a,l,h,c,u,d,p,f,g,m,_,y,x=4096,b=i,v=new Array(i),w=new Array(x),S=new Array(x),A=new Array(4097);for(a=1+(r=1<<(d=t)),n=r+2,h=-1,s=(1<<(o=d+1))-1,c=0;c<r;c++)w[c]=0,S[c]=c;for(p=f=g=m=_=y=0,u=0;u<b;){if(0===m){if(f<o){p+=e[y]<<f,f+=8,y++;continue}if(c=p&s,p>>=o,f-=o,c>n||c==a)break;if(c==r){s=(1<<(o=d+1))-1,n=r+2,h=-1;continue}if(-1==h){A[m++]=S[c],h=c,g=c;continue}for(l=c,c==n&&(A[m++]=g,c=h);c>r;)A[m++]=S[c],c=w[c];g=255&S[c],A[m++]=g,n<x&&(w[n]=h,S[n]=g,0===(++n&s)&&n<x&&(o++,s+=n)),h=l}m--,v[_++]=A[m],u++}for(u=_;u<b;u++)v[u]=0;return v}),nx);jy.parseGIF=function(t){var r=new Uint8Array(t);return(0,i.parse)((0,n.buildStream)(r),e.default)};var o=function(t,e,i){if(t.image){var n=t.image,o=n.descriptor.width*n.descriptor.height,a=(0,s.lzw)(n.data.minCodeSize,n.data.blocks,o);n.descriptor.lct.interlaced&&(a=(0,r.deinterlace)(a,n.descriptor.width));var l={pixels:a,dims:{top:t.image.descriptor.top,left:t.image.descriptor.left,width:t.image.descriptor.width,height:t.image.descriptor.height}};return n.descriptor.lct&&n.descriptor.lct.exists?l.colorTable=n.lct:l.colorTable=e,t.gce&&(l.delay=10*(t.gce.delay||10),l.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(l.transparentIndex=t.gce.transparentColorIndex)),i&&(l.patch=function(t){for(var e=t.pixels.length,i=new Uint8ClampedArray(4*e),n=0;n<e;n++){var r=4*n,s=t.pixels[n],o=t.colorTable[s]||[0,0,0];i[r]=o[0],i[r+1]=o[1],i[r+2]=o[2],i[r+3]=s!==t.transparentIndex?255:0}return i}(l)),l}console.warn("gif frame does not have associated image.")};return jy.decompressFrame=o,jy.decompressFrames=function(t,e){return t.frames.filter(function(t){return t.image}).map(function(i){return o(i,t.gct,e)})},jy}();class sx{constructor(t){if(!t||!t.length)throw new Error("Invalid frames");const[{texture:{width:e,height:i}}]=t;this.width=e,this.height=i,this.frames=t,this.textures=this.frames.map(t=>t.texture),this.totalFrames=this.frames.length,this.duration=this.frames[this.totalFrames-1].end}destroy(){for(const t of this.textures)t.destroy(!0);for(const t of this.frames)t.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(t,e){var i;if(!t||0===t.byteLength)throw new Error("Invalid buffer");const n=rx.parseGIF(t);(t=>{var e;let i=null;for(const n of t.frames)i=null!=(e=n.gce)?e:i,"image"in n&&!("gce"in n)&&(n.gce=i)})(n);const r=rx.decompressFrames(n,!0),s=[],o=n.lsd.width,a=n.lsd.height,l=Re.get().createCanvas(o,a),h=l.getContext("2d",{willReadFrequently:!0}),c=Re.get().createCanvas(),u=c.getContext("2d");let d=0,p=null;const f=1e3/(null!=(i=null==e?void 0:e.fps)?i:30);for(let g=0;g<r.length;g++){const{disposalType:t=2,delay:e=f,patch:i,dims:{width:n,height:l,left:m,top:_}}=r[g];c.width=n,c.height=l,u.clearRect(0,0,n,l);const y=u.createImageData(n,l);y.data.set(i),u.putImageData(y,0,0),3===t&&(p=h.getImageData(0,0,o,a)),h.drawImage(c,m,_);const x=h.getImageData(0,0,o,a);2===t?h.clearRect(0,0,o,a):3===t&&h.putImageData(p,0,0);const b=Re.get().createCanvas(x.width,x.height);b.getContext("2d").putImageData(x,0,0),s.push({start:d,end:d+e,texture:new J({source:new Be({resource:b})})}),d+=e}return l.width=l.height=0,c.width=c.height=0,new sx(s)}}const ox={extension:o.Asset,detection:{test:()=>__async(null,null,function*(){return!0}),add:t=>__async(null,null,function*(){return[...t,"gif"]}),remove:t=>__async(null,null,function*(){return t.filter(t=>"gif"!==t)})},loader:{name:"gifLoader",id:"gif",test:t=>".gif"===Ze.extname(t)||t.startsWith("data:image/gif"),load:(t,e)=>__async(null,null,function*(){const i=yield Re.get().fetch(t),n=yield i.arrayBuffer();return sx.from(n,null==e?void 0:e.data)}),unload:t=>__async(null,null,function*(){t.destroy()})}},ax=class t extends ve{constructor(...e){const i=e[0]instanceof sx?{source:e[0]}:e[0],n=Object.assign({},t.defaultOptions,i),{scaleMode:r,source:s,fps:o,loop:a,animationSpeed:l,autoPlay:h,autoUpdate:c,onComplete:u,onFrameChange:d,onLoop:p}=n,f=__objRest(n,["scaleMode","source","fps","loop","animationSpeed","autoPlay","autoUpdate","onComplete","onFrameChange","onLoop"]);super(__spreadValues({texture:J.EMPTY},f)),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=s.textures[0],this.duration=s.frames[s.frames.length-1].end,this._source=s,this._playing=!1,this._currentTime=0,this._isConnectedToTicker=!1,Object.assign(this,{fps:o,loop:a,animationSpeed:l,autoPlay:h,autoUpdate:c,onComplete:u,onFrameChange:d,onLoop:p}),this.currentFrame=0,h&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(Ue.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Ue.shared.add(this.update,this,ke.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(t){var e,i;if(!this._playing)return;const n=this.animationSpeed*t.deltaTime/Ue.targetFPMS,r=this._currentTime+n,s=r%this.duration,o=this._source.frames.findIndex(t=>t.start<=s&&t.end>s);r>=this.duration?this.loop?(this._currentTime=s,this._updateFrameIndex(o),null==(e=this.onLoop)||e.call(this)):(this._currentTime=this.duration,this._updateFrameIndex(this.totalFrames-1),null==(i=this.onComplete)||i.call(this),this.stop()):(this._currentTime=s,this._updateFrameIndex(o))}_updateFrame(){this.dirty&&(this.texture=this._source.frames[this._currentFrame].texture,this.dirty=!1)}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(Ue.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Ue.shared.add(this.update,this),this._isConnectedToTicker=!0))}get currentFrame(){return this._currentFrame}set currentFrame(t){this._updateFrameIndex(t),this._currentTime=this._source.frames[t].start}get source(){return this._source}_updateFrameIndex(t){var e;if(t<0||t>=this.totalFrames)throw new Error(`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${t}`);this._currentFrame!==t&&(this._currentFrame=t,this.dirty=!0,null==(e=this.onFrameChange)||e.call(this,t))}get totalFrames(){return this._source.totalFrames}destroy(t=!1){this.stop(),super.destroy(),t&&this._source.destroy();const e=null;this._source=e,this.onComplete=e,this.onFrameChange=e,this.onLoop=e}clone(){const e=new t({source:this._source,autoUpdate:this._autoUpdate,loop:this.loop,autoPlay:this.autoPlay,scaleMode:this.texture.source.scaleMode,animationSpeed:this.animationSpeed,onComplete:this.onComplete,onFrameChange:this.onFrameChange,onLoop:this.onLoop});return e.dirty=!0,e}};ax.defaultOptions={scaleMode:"linear",fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};let lx=ax;h.add(ox);class hx extends lx{constructor(t){super(t),__publicField(this,"throttledUpdateScale"),__publicField(this,"fixedWidth",0),__publicField(this,"fixedHeight",0),__publicField(this,"isFixedSizeSet",!1),__publicField(this,"sizeFixed",!0),__publicField(this,"baselineScale",1),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=zg(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,(t&&this.isFixedSizeSet||!t&&this.isFixedSizeSet)&&this.applySize()}set width(t){this.isFixedSizeSet?vm.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置宽度"):this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet?vm.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置高度"):this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){U_().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||0===this.texture.width||0===this.texture.height)return;const t=U_(),e=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const n=t.currentScale;if(0===n)return;const r=e/n,s=i/n;super.scale.set(r,s)}else super.scale.set(e/this.baselineScale,i/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():0!==t&&super.scale.set(1/t))}static createFromSrc(t,e){return __async(this,null,function*(){try{const i=yield Ya.load(t),n=new hx({source:i});return void 0!==e.sizeFixed&&n.setSizeFixed(e.sizeFixed),n.setFixedSize(e.width,e.height),n}catch(i){throw vm.error(`Failed to load GIF "${t}":`,i),i}})}draw(t,e){const{x:i,y:n,rotation:r=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=r,this.position.set(i,n)}destroy(t){U_().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class cx extends hx{constructor(t,e){super({source:t}),__publicField(this,"elementData"),__publicField(this,"clickHandler",null),this.elementData=e}initialize(){return __async(this,null,function*(){void 0!==this.elementData.sizeFixed&&this.setSizeFixed(this.elementData.sizeFixed),this.setFixedSize(this.elementData.width,this.elementData.height),this.position.set(this.elementData.x,this.elementData.y),void 0!==this.elementData.rotation&&(this.rotation=this.elementData.rotation),void 0!==this.elementData.opacity&&(this.alpha=this.elementData.opacity),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"})}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new iy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var t,e;null==(e=null==(t=U_().events)?void 0:t.onClickCustomElement)||e.call(t,this.getElementData())}getElementData(){return __spreadValues({},this.elementData)}updateElementData(t){return __async(this,null,function*(){const e=this.elementData;if(this.elementData=t,e.src!==t.src)throw new Error("GIF source change requires recreation of instance");e.sizeFixed!==t.sizeFixed&&void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),e.width===t.width&&e.height===t.height||this.setFixedSize(t.width,t.height),this.position.set(t.x,t.y),void 0!==t.rotation&&(this.rotation=t.rotation),void 0!==t.opacity&&(this.alpha=t.opacity),t.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")})}isSameData(t){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}destroy(){this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class ux extends oy{constructor(t){super(),__publicField(this,"elementData"),__publicField(this,"clickHandler",null),this.elementData=t}initialize(){return __async(this,null,function*(){yield this.loadTextureAndSetSize(this.elementData.src,{width:this.elementData.width,height:this.elementData.height,sizeFixed:this.elementData.sizeFixed}),this.position.set(this.elementData.x,this.elementData.y),void 0!==this.elementData.rotation&&(this.rotation=this.elementData.rotation),void 0!==this.elementData.opacity&&(this.alpha=this.elementData.opacity),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"})}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new iy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){var t,e;null==(e=null==(t=U_().events)?void 0:t.onClickCustomElement)||e.call(t,this.getElementData())}getElementData(){return __spreadValues({},this.elementData)}updateElementData(t){return __async(this,null,function*(){const e=this.elementData;this.elementData=t,e.src!==t.src?yield this.loadTextureAndSetSize(t.src,{width:t.width,height:t.height,sizeFixed:t.sizeFixed}):(e.sizeFixed!==t.sizeFixed&&void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),e.width===t.width&&e.height===t.height||this.setFixedSize(t.width,t.height)),this.position.set(t.x,t.y),void 0!==t.rotation&&(this.rotation=t.rotation),void 0!==t.opacity&&(this.alpha=t.opacity),t.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")})}isSameData(t){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}destroy(){this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class dx extends Za{constructor(t){super(t),__publicField(this,"throttledUpdateScale"),__publicField(this,"fixedWidth",0),__publicField(this,"fixedHeight",0),__publicField(this,"isFixedSizeSet",!1),this.anchor.set(.5),this.throttledUpdateScale=zg(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applyFixedSize()}registerScaleListener(){U_().emitter.on("antiScale",this.throttledUpdateScale)}applyFixedSize(){if(!this.isFixedSizeSet)return;const t=U_().currentScale;if(0===t)return;const e=1/t;this.scale.set(e),this.element&&(this.element.style.width=`${this.fixedWidth}px`,this.element.style.height=`${this.fixedHeight}px`)}updateScale(t){this.isFixedSizeSet&&0!==t&&this.applyFixedSize()}destroy(t){U_().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class px extends dx{constructor(t){const e=document.createElement("div");px.setupDefaultStyles(e,t),e.innerHTML=t.htmlContent,super({element:e}),__publicField(this,"elementData"),__publicField(this,"domClickHandler",null),__publicField(this,"resizeObserver",null),this.elementData=t}initialize(){return __async(this,null,function*(){this.alpha=0,this.position.set(this.elementData.x,this.elementData.y),void 0!==this.elementData.rotation&&(this.rotation=this.elementData.rotation),this.elementData.width&&this.elementData.height?(this.setFixedSize(this.elementData.width,this.elementData.height),this.waitForElementInsertion()):this.setupAutoSize(),this.elementData.interactive?this.setupClickHandler():this.eventMode="none"})}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&&("undefined"!=typeof ResizeObserver?(this.resizeObserver=new ResizeObserver(t=>{var e;const i=t[0];i&&i.contentRect.width>0&&i.contentRect.height>0&&(this.setFixedSize(i.contentRect.width,i.contentRect.height),0===this.alpha&&this.showElement(),null==(e=this.resizeObserver)||e.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)return void requestAnimationFrame(t);const e=this.element.getBoundingClientRect();e.width>0&&e.height>0?(this.setFixedSize(e.width,e.height),0===this.alpha&&this.showElement()):requestAnimationFrame(t)};requestAnimationFrame(t)}showElement(){var t,e;this.alpha=null!=(t=this.elementData.opacity)?t:1,this.element.style.pointerEvents=this.elementData.interactive?"auto":"none",this.interactive=null!=(e=this.elementData.interactive)&&e,this.elementData.interactive&&this.element&&(this.element.style.setProperty("-webkit-tap-highlight-color","transparent"),this.element.style.setProperty("-webkit-touch-callout","none"))}setupClickHandler(){this.element&&(this.domClickHandler=t=>{t.preventDefault(),t.stopPropagation(),this.handleClick()},this.element.addEventListener("click",this.domClickHandler))}handleClick(){var t,e;null==(e=null==(t=U_().events)?void 0:t.onClickCustomElement)||e.call(t,this.getElementData())}getElementData(){return __spreadValues({},this.elementData)}updateElementData(t){return __async(this,null,function*(){var e,i;const n=this.elementData;this.elementData=t,n.htmlContent!==t.htmlContent&&this.element&&(this.element.innerHTML=t.htmlContent,t.width&&t.height||this.waitForElementDimensions()),n.width===t.width&&n.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()),this.position.set(t.x,t.y),this.rotation=null!=(e=t.rotation)?e:0,this.alpha=null!=(i=t.opacity)?i: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}static setupDefaultStyles(t,e){const i={position:"relative",boxSizing:"border-box",webkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",background:"transparent",userSelect:"auto",webkitUserSelect:"auto",transformOrigin:"50% 50%"};e.width&&e.height?(i.width=`${e.width}px`,i.height=`${e.height}px`,i.overflow="hidden"):(i.width=e.width?`${e.width}px`:"auto",i.height=e.height?`${e.height}px`:"auto",i.overflow="visible"),Object.assign(t.style,i),t.style.setProperty("-webkit-tap-highlight-color","transparent"),t.style.setProperty("-webkit-touch-callout","none")}destroy(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null),super.destroy()}}class fx{constructor(){__publicField(this,"customElementsMap",new Map),__publicField(this,"gifTicker",null),__publicField(this,"gifElements",new Set)}updatePositionByOrigin(t,e){const i=U_(),n=i.appContainer.getLayer(q_),r=i.appContainer.getLayer($_);n&&n.position.set(t,e),r&&r.position.set(t,e)}drawCustomElements(t){return __async(this,null,function*(){if(!t||0===t.length)return void this.clearAllCustomElements();const e=new Set(t.map(t=>t.id)),i=Array.from(this.customElementsMap.keys());for(const t of i)e.has(t)||this.removeCustomElement(t);const n=t.map(t=>__async(this,null,function*(){const e=this.customElementsMap.get(t.id);e?this.isSameData(e,t)||("gif"===t.type&&e.getElementData().src!==t.src?(this.removeCustomElement(t.id),yield this.addNewCustomElement(t)):yield this.updateElementData(e,t)):yield this.addNewCustomElement(t)}));yield Promise.all(n),this.updateGifTicker()})}clearAllCustomElements(){const t=U_();this.customElementsMap.forEach(e=>{e instanceof cx?t.appContainer.removeFromLayer($_,e):t.appContainer.removeFromLayer(q_,e),e.destroy()}),this.customElementsMap.clear(),this.gifElements.clear(),this.stopGifTicker()}addNewCustomElement(t){return __async(this,null,function*(){const e=U_();let i;switch(t.type){case"image":i=new ux(t);break;case"gif":{const e=yield Ya.load(t.src);i=new cx(e,t);break}case"html":i=new px(t);break;default:throw new Error(`Unsupported custom element type: ${t.type}`)}yield i.initialize(),this.customElementsMap.set(t.id,i),i instanceof cx?(e.appContainer.addToLayer($_,i),this.gifElements.add(i)):e.appContainer.addToLayer(q_,i)})}removeCustomElement(t){const e=U_(),i=this.customElementsMap.get(t);i&&(i instanceof cx?(this.gifElements.delete(i),e.appContainer.removeFromLayer($_,i)):e.appContainer.removeFromLayer(q_,i),i.destroy(),this.customElementsMap.delete(t))}isSameData(t,e){return t.getElementData().type===e.type&&(("image"===e.type&&t instanceof ux||"gif"===e.type&&t instanceof cx||"html"===e.type&&t instanceof px)&&t.isSameData(e))}updateElementData(t,e){return __async(this,null,function*(){if("image"===e.type&&t instanceof ux)yield t.updateElementData(e);else if("gif"===e.type&&t instanceof cx)yield t.updateElementData(e);else{if(!("html"===e.type&&t instanceof px))throw new Error("Element type mismatch during update");yield t.updateElementData(e)}})}updateGifTicker(){this.gifElements.size>0?this.startGifTicker():this.stopGifTicker()}startGifTicker(){var t;(null==(t=this.gifTicker)?void 0:t.started)||(this.gifTicker?this.gifTicker.maxFPS=1:(this.gifTicker=new Ue,this.gifTicker.maxFPS=1,this.gifTicker.add(()=>{this.renderGifContainer()})),this.gifTicker.start())}stopGifTicker(){var t;(null==(t=this.gifTicker)?void 0:t.started)&&(vm.log("⏸️ [GifTicker] 停止 GIF 专用渲染"),this.gifTicker.stop())}renderGifContainer(){const t=U_();if(0===this.gifElements.size)return;const e=t.getApp();e.renderer.render(e.stage)}destroy(){this.stopGifTicker(),this.gifTicker&&(this.gifTicker.destroy(),this.gifTicker=null),this.clearAllCustomElements()}}class gx extends Rl{constructor(t){var e;const i=U_(),{nameLabel:n,colors:r}=i.roomConfig,s=null!=(e=t.colorIndex)?e:t.index,o=r.name[s%r.name.length],a=new zo({fontSize:n.fontSize,fontFamily:n.fontFamily,fontWeight:n.fontWeight,fill:o,align:"center"});super({text:t.name||"Unknown",style:a}),__publicField(this,"roomId"),__publicField(this,"roomIndex"),this.roomId=t.id,this.roomIndex=t.index,this.anchor.set(.5)}updateName(t){this.text=t}refreshColor(t){var e;const i=U_(),{colors:n}=i.roomConfig,r=i.getRoomData(this.roomId),s=null!=(e=null==r?void 0:r.colorIndex)?e:this.roomIndex,o=null!=t?t:n.name[s%n.name.length];this.style.fill=o}}class mx extends xe{constructor(t){var e;super(),__publicField(this,"background"),__publicField(this,"cleanModeIcon"),__publicField(this,"suctionIcon"),__publicField(this,"cisternIcon"),__publicField(this,"cleanTimesIcon"),__publicField(this,"orderContainer"),__publicField(this,"orderBackground"),__publicField(this,"orderText"),__publicField(this,"bubble",null),__publicField(this,"isFolded",!1),__publicField(this,"roomId"),__publicField(this,"roomIndex");const i=U_(),n=i.roomConfig;this.roomId=t.id,this.roomIndex=t.index,this.background=new fl;const{property:r,colors:{propertyTheme:s}}=n;n.property.foldable&&(this.bubble=new fl);const o=s[(null!=(e=t.colorIndex)?e:t.index)%s.length];this.cleanModeIcon=new oy,this.cleanModeIcon.tint=o,this.cleanModeIcon.anchor.set(0,0),this.suctionIcon=new oy,this.suctionIcon.tint=o,this.suctionIcon.anchor.set(0,0),this.cisternIcon=new oy,this.cisternIcon.tint=o,this.cisternIcon.anchor.set(0,0),this.cleanTimesIcon=new oy,this.cleanTimesIcon.tint=o,this.cleanTimesIcon.anchor.set(0,0),this.orderContainer=new xe,this.orderBackground=new fl,this.orderText=new Rl({text:"",style:new zo({fontSize:r.cleanOrder.fontSize,fontFamily:r.cleanOrder.fontFamily,fontWeight:r.cleanOrder.fontWeight,fill:r.cleanOrder.color,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.bubble&&this.addChild(this.bubble),this.addChild(this.cleanModeIcon),this.addChild(this.suctionIcon),this.addChild(this.cisternIcon),this.addChild(this.cleanTimesIcon),this.addChild(this.orderContainer),this.visible=i.runtimeSnapshot.showRoomProperty,this.updateProperty(t)}updateProperty(t){return __async(this,null,function*(){yield this.updateIcons(t),this.updateBackground()})}getDisplayElements(t){const e=U_(),{displayOrders:i}=e.roomConfig.property,{showRoomOrder:n,showRoomProperty:r}=e.runtimeSnapshot,s=t.order||0,o=n&&s>0,a=r&&i.includes("cleanMode"),l=r&&i.includes("suction"),h=r&&i.includes("cistern"),c=r&&i.includes("cleanTimes")&&t.cleanTimes>0,u={cleanMode:{element:this.cleanModeIcon,show:a,isOrder:!1},suction:{element:this.suctionIcon,show:l,isOrder:!1},cistern:{element:this.cisternIcon,show:h,isOrder:!1},cleanTimes:{element:this.cleanTimesIcon,show:c,isOrder:!1}},d=[];return o&&d.push({element:this.orderContainer,show:!0,isOrder:!0}),i.forEach(t=>{const e=u[t];e&&e.show&&d.push(e)}),{shouldShowOrder:o,shouldShowCleanMode:a,shouldShowSuction:l,shouldShowCistern:h,shouldShowCleanTimes:c,elementsToShow:d,orderValue:s}}updateIcons(t){return __async(this,null,function*(){var e;const i=U_(),{iconWidth:n,iconHeight:r,container:s,cleanOrder:o,foldable:a,iconGap:l}=i.roomConfig.property,{propertyTheme:h}=i.roomConfig.colors,{paddingHorizontal:c,paddingVertical:u}=s,{shouldShowOrder:d,shouldShowCleanMode:p,shouldShowSuction:f,shouldShowCistern:g,shouldShowCleanTimes:m,elementsToShow:_,orderValue:y}=this.getDisplayElements(t);this.orderContainer.visible=d,this.cleanModeIcon.visible=p,this.suctionIcon.visible=f,this.cisternIcon.visible=g,this.cleanTimesIcon.visible=m,a&&this.isFolded&&(this.orderContainer.visible=!1,this.cleanModeIcon.visible=!1,this.suctionIcon.visible=!1,this.cisternIcon.visible=!1,this.cleanTimesIcon.visible=!1);const x=[];if(p&&x.push(this.cleanModeIcon.loadTextureAndSetSize(`cleanMode_${t.cleanMode}`,{width:n,height:r,sizeFixed:!1})),f&&x.push(this.suctionIcon.loadTextureAndSetSize(`fan_${t.suction}`,{width:n,height:r,sizeFixed:!1})),g&&x.push(this.cisternIcon.loadTextureAndSetSize(`water_${t.cistern}`,{width:n,height:r,sizeFixed:!1})),m){const e=t.cleanTimes||1;x.push(this.cleanTimesIcon.loadTextureAndSetSize(`cleanTimes${e}`,{width:n,height:r,sizeFixed:!1}))}if(yield Promise.all(x),d){this.orderText.text=y.toString();const t=i.getRoomData(this.roomId),s=null!=(e=null==t?void 0:t.colorIndex)?e:this.roomIndex;this.orderBackground.clear(),this.orderBackground.setFillStyle({color:h[s%h.length]}),this.orderBackground.circle(n/2,r/2,n/2).fill(),this.orderText.position.set(n/2,r/2)}let b=c;_.forEach((t,e)=>{const{element:i,isOrder:r}=t;i.position.set(b,u),b+=n,e<_.length-1&&(b+=r?o.gapRight:l)})})}updateBackground(){const t=U_().roomConfig,{container:e,foldable:i}=t.property,{borderRadius:n,tailHeight:r,tailWidth:s,backgroundColor:o}=e,a=this.calculateContentWidth(),l=this.calculateContentHeight(),h=Math.min(s,a/2);if(this.background.clear(),this.bubble&&this.bubble.clear(),this.background.setFillStyle({color:o}),this.background.roundRect(0,0,a,l,n).fill(),i&&this.bubble){const t=(a-h)/2;this.bubble.setFillStyle({color:o}),this.bubble.poly([t,l-1,t+h,l-1,t+h/2,l+r]).fill()}}calculateContentWidth(){const t=U_(),{iconWidth:e,container:i,cleanOrder:n,iconGap:r}=t.roomConfig.property,{paddingHorizontal:s}=i,o=t.getRoomData(this.roomId);if(!o)return 2*s;const{elementsToShow:a}=this.getDisplayElements(o);let l=s;return a.forEach((t,i)=>{const{isOrder:s}=t;l+=e,i<a.length-1&&(l+=s?n.gapRight:r)}),l+=s,l}calculateContentHeight(){const t=U_().roomConfig,{iconHeight:e,container:i}=t.property;return i.paddingVertical+e+i.paddingVertical}getTotalHeight(){const t=U_(),{foldable:e,container:i}=t.roomConfig.property,{tailHeight:n}=i;return this.calculateContentHeight()+(e?n:0)}getTotalWidth(){return this.calculateContentWidth()}setFolded(t){const e=U_(),{foldable:i}=e.roomConfig.property;if(i)if(this.isFolded=t,t)this.background.visible=!1,this.cleanModeIcon.visible=!1,this.suctionIcon.visible=!1,this.cisternIcon.visible=!1,this.cleanTimesIcon.visible=!1,this.orderContainer.visible=!1,this.bubble&&(this.bubble.visible=!0,this.bubble.rotation=Math.PI,this.repositionFoldedBubble());else{this.background.visible=!0,this.bubble&&(this.bubble.visible=!0,this.bubble.rotation=0,this.bubble.position.set(0,0)),this.updateBackground();const t=e.getRoomData(this.roomId);t&&this.updateIcons(t)}}isFoldedState(){const t=U_(),{foldable:e}=t.roomConfig.property;return!!e&&this.isFolded}repositionFoldedBubble(){const t=U_(),{foldable:e}=t.roomConfig.property;if(!e||!this.bubble)return;const i=t.roomConfig,{tailHeight:n}=i.property.container,r=this.calculateContentWidth(),s=this.calculateContentHeight(),o=r/2;this.bubble.position.set(o,s+n/2)}refreshColor(){var t;const e=U_(),{propertyTheme:i}=e.roomConfig.colors,n=e.getRoomData(this.roomId),r=null!=(t=null==n?void 0:n.colorIndex)?t:this.roomIndex,s=i[r%i.length];if(this.cleanModeIcon&&(this.cleanModeIcon.tint=s),this.suctionIcon&&(this.suctionIcon.tint=s),this.cisternIcon&&(this.cisternIcon.tint=s),this.cleanTimesIcon&&(this.cleanTimesIcon.tint=s),this.orderBackground&&this.orderBackground.visible){const{property:t}=e.roomConfig,n=t.iconWidth,s=t.iconHeight;this.orderBackground.clear(),this.orderBackground.setFillStyle({color:i[r%i.length]}),this.orderBackground.circle(n/2,s/2,n/2).fill()}}destroy(){var t,e,i,n;null==(t=this.cleanModeIcon)||t.destroy(),null==(e=this.suctionIcon)||e.destroy(),null==(i=this.cisternIcon)||i.destroy(),null==(n=this.cleanTimesIcon)||n.destroy(),super.destroy()}}class _x extends xe{constructor(t){super(),__publicField(this,"background"),__publicField(this,"checkmarkIcon"),__publicField(this,"bubble"),__publicField(this,"roomIndex"),__publicField(this,"roomId");const e=U_().roomConfig;this.roomId=t.id,this.roomIndex=t.index,this.background=new fl,this.bubble=new fl;const{colors:{selectionIndicatorIcon:i}}=e;this.checkmarkIcon=new oy,this.checkmarkIcon.tint=i[t.index%i.length],this.checkmarkIcon.anchor.set(0,0),this.addChild(this.background),this.addChild(this.bubble),this.addChild(this.checkmarkIcon),this.updateIndicator(t)}updateIndicator(t){return __async(this,null,function*(){const e=U_(),{roomSelectionMode:i,enableRoomSelection:n,selectRoomIds:r}=e.runtimeSnapshot;if(!n||"checkmark"!==i)return void(this.visible=!1);const s=r.includes(t.id);yield this.showCheckmarkMode(s),this.updateBackground()})}showCheckmarkMode(t){return __async(this,null,function*(){const e=U_(),{selectionIndicator:i}=e.roomConfig,{iconWidth:n,iconHeight:r}=i;if(t){this.visible=!0,this.checkmarkIcon.visible=!0,yield this.checkmarkIcon.loadTextureAndSetSize("checkmark",{width:n,height:r,sizeFixed:!1});const t=i.containerWidth/2,e=i.containerHeight/2;this.checkmarkIcon.position.set(t-n/2,e-r/2)}else this.visible=!1})}updateBackground(){var t;const e=U_(),{selectionIndicator:i,colors:n}=e.roomConfig,{containerWidth:r,containerHeight:s,strokeWidth:o,strokeColor:a,borderRadius:l,tailHeight:h,tailWidth:c}=i,u=e.getRoomData(this.roomId),d=null!=(t=null==u?void 0:u.colorIndex)?t:this.roomIndex,p=n.selectionIndicatorBackground[d%n.selectionIndicatorBackground.length];if(this.background.clear(),this.bubble.clear(),this.background.setFillStyle({color:p}).roundRect(0,0,r,s,l).fill().setStrokeStyle({color:a,width:o,alignment:0}).stroke(),h>0&&c>0){const t=(r-c)/2;this.bubble.setFillStyle({color:a});const e=s+o;this.bubble.poly([t,e-1,t+c,e-1,t+c/2,e+h]).fill()}}getTotalHeight(){const t=U_(),{selectionIndicator:e}=t.roomConfig,{containerHeight:i,tailHeight:n,strokeWidth:r}=e;return i+r+(n>0?n:0)}getTotalWidth(){const t=U_(),{selectionIndicator:e}=t.roomConfig;return e.containerWidth}refreshColor(){return __async(this,null,function*(){const t=U_().getRoomData(this.roomId);t&&(yield this.updateIndicator(t))})}destroy(){var t;null==(t=this.checkmarkIcon)||t.destroy(),super.destroy()}}class yx extends vy{constructor(t){super(),__publicField(this,"roomId"),__publicField(this,"roomName"),__publicField(this,"roomProperty",null),__publicField(this,"roomSelectionIndicator",null),__publicField(this,"clickHandler",null);const e=U_();this.enableRenderGroup(),this.roomId=t.id,t.centerPoint&&this.position.set(t.centerPoint.x,t.centerPoint.y),this.roomName=new gx(t),this.roomName.visible=e.runtimeSnapshot.showRoomName,this.createRoomProperty(t),this.createRoomSelectionIndicator(t),this.updateLayout(),this.clickHandler=new iy(this,{onClick:()=>{var i,n;null==(n=null==(i=e.events)?void 0:i.onClickRoomProperties)||n.call(i,t)}})}shouldShowRoomProperty(){const t=U_(),{showRoomOrder:e,showRoomProperty:i,selectRoomIds:n,enableRoomSelection:r,roomSelectionMode:s}=t.runtimeSnapshot,o=t.getRoomData(this.roomId);if(!o)return!1;if(r&&"checkmark"===s&&n.includes(this.roomId))return!1;const a=e&&(o.order||0)>0,l=i&&(o.suction&&t.roomConfig.property.displayOrders.includes("suction")||o.cistern&&t.roomConfig.property.displayOrders.includes("cistern")||o.cleanTimes>0&&t.roomConfig.property.displayOrders.includes("cleanTimes"));return a||l}shouldShowRoomSelectionIndicator(){const t=U_(),{enableRoomSelection:e,roomSelectionMode:i}=t.runtimeSnapshot;return e&&"checkmark"===i}updateRoomPropertyVisibility(){const t=U_();if(!this.roomProperty)return;if(this.shouldShowRoomProperty()){this.roomProperty.visible=!0;const e=t.runtimeSnapshot.roomPropertyFoldIds.includes(this.roomId);this.roomProperty.setFolded(e);const i=t.getRoomData(this.roomId);i&&this.roomProperty.updateProperty(i)}else this.roomProperty.visible=!1;this.updateLayout()}updateRoomSelectionIndicatorVisibility(){return __async(this,null,function*(){const t=U_();if(!this.roomSelectionIndicator)return;if(this.shouldShowRoomSelectionIndicator()){const e=t.getRoomData(this.roomId);e&&(yield this.roomSelectionIndicator.updateIndicator(e))}else this.roomSelectionIndicator.visible=!1;this.updateLayout()})}createRoomProperty(t){return __async(this,null,function*(){const e=U_();this.roomProperty&&(this.removeChild(this.roomProperty),this.roomProperty.destroy()),this.roomProperty=new mx(t),yield this.roomProperty.updateProperty(t),this.addChild(this.roomProperty),this.addChild(this.roomName),this.roomName.visible=e.runtimeSnapshot.showRoomName,this.updateRoomPropertyVisibility()})}createRoomSelectionIndicator(t){return __async(this,null,function*(){this.roomSelectionIndicator&&(this.removeChild(this.roomSelectionIndicator),this.roomSelectionIndicator.destroy()),this.roomSelectionIndicator=new _x(t),this.addChild(this.roomSelectionIndicator),yield this.updateRoomSelectionIndicatorVisibility()})}updateLayout(){var t,e;const i=U_(),{property:{offsetY:n,offsetX:r},selectionIndicator:{offsetY:s,offsetX:o}}=i.roomConfig,a=(null==(t=this.roomProperty)?void 0:t.visible)||!1,l=this.roomName.visible,h=(null==(e=this.roomSelectionIndicator)?void 0:e.visible)||!1;if(a&&this.roomProperty)if(this.roomProperty.isFoldedState())this.roomProperty.position.set(r,-n);else{const t=this.roomProperty.getTotalHeight(),e=this.roomProperty.getTotalWidth();l?(this.roomProperty.position.set(-e/2+r,-n-t),this.roomName.position.set(0,0)):this.roomProperty.position.set(-e/2+r,-t/2-n)}if(h&&this.roomSelectionIndicator){const t=this.roomSelectionIndicator.getTotalHeight(),e=this.roomSelectionIndicator.getTotalWidth();l?(this.roomSelectionIndicator.position.set(-e/2+o,-s-t),this.roomName.position.set(0,0)):this.roomSelectionIndicator.position.set(-e/2+o,-t/2-s)}!l||a||h||this.roomName.position.set(0,0)}updateName(t){this.roomName.updateName(t)}updateRoomNameVisibility(t){this.roomName.visible=t,this.updateLayout()}updatePosition(t){this.position.set(t.x,t.y)}refreshColor(){return __async(this,null,function*(){this.roomName&&this.roomName.refreshColor(),this.roomProperty&&this.roomProperty.refreshColor(),this.roomSelectionIndicator&&(yield this.roomSelectionIndicator.refreshColor())})}destroy(){var t,e,i,n;null==(t=this.clickHandler)||t.destroy(),this.clickHandler=null,null==(e=this.roomProperty)||e.destroy(),this.roomProperty=null,null==(i=this.roomSelectionIndicator)||i.destroy(),this.roomSelectionIndicator=null,null==(n=this.roomName)||n.destroy(),super.destroy()}}class xx extends xe{constructor(){super({isRenderGroup:!0}),__publicField(this,"floorTypeMap",new Map),__publicField(this,"floorTypeMasks",new Map),__publicField(this,"floorTypeToRooms",new Map);U_().appContainer.addToLayer(N_,this)}createFloorTypes(t){return __async(this,null,function*(){if(!U_().runtimeSnapshot.showRoomFloorType)return;this.clearFloorTypes();const e=this.groupRoomsByFloorType(t),i=[];for(const[t,n]of e)i.push(this.createMergedFloorType(t,n));yield Promise.all(i)})}groupRoomsByFloorType(t){const e=new Map,i=U_();return t.forEach((t,n)=>{const r=i.getRoomData(n),s=(null==r?void 0:r.floorType)||0;s>=0&&(e.has(s)||e.set(s,[]),e.get(s).push({roomId:n,graphics:t}))}),e}createMergedFloorType(t,e){return __async(this,null,function*(){const i=U_(),{assets:n,opacity:r,scale:s}=i.roomConfig.floorType,o=t%n.length,a=`floorType${o}`;if(!n[o])return void vm.warn(`No texture asset configured for floorType: ${t}`);const l=yield Ya.load(a);if(!l)return void vm.warn(`Floor material texture not found: ${a}`);const h=(t=>{if(0===t.length)return{x:0,y:0,width:0,height:0};let e=t[0].x,i=t[0].y,n=t[0].x+t[0].width,r=t[0].y+t[0].height;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.min(i,t.y),n=Math.max(n,t.x+t.width),r=Math.max(r,t.y+t.height)}),{x:e,y:i,width:n-e,height:r-i}})(e.map(({graphics:t})=>t.getLocalBounds())),c=new vl({texture:l,width:h.width,height:h.height});c.x=h.x,c.y=h.y,c.alpha=r,c.tileScale.set(s);const u=this.createMergedMask(e.map(({graphics:t})=>t));c.mask=u,this.addChild(c),this.floorTypeMap.set(t,c),this.floorTypeMasks.set(t,u),this.floorTypeToRooms.set(t,new Set(e.map(({roomId:t})=>t)))})}createMergedMask(t){const e=new xe;return t.forEach(t=>{const i=new fl;i.context=t.context.clone(),e.addChild(i)}),e}clearFloorTypes(){this.floorTypeMap.forEach(t=>{try{this.removeChild(t),t.destroy()}catch(e){vm.warn("Error destroying floor material:",e)}}),this.floorTypeMap.clear(),this.floorTypeMasks.forEach(t=>{try{t.destroy()}catch(e){vm.warn("Error destroying floor mask:",e)}}),this.floorTypeMasks.clear(),this.floorTypeToRooms.clear()}destroy(){this.clearFloorTypes(),super.destroy()}}class bx{constructor(){__publicField(this,"unsubscribeFns",[]),__publicField(this,"roomInfoContainer",new xe),__publicField(this,"roomInfoMap",new Map),__publicField(this,"roomDisplayMap",new Map),__publicField(this,"roomFloorType",new xx);const t=U_();t.appContainer.addToLayer(X_,this.roomInfoContainer);const e=ly(t.runtime,"showRoomFloorType",t=>{vm.log(`[runtime] showRoomFloorType: ${t}`),t?this.updateFloorTypes():this.roomFloorType.clearFloorTypes()}),i=ly(t.runtime,"showRoomProperty",t=>{vm.log(`[runtime] showRoomProperty: ${t}`),this.updateAllRoomPropertyVisibility()}),n=ly(t.runtime,"showRoomOrder",t=>{vm.log(`[runtime] showRoomOrder: ${t}`),this.updateAllRoomPropertyVisibility()}),r=ly(t.runtime,"roomPropertyFoldIds",t=>{vm.log(`[runtime] roomPropertyFoldIds: ${t}`),this.updateAllRoomPropertyVisibility()}),s=ly(t.runtime,"showRoomName",t=>{vm.log(`[runtime] showRoomName: ${t}`),this.updateAllRoomNameVisibility(t)}),o=ly(t.runtime,"enableRoomSelection",t=>{vm.log(`[runtime] enableRoomSelection: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),a=ly(t.runtime,"selectRoomIds",t=>{vm.log(`[runtime] selectRoomIds: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),l=ly(t.runtime,"roomSelectionMode",t=>{vm.log(`[runtime] roomSelectionMode: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()});this.unsubscribeFns.push(e,i,n,r,s,o,a,l)}drawRoomProperty(t){const e=U_();return this.roomDisplayMap.clear(),t.forEach((t,i)=>{const n=e.mapManager.getRoomById(t.id),r=__spreadProps(__spreadValues({},t),{centerPoint:(null==n?void 0:n.centerPoint)||null,index:i,colorIndex:null==n?void 0:n.colorIndex});this.roomDisplayMap.set(t.id,r)}),this.updateRoomInfoDisplay(),this.updateFloorTypes(),!0}updateRoomInfoDisplay(){if(0===this.roomDisplayMap.size)return;const t=Array.from(this.roomDisplayMap.values()).filter(t=>null!==t.centerPoint);this.clearRoomInfos(),t.forEach(t=>{this.createRoomInfo(t)})}createRoomInfo(t){const e=new yx(t);this.roomInfoContainer.addChild(e),this.roomInfoMap.set(t.id,e)}updateRoomName(t,e){const i=this.roomInfoMap.get(t);i&&i.updateName(e)}updateRoomPosition(t,e){const i=this.roomDisplayMap.get(t);i&&(i.centerPoint=e);const n=this.roomInfoMap.get(t);n&&n.updatePosition(e)}clearRoomInfos(){this.roomInfoMap.forEach(t=>{t.destroy()}),this.roomInfoMap.clear(),this.roomInfoContainer.removeChildren()}getRoomPropertyById(t){return this.roomDisplayMap.get(t)}refresh(){const t=U_();this.roomFloorType.clearFloorTypes(),this.roomDisplayMap.forEach((e,i)=>{const n=t.mapManager.getRoomById(i),r=(null==n?void 0:n.centerPoint)||null;if(e.centerPoint!==r){e.centerPoint=r;const t=this.roomInfoMap.get(i);t&&r&&t.updatePosition(r)}const s=null==n?void 0:n.colorIndex;if(e.colorIndex!==s&&void 0!==s){e.colorIndex=s;const t=this.roomInfoMap.get(i);t&&t.refreshColor()}}),this.updateRoomInfoDisplay(),this.updateFloorTypes()}updateAllRoomPropertyVisibility(){this.roomInfoMap.forEach(t=>{t.updateRoomPropertyVisibility()})}updateAllRoomNameVisibility(t){this.roomInfoMap.forEach(e=>{e.updateRoomNameVisibility(t)})}updateAllRoomSelectionIndicatorVisibility(){this.roomInfoMap.forEach(t=>{t.updateRoomSelectionIndicatorVisibility()})}updateFloorTypes(){return __async(this,null,function*(){const t=U_(),e=t.mapManager.roomFill.getRoomGraphicsMap();e.size>0&&(yield this.roomFloorType.createFloorTypes(e),t.getApp().renderOnceNextFrame())})}destroy(){this.clearRoomInfos(),this.roomInfoContainer.destroy(),this.roomFloorType.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}(null==(e=null==navigator?void 0:navigator.userAgent)?void 0:e.includes("tuya-ark-ide"))||null==(i=null==navigator?void 0:navigator.userAgent)||i.includes("miniProgram");const vx=()=>{var t,e;if(!Ai.any)return!0;const i=navigator.userAgent.toLowerCase();let n=!1;if(/iphone|ipad|ipod/.test(i)){const e=null==(t=i.match(/os (\d+)_/))?void 0:t[1];n=(e?parseInt(e):0)>=12}else if(/android/.test(i)){const t=null==(e=i.match(/android (\d+)/))?void 0:e[1];n=(t?parseInt(t):0)>=10}return n&&(()=>{const t=navigator.deviceMemory;return!t||t>=4})()};class wx extends Kn{constructor(t=k_){var e;super(),__publicField(this,"mapState",null),__publicField(this,"components",{}),__publicField(this,"managers",{}),__publicField(this,"config",E_),__publicField(this,"runtime"),__publicField(this,"scaleMin",.5),__publicField(this,"scaleMax",5),__publicField(this,"events",{}),__publicField(this,"instanceKey"),__publicField(this,"containerElement"),__publicField(this,"emitter",{all:e=e||new Map,on:function(t,i){var n=e.get(t);n?n.push(i):e.set(t,[i])},off:function(t,i){var n=e.get(t);n&&(i?n.splice(n.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var n=e.get(t);n&&n.slice().map(function(t){t(i)}),(n=e.get("*"))&&n.slice().map(function(e){e(t,i)})}}),__publicField(this,"tickerState",{renderReasons:new Set,renderTimer:null}),__publicField(this,"pendingAsyncRender",!1),__publicField(this,"isFirstMapDraw",!0),__publicField(this,"onVisibilityChange",()=>{var t;"visible"===document.visibilityState||null==(t=this.components.interaction)||t.clearTouches()}),this.instanceKey=t,D_.registerInstance(t,this),globalThis.__PIXI_APP__=this}initialize(t){return __async(this,null,function*(){return D_.provideAsync(this,()=>__async(this,null,function*(){const e=t,{resizeTo:i,events:n,config:r,runtime:s={}}=e,o=__objRest(e,["resizeTo","events","config","runtime"]);this.config=Lg(this.config,null!=r?r:{}),vm.log("Applying config",this.config,r),this.runtime=A_(Object.assign({},R_,s));const a=this.instanceKey===k_;this.containerElement=i;const l=a?{textureGCMaxIdle:Ai.any?180:3600,textureGCCheckCountMax:Ai.any?100:50,autoStart:!1,eventFeatures:{move:!0,globalMove:!1,click:!0,wheel:!0}}:{textureGCMaxIdle:60,textureGCCheckCountMax:10,autoStart:!1,eventFeatures:{move:!1,globalMove:!1,click:!1,wheel:!1}};yield this.init(__spreadValues(__spreadValues({resizeTo:a?i:void 0,preferWebGLVersion:2,resolution:window.devicePixelRatio||1,antialias:vx(),autoDensity:!0,backgroundColor:this.config.global.backgroundColor},l),o)),this.preloadAssets(),this.scaleMax=this.config.interaction.zoomRange.max,this.scaleMin=this.config.interaction.zoomRange.min,this.events=n,this.initializeViewportContainer(),this.initializeInteraction(),this.initializeAppContainer(),this.managers.mapManager=new uy,this.managers.heatmapManager=new by,this.managers.pathManager=new yy,this.managers.controlsManager=new Ny,this.managers.detectedObjectManager=new Hy,this.managers.customElementsManager=new fx,this.managers.roomsManager=new bx,document.addEventListener("visibilitychange",this.onVisibilityChange)}))})}drawMap(t){return __async(this,null,function*(){return D_.provideAsync(this,()=>__async(this,null,function*(){var e,i,n,r,s,o,a;vm.log("[Map] drawMap",t);const{size:l,resolution:h,origin:c}=t;c[0]===(null==(e=this.mapState)?void 0:e.origin.x)&&c[1]===(null==(i=this.mapState)?void 0:i.origin.y)||(this.managers.pathManager.updatePositionByOrigin(...c),this.managers.controlsManager.updatePositionByOrigin(...c),this.managers.detectedObjectManager.updatePositionByOrigin(...c),this.managers.customElementsManager.updatePositionByOrigin(...c)),this.mapState={id:t.id,status:1===t.status,origin:{x:c[0],y:c[1]},charger:{x:t.charger.coordinate[0],y:t.charger.coordinate[1]},chargerDirection:null!=(n=t.charger.angle)?n:0,resolution:h,width:l[0],height:l[1],mapType:"structured"},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,null==(s=null==(r=this.events)?void 0:r.onMapFirstDrawed)||s.call(r,this.mapState)),null==(a=null==(o=this.events)?void 0:o.onMapDrawed)||a.call(o,this.mapState),yield this.managers.mapManager.drawMap(t),this.renderOnce()}))})}drawRasterMap(t){return __async(this,null,function*(){return D_.provideAsync(this,()=>__async(this,null,function*(){var e,i,n,r,s,o,a;vm.log("[Map] drawRasterMap",t);const{mapHeader:l,mapData:h}=t,{originX:c,originY:u}=l;c===(null==(e=this.mapState)?void 0:e.origin.x)&&u===(null==(i=this.mapState)?void 0:i.origin.y)||(this.managers.pathManager.updatePositionByOrigin(c,u),this.managers.controlsManager.updatePositionByOrigin(c,u),this.managers.detectedObjectManager.updatePositionByOrigin(c,u),this.managers.customElementsManager.updatePositionByOrigin(c,u)),this.mapState={id:l.id,status:l.mapStable,origin:{x:c,y:u},charger:{x:l.chargeX,y:l.chargeY},chargerDirection:null!=(n=l.chargeDirection)?n:0,resolution:100*l.mapResolution,width:l.mapWidth,height:l.mapHeight,version:l.version,mapType:"raster"},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,null==(s=null==(r=this.events)?void 0:r.onMapFirstDrawed)||s.call(r,this.mapState)),null==(a=null==(o=this.events)?void 0:o.onMapDrawed)||a.call(o,this.mapState),yield this.managers.mapManager.drawRasterMap(h.parsed,this.mapState),this.renderOnce()}))})}drawPath(t){return D_.provide(this,()=>{var e,i,n;vm.log("[Path] drawPath",t),null==(n=null==(e=this.events)?void 0:e.onPathDrawed)||n.call(e,{id:t.pathHeader.pathId,type:t.pathHeader.type,direction:t.pathHeader.direction,count:t.pathHeader.count,initFlag:t.pathHeader.initFlag,robotPosition:null!=(i=t.pathPoints[t.pathPoints.length-1])?i:null}),this.managers.pathManager.draw(t),this.renderOnce()})}drawRoomProperty(t){return __async(this,null,function*(){return D_.provide(this,()=>{var e,i;vm.log("[Room] drawRoomProperty",t),null==(i=null==(e=this.events)?void 0:e.onRoomPropertiesDrawed)||i.call(e,t),this.managers.roomsManager.drawRoomProperty(t),this.renderOnceNextFrame()})})}drawHeatmap({mapData:t,heatmapPoints:e,useGradient:i=!0}){return D_.provide(this,()=>{vm.log("[Heatmap] drawHeatmap",e),this.managers.heatmapManager.draw({mapData:t,heatmapPoints:e,useGradient:i}),this.renderOnce()})}drawForbiddenSweepZones(t){return D_.provide(this,()=>{vm.log("[Controls] drawForbiddenSweepZones",t),this.managers.controlsManager.drawForbiddenSweepZones(t),this.renderOnceNextFrame()})}drawForbiddenMopZones(t){return D_.provide(this,()=>{vm.log("[Controls] drawForbiddenMopZones",t),this.managers.controlsManager.drawForbiddenMopZones(t),this.renderOnceNextFrame()})}drawCleanZones(t){return D_.provide(this,()=>{vm.log("[Controls] drawCleanZones",t),this.managers.controlsManager.drawCleanZones(t),this.renderOnceNextFrame()})}drawVirtualWalls(t){return D_.provide(this,()=>{vm.log("[Controls] drawVirtualWalls",t),this.managers.controlsManager.drawVirtualWalls(t),this.renderOnceNextFrame()})}drawSpots(t){return D_.provide(this,()=>{vm.log("[Controls] drawSpots",t),this.managers.controlsManager.drawSpots(t),this.renderOnceNextFrame()})}drawDetectedObjects(t){return __async(this,null,function*(){return D_.provideAsync(this,()=>__async(this,null,function*(){vm.log("[DetectedObject] drawDetectedObjects",t),yield this.managers.detectedObjectManager.drawDetectedObjects(t),this.renderOnceNextFrame()}))})}drawCustomElements(t){return __async(this,null,function*(){return D_.provideAsync(this,()=>__async(this,null,function*(){vm.log("[CustomElements] drawCustomElements",t),yield 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()}getEffectiveDividerPoints(){return this.managers.controlsManager.getEffectiveDividerPoints()}getDividerEndPoints(){return this.managers.controlsManager.getDividerEndPoints()}resetPanZoom(){this.components.interaction.setPanZoom()}fitMapToView(t,e=!1){return D_.provide(this,()=>{if(!t||t.minX===t.maxX||t.minY===t.maxY)return void vm.warn("地图边界无效,无法自动适配视图");const i=this.config.map.autoPaddingPercent||.1,n=this.getViewportBounds(),r=t.maxX-t.minX,s=t.maxY-t.minY,o=n.width,a=n.height,l=o*(1-2*i)/r,h=a*(1-2*i)/s,c=Math.min(l,h),u=Math.max(this.config.interaction.fitMinScale,this.scaleMin),d=Math.min(this.config.interaction.fitMaxScale,this.scaleMax),p=Math.max(u,Math.min(d,c)),f=o/2-(t.minX+r/2)*p,g=a/2-(t.minY+s/2)*p;this.components.interaction.setPanZoom({targetPosition:{x:f,y:g},targetScale:{x:p,y:p},setCenter:!0,setScale:!0},e)})}getViewportBounds(){var t;return(null==(t=this.components.viewportContainer)?void 0:t.getViewportBounds())||{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}updateRuntime(t){Object.assign(this.runtime,t),this.renderOnceNextFrame()}metersToPixels(t){var e;if(!(null==(e=this.mapState)?void 0:e.resolution))return vm.warn("Map resolution not available, using default resolution (5cm/pixel)"),20*t;return t*(1/(this.mapState.resolution/100))}pixelsToMeters(t){var e;if(!(null==(e=this.mapState)?void 0:e.resolution))return vm.warn("Map resolution not available, using default resolution (5cm/pixel)"),.05*t;return t*(this.mapState.resolution/100)}toFixedSize(t,e){return t/(null!=e?e:this.components.appContainer.scale.x)}fromFixedSize(t,e){return t*(null!=e?e:this.components.appContainer.scale.x)}getViewportCenterPoint(){if(!this.mapState)return vm.warn("Map state not available, cannot calculate center point"),null;const t=this.getViewportBounds(),e=t.x+t.width/2,i=t.y+t.height/2,n=this.components.appContainer,r=n.scale.x,s=(e-n.x)/r,o=(i-n.y)/r;return{x:s-this.mapState.origin.x,y:o-this.mapState.origin.y}}getMapCenterPoint(){if(!this.mapState)return vm.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 vm.warn("Invalid map bounds, cannot calculate map center point"),null;const e=(t.minX+t.maxX)/2,i=(t.minY+t.maxY)/2;return{x:e-this.mapState.origin.x,y:i-this.mapState.origin.y}}getWallPointsByViewportCenter(t){const{width:e=this.config.controls.virtualWall.minWidth,direction:i="horizontal",offsetX:n=0,offsetY:r=0}=t||{},s=this.getViewportCenterPoint()||{x:0,y:0},o=this.metersToPixels(e);return e_(s.x,s.y,o,i).map(t=>({x:t.x+n,y:t.y+r}))}getForbiddenSweepZonePointsByViewportCenter(t){const e=this.config.controls.forbiddenSweepZone,{size:i=e.minSize,offsetX:n=0,offsetY:r=0}=t||{};return this.generateZonePoints(i,n,r)}getForbiddenMopZonePointsByViewportCenter(t){const e=this.config.controls.forbiddenMopZone,{size:i=e.minSize,offsetX:n=0,offsetY:r=0}=t||{};return this.generateZonePoints(i,n,r)}getCleanZonePointsByViewportCenter(t){const e=this.config.controls.cleanZone,{size:i=e.minSize,offsetX:n=0,offsetY:r=0}=t||{};return this.generateZonePoints(i,n,r)}getSpotPointByViewportCenter(t){const{offsetX:e=0,offsetY:i=0}=t||{},n=this.getViewportCenterPoint()||{x:0,y:0};return{x:n.x+e,y:n.y+i}}areRoomsAdjacent(t){const e=this.config.map.adjacencyThreshold;return D_.provide(this,()=>{var i,n;if(!t||0===t.length)return vm.warn("[Room] No room IDs provided"),!1;if(1===t.length)return!0;const r=Array.from(new Set(t));if(1===r.length)return!0;return"raster"===(null!=(n=null==(i=this.mapState)?void 0:i.mapType)?n:"structured")?this.areRasterRoomsAdjacentInternal(r,e):this.areStructuredRoomsAdjacentInternal(r,e)})}isPointInAnyRoom(t){return D_.provide(this,()=>{var e,i;if(!t||"number"!=typeof t.x||"number"!=typeof t.y)return vm.warn("[Room] Invalid point provided"),null;return"raster"===(null!=(i=null==(e=this.mapState)?void 0:e.mapType)?i:"structured")?this.isPointInAnyRoomRasterInternal(t):this.isPointInAnyRoomStructuredInternal(t)})}isPointInAnyRoomStructuredInternal(t){if(!this.mapState)return vm.warn("[Room] Map state not available"),null;const e={x:t.x+this.mapState.origin.x,y:t.y+this.mapState.origin.y},i=this.managers.mapManager.getAllRooms();for(const n of i)if(n.outlinePoints&&n.outlinePoints.length>=3&&Rm(e,n.outlinePoints)){const t=this.managers.roomsManager.getRoomPropertyById(n.id);return t||(vm.warn(`[Room] Room ${n.id} found in geometry but not in RoomManager`),null)}return null}isPointInAnyRoomRasterInternal(t){if(!this.mapState)return vm.warn("[Room] Map state not available"),null;const e=this.mapState.width,i=this.mapState.height,n=t.x+this.mapState.origin.x,r=t.y+this.mapState.origin.y,s=Math.round(n),o=Math.round(r);if(s<0||s>=e||o<0||o>=i)return vm.warn(`[Room] Point (${s}, ${o}) is out of map bounds (${e}x${i})`),null;const a=o*e+s,l=this.managers.mapManager.getAllRooms();for(const h of l){const t=this.managers.mapManager.getRasterRoomPixels(h.id);if(t&&t.length>0&&Tm(t,a)){const t=this.managers.roomsManager.getRoomPropertyById(h.id);return t||(vm.warn(`[Room] Room ${h.id} found in geometry but not in RoomManager`),null)}}return null}areStructuredRoomsAdjacentInternal(t,e){const i=[];for(const r of t){const t=this.managers.mapManager.getRoomById(r);if(!t)return vm.warn(`[Room] Room ${r} not found in map`),!1;if(!t.outlinePoints||0===t.outlinePoints.length)return vm.warn(`[Room] Room ${r} has no outline points`),!1;i.push({id:r,points:t.outlinePoints})}const n=[];for(let r=0;r<i.length;r++)for(let t=r+1;t<i.length;t++){const s=i[r],o=i[t];i_(s.points,o.points,e)&&n.push([r,t])}return r_(i.length,n)}areRasterRoomsAdjacentInternal(t,e){if(!this.mapState)return vm.warn("[Room] Map state not available"),!1;const i=this.mapState.width,n=[];for(const s of t){const t=this.managers.mapManager.getRasterRoomPixels(s);if(!t)return vm.warn(`[Room] Room ${s} pixel data not found in raster map`),!1;n.push({id:s,pixels:t})}const r=[];for(let s=0;s<n.length;s++)for(let t=s+1;t<n.length;t++){const o=n[s],a=n[t];n_(o.pixels,a.pixels,i,e)&&r.push([s,t])}return r_(n.length,r)}snapshot(){return __async(this,null,function*(){this.render(),yield new Promise(t=>setTimeout(t,0));const{snapshot:t}=this.config;return yield this.renderer.extract.base64({target:this.components.appContainer,format:t.format,quality:t.quality,resolution:t.resolution,antialias:t.antialias})})}snapshotByData(t){return __async(this,arguments,function*({map:t,path:e,roomProperties:i,customElements:n,forbiddenSweepZones:o,forbiddenMopZones:a,virtualWalls:l,detectedObjects:h},c={}){const u=`SNAPSHOT_${((t=21)=>{let e="",i=0|t;for(;i--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return e})()}`;vm.log(`[MapApplication] ${u} snapshot start`);const d=new wx(u);try{if(yield d.initialize({config:this.config,runtime:c}),!t)throw new Error("Map data is required");if(t.startsWith("7b22")){const{decodeMapStructured:e}=yield s(()=>__async(this,null,function*(){const{decodeMapStructured:t}=yield Promise.resolve().then(()=>bm);return{decodeMapStructured:t}}),0,r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("assets/index-CMaxpPPD.js",document.baseURI).href),i=e(t);yield d.drawMap(i)}else{const{decodeMap:e}=yield s(()=>__async(this,null,function*(){const{decodeMap:t}=yield Promise.resolve().then(()=>bm);return{decodeMap:t}}),0,r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("assets/index-CMaxpPPD.js",document.baseURI).href),i=e(t);if(!i)throw new Error("Failed to decode raster map data");yield d.drawRasterMap(i)}if(e){const{decodePath:t}=yield s(()=>__async(this,null,function*(){const{decodePath:t}=yield Promise.resolve().then(()=>bm);return{decodePath:t}}),0,r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("assets/index-CMaxpPPD.js",document.baseURI).href),i=t(e);d.drawPath(i)}i&&i.length>0&&d.drawRoomProperty(i),o&&o.length>0&&d.drawForbiddenSweepZones(o),a&&a.length>0&&d.drawForbiddenMopZones(a),l&&l.length>0&&d.drawVirtualWalls(l),h&&h.length>0&&(yield d.drawDetectedObjects(h)),n&&n.length>0&&(yield d.drawCustomElements(n));const p=yield d.snapshot();return vm.log(`[MapApplication] ${u} snapshot completed successfully`),p}catch(p){throw vm.error(`[MapApplication] ${u} snapshot other map failed:`,p),p}finally{vm.log(`[MapApplication] ${u} destroy`),d.destroy()}})}renderOnce(){vm.log("[Pixi] renderOnce"),this.render()}renderOnceNextFrame(){this.pendingAsyncRender||(this.pendingAsyncRender=!0,requestAnimationFrame(()=>{vm.log("[Pixi] renderOnceNextFrame"),this.render(),this.pendingAsyncRender=!1}))}requestRender(t,e=!1){e?(this.tickerState.renderReasons.add(t),this.ticker.started||(vm.debug(`🎬 [Ticker] START: ${t}`),this.ticker.start())):this.renderOnceNextFrame()}stopRender(t){this.tickerState.renderReasons.delete(t),0===this.tickerState.renderReasons.size&&this.scheduleStopRender("final",100)}destroy(){D_.unregisterInstance(this.instanceKey),this.tickerState.renderTimer&&clearTimeout(this.tickerState.renderTimer),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.detectedObjectManager.destroy(),this.managers.customElementsManager.destroy(),this.managers.roomsManager.destroy(),this.components.interaction.destroy(),this.components.viewportContainer.destroy(),this.components.appContainer.destroy(),super.destroy()}initializeViewportContainer(){this.components.viewportContainer=new G_(this.config,this.containerElement),this.stage.addChild(this.components.viewportContainer)}initializeAppContainer(){this.components.appContainer=new ty,this.components.interaction.addChild(this.components.appContainer)}initializeInteraction(){this.components.interaction=new s_,this.components.viewportContainer.addChild(this.components.interaction)}scheduleStopRender(t,e){this.tickerState.renderTimer&&clearTimeout(this.tickerState.renderTimer),this.tickerState.renderTimer=setTimeout(()=>{this.tickerState.renderReasons.delete(t),0===this.tickerState.renderReasons.size&&(vm.debug("⏸️ [Ticker] STOP"),this.ticker.stop())},e)}generateZonePoints(t,e,i){const n=this.getViewportCenterPoint()||{x:0,y:0},r=this.metersToPixels(t)/2,s=n.x+e,o=n.y+i;return[{x:s-r,y:o-r},{x:s+r,y:o-r},{x:s+r,y:o+r},{x:s-r,y:o+r}]}preloadAssets(){const t=this.config.robot.icon.src,e=this.config.chargingStation.icon.src,i=[];Ya.add({alias:"robot",src:t}),i.push("robot"),Ya.add({alias:"chargingStation",src:e}),i.push("chargingStation"),Ya.add({alias:"deleteIcon",src:this.config.controls.deleteIconSrc}),i.push("deleteIcon"),Ya.add({alias:"rotateIcon",src:this.config.controls.rotateIconSrc}),i.push("rotateIcon"),Ya.add({alias:"scaleIcon",src:this.config.controls.scaleIconSrc}),i.push("scaleIcon"),Ya.add({alias:"moveIcon",src:this.config.controls.moveIconSrc}),i.push("moveIcon"),Ya.add({alias:"checkmark",src:this.config.room.selectionIndicator.iconSrc}),i.push("checkmark"),Ya.add({alias:"spotIcon",src:this.config.controls.spot.iconSrc}),i.push("spotIcon"),this.config.room.property.cleanMode.assets.forEach((t,e)=>{const n=`cleanMode_${e}`;Ya.add({alias:n,src:t}),i.push(n)}),this.config.room.property.suction.assets.forEach((t,e)=>{const n=`fan_${e}`;Ya.add({alias:n,src:t}),i.push(n)}),this.config.room.property.cistern.assets.forEach((t,e)=>{const n=`water_${e}`;Ya.add({alias:n,src:t}),i.push(n)}),this.config.room.property.cleanTimes.assets.forEach((t,e)=>{const n=`cleanTimes${e+1}`;Ya.add({alias:n,src:t}),i.push(n)}),this.config.room.floorType.assets.forEach((t,e)=>{if(!t)return;const n=`floorType${e}`;Ya.add({alias:n,src:t}),i.push(n)}),Ya.backgroundLoad(i)}}var Sx,Ax,Tx,Cx={exports:{}};function Px(){if(Ax)return Sx;function t(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,n)}return i}function e(e){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?t(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e,i){return Object.defineProperty(t,"prototype",{writable:!1}),t}function r(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function s(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return o(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}Ax=1;var a="RNWV:sync",l="success",h="fail",c=0,u=n(function t(){var e=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.promise=new Promise(function(t,i){e.resolve=t,e.reject=i})});function d(t){return"".concat(t.command,"(").concat(t.id,")")}var p=null,f="undefined"!=typeof window,g=function(t){var e,i=[],n=(e={send:[],receive:[],ready:[]},{addEventListener:function(t,i){if(t in e){var n=e[t];n.indexOf(i)<0&&n.push(i)}},removeEventListener:function(t,i){if(t in e){var n=e[t],r=n.indexOf(i);r>=0&&n.splice(r,1)}},emitEvent:function(t,i){t in e&&e[t].forEach(function(t){return t(i)})}}),r={},o={},p={};function f(t){return function(){for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return s=function(t,e){return{id:c++,command:t,data:e,reply:!1,status:l}}(t,i),o=new u,r[d(s)]=o,m(s),o.promise;var s,o}}function g(t,e){return o[t]=function(t){return e.apply(void 0,s(t))},!i&&b(),{define:g,bind:f}}function m(e){!(e.command===a)&&i?i.push(e):t(e),n.emitEvent("send",e)}function _(t,e,i){t.reply=!0,t.data=e,t.status=i,m(t)}var y=f(a);function x(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(t){return!p[t]}).map(function(t){p[t]=f(t)}),function(){if(i){var t=i;i=null,t.forEach(function(t){m(t)}),n.emitEvent("ready")}}(),Object.keys(o)}function b(){y(Object.keys(o)).then(x)}return g(a,x),{bind:f,define:g,listener:function(t){var e=t.detail&&JSON.parse(t.detail.data[0])||t;if(e.reply){var i=d(e);r[i]&&(e.status===h?r[i].reject(e.data):r[i].resolve(e.data))}else if(o[e.command]){var s=o[e.command](e.data);s&&s.then?s.then(function(t){_(e,t,l)}).catch(function(t){_(e,t,h)}):_(e,s,l)}else _(e,"function ".concat(e.command," is not defined"),h);n.emitEvent("receive",e)},ready:b,fn:p,addEventListener:n.addEventListener,removeEventListener:n.removeEventListener,isConnect:function(){return!i}}}(function(t){var e="string"==typeof t?t:JSON.stringify(t);f&&p&&p(e)}),m=g.bind,_=g.define,y=g.listener,x=g.ready,b=g.fn,v=g.addEventListener,w=g.removeEventListener,S=g.isConnect,A=function(t){var e;if("object"===i(t))e=t;else if("string"==typeof t)try{e=JSON.parse(t)}catch(n){}e&&(e.command||e.reply)&&y(e)},T=function(t){var e=new MessageEvent("message",{data:t});A(e.data)};if(f){var C=window.originalPostMessage;if(C)p=function(){var t;window&&"function"==typeof window.postMessage&&(t=window).postMessage.apply(t,arguments)},x();else{var P={get:function(){return C},set:function(t){(C=t)&&(p=function(){var t;window&&"function"==typeof window.postMessage&&(t=window).postMessage.apply(t,arguments)},setTimeout(x,50))}};Object.defineProperty(window,"originalPostMessage",P)}var M=window.ReactNativeWebView;if(M)p=function(){var t;window&&window.ReactNativeWebView&&"function"==typeof window.ReactNativeWebView.postMessage?(t=window.ReactNativeWebView).postMessage.apply(t,arguments):console.error("ReactNativeWebView has been dispose")},x();else{var E={get:function(){return M},set:function(t){(M=t)&&(p=function(){var t;window&&window.ReactNativeWebView&&"function"==typeof window.ReactNativeWebView.postMessage?(t=window.ReactNativeWebView).postMessage.apply(t,arguments):console.error("ReactNativeWebView has been dispose")},setTimeout(x,50))}};Object.defineProperty(window,"ReactNativeWebView",E)}var R=window.gzlJSBridge;if(R)p=function(){try{if(window&&window.gzlJSBridge&&"function"==typeof window.gzlJSBridge.webviewMessage){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];var r={data:e({},i)};window.gzlJSBridge.webviewMessage("postMessage",JSON.stringify(r))}else console.error("gzlJSBridge has been dispose")}catch(s){console.error("gzlJSBridge postMessage error ==>",s)}window.gzlJSBridge.receiveMessageHandler=function(t){T(t.data)}},x();else{var B={get:function(){return R},set:function(t){(R=t)&&(p=function(){try{if(window&&window.gzlJSBridge&&"function"==typeof window.gzlJSBridge.webviewMessage){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];var r={data:e({},i)};window.gzlJSBridge.webviewMessage("postMessage",JSON.stringify(r))}else console.error("gzlJSBridge has been dispose")}catch(s){console.error("gzlJSBridge postMessage error ==>",s)}},window.gzlJSBridge.receiveMessageHandler=function(t){T(t.data)},setTimeout(x,50))}};Object.defineProperty(window,"gzlJSBridge",B)}C||M||R||(p=function(){if(window&&"function"==typeof window.postMessage){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];var r={data:e({},i)};window.parent.postMessage(r,"*")}else console.error("browser mini program has been dispose")},x()),window.document.addEventListener("message",function(t){return C&&A(t.data)}),window.addEventListener("message",function(t){return M&&A(t.data)}),window.document.addEventListener("message",function(t){return M&&A(t.data)}),window.addEventListener("message",function(t){return!M&&T(t.data)})}return Sx={bind:m,define:_,fn:b,addEventListener:v,removeEventListener:w,isConnect:S}}const Mx=p(function(){if(Tx)return Cx.exports;Tx=1;var t=Px();return Cx.exports=t,Cx.exports.default=t,Cx.exports}());document.addEventListener("DOMContentLoaded",()=>__async(null,null,function*(){let t=null;document.addEventListener("beforeunload",()=>{null==t||t.destroy()});try{Mx.bind("onDocumentReady")();const e=e=>__async(null,[e],function*({options:e,runtime:i}){t=new wx;const n=__objRest(e,[]),r=document.getElementById("container");var s,o;yield t.initialize({resizeTo:null!=r?r:window,events:F_.reduce((t,e)=>((t=null!=t?t:{})[e]=function(t,e){return(...i)=>(vm.log(`[Event] ${t}`,...i),e(...i))}(e,Mx.bind(e)),t),{}),config:n,runtime:i}),r?r.appendChild(t.canvas):document.body.appendChild(t.canvas),Mx.define("onUpdateRuntime",e=>{null==t||t.updateRuntime(e)}),Mx.define("onReceiveMap",e=>{if(e)if(e.startsWith("7b22"))null==t||t.drawMap(fm(e));else{const i=gm(e);i?null==t||t.drawRasterMap(i):vm.error("Failed to decode raster map data")}}),Mx.define("onReceivePath",e=>{e&&(null==t||t.drawPath(xm(e)))}),Mx.define("onReceiveRoomProperties",e=>{e&&(null==t||t.drawRoomProperty(e))}),Mx.define("onReceiveForbiddenSweepZones",e=>{e&&(null==t||t.drawForbiddenSweepZones(e))}),Mx.define("onReceiveForbiddenMopZones",e=>{e&&(null==t||t.drawForbiddenMopZones(e))}),Mx.define("onReceiveCleanZones",e=>{e&&(null==t||t.drawCleanZones(e))}),Mx.define("onReceiveVirtualWalls",e=>{e&&(null==t||t.drawVirtualWalls(e))}),Mx.define("onReceiveSpots",e=>{e&&(null==t||t.drawSpots(e))}),Mx.define("onReceiveDetectedObjects",e=>{e&&(null==t||t.drawDetectedObjects(e))}),Mx.define("onReceiveCustomElements",e=>{e&&(null==t||t.drawCustomElements(e))}),s=t,o=Mx,B_.forEach(t=>{"function"==typeof s[t]?o.define(t,s[t].bind(s)):vm.warn(`Method ${t} not found on target object`)}),yield Mx.bind("onInitialized")()});document.body?Mx.define("initApp",e):vm.error("document.body is null")}catch(e){console.error(e)}})),h.add(Ci),h.mixin(xe,{accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1}),h.add(Qn),h.add(Jn),h.add(sl),h.mixin(xe,ol),h.add(qa),h.add($u),h.add(Js),h.add(ed),h.add(cd),h.add(ud),h.add(Wd),h.add(Hd),h.add(Fd),h.add(Nd),h.add(Od),h.add(Sd),h.add(gd),h.add(cl),h.add(al);const Ex=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Rx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));Symbol.toStringTag}();
|