@ray-js/robot-map-sdk 0.0.3-beta-9 → 0.0.3-beta-11
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/Interaction.js +1 -1
- package/dist/application/MapApplication.js +1 -1
- package/dist/assets/floorType1.png.js +1 -0
- package/dist/assets/floorType2.png.js +1 -0
- package/dist/components/Map/Free.js +1 -1
- package/dist/components/Map/Obstacle.js +1 -1
- package/dist/components/Path/index.js +1 -1
- package/dist/components/RoomFloorType/index.js +1 -1
- package/dist/components/RoomInfo/RoomProperty.js +1 -1
- package/dist/components/RoomInfo/RoomSelectionIndicator.js +1 -1
- package/dist/components/RoomInfo/index.js +1 -1
- package/dist/constant/config.js +1 -1
- package/dist/constant/methods.js +1 -1
- package/dist/index.d.ts +43 -1
- package/dist/index.rjs.js +1 -1
- package/dist/managers/MapManager.js +1 -1
- package/dist/managers/RoomManager.js +1 -1
- package/dist/utils/algorithm.js +1 -1
- package/dist-app/assets/{index-C3rjigWj.js → index-BZrSlwsu.js} +1 -1
- package/dist-app/index.html +1 -1
- package/dist-docs/404.html +2 -2
- package/dist-docs/assets/{app.BGQfBD4o.js → app.DQX-KXAE.js} +1 -1
- package/dist-docs/assets/chunks/@localSearchIndexroot.DFhlA73m.js +1 -0
- package/dist-docs/assets/chunks/{VPLocalSearchBox.YvMlJA6m.js → VPLocalSearchBox.DMOz5xxA.js} +1 -1
- package/dist-docs/assets/chunks/{theme.1StzhkaW.js → theme.BNIQfRMl.js} +2 -2
- package/dist-docs/assets/{guide_advanced-usage.md.ChUH15VJ.js → guide_advanced-usage.md.DUawnQ9c.js} +6 -6
- package/dist-docs/assets/{guide_advanced-usage.md.ChUH15VJ.lean.js → guide_advanced-usage.md.DUawnQ9c.lean.js} +1 -1
- package/dist-docs/assets/{guide_getting-started.md.D0sqgiqb.js → guide_getting-started.md.pCYbkwjy.js} +1 -1
- package/dist-docs/assets/{reference_methods.md.BkU-PXMt.js → reference_methods.md.B71e_LYO.js} +6 -3
- package/dist-docs/assets/{reference_methods.md.BkU-PXMt.lean.js → reference_methods.md.B71e_LYO.lean.js} +1 -1
- package/dist-docs/guide/advanced-usage.html +9 -9
- 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 +3 -3
- package/dist-docs/reference/data.html +3 -3
- package/dist-docs/reference/methods.html +9 -6
- package/dist-docs/reference/runtime.html +3 -3
- package/dist-docs/reference/types.html +3 -3
- package/dist-docs/reference/utils.html +3 -3
- package/package.json +1 -1
- package/dist-docs/assets/chunks/@localSearchIndexroot.CSdgg9Q0.js +0 -1
- /package/dist/assets/{floorType.png.js → floorType3.png.js} +0 -0
- /package/dist-docs/assets/{guide_getting-started.md.D0sqgiqb.lean.js → guide_getting-started.md.pCYbkwjy.lean.js} +0 -0
package/dist/index.rjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function e(t="default"){return void 0===In[t]&&(In[t]=-1),++In[t]}function i(t,e,i=3){if(An[e])return;let n=(new Error).stack;void 0===n||(n=n.split("\n").splice(i).join("\n"),console.groupCollapsed),An[e]=!0}function n(t){return t+=0===t?1:0,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,1+((t|=t>>>8)|t>>>16)}function s(t){return!(t&t-1||!t)}function r(t){const e={};for(const i in t)void 0!==t[i]&&(e[i]=t[i]);return e}function o(t,e,i){const{width:n,height:s}=i.orig,r=i.trim;if(r){const i=r.width,o=r.height;t.minX=r.x-e._x*n,t.maxX=t.minX+i,t.minY=r.y-e._y*s,t.maxY=t.minY+o}else t.minX=-e._x*n,t.maxX=t.minX+n,t.minY=-e._y*s,t.maxY=t.minY+s}function a(...t){500!==fs&&fs++}function h(t,e,i){const n=t.length;let s;if(e>=n||0===i)return;const r=n-(i=e+i>n?n-e:i);for(s=e;s<r;++s)t[s]=t[s+i];t.length=r}function l(t,e,i){let n,s;return i.clear(),t.parent?e?n=t.parent.worldTransform:(s=Ss.get().identity(),n=d(t,s)):n=un.IDENTITY,c(t,i,n,e),s&&Ss.return(s),i.isValid||i.set(0,0,0,0),i}function c(t,e,i,n){if(!t.visible||!t.measurable)return;let s;n?s=t.worldTransform:(t.updateLocalTransform(),s=Ss.get(),s.appendFrom(t.localTransform,i));const r=e,o=!!t.effects.length;if(o&&(e=Is.get().clear()),t.boundsArea)e.addRect(t.boundsArea,s);else{t.bounds&&(e.matrix=s,e.addBounds(t.bounds));for(let i=0;i<t.children.length;i++)c(t.children[i],e,s,n)}if(o){for(let i=0;i<t.effects.length;i++)t.effects[i].addBounds?.(e);r.addBounds(e,un.IDENTITY),Is.return(e)}n||Ss.return(s)}function d(t,e){const i=t.parent;return i&&(d(i,e),i.updateLocalTransform(),e.append(i.localTransform)),e}function u(t,e){return 16777215!==t&&e?16777215!==e&&t?((t>>16&255)*(e>>16&255)/255<<16)+((t>>8&255)*(e>>8&255)/255<<8)+((255&t)*(255&e)/255|0):t:e}function p(t,e){return t===Ts?e:e===Ts?t:u(t,e)}function f(t){return((255&t)<<16)+(65280&t)+(t>>16&255)}function g(t,e,i){return e.clear(),i||(i=un.IDENTITY),m(t,e,i,t,!0),e.isValid||e.set(0,0,0,0),e}function m(t,e,i,n,s){let r;if(s)r=Ss.get(),r=i.copyTo(r);else{if(!t.visible||!t.measurable)return;t.updateLocalTransform();const e=t.localTransform;r=Ss.get(),r.appendFrom(e,i)}const o=e,a=!!t.effects.length;if(a&&(e=Is.get().clear()),t.boundsArea)e.addRect(t.boundsArea,r);else{t.renderPipeId&&(e.matrix=r,e.addBounds(t.bounds));const i=t.children;for(let t=0;t<i.length;t++)m(i[t],e,r,n,!1)}if(a){for(let i=0;i<t.effects.length;i++)t.effects[i].addLocalBounds?.(e,n);o.addBounds(e,un.IDENTITY),Is.return(e)}Ss.return(r)}function y(t,e){const i=t.children;for(let t=0;t<i.length;t++){const n=i[t],s=n.uid,r=(65535&n._didViewChangeTick)<<16|65535&n._didContainerChangeTick,o=e.index;e.data[o]===s&&e.data[o+1]===r||(e.data[e.index]=s,e.data[e.index+1]=r,e.didChange=!0),e.index=o+2,n.children.length&&y(n,e)}return e.didChange}function x(t,e){return t._zIndex-e._zIndex}function b(t,e,i){const n=Zs;t.measurable=!0,l(t,i,n),e.addBoundsMask(n),t.measurable=!1}function _(t,e,i){const n=Is.get();t.measurable=!0;const s=Ss.get().identity();g(t,n,v(t,i,s)),t.measurable=!1,e.addBoundsMask(n),Ss.return(s),Is.return(n)}function v(t,e,i){return t?(t!==e&&(v(t.parent,e,i),t.updateLocalTransform(),i.append(t.localTransform)),i):(a(),i)}async function w(){return nr??(nr=(async()=>{const t=qs.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await 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(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const s=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,s),t.deleteFramebuffer(n),t.deleteTexture(i),t.getExtension("WEBGL_lose_context")?.loseContext(),s[0]<=s[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),nr}function C(t={}){const e=t&&t.resource,i=e?t.resource:t,n=e?t:{resource:t};for(let t=0;t<lr.length;t++){const e=lr[t];if(e.test(i))return new e(n)}throw new Error(`Could not find a source type for resource: ${n.resource}`)}function S(t){if("string"!=typeof t)throw new TypeError(`Path must be a string. Received ${JSON.stringify(t)}`)}function I(t){return t.split("?")[0].split("#")[0]}function A(t,e,i,n,s){const r=e[i];for(let o=0;o<r.length;o++){const a=r[o];i<e.length-1?A(t.replace(n[i],a),e,i+1,n,s):s.push(t.replace(n[i],a))}}function M(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)}),A(t,n,0,e,i)}else i.push(t);return i}function T(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=dr.dirname(t[0]);e.linkedSheets.forEach((t,s)=>{const r=T([`${i}/${e.data.meta.related_multi_packs[s]}`],t,!0);Object.assign(n,r)})}return n}function P(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 s=function(t){return function(e){return e.test(t)}}(i),r={apple:{phone:s(vr)&&!s(Pr),ipod:s(wr),tablet:!s(vr)&&(s(Cr)||Fr(e))&&!s(Pr),universal:s(Sr),device:(s(vr)||s(wr)||s(Cr)||s(Sr)||Fr(e))&&!s(Pr)},amazon:{phone:s(Mr),tablet:!s(Mr)&&s(Tr),device:s(Mr)||s(Tr)},android:{phone:!s(Pr)&&s(Mr)||!s(Pr)&&s(Ir),tablet:!s(Pr)&&!s(Mr)&&!s(Ir)&&(s(Tr)||s(Ar)),device:!s(Pr)&&(s(Mr)||s(Tr)||s(Ir)||s(Ar))||s(/\bokhttp\b/i)},windows:{phone:s(Pr),tablet:s(Er),device:s(Pr)||s(Er)},other:{blackberry:s(Br),blackberry10:s(Or),opera:s(kr),firefox:s(Dr),chrome:s(Rr),device:s(Br)||s(Or)||s(kr)||s(Dr)||s(Rr)},any:!1,phone:!1,tablet:!1};return r.any=r.apple.device||r.android.device||r.windows.device||r.other.device,r.phone=r.apple.phone||r.android.phone||r.windows.phone,r.tablet=r.apple.tablet||r.android.tablet||r.windows.tablet,r}function E(t,e){let i=Nr[t];return void 0===i&&(void 0===Ur[e]&&(Ur[e]=1),Nr[t]=i=Ur[e]++),i}function B(){if(!zr||zr?.isContextLost()){const t=qs.get().createCanvas();zr=t.getContext("webgl",{})}return zr}function O(){if(!Hr){Hr="mediump";const t=B();if(t&&t.getShaderPrecisionFormat){const e=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT);Hr=e.precision?"highp":"mediump"}}return Hr}function k(t){return Kr[t]??Kr.float32}function R(t){const e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,s=/:\s*(\w+)/,r=/(\w+)\s*:\s*([\w\<\>]+)/g,o=/struct\s+(\w+)/,a=t.match(/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g)?.map(t=>({group:parseInt(t.match(e)[1],10),binding:parseInt(t.match(i)[1],10),name:t.match(n)[2],isUniform:"<uniform>"===t.match(n)[1],type:t.match(s)[1]}));if(!a)return{groups:[],structs:[]};const h=t.match(/struct\s+(\w+)\s*{([^}]+)}/g)?.map(t=>{const e=t.match(o)[1],i=t.match(r).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})=>a.some(e=>e.type===t))??[];return{groups:a,structs:h}}function D(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}function F(){if("boolean"==typeof go)return go;try{const t=new Function("param1","param2","param3","return param1[param2] === param3;");go=!0===t({a:"b"},"a","b")}catch(t){go=!1}return go}function L(t,e,i=2){const n=e&&e.length,s=n?e[0]*i:t.length;let r=j(t,0,s,i,!0);const o=[];if(!r||r.next===r.prev)return o;let a,h,l;if(n&&(r=function(t,e,i,n){const s=[];for(let i=0,r=e.length;i<r;i++){const o=j(t,e[i]*n,i<r-1?e[i+1]*n:t.length,n,!1);o===o.next&&(o.steiner=!0),s.push(Y(o))}s.sort(W);for(let t=0;t<s.length;t++)i=Z(s[t],i);return i}(t,e,r,i)),t.length>80*i){a=t[0],h=t[1];let e=a,n=h;for(let r=i;r<s;r+=i){const i=t[r],s=t[r+1];i<a&&(a=i),s<h&&(h=s),i>e&&(e=i),s>n&&(n=s)}l=Math.max(e-a,n-h),l=0!==l?32767/l:0}return U(r,o,i,a,h,l,0),o}function j(t,e,i,n,s){let r;if(s===function(t,e,i,n){let s=0;for(let r=e,o=i-n;r<i;r+=n)s+=(t[o]-t[r])*(t[r+1]+t[o+1]),o=r;return s}(t,e,i,n)>0)for(let s=e;s<i;s+=n)r=ot(s/n|0,t[s],t[s+1],r);else for(let s=i-n;s>=e;s-=n)r=ot(s/n|0,t[s],t[s+1],r);return r&&tt(r,r.next)&&(at(r),r=r.next),r}function G(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!tt(n,n.next)&&0!==$(n.prev,n,n.next))n=n.next;else{if(at(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function U(t,e,i,n,s,r,o){if(!t)return;!o&&r&&function(t,e,i,n){let s=t;do{0===s.z&&(s.z=X(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){let e,i=1;do{let n,s=t;t=null;let r=null;for(e=0;s;){e++;let o=s,a=0;for(let t=0;t<i&&(a++,o=o.nextZ,o);t++);let h=i;for(;a>0||h>0&&o;)0!==a&&(0===h||!o||s.z<=o.z)?(n=s,s=s.nextZ,a--):(n=o,o=o.nextZ,h--),r?r.nextZ=n:t=n,n.prevZ=r,r=n;s=o}r.nextZ=null,i*=2}while(e>1)}(s)}(t,n,s,r);let a=t;for(;t.prev!==t.next;){const h=t.prev,l=t.next;if(r?z(t,n,s,r):N(t))e.push(h.i,t.i,l.i),at(t),t=l.next,a=l.next;else if((t=l)===a){o?1===o?U(t=H(G(t),e),e,i,n,s,r,2):2===o&&V(t,e,i,n,s,r):U(G(t),e,i,n,s,r,1);break}}}function N(t){const e=t.prev,i=t,n=t.next;if($(e,i,n)>=0)return!1;const s=e.x,r=i.x,o=n.x,a=e.y,h=i.y,l=n.y,c=Math.min(s,r,o),d=Math.min(a,h,l),u=Math.max(s,r,o),p=Math.max(a,h,l);let f=n.next;for(;f!==e;){if(f.x>=c&&f.x<=u&&f.y>=d&&f.y<=p&&q(s,a,r,h,o,l,f.x,f.y)&&$(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function z(t,e,i,n){const s=t.prev,r=t,o=t.next;if($(s,r,o)>=0)return!1;const a=s.x,h=r.x,l=o.x,c=s.y,d=r.y,u=o.y,p=Math.min(a,h,l),f=Math.min(c,d,u),g=Math.max(a,h,l),m=Math.max(c,d,u),y=X(p,f,e,i,n),x=X(g,m,e,i,n);let b=t.prevZ,_=t.nextZ;for(;b&&b.z>=y&&_&&_.z<=x;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==o&&q(a,c,h,d,l,u,b.x,b.y)&&$(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,_.x>=p&&_.x<=g&&_.y>=f&&_.y<=m&&_!==s&&_!==o&&q(a,c,h,d,l,u,_.x,_.y)&&$(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==o&&q(a,c,h,d,l,u,b.x,b.y)&&$(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=g&&_.y>=f&&_.y<=m&&_!==s&&_!==o&&q(a,c,h,d,l,u,_.x,_.y)&&$(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function H(t,e){let i=t;do{const n=i.prev,s=i.next.next;!tt(n,s)&&et(n,i,i.next,s)&&st(n,s)&&st(s,n)&&(e.push(n.i,i.i,s.i),at(i),at(i.next),i=t=s),i=i.next}while(i!==t);return G(i)}function V(t,e,i,n,s,r){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&Q(o,t)){let a=rt(o,t);return o=G(o,o.next),a=G(a,a.next),U(o,e,i,n,s,r,0),void U(a,e,i,n,s,r,0)}t=t.next}o=o.next}while(o!==t)}function W(t,e){let i=t.x-e.x;return 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)),i}function Z(t,e){const i=function(t,e){let i=e;const n=t.x,s=t.y;let r,o=-1/0;if(tt(t,i))return i;do{if(tt(t,i.next))return i.next;if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){const t=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>o&&(o=t,r=i.x<i.next.x?i:i.next,t===n))return r}i=i.next}while(i!==e);if(!r)return null;const a=r,h=r.x,l=r.y;let c=1/0;i=r;do{if(n>=i.x&&i.x>=h&&n!==i.x&&K(s<l?n:o,s,h,l,s<l?o:n,s,i.x,i.y)){const e=Math.abs(s-i.y)/(n-i.x);st(i,t)&&(e<c||e===c&&(i.x>r.x||i.x===r.x&&J(r,i)))&&(r=i,c=e)}i=i.next}while(i!==a);return r}(t,e);if(!i)return e;const n=rt(i,t);return G(n,n.next),G(i,i.next)}function J(t,e){return $(t.prev,t,e.prev)<0&&$(e.next,t,t.next)<0}function X(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Y(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 K(t,e,i,n,s,r,o,a){return(s-o)*(e-a)>=(t-o)*(r-a)&&(t-o)*(n-a)>=(i-o)*(e-a)&&(i-o)*(r-a)>=(s-o)*(n-a)}function q(t,e,i,n,s,r,o,a){return!(t===o&&e===a)&&K(t,e,i,n,s,r,o,a)}function Q(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&&et(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(st(t,e)&&st(e,t)&&function(t,e){let i=t,n=!1;const s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&($(t.prev,t,e.prev)||$(t,e.prev,e))||tt(t,e)&&$(t.prev,t,t.next)>0&&$(e.prev,e,e.next)>0)}function $(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function tt(t,e){return t.x===e.x&&t.y===e.y}function et(t,e,i,n){const s=nt($(t,e,i)),r=nt($(t,e,n)),o=nt($(i,n,t)),a=nt($(i,n,e));return s!==r&&o!==a||!(0!==s||!it(t,i,e))||!(0!==r||!it(t,n,e))||!(0!==o||!it(i,t,n))||!(0!==a||!it(i,e,n))}function it(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 nt(t){return t>0?1:t<0?-1:0}function st(t,e){return $(t.prev,t,t.next)<0?$(t,e,t.next)>=0&&$(t,t.prev,e)>=0:$(t,e,t.prev)<0||$(t,t.next,e)<0}function rt(t,e){const i=ht(t.i,t.x,t.y),n=ht(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function ot(t,e,i,n){const s=ht(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function at(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 ht(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function lt(t){return void 0!==vo||(vo=(()=>{const e={stencil:!0,failIfMajorPerformanceCaveat:t??Co.defaultOptions.failIfMajorPerformanceCaveat};try{if(!qs.get().getWebGLRenderingContext())return!1;let t=qs.get().createCanvas().getContext("webgl",e);const i=!!t?.getContextAttributes()?.stencil;if(t){const e=t.getExtension("WEBGL_lose_context");e&&e.loseContext()}return t=null,i}catch(t){return!1}})()),vo}async function ct(t={}){return void 0!==wo||(wo=await(async()=>{const e=qs.get().getNavigator().gpu;if(!e)return!1;try{const i=await e.requestAdapter(t);return await i.requestDevice(),!0}catch(t){return!1}})()),wo}function dt(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 t=i.length-1;t>=0;t--){let e=i[t].trim();/([\"\'])[^\'\"]+\1/.test(e)||ko.includes(e)||(e=`"${e}"`),i[t]=e}return`${t.fontStyle} ${t.fontVariant} ${t.fontWeight} ${e} ${i.join(",")}`}function ut(t,e){for(let i=0;i<e.length;i++){const n=e[i];t.addColorStop(n.offset,n.color)}}function pt(t,e){const i=qs.get().createCanvas(t,e),n=i.getContext("2d");return{canvas:i,context:n}}function ft(t,e,i,n,s,r){const o=s-i,a=r-n,h=o*o+a*a;let l,c,d=-1;0!==h&&(d=((t-i)*o+(e-n)*a)/h),d<0?(l=i,c=n):d>1?(l=s,c=r):(l=i+d*o,c=n+d*a);const u=t-l,p=e-c;return u*u+p*p}function gt(t,e,i){let n=2166136261;for(let i=0;i<e;i++)n^=t[i].uid,n=Math.imul(n,16777619),n>>>=0;return Ko[n]||function(t,e,i,n){const s={};let r=0;for(let i=0;i<n;i++){const n=i<e?t[i]:Fn.EMPTY.source;s[r++]=n.source,s[r++]=n.style}const o=new ro(s);return Ko[i]=o,o}(t,e,n,i)}function mt(t,e){const i=t.byteLength/8|0,n=new Float64Array(t,0,i);new Float64Array(e,0,i).set(n);const s=t.byteLength-8*i;if(s>0){const n=new Uint8Array(t,8*i,s);new Uint8Array(e,8*i,s).set(n)}}function yt(t,e){return"no-premultiply-alpha"===e.alphaMode&&Qo[t]||t}function xt(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 bt(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=ta.replace(/%forloop%/gi,xt(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}function _t(){return ra>0?sa[--ra]:new na}function vt(t){sa[ra++]=t}function wt(t,e){if(!(t instanceof ca)){let i=e?la.INDEX:la.VERTEX;t instanceof Array&&(e?(t=new Uint32Array(t),i=la.INDEX|la.COPY_DST):(t=new Float32Array(t),i=la.VERTEX|la.COPY_DST)),t=new ca({data:t,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:i})}return t}function Ct(t,e,i){if(t)for(const n in t){const s=e[n.toLocaleLowerCase()];if(s){let e=t[n];"header"===n&&(e=e.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),i&&s.push(`//----${i}----//`),s.push(e)}else a()}}function St(t){const e={};return(t.match(ga)?.map(t=>t.replace(/[{()}]/g,""))??[]).forEach(t=>{e[t]=[]}),e}function It(t,e){let i;const n=/@in\s+([^;]+);/g;for(;null!==(i=n.exec(t));)e.push(i[1])}function At(t,e,i=!1){const n=[];It(e,n),t.forEach(t=>{t.header&&It(t.header,n)});const s=n;i&&s.sort();const r=s.map((t,e)=>` @location(${e}) ${t},`).join("\n");let o=e.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`\n${r}\n`),o}function Mt(t,e){let i;const n=/@out\s+([^;]+);/g;for(;null!==(i=n.exec(t));)e.push(i[1])}function Tt(t,e){let i=t;for(const t in e){const n=e[t];i=n.join("\n").length?i.replace(`{{${t}}}`,`//-----${t} START-----//\n${n.join("\n")}\n//----${t} FINISH----//`):i.replace(`{{${t}}}`,"")}return i}function Pt({template:t,bits:e}){const i=Et(t,e);return ma[i]||(ma[i]=Bt(t.vertex,t.fragment,e)),ma[i]}function Et(t,e){return e.map(t=>(ya.has(t)||ya.set(t,xa++),ya.get(t))).sort((t,e)=>t-e).join("-")+t.vertex+t.fragment}function Bt(t,e,i){const n=St(t),s=St(e);return i.forEach(t=>{Ct(t.vertex,n,t.name),Ct(t.fragment,s,t.name)}),{vertex:Tt(t,n),fragment:Tt(e,s)}}function Ot({bits:t,name:e}){const i=function({template:t,bits:e}){const i=Et(t,e);if(ma[i])return ma[i];const{vertex:n,fragment:s}=function(t,e){const i=e.map(t=>t.vertex).filter(t=>!!t),n=e.map(t=>t.fragment).filter(t=>!!t);let s=At(i,t.vertex,!0);return s=function(t,e){const i=[];Mt(e,i),t.forEach(t=>{t.header&&Mt(t.header,i)});let n=0;const s=i.sort().map(t=>t.indexOf("builtin")>-1?t:`@location(${n++}) ${t}`).join(",\n"),r=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${s}\n`),a=a.replace("{{start}}",`\n${r}\n`),a=a.replace("{{return}}",`\n${o}\n`),a}(i,s),{vertex:s,fragment:At(n,t.fragment,!0)}}(t,e);return ma[i]=Bt(n,s,e),ma[i]}({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:[ba,...t]});return to.from({name:e,vertex:{source:i.vertex,entryPoint:"main"},fragment:{source:i.fragment,entryPoint:"main"}})}function kt({bits:t,name:e}){return new Yr({name:e,...Pt({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:[_a,...t]})})}function Rt(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 Dt(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 Ft(t){return Ca[t]||(Ca[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 ${Rt(t)}\n `,main:`\n var uvDx = dpdx(vUV);\n var uvDy = dpdy(vUV);\n\n ${Dt(t)}\n `}}),Ca[t]}function Lt(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 jt(t){return Sa[t]||(Sa[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 ${Lt(t)}\n `}}),Sa[t]}function Gt(t){let e=Ma[t];if(e)return e;const i=new Int32Array(t);for(let e=0;e<t;e++)i[e]=e;return e=Ma[t]=new so({uTextures:{value:i,type:"i32",size:t}},{isStatic:!0}),e}function Ut(t,e,i,n,s){const r=e.a,o=e.b,a=e.c,h=e.d,l=e.tx,c=e.ty;i||(i=0),n||(n=2),s||(s=t.length/n-i);let d=i*n;for(let e=0;e<s;e++){const e=t[d],i=t[d+1];t[d]=r*e+a*i+l,t[d+1]=o*e+h*i+c,d+=n}}function Nt(t,e,i,n,s,r,o,a){let h,l;o?(h=n,l=-i):(h=-n,l=i);const c=t-i*s+h,d=e-n*s+l,u=t+i*r+h,p=e+n*r+l;return a.push(c,d),a.push(u,p),2}function zt(t,e,i,n,s,r,o,a){const h=i-t,l=n-e;let c=Math.atan2(h,l),d=Math.atan2(s-t,r-e);a&&c<d?c+=2*Math.PI:!a&&c>d&&(d+=2*Math.PI);let u=c;const p=d-c,f=Math.abs(p),g=Math.sqrt(h*h+l*l),m=1+(15*f*Math.sqrt(g)/Math.PI|0),y=p/m;if(u+=y,a){o.push(t,e),o.push(i,n);for(let i=1,n=u;i<m;i++,n+=y)o.push(t,e),o.push(t+Math.sin(n)*g,e+Math.cos(n)*g);o.push(t,e),o.push(s,r)}else{o.push(i,n),o.push(t,e);for(let i=1,n=u;i<m;i++,n+=y)o.push(t+Math.sin(n)*g,e+Math.cos(n)*g),o.push(t,e);o.push(s,r),o.push(t,e)}return 2*m}function Ht(t,e,i,n,s,r,o){const a=mo(t,e,2);if(!a)return;for(let t=0;t<a.length;t+=3)r[o++]=a[t]+s,r[o++]=a[t+1]+s,r[o++]=a[t+2]+s;let h=s*n;for(let e=0;e<t.length;e+=2)i[h]=t[e],i[h+1]=t[e+1],h+=n}function Vt(t,e,i){const n=[],s=Va.rectangle,r=Wa;r.x=t.dx,r.y=t.dy,r.width=t.dw,r.height=t.dh;const o=t.transform;if(!s.build(r,n))return;const{vertices:a,uvs:h,indices:l}=i,c=l.length,d=a.length/2;o&&Ut(n,o),s.triangulate(n,a,2,d,l,c);const u=t.image,p=u.uvs;h.push(p.x0,p.y0,p.x1,p.y1,p.x3,p.y3,p.x2,p.y2);const f=ms.get(ka);f.indexOffset=c,f.indexSize=l.length-c,f.attributeOffset=d,f.attributeSize=a.length/2-d,f.baseColor=t.style,f.alpha=t.alpha,f.texture=u,f.geometryData=i,e.push(f)}function Wt(t,e,i,n,s){const{vertices:r,uvs:o,indices:a}=s;t.shapePrimitives.forEach(({shape:t,transform:h,holes:l})=>{const c=[],d=Va[t.type];if(!d.build(t,c))return;const u=a.length,p=r.length/2;let f="triangle-list";if(h&&Ut(c,h),i){const i=t.closePath??!0,n=e;n.pixelLine?(function(t,e,i,n){const s=La;if(0===t.length)return;const r=t[0],o=t[1],a=t[t.length-2],h=t[t.length-1],l=e||Math.abs(r-a)<s&&Math.abs(o-h)<s,c=i,d=t.length/2,u=c.length/2;for(let e=0;e<d;e++)c.push(t[2*e]),c.push(t[2*e+1]);for(let t=0;t<d-1;t++)n.push(u+t,u+t+1);l&&n.push(u+d-1,u)}(c,i,r,a),f="line-list"):function(t,e,i,n,s,r){const o=La;if(0===t.length)return;const a=e;let h=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,s=t[e-2],r=t[e-1];n<e;n+=2){const e=t[n],o=t[n+1];i+=(e-s)*(o+r),s=e,r=o}return i<0?-1:1}(t);h=(h-.5)*e+.5}const l=new cn(t[0],t[1]),c=new cn(t[t.length-2],t[t.length-1]),d=n,u=Math.abs(l.x-c.x)<o&&Math.abs(l.y-c.y)<o;if(d){t=t.slice(),u&&(t.pop(),t.pop(),c.set(t[t.length-2],t[t.length-1]));const e=.5*(l.x+c.x),i=.5*(c.y+l.y);t.unshift(e,i),t.push(e,i)}const p=s,f=t.length/2;let g=t.length;const m=p.length/2,y=a.width/2,x=y*y,b=a.miterLimit*a.miterLimit;let _=t[0],v=t[1],w=t[2],C=t[3],S=0,I=0,A=-(v-C),M=_-w,T=0,P=0,E=Math.sqrt(A*A+M*M);A/=E,M/=E,A*=y,M*=y;const B=2*(1-h),O=2*h;d||("round"===a.cap?g+=zt(_-A*(B-O)*.5,v-M*(B-O)*.5,_-A*B,v-M*B,_+A*O,v+M*O,p,!0)+2:"square"===a.cap&&(g+=Nt(_,v,A,M,B,O,!0,p))),p.push(_-A*B,v-M*B),p.push(_+A*O,v+M*O);for(let e=1;e<f-1;++e){_=t[2*(e-1)],v=t[2*(e-1)+1],w=t[2*e],C=t[2*e+1],S=t[2*(e+1)],I=t[2*(e+1)+1],A=-(v-C),M=_-w,E=Math.sqrt(A*A+M*M),A/=E,M/=E,A*=y,M*=y,T=-(C-I),P=w-S,E=Math.sqrt(T*T+P*P),T/=E,P/=E,T*=y,P*=y;const i=w-_,n=v-C,s=w-S,r=I-C,o=i*s+n*r,h=n*s-r*i,l=h<0;if(Math.abs(h)<.001*Math.abs(o)){p.push(w-A*B,C-M*B),p.push(w+A*O,C+M*O),o>=0&&("round"===a.join?g+=zt(w,C,w-A*B,C-M*B,w-T*B,C-P*B,p,!1)+4:g+=2,p.push(w-T*O,C-P*O),p.push(w+T*B,C+P*B));continue}const c=(-A+_)*(-M+C)-(-A+w)*(-M+v),d=(-T+S)*(-P+C)-(-T+w)*(-P+I),u=(i*d-s*c)/h,f=(r*c-n*d)/h,m=(u-w)*(u-w)+(f-C)*(f-C),k=w+(u-w)*B,R=C+(f-C)*B,D=w-(u-w)*O,F=C-(f-C)*O,L=l?B:O;m<=Math.min(i*i+n*n,s*s+r*r)+L*L*x?"bevel"===a.join||m/x>b?(l?(p.push(k,R),p.push(w+A*O,C+M*O),p.push(k,R),p.push(w+T*O,C+P*O)):(p.push(w-A*B,C-M*B),p.push(D,F),p.push(w-T*B,C-P*B),p.push(D,F)),g+=2):"round"===a.join?l?(p.push(k,R),p.push(w+A*O,C+M*O),g+=zt(w,C,w+A*O,C+M*O,w+T*O,C+P*O,p,!0)+4,p.push(k,R),p.push(w+T*O,C+P*O)):(p.push(w-A*B,C-M*B),p.push(D,F),g+=zt(w,C,w-A*B,C-M*B,w-T*B,C-P*B,p,!1)+4,p.push(w-T*B,C-P*B),p.push(D,F)):(p.push(k,R),p.push(D,F)):(p.push(w-A*B,C-M*B),p.push(w+A*O,C+M*O),"round"===a.join?g+=l?zt(w,C,w+A*O,C+M*O,w+T*O,C+P*O,p,!0)+2:zt(w,C,w-A*B,C-M*B,w-T*B,C-P*B,p,!1)+2:"miter"===a.join&&m/x<=b&&(l?(p.push(D,F),p.push(D,F)):(p.push(k,R),p.push(k,R)),g+=2),p.push(w-T*B,C-P*B),p.push(w+T*O,C+P*O),g+=2)}_=t[2*(f-2)],v=t[2*(f-2)+1],w=t[2*(f-1)],C=t[2*(f-1)+1],A=-(v-C),M=_-w,E=Math.sqrt(A*A+M*M),A/=E,M/=E,A*=y,M*=y,p.push(w-A*B,C-M*B),p.push(w+A*O,C+M*O),d||("round"===a.cap?g+=zt(w-A*(B-O)*.5,C-M*(B-O)*.5,w-A*B,C-M*B,w+A*O,C+M*O,p,!1)+2:"square"===a.cap&&(g+=Nt(w,C,A,M,B,O,!1,p)));for(let t=m;t<g+m-2;++t)_=p[2*t],v=p[2*t+1],w=p[2*(t+1)],C=p[2*(t+1)+1],S=p[2*(t+2)],I=p[2*(t+2)+1],Math.abs(_*(C-I)+w*(I-v)+S*(v-C))<1e-8||r.push(t,t+1,t+2)}(c,n,0,i,r,a)}else if(l){const t=[],e=c.slice();(function(t){const e=[];for(let i=0;i<t.length;i++){const n=t[i].shape,s=[];Va[n.type].build(n,s)&&e.push(s)}return e})(l).forEach(i=>{t.push(e.length/2),e.push(...i)}),Ht(e,t,r,2,p,a,u)}else d.triangulate(c,r,2,p,a,u);const g=o.length/2,m=e.texture;if(m!==Fn.WHITE){const i=function(t,e,i,n){const s=e.matrix?t.copyFrom(e.matrix).invert():t.identity();if("local"===e.textureSpace){const t=i.getBounds(Ha);e.width&&t.pad(e.width);const{x:n,y:r}=t,o=1/t.width,a=1/t.height,h=-n*o,l=-r*a,c=s.a,d=s.b,u=s.c,p=s.d;s.a*=o,s.b*=o,s.c*=a,s.d*=a,s.tx=h*c+l*u+s.tx,s.ty=h*d+l*p+s.ty}else s.translate(e.texture.frame.x,e.texture.frame.y),s.scale(1/e.texture.source.width,1/e.texture.source.height);const r=e.texture.source.style;return e.fill instanceof Go||"clamp-to-edge"!==r.addressMode||(r.addressMode="repeat",r.update()),n&&s.append(za.copyFrom(n).invert()),s}(Za,e,t,h);!function(t,e,i,n,s,r,o,a=null){let h=0;i*=e,s*=r;const l=a.a,c=a.b,d=a.c,u=a.d,p=a.tx,f=a.ty;for(;h<o;){const o=t[i],a=t[i+1];n[s]=l*o+d*a+p,n[s+1]=c*o+u*a+f,s+=r,i+=e,h++}}(r,2,p,o,g,2,r.length/2-p,i)}else!function(t,e,i,n){let s=0;for(e*=2;s<n;)t[e]=0,t[e+1]=0,e+=2,s++}(o,g,0,r.length/2-p);const y=ms.get(ka);y.indexOffset=u,y.indexSize=a.length-u,y.attributeOffset=p,y.attributeSize=r.length/2-p,y.baseColor=e.color,y.alpha=e.alpha,y.texture=m,y.geometryData=s,y.topology=f,n.push(y)})}function Zt(t,e,i,n,s,r,o,a,h,l){let c=(1-Math.min(.99,Math.max(0,l??Ka.defaultOptions.bezierSmoothness)))/1;return c*=c,function(t,e,i,n,s,r,o,a,h,l){Jt(t,e,i,n,s,r,o,a,h,l,0),h.push(o,a)}(e,i,n,s,r,o,a,h,t,c),t}function Jt(t,e,i,n,s,r,o,a,h,l,c){if(c>8)return;const d=(t+i)/2,u=(e+n)/2,p=(i+s)/2,f=(n+r)/2,g=(s+o)/2,m=(r+a)/2,y=(d+p)/2,x=(u+f)/2,b=(p+g)/2,_=(f+m)/2,v=(y+b)/2,w=(x+_)/2;if(c>0){let c=o-t,d=a-e;const u=Math.abs((i-o)*d-(n-a)*c),p=Math.abs((s-o)*d-(r-a)*c);if(u>qa&&p>qa){if((u+p)*(u+p)<=l*(c*c+d*d))return void h.push(v,w)}else if(u>qa){if(u*u<=l*(c*c+d*d))return void h.push(v,w)}else if(p>qa){if(p*p<=l*(c*c+d*d))return void h.push(v,w)}else if(c=v-(t+o)/2,d=w-(e+a)/2,c*c+d*d<=l)return void h.push(v,w)}Jt(t,e,d,u,y,x,v,w,h,l,c+1),Jt(v,w,b,_,g,m,o,a,h,l,c+1)}function Xt(t,e,i,n,s,r,o,a){let h=(1-Math.min(.99,Math.max(0,a??Ka.defaultOptions.bezierSmoothness)))/1;return h*=h,function(t,e,i,n,s,r,o,a){Yt(o,t,e,i,n,s,r,a,0),o.push(s,r)}(e,i,n,s,r,o,t,h),t}function Yt(t,e,i,n,s,r,o,a,h){if(h>8)return;const l=(e+n)/2,c=(i+s)/2,d=(n+r)/2,u=(s+o)/2,p=(l+d)/2,f=(c+u)/2;let g=r-e,m=o-i;const y=Math.abs((n-r)*m-(s-o)*g);if(y>1.1920929e-7){if(y*y<=a*(g*g+m*m))return void t.push(p,f)}else if(g=p-(e+r)/2,m=f-(i+o)/2,g*g+m*m<=a)return void t.push(p,f);Yt(t,e,i,l,c,p,f,a,h+1),Yt(t,p,f,d,u,r,o,a,h+1)}function Kt(t,e,i,n,s,r,o,a){let h=Math.abs(s-r);(!o&&s>r||o&&r>s)&&(h=2*Math.PI-h),a||(a=Math.max(6,Math.floor(6*Math.pow(n,1/3)*(h/Math.PI))));let l=h/(a=Math.max(a,3)),c=s;l*=o?-1:1;for(let s=0;s<a+1;s++){const s=e+Math.cos(c)*n,r=i+Math.sin(c)*n;t.push(s,r),c+=l}}function qt(t,e){const i=-1.5707963267948966===e?-.551915024494:4/3*Math.tan(e/4),n=1.5707963267948966===e?.551915024494:i,s=Math.cos(t),r=Math.sin(t),o=Math.cos(t+e),a=Math.sin(t+e);return[{x:s-r*n,y:r+s*n},{x:o+a*n,y:a-o*n},{x:o,y:a}]}function Qt(t,e){return t?t.prepend(e):e.clone()}function $t(t,e,i){const n=t.getAttribute(e);return n?Number(n):i}function te(t){const e=$t(t,"x1",0),i=$t(t,"y1",0),n=$t(t,"x2",1),s=$t(t,"y2",0),r=t.getAttribute("gradientUnits")||"objectBoundingBox",o=new Go(e,i,n,s,"objectBoundingBox"===r?"local":"global");for(let e=0;e<t.children.length;e++){const i=t.children[e],n=$t(i,"offset",0),s=ps.shared.setValue(i.getAttribute("stop-color")).toNumber();o.addColorStop(n,s)}return o}function ee(t){return a(),new Go(0,0,1,0)}function ie(t){const e=t.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}function ne(t,e){const i=t.getAttribute("style"),n={},s={},r={strokeStyle:n,fillStyle:s,useFill:!1,useStroke:!1};for(const i in rh){const n=t.getAttribute(i);n&&se(e,r,i,n.trim())}if(i){const t=i.split(";");for(let i=0;i<t.length;i++){const n=t[i].trim(),[s,o]=n.split(":");rh[s]&&se(e,r,s,o.trim())}}return{strokeStyle:r.useStroke?n:null,fillStyle:r.useFill?s:null,useFill:r.useFill,useStroke:r.useStroke}}function se(t,e,i,n){switch(i){case"stroke":if("none"!==n){if(n.startsWith("url(")){const i=ie(n);e.strokeStyle.fill=t.defs[i]}else e.strokeStyle.color=ps.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=ie(n);e.fillStyle.fill=t.defs[i]}else e.fillStyle.color=ps.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 re(t,e,i,n){const s=t.children,{fillStyle:r,strokeStyle:o}=ne(t,e);r&&i?i={...i,...r}:r&&(i=r),o&&n?n={...n,...o}:o&&(n=o);const h=!i&&!n;let l,c,d,u,p,f,g,m,y,x,b,_,v,w,C,S,I;switch(h&&(i={color:0}),t.nodeName.toLowerCase()){case"path":w=t.getAttribute("d"),"evenodd"===t.getAttribute("fill-rule")&&a(),C=new sh(w,!0),e.context.path(C),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"circle":g=$t(t,"cx",0),m=$t(t,"cy",0),y=$t(t,"r",0),e.context.ellipse(g,m,y,y),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"rect":l=$t(t,"x",0),c=$t(t,"y",0),S=$t(t,"width",0),I=$t(t,"height",0),x=$t(t,"rx",0),b=$t(t,"ry",0),x||b?e.context.roundRect(l,c,S,I,x||b):e.context.rect(l,c,S,I),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"ellipse":g=$t(t,"cx",0),m=$t(t,"cy",0),x=$t(t,"rx",0),b=$t(t,"ry",0),e.context.beginPath(),e.context.ellipse(g,m,x,b),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"line":d=$t(t,"x1",0),u=$t(t,"y1",0),p=$t(t,"x2",0),f=$t(t,"y2",0),e.context.beginPath(),e.context.moveTo(d,u),e.context.lineTo(p,f),n&&e.context.stroke(n);break;case"polygon":v=t.getAttribute("points"),_=v.match(/\d+/g).map(t=>parseInt(t,10)),e.context.poly(_,!0),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"polyline":v=t.getAttribute("points"),_=v.match(/\d+/g).map(t=>parseInt(t,10)),e.context.poly(_,!1),n&&e.context.stroke(n);break;case"g":case"svg":break;default:a(t.nodeName)}h&&(i=null);for(let t=0;t<s.length;t++)re(s[t],e,i,n)}function oe(t){return t instanceof No}function ae(t){return t instanceof Go}function he(t,e,i){return t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,{...i,...t}}function le(t,e,i){return e.buildGradient(),t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,t.textureSpace=e.textureSpace,{...i,...t}}function ce(t,e){if(null==t)return null;const i={},n=t;return function(t){return ps.isColorLike(t)}(t)?function(t,e,i){const n=ps.shared.setValue(e??0);return t.color=n.toNumber(),t.alpha=1===n.alpha?i.alpha:n.alpha,t.texture=Fn.WHITE,{...i,...t}}(i,t,e):function(t){return t instanceof Fn}(t)?function(t,e,i){return t.texture=e,{...i,...t}}(i,t,e):oe(t)?he(i,t,e):ae(t)?le(i,t,e):n.fill&&oe(n.fill)?he(n,n.fill,e):n.fill&&ae(n.fill)?le(n,n.fill,e):function(t,e){const i={...e,...t},n=ps.shared.setValue(i.color);return i.alpha*=n.alpha,i.color=n.toNumber(),i}(n,e)}function de(t,e){const{width:i,alignment:n,miterLimit:s,cap:r,join:o,pixelLine:a,...h}=e,l=ce(t,h);return l?{width:i,alignment:n,miterLimit:s,cap:r,join:o,pixelLine:a,...l}:null}function ue(t,e,i){return t?(e[i++]=t.color,e[i++]=t.alpha,e[i++]=t.fill?.styleKey,i):i}function pe(t,e,i,n=0){if(t.texture===Fn.WHITE&&!t.fill)return ps.shared.setValue(t.color).setAlpha(t.alpha??1).toHexa();if(!t.fill){const i=e.createPattern(t.texture.source.resource,"repeat"),n=t.matrix.copyTo(un.shared);return n.scale(t.texture.frame.width,t.texture.frame.height),i.setTransform(n),i}if(t.fill instanceof No){const i=t.fill,n=e.createPattern(i.texture.source.resource,"repeat"),s=i.transform.copyTo(un.shared);return s.scale(i.texture.frame.width,i.texture.frame.height),n.setTransform(s),n}if(t.fill instanceof Go){const s=t.fill,r="linear"===s.type,o="local"===s.textureSpace;let a,h=1,l=1;o&&i&&(h=i.width+n,l=i.height+n);let c=!1;if(r){const{start:t,end:i}=s;a=e.createLinearGradient(t.x*h,t.y*l,i.x*h,i.y*l),c=Math.abs(i.x-t.x)<Math.abs(.1*(i.y-t.y))}else{const{center:t,innerRadius:i,outerCenter:n,outerRadius:r}=s;a=e.createRadialGradient(t.x*h,t.y*l,i*h,n.x*h,n.y*l,r*h)}if(c&&o&&i){const t=i.lineHeight/l;for(let e=0;e<i.lines.length;e++){const r=(e*i.lineHeight+n/2)/l;s.colorStops.forEach(e=>{const i=r+e.offset*t;a.addColorStop(Math.floor(i*fh)/fh,ps.shared.setValue(e.color).toHex())})}}else s.colorStops.forEach(t=>{a.addColorStop(t.offset,ps.shared.setValue(t.color).toHex())});return a}return a(),"red"}function fe(t,e,i,n){const s={width:0,height:0,offsetY:0,scale:e.fontSize/i.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};s.offsetY=i.baseLineOffset;let r=s.lines[0],o=null,a=!0;const h={width:0,start:0,index:0,positions:[],chars:[]},l=i.baseMeasurementFontSize/e.fontSize,c=e.letterSpacing*l,d=e.wordWrapWidth*l,u=e.lineHeight?e.lineHeight*l:i.lineHeight,p=e.wordWrap&&e.breakWords,f=t=>{const e=r.width;for(let i=0;i<h.index;i++){const n=t.positions[i];r.chars.push(t.chars[i]),r.charPositions.push(n+e)}r.width+=t.width,a=!1,h.width=0,h.index=0,h.chars.length=0},g=()=>{let t=r.chars.length-1;if(n){let e=r.chars[t];for(;" "===e;)r.width-=i.chars[e].xAdvance,e=r.chars[--t]}s.width=Math.max(s.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,s.lines.push(r),s.height+=u},m=t=>t-c>d;for(let n=0;n<t.length+1;n++){let s;const l=n===t.length;l||(s=t[n]);const d=i.chars[s]||i.chars[" "];if(/(?:\s)/.test(s)||"\r"===s||"\n"===s||l){if(!a&&e.wordWrap&&m(r.width+h.width)?(g(),f(h),l||r.charPositions.push(0)):(h.start=r.width,f(h),l||r.charPositions.push(0)),"\r"===s||"\n"===s)0!==r.width&&g();else if(!l){const t=d.xAdvance+(d.kerning[o]||0)+c;r.width+=t,r.spaceWidth=t,r.spacesIndex.push(r.charPositions.length),r.chars.push(s)}}else{const t=d.kerning[o]||0,e=d.xAdvance+t+c;p&&m(r.width+h.width+e)&&(f(h),g()),h.positions[h.index++]=h.width+t,h.chars.push(s),h.width+=e}o=s}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}}(s):"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}}(s):"justify"===e.align&&function(t){const e=t.width;for(let i=0;i<t.lines.length;i++){const n=t.lines[i];let s=0,r=n.spacesIndex[s++],o=0;const a=n.spacesIndex.length,h=(e-n.width)/a;for(let t=0;t<n.charPositions.length;t++)t===r&&(r=n.spacesIndex[s++],o+=h),n.charPositions[t]+=o}}(s),s}async function ge(t){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=await(await fetch(t)).blob();await createImageBitmap(e)}catch(t){return!1}return!0}return!1}function me(t){return!Eh&&""!==document.createElement("video").canPlayType(t)}function ye(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 xe(t,e){const i=t.split("?")[0],n=dr.extname(i).toLowerCase();return Array.isArray(e)?e.includes(n):n===e}function be(t){return zh.test(t)?t:encodeURI(t)}function _e(t,e=1){const i=pr.RETINA_PREFIX?.exec(t);return i?parseFloat(i[1]):e}function ve(t,e,i){t.label=i,t._sourceOrigin=i;const n=new Fn({source:t,label:i}),s=()=>{delete e.promiseCache[i],hr.has(i)&&hr.remove(i)};return n.source.once("destroy",()=>{e.promiseCache[i]&&(a(),s())}),n.once("destroy",()=>{t.destroyed||(a(),s())}),n}function we(t,e,i,n,s,r,o,a){const h=o-i,l=a-n,c=s-i,d=r-n,u=t-i,p=e-n,f=h*h+l*l,g=h*c+l*d,m=h*u+l*p,y=c*c+d*d,x=c*u+d*p,b=1/(f*y-g*g),_=(y*m-g*x)*b,v=(f*x-g*m)*b;return _>=0&&v>=0&&_+v<1}function Ce(t,e,i){for(let n=0,s=4*i*e;n<e;++n,s+=4)if(0!==t[s+3])return!1;return!0}function Se(t,e,i,n,s){const r=4*e;for(let e=n,o=n*r+4*i;e<=s;++e,o+=r)if(0!==t[o+3])return!1;return!0}function Ie(...t){let e=t[0];e.canvas||(e={canvas:t[0],resolution:t[1]});const{canvas:i}=e,s=Math.min(e.resolution??1,1),r=e.width??i.width,o=e.height??i.height;let a=e.output;if(function(t,e){Ll||(Ll=qs.get().createCanvas(256,128),jl=Ll.getContext("2d",{willReadFrequently:!0}),jl.globalCompositeOperation="copy",jl.globalAlpha=1),(Ll.width<t||Ll.height<e)&&(Ll.width=n(t),Ll.height=n(e))}(r,o),!jl)throw new TypeError("Failed to get canvas 2D context");jl.drawImage(i,0,0,r,o,0,0,r*s,o*s);const h=jl.getImageData(0,0,r,o).data;let l=0,c=0,d=r-1,u=o-1;for(;c<o&&Ce(h,r,c);)++c;if(c===o)return Sn.EMPTY;for(;Ce(h,r,u);)--u;for(;Se(h,r,l,c,u);)++l;for(;Se(h,r,d,c,u);)--d;return++d,++u,jl.globalCompositeOperation="source-over",jl.strokeRect(l,c,d-l,u-c),jl.globalCompositeOperation="copy",a??(a=new Sn),a.set(l/s,c/s,(d-l)/s,(u-c)/s),a}function Ae(t,e){for(const i in t.attributes){const n=t.attributes[i],s=e[i];s?(n.format??(n.format=s.format),n.offset??(n.offset=s.offset),n.instance??(n.instance=s.instance)):a()}!function(t){const{buffers:e,attributes:i}=t,n={},s={};for(const t in e){const i=e[t];n[i.uid]=0,s[i.uid]=0}for(const t in i){const e=i[t];n[e.buffer.uid]+=k(e.format).stride}for(const t in i){const e=i[t];e.stride??(e.stride=n[e.buffer.uid]),e.start??(e.start=s[e.buffer.uid]),s[e.buffer.uid]+=k(e.format).stride}}(t)}function Me(t){return gc[t]??gc.float32}function Te(t){const e=t.map(t=>({data:t,offset:0,size:0}));let i=0,n=0;for(let t=0;t<e.length;t++){const s=e[t];if(i=Tc[s.data.type],!i)throw new Error(`Unknown type ${s.data.type}`);s.data.size>1&&(i=Math.max(i,16)*s.data.size);const r=12===i?16:i;s.size=i;const o=n%16;n+=o>0&&16-o<r?(16-o)%16:(i-o%i)%i,s.offset=n,n+=i}return n=16*Math.ceil(n/16),{uboElements:e,size:n}}function Pe(t,e,i,n){const s=["\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 r=0;for(let o=0;o<t.length;o++){const a=t[o],h=a.data.name;let l=!1,c=0;for(let t=0;t<Pc.length;t++)if(Pc[t].test(a.data)){c=a.offset/4,s.push(`name = "${h}";`,`offset += ${c-r};`,Pc[t][e]||Pc[t].ubo),l=!0;break}if(!l)if(a.data.size>1)c=a.offset/4,s.push(i(a,c-r));else{const t=n[a.data.type];c=a.offset/4,s.push(`\n v = uv.${h};\n offset += ${c-r};\n ${t};\n `)}r=c}const o=s.join("\n");return new Function("uv","data","dataInt32","offset",o)}function Ee(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 `}function Be(t,e){const i=Math.max(Tc[t.data.type]/16,1),n=t.data.value.length/t.data.size,s=(4-n%4)%4,r=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 ${r}[arrayOffset++] = v[t++];\n }\n ${0!==s?`arrayOffset += ${s};`:""}\n }\n `}function Oe(t){return Pe(t,"uboStd40",Be,Ec)}function ke(t,e){if(!Rc.has(t)){const i=new Fn({source:new Qs({resource:t,...e})}),n=()=>{Rc.get(t)===i&&Rc.delete(t)};i.once("destroy",n),i.source.once("destroy",n),Rc.set(t,i)}return Rc.get(t)}function Re(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}function De(t){const e=new Array(t);for(let t=0;t<e.length;t++)e[t]=!1;return e}function Fe(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 De(2*e);case"bvec3":return De(3*e);case"bvec4":return De(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}function Le(t,e){if(!Nc){const e=Object.keys(zc);Nc={};for(let i=0;i<e.length;++i){const n=e[i];Nc[t[n]]=zc[n]}}return Nc[e]}function je(t,e){const i=Le(t,e);return Hc[i]||"float32"}function Ge(t,e){const i=t.getShaderSource(e).split("\n").map((t,e)=>`${e}: ${t}`),n=t.getShaderInfoLog(e).split("\n"),s={},r=n.map(t=>parseFloat(t.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(t=>!(!t||s[t]||(s[t]=!0,0))),o=[""];r.forEach(t=>{i[t-1]=`%c${i[t-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const a=i.join("\n");o[0]=a}function Ue(t,e,i,n,s,r,o,a){const h=r;if(!a||"repeat"!==t.addressModeU||"repeat"!==t.addressModeV||"repeat"!==t.addressModeW){const i=rd[o?"clamp-to-edge":t.addressModeU],n=rd[o?"clamp-to-edge":t.addressModeV],r=rd[o?"clamp-to-edge":t.addressModeW];e[s](h,e.TEXTURE_WRAP_S,i),e[s](h,e.TEXTURE_WRAP_T,n),e.TEXTURE_WRAP_R&&e[s](h,e.TEXTURE_WRAP_R,r)}if(a&&"linear"===t.magFilter||e[s](h,e.TEXTURE_MAG_FILTER,nd[t.magFilter]),i){if(!a||"linear"!==t.mipmapFilter){const i=sd[t.minFilter][t.mipmapFilter];e[s](h,e.TEXTURE_MIN_FILTER,i)}}else e[s](h,e.TEXTURE_MIN_FILTER,nd[t.minFilter]);if(n&&t.maxAnisotropy>1){const i=Math.min(t.maxAnisotropy,e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));e[s](h,n.TEXTURE_MAX_ANISOTROPY_EXT,i)}t.compare&&e[s](h,e.TEXTURE_COMPARE_FUNC,od[t.compare])}function Ne(t,e){const i=t.instructionSet,n=i.instructions;for(let t=0;t<i.instructionSize;t++){const i=n[t];e[i.renderPipeId].execute(i)}}function ze(t,e){e||(e=0);for(let i=e;i<t.length&&t[i];i++)t[i]=null}function He(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=p(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 e in i){const s=Number(e),r=i[e],o=r.list,a=r.index;for(let e=0;e<a;e++){const i=o[e];i.parentRenderGroup===t&&i.relativeRenderGroupDepth===s&&Ve(i,n,0)}ze(o,a),r.index=0}if(e)for(let i=0;i<t.renderGroupChildren.length;i++)He(t.renderGroupChildren[i],e)}function Ve(t,e,i){if(e===t.updateTick)return;t.updateTick=e,t.didChange=!1;const n=t.localTransform;t.updateLocalTransform();const s=t.parent;if(s&&!s.renderGroup?(i|=t._updateFlags,t.relativeGroupTransform.appendFrom(n,s.relativeGroupTransform),7&i&&We(t,s,i)):(i=t._updateFlags,t.relativeGroupTransform.copyFrom(n),7&i&&We(t,fd,i)),!t.renderGroup){const n=t.children,s=n.length;for(let t=0;t<s;t++)Ve(n[t],e,i);const r=t.parentRenderGroup,o=t;o.renderPipeId&&!r.structureDidChange&&r.updateRenderable(o)}}function We(t,e,i){if(1&i){t.groupColor=p(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}function Ze(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}function Je(t){let e=!1;for(const i in t)if(null==t[i]){e=!0;break}if(!e)return t;const i=Object.create(null);for(const e in t){const n=t[e];n&&(i[e]=n)}return i}function Xe(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}function Ye(t){const e=t.map(t=>({data:t,offset:0,size:0}));let i=0;for(let t=0;t<e.length;t++){const n=e[t];let s=su[n.data.type].size;const r=su[n.data.type].align;if(!su[n.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${n.data.type}`);n.data.size>1&&(s=Math.max(s,r)*n.data.size),i=Math.ceil(i/r)*r,n.size=s,n.offset=i,i+=s}return i=16*Math.ceil(i/16),{uboElements:e,size:i}}function Ke(t,e){const{size:i,align:n}=su[t.data.type],s=(n-i)/4,r=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 ${r}[arrayOffset++] = v[t++];\n }\n ${0!==s?`arrayOffset += ${s};`:""}\n }\n `}function qe(t){return Pe(t,"uboWgsl",Ke,Bc)}function Qe(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 t=0,n=0;t<i;t+=6,n+=4)e[t+0]=n+0,e[t+1]=n+1,e[t+2]=n+2,e[t+3]=n+0,e[t+4]=n+2,e[t+5]=n+3;return e}function $e(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];e===r.dynamic&&(i.push(`offset = index + ${n}`),i.push(r.code),n+=k(r.format).stride/4)}i.push("\n index += stride * 4;\n }\n "),i.unshift(`\n var stride = ${n};\n `);const s=i.join("\n");return new Function("ps","f32v","u32v",s)}function ti(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}function ei(t,e){const{texture:i,bounds:n}=t,s=e._style._getFinalPadding();o(n,e._anchor,i);const r=e._anchor._x*s*2,a=e._anchor._y*s*2;n.minX-=s-r,n.minY-=s-a,n.maxX-=s-r,n.maxY-=s-a}function ii(t,e,i,n){const s=yp;s.minX=0,s.minY=0,s.maxX=t.width/n|0,s.maxY=t.height/n|0;const r=Ls.getOptimalTexture(s.width,s.height,n,!1);return r.source.uploadMethodId="image",r.source.resource=t,r.source.alphaMode="premultiply-alpha-on-upload",r.frame.width=e/n,r.frame.height=i/n,r.source.emit("update",r.source),r.updateUvs(),r}function ni(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Op&&Op in Object(t)?function(t){var e=Tp.call(t,Ep),i=t[Ep];try{t[Ep]=void 0;var n=!0}catch(t){}var s=Pp.call(t);return n&&(e?t[Ep]=i:delete t[Ep]),s}(t):function(t){return Bp.call(t)}(t)}function si(t){return null!=t&&"object"==typeof t}function ri(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function oi(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||si(t)&&"[object Symbol]"==ni(t)}(t))return NaN;if(ri(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ri(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;var i;t=(i=t)?i.slice(0,function(t){for(var e=t.length;e--&&Rp.test(t.charAt(e)););return e}(i)+1).replace(Dp,""):i;var n=Lp.test(t);return n||jp.test(t)?Gp(t.slice(2),n?2:8):Fp.test(t)?NaN:+t}function ai(t){return t}function hi(t){if(!ri(t))return!1;var e=ni(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}function li(t){if(null!=t){try{return Hp.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function ci(t,e){var i=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!ri(t)||(e=t,zp&&zp in e))&&(hi(t)?Yp:Vp).test(li(t));var e}(i)?i:void 0}function di(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&sf.test(t))&&t>-1&&t%1==0&&t<e}function ui(t,e,i){"__proto__"==e&&tf?tf(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}function pi(t,e){return t===e||t!=t&&e!=e}function fi(t,e,i){var n=t[e];rf.call(t,e)&&pi(n,i)&&(void 0!==i||e in t)||ui(t,e,i)}function gi(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function mi(t){return null!=t&&gi(t.length)&&!hi(t)}function yi(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||af)}function xi(t){return si(t)&&"[object Arguments]"==ni(t)}function bi(t,e){var i=kp(t),n=!i&&df(t),s=!i&&!n&&gf(t),r=!i&&!n&&!s&&Cf(t),o=i||n||s||r,a=o?function(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n}(t.length,String):[],h=a.length;for(var l in t)!e&&!Sf.call(t,l)||o&&("length"==l||s&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||di(l,h))||a.push(l);return a}function _i(t,e){return function(i){return t(e(i))}}function vi(t){return mi(t)?bi(t,!0):function(t){if(!ri(t))return function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e}(t);var e=yi(t),i=[];for(var n in t)("constructor"!=n||!e&&Mf.call(t,n))&&i.push(n);return i}(t)}function wi(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 Ci(t,e){for(var i=t.length;i--;)if(pi(t[i][0],e))return i;return-1}function Si(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 Ii(t,e){var i=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?i["string"==typeof e?"string":"hash"]:i.map}function Ai(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 Mi(t,e,i){var n=-1,s=t.length;e<0&&(e=-e>s?0:s+e),(i=i>s?s:i)<0&&(i+=s),s=e>i?0:i-e>>>0,e>>>=0;for(var r=Array(s);++n<s;)r[n]=t[n+e];return r}function Ti(t){var e=this.__data__=new Si(t);this.size=e.size}function Pi(t){return function(t,e,i){var n=function(t){return mi(t)?bi(t):function(t){if(!yi(t))return If(t);var e=[];for(var i in Object(t))Af.call(t,i)&&"constructor"!=i&&e.push(i);return e}(t)}(t);return kp(t)?n:function(t,e){for(var i=-1,n=e.length,s=t.length;++i<n;)t[s+i]=e[i];return t}(n,i(t))}(t,0,Zf)}function Ei(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new Ai;++e<i;)this.add(t[e])}function Bi(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(e(t[i],i,t))return!0;return!1}function Oi(t,e,i,n,s,r){var o=1&i,a=t.length,h=e.length;if(a!=h&&!(o&&h>a))return!1;var l=r.get(t),c=r.get(e);if(l&&c)return l==e&&c==t;var d=-1,u=!0,p=2&i?new Ei:void 0;for(r.set(t,e),r.set(e,t);++d<a;){var f=t[d],g=e[d];if(n)var m=o?n(g,f,d,e,t,r):n(f,g,d,t,e,r);if(void 0!==m){if(m)continue;u=!1;break}if(p){if(!Bi(e,function(t,e){if(o=e,!p.has(o)&&(f===t||s(f,t,i,n,r)))return p.push(e);var o})){u=!1;break}}else if(f!==g&&!s(f,g,i,n,r)){u=!1;break}}return r.delete(t),r.delete(e),u}function ki(t){var e=-1,i=Array(t.size);return t.forEach(function(t,n){i[++e]=[n,t]}),i}function Ri(t){var e=-1,i=Array(t.size);return t.forEach(function(t){i[++e]=t}),i}function Di(t,e,i,n,s){return t===e||(null==t||null==e||!si(t)&&!si(e)?t!=t&&e!=e:function(t,e,i,n,s,r){var o=kp(t),a=kp(e),h=o?pg:og(t),l=a?pg:og(e),c=(h=h==ug?fg:h)==fg,d=(l=l==ug?fg:l)==fg,u=h==l;if(u&&gf(t)){if(!gf(e))return!1;o=!0,c=!1}if(u&&!c)return r||(r=new Ti),o||Cf(t)?Oi(t,e,i,n,s,r):function(t,e,i,n,s,r,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||!r(new ag(t),new ag(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return pi(+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=ki;case"[object Set]":var h=1&n;if(a||(a=Ri),t.size!=e.size&&!h)return!1;var l=o.get(t);if(l)return l==e;n|=2,o.set(t,e);var c=Oi(a(t),a(e),n,s,r,o);return o.delete(t),c;case"[object Symbol]":if(cg)return cg.call(t)==cg.call(e)}return!1}(t,e,h,i,n,s,r);if(!(1&i)){var p=c&&gg.call(t,"__wrapped__"),f=d&&gg.call(e,"__wrapped__");if(p||f){var g=p?t.value():t,m=f?e.value():e;return r||(r=new Ti),s(g,m,i,n,r)}}return!!u&&(r||(r=new Ti),function(t,e,i,n,s,r){var o=1&i,a=Pi(t),h=a.length;if(h!=Pi(e).length&&!o)return!1;for(var l=h;l--;){var c=a[l];if(!(o?c in e:dg.call(e,c)))return!1}var d=r.get(t),u=r.get(e);if(d&&u)return d==e&&u==t;var p=!0;r.set(t,e),r.set(e,t);for(var f=o;++l<h;){var g=t[c=a[l]],m=e[c];if(n)var y=o?n(m,g,c,e,t,r):n(g,m,c,t,e,r);if(!(void 0===y?g===m||s(g,m,i,n,r):y)){p=!1;break}f||(f="constructor"==c)}if(p&&!f){var x=t.constructor,b=e.constructor;x==b||!("constructor"in t)||!("constructor"in e)||"function"==typeof x&&x instanceof x&&"function"==typeof b&&b instanceof b||(p=!1)}return r.delete(t),r.delete(e),p}(t,e,i,n,s,r))}(t,e,i,n,Di,s))}function Fi(t,e,i){function n(e){var i=h,n=l;return h=l=void 0,f=e,d=t.apply(n,i)}function s(t){var i=t-p;return void 0===p||i>=e||i<0||m&&t-f>=c}function r(){var t=yg();if(s(t))return o(t);u=setTimeout(r,function(t){var i=e-(t-p);return m?bg(i,c-(t-f)):i}(t))}function o(t){return u=void 0,y&&h?n(t):(h=l=void 0,d)}function a(){var t=yg(),i=s(t);if(h=arguments,l=this,p=t,i){if(void 0===u)return function(t){return f=t,u=setTimeout(r,e),g?n(t):d}(p);if(m)return clearTimeout(u),u=setTimeout(r,e),n(p)}return void 0===u&&(u=setTimeout(r,e)),d}var h,l,c,d,u,p,f=0,g=!1,m=!1,y=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return e=oi(e)||0,ri(i)&&(g=!!i.leading,c=(m="maxWait"in i)?xg(oi(i.maxWait)||0,e):c,y="trailing"in i?!!i.trailing:y),a.cancel=function(){void 0!==u&&clearTimeout(u),f=0,h=p=l=u=void 0},a.flush=function(){return void 0===u?d:o(yg())},a}function Li(t,e,i){(void 0!==i&&!pi(t[e],i)||void 0===i&&!(e in t))&&ui(t,e,i)}function ji(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Gi(t,e,i,n,s){t!==e&&mg(e,function(r,o){if(s||(s=new Ti),ri(r))!function(t,e,i,n,s,r,o){var a=ji(t,i),h=ji(e,i),l=o.get(h);if(l)Li(t,i,l);else{var c,d=r?r(a,h,i+"",t,e,o):void 0,u=void 0===d;if(u){var p=kp(h),f=!p&&gf(h),g=!p&&!f&&Cf(h);d=h,p||f||g?kp(a)?d=a:si(c=a)&&mi(c)?d=function(t,e){var i=-1,n=t.length;for(e||(e=Array(n));++i<n;)e[i]=t[i];return e}(a):f?(u=!1,d=h.slice()):g?(u=!1,d=function(t){var e=function(t){var e=new t.constructor(t.byteLength);return new ag(e).set(new ag(t)),e}(t.buffer);return new t.constructor(e,t.byteOffset,t.length)}(h)):d=[]:function(t){if(!si(t)||"[object Object]"!=ni(t))return!1;var e=kf(t);if(null===e)return!0;var i=Lf.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&Ff.call(i)==jf}(h)||df(h)?(d=a,df(a)?d=function(t){return function(t,e,i){var n=!i;i||(i={});for(var s=-1,r=e.length;++s<r;){var o=e[s],a=void 0;void 0===a&&(a=t[o]),n?ui(i,o,a):fi(i,o,a)}return i}(t,vi(t))}(a):ri(a)&&!hi(a)||(d=function(t){return"function"!=typeof t.constructor||yi(t)?{}:Qp(kf(t))}(h))):u=!1}u&&(o.set(h,d),s(d,h,n,r,o),o.delete(h)),Li(t,i,d)}}(t,e,o,i,Gi,n,s);else{var a=n?n(ji(t,o),r,o+"",t,e,s):void 0;void 0===a&&(a=r),Li(t,o,a)}},vi)}function Ui(t,e){return Di(t,e)}function Ni(t,e,i){var n=!0,s=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return ri(i)&&(n="leading"in i?!!i.leading:n,s="trailing"in i?!!i.trailing:s),Fi(t,e,{leading:n,maxWait:e,trailing:s})}function zi(t,e,i,n){let s=3&t,r=t>>2&63;if(1===s||62===r)i.push(e);else if(0===s&&r<=31)n.has(r)||n.set(r,[]),n.get(r).push(e);else if(0===s){let t;switch(r){case 60:t=zg.NO_ROOM_DATA;break;case 61:t=zg.ROOM_GAP;break;case 62:t=zg.OBSTACLE_ROOM;break;case 63:t=zg.UNKNOWN_ROOM}void 0!==t&&(n.has(t)||n.set(t,[]),n.get(t).push(e))}}function Hi(t){switch(t){case 28:return zg.NO_ROOM_DATA;case 29:return zg.ROOM_GAP;case 30:return zg.OBSTACLE_ROOM;case 31:return zg.UNKNOWN_ROOM;default:return}}function Vi(t,e,i,n,s){let r=7&t,o=t>>3&31;if(1===r||30===o)i.push(e);else if(2===r)if(n.push(e),o<=27)s.has(o)||s.set(o,[]),s.get(o).push(e);else{let t=Hi(o);void 0!==t&&(s.has(t)||s.set(t,[]),s.get(t).push(e))}else if(7===r)if(o<=27)s.has(o)||s.set(o,[]),s.get(o).push(e);else{let t=Hi(o);void 0!==t&&(s.has(t)||s.set(t,[]),s.get(t).push(e))}}function Wi(t={}){if(!Rm(t))throw new Error("object required");const e=Um.get(t);if(e)return e;let i=Gm[0];const n=new Set,s=(t,e=++Gm[0])=>{i!==e&&(r=i=e,n.forEach(i=>i(t,e)))};let r=i;const o=t=>(e,i)=>{const n=[...e];n[1]=[t,...n[1]],s(n,i)},a=new Map;let h=!0;const l=Vm(()=>h,(t,e)=>{const i=!Lm.has(e)&&Fm.get(e);if(i){if("production"!==(km?"core":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))},s),c=zm(t,l);Um.set(t,c);const d=[t,(t=Gm[0])=>(r!==t&&(r=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"!==(km?"core":void 0)&&e)throw new Error("remove already exists");const n=t[2](o(i));a.set(i,[t,n])}),()=>{n.delete(t),0===n.size&&a.forEach(([t,e],i)=>{e&&(e(),a.set(i,[t]))})})];return Fm.set(c,d),Reflect.ownKeys(t).forEach(e=>{const i=Object.getOwnPropertyDescriptor(t,e);"value"in i&&i.writable&&(c[e]=t[e])}),h=!1,c}function Zi(){return ty.getService()}function Ji(){return Oy||(Oy=1,Object.defineProperty(Uy,"__esModule",{value:!0}),Uy.loop=Uy.conditional=Uy.parse=void 0,Uy.parse=function t(e,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n;if(Array.isArray(i))i.forEach(function(i){return t(e,i,n,s)});else if("function"==typeof i)i(e,n,s,t);else{var r=Object.keys(i)[0];Array.isArray(i[r])?(s[r]={},t(e,i[r],n,s[r])):s[r]=i[r](e,n,s,t)}return n},Uy.conditional=function(t,e){return function(i,n,s,r){e(i,n,s)&&r(i,t,n,s)}},Uy.loop=function(t,e){return function(i,n,s,r){for(var o=[],a=i.pos;e(i,n,s);){var h={};if(r(i,t,n,h),i.pos===a)break;a=i.pos,o.push(h)}return o}}),Uy}function Xi(){if(ky)return Ny;ky=1,Object.defineProperty(Ny,"__esModule",{value:!0}),Ny.readBits=Ny.readArray=Ny.readUnsigned=Ny.readString=Ny.peekBytes=Ny.readBytes=Ny.peekByte=Ny.readByte=Ny.buildStream=void 0,Ny.buildStream=function(t){return{data:t,pos:0}},Ny.readByte=function(){return function(t){return t.data[t.pos++]}},Ny.peekByte=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function(e){return e.data[e.pos+t]}};var t=function(t){return function(e){return e.data.subarray(e.pos,e.pos+=t)}};return Ny.readBytes=t,Ny.peekBytes=function(t){return function(e){return e.data.subarray(e.pos,e.pos+t)}},Ny.readString=function(e){return function(i){return Array.from(t(e)(i)).map(function(t){return String.fromCharCode(t)}).join("")}},Ny.readUnsigned=function(e){return function(i){var n=t(2)(i);return e?(n[1]<<8)+n[0]:(n[0]<<8)+n[1]}},Ny.readArray=function(e,i){return function(n,s,r){for(var o="function"==typeof i?i(n,s,r):i,a=t(e),h=new Array(o),l=0;l<o;l++)h[l]=a(n);return h}},Ny.readBits=function(t){return function(e){for(var i=function(t){return t.data[t.pos++]}(e),n=new Array(8),s=0;s<8;s++)n[7-s]=!!(i&1<<s);return Object.keys(t).reduce(function(e,i){var s=t[i];return s.length?e[i]=function(t,e,i){for(var n=0,s=0;s<i;s++)n+=t[e+s]&&Math.pow(2,i-s-1);return n}(n,s.index,s.length):e[i]=n[s.index],e},{})}},Ny}function Yi(t,e,i,n){let s=t[e];return function(t,e){const i=Fm.get(t);let n;const s=[],r=i[2];let o=!1;const a=r(t=>{s.push(t),n||(n=Promise.resolve().then(()=>{n=void 0,o&&e(s.splice(0))}))});return o=!0,()=>{o=!1,a()}}(t,()=>{const n=t[e];Object.is(s,n)||i(s=n)})}var Ki=(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))(Ki||{});const qi=t=>{if("function"==typeof t||"object"==typeof t&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");t={..."object"!=typeof t.extension?{type:t.extension}:t.extension,ref:t}}if("object"!=typeof t)throw new Error("Invalid extension type");return"string"==typeof(t={...t}).type&&(t.type=[t.type]),t},Qi=(t,e)=>qi(t).priority??e,$i={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(qi).forEach(t=>{t.type.forEach(e=>this._removeHandlers[e]?.(t))}),this},add(...t){return t.map(qi).forEach(t=>{t.type.forEach(e=>{const i=this._addHandlers,n=this._queue;i[e]?i[e]?.(t):(n[e]=n[e]||[],n[e]?.push(t))})}),this},handle(t,e,i){const n=this._addHandlers,s=this._removeHandlers;if(n[t]||s[t])throw new Error(`Extension type ${t} already has a handler`);n[t]=e,s[t]=i;const r=this._queue;return r[t]&&(r[t]?.forEach(t=>e(t)),delete r[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)=>Qi(e.value,i)-Qi(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)=>Qi(e,i)-Qi(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))}},tn={extension:{type:Ki.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(()=>Dx)}},en={extension:{type:Ki.Environment,name:"webworker",priority:0},test:()=>"undefined"!=typeof self&&void 0!==self.WorkerGlobalScope,load:async()=>{await Promise.resolve().then(()=>Fx)}};class nn{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new nn(t??this._observer,this._x,this._y)}set(t=0,e=t){return this._x===t&&this._y===e||(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return this._x===t.x&&this._y===t.y||(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}var sn,rn={exports:{}};const on=t((sn||(sn=1,function(t){function e(){}function i(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function n(t,e,n,s,r){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new i(n,s||t,r),h=a?a+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],o]:t._events[h].push(o):(t._events[h]=o,t._eventsCount++),t}function s(t,i){0===--t._eventsCount?t._events=new e:delete t._events[i]}function r(){this._events=new e,this._eventsCount=0}var o=Object.prototype.hasOwnProperty,a="~";Object.create&&(e.prototype=Object.create(null),(new e).__proto__||(a=!1)),r.prototype.eventNames=function(){var t,e,i=[];if(0===this._eventsCount)return i;for(e in t=this._events)o.call(t,e)&&i.push(a?e.slice(1):e);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},r.prototype.listeners=function(t){var e=a?a+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,s=i.length,r=new Array(s);n<s;n++)r[n]=i[n].fn;return r},r.prototype.listenerCount=function(t){var e=a?a+t:t,i=this._events[e];return i?i.fn?1:i.length:0},r.prototype.emit=function(t,e,i,n,s,r){var o=a?a+t:t;if(!this._events[o])return!1;var h,l,c=this._events[o],d=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),d){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,i),!0;case 4:return c.fn.call(c.context,e,i,n),!0;case 5:return c.fn.call(c.context,e,i,n,s),!0;case 6:return c.fn.call(c.context,e,i,n,s,r),!0}for(l=1,h=new Array(d-1);l<d;l++)h[l-1]=arguments[l];c.fn.apply(c.context,h)}else{var u,p=c.length;for(l=0;l<p;l++)switch(c[l].once&&this.removeListener(t,c[l].fn,void 0,!0),d){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,e);break;case 3:c[l].fn.call(c[l].context,e,i);break;case 4:c[l].fn.call(c[l].context,e,i,n);break;default:if(!h)for(u=1,h=new Array(d-1);u<d;u++)h[u-1]=arguments[u];c[l].fn.apply(c[l].context,h)}}return!0},r.prototype.on=function(t,e,i){return n(this,t,e,i,!1)},r.prototype.once=function(t,e,i){return n(this,t,e,i,!0)},r.prototype.removeListener=function(t,e,i,n){var r=a?a+t:t;if(!this._events[r])return this;if(!e)return s(this,r),this;var o=this._events[r];if(o.fn)o.fn!==e||n&&!o.once||i&&o.context!==i||s(this,r);else{for(var h=0,l=[],c=o.length;h<c;h++)(o[h].fn!==e||n&&!o[h].once||i&&o[h].context!==i)&&l.push(o[h]);l.length?this._events[r]=1===l.length?l[0]:l:s(this,r)}return this},r.prototype.removeAllListeners=function(t){var i;return t?(i=a?a+t:t,this._events[i]&&s(this,i)):(this._events=new e,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prefixed=a,r.EventEmitter=r,t.exports=r}(rn)),rn.exports)),an=2*Math.PI,hn=180/Math.PI,ln=Math.PI/180;class cn{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new cn(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 dn.x=0,dn.y=0,dn}}const dn=new cn;class un{constructor(t=1,e=0,i=0,n=1,s=0,r=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,this.ty=r}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,s,r){return this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,this.ty=r,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 cn;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 cn;const i=this.a,n=this.b,s=this.c,r=this.d,o=this.tx,a=this.ty,h=1/(i*r+s*-n),l=t.x,c=t.y;return e.x=r*h*l+-s*h*c+(a*s-o*r)*h,e.y=i*h*c+-n*h*l+(-a*i+o*n)*h,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,s=this.c,r=this.tx;return this.a=n*e-this.b*i,this.b=n*i+this.b*e,this.c=s*e-this.d*i,this.d=s*i+this.d*e,this.tx=r*e-this.ty*i,this.ty=r*i+this.ty*e,this}append(t){const e=this.a,i=this.b,n=this.c,s=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*i+t.b*s,this.c=t.c*e+t.d*n,this.d=t.c*i+t.d*s,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*i+t.ty*s+this.ty,this}appendFrom(t,e){const i=t.a,n=t.b,s=t.c,r=t.d,o=t.tx,a=t.ty,h=e.a,l=e.b,c=e.c,d=e.d;return this.a=i*h+n*c,this.b=i*l+n*d,this.c=s*h+r*c,this.d=s*l+r*d,this.tx=o*h+a*c+e.tx,this.ty=o*l+a*d+e.ty,this}setTransform(t,e,i,n,s,r,o,a,h){return this.a=Math.cos(o+h)*s,this.b=Math.sin(o+h)*s,this.c=-Math.sin(o-a)*r,this.d=Math.cos(o-a)*r,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,s=this.d,r=t.pivot,o=-Math.atan2(-n,s),a=Math.atan2(i,e),h=Math.abs(o+a);return h<1e-5||Math.abs(an-h)<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+s*s),t.position.x=this.tx+(r.x*e+r.y*n),t.position.y=this.ty+(r.x*i+r.y*s),t}invert(){const t=this.a,e=this.b,i=this.c,n=this.d,s=this.tx,r=t*n-e*i;return this.a=n/r,this.b=-e/r,this.c=-i/r,this.d=t/r,this.tx=(i*this.ty-n*s)/r,this.ty=-(t*this.ty-e*s)/r,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 un;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 fn.identity()}static get shared(){return pn.identity()}}const pn=new un,fn=new un,gn=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],mn=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],yn=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],xn=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],bn=[],_n=[],vn=Math.sign;!function(){for(let t=0;t<16;t++){const e=[];bn.push(e);for(let i=0;i<16;i++){const n=vn(gn[t]*gn[i]+yn[t]*mn[i]),s=vn(mn[t]*gn[i]+xn[t]*mn[i]),r=vn(gn[t]*yn[i]+yn[t]*xn[i]),o=vn(mn[t]*yn[i]+xn[t]*xn[i]);for(let t=0;t<16;t++)if(gn[t]===n&&mn[t]===s&&yn[t]===r&&xn[t]===o){e.push(t);break}}}for(let t=0;t<16;t++){const e=new un;e.set(gn[t],mn[t],yn[t],xn[t],0,0),_n.push(e)}}();const wn={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=>gn[t],uY:t=>mn[t],vX:t=>yn[t],vY:t=>xn[t],inv:t=>8&t?15&t:7&-t,add:(t,e)=>bn[t][e],sub:(t,e)=>bn[t][wn.inv(e)],rotate180:t=>4^t,isVertical:t=>2==(3&t),byDirection:(t,e)=>2*Math.abs(t)<=Math.abs(e)?e>=0?wn.S:wn.N:2*Math.abs(e)<=Math.abs(t)?t>0?wn.E:wn.W:e>0?t>0?wn.SE:wn.SW:t>0?wn.NE:wn.NW,matrixAppendRotationInv:(t,e,i=0,n=0)=>{const s=_n[wn.inv(e)];s.tx=i,s.ty=n,t.append(s)},transformRectCoords:(t,e,i,n)=>{const{x:s,y:r,width:o,height:a}=t,{x:h,y:l,width:c,height:d}=e;return i===wn.E?(n.set(s+h,r+l,o,a),n):i===wn.S?n.set(c-r-a+h,s+l,a,o):i===wn.W?n.set(c-s-o+h,d-r-a+l,o,a):i===wn.N?n.set(r+h,d-s-o+l,a,o):n.set(s+h,r+l,o,a)}},Cn=[new cn,new cn,new cn,new cn];class Sn{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 Sn(0,0,0,0)}clone(){return new Sn(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:s,height:r}=this;if(s<=0||r<=0)return!1;const o=this.x,a=this.y,h=i*(1-n),l=i-h;return t>=o-h&&t<=o+s+h&&e>=a-h&&e<=a+r+h&&!(t>o+l&&t<o+s-l&&e>a+l&&e<a+r-l)}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,s=this.top,r=this.bottom;if(n<=i||r<=s)return!1;const o=Cn[0].set(t.left,t.top),a=Cn[1].set(t.left,t.bottom),h=Cn[2].set(t.right,t.top),l=Cn[3].set(t.right,t.bottom);if(h.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(h,h),e.apply(l,l),Math.max(o.x,a.x,h.x,l.x)<=i||Math.min(o.x,a.x,h.x,l.x)>=n||Math.max(o.y,a.y,h.y,l.y)<=s||Math.min(o.y,a.y,h.y,l.y)>=r)return!1;const d=c*(a.y-o.y),u=c*(o.x-a.x),p=d*i+u*s,f=d*n+u*s,g=d*i+u*r,m=d*n+u*r;if(Math.max(p,f,g,m)<=d*o.x+u*o.y||Math.min(p,f,g,m)>=d*l.x+u*l.y)return!1;const y=c*(o.y-h.y),x=c*(h.x-o.x),b=y*i+x*s,_=y*n+x*s,v=y*i+x*r,w=y*n+x*r;return!(Math.max(b,_,v,w)<=y*o.x+x*o.y||Math.min(b,_,v,w)>=y*l.x+x*l.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),s=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(s-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),s=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=n,this.height=s-n,this}getBounds(t){return t||(t=new Sn),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,s=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&&s>=this.y&&s<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 In={default:-1},An={},Mn=()=>{},Tn=Object.create(null),Pn=class t extends on{constructor(e={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,e={...t.defaultOptions,...e},this.addressMode=e.addressMode,this.addressModeU=e.addressModeU??this.addressModeU,this.addressModeV=e.addressModeV??this.addressModeV,this.addressModeW=e.addressModeW??this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=e.magFilter??this.magFilter,this.minFilter=e.minFilter??this.minFilter,this.mipmapFilter=e.mipmapFilter??this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=e.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){i(0,"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 i=Tn[t];return void 0===i&&(Tn[t]=e("resource")),i}(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Pn.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let En=Pn;const Bn=class t extends on{constructor(i={}){super(),this.options=i,this.uid=e("textureSource"),this._resourceType="textureSource",this._resourceId=e("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,i={...t.defaultOptions,...i},this.label=i.label??"",this.resource=i.resource,this.autoGarbageCollect=i.autoGarbageCollect,this._resolution=i.resolution,i.width?this.pixelWidth=i.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,i.height?this.pixelHeight=i.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=i.format,this.dimension=i.dimensions,this.mipLevelCount=i.mipLevelCount,this.autoGenerateMipmaps=i.autoGenerateMipmaps,this.sampleCount=i.sampleCount,this.antialias=i.antialias,this.alphaMode=i.alphaMode,this.style=new En(r(i)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){this.style!==t&&(this._style?.off("change",this._onStyleChange,this),this._style=t,this._style?.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!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=e("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,i,n){n||(n=this._resolution),t||(t=this.width),i||(i=this.height);const s=Math.round(t*n),r=Math.round(i*n);return this.width=s/n,this.height=r/n,this._resolution=n,(this.pixelWidth!==s||this.pixelHeight!==r)&&(this._refreshPOT(),this.pixelWidth=s,this.pixelHeight=r,this.emit("resize",this),this._resourceId=e("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=s(this.pixelWidth)&&s(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Bn.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let On=Bn;class kn extends On{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({...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}}kn.extension=Ki.TextureSource;const Rn=new un;class Dn{constructor(t,e){this.mapCoord=new un,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){this.texture!==t&&(this._texture?.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){void 0===e&&(e=t);const i=this.mapCoord;for(let n=0;n<t.length;n+=2){const s=t[n],r=t[n+1];e[n]=s*i.a+r*i.c+i.tx,e[n+1]=s*i.b+r*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&&(Rn.set(i.width/n.width,0,0,i.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Rn));const s=t.source,r=this.uClampFrame,o=this.clampMargin/s._resolution,a=this.clampOffset/s._resolution;return r[0]=(t.frame.x+o+a)/s.width,r[1]=(t.frame.y+o+a)/s.height,r[2]=(t.frame.x+t.frame.width-o+a)/s.width,r[3]=(t.frame.y+t.frame.height-o+a)/s.height,this.uClampOffset[0]=this.clampOffset/s.pixelWidth,this.uClampOffset[1]=this.clampOffset/s.pixelHeight,this.isSimple=t.frame.width===s.width&&t.frame.height===s.height&&0===t.rotate,!0}}class Fn extends on{constructor({source:t,label:i,frame:n,orig:s,trim:r,defaultAnchor:o,defaultBorders:a,rotate:h,dynamic:l}={}){if(super(),this.uid=e("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Sn,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=i,this.source=t?.source??new On,this.noFrame=!n,n)this.frame.copyFrom(n);else{const{width:t,height:e}=this._source;this.frame.width=t,this.frame.height=e}this.orig=s||this.frame,this.trim=r,this.rotate=h??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=l||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new Dn(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,s=e.x/i,r=e.y/n,o=e.width/i,a=e.height/n;let h=this.rotate;if(h){const e=o/2,i=a/2,n=s+e,l=r+i;h=wn.add(h,wn.NW),t.x0=n+e*wn.uX(h),t.y0=l+i*wn.uY(h),h=wn.add(h,2),t.x1=n+e*wn.uX(h),t.y1=l+i*wn.uY(h),h=wn.add(h,2),t.x2=n+e*wn.uX(h),t.y2=l+i*wn.uY(h),h=wn.add(h,2),t.x3=n+e*wn.uX(h),t.y3=l+i*wn.uY(h)}else t.x0=s,t.y0=r,t.x1=s+o,t.y1=r,t.x2=s+o,t.y2=r+a,t.x3=s,t.y3=r+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 i(0,"Texture.baseTexture is now Texture.source"),this._source}}Fn.EMPTY=new Fn({label:"EMPTY",source:new On({label:"EMPTY"})}),Fn.EMPTY.destroy=Mn,Fn.WHITE=new Fn({source:new kn({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),Fn.WHITE.destroy=Mn;const Ln=new un;class jn{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=Ln,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 Sn);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=Ln,this}set(t,e,i,n){this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}addFrame(t,e,i,n,s){s||(s=this.matrix);const r=s.a,o=s.b,a=s.c,h=s.d,l=s.tx,c=s.ty;let d=this.minX,u=this.minY,p=this.maxX,f=this.maxY,g=r*t+a*e+l,m=o*t+h*e+c;g<d&&(d=g),m<u&&(u=m),g>p&&(p=g),m>f&&(f=m),g=r*i+a*e+l,m=o*i+h*e+c,g<d&&(d=g),m<u&&(u=m),g>p&&(p=g),m>f&&(f=m),g=r*t+a*n+l,m=o*t+h*n+c,g<d&&(d=g),m<u&&(u=m),g>p&&(p=g),m>f&&(f=m),g=r*i+a*n+l,m=o*i+h*n+c,g<d&&(d=g),m<u&&(u=m),g>p&&(p=g),m>f&&(f=m),this.minX=d,this.minY=u,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,s=this.maxY,{a:r,b:o,c:a,d:h,tx:l,ty:c}=t;let d=r*e+a*i+l,u=o*e+h*i+c;this.minX=d,this.minY=u,this.maxX=d,this.maxY=u,d=r*n+a*i+l,u=o*n+h*i+c,this.minX=d<this.minX?d:this.minX,this.minY=u<this.minY?u:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=u>this.maxY?u:this.maxY,d=r*e+a*s+l,u=o*e+h*s+c,this.minX=d<this.minX?d:this.minX,this.minY=u<this.minY?u:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=u>this.maxY?u:this.maxY,d=r*n+a*s+l,u=o*n+h*s+c,this.minX=d<this.minX?d:this.minX,this.minY=u<this.minY?u:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=u>this.maxY?u: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 jn(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 s=this.minX,r=this.minY,o=this.maxX,a=this.maxY;n||(n=this.matrix);const h=n.a,l=n.b,c=n.c,d=n.d,u=n.tx,p=n.ty;for(let n=e;n<i;n+=2){const e=t[n],i=t[n+1],f=h*e+c*i+u,g=l*e+d*i+p;s=f<s?f:s,r=g<r?g:r,o=f>o?f:o,a=g>a?g:a}this.minX=s,this.minY=r,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 Gn={grad:.9,turn:360,rad:360/(2*Math.PI)},Un=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},Nn=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=Math.pow(10,e)),Math.round(i*t)/i+0},zn=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=1),t>i?i:t>e?t:e},Hn=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},Vn=function(t){return{r:zn(t.r,0,255),g:zn(t.g,0,255),b:zn(t.b,0,255),a:zn(t.a)}},Wn=function(t){return{r:Nn(t.r),g:Nn(t.g),b:Nn(t.b),a:Nn(t.a,3)}},Zn=/^#([0-9a-f]{3,8})$/i,Jn=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},Xn=function(t){var e=t.r,i=t.g,n=t.b,s=t.a,r=Math.max(e,i,n),o=r-Math.min(e,i,n),a=o?r===e?(i-n)/o:r===i?2+(n-e)/o:4+(e-i)/o:0;return{h:60*(a<0?a+6:a),s:r?o/r*100:0,v:r/255*100,a:s}},Yn=function(t){var e=t.h,i=t.s,n=t.v,s=t.a;e=e/360*6,i/=100,n/=100;var r=Math.floor(e),o=n*(1-i),a=n*(1-(e-r)*i),h=n*(1-(1-e+r)*i),l=r%6;return{r:255*[n,a,o,o,h,n][l],g:255*[h,n,n,a,o,o][l],b:255*[o,o,h,n,n,a][l],a:s}},Kn=function(t){return{h:Hn(t.h),s:zn(t.s,0,100),l:zn(t.l,0,100),a:zn(t.a)}},qn=function(t){return{h:Nn(t.h),s:Nn(t.s),l:Nn(t.l),a:Nn(t.a,3)}},Qn=function(t){return Yn((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},$n=function(t){return{h:(e=Xn(t)).h,s:(s=(200-(i=e.s))*(n=e.v)/100)>0&&s<200?i*n/100/(s<=100?s:200-s)*100:0,l:s/2,a:e.a};var e,i,n,s},ts=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,es=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,is=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ns=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ss={string:[[function(t){var e=Zn.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?Nn(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?Nn(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=is.exec(t)||ns.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:Vn({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=ts.exec(t)||es.exec(t);if(!e)return null;var i,n,s=Kn({h:(i=e[1],n=e[2],void 0===n&&(n="deg"),Number(i)*(Gn[n]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return Qn(s)},"hsl"]],object:[[function(t){var e=t.r,i=t.g,n=t.b,s=t.a,r=void 0===s?1:s;return Un(e)&&Un(i)&&Un(n)?Vn({r:Number(e),g:Number(i),b:Number(n),a:Number(r)}):null},"rgb"],[function(t){var e=t.h,i=t.s,n=t.l,s=t.a,r=void 0===s?1:s;if(!Un(e)||!Un(i)||!Un(n))return null;var o=Kn({h:Number(e),s:Number(i),l:Number(n),a:Number(r)});return Qn(o)},"hsl"],[function(t){var e=t.h,i=t.s,n=t.v,s=t.a,r=void 0===s?1:s;if(!Un(e)||!Un(i)||!Un(n))return null;var o,a=(o={h:Number(e),s:Number(i),v:Number(n),a:Number(r)},{h:Hn(o.h),s:zn(o.s,0,100),v:zn(o.v,0,100),a:zn(o.a)});return Yn(a)},"hsv"]]},rs=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]},os=function(t,e){var i=$n(t);return{h:i.h,s:zn(i.s+100*e,0,100),l:i.l,a:i.a}},as=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},hs=function(t,e){var i=$n(t);return{h:i.h,s:i.s,l:zn(i.l+100*e,0,100),a:i.a}},ls=function(){function t(t){this.parsed=function(t){return"string"==typeof t?rs(t.trim(),ss.string):"object"==typeof t&&null!==t?rs(t,ss.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 Nn(as(this.rgba),2)},t.prototype.isDark=function(){return as(this.rgba)<.5},t.prototype.isLight=function(){return as(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=Wn(this.rgba)).r,i=t.g,n=t.b,r=(s=t.a)<1?Jn(Nn(255*s)):"","#"+Jn(e)+Jn(i)+Jn(n)+r;var t,e,i,n,s,r},t.prototype.toRgb=function(){return Wn(this.rgba)},t.prototype.toRgbString=function(){return e=(t=Wn(this.rgba)).r,i=t.g,n=t.b,(s=t.a)<1?"rgba("+e+", "+i+", "+n+", "+s+")":"rgb("+e+", "+i+", "+n+")";var t,e,i,n,s},t.prototype.toHsl=function(){return qn($n(this.rgba))},t.prototype.toHslString=function(){return e=(t=qn($n(this.rgba))).h,i=t.s,n=t.l,(s=t.a)<1?"hsla("+e+", "+i+"%, "+n+"%, "+s+")":"hsl("+e+", "+i+"%, "+n+"%)";var t,e,i,n,s},t.prototype.toHsv=function(){return t=Xn(this.rgba),{h:Nn(t.h),s:Nn(t.s),v:Nn(t.v),a:Nn(t.a,3)};var t},t.prototype.invert=function(){return cs({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),cs(os(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),cs(os(this.rgba,-t))},t.prototype.grayscale=function(){return cs(os(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),cs(hs(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),cs(hs(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?cs({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Nn(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=$n(this.rgba);return"number"==typeof t?cs({h:t,s:e.s,l:e.l,a:e.a}):Nn(e.h)},t.prototype.isEqual=function(t){return this.toHex()===cs(t).toHex()},t}(),cs=function(t){return t instanceof ls?t:new ls(t)},ds=[];[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 s in i)n[i[s]]=s;var r={};t.prototype.toName=function(e){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var s,o,a=n[this.toHex()];if(a)return a;if(null==e?void 0:e.closest){var h=this.toRgb(),l=1/0,c="black";if(!r.length)for(var d in i)r[d]=new t(i[d]).toRgb();for(var u in i){var p=(s=h,o=r[u],Math.pow(s.r-o.r,2)+Math.pow(s.g-o.g,2)+Math.pow(s.b-o.b,2));p<l&&(l=p,c=u)}return c}},e.string.push([function(e){var n=e.toLowerCase(),s="transparent"===n?"#0000":i[n];return s?new t(s).toRgb():null},"name"])}].forEach(function(t){ds.indexOf(t)<0&&(t(ls,ss),ds.push(t))});const us=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?{...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,s]=this._components;return t[0]=e,t[1]=i,t[2]=n,t[3]=s,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,s,r]=t._temp.setValue(e)._components;return this._components[0]*=i,this._components[1]*=n,this._components[2]*=s,this._components[3]*=r,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(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,s=255&this._int;return e&&(i=i*t+.5|0,n=n*t+.5|0,s=s*t+.5|0),(255*t<<24)+(i<<16)+(n<<8)+s}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,s,r;if(("number"==typeof e||e instanceof Number)&&e>=0&&e<=16777215)i=(e>>16&255)/255,n=(e>>8&255)/255,s=(255&e)/255,r=1;else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[i,n,s,r=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[i,n,s,r=255]=e,i/=255,n/=255,s/=255,r/=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=cs(e);o.isValid()&&(({r:i,g:n,b:s,a:r}=o.rgba),i/=255,n/=255,s/=255)}if(void 0===i)throw new Error(`Unable to convert color ${e}`);this._components[0]=i,this._components[1]=n,this._components[2]=s,this._components[3]=r,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,s)=>{t[s]=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}};us.shared=new us,us._temp=new us,us.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let ps=us,fs=0;class gs{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){let e;return e=this._index>0?this._pool[--this._index]:new this._classType,e.init?.(t),e}return(t){t.reset?.(),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}const ms=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 gs(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}},ys={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(t){"boolean"==typeof t&&!1===t?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(!0===t?{}:t))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(t){i(0,"cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(t)}},xs={allowChildren:!0,removeChildren(t=0,e){const i=e??this.children.length,n=i-t,s=[];if(n>0&&n<=i){for(let e=i-1;e>=t;e--){const t=this.children[e];t&&(s.push(t),t.parent=null)}h(this.children,t,i);const e=this.renderGroup||this.parentRenderGroup;e&&e.removeChildren(s);for(let t=0;t<s.length;++t){const e=s[t];e.parentRenderLayer?.detach(e),this.emit("childRemoved",e,this,t),s[t].emit("removed",this)}return s.length>0&&this._didViewChangeTick++,s}if(0===n&&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||i(0,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:n}=this;if(e<0||e>n.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${n.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===n.length?n.push(t):n.splice(e,0,t),t.parent=this,t.didChange=!0,t._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.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 s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.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)}},bs={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,s=n.length;for(let r=0;r<s;r++)n[r].collectRenderables(t,e,i)},collectRenderablesWithEffects(t,e,i){const{renderPipes:n}=e;for(let e=0;e<this.effects.length;e++){const i=this.effects[e];n[i.pipe].push(i,this,t)}this.collectRenderablesSimple(t,e,i);for(let e=this.effects.length-1;e>=0;e--){const i=this.effects[e];n[i.pipe].pop(i,this,t)}}};class _s{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 vs=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 ms.get(i.maskClass,t)}return t}returnMaskEffect(t){ms.return(t)}};$i.handleByList(Ki.MaskEffect,vs._effectClasses);const ws={_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;e?.mask!==t&&(e&&(this.removeEffect(e),vs.returnMaskEffect(e),this._maskEffect=null),null!=t&&(this._maskEffect=vs.getMaskEffect(t),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(t){this._maskOptions={...this._maskOptions,...t},t.mask&&(this.mask=t.mask),this._markStructureAsChanged()},set filters(t){!Array.isArray(t)&&t&&(t=[t]);const e=this._filterEffect||(this._filterEffect=new _s),i=t?.length>0,n=i!==e.filters?.length>0;t=Array.isArray(t)?t.slice(0):t,e.filters=Object.freeze(t),n&&(i?this.addEffect(e):(this.removeEffect(e),e.filters=t??null))},get filters(){return this._filterEffect?.filters},set filterArea(t){this._filterEffect||(this._filterEffect=new _s),this._filterEffect.filterArea=t},get filterArea(){return this._filterEffect?.filterArea}},Cs={label:null,get name(){return i(0,"Container.name property has been removed, use Container.label instead"),this.label},set name(t){i(0,"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 e=0;e<i.length;e++){const n=i[e];if(n.label===t||t instanceof RegExp&&t.test(n.label))return n}if(e)for(let e=0;e<i.length;e++){const n=i[e].getChildByLabel(t,!0);if(n)return n}return null},getChildrenByLabel(t,e=!1,i=[]){const n=this.children;for(let e=0;e<n.length;e++){const s=n[e];(s.label===t||t instanceof RegExp&&t.test(s.label))&&i.push(s)}if(e)for(let e=0;e<n.length;e++)n[e].getChildrenByLabel(t,!0,i);return i}},Ss=new gs(un),Is=new gs(jn),As=new un,Ms={getFastGlobalBounds(t,e){e||(e=new jn),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 s=!!this.effects.length;if((this.renderGroup||s)&&(n=Is.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 s=0;s<e.length;s++)e[s]._getGlobalBoundsRecursive(t,n,i)}if(s){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(As).invert()),e.addBounds(n),Is.return(n)}else this.renderGroup&&(e.addBounds(n,this.relativeGroupTransform),Is.return(n))}},Ts=16777215,Ps={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 un,e){if(e)return t.copyFrom(this.worldTransform);this.updateLocalTransform();const i=d(this,Ss.get().identity());return t.appendFrom(this.localTransform,i),Ss.return(i),t},getGlobalTint(t){if(t)return this.renderGroup?f(this.renderGroup.worldColor):this.parentRenderGroup?f(p(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,i=this.parent;for(;i;)e=p(e,i.localColor),i=i.parent;return f(e)}},Es=new un,Bs={_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 jn});const t=this._localBoundsCacheData;return t.index=1,t.didChange=!1,t.data[0]!==this._didViewChangeTick&&(t.didChange=!0,t.data[0]=this._didViewChangeTick),y(this,t),t.didChange&&g(this,t.localBounds,Es),t.localBounds},getBounds(t,e){return l(this,t,e||new jn)}},Os={_onRender:null,set onRender(t){const e=this.renderGroup||this.parentRenderGroup;if(!t)return this._onRender&&e?.removeOnRender(this),void(this._onRender=null);this._onRender||e?.addOnRender(this),this._onRender=t},get onRender(){return this._onRender}},ks={_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(x))}},Rs={getGlobalPosition(t=new cn,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(Ss.get(),i);return e=n.apply(t,e),Ss.return(n),e},toLocal(t,e,i,n){e&&(t=e.toGlobal(t,i,n));const s=this.getGlobalTransform(Ss.get(),n);return i=s.applyInverse(t,i),Ss.return(s),i}};class Ds{constructor(){this.uid=e("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}}let Fs=0;const Ls=new class{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new En(this.textureOptions)}createTexture(t,e,i){const n=new On({...this.textureOptions,width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1});return new Fn({source:n,label:"texturePool_"+Fs++})}getOptimalTexture(t,e,i=1,s){let r=Math.ceil(t*i-1e-6),o=Math.ceil(e*i-1e-6);r=n(r),o=n(o);const a=(r<<17)+(o<<1)+(s?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let h=this._texturePool[a].pop();return h||(h=this.createTexture(r,o,s)),h.source._resolution=i,h.source.width=r/i,h.source.height=o/i,h.source.pixelWidth=r,h.source.pixelHeight=o,h.frame.x=0,h.frame.y=0,h.frame.width=t,h.frame.height=e,h.updateUvs(),this._poolKeyHash[h.uid]=a,h}getSameSizeTexture(t,e=!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 t in this._texturePool){const e=this._texturePool[t];if(e)for(let t=0;t<e.length;t++)e[t].destroy(!0)}this._texturePool={}}};class js{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new un,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 Ds,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 t=0;t<e.length;t++){const i=e[t];i._updateFlags=15,this.addChild(i)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(Ls.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 t=0;t<e.length;t++)this.addChild(e[t])}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 t=0;t<e.length;t++)this.removeChild(e[t])}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 t=0;t<i.length;t++)this._getChildren(i[t],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return 1&this._matrixDirty?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new un),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return 2&this._matrixDirty?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new un),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 un),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 Gs=new nn(null),Us=new nn(null),Ns=new nn(null,1,1),zs=new nn(null);class Hs extends on{constructor(t={}){super(),this.uid=e("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 un,this.relativeGroupTransform=new un,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new nn(this,0,0),this._scale=Ns,this._pivot=Us,this._origin=zs,this._skew=Gs,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}),t.children?.forEach(t=>this.addChild(t)),t.parent?.addChild(this)}static mixin(t){i(0,"Container.mixin is deprecated, please use extensions.mixin instead."),$i.mixin(Hs,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||i(0,"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],n=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),n&&(n.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,n&&n.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;t?.removeChild(this),this.renderGroup=ms.get(js,this),this.groupTransform=un.IDENTITY,t?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),ms.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&0===this.effects.length}get worldTransform(){return this._worldTransform||(this._worldTransform=new un),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*hn}set angle(t){this.rotation=t*ln}get pivot(){return this._pivot===Us&&(this._pivot=new nn(this,0,0)),this._pivot}set pivot(t){this._pivot===Us&&(this._pivot=new nn(this,0,0),this._origin!==zs&&a()),"number"==typeof t?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Gs&&(this._skew=new nn(this,0,0)),this._skew}set skew(t){this._skew===Gs&&(this._skew=new nn(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Ns&&(this._scale=new nn(this,1,1)),this._scale}set scale(t){this._scale===Ns&&(this._scale=new nn(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===zs&&(this._origin=new nn(this,0,0)),this._origin}set origin(t){this._origin===zs&&(this._origin=new nn(this,0,0),this._pivot!==Us&&a()),"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){const i=this.getLocalBounds();"object"==typeof t?(e=t.height??t.width,t=t.width):e??(e=t),void 0!==t&&this._setWidth(t,i.width),void 0!==e&&this._setHeight(e,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set("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,s=this._origin,r=this._position,o=i._x,a=i._y,h=n._x,l=n._y,c=-s._x,d=-s._y;e.a=this._cx*o,e.b=this._sx*o,e.c=this._cy*a,e.d=this._sy*a,e.tx=r._x-(h*e.a+l*e.c)+(c*e.a+d*e.c)-c,e.ty=r._y-(h*e.b+l*e.d)+(c*e.b+d*e.d)-d}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=1,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=ps.shared.setValue(t??16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=1,this._onUpdate())}get tint(){return f(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){if(this.destroyed)return;let e;if(this.destroyed=!0,this.children.length&&(e=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),("boolean"==typeof t?t:t?.children)&&e)for(let i=0;i<e.length;++i)e[i].destroy(t);this.renderGroup?.destroy(),this.renderGroup=null}}$i.mixin(Hs,xs,Ms,Rs,Os,Bs,ws,Cs,ks,{cullArea:null,cullable:!1,cullableChildren:!0},ys,Ps,bs);class Vs extends Hs{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this._bounds=new jn(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){super.destroy(t),this._bounds=null;for(const t in this._gpuData)this._gpuData[t].destroy?.();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 s=this.children,r=s.length;for(let n=0;n<r;n++)s[n].collectRenderables(t,e,i)}}class Ws extends Vs{constructor(t=Fn.EMPTY){t instanceof Fn&&(t={texture:t});const{texture:e=Fn.EMPTY,anchor:i,roundPixels:n,width:s,height:r,...o}=t;super({label:"Sprite",...o}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new nn({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=n??!1,void 0!==s&&(this.width=s),void 0!==r&&(this.height=r)}static from(t,e=!1){return new Ws(t instanceof Fn?t:Fn.from(t,e))}set texture(t){t||(t=Fn.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 o(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return i(0,"Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:n,height:s}=e.orig;i.minX=-t._x*n,i.maxX=i.minX+n,i.minY=-t._y*s,i.maxY=i.minY+s}destroy(t=!1){if(super.destroy(t),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t: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){"object"==typeof t?(e=t.height??t.width,t=t.width):e??(e=t),void 0!==t&&this._setWidth(t,this._texture.orig.width),void 0!==e&&this._setHeight(e,this._texture.orig.height)}}const Zs=new jn;class Js{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Ws),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||b(this.mask,t,e)}addLocalBounds(t,e){_(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof Ws}}Js.extension=Ki.MaskEffect;class Xs{constructor(t){this.priority=0,this.pipe="colorMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return"number"==typeof t}}Xs.extension=Ki.MaskEffect;class Ys{constructor(t){this.priority=0,this.pipe="stencilMask",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){b(this.mask,t,e)}addLocalBounds(t,e){_(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof Hs}}Ys.extension=Ki.MaskEffect;let Ks={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:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(t,e)=>fetch(t,e),parseXML:t=>(new DOMParser).parseFromString(t,"text/xml")};const qs={get:()=>Ks,set(t){Ks=t}};class Qs extends On{constructor(t){t.resource||(t.resource=qs.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"))}}Qs.extension=Ki.TextureSource;class $s extends On{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}}$s.extension=Ki.TextureSource;var tr=(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))(tr||{});class er{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 ir=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 er(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=tr.NORMAL){return this._addListener(new er(t,e,i))}addOnce(t,e,i=tr.NORMAL){return this._addListener(new er(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 s=n.next;for(;s;)s=s.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}};ir.targetFPMS=.06;let nr,sr=ir;const rr=class t extends On{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...t.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=!1!==e.autoPlay,this.alphaMode=e.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),!1!==e.autoLoad&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=sr.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await w(),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&&(sr.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||(sr.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(sr.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};rr.extension=Ki.TextureSource,rr.defaultOptions={...On.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1},rr.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let or=rr;const ar=(t,e,i=!1)=>(Array.isArray(t)||(t=[t]),e?t.map(t=>"string"==typeof t||i?e(t):t):t),hr=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||a(),e}set(t,e){const i=ar(t);let n;for(let t=0;t<this.parsers.length;t++){const s=this.parsers[t];if(s.test(e)){n=s.getCacheableAssets(i,e);break}}const s=new Map(Object.entries(n||{}));n||i.forEach(t=>{s.set(t,e)});const r=[...s.keys()],o={cacheKeys:r,keys:i};i.forEach(t=>{this._cacheMap.set(t,o)}),r.forEach(t=>{const i=n?n[t]:e;this._cache.has(t)&&this._cache.get(t)!==i&&a(),this._cache.set(t,s.get(t))})}remove(t){if(!this._cacheMap.has(t))return void a();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}},lr=[];$i.handleByList(Ki.TextureSource,lr),Fn.from=function(t,e=!1){return"string"==typeof t?hr.get(t):t instanceof On?new Fn({source:t}):function(t={},e=!1){const i=t&&t.resource,n=i?t.resource:t,s=i?t:{resource:t};if(!e&&hr.has(n))return hr.get(n);const r=new Fn({source:C(s)});return r.on("destroy",()=>{hr.has(n)&&hr.remove(n)}),e||hr.set(n,r),r}(t,e)},On.from=C,$i.add(Js,Xs,Ys,or,$s,Qs,kn);var cr=(t=>(t[t.Low=0]="Low",t[t.Normal=1]="Normal",t[t.High=2]="High",t))(cr||{});const dr={toPosix:t=>t.replace(new RegExp("\\".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),"/"),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){S(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(S(t),this.isDataUrl(t)||this.isBlobUrl(t))return t;const n=I(this.toPosix(e??qs.get().getBaseUrl())),s=I(this.toPosix(i??this.rootname(n)));return(t=this.toPosix(t)).startsWith("/")?dr.join(s,t.slice(1)):this.isAbsolute(t)?t:this.join(n,t)},normalize(t){if(S(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,s=0,r=-1;for(let o=0;o<=t.length;++o){if(o<t.length)r=t.charCodeAt(o);else{if(47===r)break;r=47}if(47===r){if(n===o-1||1===s);else if(n!==o-1&&2===s){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,s=0;continue}}else if(2===e.length||1===e.length){e="",i=0,n=o,s=0;continue}}else e.length>0?e+=`/${t.slice(n+1,o)}`:e=t.slice(n+1,o),i=o-n-1;n=o,s=0}else 46===r&&-1!==s?++s:s=-1}return e}(t)).length>0&&n&&(t+="/"),i?`/${t}`:e+t},isAbsolute(t){return S(t),t=this.toPosix(t),!!this.hasProtocol(t)||t.startsWith("/")},join(...t){if(0===t.length)return".";let e;for(let i=0;i<t.length;++i){const n=t[i];if(S(n),n.length>0)if(void 0===e)e=n;else{const s=t[i-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?e+=`/../${n}`:e+=`/${n}`}}return void 0===e?".":this.normalize(e)},dirname(t){if(S(t),0===t.length)return".";let e=(t=this.toPosix(t)).charCodeAt(0);const i=47===e;let n=-1,s=!0;const r=this.getProtocol(t),o=t;for(let i=(t=t.slice(r.length)).length-1;i>=1;--i)if(e=t.charCodeAt(i),47===e){if(!s){n=i;break}}else s=!1;return-1===n?i?"/":this.isUrl(o)?r+t:r:i&&1===n?"//":r+t.slice(0,n)},rootname(t){S(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){S(t),e&&S(e),t=I(this.toPosix(t));let i,n=0,s=-1,r=!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 h=t.charCodeAt(i);if(47===h){if(!r){n=i+1;break}}else-1===a&&(r=!1,a=i+1),o>=0&&(h===e.charCodeAt(o)?-1===--o&&(s=i):(o=-1,s=a))}return n===s?s=a:-1===s&&(s=t.length),t.slice(n,s)}for(i=t.length-1;i>=0;--i)if(47===t.charCodeAt(i)){if(!r){n=i+1;break}}else-1===s&&(r=!1,s=i+1);return-1===s?"":t.slice(n,s)},extname(t){S(t);let e=-1,i=0,n=-1,s=!0,r=0;for(let o=(t=I(this.toPosix(t))).length-1;o>=0;--o){const a=t.charCodeAt(o);if(47!==a)-1===n&&(s=!1,n=o+1),46===a?-1===e?e=o:1!==r&&(r=1):-1!==e&&(r=-1);else if(!s){i=o+1;break}}return-1===e||-1===n||0===r||1===r&&e===n-1&&e===i+1?"":t.slice(e,n)},parse(t){S(t);const e={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return e;let i=(t=I(this.toPosix(t))).charCodeAt(0);const n=this.isAbsolute(t);let s;e.root=this.rootname(t),s=n||this.hasProtocol(t)?1:0;let r=-1,o=0,a=-1,h=!0,l=t.length-1,c=0;for(;l>=s;--l)if(i=t.charCodeAt(l),47!==i)-1===a&&(h=!1,a=l+1),46===i?-1===r?r=l:1!==c&&(c=1):-1!==r&&(c=-1);else if(!h){o=l+1;break}return-1===r||-1===a||0===c||1===c&&r===a-1&&r===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,r),e.base=t.slice(1,a)):(e.name=t.slice(o,r),e.base=t.slice(o,a)),e.ext=t.slice(r,a)),e.dir=this.dirname(t),e},sep:"/",delimiter:":",joinExtensions:[".html"]},ur=t=>!Array.isArray(t);class pr{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,"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 ar(e||i,t=>"string"==typeof t?t:Array.isArray(t)?t.map(t=>t?.src??t):t?.src?t.src:t,!0)}addManifest(t){this._manifest&&a(),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}:{alias:t,...e})),n.forEach(e=>{const n=e.src,s=e.alias;let r;if("string"==typeof s){const e=this._createBundleAssetId(t,s);i.push(e),r=[s,e]}else{const e=s.map(e=>this._createBundleAssetId(t,e));i.push(...e),r=[...s,...e]}this.add({...e,alias:r,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)&&a()},ar(e).forEach(t=>{const{src:e}=t;let{data:n,format:s,loadParser:r,parser:o}=t;const a=ar(e).map(t=>"string"==typeof t?M(t):Array.isArray(t)?t:[t]),h=this.getAlias(t);Array.isArray(h)?h.forEach(i):i(h);const l=[];a.forEach(t=>{t.forEach(t=>{let e={};if("object"!=typeof t){e.src=t;for(let i=0;i<this._parsers.length;i++){const n=this._parsers[i];if(n.test(t)){e=n.parse(t);break}}}else n=t.data??n,s=t.format??s,(t.loadParser||t.parser)&&(r=t.loadParser??r,o=t.parser??o),e={...e,...t};if(!h)throw new Error(`[Resolver] alias is undefined for this asset: ${e.src}`);e=this._buildResolvedAsset(e,{aliases:h,data:n,format:s,loadParser:r,parser:o}),l.push(e)})}),h.forEach(t=>{this._assetMap[t]=l})})}resolveBundle(t){const e=ur(t);t=ar(t);const i={};return t.forEach(t=>{const e=this._bundles[t];if(e){const n=this.resolve(e),s={};for(const e in n){const i=n[e];s[this._extractAssetIdFromBundle(t,e)]=i}i[t]=s}}),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=ur(t);t=ar(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);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){return this._defaultSearchParams?`${t}${/\?/.test(t)?"&":"?"}${this._defaultSearchParams}`:t}_buildResolvedAsset(t,e){const{aliases:i,data:n,loadParser:s,parser:r,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=dr.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=s??t.loadParser,t.parser=r??t.parser,t.format=o??t.format??t.src.split(".").pop().split("?").shift().split("#").shift(),t}}pr.RETINA_PREFIX=/@([0-9\.]+)x/;const fr=(t,e)=>{const i=e.split("?")[1];return i&&(t+=`?${i}`),t},gr=class t{constructor(t,e){this.linkedSheets=[];let i=t;t?.source instanceof On&&(i={texture:t,data:e});const{texture:n,data:s,cachePrefix:r=""}=i;this.cachePrefix=r,this._texture=n instanceof Fn?n:null,this.textureSource=n.source,this.textures={},this.animations={},this.data=s;const o=parseFloat(s.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,s=null;const r=!1!==e.trimmed&&e.sourceSize?e.sourceSize:e.frame,o=new Sn(0,0,Math.floor(r.w)/this.resolution,Math.floor(r.h)/this.resolution);i=e.rotated?new Sn(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 Sn(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&&(s=new Sn(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 Fn({source:this.textureSource,frame:i,orig:o,trim:s,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){for(const t in this.textures)this.textures[t].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};gr.BATCH_SIZE=1e3;let mr=gr;const yr=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"],xr={extension:Ki.Asset,cache:{test:t=>t instanceof mr,getCacheableAssets:(t,e)=>T(t,e,!1)},resolver:{extension:{type:Ki.ResolveParser,name:"resolveSpritesheet"},test:t=>{const e=t.split("?")[0].split("."),i=e.pop(),n=e.pop();return"json"===i&&yr.includes(n)},parse:t=>{const e=t.split(".");return{resolution:parseFloat(pr.RETINA_PREFIX.exec(t)?.[1]??"1"),format:e[e.length-2],src:t}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:Ki.LoadParser,priority:cr.Normal,name:"spritesheetLoader"},testParse:async(t,e)=>".json"===dr.extname(e.src).toLowerCase()&&!!t.frames,async parse(t,e,i){const{texture:n,imageFilename:s,textureOptions:r,cachePrefix:o}=e?.data??{};let a,h=dr.dirname(e.src);if(h&&h.lastIndexOf("/")!==h.length-1&&(h+="/"),n instanceof Fn)a=n;else{const n=fr(h+(s??t.meta.image),e.src);a=(await i.load([{src:n,data:r}]))[n]}const l=new mr({texture:a.source,data:t,cachePrefix:o});await l.parse();const c=t?.meta?.related_multi_packs;if(Array.isArray(c)){const t=[];for(const n of c){if("string"!=typeof n)continue;let s=h+n;e.data?.ignoreMultiPack||(s=fr(s,e.src),t.push(i.load({src:s,data:{textureOptions:r,ignoreMultiPack:!0}})))}const n=await Promise.all(t);l.linkedSheets=n,n.forEach(t=>{t.linkedSheets=[l].concat(l.linkedSheets.filter(e=>e!==t))})}return l},async unload(t,e,i){await i.unload(t.textureSource._sourceOrigin),t.destroy(!1)}}};$i.add(xr);class br{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,s=t.height/i*this._renderer.resolution,r=`translate(${t.left}px, ${t.top}px) scale(${n}, ${s})`;r!==this._lastTransform&&(this._domElement.style.transform=r,this._lastTransform=r)},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,s=e.contentRect.height/i*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==s)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=s)}}),this._observer.observe(this._canvas)):this._tickerAttached||sr.shared.add(this.updateTranslation,this,tr.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&sr.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 _r{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=_r.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new cn,this.page=new cn,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,s){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 vr=/iPhone/i,wr=/iPod/i,Cr=/iPad/i,Sr=/\biOS-universal(?:.+)Mac\b/i,Ir=/\bAndroid(?:.+)Mobile\b/i,Ar=/Android/i,Mr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Tr=/Silk/i,Pr=/Windows Phone/i,Er=/\bWindows(?:.+)ARM\b/i,Br=/BlackBerry/i,Or=/BB10/i,kr=/Opera Mini/i,Rr=/\b(CriOS|Chrome)(?:.+)Mobile/i,Dr=/Mobile(?:.+)Firefox\b/i,Fr=function(t){return void 0!==t&&"MacIntel"===t.platform&&"number"==typeof t.maxTouchPoints&&t.maxTouchPoints>1&&"undefined"==typeof MSStream};const Lr=(P.default??P)(globalThis.navigator),jr=class t{constructor(t,e=Lr){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 br({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 t=0;t<e.length;t++)this._updateAccessibleObjects(e[t])}init(e){const i={accessibilityOptions:{...t.defaultOptions,...e?.accessibilityOptions||{}}};this.debug=i.accessibilityOptions.debug,this._activateOnTab=i.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=i.accessibilityOptions.deactivateOnMouseMove,i.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 t=this._children.length-1;t>=0;t--){const i=this._children[t];e.has(t)||(i._accessibleDiv&&i._accessibleDiv.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),this._pool.push(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1,h(this._children,t,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let t=0;t<this._children.length;t++){const e=this._children[t];if(!e._accessibleActive||!e._accessibleDiv)continue;const i=e._accessibleDiv,n=e.hitArea||e.getBounds().rectangle;if(e.hitArea){const t=e.worldTransform;i.style.left=`${t.tx+n.x*t.a}px`,i.style.top=`${t.ty+n.y*t.d}px`,i.style.width=n.width*t.a+"px",i.style.height=n.height*t.d+"px"}else this._capHitArea(n),i.style.left=`${n.x}px`,i.style.top=`${n.y}px`,i.style.width=`${n.width}px`,i.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,s=Object.assign(new _r(n),{target:i});n.rootTarget=this._renderer.lastObjectRendered,e.forEach(t=>n.dispatchEvent(s,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(){this._deactivate(),this._destroyTouchHook(),this._canvasObserver?.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()}};jr.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem],name:"accessibility"},jr.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let Gr=jr;const Ur=Object.create(null),Nr=Object.create(null);let zr,Hr;const Vr={},Wr={},Zr={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 s=i?e.requestedFragmentPrecision:e.requestedVertexPrecision;return"highp"===s&&"highp"!==n&&(s="mediump"),`precision ${s} 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?Vr:Wr;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}},Jr=Object.create(null),Xr=class t{constructor(e){const i=-1!==(e={...t.defaultOptions,...e}).fragment.indexOf("#version 300 es"),n={stripVersion:i,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:O()},setProgramName:{name:e.name},addProgramDefines:i,insertVersion:i};let s=e.fragment,r=e.vertex;Object.keys(Zr).forEach(t=>{const e=n[t];s=Zr[t](s,e,!0),r=Zr[t](r,e,!1)}),this.fragment=s,this.vertex=r,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=E(`${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 Jr[i]||(Jr[i]=new t(e)),Jr[i]}};Xr.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Yr=Xr;const Kr={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}},qr={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"};var Qr=(t=>(t[t.VERTEX=1]="VERTEX",t[t.FRAGMENT=2]="FRAGMENT",t[t.COMPUTE=4]="COMPUTE",t))(Qr||{});const $r=Object.create(null);class to{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:n,gpuLayout:s,name:r}=t;if(this.name=r,this.fragment=e,this.vertex=i,e.source===i.source){const t=R(e.source);this.structsAndGroups=t}else{const t=R(i.source),n=R(e.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,n)}this.layout=n??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=s??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:Qr.VERTEX|Qr.FRAGMENT,buffer:{type:"uniform"}}):"sampler"===n.type?e[n.group].push({binding:n.binding,visibility:Qr.FRAGMENT,sampler:{type:"filtering"}}):"texture_2d"===n.type&&e[n.group].push({binding:n.binding,visibility:Qr.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return e}(this.structsAndGroups),this.autoAssignGlobalUniforms=!(void 0===this.layout[0]?.globalUniforms),this.autoAssignLocalUniforms=!(void 0===this.layout[1]?.localUniforms),this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=E(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=function({source:t,entryPoint:e}){const i={},n=t.indexOf(`fn ${e}`);if(-1!==n){const e=t.indexOf("->",n);if(-1!==e){const s=t.substring(n,e),r=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;null!==(o=r.exec(s));){const t=qr[o[3]]??"float32";i[o[2]]={location:parseInt(o[1],10),format:t,stride:k(t).stride,offset:0,instance:!1,start:0}}}}return i}(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 $r[e]||($r[e]=new to(t)),$r[e]}}const eo=["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>"],io=eo.reduce((t,e)=>(t[e]=!0,t),{}),no=class t{constructor(i,n){this._touched=0,this.uid=e("uniform"),this._resourceType="uniformGroup",this._resourceId=e("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,n={...t.defaultOptions,...n},this.uniformStructures=i;const s={};for(const t in i){const e=i[t];if(e.name=t,e.size=e.size??1,!io[e.type])throw new Error(`Uniform type ${e.type} is not supported. Supported uniform types are: ${eo.join(", ")}`);e.value??(e.value=D(e.type,e.size)),s[t]=e.value}this.uniforms=s,this._dirtyId=1,this.ubo=n.ubo,this.isStatic=n.isStatic,this._signature=E(Object.keys(s).map(t=>`${t}-${i[t].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};no.defaultOptions={ubo:!1,isStatic:!1};let so=no;class ro{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){const i=this.resources[e];t!==i&&(i&&t.off?.("change",this.onResourceChange,this),t.on?.("change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const i in e)e[i]._touched=t}destroy(){const t=this.resources;for(const e in t){const i=t[e];i.off?.("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 oo=(t=>(t[t.WEBGL=1]="WEBGL",t[t.WEBGPU=2]="WEBGPU",t[t.BOTH=3]="BOTH",t))(oo||{});class ao extends on{constructor(t){super(),this.uid=e("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:i,glProgram:n,groups:s,resources:r,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=i,this.glProgram=n,void 0===o&&(o=0,i&&(o|=oo.WEBGPU),n&&(o|=oo.WEBGL)),this.compatibleRenderers=o;const h={};if(r||s||(r={}),r&&s)throw new Error("[Shader] Cannot have both resources and groups");if(!i&&s&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!i&&s&&a)for(const t in a)for(const e in a[t]){const i=a[t][e];h[i]={group:t,binding:e,name:i}}else if(i&&s&&!a){const t=i.structsAndGroups.groups;a={},t.forEach(t=>{a[t.group]=a[t.group]||{},a[t.group][t.binding]=t.name,h[t.name]=t})}else if(r){s={},a={},i&&i.structsAndGroups.groups.forEach(t=>{a[t.group]=a[t.group]||{},a[t.group][t.binding]=t.name,h[t.name]=t});let t=0;for(const e in r)h[e]||(s[99]||(s[99]=new ro,this._ownedBindGroups.push(s[99])),h[e]={group:99,binding:t,name:e},a[99]=a[99]||{},a[99][t]=e,t++);for(const t in r){const e=t;let i=r[t];i.source||i._resourceType||(i=new so(i));const n=h[e];n&&(s[n.group]||(s[n.group]=new ro,this._ownedBindGroups.push(s[n.group])),s[n.group].setResource(i,n.binding))}}this.groups=s,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(s,h)}addResource(t,e,i){var n,s;(n=this._uniformBindMap)[e]||(n[e]={}),(s=this._uniformBindMap[e])[i]||(s[i]=t),this.groups[e]||(this.groups[e]=new ro,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const n in e){const s=e[n];Object.defineProperty(i,s.name,{get:()=>t[s.group].getResource(s.binding),set(e){t[s.group].setResource(e,s.binding)}})}return i}destroy(t=!1){this.emit("destroy",this),t&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(t=>{t.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:i,...n}=t;let s,r;return e&&(s=to.from(e)),i&&(r=Yr.from(i)),new ao({gpuProgram:s,glProgram:r,...n})}}const ho={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},lo=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=ho[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}};lo.default2d=lo.for2d();let co=lo;const uo=class t extends ao{constructor(e){super(e={...t.defaultOptions,...e}),this.enabled=!0,this._state=co.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{gpu:i,gl:n,...s}=e;let r,o;return i&&(r=to.from(i)),n&&(o=Yr.from(n)),new t({gpuProgram:r,glProgram:o,...s})}};uo.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let po=uo;const fo=[];let go;$i.handleByNamedList(Ki.Environment,fo);const mo=L.default||L;var yo=(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))(yo||{});class xo{constructor(t){this.items=[],this._name=t}emit(t,e,i,n,s,r,o,a){const{name:h,items:l}=this;for(let c=0,d=l.length;c<d;c++)l[c][h](t,e,i,n,s,r,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 bo=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],_o=class t extends on{constructor(t){super(),this.uid=e("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=[...bo,...this.config.runners??[]];this._addRunners(...i),this._unsafeEvalCheck()}async init(e={}){const i=!0===e.skipExtensionImports||!1===e.manageImports;await async function(t){if(!t)for(let t=0;t<fo.length;t++){const e=fo[t];if(e.value.test())return void await e.value.load()}}(i),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const t in this._systemsHash)e={...this._systemsHash[t].constructor.defaultOptions,...e};e={...t.defaultOptions,...e},this._roundPixels=e.roundPixels?1:0;for(let t=0;t<this.runners.init.items.length;t++)await this.runners.init.items[t].init(e);this._initOptions=e}render(t,e){let n=t;if(n instanceof Hs&&(n={container:n},e&&(i(0,"passing a second argument is deprecated, please use render options instead"),n.target=e.renderTexture)),n.target||(n.target=this.view.renderTarget),n.target===this.view.renderTarget&&(this._lastObjectRendered=n.container,n.clearColor??(n.clearColor=this.background.colorRgba),n.clear??(n.clear=this.background.clearBeforeRender)),n.clearColor){const t=Array.isArray(n.clearColor)&&4===n.clearColor.length;n.clearColor=t?n.clearColor:ps.shared.setValue(n.clearColor).toArray()}n.transform||(n.container.updateLocalTransform(),n.transform=n.container.localTransform),n.container.enableRenderGroup(),this.runners.prerender.emit(n),this.runners.renderStart.emit(n),this.runners.render.emit(n),this.runners.renderEnd.emit(n),this.runners.postrender.emit(n)}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),t.clear??(t.clear=yo.ALL);const{clear:e,clearColor:i,target:n}=t;ps.shared.setValue(i??this.background.colorRgba),this.renderTarget.clear(n,e,ps.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 xo(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 t in this.runners)this.runners[t].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,s=i[n];this.renderPipes[n]=new e(this,s?new s: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(!F())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()}};_o.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let vo,wo,Co=_o;const So=["webgl","webgpu","canvas"],Io="8.12.0";class Ao{static init(){globalThis.__PIXI_APP_INIT__?.(this,Io)}static destroy(){}}Ao.extension=Ki.Application;class Mo{constructor(t){this._renderer=t}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,Io)}destroy(){this._renderer=null}}Mo.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem],name:"initHook",priority:-10};const To=class t{constructor(...t){this.stage=new Hs,void 0!==t[0]&&i(0,"Application constructor options are deprecated, please use Application.init() instead.")}async init(e){e={...e},this.renderer=await async function(t){let e,i=[];t.preference?(i.push(t.preference),So.forEach(e=>{e!==t.preference&&i.push(e)})):i=So.slice();let n={};for(let s=0;s<i.length;s++){const r=i[s];if("webgpu"===r&&await ct()){const{WebGPURenderer:i}=await Promise.resolve().then(()=>Ou);e=i,n={...t,...t.webgpu};break}if("webgl"===r&<(t.failIfMajorPerformanceCaveat??Co.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:i}=await Promise.resolve().then(()=>Yd);e=i,n={...t,...t.webgl};break}if("canvas"===r)throw n={...t},new Error("CanvasRenderer is not yet implemented")}if(delete n.webgpu,delete n.webgl,!e)throw new Error("No available renderer for the current environment");const s=new e;return await s.init(n),s}(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 i(0,"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}};To._plugins=[];let Po=To;$i.handleByList(Ki.Application,Po._plugins),$i.add(Ao);class Eo{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}}Eo.extension=Ki.Application;class Bo{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,tr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?sr.shared:new sr,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Bo.extension=Ki.Application;class Oo extends on{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 i(0,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return i(0,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return i(0,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return i(0,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return i(0,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners();for(const t in this.chars)this.chars[t].texture?.destroy();this.chars=null,t&&(this.pages.forEach(t=>t.texture.destroy(!0)),this.pages=null)}}const ko=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Ro={willReadFrequently:!0},Do=class t{static get experimentalLetterSpacingSupported(){let e=t._experimentalLetterSpacingSupported;if(void 0===e){const i=qs.get().getCanvasRenderingContext2D().prototype;e=t._experimentalLetterSpacingSupported="letterSpacing"in i||"textLetterSpacing"in i}return e}constructor(t,e,i,n,s,r,o,a,h){this.text=t,this.style=e,this.width=i,this.height=n,this.lines=s,this.lineWidths=r,this.lineHeight=o,this.maxLineWidth=a,this.fontProperties=h}static measureText(e=" ",i,n=t._canvas,s=i.wordWrap){const r=dt(i),o=t.measureFont(r);0===o.fontSize&&(o.fontSize=i.fontSize,o.ascent=i.fontSize);const a=t.__context;a.font=r;const h=(s?t._wordWrap(e,i,n):e).split(/(?:\r\n|\r|\n)/),l=new Array(h.length);let c=0;for(let e=0;e<h.length;e++){const n=t._measureText(h[e],i.letterSpacing,a);l[e]=n,c=Math.max(c,n)}const d=i._stroke?.width||0;let u=c+d;i.dropShadow&&(u+=i.dropShadow.distance);const p=i.lineHeight||o.fontSize;let f=Math.max(p,o.fontSize+d)+(h.length-1)*(p+i.leading);return i.dropShadow&&(f+=i.dropShadow.distance),new t(e,i,u,f,h,l,p+i.leading,c,o)}static _measureText(e,i,n){let s=!1;t.experimentalLetterSpacingSupported&&(t.experimentalLetterSpacing?(n.letterSpacing=`${i}px`,n.textLetterSpacing=`${i}px`,s=!0):(n.letterSpacing="0px",n.textLetterSpacing="0px"));const r=n.measureText(e);let o=r.width;const a=-r.actualBoundingBoxLeft;let h=r.actualBoundingBoxRight-a;if(o>0)if(s)o-=i,h-=i;else{const n=(t.graphemeSegmenter(e).length-1)*i;o+=n,h+=n}return Math.max(o,h)}static _wordWrap(e,i,n=t._canvas){const s=n.getContext("2d",Ro);let r=0,o="",a="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=i,d=t._collapseSpaces(c),u=t._collapseNewlines(c);let p=!d;const f=i.wordWrapWidth+l,g=t._tokenize(e);for(let e=0;e<g.length;e++){let n=g[e];if(t._isNewline(n)){if(!u){a+=t._addLine(o),p=!d,o="",r=0;continue}n=" "}if(d){const e=t.isBreakingSpace(n),i=t.isBreakingSpace(o[o.length-1]);if(e&&i)continue}const c=t._getFromCache(n,l,h,s);if(c>f)if(""!==o&&(a+=t._addLine(o),o="",r=0),t.canBreakWords(n,i.breakWords)){const e=t.wordWrapSplit(n);for(let c=0;c<e.length;c++){let d=e[c],u=d,g=1;for(;e[c+g];){const s=e[c+g];if(t.canBreakChars(u,s,n,c,i.breakWords))break;d+=s,u=s,g++}c+=g-1;const m=t._getFromCache(d,l,h,s);m+r>f&&(a+=t._addLine(o),p=!1,o="",r=0),o+=d,r+=m}}else{o.length>0&&(a+=t._addLine(o),o="",r=0);const i=e===g.length-1;a+=t._addLine(n,!i),p=!1,o="",r=0}else c+r>f&&(p=!1,a+=t._addLine(o),o="",r=0),(o.length>0||!t.isBreakingSpace(n)||p)&&(o+=n,r+=c)}return a+=t._addLine(o,!1),a}static _addLine(e,i=!0){return e=t._trimRight(e),i?`${e}\n`:e}static _getFromCache(e,i,n,s){let r=n[e];return"number"!=typeof r&&(r=t._measureText(e,i,s)+i,n[e]=r),r}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 s=0;s<e.length;s++){const r=e[s],o=e[s+1];t.isBreakingSpace(r,o)||t._isNewline(r)?(""!==n&&(i.push(n),n=""),"\r"===r&&"\n"===o?(i.push("\r\n"),s++):i.push(r)):n+=r}return""!==n&&i.push(n),i}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,n,s){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),s={ascent:n.actualBoundingBoxAscent,descent:n.actualBoundingBoxDescent,fontSize:n.actualBoundingBoxAscent+n.actualBoundingBoxDescent};return t._fonts[e]=s,s}static clearMetrics(e=""){e?delete t._fonts[e]:t._fonts={}}static get _canvas(){if(!t.__canvas){let e;try{const i=new OffscreenCanvas(0,0),n=i.getContext("2d",Ro);if(n?.measureText)return t.__canvas=i,i;e=qs.get().createCanvas()}catch(t){e=qs.get().createCanvas()}e.width=e.height=10,t.__canvas=e}return t.__canvas}static get _context(){return t.__context||(t.__context=t._canvas.getContext("2d",Ro)),t.__context}};Do.METRICS_STRING="|ÉqÅ",Do.BASELINE_SYMBOL="M",Do.BASELINE_MULTIPLIER=1.4,Do.HEIGHT_MULTIPLIER=2,Do.graphemeSegmenter=(()=>t=>[...t])(),Do.experimentalLetterSpacing=!1,Do._fonts={},Do._newlines=[10,13],Do._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Fo=Do;const Lo=[{offset:0,color:"white"},{offset:1,color:"black"}],jo=class t{constructor(...n){this.uid=e("fillGradient"),this.type="linear",this.colorStops=[];let s=function(t){let e=t[0]??{};return("number"==typeof e||t[1])&&(i(0,"use options object instead"),e={type:"linear",start:{x:t[0],y:t[1]},end:{x:t[2],y:t[3]},textureSpace:t[4],textureSize:t[5]??Go.defaultLinearOptions.textureSize}),e}(n);s={..."radial"===s.type?t.defaultRadialOptions:t.defaultLinearOptions,...r(s)},this._textureSize=s.textureSize,this._wrapMode=s.wrapMode,"radial"===s.type?(this.center=s.center,this.outerCenter=s.outerCenter??this.center,this.innerRadius=s.innerRadius,this.outerRadius=s.outerRadius,this.scale=s.scale,this.rotation=s.rotation):(this.start=s.start,this.end=s.end),this.textureSpace=s.textureSpace,this.type=s.type,s.colorStops.forEach(t=>{this.addColorStop(t.offset,t.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:ps.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:n}=this.end,s=i-t,r=n-e;const o=s<0||r<0;if("clamp-to-edge"===this._wrapMode){if(s<0){const e=t;t=i,i=e,s*=-1}if(r<0){const t=e;e=n,n=t,r*=-1}}const a=this.colorStops.length?this.colorStops:Lo,h=this._textureSize,{canvas:l,context:c}=pt(h,1),d=o?c.createLinearGradient(this._textureSize,0,0,0):c.createLinearGradient(0,0,this._textureSize,0);ut(d,a),c.fillStyle=d,c.fillRect(0,0,h,1),this.texture=new Fn({source:new $s({resource:l,addressMode:this._wrapMode})});const u=Math.sqrt(s*s+r*r),p=Math.atan2(r,s),f=new un;f.scale(u/h,1),f.rotate(p),f.translate(t,e),"local"===this.textureSpace&&f.scale(h,h),this.transform=f}buildGradient(){"linear"===this.type?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Lo,e=this._textureSize,{canvas:i,context:n}=pt(e,e),{x:s,y:r}=this.center,{x:o,y:a}=this.outerCenter,h=this.innerRadius,l=this.outerRadius,c=o-l,d=a-l,u=e/(2*l),p=(s-c)*u,f=(r-d)*u,g=n.createRadialGradient(p,f,h*u,(o-c)*u,(a-d)*u,l*u);ut(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 Fn({source:new $s({resource:i,addressMode:this._wrapMode})});const m=new un;m.scale(1/u,1/u),m.translate(c,d),"local"===this.textureSpace&&m.scale(e,e),this.transform=m}get styleKey(){return this.uid}destroy(){this.texture?.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}};jo.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},jo.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Go=jo;const Uo={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 No{constructor(t,i){this.uid=e("fillPattern"),this.transform=new un,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),i&&(t.source.style.addressModeU=Uo[i].addressModeU,t.source.style.addressModeV=Uo[i].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 zo,Ho;const Vo=t(function(){if(Ho)return zo;Ho=1,zo=function(n){var s=[];return n.replace(e,function(e,n,r){var o=n.toLowerCase();for(r=function(t){var e=t.match(i);return e?e.map(Number):[]}(r),"m"==o&&r.length>2&&(s.push([n].concat(r.splice(0,2))),o="l",n="m"==n?"l":"L");;){if(r.length==t[o])return r.unshift(n),s.push(r);if(r.length<t[o])throw new Error("malformed path data");s.push([n].concat(r.splice(0,t[o])))}}),s};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 zo}());class Wo{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new Wo(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,s=this.y-e;return n*=n,s*=s,n+s<=i}strokeContains(t,e,i,n=.5){if(0===this.radius)return!1;const s=this.x-t,r=this.y-e,o=this.radius,a=(1-n)*i,h=Math.sqrt(s*s+r*r);return h<=o+a&&h>o-(i-a)}getBounds(t){return t||(t=new Sn),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 Zo{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 Zo(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:s,halfHeight:r}=this;if(s<=0||r<=0)return!1;const o=i*(1-n),a=i-o,h=s-a,l=r-a,c=s+o,d=r+o,u=t-this.x,p=e-this.y;return u*u/(h*h)+p*p/(l*l)>1&&u*u/(c*c)+p*p/(d*d)<=1}getBounds(t){return t||(t=new Sn),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}]`}}class Jo{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 s=e[n],r=e[n+1];t+=(e[(n+2)%i]-s)*(e[(n+3)%i]+r)}return t<0}containsPolygon(t){const e=this.getBounds(void 0),i=t.getBounds(void 0);if(!e.containsRect(i))return!1;const n=t.points;for(let t=0;t<n.length;t+=2){const e=n[t],i=n[t+1];if(!this.contains(e,i))return!1}return!0}clone(){const t=this.points.slice(),e=new Jo(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const n=this.points.length/2;for(let s=0,r=n-1;s<n;r=s++){const n=this.points[2*s],o=this.points[2*s+1],a=this.points[2*r],h=this.points[2*r+1];o>e!=h>e&&t<(e-o)/(h-o)*(a-n)+n&&(i=!i)}return i}strokeContains(t,e,i,n=.5){const s=i*i,r=s*(1-n),o=s-r,{points:a}=this,h=a.length-(this.closePath?0:2);for(let i=0;i<h;i+=2){const n=a[i],s=a[i+1],h=a[(i+2)%a.length],l=a[(i+3)%a.length];if(ft(t,e,n,s,h,l)<=(Math.sign((h-n)*(e-s)-(l-s)*(t-n))<0?o:r))return!0}return!1}getBounds(t){t||(t=new Sn);const e=this.points;let i=1/0,n=-1/0,s=1/0,r=-1/0;for(let t=0,o=e.length;t<o;t+=2){const o=e[t],a=e[t+1];i=o<i?o:i,n=o>n?o:n,s=a<s?a:s,r=a>r?a:r}return t.x=i,t.width=n-i,t.y=s,t.height=r-s,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 i(0,"Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return i(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 Xo=(t,e,i,n,s,r,o)=>{const a=t-i,h=e-n,l=Math.sqrt(a*a+h*h);return l>=s-r&&l<=s+o};class Yo{constructor(t=0,e=0,i=0,n=0,s=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=n,this.radius=s}getBounds(t){return t||(t=new Sn),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Yo(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),s=e-(this.y+i);const r=i*i;if(n*n+s*s<=r)return!0;if(n=t-(this.x+this.width-i),n*n+s*s<=r)return!0;if(s=e-(this.y+this.height-i),n*n+s*s<=r)return!0;if(n=t-(this.x+i),n*n+s*s<=r)return!0}return!1}strokeContains(t,e,i,n=.5){const{x:s,y:r,width:o,height:a,radius:h}=this,l=i*(1-n),c=i-l,d=s+h,u=r+h,p=s+o,f=r+a;return(t>=s-l&&t<=s+c||t>=p-c&&t<=p+l)&&e>=u&&e<=u+(a-2*h)||(e>=r-l&&e<=r+c||e>=f-c&&e<=f+l)&&t>=d&&t<=d+(o-2*h)||t<d&&e<u&&Xo(t,e,d,u,h,c,l)||t>p-h&&e<u&&Xo(t,e,p-h,u,h,c,l)||t>p-h&&e>f-h&&Xo(t,e,p-h,f-h,h,c,l)||t<d&&e>f-h&&Xo(t,e,d,f-h,h,c,l)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const Ko={};class qo{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`)}}}const Qo={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var $o=(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))($o||{});const ta=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join("\n");let ea=null;class ia{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 na{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new ia,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const sa=[];let ra=0,oa=0;const aa=class t{constructor(n){this.uid=e("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],(n={...t.defaultOptions,...n}).maxTextures||(i(0,"maxTextures is a required option for Batcher now, please pass it in the options"),n.maxTextures=function(){if(ea)return ea;const t=B();return ea=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),ea=bt(ea,t),t.getExtension("WEBGL_lose_context")?.loseContext(),ea}());const{maxTextures:s,attributesInitialSize:r,indicesInitialSize:o}=n;this.attributeBuffer=new qo(4*r),this.indexBuffer=new Uint16Array(o),this.maxTextures=s}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)vt(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=_t(),n=i.textures;n.clear();const s=e[this.elementStart];let r=yt(s.blendMode,s.texture._source),o=s.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,h=this.attributeBuffer.uint32View,l=this.indexBuffer;let c=this._batchIndexSize,d=this._batchIndexStart,u="startBatch";const p=this.maxTextures;for(let s=this.elementStart;s<this.elementSize;++s){const f=e[s];e[s]=null;const g=f.texture._source,m=yt(f.blendMode,g),y=r!==m||o!==f.topology;g._batchTick!==oa||y?(g._batchTick=oa,(n.count>=p||y)&&(this._finishBatch(i,d,c-d,n,r,o,t,u),u="renderBatch",d=c,r=m,o=f.topology,i=_t(),n=i.textures,n.clear(),++oa),f._textureId=g._textureBindLocation=n.count,n.ids[g.uid]=n.count,n.textures[n.count++]=g,f._batch=i,c+=f.indexSize,f.packAsQuad?(this.packQuadAttributes(f,a,h,f._attributeStart,f._textureId),this.packQuadIndex(l,f._indexStart,f._attributeStart/this.vertexSize)):(this.packAttributes(f,a,h,f._attributeStart,f._textureId),this.packIndex(f,l,f._indexStart,f._attributeStart/this.vertexSize))):(f._textureId=g._textureBindLocation,c+=f.indexSize,f.packAsQuad?(this.packQuadAttributes(f,a,h,f._attributeStart,f._textureId),this.packQuadIndex(l,f._indexStart,f._attributeStart/this.vertexSize)):(this.packAttributes(f,a,h,f._attributeStart,f._textureId),this.packIndex(f,l,f._indexStart,f._attributeStart/this.vertexSize)),f._batch=i)}n.count>0&&(this._finishBatch(i,d,c-d,n,r,o,t,u),d=c,++oa),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=c}_finishBatch(t,e,i,n,s,r,o,a){t.gpuBindGroup=null,t.bindGroup=null,t.action=a,t.batcher=this,t.textures=n,t.blendMode=s,t.topology=r,t.start=e,t.size=i,++oa,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 qo(e);mt(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 t=0;t<e.length;t++)n[t]=e[t];else mt(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 s=t.indices,r=t.indexSize,o=t.indexOffset,a=t.attributeOffset;for(let t=0;t<r;t++)e[i++]=n+s[t+o]-a}destroy(){for(let t=0;t<this.batches.length;t++)vt(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}};aa.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let ha=aa;var la=(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))(la||{});let ca=class extends on{constructor(t){let{data:i,size:n}=t;const{usage:s,label:r,shrinkToFit:o}=t;super(),this.uid=e("buffer"),this._resourceType="buffer",this._resourceId=e("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,i instanceof Array&&(i=new Float32Array(i)),this._data=i,n??(n=i?.byteLength);const a=!!i;this.descriptor={size:n,usage:s,mappedAtCreation:a,label:r},this.shrinkToFit=o??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&la.STATIC)}set static(t){t?this.descriptor.usage|=la.STATIC:this.descriptor.usage&=~la.STATIC}setDataWithSize(t,i,n){if(this._updateID++,this._updateSize=i*t.BYTES_PER_ELEMENT,this._data===t)return void(n&&this.emit("update",this));const s=this._data;this._data=t,this._dataInt32=null,s&&s.length===t.length||!this.shrinkToFit&&s&&t.byteLength<s.byteLength?n&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=e("resource"),this.emit("change",this))}update(t){this._updateSize=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()}};class da extends on{constructor(t={}){super(),this.uid=e("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new jn,this._boundsDirty=!0;const{attributes:i,indexBuffer:n,topology:s}=t;if(this.buffers=[],this.attributes={},i)for(const t in i)this.addAttribute(t,i[t]);this.instanceCount=t.instanceCount??1,n&&this.addIndex(n),this.topology=s||"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 ca||Array.isArray(t)||t.BYTES_PER_ELEMENT)&&(t={buffer:t}),t.buffer=wt(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=wt(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,function(t,e,i){const n=t.getAttribute("aPosition");if(!n)return i.minX=0,i.minY=0,i.maxX=0,i.maxY=0,i;const s=n.buffer.data;let r=1/0,o=1/0,a=-1/0,h=-1/0;const l=s.BYTES_PER_ELEMENT,c=(n.offset||0)/l,d=(n.stride||8)/l;for(let t=c;t<s.length;t+=d){const e=s[t],i=s[t+1];e>a&&(a=e),i>h&&(h=i),e<r&&(r=e),i<o&&(o=i)}return i.minX=r,i.minY=o,i.maxX=a,i.maxY=h,i}(this,0,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 ua=new Float32Array(1),pa=new Uint32Array(1);class fa extends da{constructor(){const t=new ca({data:ua,label:"attribute-batch-buffer",usage:la.VERTEX|la.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 ca({data:pa,label:"index-batch-buffer",usage:la.INDEX|la.COPY_DST,shrinkToFit:!1})})}}const ga=/\{\{(.*?)\}\}/g,ma=Object.create(null),ya=new Map;let xa=0;const ba={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 "}},_a={name:"global-uniforms-bit",vertex:{header:"\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform vec4 uWorldColorAlpha;\n uniform vec2 uResolution;\n "}},va={name:"color-bit",vertex:{header:"\n @in aColor: vec4<f32>;\n ",main:"\n vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);\n "}},wa={name:"color-bit",vertex:{header:"\n in vec4 aColor;\n ",main:"\n vColor *= vec4(aColor.rgb * aColor.a, aColor.a);\n "}},Ca={},Sa={},Ia={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 "}},Aa={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 "}},Ma={};class Ta extends ao{constructor(t){super({glProgram:kt({name:"batch",bits:[wa,jt(t),Aa]}),gpuProgram:Ot({name:"batch",bits:[va,Ft(t),Ia]}),resources:{batchSamplers:Gt(t)}})}}let Pa=null;const Ea=class t extends ha{constructor(e){super(e),this.geometry=new fa,this.name=t.extension.name,this.vertexSize=6,Pa??(Pa=new Ta(e.maxTextures)),this.shader=Pa}packAttributes(t,e,i,n,s){const r=s<<16|65535&t.roundPixels,o=t.transform,a=o.a,h=o.b,l=o.c,c=o.d,d=o.tx,u=o.ty,{positions:p,uvs:f}=t,g=t.color,m=t.attributeOffset,y=m+t.attributeSize;for(let t=m;t<y;t++){const s=2*t,o=p[s],m=p[s+1];e[n++]=a*o+l*m+d,e[n++]=c*m+h*o+u,e[n++]=f[s],e[n++]=f[s+1],i[n++]=g,i[n++]=r}}packQuadAttributes(t,e,i,n,s){const r=t.texture,o=t.transform,a=o.a,h=o.b,l=o.c,c=o.d,d=o.tx,u=o.ty,p=t.bounds,f=p.maxX,g=p.minX,m=p.maxY,y=p.minY,x=r.uvs,b=t.color,_=s<<16|65535&t.roundPixels;e[n+0]=a*g+l*y+d,e[n+1]=c*y+h*g+u,e[n+2]=x.x0,e[n+3]=x.y0,i[n+4]=b,i[n+5]=_,e[n+6]=a*f+l*y+d,e[n+7]=c*y+h*f+u,e[n+8]=x.x1,e[n+9]=x.y1,i[n+10]=b,i[n+11]=_,e[n+12]=a*f+l*m+d,e[n+13]=c*m+h*f+u,e[n+14]=x.x2,e[n+15]=x.y2,i[n+16]=b,i[n+17]=_,e[n+18]=a*g+l*m+d,e[n+19]=c*m+h*g+u,e[n+20]=x.x3,e[n+21]=x.y3,i[n+22]=b,i[n+23]=_}};Ea.extension={type:[Ki.Batcher],name:"default"};let Ba=Ea;const Oa=new un;class ka{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?u(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(255*this.alpha<<24)}get transform(){return this.renderable?.groupTransform||Oa}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 Ra={extension:{type:Ki.ShapeBuilder,name:"circle"},build(t,e){let i,n,s,r,o,a;if("circle"===t.type){const e=t;if(o=a=e.radius,o<=0)return!1;i=e.x,n=e.y,s=r=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,s=r=0}else{const e=t,h=e.width/2,l=e.height/2;i=e.x+h,n=e.y+l,o=a=Math.max(0,Math.min(e.radius,Math.min(h,l))),s=h-o,r=l-a}if(s<0||r<0)return!1;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=8*h+(s?4:0)+(r?4:0);if(0===l)return!1;if(0===h)return e[0]=e[6]=i+s,e[1]=e[3]=n+r,e[2]=e[4]=i-s,e[5]=e[7]=n-r,!0;let c=0,d=4*h+(s?2:0)+2,u=d,p=l,f=s+o,g=r,m=i+f,y=i-f,x=n+g;if(e[c++]=m,e[c++]=x,e[--d]=x,e[--d]=y,r){const t=n-g;e[u++]=y,e[u++]=t,e[--p]=t,e[--p]=m}for(let t=1;t<h;t++){const l=Math.PI/2*(t/h),f=s+Math.cos(l)*o,g=r+Math.sin(l)*a,m=i+f,y=i-f,x=n+g,b=n-g;e[c++]=m,e[c++]=x,e[--d]=x,e[--d]=y,e[u++]=y,e[u++]=b,e[--p]=b,e[--p]=m}f=s,g=r+a,m=i+f,y=i-f,x=n+g;const b=n-g;return e[c++]=m,e[c++]=x,e[--p]=b,e[--p]=m,s&&(e[c++]=y,e[c++]=x,e[--p]=b,e[--p]=y),!0},triangulate(t,e,i,n,s,r){if(0===t.length)return;let o=0,a=0;for(let e=0;e<t.length;e+=2)o+=t[e],a+=t[e+1];o/=t.length/2,a/=t.length/2;let h=n;e[h*i]=o,e[h*i+1]=a;const l=h++;for(let n=0;n<t.length;n+=2)e[h*i]=t[n],e[h*i+1]=t[n+1],n>0&&(s[r++]=h,s[r++]=l,s[r++]=h-1),h++;s[r++]=l+1,s[r++]=l,s[r++]=h-1}},Da={...Ra,extension:{...Ra.extension,name:"ellipse"}},Fa={...Ra,extension:{...Ra.extension,name:"roundedRectangle"}},La=1e-4,ja=[],Ga={extension:{type:Ki.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,s,r){Ht(t,ja,e,i,n,s,r)}},Ua={extension:{type:Ki.ShapeBuilder,name:"rectangle"},build(t,e){const i=t,n=i.x,s=i.y,r=i.width,o=i.height;return r>0&&o>0&&(e[0]=n,e[1]=s,e[2]=n+r,e[3]=s,e[4]=n+r,e[5]=s+o,e[6]=n,e[7]=s+o,!0)},triangulate(t,e,i,n,s,r){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;s[r++]=a,s[r++]=a+1,s[r++]=a+2,s[r++]=a+1,s[r++]=a+3,s[r++]=a+2}},Na={extension:{type:Ki.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,s,r){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;s[r++]=a,s[r++]=a+1,s[r++]=a+2}},za=new un,Ha=new Sn,Va={};$i.handleByMap(Ki.ShapeBuilder,Va),$i.add(Ua,Ga,Na,Ra,Da,Fa);const Wa=new Sn,Za=new un;class Ja{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class Xa{constructor(){this.instructions=new Ds}init(t){this.batcher=new Ba({maxTextures:t}),this.instructions.reset()}get geometry(){return i(0,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}}const Ya=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){t.defaultOptions.bezierSmoothness=e?.bezierSmoothness??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 e=0;e<t.instructions.length;e++){const s=t.instructions[e];if("texture"===s.action)Vt(s.data,n,i);else if("fill"===s.action||"stroke"===s.action){const t="stroke"===s.action,e=s.data.path.shapePath,r=s.data.style,o=s.data.hole;t&&o&&Wt(o.shapePath,r,!0,n,i),o&&(e.shapePrimitives[e.shapePrimitives.length-1].holes=o.shapePath.shapePrimitives),Wt(e,r,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=ms.get(Xa,{maxTextures:this._renderer.limits.maxBatchableTextures}),{batches:i,geometryData:n}=this._gpuContextHash[t.uid],s=n.vertices.length,r=n.indices.length;for(let t=0;t<i.length;t++)i[t].applyTransform=!1;const o=e.batcher;o.ensureAttributeBuffer(s),o.ensureIndexBuffer(r),o.begin();for(let t=0;t<i.length;t++){const e=i[t];o.add(e)}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 h=o.batches;for(let t=0;t<h.length;t++){const e=h[t];e.bindGroup=gt(e.textures.textures,e.textures.count,this._renderer.limits.maxBatchableTextures)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new Ja;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]&&(ms.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(t=>{ms.return(t)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};Ya.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"graphicsContext"},Ya.defaultOptions={bezierSmoothness:.5};let Ka=Ya;const qa=1.1920929e-7,Qa=2*Math.PI,$a={centerX:0,centerY:0,ang1:0,ang2:0},th=({x:t,y:e},i,n,s,r,o,a,h)=>{const l=s*(t*=i)-r*(e*=n),c=r*t+s*e;return h.x=l+o,h.y=c+a,h},eh=(t,e,i,n)=>{let s=t*i+e*n;return s>1&&(s=1),s<-1&&(s=-1),(t*n-e*i<0?-1:1)*Math.acos(s)},ih=new Sn;class nh{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new jn,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],s=i[i.length-1];return n===t&&s===e||i.push(t,e),this}arc(t,e,i,n,s,r){return this._ensurePoly(!1),Kt(this._currentPoly.points,t,e,i,n,s,r),this}arcTo(t,e,i,n,s){return this._ensurePoly(),function(t,e,i,n,s,r){const o=t[t.length-2],a=t[t.length-1]-i,h=o-e,l=s-i,c=n-e,d=Math.abs(a*c-h*l);if(d<1e-8||0===r)return void(t[t.length-2]===e&&t[t.length-1]===i||t.push(e,i));const u=a*a+h*h,p=l*l+c*c,f=a*l+h*c,g=r*Math.sqrt(u)/d,m=r*Math.sqrt(p)/d,y=g*f/u,x=m*f/p,b=g*c+m*h,_=g*l+m*a,v=h*(m+y),w=a*(m+y),C=c*(g+x),S=l*(g+x);Kt(t,b+e,_+i,r,Math.atan2(w-_,v-b),Math.atan2(S-_,C-b),h*l>c*a)}(this._currentPoly.points,t,e,i,n,s),this}arcToSvg(t,e,i,n,s,r,o){return function(t,e,i,n,s,r,o,a=0,h=0,l=0){if(0===r||0===o)return;const c=Math.sin(a*Qa/360),d=Math.cos(a*Qa/360),u=d*(e-n)/2+c*(i-s)/2,p=-c*(e-n)/2+d*(i-s)/2;if(0===u&&0===p)return;r=Math.abs(r),o=Math.abs(o);const f=Math.pow(u,2)/Math.pow(r,2)+Math.pow(p,2)/Math.pow(o,2);f>1&&(r*=Math.sqrt(f),o*=Math.sqrt(f)),((t,e,i,n,s,r,o,a,h,l,c,d,u)=>{const p=Math.pow(s,2),f=Math.pow(r,2),g=Math.pow(c,2),m=Math.pow(d,2);let y=p*f-p*m-f*g;y<0&&(y=0),y/=p*m+f*g,y=Math.sqrt(y)*(o===a?-1:1);const x=y*s/r*d,b=y*-r/s*c,_=l*x-h*b+(t+i)/2,v=h*x+l*b+(e+n)/2,w=(c-x)/s,C=(d-b)/r,S=(-c-x)/s,I=(-d-b)/r,A=eh(1,0,w,C);let M=eh(w,C,S,I);0===a&&M>0&&(M-=Qa),1===a&&M<0&&(M+=Qa),u.centerX=_,u.centerY=v,u.ang1=A,u.ang2=M})(e,i,n,s,r,o,h,l,c,d,u,p,$a);let{ang1:g,ang2:m}=$a;const{centerX:y,centerY:x}=$a;let b=Math.abs(m)/(Qa/4);Math.abs(1-b)<1e-7&&(b=1);const _=Math.max(Math.ceil(b),1);m/=_;let v=t[t.length-2],w=t[t.length-1];const C={x:0,y:0};for(let e=0;e<_;e++){const e=qt(g,m),{x:i,y:n}=th(e[0],r,o,d,c,y,x,C),{x:s,y:a}=th(e[1],r,o,d,c,y,x,C),{x:h,y:l}=th(e[2],r,o,d,c,y,x,C);Zt(t,v,w,i,n,s,a,h,l),v=h,w=l,g+=m}}(this._currentPoly.points,this._currentPoly.lastX,this._currentPoly.lastY,r,o,t,e,i,n,s),this}bezierCurveTo(t,e,i,n,s,r,o){this._ensurePoly();const a=this._currentPoly;return Zt(this._currentPoly.points,a.lastX,a.lastY,t,e,i,n,s,r,o),this}quadraticCurveTo(t,e,i,n,s){this._ensurePoly();const r=this._currentPoly;return Xt(this._currentPoly.points,r.lastX,r.lastY,t,e,i,n,s),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 e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.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 s=n.shape,r=t?.shape;r&&r.containsPolygon(s)?(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,s){return this.drawShape(new Sn(t,e,i,n),s),this}circle(t,e,i,n){return this.drawShape(new Wo(t,e,i),n),this}poly(t,e,i){const n=new Jo(t);return n.closePath=e,this.drawShape(n,i),this}regularPoly(t,e,i,n,s=0,r){n=Math.max(0|n,3);const o=-1*Math.PI/2+s,a=2*Math.PI/n,h=[];for(let s=0;s<n;s++){const n=o-s*a;h.push(t+i*Math.cos(n),e+i*Math.sin(n))}return this.poly(h,!0,r),this}roundPoly(t,e,i,n,s,r=0,o){if(n=Math.max(0|n,3),s<=0)return this.regularPoly(t,e,i,n,r);const a=i*Math.sin(Math.PI/n)-.001;s=Math.min(s,a);const h=-1*Math.PI/2+r,l=2*Math.PI/n,c=(n-2)*Math.PI/n/2;for(let r=0;r<n;r++){const n=r*l+h,a=t+i*Math.cos(n),d=e+i*Math.sin(n),u=n+Math.PI+c,p=n-Math.PI-c,f=a+s*Math.cos(u),g=d+s*Math.sin(u),m=a+s*Math.cos(p),y=d+s*Math.sin(p);0===r?this.moveTo(f,g):this.lineTo(f,g),this.quadraticCurveTo(a,d,m,y,o)}return this.closePath()}roundShape(t,e,i=!1,n){return t.length<3?this:(i?function(t,e,i,n){const s=(t,e)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),r=(t,e,i)=>({x:t.x+(e.x-t.x)*i,y:t.y+(e.y-t.y)*i}),o=e.length;for(let a=0;a<o;a++){const h=e[(a+1)%o],l=h.radius??i;if(l<=0){0===a?t.moveTo(h.x,h.y):t.lineTo(h.x,h.y);continue}const c=e[a],d=e[(a+2)%o],u=s(c,h);let p;p=u<1e-4?h:r(h,c,Math.min(u/2,l)/u);const f=s(d,h);let g;g=f<1e-4?h:r(h,d,Math.min(f/2,l)/f),0===a?t.moveTo(p.x,p.y):t.lineTo(p.x,p.y),t.quadraticCurveTo(h.x,h.y,g.x,g.y,n)}}(this,t,e,n):function(t,e,i){const n=(t,e)=>{const i=e.x-t.x,n=e.y-t.y,s=Math.sqrt(i*i+n*n);return{len:s,nx:i/s,ny:n/s}},s=(e,i)=>{0===e?t.moveTo(i.x,i.y):t.lineTo(i.x,i.y)};let r=e[e.length-1];for(let o=0;o<e.length;o++){const a=e[o%e.length],h=a.radius??i;if(h<=0){s(o,a),r=a;continue}const l=e[(o+1)%e.length],c=n(a,r),d=n(a,l);if(c.len<1e-4||d.len<1e-4){s(o,a),r=a;continue}let u=Math.asin(c.nx*d.ny-c.ny*d.nx),p=1,f=!1;c.nx*d.nx-c.ny*-d.ny<0?u<0?u=Math.PI+u:(u=Math.PI-u,p=-1,f=!0):u>0&&(p=-1,f=!0);const g=u/2;let m,y=Math.abs(Math.cos(g)*h/Math.sin(g));y>Math.min(c.len/2,d.len/2)?(y=Math.min(c.len/2,d.len/2),m=Math.abs(y*Math.sin(g)/Math.cos(g))):m=h;const x=a.x+d.nx*y+-d.ny*m*p,b=a.y+d.ny*y+d.nx*m*p,_=Math.atan2(c.ny,c.nx)+Math.PI/2*p,v=Math.atan2(d.ny,d.nx)-Math.PI/2*p;0===o&&t.moveTo(x+Math.cos(_)*m,b+Math.sin(_)*m),t.arc(x,b,m,_,v,f),r=a}}(this,t,e),this.closePath())}filletRect(t,e,i,n,s){if(0===s)return this.rect(t,e,i,n);const r=Math.min(i,n)/2,o=Math.min(r,Math.max(-r,s)),a=t+i,h=e+n,l=o<0?-o:0,c=Math.abs(o);return this.moveTo(t,e+c).arcTo(t+l,e+l,t+c,e,c).lineTo(a-c,e).arcTo(a-l,e+l,a,e+c,c).lineTo(a,h-c).arcTo(a-l,h-l,t+i-c,h,c).lineTo(t+c,h).arcTo(t+l,h-l,t,h-c,c).closePath()}chamferRect(t,e,i,n,s,r){if(s<=0)return this.rect(t,e,i,n);const o=Math.min(s,Math.min(i,n)/2),a=t+i,h=e+n,l=[t+o,e,a-o,e,a,e+o,a,h-o,a-o,h,t+o,h,t,h-o,t,e+o];for(let t=l.length-1;t>=2;t-=2)l[t]===l[t-2]&&l[t-1]===l[t-3]&&l.splice(t-1,2);return this.poly(l,!0,r)}ellipse(t,e,i,n,s){return this.drawShape(new Zo(t,e,i,n),s),this}roundRect(t,e,i,n,s,r){return this.drawShape(new Yo(t,e,i,n,s),r),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 Jo,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 Jo,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,s=e;e=n.a*e+n.c*i+n.tx,i=n.b*s+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],s=n.shape.getBounds(ih);n.transform?t.addRect(s,n.transform):t.addRect(s)}return t}}class sh{constructor(t,i=!1){this.instructions=[],this.uid=e("graphicsPath"),this._dirty=!0,this.checkForHoles=i,"string"==typeof t?function(t,e){const i=Vo(t),n=[];let s=null,r=0,o=0;for(let t=0;t<i.length;t++){const h=i[t],l=h[0],c=h;switch(l){case"M":r=c[1],o=c[2],e.moveTo(r,o);break;case"m":r+=c[1],o+=c[2],e.moveTo(r,o);break;case"H":r=c[1],e.lineTo(r,o);break;case"h":r+=c[1],e.lineTo(r,o);break;case"V":o=c[1],e.lineTo(r,o);break;case"v":o+=c[1],e.lineTo(r,o);break;case"L":r=c[1],o=c[2],e.lineTo(r,o);break;case"l":r+=c[1],o+=c[2],e.lineTo(r,o);break;case"C":r=c[5],o=c[6],e.bezierCurveTo(c[1],c[2],c[3],c[4],r,o);break;case"c":e.bezierCurveTo(r+c[1],o+c[2],r+c[3],o+c[4],r+c[5],o+c[6]),r+=c[5],o+=c[6];break;case"S":r=c[3],o=c[4],e.bezierCurveToShort(c[1],c[2],r,o);break;case"s":e.bezierCurveToShort(r+c[1],o+c[2],r+c[3],o+c[4]),r+=c[3],o+=c[4];break;case"Q":r=c[3],o=c[4],e.quadraticCurveTo(c[1],c[2],r,o);break;case"q":e.quadraticCurveTo(r+c[1],o+c[2],r+c[3],o+c[4]),r+=c[3],o+=c[4];break;case"T":r=c[1],o=c[2],e.quadraticCurveToShort(r,o);break;case"t":r+=c[1],o+=c[2],e.quadraticCurveToShort(r,o);break;case"A":r=c[6],o=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,o);break;case"a":r+=c[6],o+=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,o);break;case"Z":case"z":e.closePath(),n.length>0&&(s=n.pop(),s?(r=s.startX,o=s.startY):(r=0,o=0)),s=null;break;default:a()}"Z"!==l&&"z"!==l&&null===s&&(s={startX:r,startY:o},n.push(s))}}(t,this):this.instructions=t?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new nh(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,s){const r=this.instructions[this.instructions.length-1],o=this.getLastPoint(cn.shared);let a=0,h=0;if(r&&"bezierCurveTo"===r.action){a=r.data[2],h=r.data[3];const t=o.x,e=o.y;a=t+(t-a),h=e+(e-h)}else a=o.x,h=o.y;return this.instructions.push({action:"bezierCurveTo",data:[a,h,t,e,i,n,s]}),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],s=this.getLastPoint(cn.shared);let r=0,o=0;if(n&&"quadraticCurveTo"===n.action){r=n.data[0],o=n.data[1];const t=s.x,e=s.y;r=t+(t-r),o=e+(e-o)}else r=s.x,o=s.y;return this.instructions.push({action:"quadraticCurveTo",data:[r,o,t,e,i]}),this._dirty=!0,this}rect(t,e,i,n,s){return this.instructions.push({action:"rect",data:[t,e,i,n,s]}),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,s,r,o){s||(s=n/2);const a=-1*Math.PI/2+r,h=2*i,l=2*Math.PI/h,c=[];for(let i=0;i<h;i++){const r=i%2?s:n,o=i*l+a;c.push(t+r*Math.cos(o),e+r*Math.sin(o))}return this.poly(c,!0,o),this}clone(t=!1){const e=new sh;if(e.checkForHoles=this.checkForHoles,t)for(let t=0;t<this.instructions.length;t++){const i=this.instructions[t];e.instructions.push({action:i.action,data:i.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,s=t.d,r=t.tx,o=t.ty;let h=0,l=0,c=0,d=0,u=0,p=0,f=0,g=0;for(let m=0;m<this.instructions.length;m++){const y=this.instructions[m],x=y.data;switch(y.action){case"moveTo":case"lineTo":h=x[0],l=x[1],x[0]=e*h+n*l+r,x[1]=i*h+s*l+o;break;case"bezierCurveTo":c=x[0],d=x[1],u=x[2],p=x[3],h=x[4],l=x[5],x[0]=e*c+n*d+r,x[1]=i*c+s*d+o,x[2]=e*u+n*p+r,x[3]=i*u+s*p+o,x[4]=e*h+n*l+r,x[5]=i*h+s*l+o;break;case"quadraticCurveTo":c=x[0],d=x[1],h=x[2],l=x[3],x[0]=e*c+n*d+r,x[1]=i*c+s*d+o,x[2]=e*h+n*l+r,x[3]=i*h+s*l+o;break;case"arcToSvg":h=x[5],l=x[6],f=x[0],g=x[1],x[0]=e*f+n*g,x[1]=i*f+s*g,x[5]=e*h+n*l+r,x[6]=i*h+s*l+o;break;case"circle":x[4]=Qt(x[3],t);break;case"rect":x[4]=Qt(x[4],t);break;case"ellipse":x[8]=Qt(x[8],t);break;case"roundRect":x[5]=Qt(x[5],t);break;case"addPath":x[0].transform(t);break;case"poly":x[2]=Qt(x[2],t);break;default:a(y.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}}const rh={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}},oh=new cn,ah=new un,hh=class t extends on{constructor(){super(...arguments),this.uid=e("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new sh,this._transform=new un,this._fillStyle={...t.defaultFillStyle},this._strokeStyle={...t.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new jn,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={...this._fillStyle},e._strokeStyle={...this._strokeStyle},e._stateStack=this._stateStack.slice(),e._bounds=this._bounds.clone(),e._boundsDirty=!0,e}get fillStyle(){return this._fillStyle}set fillStyle(e){this._fillStyle=ce(e,t.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=de(e,t.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=ce(e,t.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=ce(e,t.defaultStrokeStyle),this}texture(t,e,i,n,s,r){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:n||0,dw:s||t.frame.width,dh:r||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?ps.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new sh,this}fill(e,n){let s;const r=this.instructions[this.instructions.length-1];return s=0===this._tick&&r&&"stroke"===r.action?r.data.path:this._activePath.clone(),s?(null!=e&&(void 0!==n&&"number"==typeof e&&(i(0,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:n}),this._fillStyle=ce(e,t.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(cn.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=de(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,s,r){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,s,r),this}arcTo(t,e,i,n,s){this._tick++;const r=this._transform;return this._activePath.arcTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty,r.a*i+r.c*n+r.tx,r.b*i+r.d*n+r.ty,s),this}arcToSvg(t,e,i,n,s,r,o){this._tick++;const a=this._transform;return this._activePath.arcToSvg(t,e,i,n,s,a.a*r+a.c*o+a.tx,a.b*r+a.d*o+a.ty),this}bezierCurveTo(t,e,i,n,s,r,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*s+a.c*r+a.tx,a.b*s+a.d*r+a.ty,o),this}closePath(){return this._tick++,this._activePath?.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,s=i.a*t+i.c*e+i.tx,r=i.b*t+i.d*e+i.ty;return 1===n.length&&"moveTo"===n[0].action?(n[0].data[0]=s,n[0].data[1]=r,this):(this._activePath.moveTo(s,r),this)}quadraticCurveTo(t,e,i,n,s){this._tick++;const r=this._transform;return this._activePath.quadraticCurveTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty,r.a*i+r.c*n+r.tx,r.b*i+r.d*n+r.ty,s),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,s){return this._tick++,this._activePath.roundRect(t,e,i,n,s,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,n,s=0,r){return this._tick++,this._activePath.regularPoly(t,e,i,n,s,r),this}roundPoly(t,e,i,n,s,r){return this._tick++,this._activePath.roundPoly(t,e,i,n,s,r),this}roundShape(t,e,i,n){return this._tick++,this._activePath.roundShape(t,e,i,n),this}filletRect(t,e,i,n,s){return this._tick++,this._activePath.filletRect(t,e,i,n,s),this}chamferRect(t,e,i,n,s,r){return this._tick++,this._activePath.chamferRect(t,e,i,n,s,r),this}star(t,e,i,n,s=0,r=0){return this._tick++,this._activePath.star(t,e,i,n,s,r,this._transform.clone()),this}svg(t){return this._tick++,function(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 sh};!function(t,e){const i=t.querySelectorAll("defs");for(let t=0;t<i.length;t++){const n=i[t];for(let t=0;t<n.children.length;t++){const i=n.children[t];switch(i.nodeName.toLowerCase()){case"lineargradient":e.defs[i.id]=te(i);break;case"radialgradient":e.defs[i.id]=ee()}}}}(t,i);const n=t.children,{fillStyle:s,strokeStyle:r}=ne(t,i);for(let t=0;t<n.length;t++){const e=n[t];"defs"!==e.nodeName.toLowerCase()&&re(e,i,s,r)}}(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,n,s,r){return t instanceof un?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,n,s,r),this)}transform(t,e,i,n,s,r){return t instanceof un?(this._transform.append(t),this):(ah.set(t,e,i,n,s,r),this._transform.append(ah),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,s=e.style.width*(1-n),r=e.path.bounds;t.addFrame(r.minX-s,r.minY-s,r.maxX+s,r.maxY+s)}}return t}containsPoint(t){if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let i=!1;for(let n=0;n<e.length;n++){const s=e[n],r=s.data,o=r.path;if(!s.action||!o)continue;const a=r.style,h=o.shapePath.shapePrimitives;for(let e=0;e<h.length;e++){const n=h[e].shape;if(!a||!n)continue;const o=h[e].transform,l=o?o.applyInverse(t,oh):t;if("fill"===s.action)i=n.contains(l.x,l.y);else{const t=a;i=n.strokeContains(l.x,l.y,t.width,t.alignment)}const c=r.hole;if(c){const t=c.shapePath?.shapePrimitives;if(t)for(let e=0;e<t.length;e++)t[e].shape.contains(l.x,l.y)&&(i=!1)}if(i)return!0}}return i}destroy(t=!1){if(this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t: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}};hh.defaultFillStyle={color:16777215,alpha:1,texture:Fn.WHITE,matrix:null,fill:null,textureSpace:"local"},hh.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:Fn.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let lh=hh;const ch=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"],dh=class t extends on{constructor(e={}){super(),function(t){const e=t;if("boolean"==typeof e.dropShadow&&e.dropShadow){const i=uh.defaultDropShadow;t.dropShadow={alpha:e.dropShadowAlpha??i.alpha,angle:e.dropShadowAngle??i.angle,blur:e.dropShadowBlur??i.blur,color:e.dropShadowColor??i.color,distance:e.dropShadowDistance??i.distance}}if(void 0!==e.strokeThickness){i(0,"strokeThickness is now a part of stroke");const n=e.stroke;let s={};if(ps.isColorLike(n))s.color=n;else if(n instanceof Go||n instanceof No)s.fill=n;else{if(!Object.hasOwnProperty.call(n,"color")&&!Object.hasOwnProperty.call(n,"fill"))throw new Error("Invalid stroke value.");s=n}t.stroke={...s,width:e.strokeThickness}}if(Array.isArray(e.fillGradientStops)){if(i(0,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(e.fill)||0===e.fill.length)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");e.fill.length!==e.fillGradientStops.length&&a();const n=new Go({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),s=e.fillGradientStops.slice(),r=e.fill.map(t=>ps.shared.setValue(t).toNumber());s.forEach((t,e)=>{n.addColorStop(t,r[e])}),t.fill={fill:n}}}(e);const n={...t.defaultTextStyle,...e};for(const t in n)this[t]=n[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({...t.defaultDropShadow,...e}):e?this._createProxy({...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({...lh.defaultFillStyle,...t},()=>{this._fill=ce({...this._originalFill},lh.defaultFillStyle)})),this._fill=ce(0===t?"black":t,lh.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...lh.defaultStrokeStyle,...t},()=>{this._stroke=de({...this._originalStroke},lh.defaultStrokeStyle)})),this._stroke=de(t,lh.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=function(t){const e=[];let i=0;for(let n=0;n<ch.length;n++){const s=`_${ch[n]}`;e[i++]=t[s]}return i=ue(t._fill,e,i),i=function(t,e,i){return t?(i=ue(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++]=ps.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("-")}(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?{...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){if(this.removeAllListeners(),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._fill?.texture&&this._fill.texture.destroy(e),this._originalFill?.texture&&this._originalFill.texture.destroy(e),this._stroke?.texture&&this._stroke.texture.destroy(e),this._originalStroke?.texture&&this._originalStroke.texture.destroy(e)}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,e?.(i,n),this.update(),!0)})}_isFillStyle(t){return null!==(t??null)&&!(ps.isColorLike(t)||t instanceof Go||t instanceof No)}};dh.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},dh.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 uh=dh;const ph=new class{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=qs.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 s=((t=n(t))<<17)+((e=n(e))<<1);this._canvasPool[s]||(this._canvasPool[s]=[]);let r=this._canvasPool[s].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:n}=e,s=(i<<17)+(n<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,n),this._canvasPool[s].push(t)}clear(){this._canvasPool={}}},fh=1e5,gh=class t extends Oo{constructor(e){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 i={...t.defaultOptions,...e};this._textureSize=i.textureSize,this._mipmap=i.mipmap;const n=i.style.clone();i.overrideFill&&(n._fill.color=16777215,n._fill.alpha=1,n._fill.texture=Fn.WHITE,n._fill.fill=null),this.applyFillAsTint=i.overrideFill;const s=n.fontSize;n.fontSize=this.baseMeasurementFontSize;const r=dt(n);i.overrideSize?n._stroke&&(n._stroke.width*=this.baseRenderedFontSize/s):n.fontSize=this.baseRenderedFontSize=s,this._style=n,this._skipKerning=i.skipKerning??!1,this.resolution=i.resolution??1,this._padding=i.padding??4,i.textureStyle&&(this._textureStyle=i.textureStyle instanceof En?i.textureStyle:new En(i.textureStyle)),this.fontMetrics=Fo.measureFont(r),this.lineHeight=n.lineHeight||this.fontMetrics.fontSize||n.fontSize}ensureCharacters(t){const e=Fo.graphemeSegmenter(t).filter(t=>!this._currentChars.includes(t)).filter((t,e,i)=>i.indexOf(t)===e);if(!e.length)return;let i;this._currentChars=[...this._currentChars,...e],i=-1===this._currentPageIndex?this._nextPage():this.pages[this._currentPageIndex];let{canvas:n,context:s}=i.canvasAndContext,r=i.texture.source;const o=this._style;let a=this._currentX,h=this._currentY,l=this._currentMaxCharHeight;const c=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=this._padding*c;let u=!1;const p=n.width/this.resolution,f=n.height/this.resolution;for(let t=0;t<e.length;t++){const i=e[t],g=Fo.measureText(i,o,n,!1);g.lineHeight=g.height;const m=g.width*c,y=Math.ceil(("italic"===o.fontStyle?2:1)*m)+2*d,x=g.height*c+2*d;if(u=!1,"\n"!==i&&"\r"!==i&&"\t"!==i&&" "!==i&&(u=!0,l=Math.ceil(Math.max(x,l))),a+y>p&&(h+=l,l=x,a=0,h+l>f)){r.update();const t=this._nextPage();n=t.canvasAndContext.canvas,s=t.canvasAndContext.context,r=t.texture.source,a=0,h=0,l=0}const b=m/c-(o.dropShadow?.distance??0)-(o._stroke?.width??0);if(this.chars[i]={id:i.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:b,kerning:{}},u){this._drawGlyph(s,g,a+d,h+d,c,o);const t=r.width*c,e=r.height*c,n=new Sn(a/t*r.width,h/e*r.height,y/t*r.width,x/e*r.height);this.chars[i].texture=new Fn({source:r,frame:n}),a+=Math.ceil(y)}}r.update(),this._currentX=a,this._currentY=h,this._currentMaxCharHeight=l,this._skipKerning&&this._applyKerning(e,s)}get pageTextures(){return i(0,"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 s=t[n];for(let t=0;t<this._currentChars.length;t++){const n=this._currentChars[t];let r=i[s];r||(r=i[s]=e.measureText(s).width);let o=i[n];o||(o=i[n]=e.measureText(n).width);let a=e.measureText(s+n).width,h=a-(r+o);h&&(this.chars[s].kerning[n]=h),a=e.measureText(s+n).width,h=a-(r+o),h&&(this.chars[n].kerning[s]=h)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=ph.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),n=new Fn({source:new $s({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(n.source.style=this._textureStyle);const s={canvasAndContext:e,texture:n};return this.pages[this._currentPageIndex]=s,s}_setupContext(t,e,i){e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=dt(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const n=e._stroke,s=n?.width??0;if(n&&(t.lineWidth=s,t.lineJoin=n.join,t.miterLimit=n.miterLimit,t.strokeStyle=pe(n,t)),e._fill&&(t.fillStyle=pe(e._fill,t)),e.dropShadow){const n=e.dropShadow,s=ps.shared.setValue(n.color).toArray(),r=n.blur*i,o=n.distance*i;t.shadowColor=`rgba(${255*s[0]},${255*s[1]},${255*s[2]},${n.alpha})`,t.shadowBlur=r,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,s,r){const o=e.text,a=e.fontProperties,h=r._stroke,l=(h?.width??0)*s,c=i+l/2,d=n-l/2,u=a.descent*s,p=e.lineHeight*s;let f=!1;r.stroke&&l&&(f=!0,t.strokeText(o,c,d+p-u));const{shadowBlur:g,shadowOffsetX:m,shadowOffsetY:y}=t;r._fill&&(f&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(o,c,d+p-u)),f&&(t.shadowBlur=g,t.shadowOffsetX=m,t.shadowOffsetY=y)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];ph.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}};gh.defaultOptions={textureSize:512,style:new uh,mipmap:!0};let mh=gh,yh=0;const xh=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){let i=`${e.fontFamily}-bitmap`,n=!0;if(e._fill.fill&&!e._stroke)i+=e._fill.fill.styleKey,n=!1;else if(e._stroke||e.dropShadow){let t=e.styleKey;t=t.substring(0,t.lastIndexOf("-")),i=`${t}-bitmap`,n=!1}if(!hr.has(i)){const t=Object.create(e);t.lineHeight=0;const s=new mh({style:t,overrideFill:n,overrideSize:!0,...this.defaultOptions});yh++,yh>50&&a(),s.once("destroy",()=>{yh--,hr.remove(i)}),hr.set(i,s)}const s=hr.get(i);return s.ensureCharacters?.(t),s}getLayout(t,e,i=!0){const n=this.getFont(t,e);return fe(Fo.graphemeSegmenter(t),e,n,i)}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){let e=t[0];"string"==typeof e&&(e={name:e,style:t[1],chars:t[2]?.chars,resolution:t[2]?.resolution,padding:t[2]?.padding,skipKerning:t[2]?.skipKerning},i(0,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const n=e?.name;if(!n)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const s=e.style,r=s instanceof uh?s:new uh(s),o=e.dynamicFill??this._canUseTintForStyle(r),a=new mh({style:r,overrideFill:o,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1,textureStyle:e.textureStyle}),h=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,s=i;n<=s;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}(e.chars);return a.ensureCharacters(h.join("")),hr.set(`${n}-bitmap`,a),a.once("destroy",()=>hr.remove(`${n}-bitmap`)),a}uninstall(t){const e=`${t}-bitmap`,i=hr.get(e);i&&i.destroy()}_canUseTintForStyle(t){return!(t._stroke||t.dropShadow&&0!==t.dropShadow.color||t._fill.fill||16777215!==t._fill.color)}};class bh extends Oo{constructor(t,e){super();const{textures:i,data:n}=t;Object.keys(n.pages).forEach(t=>{const e=n.pages[parseInt(t,10)],s=i[e.id];this.pages.push({texture:s})}),Object.keys(n.chars).forEach(t=>{const e=n.chars[t],{frame:s,source:r,rotate:o}=i[e.page],a=wn.transformRectCoords(e,s,o,new Sn),h=new Fn({frame:a,orig:new Sn(0,0,e.width,e.height),source:r,rotate:o});this.chars[t]={id:t.codePointAt(0),xOffset:e.xOffset,yOffset:e.yOffset,xAdvance:e.xAdvance,kerning:e.kerning??{},texture:h}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=n.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){xh.install(t)}static uninstall(t){xh.uninstall(t)}}const _h={test:t=>"string"==typeof t&&t.startsWith("info face="),parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const t in e){const n=e[t].match(/^[a-z]+/gm)[0],s=e[t].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),r={};for(const t in s){const e=s[t].split("="),i=e[0],n=e[1].replace(/"/gm,""),o=parseFloat(n),a=isNaN(o)?n:o;r[i]=a}i[n].push(r)}const n={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[s]=i.info,[r]=i.common,[o]=i.distanceField??[];o&&(n.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),n.fontSize=parseInt(s.size,10),n.fontFamily=s.face,n.lineHeight=parseInt(r.lineHeight,10);const a=i.page;for(let t=0;t<a.length;t++)n.pages.push({id:parseInt(a[t].id,10)||0,file:a[t].file});const h={};n.baseLineOffset=n.lineHeight-parseInt(r.base,10);const l=i.char;for(let t=0;t<l.length;t++){const e=l[t],i=parseInt(e.id,10);let s=e.letter??e.char??String.fromCharCode(i);"space"===s&&(s=" "),h[i]=s,n.chars[s]={id:i,page:parseInt(e.page,10)||0,x:parseInt(e.x,10),y:parseInt(e.y,10),width:parseInt(e.width,10),height:parseInt(e.height,10),xOffset:parseInt(e.xoffset,10),yOffset:parseInt(e.yoffset,10),xAdvance:parseInt(e.xadvance,10),kerning:{}}}const c=i.kerning||[];for(let t=0;t<c.length;t++){const e=parseInt(c[t].first,10),i=parseInt(c[t].second,10),s=parseInt(c[t].amount,10);n.chars[h[i]].kerning[h[e]]=s}return n}},vh={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){const e={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},i=t.getElementsByTagName("info")[0],n=t.getElementsByTagName("common")[0],s=t.getElementsByTagName("distanceField")[0];s&&(e.distanceField={type:s.getAttribute("fieldType"),range:parseInt(s.getAttribute("distanceRange"),10)});const r=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning");e.fontSize=parseInt(i.getAttribute("size"),10),e.fontFamily=i.getAttribute("face"),e.lineHeight=parseInt(n.getAttribute("lineHeight"),10);for(let t=0;t<r.length;t++)e.pages.push({id:parseInt(r[t].getAttribute("id"),10)||0,file:r[t].getAttribute("file")});const h={};e.baseLineOffset=e.lineHeight-parseInt(n.getAttribute("base"),10);for(let t=0;t<o.length;t++){const i=o[t],n=parseInt(i.getAttribute("id"),10);let s=i.getAttribute("letter")??i.getAttribute("char")??String.fromCharCode(n);"space"===s&&(s=" "),h[n]=s,e.chars[s]={id:n,page:parseInt(i.getAttribute("page"),10)||0,x:parseInt(i.getAttribute("x"),10),y:parseInt(i.getAttribute("y"),10),width:parseInt(i.getAttribute("width"),10),height:parseInt(i.getAttribute("height"),10),xOffset:parseInt(i.getAttribute("xoffset"),10),yOffset:parseInt(i.getAttribute("yoffset"),10),xAdvance:parseInt(i.getAttribute("xadvance"),10),kerning:{}}}for(let t=0;t<a.length;t++){const i=parseInt(a[t].getAttribute("first"),10),n=parseInt(a[t].getAttribute("second"),10),s=parseInt(a[t].getAttribute("amount"),10);e.chars[h[n]].kerning[h[i]]=s}return e}},wh=[".xml",".fnt"],Ch={extension:{type:Ki.CacheParser,name:"cacheBitmapFont"},test:t=>t instanceof bh,getCacheableAssets(t,e){const i={};return t.forEach(t=>{i[t]=e,i[`${t}-bitmap`]=e}),i[`${e.fontFamily}-bitmap`]=e,i}},Sh={extension:{type:Ki.LoadParser,priority:cr.Normal},name:"loadBitmapFont",id:"bitmap-font",test:t=>wh.includes(dr.extname(t).toLowerCase()),testParse:async t=>_h.test(t)||(t=>!("string"!=typeof t||!t.includes("<font>"))&&vh.test(qs.get().parseXML(t)))(t),async parse(t,e,i){const n=_h.test(t)?_h.parse(t):(t=>vh.parse(qs.get().parseXML(t)))(t),{src:s}=e,{pages:r}=n,o=[],a=n.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let t=0;t<r.length;++t){const e=r[t].file;let i=dr.join(dr.dirname(s),e);i=fr(i,s),o.push({src:i,data:a})}const h=await i.load(o),l=o.map(t=>h[t.src]);return new bh({data:n,textures:l},s)},async load(t,e){const i=await qs.get().fetch(t);return await i.text()},async unload(t,e,i){await Promise.all(t.pages.map(t=>i.unload(t.texture.source._sourceOrigin))),t.destroy()}};class Ih{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,this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const Ah={extension:{type:Ki.CacheParser,name:"cacheTextureArray"},test:t=>Array.isArray(t)&&t.every(t=>t instanceof Fn),getCacheableAssets:(t,e)=>{const i={};return t.forEach(t=>{e.forEach((e,n)=>{i[t+(0===n?"":n+1)]=e})}),i}},Mh={extension:{type:Ki.DetectionParser,priority:1},test:async()=>ge("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async t=>[...t,"avif"],remove:async t=>t.filter(t=>"avif"!==t)},Th=["png","jpg","jpeg"],Ph={extension:{type:Ki.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async t=>[...t,...Th],remove:async t=>t.filter(t=>!Th.includes(t))},Eh="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope,Bh={extension:{type:Ki.DetectionParser,priority:0},test:async()=>me("video/mp4"),add:async t=>[...t,"mp4","m4v"],remove:async t=>t.filter(t=>"mp4"!==t&&"m4v"!==t)},Oh={extension:{type:Ki.DetectionParser,priority:0},test:async()=>me("video/ogg"),add:async t=>[...t,"ogv"],remove:async t=>t.filter(t=>"ogv"!==t)},kh={extension:{type:Ki.DetectionParser,priority:0},test:async()=>me("video/webm"),add:async t=>[...t,"webm"],remove:async t=>t.filter(t=>"webm"!==t)},Rh={extension:{type:Ki.DetectionParser,priority:0},test:async()=>ge("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async t=>[...t,"webp"],remove:async t=>t.filter(t=>"webp"!==t)};class Dh{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{let n=null,s=null;if((e.parser||e.loadParser)&&(s=this._parserHash[e.parser||e.loadParser],e.loadParser&&a(),s||a(e.parser||e.loadParser)),!s){for(let i=0;i<this.parsers.length;i++){const n=this.parsers[i];if(n.load&&n.test?.(t,e,this)){s=n;break}}if(!s)return a(),null}n=await s.load(t,e,this),i.parser=s;for(let t=0;t<this.parsers.length;t++){const s=this.parsers[t];s.parse&&s.parse&&await(s.testParse?.(n,e,this))&&(n=await s.parse(n,e,this)||n,i.parser=s)}return n})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const n={},s=ur(t),r=ar(t,t=>({alias:[t],src:t,data:{}})),o=r.length,a=r.map(async t=>{const s=dr.toAbsolute(t.src);if(!n[t.src])try{this.promiseCache[s]||(this.promiseCache[s]=this._getLoadPromiseAndParser(s,t)),n[t.src]=await this.promiseCache[s].promise,e&&e(++i/o)}catch(e){throw delete this.promiseCache[s],delete n[t.src],new Error(`[Loader.load] Failed to load ${s}.\n${e}`)}});return await Promise.all(a),s?n[r[0].src]:n}async unload(t){const e=ar(t,t=>({alias:[t],src:t})).map(async t=>{const e=dr.toAbsolute(t.src),i=this.promiseCache[e];if(i){const n=await i.promise;delete this.promiseCache[e],await(i.parser?.unload?.(n,t,this))}});await 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])&&a(e.id):a(),t[e.name]=e,e.id&&(t[e.id]=e),t),{})}}const Fh={extension:{type:Ki.LoadParser,priority:cr.Low},name:"loadJson",id:"json",test:t=>ye(t,"application/json")||xe(t,".json"),async load(t){const e=await qs.get().fetch(t);return await e.json()}},Lh={name:"loadTxt",id:"text",extension:{type:Ki.LoadParser,priority:cr.Low,name:"loadTxt"},test:t=>ye(t,"text/plain")||xe(t,".txt"),async load(t){const e=await qs.get().fetch(t);return await e.text()}},jh=["normal","bold","100","200","300","400","500","600","700","800","900"],Gh=[".ttf",".otf",".woff",".woff2"],Uh=["font/ttf","font/otf","font/woff","font/woff2"],Nh=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i,zh=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/,Hh={extension:{type:Ki.LoadParser,priority:cr.Low},name:"loadWebFont",id:"web-font",test:t=>ye(t,Uh)||xe(t,Gh),async load(t,e){const i=qs.get().getFontFaceSet();if(i){const n=[],s=e.data?.family??function(t){const e=dr.extname(t),i=dr.basename(t,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1));let n=i.length>0;for(const t of i)if(!t.match(Nh)){n=!1;break}let s=i.join(" ");return n||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}(t),r=e.data?.weights?.filter(t=>jh.includes(t))??["normal"],o=e.data??{};for(let e=0;e<r.length;e++){const a=r[e],h=new FontFace(s,`url(${be(t)})`,{...o,weight:a});await h.load(),i.add(h),n.push(h)}return hr.has(`${s}-and-url`)?hr.get(`${s}-and-url`).entries.push({url:t,faces:n}):hr.set(`${s}-and-url`,{entries:[{url:t,faces:n}]}),1===n.length?n[0]:n}return a(),null},unload(t){const e=Array.isArray(t)?t:[t],i=e[0].family,n=hr.get(`${i}-and-url`),s=n.entries.find(t=>t.faces.some(t=>-1!==e.indexOf(t)));s.faces=s.faces.filter(t=>-1===e.indexOf(t)),0===s.faces.length&&(n.entries=n.entries.filter(t=>t!==s)),e.forEach(t=>{qs.get().getFontFaceSet().delete(t)}),0===n.entries.length&&hr.remove(`${i}-and-url`)}},Vh={extension:{type:Ki.LoadParser,priority:cr.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test:t=>ye(t,"image/svg+xml")||xe(t,".svg"),async load(t,e,i){return e.data?.parseAsGraphicsContext??this.config.parseAsGraphicsContext?async function(t){const e=await qs.get().fetch(t),i=await e.text(),n=new lh;return n.svg(i),n}(t):async function(t,e,i,n){const s=await qs.get().fetch(t),r=await s.blob(),o=URL.createObjectURL(r),a=qs.get().createImage();a.src=o,a.crossOrigin=n,await a.decode(),URL.revokeObjectURL(o);const h=e.data?.width??a.width,l=e.data?.height??a.height,c=e.data?.resolution||_e(t),d=qs.get().createCanvas(h*c,l*c);d.getContext("2d").drawImage(a,0,0,h*c,l*c);const{parseAsGraphicsContext:u,...p}=e.data??{};return ve(new $s({resource:d,alphaMode:"premultiply-alpha-on-upload",resolution:c,...p}),i,t)}(t,e,i,this.config.crossOrigin)},unload(t){t.destroy(!0)}};let Wh=null,Zh=class{constructor(){Wh||(Wh=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(Wh)}};Zh.revokeObjectURL=function(){Wh&&(URL.revokeObjectURL(Wh),Wh=null)};let Jh=null;class Xh{constructor(){Jh||(Jh=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(Jh)}}Xh.revokeObjectURL=function(){Jh&&(URL.revokeObjectURL(Jh),Jh=null)};let Yh,Kh=0;const qh=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 Zh;e.addEventListener("message",i=>{e.terminate(),Zh.revokeObjectURL(),t(i.data)})})),this._isImageBitmapSupported}loadImageBitmap(t,e){return this._run("loadImageBitmap",[t,e?.data?.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){void 0===Yh&&(Yh=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<Yh&&(this._createdWorkers++,t=(new Xh).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}async _run(t,e){await 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[Kh]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Kh++,id:i})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t?.(new Error("WorkerManager destroyed"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}},Qh=[".jpeg",".jpg",".png",".webp",".avif"],$h=["image/jpeg","image/png","image/webp","image/avif"],tl={name:"loadTextures",id:"texture",extension:{type:Ki.LoadParser,priority:cr.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test:t=>ye(t,$h)||xe(t,Qh),async load(t,e,i){let n=null;return n=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await qh.isImageBitmapSupported()?await qh.loadImageBitmap(t,e):await async function(t,e){const i=await qs.get().fetch(t);if(!i.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${t}: ${i.status} ${i.statusText}`);const n=await i.blob();return"premultiplied-alpha"===e?.data?.alphaMode?createImageBitmap(n,{premultiplyAlpha:"none"}):createImageBitmap(n)}(t,e):await new Promise((e,i)=>{n=qs.get().createImage(),n.crossOrigin=this.config.crossOrigin,n.src=t,n.complete?e(n):(n.onload=()=>{e(n)},n.onerror=i)}),ve(new $s({resource:n,alphaMode:"premultiply-alpha-on-upload",resolution:e.data?.resolution||_e(t),...e.data}),i,t)},unload(t){t.destroy(!0)}},el=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let il,nl;const sl={name:"loadVideo",id:"video",extension:{type:Ki.LoadParser,name:"loadVideo"},test(t){if(!il||!nl){const{validVideoExtensions:t,validVideoMime:e}=function(){const t=[],e=[];for(const i of el){const n=or.MIME_TYPES[i.substring(1)]||`video/${i.substring(1)}`;me(n)&&(t.push(i),e.includes(n)||e.push(n))}return{validVideoExtensions:t,validVideoMime:e}}();il=t,nl=e}const e=ye(t,nl),i=xe(t,il);return e||i},async load(t,e,i){const n={...or.defaultOptions,resolution:e.data?.resolution||_e(t),alphaMode:e.data?.alphaMode||await w(),...e.data},s=document.createElement("video"),r={preload:!1!==n.autoLoad?"auto":void 0,"webkit-playsinline":!1!==n.playsinline?"":void 0,playsinline:!1!==n.playsinline?"":void 0,muted:!0===n.muted?"":void 0,loop:!0===n.loop?"":void 0,autoplay:!1!==n.autoPlay?"":void 0};Object.keys(r).forEach(t=>{const e=r[t];void 0!==e&&s.setAttribute(t,e)}),!0===n.muted&&(s.muted=!0),function(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);return i.hostname!==e.hostname||i.port!==e.port||i.protocol!==e.protocol?"anonymous":""}(e)}(s,t,n.crossorigin);const o=document.createElement("source");let a;if(n.mime)a=n.mime;else if(t.startsWith("data:"))a=t.slice(5,t.indexOf(";"));else if(!t.startsWith("blob:")){const e=t.split("?")[0].slice(t.lastIndexOf(".")+1).toLowerCase();a=or.MIME_TYPES[e]||`video/${e}`}return o.src=t,a&&(o.type=a),new Promise(r=>{const a=async()=>{const o=new or({...n,resource:s});var h;s.removeEventListener("canplay",a),e.data.preload&&await(h=s,new Promise((t,e)=>{function i(){s(),t()}function n(t){s(),e(t)}function s(){h.removeEventListener("canplaythrough",i),h.removeEventListener("error",n)}h.addEventListener("canplaythrough",i),h.addEventListener("error",n),h.load()})),r(ve(o,i,t))};n.preload&&!n.autoPlay&&s.load(),s.addEventListener("canplay",a),s.appendChild(o)})},unload(t){t.destroy(!0)}},rl={extension:{type:Ki.ResolveParser,name:"resolveTexture"},test:tl.test,parse:t=>({resolution:parseFloat(pr.RETINA_PREFIX.exec(t)?.[1]??"1"),format:t.split(".").pop(),src:t})},ol={extension:{type:Ki.ResolveParser,priority:-2,name:"resolveJson"},test:t=>pr.RETINA_PREFIX.test(t)&&t.endsWith(".json"),parse:rl.parse},al=new class{constructor(){this._detections=[],this._initialized=!1,this.resolver=new pr,this.loader=new Dh,this.cache=hr,this._backgroundLoader=new Ih(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){if(this._initialized)return void a();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=await this.load(e)),this.resolver.addManifest(e)}const e=t.texturePreference?.resolution??1,i="number"==typeof e?[e]:e,n=await this._detectFormats({preferredFormats:t.texturePreference?.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=ur(t),n=ar(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}),s=this.resolver.resolve(n),r=await this._mapLoadToResolve(s,e);return i?r[n[0]]:r}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;"string"==typeof t&&(i=!0,t=[t]);const n=this.resolver.resolveBundle(t),s={},r=Object.keys(n);let o=0,a=0;const h=()=>{e?.(++o/a)},l=r.map(t=>{const e=n[t],i=Object.values(e),r=[...new Set(i.flat())];return a+=r.length,this._mapLoadToResolve(e,h).then(e=>{s[t]=e})});return await Promise.all(l),i?s[t[0]]:s}async backgroundLoad(t){this._initialized||await this.init(),"string"==typeof t&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await 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 hr.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=hr.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const s={};return i.forEach(t=>{const e=n[t.src],i=[t.src];t.alias&&i.push(...t.alias),i.forEach(t=>{s[t]=e}),hr.set(i,e)}),s}async unload(t){this._initialized||await this.init();const e=ar(t).map(t=>"string"!=typeof t?t.src:t),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=ar(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(t=>this._unloadFromResolved(e[t]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(t=>{hr.remove(t.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((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]})})}};$i.handleByList(Ki.LoadParser,al.loader.parsers).handleByList(Ki.ResolveParser,al.resolver.parsers).handleByList(Ki.CacheParser,al.cache.parsers).handleByList(Ki.DetectionParser,al.detections),$i.add(Ah,Ph,Mh,Rh,Bh,Oh,kh,Fh,Lh,Hh,Vh,tl,sl,Sh,Ch,rl,ol);const hl={loader:Ki.LoadParser,resolver:Ki.ResolveParser,cache:Ki.CacheParser,detection:Ki.DetectionParser};$i.handle(Ki.Asset,t=>{const e=t.ref;Object.entries(hl).filter(([t])=>!!e[t]).forEach(([t,i])=>$i.add(Object.assign(e[t],{extension:e[t].extension??i})))},t=>{const e=t.ref;Object.keys(hl).filter(t=>!!e[t]).forEach(t=>$i.remove(e[t]))});class ll extends Vs{constructor(t={}){const{element:e,anchor:i,...n}=t;super({label:"DOMContainer",...n}),this.renderPipeId="dom",this.batched=!1,this._anchor=new cn(0,0),i&&(this.anchor=i),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){super.destroy(t),this._element?.parentNode?.removeChild(this._element),this._element=null,this._anchor=null}}class cl{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 br({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)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,s=i.width*e.x,r=i.height*e.y;n.style.transformOrigin=`${s}px ${r}px`,n.style.transform=`matrix(${t.a}, ${t.b}, ${t.c}, ${t.d}, ${t.tx-s}, ${t.ty-r})`,n.style.opacity=i.groupAlpha.toString()}}}else this._domElement.remove()}destroy(){this._renderer.runners.postrender.remove(this);for(let t=0;t<this._attachedDomElements.length;t++){const e=this._attachedDomElements[t];e.element?.remove()}this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}cl.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"dom"};const dl=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&&(sr.system.add(this._tickerUpdate,this,tr.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(sr.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 ul extends _r{constructor(){super(...arguments),this.client=new cn,this.movement=new cn,this.offset=new cn,this.global=new cn,this.screen=new cn}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,s,r,o,a,h,l,c,d,u,p,f){throw new Error("Method not implemented.")}}class pl extends ul{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 fl extends ul{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}fl.DOM_DELTA_PIXEL=0,fl.DOM_DELTA_LINE=1,fl.DOM_DELTA_PAGE=2;const gl=new cn,ml=new cn;class yl{constructor(t){this.dispatch=new on,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 a(t.type)}hitTest(t,e){dl.pauseUpdate=!0;const i=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,gl.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,s=i.length-1;n<s;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 e=i.length-1;e>=0;e--)n.forEach(n=>{t.currentTarget=i[e],this.notifyTarget(t,n)})}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,s,r=!1){let o=!1;if(this._interactivePrune(t))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(dl.pauseUpdate=!1),t.interactiveChildren&&t.children){const a=t.children;for(let h=a.length-1;h>=0;h--){const l=a[h],c=this.hitTestMoveRecursive(l,this._isInteractive(e)?e:l.eventMode,i,n,s,r||s(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),h=t.isInteractive();return h&&h&&this._allInteractiveElements.push(t),r||this._hitElements.length>0?null:o?this._hitElements:a&&!s(t,i)&&n(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,n,s){if(this._interactivePrune(t)||s(t,i))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(dl.pauseUpdate=!1),t.interactiveChildren&&t.children){const r=t.children,o=i;for(let i=r.length-1;i>=0;i--){const a=r[i],h=this.hitTestRecursive(a,this._isInteractive(e)?e:a.eventMode,o,n,s);if(h){if(h.length>0&&!h[h.length-1].parent)continue;const e=t.isInteractive();return(h.length>0||e)&&h.push(t),h}}}const r=this._isInteractive(e),o=t.isInteractive();return r&&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,ml),!t.hitArea.contains(ml.x,ml.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&&!n.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return!!t.hitArea||!!t?.containsPoint&&(t.worldTransform.applyInverse(e,ml),t.containsPoint(ml))}notifyTarget(t,e){if(!t.currentTarget.isInteractive())return;e??(e=t.type);const i=`on${e}`;t.currentTarget[i]?.(t);const n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof pl))return void a();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){if(!(t instanceof pl))return void a();this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i="mouse"===e.pointerType||"pen"===e.pointerType,n=this.trackingData(t.pointerId),s=this.findMountedTarget(n.overTargets);if(n.overTargets?.length>0&&s!==e.target){const n="mousemove"===t.type?"mouseout":"pointerout",r=this.createPointerEvent(t,n,s);if(this.dispatchEvent(r,"pointerout"),i&&this.dispatchEvent(r,"mouseout"),!e.composedPath().includes(s)){const n=this.createPointerEvent(t,"pointerleave",s);for(n.eventPhase=n.AT_TARGET;n.target&&!e.composedPath().includes(n.target);)n.currentTarget=n.target,this.notifyTarget(n),i&&this.notifyTarget(n,"mouseleave"),n.target=n.target.parent;this.freeEvent(n)}this.freeEvent(r)}if(s!==e.target){const n="mousemove"===t.type?"mouseover":"pointerover",r=this.clonePointerEvent(e,n);this.dispatchEvent(r,"pointerover"),i&&this.dispatchEvent(r,"mouseover");let o=s?.parent;for(;o&&o!==this.rootTarget.parent&&o!==e.target;)o=o.parent;if(!o||o===this.rootTarget.parent){const t=this.clonePointerEvent(e,"pointerenter");for(t.eventPhase=t.AT_TARGET;t.target&&t.target!==s&&t.target!==this.rootTarget.parent;)t.currentTarget=t.target,this.notifyTarget(t),i&&this.notifyTarget(t,"mouseenter"),t.target=t.target.parent;this.freeEvent(t)}this.freeEvent(r)}const r=[],o=this.enableGlobalMoveEvents??!0;this.moveOnAll?r.push("pointermove"):this.dispatchEvent(e,"pointermove"),o&&r.push("globalpointermove"),"touch"===e.pointerType&&(this.moveOnAll?r.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),o&&r.push("globaltouchmove")),i&&(this.moveOnAll?r.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),o&&r.push("globalmousemove"),this.cursor=e.target?.cursor),r.length>0&&this.all(e,r),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){if(!(t instanceof pl))return void a();const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),n="mouse"===i.pointerType||"pen"===i.pointerType;this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),"mouse"===i.pointerType&&(this.cursor=i.target?.cursor);const s=this.clonePointerEvent(i,"pointerenter");for(s.eventPhase=s.AT_TARGET;s.target&&s.target!==this.rootTarget.parent;)s.currentTarget=s.target,this.notifyTarget(s),n&&this.notifyTarget(s,"mouseenter"),s.target=s.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(s)}mapPointerOut(t){if(!(t instanceof pl))return void a();const e=this.trackingData(t.pointerId);if(e.overTargets){const i="mouse"===t.pointerType||"pen"===t.pointerType,n=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",n);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const r=this.createPointerEvent(t,"pointerleave",n);for(r.eventPhase=r.AT_TARGET;r.target&&r.target!==this.rootTarget.parent;)r.currentTarget=r.target,this.notifyTarget(r),i&&this.notifyTarget(r,"mouseleave"),r.target=r.target.parent;e.overTargets=null,this.freeEvent(s),this.freeEvent(r)}this.cursor=null}mapPointerUp(t){if(!(t instanceof pl))return void a();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),s=this.findMountedTarget(n.pressTargetsByButton[t.button]);let r=s;if(s&&!i.composedPath().includes(s)){let e=s;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],r=e}if(r){const s=this.clonePointerEvent(i,"click");s.target=r,s.path=null,n.clicksByButton[t.button]||(n.clicksByButton[t.button]={clickCount:0,target:s.target,timeStamp:e});const o=n.clicksByButton[t.button];if(o.target===s.target&&e-o.timeStamp<200?++o.clickCount:o.clickCount=1,o.target=s.target,o.timeStamp=e,s.detail=o.clickCount,"mouse"===s.pointerType){const t=2===s.button;this.dispatchEvent(s,t?"rightclick":"click")}else"touch"===s.pointerType&&this.dispatchEvent(s,"tap");this.dispatchEvent(s,"pointertap"),this.freeEvent(s)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof pl))return void a();const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),n=this.createPointerEvent(t);if(i){let s=i;for(;s;)n.currentTarget=s,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"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(n)}mapWheel(t){if(!(t instanceof fl))return void a();const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const n=this.allocateEvent(pl);return this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.nativeEvent=t.nativeEvent,n.originalEvent=t,n.target=i??this.hitTest(n.global.x,n.global.y)??this._hitElements[0],"string"==typeof e&&(n.type=e),n}createWheelEvent(t){const e=this.allocateEvent(fl);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(pl);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof pl&&e instanceof pl&&(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 ul&&e instanceof ul&&(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,s=i.length;n<s&&!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 xl={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},bl=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 yl(null),dl.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new pl(null),this._rootWheelEvent=new fl(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...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){const{canvas:i,resolution:n}=this.renderer;this.setTargetElement(i),this.resolution=n,t._defaultEventMode=e.eventMode??"passive",Object.assign(this.features,e.eventFeatures??{}),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);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let t=0,i=e.length;t<i;t++){const i=e[t],n=this._bootstrapEvent(this._rootPointerEvent,i);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,dl.pointerMoved();const e=this._normalizeToPointerData(t);for(let t=0,i=e.length;t<i;t++){const i=this._bootstrapEvent(this._rootPointerEvent,e[t]);this.rootBoundary.mapEvent(i)}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 t=0,e=n.length;t<e;t++){const e=this._bootstrapEvent(this._rootPointerEvent,n[t]);e.type+=i,this.rootBoundary.mapEvent(e)}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 t=0,i=e.length;t<i;t++){const i=this._bootstrapEvent(this._rootPointerEvent,e[t]);this.rootBoundary.mapEvent(i)}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,dl.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;dl.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;dl.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},s=1/this.resolution;t.x=(e-n.left)*(this.domElement.width/n.width)*s,t.y=(i-n.top)*(this.domElement.height/n.height)*s}_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)){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)}else e.push(t);return e}normalizeWheelEvent(t){const e=this._rootWheelEvent;return this._transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}_bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this._transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=xl[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}};bl.extension={name:"events",type:[Ki.WebGLSystem,Ki.CanvasSystem,Ki.WebGPUSystem],priority:-1},bl.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let _l=bl;const vl={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(){return this._internalEventMode??_l.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,s="object"==typeof i?i.signal:void 0,r="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,h=this;s&&s.addEventListener("abort",()=>{h.off(t,a,o)}),r?h.once(t,a,o):h.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 _r))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 wl{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}}wl.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"filter"};const Cl=new da({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 Sl{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new jn,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0}}}class Il{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new so({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 ro({}),this.renderer=t}get activeBackTexture(){return this._activeFilterData?.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 s=e.renderTarget.renderTarget.colorTexture.source,r=s.resolution,o=s.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,r,1),n.skip)return;const h=this._getPreviousFilterData(),l=this._findFilterResolution(r);let c=0,d=0;h&&(c=h.bounds.minX,d=h.bounds.minY),this._calculateGlobalFrame(n,c,d,l,s.width,s.height),this._setupFilterTextures(n,a,e,h)}generateFilteredTexture({texture:t,filters:e}){const i=this._pushFilterData();this._activeFilterData=i,i.skip=!1,i.filters=e;const n=t.source,s=n.resolution,r=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,r,s,0),i.skip)return t;const a=s;this._calculateGlobalFrame(i,0,0,a,n.width,n.height),i.outputRenderSurface=Ls.getOptimalTexture(o.width,o.height,i.resolution,i.antialias),i.backTexture=Fn.EMPTY,i.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(i,!0);const h=i.outputRenderSurface;return h.source.alphaMode="premultiplied-alpha",h}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&&Ls.returnTexture(e.backTexture),Ls.returnTexture(e.inputTexture))}getBackTexture(t,e,i){const n=t.colorTexture.source._resolution,s=Ls.getOptimalTexture(e.width,e.height,n,!1);let r=e.minX,o=e.minY;i&&(r-=i.minX,o-=i.minY),r=Math.floor(r*n),o=Math.floor(o*n);const a=Math.ceil(e.width*n),h=Math.ceil(e.height*n);return this.renderer.renderTarget.copyToTexture(t,s,{x:r,y:o},{width:a,height:h},{x:0,y:0}),s}applyFilter(t,e,i,n){const s=this.renderer,r=this._activeFilterData,o=r.outputRenderSurface===i,a=s.renderTarget.rootRenderTarget.colorTexture.source._resolution,h=this._findFilterResolution(a);let l=0,c=0;if(o){const t=this._findPreviousFilterOffset();l=t.x,c=t.y}this._updateFilterUniforms(e,i,r,l,c,h,o,n),this._setupBindGroupsAndRender(t,e,s)}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),s=e.worldTransform.copyTo(un.shared),r=e.renderGroup||e.parentRenderGroup;return r&&r.cacheToLocalTransform&&s.prepend(r.cacheToLocalTransform),s.invert(),n.prepend(s),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:Cl,shader:t,state:t._state,topology:"triangle-list"}),i.type===oo.WEBGL&&i.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,i,n){if(t.backTexture=Fn.EMPTY,t.blendRequired){i.renderTarget.finishRenderPass();const s=i.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(s,e,n?.bounds)}t.inputTexture=Ls.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,s,r){const o=t.globalFrame;o.x=e*n,o.y=i*n,o.width=s*n,o.height=r*n}_updateFilterUniforms(t,e,i,n,s,r,o,a){const h=this._filterGlobalUniforms.uniforms,l=h.uOutputFrame,c=h.uInputSize,d=h.uInputPixel,u=h.uInputClamp,p=h.uGlobalFrame,f=h.uOutputTexture;o?(l[0]=i.bounds.minX-n,l[1]=i.bounds.minY-s):(l[0]=0,l[1]=0),l[2]=t.frame.width,l[3]=t.frame.height,c[0]=t.source.width,c[1]=t.source.height,c[2]=1/c[0],c[3]=1/c[1],d[0]=t.source.pixelWidth,d[1]=t.source.pixelHeight,d[2]=1/d[0],d[3]=1/d[1],u[0]=.5*d[2],u[1]=.5*d[3],u[2]=t.frame.width*c[2]-.5*d[2],u[3]=t.frame.height*c[3]-.5*d[3];const g=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=n*r,p[1]=s*r,p[2]=g.source.width*r,p[3]=g.source.height*r,e instanceof Fn&&(e.source.resource=null);const m=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!a),e instanceof Fn?(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 i=0;i<t.length;i++){const n=t[i];n.globalDisplayStatus<7||(e.matrix=n.worldTransform,e.addBounds(n.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,s=t.filters;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),1===s.length)s[0].apply(this,i,t.outputRenderSurface,e);else{let i=t.inputTexture;const r=Ls.getOptimalTexture(n.width,n.height,i.source._resolution,!1);let o=r,a=0;for(a=0;a<s.length-1;++a){s[a].apply(this,i,o,!0);const t=i;i=o,o=t}s[a].apply(this,i,t.outputRenderSurface,e),Ls.returnTexture(r)}}_calculateFilterBounds(t,e,i,n,s){const r=this.renderer,o=t.bounds,h=t.filters;let l=1/0,c=0,d=!0,u=!1,p=!1,f=!0;for(let t=0;t<h.length;t++){const e=h[t];if(l=Math.min(l,"inherit"===e.resolution?n:e.resolution),c+=e.padding,"off"===e.antialias?d=!1:"inherit"===e.antialias&&d&&(d=i),e.clipToViewport||(f=!1),!(e.compatibleRenderers&r.type)){p=!1;break}if(e.blendRequired&&!(r.backBuffer?.useBackBuffer??1)){a(),p=!1;break}p=e.enabled||p,u||(u=e.blendRequired)}p?(f&&o.fitBounds(0,e.width/n,0,e.height/n),o.scale(l).ceil().scale(1/l).pad((0|c)*s),o.isPositive?(t.antialias=d,t.resolution=l,t.blendRequired=u):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 Sl),this._filterStackIndex++,t}}Il.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem],name:"filter"};var Al="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 Ml extends po{constructor(t){const{sprite:e,...i}=t,n=new Dn(e.texture),s=new so({uFilterMatrix:{value:new un,type:"mat3x3<f32>"},uMaskClamp:{value:n.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"}});super({...i,gpuProgram:to.from({vertex:{source:Al,entryPoint:"mainVertex"},fragment:{source:Al,entryPoint:"mainFragment"}}),glProgram:Yr.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"}),clipToViewport:!1,resources:{filterUniforms:s,uMaskTexture:e.texture.source}}),this.sprite=e,this._textureMatrix=n}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)}}class Tl extends Vs{constructor(t){t instanceof lh&&(t={context:t});const{context:e,roundPixels:i,...n}=t||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",this._context=e||(this._ownedContext=new lh),this._context.on("update",this.onViewUpdate,this),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=i??!1}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!==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){return t?new Tl(this._context.clone()):(this._ownedContext=null,new Tl(this._context))}lineStyle(t,e,n){i(0,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const s={};return t&&(s.width=t),e&&(s.color=e),n&&(s.alpha=n),this.context.strokeStyle=s,this}beginFill(t,e){i(0,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const n={};return void 0!==t&&(n.color=t),void 0!==e&&(n.alpha=e),this.context.fillStyle=n,this}endFill(){i(0,"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===lh.defaultStrokeStyle.width&&t.color===lh.defaultStrokeStyle.color&&t.alpha===lh.defaultStrokeStyle.alpha||this.context.stroke(),this}drawCircle(...t){return i(0,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return i(0,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return i(0,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return i(0,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return i(0,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return i(0,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const Pl=class t extends da{constructor(...e){let n=e[0]??{};n instanceof Float32Array&&(i(0,"use new MeshGeometry({ positions, uvs, indices }) instead"),n={positions:n,uvs:e[1],indices:e[2]}),n={...t.defaultOptions,...n};const s=n.positions||new Float32Array([0,0,1,0,1,1,0,1]);let r=n.uvs;r||(r=n.positions?new Float32Array(s.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 ca({data:s,label:"attribute-mesh-positions",shrinkToFit:a,usage:la.VERTEX|la.COPY_DST}),format:"float32x2",stride:8,offset:0},aUV:{buffer:new ca({data:r,label:"attribute-mesh-uvs",shrinkToFit:a,usage:la.VERTEX|la.COPY_DST}),format:"float32x2",stride:8,offset:0}},indexBuffer:new ca({data:o,label:"index-mesh-buffer",shrinkToFit:a,usage:la.INDEX|la.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}};Pl.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let El=Pl;class Bl extends Vs{constructor(...t){let e=t[0];e instanceof da&&(i(0,"Mesh: use new Mesh({ geometry, shader }) instead"),e={geometry:e,shader:t[1]},t[3]&&(i(0,"Mesh: drawMode argument has been removed, use geometry.topology instead"),e.geometry.topology=t[3]));const{geometry:n,shader:s,texture:r,roundPixels:o,state:a,...h}=e;super({label:"Mesh",...h}),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=s??null,this.texture=r??s?.texture??Fn.WHITE,this.state=a??co.for2d(),this._geometry=n,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=o??!1}get material(){return i(0,"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){this._geometry!==t&&(this._geometry?.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=Fn.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 El&&("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,s="triangle-strip"===this.geometry.topology?3:1;if(this.geometry.getIndex()){const t=this.geometry.getIndex().data,r=t.length;for(let o=0;o+2<r;o+=s){const s=2*t[o],r=2*t[o+1],a=2*t[o+2];if(we(e,i,n[s],n[s+1],n[r],n[r+1],n[a],n[a+1]))return!0}}else{const t=n.length/2;for(let r=0;r+2<t;r+=s){const t=2*r,s=2*(r+1),o=2*(r+2);if(we(e,i,n[t],n[t+1],n[s],n[s+1],n[o],n[o+1]))return!0}}return!1}destroy(t){if(super.destroy(t),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._texture.destroy(e)}this._geometry?.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null,this._gpuData=null}}class Ol extends Ws{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{animationSpeed:i=1,autoPlay:n=!1,autoUpdate:s=!0,loop:r=!0,onComplete:o=null,onFrameChange:a=null,onLoop:h=null,textures:l,updateAnchor:c=!1,...d}=e,[u]=l;super({...d,texture:u instanceof Fn?u:u.texture}),this._textures=null,this._durations=null,this._autoUpdate=s,this._isConnectedToTicker=!1,this.animationSpeed=i,this.loop=r,this.updateAnchor=c,this.onComplete=o,this.onFrameChange=a,this.onLoop=h,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=l,n&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(sr.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(sr.shared.add(this.update,this,tr.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:t?.texture){const e="boolean"==typeof t?t: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(Fn.from(t[i]));return new Ol(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(Fn.from(t[i]));return new Ol(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof Fn)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?(sr.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(sr.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class kl{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t??new un,this.observer=e,this.position=new nn(this,0,0),this.scale=new nn(this,1,1),this.pivot=new nn(this,0,0),this.skew=new nn(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){this.dirty=!0,t===this.skew&&this.updateSkew(),this.observer?._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 Rl=class t extends Vs{constructor(...e){let n=e[0]||{};n instanceof Fn&&(n={texture:n}),e.length>1&&(i(0,"use new TilingSprite({ texture, width:100, height:100 }) instead"),n.width=e[1],n.height=e[2]),n={...t.defaultOptions,...n};const{texture:s,anchor:r,tilePosition:o,tileScale:a,tileRotation:h,width:l,height:c,applyAnchorToTexture:d,roundPixels:u,...p}=n??{};super({label:"TilingSprite",...p}),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new nn({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=d,this.texture=s,this._width=l??s.width,this._height=c??s.height,this._tileTransform=new kl({observer:{_onUpdate:()=>this.onViewUpdate()}}),r&&(this.anchor=r),this.tilePosition=o,this.tileScale=a,this.tileRotation=h,this.roundPixels=u??!1}static from(e,i={}){return new t("string"==typeof e?{texture:hr.get(e),...i}:{texture:e,...i})}get uvRespectAnchor(){return a(),this.applyAnchorToTexture}set uvRespectAnchor(t){a(),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=Fn.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){"object"==typeof t&&(e=t.height??t.width,t=t.width),this._width=t,this._height=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 s=0;return t.x>=n&&t.x<=n+e&&(s=-i*this._anchor._y,t.y>=s&&t.y<=s+i)}destroy(t=!1){if(super.destroy(t),this._anchor=null,this._tileTransform=null,this._bounds=null,"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._texture.destroy(e)}this._texture=null}};Rl.defaultOptions={texture:Fn.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let Dl=Rl;class Fl extends Vs{constructor(t,e){const{text:i,resolution:n,style:s,anchor:r,width:o,height:a,roundPixels:h,...l}=t;super({...l}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i??"",this.style=s,this.resolution=n??null,this.allowChildren=!1,this._anchor=new nn({_onUpdate:()=>{this.onViewUpdate()}}),r&&(this.anchor=r),this.roundPixels=h??!1,void 0!==o&&(this.width=o),void 0!==a&&(this.height=a)}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){t||(t={}),this._style?.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){"object"==typeof t?(e=t.height??t.width,t=t.width):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 s=0;return t.x>=n&&t.x<=n+e&&(s=-i*this.anchor.y,t.y>=s&&t.y<=s+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:t?.style)&&this._style.destroy(t),this._style=null,this._text=null}}let Ll=null,jl=null;const Gl=new Sn,Ul=new class{getCanvasAndContext(t){const{text:e,style:i,resolution:n=1}=t,s=i._getFinalPadding(),r=Fo.measureText(e||" ",i),o=Math.ceil(Math.ceil(Math.max(1,r.width)+2*s)*n),a=Math.ceil(Math.ceil(Math.max(1,r.height)+2*s)*n),h=ph.getOptimalCanvasAndContext(o,a);return this._renderTextToCanvas(e,i,s,n,h),{canvasAndContext:h,frame:i.trim?Ie({canvas:h.canvas,width:o,height:a,resolution:1,output:Gl}):Gl.set(0,0,o,a)}}returnCanvasAndContext(t){ph.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,i,n,s){const{canvas:r,context:o}=s,a=dt(e),h=Fo.measureText(t||" ",e),l=h.lines,c=h.lineHeight,d=h.lineWidths,u=h.maxLineWidth,p=h.fontProperties,f=r.height;if(o.resetTransform(),o.scale(n,n),o.textBaseline=e.textBaseline,e._stroke?.width){const t=e._stroke;o.lineWidth=t.width,o.miterLimit=t.miterLimit,o.lineJoin=t.join,o.lineCap=t.cap}let g,m;o.font=a;const y=e.dropShadow?2:1;for(let t=0;t<y;++t){const r=e.dropShadow&&0===t,a=r?Math.ceil(Math.max(1,f)+2*i):0,y=a*n;if(r){o.fillStyle="black",o.strokeStyle="black";const t=e.dropShadow,i=t.color,s=t.alpha;o.shadowColor=ps.shared.setValue(i).setAlpha(s).toRgbaString();const r=t.blur*n,a=t.distance*n;o.shadowBlur=r,o.shadowOffsetX=Math.cos(t.angle)*a,o.shadowOffsetY=Math.sin(t.angle)*a+y}else{if(o.fillStyle=e._fill?pe(e._fill,o,h,2*i):null,e._stroke?.width){const t=.5*e._stroke.width+2*i;o.strokeStyle=pe(e._stroke,o,h,t)}o.shadowColor="black"}let x=(c-p.fontSize)/2;c-p.fontSize<0&&(x=0);const b=e._stroke?.width??0;for(let t=0;t<l.length;t++)g=b/2,m=b/2+t*c+p.ascent+x,"right"===e.align?g+=u-d[t]:"center"===e.align&&(g+=(u-d[t])/2),e._stroke?.width&&this._drawLetterSpacing(l[t],e,s,g+i,m+i-a,!0),void 0!==e._fill&&this._drawLetterSpacing(l[t],e,s,g+i,m+i-a)}}_drawLetterSpacing(t,e,i,n,s,r=!1){const{context:o}=i,a=e.letterSpacing;let h=!1;if(Fo.experimentalLetterSpacingSupported&&(Fo.experimentalLetterSpacing?(o.letterSpacing=`${a}px`,o.textLetterSpacing=`${a}px`,h=!0):(o.letterSpacing="0px",o.textLetterSpacing="0px")),0===a||h)return void(r?o.strokeText(t,n,s):o.fillText(t,n,s));let l=n;const c=Fo.graphemeSegmenter(t);let d=o.measureText(t).width,u=0;for(let t=0;t<c.length;++t){const e=c[t];r?o.strokeText(e,l,s):o.fillText(e,l,s);let i="";for(let e=t+1;e<c.length;++e)i+=c[e];u=o.measureText(i).width,l+=d-u+a,d=u}}};class Nl extends Fl{constructor(...t){const e=function(t){let e=t[0]??{};return("string"==typeof e||t[1])&&(i(0,'use new Text({ text: "hi!", style }) instead'),e={text:e,style:t[1]}),e}(t);super(e,uh),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof En?e.textureStyle:new En(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,n=0;if(this._style.trim){const{frame:t,canvasAndContext:e}=Ul.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Ul.returnCanvasAndContext(e),i=t.width,n=t.height}else{const t=Fo.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 zl="http://www.w3.org/2000/svg",Hl="http://www.w3.org/1999/xhtml";class Vl{constructor(){this.svgRoot=document.createElementNS(zl,"svg"),this.foreignObject=document.createElementNS(zl,"foreignObject"),this.domElement=document.createElementNS(Hl,"div"),this.styleElement=document.createElementNS(Hl,"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=qs.get().createImage()}}let Wl;class Zl{constructor(){this._tempState=co.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,i){const n=t.renderer,s=this._didUploadHash[i.uid];n.shader.bind(i,s),s||(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 t=0;t<e.textures.count;t++)i.texture.bind(n[t],t);i.geometry.draw(e.topology,e.size,e.start)}}Zl.extension={type:[Ki.WebGLPipesAdaptor],name:"batch"};const Jl=co.for2d();class Xl{start(t,e,i){const n=t.renderer,s=n.encoder,r=i.gpuProgram;this._shader=i,this._geometry=e,s.setGeometry(e,r),Jl.blendMode="normal",n.pipeline.getPipeline(e,r,Jl);const o=n.globalUniforms.bindGroup;s.resetBindGroup(1),s.setBindGroup(0,o,r)}execute(t,e){const i=this._shader.gpuProgram,n=t.renderer,s=n.encoder;if(!e.bindGroup){const t=e.textures;e.bindGroup=gt(t.textures,t.count,n.limits.maxBatchableTextures)}Jl.blendMode=e.blendMode;const r=n.bindGroup.getBindGroup(e.bindGroup,i,1),o=n.pipeline.getPipeline(this._geometry,i,Jl,e.topology);e.bindGroup._touch(n.textureGC.count),s.setPipeline(o),s.renderPassEncoder.setBindGroup(1,r),s.renderPassEncoder.drawIndexed(e.size,1,e.start)}}Xl.extension={type:[Ki.WebGPUPipesAdaptor],name:"batch"};const Yl=class t{constructor(t,e){this.state=co.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init?.(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 Ba({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=e,this._activeBatch=this._activeBatches.default;for(const t in this._activeBatches)this._activeBatches[t].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 t in e){const i=e[t],n=i.geometry;n.indexBuffer.setDataWithSize(i.indexBuffer,i.indexSize,!0),n.buffers[0].setDataWithSize(i.attributeBuffer.float32View,i.attributeSize,!1)}}upload(t){const e=this._batchersByInstructionSet[t.uid];for(const t in e){const i=e[t],n=i.geometry;i.dirty&&(i.dirty=!1,n.buffers[0].update(4*i.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}};Yl.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"batch"},Yl._availableBatchers=Object.create(null);let Kl=Yl;$i.handleByMap(Ki.Batcher,Kl._availableBatchers),$i.add(Ba);const ql={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 "}},Ql={...ql,vertex:{...ql.vertex,header:ql.vertex.header.replace("group(1)","group(2)")}},$l={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 "}},tc={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 "}},ec={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 "}},ic=new jn;class nc extends _s{constructor(){super(),this.filters=[new Ml({sprite:new Ws(Fn.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 sc{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=ms.get(nc);if(n.inverse=t.inverse,i){t.mask.mask.measurable=!0;const i=l(t.mask.mask,!0,ic);t.mask.mask.measurable=!1,i.ceil();const s=e.renderTarget.renderTarget.colorTexture.source,r=Ls.getOptimalTexture(i.width,i.height,s._resolution,s.antialias);e.renderTarget.push(r,!0),e.globalUniforms.push({offset:i,worldColor:4294967295});const o=n.sprite;o.texture=r,o.worldTransform.tx=i.minX,o.worldTransform.ty=i.minY,this._activeMaskStage.push({filterEffect:n,maskedContainer:t.maskedContainer,filterTexture:r})}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===oo.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&&Ls.returnTexture(t.filterTexture),ms.return(t.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}sc.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"alphaMask"};class rc{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 s=this._colorStack[this._colorStackIndex];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;this._colorStackIndex--;const s=n[this._colorStackIndex-1];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._colorStack=null}}rc.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"colorMask"};class oc{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,i){var n;const s=t,r=this._renderer;r.renderPipes.batch.break(i),r.renderPipes.blendMode.setBlendMode(s.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const o=s.mask;o.includeInBuild=!0,this._maskHash.has(s)||this._maskHash.set(s,{instructionsStart:0,instructionsLength:0});const a=this._maskHash.get(s);a.instructionsStart=i.instructionSize,o.collectRenderables(i,r,null),o.includeInBuild=!1,r.renderPipes.batch.break(i),i.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const h=i.instructionSize-a.instructionsStart-1;a.instructionsLength=h;const l=r.renderTarget.renderTarget.uid;(n=this._maskStackHash)[l]??(n[l]=0)}pop(t,e,i){const n=t,s=this._renderer;s.renderPipes.batch.break(i),s.renderPipes.blendMode.setBlendMode(n.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1});const r=this._maskHash.get(t);for(let t=0;t<r.instructionsLength;t++)i.instructions[i.instructionSize++]=i.instructions[r.instructionsStart++];i.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e;const i=this._renderer,n=i.renderTarget.renderTarget.uid;let s=(e=this._maskStackHash)[n]??(e[n]=0);"pushMaskBegin"===t.action?(i.renderTarget.ensureDepthStencil(),i.stencil.setStencilMode($o.RENDERING_MASK_ADD,s),s++,i.colorMask.setMask(0)):"pushMaskEnd"===t.action?(t.inverse?i.stencil.setStencilMode($o.INVERSE_MASK_ACTIVE,s):i.stencil.setStencilMode($o.MASK_ACTIVE,s),i.colorMask.setMask(15)):"popMaskBegin"===t.action?(i.colorMask.setMask(0),0!==s?i.stencil.setStencilMode($o.RENDERING_MASK_REMOVE,s):(i.renderTarget.clear(null,yo.STENCIL),i.stencil.setStencilMode($o.DISABLED,s)),s--):"popMaskEnd"===t.action&&(t.inverse?i.stencil.setStencilMode($o.INVERSE_MASK_ACTIVE,s):i.stencil.setStencilMode($o.MASK_ACTIVE,s),i.colorMask.setMask(15)),this._maskStackHash[n]=s}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}oc.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"stencilMask"};var ac=(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))(ac||{});class hc{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class lc{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:s}=this;i||(i=0),e||(e=0),this._boundBufferBases[e]=null,s.bindBufferRange(s.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,s=t.descriptor.usage&la.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,s)):(i.byteLength=t.descriptor.size,e.bufferData(i.type,i.byteLength,s)),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=ac.ARRAY_BUFFER;t.descriptor.usage&la.INDEX?i=ac.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&la.UNIFORM&&(i=ac.UNIFORM_BUFFER);const n=new hc(e.createBuffer(),i);return this._gpuBuffers[t.uid]=n,t.on("destroy",this.onBufferDestroy,this),n}resetState(){this._boundBufferBases=Object.create(null)}}lc.extension={type:[Ki.WebGLSystem],name:"buffer"};const cc=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){e={...t.defaultOptions,...e};let i=this.multiView=e.multiView;if(e.context&&i&&(a(),i=!1),this.canvas=i?qs.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,i=e.premultipliedAlpha??!0,n=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:t,premultipliedAlpha:i,antialias:n,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(t){if(!this.multiView)return void(t!==this.canvas&&a());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 qs.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={...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={...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(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this._renderer.view.canvas;this._renderer=null,t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&!e.stencil&&a();const i=this.supports,n=2===this.webGLVersion,s=this.extensions;i.uint32Indices=n||!!s.uint32ElementIndex,i.uniformBufferObject=n,i.vertexArrayObject=n||!!s.vertexArrayObject,i.srgbTextures=n||!!s.srgb,i.nonPowOf2wrapping=n,i.nonPowOf2mipmaps=n,i.msaa=n,i.uint32Indices||a()}};cc.extension={type:[Ki.WebGLSystem],name:"context"},cc.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let dc=cc;var uc=(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))(uc||{}),pc=(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))(pc||{}),fc=(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))(fc||{});const gc={uint8x2:fc.UNSIGNED_BYTE,uint8x4:fc.UNSIGNED_BYTE,sint8x2:fc.BYTE,sint8x4:fc.BYTE,unorm8x2:fc.UNSIGNED_BYTE,unorm8x4:fc.UNSIGNED_BYTE,snorm8x2:fc.BYTE,snorm8x4:fc.BYTE,uint16x2:fc.UNSIGNED_SHORT,uint16x4:fc.UNSIGNED_SHORT,sint16x2:fc.SHORT,sint16x4:fc.SHORT,unorm16x2:fc.UNSIGNED_SHORT,unorm16x4:fc.UNSIGNED_SHORT,snorm16x2:fc.SHORT,snorm16x4:fc.SHORT,float16x2:fc.HALF_FLOAT,float16x4:fc.HALF_FLOAT,float32:fc.FLOAT,float32x2:fc.FLOAT,float32x3:fc.FLOAT,float32x4:fc.FLOAT,uint32:fc.UNSIGNED_INT,uint32x2:fc.UNSIGNED_INT,uint32x3:fc.UNSIGNED_INT,uint32x4:fc.UNSIGNED_INT,sint32:fc.INT,sint32x2:fc.INT,sint32x3:fc.INT,sint32x4:fc.INT},mc={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class yc{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,s)=>{i.drawArraysInstancedANGLE(t,e,n,s)},t.drawElementsInstanced=(t,e,n,s,r)=>{i.drawElementsInstancedANGLE(t,e,n,s,r)},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 t in n)if(!i[t])throw new Error(`shader and geometry incompatible, geometry missing the "${t}" attribute`)}getSignature(t,e){const i=t.attributes,n=e._attributeData,s=["g",t.uid];for(const t in i)n[t]&&s.push(t,n[t].location);return s.join("-")}getVao(t,e){return this._geometryVaoHash[t.uid]?.[e._key]||this.initGeometryVao(t,e)}initGeometryVao(t,e,i=!0){const n=this._renderer.gl,s=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const r=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[r];if(a)return o[e._key]=a,a;Ae(t,e._attributeData);const h=t.buffers;a=n.createVertexArray(),n.bindVertexArray(a);for(let t=0;t<h.length;t++){const e=h[t];s.bind(e)}return this.activateVao(t,e),o[e._key]=a,o[r]=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){const i=this._renderer.gl,n=this._renderer.buffer,s=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let r=null;for(const t in s){const o=s[t],a=o.buffer,h=n.getGlBuffer(a),l=e._attributeData[t];if(l){r!==h&&(n.bind(a),r=h);const t=l.location;i.enableVertexAttribArray(t);const e=k(o.format),s=Me(o.format);if("int"===l.format?.substring(1,4)?i.vertexAttribIPointer(t,e.size,s,o.stride,o.offset):i.vertexAttribPointer(t,e.size,s,e.normalised,o.stride,o.offset),o.instance){if(!this.hasInstance)throw new Error("geometry error, GPU Instancing is not supported on this device");{const e=o.divisor??1;i.vertexAttribDivisor(t,e)}}}}}draw(t,e,i,n){const{gl:s}=this._renderer,r=this._activeGeometry,o=mc[t||r.topology];if(n??(n=r.instanceCount),r.indexBuffer){const t=r.indexBuffer.data.BYTES_PER_ELEMENT,a=2===t?s.UNSIGNED_SHORT:s.UNSIGNED_INT;n>1?s.drawElementsInstanced(o,e||r.indexBuffer.data.length,a,(i||0)*t,n):s.drawElements(o,e||r.indexBuffer.data.length,a,(i||0)*t)}else n>1?s.drawArraysInstanced(o,i||0,e||r.getSize(),n):s.drawArrays(o,i||0,e||r.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}}yc.extension={type:[Ki.WebGLSystem],name:"geometry"};const xc=new da({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),bc=class t{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(e={}){const{useBackBuffer:i,antialias:n}={...t.defaultOptions,...e};this.useBackBuffer=i,this._antialias=n,this._renderer.context.supports.msaa||(a(),this._antialias=!1),this._state=co.for2d();const s=new Yr({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 ao({glProgram:s,resources:{uTexture:Fn.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:xc,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new Fn({source:new On({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)}};bc.extension={type:[Ki.WebGLSystem],name:"backBuffer",priority:1},bc.defaultOptions={useBackBuffer:!1};let _c=bc;class vc{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)))}}vc.extension={type:[Ki.WebGLSystem],name:"colorMask"};class wc{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:s,skipSync:r,topology:o,size:a,start:h,instanceCount:l}=t;e.shader.bind(n,r),e.geometry.bind(i,e.shader._activeProgram),s&&e.state.set(s),e.geometry.draw(o,a,h,l??i.instanceCount)}destroy(){this._renderer=null}}wc.extension={type:[Ki.WebGLSystem],name:"encoder"};class Cc{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=bt(this.maxTextures,t),this.maxUniformBindings=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS)}destroy(){}}Cc.extension={type:[Ki.WebGLSystem],name:"limits"};class Sc{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const Ic=[];Ic[$o.NONE]=void 0,Ic[$o.DISABLED]={stencilWriteMask:0,stencilReadMask:0},Ic[$o.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},Ic[$o.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},Ic[$o.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},Ic[$o.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class Ac{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:$o.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:$o.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=$o.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],n=this._gl,s=Ic[t],r=this._stencilCache;i.stencilMode=t,i.stencilReference=e,t!==$o.DISABLED?(this._stencilCache.enabled||(this._stencilCache.enabled=!0,n.enable(n.STENCIL_TEST)),t===r.stencilMode&&r.stencilReference===e||(r.stencilMode=t,r.stencilReference=e,n.stencilFunc(this._comparisonFuncMapping[s.stencilBack.compare],e,255),n.stencilOp(n.KEEP,n.KEEP,this._stencilOpsMapping[s.stencilBack.passOp]))):this._stencilCache.enabled&&(this._stencilCache.enabled=!1,n.disable(n.STENCIL_TEST))}}Ac.extension={type:[Ki.WebGLSystem],name:"stencil"};class Mc{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!F())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 ca({data:new Float32Array(e.layout.size/4),usage:la.UNIFORM|la.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]),s=this._adaptor.createUboElements(n),r=this._generateUboSync(s.uboElements);i=this._syncFunctionHash[e]={layout:s,syncFunction:r}}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 ca({data:new Float32Array(n.layout.size/4),usage:la.UNIFORM|la.COPY_DST}));let s=null;return e||(e=t.buffer.data,s=t.buffer.dataInt32),i||(i=0),n.syncFunction(t.uniforms,e,s,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 Tc={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},Pc=[{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 "}],Ec={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>":Ee(3,2),"mat4x2<f32>":Ee(4,2),"mat2x3<f32>":Ee(2,3),"mat4x3<f32>":Ee(4,3),"mat2x4<f32>":Ee(2,4),"mat3x4<f32>":Ee(3,4)},Bc={...Ec,"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 "};class Oc extends Mc{constructor(){super({createUboElements:Te,generateUboSync:Oe})}}Oc.extension={type:[Ki.WebGLSystem],name:"ubo"};class kc{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Sn}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Sn}copyToTexture(t,e,i,n,s){const r=this._renderTargetSystem,o=this._renderer,a=r.getGpuRenderTarget(t),h=o.gl;return this.finishRenderPass(t),h.bindFramebuffer(h.FRAMEBUFFER,a.resolveTargetFramebuffer),o.texture.bind(e,0),h.copyTexSubImage2D(h.TEXTURE_2D,0,s.x,s.y,i.x,i.y,n.width,n.height),e}startRenderPass(t,e=!0,i,n){const s=this._renderTargetSystem,r=t.colorTexture,o=s.getGpuRenderTarget(t);let a=n.y;t.isRoot&&(a=r.pixelHeight-n.height),t.colorTextures.forEach(t=>{this._renderer.texture.unbind(t)});const h=this._renderer.gl;h.bindFramebuffer(h.FRAMEBUFFER,o.framebuffer);const l=this._viewPortCache;l.x===n.x&&l.y===a&&l.width===n.width&&l.height===n.height||(l.x=n.x,l.y=a,l.width=n.width,l.height=n.height,h.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 Sc;return t.colorTexture instanceof Qs?(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?yo.ALL:yo.NONE);const s=this._renderer.gl;if(e&yo.COLOR){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],s.clearColor(e[0],e[1],e[2],e[3]))}s.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,s=n.createFramebuffer();if(e.resolveTargetFramebuffer=s,n.bindFramebuffer(n.FRAMEBUFFER,s),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((t,s)=>{const r=t.source;r.antialias&&(i.context.supports.msaa?e.msaa=!0:a()),i.texture.bindSource(r,0);const o=i.texture.getGlSource(r).texture;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+s,3553,o,0)}),e.msaa){const i=n.createFramebuffer();e.framebuffer=i,n.bindFramebuffer(n.FRAMEBUFFER,i),t.colorTextures.forEach((t,i)=>{const s=n.createRenderbuffer();e.msaaRenderBuffer[i]=s})}else e.framebuffer=s;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,s=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,s),t.colorTextures.forEach((t,s)=>{const r=t.source;i.texture.bindSource(r,0);const o=i.texture.getGlSource(r).internalFormat,a=e.msaaRenderBuffer[s];n.bindRenderbuffer(n.RENDERBUFFER,a),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,o,r.pixelWidth,r.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+s,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&&Qs.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&Qs.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,i=t.colorTexture;i.context2D.drawImage(e,0,i.pixelHeight-e.height)}}}const Rc=new Map,Dc=class t{constructor(i={}){if(this.uid=e("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,i={...t.defaultOptions,...i},this.stencil=i.stencil,this.depth=i.depth,this.isRoot=i.isRoot,"number"==typeof i.colorTextures){this._managedColorTextures=!0;for(let t=0;t<i.colorTextures;t++)this.colorTextures.push(new On({width:i.width,height:i.height,resolution:i.resolution,antialias:i.antialias}))}else{this.colorTextures=[...i.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),(i.depthStencilTexture||this.stencil)&&(i.depthStencilTexture instanceof Fn||i.depthStencilTexture instanceof On?this.depthStencilTexture=i.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 On({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((s,r)=>{n&&0===r||s.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)}};Dc.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Fc=Dc;class Lc{constructor(t){this.rootViewPort=new Sn,this.viewport=new Sn,this.onRenderTargetChange=new xo("onRenderTargetChange"),this.projectionMatrix=new un,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}){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),this.adaptor.prerender?.(this.rootRenderTarget)}postrender(){this.adaptor.postrender?.(this.rootRenderTarget)}bind(t,e=!0,i,n){const s=this.getRenderTarget(t),r=this.renderTarget!==s;this.renderTarget=s,this.renderSurface=t;const o=this.getGpuRenderTarget(s);s.pixelWidth===o.width&&s.pixelHeight===o.height||(this.adaptor.resizeGpuRenderTarget(s),o.width=s.pixelWidth,o.height=s.pixelHeight);const a=s.colorTexture,h=this.viewport,l=a.pixelWidth,c=a.pixelHeight;if(!n&&t instanceof Fn&&(n=t.frame),n){const t=a._resolution;h.x=n.x*t+.5|0,h.y=n.y*t+.5|0,h.width=n.width*t+.5|0,h.height=n.height*t+.5|0}else h.x=0,h.y=0,h.width=l,h.height=c;return function(t,e,i,n,s,r){const o=r?1:-1;t.identity(),t.a=1/n*2,t.d=o*(1/s*2),t.tx=-1-0*t.a,t.ty=-o-0*t.d}(this.projectionMatrix,0,0,h.width/a.resolution,h.height/a.resolution,!s.isRoot),this.adaptor.startRenderPass(s,e,i,h),r&&this.onRenderTargetChange.emit(s),s}clear(t,e=yo.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=yo.ALL,i,n){const s=this.bind(t,e,i,n);return this._renderTargetStack.push({renderTarget:s,frame:n}),s}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame)}getRenderTarget(t){return t.isTexture&&(t=t.source),this._renderSurfaceToRenderTargetHash.get(t)??this._initRenderTarget(t)}copyToTexture(t,e,i,n,s){i.x<0&&(n.width+=i.x,s.x-=i.x,i.x=0),i.y<0&&(n.height+=i.y,s.y-=i.y,i.y=0);const{pixelWidth:r,pixelHeight:o}=t;return n.width=Math.min(n.width,r-i.x),n.height=Math.min(n.height,o-i.y),this.adaptor.copyToTexture(t,e,i,n,s)}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 Qs.test(t)&&(t=ke(t).source),t instanceof Fc?e=t:t instanceof On&&(e=new Fc({colorTextures:[t]}),t.source instanceof Qs&&(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 jc extends Lc{constructor(t){super(t),this.adaptor=new kc,this.adaptor.init(t,this)}}jc.extension={type:[Ki.WebGLSystem],name:"renderTarget"};class Gc extends on{constructor({buffer:t,offset:i,size:n}){super(),this.uid=e("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=e("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=0|i,this.size=n,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=e("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}class Uc{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}}let Nc=null;const zc={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"},Hc={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"},Vc={textureCount:0,blockIndex:0};class Wc{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;Vc.textureCount=0,Vc.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,Vc)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,Vc)}bindUniformBlock(t,e,i=0){const n=this._renderer.buffer,s=this._getProgramData(this._activeProgram),r=t._bufferResource;r||this._renderer.ubo.updateUniformGroup(t);const o=t.buffer,a=n.updateBuffer(o),h=n.freeLocationForBufferBase(a);if(r){const{offset:e,size:i}=t;0===e&&i===o.data.byteLength?n.bindBufferBase(a,h):n.bindBufferRange(a,h,e)}else n.getLastBindBaseLocation(a)!==h&&n.bindBufferBase(a,h);const l=this._activeProgram._uniformBlockData[e].index;s.uniformBlockBindings[i]!==h&&(s.uniformBlockBindings[i]=h,this._renderer.gl.uniformBlockBinding(s.program,l,h))}_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]=function(t,e){const i=Re(t,t.VERTEX_SHADER,e.vertex),n=Re(t,t.FRAGMENT_SHADER,e.fragment),s=t.createProgram();t.attachShader(s,i),t.attachShader(s,n);const r=e.transformFeedbackVaryings;r&&("function"!=typeof t.transformFeedbackVaryings?a():t.transformFeedbackVaryings(s,r.names,"separate"===r.bufferMode?t.SEPARATE_ATTRIBS:t.INTERLEAVED_ATTRIBS)),t.linkProgram(s),t.getProgramParameter(s,t.LINK_STATUS)||function(t,e,i,n){t.getProgramParameter(e,t.LINK_STATUS)||(t.getShaderParameter(i,t.COMPILE_STATUS)||Ge(t,i),t.getShaderParameter(n,t.COMPILE_STATUS)||Ge(t,n),t.getProgramInfoLog(e))}(t,s,i,n),e._attributeData=function(t,e,i=!1){const n={},s=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i<s;i++){const s=e.getActiveAttrib(t,i);if(s.name.startsWith("gl_"))continue;const r=je(e,s.type);n[s.name]={location:0,format:r,stride:k(r).stride,offset:0,instance:!1,start:0}}const r=Object.keys(n);if(i){r.sort((t,e)=>t>e?1:-1);for(let i=0;i<r.length;i++)n[r[i]].location=i,e.bindAttribLocation(t,i,r[i]);e.linkProgram(t)}else for(let i=0;i<r.length;i++)n[r[i]].location=e.getAttribLocation(t,r[i]);return n}(s,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 s=0;s<n;s++){const n=e.getActiveUniform(t,s),r=n.name.replace(/\[.*?\]$/,""),o=!!n.name.match(/\[.*?\]$/),a=Le(e,n.type);i[r]={name:r,index:s,type:a,size:n.size,isArray:o,value:Fe(a,n.size)}}return i}(s,t),e._uniformBlockData=function(t,e){if(!e.ACTIVE_UNIFORM_BLOCKS)return{};const i={},n=e.getProgramParameter(t,e.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<n;s++){const n=e.getActiveUniformBlockName(t,s),r=e.getUniformBlockIndex(t,n),o=e.getActiveUniformBlockParameter(t,s,e.UNIFORM_BLOCK_DATA_SIZE);i[n]={name:n,index:r,size:o}}return i}(s,t),t.deleteShader(i),t.deleteShader(n);const o={};for(const i in e._uniformData){const n=e._uniformData[i];o[i]={location:t.getUniformLocation(s,i),value:Fe(n.type,n.size)}}return new Uc(s,o)}(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 s=!1,r=0;const o=e._getProgramData(t.glProgram);for(const a in t.groups){const h=t.groups[a];i.push(`\n resources = g[${a}].resources;\n `);for(const l in h.resources){const c=h.resources[l];if(c instanceof so)if(c.ubo){const e=t._uniformBindMap[a][Number(l)];i.push(`\n sS.bindUniformBlock(\n resources[${l}],\n '${e}',\n ${t.glProgram._uniformBlockData[e].index}\n );\n `)}else i.push(`\n ugS.updateUniformGroup(resources[${l}], p, sD);\n `);else if(c instanceof Gc){const e=t._uniformBindMap[a][Number(l)];i.push(`\n sS.bindUniformBlock(\n resources[${l}],\n '${e}',\n ${t.glProgram._uniformBlockData[e].index}\n );\n `)}else if(c instanceof On){const h=t._uniformBindMap[a][l],c=o.uniformData[h];c&&(s||(s=!0,n.push("\n var tS = r.texture;\n ")),e._gl.uniform1i(c.location,r),i.push(`\n tS.bind(resources[${l}], ${r});\n `),r++)}}}const a=[...n,...i].join("\n");return new Function("r","s","sD",a)}(t,e)}resetState(){this._activeProgram=null}}Wc.extension={type:[Ki.WebGLSystem],name:"shader"};const Zc={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);"},Jc={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 Xc{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);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){return this._uniformGroupSyncHash[t._signature]?.[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 so?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 Gc&&i.push(`\n renderer.shader.bindBufferResource(uv.${n}, "${n}");\n `);continue}const s=t.uniformStructures[n];let r=!1;for(let t=0;t<Pc.length;t++){const e=Pc[t];if(s.type===e.type&&e.test(s)){i.push(`name = "${n}";`,Pc[t].uniform),r=!0;break}}if(!r){const t=(1===s.size?Zc:Jc)[s.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,s=[`${i}-`];for(const t in n)s.push(t),e[t]&&s.push(e[t].type);return s.join("-")}destroy(){this._renderer=null,this._cache=null}}Xc.extension={type:[Ki.WebGLSystem],name:"uniformGroup"};const Yc=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=co.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 qs.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}};Yc.extension={type:[Ki.WebGLSystem],name:"state"};let Kc=Yc;class qc{constructor(t){this.target=pc.TEXTURE_2D,this.texture=t,this.width=-1,this.height=-1,this.type=fc.UNSIGNED_BYTE,this.internalFormat=uc.RGBA,this.format=uc.RGBA,this.samplerType=0}}const Qc={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}},$c={"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},td={id:"compressed",upload(t,e,i){i.pixelStorei(i.UNPACK_ALIGNMENT,4);let n=t.pixelWidth,s=t.pixelHeight;const r=!!$c[t.format];for(let o=0;o<t.resource.length;o++){const a=t.resource[o];r?i.compressedTexImage2D(i.TEXTURE_2D,o,e.internalFormat,n,s,0,a):i.texImage2D(i.TEXTURE_2D,o,e.internalFormat,n,s,0,e.format,e.type,a),n=Math.max(n>>1,1),s=Math.max(s>>1,1)}}},ed={id:"image",upload(t,e,i,n){const s=e.width,r=e.height,o=t.pixelWidth,a=t.pixelHeight,h=t.resourceWidth,l=t.resourceHeight;h<o||l<a?(s===o&&r===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,h,l,e.format,e.type,t.resource):i.texSubImage2D(i.TEXTURE_2D,0,0,0,e.format,e.type,t.resource)):s===o&&r===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}},id={id:"video",upload(t,e,i,n){t.isValid?ed.upload(t,e,i,n):i.texImage2D(e.target,0,e.internalFormat,1,1,0,e.format,e.type,null)}},nd={linear:9729,nearest:9728},sd={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},rd={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},od={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};class ad{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:ed,buffer:Qc,video:id,compressed:td},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 qs.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),{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 t=0;t<16;t++)this.bind(Fn.EMPTY,t)}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=Fn.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 t=0;t<i.length;t++)if(i[t]===e){this._activateLocation(t);const s=this.getGlSource(e);n.bindTexture(s.target,null),i[t]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,i=new qc(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,Ue(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,Ue(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),s=qs.get().createCanvas();s.width=i,s.height=n;const r=s.getContext("2d");if(r){const t=r.createImageData(i,n);t.data.set(e),r.putImageData(t,0,0)}return s}getPixels(t){const e=t.source.resolution,i=t.frame,n=Math.max(Math.round(i.width*e),1),s=Math.max(Math.round(i.height*e),1),r=new Uint8Array(4*n*s),o=this._renderer,a=o.renderTarget.getRenderTarget(t),h=o.renderTarget.getGpuRenderTarget(a),l=o.gl;return l.bindFramebuffer(l.FRAMEBUFFER,h.resolveTargetFramebuffer),l.readPixels(Math.round(i.x*e),Math.round(i.y*e),n,s,l.RGBA,l.UNSIGNED_BYTE,r),{pixels:new Uint8ClampedArray(r.buffer),width:n,height:s}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(Fn.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}ad.extension={type:[Ki.WebGLSystem],name:"texture"};class hd{contextChange(t){const e=new so({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new un,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),i=t.limits.maxBatchableTextures,n=kt({name:"graphics",bits:[wa,jt(i),$l,Aa]});this.shader=new ao({glProgram:n,resources:{localUniforms:e,batchSamplers:Gt(i)}})}execute(t,e){const i=e.context,n=i.customShader||this.shader,s=t.renderer,r=s.graphicsContext,{batcher:o,instructions:a}=r.getContextRenderData(i);n.groups[0]=s.globalUniforms.bindGroup,s.state.set(t.state),s.shader.bind(n),s.geometry.bind(o.geometry,n.glProgram);const h=a.instructions;for(let t=0;t<a.instructionSize;t++){const e=h[t];if(e.size){for(let t=0;t<e.textures.count;t++)s.texture.bind(e.textures.textures[t],t);s.geometry.draw(e.topology,e.size,e.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}hd.extension={type:[Ki.WebGLPipesAdaptor],name:"graphics"};class ld{init(){const t=kt({name:"mesh",bits:[$l,ec,Aa]});this._shader=new ao({glProgram:t,resources:{uTexture:Fn.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new un}}}})}execute(t,e){const i=t.renderer;let n=e._shader;if(n){if(!n.glProgram)return void a(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}}ld.extension={type:[Ki.WebGLPipesAdaptor],name:"mesh"};class cd{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}}cd.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"customRender"};class dd{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(){}}const ud=new un;class pd{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&&(ms.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){const i=t._batchableRenderGroup??(t._batchableRenderGroup=ms.get(dd));i.renderable=t.root,i.transform=t.root.relativeGroupTransform,i.texture=t.texture,i.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.batch.addToBatch(i,e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;const e=ud.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}),Ne(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}),Ne(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}pd.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"renderGroup"};const fd=new Hs,gd=new un;class md{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 s=this._renderer;let r=gd;e&&(r=r.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const o=s.renderPipes;this._updateCachedRenderGroups(t.renderGroup,null),this._updateRenderGroups(t.renderGroup),s.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),Ne(t.renderGroup,o),o.uniformBatch&&o.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(r),t.parent=i,t.renderGroup.renderGroupParent=n}destroy(){this._renderer=null}_updateCachedRenderGroups(t,e){if(t.isCachedAsTexture){if(!t.updateCacheTexture)return;e=t}t._parentCacheAsTextureRenderGroup=e;for(let i=t.renderGroupChildren.length-1;i>=0;i--)this._updateCachedRenderGroups(t.renderGroupChildren[i],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const e=t.root.getLocalBounds();e.ceil();const i=t.texture;t.texture&&Ls.returnTexture(t.texture,!0);const n=this._renderer,s=t.textureOptions.resolution||n.view.resolution,r=t.textureOptions.antialias??n.view.antialias,o=t.textureOptions.scaleMode??"linear",a=Ls.getOptimalTexture(e.width,e.height,s,r);a._source.style=new En({scaleMode:o}),t.texture=a,t._textureBounds||(t._textureBounds=new jn),t._textureBounds.copyFrom(e),i!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(Ls.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?ze(t.childrenRenderablesToUpdate.list,0):function(t,e){const{list:i,index:n}=t.childrenRenderablesToUpdate;let s=!1;for(let t=0;t<n;t++){const n=i[t];if(s=e[n.renderPipeId].validateRenderable(n),s)break}t.structureDidChange=s}(t,i),He(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 e=0;e<t.renderGroupChildren.length;e++)this._updateRenderGroups(t.renderGroupChildren[e])}_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)}ze(e,i)}_buildInstructions(t,e){const i=t.root,n=t.instructionSet;n.reset();const s=e.renderPipes?e:e.batch.renderer,r=s.renderPipes;r.batch.buildStart(n),r.blendMode.buildStart(),r.colorMask.buildStart(),i.sortableChildren&&i.sortChildren(),i.collectRenderablesWithEffects(n,s,null),r.batch.buildEnd(n),r.blendMode.buildEnd(n)}}md.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"renderGroup"};class yd{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 dd;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}}yd.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"sprite"};const xd=class t{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new ps(0),this.color=this._backgroundColor,this.alpha=1}init(e){e={...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){ps.shared.setValue(t).alpha<1&&1===this._backgroundColor.alpha&&a(),this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};xd.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"background",priority:0},xd.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let bd=xd;const _d={};$i.handle(Ki.BlendMode,t=>{if(!t.name)throw new Error("BlendMode extension must have a name property");_d[t.name]=t.ref},t=>{delete _d[t.name]});class vd{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=!!_d[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(!_d[e])return void a();let i=this._filterHash[e];i||(i=this._filterHash[e]=new _s,i.filters=[new _d[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}}vd.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"blendMode"};const wd={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Cd=class t{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof Hs||t instanceof Fn?{target:t,...e}:{...e,...t}}async image(t){const e=qs.get().createImage();return e.src=await this.base64(t),e}async base64(e){e=this._normalizeOptions(e,t.defaultImageOptions);const{format:i,quality:n}=e,s=this.canvas(e);if(void 0!==s.toBlob)return new Promise((t,e)=>{s.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)},wd[i],n)});if(void 0!==s.toDataURL)return s.toDataURL(wd[i],n);if(void 0!==s.convertToBlob){const t=await s.convertToBlob({type:wd[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 Fn)return i.texture.generateCanvas(e);const n=i.textureGenerator.generateTexture(t),s=i.texture.generateCanvas(n);return n.destroy(!0),s}pixels(t){const e=(t=this._normalizeOptions(t)).target,i=this._renderer,n=e instanceof Fn?e:i.textureGenerator.generateTexture(t),s=i.texture.getPixels(n);return e instanceof Hs&&n.destroy(!0),s}texture(t){return(t=this._normalizeOptions(t)).target instanceof Fn?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){t=this._normalizeOptions(t);const e=this.canvas(t),i=document.createElement("a");i.download=t.filename??"image.png",i.href=e.toDataURL("image/png"),document.body.appendChild(i),i.click(),document.body.removeChild(i)}log(t){const e=t.width??200;t=this._normalizeOptions(t),["font-size: 1px;",`padding: ${e}px 300px;`,`background: url(${this.canvas(t).toDataURL()}) no-repeat;`,"background-size: contain;"].join(" ")}destroy(){this._renderer=null}};Cd.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem],name:"extract"},Cd.defaultImageOptions={format:"png",quality:1};let Sd=Cd;class Id extends Fn{static create(t){return new Id({source:new On(t)})}resize(t,e,i){return this.source.resize(t,e,i),this}}const Ad=new Sn,Md=new jn,Td=[0,0,0,0];class Pd{constructor(t){this._renderer=t}generateTexture(t){t instanceof Hs&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const e=t.resolution||this._renderer.resolution,i=t.antialias||this._renderer.view.antialias,n=t.target;let s=t.clearColor;s=s?Array.isArray(s)&&4===s.length?s:ps.shared.setValue(s).toArray():Td;const r=t.frame?.copyTo(Ad)||g(n,Md).rectangle;r.width=0|Math.max(r.width,1/e),r.height=0|Math.max(r.height,1/e);const o=Id.create({...t.textureSourceOptions,width:r.width,height:r.height,resolution:e,antialias:i}),a=un.shared.translate(-r.x,-r.y);return this._renderer.render({container:n,transform:a,target:o,clearColor:s}),o.source.updateMipmaps(),o}destroy(){this._renderer=null}}Pd.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem],name:"textureGenerator"};class Ed{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:s}){const r=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{worldTransformMatrix:new un,worldColor:4294967295,offset:new cn},a={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||r.size,worldTransformMatrix:i||o.worldTransformMatrix,worldColor:n||o.worldColor,offset:s||o.offset,bindGroup:null},h=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(h);const l=h.uniforms;let c;l.uProjectionMatrix=a.projectionMatrix,l.uResolution=a.resolution,l.uWorldTransformMatrix.copyFrom(a.worldTransformMatrix),l.uWorldTransformMatrix.tx-=a.offset.x,l.uWorldTransformMatrix.ty-=a.offset.y,Ze(a.worldColor,l.uWorldColorAlpha,0),h.update(),this._renderer.renderPipes.uniformBatch?c=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(h,!1):(c=this._bindGroupPool.pop()||new ro,this._activeBindGroups.push(c),c.setResource(h,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===oo.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 so({uProjectionMatrix:{value:new un,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new un,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null}}Ed.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"globalUniforms"};let Bd=1;class Od{constructor(){this._tasks=[],this._offset=0}init(){sr.system.add(this._update,this)}repeat(t,e,i=!0){const n=Bd++;let s=0;return i&&(this._offset+=1e3,s=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:s,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(){sr.system.remove(this._update,this),this._tasks.length=0}}Od.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"scheduler",priority:0};let kd=!1;class Rd{constructor(t){this._renderer=t}init(t){if(t.hello){let t=this._renderer.name;this._renderer.type===oo.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),function(t){if(!kd){if(qs.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${Io} (${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 ${Io} - ${t} - http://www.pixijs.com/`);kd=!0}}(t)}}}Rd.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"hello",priority:-2},Rd.defaultOptions={hello:!1};let Dd=0;const Fd=class t{constructor(t){this._managedRenderables=[],this._managedHashes=[],this._managedArrays=[],this._renderer=t}init(e){e={...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]=Je(t.context[t.hash])},this._frequency),this._arrayHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedArrays)Xe(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=Dd++,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(){const t=this._now,e=this._managedRenderables,i=this._renderer.renderPipes;let n=0;for(let s=0;s<e.length;s++){const r=e[s];if(null===r){n++;continue}const o=r.renderGroup??r.parentRenderGroup,a=o?.instructionSet?.gcTick??-1;if((o?.gcTick??0)===a&&(r._lastUsed=t),t-r._lastUsed>this.maxUnusedTime){if(!r.destroyed){const t=i;o&&(o.structureDidChange=!0),t[r.renderPipeId].destroyRenderable(r)}r._lastUsed=-1,n++,r.off("destroyed",this._removeRenderable,this)}else e[s-n]=r}e.length-=n}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)}};Fd.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem],name:"renderableGC",priority:0},Fd.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let Ld=Fd;const jd=class t{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(e){e={...t.defaultOptions,...e},this.checkCountMax=e.textureGCCheckCountMax,this.maxIdle=e.textureGCAMaxIdle??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}};jd.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem],name:"textureGC"},jd.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Gd=jd;const Ud=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={...t.defaultOptions,...e}).view&&(i(0,"ViewSystem.view has been renamed to ViewSystem.canvas"),e.canvas=e.view),this.screen=new Sn(0,0,e.width,e.height),this.canvas=e.canvas||qs.get().createCanvas(),this.antialias=!!e.antialias,this.texture=ke(this.canvas,e),this.renderTarget=new Fc({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:t?.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}};Ud.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"view",priority:0},Ud.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};const Nd=[bd,Ed,Rd,Ud,md,Gd,Pd,Sd,Mo,Ld,Od],zd=[vd,Kl,yd,pd,sc,oc,rc,cd],Hd=[...Nd,Oc,_c,dc,Cc,lc,ad,jc,yc,Xc,Wc,wc,Kc,Ac,vc],Vd=[...zd],Wd=[Zl,ld,hd],Zd=[],Jd=[],Xd=[];$i.handleByNamedList(Ki.WebGLSystem,Zd),$i.handleByNamedList(Ki.WebGLPipes,Jd),$i.handleByNamedList(Ki.WebGLPipesAdaptor,Xd),$i.add(...Hd,...Vd,...Wd);const Yd=Object.freeze(Object.defineProperty({__proto__:null,WebGLRenderer:class extends Co{constructor(){super({name:"webgl",type:oo.WEBGL,systems:Zd,renderPipes:Jd,renderPipeAdaptors:Xd})}}},Symbol.toStringTag,{value:"Module"}));class Kd{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){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,i)}_createBindGroup(t,e,i){const n=this._gpu.device,s=e.layout[i],r=[],o=this._renderer;for(const e in s){const i=t.resources[e]??t.resources[s[e]];let n;if("uniformGroup"===i._resourceType){const t=i;o.ubo.updateUniformGroup(t);const e=t.buffer;n={buffer:o.buffer.getGPUBuffer(e),offset:0,size:e.descriptor.size}}else if("buffer"===i._resourceType){const t=i;n={buffer:o.buffer.getGPUBuffer(t),offset:0,size:t.descriptor.size}}else if("bufferResource"===i._resourceType){const t=i;n={buffer:o.buffer.getGPUBuffer(t.buffer),offset:t.offset,size:t.size}}else if("textureSampler"===i._resourceType){const t=i;n=o.texture.getGpuSampler(t)}else if("textureSource"===i._resourceType){const t=i;n=o.texture.getGpuSource(t).createView({})}r.push({binding:s[e],resource:n})}const a=o.shader.getProgramData(e).bindGroups[i],h=n.createBindGroup({layout:a,entries:r});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}}Kd.extension={type:[Ki.WebGPUSystem],name:"bindGroup"};class qd{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&&(mt(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}}qd.extension={type:[Ki.WebGPUSystem],name:"buffer"};class Qd{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 $d{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}}$d.extension={type:[Ki.WebGPUSystem],name:"colorMask"};class tu{constructor(t){this._renderer=t}async init(t){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}async _createDeviceAndAdaptor(t){const e=await qs.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=await e.requestDevice({requiredFeatures:i});return{adapter:e,device:n}}destroy(){this.gpu=null,this._renderer=null}}tu.extension={type:[Ki.WebGPUSystem],name:"device"},tu.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class eu{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 s=this._renderer.pipeline.getPipeline(t,e,i,n);this.setPipeline(s)}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 e in i)this._setVertexBuffer(e,t.attributes[i[e]].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:s,size:r,start:o,instanceCount:a,skipSync:h}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,n,s),this.setGeometry(e,i.gpuProgram),this._setShaderBindGroups(i,h),e.indexBuffer?this.renderPassEncoder.drawIndexed(r||e.indexBuffer.data.length,a??e.instanceCount,o||0):this.renderPassEncoder.draw(r||e.getSize(),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={...this._boundVertexBuffer},n=this._boundIndexBuffer,s={...this._boundBindGroup};this._clearCache();const r=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(r.x,r.y,r.width,r.height,0,1),this.setPipeline(e);for(const t in i)this._setVertexBuffer(t,i[t]);for(const t in s)this.setBindGroup(t,s[t],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}}eu.extension={type:[Ki.WebGPUSystem],name:"encoder",priority:1};class iu{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}iu.extension={type:[Ki.WebGPUSystem],name:"limits"};class nu{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:$o.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}}nu.extension={type:[Ki.WebGPUSystem],name:"stencil"};const su={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}};class ru extends Mc{constructor(){super({createUboElements:Ye,generateUboSync:qe})}}ru.extension={type:[Ki.WebGPUSystem],name:"ubo"};const ou=128;class au{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 Qd({minUniformOffsetAlignment:ou});for(let t=0;t<2;t++){let e=la.UNIFORM|la.COPY_DST;0===t&&(e|=la.COPY_SRC),this._buffers.push(new ca({data:this._batchBuffer.data,usage:e}))}}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/ou),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/ou)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/ou)}getArrayBufferResource(t){const e=this._batchBuffer.addGroup(t)/ou;return this._getBufferResource(e)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new Gc({buffer:e,offset:256*(t/2|0),size:ou})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new ro({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 s=this._buffers[n];i.copyBufferToBuffer(t.getGPUBuffer(e),ou,t.getGPUBuffer(s),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}}au.extension={type:[Ki.WebGPUPipes],name:"uniformBatch"};const hu={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};class lu{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($o.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=Ic[t],this._updatePipeHash())}setPipeline(t,e,i,n){const s=this.getPipeline(t,e,i);n.setPipeline(s)}getPipeline(t,e,i,n){t._layoutKey||(Ae(t,e.attributeData),this._generateBufferKey(t)),n||(n=t.topology);const s=function(t,e,i,n,s){return t<<24|e<<16|i<<10|n<<5|s}(t._layoutKey,e._layoutKey,i.data,i._blendModeId,hu[n]);return this._pipeCache[s]||(this._pipeCache[s]=this._createPipeline(t,e,i,n)),this._pipeCache[s]}_createPipeline(t,e,i,n){const s=this._gpu.device,r=this._createVertexBufferLayouts(t,e),o=this._renderer.state.getColorTargets(i);o[0].writeMask=this._stencilMode===$o.RENDERING_MASK_ADD?0:this._colorMask;const a=this._renderer.shader.getProgramData(e).pipeline,h={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:r},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"};return this._depthStencilAttachment&&(h.depthStencil={...this._stencilState,format:"depth24plus-stencil8",depthWriteEnabled:i.depthTest,depthCompare:i.depthTest?"less":"always"}),s.createRenderPipeline(h)}_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 s=e.join("|");return t._layoutKey=E(s,"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 s=e.join("|");return t._attributeLocationsKey=E(s,"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),s=Object.create(null),r=e.attributeData;for(let t=0;t<n.length;t++){const e=Object.values(n[t].attributes)[0].shaderLocation;for(const i in r)if(r[i].location===e){s[t]=i;break}}return this._bindingNamesCache[i]=s,s}_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=>{const s={arrayStride:0,stepMode:"vertex",attributes:[]},r=s.attributes;for(const n in e.attributeData){const o=t.attributes[n];1!==(o.divisor??1)&&a(o.divisor),o.buffer===i&&(s.arrayStride=o.stride,s.stepMode=o.instance?"instance":"vertex",r.push({shaderLocation:e.attributeData[n].location,offset:o.offset,format:o.format}))}r.length&&n.push(s)}),this._bufferLayoutsCache[i]=n,n}_updatePipeHash(){const t=(e=this._stencilMode,i=this._multisampleCount,this._colorMask<<6|e<<3|this._depthStencilAttachment<<1|i);var e,i;this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}lu.extension={type:[Ki.WebGPUSystem],name:"pipeline"};class cu{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class du{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,n,s){const r=this._renderer,o=this._getGpuColorTexture(t),a=r.texture.getGpuSource(e.source);return r.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:i},{texture:a,origin:s},n),e}startRenderPass(t,e=!0,i,n){const s=this._renderTargetSystem.getGpuRenderTarget(t),r=this.getDescriptor(t,e,i);s.descriptor=r,this._renderer.pipeline.setRenderTarget(s),this._renderer.encoder.beginRenderPass(s),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?yo.ALL:yo.NONE);const n=this._renderTargetSystem,s=n.getGpuRenderTarget(t),r=t.colorTextures.map((t,r)=>{const o=s.contexts[r];let a,h;a=o?o.getCurrentTexture().createView():this._renderer.texture.getGpuSource(t).createView({mipLevelCount:1}),s.msaaTextures[r]&&(h=a,a=this._renderer.texture.getTextureView(s.msaaTextures[r]));const l=e&yo.COLOR?"clear":"load";return i??(i=n.defaultClearColor),{view:a,resolveTarget:h,clearValue:i,storeOp:"store",loadOp:l}});let o;if(!t.stencil&&!t.depth||t.depthStencilTexture||(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=s.msaa?4:1),t.depthStencilTexture){const i=e&yo.STENCIL?"clear":"load",n=e&yo.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:r,depthStencilAttachment:o}}clear(t,e=!0,i,n){if(!e)return;const{gpu:s,encoder:r}=this._renderer,o=s.device;if(null===r.commandEncoder){const s=o.createCommandEncoder(),r=this.getDescriptor(t,e,i),a=s.beginRenderPass(r);a.setViewport(n.x,n.y,n.width,n.height,0,1),a.end();const h=s.finish();o.queue.submit([h])}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 Qs){const n=t.resource.getContext("webgpu"),s=t.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:s})}catch(t){}e.contexts[i]=n}if(e.msaa=t.source.antialias,t.source.antialias){const t=new On({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];n?.resize(t.source.width,t.source.height,t.source._resolution)})}}class uu extends Lc{constructor(t){super(t),this.adaptor=new du,this.adaptor.init(t,this)}}uu.extension={type:[Ki.WebGPUSystem],name:"renderTarget"};class pu{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}}pu.extension={type:[Ki.WebGPUSystem],name:"shader"};const fu={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 gu{constructor(){this.defaultState=new co,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:fu[t.blendMode]||fu.normal}]}destroy(){this.gpu=null}}gu.extension={type:[Ki.WebGPUSystem],name:"state"};const mu={type:"image",upload(t,e,i){const n=t.resource,s=(0|t.pixelWidth)*(0|t.pixelHeight),r=n.byteLength/s;i.device.queue.writeTexture({texture:e},n,{offset:0,rowsPerImage:t.pixelHeight,bytesPerRow:t.pixelHeight*r},{width:t.pixelWidth,height:t.pixelHeight,depthOrArrayLayers:1})}},yu={"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}},xu={blockBytes:4,blockWidth:1,blockHeight:1},bu={type:"compressed",upload(t,e,i){let n=t.pixelWidth,s=t.pixelHeight;const r=yu[t.format]||xu;for(let o=0;o<t.resource.length;o++){const a=t.resource[o],h=Math.ceil(n/r.blockWidth)*r.blockBytes;i.device.queue.writeTexture({texture:e,mipLevel:o},a,{offset:0,bytesPerRow:h},{width:Math.ceil(n/r.blockWidth)*r.blockWidth,height:Math.ceil(s/r.blockHeight)*r.blockHeight,depthOrArrayLayers:1}),n=Math.max(n>>1,1),s=Math.max(s>>1,1)}}},_u={type:"image",upload(t,e,i){const n=t.resource;if(!n)return;if(globalThis.HTMLImageElement&&n instanceof HTMLImageElement){const e=qs.get().createCanvas(n.width,n.height);e.getContext("2d").drawImage(n,0,0,n.width,n.height),t.resource=e,a()}const s=Math.min(e.width,t.resourceWidth||t.pixelWidth),r=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:s,height:r})}},vu={type:"video",upload(t,e,i){_u.upload(t,e,i)}};class wu{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,s=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!s){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 r=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}),h=s?1:0;for(let s=1;s<t.mipLevelCount;++s){const t=i.createView({baseMipLevel:h++,mipLevelCount:1,dimension:"2d",baseArrayLayer:a,arrayLayerCount:1}),s=r.beginRenderPass({colorAttachments:[{view:t,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),l=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.sampler},{binding:1,resource:n}]});s.setPipeline(e),s.setBindGroup(0,l),s.draw(3,1,0,0),s.end(),n=t}}if(!s){const e={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:n};for(let n=1;n<t.mipLevelCount;++n)r.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([r.finish()]),s||i.destroy(),t}}class Cu{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:_u,buffer:mu,video:vu,compressed:bu},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=yu[t.format]||{blockWidth:1,blockHeight:1},n=Math.ceil(t.pixelWidth/i.blockWidth)*i.blockWidth,s=Math.ceil(t.pixelHeight/i.blockHeight)*i.blockHeight,r={label:t.label,size:{width:n,height:s},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},o=this._gpuSources[t.uid]=this._gpu.device.createTexture(r);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 wu(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){return this._bindGroupHash[t.uid]??this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source;return this._bindGroupHash[t.uid]=new ro({0:e,1:e.style,2:new so({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){const e=t.source;return this._textureViewHash[e.uid]??this._createTextureView(e)}_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=qs.get().createCanvas();n.width=t.source.pixelWidth,n.height=t.source.pixelHeight;const s=n.getContext("webgpu");return s.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:qs.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:s.getCurrentTexture()},{width:n.width,height:n.height}),e.gpu.device.queue.submit([i.finish()]),n}getPixels(t){const e=this.generateCanvas(t),i=ph.getOptimalCanvasAndContext(e.width,e.height),n=i.context;n.drawImage(e,0,0);const{width:s,height:r}=e,o=n.getImageData(0,0,s,r),a=new Uint8ClampedArray(o.data.buffer);return ph.returnCanvasAndContext(i),{pixels:a,width:s,height:r}}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];i?.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}Cu.extension={type:[Ki.WebGPUSystem],name:"texture"};class Su{constructor(){this._maxTextures=0}contextChange(t){const e=new so({uTransformMatrix:{value:new un,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=Ot({name:"graphics",bits:[va,Ft(this._maxTextures),Ql,Ia]});this.shader=new ao({gpuProgram:i,resources:{localUniforms:e}})}execute(t,e){const i=e.context,n=i.customShader||this.shader,s=t.renderer,r=s.graphicsContext,{batcher:o,instructions:a}=r.getContextRenderData(i),h=s.encoder;h.setGeometry(o.geometry,n.gpuProgram);const l=s.globalUniforms.bindGroup;h.setBindGroup(0,l,n.gpuProgram);const c=s.renderPipes.uniformBatch.getUniformBindGroup(n.resources.localUniforms,!0);h.setBindGroup(2,c,n.gpuProgram);const d=a.instructions;let u=null;for(let e=0;e<a.instructionSize;e++){const i=d[e];if(i.topology!==u&&(u=i.topology,h.setPipelineFromGeometryProgramAndState(o.geometry,n.gpuProgram,t.state,i.topology)),n.groups[1]=i.bindGroup,!i.gpuBindGroup){const t=i.textures;i.bindGroup=gt(t.textures,t.count,this._maxTextures),i.gpuBindGroup=s.bindGroup.getBindGroup(i.bindGroup,n.gpuProgram,1)}h.setBindGroup(1,i.bindGroup,n.gpuProgram),h.renderPassEncoder.drawIndexed(i.size,1,i.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}Su.extension={type:[Ki.WebGPUPipesAdaptor],name:"graphics"};class Iu{init(){const t=Ot({name:"mesh",bits:[ql,tc,Ia]});this._shader=new ao({gpuProgram:t,resources:{uTexture:Fn.EMPTY._source,uSampler:Fn.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new un}}}})}execute(t,e){const i=t.renderer;let n=e._shader;if(n){if(!n.gpuProgram)return void a(e.shader)}else n=this._shader,n.groups[2]=i.texture.getTextureBindGroup(e.texture);const s=n.gpuProgram;if(s.autoAssignGlobalUniforms&&(n.groups[0]=i.globalUniforms.bindGroup),s.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}}Iu.extension={type:[Ki.WebGPUPipesAdaptor],name:"mesh"};const Au=[...Nd,ru,eu,tu,iu,qd,Cu,uu,pu,gu,lu,$d,nu,Kd],Mu=[...zd,au],Tu=[Xl,Iu,Su],Pu=[],Eu=[],Bu=[];$i.handleByNamedList(Ki.WebGPUSystem,Pu),$i.handleByNamedList(Ki.WebGPUPipes,Eu),$i.handleByNamedList(Ki.WebGPUPipesAdaptor,Bu),$i.add(...Au,...Mu,...Tu);const Ou=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:class extends Co{constructor(){super({name:"webgpu",type:oo.WEBGPU,systems:Pu,renderPipes:Eu,renderPipeAdaptors:Bu})}}},Symbol.toStringTag,{value:"Module"}));class ku{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{ms.return(t)}),this.batches.length=0}}class Ru{constructor(t,e){this.state=co.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 t=0;t<e.length;t++){const i=e[t];i._batcher.updateElement(i)}}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 s=n.resources.localUniforms.uniforms;s.uTransformMatrix=t.groupTransform,s.uRound=e._roundPixels|t._roundPixels,Ze(t.groupColorAlpha,s.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 t=0;t<n.length;t++){const s=n[t];i.addToBatch(s,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new ku;return t._gpuData[this.renderer.uid]=e,e}_updateBatchesForRenderable(t,e){const i=t.context,n=this.renderer.graphicsContext.getGpuContext(i),s=this.renderer._roundPixels|t._roundPixels;e.batches=n.batches.map(e=>{const i=ms.get(ka);return e.copyTo(i),i.renderable=t,i.roundPixels=s,i})}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}Ru.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"graphics"};const Du=class t extends El{constructor(...t){super({});let e=t[0]??{};"number"==typeof e&&(i(0,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),e={width:e,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(e)}build(e){e={...t.defaultOptions,...e},this.verticesX=this.verticesX??e.verticesX,this.verticesY=this.verticesY??e.verticesY,this.width=this.width??e.width,this.height=this.height??e.height;const i=this.verticesX*this.verticesY,n=[],s=[],r=[],o=this.verticesX-1,a=this.verticesY-1,h=this.width/o,l=this.height/a;for(let t=0;t<i;t++){const e=t%this.verticesX,i=t/this.verticesX|0;n.push(e*h,i*l),s.push(e/o,i/a)}const c=o*a;for(let t=0;t<c;t++){const e=t%o,i=t/o|0,n=i*this.verticesX+e,s=i*this.verticesX+e+1,a=(i+1)*this.verticesX+e,h=(i+1)*this.verticesX+e+1;r.push(n,s,a,s,h,a)}this.buffers[0].data=new Float32Array(n),this.buffers[1].data=new Float32Array(s),this.indexBuffer.data=new Uint32Array(r),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};Du.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let Fu=Du;class Lu{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 ju{destroy(){}}class Gu{constructor(t,e){this.localUniforms=new so({uTransformMatrix:{value:new un,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new ro({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){const i=this.renderer.renderPipes.batch,n=this._getMeshData(t);if(t.didViewUpdate&&(n.indexSize=t._geometry.indices?.length,n.vertexSize=t._geometry.positions?.length),n.batched){const n=this._getBatchableMesh(t);n.setTexture(t._texture),n.geometry=t._geometry,i.addToBatch(n,e)}else i.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=yt(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),Ze(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 ju),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 ju),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new Lu;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}}Gu.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"mesh"};class Uu{execute(t,e){const i=t.state,n=t.renderer,s=e.shader||t.defaultShader;s.resources.uTexture=e.texture._source,s.resources.uniforms=t.localUniforms;const r=n.gl,o=t.getBuffers(e);n.shader.bind(s),n.state.set(i),n.geometry.bind(o.geometry,s.glProgram);const a=2===o.geometry.indexBuffer.data.BYTES_PER_ELEMENT?r.UNSIGNED_SHORT:r.UNSIGNED_INT;r.drawElements(r.TRIANGLES,6*e.particleChildren.length,a,0)}}class Nu{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 s=t.state,r=t.getBuffers(e);i.encoder.draw({geometry:r.geometry,shader:e.shader||t.defaultShader,state:s,size:6*e.particleChildren.length})}}class zu{constructor(t){this._size=0,this._generateParticleUpdateCache={};const e=this._size=t.size??1e3,i=t.properties;let n=0,s=0;for(const t in i){const e=i[t],r=k(e.format);e.dynamic?s+=r.stride:n+=r.stride}this._dynamicStride=s/4,this._staticStride=n/4,this.staticAttributeBuffer=new qo(4*e*n),this.dynamicAttributeBuffer=new qo(4*e*s),this.indexBuffer=Qe(e);const r=new da;let o=0,a=0;this._staticBuffer=new ca({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:la.VERTEX|la.COPY_DST}),this._dynamicBuffer=new ca({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:la.VERTEX|la.COPY_DST});for(const t in i){const e=i[t],n=k(e.format);e.dynamic?(r.addAttribute(e.attributeName,{buffer:this._dynamicBuffer,stride:4*this._dynamicStride,offset:4*o,format:e.format}),o+=n.size):(r.addAttribute(e.attributeName,{buffer:this._staticBuffer,stride:4*this._staticStride,offset:4*a,format:e.format}),a+=n.size)}r.addIndex(this.indexBuffer);const h=this.getParticleUpdate(i);this._dynamicUpload=h.dynamicUpdate,this._staticUpload=h.staticUpdate,this.geometry=r}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:$e(t,!0),staticUpdate:$e(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 qo(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new qo(this._size*this._dynamicStride*4*4),this.indexBuffer=Qe(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 Hu="\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 Vu extends ao{constructor(){super({glProgram:Yr.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:to.from({fragment:{source:Hu,entryPoint:"mainFragment"},vertex:{source:Hu,entryPoint:"mainVertex"}}),resources:{uTexture:Fn.WHITE.source,uSampler:new En({}),uniforms:{uTranslationMatrix:{value:new un,type:"mat3x3<f32>"},uColor:{value:new ps(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}}class Wu{constructor(t,e){this.state=co.for2d(),this.localUniforms=new so({uTranslationMatrix:{value:new un,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 Vu,this.state=co.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 zu({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 s=this.state;n.update(e,t._childrenDirty),t._childrenDirty=!1,s.blendMode=yt(t.blendMode,t.texture._source);const r=this.localUniforms.uniforms,o=r.uTranslationMatrix;t.worldTransform.copyTo(o),o.prepend(i.globalUniforms.globalUniformData.projectionMatrix),r.uResolution=i.globalUniforms.globalUniformData.resolution,r.uRound=i._roundPixels|t._roundPixels,Ze(t.groupColorAlpha,r.uColor,0),this.adaptor.execute(this,t)}destroy(){this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}class Zu extends Wu{constructor(t){super(t,new Uu)}}Zu.extension={type:[Ki.WebGLPipes],name:"particle"};class Ju extends Wu{constructor(t){super(t,new Nu)}}Ju.extension={type:[Ki.WebGPUPipes],name:"particle"};const Xu=class t extends Fu{constructor(e={}){super({width:(e={...t.defaultOptions,...e}).width,height:e.height,verticesX:4,verticesY:4}),this.update(e)}update(t){this.width=t.width??this.width,this.height=t.height??this.height,this._originalWidth=t.originalWidth??this._originalWidth,this._originalHeight=t.originalHeight??this._originalHeight,this._leftWidth=t.leftWidth??this._leftWidth,this._rightWidth=t.rightWidth??this._rightWidth,this._topHeight=t.topHeight??this._topHeight,this._bottomHeight=t.bottomHeight??this._bottomHeight,this._anchorX=t.anchor?.x,this._anchorY=t.anchor?.y,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:i,_leftWidth:n,_rightWidth:s,_topHeight:r,_bottomHeight:o,_anchorX:a,_anchorY:h}=this,l=n+s,c=e>l?1:e/l,d=r+o,u=i>d?1:i/d,p=Math.min(c,u),f=a*e,g=h*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-s*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]=r*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()}};Xu.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let Yu=Xu;class Ku extends Lu{constructor(){super(),this.geometry=new Yu}destroy(){this.geometry.destroy()}}class qu{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 Ku,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}}qu.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"nineSliceSprite"};const Qu={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 "}},$u={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 tp,ep;class ip extends ao{constructor(){tp??(tp=Ot({name:"tiling-sprite-shader",bits:[ql,Qu,Ia]})),ep??(ep=kt({name:"tiling-sprite-shader",bits:[$l,$u,Aa]}));const t=new so({uMapCoord:{value:new un,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 un,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:ep,gpuProgram:tp,resources:{localUniforms:new so({uTransformMatrix:{value:new un,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:Fn.EMPTY.source,uSampler:Fn.EMPTY.source.style}})}updateUniforms(t,e,i,n,s,r){const o=this.resources.tilingUniforms,a=r.width,h=r.height,l=r.textureMatrix,c=o.uniforms.uTextureTransform;c.set(i.a*a/t,i.b*a/e,i.c*h/t,i.d*h/e,i.tx/t,i.ty/e),c.invert(),o.uniforms.uMapCoord=l.mapCoord,o.uniforms.uClampFrame=l.uClampFrame,o.uniforms.uClampOffset=l.uClampOffset,o.uniforms.uTextureTransform=c,o.uniforms.uSizeAnchor[0]=t,o.uniforms.uSizeAnchor[1]=e,o.uniforms.uSizeAnchor[2]=n,o.uniforms.uSizeAnchor[3]=s,r&&(this.resources.uTexture=r.source,this.resources.uSampler=r.source.style)}}const np=new class extends El{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 sp{constructor(){this.canBatch=!0,this.geometry=new El({indices:np.indices.slice(),positions:np.positions.slice(),uvs:np.uvs.slice()})}destroy(){this.geometry.destroy(),this.shader?.destroy()}}class rp{constructor(t){this._state=co.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:s,canBatch:r}=n;if(r){n.batchableMesh||(n.batchableMesh=new Lu);const r=n.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),r.geometry=s,r.renderable=t,r.transform=t.groupTransform,r.setTexture(t._texture)),r.roundPixels=this._renderer._roundPixels|t._roundPixels,i.addToBatch(r,e)}else i.break(e),n.shader||(n.shader=new ip),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,Ze(t.groupColorAlpha,i.uColor,0),this._state.blendMode=yt(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:np,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 sp;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,s=i.frame.height;let r=0,o=0;t.applyAnchorToTexture&&(r=t.anchor.x,o=t.anchor.y),e[0]=e[6]=-r,e[2]=e[4]=1-r,e[1]=e[3]=-o,e[5]=e[7]=1-o;const a=un.shared;a.copyFrom(t._tileTransform.matrix),a.tx/=t.width,a.ty/=t.height,a.invert(),a.scale(t.width/n,t.height/s),function(t,e,i,n){let s=0;const r=t.length/2,o=n.a,a=n.b,h=n.c,l=n.d,c=n.tx,d=n.ty;for(i*=2;s<r;){const e=t[i],n=t[i+1];t[i]=o*e+h*n+c,t[i+1]=a*e+l*n+d,i+=2,s++}}(e,0,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===oo.WEBGL&&(n=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=i.textureMatrix.isSimple&&(n||i.source.isPowerOfTwo),e.canBatch}}rp.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"tilingSprite"};const op={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 "}},ap={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 "}},hp={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 "}},lp={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 cp,dp;class up extends ao{constructor(t){const e=new so({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new un,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});cp??(cp=Ot({name:"sdf-shader",bits:[va,Ft(t),op,hp,Ia]})),dp??(dp=kt({name:"sdf-shader",bits:[wa,jt(t),ap,lp,Aa]})),super({glProgram:dp,gpuProgram:cp,resources:{localUniforms:e,batchSamplers:Gt(t)}})}}class pp extends Tl{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class fp{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);ti(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);ti(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:i}=e,n=xh.getFont(t.text,t._style);i.clear(),"none"!==n.distanceField.type&&(i.customShader||(i.customShader=new up(this._renderer.limits.maxBatchableTextures)));const s=Fo.graphemeSegmenter(t.text),r=t._style;let o=n.baseLineOffset;const a=fe(s,r,n,!0),h=r.padding,l=a.scale;let c=a.width,d=a.height+a.offsetY;r._stroke&&(c+=r._stroke.width/l,d+=r._stroke.width/l),i.translate(-t._anchor._x*c-h,-t._anchor._y*d-h).scale(l,l);const u=n.applyFillAsTint?r._fill.color:16777215;let p=n.fontMetrics.fontSize,f=n.lineHeight;r.lineHeight&&(p=r.fontSize/l,f=r.lineHeight/l);let g=(f-p)/2;g-n.baseLineOffset<0&&(g=0);for(let t=0;t<a.lines.length;t++){const e=a.lines[t];for(let t=0;t<e.charPositions.length;t++){const s=e.chars[t],r=n.chars[s];if(r?.texture){const n=r.texture;i.texture(n,u||"black",Math.round(e.charPositions[t]+r.xOffset),Math.round(o+r.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 pp;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=hr.get(`${i}-bitmap`),{a:s,b:r,c:o,d:a}=t.groupTransform,h=Math.sqrt(s*s+r*r),l=Math.sqrt(o*o+a*a),c=(Math.abs(h)+Math.abs(l))/2,d=n.baseRenderedFontSize/t._style.fontSize,u=c*n.distanceField.range*(1/d);e.customShader.resources.localUniforms.uniforms.uDistance=u}destroy(){this._renderer=null}}fp.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"bitmapText"};class gp extends dd{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}}class mp{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=>{}),t._didTextUpdate=!1,ei(i,t)),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}async _updateGpuText(t){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=await i;const n=t.renderGroup||t.parentRenderGroup;n&&(n.structureDidChange=!0),e.generatingTexture=!1,ei(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new gp(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.texture=Fn.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}}mp.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"htmlText"};const yp=new jn,xp=new Map;class bp{constructor(t){this._renderer=t,this._createCanvas=t.type===oo.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){const{text:e,style:i,resolution:n,textureStyle:s}=t,r=ms.get(Vl),o=function(t,e){function i(t){r[t]||(s.push(t),r[t]=!0)}const n=e.fontFamily,s=[],r={},o=t.match(/font-family:([^;"\s]+)/g);if(Array.isArray(n))for(let t=0;t<n.length;t++)i(n[t]);else i(n);o&&o.forEach(t=>{i(t.split(":")[1].trim())});for(const t in e.tagStyles)i(e.tagStyles[t].fontFamily);return s}(e,i),a=await async function(t){const e=t.filter(t=>hr.has(`${t}-and-url`)).map(t=>{if(!xp.has(t)){const{entries:e}=hr.get(`${t}-and-url`),i=[];e.forEach(e=>{const n=e.url,s=e.faces.map(t=>({weight:t.weight,style:t.style}));i.push(...s.map(e=>async function(t,e){const i=await async function(t){const e=await qs.get().fetch(t),i=await e.blob(),n=new FileReader;return await 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 }`}({fontWeight:e.weight,fontStyle:e.style,fontFamily:t},n)))}),xp.set(t,Promise.all(i).then(t=>t.join("\n")))}return xp.get(t)});return(await Promise.all(e)).join("\n")}(o),h=function(t,e,i,n){n||(n=Wl||(Wl=new Vl));const{domElement:s,styleElement:r,svgRoot:o}=n;s.innerHTML=`<style>${e.cssStyle};</style><div style='padding:0'>${t}</div>`,s.setAttribute("style","transform-origin: top left; display: inline-block"),i&&(r.textContent=i),document.body.appendChild(o);const a=s.getBoundingClientRect();o.remove();const h=2*e.padding;return{width:a.width-h,height:a.height-h}}(e,i,a,r),l=Math.ceil(Math.ceil(Math.max(1,h.width)+2*i.padding)*n),c=Math.ceil(Math.ceil(Math.max(1,h.height)+2*i.padding)*n),d=r.image;d.width=2+(0|l),d.height=2+(0|c);const u=function(t,e,i,n,s){const{domElement:r,styleElement:o,svgRoot:a}=s;r.innerHTML=`<style>${e.cssStyle}</style><div style='padding:0;'>${t}</div>`,r.setAttribute("style",`transform: scale(${i});transform-origin: top left; display: inline-block`),o.textContent=n;const{width:h,height:l}=s.image;return a.setAttribute("width",h.toString()),a.setAttribute("height",l.toString()),(new XMLSerializer).serializeToString(a)}(e,i,n,a,r);await function(t,e,i){return new Promise(async n=>{i&&await new Promise(t=>setTimeout(t,100)),t.onload=()=>{n()},t.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(e)}`,t.crossOrigin="anonymous"})}(d,u,function(){const{userAgent:t}=qs.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}()&&o.length>0);const p=d;let f;this._createCanvas&&(f=function(t,e){const i=ph.getOptimalCanvasAndContext(t.width,t.height,e),{context:n}=i;return n.clearRect(0,0,t.width,t.height),n.drawImage(t,0,0),i}(d,n));const g=ii(f?f.canvas:p,d.width-2,d.height-2,n);return s&&(g.source.style=s),this._createCanvas&&(this._renderer.texture.initSource(g.source),ph.returnCanvasAndContext(f)),ms.return(r),g}returnTexturePromise(t){t.then(t=>{this._cleanUp(t)}).catch(()=>{a()})}_cleanUp(t){Ls.returnTexture(t,!0),t.source.resource=null,t.source.uploadMethodId="unknown"}destroy(){this._renderer=null}}bp.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"htmlText"};class _p extends dd{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 vp{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),ei(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new _p(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}}vp.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"text"};class wp{constructor(t){this._renderer=t}getTexture(t,e,n,s){"string"==typeof t&&(i(0,"CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:n,resolution:e}),t.style instanceof uh||(t.style=new uh(t.style)),t.textureStyle instanceof En||(t.textureStyle=new En(t.textureStyle)),"string"!=typeof t.text&&(t.text=t.text.toString());const{text:r,style:o,textureStyle:a}=t,h=t.resolution??this._renderer.resolution,{frame:l,canvasAndContext:c}=Ul.getCanvasAndContext({text:r,style:o,resolution:h}),d=ii(c.canvas,l.width,l.height,h);if(a&&(d.source.style=a),o.trim&&(l.pad(o.padding),d.frame.copyFrom(l),d.frame.scale(1/h),d.updateUvs()),o.filters){const t=this._applyFilters(d,o.filters);return this.returnTexture(d),Ul.returnCanvasAndContext(c),t}return this._renderer.texture.initSource(d._source),Ul.returnCanvasAndContext(c),d}returnTexture(t){const e=t.source;e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",Ls.returnTexture(t,!0)}renderTextToCanvas(){i(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}}wp.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"canvasText"},$i.add(tn,en);var Cp="object"==typeof global&&global&&global.Object===Object&&global,Sp="object"==typeof self&&self&&self.Object===Object&&self,Ip=Cp||Sp||Function("return this")(),Ap=Ip.Symbol,Mp=Object.prototype,Tp=Mp.hasOwnProperty,Pp=Mp.toString,Ep=Ap?Ap.toStringTag:void 0,Bp=Object.prototype.toString,Op=Ap?Ap.toStringTag:void 0,kp=Array.isArray,Rp=/\s/,Dp=/^\s+/,Fp=/^[-+]0x[0-9a-f]+$/i,Lp=/^0b[01]+$/i,jp=/^0o[0-7]+$/i,Gp=parseInt,Up=1/0,Np=Ip["__core-js_shared__"],zp=function(){var t=/[^.]+$/.exec(Np&&Np.keys&&Np.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Hp=Function.prototype.toString,Vp=/^\[object .+?Constructor\]$/,Wp=Function.prototype,Zp=Object.prototype,Jp=Wp.toString,Xp=Zp.hasOwnProperty,Yp=RegExp("^"+Jp.call(Xp).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Kp=ci(Ip,"WeakMap"),qp=Object.create,Qp=function(){function t(){}return function(e){if(!ri(e))return{};if(qp)return qp(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}(),$p=Date.now,tf=function(){try{var t=ci(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),ef=tf?function(t,e){return tf(t,"toString",{configurable:!0,enumerable:!1,value:(i=e,function(){return i}),writable:!0});var i}:ai,nf=function(t){var e=0,i=0;return function(){var n=$p(),s=16-(n-i);if(i=n,s>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(ef),sf=/^(?:0|[1-9]\d*)$/,rf=Object.prototype.hasOwnProperty,of=Math.max,af=Object.prototype,hf=Object.prototype,lf=hf.hasOwnProperty,cf=hf.propertyIsEnumerable,df=xi(function(){return arguments}())?xi:function(t){return si(t)&&lf.call(t,"callee")&&!cf.call(t,"callee")},uf="object"==typeof exports&&exports&&!exports.nodeType&&exports,pf=uf&&"object"==typeof module&&module&&!module.nodeType&&module,ff=pf&&pf.exports===uf?Ip.Buffer:void 0,gf=(ff?ff.isBuffer:void 0)||function(){return!1},mf={};mf["[object Float32Array]"]=mf["[object Float64Array]"]=mf["[object Int8Array]"]=mf["[object Int16Array]"]=mf["[object Int32Array]"]=mf["[object Uint8Array]"]=mf["[object Uint8ClampedArray]"]=mf["[object Uint16Array]"]=mf["[object Uint32Array]"]=!0,mf["[object Arguments]"]=mf["[object Array]"]=mf["[object ArrayBuffer]"]=mf["[object Boolean]"]=mf["[object DataView]"]=mf["[object Date]"]=mf["[object Error]"]=mf["[object Function]"]=mf["[object Map]"]=mf["[object Number]"]=mf["[object Object]"]=mf["[object RegExp]"]=mf["[object Set]"]=mf["[object String]"]=mf["[object WeakMap]"]=!1;var yf,xf="object"==typeof exports&&exports&&!exports.nodeType&&exports,bf=xf&&"object"==typeof module&&module&&!module.nodeType&&module,_f=bf&&bf.exports===xf&&Cp.process,vf=function(){try{return bf&&bf.require&&bf.require("util").types||_f&&_f.binding&&_f.binding("util")}catch(t){}}(),wf=vf&&vf.isTypedArray,Cf=wf?(yf=wf,function(t){return yf(t)}):function(t){return si(t)&&gi(t.length)&&!!mf[ni(t)]},Sf=Object.prototype.hasOwnProperty,If=_i(Object.keys,Object),Af=Object.prototype.hasOwnProperty,Mf=Object.prototype.hasOwnProperty,Tf=ci(Object,"create"),Pf=Object.prototype.hasOwnProperty,Ef=Object.prototype.hasOwnProperty;wi.prototype.clear=function(){this.__data__=Tf?Tf(null):{},this.size=0},wi.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},wi.prototype.get=function(t){var e=this.__data__;if(Tf){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return Pf.call(e,t)?e[t]:void 0},wi.prototype.has=function(t){var e=this.__data__;return Tf?void 0!==e[t]:Ef.call(e,t)},wi.prototype.set=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Tf&&void 0===e?"__lodash_hash_undefined__":e,this};var Bf=Array.prototype.splice;Si.prototype.clear=function(){this.__data__=[],this.size=0},Si.prototype.delete=function(t){var e=this.__data__,i=Ci(e,t);return!(i<0||(i==e.length-1?e.pop():Bf.call(e,i,1),--this.size,0))},Si.prototype.get=function(t){var e=this.__data__,i=Ci(e,t);return i<0?void 0:e[i][1]},Si.prototype.has=function(t){return Ci(this.__data__,t)>-1},Si.prototype.set=function(t,e){var i=this.__data__,n=Ci(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this};var Of=ci(Ip,"Map");Ai.prototype.clear=function(){this.size=0,this.__data__={hash:new wi,map:new(Of||Si),string:new wi}},Ai.prototype.delete=function(t){var e=Ii(this,t).delete(t);return this.size-=e?1:0,e},Ai.prototype.get=function(t){return Ii(this,t).get(t)},Ai.prototype.has=function(t){return Ii(this,t).has(t)},Ai.prototype.set=function(t,e){var i=Ii(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this};var kf=_i(Object.getPrototypeOf,Object),Rf=Function.prototype,Df=Object.prototype,Ff=Rf.toString,Lf=Df.hasOwnProperty,jf=Ff.call(Object),Gf=Math.ceil,Uf=Math.max;Ti.prototype.clear=function(){this.__data__=new Si,this.size=0},Ti.prototype.delete=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i},Ti.prototype.get=function(t){return this.__data__.get(t)},Ti.prototype.has=function(t){return this.__data__.has(t)},Ti.prototype.set=function(t,e){var i=this.__data__;if(i instanceof Si){var n=i.__data__;if(!Of||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new Ai(n)}return i.set(t,e),this.size=i.size,this};var Nf="object"==typeof exports&&exports&&!exports.nodeType&&exports,zf=Nf&&"object"==typeof module&&module&&!module.nodeType&&module,Hf=zf&&zf.exports===Nf?Ip.Buffer:void 0;Hf&&Hf.allocUnsafe;var Vf=Object.prototype.propertyIsEnumerable,Wf=Object.getOwnPropertySymbols,Zf=Wf?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var i=-1,n=null==t?0:t.length,s=0,r=[];++i<n;){var o=t[i];e(o)&&(r[s++]=o)}return r}(Wf(t),function(e){return Vf.call(t,e)}))}:function(){return[]},Jf=ci(Ip,"DataView"),Xf=ci(Ip,"Promise"),Yf=ci(Ip,"Set"),Kf="[object Map]",qf="[object Promise]",Qf="[object Set]",$f="[object WeakMap]",tg="[object DataView]",eg=li(Jf),ig=li(Of),ng=li(Xf),sg=li(Yf),rg=li(Kp),og=ni;(Jf&&og(new Jf(new ArrayBuffer(1)))!=tg||Of&&og(new Of)!=Kf||Xf&&og(Xf.resolve())!=qf||Yf&&og(new Yf)!=Qf||Kp&&og(new Kp)!=$f)&&(og=function(t){var e=ni(t),i="[object Object]"==e?t.constructor:void 0,n=i?li(i):"";if(n)switch(n){case eg:return tg;case ig:return Kf;case ng:return qf;case sg:return Qf;case rg:return $f}return e});var ag=Ip.Uint8Array;Ei.prototype.add=Ei.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Ei.prototype.has=function(t){return this.__data__.has(t)};var hg,lg=Ap?Ap.prototype:void 0,cg=lg?lg.valueOf:void 0,dg=Object.prototype.hasOwnProperty,ug="[object Arguments]",pg="[object Array]",fg="[object Object]",gg=Object.prototype.hasOwnProperty,mg=function(t,e,i){for(var n=-1,s=Object(t),r=i(t),o=r.length;o--;){var a=r[++n];if(!1===e(s[a],a,s))break}return t},yg=function(){return Ip.Date.now()},xg=Math.max,bg=Math.min,_g=(hg=function(t,e,i){Gi(t,e,i)},function(t){return nf(function(t,e,i){return e=of(void 0===e?t.length-1:e,0),function(){for(var n=arguments,s=-1,r=of(n.length-e,0),o=Array(r);++s<r;)o[s]=n[e+s];s=-1;for(var a=Array(e+1);++s<e;)a[s]=n[s];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,void 0,ai),t+"")}(function(t,e){var i=-1,n=e.length,s=n>1?e[n-1]:void 0,r=n>2?e[2]:void 0;for(s=hg.length>3&&"function"==typeof s?(n--,s):void 0,r&&function(t,e,i){if(!ri(i))return!1;var n=typeof e;return!!("number"==n?mi(i)&&di(e,i.length):"string"==n&&e in i)&&pi(i[e],t)}(e[0],e[1],r)&&(s=n<3?void 0:s,n=1),t=Object(t);++i<n;){var o=e[i];o&&hg(t,o,i)}return t}));!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 vg,wg,Cg,Sg={},Ig={},Ag={},Mg=(Cg||(Cg=1,function(t){function e(t){if(t>J)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,i.prototype),e}function i(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 r(t)}return n(t,e,i)}function n(t,n,s){if("string"==typeof t)return function(t,n){if("string"==typeof n&&""!==n||(n="utf8"),!i.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const s=0|l(t,n);let r=e(s);const o=r.write(t,n);return o!==s&&(r=r.slice(0,o)),r}(t,n);if(ArrayBuffer.isView(t))return function(t){if(U(t,Uint8Array)){const e=new Uint8Array(t);return a(e.buffer,e.byteOffset,e.byteLength)}return o(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(U(t,ArrayBuffer)||t&&U(t.buffer,ArrayBuffer))return a(t,n,s);if("undefined"!=typeof SharedArrayBuffer&&(U(t,SharedArrayBuffer)||t&&U(t.buffer,SharedArrayBuffer)))return a(t,n,s);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return i.from(r,n,s);const c=function(t){if(i.isBuffer(t)){const i=0|h(t.length),n=e(i);return 0===n.length||t.copy(n,0,0,i),n}return void 0!==t.length?"number"!=typeof t.length||N(t.length)?e(0):o(t):"Buffer"===t.type&&Array.isArray(t.data)?o(t.data):void 0}(t);if(c)return c;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return i.from(t[Symbol.toPrimitive]("string"),n,s);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function s(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 r(t){return s(t),e(t<0?0:0|h(t))}function o(t){const i=t.length<0?0:0|h(t.length),n=e(i);for(let e=0;e<i;e+=1)n[e]=255&t[e];return n}function a(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let s;return s=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(s,i.prototype),s}function h(t){if(t>=J)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+J.toString(16)+" bytes");return 0|t}function l(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||U(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 n=t.length,s=arguments.length>2&&!0===arguments[2];if(!s&&0===n)return 0;let r=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return j(t).length;default:if(r)return s?-1:L(t).length;e=(""+e).toLowerCase(),r=!0}}function c(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 C(this,e,i);case"utf8":case"utf-8":return _(this,e,i);case"ascii":return v(this,e,i);case"latin1":case"binary":return w(this,e,i);case"base64":return b(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function d(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function u(t,e,n,s,r){if(0===t.length)return-1;if("string"==typeof n?(s=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),N(n=+n)&&(n=r?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(r)return-1;n=t.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof e&&(e=i.from(e,s)),i.isBuffer(e))return 0===e.length?-1:p(t,e,n,s,r);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):p(t,[e],n,s,r);throw new TypeError("val must be string, number or Buffer")}function p(t,e,i,n,s){function r(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}let o,a=1,h=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;a=2,h/=2,l/=2,i/=2}if(s){let n=-1;for(o=i;o<h;o++)if(r(t,o)===r(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===l)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(i+l>h&&(i=h-l),o=i;o>=0;o--){let i=!0;for(let n=0;n<l;n++)if(r(t,o+n)!==r(e,n)){i=!1;break}if(i)return o}return-1}function f(t,e,i,n){i=Number(i)||0;const s=t.length-i;n?(n=Number(n))>s&&(n=s):n=s;const r=e.length;let o;for(n>r/2&&(n=r/2),o=0;o<n;++o){const n=parseInt(e.substr(2*o,2),16);if(N(n))return o;t[i+o]=n}return o}function g(t,e,i,n){return G(L(e,t.length-i),t,i,n)}function m(t,e,i,n){return G(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 y(t,e,i,n){return G(j(e),t,i,n)}function x(t,e,i,n){return G(function(t,e){let i,n,s;const r=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)i=t.charCodeAt(o),n=i>>8,s=i%256,r.push(s),r.push(n);return r}(e,t.length-i),t,i,n)}function b(t,e,i){return 0===e&&i===t.length?V.fromByteArray(t):V.fromByteArray(t.slice(e,i))}function _(t,e,i){i=Math.min(t.length,i);const n=[];let s=e;for(;s<i;){const e=t[s];let r=null,o=e>239?4:e>223?3:e>191?2:1;if(s+o<=i){let i,n,a,h;switch(o){case 1:e<128&&(r=e);break;case 2:i=t[s+1],128==(192&i)&&(h=(31&e)<<6|63&i,h>127&&(r=h));break;case 3:i=t[s+1],n=t[s+2],128==(192&i)&&128==(192&n)&&(h=(15&e)<<12|(63&i)<<6|63&n,h>2047&&(h<55296||h>57343)&&(r=h));break;case 4:i=t[s+1],n=t[s+2],a=t[s+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(h=(15&e)<<18|(63&i)<<12|(63&n)<<6|63&a,h>65535&&h<1114112&&(r=h))}}null===r?(r=65533,o=1):r>65535&&(r-=65536,n.push(r>>>10&1023|55296),r=56320|1023&r),n.push(r),s+=o}return function(t){const e=t.length;if(e<=X)return String.fromCharCode.apply(String,t);let i="",n=0;for(;n<e;)i+=String.fromCharCode.apply(String,t.slice(n,n+=X));return i}(n)}function v(t,e,i){let n="";i=Math.min(t.length,i);for(let s=e;s<i;++s)n+=String.fromCharCode(127&t[s]);return n}function w(t,e,i){let n="";i=Math.min(t.length,i);for(let s=e;s<i;++s)n+=String.fromCharCode(t[s]);return n}function C(t,e,i){const n=t.length;(!e||e<0)&&(e=0),(!i||i<0||i>n)&&(i=n);let s="";for(let n=e;n<i;++n)s+=q[t[n]];return s}function S(t,e,i){const n=t.slice(e,i);let s="";for(let t=0;t<n.length-1;t+=2)s+=String.fromCharCode(n[t]+256*n[t+1]);return s}function I(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 A(t,e,n,s,r,o){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||e<o)throw new RangeError('"value" argument is out of bounds');if(n+s>t.length)throw new RangeError("Index out of range")}function M(t,e,i,n,s){R(e,n,s,t,i,7);let r=Number(e&BigInt(4294967295));t[i++]=r,r>>=8,t[i++]=r,r>>=8,t[i++]=r,r>>=8,t[i++]=r;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 T(t,e,i,n,s){R(e,n,s,t,i,7);let r=Number(e&BigInt(4294967295));t[i+7]=r,r>>=8,t[i+6]=r,r>>=8,t[i+5]=r,r>>=8,t[i+4]=r;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 P(t,e,i,n,s,r){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function E(t,e,i,n,s){return e=+e,i>>>=0,s||P(t,0,i,4),W.write(t,e,i,n,23,4),i+4}function B(t,e,i,n,s){return e=+e,i>>>=0,s||P(t,0,i,8),W.write(t,e,i,n,52,8),i+8}function O(t,e,i){Y[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 k(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 R(t,e,i,n,s,r){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*(r+1)}${i}`:`>= -(2${i} ** ${8*(r+1)-1}${i}) and < 2 ** ${8*(r+1)-1}${i}`,new Y.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,i){D(e,"offset"),void 0!==t[e]&&void 0!==t[e+i]||F(e,t.length-(i+1))}(n,s,r)}function D(t,e){if("number"!=typeof t)throw new Y.ERR_INVALID_ARG_TYPE(e,"number",t)}function F(t,e,i){if(Math.floor(t)!==t)throw D(t,i),new Y.ERR_OUT_OF_RANGE("offset","an integer",t);if(e<0)throw new Y.ERR_BUFFER_OUT_OF_BOUNDS;throw new Y.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}function L(t,e){let i;e=e||1/0;const n=t.length;let s=null;const r=[];for(let o=0;o<n;++o){if(i=t.charCodeAt(o),i>55295&&i<57344){if(!s){if(i>56319){(e-=3)>-1&&r.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&r.push(239,191,189);continue}s=i;continue}if(i<56320){(e-=3)>-1&&r.push(239,191,189),s=i;continue}i=65536+(s-55296<<10|i-56320)}else s&&(e-=3)>-1&&r.push(239,191,189);if(s=null,i<128){if((e-=1)<0)break;r.push(i)}else if(i<2048){if((e-=2)<0)break;r.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;r.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;r.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return r}function j(t){return V.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,i,n){let s;for(s=0;s<n&&!(s+i>=e.length||s>=t.length);++s)e[s+i]=t[s];return s}function U(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function N(t){return t!=t}function z(t){return"undefined"==typeof BigInt?H:t}function H(){throw new Error("BigInt not supported")}const V=function(){function t(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 e(t){return n[t>>18&63]+n[t>>12&63]+n[t>>6&63]+n[63&t]}function i(t,i,n){for(var s,r=[],o=i;o<n;o+=3)s=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),r.push(e(s));return r.join("")}if(vg)return Ig;vg=1,Ig.byteLength=function(e){var i=t(e),n=i[0],s=i[1];return 3*(n+s)/4-s},Ig.toByteArray=function(e){var i,n,o=t(e),a=o[0],h=o[1],l=new r(function(t,e,i){return 3*(e+i)/4-i}(0,a,h)),c=0,d=h>0?a-4:a;for(n=0;n<d;n+=4)i=s[e.charCodeAt(n)]<<18|s[e.charCodeAt(n+1)]<<12|s[e.charCodeAt(n+2)]<<6|s[e.charCodeAt(n+3)],l[c++]=i>>16&255,l[c++]=i>>8&255,l[c++]=255&i;return 2===h&&(i=s[e.charCodeAt(n)]<<2|s[e.charCodeAt(n+1)]>>4,l[c++]=255&i),1===h&&(i=s[e.charCodeAt(n)]<<10|s[e.charCodeAt(n+1)]<<4|s[e.charCodeAt(n+2)]>>2,l[c++]=i>>8&255,l[c++]=255&i),l},Ig.fromByteArray=function(t){for(var e,s=t.length,r=s%3,o=[],a=16383,h=0,l=s-r;h<l;h+=a)o.push(i(t,h,h+a>l?l:h+a));return 1===r?(e=t[s-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[s-2]<<8)+t[s-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),o.join("")};for(var n=[],s=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)n[a]=o[a],s[o.charCodeAt(a)]=a;return s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63,Ig}(),W=(wg||(wg=1,Ag.read=function(t,e,i,n,s){var r,o,a=8*s-n-1,h=(1<<a)-1,l=h>>1,c=-7,d=i?s-1:0,u=i?-1:1,p=t[e+d];for(d+=u,r=p&(1<<-c)-1,p>>=-c,c+=a;c>0;r=256*r+t[e+d],d+=u,c-=8);for(o=r&(1<<-c)-1,r>>=-c,c+=n;c>0;o=256*o+t[e+d],d+=u,c-=8);if(0===r)r=1-l;else{if(r===h)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),r-=l}return(p?-1:1)*o*Math.pow(2,r-n)},Ag.write=function(t,e,i,n,s,r){var o,a,h,l=8*r-s-1,c=(1<<l)-1,d=c>>1,u=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:r-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*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+d>=1?u/h:u*Math.pow(2,1-d))*h>=2&&(o++,h/=2),o+d>=c?(a=0,o=c):o+d>=1?(a=(e*h-1)*Math.pow(2,s),o+=d):(a=e*Math.pow(2,d-1)*Math.pow(2,s),o=0));s>=8;t[i+p]=255&a,p+=f,a/=256,s-=8);for(o=o<<s|a,l+=s;l>0;t[i+p]=255&o,p+=f,o/=256,l-=8);t[i+p-f]|=128*g}),Ag),Z="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=i,t.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},t.INSPECT_MAX_BYTES=50;const J=2147483647;t.kMaxLength=J,i.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}}(),!i.TYPED_ARRAY_SUPPORT&&"undefined"!=typeof console&&console.error,Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}}),i.poolSize=8192,i.from=function(t,e,i){return n(t,e,i)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(t,i,n){return function(t,i,n){return s(t),t<=0?e(t):void 0!==i?"string"==typeof n?e(t).fill(i,n):e(t).fill(i):e(t)}(t,i,n)},i.allocUnsafe=function(t){return r(t)},i.allocUnsafeSlow=function(t){return r(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==i.prototype},i.compare=function(t,e){if(U(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),U(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,s=e.length;for(let i=0,r=Math.min(n,s);i<r;++i)if(t[i]!==e[i]){n=t[i],s=e[i];break}return n<s?-1:s<n?1:0},i.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}},i.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return i.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const s=i.allocUnsafe(e);let r=0;for(n=0;n<t.length;++n){let e=t[n];if(U(e,Uint8Array))r+e.length>s.length?(i.isBuffer(e)||(e=i.from(e)),e.copy(s,r)):Uint8Array.prototype.set.call(s,e,r);else{if(!i.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(s,r)}r+=e.length}return s},i.byteLength=l,i.prototype._isBuffer=!0,i.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)d(this,e,e+1);return this},i.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)d(this,e,e+3),d(this,e+1,e+2);return this},i.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)d(this,e,e+7),d(this,e+1,e+6),d(this,e+2,e+5),d(this,e+3,e+4);return this},i.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?_(this,0,t):c.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.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+">"},Z&&(i.prototype[Z]=i.prototype.inspect),i.prototype.compare=function(t,e,n,s,r){if(U(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.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===n&&(n=t?t.length:0),void 0===s&&(s=0),void 0===r&&(r=this.length),e<0||n>t.length||s<0||r>this.length)throw new RangeError("out of range index");if(s>=r&&e>=n)return 0;if(s>=r)return-1;if(e>=n)return 1;if(this===t)return 0;let o=(r>>>=0)-(s>>>=0),a=(n>>>=0)-(e>>>=0);const h=Math.min(o,a),l=this.slice(s,r),c=t.slice(e,n);for(let t=0;t<h;++t)if(l[t]!==c[t]){o=l[t],a=c[t];break}return o<a?-1:a<o?1:0},i.prototype.includes=function(t,e,i){return-1!==this.indexOf(t,e,i)},i.prototype.indexOf=function(t,e,i){return u(this,t,e,i,!0)},i.prototype.lastIndexOf=function(t,e,i){return u(this,t,e,i,!1)},i.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 s=this.length-e;if((void 0===i||i>s)&&(i=s),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let r=!1;for(;;)switch(n){case"hex":return f(this,t,e,i);case"utf8":case"utf-8":return g(this,t,e,i);case"ascii":case"latin1":case"binary":return m(this,t,e,i);case"base64":return y(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,i);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),r=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const X=4096;i.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const s=this.subarray(t,e);return Object.setPrototypeOf(s,i.prototype),s},i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,i){t>>>=0,e>>>=0,i||I(t,e,this.length);let n=this[t],s=1,r=0;for(;++r<e&&(s*=256);)n+=this[t+r]*s;return n},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,i){t>>>=0,e>>>=0,i||I(t,e,this.length);let n=this[t+--e],s=1;for(;e>0&&(s*=256);)n+=this[t+--e]*s;return n},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t>>>=0,e||I(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||I(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||I(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readBigUInt64LE=z(function(t){D(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||F(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,s=this[++t]+256*this[++t]+65536*this[++t]+i*2**24;return BigInt(n)+(BigInt(s)<<BigInt(32))}),i.prototype.readBigUInt64BE=z(function(t){D(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||F(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],s=this[++t]*2**24+65536*this[++t]+256*this[++t]+i;return(BigInt(n)<<BigInt(32))+BigInt(s)}),i.prototype.readIntLE=function(t,e,i){t>>>=0,e>>>=0,i||I(t,e,this.length);let n=this[t],s=1,r=0;for(;++r<e&&(s*=256);)n+=this[t+r]*s;return s*=128,n>=s&&(n-=Math.pow(2,8*e)),n},i.prototype.readIntBE=function(t,e,i){t>>>=0,e>>>=0,i||I(t,e,this.length);let n=e,s=1,r=this[t+--n];for(;n>0&&(s*=256);)r+=this[t+--n]*s;return s*=128,r>=s&&(r-=Math.pow(2,8*e)),r},i.prototype.readInt8=function(t,e){return t>>>=0,e||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||I(t,2,this.length);const i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},i.prototype.readInt16BE=function(t,e){t>>>=0,e||I(t,2,this.length);const i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readBigInt64LE=z(function(t){D(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||F(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),i.prototype.readBigInt64BE=z(function(t){D(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||F(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+i)}),i.prototype.readFloatLE=function(t,e){return t>>>=0,e||I(t,4,this.length),W.read(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||I(t,4,this.length),W.read(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||I(t,8,this.length),W.read(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||I(t,8,this.length),W.read(this,t,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,i,n){t=+t,e>>>=0,i>>>=0,n||A(this,t,e,i,Math.pow(2,8*i)-1,0);let s=1,r=0;for(this[e]=255&t;++r<i&&(s*=256);)this[e+r]=t/s&255;return e+i},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,i,n){t=+t,e>>>=0,i>>>=0,n||A(this,t,e,i,Math.pow(2,8*i)-1,0);let s=i-1,r=1;for(this[e+s]=255&t;--s>=0&&(r*=256);)this[e+s]=t/r&255;return e+i},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(t,e,i){return t=+t,e>>>=0,i||A(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},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(t,e,i){return t=+t,e>>>=0,i||A(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},i.prototype.writeBigUInt64LE=z(function(t,e=0){return M(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeBigUInt64BE=z(function(t,e=0){return T(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*i-1);A(this,t,e,i,n-1,-n)}let s=0,r=1,o=0;for(this[e]=255&t;++s<i&&(r*=256);)t<0&&0===o&&0!==this[e+s-1]&&(o=1),this[e+s]=(t/r|0)-o&255;return e+i},i.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*i-1);A(this,t,e,i,n-1,-n)}let s=i-1,r=1,o=0;for(this[e+s]=255&t;--s>=0&&(r*=256);)t<0&&0===o&&0!==this[e+s+1]&&(o=1),this[e+s]=(t/r|0)-o&255;return e+i},i.prototype.writeInt8=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,i){return t=+t,e>>>=0,i||A(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},i.prototype.writeInt32BE=function(t,e,i){return t=+t,e>>>=0,i||A(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},i.prototype.writeBigInt64LE=z(function(t,e=0){return M(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeBigInt64BE=z(function(t,e=0){return T(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeFloatLE=function(t,e,i){return E(this,t,e,!0,i)},i.prototype.writeFloatBE=function(t,e,i){return E(this,t,e,!1,i)},i.prototype.writeDoubleLE=function(t,e,i){return B(this,t,e,!0,i)},i.prototype.writeDoubleBE=function(t,e,i){return B(this,t,e,!1,i)},i.prototype.copy=function(t,e,n,s){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),s||0===s||(s=this.length),e>=t.length&&(e=t.length),e||(e=0),s>0&&s<n&&(s=n),s===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),t.length-e<s-n&&(s=t.length-e+n);const r=s-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,s):Uint8Array.prototype.set.call(t,this.subarray(n,s),e),r},i.prototype.fill=function(t,e,n,s){if("string"==typeof t){if("string"==typeof e?(s=e,e=0,n=this.length):"string"==typeof n&&(s=n,n=this.length),void 0!==s&&"string"!=typeof s)throw new TypeError("encoding must be a string");if("string"==typeof s&&!i.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(1===t.length){const e=t.charCodeAt(0);("utf8"===s&&e<128||"latin1"===s)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let r;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(r=e;r<n;++r)this[r]=t;else{const o=i.isBuffer(t)?t:i.from(t,s),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(r=0;r<n-e;++r)this[r+e]=o[r%a]}return this};const Y={};O("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),O("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),O("ERR_OUT_OF_RANGE",function(t,e,i){let n=`The value of "${t}" is out of range.`,s=i;return Number.isInteger(i)&&Math.abs(i)>2**32?s=k(String(i)):"bigint"==typeof i&&(s=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(s=k(s)),s+="n"),n+=` It must be ${e}. Received ${s}`,n},RangeError);const K=/[^+/0-9A-Za-z-_]/g,q=function(){const t="0123456789abcdef",e=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let s=0;s<16;++s)e[n+s]=t[i]+t[s]}return e}()}(Sg)),Sg),Tg=(t,e)=>Number((e/10**t).toFixed(t)),Pg=t=>t>32767?t-65535:t,Eg=(t,e)=>e+(t<<8),Bg=(t,e)=>Tg(t,Pg(e)),Og=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 s=parseInt(e[t],16);s>31&&127!==s&&(i[n++]=s)}let s=i.slice(0,n);return Array.from(s).map(t=>String.fromCharCode(t)).join("")}catch(t){return""}},kg=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{return""}},Rg=(t,e=1)=>{let i=[];for(let n=0;n<t.length;n+=2*e){let s=t.slice(n,n+2*e),r=parseInt(s,16);i.push(r)}return i},Dg=({chargeX:t,chargeY:e},{originX:i,originY:n})=>t<=0&&e<=0?null:{x:t-i,y:e-n},Fg=(t,e)=>parseInt((t+e).slice(-8),2).toString(16).padStart(2,"0"),Lg=t=>{let e=parseInt(t.slice(0,2),16),i=t.slice(0,3===e?52:48),n=2,s=parseInt(i.slice(n,n+4),16);n+=4;let r=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 h=Tg(1,parseInt(i.slice(n,n+4),16));n+=4;let l=Tg(1,parseInt(i.slice(n,n+4),16));n+=4;let c=Tg(2,parseInt(i.slice(n,n+4),16));n+=4;let d=Tg(1,parseInt(i.slice(n,n+4),16));n+=4;let u,p=Tg(1,parseInt(i.slice(n,n+4),16));3===e&&(n+=4,u=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:s,mapStable:r,mapWidth:o,mapHeight:a,originX:h,originY:l,mapResolution:c,chargeX:d,chargeY:p,chargeDirection:u,chargePositionTransformed:Dg({chargeX:d,chargeY:p},{originX:h,originY:l}),dataLengthBeforeCompress:f,dataLengthAfterCompress:g}},jg={"00":"00","01":"f1",10:"f2",11:"ff"},Gg={sweep:"00",barrier:"01",battery:"10",unknown:"11"},Ug={sweep:"111",barrier:"001",carpet:"010",unknown:"000"},Ng={0:{typeMap:Gg},1:{typeMap:Gg},2:{typeMap:Ug},3:{typeMap:Ug}},zg={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 Hg=(t,e=1048576)=>{let i=Mg.Buffer.from(t),n=1073741824,s=e;if(e>n)return s=n,null;let r=Mg.Buffer.alloc(s),o=function(t,e,i,n){for(var s=i=i||0,r=n=n||t.length-i,o=0;s<r;){let i=t[s++],n=i>>4;if(n>0){for(var a=n+240;255===a;)n+=a=t[s++];for(var h=s+n;s<h;)e[o++]=t[s++];if(s===r)return o}let l=t[s++]|t[s++]<<8;if(0===l||l>o)return-(s-2);let c=15&i;for(a=c+240;255===a;)c+=a=t[s++];let d=o-l;for(h=o+c+4;o<h;)e[o++]=e[d++]}return o}(i,r);return r=r.slice(0,o),r},Vg=(t,e=1)=>{if(!t)return[];let i=parseInt(t.slice(2,4),16),n=t.slice(4),s=[],r=0;for(let t=0;t<i;t++){let t=n.slice(r,r+94),i=parseInt(t.slice(0,4),16),o=parseInt(t.slice(4,8),16),a=parseInt(t.slice(8,12),16),h=parseInt(t.slice(12,16),16),l=parseInt(t.slice(16,18),16),c=1===parseInt(t.slice(18,20),16),d=1===parseInt(t.slice(20,22),16),u=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),y=t.slice(54,54+2*m),x=m>0?kg(y):"";r+=2*(47+4*parseInt(t.slice(92,94),16));let b=Fg(i.toString(2),Ng[e].typeMap.sweep);s.push({roomId:i,pointHex:b,name:x,order:o,suction:u,cistern:p,colorOrder:l,sweepTimes:a,mopTimes:h,sweepForbidden:c,mopForbidden:d,yMop:f,floorMaterial:g,originStr:t,reservedStr:t.slice(30,52)})}return s},Wg=(t,e)=>{let{mapWidth:i,mapHeight:n,dataLengthAfterCompress:s,dataLengthBeforeCompress:r,mapHeaderStr:o,version:a}=e,h=o.length,l="",c="",d=i*n,u=[],p=[],f=new Map;if(s>0){let e=4*r,s=Rg(t.slice(h,h+2*r)),o=Hg(s,e);if(!o)return{mapRooms:[],mapPointsStr:"",parsed:{obstacles:new Uint32Array,carpet:new Uint32Array,rooms:new Map,width:i,height:n,totalPixels:d}};let g=Array.from(o);if(0===a){let t=[];f.set(zg.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 s=i.substring(n,n+2),r=jg[s];t.push(r);let o=4*e+n/2;if(o>=d)break;switch(parseInt(s,2)){case 0:f.get(zg.NO_ROOM_DATA).push(o);break;case 1:u.push(o)}}}l=t.join("").slice(0,2*d),c=""}else{let t=g.slice(0,d),e=[];for(let i=0;i<t.length;i++){let n=t[i];e.push(n.toString(16).padStart(2,"0")),1===a?zi(n,i,u,f):Vi(n,i,u,p,f)}l=e.join(""),c=g.slice(d).map(t=>t.toString(16).padStart(2,"0")).join("")}}else if(0===a){let e=[],i=t.slice(h).match(/.{2}/g)||[];f.set(zg.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 s=n.substring(i,i+2);e.push(jg[s]);let r=4*t+i/2;if(r>=d)break;switch(parseInt(s,2)){case 0:f.get(zg.NO_ROOM_DATA).push(r);break;case 1:u.push(r)}}}l=e.join(""),c=""}else{let e=t.slice(h,h+2*d),i=[];for(let t=0;t<d;t++){let n=e.slice(2*t,2*t+2);i.push(n);let s=parseInt(n,16);1===a?zi(s,t,u,f):Vi(s,t,u,p,f)}l=i.join(""),c=t.slice(h+2*d)}l=l.toLowerCase(),i*n*2>l.length&&(l=l.padStart(i*n*2,"f")),i*n*2<l.length&&(l=l.slice(l.length-i*n*2));let g=Vg(c,a),m=new Map;return f.forEach((t,e)=>{t.length>0&&m.set(e,new Uint32Array(t))}),{mapRooms:g,mapPointsStr:l,parsed:{obstacles:new Uint32Array(u),carpet:new Uint32Array(p),rooms:m,width:i,height:n,totalPixels:d}}},Zg=t=>{try{if(!t)return null;let e=Lg(t),{mapWidth:i,mapHeight:n,dataLengthAfterCompress:s,dataLengthBeforeCompress:r,mapHeaderStr:o,version:a}=e,h=o.length,l="",c=i*n;if(s>0){let e=4*r,i=Rg(t.slice(h,h+2*r)),n=Hg(i,e);if(!n)return[];let s=Array.from(n);if(0===a)return[];l=s.slice(c).map(t=>t.toString(16).padStart(2,"0")).join("")}else{if(0===a)return[];l=t.slice(h+2*c)}return Vg(l,a)}catch(t){return null}},Jg={"00":"common",10:"charge","01":"transitions",11:"mop"},Xg=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)}},Yg=(t,e)=>{let{dataLengthAfterCompress:i,count:n}=e,s=[];if(i>0){let e=4*n,i=Rg(t.slice(26)),r=Hg(i,e);if(!r)return[];let o=Array.from(r);for(let t=0;t<o.length;t+=4){let e=Eg(o[t],o[t+1]),i=Eg(o[t+2],o[t+3]);s.push([e,i])}}else s=function(t,e){e=void 0===e?1:Uf(function(t){var e=function(t){return t?(t=oi(t))===Up||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}(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var n=0,s=0,r=Array(Gf(i/e));n<i;)r[s++]=Mi(t,n,n+=e);return r}(Rg(t.slice(26),2),2);let r=[];for(let t=0;t<s.length;t++){let[e,i]=s[t],n=`${1&e}${1&i}`;r.push({x:Bg(1,-2&e),y:-Bg(1,-2&i),type:Jg[n]})}return r};const Kg=Object.freeze(Object.defineProperty({__proto__:null,BITMAP_TYPE_HEX_MAP:jg,BITMAP_TYPE_MAP:Gg,BITMAP_TYPE_MAP_V2:Ug,MAP_VERSION_MAP:Ng,PATH_HEADER_LENGTH:13,PATH_POINT_TYPE_MAP:Jg,SPECIAL_ROOM_IDS:zg,combineTwoBinaryToHex:Fg,dealPL:Pg,decodeMap:t=>{try{if(!t)return null;let e=Lg(t);return{mapHeader:e,mapData:Wg(t,e)}}catch(t){return null}},decodeMapData:Wg,decodeMapHeader:Lg,decodeMapRooms:Zg,decodeMapStructured:t=>{try{return JSON.parse(Og(t))}catch(t){return{}}},decodePath:t=>{let e=Xg(t);return{pathHeader:e,pathPoints:Yg(t,e)}},decodePathData:Yg,decodePathHeader:Xg,hexStringToNumber:Rg,hexToUTF8:Og,hexToUriDecodedString:kg,highLowToInt:Eg,scaleNumber:Tg,transformChargeXY:Dg,transformXY:Bg},Symbol.toStringTag,{value:"Module"})),qg=(t,e)=>(Zg(t)??[]).map(t=>({id:t.roomId,name:t.name,cleanTimes:t.sweepTimes,order:t.order,floorType:t.floorMaterial,yMop:t.yMop?1:0,suction:t.suction,cistern:t.cistern,cleanMode:t.sweepForbidden||t.mopForbidden?t.sweepForbidden?2:1:0,...e?.(t.reservedStr)??{}})),Qg={log(t,...e){},warn(t,...e){},error(t,...e){},debug(t,...e){},success(t,...e){}},$g=t=>{if(t.length<=1)return[...t];const e=tm(t),i=e.slice(1).map((t,i)=>({prev:e[i],current:t})),n=new Map;return i.forEach(({prev:t,current:e})=>{em(t,e).forEach(t=>{const e=`${t.x},${t.y}`;n.has(e)||n.set(e,t)})}),Array.from(n.values())},tm=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]},em=(t,e)=>{const i=[],n=Math.abs(e.x-t.x),s=Math.abs(e.y-t.y),r=t.x<e.x?1:-1,o=t.y<e.y?1:-1;let a=n-s,h=t.x,l=t.y;for(;i.push({x:h,y:l}),h!==e.x||l!==e.y;){const t=2*a;t>-s&&(a-=s,h+=r),t<n&&(a+=n,l+=o)}return i},im=(t,e,i,n,s,r=8)=>{const o={x:(e+n)/2,y:(i+s)/2},a=n-e,h=s-i,l=Math.min(r,.2*Math.min(a,h));return om(o,t)&&sm(o,t)>=l?o:nm(t,o,l)},nm=(t,e,i)=>{const{minX:n,minY:s,maxX:r,maxY:o}=lm(t),a=r-n,h=o-s,l=e.x,c=e.y,d=Math.min(.5,.05*Math.min(a,h)),u=[];if(om({x:l,y:c},t)){const e=sm({x:l,y:c},t);u.push({point:{x:l,y:c},distance:e,centerDistance:0})}const p=.6*Math.max(a,h),f=Math.PI/16;for(let e=d;e<=p;e+=d){const a=f*(1+e/p);for(let h=0;h<2*Math.PI;h+=a){const a=l+e*Math.cos(h),d=c+e*Math.sin(h);if(a>=n&&a<=r&&d>=s&&d<=o){const e={x:a,y:d};if(om(e,t)){const n=sm(e,t),s=pm({x:a,y:d},{x:l,y:c});n>=i&&u.push({point:e,distance:n,centerDistance:s})}}}if(u.length>=15)break}if(u.length>0){const t=u.map(t=>({...t,score:1.5*t.distance-.5*t.centerDistance}));return t.sort((t,e)=>e.score-t.score),t[0].point}if(0===u.length){let e={x:l,y:c},i=0;const a=2*d;for(let h=n;h<=r;h+=a)for(let n=s;n<=o;n+=a){const s={x:h,y:n};if(om(s,t)){const n=sm(s,t);n>i&&(i=n,e=s)}}return e}return{x:l,y:c}},sm=(t,e)=>{let i=1/0;for(let n=0,s=e.length-1;n<e.length;s=n++){const r=e[s],o=e[n],a=rm(t,r,o);i=Math.min(i,a)}return i},rm=(t,e,i)=>{const n=(e.x-i.x)**2+(e.y-i.y)**2;if(0===n)return pm(t,e);const s=Math.max(0,Math.min(1,((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/n)),r=e.x+s*(i.x-e.x),o=e.y+s*(i.y-e.y);return pm(t,{x:r,y:o})},om=(t,e,i=!1)=>{if(e.length<3)return!1;if(i&&am(t,e))return!0;let n=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){const r=e[i].x,o=e[i].y,a=e[s].x,h=e[s].y;o>t.y!=h>t.y&&t.x<(a-r)*(t.y-o)/(h-o)+r&&(n=!n)}return n},am=(t,e)=>{if(e.length<2)return!1;for(let i=0;i<e.length;i++){const n=(i+1)%e.length;if(hm(t,e[i],e[n]))return!0}return!1},hm=(t,e,i,n=.5)=>{if(rm(t,e,i)>n)return!1;const s=Math.min(e.x,i.x)-n,r=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>=s&&t.x<=r&&t.y>=o&&t.y<=a},lm=t=>{if(0===t.length)return{minX:0,minY:0,maxX:0,maxY:0};let e=1/0,i=1/0,n=-1/0,s=-1/0;for(const r of t)e=Math.min(e,r.x),i=Math.min(i,r.y),n=Math.max(n,r.x),s=Math.max(s,r.y);return{minX:e,minY:i,maxX:n,maxY:s}},cm=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=cm(t),i=pm(t[0],t[1]),n=pm(t[1],t[2]),s=Math.atan2(t[1].y-t[0].y,t[1].x-t[0].x),r=[{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(s),a=Math.sin(s);return r.map(t=>({x:t.x*o-t.y*a+e.x,y:t.x*a+t.y*o+e.y}))},um=(t,e,i,n=10)=>{if(0===i)return 1;const s=(t.x*e.x+t.y*e.y)/i/i,r=n/i;return s<=0?r:Math.max(s,r)},pm=(t,e)=>{const i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},fm=t=>Math.sqrt(t.x*t.x+t.y*t.y),gm=(t,e)=>({x:e.x-t.x,y:e.y-t.y}),mm=t=>{const e=fm(t);return 0===e?{x:0,y:0}:{x:t.x/e,y:t.y/e}},ym=(t,e)=>{const i=gm(t,e);return mm(i)},xm=t=>({x:-t.y,y:t.x}),bm=(t,e)=>{const i=ym(t,e);return xm(i)},_m=(t,e)=>{const i=mm(t),n=mm(e),s={x:(i.x+n.x)/2,y:(i.y+n.y)/2};return mm(s)},vm=(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},wm=(t,e,i)=>{if(0===pm(t,e))return[];const n=bm(t,e),s=i/2;return[t.x+n.x*s,t.y+n.y*s,e.x+n.x*s,e.y+n.y*s,e.x-n.x*s,e.y-n.y*s,t.x-n.x*s,t.y-n.y*s]},Cm=(t,e,i,n)=>{const s=gm(t,e),r=gm(t,i),o=_m(s,r),a=-o.x,h=-o.y;return{x:t.x+a*n,y:t.y+h*n}},Sm=(t,e,i,n)=>{const s=(t.x-i.x)*(e.y-i.y)-(t.y-i.y)*(e.x-i.x),r=(t.x-n.x)*(e.y-n.y)-(t.y-n.y)*(e.x-n.x);if(s*r>=0)return null;const o=(i.x-t.x)*(n.y-t.y)-(i.y-t.y)*(n.x-t.x);if(o*(o+s-r)>=0)return null;const a=o/(r-s),h=a*(e.x-t.x),l=a*(e.y-t.y);return{x:t.x+h,y:t.y+l}},Im=(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)}),Am=(t,e,i,n,s)=>t.x>=e&&t.x<=e+n&&t.y>=i&&t.y<=i+s,Mm=(t,e,i,n)=>{const s=i/2;return"horizontal"===n?[{x:t-s,y:e},{x:t+s,y:e}]:[{x:t,y:e-s},{x:t,y:e+s}]};class Tm extends Hs{dragStart=null;initialTouchDistance=null;initialScale=null;activeTouches=new Map;firstTouchId=null;secondTouchId=null;zoomFactor=.8;scaleMin=.2;scaleMax=5;originalPosition={x:0,y:0};targetPosition={x:0,y:0};centerPosition={x:0,y:0};originalScale={x:1,y:1};targetScale={x:1,y:1};defaultScale={x:1,y:1};transitionDuration=500;transitionStartTime=null;initialPinchCenter=null;isGestureValid=!0;lastTapTime=0;doubleTapDelay=300;doubleTapZoomFactor=1.5;lastTapPosition=null;tapDistanceThreshold=20;tapDetectionEnabled=!0;isGestureHijacked=!1;hijackedPointerId=null;isHijackPaused=!1;interactionGraphics;viewportBounds;boundResetAnimation;debouncedStopWheelRender;interactionState={isInteracting:!1,isAnimating:!1,interactionTimer:null,renderReasons:new Set};throttledAntiScale;constructor(){super();const t=Zi().getApp();this.viewportBounds=t.getViewportBounds(),this.eventMode="static",this.interactionGraphics=new Tl,this.interactionGraphics.rect(this.viewportBounds.x,this.viewportBounds.y,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.x+this.viewportBounds.width/2),y:Math.round(this.viewportBounds.y+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=Ni(t=>{Zi().emitter.emit("antiScale",t)},16,{leading:!0,trailing:!0}),this.boundResetAnimation=this.resetAnimation.bind(this),this.debouncedStopWheelRender=Fi(()=>{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)),Zi().emitter.on("gestureHijackStart",this.handleGestureHijacked),document.addEventListener("pointercancel",()=>{this.clearTouches()})}resetPan(t){const e=Zi(),i=e.getApp(),n=e.appContainer;null!==this.transitionStartTime&&(i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null);const s=this.centerPosition.x-t.x*n.scale.x,r=this.centerPosition.y-t.y*n.scale.y;this.originalPosition={x:n.x,y:n.y},this.targetPosition={x:s,y:r},this.originalScale={x:n.scale.x,y:n.scale.y},this.targetScale={x:n.scale.x,y:n.scale.y};const o=(a=Math.sqrt((n.x-s)**2+(n.y-r)**2),Math.pow(Math.min(1,a/1e3),.5));var a;this.transitionDuration=500+1e3*Math.min(1,Math.pow(o,2)),this.transitionStartTime=i.ticker.lastTime,i.ticker.add(this.boundResetAnimation)}setPanZoom({targetPosition:t,targetScale:e,setCenter:i=!1,setScale:n=!1}={},s=!0){const r=Zi(),o=r.getApp(),a=r.appContainer;if(i&&t&&(this.centerPosition={x:t.x,y:t.y},Qg.debug("[Interaction] Set center position:",this.centerPosition)),n&&e&&(this.defaultScale={x:e.x,y:e.y},Qg.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,!s)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));var h,l,c;const d=.8*(h=Math.sqrt((a.x-this.targetPosition.x)**2+(a.y-this.targetPosition.y)**2),Math.pow(Math.min(1,h/1e3),.5))+.2*(l=a.scale.x,c=this.targetScale.x,Math.pow(Math.min(1,Math.abs(l-c)/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=Zi().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(),Zi().emitter.off("gestureHijackStart",this.handleGestureHijacked),super.destroy()}handleGestureHijacked=t=>{this.isGestureHijacked=!0,this.hijackedPointerId=t.pointerId,this.isHijackPaused=!1,this.clearTouches(),this.activeTouches.set(t.pointerId,{x:t.global.x,y:t.global.y}),this.firstTouchId=t.pointerId,this.dragStart={x:t.global.x,y:t.global.y}};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=Zi(),e=t.getApp(),i=t.appContainer;if(null===this.transitionStartTime)return;const{targetPosition:n,targetScale:s}=this,r=e.ticker.lastTime,o=Math.min(1,(r-this.transitionStartTime)/this.transitionDuration);if(o>=1)i.position.set(n.x,n.y),i.scale.set(s.x,s.y),this.antiScale(s.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,r=this.originalPosition.y+(n.y-this.originalPosition.y)*t,h=this.originalScale.x+(s.x-this.originalScale.x)*t,l=this.originalScale.y+(s.y-this.originalScale.y)*t;i.position.set(e,r),i.scale.set(h,l),this.antiScale(h)}var a}onWheel(t){const e=Zi();if(this.isGestureHijacked)return void Qg.warn("⚠️ [onWheel] 被手势劫持阻止执行",{isGestureHijacked:this.isGestureHijacked,hijackedPointerId:this.hijackedPointerId,isHijackPaused:this.isHijackPaused});e.getApp().requestRender("wheel",!0),this.debouncedStopWheelRender();const{scaleMin:i,scaleMax:n}=this,s=e.appContainer;t.preventDefault();const r=t.clientX,o=t.clientY,a=(r-s.x)/s.scale.x,h=(o-s.y)/s.scale.y,l=t.deltaY>0?.95:1.05;let c=s.scale.x*l,d=s.scale.y*l;if(c=Math.max(i,Math.min(n,c)),d=Math.max(i,Math.min(n,d)),c===s.scale.x&&d===s.scale.y)return;const u=r-a*c,p=o-h*d;try{s.scale.set(c,d),s.position.set(u,p),this.antiScale(c)}catch(t){Qg.error("❌ [onWheel] 应用缩放时发生错误:",t)}}onPointerDown(t){const e=Zi();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;if(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),this.activeTouches.set(t.pointerId,{x:t.global.x,y:t.global.y}),1===this.activeTouches.size)this.firstTouchId=t.pointerId,this.dragStart={x:t.global.x,y:t.global.y};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=Zi();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;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=Zi(),{interactionConfig:i}=e;if(!i.enableDoubleTapZoom)return;const n=performance.now(),s={x:t.global.x,y:t.global.y};n-this.lastTapTime<this.doubleTapDelay&&this.lastTapPosition&&pm(s,this.lastTapPosition)<this.tapDistanceThreshold?(this.handleDoubleTap(s),this.lastTapTime=0,this.lastTapPosition=null):(this.lastTapTime=n,this.lastTapPosition=s)}handleDoubleTap(t){const e=Zi(),i=e.getApp(),n=e.appContainer,{scaleMin:s,scaleMax:r,doubleTapZoomFactor:o}=this,a=t.x,h=t.y,l=(a-n.x)/n.scale.x,c=(h-n.y)/n.scale.y;let d=n.scale.x*o,u=n.scale.y*o;d=Math.max(s,Math.min(r,d)),u=Math.max(s,Math.min(r,u)),this.originalPosition={x:n.x,y:n.y},this.originalScale={x:n.scale.x,y:n.scale.y};const p=a-l*d,f=h-c*u;this.targetPosition={x:p,y:f},this.targetScale={x:d,y:u},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)return t.pointerId===this.hijackedPointerId?(this.activeTouches.set(t.pointerId,{x:t.global.x,y:t.global.y}),void Zi().emitter.emit("gestureHijackPointerMove",t)):void 0;this.activeTouches.has(t.pointerId)&&this.isGestureValid&&(this.activeTouches.set(t.pointerId,{x:t.global.x,y:t.global.y}),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=Zi(),i=this.activeTouches.get(t.pointerId),n=e.appContainer,{x:s,y:r}=this.dragStart;n.position.set(n.x+i.x-s,n.y+i.y-r),this.dragStart={x:i.x,y:i.y}}applyPinchZoom(){const t=Zi().appContainer,e=Array.from(this.activeTouches.values());if(e.length<2||!this.initialTouchDistance||!this.initialScale||!this.initialPinchCenter)return;const i=pm(e[0],e[1]),n={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},s=(n.x-t.position.x)/t.scale.x,r=(n.y-t.position.y)/t.scale.y,o=(i/this.initialTouchDistance)**this.zoomFactor,a=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.x*o)),h=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.y*o));t.scale.set(a,h);let l=n.x-s*a,c=n.y-r*h;l+=n.x-this.initialPinchCenter.x,c+=n.y-this.initialPinchCenter.y,t.position.set(l,c),this.antiScale(a),this.initialPinchCenter=n}setInitialScaleAndDistance(t){const e=Array.from(this.activeTouches.values());e.length<2||(this.initialTouchDistance=pm(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 Pm=Symbol(),Em=Object.getPrototypeOf,Bm=new WeakMap,Om=(t,e=!0)=>{Bm.set(t,e)},km={},Rm=t=>"object"==typeof t&&null!==t,Dm=(t,e)=>{const i=jm.get(t);if((null==i?void 0:i[0])===e)return i[1];const n=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return Om(n,!0),jm.set(t,[e,n]),Reflect.ownKeys(t).forEach(e=>{if(Object.getOwnPropertyDescriptor(n,e))return;const i=Reflect.get(t,e),{enumerable:s}=Reflect.getOwnPropertyDescriptor(t,e),r={value:i,enumerable:s,configurable:!0};if(Lm.has(i))Om(i,!1);else if(Fm.has(i)){const[t,e]=Fm.get(i);r.value=Dm(t,e())}Object.defineProperty(n,e,r)}),Object.preventExtensions(n)},Fm=new WeakMap,Lm=new WeakSet,jm=new WeakMap,Gm=[1],Um=new WeakMap;let Nm=Object.is,zm=(t,e)=>new Proxy(t,e),Hm=Dm,Vm=(t,e,i,n)=>({deleteProperty(t,e){const s=Reflect.get(t,e);i(e);const r=Reflect.deleteProperty(t,e);return r&&n(["delete",[e],s]),r},set(s,r,o,a){const h=!t()&&Reflect.has(s,r),l=Reflect.get(s,r,a);if(h&&(Nm(l,o)||Um.has(o)&&Nm(l,Um.get(o))))return!0;var c;i(r),Rm(o)&&(o=(t=>t&&(Bm.has(t)?Bm.get(t):Em(t)===Object.prototype||Em(t)===Array.prototype))(c=o)&&c[Pm]||o);const d=Fm.has(o)||!Rm(u=o)||Lm.has(u)||!Array.isArray(u)&&Symbol.iterator in u||u instanceof WeakMap||u instanceof WeakSet||u instanceof Error||u instanceof Number||u instanceof Date||u instanceof String||u instanceof RegExp||u instanceof ArrayBuffer||u instanceof Promise?o:Wi(o);var u;return e(r,d),Reflect.set(s,r,d,a),n(["set",[r],o,l]),!0}});const Wm="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAPElEQVR4AezXMQoAMAgDwND//9n2B51EhxNcQ7gtJ7NX0wWiAAECBAgQIECAAAECBAgQWCFQb6G3/Sc7FwAA//+f4+OPAAAABklEQVQDAI04ICFaxIVcAAAAAElFTkSuQmCC",Zm="system-ui, -apple-system, sans-serif",Jm=["#d7bb46","#4990d7","#58a789","#749cd7","#f2646c","#91be76","#4ec7b1","#4bb3c8","#e7858a","#7fa96e","#efa667","#a3d774","#6b82d8","#75b551","#b392cd","#ed5454"],Xm={global:{containerTop:"0px",containerLeft:"0px",containerWidth:"100%",containerHeight:"100%",backgroundColor:"#f6f6f6"},map:{autoPaddingPercent:.05,obstacleColor:"#999999",freeColor:"#ebebeb"},room:{colors:{active:["#fae9a3","#a6d0fa","#9ce3c8","#d1e2fa","#fed8da","#d4f0c3","#a1f3e4","#a0e5f3","#fee6e8","#c1e5b1","#fee9d7","#e4fad1","#c8d3fa","#b8ea9c","#f0e5f9","#fdc4c4"],inactive:["#fef5d2","#d5e9fe","#c0f2df","#e7f0fe","#fef0f1","#f0fbe9","#ccfbf3","#caf3fc","#fff3f4","#def5d4","#fef1e6","#f2fee7","#e6ebfe","#d5f7c2","#f3e9fb","#fee2e2"],name:Jm,propertyTheme:Jm,selectionIndicatorBackground:Jm,selectionIndicatorIcon:["#ffffff"],[zg.NO_ROOM_DATA]:"#ebebeb",[zg.ROOM_GAP]:"#ebebeb",[zg.OBSTACLE_ROOM]:"#ebebeb",[zg.UNKNOWN_ROOM]:"#ebebeb"},nameLabel:{fontSize:10,fontFamily:Zm,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:Zm,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:["",Wm,Wm,Wm],opacity:.1,scale:.2}},path:{lineWidthFixed:!1,incrementalThreshold:5,commonPath:{color:16777215,width:.5},transitionPath:{color:"transparent",width:.5},chargePath:{color:"transparent",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:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAC0FBMVEUAAABd/v9g//9c/v9c/v9d//9d/P9c//9a//9g//9d//9c/v9c//9c/f9b/f9c//9c/P9d///1+fxdoP5c/v9at/vt8vfv8/hbrvzr8PZcpP3s8fbq7/RcqP3v9PlauftbsPxcqv3p7vTy9/rp7vVatvvp7/Zdo/5bs/vs8ffw9vpauvtbtPtcpv7q8PdatPtdov7z+Pvm6/BcrP3y9vlcqf3n7fTo7fPo7PJbsf3x9vvn7PLy9/3m6vDn7fPz+P3w9fnr7/Zc+P/0+f3v8/ru8/nj6O70+PvT2N3q7vTq7/Lu8vbw9Pfc4OTd4ufc4ebj5+vf5Olyrf3f4+fr8fTY3OFbvvzw9fvl6u/i5+3g5eva3+PZ3eKDtvvb3+TW2+Bc2/7r8Pjt8fRb3f5b0v3s8fnm6/Lk6O/z9/3p7fDk6ezV2t/z+f3u8/fn6u3k6fDR1dpb5f5b4f7h5uvL0NXHy9Bc8/9c7f9c4P9oqP1hpf13sfvJzdJc+v/o7O9d1f9d0P9c9f5c6v7Dx8vAxMj3+/9c5/9b2f1axvxhtPyHyfvV6fji7fbi5unAxspcw/5duP283vqo1PnN5fjO09jN0tezt7ujp6tdrP5b1v1czv1awftiuftau/qGufrk7/itzvXX4e27v8OtsLSeoqZcyf5dxv5ouPxqsvxtrPxnu/uy1fjn8Pfc6/eKu/e71vaexfbR4fOryvHN3O/h5ObY297P0NPFyc22u8CQk5b0+f9c1/5cu/5hqv1by/xjrvx/wft8uvui1Pqb0fqSy/qjy/iTwPi9wcWoq66LjpGGiIqAg4Vuv/t0uPus2PrA4Pmcy/l/tPnE2/Th6fLY5fLc5fDh5+/V19m6vL6ws7aanqOUl5pcy/6My/t2wftvsfuZxfmixvLH2e6+0+3T3euXm59bs/3G4/q13PqMw/qfutReYmWIw/lehat+lKpucXTzEWWjAAAAEnRSTlMA3yDvv59gQDAQj8+vgHBQUGCCCRFYAAATkklEQVRo3rWbh1dcRRTGJVRDjBHXjSuIumwWH8YV1rgL7C6dZbObpUgvgpAAAkJIgFSMplhiiqYbS6JJ7C1RY2Lvvffee/8X/O7M7OMNDwyQeA/mHD1Hf373fnPnzpvhuHHH8THTTpgcEREWFm4whIeFxU6JnBoVc/xx/2/EREXGGkaMsMioScccJ5RGTYFGHnmrVi1ZcvHll1+8ZMmCxXmhfxo+JerYK58WGUJeft2TGWedddb5iFN5nF315bwFeZwdEX0s2ZMimdZFC2+//oILAEUIsiaq5i3MY+zJxyrn0ZFM6tyq0y9AjMY9k+I6zo6IPgbYqAgDYu51pyOOREbMuGbVMUFP4tiM08fGRWRknHJ1HqFjjqq2VNl5GecCOnby2Wdz9OQJ2ywqDP/6Exnnjo+LAHou2WzqxLO8MOO0cxHjU5xxNqJqMeV7AgY/EXIX3XHa+LkIAs+cec1KNLRxm+wEyvJZpyHGrxhB5PPOmEuVHl+aITcPchETV4zYCZPFThofd9GpoE5MsQCfN/O886jSYWMmx4B7BZBHrxjwuSDHjNFW4eAmnzY6+am7fntp86ZNb53/zL0ffnjgwc3vPrd2xBrzuBrrakwWO8lA3ORRuE8999L799m658yZk7Pu/N/ri8s2lPb4/ZYtm59dO4JiwGfM2In/4Elj2BLIVskA68gAP3fv/Up3ANCcHPx171+PHRoY7N/qqyzv9Fesv/dZfY0JPGMeLHbiEesbbsj7GdwRFN/17ofxgemJ0wV3Vk5OzaPBg73bBtesHtzqa9iwouX+d+/U1XgG4po8Q3jMkf18XWrqCIq/ubXNZDSCmwhwCoGHoqLYNwB2fWnLfZvXDq8xkefpva3n3g6uTvHdt643xRsB5ooToXlWCqcm8fA39Pf7Gkr9u59fK9cYccopFx+BHAtfpabqFD/17YcJpnjFaOwmcDdSrYLBFZE2y97V39uwoWLdtTOlGgPMyaNzJxsMlwM7XPHy9525pJcUM8lccIqWC3BRWlpLQ39vZalp051yjQEm8gn/YejFJ5+sU/zyB7NNpngCdxO5EGzUWA9GxKUFuvp99R3rn5VrTOSVsPaoBc67AVxZ8VMPuswJBAZ6OoHBBVivmLiItI7e3q7SLc/LNUbcdNloZY6AsU4ervju79PNCSgwShyvTJ9O7ipMTAE4h4NlwSySglt9xS2/rpVqjIC1I0biTkWBwZUVL78NegEmvVAMMIIEzwmBU7SCEZfirxW9vcGKLTdLNUYsNBii9Nzjww2Lzj15iKxyOZjQRGUrGQHF1cTVgOMEGBHo8tX7192jrTGiaiVLtt7R16tchOCmExieptWkoMZGYAtTCgoo1TkEzpQFi5jV4Gvw/3KzWmM12ZG6VmkwXAUswILMuPZ0pzlhNhQzWyOguBB6C6A4E7keDQyPlfjqQZbBZ1xlMEzSO+sGBv52V0jx0oft6RA8G2DGVQhMAXLKdCimIqtgHbm4K1jx64yZEvgmnb+iubMQD94qFCf/UONKd6abZwtzgUxgKGYhg4lbFDdMc2V5/PMzZMnMX7LgvHM5+MCDQvF3Xgh2mlFjRLyJrSdKNUKQCZwiwDrFWFb1DWWBayXuGTethGRZ8BUn8/joYa74vT67C4pRY/QPAtN6UsEpBYk6xQDLkVNZWbr7TQl8Bjpn9IiCU3s+YtylP9ZAMNWY25qqHKB9QuQ6BWCydWZmpg6shr+pcsU7MvgmydiThgQvK+1MJvJDXrurI50rFuvJiGDgQp5pBCkWkqnGuiitrG/5SiYvgLG1a/hcAV76yIal4L5XV+NyprtI8Gz/bIBJsELdOlTiggIuWXJ1/vAyNzaV33+zhitLRtPCGhbg4CN3p6Yu+97rQYXTHU6zZh2LrpnIUy1ynTQ6GFFR2dSxWQKfs8AQrrHW9Sq4Prg8NfmBOg+sRaZ2mv0JCIChl4HRMwuZaC45ya3mmvdLOcoqS9a/KYFvNBim6awF8MGDu5hge1YWgallcsViIQONplnIwdVUZbdblayPWZWVK96WJV9GuRaZvhhIHhd+8snLqbsgGGBKNc+1ie9PPNSVDMW8a4JMQWC9vxqKd9+j5SLXBn5kj0Kmh8CPPrp/2Q9eu70tywmwmcBmArOFzLdkyMVPgSADDbKYfeRk4+8guaHjeQn8dKh7TTHknTwEHnh0//KydrvHRYotoZZJtmbR3U0LakiyOg5kAlxUNILovnoYWws+Z6VhCgMj0xrw6tUvPVQ7385S7XLQcgI6t0KAFWCZwYTiaoFGUJlHIgcqG/zXSpJXcV9PwsSjAb/yyq0/ej2oscPJwRZaTnzqChgFGKJVyehdgh5KtxxFJZWlmyTF2JZjeIkzNOBPP324rB3cNkdWutNipolL2JqWFMgAUxSEyDmhYGRKuLbEiJrK4Pp7tOBreJEjUWINePv28tp2KOY1BtiSwNgAk6/5OFCIlaxGDiZtRABosEn08BXVhFxrwGJBhRmWaMDL9+6t99ZAscsBMEs1aqxuyfhhq4lyLaIAZ4vuAGJF/8Y1g+W6YQS5bip9W8r1YkMsVjFKrAXv2FHs9bQBnEWpZuCQrZFqAsPXFCEsuMZAoGL1jn17Nm7cePjVNTVJw7aLzqbguuu1iufSSo7B8VADvmjfqyhxm4crtjjJXCBXJOSCC9WhHUp1NswWiK/w7djeW+exKIqjduv2wZyi4buj6R4VLNwlewvgL/b2wVvCXA4HV2w1wddwlzr+hDTjT6TfP7hvoNZhyWozm0w2k7d/T0AeOZu6UGQNGO6aRnN8shb82J4+WCuUagIn+GlbFL6mKUSQYbFC4pr8g59vs1tK6hrrXM66hhqb2bcmR5q+Gn09L2hrXIUDnGxqgF/vr53vYeZywFwAW5Frq4ncJbYokNUgcELwsUMeS2Kjw2JrLVQs7U4loXebVnJRmW/D2yqX23oyGuZiCfxGQy243NVZTjRrgHFaRO+iQO/ScV079nodKUarxWIrKFCsNqVA8WzskDaKrpJ3tOBbFmPkizUskcHF3vlwNYGd2wbbnGaLJYGKrLYQCg3YZG54o9fhMVusVoBbbTZFaW22lfRrwTWwtaSYwGHo1FKqi2kZe1iqfb0OgK2scYnmpaCFDBP86k+1li6nBWSArc3NzTa7teaVJA24o6l+vbbGtywwhOnAr5WjU3u44sE1bdgXheJcJZ4yLfYJwTWaZnu++MzcVga9iAIIttls7e3NA3bUtqejk/ErmuqtkmICh+MIIbm6zAtzMVc7fdvasB1bZnMwJBNaay+Azd5/9lTbra2KYttaZ3b4bM2KYvUqJYNxRR1XXnnlijkM3NAi1Xgh9ieD4UY92M5c7az0uaBYXcgUonkJzUbFZO77Y/vj3urHL812H+o73NerFLS2Gpta7YNxLXFzZs2JKwW4paleAlPrGh2c5XAO7MlywFzItc1q4jMu9ZD46UI09gwGdtcaq92Z1avLttm78rPd7mpPtXcgbs6cK68smtXDwQGpxgDrUo0a1wjFWT4fzT5WgMHl8w8DGxlZgL1v7LGZE6jEJZ5Wc3s+8puT/rjPF1fUsqKlp6eIDbnBgKSYUq03F1PcRoq39meZ0UHI1jYTSbahyuACyshGqrH98x3tZgWmtijVilWpzn78ypru/EOzLoW70ri3/ZUlu1Ww6mr9cpovXJ3VNNCGORNg5NqUm5sr3EVkIwUpTnCtea3Y4TKDjFVsBdnttj/u36htXSsaytfrXB1huEpuICVItVhO5jqa6Dk4F8nOhVw+DYhA2hPMda+vznLWmS3oWABbW6uVAjcyna9pII1lW6QarzLE6sCv+3ivtjvY7CM6CBRTlRlYCRBSI3nPT/UOrw+Cm9FDrLbqgmrvmhzNnFtU2rhhk6R4EebMyfImseu1Q7WqYoAtIbCNvJWrMGML8nQCQ7J33/Y+x/yNXitlOjGttdW+plzeJBp7Nks1ptnnhGHb4heHa9vZ6ONk+yJmENiGu6sC7oJk1r+0kp11+w6XmVo9jX2t1ZmJNmvtxq40IVh8cQv6X9SCsS1OPW7asEFg3946gNkEwlItbA01MBeKLA6OtJanh8jmsh17m5yKLReptnm6DnclSeA5jcGWN3VjJkafJzXg9159tcyr1jjdQnOmVbQQ6l6KYtL6S5Bnu9b8tL2/rq6vrGzg8Ct2jLj5WlM3lu++WTf6HC+3ruWffRakhRwautQik2GpyAopJvZQKPS/lL56777PP9/x2erOFMyZ4Gq8FcRErwVfzY5tsbC1NNAXk7uoZWa50h2iyDgwwq+skzBjGzVkamBsDpxO430KHaKkE3pSY2OHNPngDBOmH+hfWXNbnTc0gjCwk8CzUT34iyTHy5qpdSIC9LER5KQkd1FctvRVoLGk4mtproap9UeY1QP7S7xi6BLriXdrgK3oXbZmLZZ/RwabfdTNRCRlp6Vl50tjdXDDupv1Rxh5sKZj6gM/8FzDXQRWe5cNSwq+bobkITQBKQoht5pxs9Muzc+WFxMyrQWjxJP4MXWJBvzo1l0v97XzfZHmTA624oumDaIBVu0ljlFAEjwFgt1u9yVuOCtfq7ijpPy+NyWw+PyCOXORBtz7ya6lOKcSmI5tZnaK4ZJ5+7Khylyzqhg/BZRoIhNYSnV5cQ9GTA0ZJZ4ywqeITw6+l/pdbWh/IsUIKzKekIs6U8dm9lLELsXPygXgAgzB2VTibA25ori84toRP0VgJWs/vhw8eGHq3be1o8bINbkL9uJTiNijcm3NpFgJSYZeCnBBznZfghIjhgSXd+LEpgUj08cDKy0ogBuCF6YmP1QLMC+yxeHguabDKrNXLnUvlDqUazIWCRaKLyHB+UWC64fgr6RMV12mfsCdhq6pgoMAk+SQu8y0M3JfI6hji1yHJKvf+YRid3Y+kUOfy4s7150yQ0t+mn+/lT+/APzII1CcjCoDzHMNyQCLXFMTsQkyB2MZgypSDbIbVKDFGi4pxydrSfFiNdPItbgXQNxN4NTkZQ/jYyZtyaxdC18jrIysNNMfRvUKjMgFbDWR5EuyAc7ntzHBko5NsuAq7UOJSUP2WrqBfb1NvqjOo+YaYEgG2RKS3ExrWUimb5tcspuKDHY2JZs0JxWXlO6+Z4YEnsu6h17y0s6epakgn/YQk+xwka+ZvSwCTGTYS811NykuwI1QCinmyWbsuKI+JPor+W5AWEt/NbCsp2cZKUay2/kUku6g7sXAZG0h2TZEBpcF5TozG1TCErgjWOzfJHNJcLR8GbJISJ7vEbcwy8tYvxY7FMs1fgC2ypLF5RsVGcHLzNgVweKedfeMJlhElHr9c+BA6N7pgVoPndyIjOkaVAS3F5ayTZVMYLroTFTBtJYvzW5pLO687+uZMnghBI9y4fXgg+pN2/6PaUkNSbYQ2cLnTZstXgUTGT8CjGSnQXJ8Q0mp7Vrt3SJCf+EFY4s96oGX1bvFZQ/VItlOdQCygM2rjFMFqiyWlLgfSUFALzkbiv3g3vfiTJl7xmIatoZFpNiWk9W7RSK327NCAxAniyrncnsr0Awwi8RMSGZc+NoFbjy4MvhpWsP6+3Jc48q3qSDf6vVkYUmZIZn5SyQbfdOk2NTGSVgaBKpT3IS+JKmuvrgz8MLw++OqlZqmpfeXRjHI+5FtNl/z9mURUxBJZsYWmo2FYvKhXHfXN5b3KNeSXkkyltLUUa7qr5MVUzzwMRoJb18OYImMNLOUN5s0yWZFzqTo7Cop89//9UwKLXcnnDX64wT9q4jlD89vc4LMzhR8u7DizIC5QPhL4ZczmAYyMXUlVDaVlLZsuRNQYMfwOAFxIp6P6RTj+cmtWFYg0+cQglv4eI8ygxwPKjQzMN4OmBp9jeUrbM+vld+BUCyiJTz6Q70rdIrx4mbXAY+dkZ1kbnGU4tM9yK1GwNk3bHOjD65q2fLs8Lc+VOD/fL4XBrJOMcjP7P/I43KSXt5JwESyIZyyTZrpo0RdF2H9u19Yy7gstE9uYo/wyIjI+tdN31C+HeASWVhbzEJYUYqzuKu3K1jWU3Hf23fq3nMBvHMsz5vu0Cum+Oalj9gtGJWargtwJiVygr2uyde/zVdfXtoRWL/5Tv17LoDnEXcMD8n0ilk88/L789tcVGgL0JaE9b9/cWjj6oFtvspgWWlHS2DLi2tHeLM3todksLbm6Zz+zd5d377/gQtspwMZf+7vgcaS4rLSzhX+lvgteL2mf7OnPp2LHttjwS85WE9GPPPcS/ce+OADh+Pe8x9w+f3+BPP972z+c+3I7zIJfPWYHgsiovE8cl7yf7/LfOaut97Cu8y7fnvx2bfu+s93mcQNP3HsD0KfYNSje3vLAtywmPE8gV2ccSxeolat5H4eMzkWFvvy6N/ewlbj4iIms2fOR6cYIyXd84wzounF8ZNHU+N5lOYTJ/iU/aqMiSquumqCT9kRU8NZvidS4yrKcljUhH/vhiqdN+/88SquuhpZNkRC7oQjJoKjx0PGh3+e5aOLaKBR66rzx8h9mmNFlo8eTb+Ec2TyNfyXcCKjj9WvHU0O5+wbrx+dW3XjAlQWjfloaqu3WXQE2ARfeOPtT54pk8+uumPnKkhlYukB0f/4q2WLF+BXy3buxK+WrVr1//5qmch5VGSYYcSIjYzS7UHHWnlM1NTIKbGhXx+MiJh8wrSY8Sv9F+RaDBk7fzBtAAAAAElFTkSuQmCC"},speed:0,rotationCorrection:0,sleepAnimation:{jsonSrc:"data:application/json;base64,eyJmcmFtZXMiOiB7Cgoic2xlZXBfMDAwLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDAxLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6ODAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzAwMi5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjE2MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDAzLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMDQucG5nIjoKewoJImZyYW1lIjogeyJ4IjozMjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzAwNS5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjQwMCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDA2LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6ODAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzAwNy5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjgwLCJ5Ijo4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDA4LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MTYwLCJ5Ijo4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDA5LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDEwLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MzIwLCJ5Ijo4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDExLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6NDAwLCJ5Ijo4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDEyLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6MTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMTMucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6MTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMTQucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjE2MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDE1LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5IjoxNjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzAxNi5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6MTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMTcucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjE2MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDE4LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6MjQwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMTkucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6MjQwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMjAucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjI0MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDIxLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5IjoyNDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzAyMi5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6MjQwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMjMucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjI0MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDI0LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6MzIwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMjUucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6MzIwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMjYucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjMyMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDI3LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5IjozMjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzAyOC5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6MzIwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMjkucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjMyMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDMwLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6NDAwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMzEucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6NDAwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMzIucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjQwMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDMzLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo0MDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzAzNC5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6NDAwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMzUucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjQwMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDM2LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6NDgwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMzcucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6NDgwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMzgucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjQ4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDM5LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo0ODAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA0MC5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6NDgwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNDEucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjQ4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDQyLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6NTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNDMucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6NTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNDQucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjU2MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDQ1LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo1NjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA0Ni5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6NTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNDcucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjU2MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDQ4LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6NjQwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNDkucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6NjQwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNTAucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjY0MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDUxLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo2NDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA1Mi5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6NjQwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNTMucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjY0MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDU0LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6NzIwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNTUucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6NzIwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNTYucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjcyMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDU3LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo3MjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA1OC5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6NzIwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNTkucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjcyMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDYwLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6ODAwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNjEucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6ODAwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNjIucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjgwMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDYzLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo4MDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA2NC5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6ODAwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNjUucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjgwMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDY2LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6ODgwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNjcucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6ODgwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNjgucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjg4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDY5LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo4ODAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA3MC5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6ODgwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNzEucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjg4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDcyLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6OTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNzMucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6OTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNzQucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjk2MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDc1LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo5NjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA3Ni5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6OTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNzcucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjk2MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDc4LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6MTA0MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDc5LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6ODAsInkiOjEwNDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA4MC5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjE2MCwieSI6MTA0MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDgxLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5IjoxMDQwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wODIucG5nIjoKewoJImZyYW1lIjogeyJ4IjozMjAsInkiOjEwNDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA4My5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjQwMCwieSI6MTA0MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDg0LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6MTEyMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDg1LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6ODAsInkiOjExMjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA4Ni5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjE2MCwieSI6MTEyMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDg3LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5IjoxMTIwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wODgucG5nIjoKewoJImZyYW1lIjogeyJ4IjozMjAsInkiOjExMjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA4OS5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjQwMCwieSI6MTEyMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDkwLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6MTIwMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDkxLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6ODAsInkiOjEyMDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA5Mi5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjE2MCwieSI6MTIwMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDkzLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5IjoxMjAwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wOTQucG5nIjoKewoJImZyYW1lIjogeyJ4IjozMjAsInkiOjEyMDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA5NS5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjQwMCwieSI6MTIwMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9fSwKImFuaW1hdGlvbnMiOiB7Cgkic2xlZXAiOiBbInNsZWVwXzAwMC5wbmciLCJzbGVlcF8wMDEucG5nIiwic2xlZXBfMDAyLnBuZyIsInNsZWVwXzAwMy5wbmciLCJzbGVlcF8wMDQucG5nIiwic2xlZXBfMDA1LnBuZyIsInNsZWVwXzAwNi5wbmciLCJzbGVlcF8wMDcucG5nIiwic2xlZXBfMDA4LnBuZyIsInNsZWVwXzAwOS5wbmciLCJzbGVlcF8wMTAucG5nIiwic2xlZXBfMDExLnBuZyIsInNsZWVwXzAxMi5wbmciLCJzbGVlcF8wMTMucG5nIiwic2xlZXBfMDE0LnBuZyIsInNsZWVwXzAxNS5wbmciLCJzbGVlcF8wMTYucG5nIiwic2xlZXBfMDE3LnBuZyIsInNsZWVwXzAxOC5wbmciLCJzbGVlcF8wMTkucG5nIiwic2xlZXBfMDIwLnBuZyIsInNsZWVwXzAyMS5wbmciLCJzbGVlcF8wMjIucG5nIiwic2xlZXBfMDIzLnBuZyIsInNsZWVwXzAyNC5wbmciLCJzbGVlcF8wMjUucG5nIiwic2xlZXBfMDI2LnBuZyIsInNsZWVwXzAyNy5wbmciLCJzbGVlcF8wMjgucG5nIiwic2xlZXBfMDI5LnBuZyIsInNsZWVwXzAzMC5wbmciLCJzbGVlcF8wMzEucG5nIiwic2xlZXBfMDMyLnBuZyIsInNsZWVwXzAzMy5wbmciLCJzbGVlcF8wMzQucG5nIiwic2xlZXBfMDM1LnBuZyIsInNsZWVwXzAzNi5wbmciLCJzbGVlcF8wMzcucG5nIiwic2xlZXBfMDM4LnBuZyIsInNsZWVwXzAzOS5wbmciLCJzbGVlcF8wNDAucG5nIiwic2xlZXBfMDQxLnBuZyIsInNsZWVwXzA0Mi5wbmciLCJzbGVlcF8wNDMucG5nIiwic2xlZXBfMDQ0LnBuZyIsInNsZWVwXzA0NS5wbmciLCJzbGVlcF8wNDYucG5nIiwic2xlZXBfMDQ3LnBuZyIsInNsZWVwXzA0OC5wbmciLCJzbGVlcF8wNDkucG5nIiwic2xlZXBfMDUwLnBuZyIsInNsZWVwXzA1MS5wbmciLCJzbGVlcF8wNTIucG5nIiwic2xlZXBfMDUzLnBuZyIsInNsZWVwXzA1NC5wbmciLCJzbGVlcF8wNTUucG5nIiwic2xlZXBfMDU2LnBuZyIsInNsZWVwXzA1Ny5wbmciLCJzbGVlcF8wNTgucG5nIiwic2xlZXBfMDU5LnBuZyIsInNsZWVwXzA2MC5wbmciLCJzbGVlcF8wNjEucG5nIiwic2xlZXBfMDYyLnBuZyIsInNsZWVwXzA2My5wbmciLCJzbGVlcF8wNjQucG5nIiwic2xlZXBfMDY1LnBuZyIsInNsZWVwXzA2Ni5wbmciLCJzbGVlcF8wNjcucG5nIiwic2xlZXBfMDY4LnBuZyIsInNsZWVwXzA2OS5wbmciLCJzbGVlcF8wNzAucG5nIiwic2xlZXBfMDcxLnBuZyIsInNsZWVwXzA3Mi5wbmciLCJzbGVlcF8wNzMucG5nIiwic2xlZXBfMDc0LnBuZyIsInNsZWVwXzA3NS5wbmciLCJzbGVlcF8wNzYucG5nIiwic2xlZXBfMDc3LnBuZyIsInNsZWVwXzA3OC5wbmciLCJzbGVlcF8wNzkucG5nIiwic2xlZXBfMDgwLnBuZyIsInNsZWVwXzA4MS5wbmciLCJzbGVlcF8wODIucG5nIiwic2xlZXBfMDgzLnBuZyIsInNsZWVwXzA4NC5wbmciLCJzbGVlcF8wODUucG5nIiwic2xlZXBfMDg2LnBuZyIsInNsZWVwXzA4Ny5wbmciLCJzbGVlcF8wODgucG5nIiwic2xlZXBfMDg5LnBuZyIsInNsZWVwXzA5MC5wbmciLCJzbGVlcF8wOTEucG5nIiwic2xlZXBfMDkyLnBuZyIsInNsZWVwXzA5My5wbmciLCJzbGVlcF8wOTQucG5nIiwic2xlZXBfMDk1LnBuZyJdCn0sCiJtZXRhIjogewoJImFwcCI6ICJodHRwczovL3d3dy5jb2RlYW5kd2ViLmNvbS90ZXh0dXJlcGFja2VyIiwKCSJ2ZXJzaW9uIjogIjEuMSIsCgkiaW1hZ2UiOiAic2xlZXAucG5nIiwKCSJmb3JtYXQiOiAiUkdCQTg4ODgiLAoJInNpemUiOiB7InciOjQ4MCwiaCI6MTI4MH0sCgkic2NhbGUiOiAiMSIsCgkic21hcnR1cGRhdGUiOiAiJFRleHR1cmVQYWNrZXI6U21hcnRVcGRhdGU6NjYyMDEzY2I2NDMwZGNjYWFjM2ExYTBiYjVlOTc4MzM6NTE3ZDlkN2RjOGI2MDBkMmQ2ZWIyOTVjMzc5ZTJmZmI6ZmViYzA4ZWVlMDM4NjliMDAwNmM5ZmQxNWI3NDMzOTkkIgp9Cn0K",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:Zm,textFontWeight:"400",unitLabel:"m",forbiddenSweepZone:{minSize:1,iconWrapperFillColor:"#ff4444",strokeColor:"#ff4444",strokeWidth:2,fillColor:"rgba(255, 68, 68, 0.1)",outlineOffset:20,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",textColor:"#ff4444",textPosition:"bottom",textOffset:10,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:20,outlineStrokeColor:"#fe8a07",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(254, 138, 7, 0.05)",textColor:"#fe8a07",textPosition:"bottom",textOffset:10,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:20,outlineStrokeColor:"#5d68fe",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(93, 104, 254, 0.05)",textColor:"#5d68fe",textPosition:"bottom",textOffset:10,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},virtualWall:{iconWrapperFillColor:"#ff4444",lineWidth:2,lineColor:"#ff4444",hitAreaThickness:30,outlineOffset:20,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",minWidth:1,textColor:"#ff4444",textOffset:10,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:10,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:window?.devicePixelRatio||1}},Ym={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},Km=["resetPanZoom","getForbiddenSweepZones","getForbiddenMopZones","getCleanZones","getVirtualWalls","getSpots","getViewportCenterPoint","getMapCenterPoint","getWallPointsByViewportCenter","getForbiddenSweepZonePointsByViewportCenter","getForbiddenMopZonePointsByViewportCenter","getCleanZonePointsByViewportCenter","getSpotPointByViewportCenter","getEffectiveDividerPoints","getDividerEndPoints","snapshot","snapshotByData"],qm=["onMapFirstDrawed","onMapDrawed","onPathDrawed","onRoomPropertiesDrawed","onClickRoom","onClickRoomProperties","onRemoveForbiddenSweepZone","onRemoveForbiddenMopZone","onRemoveCleanZone","onRemoveVirtualWall","onUpdateForbiddenSweepZone","onUpdateForbiddenMopZone","onUpdateCleanZone","onUpdateVirtualWall","onUpdateSpot","onUpdateDivider","onClickForbiddenSweepZone","onClickForbiddenMopZone","onClickCleanZone","onClickVirtualWall","onClickSpot","onClickDetectedObject","onClickCustomElement"],Qm="MAIN",$m=5e3;class ty{static contextStack=[];static instanceMap=new Map;static serviceCache=new WeakMap;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 ey,this.serviceCache.set(t,e)),e}static provide(t,e){this.contextStack.push(t);try{return e()}finally{this.contextStack.pop()}}static async provideAsync(t,e){this.contextStack.push(t);try{return await e()}finally{this.contextStack.pop()}}static useContext(){const t=this.contextStack[this.contextStack.length-1];if(!t){const t=this.instanceMap.get(Qm);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(Qm)}static clear(){this.contextStack.length=0,this.instanceMap.clear()}}class ey{getApp(){return ty.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=Fm.get(t),[i,n]=e;return Hm(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}}class iy extends Hs{viewportBounds={x:0,y:0,width:0,height:0};maskGraphics=null;containerElement=null;constructor(t,e){super(),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:s}=t,{width:r,height:o}=this.getContainerSize(),a=this.parseSize(i,r),h=this.parseSize(e,o),l=this.parseSize(n,r),c=this.parseSize(s,o);this.viewportBounds={x:a,y:h,width:l,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 Tl,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}return t.endsWith("rpx")?parseFloat(t)*(window.innerWidth/750):t.endsWith("px")||!isNaN(parseFloat(t))?parseFloat(t):(Qg.warn(`Cannot parse size value: ${t}`),0)}getViewportBounds(){return{...this.viewportBounds}}updateViewport(t){this.calculateViewportBounds(t.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),this.maskGraphics?.clear(),this.maskGraphics?.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215)}addContent(t){this.addChild(t)}}const ny="roomFill",sy="free",ry="roomFloorType",oy="carpet",ay="obstacle",hy="heatmap",ly="path",cy="controls",dy="roomInfo",uy="detectedObject",py="customElement",fy="customElementGif",gy="chargingStation",my="robot",yy=["interaction",ny,sy,ry,oy,ay,hy,ly,dy,uy,py,fy,gy,my,cy];class xy extends Hs{layers=new Map;constructor(){super();const t=Zi().getApp().getViewportBounds();this.position.set(Math.round(t.width/2),Math.round(t.height/2)),this.initializeLayers()}initializeLayers(){Object.values(yy).forEach(t=>{const e=new Hs;e.label=t,t===cy&&(e.isRenderGroup=!0),t!==ry&&t!==oy||(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):(Qg.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 by extends Tl{constructor(){super(),Zi().appContainer.addToLayer(ay,this)}draw(t){const e=Zi();this.clear(),this.setFillStyle({color:e.mapConfig.obstacleColor});for(const e of t){const t=e.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(),this.updateCacheTexture()}drawRaster(t,e){const i=Zi();if(this.clear(),0!==t.length){this.setFillStyle({color:i.mapConfig.obstacleColor});for(let n=0;n<t.length;n+=$m){const s=Math.min(n+$m,t.length);for(let i=n;i<s;i++){const n=t[i],s=n%e,r=Math.floor(n/e);this.rect(s,r,1,1)}this.fill(),s<t.length&&this.setFillStyle({color:i.mapConfig.obstacleColor})}this.updateCacheTexture()}}destroy(t){super.destroy(t)}}class _y extends Tl{constructor(){super(),Zi().appContainer.addToLayer(sy,this)}draw(t){const e=Zi();this.clear(),this.setFillStyle({color:e.mapConfig.freeColor});for(const e of t){const t=e.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(),this.updateCacheTexture()}destroy(t){super.destroy(t)}}class vy{target;isPointerDown=!1;pointerDownPos=null;clickThreshold;stopPropagation;clickCallback=null;constructor(t,e={}){this.target=t,this.clickThreshold=e.clickThreshold??10,this.stopPropagation=e.stopPropagation??!1,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 wy extends Hs{roomGraphicsMap=new Map;roomContextMap=new Map;roomClickHandlerMap=new Map;unsubscribeFns=[];mapWidth=0;rasterRoomDataMap=new Map;constructor(){super({isRenderGroup:!0}),Zi().appContainer.addToLayer(ny,this)}draw(t){const e=Zi();this.clearRooms();const i=e.roomConfig,{selectRoomIds:n,enableRoomSelection:s}=e.runtimeSnapshot;t.forEach((t,e)=>{const r=t.id>=255,o=new Tl,a=new lh,h=new lh;if(r)a.setFillStyle({color:t.color}),h.setFillStyle({color:t.color});else{const t=e%i.colors.active.length,n=e%i.colors.inactive.length,s=i.colors.active[t],r=i.colors.inactive[n];a.setFillStyle({color:s}),h.setFillStyle({color:r})}if(a.poly(t.polyPoints).fill(),h.poly(t.polyPoints).fill(),t.outlinePoints.forEach(t=>{a.rect(t.x,t.y,1,1).fill(),h.rect(t.x,t.y,1,1).fill()}),o.context=r?a:s&&!n.includes(t.id)?h:a,!r){const e=new vy(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:h}),this.addChild(o)})}drawRaster(t){const e=Zi();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:s,activeColor:r,inactiveColor:o}=t,a=new Tl,h=new lh,l=new lh;h.setFillStyle({color:r}),l.setFillStyle({color:o}),this.drawPixelPointsInBatches(h,s,$m,this.mapWidth),this.drawPixelPointsInBatches(l,s,$m,this.mapWidth);const c="number"==typeof n,d=!e||c&&i.includes(n);if(a.context=e&&c&&!d?l:h,c){const t=new vy(a,{clickThreshold:10,onClick:()=>{this.handleRoomClick(n)}});this.roomClickHandlerMap.set(n,t)}this.roomGraphicsMap.set(n,a),this.roomContextMap.set(n,{activeContext:h,inactiveContext:l}),this.rasterRoomDataMap.set(n,t),this.addChild(a)}drawPixelPointsInBatches(t,e,i,n){for(let s=0;s<e.length;s+=i){const r=Math.min(s+i,e.length);for(let i=s;i<r;i++){const s=e[i],r=s%n,o=Math.floor(s/n);t.rect(r,o,1,1)}t.fill()}}handleRoomClick(t){const e=Zi();e.events?.onClickRoom?.(e.getRoomData(t)??{id:t})}setRoomStateBySelectIds(t){const e=Zi(),{enableRoomSelection:i}=e.runtimeSnapshot;this.roomGraphicsMap.forEach((e,n)=>{if("number"==typeof n){const s=!i||t.includes(n),r=this.roomContextMap.get(n);r&&(e.context=s?r.activeContext:r.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):Qg.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(t){Qg.warn("Error destroying click handler:",t)}}),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 Cy extends Hs{carpetSprite=null;carpetMask=null;constructor(){super({isRenderGroup:!0}),Zi().appContainer.addToLayer(oy,this)}async createCarpetFromRasterData(t,e){const i=Zi();if(!i.runtimeSnapshot.showCarpet)return;if(this.clearCarpet(),0===t.length)return;const{src:n,opacity:s,scale:r}=i.carpetConfig,o=await al.load(n);if(!o)return void Qg.warn(`Carpet texture not found: ${n}`);const a=this.createCarpetGraphics(t,e),h=a.getLocalBounds();if(0===h.width||0===h.height)return;const l=new Dl({texture:o,width:h.width,height:h.height});l.x=h.x,l.y=h.y,l.alpha=s,l.tileScale.set(r);const c=new Hs;c.addChild(a),l.mask=c,this.addChild(l),this.carpetSprite=l,this.carpetMask=c,i.getApp().renderOnceNextFrame()}createCarpetGraphics(t,e){const i=new Tl;for(let n=0;n<t.length;n++){const s=t[n],r=s%e,o=Math.floor(s/e);i.rect(r,o,1,1)}return i.fill(16777215),i}clearCarpet(){if(this.carpetSprite){try{this.removeChild(this.carpetSprite),this.carpetSprite.destroy()}catch(t){Qg.warn("Error destroying carpet sprite:",t)}this.carpetSprite=null}if(this.carpetMask){try{this.carpetMask.destroy()}catch(t){Qg.warn("Error destroying carpet mask:",t)}this.carpetMask=null}}async createCarpetFromStructuredData(t){const e=Zi();if(!e.runtimeSnapshot.showCarpet)return;if(this.clearCarpet(),0===t.length)return;const{src:i,opacity:n,scale:s}=e.carpetConfig,r=await al.load(i);if(!r)return void Qg.warn(`Carpet texture not found: ${i}`);const o=this.createCarpetGraphicsFromStructuredData(t),a=o.getLocalBounds();if(0===a.width||0===a.height)return;const h=new Dl({texture:r,width:a.width,height:a.height});h.x=a.x,h.y=a.y,h.alpha=n,h.tileScale.set(s);const l=new Hs;l.addChild(o),h.mask=l,this.addChild(h),this.carpetSprite=h,this.carpetMask=l,e.getApp().renderOnceNextFrame()}createCarpetGraphicsFromStructuredData(t){const e=new Tl;for(const i of t){const t=i.coordinates;for(let i=0;i<t.length;i+=2){const n=t[i],s=t[i+1];e.rect(n,s,1,1)}}return e.fill(16777215),e}destroy(){this.clearCarpet(),super.destroy()}}class Sy extends Hs{throttledUpdateScale;constructor(){super(),this.throttledUpdateScale=Ni(this.updateScale.bind(this),30,{leading:!0,trailing:!0});const t=Zi();this.updateScale(t.currentScale),this.registerScaleListener()}registerScaleListener(){Zi().emitter.on("antiScale",this.throttledUpdateScale)}updateScale(t){0!==t&&this.scale.set(1/t)}destroy(t){Zi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Iy extends Ws{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;sizeFixed=!0;baselineScale=1;constructor(t){super(t),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ni(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?Qg.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置宽度"):this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet?Qg.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置高度"):this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){Zi().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||0===this.texture.width||0===this.texture.height)return;const t=Zi(),e=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const n=t.currentScale;if(0===n)return;const s=e/n,r=i/n;super.scale.set(s,r)}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))}async loadTextureAndSetSize(t,e){try{const i=Zi(),n=await al.load(t);this.texture=n,void 0!==e.sizeFixed&&this.setSizeFixed(e.sizeFixed),this.setFixedSize(e.width,e.height),i.getApp().renderOnceNextFrame()}catch(e){Qg.error(`Failed to load texture "${t}":`,e)}}draw(t,e){const{x:i,y:n,rotation:s=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=s,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){Zi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Ay extends Sy{background;icon;options;constructor(t){super(),this.options=t,this.background=new Tl,this.addChild(this.background),this.icon=new Iy,this.addChild(this.icon),this.eventMode="static",this.render(),this.setupHitArea(),this.setupEvents()}setupHitArea(){const t=Zi().controlsConfig,e=t.iconWrapperWidth+16,i=t.iconWrapperHeight+16;this.hitArea=new Sn(-e/2,-i/2,e,i)}async render(){this.renderBackground(),this.renderIcon()}renderBackground(){const t=Zi().controlsConfig;this.background.clear(),this.background.roundRect(-t.iconWrapperWidth/2,-t.iconWrapperHeight/2,t.iconWrapperWidth,t.iconWrapperHeight,t.iconWrapperBorderRadius).fill(this.options.backgroundColor)}async renderIcon(){try{const t=Zi().controlsConfig;await this.icon.loadTextureAndSetSize(this.options.iconAlias,{width:t.iconWidth,height:t.iconHeight,sizeFixed:!1}),this.icon.visible=!0}catch(t){Qg.error(`Failed to load icon: ${this.options.iconAlias}`,t)}}destroy(){super.destroy()}}class My extends Hs{borderOptions;solidLine=null;dashGraphics=null;fillGraphics=null;constructor(t){super(),this.borderOptions={...t},this.drawBorder(),this.setupAntiScaleListener(),this.eventMode="none"}setupAntiScaleListener(){Zi().emitter.on("antiScale",this.handleAntiScale)}handleAntiScale=()=>{this.drawBorder()};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 Tl,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=Zi();this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy()),this.solidLine=new Tl;const s=n.getApp().toFixedSize(i.width);this.solidLine.setStrokeStyle({color:i.color,width:s}),this.solidLine.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)this.solidLine.lineTo(t[e].x,t[e].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 Qg.warn("Invalid dashArray:",i.dashArray);const n=Zi();this.dashGraphics=new Tl;const s=n.getApp().toFixedSize(i.width);this.dashGraphics.setStrokeStyle({color:i.color,width:s});const r=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,r,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 Qg.warn("Invalid dash parameters:",{dashLength:i,gapLength:n});const s=this.calculatePathSegments(e),r=s.reduce((t,e)=>t+e.length,0);if(0===r)return;const o=i+n;let a=0;for(;a<r;){const e=a+i;e<=r?this.drawContinuousDashSegment(t,s,a,e):this.drawContinuousDashSegment(t,s,a,r),a+=o}}calculatePathSegments(t){const e=[];for(let i=0;i<t.length-1;i++){const n=t[i],s=t[i+1],r=s.x-n.x,o=s.y-n.y,a=Math.sqrt(r*r+o*o);e.push({start:n,end:s,length:a})}return e}drawContinuousDashSegment(t,e,i,n){if(i>=n)return;let s=0,r=!1,o=null;for(const a of e){const e=s,h=s+a.length;if(h>i&&e<n){const s=Math.max(i,e),l=Math.min(n,h),c=(s-e)/a.length,d=(l-e)/a.length,u={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)*d,y:a.start.y+(a.end.y-a.start.y)*d};r?o&&Math.sqrt(Math.pow(u.x-o.x,2)+Math.pow(u.y-o.y,2))>.1&&t.lineTo(u.x,u.y):(t.moveTo(u.x,u.y),r=!0),t.lineTo(p.x,p.y),o=p}if(s+=a.length,s>=n)break}}clearBorder(){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy(),this.fillGraphics=null),this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy(),this.solidLine=null),this.dashGraphics&&(this.removeChild(this.dashGraphics),this.dashGraphics.destroy(),this.dashGraphics=null)}updateStyle(t){this.borderOptions.style={...this.borderOptions.style,...t},this.drawBorder()}updatePoints(t){this.borderOptions.points=t,this.drawBorder()}setClosePath(t){this.borderOptions.closePath=t,this.drawBorder()}getOptions(){return{...this.borderOptions}}destroy(){Zi().emitter.off("antiScale",this.handleAntiScale),this.clearBorder(),super.destroy()}}class Ty extends Tl{fillOptions;isDragging=!1;dragStartPosition=null;constructor(t){super(),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}=Zi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Zi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handlePointerDown=t=>{t.stopPropagation(),this.startDragging(t)};startDragging(t){this.isDragging=!0;const e=this.parent.toLocal(t.global);this.dragStartPosition={x:e.x,y:e.y},this.fillOptions.onDragStart?.(t),Zi().emitter.emit("gestureHijackStart",t)}handleDragPointerMove=t=>{this.isDragging&&this.dragStartPosition&&this.fillOptions.onDragMove?.(t)};handleDragPointerUp=()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.fillOptions.onDragEnd?.())};handleDragCancel=()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.fillOptions.onDragEnd?.())};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={...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 Py extends Tl{lineOptions;strokeContext=null;constructor(t){super(),this.lineOptions={...t},this.eventMode="static",this.drawDashLine(),this.setupAntiScaleListener()}setupAntiScaleListener(){Zi().emitter.on("antiScale",this.drawDashLine)}drawDashLine=()=>{const{start:t,end:e,style:i}=this.lineOptions;this.clear(),this.strokeContext&&this.strokeContext.destroy();const n=Zi();this.strokeContext=new lh;const s=n.getApp().toFixedSize(i.width);this.strokeContext.setStrokeStyle({color:i.color,width:s}),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};drawDashedLineToContext(t,e,i,n,s,r,o){const a=n-e,h=s-i,l=Math.sqrt(a*a+h*h);if(0===l)return;const c=Zi(),d=c.getApp().toFixedSize(r),u=d+c.getApp().toFixedSize(o),p=l/u,f=Math.round(p);if(0===f)return t.moveTo(e,i),void t.lineTo(n,s);const g=l/f,m=g*(d/u),y=a/l,x=h/l;for(let n=0;n<f;n++){const s=n*g,r=s+m;if(s>=l)break;const o=Math.min(r,l),a=e+s*y,h=i+s*x,c=e+o*y,d=i+o*x;t.moveTo(a,h),t.lineTo(c,d)}}updatePoints(t,e){this.lineOptions.start=t,this.lineOptions.end=e,this.drawDashLine()}updateStyle(t){this.lineOptions.style={...this.lineOptions.style,...t},this.drawDashLine()}getOptions(){return{...this.lineOptions}}destroy(){Zi().emitter.off("antiScale",this.drawDashLine),this.strokeContext&&this.strokeContext.destroy(),super.destroy()}}class Ey extends Tl{constructor(t){super(),this.options=t,this.initialPosition={...t.position},this.position.set(t.position.x,t.position.y),this.eventMode="static",this.cursor="pointer",this.setupEvents(),this.draw(),this.setupDragEventListeners()}isDragging=!1;dragStartPosition=null;initialPosition;draw(){const t=Zi(),{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=Zi(),{config:e}=this.options,i=Math.max(e.endPointSize/2+10,20),n=t.getApp().toFixedSize(i);this.hitArea=new Wo(0,0,n)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}setupDragEventListeners(){const{emitter:t}=Zi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Zi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handlePointerDown(t){t.stopPropagation(),this.startDragging(t)}startDragging(t){const e=Zi();this.isDragging=!0,this.dragStartPosition=this.parent.toLocal(t.global),this.initialPosition={x:this.x,y:this.y},this.options.onDragStart?.(),e.getApp().requestRender("endpoint-drag",!0),Zi().emitter.emit("gestureHijackStart",t)}handleDragPointerMove=t=>{if(!this.isDragging||!this.dragStartPosition)return;const e=this.parent.toLocal(t.global),i=e.x-this.dragStartPosition.x,n=e.y-this.dragStartPosition.y,s={x:this.initialPosition.x+i,y:this.initialPosition.y+n};this.position.set(s.x,s.y),this.options.onDragMove?.(s)};handleDragPointerUp=()=>{if(!this.isDragging)return;const t=Zi();this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("endpoint-drag"),this.options.onDragEnd?.()};handleDragCancel=()=>{if(!this.isDragging)return;const t=Zi();this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("endpoint-drag"),this.options.onDragEnd?.()};updatePosition(t){this.position.set(t.x,t.y),this.initialPosition={...t}}getPosition(){return{x:this.x,y:this.y}}redraw(){this.draw()}destroy(){this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.cleanupDragEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class By extends ll{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;constructor(t){super(t),this.anchor.set(.5),this.throttledUpdateScale=Ni(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(){Zi().emitter.on("antiScale",this.throttledUpdateScale)}applyFixedSize(){if(!this.isFixedSizeSet)return;const t=Zi().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){Zi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}var Oy,ky,Ry,Dy,Fy,Ly,jy={},Gy={},Uy={},Ny={},zy={},Hy={},Vy=function(){if(Ly)return jy;Ly=1,Object.defineProperty(jy,"__esModule",{value:!0}),jy.decompressFrames=jy.decompressFrame=jy.parseGIF=void 0;var t,e=(Ry||(Ry=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var e=Ji(),i=Xi(),n={blocks:function(t){for(var e=[],n=t.data.length,s=0,r=(0,i.readByte)()(t);0!==r&&r;r=(0,i.readByte)()(t)){if(t.pos+r>=n){var o=n-t.pos;e.push((0,i.readBytes)(o)(t)),s+=o;break}e.push((0,i.readBytes)(r)(t)),s+=r}for(var a=new Uint8Array(s),h=0,l=0;l<e.length;l++)a.set(e[l],h),h+=e[l].length;return a}},s=(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]}),r=(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]}),h=(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]}),l=[{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)([s,a,h,r,o],function(t){var e=(0,i.peekByte)()(t);return 33===e||44===e})}];t.default=l}(Gy)),(t=Gy)&&t.__esModule?t:{default:t}),i=Ji(),n=Xi(),s=(Dy||(Dy=1,Object.defineProperty(zy,"__esModule",{value:!0}),zy.deinterlace=void 0,zy.deinterlace=function(t,e){for(var i=new Array(t.length),n=t.length/e,s=function(n,s){var r=t.slice(s*e,(s+1)*e);i.splice.apply(i,[n*e,e].concat(r))},r=[0,4,2,1],o=[8,8,4,2],a=0,h=0;h<4;h++)for(var l=r[h];l<n;l+=o[h])s(l,a),a++;return i}),zy),r=(Fy||(Fy=1,Object.defineProperty(Hy,"__esModule",{value:!0}),Hy.lzw=void 0,Hy.lzw=function(t,e,i){var n,s,r,o,a,h,l,c,d,u,p,f,g,m,y,x,b=4096,_=i,v=new Array(i),w=new Array(b),C=new Array(b),S=new Array(4097);for(a=1+(s=1<<(u=t)),n=s+2,l=-1,r=(1<<(o=u+1))-1,c=0;c<s;c++)w[c]=0,C[c]=c;for(p=f=g=m=y=x=0,d=0;d<_;){if(0===m){if(f<o){p+=e[x]<<f,f+=8,x++;continue}if(c=p&r,p>>=o,f-=o,c>n||c==a)break;if(c==s){r=(1<<(o=u+1))-1,n=s+2,l=-1;continue}if(-1==l){S[m++]=C[c],l=c,g=c;continue}for(h=c,c==n&&(S[m++]=g,c=l);c>s;)S[m++]=C[c],c=w[c];g=255&C[c],S[m++]=g,n<b&&(w[n]=l,C[n]=g,0===(++n&r)&&n<b&&(o++,r+=n)),l=h}m--,v[y++]=S[m],d++}for(d=y;d<_;d++)v[d]=0;return v}),Hy);jy.parseGIF=function(t){var s=new Uint8Array(t);return(0,i.parse)((0,n.buildStream)(s),e.default)};var o=function(t,e,i){if(t.image){var n=t.image,o=n.descriptor.width*n.descriptor.height,a=(0,r.lzw)(n.data.minCodeSize,n.data.blocks,o);n.descriptor.lct.interlaced&&(a=(0,s.deinterlace)(a,n.descriptor.width));var h={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?h.colorTable=n.lct:h.colorTable=e,t.gce&&(h.delay=10*(t.gce.delay||10),h.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(h.transparentIndex=t.gce.transparentColorIndex)),i&&(h.patch=function(t){for(var e=t.pixels.length,i=new Uint8ClampedArray(4*e),n=0;n<e;n++){var s=4*n,r=t.pixels[n],o=t.colorTable[r]||[0,0,0];i[s]=o[0],i[s+1]=o[1],i[s+2]=o[2],i[s+3]=r!==t.transparentIndex?255:0}return i}(h)),h}};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 Wy{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){if(!t||0===t.byteLength)throw new Error("Invalid buffer");const i=Vy.parseGIF(t);(t=>{let e=null;for(const i of t.frames)e=i.gce??e,"image"in i&&!("gce"in i)&&(i.gce=e)})(i);const n=Vy.decompressFrames(i,!0),s=[],r=i.lsd.width,o=i.lsd.height,a=qs.get().createCanvas(r,o),h=a.getContext("2d",{willReadFrequently:!0}),l=qs.get().createCanvas(),c=l.getContext("2d");let d=0,u=null;const p=1e3/(e?.fps??30);for(let t=0;t<n.length;t++){const{disposalType:e=2,delay:i=p,patch:a,dims:{width:f,height:g,left:m,top:y}}=n[t];l.width=f,l.height=g,c.clearRect(0,0,f,g);const x=c.createImageData(f,g);x.data.set(a),c.putImageData(x,0,0),3===e&&(u=h.getImageData(0,0,r,o)),h.drawImage(l,m,y);const b=h.getImageData(0,0,r,o);2===e?h.clearRect(0,0,r,o):3===e&&h.putImageData(u,0,0);const _=qs.get().createCanvas(b.width,b.height);_.getContext("2d").putImageData(b,0,0),s.push({start:d,end:d+i,texture:new Fn({source:new Qs({resource:_})})}),d+=i}return a.width=a.height=0,l.width=l.height=0,new Wy(s)}}const Zy={extension:Ki.Asset,detection:{test:async()=>!0,add:async t=>[...t,"gif"],remove:async t=>t.filter(t=>"gif"!==t)},loader:{name:"gifLoader",id:"gif",test:t=>".gif"===dr.extname(t)||t.startsWith("data:image/gif"),load:async(t,e)=>{const i=await qs.get().fetch(t),n=await i.arrayBuffer();return Wy.from(n,e?.data)},unload:async t=>{t.destroy()}}},Jy=class t extends Ws{constructor(...e){const i=e[0]instanceof Wy?{source:e[0]}:e[0],{scaleMode:n,source:s,fps:r,loop:o,animationSpeed:a,autoPlay:h,autoUpdate:l,onComplete:c,onFrameChange:d,onLoop:u,...p}=Object.assign({},t.defaultOptions,i);super({texture:Fn.EMPTY,...p}),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:r,loop:o,animationSpeed:a,autoPlay:h,autoUpdate:l,onComplete:c,onFrameChange:d,onLoop:u}),this.currentFrame=0,h&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(sr.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(sr.shared.add(this.update,this,tr.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){if(!this._playing)return;const e=this.animationSpeed*t.deltaTime/sr.targetFPMS,i=this._currentTime+e,n=i%this.duration,s=this._source.frames.findIndex(t=>t.start<=n&&t.end>n);i>=this.duration?this.loop?(this._currentTime=n,this._updateFrameIndex(s),this.onLoop?.()):(this._currentTime=this.duration,this._updateFrameIndex(this.totalFrames-1),this.onComplete?.(),this.stop()):(this._currentTime=n,this._updateFrameIndex(s))}_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?(sr.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(sr.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){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,this.onFrameChange?.(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}};Jy.defaultOptions={scaleMode:"linear",fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};let Xy=Jy;$i.add(Zy);class Yy extends Xy{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;sizeFixed=!0;baselineScale=1;constructor(t){super(t),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ni(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?Qg.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置宽度"):this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet?Qg.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置高度"):this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){Zi().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||0===this.texture.width||0===this.texture.height)return;const t=Zi(),e=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const n=t.currentScale;if(0===n)return;const s=e/n,r=i/n;super.scale.set(s,r)}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 async createFromSrc(t,e){try{const i=await al.load(t),n=new Yy({source:i});return void 0!==e.sizeFixed&&n.setSizeFixed(e.sizeFixed),n.setFixedSize(e.width,e.height),n}catch(e){throw Qg.error(`Failed to load GIF "${t}":`,e),e}}draw(t,e){const{x:i,y:n,rotation:s=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=s,this.position.set(i,n)}destroy(t){Zi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Ky extends Ol{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;sizeFixed=!0;baselineScale=1;static animationTicker=null;static animatedSprites=new Set;constructor(t){super(t||[]),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ni(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(){Zi().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=Zi(),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 s=i/e,r=n/e;super.scale.set(s,r)}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 async loadAnimationTextures(t,e="sleep_",i=96){try{await al.load(t);const n=[];for(let t=0;t<i;t++){const i=`${e}${t.toString().padStart(3,"0")}.png`,s=Fn.from(i);s&&n.push(s)}return n}catch(t){return[]}}setupAnimation(t){void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),this.setFixedSize(t.width,t.height),this.animationSpeed=.5,this.loop=!0,Qg.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:s=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=s,this.position.set(i,n)}play(){this.textures&&this.textures.length>0&&(super.play(),Ky.animatedSprites.add(this),Ky.startAnimationTicker())}stop(){super.stop(),Ky.animatedSprites.delete(this),Ky.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(){Ky.animationTicker?.started||(Ky.animationTicker||(Ky.animationTicker=new sr,Ky.animationTicker.maxFPS=24,Ky.animationTicker.add(()=>{Ky.updateAnimations()})),Ky.animationTicker.start(),Qg.log("🎬 [AnimationTicker] Started animation ticker"))}static updateAnimationTicker(){Ky.animatedSprites.size>0?Ky.startAnimationTicker():Ky.stopAnimationTicker()}static stopAnimationTicker(){Ky.animationTicker?.started&&(Qg.log("⏸️ [AnimationTicker] Stopped animation ticker"),Ky.animationTicker.stop())}static updateAnimations(){if(0===Ky.animatedSprites.size)return;const t=Zi().getApp();t.renderer.render(t.stage)}destroy(t){Ky.animatedSprites.delete(this),Ky.updateAnimationTicker(),Zi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class qy extends Nl{throttledUpdateScale;constructor({text:t,style:e}){super({text:t,style:e}),this.throttledUpdateScale=Ni(this.updateScale.bind(this),20,{leading:!0,trailing:!0}),this.registerScaleListener(),this.updateScale(Zi().currentScale)}registerScaleListener(){Zi().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){Zi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Qy extends Ay{isMoving=!1;dragStartPosition=null;constructor(t){super(t),this.setupMoveEventListeners()}setupMoveEventListeners(){const{emitter:t}=Zi();t.on("gestureHijackPointerMove",this.handleMovePointerMove),t.on("gestureHijackPointerUp",this.handleMovePointerUp),t.on("gestureHijackCancel",this.handleMoveCancel)}cleanupMoveEventListeners(){const{emitter:t}=Zi();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){this.isMoving=!0,this.dragStartPosition=this.parent.toLocal(t.global),this.options.onMoveStart?.(),Zi().emitter.emit("gestureHijackStart",t)}handleMovePointerMove=t=>{this.isMoving&&this.dragStartPosition&&this.options.onMoveMove?.(t)};handleMovePointerUp=()=>{this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,this.options.onMoveEnd?.())};handleMoveCancel=()=>{this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,this.options.onMoveEnd?.())};isCurrentlyMoving(){return this.isMoving}getDragStartPosition(){return this.dragStartPosition?{...this.dragStartPosition}:null}stopMoving(){this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,this.options.onMoveEnd?.())}destroy(){this.stopMoving(),this.cleanupMoveEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class $y extends Ay{clickHandler=null;constructor(t){super(t)}setupEvents(){this.clickHandler=new vy(this,{onClick:this.options.onClick,stopPropagation:!0})}destroy(){this.clickHandler?.destroy(),super.destroy()}}class tx extends Ay{isRotating=!1;rotationCenter={x:0,y:0};lastAngle=0;constructor(t){super(t),this.setupRotationEventListeners()}setupRotationEventListeners(){const{emitter:t}=Zi();Zi().emitter.on("gestureHijackPointerMove",this.handleRotationPointerMove),t.on("gestureHijackPointerUp",this.handleRotationPointerUp),t.on("gestureHijackCancel",this.handleRotationCancel)}cleanupRotationEventListeners(){const{emitter:t}=Zi();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){this.isRotating=!0;const e=this.options.getTargetPoints();this.rotationCenter=cm(e);const i=this.parent.toLocal(t.global);this.lastAngle=Math.atan2(i.y-this.rotationCenter.y,i.x-this.rotationCenter.x),this.options.onRotationStart?.(this.rotationCenter),Zi().emitter.emit("gestureHijackStart",t)}handleRotationPointerMove=t=>{if(!this.isRotating)return;const e=this.parent.toLocal(t.global),i=Math.atan2(e.y-this.rotationCenter.y,e.x-this.rotationCenter.x),n=i-this.lastAngle;this.options.onRotationMove?.(n),this.lastAngle=i};handleRotationPointerUp=()=>{this.isRotating&&(this.isRotating=!1,this.options.onRotationEnd?.())};handleRotationCancel=()=>{this.isRotating&&(this.isRotating=!1,this.options.onRotationEnd?.())};isCurrentlyRotating(){return this.isRotating}stopRotation(){this.isRotating&&(this.isRotating=!1,this.options.onRotationEnd?.())}destroy(){this.stopRotation(),this.cleanupRotationEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class ex extends Ay{isScaling=!1;initialButtonPosition=null;dragStartPosition=null;constructor(t){super(t),this.setupScaleEventListeners()}setupScaleEventListeners(){const{emitter:t}=Zi();t.on("gestureHijackPointerMove",this.handleScalePointerMove),t.on("gestureHijackPointerUp",this.handleScalePointerUp),t.on("gestureHijackCancel",this.handleScaleCancel)}cleanupScaleEventListeners(){const{emitter:t}=Zi();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){this.isScaling=!0,this.dragStartPosition=this.parent.toLocal(t.global);const e=this.options.getTargetPoints(),i=this.options.getButtonIndex();i>=0&&i<e.length&&(this.initialButtonPosition={...e[i]}),this.options.onScaleStart?.(i),Zi().emitter.emit("gestureHijackStart",t)}handleScalePointerMove=t=>{if(!this.isScaling||!this.initialButtonPosition||!this.dragStartPosition)return;const e=this.parent.toLocal(t.global),i=e.x-this.dragStartPosition.x,n=e.y-this.dragStartPosition.y,s={x:this.initialButtonPosition.x+i,y:this.initialButtonPosition.y+n};this.options.onScaleMove?.(s)};handleScalePointerUp=()=>{this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,this.options.onScaleEnd?.())};handleScaleCancel=()=>{this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,this.options.onScaleEnd?.())};isCurrentlyScaling(){return this.isScaling}stopScaling(){this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,this.options.onScaleEnd?.())}destroy(){this.stopScaling(),this.cleanupScaleEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class ix extends Hs{static BUTTON_INDICES={REMOVE:0,ROTATE:1,SCALE:2,MOVE:3,FIXED:0};zoneData;zoneType;zoneConfig;controlsConfig;zoneEvents;controlFill;zoneBorder;outlineBorder;moveLine;sizeText;controlButtons;deleteButton=null;rotateButton=null;scaleButton=null;moveButton=null;totalRotationAngle=0;rotationCenter=null;initialZonePoints=[];clickHandler=null;throttledUpdateOutline;constructor(t){super();const{zoneData:e,zoneType:i,events:n={}}=t;this.zoneType=i,this.zoneEvents=n,this.zoneConfig=this.getZoneConfig(),this.controlsConfig=this.getControlsConfig();const s=this.validateAndCorrectZoneSize(e.points),r=dm(s);this.zoneData={...e,points:r},this.throttledUpdateOutline=Ni(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.createControlButtons(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){Zi().emitter.on("antiScale",this.throttledUpdateOutline)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition())}getZoneConfig(){const t=Zi(),{controls:e}=t.getConfig();return e[this.zoneType]}getControlsConfig(){const t=Zi(),{controls:e}=t.getConfig();return e}validateAndCorrectZoneSize(t){const e=Zi();if(t.length<4)return t;const i=e.metersToPixels(this.zoneConfig.minSize),[n,s,,r]=t,o=pm(n,s),a=pm(n,r);if(o>=i&&a>=i)return t;const h=cm(t),l=mm(gm(n,s)),c=mm(gm(n,r)),d=Math.max(o,i)/2,u=Math.max(a,i)/2;return[{x:h.x-l.x*d-c.x*u,y:h.y-l.y*d-c.y*u},{x:h.x+l.x*d-c.x*u,y:h.y+l.y*d-c.y*u},{x:h.x+l.x*d+c.x*u,y:h.y+l.y*d+c.y*u},{x:h.x-l.x*d+c.x*u,y:h.y-l.y*d+c.y*u}]}getEditingIdsKey(){switch(this.zoneType){case"forbiddenSweepZone":default:return"editingForbiddenSweepZoneIds";case"forbiddenMopZone":return"editingForbiddenMopZoneIds";case"cleanZone":return"editingCleanZoneIds"}}isEditingEnabled(){const t=this.getEditingIdsKey();return Zi().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 Hs,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.drawZone()}createControlButtons(){const t=this.calculateOutlinePoints();if(t.length<4)return;this.deleteButton=new $y({iconAlias:"deleteIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onClick:this.handleDelete}),this.deleteButton.position.set(t[ix.BUTTON_INDICES.REMOVE].x,t[ix.BUTTON_INDICES.REMOVE].y),this.rotateButton=new tx({iconAlias:"rotateIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,onRotationStart:this.handleRotationStart,onRotationMove:this.handleRotationMove,onRotationEnd:this.handleRotationEnd}),this.rotateButton.position.set(t[ix.BUTTON_INDICES.ROTATE].x,t[ix.BUTTON_INDICES.ROTATE].y),this.scaleButton=new ex({iconAlias:"scaleIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,getButtonIndex:()=>ix.BUTTON_INDICES.SCALE,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(t[ix.BUTTON_INDICES.SCALE].x,t[ix.BUTTON_INDICES.SCALE].y);const e=this.calculateMoveButtonPosition();this.moveButton=new Qy({iconAlias:"moveIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(e.x,e.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 Ty({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;return t.length<4?t:((t,e)=>{if(t.length<3)return t;const i=[];for(let n=0;n<t.length;n++){const s=t[n],r=t[(n+1)%t.length],o=t[(n-1+t.length)%t.length],a=gm(s,r);if(0===fm(a)){i.push(s);continue}const h=mm(a),l={x:h.y,y:-h.x},c=gm(o,s);let d={x:0,y:0};if(fm(c)>0){const t=mm(c);d={x:t.y,y:-t.x}}const u=_m(d,l),p=d.x*l.x+d.y*l.y,f=1/Math.max(.1,Math.sqrt((1+p)/2)),g={x:s.x+u.x*e*f,y:s.y+u.y*e*f};i.push(g)}return i})(t,Zi().getApp().toFixedSize(this.zoneConfig.outlineOffset))}calculateMoveLinePoints(t){return t.length<4?[]:[t[ix.BUTTON_INDICES.MOVE],this.calculateMoveButtonPosition()]}createSizeText(){const t=this.calculateZoneSizeText(),e=new qy({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,s=pm(e,i),r=pm(e,n),o=Zi(),a=o.pixelsToMeters(s),h=o.pixelsToMeters(r);return`${a.toFixed(1)}${this.controlsConfig.unitLabel}*${h.toFixed(1)}${this.controlsConfig.unitLabel}`}calculateSizeTextPosition(){const{points:t}=this.zoneData;if(t.length<4)return{x:0,y:0};const[e,i,n,s]=t,{textPosition:r,textOffset:o}=this.zoneConfig,a=Zi().getApp().toFixedSize(o);let h,l;switch(r){case"top":{h={x:(e.x+i.x)/2,y:(e.y+i.y)/2};const t=mm(gm(i,e)),n={x:t.y,y:-t.x};l={x:n.x*a,y:n.y*a};break}case"right":{h={x:(i.x+n.x)/2,y:(i.y+n.y)/2};const t=mm(gm(i,n)),e={x:t.y,y:-t.x};l={x:e.x*a,y:e.y*a};break}case"bottom":{h={x:(s.x+n.x)/2,y:(s.y+n.y)/2};const t=mm(gm(s,n)),e={x:-t.y,y:t.x};l={x:e.x*a,y:e.y*a};break}case"left":{h={x:(e.x+s.x)/2,y:(e.y+s.y)/2};const t=mm(gm(s,e)),i={x:t.y,y:-t.x};l={x:i.x*a,y:i.y*a};break}default:h={x:(e.x+i.x)/2,y:(e.y+i.y)/2},l={x:0,y:a}}return{x:h.x+l.x,y:h.y+l.y}}calculateSizeTextRotation(){const{points:t}=this.zoneData;if(t.length<4)return 0;const[e,i,n,s]=t,{textPosition:r}=this.zoneConfig;let o,a;switch(r){case"top":default:o=e,a=i;break;case"right":o=i,a=n;break;case"bottom":o=n,a=s;break;case"left":o=s,a=e}return vm(o,a)}calculateMoveButtonPosition(){const t=this.calculateOutlinePoints();if(t.length<4)return{x:0,y:0};const e=Zi(),{controls:i}=e.getConfig(),n=t[ix.BUTTON_INDICES.MOVE],s=t[2],r=t[0],o=e.getApp().toFixedSize(i.moveButtonOffset);return Cm(n,s,r,o)}handleDragStart=()=>{if(!this.isEditingEnabled())return;const t=Zi();this.initialZonePoints=this.zoneData.points.map(t=>({...t})),t.getApp().requestRender("zone-drag",!0)};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,s=e.y-i.y;this.applyTranslation(n,s)};handleDragEnd=()=>{const t=Zi();this.initialZonePoints=[],t.getApp().stopRender("zone-drag"),this.zoneEvents.onUpdate?.(this.getZoneData())};applyTranslation(t,e){this.zoneData.points=this.initialZonePoints.map(i=>({x:i.x+t,y:i.y+e})),this.drawZone(),this.updateControlButtonsPosition()}handleRotationStart=t=>{const e=Zi();this.totalRotationAngle=0,this.rotationCenter=t,this.initialZonePoints=this.zoneData.points.map(t=>({...t})),e.getApp().requestRender("zone-rotate",!0)};handleRotationMove=t=>{this.totalRotationAngle+=t,this.applyRotation(t)};handleRotationEnd=()=>{const t=Zi();this.rotationCenter=null,this.totalRotationAngle=0,this.initialZonePoints=[],t.getApp().stopRender("zone-rotate"),this.zoneEvents.onUpdate?.(this.getZoneData())};applyRotation(t){this.rotationCenter&&(this.zoneData.points=((t,e,i)=>t.map(t=>((t,e,i)=>{const n=Math.cos(i),s=Math.sin(i),r=t.x-e.x,o=t.y-e.y;return{x:r*n-o*s+e.x,y:r*s+o*n+e.y}})(t,e,i)))(this.zoneData.points,this.rotationCenter,t),this.drawZone(),this.updateControlButtonsPosition())}handleScaleStart=()=>{const t=Zi();this.initialZonePoints=this.zoneData.points.map(t=>({...t})),t.getApp().requestRender("zone-scale",!0)};handleScaleMove=t=>{0!==this.initialZonePoints.length&&this.applyEdgeBasedScale(t)};handleScaleEnd=()=>{const t=Zi();this.initialZonePoints=[],t.getApp().stopRender("zone-scale"),this.zoneEvents.onUpdate?.(this.getZoneData())};applyEdgeBasedScale(t){if(this.initialZonePoints.length<4)return;const e=Zi(),{FIXED:i}=ix.BUTTON_INDICES,{x:n,y:s}=this.initialZonePoints[i],[,r,,o]=this.initialZonePoints,a={x:n,y:s},h=gm(a,r),l=gm(a,o),c=gm(a,t),d=fm(h),u=fm(l);if(0===d||0===u)return;const p=e.metersToPixels(this.zoneConfig.minSize),[f,g]=[um(c,h,d,p),um(c,l,u,p)];this.zoneData.points=[a,{x:n+h.x*f,y:s+h.y*f},{x:n+h.x*f+l.x*g,y:s+h.y*f+l.y*g},{x:n+l.x*g,y:s+l.y*g}],this.drawZone(),this.updateControlButtonsPosition()}handleMoveStart=()=>{const t=Zi();this.initialZonePoints=this.zoneData.points.map(t=>({...t})),t.getApp().requestRender("zone-move",!0)};handleMove=t=>{if(!this.isEditingEnabled()||0===this.initialZonePoints.length)return;const e=this.parent.toLocal(t.global),i=this.moveButton?.getDragStartPosition();if(!i)return;const n=e.x-i.x,s=e.y-i.y;this.applyTranslation(n,s)};handleMoveEnd=()=>{const t=Zi();this.initialZonePoints=[],t.getApp().stopRender("zone-move"),this.zoneEvents.onUpdate?.(this.getZoneData())};handleDelete=()=>{this.zoneEvents.onRemove?.(this.zoneData.id)};setupClickHandler(){this.clickHandler=new vy(this,{onClick:()=>{this.isEditingEnabled()||this.zoneEvents?.onClick?.(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 t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:e,ROTATE:i,SCALE:n}=ix.BUTTON_INDICES,s=this.calculateMoveButtonPosition();[{button:this.deleteButton,point:t[e]},{button:this.rotateButton,point:t[i]},{button:this.scaleButton,point:t[n]},{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(){const t=this.controlFill.isCurrentlyDragging(),e=this.scaleButton?.isCurrentlyScaling()||!1,i=this.rotateButton?.isCurrentlyRotating()||!1,n=this.moveButton?.isCurrentlyMoving()||!1;return{isDragging:t,isScaling:e,isRotating:i,isMoving:n,hasAnyOperation:t||e||i||n}}stopAllOperations(){this.controlFill.stopDragging(),this.scaleButton?.stopScaling(),this.rotateButton?.stopRotation(),this.moveButton?.stopMoving()}stopDragging(){this.controlFill.stopDragging()}stopScaling(){this.scaleButton?.stopScaling()}stopRotating(){this.rotateButton?.stopRotation()}stopMoving(){this.moveButton?.stopMoving()}isCurrentlyDragging(){return this.controlFill.isCurrentlyDragging()}isCurrentlyScaling(){return this.scaleButton?.isCurrentlyScaling()||!1}isCurrentlyRotating(){return this.rotateButton?.isCurrentlyRotating()||!1}isCurrentlyMoving(){return this.moveButton?.isCurrentlyMoving()||!1}updateZoneData(t){const e=this.validateAndCorrectZoneSize(t.points),i=dm(e);this.zoneData={...t,points:i},this.drawZone(),this.updateControlButtonsPosition(),this.updateEditState()}getZoneData(){return{...this.zoneData}}destroy(){Zi().emitter.off("antiScale",this.throttledUpdateOutline),this.clickHandler?.destroy(),this.clickHandler=null,this.deleteButton?.destroy(),this.rotateButton?.destroy(),this.scaleButton?.destroy(),this.moveButton?.destroy(),this.deleteButton=null,this.rotateButton=null,this.scaleButton=null,this.moveButton=null,this.zoneBorder?.destroy(),this.outlineBorder?.destroy(),this.moveLine?.destroy(),this.sizeText?.destroy(),this.controlFill?.destroy(),this.controlButtons?.destroy(),super.destroy()}}class nx extends Tl{currentPosition=null;config;constructor(t){super(),this.setupAntiScaleListener(),this.config=t.config}setupAntiScaleListener(){Zi().emitter.on("antiScale",this.handleScaleChange)}handleScaleChange=()=>{this.redraw()};draw(t){const e=Zi();this.currentPosition=t;const{ringSize:i,ringColor:n,ringStrokeWidth:s,ringStrokeColor:r,ringStrokeDashed:o,ringStrokeDashArray:a}=this.config;this.clear();const h=e.metersToPixels(i),l=e.getApp().toFixedSize(s);this.setFillStyle({color:n}),o&&a.length>=2?this.drawDashedCircle(t,h,r,l,a):this.circle(t.x,t.y,h).fill().stroke({color:r,width:l,cap:"round",join:"round"})}drawDashedCircle(t,e,i,n,s){const r=Zi();this.circle(t.x,t.y,e).fill();const o=r.getApp().toFixedSize(s[0]),a=r.getApp().toFixedSize(s[1]),h=2*Math.PI*e,l=o+a,c=Math.floor(h/l);if(0===c)return void this.circle(t.x,t.y,e).stroke({color:i,width:n,cap:"round",join:"round"});const d=h/c,u=d*(o/l);for(let i=0;i<c;i++){const n=i*d/e,s=(i*d+u)/e,r=Math.max(4,Math.ceil(Math.abs(s-n)*e/2)),o=(s-n)/r;for(let i=0;i<=r;i++){const s=n+o*i,r=t.x+e*Math.cos(s),a=t.y+e*Math.sin(s);0===i?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(){Zi().emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class sx extends Iy{constructor(){super(),this.initializeSprite()}async initializeSprite(){const t=Zi();await this.loadTextureAndSetSize("chargingStation",t.chargingStationConfig.icon)}async draw({x:t,y:e,rotation:i}){const n=Zi();super.draw({x:t,y:e,rotation:i},()=>n.runtimeSnapshot.showChargingStation)}}class rx extends Hs{chargingStation;ring;unsubscribeFns=[];constructor(){super();const t=Zi();t.appContainer.addToLayer(gy,this),this.ring=new nx({config:t.chargingStationConfig}),this.ring.visible=t.runtimeSnapshot.showChargingStationRing,this.addChild(this.ring),this.chargingStation=new sx,this.addChild(this.chargingStation);const e=Yi(t.runtime,"showChargingStationRing",t=>{Qg.log(`[runtime] showChargingStationRing: ${t}`),this.ring.visible=t});this.unsubscribeFns.push(e)}async draw({x:t,y:e,rotation:i}){0===t&&0===e||(this.ring.draw({x:t,y:e}),await this.chargingStation.draw({x:t,y:e,rotation:i}))}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.ring.destroy(),super.destroy()}}class ox{obstacle=new by;free=new _y;roomFill=new wy;carpet=new Cy;chargingStation=new rx;mapBounds={minX:0,minY:0,maxX:0,maxY:0};lastMapId=null;roomGeometryMap=new Map;carpetData=null;unsubscribeFns=[];constructor(){const t=Zi(),e=Yi(t.runtime,"enableRoomSelection",e=>{if(Qg.log(`[runtime] enableRoomSelection: ${e}`),e){this.roomFill.setAllRoomsState(!1);const e=t.runtimeSnapshot.selectRoomIds;this.roomFill.setRoomStateBySelectIds(e)}else this.roomFill.setAllRoomsState(!0)}),i=Yi(t.runtime,"selectRoomIds",t=>{Qg.log(`[runtime] selectRoomIds: ${t}`),this.roomFill.setRoomStateBySelectIds(t)}),n=Yi(t.runtime,"showChargingStation",t=>{Qg.log(`[runtime] showChargingStation: ${t}`),this.chargingStation.visible=t}),s=Yi(t.runtime,"showCarpet",t=>{Qg.log(`[runtime] showCarpet: ${t}`),t?this.createCarpet():this.carpet.clearCarpet()});this.unsubscribeFns.push(e,i,n,s)}async drawMap(t){const e=Zi(),{id:i,obstacles:n,free:s,rooms:r,charger:o,carpet:a}=t;this.clearComponents(),this.resetGeometryData();const h=this.processRoomsGeometry(r);this.roomFill.draw(h),this.free.draw(s),this.obstacle.draw(n),this.carpetData={type:"structured",carpetData:a},this.createCarpet();const l=this.mergeLayerBounds();Ui(l,this.mapBounds)||(Qg.debug("[Map] Map bounds updated:",l),this.mapBounds=l,this.lastMapId!==i&&(e.getApp().fitMapToView(this.mapBounds),this.lastMapId=i));const c=((t.charger.angle??0)+e.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:o.coordinate[0],y:o.coordinate[1],rotation:c}),e.roomsManager.refresh(),!0}async drawRasterMap(t,e){const i=Zi();this.clearComponents();const{id:n,width:s,height:r,charger:o,chargerDirection:a}=e;Qg.debug("[Map] Parsed Raster Map Data",t),this.obstacle.drawRaster(t.obstacles,s),this.carpetData={type:"raster",carpetPixels:t.carpet,mapWidth:s},this.createCarpet();const h=this.processRasterData(t);this.roomFill.drawRaster(h);const l=((t,e,i)=>{let n=1/0,s=1/0,r=-1/0,o=-1/0;for(let i=0;i<t.obstacles.length;i++){const a=t.obstacles[i],h=a%e,l=Math.floor(a/e);n=Math.min(n,h),s=Math.min(s,l),r=Math.max(r,h),o=Math.max(o,l)}return t.rooms.forEach(t=>{for(let i=0;i<t.length;i++){const a=t[i],h=a%e,l=Math.floor(a/e);n=Math.min(n,h),s=Math.min(s,l),r=Math.max(r,h),o=Math.max(o,l)}}),n===1/0?{minX:0,minY:0,maxX:e,maxY:i}:{minX:Math.max(0,n),minY:Math.max(0,s),maxX:Math.min(e,r),maxY:Math.min(i,o)}})(t,s,r);Ui(l,this.mapBounds)||(Qg.debug("[Map] Raster map bounds updated:",l),this.mapBounds=l,this.lastMapId!==n&&(i.getApp().fitMapToView(this.mapBounds),this.lastMapId=n));const c=(a+i.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:o.x,y:o.y,rotation:c}),this.generateRoomGeometryFromRaster(t),i.roomsManager.refresh(),!0}resetGeometryData(){this.roomGeometryMap.clear(),this.mapBounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}async createCarpet(){if(Zi().runtimeSnapshot.showCarpet&&this.carpetData)if("raster"===this.carpetData.type){const{carpetPixels:t,mapWidth:e}=this.carpetData;await this.carpet.createCarpetFromRasterData(t,e)}else if("structured"===this.carpetData.type){const{carpetData:t}=this.carpetData;await this.carpet.createCarpetFromStructuredData(t)}}processRoomsGeometry(t){if(!t)return[];const e=Zi(),{active:i}=e.roomConfig.colors,n=e.roomConfig.colors[zg.UNKNOWN_ROOM];if(0===Object.keys(t).length)return this.mapBounds={minX:0,minY:0,maxX:0,maxY:0},[];const s=Object.keys(t).sort((t,e)=>Number(t)-Number(e)),r=s.filter(t=>Number(t)<255),o=s.filter(t=>Number(t)>=255),a=[];return r.forEach((e,n)=>{const{coordinates:s}=t[e];if(s.length<4)return;const r=Number(e),o=n%i.length,h=i[o];let l=1/0,c=1/0,d=-1/0,u=-1/0;const p=[];for(let t=0;t<s.length;t+=2){const e=s[t],i=s[t+1];l=Math.min(l,e),c=Math.min(c,i),d=Math.max(d,e),u=Math.max(u,i),p.push({x:e,y:i})}const f=new Sn(l,c,d-l+1,u-c+1),g=$g(p),m=g.flatMap(t=>[t.x+.5,t.y+.5]),y={id:r,color:h,boundingBox:f,points:p,outlinePoints:g,polyPoints:m,centerPoint:im(g,l,c,d,u)};this.roomGeometryMap.set(r,y),a.push(y),this.mapBounds.minX=Math.min(this.mapBounds.minX,l),this.mapBounds.minY=Math.min(this.mapBounds.minY,c),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,d),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,u)}),o.forEach(e=>{const{coordinates:i}=t[e];if(i.length<4)return;const s=Number(e);let r=1/0,o=1/0,h=-1/0,l=-1/0;const c=[];for(let t=0;t<i.length;t+=2){const e=i[t],n=i[t+1];r=Math.min(r,e),o=Math.min(o,n),h=Math.max(h,e),l=Math.max(l,n),c.push({x:e,y:n})}const d=new Sn(r,o,h-r+1,l-o+1),u=$g(c),p=u.flatMap(t=>[t.x+.5,t.y+.5]),f=im(u,r,o,h,l),g={id:s,color:n,boundingBox:d,points:c,outlinePoints:u,polyPoints:p,centerPoint:f};a.push(g),this.mapBounds.minX=Math.min(this.mapBounds.minX,r),this.mapBounds.minY=Math.min(this.mapBounds.minY,o),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,h),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,l)}),a}mergeLayerBounds(){let t={...this.mapBounds};if(this.obstacle.bounds&&(t=Im(t,this.obstacle.bounds)),this.roomFill.children.length>0){const e=this.roomFill.getLocalBounds();e.width>0&&e.height>0&&(t=Im(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 by,this.free.clear(),this.free.destroy(),this.free=new _y,this.carpet.clearCarpet(),this.carpetData=null,this.roomFill.removeChildren(),this.roomFill.destroy(),this.roomFill=new wy}processRasterData(t){const e=Zi().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 s=[...i.map(([t,i],n)=>{const s=n%e.colors.active.length,r=n%e.colors.inactive.length;return{roomId:t,pixelIndices:i,activeColor:e.colors.active[s],inactiveColor:e.colors.inactive[r]}}),...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:s,width:t.width,height:t.height,totalPixels:t.totalPixels}}generateRoomGeometryFromRaster(t){const e=Zi();this.roomGeometryMap.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),n.forEach((e,n)=>{const s=t.rooms.get(e);let r=1/0,o=1/0,a=-1/0,h=-1/0;for(let e=0;e<s.length;e++){const i=s[e],n=i%t.width,l=Math.floor(i/t.width);r=Math.min(r,n),o=Math.min(o,l),a=Math.max(a,n),h=Math.max(h,l)}const l=((t,e,i,n,s,r)=>{const o=new Set(t),a=((t,e)=>{let i=0,n=0;for(let s=0;s<t.length;s++){const r=t[s];i+=r%e,n+=Math.floor(r/e)}return{x:i/t.length,y:n/t.length}})(t,e),h=((t,e,i,n,s,r,o)=>{const a={x:n-10,y:t.y},h={x:r+10,y:t.y},l={x:r,y:s},c={x:r,y:o},d=Sm(a,h,{x:n,y:s},{x:n,y:o}),u=Sm(a,h,l,c);if(!d||!u)return null;const p=[],f=Math.max(n,Math.min(d.x,u.x)),g=Math.min(r,Math.max(d.x,u.x)),m=Math.round(t.y);for(let t=Math.round(f);t<=Math.round(g);t++){const n=m*i+t;e.has(n)&&p.push({x:t,y:m})}if(p.length>=2){const t=(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 s=1;s<t.length;s++){const r=t[s];n(r)<n(e)&&(e=r),n(r)>n(i)&&(i=r)}return{min:e,max:i}})(p),n={x:(t.min.x+t.max.x)/2,y:(t.min.y+t.max.y)/2},s=Math.round(n.y)*i+Math.round(n.x);if(e.has(s))return n}return null})(a,o,e,i,n,s,r);return h||a})(s,t.width,r,o,a,h),c=n%i.length,d={id:e,color:i[c],boundingBox:new Sn(r,o,a-r+1,h-o+1),points:[],outlinePoints:[],polyPoints:[],centerPoint:l};this.roomGeometryMap.set(e,d)})}destroy(){this.obstacle.destroy(),this.free.destroy(),this.roomFill.destroy(),this.carpet.destroy(),this.chargingStation.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}class ax extends Hs{commonPath;chargePath;transitionsPath;mopPath;pathData=null;lastPointCount=0;lastDrawnPosition=null;isRealTimeDrawing=!1;throttledUpdateLineWidth;throttledHandleRobotPosition;constructor(){super({isRenderGroup:!0});const t=Zi();t.appContainer.addToLayer(ly,this),this.eventMode="none",this.commonPath=new Tl,this.chargePath=new Tl,this.transitionsPath=new Tl,this.mopPath=new Tl,this.addChild(this.commonPath),this.addChild(this.chargePath),this.addChild(this.transitionsPath),this.addChild(this.mopPath),this.visible=t.runtimeSnapshot.showPath,this.chargePath.visible=!1,this.transitionsPath.visible=!1,this.mopPath.visible=!1,this.throttledUpdateLineWidth=Ni(this.updateLineWidth.bind(this),50,{leading:!0,trailing:!0}),this.throttledHandleRobotPosition=Ni(this.handleRobotPositionUpdate.bind(this),0),this.registerEventListeners()}registerEventListeners(){const{emitter:t}=Zi();t.on("antiScale",this.throttledUpdateLineWidth.bind(this)),t.on("robotPositionUpdate",this.throttledHandleRobotPosition),t.on("robotAnimationComplete",this.handleRobotAnimationComplete.bind(this))}handleRobotAnimationComplete(){this.isRealTimeDrawing&&this.stopRealTimeDrawing()}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=Zi();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=Zi(),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 s=t[n],r=s.type||"common";let o;switch(r){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||r!==e?o.moveTo(s.x,s.y):o===i&&o.lineTo(s.x,s.y),e=r,i=o}}updatePositionByOrigin(t,e){this.position.set(t,e)}drawFull(t){Qg.debug("[Path] Draw Full Path",t),this.pathData=t,this.redrawPaths(t),this.lastPointCount=t.pathPoints?.length||0}drawIncremental(t){const e=Zi(),i=this.lastPointCount,n=t.pathPoints?.slice(i)||[];if(n.length>0)if(this.setupPathStyles(),Qg.debug("[Path] Draw Incremental Path",n),e.robotConfig.speed>0){if(this.isRealTimeDrawing=!0,i>0&&this.pathData?.pathPoints){const t=this.pathData.pathPoints[i-1];this.lastDrawnPosition={x:t.x,y:t.y}}}else this.drawNewPathSegments(n,i,t.pathPoints,this.pathData?.pathPoints);this.pathData=t,this.lastPointCount=t.pathPoints?.length||0}drawNewPathSegments(t,e,i,n){if(!i||0===t.length)return;let s=null;e>0&&(n&&n[e-1]?s=n[e-1]:i[e-1]&&(s=i[e-1]));let r=null,o=null,a=!1;for(let e=0;e<t.length;e++){const i=t[e],n=i.type||"common";let h;switch(n){case"common":default:h=this.commonPath;break;case"charge":h=this.chargePath;break;case"transitions":h=this.transitionsPath;break;case"mop":h=this.mopPath}n!==r||0===e?(o&&a&&o.stroke(),r=n,o=h,a=!0,s&&0===e&&s.type===n?(h.moveTo(s.x,s.y),h.lineTo(i.x,i.y)):h.moveTo(i.x,i.y)):h.lineTo(i.x,i.y)}o&&a&&o.stroke()}stopRealTimeDrawing(){this.isRealTimeDrawing=!1,this.lastDrawnPosition=null}destroy(t){const{emitter:e}=Zi();e.off("antiScale",this.updateLineWidth.bind(this)),e.off("robotPositionUpdate",this.throttledHandleRobotPosition),e.off("robotAnimationComplete",this.handleRobotAnimationComplete.bind(this)),this.stopRealTimeDrawing(),super.destroy(t)}}class hx extends Iy{constructor(){super(),this.initializeSprite()}async initializeSprite(){const t=Zi();await this.loadTextureAndSetSize("robot",t.robotConfig.icon)}async draw({x:t,y:e,rotation:i}){super.draw({x:t,y:e,rotation:i})}}class lx extends Ky{unsubscribeFns=[];throttledUpdateOffset;fixedOffsetX=0;fixedOffsetY=0;constructor(t){super(t),this.throttledUpdateOffset=Ni(this.updateOffset.bind(this),30,{leading:!0,trailing:!0}),this.initializeAnimation()}static async create(){const t=Zi().robotConfig,e=await Ky.loadAnimationTextures(t.sleepAnimation.jsonSrc,t.sleepAnimation.framePrefix,t.sleepAnimation.frameCount);0===e.length&&(Qg.warn("No textures loaded for sleep animation"),e.push(Fn.EMPTY));const i=new lx(e);return i.setupAnimation({width:t.sleepAnimation.width,height:t.sleepAnimation.height,sizeFixed:t.sleepAnimation.sizeFixed}),i}initializeAnimation(){const t=Zi();this.visible=!1,this.fixedOffsetX=t.robotConfig.sleepAnimation.offsetX,this.fixedOffsetY=t.robotConfig.sleepAnimation.offsetY,t.emitter.on("antiScale",this.throttledUpdateOffset);const e=Yi(t.runtime,"showRobotSleepAnimation",t=>{Qg.log(`[runtime] showRobotSleepAnimation: ${t}`),this.updateVisibility()});this.unsubscribeFns.push(e)}shouldShow(){const t=Zi().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=Zi(),i=e.getApp().toFixedSize(e.robotConfig.sleepAnimation.offsetX),n=e.getApp().toFixedSize(e.robotConfig.sleepAnimation.offsetY),s={...t,x:t.x+i,y:t.y+n};super.draw(s,()=>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){Zi().emitter.off("antiScale",this.throttledUpdateOffset),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.stop(),super.destroy(t)}}class cx extends Hs{robot;ring;sleepAnimation=null;unsubscribeFns=[];targetPosition=null;targetRotation=null;isMoving=!1;pathQueue=[];lastPosition=null;currentPathType=void 0;lastUpdateTime=0;constructor(){super();const t=Zi();t.appContainer.addToLayer(my,this),this.visible=t.runtimeSnapshot.showPath,this.ring=new nx({config:t.robotConfig}),this.ring.visible=t.runtimeSnapshot.showRobotRing,this.addChild(this.ring),this.robot=new hx,this.addChild(this.robot),this.lastUpdateTime=Date.now(),t.robotConfig.speed>0&&t.getApp().ticker.add(this.update,this);const e=Yi(t.runtime,"showRobotRing",t=>{Qg.log(`[runtime] showRobotRing: ${t}`),this.ring.visible=t});this.unsubscribeFns.push(e)}async initializeSleepAnimation(){try{this.sleepAnimation=await lx.create(),this.addChild(this.sleepAnimation),Qg.log("Sleep animation added to robot")}catch(t){Qg.error("Failed to initialize sleep animation:",t)}}updatePositionByOrigin(t,e){this.position.set(t,e)}async draw({x:t,y:e,rotation:i}){this.ring.draw({x:t,y:e}),await this.robot.draw({x:t,y:e,rotation:i}),this.sleepAnimation||await 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 Zi().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=Zi(),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,s=Math.sqrt(e*e+n*n),r=t.robotConfig.speed,o=t.getApp().metersToPixels(r);if(0===r)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);s<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/s),this.robot.y+=n*(a/s),Zi().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(){Zi().getApp().requestRender("robot-animation",!0)}set visible(t){super.visible=t,this.sleepAnimation&&this.sleepAnimation.onRobotVisibilityChanged()}get visible(){return super.visible}stopRobotAnimation(){Zi().getApp().stopRender("robot-animation")}remove(){this.pathQueue=[],this.isMoving=!1,this.targetPosition=null,this.stopRobotAnimation()}destroy(t){const e=Zi();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 dx{path;robot;unsubscribeFns=[];lastDrawnPathData=null;constructor(){const t=Zi();this.path=new ax,this.robot=new cx;const e=Yi(t.runtime,"showPath",t=>{Qg.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){const e=Zi();if(!this.lastDrawnPathData)return!1;const i=t.pathHeader?.pathId,n=this.lastDrawnPathData.pathHeader?.pathId;if(i!==n)return!1;const s=(t.pathPoints?.length||0)-(this.lastDrawnPathData.pathPoints?.length||0),r=e.pathConfig.incrementalThreshold;return!(s<=0||s>r)}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+Zi().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){const e=Zi();if(!this.lastDrawnPathData||!t.pathPoints)return;this.path.drawIncremental(t);const i=this.lastDrawnPathData.pathPoints?.length||0,n=t.pathPoints.slice(i);if(0!==n.length)if(e.robotConfig.speed>0)n.forEach(e=>{this.moveRobotToPoint(e,t.pathHeader.direction,!0)});else{const e=n[n.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 ux extends Hs{colorGradients=[];cellSize=2;constructor(){super();const t=Zi();t.appContainer.addToLayer(hy,this);const e=t.heatMapConfig;this.colorGradients=e.colorGradients.map(t=>new ps(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=Zi().mapManager.roomFill.children.filter(t=>t instanceof Tl),i=new Tl;for(const t of e)i.context.instructions.push(...t.context.instructions);i.context.dirty=!0,t.setMask({mask:i}),this.addChild(i)}gridDrawing(t){const e=[],i=[],n=t.length,s=t[0].length;for(let r=0;r<n;r++)for(let n=0;n<s;n++){const s=t[r][n],o=this.cellSize/2,a=s.x-o,h=s.y-o,l=s.x+o,c=s.y+o;e.push(a,h),i.push(s.signal),e.push(l,h),i.push(s.signal),e.push(l,c),i.push(s.signal),e.push(a,h),i.push(s.signal),e.push(l,c),i.push(s.signal),e.push(a,c),i.push(s.signal)}const r=new da({attributes:{aPosition:new Float32Array(e),aSignal:new Float32Array(i)}}),o=new ao({glProgram:new Yr({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 Bl({geometry:r,shader:o});return a.alpha=.8,a}gradientDrawing(t){const e=[],i=[],n=t.length,s=t[0].length;for(let r=0;r<n;r++)for(let o=0;o<s;o++){const a=t[r][o],h=this.cellSize/2,l=(e,i)=>e<0||e>=n||i<0||i>=s?a.signal:t[e][i].signal,c=(l(r-1,o-1)+l(r-1,o)+l(r,o-1)+a.signal)/4,d=(l(r-1,o)+l(r-1,o+1)+a.signal+l(r,o+1))/4,u=(a.signal+l(r,o+1)+l(r+1,o)+l(r+1,o+1))/4,p=(l(r,o-1)+a.signal+l(r+1,o-1)+l(r+1,o))/4,f=a.x-h,g=a.y-h,m=a.x+h,y=a.y+h;e.push(f,g,m,g,m,y),i.push(c,d,u),e.push(f,g,m,y,f,y),i.push(c,u,p)}const r=new da({attributes:{aPosition:new Float32Array(e),aSignal:new Float32Array(i)}}),o=new ao({glProgram:new Yr({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 Bl({geometry:r,shader:o});return a.alpha=.8,a}}class px{heatmap=new ux;pointsTopLeftOrigin=[];signalGrid=[];cellSize=2;maxDistance=14;smoothIterations=10;heatmapAlpha=.8;constructor(){const t=Zi().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=Zi(),s=t.origin[0],r=t.origin[1],{minX:o,minY:a}=n.mapManager.mapBounds,h=e.map(t=>({x:+(s+t.x-o).toFixed(0),y:+(r+t.y-a).toFixed(0),signal:t.signal}));this.signalGrid=this.calculateInterpolatedSignal(h),this.heatmap.draw(this.signalGrid,i,this.heatmapAlpha)}calculateInterpolatedSignal(t){const e=Zi(),{minX:i,minY:n,maxX:s,maxY:r}=e.mapManager.mapBounds,o=Math.ceil((r-n)/this.cellSize),a=Math.ceil((s-i)/this.cellSize),h=Array(o).fill(null).map(()=>Array(a).fill(null));for(let e=0;e<o;e++){const o=n+e*this.cellSize+this.cellSize/2,l=Math.min(this.cellSize,r-(o-this.cellSize/2));for(let n=0;n<a;n++){const r=i+n*this.cellSize+this.cellSize/2,a=Math.min(this.cellSize,s-(r-this.cellSize/2));let c=0,d=!1;for(let e=0;e<t.length;e++){const i=t[e];if(Math.abs(r-i.x)<=a/2&&Math.abs(o-i.y)<=l/2){const t=1-i.signal/7;c=Math.round(10*Math.max(c,t))/10,d=!0}}h[e][n]={x:r,y:o,signal:c,hasPoint:d}}}const l=(e,i)=>{if(0===t.length)return 0;let n=0,s=0;for(const r of t){const t=Math.sqrt((e-r.x)**2+(i-r.y)**2);if(t<=this.maxDistance){const e=1/(1+t);s+=e*(1-r.signal/7),n+=e}}return 0===n?0:Math.round(s/n*1e3)/1e3};for(let t=0;t<o;t++)for(let e=0;e<a;e++){const i=h[t][e];i.hasPoint||(i.signal=l(i.x,i.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 s=0,r=0;const h=4;for(let e=-h;e<=h;e++)for(let l=-h;l<=h;l++){if(0===e&&0===l)continue;const h=i+e,c=n+l;if(h>=0&&h<o&&c>=0&&c<a){const i=1/(1+.3*Math.sqrt(e*e+l*l));s+=t[h][c].signal*i,r+=i}}if(r>0){const o=s/r,a=.6,h=.4;e[i][n].signal=t[i][n].signal*a+o*h,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}})(h,this.smoothIterations),h}}class fx extends ix{constructor(t){const e=Zi();super({zoneData:t.zoneData,zoneType:"forbiddenSweepZone",events:{onRemove:t=>{e.events?.onRemoveForbiddenSweepZone?.(t)},onUpdate:t=>{e.events?.onUpdateForbiddenSweepZone?.(t)},onClick:t=>{e.events?.onClickForbiddenSweepZone?.(t)}}})}static create(t){return new fx({zoneData:t})}}class gx extends ix{constructor(t){const e=Zi();super({zoneData:t.zoneData,zoneType:"forbiddenMopZone",events:{onRemove:t=>{e.events?.onRemoveForbiddenMopZone?.(t)},onUpdate:t=>{e.events?.onUpdateForbiddenMopZone?.(t)},onClick:t=>{e.events?.onClickForbiddenMopZone?.(t)}}})}static create(t){return new gx({zoneData:t})}}class mx extends ix{constructor(t){const e=Zi();super({zoneData:t.zoneData,zoneType:"cleanZone",events:{onRemove:t=>{e.events?.onRemoveCleanZone?.(t)},onUpdate:t=>{e.events?.onUpdateCleanZone?.(t)},onClick:t=>{e.events?.onClickCleanZone?.(t)}}})}static create(t){return new mx({zoneData:t})}}class yx extends Hs{static BUTTON_INDICES={REMOVE:0,SCALE:2,MOVE:3};wallData;wallConfig;controlsConfig;wallEvents;wallLine;outlineBorder;moveLine;lengthText;controlButtons;removeButton=null;scaleButton=null;moveButton=null;initialWallPoints=[];isDragging=!1;dragStartPosition=null;throttledUpdateOutline;throttledHandleScaleChange;wallLineClickHandler=null;constructor(t){super();const{wallData:e,events:i={}}=t;this.wallEvents=i;const n=Zi();this.wallConfig=n.controlsConfig.virtualWall,this.controlsConfig=n.controlsConfig,this.wallData={...e,points:this.validateAndCorrectWallLength(e.points)},this.throttledHandleScaleChange=Ni(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.throttledUpdateOutline=Ni(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.registerScaleListener(),this.setupDragEventListeners()}validateAndCorrectWallLength(t){const e=Zi();if(t.length<2)return t;const[i,n]=t,s=e.metersToPixels(this.wallConfig.minWidth),r=pm(i,n);if(r>=s)return t;if(0===r)return[i,{x:i.x+s,y:i.y}];const o=mm(gm(i,n));return[i,{x:i.x+o.x*s,y:i.y+o.y*s}]}isEditingEnabled(){return Zi().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 Hs,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:s,normal:r}=this.wallConfig,o=this.isEditingEnabled()?s:r;o.isDashed?this.wallLine=new Py({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 qy({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 s=this.calculateTextRotation();return i.rotation=s,i.eventMode="none",i}calculateWallLengthInMeters(){const t=Zi(),{points:e}=this.wallData;if(e.length<2)return 0;const i=pm(e[0],e[1]);return t.pixelsToMeters(i)}formatLengthText(t){return`${t.toFixed(1)}${this.controlsConfig.unitLabel}`}calculateTextPosition(){const t=Zi(),{points:e}=this.wallData;if(e.length<2)return{x:0,y:0};const[i,n]=e;return((t,e,i)=>{const n=cm([t,e]),s=bm(t,e);return{x:n.x+s.x*i,y:n.y+s.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 vm(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=Zi(),i=t||this.wallData.points;if(i.length<2)return i;const n=e.getApp().toFixedSize(this.wallConfig.outlineOffset),s=((t,e,i)=>{if(0===pm(t,e))return[t,t,t,t];const n=ym(t,e),s=xm(n),r=t.x-n.x*i,o=t.y-n.y*i,a=e.x+n.x*i,h=e.y+n.y*i;return[{x:r+s.x*i,y:o+s.y*i},{x:a+s.x*i,y:h+s.y*i},{x:a-s.x*i,y:h-s.y*i},{x:r-s.x*i,y:o-s.y*i}]})(i[0],i[1],n);return[s[3],s[2],s[1],s[0]]}calculateMoveLinePoints(t){if(t.length<4)return[];const{MOVE:e}=yx.BUTTON_INDICES;return[t[e],this.calculateMoveButtonPosition()]}calculateMoveButtonPosition(){const t=Zi(),{moveButtonOffset:e}=this.controlsConfig,i=this.calculateOutlinePoints();if(i.length<4)return{x:0,y:0};const{MOVE:n}=yx.BUTTON_INDICES,s=i[n],r=i[(n+3)%4],o=i[(n+1)%4],a=t.getApp().toFixedSize(e);return Cm(s,o,r,a)}createControlButtons(){const t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:e,SCALE:i}=yx.BUTTON_INDICES;this.removeButton=new $y({iconAlias:"deleteIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onClick:this.handleRemove}),this.removeButton.position.set(t[e].x,t[e].y),this.scaleButton=new ex({iconAlias:"scaleIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,getTargetPoints:()=>this.calculateOutlinePoints(),getButtonIndex:()=>i,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(t[i].x,t[i].y);const n=this.calculateMoveButtonPosition();this.moveButton=new Qy({iconAlias:"moveIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(n.x,n.y),this.controlButtons.addChild(this.removeButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}handleRemove=()=>{this.wallEvents.onRemove?.(this.wallData.id)};initializeOperation=()=>{this.initialWallPoints=this.wallData.points.map(t=>({...t}))};finalizeOperation=()=>{this.initialWallPoints=[],this.wallEvents.onUpdate?.(this.getWallData())};handleScaleStart=()=>{const t=Zi();this.initializeOperation(),t.getApp().requestRender("virtualwall-scale",!0)};handleScaleMove=t=>{0!==this.initialWallPoints.length&&this.applyScaleAndRotation(t)};handleScaleEnd=()=>{const t=Zi();this.finalizeOperation(),t.getApp().stopRender("virtualwall-scale")};handleMoveStart=()=>{const t=Zi();this.initializeOperation(),t.getApp().requestRender("virtualwall-move",!0)};handleMove=t=>{if(0===this.initialWallPoints.length)return;const e=this.parent.toLocal(t.global),i=this.getDragStartPosition()||this.moveButton?.getDragStartPosition();if(!i)return;const n=e.x-i.x,s=e.y-i.y;this.applyTranslation(n,s)};handleMoveEnd=()=>{const t=Zi();this.finalizeOperation(),t.getApp().stopRender("virtualwall-move")};applyScaleAndRotation(t){const e=Zi();if(this.initialWallPoints.length<2)return;const[i,n]=this.initialWallPoints,s=i,r=this.calculateOutlinePoints(this.initialWallPoints);if(r.length<4)return;const o=r[yx.BUTTON_INDICES.SCALE],a=gm(n,o),h={x:t.x-a.x,y:t.y-a.y},l=gm(s,h),c=pm(s,h),d=e.metersToPixels(this.wallConfig.minWidth);let u;if(c<d)if(0===c)u={x:s.x+d,y:s.y};else{const t=mm(l);u={x:s.x+t.x*d,y:s.y+t.y*d}}else u=h;this.wallData.points=[s,u],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 Py?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 t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:e,SCALE:i}=yx.BUTTON_INDICES,n=this.calculateMoveButtonPosition();this.removeButton.position.set(t[e].x,t[e].y),this.scaleButton.position.set(t[i].x,t[i].y),this.moveButton.position.set(n.x,n.y)}updateEditState(){const t=this.isEditingEnabled();this.controlButtons.visible=t,this.outlineBorder.visible=t,this.moveLine.visible=t,this.lengthText&&(this.lengthText.visible=t),t&&(this.updateOutlineComponents(),this.updateControlButtonsPosition(),this.updateLengthTextPosition()),this.updateWallLineStyle(),this.setupWallLineInteraction(),this.zIndex=t?1e3:0}createSolidLine(t,e,i,n){const s=Zi(),r=new Tl;r.eventMode="static";const o=s.getApp().toFixedSize(i);return r.moveTo(t.x,t.y),r.lineTo(e.x,e.y),r.stroke({color:n,width:o}),r}updateWallLineStyle(){const t=this.isEditingEnabled(),{editing:e,normal:i,lineWidth:n,lineColor:s}=this.wallConfig,r=t?e:i;this.wallLine instanceof Py!==r.isDashed?(this.removeChild(this.wallLine),this.wallLine.destroy(),this.createWallLine(!1),this.addChild(this.wallLine)):this.wallLine instanceof Py?this.wallLine.updateStyle({color:s.toString(),width:n,dashArray:r.dashArray}):this.redrawSolidLine()}registerScaleListener(){const{emitter:t}=Zi();t.on("antiScale",this.throttledUpdateOutline),t.on("antiScale",this.throttledHandleScaleChange)}redrawSolidLine(){const t=Zi();if(!this.wallLine||this.wallLine instanceof Py)return;const{points:e}=this.wallData;if(e.length<2)return;const{lineWidth:i,lineColor:n}=this.wallConfig,s=t.getApp().toFixedSize(i);this.wallLine.clear(),this.wallLine.setStrokeStyle({color:n.toString(),width:s}).moveTo(e[0].x,e[0].y).lineTo(e[1].x,e[1].y).stroke()}handleScaleChange=()=>{this.redrawSolidLine(),this.setupWallLineHitArea()};setupWallLineInteraction(){if(!this.wallLine)return;this.setupWallLineHitArea();const t=this.isEditingEnabled();this.wallLineClickHandler?.destroy(),this.wallLineClickHandler=null,this.wallLine.off("pointerdown",this.handleWallLinePointerDown),t?this.wallLine.on("pointerdown",this.handleWallLinePointerDown):this.wallLineClickHandler=new vy(this.wallLine,{onClick:()=>{this.wallEvents?.onClick?.(this.getWallData())},stopPropagation:!1})}setupDragEventListeners(){const{emitter:t}=Zi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Zi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handleWallLinePointerDown=t=>{this.isEditingEnabled()&&(t.stopPropagation(),this.startDragging(t))};startDragging(t){const e=Zi();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),Zi().emitter.emit("gestureHijackStart",t)}handleDragPointerMove=t=>{this.isDragging&&this.dragStartPosition&&this.handleMove(t)};handleDragPointerUp=()=>{const t=Zi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("virtualwall-drag"),this.finalizeOperation())};handleDragCancel=()=>{const t=Zi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("virtualwall-drag"),this.handleMoveEnd())};getDragStartPosition(){return this.dragStartPosition}setupWallLineHitArea(){const t=Zi();if(!this.wallLine)return;const{points:e}=this.wallData;if(e.length<2)return;const{hitAreaThickness:i}=this.wallConfig,n=t.getApp().toFixedSize(i),s=wm(e[0],e[1],n);if(0===s.length)return;const r=new Jo(s);this.wallLine.hitArea=r}getWallData(){return{...this.wallData}}updateWallData(t){this.wallData={...t,points:this.validateAndCorrectWallLength(t.points)},this.updateAllComponents(),this.updateControlButtonsPosition()}updateEditingState(){this.updateEditState()}destroy(){Zi().emitter.off("antiScale",this.throttledUpdateOutline),Zi().emitter.off("antiScale",this.throttledHandleScaleChange),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.wallLine&&this.wallLine.off("pointerdown",this.handleWallLinePointerDown),this.wallLineClickHandler?.destroy(),this.wallLineClickHandler=null,this.wallLine?.destroy(),this.lengthText?.destroy(),this.outlineBorder?.destroy(),this.moveLine?.destroy(),this.controlButtons?.destroy(),this.removeButton?.destroy(),this.scaleButton?.destroy(),this.moveButton?.destroy(),this.removeButton=null,this.scaleButton=null,this.moveButton=null,super.destroy()}}class xx extends Hs{spotData;spotConfig;controlsConfig;spotEvents;controlFill;spotBorder;centerIcon;sizeText;clickHandler=null;initialSpotPoint=null;throttledUpdateScale;constructor(t){super();const{spotData:e,events:i={}}=t,n=Zi();this.spotData=e,this.spotEvents=i,this.controlsConfig=n.controlsConfig,this.spotConfig=n.controlsConfig.spot,this.throttledUpdateScale=Ni(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){Zi().emitter.on("antiScale",this.throttledUpdateScale)}updateScale(){this.isEditingEnabled()&&this.updateSizeTextPosition()}isEditingEnabled(){return Zi().runtimeSnapshot.editingSpotIds.includes(this.spotData.id)}calculateRectanglePoints(){const t=Zi(),{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 Ty({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 Iy;return this.loadIconTexture(t),t.position.set(this.spotData.point.x,this.spotData.point.y),t.eventMode="none",t.visible=!1,t}async loadIconTexture(t){const{iconSize:e}=this.spotConfig;await t.loadTextureAndSetSize("spotIcon",{width:e,height:e,sizeFixed:!1}),t.visible=this.isEditingEnabled()}createSizeText(){const t=this.calculateSpotSizeText(),e=new qy({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=Zi(),e=this.calculateRectanglePoints();if(e.length<4)return{x:0,y:0};const[i,n,s,r]=e,{textPosition:o,textOffset:a}=this.spotConfig,h=t.getApp().toFixedSize(a);let l,c;switch(o){case"top":default:l={x:(i.x+n.x)/2,y:(i.y+n.y)/2},c={x:l.x,y:l.y+h};break;case"right":l={x:(n.x+s.x)/2,y:(n.y+s.y)/2},c={x:l.x+h,y:l.y};break;case"bottom":l={x:(r.x+s.x)/2,y:(r.y+s.y)/2},c={x:l.x,y:l.y+h};break;case"left":l={x:(i.x+r.x)/2,y:(i.y+r.y)/2},c={x:l.x-h,y:l.y}}return c}handleDragStart=()=>{const t=Zi();this.isEditingEnabled()&&(this.initialSpotPoint={...this.spotData.point},t.getApp().requestRender("spot-drag",!0))};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,s=e.y-i.y;this.applyTranslation(n,s)};handleDragEnd=()=>{const t=Zi();this.initialSpotPoint=null,t.getApp().stopRender("spot-drag"),this.spotEvents.onUpdate?.(this.getSpotData())};applyTranslation(t,e){this.initialSpotPoint&&(this.spotData.point={x:this.initialSpotPoint.x+t,y:this.initialSpotPoint.y+e},this.drawSpot())}setupClickHandler(){this.clickHandler=new vy(this,{onClick:()=>{this.isEditingEnabled()||this.spotEvents?.onClick?.(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={...t},this.drawSpot(),this.updateEditState()}getSpotData(){return{...this.spotData}}destroy(){Zi().emitter.off("antiScale",this.throttledUpdateScale),this.clickHandler?.destroy(),this.clickHandler=null,this.controlFill?.destroy(),this.spotBorder?.destroy(),this.centerIcon?.destroy(),this.sizeText?.destroy(),super.destroy()}static create(t){const e=Zi();return new xx({spotData:t,events:{onUpdate:t=>{e.events?.onUpdateSpot?.(t)},onClick:t=>{e.events?.onClickSpot?.(t)}}})}}class bx extends Hs{endPoints;dividerConfig;dividerEvents;roomId;roomGeometry=null;dashLine;solidLine=null;startEndPoint;endEndPoint;solidLinePoints=null;initialDividerPoints=[];isDragging=!1;dragStartPosition=null;throttledHandleScaleChange;constructor(t){super();const{endPoints:e,roomId:i,events:n={}}=t;this.dividerEvents=n,this.roomId=i;const s=Zi();this.dividerConfig=s.dividerConfig,this.roomGeometry=s.mapManager.getRoomById(this.roomId)||null,this.endPoints=e?this.validateDividerPoints(e):this.createDefaultdividerPoints(),this.throttledHandleScaleChange=Ni(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 Qg.warn("Room geometry not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const t=Zi(),e=t.getApp().mapState;if(!e)return Qg.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),s=this.dividerConfig.defaultDirection,r=i.x+i.width/2,o=i.y+i.height/2,a="horizontal"===s?i.width+2*n:i.height+2*n;return Mm(r,o,a,s).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 Py({start:t[0],end:t[1],style:{color:n.toString(),width:e,dashArray:i}})}createEndPoints(){const t=this.endPoints;this.startEndPoint=new Ey({position:t[0],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:t=>this.handleEndPointDragMove(0,t),onDragEnd:this.handleEndPointDragEnd}),this.endEndPoint=new Ey({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=Zi();if(!this.dashLine)return;const e=this.endPoints;if(e.length<2)return;const{hitAreaThickness:i}=this.dividerConfig,n=t.getApp().toFixedSize(i),s=wm(e[0],e[1],n);if(0===s.length)return;const r=new Jo(s);this.dashLine.hitArea=r}handleEndPointDragStart=()=>{const t=Zi();this.initialDividerPoints=this.endPoints.map(t=>({...t})),this.clearSolidLine(),t.getApp().requestRender("divider-endpoint-drag",!0)};handleEndPointDragMove=(t,e)=>{0!==this.initialDividerPoints.length&&(this.endPoints[t]=e,this.updateDashLine(),this.updateSolidLine(),this.setupDashLineHitArea())};handleEndPointDragEnd=()=>{const t=Zi();this.initialDividerPoints=[],t.getApp().stopRender("divider-endpoint-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),this.dividerEvents.onUpdate?.(this.getDividerEndPoints())};handleDashLinePointerDown=t=>{t.stopPropagation(),this.startDragging(t)};startDragging(t){const e=Zi();this.isDragging=!0;const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},this.initialDividerPoints=this.endPoints.map(t=>({...t})),this.clearSolidLine(),e.getApp().requestRender("divider-drag",!0),Zi().emitter.emit("gestureHijackStart",t)}setupDragEventListeners(){const{emitter:t}=Zi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Zi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}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()};handleDragPointerUp=()=>{const t=Zi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],t.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),this.dividerEvents.onUpdate?.(this.getDividerEndPoints()))};handleDragCancel=()=>{const t=Zi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],t.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),this.dividerEvents.onUpdate?.(this.getDividerEndPoints()))};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=Zi().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}=Zi();t.on("antiScale",this.throttledHandleScaleChange)}handleScaleChange=()=>{this.startEndPoint?.redraw(),this.endEndPoint?.redraw(),this.updateSolidLine(),this.setupDashLineHitArea()};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=Zi().mapManager.roomFill;return t&&this.roomId&&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),s=this.isPointInRoomFill(i);if(n||s)return null;const r=((t,e,i=1,n=2e3)=>{const s=[],r=e.x-t.x,o=e.y-t.y,a=Math.sqrt(r*r+o*o);if(0===a)return[t];const h=Math.min(Math.max(Math.ceil(a/i),2),n);for(let e=0;e<=h;e++){const i=e/h,n={x:t.x+i*r,y:t.y+i*o};s.push(n)}return s})(e,i),o=[];for(const t of r)this.isPointInRoomFill(t)&&o.push(t);if(0===o.length)return null;const a=o[0],h=o[o.length-1];if(pm(a,h)<3)return null;const l=((t,e,i)=>{const n=e.x-t.x,s=e.y-t.y,r=Math.sqrt(n*n+s*s);if(0===r)return[t,e];const o=n/r,a=s/r;return[{x:t.x-o*i,y:t.y-a*i},{x:e.x+o*i,y:e.y+a*i}]})(a,h,.5);return l}isPointInRoomFill(t){if(!this.roomId)return!1;const e=Zi().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=Zi(),i=e.getApp().mapState,n=e.mapManager.roomFill;if(!i||!n)return!1;const s=n.getRasterRoomData(this.roomId);if(!s)return!1;const r=n.getMapWidth();if(0===r)return!1;const o=Math.round(t.y)*r+Math.round(t.x);for(let t=0;t<s.pixelIndices.length;t++)if(s.pixelIndices[t]===o)return!0;return!1}isPointInStructuredRoomFill(t){const e={x:Math.round(t.x),y:Math.round(t.y)},i=Zi(),n=i.getApp().mapState,s=i.mapManager.getRoomById(this.roomId);return!!(n&&s&&s.outlinePoints)&&om(e,s.outlinePoints,!0)}isRasterData(){const t=Zi().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=Zi().getApp().mapState;return!!i&&!((t,e,i,n,s,r)=>{const o=i+s,a=n+r,h=Math.min(t.x,e.x),l=Math.max(t.x,e.x),c=Math.min(t.y,e.y),d=Math.max(t.y,e.y);if(l<i||h>o||d<n||c>a)return!1;if(Am(t,i,n,s,r)||Am(e,i,n,s,r))return!0;const u=[{x:i,y:n},{x:o,y:n},{x:o,y:a},{x:i,y:a}];for(let i=0;i<4;i++)if(Sm(t,e,u[i],u[(i+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=Zi(),{resetDividerWhenOutOfRoom:e}=t.dividerConfig;e&&this.isDividerCompletelyOutOfRoom()&&this.resetToDefaultState()}resetToDefaultState(){this.endPoints=this.createDefaultdividerPoints(),this.calculateAndCreateSolidLine(),this.updateComponents(),this.dividerEvents.onUpdate?.(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=Zi();this.solidLine=new Tl,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(){Zi().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(),this.dashLine?.destroy(),this.startEndPoint?.destroy(),this.endEndPoint?.destroy(),super.destroy()}}class _x{forbiddenSweepZoneMap=new Map;forbiddenMopZoneMap=new Map;cleanZoneMap=new Map;virtualWallMap=new Map;spotMap=new Map;divider=null;unsubscribeFns=[];constructor(){const t=Zi(),e=Yi(t.runtime,"editingForbiddenSweepZoneIds",t=>{Qg.log(`[runtime] editingForbiddenSweepZoneIds: ${t}`),this.updateZonesEditState(this.forbiddenSweepZoneMap)}),i=Yi(t.runtime,"editingForbiddenMopZoneIds",t=>{Qg.log(`[runtime] editingForbiddenMopZoneIds: ${t}`),this.updateZonesEditState(this.forbiddenMopZoneMap)}),n=Yi(t.runtime,"editingCleanZoneIds",t=>{Qg.log(`[runtime] editingCleanZoneIds: ${t}`),this.updateZonesEditState(this.cleanZoneMap)}),s=Yi(t.runtime,"editingVirtualWallIds",t=>{Qg.log(`[runtime] editingVirtualWallIds: ${t}`),this.updateVirtualWallsEditState(this.virtualWallMap)}),r=Yi(t.runtime,"editingSpotIds",t=>{Qg.log(`[runtime] editingSpotIds: ${t}`),this.updateSpotsEditState(this.spotMap)}),o=Yi(t.runtime,"dividingRoomId",t=>{Qg.log(`[runtime] dividingRoomId: ${t}`),this.handleDividingRoomIdChange(t)});this.unsubscribeFns.push(e,i,n,s,r,o)}updatePositionByOrigin(t,e){const i=Zi().appContainer.getLayer(cy);i&&i.position.set(t,e)}drawForbiddenSweepZones(t){this.drawZones(t,this.forbiddenSweepZoneMap,t=>fx.create(t))}getForbiddenSweepZones(){return this.getZonesData(this.forbiddenSweepZoneMap)}clearAllForbiddenSweepZones(){this.clearAllZones(this.forbiddenSweepZoneMap)}drawForbiddenMopZones(t){this.drawZones(t,this.forbiddenMopZoneMap,t=>gx.create(t))}getForbiddenMopZones(){return this.getZonesData(this.forbiddenMopZoneMap)}clearAllForbiddenMopZones(){this.clearAllZones(this.forbiddenMopZoneMap)}drawCleanZones(t){this.drawZones(t,this.cleanZoneMap,t=>mx.create(t))}getCleanZones(){return this.getZonesData(this.cleanZoneMap)}clearAllCleanZones(){this.clearAllZones(this.cleanZoneMap)}drawVirtualWalls(t){const e=Zi(),i=this.virtualWallMap,n=new Set(t.map(t=>t.id));for(const[t,s]of i)n.has(t)||(e.appContainer.removeFromLayer(cy,s),s.destroy(),i.delete(t));t.forEach(t=>{const n=i.get(t.id);if(n)this.isWallDataEqual(n.getWallData(),t)||n.updateWallData(t);else{const n=new yx({wallData:t,events:{onRemove:t=>{e.events?.onRemoveVirtualWall?.(t)},onUpdate:t=>{e.events?.onUpdateVirtualWall?.(t)},onClick:t=>{e.events?.onClickVirtualWall?.(t)}}});i.set(t.id,n),e.appContainer.addToLayer(cy,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 t of i)n.has(t)||this.removeSpot(t,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()),s=new Set(t.map(t=>t.id));for(const t of n)s.has(t)||this.removeZone(t,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=Zi(),s=i(t);e.set(t.id,s),n.appContainer.addToLayer(cy,s)}removeZone(t,e){const i=Zi(),n=e.get(t);n&&(i.appContainer.removeFromLayer(cy,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)=>{const n=t.get(i);n&&(n.parent?.removeChild(n),n.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],s=e.points[i];if(Math.abs(n.x-s.x)>.1||Math.abs(n.y-s.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],s=e.points[i];if(Math.abs(n.x-s.x)>.1||Math.abs(n.y-s.y)>.1)return!1}return!0}addNewSpot(t,e){const i=Zi(),n=xx.create(t);e.set(t.id,n),i.appContainer.addToLayer(cy,n)}removeSpot(t,e){const i=Zi(),n=e.get(t);n&&(i.appContainer.removeFromLayer(cy,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)=>{const n=t.get(i);n&&(n.parent?.removeChild(n),n.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){null!=t&&this.getRoomGeometry(t)?this.createDefaultDivider(t):this.clearDivider()}getRoomGeometry(t){return Zi().mapManager.getRoomById(t)}createDefaultDivider(t){const e=Zi();this.clearDivider(),this.divider=new bx({roomId:t,events:{onUpdate:t=>{e.events?.onUpdateDivider?.(t)}}}),e.appContainer.addToLayer(cy,this.divider)}clearDivider(){this.divider&&(Zi().appContainer.removeFromLayer(cy,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 vx extends Iy{objectData;clickHandler=null;constructor(t){super(),this.objectData=t}async initializeSprite(){const t=Zi().detectedObjectConfig,e=this.objectData.width||t.width,i=this.objectData.height||t.height;await 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 vy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){const t=Zi();t.events?.onClickDetectedObject?.(this.getObjectData())}getObjectData(){return{...this.objectData}}async updateObjectData(t){const e=Zi(),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;await 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 wx{detectedObjectMap=new Map;updatePositionByOrigin(t,e){const i=Zi().appContainer.getLayer(uy);i&&i.position.set(t,e)}async drawDetectedObjects(t){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 e of t){const t=this.detectedObjectMap.get(e.id);t?t.isSameData(e)||await t.updateObjectData(e):await this.addNewDetectedObject(e)}}clearAllDetectedObjects(){const t=Zi();this.detectedObjectMap.forEach(e=>{t.appContainer.removeFromLayer(uy,e),e.destroy()}),this.detectedObjectMap.clear()}async addNewDetectedObject(t){const e=Zi(),i=new vx(t);await i.initializeSprite(),this.detectedObjectMap.set(t.id,i),e.appContainer.addToLayer(uy,i)}removeDetectedObject(t){const e=Zi(),i=this.detectedObjectMap.get(t);i&&(e.appContainer.removeFromLayer(uy,i),i.destroy(),this.detectedObjectMap.delete(t))}destroy(){this.clearAllDetectedObjects()}}class Cx extends Iy{elementData;clickHandler=null;constructor(t){super(),this.elementData=t}async initialize(){await this.loadTextureAndSetSize(this.elementData.src,{width:this.elementData.width,height: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 vy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){const t=Zi();t.events?.onClickCustomElement?.(this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const e=this.elementData;this.elementData=t,e.src!==t.src&&await this.loadTextureAndSetSize(t.src,{width:t.width,height:t.height}),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}destroy(){this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class Sx extends Yy{elementData;clickHandler=null;constructor(t,e){super({source:t}),this.elementData=e}async initialize(){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 vy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){const t=Zi();t.events?.onClickCustomElement?.(this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const e=this.elementData;if(this.elementData=t,e.src!==t.src)throw new Error("GIF source change requires recreation of instance");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}destroy(){this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class Ix extends By{elementData;domClickHandler=null;resizeObserver=null;constructor(t){const e=document.createElement("div");Ix.setupDefaultStyles(e,t),e.innerHTML=t.htmlContent,super({element:e}),this.elementData=t}async initialize(){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=>{const e=t[0];e&&e.contentRect.width>0&&e.contentRect.height>0&&(this.setFixedSize(e.contentRect.width,e.contentRect.height),0===this.alpha&&this.showElement(),this.resizeObserver?.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(){this.alpha=this.elementData.opacity??1,this.element.style.pointerEvents=this.elementData.interactive?"auto":"none",this.interactive=this.elementData.interactive??!1,this.elementData.interactive&&this.element&&(this.element.style.setProperty("-webkit-tap-highlight-color","transparent"),this.element.style.setProperty("-webkit-touch-callout","none"))}setupClickHandler(){this.element&&(this.domClickHandler=t=>{t.preventDefault(),t.stopPropagation(),this.handleClick()},this.element.addEventListener("click",this.domClickHandler))}handleClick(){const t=Zi();t.events?.onClickCustomElement?.(this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const e=this.elementData;this.elementData=t,e.htmlContent!==t.htmlContent&&this.element&&(this.element.innerHTML=t.htmlContent,t.width&&t.height||this.waitForElementDimensions()),e.width===t.width&&e.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=t.rotation??0,this.alpha=t.opacity??1,t.interactive?this.domClickHandler||this.setupClickHandler():(this.eventMode="none",this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null))}isSameData(t){return this.elementData.id===t.id&&this.elementData.type===t.type&&this.elementData.htmlContent===t.htmlContent&&this.elementData.x===t.x&&this.elementData.y===t.y&&this.elementData.width===t.width&&this.elementData.height===t.height&&this.elementData.rotation===t.rotation&&this.elementData.opacity===t.opacity&&this.elementData.interactive===t.interactive}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 Ax{customElementsMap=new Map;gifTicker=null;gifElements=new Set;constructor(){}updatePositionByOrigin(t,e){const i=Zi(),n=i.appContainer.getLayer(py),s=i.appContainer.getLayer(fy);n&&n.position.set(t,e),s&&s.position.set(t,e)}async drawCustomElements(t){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(async t=>{const e=this.customElementsMap.get(t.id);e?this.isSameData(e,t)||("gif"===t.type&&e.getElementData().src!==t.src?(this.removeCustomElement(t.id),await this.addNewCustomElement(t)):await this.updateElementData(e,t)):await this.addNewCustomElement(t)});await Promise.all(n),this.updateGifTicker()}clearAllCustomElements(){const t=Zi();this.customElementsMap.forEach(e=>{e instanceof Sx?t.appContainer.removeFromLayer(fy,e):t.appContainer.removeFromLayer(py,e),e.destroy()}),this.customElementsMap.clear(),this.gifElements.clear(),this.stopGifTicker()}async addNewCustomElement(t){const e=Zi();let i;switch(t.type){case"image":i=new Cx(t);break;case"gif":{const e=await al.load(t.src);i=new Sx(e,t);break}case"html":i=new Ix(t);break;default:throw new Error(`Unsupported custom element type: ${t.type}`)}await i.initialize(),this.customElementsMap.set(t.id,i),i instanceof Sx?(e.appContainer.addToLayer(fy,i),this.gifElements.add(i)):e.appContainer.addToLayer(py,i)}removeCustomElement(t){const e=Zi(),i=this.customElementsMap.get(t);i&&(i instanceof Sx?(this.gifElements.delete(i),e.appContainer.removeFromLayer(fy,i)):e.appContainer.removeFromLayer(py,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 Sx||"html"===e.type&&t instanceof Ix)&&t.isSameData(e)}async updateElementData(t,e){if("image"===e.type&&t instanceof Cx)await t.updateElementData(e);else if("gif"===e.type&&t instanceof Sx)await t.updateElementData(e);else{if(!("html"===e.type&&t instanceof Ix))throw new Error("Element type mismatch during update");await t.updateElementData(e)}}updateGifTicker(){this.gifElements.size>0?this.startGifTicker():this.stopGifTicker()}startGifTicker(){this.gifTicker?.started||(this.gifTicker?this.gifTicker.maxFPS=1:(this.gifTicker=new sr,this.gifTicker.maxFPS=1,this.gifTicker.add(()=>{this.renderGifContainer()})),this.gifTicker.start())}stopGifTicker(){this.gifTicker?.started&&(Qg.log("⏸️ [GifTicker] 停止 GIF 专用渲染"),this.gifTicker.stop())}renderGifContainer(){const t=Zi();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 Mx extends Nl{roomId;roomIndex;constructor(t){const e=Zi(),{nameLabel:i,colors:n}=e.roomConfig,s=n.name[t.index%n.name.length],r=new uh({fontSize:i.fontSize,fontFamily:i.fontFamily,fontWeight:i.fontWeight,fill:s,align:"center"});super({text:t.name||"Unknown",style:r}),this.roomId=t.id,this.roomIndex=t.index,this.anchor.set(.5)}updateName(t){this.text=t}updateColor(t){const e=Zi(),{colors:i}=e.roomConfig,n=t??i.name[this.roomIndex%i.name.length];this.style.fill=n}}class Tx extends Hs{background;cleanModeIcon;suctionIcon;cisternIcon;cleanTimesIcon;orderContainer;orderBackground;orderText;bubble=null;isFolded=!1;roomId;constructor(t){super();const e=Zi(),i=e.roomConfig;this.roomId=t.id,this.background=new Tl;const{property:n,colors:{propertyTheme:s}}=i;i.property.foldable&&(this.bubble=new Tl);const r=s[t.index%s.length];this.cleanModeIcon=new Iy,this.cleanModeIcon.tint=r,this.cleanModeIcon.anchor.set(0,0),this.suctionIcon=new Iy,this.suctionIcon.tint=r,this.suctionIcon.anchor.set(0,0),this.cisternIcon=new Iy,this.cisternIcon.tint=r,this.cisternIcon.anchor.set(0,0),this.cleanTimesIcon=new Iy,this.cleanTimesIcon.tint=r,this.cleanTimesIcon.anchor.set(0,0),this.orderContainer=new Hs,this.orderBackground=new Tl,this.orderText=new Nl({text:"",style:new uh({fontSize:n.cleanOrder.fontSize,fontFamily:n.cleanOrder.fontFamily,fontWeight:n.cleanOrder.fontWeight,fill:n.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=e.runtimeSnapshot.showRoomProperty,this.updateProperty(t)}async updateProperty(t){await this.updateIcons(t),this.updateBackground()}getDisplayElements(t){const e=Zi(),{displayOrders:i,cleanMode:n,suction:s,cistern:r}=e.roomConfig.property,{showRoomOrder:o,showRoomProperty:a}=e.runtimeSnapshot,h=t.order||0,l=o&&h>0,c=a&&i.includes("cleanMode"),d=a&&i.includes("suction"),u=a&&i.includes("cistern"),p=a&&i.includes("cleanTimes")&&t.cleanTimes>0,f={cleanMode:{element:this.cleanModeIcon,show:c,isOrder:!1},suction:{element:this.suctionIcon,show:d,isOrder:!1},cistern:{element:this.cisternIcon,show:u,isOrder:!1},cleanTimes:{element:this.cleanTimesIcon,show:p,isOrder:!1}},g=[];return l&&g.push({element:this.orderContainer,show:!0,isOrder:!0}),i.forEach(t=>{const e=f[t];e&&e.show&&g.push(e)}),{shouldShowOrder:l,shouldShowCleanMode:c,shouldShowSuction:d,shouldShowCistern:u,shouldShowCleanTimes:p,elementsToShow:g,orderValue:h}}async updateIcons(t){const e=Zi(),{iconWidth:i,iconHeight:n,container:s,cleanOrder:r,foldable:o,iconGap:a}=e.roomConfig.property,{propertyTheme:h}=e.roomConfig.colors,{paddingHorizontal:l,paddingVertical:c}=s,{shouldShowOrder:d,shouldShowCleanMode:u,shouldShowSuction:p,shouldShowCistern:f,shouldShowCleanTimes:g,elementsToShow:m,orderValue:y}=this.getDisplayElements(t);this.orderContainer.visible=d,this.cleanModeIcon.visible=u,this.suctionIcon.visible=p,this.cisternIcon.visible=f,this.cleanTimesIcon.visible=g,o&&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(u&&x.push(this.cleanModeIcon.loadTextureAndSetSize(`cleanMode_${t.cleanMode}`,{width:i,height:n,sizeFixed:!1})),p&&x.push(this.suctionIcon.loadTextureAndSetSize(`fan_${t.suction}`,{width:i,height:n,sizeFixed:!1})),f&&x.push(this.cisternIcon.loadTextureAndSetSize(`water_${t.cistern}`,{width:i,height:n,sizeFixed:!1})),g){const e=t.cleanTimes||1;x.push(this.cleanTimesIcon.loadTextureAndSetSize(`cleanTimes${e}`,{width:i,height:n,sizeFixed:!1}))}await Promise.all(x),d&&(this.orderText.text=y.toString(),this.orderBackground.clear(),this.orderBackground.setFillStyle({color:h[t.index%h.length]}),this.orderBackground.circle(i/2,n/2,i/2).fill(),this.orderText.position.set(i/2,n/2));let b=l;m.forEach((t,e)=>{const{element:n,isOrder:s}=t;n.position.set(b,c),b+=i,e<m.length-1&&(b+=s?r.gapRight:a)})}updateBackground(){const t=Zi().roomConfig,{container:e,foldable:i}=t.property,{borderRadius:n,tailHeight:s,tailWidth:r,backgroundColor:o}=e,a=this.calculateContentWidth(),h=this.calculateContentHeight(),l=Math.min(r,a/2);if(this.background.clear(),this.bubble&&this.bubble.clear(),this.background.setFillStyle({color:o}),this.background.roundRect(0,0,a,h,n).fill(),i&&this.bubble){const t=(a-l)/2;this.bubble.setFillStyle({color:o}),this.bubble.poly([t,h-1,t+l,h-1,t+l/2,h+s]).fill()}}calculateContentWidth(){const t=Zi(),{iconWidth:e,container:i,cleanOrder:n,iconGap:s}=t.roomConfig.property,{paddingHorizontal:r}=i,o=t.getRoomData(this.roomId);if(!o)return 2*r;const{elementsToShow:a}=this.getDisplayElements(o);let h=r;return a.forEach((t,i)=>{const{isOrder:r}=t;h+=e,i<a.length-1&&(h+=r?n.gapRight:s)}),h+=r,h}calculateContentHeight(){const t=Zi().roomConfig,{iconHeight:e,container:i}=t.property;return i.paddingVertical+e+i.paddingVertical}getTotalHeight(){const t=Zi(),{foldable:e,container:i}=t.roomConfig.property,{tailHeight:n}=i;return this.calculateContentHeight()+(e?n:0)}getTotalWidth(){return this.calculateContentWidth()}setFolded(t){const e=Zi(),{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=Zi(),{foldable:e}=t.roomConfig.property;return!!e&&this.isFolded}repositionFoldedBubble(){const t=Zi(),{foldable:e}=t.roomConfig.property;if(!e||!this.bubble)return;const i=t.roomConfig,{tailHeight:n}=i.property.container,s=this.calculateContentWidth(),r=this.calculateContentHeight(),o=s/2;this.bubble.position.set(o,r+n/2)}}class Px extends Hs{background;checkmarkIcon;bubble;roomId;constructor(t){super();const e=Zi().roomConfig;this.roomId=t.id,this.background=new Tl,this.bubble=new Tl;const{colors:{selectionIndicatorIcon:i}}=e;this.checkmarkIcon=new Iy,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)}async updateIndicator(t){const e=Zi(),{roomSelectionMode:i,enableRoomSelection:n,selectRoomIds:s}=e.runtimeSnapshot;if(!n||"checkmark"!==i)return void(this.visible=!1);const r=s.includes(t.id);await this.showCheckmarkMode(r),this.updateBackground()}async showCheckmarkMode(t){const e=Zi(),{selectionIndicator:i}=e.roomConfig,{iconWidth:n,iconHeight:s}=i;if(t){this.visible=!0,this.checkmarkIcon.visible=!0,await this.checkmarkIcon.loadTextureAndSetSize("checkmark",{width:n,height:s,sizeFixed:!1});const t=i.containerWidth/2,e=i.containerHeight/2;this.checkmarkIcon.position.set(t-n/2,e-s/2)}else this.visible=!1}updateBackground(){const t=Zi(),{selectionIndicator:e,colors:i}=t.roomConfig,{containerWidth:n,containerHeight:s,strokeWidth:r,strokeColor:o,borderRadius:a,tailHeight:h,tailWidth:l}=e,c=t.getRoomData(this.roomId);if(!c)return;const d=i.selectionIndicatorBackground[c.index%i.selectionIndicatorBackground.length];if(this.background.clear(),this.bubble.clear(),this.background.setFillStyle({color:d}).roundRect(0,0,n,s,a).fill().setStrokeStyle({color:o,width:r,alignment:0}).stroke(),h>0&&l>0){const t=(n-l)/2;this.bubble.setFillStyle({color:o});const e=s+r;this.bubble.poly([t,e-1,t+l,e-1,t+l/2,e+h]).fill()}}getTotalHeight(){const t=Zi(),{selectionIndicator:e}=t.roomConfig,{containerHeight:i,tailHeight:n,strokeWidth:s}=e;return i+s+(n>0?n:0)}getTotalWidth(){const t=Zi(),{selectionIndicator:e}=t.roomConfig;return e.containerWidth}}class Ex extends Sy{roomId;roomName;roomProperty=null;roomSelectionIndicator=null;clickHandler=null;constructor(t){super();const e=Zi();this.enableRenderGroup(),this.roomId=t.id,t.centerPoint&&this.position.set(t.centerPoint.x,t.centerPoint.y),this.roomName=new Mx(t),this.roomName.visible=e.runtimeSnapshot.showRoomName,this.createRoomProperty(t),this.createRoomSelectionIndicator(t),this.updateLayout(),this.clickHandler=new vy(this,{onClick:()=>{e.events?.onClickRoomProperties?.(t)}})}shouldShowRoomProperty(){const t=Zi(),{showRoomOrder:e,showRoomProperty:i,enableRoomSelection:n,roomSelectionMode:s}=t.runtimeSnapshot,r=t.getRoomData(this.roomId);if(!r)return!1;if(n&&"checkmark"===s)return!1;const o=e&&(r.order||0)>0,a=i&&(r.suction&&t.roomConfig.property.displayOrders.includes("suction")||r.cistern&&t.roomConfig.property.displayOrders.includes("cistern")||r.cleanTimes>0&&t.roomConfig.property.displayOrders.includes("cleanTimes"));return o||a}shouldShowRoomSelectionIndicator(){const t=Zi(),{enableRoomSelection:e,roomSelectionMode:i}=t.runtimeSnapshot;return e&&"checkmark"===i}updateRoomPropertyVisibility(){const t=Zi();if(this.roomProperty){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()}}async updateRoomSelectionIndicatorVisibility(){const t=Zi();if(this.roomSelectionIndicator){if(this.shouldShowRoomSelectionIndicator()){const e=t.getRoomData(this.roomId);e&&await this.roomSelectionIndicator.updateIndicator(e)}else this.roomSelectionIndicator.visible=!1;this.updateLayout()}}async createRoomProperty(t){const e=Zi();this.roomProperty&&(this.removeChild(this.roomProperty),this.roomProperty.destroy()),this.roomProperty=new Tx(t),await this.roomProperty.updateProperty(t),this.addChild(this.roomProperty),this.addChild(this.roomName),this.roomName.visible=e.runtimeSnapshot.showRoomName,this.updateRoomPropertyVisibility()}async createRoomSelectionIndicator(t){this.roomSelectionIndicator&&(this.removeChild(this.roomSelectionIndicator),this.roomSelectionIndicator.destroy()),this.roomSelectionIndicator=new Px(t),this.addChild(this.roomSelectionIndicator),await this.updateRoomSelectionIndicatorVisibility()}updateLayout(){const t=Zi(),{property:{offsetY:e,offsetX:i},selectionIndicator:{offsetY:n,offsetX:s}}=t.roomConfig,r=this.roomProperty?.visible||!1,o=this.roomName.visible,a=this.roomSelectionIndicator?.visible||!1;if(r&&this.roomProperty)if(this.roomProperty.isFoldedState())this.roomProperty.position.set(i,-e);else{const t=this.roomProperty.getTotalHeight(),n=this.roomProperty.getTotalWidth();o?(this.roomProperty.position.set(-n/2+i,-e-t),this.roomName.position.set(0,0)):this.roomProperty.position.set(-n/2+i,-t/2-e)}if(a&&this.roomSelectionIndicator){const t=this.roomSelectionIndicator.getTotalHeight(),e=this.roomSelectionIndicator.getTotalWidth();o?(this.roomSelectionIndicator.position.set(-e/2+s,-n-t),this.roomName.position.set(0,0)):this.roomSelectionIndicator.position.set(-e/2+s,-t/2-n)}!o||r||a||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)}destroy(){this.clickHandler?.destroy(),this.clickHandler=null,super.destroy()}}class Bx extends Hs{floorTypeMap=new Map;floorTypeMasks=new Map;floorTypeToRooms=new Map;constructor(){super({isRenderGroup:!0}),Zi().appContainer.addToLayer(ry,this)}async createFloorTypes(t){if(!Zi().runtimeSnapshot.showRoomFloorType)return;this.clearFloorTypes();const e=this.groupRoomsByFloorType(t),i=[];for(const[t,n]of e)i.push(this.createMergedFloorType(t,n));await Promise.all(i)}groupRoomsByFloorType(t){const e=new Map,i=Zi();return t.forEach((t,n)=>{const s=i.getRoomData(n),r=s?.floorType||0;r>=0&&(e.has(r)||e.set(r,[]),e.get(r).push({roomId:n,graphics:t}))}),e}async createMergedFloorType(t,e){const i=Zi(),{assets:n,opacity:s,scale:r}=i.roomConfig.floorType,o=n[t%n.length];if(!o)return void Qg.warn(`No texture asset configured for floorType: ${t}`);const a=await al.load(o);if(!a)return void Qg.warn(`Floor material texture not found: ${o}`);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,s=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),s=Math.max(s,t.y+t.height)}),{x:e,y:i,width:n-e,height:s-i}})(e.map(({graphics:t})=>t.getLocalBounds())),l=new Dl({texture:a,width:h.width,height:h.height});l.x=h.x,l.y=h.y,l.alpha=s,l.tileScale.set(r);const c=this.createMergedMask(e.map(({graphics:t})=>t));l.mask=c,this.addChild(l),this.floorTypeMap.set(t,l),this.floorTypeMasks.set(t,c),this.floorTypeToRooms.set(t,new Set(e.map(({roomId:t})=>t)))}createMergedMask(t){const e=new Hs;return t.forEach(t=>{const i=new Tl;i.context=t.context.clone(),e.addChild(i)}),e}clearFloorTypes(){this.floorTypeMap.forEach(t=>{try{this.removeChild(t),t.destroy()}catch(t){Qg.warn("Error destroying floor material:",t)}}),this.floorTypeMap.clear(),this.floorTypeMasks.forEach(t=>{try{t.destroy()}catch(t){Qg.warn("Error destroying floor mask:",t)}}),this.floorTypeMasks.clear(),this.floorTypeToRooms.clear()}destroy(){this.clearFloorTypes(),super.destroy()}}class Ox{unsubscribeFns=[];roomInfoContainer=new Hs;roomInfoMap=new Map;roomDisplayMap=new Map;roomFloorType=new Bx;constructor(){const t=Zi();t.appContainer.addToLayer(dy,this.roomInfoContainer);const e=Yi(t.runtime,"showRoomFloorType",t=>{Qg.log(`[runtime] showRoomFloorType: ${t}`),t?this.updateFloorTypes():this.roomFloorType.clearFloorTypes()}),i=Yi(t.runtime,"showRoomProperty",t=>{Qg.log(`[runtime] showRoomProperty: ${t}`),this.updateAllRoomPropertyVisibility()}),n=Yi(t.runtime,"showRoomOrder",t=>{Qg.log(`[runtime] showRoomOrder: ${t}`),this.updateAllRoomPropertyVisibility()}),s=Yi(t.runtime,"roomPropertyFoldIds",t=>{Qg.log(`[runtime] roomPropertyFoldIds: ${t}`),this.updateAllRoomPropertyVisibility()}),r=Yi(t.runtime,"showRoomName",t=>{Qg.log(`[runtime] showRoomName: ${t}`),this.updateAllRoomNameVisibility(t)}),o=Yi(t.runtime,"enableRoomSelection",t=>{Qg.log(`[runtime] enableRoomSelection: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),a=Yi(t.runtime,"selectRoomIds",t=>{Qg.log(`[runtime] selectRoomIds: ${t}`),this.updateAllRoomSelectionIndicatorVisibility()}),h=Yi(t.runtime,"roomSelectionMode",t=>{Qg.log(`[runtime] roomSelectionMode: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()});this.unsubscribeFns.push(e,i,n,s,r,o,a,h)}drawRoomProperty(t){const e=Zi();return this.roomDisplayMap.clear(),t.forEach((t,i)=>{const n=e.mapManager.getRoomById(t.id),s={...t,centerPoint:n?.centerPoint||null,index:i};this.roomDisplayMap.set(t.id,s)}),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 Ex(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=Zi();this.roomFloorType.clearFloorTypes(),this.roomDisplayMap.forEach((e,i)=>{const n=t.mapManager.getRoomById(i),s=n?.centerPoint||null;if(e.centerPoint!==s){e.centerPoint=s;const t=this.roomInfoMap.get(i);t&&s&&t.updatePosition(s)}}),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()})}async updateFloorTypes(){const t=Zi(),e=t.mapManager.roomFill.getRoomGraphicsMap();e.size>0&&(await this.roomFloorType.createFloorTypes(e),t.getApp().renderOnceNextFrame())}destroy(){this.clearRoomInfos(),this.roomInfoContainer.destroy(),this.roomFloorType.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}navigator?.userAgent?.includes("tuya-ark-ide")||navigator?.userAgent?.includes("miniProgram");const kx=()=>{if(!Lr.any)return!0;const t=navigator.userAgent.toLowerCase();let e=!1;if(/iphone|ipad|ipod/.test(t)){const i=t.match(/os (\d+)_/)?.[1];e=(i?parseInt(i):0)>=12}else if(/android/.test(t)){const i=t.match(/android (\d+)/)?.[1];e=(i?parseInt(i):0)>=10}return e&&(()=>{const t=navigator.deviceMemory;return!t||t>=4})()};class Rx extends Po{mapState=null;components={};managers={};config=Xm;runtime;scaleMin=.5;scaleMax=5;events={};instanceKey;containerElement;emitter=function(t){return{all:t=t||new Map,on:function(e,i){var n=t.get(e);n?n.push(i):t.set(e,[i])},off:function(e,i){var n=t.get(e);n&&(i?n.splice(n.indexOf(i)>>>0,1):t.set(e,[]))},emit:function(e,i){var n=t.get(e);n&&n.slice().map(function(t){t(i)}),(n=t.get("*"))&&n.slice().map(function(t){t(e,i)})}}}();tickerState={renderReasons:new Set,renderTimer:null};pendingAsyncRender=!1;isFirstMapDraw=!0;constructor(t=Qm){super(),this.instanceKey=t,ty.registerInstance(t,this),globalThis.__PIXI_APP__=this}async initialize(t){return ty.provideAsync(this,async()=>{const{resizeTo:e,events:i,config:n,runtime:s={},...r}=t;this.config=_g(this.config,n??{}),this.runtime=Wi(Object.assign({},Ym,s));const o=this.instanceKey===Qm;this.containerElement=e;const a=o?{textureGCMaxIdle:Lr.any?180:3600,textureGCCheckCountMax:Lr.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}};await this.init({resizeTo:o?e:void 0,preferWebGLVersion:2,resolution:window.devicePixelRatio||1,antialias:kx(),autoDensity:!0,backgroundColor:this.config.global.backgroundColor,...a,...r}),this.preloadAssets(),this.scaleMax=this.config.interaction.zoomRange.max,this.scaleMin=this.config.interaction.zoomRange.min,this.events=i,this.initializeViewportContainer(),this.initializeInteraction(),this.initializeAppContainer(),this.managers.mapManager=new ox,this.managers.heatmapManager=new px,this.managers.pathManager=new dx,this.managers.controlsManager=new _x,this.managers.detectedObjectManager=new wx,this.managers.customElementsManager=new Ax,this.managers.roomsManager=new Ox,document.addEventListener("visibilitychange",this.onVisibilityChange)})}async drawMap(t){return ty.provideAsync(this,async()=>{Qg.log("[Map] drawMap",t);const{size:e,resolution:i,origin:n}=t;n[0]===this.mapState?.origin.x&&n[1]===this.mapState?.origin.y||(this.managers.pathManager.updatePositionByOrigin(...n),this.managers.controlsManager.updatePositionByOrigin(...n),this.managers.detectedObjectManager.updatePositionByOrigin(...n),this.managers.customElementsManager.updatePositionByOrigin(...n)),this.mapState={id:t.id,status:1===t.status,origin:{x:n[0],y:n[1]},charger:{x:t.charger.coordinate[0],y:t.charger.coordinate[1]},chargerDirection:t.charger.angle??0,resolution:i,width:e[0],height:e[1]},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,this.events?.onMapFirstDrawed?.(this.mapState)),this.events?.onMapDrawed?.(this.mapState),await this.managers.mapManager.drawMap(t),this.renderOnce()})}async drawRasterMap(t){return ty.provideAsync(this,async()=>{Qg.log("[Map] drawRasterMap",t);const{mapHeader:e,mapData:i}=t,{originX:n,originY:s}=e;n===this.mapState?.origin.x&&s===this.mapState?.origin.y||(this.managers.pathManager.updatePositionByOrigin(n,s),this.managers.controlsManager.updatePositionByOrigin(n,s),this.managers.detectedObjectManager.updatePositionByOrigin(n,s),this.managers.customElementsManager.updatePositionByOrigin(n,s)),this.mapState={id:e.id,status:e.mapStable,origin:{x:n,y:s},charger:{x:e.chargeX,y:e.chargeY},chargerDirection:e.chargeDirection??0,resolution:100*e.mapResolution,width:e.mapWidth,height:e.mapHeight,version:e.version},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,this.events?.onMapFirstDrawed?.(this.mapState)),this.events?.onMapDrawed?.(this.mapState),await this.managers.mapManager.drawRasterMap(i.parsed,this.mapState),this.renderOnce()})}drawPath(t){return ty.provide(this,()=>{Qg.log("[Path] drawPath",t),this.events?.onPathDrawed?.({id:t.pathHeader.pathId,type:t.pathHeader.type,direction:t.pathHeader.direction,count:t.pathHeader.count,initFlag:t.pathHeader.initFlag,robotPosition:t.pathPoints[t.pathPoints.length-1]??null}),this.managers.pathManager.draw(t),this.renderOnce()})}async drawRoomProperty(t){return ty.provide(this,()=>{Qg.log("[Room] drawRoomProperty",t),this.events?.onRoomPropertiesDrawed?.(t),this.managers.roomsManager.drawRoomProperty(t),this.renderOnceNextFrame()})}drawHeatmap({mapData:t,heatmapPoints:e,useGradient:i=!0}){return ty.provide(this,()=>{Qg.log("[Heatmap] drawHeatmap",e),this.managers.heatmapManager.draw({mapData:t,heatmapPoints:e,useGradient:i}),this.renderOnce()})}drawForbiddenSweepZones(t){return ty.provide(this,()=>{Qg.log("[Controls] drawForbiddenSweepZones",t),this.managers.controlsManager.drawForbiddenSweepZones(t),this.renderOnceNextFrame()})}drawForbiddenMopZones(t){return ty.provide(this,()=>{Qg.log("[Controls] drawForbiddenMopZones",t),this.managers.controlsManager.drawForbiddenMopZones(t),this.renderOnceNextFrame()})}drawCleanZones(t){return ty.provide(this,()=>{Qg.log("[Controls] drawCleanZones",t),this.managers.controlsManager.drawCleanZones(t),this.renderOnceNextFrame()})}drawVirtualWalls(t){return ty.provide(this,()=>{Qg.log("[Controls] drawVirtualWalls",t),this.managers.controlsManager.drawVirtualWalls(t),this.renderOnceNextFrame()})}drawSpots(t){return ty.provide(this,()=>{Qg.log("[Controls] drawSpots",t),this.managers.controlsManager.drawSpots(t),this.renderOnceNextFrame()})}async drawDetectedObjects(t){return ty.provideAsync(this,async()=>{Qg.log("[DetectedObject] drawDetectedObjects",t),await this.managers.detectedObjectManager.drawDetectedObjects(t),this.renderOnceNextFrame()})}async drawCustomElements(t){return ty.provideAsync(this,async()=>{Qg.log("[CustomElements] drawCustomElements",t),await this.managers.customElementsManager.drawCustomElements(t),this.renderOnceNextFrame()})}getForbiddenSweepZones(){return this.managers.controlsManager.getForbiddenSweepZones()}getForbiddenMopZones(){return this.managers.controlsManager.getForbiddenMopZones()}getCleanZones(){return this.managers.controlsManager.getCleanZones()}getVirtualWalls(){return this.managers.controlsManager.getVirtualWalls()}getSpots(){return this.managers.controlsManager.getSpots()}getEffectiveDividerPoints(){return this.managers.controlsManager.getEffectiveDividerPoints()}getDividerEndPoints(){return this.managers.controlsManager.getDividerEndPoints()}resetPanZoom(){this.components.interaction.setPanZoom()}fitMapToView(t,e=!1){return ty.provide(this,()=>{if(!t||t.minX===t.maxX||t.minY===t.maxY)return void Qg.warn("地图边界无效,无法自动适配视图");const i=this.config.map.autoPaddingPercent||.1,n=this.getViewportBounds(),s=t.maxX-t.minX,r=t.maxY-t.minY,o=n.width,a=n.height,h=o*(1-2*i)/s,l=a*(1-2*i)/r,c=Math.min(h,l),d=Math.max(this.config.interaction.fitMinScale,this.scaleMin),u=Math.min(this.config.interaction.fitMaxScale,this.scaleMax),p=Math.max(d,Math.min(u,c)),f=o/2-(t.minX+s/2)*p,g=a/2-(t.minY+r/2)*p;this.components.interaction.setPanZoom({targetPosition:{x:f,y:g},targetScale:{x:p,y:p},setCenter:!0,setScale:!0},e)})}getViewportBounds(){return this.components.viewportContainer?.getViewportBounds()||{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}updateRuntime(t){Object.assign(this.runtime,t),this.renderOnceNextFrame()}metersToPixels(t){return this.mapState?.resolution?t*(1/(this.mapState.resolution/100)):(Qg.warn("Map resolution not available, using default resolution (5cm/pixel)"),20*t)}pixelsToMeters(t){return this.mapState?.resolution?t*(this.mapState.resolution/100):(Qg.warn("Map resolution not available, using default resolution (5cm/pixel)"),.05*t)}toFixedSize(t,e){return t/(e??this.components.appContainer.scale.x)}fromFixedSize(t,e){return t*(e??this.components.appContainer.scale.x)}getViewportCenterPoint(){if(!this.mapState)return Qg.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,s=n.scale.x,r=(e-n.x)/s,o=(i-n.y)/s;return{x:r-this.mapState.origin.x,y:o-this.mapState.origin.y}}getMapCenterPoint(){if(!this.mapState)return Qg.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 Qg.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:s=0}=t||{},r=this.getViewportCenterPoint()||{x:0,y:0},o=this.metersToPixels(e);return Mm(r.x,r.y,o,i).map(t=>({x:t.x+n,y:t.y+s}))}getForbiddenSweepZonePointsByViewportCenter(t){const e=this.config.controls.forbiddenSweepZone,{size:i=e.minSize,offsetX:n=0,offsetY:s=0}=t||{};return this.generateZonePoints(i,n,s)}getForbiddenMopZonePointsByViewportCenter(t){const e=this.config.controls.forbiddenMopZone,{size:i=e.minSize,offsetX:n=0,offsetY:s=0}=t||{};return this.generateZonePoints(i,n,s)}getCleanZonePointsByViewportCenter(t){const e=this.config.controls.cleanZone,{size:i=e.minSize,offsetX:n=0,offsetY:s=0}=t||{};return this.generateZonePoints(i,n,s)}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}}async snapshot(){this.render(),await new Promise(t=>setTimeout(t,0));const{snapshot:t}=this.config;return await this.renderer.extract.base64({target:this.components.appContainer,format:t.format,quality:t.quality,resolution:t.resolution,antialias:t.antialias})}async snapshotByData({map:t,path:e,roomProperties:i,customElements:n,forbiddenSweepZones:s,forbiddenMopZones:r,virtualWalls:o,detectedObjects:a},h={}){const l=`SNAPSHOT_${((t=21)=>{let e="",i=0|t;for(;i--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return e})()}`;Qg.log(`[MapApplication] ${l} snapshot start`);const c=new Rx(l);try{if(await c.initialize({config:this.config,runtime:h}),!t)throw new Error("Map data is required");if(t.startsWith("7b22")){const{decodeMapStructured:e}=await Promise.resolve().then(()=>Kg),i=e(t);await c.drawMap(i)}else{const{decodeMap:e}=await Promise.resolve().then(()=>Kg),i=e(t);if(!i)throw new Error("Failed to decode raster map data");await c.drawRasterMap(i)}if(e){const{decodePath:t}=await Promise.resolve().then(()=>Kg),i=t(e);c.drawPath(i)}i&&i.length>0&&c.drawRoomProperty(i),s&&s.length>0&&c.drawForbiddenSweepZones(s),r&&r.length>0&&c.drawForbiddenMopZones(r),o&&o.length>0&&c.drawVirtualWalls(o),a&&a.length>0&&await c.drawDetectedObjects(a),n&&n.length>0&&await c.drawCustomElements(n);const d=await c.snapshot();return Qg.log(`[MapApplication] ${l} snapshot completed successfully`),d}catch(t){throw Qg.error(`[MapApplication] ${l} snapshot other map failed:`,t),t}finally{Qg.log(`[MapApplication] ${l} destroy`),c.destroy()}}renderOnce(){Qg.log("[Pixi] renderOnce"),this.render()}renderOnceNextFrame(){this.pendingAsyncRender||(this.pendingAsyncRender=!0,requestAnimationFrame(()=>{Qg.log("[Pixi] renderOnceNextFrame"),this.render(),this.pendingAsyncRender=!1}))}requestRender(t,e=!1){e?(this.tickerState.renderReasons.add(t),this.ticker.started||(Qg.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(){ty.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 iy(this.config,this.containerElement),this.stage.addChild(this.components.viewportContainer)}initializeAppContainer(){this.components.appContainer=new xy,this.components.interaction.addChild(this.components.appContainer)}initializeInteraction(){this.components.interaction=new Tm,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&&(Qg.debug("⏸️ [Ticker] STOP"),this.ticker.stop())},e)}generateZonePoints(t,e,i){const n=this.getViewportCenterPoint()||{x:0,y:0},s=this.metersToPixels(t)/2,r=n.x+e,o=n.y+i;return[{x:r-s,y:o-s},{x:r+s,y:o-s},{x:r+s,y:o+s},{x:r-s,y:o+s}]}preloadAssets(){const t=this.config.robot.icon.src,e=this.config.chargingStation.icon.src,i=[];al.add({alias:"robot",src:t}),i.push("robot"),al.add({alias:"chargingStation",src:e}),i.push("chargingStation"),al.add({alias:"deleteIcon",src:this.config.controls.deleteIconSrc}),i.push("deleteIcon"),al.add({alias:"rotateIcon",src:this.config.controls.rotateIconSrc}),i.push("rotateIcon"),al.add({alias:"scaleIcon",src:this.config.controls.scaleIconSrc}),i.push("scaleIcon"),al.add({alias:"moveIcon",src:this.config.controls.moveIconSrc}),i.push("moveIcon"),al.add({alias:"checkmark",src:this.config.room.selectionIndicator.iconSrc}),i.push("checkmark"),al.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}`;al.add({alias:n,src:t}),i.push(n)}),this.config.room.property.suction.assets.forEach((t,e)=>{const n=`fan_${e}`;al.add({alias:n,src:t}),i.push(n)}),this.config.room.property.cistern.assets.forEach((t,e)=>{const n=`water_${e}`;al.add({alias:n,src:t}),i.push(n)}),this.config.room.property.cleanTimes.assets.forEach((t,e)=>{const n=`cleanTimes${e+1}`;al.add({alias:n,src:t}),i.push(n)}),al.backgroundLoad(i)}onVisibilityChange=()=>{"visible"===document.visibilityState||this.components.interaction?.clearTouches()}}$i.add(Gr),$i.mixin(Hs,{accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1}),$i.add(Eo),$i.add(Bo),$i.add(_l),$i.mixin(Hs,vl),$i.add(cl),$i.add(Ru),$i.add(Ka),$i.add(Gu),$i.add(Zu),$i.add(Ju),$i.add(wp),$i.add(vp),$i.add(fp),$i.add(bp),$i.add(mp),$i.add(rp),$i.add(qu),$i.add(Il),$i.add(wl);const Dx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Fx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{ty as AppContext,Km as MAP_API_METHODS,qm as MAP_CALLBACK_METHODS,Rx as MapApplication,qg as decodeRoomProperties,Zi as useAppService};
|
|
1
|
+
function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function e(t="default"){return void 0===An[t]&&(An[t]=-1),++An[t]}function i(t,e,i=3){if(In[e])return;let n=(new Error).stack;void 0===n||(n=n.split("\n").splice(i).join("\n"),console.groupCollapsed),In[e]=!0}function n(t){return t+=0===t?1:0,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,1+((t|=t>>>8)|t>>>16)}function s(t){return!(t&t-1||!t)}function r(t){const e={};for(const i in t)void 0!==t[i]&&(e[i]=t[i]);return e}function o(t,e,i){const{width:n,height:s}=i.orig,r=i.trim;if(r){const i=r.width,o=r.height;t.minX=r.x-e._x*n,t.maxX=t.minX+i,t.minY=r.y-e._y*s,t.maxY=t.minY+o}else t.minX=-e._x*n,t.maxX=t.minX+n,t.minY=-e._y*s,t.maxY=t.minY+s}function a(...t){500!==fs&&fs++}function h(t,e,i){const n=t.length;let s;if(e>=n||0===i)return;const r=n-(i=e+i>n?n-e:i);for(s=e;s<r;++s)t[s]=t[s+i];t.length=r}function l(t,e,i){let n,s;return i.clear(),t.parent?e?n=t.parent.worldTransform:(s=Ss.get().identity(),n=d(t,s)):n=un.IDENTITY,c(t,i,n,e),s&&Ss.return(s),i.isValid||i.set(0,0,0,0),i}function c(t,e,i,n){if(!t.visible||!t.measurable)return;let s;n?s=t.worldTransform:(t.updateLocalTransform(),s=Ss.get(),s.appendFrom(t.localTransform,i));const r=e,o=!!t.effects.length;if(o&&(e=As.get().clear()),t.boundsArea)e.addRect(t.boundsArea,s);else{t.bounds&&(e.matrix=s,e.addBounds(t.bounds));for(let i=0;i<t.children.length;i++)c(t.children[i],e,s,n)}if(o){for(let i=0;i<t.effects.length;i++)t.effects[i].addBounds?.(e);r.addBounds(e,un.IDENTITY),As.return(e)}n||Ss.return(s)}function d(t,e){const i=t.parent;return i&&(d(i,e),i.updateLocalTransform(),e.append(i.localTransform)),e}function u(t,e){return 16777215!==t&&e?16777215!==e&&t?((t>>16&255)*(e>>16&255)/255<<16)+((t>>8&255)*(e>>8&255)/255<<8)+((255&t)*(255&e)/255|0):t:e}function p(t,e){return t===Ts?e:e===Ts?t:u(t,e)}function f(t){return((255&t)<<16)+(65280&t)+(t>>16&255)}function g(t,e,i){return e.clear(),i||(i=un.IDENTITY),m(t,e,i,t,!0),e.isValid||e.set(0,0,0,0),e}function m(t,e,i,n,s){let r;if(s)r=Ss.get(),r=i.copyTo(r);else{if(!t.visible||!t.measurable)return;t.updateLocalTransform();const e=t.localTransform;r=Ss.get(),r.appendFrom(e,i)}const o=e,a=!!t.effects.length;if(a&&(e=As.get().clear()),t.boundsArea)e.addRect(t.boundsArea,r);else{t.renderPipeId&&(e.matrix=r,e.addBounds(t.bounds));const i=t.children;for(let t=0;t<i.length;t++)m(i[t],e,r,n,!1)}if(a){for(let i=0;i<t.effects.length;i++)t.effects[i].addLocalBounds?.(e,n);o.addBounds(e,un.IDENTITY),As.return(e)}Ss.return(r)}function y(t,e){const i=t.children;for(let t=0;t<i.length;t++){const n=i[t],s=n.uid,r=(65535&n._didViewChangeTick)<<16|65535&n._didContainerChangeTick,o=e.index;e.data[o]===s&&e.data[o+1]===r||(e.data[e.index]=s,e.data[e.index+1]=r,e.didChange=!0),e.index=o+2,n.children.length&&y(n,e)}return e.didChange}function x(t,e){return t._zIndex-e._zIndex}function b(t,e,i){const n=Zs;t.measurable=!0,l(t,i,n),e.addBoundsMask(n),t.measurable=!1}function _(t,e,i){const n=As.get();t.measurable=!0;const s=Ss.get().identity();g(t,n,v(t,i,s)),t.measurable=!1,e.addBoundsMask(n),Ss.return(s),As.return(n)}function v(t,e,i){return t?(t!==e&&(v(t.parent,e,i),t.updateLocalTransform(),i.append(t.localTransform)),i):(a(),i)}async function w(){return nr??(nr=(async()=>{const t=qs.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await 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(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const s=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,s),t.deleteFramebuffer(n),t.deleteTexture(i),t.getExtension("WEBGL_lose_context")?.loseContext(),s[0]<=s[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),nr}function C(t={}){const e=t&&t.resource,i=e?t.resource:t,n=e?t:{resource:t};for(let t=0;t<lr.length;t++){const e=lr[t];if(e.test(i))return new e(n)}throw new Error(`Could not find a source type for resource: ${n.resource}`)}function S(t){if("string"!=typeof t)throw new TypeError(`Path must be a string. Received ${JSON.stringify(t)}`)}function A(t){return t.split("?")[0].split("#")[0]}function I(t,e,i,n,s){const r=e[i];for(let o=0;o<r.length;o++){const a=r[o];i<e.length-1?I(t.replace(n[i],a),e,i+1,n,s):s.push(t.replace(n[i],a))}}function M(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)}),I(t,n,0,e,i)}else i.push(t);return i}function T(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=dr.dirname(t[0]);e.linkedSheets.forEach((t,s)=>{const r=T([`${i}/${e.data.meta.related_multi_packs[s]}`],t,!0);Object.assign(n,r)})}return n}function P(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 s=function(t){return function(e){return e.test(t)}}(i),r={apple:{phone:s(vr)&&!s(Pr),ipod:s(wr),tablet:!s(vr)&&(s(Cr)||Fr(e))&&!s(Pr),universal:s(Sr),device:(s(vr)||s(wr)||s(Cr)||s(Sr)||Fr(e))&&!s(Pr)},amazon:{phone:s(Mr),tablet:!s(Mr)&&s(Tr),device:s(Mr)||s(Tr)},android:{phone:!s(Pr)&&s(Mr)||!s(Pr)&&s(Ar),tablet:!s(Pr)&&!s(Mr)&&!s(Ar)&&(s(Tr)||s(Ir)),device:!s(Pr)&&(s(Mr)||s(Tr)||s(Ar)||s(Ir))||s(/\bokhttp\b/i)},windows:{phone:s(Pr),tablet:s(Er),device:s(Pr)||s(Er)},other:{blackberry:s(Br),blackberry10:s(Or),opera:s(kr),firefox:s(Dr),chrome:s(Rr),device:s(Br)||s(Or)||s(kr)||s(Dr)||s(Rr)},any:!1,phone:!1,tablet:!1};return r.any=r.apple.device||r.android.device||r.windows.device||r.other.device,r.phone=r.apple.phone||r.android.phone||r.windows.phone,r.tablet=r.apple.tablet||r.android.tablet||r.windows.tablet,r}function E(t,e){let i=Nr[t];return void 0===i&&(void 0===Ur[e]&&(Ur[e]=1),Nr[t]=i=Ur[e]++),i}function B(){if(!zr||zr?.isContextLost()){const t=qs.get().createCanvas();zr=t.getContext("webgl",{})}return zr}function O(){if(!Hr){Hr="mediump";const t=B();if(t&&t.getShaderPrecisionFormat){const e=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT);Hr=e.precision?"highp":"mediump"}}return Hr}function k(t){return Kr[t]??Kr.float32}function R(t){const e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,s=/:\s*(\w+)/,r=/(\w+)\s*:\s*([\w\<\>]+)/g,o=/struct\s+(\w+)/,a=t.match(/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g)?.map(t=>({group:parseInt(t.match(e)[1],10),binding:parseInt(t.match(i)[1],10),name:t.match(n)[2],isUniform:"<uniform>"===t.match(n)[1],type:t.match(s)[1]}));if(!a)return{groups:[],structs:[]};const h=t.match(/struct\s+(\w+)\s*{([^}]+)}/g)?.map(t=>{const e=t.match(o)[1],i=t.match(r).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})=>a.some(e=>e.type===t))??[];return{groups:a,structs:h}}function D(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}function F(){if("boolean"==typeof go)return go;try{const t=new Function("param1","param2","param3","return param1[param2] === param3;");go=!0===t({a:"b"},"a","b")}catch(t){go=!1}return go}function L(t,e,i=2){const n=e&&e.length,s=n?e[0]*i:t.length;let r=j(t,0,s,i,!0);const o=[];if(!r||r.next===r.prev)return o;let a,h,l;if(n&&(r=function(t,e,i,n){const s=[];for(let i=0,r=e.length;i<r;i++){const o=j(t,e[i]*n,i<r-1?e[i+1]*n:t.length,n,!1);o===o.next&&(o.steiner=!0),s.push(Y(o))}s.sort(W);for(let t=0;t<s.length;t++)i=Z(s[t],i);return i}(t,e,r,i)),t.length>80*i){a=t[0],h=t[1];let e=a,n=h;for(let r=i;r<s;r+=i){const i=t[r],s=t[r+1];i<a&&(a=i),s<h&&(h=s),i>e&&(e=i),s>n&&(n=s)}l=Math.max(e-a,n-h),l=0!==l?32767/l:0}return U(r,o,i,a,h,l,0),o}function j(t,e,i,n,s){let r;if(s===function(t,e,i,n){let s=0;for(let r=e,o=i-n;r<i;r+=n)s+=(t[o]-t[r])*(t[r+1]+t[o+1]),o=r;return s}(t,e,i,n)>0)for(let s=e;s<i;s+=n)r=ot(s/n|0,t[s],t[s+1],r);else for(let s=i-n;s>=e;s-=n)r=ot(s/n|0,t[s],t[s+1],r);return r&&tt(r,r.next)&&(at(r),r=r.next),r}function G(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!tt(n,n.next)&&0!==$(n.prev,n,n.next))n=n.next;else{if(at(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function U(t,e,i,n,s,r,o){if(!t)return;!o&&r&&function(t,e,i,n){let s=t;do{0===s.z&&(s.z=X(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){let e,i=1;do{let n,s=t;t=null;let r=null;for(e=0;s;){e++;let o=s,a=0;for(let t=0;t<i&&(a++,o=o.nextZ,o);t++);let h=i;for(;a>0||h>0&&o;)0!==a&&(0===h||!o||s.z<=o.z)?(n=s,s=s.nextZ,a--):(n=o,o=o.nextZ,h--),r?r.nextZ=n:t=n,n.prevZ=r,r=n;s=o}r.nextZ=null,i*=2}while(e>1)}(s)}(t,n,s,r);let a=t;for(;t.prev!==t.next;){const h=t.prev,l=t.next;if(r?z(t,n,s,r):N(t))e.push(h.i,t.i,l.i),at(t),t=l.next,a=l.next;else if((t=l)===a){o?1===o?U(t=H(G(t),e),e,i,n,s,r,2):2===o&&V(t,e,i,n,s,r):U(G(t),e,i,n,s,r,1);break}}}function N(t){const e=t.prev,i=t,n=t.next;if($(e,i,n)>=0)return!1;const s=e.x,r=i.x,o=n.x,a=e.y,h=i.y,l=n.y,c=Math.min(s,r,o),d=Math.min(a,h,l),u=Math.max(s,r,o),p=Math.max(a,h,l);let f=n.next;for(;f!==e;){if(f.x>=c&&f.x<=u&&f.y>=d&&f.y<=p&&q(s,a,r,h,o,l,f.x,f.y)&&$(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function z(t,e,i,n){const s=t.prev,r=t,o=t.next;if($(s,r,o)>=0)return!1;const a=s.x,h=r.x,l=o.x,c=s.y,d=r.y,u=o.y,p=Math.min(a,h,l),f=Math.min(c,d,u),g=Math.max(a,h,l),m=Math.max(c,d,u),y=X(p,f,e,i,n),x=X(g,m,e,i,n);let b=t.prevZ,_=t.nextZ;for(;b&&b.z>=y&&_&&_.z<=x;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==o&&q(a,c,h,d,l,u,b.x,b.y)&&$(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,_.x>=p&&_.x<=g&&_.y>=f&&_.y<=m&&_!==s&&_!==o&&q(a,c,h,d,l,u,_.x,_.y)&&$(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==o&&q(a,c,h,d,l,u,b.x,b.y)&&$(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=g&&_.y>=f&&_.y<=m&&_!==s&&_!==o&&q(a,c,h,d,l,u,_.x,_.y)&&$(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function H(t,e){let i=t;do{const n=i.prev,s=i.next.next;!tt(n,s)&&et(n,i,i.next,s)&&st(n,s)&&st(s,n)&&(e.push(n.i,i.i,s.i),at(i),at(i.next),i=t=s),i=i.next}while(i!==t);return G(i)}function V(t,e,i,n,s,r){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&Q(o,t)){let a=rt(o,t);return o=G(o,o.next),a=G(a,a.next),U(o,e,i,n,s,r,0),void U(a,e,i,n,s,r,0)}t=t.next}o=o.next}while(o!==t)}function W(t,e){let i=t.x-e.x;return 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)),i}function Z(t,e){const i=function(t,e){let i=e;const n=t.x,s=t.y;let r,o=-1/0;if(tt(t,i))return i;do{if(tt(t,i.next))return i.next;if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){const t=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>o&&(o=t,r=i.x<i.next.x?i:i.next,t===n))return r}i=i.next}while(i!==e);if(!r)return null;const a=r,h=r.x,l=r.y;let c=1/0;i=r;do{if(n>=i.x&&i.x>=h&&n!==i.x&&K(s<l?n:o,s,h,l,s<l?o:n,s,i.x,i.y)){const e=Math.abs(s-i.y)/(n-i.x);st(i,t)&&(e<c||e===c&&(i.x>r.x||i.x===r.x&&J(r,i)))&&(r=i,c=e)}i=i.next}while(i!==a);return r}(t,e);if(!i)return e;const n=rt(i,t);return G(n,n.next),G(i,i.next)}function J(t,e){return $(t.prev,t,e.prev)<0&&$(e.next,t,t.next)<0}function X(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Y(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 K(t,e,i,n,s,r,o,a){return(s-o)*(e-a)>=(t-o)*(r-a)&&(t-o)*(n-a)>=(i-o)*(e-a)&&(i-o)*(r-a)>=(s-o)*(n-a)}function q(t,e,i,n,s,r,o,a){return!(t===o&&e===a)&&K(t,e,i,n,s,r,o,a)}function Q(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&&et(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(st(t,e)&&st(e,t)&&function(t,e){let i=t,n=!1;const s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&($(t.prev,t,e.prev)||$(t,e.prev,e))||tt(t,e)&&$(t.prev,t,t.next)>0&&$(e.prev,e,e.next)>0)}function $(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function tt(t,e){return t.x===e.x&&t.y===e.y}function et(t,e,i,n){const s=nt($(t,e,i)),r=nt($(t,e,n)),o=nt($(i,n,t)),a=nt($(i,n,e));return s!==r&&o!==a||!(0!==s||!it(t,i,e))||!(0!==r||!it(t,n,e))||!(0!==o||!it(i,t,n))||!(0!==a||!it(i,e,n))}function it(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 nt(t){return t>0?1:t<0?-1:0}function st(t,e){return $(t.prev,t,t.next)<0?$(t,e,t.next)>=0&&$(t,t.prev,e)>=0:$(t,e,t.prev)<0||$(t,t.next,e)<0}function rt(t,e){const i=ht(t.i,t.x,t.y),n=ht(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function ot(t,e,i,n){const s=ht(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function at(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 ht(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function lt(t){return void 0!==vo||(vo=(()=>{const e={stencil:!0,failIfMajorPerformanceCaveat:t??Co.defaultOptions.failIfMajorPerformanceCaveat};try{if(!qs.get().getWebGLRenderingContext())return!1;let t=qs.get().createCanvas().getContext("webgl",e);const i=!!t?.getContextAttributes()?.stencil;if(t){const e=t.getExtension("WEBGL_lose_context");e&&e.loseContext()}return t=null,i}catch(t){return!1}})()),vo}async function ct(t={}){return void 0!==wo||(wo=await(async()=>{const e=qs.get().getNavigator().gpu;if(!e)return!1;try{const i=await e.requestAdapter(t);return await i.requestDevice(),!0}catch(t){return!1}})()),wo}function dt(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 t=i.length-1;t>=0;t--){let e=i[t].trim();/([\"\'])[^\'\"]+\1/.test(e)||ko.includes(e)||(e=`"${e}"`),i[t]=e}return`${t.fontStyle} ${t.fontVariant} ${t.fontWeight} ${e} ${i.join(",")}`}function ut(t,e){for(let i=0;i<e.length;i++){const n=e[i];t.addColorStop(n.offset,n.color)}}function pt(t,e){const i=qs.get().createCanvas(t,e),n=i.getContext("2d");return{canvas:i,context:n}}function ft(t,e,i,n,s,r){const o=s-i,a=r-n,h=o*o+a*a;let l,c,d=-1;0!==h&&(d=((t-i)*o+(e-n)*a)/h),d<0?(l=i,c=n):d>1?(l=s,c=r):(l=i+d*o,c=n+d*a);const u=t-l,p=e-c;return u*u+p*p}function gt(t,e,i){let n=2166136261;for(let i=0;i<e;i++)n^=t[i].uid,n=Math.imul(n,16777619),n>>>=0;return Ko[n]||function(t,e,i,n){const s={};let r=0;for(let i=0;i<n;i++){const n=i<e?t[i]:Fn.EMPTY.source;s[r++]=n.source,s[r++]=n.style}const o=new ro(s);return Ko[i]=o,o}(t,e,n,i)}function mt(t,e){const i=t.byteLength/8|0,n=new Float64Array(t,0,i);new Float64Array(e,0,i).set(n);const s=t.byteLength-8*i;if(s>0){const n=new Uint8Array(t,8*i,s);new Uint8Array(e,8*i,s).set(n)}}function yt(t,e){return"no-premultiply-alpha"===e.alphaMode&&Qo[t]||t}function xt(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 bt(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=ta.replace(/%forloop%/gi,xt(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}function _t(){return ra>0?sa[--ra]:new na}function vt(t){sa[ra++]=t}function wt(t,e){if(!(t instanceof ca)){let i=e?la.INDEX:la.VERTEX;t instanceof Array&&(e?(t=new Uint32Array(t),i=la.INDEX|la.COPY_DST):(t=new Float32Array(t),i=la.VERTEX|la.COPY_DST)),t=new ca({data:t,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:i})}return t}function Ct(t,e,i){if(t)for(const n in t){const s=e[n.toLocaleLowerCase()];if(s){let e=t[n];"header"===n&&(e=e.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),i&&s.push(`//----${i}----//`),s.push(e)}else a()}}function St(t){const e={};return(t.match(ga)?.map(t=>t.replace(/[{()}]/g,""))??[]).forEach(t=>{e[t]=[]}),e}function At(t,e){let i;const n=/@in\s+([^;]+);/g;for(;null!==(i=n.exec(t));)e.push(i[1])}function It(t,e,i=!1){const n=[];At(e,n),t.forEach(t=>{t.header&&At(t.header,n)});const s=n;i&&s.sort();const r=s.map((t,e)=>` @location(${e}) ${t},`).join("\n");let o=e.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`\n${r}\n`),o}function Mt(t,e){let i;const n=/@out\s+([^;]+);/g;for(;null!==(i=n.exec(t));)e.push(i[1])}function Tt(t,e){let i=t;for(const t in e){const n=e[t];i=n.join("\n").length?i.replace(`{{${t}}}`,`//-----${t} START-----//\n${n.join("\n")}\n//----${t} FINISH----//`):i.replace(`{{${t}}}`,"")}return i}function Pt({template:t,bits:e}){const i=Et(t,e);return ma[i]||(ma[i]=Bt(t.vertex,t.fragment,e)),ma[i]}function Et(t,e){return e.map(t=>(ya.has(t)||ya.set(t,xa++),ya.get(t))).sort((t,e)=>t-e).join("-")+t.vertex+t.fragment}function Bt(t,e,i){const n=St(t),s=St(e);return i.forEach(t=>{Ct(t.vertex,n,t.name),Ct(t.fragment,s,t.name)}),{vertex:Tt(t,n),fragment:Tt(e,s)}}function Ot({bits:t,name:e}){const i=function({template:t,bits:e}){const i=Et(t,e);if(ma[i])return ma[i];const{vertex:n,fragment:s}=function(t,e){const i=e.map(t=>t.vertex).filter(t=>!!t),n=e.map(t=>t.fragment).filter(t=>!!t);let s=It(i,t.vertex,!0);return s=function(t,e){const i=[];Mt(e,i),t.forEach(t=>{t.header&&Mt(t.header,i)});let n=0;const s=i.sort().map(t=>t.indexOf("builtin")>-1?t:`@location(${n++}) ${t}`).join(",\n"),r=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${s}\n`),a=a.replace("{{start}}",`\n${r}\n`),a=a.replace("{{return}}",`\n${o}\n`),a}(i,s),{vertex:s,fragment:It(n,t.fragment,!0)}}(t,e);return ma[i]=Bt(n,s,e),ma[i]}({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:[ba,...t]});return to.from({name:e,vertex:{source:i.vertex,entryPoint:"main"},fragment:{source:i.fragment,entryPoint:"main"}})}function kt({bits:t,name:e}){return new Yr({name:e,...Pt({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:[_a,...t]})})}function Rt(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 Dt(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 Ft(t){return Ca[t]||(Ca[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 ${Rt(t)}\n `,main:`\n var uvDx = dpdx(vUV);\n var uvDy = dpdy(vUV);\n\n ${Dt(t)}\n `}}),Ca[t]}function Lt(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 jt(t){return Sa[t]||(Sa[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 ${Lt(t)}\n `}}),Sa[t]}function Gt(t){let e=Ma[t];if(e)return e;const i=new Int32Array(t);for(let e=0;e<t;e++)i[e]=e;return e=Ma[t]=new so({uTextures:{value:i,type:"i32",size:t}},{isStatic:!0}),e}function Ut(t,e,i,n,s){const r=e.a,o=e.b,a=e.c,h=e.d,l=e.tx,c=e.ty;i||(i=0),n||(n=2),s||(s=t.length/n-i);let d=i*n;for(let e=0;e<s;e++){const e=t[d],i=t[d+1];t[d]=r*e+a*i+l,t[d+1]=o*e+h*i+c,d+=n}}function Nt(t,e,i,n,s,r,o,a){let h,l;o?(h=n,l=-i):(h=-n,l=i);const c=t-i*s+h,d=e-n*s+l,u=t+i*r+h,p=e+n*r+l;return a.push(c,d),a.push(u,p),2}function zt(t,e,i,n,s,r,o,a){const h=i-t,l=n-e;let c=Math.atan2(h,l),d=Math.atan2(s-t,r-e);a&&c<d?c+=2*Math.PI:!a&&c>d&&(d+=2*Math.PI);let u=c;const p=d-c,f=Math.abs(p),g=Math.sqrt(h*h+l*l),m=1+(15*f*Math.sqrt(g)/Math.PI|0),y=p/m;if(u+=y,a){o.push(t,e),o.push(i,n);for(let i=1,n=u;i<m;i++,n+=y)o.push(t,e),o.push(t+Math.sin(n)*g,e+Math.cos(n)*g);o.push(t,e),o.push(s,r)}else{o.push(i,n),o.push(t,e);for(let i=1,n=u;i<m;i++,n+=y)o.push(t+Math.sin(n)*g,e+Math.cos(n)*g),o.push(t,e);o.push(s,r),o.push(t,e)}return 2*m}function Ht(t,e,i,n,s,r,o){const a=mo(t,e,2);if(!a)return;for(let t=0;t<a.length;t+=3)r[o++]=a[t]+s,r[o++]=a[t+1]+s,r[o++]=a[t+2]+s;let h=s*n;for(let e=0;e<t.length;e+=2)i[h]=t[e],i[h+1]=t[e+1],h+=n}function Vt(t,e,i){const n=[],s=Va.rectangle,r=Wa;r.x=t.dx,r.y=t.dy,r.width=t.dw,r.height=t.dh;const o=t.transform;if(!s.build(r,n))return;const{vertices:a,uvs:h,indices:l}=i,c=l.length,d=a.length/2;o&&Ut(n,o),s.triangulate(n,a,2,d,l,c);const u=t.image,p=u.uvs;h.push(p.x0,p.y0,p.x1,p.y1,p.x3,p.y3,p.x2,p.y2);const f=ms.get(ka);f.indexOffset=c,f.indexSize=l.length-c,f.attributeOffset=d,f.attributeSize=a.length/2-d,f.baseColor=t.style,f.alpha=t.alpha,f.texture=u,f.geometryData=i,e.push(f)}function Wt(t,e,i,n,s){const{vertices:r,uvs:o,indices:a}=s;t.shapePrimitives.forEach(({shape:t,transform:h,holes:l})=>{const c=[],d=Va[t.type];if(!d.build(t,c))return;const u=a.length,p=r.length/2;let f="triangle-list";if(h&&Ut(c,h),i){const i=t.closePath??!0,n=e;n.pixelLine?(function(t,e,i,n){const s=La;if(0===t.length)return;const r=t[0],o=t[1],a=t[t.length-2],h=t[t.length-1],l=e||Math.abs(r-a)<s&&Math.abs(o-h)<s,c=i,d=t.length/2,u=c.length/2;for(let e=0;e<d;e++)c.push(t[2*e]),c.push(t[2*e+1]);for(let t=0;t<d-1;t++)n.push(u+t,u+t+1);l&&n.push(u+d-1,u)}(c,i,r,a),f="line-list"):function(t,e,i,n,s,r){const o=La;if(0===t.length)return;const a=e;let h=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,s=t[e-2],r=t[e-1];n<e;n+=2){const e=t[n],o=t[n+1];i+=(e-s)*(o+r),s=e,r=o}return i<0?-1:1}(t);h=(h-.5)*e+.5}const l=new cn(t[0],t[1]),c=new cn(t[t.length-2],t[t.length-1]),d=n,u=Math.abs(l.x-c.x)<o&&Math.abs(l.y-c.y)<o;if(d){t=t.slice(),u&&(t.pop(),t.pop(),c.set(t[t.length-2],t[t.length-1]));const e=.5*(l.x+c.x),i=.5*(c.y+l.y);t.unshift(e,i),t.push(e,i)}const p=s,f=t.length/2;let g=t.length;const m=p.length/2,y=a.width/2,x=y*y,b=a.miterLimit*a.miterLimit;let _=t[0],v=t[1],w=t[2],C=t[3],S=0,A=0,I=-(v-C),M=_-w,T=0,P=0,E=Math.sqrt(I*I+M*M);I/=E,M/=E,I*=y,M*=y;const B=2*(1-h),O=2*h;d||("round"===a.cap?g+=zt(_-I*(B-O)*.5,v-M*(B-O)*.5,_-I*B,v-M*B,_+I*O,v+M*O,p,!0)+2:"square"===a.cap&&(g+=Nt(_,v,I,M,B,O,!0,p))),p.push(_-I*B,v-M*B),p.push(_+I*O,v+M*O);for(let e=1;e<f-1;++e){_=t[2*(e-1)],v=t[2*(e-1)+1],w=t[2*e],C=t[2*e+1],S=t[2*(e+1)],A=t[2*(e+1)+1],I=-(v-C),M=_-w,E=Math.sqrt(I*I+M*M),I/=E,M/=E,I*=y,M*=y,T=-(C-A),P=w-S,E=Math.sqrt(T*T+P*P),T/=E,P/=E,T*=y,P*=y;const i=w-_,n=v-C,s=w-S,r=A-C,o=i*s+n*r,h=n*s-r*i,l=h<0;if(Math.abs(h)<.001*Math.abs(o)){p.push(w-I*B,C-M*B),p.push(w+I*O,C+M*O),o>=0&&("round"===a.join?g+=zt(w,C,w-I*B,C-M*B,w-T*B,C-P*B,p,!1)+4:g+=2,p.push(w-T*O,C-P*O),p.push(w+T*B,C+P*B));continue}const c=(-I+_)*(-M+C)-(-I+w)*(-M+v),d=(-T+S)*(-P+C)-(-T+w)*(-P+A),u=(i*d-s*c)/h,f=(r*c-n*d)/h,m=(u-w)*(u-w)+(f-C)*(f-C),k=w+(u-w)*B,R=C+(f-C)*B,D=w-(u-w)*O,F=C-(f-C)*O,L=l?B:O;m<=Math.min(i*i+n*n,s*s+r*r)+L*L*x?"bevel"===a.join||m/x>b?(l?(p.push(k,R),p.push(w+I*O,C+M*O),p.push(k,R),p.push(w+T*O,C+P*O)):(p.push(w-I*B,C-M*B),p.push(D,F),p.push(w-T*B,C-P*B),p.push(D,F)),g+=2):"round"===a.join?l?(p.push(k,R),p.push(w+I*O,C+M*O),g+=zt(w,C,w+I*O,C+M*O,w+T*O,C+P*O,p,!0)+4,p.push(k,R),p.push(w+T*O,C+P*O)):(p.push(w-I*B,C-M*B),p.push(D,F),g+=zt(w,C,w-I*B,C-M*B,w-T*B,C-P*B,p,!1)+4,p.push(w-T*B,C-P*B),p.push(D,F)):(p.push(k,R),p.push(D,F)):(p.push(w-I*B,C-M*B),p.push(w+I*O,C+M*O),"round"===a.join?g+=l?zt(w,C,w+I*O,C+M*O,w+T*O,C+P*O,p,!0)+2:zt(w,C,w-I*B,C-M*B,w-T*B,C-P*B,p,!1)+2:"miter"===a.join&&m/x<=b&&(l?(p.push(D,F),p.push(D,F)):(p.push(k,R),p.push(k,R)),g+=2),p.push(w-T*B,C-P*B),p.push(w+T*O,C+P*O),g+=2)}_=t[2*(f-2)],v=t[2*(f-2)+1],w=t[2*(f-1)],C=t[2*(f-1)+1],I=-(v-C),M=_-w,E=Math.sqrt(I*I+M*M),I/=E,M/=E,I*=y,M*=y,p.push(w-I*B,C-M*B),p.push(w+I*O,C+M*O),d||("round"===a.cap?g+=zt(w-I*(B-O)*.5,C-M*(B-O)*.5,w-I*B,C-M*B,w+I*O,C+M*O,p,!1)+2:"square"===a.cap&&(g+=Nt(w,C,I,M,B,O,!1,p)));for(let t=m;t<g+m-2;++t)_=p[2*t],v=p[2*t+1],w=p[2*(t+1)],C=p[2*(t+1)+1],S=p[2*(t+2)],A=p[2*(t+2)+1],Math.abs(_*(C-A)+w*(A-v)+S*(v-C))<1e-8||r.push(t,t+1,t+2)}(c,n,0,i,r,a)}else if(l){const t=[],e=c.slice();(function(t){const e=[];for(let i=0;i<t.length;i++){const n=t[i].shape,s=[];Va[n.type].build(n,s)&&e.push(s)}return e})(l).forEach(i=>{t.push(e.length/2),e.push(...i)}),Ht(e,t,r,2,p,a,u)}else d.triangulate(c,r,2,p,a,u);const g=o.length/2,m=e.texture;if(m!==Fn.WHITE){const i=function(t,e,i,n){const s=e.matrix?t.copyFrom(e.matrix).invert():t.identity();if("local"===e.textureSpace){const t=i.getBounds(Ha);e.width&&t.pad(e.width);const{x:n,y:r}=t,o=1/t.width,a=1/t.height,h=-n*o,l=-r*a,c=s.a,d=s.b,u=s.c,p=s.d;s.a*=o,s.b*=o,s.c*=a,s.d*=a,s.tx=h*c+l*u+s.tx,s.ty=h*d+l*p+s.ty}else s.translate(e.texture.frame.x,e.texture.frame.y),s.scale(1/e.texture.source.width,1/e.texture.source.height);const r=e.texture.source.style;return e.fill instanceof Go||"clamp-to-edge"!==r.addressMode||(r.addressMode="repeat",r.update()),n&&s.append(za.copyFrom(n).invert()),s}(Za,e,t,h);!function(t,e,i,n,s,r,o,a=null){let h=0;i*=e,s*=r;const l=a.a,c=a.b,d=a.c,u=a.d,p=a.tx,f=a.ty;for(;h<o;){const o=t[i],a=t[i+1];n[s]=l*o+d*a+p,n[s+1]=c*o+u*a+f,s+=r,i+=e,h++}}(r,2,p,o,g,2,r.length/2-p,i)}else!function(t,e,i,n){let s=0;for(e*=2;s<n;)t[e]=0,t[e+1]=0,e+=2,s++}(o,g,0,r.length/2-p);const y=ms.get(ka);y.indexOffset=u,y.indexSize=a.length-u,y.attributeOffset=p,y.attributeSize=r.length/2-p,y.baseColor=e.color,y.alpha=e.alpha,y.texture=m,y.geometryData=s,y.topology=f,n.push(y)})}function Zt(t,e,i,n,s,r,o,a,h,l){let c=(1-Math.min(.99,Math.max(0,l??Ka.defaultOptions.bezierSmoothness)))/1;return c*=c,function(t,e,i,n,s,r,o,a,h,l){Jt(t,e,i,n,s,r,o,a,h,l,0),h.push(o,a)}(e,i,n,s,r,o,a,h,t,c),t}function Jt(t,e,i,n,s,r,o,a,h,l,c){if(c>8)return;const d=(t+i)/2,u=(e+n)/2,p=(i+s)/2,f=(n+r)/2,g=(s+o)/2,m=(r+a)/2,y=(d+p)/2,x=(u+f)/2,b=(p+g)/2,_=(f+m)/2,v=(y+b)/2,w=(x+_)/2;if(c>0){let c=o-t,d=a-e;const u=Math.abs((i-o)*d-(n-a)*c),p=Math.abs((s-o)*d-(r-a)*c);if(u>qa&&p>qa){if((u+p)*(u+p)<=l*(c*c+d*d))return void h.push(v,w)}else if(u>qa){if(u*u<=l*(c*c+d*d))return void h.push(v,w)}else if(p>qa){if(p*p<=l*(c*c+d*d))return void h.push(v,w)}else if(c=v-(t+o)/2,d=w-(e+a)/2,c*c+d*d<=l)return void h.push(v,w)}Jt(t,e,d,u,y,x,v,w,h,l,c+1),Jt(v,w,b,_,g,m,o,a,h,l,c+1)}function Xt(t,e,i,n,s,r,o,a){let h=(1-Math.min(.99,Math.max(0,a??Ka.defaultOptions.bezierSmoothness)))/1;return h*=h,function(t,e,i,n,s,r,o,a){Yt(o,t,e,i,n,s,r,a,0),o.push(s,r)}(e,i,n,s,r,o,t,h),t}function Yt(t,e,i,n,s,r,o,a,h){if(h>8)return;const l=(e+n)/2,c=(i+s)/2,d=(n+r)/2,u=(s+o)/2,p=(l+d)/2,f=(c+u)/2;let g=r-e,m=o-i;const y=Math.abs((n-r)*m-(s-o)*g);if(y>1.1920929e-7){if(y*y<=a*(g*g+m*m))return void t.push(p,f)}else if(g=p-(e+r)/2,m=f-(i+o)/2,g*g+m*m<=a)return void t.push(p,f);Yt(t,e,i,l,c,p,f,a,h+1),Yt(t,p,f,d,u,r,o,a,h+1)}function Kt(t,e,i,n,s,r,o,a){let h=Math.abs(s-r);(!o&&s>r||o&&r>s)&&(h=2*Math.PI-h),a||(a=Math.max(6,Math.floor(6*Math.pow(n,1/3)*(h/Math.PI))));let l=h/(a=Math.max(a,3)),c=s;l*=o?-1:1;for(let s=0;s<a+1;s++){const s=e+Math.cos(c)*n,r=i+Math.sin(c)*n;t.push(s,r),c+=l}}function qt(t,e){const i=-1.5707963267948966===e?-.551915024494:4/3*Math.tan(e/4),n=1.5707963267948966===e?.551915024494:i,s=Math.cos(t),r=Math.sin(t),o=Math.cos(t+e),a=Math.sin(t+e);return[{x:s-r*n,y:r+s*n},{x:o+a*n,y:a-o*n},{x:o,y:a}]}function Qt(t,e){return t?t.prepend(e):e.clone()}function $t(t,e,i){const n=t.getAttribute(e);return n?Number(n):i}function te(t){const e=$t(t,"x1",0),i=$t(t,"y1",0),n=$t(t,"x2",1),s=$t(t,"y2",0),r=t.getAttribute("gradientUnits")||"objectBoundingBox",o=new Go(e,i,n,s,"objectBoundingBox"===r?"local":"global");for(let e=0;e<t.children.length;e++){const i=t.children[e],n=$t(i,"offset",0),s=ps.shared.setValue(i.getAttribute("stop-color")).toNumber();o.addColorStop(n,s)}return o}function ee(t){return a(),new Go(0,0,1,0)}function ie(t){const e=t.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}function ne(t,e){const i=t.getAttribute("style"),n={},s={},r={strokeStyle:n,fillStyle:s,useFill:!1,useStroke:!1};for(const i in rh){const n=t.getAttribute(i);n&&se(e,r,i,n.trim())}if(i){const t=i.split(";");for(let i=0;i<t.length;i++){const n=t[i].trim(),[s,o]=n.split(":");rh[s]&&se(e,r,s,o.trim())}}return{strokeStyle:r.useStroke?n:null,fillStyle:r.useFill?s:null,useFill:r.useFill,useStroke:r.useStroke}}function se(t,e,i,n){switch(i){case"stroke":if("none"!==n){if(n.startsWith("url(")){const i=ie(n);e.strokeStyle.fill=t.defs[i]}else e.strokeStyle.color=ps.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=ie(n);e.fillStyle.fill=t.defs[i]}else e.fillStyle.color=ps.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 re(t,e,i,n){const s=t.children,{fillStyle:r,strokeStyle:o}=ne(t,e);r&&i?i={...i,...r}:r&&(i=r),o&&n?n={...n,...o}:o&&(n=o);const h=!i&&!n;let l,c,d,u,p,f,g,m,y,x,b,_,v,w,C,S,A;switch(h&&(i={color:0}),t.nodeName.toLowerCase()){case"path":w=t.getAttribute("d"),"evenodd"===t.getAttribute("fill-rule")&&a(),C=new sh(w,!0),e.context.path(C),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"circle":g=$t(t,"cx",0),m=$t(t,"cy",0),y=$t(t,"r",0),e.context.ellipse(g,m,y,y),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"rect":l=$t(t,"x",0),c=$t(t,"y",0),S=$t(t,"width",0),A=$t(t,"height",0),x=$t(t,"rx",0),b=$t(t,"ry",0),x||b?e.context.roundRect(l,c,S,A,x||b):e.context.rect(l,c,S,A),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"ellipse":g=$t(t,"cx",0),m=$t(t,"cy",0),x=$t(t,"rx",0),b=$t(t,"ry",0),e.context.beginPath(),e.context.ellipse(g,m,x,b),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"line":d=$t(t,"x1",0),u=$t(t,"y1",0),p=$t(t,"x2",0),f=$t(t,"y2",0),e.context.beginPath(),e.context.moveTo(d,u),e.context.lineTo(p,f),n&&e.context.stroke(n);break;case"polygon":v=t.getAttribute("points"),_=v.match(/\d+/g).map(t=>parseInt(t,10)),e.context.poly(_,!0),i&&e.context.fill(i),n&&e.context.stroke(n);break;case"polyline":v=t.getAttribute("points"),_=v.match(/\d+/g).map(t=>parseInt(t,10)),e.context.poly(_,!1),n&&e.context.stroke(n);break;case"g":case"svg":break;default:a(t.nodeName)}h&&(i=null);for(let t=0;t<s.length;t++)re(s[t],e,i,n)}function oe(t){return t instanceof No}function ae(t){return t instanceof Go}function he(t,e,i){return t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,{...i,...t}}function le(t,e,i){return e.buildGradient(),t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,t.textureSpace=e.textureSpace,{...i,...t}}function ce(t,e){if(null==t)return null;const i={},n=t;return function(t){return ps.isColorLike(t)}(t)?function(t,e,i){const n=ps.shared.setValue(e??0);return t.color=n.toNumber(),t.alpha=1===n.alpha?i.alpha:n.alpha,t.texture=Fn.WHITE,{...i,...t}}(i,t,e):function(t){return t instanceof Fn}(t)?function(t,e,i){return t.texture=e,{...i,...t}}(i,t,e):oe(t)?he(i,t,e):ae(t)?le(i,t,e):n.fill&&oe(n.fill)?he(n,n.fill,e):n.fill&&ae(n.fill)?le(n,n.fill,e):function(t,e){const i={...e,...t},n=ps.shared.setValue(i.color);return i.alpha*=n.alpha,i.color=n.toNumber(),i}(n,e)}function de(t,e){const{width:i,alignment:n,miterLimit:s,cap:r,join:o,pixelLine:a,...h}=e,l=ce(t,h);return l?{width:i,alignment:n,miterLimit:s,cap:r,join:o,pixelLine:a,...l}:null}function ue(t,e,i){return t?(e[i++]=t.color,e[i++]=t.alpha,e[i++]=t.fill?.styleKey,i):i}function pe(t,e,i,n=0){if(t.texture===Fn.WHITE&&!t.fill)return ps.shared.setValue(t.color).setAlpha(t.alpha??1).toHexa();if(!t.fill){const i=e.createPattern(t.texture.source.resource,"repeat"),n=t.matrix.copyTo(un.shared);return n.scale(t.texture.frame.width,t.texture.frame.height),i.setTransform(n),i}if(t.fill instanceof No){const i=t.fill,n=e.createPattern(i.texture.source.resource,"repeat"),s=i.transform.copyTo(un.shared);return s.scale(i.texture.frame.width,i.texture.frame.height),n.setTransform(s),n}if(t.fill instanceof Go){const s=t.fill,r="linear"===s.type,o="local"===s.textureSpace;let a,h=1,l=1;o&&i&&(h=i.width+n,l=i.height+n);let c=!1;if(r){const{start:t,end:i}=s;a=e.createLinearGradient(t.x*h,t.y*l,i.x*h,i.y*l),c=Math.abs(i.x-t.x)<Math.abs(.1*(i.y-t.y))}else{const{center:t,innerRadius:i,outerCenter:n,outerRadius:r}=s;a=e.createRadialGradient(t.x*h,t.y*l,i*h,n.x*h,n.y*l,r*h)}if(c&&o&&i){const t=i.lineHeight/l;for(let e=0;e<i.lines.length;e++){const r=(e*i.lineHeight+n/2)/l;s.colorStops.forEach(e=>{const i=r+e.offset*t;a.addColorStop(Math.floor(i*fh)/fh,ps.shared.setValue(e.color).toHex())})}}else s.colorStops.forEach(t=>{a.addColorStop(t.offset,ps.shared.setValue(t.color).toHex())});return a}return a(),"red"}function fe(t,e,i,n){const s={width:0,height:0,offsetY:0,scale:e.fontSize/i.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};s.offsetY=i.baseLineOffset;let r=s.lines[0],o=null,a=!0;const h={width:0,start:0,index:0,positions:[],chars:[]},l=i.baseMeasurementFontSize/e.fontSize,c=e.letterSpacing*l,d=e.wordWrapWidth*l,u=e.lineHeight?e.lineHeight*l:i.lineHeight,p=e.wordWrap&&e.breakWords,f=t=>{const e=r.width;for(let i=0;i<h.index;i++){const n=t.positions[i];r.chars.push(t.chars[i]),r.charPositions.push(n+e)}r.width+=t.width,a=!1,h.width=0,h.index=0,h.chars.length=0},g=()=>{let t=r.chars.length-1;if(n){let e=r.chars[t];for(;" "===e;)r.width-=i.chars[e].xAdvance,e=r.chars[--t]}s.width=Math.max(s.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,s.lines.push(r),s.height+=u},m=t=>t-c>d;for(let n=0;n<t.length+1;n++){let s;const l=n===t.length;l||(s=t[n]);const d=i.chars[s]||i.chars[" "];if(/(?:\s)/.test(s)||"\r"===s||"\n"===s||l){if(!a&&e.wordWrap&&m(r.width+h.width)?(g(),f(h),l||r.charPositions.push(0)):(h.start=r.width,f(h),l||r.charPositions.push(0)),"\r"===s||"\n"===s)0!==r.width&&g();else if(!l){const t=d.xAdvance+(d.kerning[o]||0)+c;r.width+=t,r.spaceWidth=t,r.spacesIndex.push(r.charPositions.length),r.chars.push(s)}}else{const t=d.kerning[o]||0,e=d.xAdvance+t+c;p&&m(r.width+h.width+e)&&(f(h),g()),h.positions[h.index++]=h.width+t,h.chars.push(s),h.width+=e}o=s}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}}(s):"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}}(s):"justify"===e.align&&function(t){const e=t.width;for(let i=0;i<t.lines.length;i++){const n=t.lines[i];let s=0,r=n.spacesIndex[s++],o=0;const a=n.spacesIndex.length,h=(e-n.width)/a;for(let t=0;t<n.charPositions.length;t++)t===r&&(r=n.spacesIndex[s++],o+=h),n.charPositions[t]+=o}}(s),s}async function ge(t){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=await(await fetch(t)).blob();await createImageBitmap(e)}catch(t){return!1}return!0}return!1}function me(t){return!Eh&&""!==document.createElement("video").canPlayType(t)}function ye(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 xe(t,e){const i=t.split("?")[0],n=dr.extname(i).toLowerCase();return Array.isArray(e)?e.includes(n):n===e}function be(t){return zh.test(t)?t:encodeURI(t)}function _e(t,e=1){const i=pr.RETINA_PREFIX?.exec(t);return i?parseFloat(i[1]):e}function ve(t,e,i){t.label=i,t._sourceOrigin=i;const n=new Fn({source:t,label:i}),s=()=>{delete e.promiseCache[i],hr.has(i)&&hr.remove(i)};return n.source.once("destroy",()=>{e.promiseCache[i]&&(a(),s())}),n.once("destroy",()=>{t.destroyed||(a(),s())}),n}function we(t,e,i,n,s,r,o,a){const h=o-i,l=a-n,c=s-i,d=r-n,u=t-i,p=e-n,f=h*h+l*l,g=h*c+l*d,m=h*u+l*p,y=c*c+d*d,x=c*u+d*p,b=1/(f*y-g*g),_=(y*m-g*x)*b,v=(f*x-g*m)*b;return _>=0&&v>=0&&_+v<1}function Ce(t,e,i){for(let n=0,s=4*i*e;n<e;++n,s+=4)if(0!==t[s+3])return!1;return!0}function Se(t,e,i,n,s){const r=4*e;for(let e=n,o=n*r+4*i;e<=s;++e,o+=r)if(0!==t[o+3])return!1;return!0}function Ae(...t){let e=t[0];e.canvas||(e={canvas:t[0],resolution:t[1]});const{canvas:i}=e,s=Math.min(e.resolution??1,1),r=e.width??i.width,o=e.height??i.height;let a=e.output;if(function(t,e){Ll||(Ll=qs.get().createCanvas(256,128),jl=Ll.getContext("2d",{willReadFrequently:!0}),jl.globalCompositeOperation="copy",jl.globalAlpha=1),(Ll.width<t||Ll.height<e)&&(Ll.width=n(t),Ll.height=n(e))}(r,o),!jl)throw new TypeError("Failed to get canvas 2D context");jl.drawImage(i,0,0,r,o,0,0,r*s,o*s);const h=jl.getImageData(0,0,r,o).data;let l=0,c=0,d=r-1,u=o-1;for(;c<o&&Ce(h,r,c);)++c;if(c===o)return Sn.EMPTY;for(;Ce(h,r,u);)--u;for(;Se(h,r,l,c,u);)++l;for(;Se(h,r,d,c,u);)--d;return++d,++u,jl.globalCompositeOperation="source-over",jl.strokeRect(l,c,d-l,u-c),jl.globalCompositeOperation="copy",a??(a=new Sn),a.set(l/s,c/s,(d-l)/s,(u-c)/s),a}function Ie(t,e){for(const i in t.attributes){const n=t.attributes[i],s=e[i];s?(n.format??(n.format=s.format),n.offset??(n.offset=s.offset),n.instance??(n.instance=s.instance)):a()}!function(t){const{buffers:e,attributes:i}=t,n={},s={};for(const t in e){const i=e[t];n[i.uid]=0,s[i.uid]=0}for(const t in i){const e=i[t];n[e.buffer.uid]+=k(e.format).stride}for(const t in i){const e=i[t];e.stride??(e.stride=n[e.buffer.uid]),e.start??(e.start=s[e.buffer.uid]),s[e.buffer.uid]+=k(e.format).stride}}(t)}function Me(t){return gc[t]??gc.float32}function Te(t){const e=t.map(t=>({data:t,offset:0,size:0}));let i=0,n=0;for(let t=0;t<e.length;t++){const s=e[t];if(i=Tc[s.data.type],!i)throw new Error(`Unknown type ${s.data.type}`);s.data.size>1&&(i=Math.max(i,16)*s.data.size);const r=12===i?16:i;s.size=i;const o=n%16;n+=o>0&&16-o<r?(16-o)%16:(i-o%i)%i,s.offset=n,n+=i}return n=16*Math.ceil(n/16),{uboElements:e,size:n}}function Pe(t,e,i,n){const s=["\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 r=0;for(let o=0;o<t.length;o++){const a=t[o],h=a.data.name;let l=!1,c=0;for(let t=0;t<Pc.length;t++)if(Pc[t].test(a.data)){c=a.offset/4,s.push(`name = "${h}";`,`offset += ${c-r};`,Pc[t][e]||Pc[t].ubo),l=!0;break}if(!l)if(a.data.size>1)c=a.offset/4,s.push(i(a,c-r));else{const t=n[a.data.type];c=a.offset/4,s.push(`\n v = uv.${h};\n offset += ${c-r};\n ${t};\n `)}r=c}const o=s.join("\n");return new Function("uv","data","dataInt32","offset",o)}function Ee(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 `}function Be(t,e){const i=Math.max(Tc[t.data.type]/16,1),n=t.data.value.length/t.data.size,s=(4-n%4)%4,r=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 ${r}[arrayOffset++] = v[t++];\n }\n ${0!==s?`arrayOffset += ${s};`:""}\n }\n `}function Oe(t){return Pe(t,"uboStd40",Be,Ec)}function ke(t,e){if(!Rc.has(t)){const i=new Fn({source:new Qs({resource:t,...e})}),n=()=>{Rc.get(t)===i&&Rc.delete(t)};i.once("destroy",n),i.source.once("destroy",n),Rc.set(t,i)}return Rc.get(t)}function Re(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}function De(t){const e=new Array(t);for(let t=0;t<e.length;t++)e[t]=!1;return e}function Fe(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 De(2*e);case"bvec3":return De(3*e);case"bvec4":return De(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}function Le(t,e){if(!Nc){const e=Object.keys(zc);Nc={};for(let i=0;i<e.length;++i){const n=e[i];Nc[t[n]]=zc[n]}}return Nc[e]}function je(t,e){const i=Le(t,e);return Hc[i]||"float32"}function Ge(t,e){const i=t.getShaderSource(e).split("\n").map((t,e)=>`${e}: ${t}`),n=t.getShaderInfoLog(e).split("\n"),s={},r=n.map(t=>parseFloat(t.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(t=>!(!t||s[t]||(s[t]=!0,0))),o=[""];r.forEach(t=>{i[t-1]=`%c${i[t-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const a=i.join("\n");o[0]=a}function Ue(t,e,i,n,s,r,o,a){const h=r;if(!a||"repeat"!==t.addressModeU||"repeat"!==t.addressModeV||"repeat"!==t.addressModeW){const i=rd[o?"clamp-to-edge":t.addressModeU],n=rd[o?"clamp-to-edge":t.addressModeV],r=rd[o?"clamp-to-edge":t.addressModeW];e[s](h,e.TEXTURE_WRAP_S,i),e[s](h,e.TEXTURE_WRAP_T,n),e.TEXTURE_WRAP_R&&e[s](h,e.TEXTURE_WRAP_R,r)}if(a&&"linear"===t.magFilter||e[s](h,e.TEXTURE_MAG_FILTER,nd[t.magFilter]),i){if(!a||"linear"!==t.mipmapFilter){const i=sd[t.minFilter][t.mipmapFilter];e[s](h,e.TEXTURE_MIN_FILTER,i)}}else e[s](h,e.TEXTURE_MIN_FILTER,nd[t.minFilter]);if(n&&t.maxAnisotropy>1){const i=Math.min(t.maxAnisotropy,e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));e[s](h,n.TEXTURE_MAX_ANISOTROPY_EXT,i)}t.compare&&e[s](h,e.TEXTURE_COMPARE_FUNC,od[t.compare])}function Ne(t,e){const i=t.instructionSet,n=i.instructions;for(let t=0;t<i.instructionSize;t++){const i=n[t];e[i.renderPipeId].execute(i)}}function ze(t,e){e||(e=0);for(let i=e;i<t.length&&t[i];i++)t[i]=null}function He(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=p(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 e in i){const s=Number(e),r=i[e],o=r.list,a=r.index;for(let e=0;e<a;e++){const i=o[e];i.parentRenderGroup===t&&i.relativeRenderGroupDepth===s&&Ve(i,n,0)}ze(o,a),r.index=0}if(e)for(let i=0;i<t.renderGroupChildren.length;i++)He(t.renderGroupChildren[i],e)}function Ve(t,e,i){if(e===t.updateTick)return;t.updateTick=e,t.didChange=!1;const n=t.localTransform;t.updateLocalTransform();const s=t.parent;if(s&&!s.renderGroup?(i|=t._updateFlags,t.relativeGroupTransform.appendFrom(n,s.relativeGroupTransform),7&i&&We(t,s,i)):(i=t._updateFlags,t.relativeGroupTransform.copyFrom(n),7&i&&We(t,fd,i)),!t.renderGroup){const n=t.children,s=n.length;for(let t=0;t<s;t++)Ve(n[t],e,i);const r=t.parentRenderGroup,o=t;o.renderPipeId&&!r.structureDidChange&&r.updateRenderable(o)}}function We(t,e,i){if(1&i){t.groupColor=p(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}function Ze(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}function Je(t){let e=!1;for(const i in t)if(null==t[i]){e=!0;break}if(!e)return t;const i=Object.create(null);for(const e in t){const n=t[e];n&&(i[e]=n)}return i}function Xe(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}function Ye(t){const e=t.map(t=>({data:t,offset:0,size:0}));let i=0;for(let t=0;t<e.length;t++){const n=e[t];let s=su[n.data.type].size;const r=su[n.data.type].align;if(!su[n.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${n.data.type}`);n.data.size>1&&(s=Math.max(s,r)*n.data.size),i=Math.ceil(i/r)*r,n.size=s,n.offset=i,i+=s}return i=16*Math.ceil(i/16),{uboElements:e,size:i}}function Ke(t,e){const{size:i,align:n}=su[t.data.type],s=(n-i)/4,r=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 ${r}[arrayOffset++] = v[t++];\n }\n ${0!==s?`arrayOffset += ${s};`:""}\n }\n `}function qe(t){return Pe(t,"uboWgsl",Ke,Bc)}function Qe(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 t=0,n=0;t<i;t+=6,n+=4)e[t+0]=n+0,e[t+1]=n+1,e[t+2]=n+2,e[t+3]=n+0,e[t+4]=n+2,e[t+5]=n+3;return e}function $e(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];e===r.dynamic&&(i.push(`offset = index + ${n}`),i.push(r.code),n+=k(r.format).stride/4)}i.push("\n index += stride * 4;\n }\n "),i.unshift(`\n var stride = ${n};\n `);const s=i.join("\n");return new Function("ps","f32v","u32v",s)}function ti(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}function ei(t,e){const{texture:i,bounds:n}=t,s=e._style._getFinalPadding();o(n,e._anchor,i);const r=e._anchor._x*s*2,a=e._anchor._y*s*2;n.minX-=s-r,n.minY-=s-a,n.maxX-=s-r,n.maxY-=s-a}function ii(t,e,i,n){const s=yp;s.minX=0,s.minY=0,s.maxX=t.width/n|0,s.maxY=t.height/n|0;const r=Ls.getOptimalTexture(s.width,s.height,n,!1);return r.source.uploadMethodId="image",r.source.resource=t,r.source.alphaMode="premultiply-alpha-on-upload",r.frame.width=e/n,r.frame.height=i/n,r.source.emit("update",r.source),r.updateUvs(),r}function ni(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Op&&Op in Object(t)?function(t){var e=Tp.call(t,Ep),i=t[Ep];try{t[Ep]=void 0;var n=!0}catch(t){}var s=Pp.call(t);return n&&(e?t[Ep]=i:delete t[Ep]),s}(t):function(t){return Bp.call(t)}(t)}function si(t){return null!=t&&"object"==typeof t}function ri(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function oi(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||si(t)&&"[object Symbol]"==ni(t)}(t))return NaN;if(ri(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ri(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;var i;t=(i=t)?i.slice(0,function(t){for(var e=t.length;e--&&Rp.test(t.charAt(e)););return e}(i)+1).replace(Dp,""):i;var n=Lp.test(t);return n||jp.test(t)?Gp(t.slice(2),n?2:8):Fp.test(t)?NaN:+t}function ai(t){return t}function hi(t){if(!ri(t))return!1;var e=ni(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}function li(t){if(null!=t){try{return Hp.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function ci(t,e){var i=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!ri(t)||(e=t,zp&&zp in e))&&(hi(t)?Yp:Vp).test(li(t));var e}(i)?i:void 0}function di(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&sf.test(t))&&t>-1&&t%1==0&&t<e}function ui(t,e,i){"__proto__"==e&&tf?tf(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}function pi(t,e){return t===e||t!=t&&e!=e}function fi(t,e,i){var n=t[e];rf.call(t,e)&&pi(n,i)&&(void 0!==i||e in t)||ui(t,e,i)}function gi(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function mi(t){return null!=t&&gi(t.length)&&!hi(t)}function yi(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||af)}function xi(t){return si(t)&&"[object Arguments]"==ni(t)}function bi(t,e){var i=kp(t),n=!i&&df(t),s=!i&&!n&&gf(t),r=!i&&!n&&!s&&Cf(t),o=i||n||s||r,a=o?function(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n}(t.length,String):[],h=a.length;for(var l in t)!e&&!Sf.call(t,l)||o&&("length"==l||s&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||di(l,h))||a.push(l);return a}function _i(t,e){return function(i){return t(e(i))}}function vi(t){return mi(t)?bi(t,!0):function(t){if(!ri(t))return function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e}(t);var e=yi(t),i=[];for(var n in t)("constructor"!=n||!e&&Mf.call(t,n))&&i.push(n);return i}(t)}function wi(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 Ci(t,e){for(var i=t.length;i--;)if(pi(t[i][0],e))return i;return-1}function Si(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 Ai(t,e){var i=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?i["string"==typeof e?"string":"hash"]:i.map}function Ii(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 Mi(t,e,i){var n=-1,s=t.length;e<0&&(e=-e>s?0:s+e),(i=i>s?s:i)<0&&(i+=s),s=e>i?0:i-e>>>0,e>>>=0;for(var r=Array(s);++n<s;)r[n]=t[n+e];return r}function Ti(t){var e=this.__data__=new Si(t);this.size=e.size}function Pi(t){return function(t,e,i){var n=function(t){return mi(t)?bi(t):function(t){if(!yi(t))return Af(t);var e=[];for(var i in Object(t))If.call(t,i)&&"constructor"!=i&&e.push(i);return e}(t)}(t);return kp(t)?n:function(t,e){for(var i=-1,n=e.length,s=t.length;++i<n;)t[s+i]=e[i];return t}(n,i(t))}(t,0,Zf)}function Ei(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new Ii;++e<i;)this.add(t[e])}function Bi(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(e(t[i],i,t))return!0;return!1}function Oi(t,e,i,n,s,r){var o=1&i,a=t.length,h=e.length;if(a!=h&&!(o&&h>a))return!1;var l=r.get(t),c=r.get(e);if(l&&c)return l==e&&c==t;var d=-1,u=!0,p=2&i?new Ei:void 0;for(r.set(t,e),r.set(e,t);++d<a;){var f=t[d],g=e[d];if(n)var m=o?n(g,f,d,e,t,r):n(f,g,d,t,e,r);if(void 0!==m){if(m)continue;u=!1;break}if(p){if(!Bi(e,function(t,e){if(o=e,!p.has(o)&&(f===t||s(f,t,i,n,r)))return p.push(e);var o})){u=!1;break}}else if(f!==g&&!s(f,g,i,n,r)){u=!1;break}}return r.delete(t),r.delete(e),u}function ki(t){var e=-1,i=Array(t.size);return t.forEach(function(t,n){i[++e]=[n,t]}),i}function Ri(t){var e=-1,i=Array(t.size);return t.forEach(function(t){i[++e]=t}),i}function Di(t,e,i,n,s){return t===e||(null==t||null==e||!si(t)&&!si(e)?t!=t&&e!=e:function(t,e,i,n,s,r){var o=kp(t),a=kp(e),h=o?pg:og(t),l=a?pg:og(e),c=(h=h==ug?fg:h)==fg,d=(l=l==ug?fg:l)==fg,u=h==l;if(u&&gf(t)){if(!gf(e))return!1;o=!0,c=!1}if(u&&!c)return r||(r=new Ti),o||Cf(t)?Oi(t,e,i,n,s,r):function(t,e,i,n,s,r,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||!r(new ag(t),new ag(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return pi(+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=ki;case"[object Set]":var h=1&n;if(a||(a=Ri),t.size!=e.size&&!h)return!1;var l=o.get(t);if(l)return l==e;n|=2,o.set(t,e);var c=Oi(a(t),a(e),n,s,r,o);return o.delete(t),c;case"[object Symbol]":if(cg)return cg.call(t)==cg.call(e)}return!1}(t,e,h,i,n,s,r);if(!(1&i)){var p=c&&gg.call(t,"__wrapped__"),f=d&&gg.call(e,"__wrapped__");if(p||f){var g=p?t.value():t,m=f?e.value():e;return r||(r=new Ti),s(g,m,i,n,r)}}return!!u&&(r||(r=new Ti),function(t,e,i,n,s,r){var o=1&i,a=Pi(t),h=a.length;if(h!=Pi(e).length&&!o)return!1;for(var l=h;l--;){var c=a[l];if(!(o?c in e:dg.call(e,c)))return!1}var d=r.get(t),u=r.get(e);if(d&&u)return d==e&&u==t;var p=!0;r.set(t,e),r.set(e,t);for(var f=o;++l<h;){var g=t[c=a[l]],m=e[c];if(n)var y=o?n(m,g,c,e,t,r):n(g,m,c,t,e,r);if(!(void 0===y?g===m||s(g,m,i,n,r):y)){p=!1;break}f||(f="constructor"==c)}if(p&&!f){var x=t.constructor,b=e.constructor;x==b||!("constructor"in t)||!("constructor"in e)||"function"==typeof x&&x instanceof x&&"function"==typeof b&&b instanceof b||(p=!1)}return r.delete(t),r.delete(e),p}(t,e,i,n,s,r))}(t,e,i,n,Di,s))}function Fi(t,e,i){function n(e){var i=h,n=l;return h=l=void 0,f=e,d=t.apply(n,i)}function s(t){var i=t-p;return void 0===p||i>=e||i<0||m&&t-f>=c}function r(){var t=yg();if(s(t))return o(t);u=setTimeout(r,function(t){var i=e-(t-p);return m?bg(i,c-(t-f)):i}(t))}function o(t){return u=void 0,y&&h?n(t):(h=l=void 0,d)}function a(){var t=yg(),i=s(t);if(h=arguments,l=this,p=t,i){if(void 0===u)return function(t){return f=t,u=setTimeout(r,e),g?n(t):d}(p);if(m)return clearTimeout(u),u=setTimeout(r,e),n(p)}return void 0===u&&(u=setTimeout(r,e)),d}var h,l,c,d,u,p,f=0,g=!1,m=!1,y=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return e=oi(e)||0,ri(i)&&(g=!!i.leading,c=(m="maxWait"in i)?xg(oi(i.maxWait)||0,e):c,y="trailing"in i?!!i.trailing:y),a.cancel=function(){void 0!==u&&clearTimeout(u),f=0,h=p=l=u=void 0},a.flush=function(){return void 0===u?d:o(yg())},a}function Li(t,e,i){(void 0!==i&&!pi(t[e],i)||void 0===i&&!(e in t))&&ui(t,e,i)}function ji(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Gi(t,e,i,n,s){t!==e&&mg(e,function(r,o){if(s||(s=new Ti),ri(r))!function(t,e,i,n,s,r,o){var a=ji(t,i),h=ji(e,i),l=o.get(h);if(l)Li(t,i,l);else{var c,d=r?r(a,h,i+"",t,e,o):void 0,u=void 0===d;if(u){var p=kp(h),f=!p&&gf(h),g=!p&&!f&&Cf(h);d=h,p||f||g?kp(a)?d=a:si(c=a)&&mi(c)?d=function(t,e){var i=-1,n=t.length;for(e||(e=Array(n));++i<n;)e[i]=t[i];return e}(a):f?(u=!1,d=h.slice()):g?(u=!1,d=function(t){var e=function(t){var e=new t.constructor(t.byteLength);return new ag(e).set(new ag(t)),e}(t.buffer);return new t.constructor(e,t.byteOffset,t.length)}(h)):d=[]:function(t){if(!si(t)||"[object Object]"!=ni(t))return!1;var e=kf(t);if(null===e)return!0;var i=Lf.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&Ff.call(i)==jf}(h)||df(h)?(d=a,df(a)?d=function(t){return function(t,e,i){var n=!i;i||(i={});for(var s=-1,r=e.length;++s<r;){var o=e[s],a=void 0;void 0===a&&(a=t[o]),n?ui(i,o,a):fi(i,o,a)}return i}(t,vi(t))}(a):ri(a)&&!hi(a)||(d=function(t){return"function"!=typeof t.constructor||yi(t)?{}:Qp(kf(t))}(h))):u=!1}u&&(o.set(h,d),s(d,h,n,r,o),o.delete(h)),Li(t,i,d)}}(t,e,o,i,Gi,n,s);else{var a=n?n(ji(t,o),r,o+"",t,e,s):void 0;void 0===a&&(a=r),Li(t,o,a)}},vi)}function Ui(t,e){return Di(t,e)}function Ni(t,e,i){var n=!0,s=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return ri(i)&&(n="leading"in i?!!i.leading:n,s="trailing"in i?!!i.trailing:s),Fi(t,e,{leading:n,maxWait:e,trailing:s})}function zi(t,e,i,n){let s=3&t,r=t>>2&63;if(1===s||62===r)i.push(e);else if(0===s&&r<=31)n.has(r)||n.set(r,[]),n.get(r).push(e);else if(0===s){let t;switch(r){case 60:t=zg.NO_ROOM_DATA;break;case 61:t=zg.ROOM_GAP;break;case 62:t=zg.OBSTACLE_ROOM;break;case 63:t=zg.UNKNOWN_ROOM}void 0!==t&&(n.has(t)||n.set(t,[]),n.get(t).push(e))}}function Hi(t){switch(t){case 28:return zg.NO_ROOM_DATA;case 29:return zg.ROOM_GAP;case 30:return zg.OBSTACLE_ROOM;case 31:return zg.UNKNOWN_ROOM;default:return}}function Vi(t,e,i,n,s){let r=7&t,o=t>>3&31;if(1===r||30===o)i.push(e);else if(2===r)if(n.push(e),o<=27)s.has(o)||s.set(o,[]),s.get(o).push(e);else{let t=Hi(o);void 0!==t&&(s.has(t)||s.set(t,[]),s.get(t).push(e))}else if(7===r)if(o<=27)s.has(o)||s.set(o,[]),s.get(o).push(e);else{let t=Hi(o);void 0!==t&&(s.has(t)||s.set(t,[]),s.get(t).push(e))}}function Wi(t={}){if(!Lm(t))throw new Error("object required");const e=Hm.get(t);if(e)return e;let i=zm[0];const n=new Set,s=(t,e=++zm[0])=>{i!==e&&(r=i=e,n.forEach(i=>i(t,e)))};let r=i;const o=t=>(e,i)=>{const n=[...e];n[1]=[t,...n[1]],s(n,i)},a=new Map;let h=!0;const l=Jm(()=>h,(t,e)=>{const i=!Um.has(e)&&Gm.get(e);if(i){if("production"!==(Fm?"core":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))},s),c=Wm(t,l);Hm.set(t,c);const d=[t,(t=zm[0])=>(r!==t&&(r=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"!==(Fm?"core":void 0)&&e)throw new Error("remove already exists");const n=t[2](o(i));a.set(i,[t,n])}),()=>{n.delete(t),0===n.size&&a.forEach(([t,e],i)=>{e&&(e(),a.set(i,[t]))})})];return Gm.set(c,d),Reflect.ownKeys(t).forEach(e=>{const i=Object.getOwnPropertyDescriptor(t,e);"value"in i&&i.writable&&(c[e]=t[e])}),h=!1,c}function Zi(){return iy.getService()}function Ji(){return Ry||(Ry=1,Object.defineProperty(zy,"__esModule",{value:!0}),zy.loop=zy.conditional=zy.parse=void 0,zy.parse=function t(e,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n;if(Array.isArray(i))i.forEach(function(i){return t(e,i,n,s)});else if("function"==typeof i)i(e,n,s,t);else{var r=Object.keys(i)[0];Array.isArray(i[r])?(s[r]={},t(e,i[r],n,s[r])):s[r]=i[r](e,n,s,t)}return n},zy.conditional=function(t,e){return function(i,n,s,r){e(i,n,s)&&r(i,t,n,s)}},zy.loop=function(t,e){return function(i,n,s,r){for(var o=[],a=i.pos;e(i,n,s);){var h={};if(r(i,t,n,h),i.pos===a)break;a=i.pos,o.push(h)}return o}}),zy}function Xi(){if(Dy)return Hy;Dy=1,Object.defineProperty(Hy,"__esModule",{value:!0}),Hy.readBits=Hy.readArray=Hy.readUnsigned=Hy.readString=Hy.peekBytes=Hy.readBytes=Hy.peekByte=Hy.readByte=Hy.buildStream=void 0,Hy.buildStream=function(t){return{data:t,pos:0}},Hy.readByte=function(){return function(t){return t.data[t.pos++]}},Hy.peekByte=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function(e){return e.data[e.pos+t]}};var t=function(t){return function(e){return e.data.subarray(e.pos,e.pos+=t)}};return Hy.readBytes=t,Hy.peekBytes=function(t){return function(e){return e.data.subarray(e.pos,e.pos+t)}},Hy.readString=function(e){return function(i){return Array.from(t(e)(i)).map(function(t){return String.fromCharCode(t)}).join("")}},Hy.readUnsigned=function(e){return function(i){var n=t(2)(i);return e?(n[1]<<8)+n[0]:(n[0]<<8)+n[1]}},Hy.readArray=function(e,i){return function(n,s,r){for(var o="function"==typeof i?i(n,s,r):i,a=t(e),h=new Array(o),l=0;l<o;l++)h[l]=a(n);return h}},Hy.readBits=function(t){return function(e){for(var i=function(t){return t.data[t.pos++]}(e),n=new Array(8),s=0;s<8;s++)n[7-s]=!!(i&1<<s);return Object.keys(t).reduce(function(e,i){var s=t[i];return s.length?e[i]=function(t,e,i){for(var n=0,s=0;s<i;s++)n+=t[e+s]&&Math.pow(2,i-s-1);return n}(n,s.index,s.length):e[i]=n[s.index],e},{})}},Hy}function Yi(t,e,i,n){let s=t[e];return function(t,e){const i=Gm.get(t);let n;const s=[],r=i[2];let o=!1;const a=r(t=>{s.push(t),n||(n=Promise.resolve().then(()=>{n=void 0,o&&e(s.splice(0))}))});return o=!0,()=>{o=!1,a()}}(t,()=>{const n=t[e];Object.is(s,n)||i(s=n)})}var Ki=(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))(Ki||{});const qi=t=>{if("function"==typeof t||"object"==typeof t&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");t={..."object"!=typeof t.extension?{type:t.extension}:t.extension,ref:t}}if("object"!=typeof t)throw new Error("Invalid extension type");return"string"==typeof(t={...t}).type&&(t.type=[t.type]),t},Qi=(t,e)=>qi(t).priority??e,$i={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(qi).forEach(t=>{t.type.forEach(e=>this._removeHandlers[e]?.(t))}),this},add(...t){return t.map(qi).forEach(t=>{t.type.forEach(e=>{const i=this._addHandlers,n=this._queue;i[e]?i[e]?.(t):(n[e]=n[e]||[],n[e]?.push(t))})}),this},handle(t,e,i){const n=this._addHandlers,s=this._removeHandlers;if(n[t]||s[t])throw new Error(`Extension type ${t} already has a handler`);n[t]=e,s[t]=i;const r=this._queue;return r[t]&&(r[t]?.forEach(t=>e(t)),delete r[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)=>Qi(e.value,i)-Qi(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)=>Qi(e,i)-Qi(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))}},tn={extension:{type:Ki.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(()=>Lx)}},en={extension:{type:Ki.Environment,name:"webworker",priority:0},test:()=>"undefined"!=typeof self&&void 0!==self.WorkerGlobalScope,load:async()=>{await Promise.resolve().then(()=>jx)}};class nn{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new nn(t??this._observer,this._x,this._y)}set(t=0,e=t){return this._x===t&&this._y===e||(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return this._x===t.x&&this._y===t.y||(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}var sn,rn={exports:{}};const on=t((sn||(sn=1,function(t){function e(){}function i(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function n(t,e,n,s,r){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new i(n,s||t,r),h=a?a+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],o]:t._events[h].push(o):(t._events[h]=o,t._eventsCount++),t}function s(t,i){0===--t._eventsCount?t._events=new e:delete t._events[i]}function r(){this._events=new e,this._eventsCount=0}var o=Object.prototype.hasOwnProperty,a="~";Object.create&&(e.prototype=Object.create(null),(new e).__proto__||(a=!1)),r.prototype.eventNames=function(){var t,e,i=[];if(0===this._eventsCount)return i;for(e in t=this._events)o.call(t,e)&&i.push(a?e.slice(1):e);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},r.prototype.listeners=function(t){var e=a?a+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,s=i.length,r=new Array(s);n<s;n++)r[n]=i[n].fn;return r},r.prototype.listenerCount=function(t){var e=a?a+t:t,i=this._events[e];return i?i.fn?1:i.length:0},r.prototype.emit=function(t,e,i,n,s,r){var o=a?a+t:t;if(!this._events[o])return!1;var h,l,c=this._events[o],d=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),d){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,i),!0;case 4:return c.fn.call(c.context,e,i,n),!0;case 5:return c.fn.call(c.context,e,i,n,s),!0;case 6:return c.fn.call(c.context,e,i,n,s,r),!0}for(l=1,h=new Array(d-1);l<d;l++)h[l-1]=arguments[l];c.fn.apply(c.context,h)}else{var u,p=c.length;for(l=0;l<p;l++)switch(c[l].once&&this.removeListener(t,c[l].fn,void 0,!0),d){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,e);break;case 3:c[l].fn.call(c[l].context,e,i);break;case 4:c[l].fn.call(c[l].context,e,i,n);break;default:if(!h)for(u=1,h=new Array(d-1);u<d;u++)h[u-1]=arguments[u];c[l].fn.apply(c[l].context,h)}}return!0},r.prototype.on=function(t,e,i){return n(this,t,e,i,!1)},r.prototype.once=function(t,e,i){return n(this,t,e,i,!0)},r.prototype.removeListener=function(t,e,i,n){var r=a?a+t:t;if(!this._events[r])return this;if(!e)return s(this,r),this;var o=this._events[r];if(o.fn)o.fn!==e||n&&!o.once||i&&o.context!==i||s(this,r);else{for(var h=0,l=[],c=o.length;h<c;h++)(o[h].fn!==e||n&&!o[h].once||i&&o[h].context!==i)&&l.push(o[h]);l.length?this._events[r]=1===l.length?l[0]:l:s(this,r)}return this},r.prototype.removeAllListeners=function(t){var i;return t?(i=a?a+t:t,this._events[i]&&s(this,i)):(this._events=new e,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prefixed=a,r.EventEmitter=r,t.exports=r}(rn)),rn.exports)),an=2*Math.PI,hn=180/Math.PI,ln=Math.PI/180;class cn{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new cn(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 dn.x=0,dn.y=0,dn}}const dn=new cn;class un{constructor(t=1,e=0,i=0,n=1,s=0,r=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,this.ty=r}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,s,r){return this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,this.ty=r,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 cn;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 cn;const i=this.a,n=this.b,s=this.c,r=this.d,o=this.tx,a=this.ty,h=1/(i*r+s*-n),l=t.x,c=t.y;return e.x=r*h*l+-s*h*c+(a*s-o*r)*h,e.y=i*h*c+-n*h*l+(-a*i+o*n)*h,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,s=this.c,r=this.tx;return this.a=n*e-this.b*i,this.b=n*i+this.b*e,this.c=s*e-this.d*i,this.d=s*i+this.d*e,this.tx=r*e-this.ty*i,this.ty=r*i+this.ty*e,this}append(t){const e=this.a,i=this.b,n=this.c,s=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*i+t.b*s,this.c=t.c*e+t.d*n,this.d=t.c*i+t.d*s,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*i+t.ty*s+this.ty,this}appendFrom(t,e){const i=t.a,n=t.b,s=t.c,r=t.d,o=t.tx,a=t.ty,h=e.a,l=e.b,c=e.c,d=e.d;return this.a=i*h+n*c,this.b=i*l+n*d,this.c=s*h+r*c,this.d=s*l+r*d,this.tx=o*h+a*c+e.tx,this.ty=o*l+a*d+e.ty,this}setTransform(t,e,i,n,s,r,o,a,h){return this.a=Math.cos(o+h)*s,this.b=Math.sin(o+h)*s,this.c=-Math.sin(o-a)*r,this.d=Math.cos(o-a)*r,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,s=this.d,r=t.pivot,o=-Math.atan2(-n,s),a=Math.atan2(i,e),h=Math.abs(o+a);return h<1e-5||Math.abs(an-h)<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+s*s),t.position.x=this.tx+(r.x*e+r.y*n),t.position.y=this.ty+(r.x*i+r.y*s),t}invert(){const t=this.a,e=this.b,i=this.c,n=this.d,s=this.tx,r=t*n-e*i;return this.a=n/r,this.b=-e/r,this.c=-i/r,this.d=t/r,this.tx=(i*this.ty-n*s)/r,this.ty=-(t*this.ty-e*s)/r,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 un;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 fn.identity()}static get shared(){return pn.identity()}}const pn=new un,fn=new un,gn=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],mn=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],yn=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],xn=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],bn=[],_n=[],vn=Math.sign;!function(){for(let t=0;t<16;t++){const e=[];bn.push(e);for(let i=0;i<16;i++){const n=vn(gn[t]*gn[i]+yn[t]*mn[i]),s=vn(mn[t]*gn[i]+xn[t]*mn[i]),r=vn(gn[t]*yn[i]+yn[t]*xn[i]),o=vn(mn[t]*yn[i]+xn[t]*xn[i]);for(let t=0;t<16;t++)if(gn[t]===n&&mn[t]===s&&yn[t]===r&&xn[t]===o){e.push(t);break}}}for(let t=0;t<16;t++){const e=new un;e.set(gn[t],mn[t],yn[t],xn[t],0,0),_n.push(e)}}();const wn={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=>gn[t],uY:t=>mn[t],vX:t=>yn[t],vY:t=>xn[t],inv:t=>8&t?15&t:7&-t,add:(t,e)=>bn[t][e],sub:(t,e)=>bn[t][wn.inv(e)],rotate180:t=>4^t,isVertical:t=>2==(3&t),byDirection:(t,e)=>2*Math.abs(t)<=Math.abs(e)?e>=0?wn.S:wn.N:2*Math.abs(e)<=Math.abs(t)?t>0?wn.E:wn.W:e>0?t>0?wn.SE:wn.SW:t>0?wn.NE:wn.NW,matrixAppendRotationInv:(t,e,i=0,n=0)=>{const s=_n[wn.inv(e)];s.tx=i,s.ty=n,t.append(s)},transformRectCoords:(t,e,i,n)=>{const{x:s,y:r,width:o,height:a}=t,{x:h,y:l,width:c,height:d}=e;return i===wn.E?(n.set(s+h,r+l,o,a),n):i===wn.S?n.set(c-r-a+h,s+l,a,o):i===wn.W?n.set(c-s-o+h,d-r-a+l,o,a):i===wn.N?n.set(r+h,d-s-o+l,a,o):n.set(s+h,r+l,o,a)}},Cn=[new cn,new cn,new cn,new cn];class Sn{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 Sn(0,0,0,0)}clone(){return new Sn(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:s,height:r}=this;if(s<=0||r<=0)return!1;const o=this.x,a=this.y,h=i*(1-n),l=i-h;return t>=o-h&&t<=o+s+h&&e>=a-h&&e<=a+r+h&&!(t>o+l&&t<o+s-l&&e>a+l&&e<a+r-l)}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,s=this.top,r=this.bottom;if(n<=i||r<=s)return!1;const o=Cn[0].set(t.left,t.top),a=Cn[1].set(t.left,t.bottom),h=Cn[2].set(t.right,t.top),l=Cn[3].set(t.right,t.bottom);if(h.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(h,h),e.apply(l,l),Math.max(o.x,a.x,h.x,l.x)<=i||Math.min(o.x,a.x,h.x,l.x)>=n||Math.max(o.y,a.y,h.y,l.y)<=s||Math.min(o.y,a.y,h.y,l.y)>=r)return!1;const d=c*(a.y-o.y),u=c*(o.x-a.x),p=d*i+u*s,f=d*n+u*s,g=d*i+u*r,m=d*n+u*r;if(Math.max(p,f,g,m)<=d*o.x+u*o.y||Math.min(p,f,g,m)>=d*l.x+u*l.y)return!1;const y=c*(o.y-h.y),x=c*(h.x-o.x),b=y*i+x*s,_=y*n+x*s,v=y*i+x*r,w=y*n+x*r;return!(Math.max(b,_,v,w)<=y*o.x+x*o.y||Math.min(b,_,v,w)>=y*l.x+x*l.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),s=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(s-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),s=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=n,this.height=s-n,this}getBounds(t){return t||(t=new Sn),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,s=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&&s>=this.y&&s<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 An={default:-1},In={},Mn=()=>{},Tn=Object.create(null),Pn=class t extends on{constructor(e={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,e={...t.defaultOptions,...e},this.addressMode=e.addressMode,this.addressModeU=e.addressModeU??this.addressModeU,this.addressModeV=e.addressModeV??this.addressModeV,this.addressModeW=e.addressModeW??this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=e.magFilter??this.magFilter,this.minFilter=e.minFilter??this.minFilter,this.mipmapFilter=e.mipmapFilter??this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=e.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){i(0,"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 i=Tn[t];return void 0===i&&(Tn[t]=e("resource")),i}(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Pn.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let En=Pn;const Bn=class t extends on{constructor(i={}){super(),this.options=i,this.uid=e("textureSource"),this._resourceType="textureSource",this._resourceId=e("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,i={...t.defaultOptions,...i},this.label=i.label??"",this.resource=i.resource,this.autoGarbageCollect=i.autoGarbageCollect,this._resolution=i.resolution,i.width?this.pixelWidth=i.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,i.height?this.pixelHeight=i.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=i.format,this.dimension=i.dimensions,this.mipLevelCount=i.mipLevelCount,this.autoGenerateMipmaps=i.autoGenerateMipmaps,this.sampleCount=i.sampleCount,this.antialias=i.antialias,this.alphaMode=i.alphaMode,this.style=new En(r(i)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){this.style!==t&&(this._style?.off("change",this._onStyleChange,this),this._style=t,this._style?.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!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=e("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,i,n){n||(n=this._resolution),t||(t=this.width),i||(i=this.height);const s=Math.round(t*n),r=Math.round(i*n);return this.width=s/n,this.height=r/n,this._resolution=n,(this.pixelWidth!==s||this.pixelHeight!==r)&&(this._refreshPOT(),this.pixelWidth=s,this.pixelHeight=r,this.emit("resize",this),this._resourceId=e("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=s(this.pixelWidth)&&s(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Bn.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let On=Bn;class kn extends On{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({...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}}kn.extension=Ki.TextureSource;const Rn=new un;class Dn{constructor(t,e){this.mapCoord=new un,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){this.texture!==t&&(this._texture?.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){void 0===e&&(e=t);const i=this.mapCoord;for(let n=0;n<t.length;n+=2){const s=t[n],r=t[n+1];e[n]=s*i.a+r*i.c+i.tx,e[n+1]=s*i.b+r*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&&(Rn.set(i.width/n.width,0,0,i.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Rn));const s=t.source,r=this.uClampFrame,o=this.clampMargin/s._resolution,a=this.clampOffset/s._resolution;return r[0]=(t.frame.x+o+a)/s.width,r[1]=(t.frame.y+o+a)/s.height,r[2]=(t.frame.x+t.frame.width-o+a)/s.width,r[3]=(t.frame.y+t.frame.height-o+a)/s.height,this.uClampOffset[0]=this.clampOffset/s.pixelWidth,this.uClampOffset[1]=this.clampOffset/s.pixelHeight,this.isSimple=t.frame.width===s.width&&t.frame.height===s.height&&0===t.rotate,!0}}class Fn extends on{constructor({source:t,label:i,frame:n,orig:s,trim:r,defaultAnchor:o,defaultBorders:a,rotate:h,dynamic:l}={}){if(super(),this.uid=e("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Sn,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=i,this.source=t?.source??new On,this.noFrame=!n,n)this.frame.copyFrom(n);else{const{width:t,height:e}=this._source;this.frame.width=t,this.frame.height=e}this.orig=s||this.frame,this.trim=r,this.rotate=h??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=l||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new Dn(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,s=e.x/i,r=e.y/n,o=e.width/i,a=e.height/n;let h=this.rotate;if(h){const e=o/2,i=a/2,n=s+e,l=r+i;h=wn.add(h,wn.NW),t.x0=n+e*wn.uX(h),t.y0=l+i*wn.uY(h),h=wn.add(h,2),t.x1=n+e*wn.uX(h),t.y1=l+i*wn.uY(h),h=wn.add(h,2),t.x2=n+e*wn.uX(h),t.y2=l+i*wn.uY(h),h=wn.add(h,2),t.x3=n+e*wn.uX(h),t.y3=l+i*wn.uY(h)}else t.x0=s,t.y0=r,t.x1=s+o,t.y1=r,t.x2=s+o,t.y2=r+a,t.x3=s,t.y3=r+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 i(0,"Texture.baseTexture is now Texture.source"),this._source}}Fn.EMPTY=new Fn({label:"EMPTY",source:new On({label:"EMPTY"})}),Fn.EMPTY.destroy=Mn,Fn.WHITE=new Fn({source:new kn({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),Fn.WHITE.destroy=Mn;const Ln=new un;class jn{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=Ln,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 Sn);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=Ln,this}set(t,e,i,n){this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}addFrame(t,e,i,n,s){s||(s=this.matrix);const r=s.a,o=s.b,a=s.c,h=s.d,l=s.tx,c=s.ty;let d=this.minX,u=this.minY,p=this.maxX,f=this.maxY,g=r*t+a*e+l,m=o*t+h*e+c;g<d&&(d=g),m<u&&(u=m),g>p&&(p=g),m>f&&(f=m),g=r*i+a*e+l,m=o*i+h*e+c,g<d&&(d=g),m<u&&(u=m),g>p&&(p=g),m>f&&(f=m),g=r*t+a*n+l,m=o*t+h*n+c,g<d&&(d=g),m<u&&(u=m),g>p&&(p=g),m>f&&(f=m),g=r*i+a*n+l,m=o*i+h*n+c,g<d&&(d=g),m<u&&(u=m),g>p&&(p=g),m>f&&(f=m),this.minX=d,this.minY=u,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,s=this.maxY,{a:r,b:o,c:a,d:h,tx:l,ty:c}=t;let d=r*e+a*i+l,u=o*e+h*i+c;this.minX=d,this.minY=u,this.maxX=d,this.maxY=u,d=r*n+a*i+l,u=o*n+h*i+c,this.minX=d<this.minX?d:this.minX,this.minY=u<this.minY?u:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=u>this.maxY?u:this.maxY,d=r*e+a*s+l,u=o*e+h*s+c,this.minX=d<this.minX?d:this.minX,this.minY=u<this.minY?u:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=u>this.maxY?u:this.maxY,d=r*n+a*s+l,u=o*n+h*s+c,this.minX=d<this.minX?d:this.minX,this.minY=u<this.minY?u:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=u>this.maxY?u: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 jn(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 s=this.minX,r=this.minY,o=this.maxX,a=this.maxY;n||(n=this.matrix);const h=n.a,l=n.b,c=n.c,d=n.d,u=n.tx,p=n.ty;for(let n=e;n<i;n+=2){const e=t[n],i=t[n+1],f=h*e+c*i+u,g=l*e+d*i+p;s=f<s?f:s,r=g<r?g:r,o=f>o?f:o,a=g>a?g:a}this.minX=s,this.minY=r,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 Gn={grad:.9,turn:360,rad:360/(2*Math.PI)},Un=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},Nn=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=Math.pow(10,e)),Math.round(i*t)/i+0},zn=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=1),t>i?i:t>e?t:e},Hn=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},Vn=function(t){return{r:zn(t.r,0,255),g:zn(t.g,0,255),b:zn(t.b,0,255),a:zn(t.a)}},Wn=function(t){return{r:Nn(t.r),g:Nn(t.g),b:Nn(t.b),a:Nn(t.a,3)}},Zn=/^#([0-9a-f]{3,8})$/i,Jn=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},Xn=function(t){var e=t.r,i=t.g,n=t.b,s=t.a,r=Math.max(e,i,n),o=r-Math.min(e,i,n),a=o?r===e?(i-n)/o:r===i?2+(n-e)/o:4+(e-i)/o:0;return{h:60*(a<0?a+6:a),s:r?o/r*100:0,v:r/255*100,a:s}},Yn=function(t){var e=t.h,i=t.s,n=t.v,s=t.a;e=e/360*6,i/=100,n/=100;var r=Math.floor(e),o=n*(1-i),a=n*(1-(e-r)*i),h=n*(1-(1-e+r)*i),l=r%6;return{r:255*[n,a,o,o,h,n][l],g:255*[h,n,n,a,o,o][l],b:255*[o,o,h,n,n,a][l],a:s}},Kn=function(t){return{h:Hn(t.h),s:zn(t.s,0,100),l:zn(t.l,0,100),a:zn(t.a)}},qn=function(t){return{h:Nn(t.h),s:Nn(t.s),l:Nn(t.l),a:Nn(t.a,3)}},Qn=function(t){return Yn((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},$n=function(t){return{h:(e=Xn(t)).h,s:(s=(200-(i=e.s))*(n=e.v)/100)>0&&s<200?i*n/100/(s<=100?s:200-s)*100:0,l:s/2,a:e.a};var e,i,n,s},ts=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,es=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,is=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ns=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ss={string:[[function(t){var e=Zn.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?Nn(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?Nn(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=is.exec(t)||ns.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:Vn({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=ts.exec(t)||es.exec(t);if(!e)return null;var i,n,s=Kn({h:(i=e[1],n=e[2],void 0===n&&(n="deg"),Number(i)*(Gn[n]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return Qn(s)},"hsl"]],object:[[function(t){var e=t.r,i=t.g,n=t.b,s=t.a,r=void 0===s?1:s;return Un(e)&&Un(i)&&Un(n)?Vn({r:Number(e),g:Number(i),b:Number(n),a:Number(r)}):null},"rgb"],[function(t){var e=t.h,i=t.s,n=t.l,s=t.a,r=void 0===s?1:s;if(!Un(e)||!Un(i)||!Un(n))return null;var o=Kn({h:Number(e),s:Number(i),l:Number(n),a:Number(r)});return Qn(o)},"hsl"],[function(t){var e=t.h,i=t.s,n=t.v,s=t.a,r=void 0===s?1:s;if(!Un(e)||!Un(i)||!Un(n))return null;var o,a=(o={h:Number(e),s:Number(i),v:Number(n),a:Number(r)},{h:Hn(o.h),s:zn(o.s,0,100),v:zn(o.v,0,100),a:zn(o.a)});return Yn(a)},"hsv"]]},rs=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]},os=function(t,e){var i=$n(t);return{h:i.h,s:zn(i.s+100*e,0,100),l:i.l,a:i.a}},as=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},hs=function(t,e){var i=$n(t);return{h:i.h,s:i.s,l:zn(i.l+100*e,0,100),a:i.a}},ls=function(){function t(t){this.parsed=function(t){return"string"==typeof t?rs(t.trim(),ss.string):"object"==typeof t&&null!==t?rs(t,ss.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 Nn(as(this.rgba),2)},t.prototype.isDark=function(){return as(this.rgba)<.5},t.prototype.isLight=function(){return as(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=Wn(this.rgba)).r,i=t.g,n=t.b,r=(s=t.a)<1?Jn(Nn(255*s)):"","#"+Jn(e)+Jn(i)+Jn(n)+r;var t,e,i,n,s,r},t.prototype.toRgb=function(){return Wn(this.rgba)},t.prototype.toRgbString=function(){return e=(t=Wn(this.rgba)).r,i=t.g,n=t.b,(s=t.a)<1?"rgba("+e+", "+i+", "+n+", "+s+")":"rgb("+e+", "+i+", "+n+")";var t,e,i,n,s},t.prototype.toHsl=function(){return qn($n(this.rgba))},t.prototype.toHslString=function(){return e=(t=qn($n(this.rgba))).h,i=t.s,n=t.l,(s=t.a)<1?"hsla("+e+", "+i+"%, "+n+"%, "+s+")":"hsl("+e+", "+i+"%, "+n+"%)";var t,e,i,n,s},t.prototype.toHsv=function(){return t=Xn(this.rgba),{h:Nn(t.h),s:Nn(t.s),v:Nn(t.v),a:Nn(t.a,3)};var t},t.prototype.invert=function(){return cs({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),cs(os(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),cs(os(this.rgba,-t))},t.prototype.grayscale=function(){return cs(os(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),cs(hs(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),cs(hs(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?cs({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Nn(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=$n(this.rgba);return"number"==typeof t?cs({h:t,s:e.s,l:e.l,a:e.a}):Nn(e.h)},t.prototype.isEqual=function(t){return this.toHex()===cs(t).toHex()},t}(),cs=function(t){return t instanceof ls?t:new ls(t)},ds=[];[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 s in i)n[i[s]]=s;var r={};t.prototype.toName=function(e){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var s,o,a=n[this.toHex()];if(a)return a;if(null==e?void 0:e.closest){var h=this.toRgb(),l=1/0,c="black";if(!r.length)for(var d in i)r[d]=new t(i[d]).toRgb();for(var u in i){var p=(s=h,o=r[u],Math.pow(s.r-o.r,2)+Math.pow(s.g-o.g,2)+Math.pow(s.b-o.b,2));p<l&&(l=p,c=u)}return c}},e.string.push([function(e){var n=e.toLowerCase(),s="transparent"===n?"#0000":i[n];return s?new t(s).toRgb():null},"name"])}].forEach(function(t){ds.indexOf(t)<0&&(t(ls,ss),ds.push(t))});const us=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?{...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,s]=this._components;return t[0]=e,t[1]=i,t[2]=n,t[3]=s,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,s,r]=t._temp.setValue(e)._components;return this._components[0]*=i,this._components[1]*=n,this._components[2]*=s,this._components[3]*=r,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(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,s=255&this._int;return e&&(i=i*t+.5|0,n=n*t+.5|0,s=s*t+.5|0),(255*t<<24)+(i<<16)+(n<<8)+s}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,s,r;if(("number"==typeof e||e instanceof Number)&&e>=0&&e<=16777215)i=(e>>16&255)/255,n=(e>>8&255)/255,s=(255&e)/255,r=1;else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[i,n,s,r=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[i,n,s,r=255]=e,i/=255,n/=255,s/=255,r/=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=cs(e);o.isValid()&&(({r:i,g:n,b:s,a:r}=o.rgba),i/=255,n/=255,s/=255)}if(void 0===i)throw new Error(`Unable to convert color ${e}`);this._components[0]=i,this._components[1]=n,this._components[2]=s,this._components[3]=r,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,s)=>{t[s]=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}};us.shared=new us,us._temp=new us,us.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let ps=us,fs=0;class gs{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){let e;return e=this._index>0?this._pool[--this._index]:new this._classType,e.init?.(t),e}return(t){t.reset?.(),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}const ms=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 gs(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}},ys={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(t){"boolean"==typeof t&&!1===t?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(!0===t?{}:t))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(t){i(0,"cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(t)}},xs={allowChildren:!0,removeChildren(t=0,e){const i=e??this.children.length,n=i-t,s=[];if(n>0&&n<=i){for(let e=i-1;e>=t;e--){const t=this.children[e];t&&(s.push(t),t.parent=null)}h(this.children,t,i);const e=this.renderGroup||this.parentRenderGroup;e&&e.removeChildren(s);for(let t=0;t<s.length;++t){const e=s[t];e.parentRenderLayer?.detach(e),this.emit("childRemoved",e,this,t),s[t].emit("removed",this)}return s.length>0&&this._didViewChangeTick++,s}if(0===n&&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||i(0,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:n}=this;if(e<0||e>n.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${n.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===n.length?n.push(t):n.splice(e,0,t),t.parent=this,t.didChange=!0,t._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.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 s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.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)}},bs={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,s=n.length;for(let r=0;r<s;r++)n[r].collectRenderables(t,e,i)},collectRenderablesWithEffects(t,e,i){const{renderPipes:n}=e;for(let e=0;e<this.effects.length;e++){const i=this.effects[e];n[i.pipe].push(i,this,t)}this.collectRenderablesSimple(t,e,i);for(let e=this.effects.length-1;e>=0;e--){const i=this.effects[e];n[i.pipe].pop(i,this,t)}}};class _s{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 vs=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 ms.get(i.maskClass,t)}return t}returnMaskEffect(t){ms.return(t)}};$i.handleByList(Ki.MaskEffect,vs._effectClasses);const ws={_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;e?.mask!==t&&(e&&(this.removeEffect(e),vs.returnMaskEffect(e),this._maskEffect=null),null!=t&&(this._maskEffect=vs.getMaskEffect(t),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(t){this._maskOptions={...this._maskOptions,...t},t.mask&&(this.mask=t.mask),this._markStructureAsChanged()},set filters(t){!Array.isArray(t)&&t&&(t=[t]);const e=this._filterEffect||(this._filterEffect=new _s),i=t?.length>0,n=i!==e.filters?.length>0;t=Array.isArray(t)?t.slice(0):t,e.filters=Object.freeze(t),n&&(i?this.addEffect(e):(this.removeEffect(e),e.filters=t??null))},get filters(){return this._filterEffect?.filters},set filterArea(t){this._filterEffect||(this._filterEffect=new _s),this._filterEffect.filterArea=t},get filterArea(){return this._filterEffect?.filterArea}},Cs={label:null,get name(){return i(0,"Container.name property has been removed, use Container.label instead"),this.label},set name(t){i(0,"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 e=0;e<i.length;e++){const n=i[e];if(n.label===t||t instanceof RegExp&&t.test(n.label))return n}if(e)for(let e=0;e<i.length;e++){const n=i[e].getChildByLabel(t,!0);if(n)return n}return null},getChildrenByLabel(t,e=!1,i=[]){const n=this.children;for(let e=0;e<n.length;e++){const s=n[e];(s.label===t||t instanceof RegExp&&t.test(s.label))&&i.push(s)}if(e)for(let e=0;e<n.length;e++)n[e].getChildrenByLabel(t,!0,i);return i}},Ss=new gs(un),As=new gs(jn),Is=new un,Ms={getFastGlobalBounds(t,e){e||(e=new jn),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 s=!!this.effects.length;if((this.renderGroup||s)&&(n=As.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 s=0;s<e.length;s++)e[s]._getGlobalBoundsRecursive(t,n,i)}if(s){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(Is).invert()),e.addBounds(n),As.return(n)}else this.renderGroup&&(e.addBounds(n,this.relativeGroupTransform),As.return(n))}},Ts=16777215,Ps={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 un,e){if(e)return t.copyFrom(this.worldTransform);this.updateLocalTransform();const i=d(this,Ss.get().identity());return t.appendFrom(this.localTransform,i),Ss.return(i),t},getGlobalTint(t){if(t)return this.renderGroup?f(this.renderGroup.worldColor):this.parentRenderGroup?f(p(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,i=this.parent;for(;i;)e=p(e,i.localColor),i=i.parent;return f(e)}},Es=new un,Bs={_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 jn});const t=this._localBoundsCacheData;return t.index=1,t.didChange=!1,t.data[0]!==this._didViewChangeTick&&(t.didChange=!0,t.data[0]=this._didViewChangeTick),y(this,t),t.didChange&&g(this,t.localBounds,Es),t.localBounds},getBounds(t,e){return l(this,t,e||new jn)}},Os={_onRender:null,set onRender(t){const e=this.renderGroup||this.parentRenderGroup;if(!t)return this._onRender&&e?.removeOnRender(this),void(this._onRender=null);this._onRender||e?.addOnRender(this),this._onRender=t},get onRender(){return this._onRender}},ks={_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(x))}},Rs={getGlobalPosition(t=new cn,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(Ss.get(),i);return e=n.apply(t,e),Ss.return(n),e},toLocal(t,e,i,n){e&&(t=e.toGlobal(t,i,n));const s=this.getGlobalTransform(Ss.get(),n);return i=s.applyInverse(t,i),Ss.return(s),i}};class Ds{constructor(){this.uid=e("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}}let Fs=0;const Ls=new class{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new En(this.textureOptions)}createTexture(t,e,i){const n=new On({...this.textureOptions,width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1});return new Fn({source:n,label:"texturePool_"+Fs++})}getOptimalTexture(t,e,i=1,s){let r=Math.ceil(t*i-1e-6),o=Math.ceil(e*i-1e-6);r=n(r),o=n(o);const a=(r<<17)+(o<<1)+(s?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let h=this._texturePool[a].pop();return h||(h=this.createTexture(r,o,s)),h.source._resolution=i,h.source.width=r/i,h.source.height=o/i,h.source.pixelWidth=r,h.source.pixelHeight=o,h.frame.x=0,h.frame.y=0,h.frame.width=t,h.frame.height=e,h.updateUvs(),this._poolKeyHash[h.uid]=a,h}getSameSizeTexture(t,e=!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 t in this._texturePool){const e=this._texturePool[t];if(e)for(let t=0;t<e.length;t++)e[t].destroy(!0)}this._texturePool={}}};class js{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new un,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 Ds,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 t=0;t<e.length;t++){const i=e[t];i._updateFlags=15,this.addChild(i)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(Ls.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 t=0;t<e.length;t++)this.addChild(e[t])}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 t=0;t<e.length;t++)this.removeChild(e[t])}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 t=0;t<i.length;t++)this._getChildren(i[t],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return 1&this._matrixDirty?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new un),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return 2&this._matrixDirty?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new un),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 un),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 Gs=new nn(null),Us=new nn(null),Ns=new nn(null,1,1),zs=new nn(null);class Hs extends on{constructor(t={}){super(),this.uid=e("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 un,this.relativeGroupTransform=new un,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new nn(this,0,0),this._scale=Ns,this._pivot=Us,this._origin=zs,this._skew=Gs,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}),t.children?.forEach(t=>this.addChild(t)),t.parent?.addChild(this)}static mixin(t){i(0,"Container.mixin is deprecated, please use extensions.mixin instead."),$i.mixin(Hs,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||i(0,"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],n=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),n&&(n.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,n&&n.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;t?.removeChild(this),this.renderGroup=ms.get(js,this),this.groupTransform=un.IDENTITY,t?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),ms.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&0===this.effects.length}get worldTransform(){return this._worldTransform||(this._worldTransform=new un),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*hn}set angle(t){this.rotation=t*ln}get pivot(){return this._pivot===Us&&(this._pivot=new nn(this,0,0)),this._pivot}set pivot(t){this._pivot===Us&&(this._pivot=new nn(this,0,0),this._origin!==zs&&a()),"number"==typeof t?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Gs&&(this._skew=new nn(this,0,0)),this._skew}set skew(t){this._skew===Gs&&(this._skew=new nn(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Ns&&(this._scale=new nn(this,1,1)),this._scale}set scale(t){this._scale===Ns&&(this._scale=new nn(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===zs&&(this._origin=new nn(this,0,0)),this._origin}set origin(t){this._origin===zs&&(this._origin=new nn(this,0,0),this._pivot!==Us&&a()),"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){const i=this.getLocalBounds();"object"==typeof t?(e=t.height??t.width,t=t.width):e??(e=t),void 0!==t&&this._setWidth(t,i.width),void 0!==e&&this._setHeight(e,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set("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,s=this._origin,r=this._position,o=i._x,a=i._y,h=n._x,l=n._y,c=-s._x,d=-s._y;e.a=this._cx*o,e.b=this._sx*o,e.c=this._cy*a,e.d=this._sy*a,e.tx=r._x-(h*e.a+l*e.c)+(c*e.a+d*e.c)-c,e.ty=r._y-(h*e.b+l*e.d)+(c*e.b+d*e.d)-d}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=1,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=ps.shared.setValue(t??16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=1,this._onUpdate())}get tint(){return f(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){if(this.destroyed)return;let e;if(this.destroyed=!0,this.children.length&&(e=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),("boolean"==typeof t?t:t?.children)&&e)for(let i=0;i<e.length;++i)e[i].destroy(t);this.renderGroup?.destroy(),this.renderGroup=null}}$i.mixin(Hs,xs,Ms,Rs,Os,Bs,ws,Cs,ks,{cullArea:null,cullable:!1,cullableChildren:!0},ys,Ps,bs);class Vs extends Hs{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this._bounds=new jn(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){super.destroy(t),this._bounds=null;for(const t in this._gpuData)this._gpuData[t].destroy?.();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 s=this.children,r=s.length;for(let n=0;n<r;n++)s[n].collectRenderables(t,e,i)}}class Ws extends Vs{constructor(t=Fn.EMPTY){t instanceof Fn&&(t={texture:t});const{texture:e=Fn.EMPTY,anchor:i,roundPixels:n,width:s,height:r,...o}=t;super({label:"Sprite",...o}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new nn({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=n??!1,void 0!==s&&(this.width=s),void 0!==r&&(this.height=r)}static from(t,e=!1){return new Ws(t instanceof Fn?t:Fn.from(t,e))}set texture(t){t||(t=Fn.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 o(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return i(0,"Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:n,height:s}=e.orig;i.minX=-t._x*n,i.maxX=i.minX+n,i.minY=-t._y*s,i.maxY=i.minY+s}destroy(t=!1){if(super.destroy(t),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t: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){"object"==typeof t?(e=t.height??t.width,t=t.width):e??(e=t),void 0!==t&&this._setWidth(t,this._texture.orig.width),void 0!==e&&this._setHeight(e,this._texture.orig.height)}}const Zs=new jn;class Js{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Ws),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||b(this.mask,t,e)}addLocalBounds(t,e){_(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof Ws}}Js.extension=Ki.MaskEffect;class Xs{constructor(t){this.priority=0,this.pipe="colorMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return"number"==typeof t}}Xs.extension=Ki.MaskEffect;class Ys{constructor(t){this.priority=0,this.pipe="stencilMask",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){b(this.mask,t,e)}addLocalBounds(t,e){_(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof Hs}}Ys.extension=Ki.MaskEffect;let Ks={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:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(t,e)=>fetch(t,e),parseXML:t=>(new DOMParser).parseFromString(t,"text/xml")};const qs={get:()=>Ks,set(t){Ks=t}};class Qs extends On{constructor(t){t.resource||(t.resource=qs.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"))}}Qs.extension=Ki.TextureSource;class $s extends On{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}}$s.extension=Ki.TextureSource;var tr=(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))(tr||{});class er{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 ir=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 er(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=tr.NORMAL){return this._addListener(new er(t,e,i))}addOnce(t,e,i=tr.NORMAL){return this._addListener(new er(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 s=n.next;for(;s;)s=s.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}};ir.targetFPMS=.06;let nr,sr=ir;const rr=class t extends On{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...t.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=!1!==e.autoPlay,this.alphaMode=e.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),!1!==e.autoLoad&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=sr.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await w(),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&&(sr.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||(sr.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(sr.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};rr.extension=Ki.TextureSource,rr.defaultOptions={...On.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1},rr.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let or=rr;const ar=(t,e,i=!1)=>(Array.isArray(t)||(t=[t]),e?t.map(t=>"string"==typeof t||i?e(t):t):t),hr=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||a(),e}set(t,e){const i=ar(t);let n;for(let t=0;t<this.parsers.length;t++){const s=this.parsers[t];if(s.test(e)){n=s.getCacheableAssets(i,e);break}}const s=new Map(Object.entries(n||{}));n||i.forEach(t=>{s.set(t,e)});const r=[...s.keys()],o={cacheKeys:r,keys:i};i.forEach(t=>{this._cacheMap.set(t,o)}),r.forEach(t=>{const i=n?n[t]:e;this._cache.has(t)&&this._cache.get(t)!==i&&a(),this._cache.set(t,s.get(t))})}remove(t){if(!this._cacheMap.has(t))return void a();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}},lr=[];$i.handleByList(Ki.TextureSource,lr),Fn.from=function(t,e=!1){return"string"==typeof t?hr.get(t):t instanceof On?new Fn({source:t}):function(t={},e=!1){const i=t&&t.resource,n=i?t.resource:t,s=i?t:{resource:t};if(!e&&hr.has(n))return hr.get(n);const r=new Fn({source:C(s)});return r.on("destroy",()=>{hr.has(n)&&hr.remove(n)}),e||hr.set(n,r),r}(t,e)},On.from=C,$i.add(Js,Xs,Ys,or,$s,Qs,kn);var cr=(t=>(t[t.Low=0]="Low",t[t.Normal=1]="Normal",t[t.High=2]="High",t))(cr||{});const dr={toPosix:t=>t.replace(new RegExp("\\".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),"/"),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){S(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(S(t),this.isDataUrl(t)||this.isBlobUrl(t))return t;const n=A(this.toPosix(e??qs.get().getBaseUrl())),s=A(this.toPosix(i??this.rootname(n)));return(t=this.toPosix(t)).startsWith("/")?dr.join(s,t.slice(1)):this.isAbsolute(t)?t:this.join(n,t)},normalize(t){if(S(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,s=0,r=-1;for(let o=0;o<=t.length;++o){if(o<t.length)r=t.charCodeAt(o);else{if(47===r)break;r=47}if(47===r){if(n===o-1||1===s);else if(n!==o-1&&2===s){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,s=0;continue}}else if(2===e.length||1===e.length){e="",i=0,n=o,s=0;continue}}else e.length>0?e+=`/${t.slice(n+1,o)}`:e=t.slice(n+1,o),i=o-n-1;n=o,s=0}else 46===r&&-1!==s?++s:s=-1}return e}(t)).length>0&&n&&(t+="/"),i?`/${t}`:e+t},isAbsolute(t){return S(t),t=this.toPosix(t),!!this.hasProtocol(t)||t.startsWith("/")},join(...t){if(0===t.length)return".";let e;for(let i=0;i<t.length;++i){const n=t[i];if(S(n),n.length>0)if(void 0===e)e=n;else{const s=t[i-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?e+=`/../${n}`:e+=`/${n}`}}return void 0===e?".":this.normalize(e)},dirname(t){if(S(t),0===t.length)return".";let e=(t=this.toPosix(t)).charCodeAt(0);const i=47===e;let n=-1,s=!0;const r=this.getProtocol(t),o=t;for(let i=(t=t.slice(r.length)).length-1;i>=1;--i)if(e=t.charCodeAt(i),47===e){if(!s){n=i;break}}else s=!1;return-1===n?i?"/":this.isUrl(o)?r+t:r:i&&1===n?"//":r+t.slice(0,n)},rootname(t){S(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){S(t),e&&S(e),t=A(this.toPosix(t));let i,n=0,s=-1,r=!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 h=t.charCodeAt(i);if(47===h){if(!r){n=i+1;break}}else-1===a&&(r=!1,a=i+1),o>=0&&(h===e.charCodeAt(o)?-1===--o&&(s=i):(o=-1,s=a))}return n===s?s=a:-1===s&&(s=t.length),t.slice(n,s)}for(i=t.length-1;i>=0;--i)if(47===t.charCodeAt(i)){if(!r){n=i+1;break}}else-1===s&&(r=!1,s=i+1);return-1===s?"":t.slice(n,s)},extname(t){S(t);let e=-1,i=0,n=-1,s=!0,r=0;for(let o=(t=A(this.toPosix(t))).length-1;o>=0;--o){const a=t.charCodeAt(o);if(47!==a)-1===n&&(s=!1,n=o+1),46===a?-1===e?e=o:1!==r&&(r=1):-1!==e&&(r=-1);else if(!s){i=o+1;break}}return-1===e||-1===n||0===r||1===r&&e===n-1&&e===i+1?"":t.slice(e,n)},parse(t){S(t);const e={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return e;let i=(t=A(this.toPosix(t))).charCodeAt(0);const n=this.isAbsolute(t);let s;e.root=this.rootname(t),s=n||this.hasProtocol(t)?1:0;let r=-1,o=0,a=-1,h=!0,l=t.length-1,c=0;for(;l>=s;--l)if(i=t.charCodeAt(l),47!==i)-1===a&&(h=!1,a=l+1),46===i?-1===r?r=l:1!==c&&(c=1):-1!==r&&(c=-1);else if(!h){o=l+1;break}return-1===r||-1===a||0===c||1===c&&r===a-1&&r===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,r),e.base=t.slice(1,a)):(e.name=t.slice(o,r),e.base=t.slice(o,a)),e.ext=t.slice(r,a)),e.dir=this.dirname(t),e},sep:"/",delimiter:":",joinExtensions:[".html"]},ur=t=>!Array.isArray(t);class pr{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,"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 ar(e||i,t=>"string"==typeof t?t:Array.isArray(t)?t.map(t=>t?.src??t):t?.src?t.src:t,!0)}addManifest(t){this._manifest&&a(),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}:{alias:t,...e})),n.forEach(e=>{const n=e.src,s=e.alias;let r;if("string"==typeof s){const e=this._createBundleAssetId(t,s);i.push(e),r=[s,e]}else{const e=s.map(e=>this._createBundleAssetId(t,e));i.push(...e),r=[...s,...e]}this.add({...e,alias:r,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)&&a()},ar(e).forEach(t=>{const{src:e}=t;let{data:n,format:s,loadParser:r,parser:o}=t;const a=ar(e).map(t=>"string"==typeof t?M(t):Array.isArray(t)?t:[t]),h=this.getAlias(t);Array.isArray(h)?h.forEach(i):i(h);const l=[];a.forEach(t=>{t.forEach(t=>{let e={};if("object"!=typeof t){e.src=t;for(let i=0;i<this._parsers.length;i++){const n=this._parsers[i];if(n.test(t)){e=n.parse(t);break}}}else n=t.data??n,s=t.format??s,(t.loadParser||t.parser)&&(r=t.loadParser??r,o=t.parser??o),e={...e,...t};if(!h)throw new Error(`[Resolver] alias is undefined for this asset: ${e.src}`);e=this._buildResolvedAsset(e,{aliases:h,data:n,format:s,loadParser:r,parser:o}),l.push(e)})}),h.forEach(t=>{this._assetMap[t]=l})})}resolveBundle(t){const e=ur(t);t=ar(t);const i={};return t.forEach(t=>{const e=this._bundles[t];if(e){const n=this.resolve(e),s={};for(const e in n){const i=n[e];s[this._extractAssetIdFromBundle(t,e)]=i}i[t]=s}}),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=ur(t);t=ar(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);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){return this._defaultSearchParams?`${t}${/\?/.test(t)?"&":"?"}${this._defaultSearchParams}`:t}_buildResolvedAsset(t,e){const{aliases:i,data:n,loadParser:s,parser:r,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=dr.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=s??t.loadParser,t.parser=r??t.parser,t.format=o??t.format??t.src.split(".").pop().split("?").shift().split("#").shift(),t}}pr.RETINA_PREFIX=/@([0-9\.]+)x/;const fr=(t,e)=>{const i=e.split("?")[1];return i&&(t+=`?${i}`),t},gr=class t{constructor(t,e){this.linkedSheets=[];let i=t;t?.source instanceof On&&(i={texture:t,data:e});const{texture:n,data:s,cachePrefix:r=""}=i;this.cachePrefix=r,this._texture=n instanceof Fn?n:null,this.textureSource=n.source,this.textures={},this.animations={},this.data=s;const o=parseFloat(s.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,s=null;const r=!1!==e.trimmed&&e.sourceSize?e.sourceSize:e.frame,o=new Sn(0,0,Math.floor(r.w)/this.resolution,Math.floor(r.h)/this.resolution);i=e.rotated?new Sn(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 Sn(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&&(s=new Sn(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 Fn({source:this.textureSource,frame:i,orig:o,trim:s,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){for(const t in this.textures)this.textures[t].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};gr.BATCH_SIZE=1e3;let mr=gr;const yr=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"],xr={extension:Ki.Asset,cache:{test:t=>t instanceof mr,getCacheableAssets:(t,e)=>T(t,e,!1)},resolver:{extension:{type:Ki.ResolveParser,name:"resolveSpritesheet"},test:t=>{const e=t.split("?")[0].split("."),i=e.pop(),n=e.pop();return"json"===i&&yr.includes(n)},parse:t=>{const e=t.split(".");return{resolution:parseFloat(pr.RETINA_PREFIX.exec(t)?.[1]??"1"),format:e[e.length-2],src:t}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:Ki.LoadParser,priority:cr.Normal,name:"spritesheetLoader"},testParse:async(t,e)=>".json"===dr.extname(e.src).toLowerCase()&&!!t.frames,async parse(t,e,i){const{texture:n,imageFilename:s,textureOptions:r,cachePrefix:o}=e?.data??{};let a,h=dr.dirname(e.src);if(h&&h.lastIndexOf("/")!==h.length-1&&(h+="/"),n instanceof Fn)a=n;else{const n=fr(h+(s??t.meta.image),e.src);a=(await i.load([{src:n,data:r}]))[n]}const l=new mr({texture:a.source,data:t,cachePrefix:o});await l.parse();const c=t?.meta?.related_multi_packs;if(Array.isArray(c)){const t=[];for(const n of c){if("string"!=typeof n)continue;let s=h+n;e.data?.ignoreMultiPack||(s=fr(s,e.src),t.push(i.load({src:s,data:{textureOptions:r,ignoreMultiPack:!0}})))}const n=await Promise.all(t);l.linkedSheets=n,n.forEach(t=>{t.linkedSheets=[l].concat(l.linkedSheets.filter(e=>e!==t))})}return l},async unload(t,e,i){await i.unload(t.textureSource._sourceOrigin),t.destroy(!1)}}};$i.add(xr);class br{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,s=t.height/i*this._renderer.resolution,r=`translate(${t.left}px, ${t.top}px) scale(${n}, ${s})`;r!==this._lastTransform&&(this._domElement.style.transform=r,this._lastTransform=r)},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,s=e.contentRect.height/i*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==s)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=s)}}),this._observer.observe(this._canvas)):this._tickerAttached||sr.shared.add(this.updateTranslation,this,tr.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&sr.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 _r{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=_r.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new cn,this.page=new cn,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,s){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 vr=/iPhone/i,wr=/iPod/i,Cr=/iPad/i,Sr=/\biOS-universal(?:.+)Mac\b/i,Ar=/\bAndroid(?:.+)Mobile\b/i,Ir=/Android/i,Mr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Tr=/Silk/i,Pr=/Windows Phone/i,Er=/\bWindows(?:.+)ARM\b/i,Br=/BlackBerry/i,Or=/BB10/i,kr=/Opera Mini/i,Rr=/\b(CriOS|Chrome)(?:.+)Mobile/i,Dr=/Mobile(?:.+)Firefox\b/i,Fr=function(t){return void 0!==t&&"MacIntel"===t.platform&&"number"==typeof t.maxTouchPoints&&t.maxTouchPoints>1&&"undefined"==typeof MSStream};const Lr=(P.default??P)(globalThis.navigator),jr=class t{constructor(t,e=Lr){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 br({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 t=0;t<e.length;t++)this._updateAccessibleObjects(e[t])}init(e){const i={accessibilityOptions:{...t.defaultOptions,...e?.accessibilityOptions||{}}};this.debug=i.accessibilityOptions.debug,this._activateOnTab=i.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=i.accessibilityOptions.deactivateOnMouseMove,i.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 t=this._children.length-1;t>=0;t--){const i=this._children[t];e.has(t)||(i._accessibleDiv&&i._accessibleDiv.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),this._pool.push(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1,h(this._children,t,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let t=0;t<this._children.length;t++){const e=this._children[t];if(!e._accessibleActive||!e._accessibleDiv)continue;const i=e._accessibleDiv,n=e.hitArea||e.getBounds().rectangle;if(e.hitArea){const t=e.worldTransform;i.style.left=`${t.tx+n.x*t.a}px`,i.style.top=`${t.ty+n.y*t.d}px`,i.style.width=n.width*t.a+"px",i.style.height=n.height*t.d+"px"}else this._capHitArea(n),i.style.left=`${n.x}px`,i.style.top=`${n.y}px`,i.style.width=`${n.width}px`,i.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,s=Object.assign(new _r(n),{target:i});n.rootTarget=this._renderer.lastObjectRendered,e.forEach(t=>n.dispatchEvent(s,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(){this._deactivate(),this._destroyTouchHook(),this._canvasObserver?.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()}};jr.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem],name:"accessibility"},jr.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let Gr=jr;const Ur=Object.create(null),Nr=Object.create(null);let zr,Hr;const Vr={},Wr={},Zr={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 s=i?e.requestedFragmentPrecision:e.requestedVertexPrecision;return"highp"===s&&"highp"!==n&&(s="mediump"),`precision ${s} 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?Vr:Wr;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}},Jr=Object.create(null),Xr=class t{constructor(e){const i=-1!==(e={...t.defaultOptions,...e}).fragment.indexOf("#version 300 es"),n={stripVersion:i,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:O()},setProgramName:{name:e.name},addProgramDefines:i,insertVersion:i};let s=e.fragment,r=e.vertex;Object.keys(Zr).forEach(t=>{const e=n[t];s=Zr[t](s,e,!0),r=Zr[t](r,e,!1)}),this.fragment=s,this.vertex=r,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=E(`${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 Jr[i]||(Jr[i]=new t(e)),Jr[i]}};Xr.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Yr=Xr;const Kr={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}},qr={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"};var Qr=(t=>(t[t.VERTEX=1]="VERTEX",t[t.FRAGMENT=2]="FRAGMENT",t[t.COMPUTE=4]="COMPUTE",t))(Qr||{});const $r=Object.create(null);class to{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:n,gpuLayout:s,name:r}=t;if(this.name=r,this.fragment=e,this.vertex=i,e.source===i.source){const t=R(e.source);this.structsAndGroups=t}else{const t=R(i.source),n=R(e.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,n)}this.layout=n??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=s??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:Qr.VERTEX|Qr.FRAGMENT,buffer:{type:"uniform"}}):"sampler"===n.type?e[n.group].push({binding:n.binding,visibility:Qr.FRAGMENT,sampler:{type:"filtering"}}):"texture_2d"===n.type&&e[n.group].push({binding:n.binding,visibility:Qr.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return e}(this.structsAndGroups),this.autoAssignGlobalUniforms=!(void 0===this.layout[0]?.globalUniforms),this.autoAssignLocalUniforms=!(void 0===this.layout[1]?.localUniforms),this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=E(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=function({source:t,entryPoint:e}){const i={},n=t.indexOf(`fn ${e}`);if(-1!==n){const e=t.indexOf("->",n);if(-1!==e){const s=t.substring(n,e),r=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;null!==(o=r.exec(s));){const t=qr[o[3]]??"float32";i[o[2]]={location:parseInt(o[1],10),format:t,stride:k(t).stride,offset:0,instance:!1,start:0}}}}return i}(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 $r[e]||($r[e]=new to(t)),$r[e]}}const eo=["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>"],io=eo.reduce((t,e)=>(t[e]=!0,t),{}),no=class t{constructor(i,n){this._touched=0,this.uid=e("uniform"),this._resourceType="uniformGroup",this._resourceId=e("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,n={...t.defaultOptions,...n},this.uniformStructures=i;const s={};for(const t in i){const e=i[t];if(e.name=t,e.size=e.size??1,!io[e.type])throw new Error(`Uniform type ${e.type} is not supported. Supported uniform types are: ${eo.join(", ")}`);e.value??(e.value=D(e.type,e.size)),s[t]=e.value}this.uniforms=s,this._dirtyId=1,this.ubo=n.ubo,this.isStatic=n.isStatic,this._signature=E(Object.keys(s).map(t=>`${t}-${i[t].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};no.defaultOptions={ubo:!1,isStatic:!1};let so=no;class ro{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){const i=this.resources[e];t!==i&&(i&&t.off?.("change",this.onResourceChange,this),t.on?.("change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const i in e)e[i]._touched=t}destroy(){const t=this.resources;for(const e in t){const i=t[e];i.off?.("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 oo=(t=>(t[t.WEBGL=1]="WEBGL",t[t.WEBGPU=2]="WEBGPU",t[t.BOTH=3]="BOTH",t))(oo||{});class ao extends on{constructor(t){super(),this.uid=e("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:i,glProgram:n,groups:s,resources:r,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=i,this.glProgram=n,void 0===o&&(o=0,i&&(o|=oo.WEBGPU),n&&(o|=oo.WEBGL)),this.compatibleRenderers=o;const h={};if(r||s||(r={}),r&&s)throw new Error("[Shader] Cannot have both resources and groups");if(!i&&s&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!i&&s&&a)for(const t in a)for(const e in a[t]){const i=a[t][e];h[i]={group:t,binding:e,name:i}}else if(i&&s&&!a){const t=i.structsAndGroups.groups;a={},t.forEach(t=>{a[t.group]=a[t.group]||{},a[t.group][t.binding]=t.name,h[t.name]=t})}else if(r){s={},a={},i&&i.structsAndGroups.groups.forEach(t=>{a[t.group]=a[t.group]||{},a[t.group][t.binding]=t.name,h[t.name]=t});let t=0;for(const e in r)h[e]||(s[99]||(s[99]=new ro,this._ownedBindGroups.push(s[99])),h[e]={group:99,binding:t,name:e},a[99]=a[99]||{},a[99][t]=e,t++);for(const t in r){const e=t;let i=r[t];i.source||i._resourceType||(i=new so(i));const n=h[e];n&&(s[n.group]||(s[n.group]=new ro,this._ownedBindGroups.push(s[n.group])),s[n.group].setResource(i,n.binding))}}this.groups=s,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(s,h)}addResource(t,e,i){var n,s;(n=this._uniformBindMap)[e]||(n[e]={}),(s=this._uniformBindMap[e])[i]||(s[i]=t),this.groups[e]||(this.groups[e]=new ro,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const n in e){const s=e[n];Object.defineProperty(i,s.name,{get:()=>t[s.group].getResource(s.binding),set(e){t[s.group].setResource(e,s.binding)}})}return i}destroy(t=!1){this.emit("destroy",this),t&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(t=>{t.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:i,...n}=t;let s,r;return e&&(s=to.from(e)),i&&(r=Yr.from(i)),new ao({gpuProgram:s,glProgram:r,...n})}}const ho={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},lo=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=ho[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}};lo.default2d=lo.for2d();let co=lo;const uo=class t extends ao{constructor(e){super(e={...t.defaultOptions,...e}),this.enabled=!0,this._state=co.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{gpu:i,gl:n,...s}=e;let r,o;return i&&(r=to.from(i)),n&&(o=Yr.from(n)),new t({gpuProgram:r,glProgram:o,...s})}};uo.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let po=uo;const fo=[];let go;$i.handleByNamedList(Ki.Environment,fo);const mo=L.default||L;var yo=(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))(yo||{});class xo{constructor(t){this.items=[],this._name=t}emit(t,e,i,n,s,r,o,a){const{name:h,items:l}=this;for(let c=0,d=l.length;c<d;c++)l[c][h](t,e,i,n,s,r,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 bo=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],_o=class t extends on{constructor(t){super(),this.uid=e("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=[...bo,...this.config.runners??[]];this._addRunners(...i),this._unsafeEvalCheck()}async init(e={}){const i=!0===e.skipExtensionImports||!1===e.manageImports;await async function(t){if(!t)for(let t=0;t<fo.length;t++){const e=fo[t];if(e.value.test())return void await e.value.load()}}(i),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const t in this._systemsHash)e={...this._systemsHash[t].constructor.defaultOptions,...e};e={...t.defaultOptions,...e},this._roundPixels=e.roundPixels?1:0;for(let t=0;t<this.runners.init.items.length;t++)await this.runners.init.items[t].init(e);this._initOptions=e}render(t,e){let n=t;if(n instanceof Hs&&(n={container:n},e&&(i(0,"passing a second argument is deprecated, please use render options instead"),n.target=e.renderTexture)),n.target||(n.target=this.view.renderTarget),n.target===this.view.renderTarget&&(this._lastObjectRendered=n.container,n.clearColor??(n.clearColor=this.background.colorRgba),n.clear??(n.clear=this.background.clearBeforeRender)),n.clearColor){const t=Array.isArray(n.clearColor)&&4===n.clearColor.length;n.clearColor=t?n.clearColor:ps.shared.setValue(n.clearColor).toArray()}n.transform||(n.container.updateLocalTransform(),n.transform=n.container.localTransform),n.container.enableRenderGroup(),this.runners.prerender.emit(n),this.runners.renderStart.emit(n),this.runners.render.emit(n),this.runners.renderEnd.emit(n),this.runners.postrender.emit(n)}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),t.clear??(t.clear=yo.ALL);const{clear:e,clearColor:i,target:n}=t;ps.shared.setValue(i??this.background.colorRgba),this.renderTarget.clear(n,e,ps.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 xo(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 t in this.runners)this.runners[t].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,s=i[n];this.renderPipes[n]=new e(this,s?new s: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(!F())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()}};_o.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let vo,wo,Co=_o;const So=["webgl","webgpu","canvas"],Ao="8.12.0";class Io{static init(){globalThis.__PIXI_APP_INIT__?.(this,Ao)}static destroy(){}}Io.extension=Ki.Application;class Mo{constructor(t){this._renderer=t}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,Ao)}destroy(){this._renderer=null}}Mo.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem],name:"initHook",priority:-10};const To=class t{constructor(...t){this.stage=new Hs,void 0!==t[0]&&i(0,"Application constructor options are deprecated, please use Application.init() instead.")}async init(e){e={...e},this.renderer=await async function(t){let e,i=[];t.preference?(i.push(t.preference),So.forEach(e=>{e!==t.preference&&i.push(e)})):i=So.slice();let n={};for(let s=0;s<i.length;s++){const r=i[s];if("webgpu"===r&&await ct()){const{WebGPURenderer:i}=await Promise.resolve().then(()=>Ou);e=i,n={...t,...t.webgpu};break}if("webgl"===r&<(t.failIfMajorPerformanceCaveat??Co.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:i}=await Promise.resolve().then(()=>Yd);e=i,n={...t,...t.webgl};break}if("canvas"===r)throw n={...t},new Error("CanvasRenderer is not yet implemented")}if(delete n.webgpu,delete n.webgl,!e)throw new Error("No available renderer for the current environment");const s=new e;return await s.init(n),s}(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 i(0,"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}};To._plugins=[];let Po=To;$i.handleByList(Ki.Application,Po._plugins),$i.add(Io);class Eo{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}}Eo.extension=Ki.Application;class Bo{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,tr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?sr.shared:new sr,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Bo.extension=Ki.Application;class Oo extends on{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 i(0,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return i(0,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return i(0,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return i(0,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return i(0,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners();for(const t in this.chars)this.chars[t].texture?.destroy();this.chars=null,t&&(this.pages.forEach(t=>t.texture.destroy(!0)),this.pages=null)}}const ko=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Ro={willReadFrequently:!0},Do=class t{static get experimentalLetterSpacingSupported(){let e=t._experimentalLetterSpacingSupported;if(void 0===e){const i=qs.get().getCanvasRenderingContext2D().prototype;e=t._experimentalLetterSpacingSupported="letterSpacing"in i||"textLetterSpacing"in i}return e}constructor(t,e,i,n,s,r,o,a,h){this.text=t,this.style=e,this.width=i,this.height=n,this.lines=s,this.lineWidths=r,this.lineHeight=o,this.maxLineWidth=a,this.fontProperties=h}static measureText(e=" ",i,n=t._canvas,s=i.wordWrap){const r=dt(i),o=t.measureFont(r);0===o.fontSize&&(o.fontSize=i.fontSize,o.ascent=i.fontSize);const a=t.__context;a.font=r;const h=(s?t._wordWrap(e,i,n):e).split(/(?:\r\n|\r|\n)/),l=new Array(h.length);let c=0;for(let e=0;e<h.length;e++){const n=t._measureText(h[e],i.letterSpacing,a);l[e]=n,c=Math.max(c,n)}const d=i._stroke?.width||0;let u=c+d;i.dropShadow&&(u+=i.dropShadow.distance);const p=i.lineHeight||o.fontSize;let f=Math.max(p,o.fontSize+d)+(h.length-1)*(p+i.leading);return i.dropShadow&&(f+=i.dropShadow.distance),new t(e,i,u,f,h,l,p+i.leading,c,o)}static _measureText(e,i,n){let s=!1;t.experimentalLetterSpacingSupported&&(t.experimentalLetterSpacing?(n.letterSpacing=`${i}px`,n.textLetterSpacing=`${i}px`,s=!0):(n.letterSpacing="0px",n.textLetterSpacing="0px"));const r=n.measureText(e);let o=r.width;const a=-r.actualBoundingBoxLeft;let h=r.actualBoundingBoxRight-a;if(o>0)if(s)o-=i,h-=i;else{const n=(t.graphemeSegmenter(e).length-1)*i;o+=n,h+=n}return Math.max(o,h)}static _wordWrap(e,i,n=t._canvas){const s=n.getContext("2d",Ro);let r=0,o="",a="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=i,d=t._collapseSpaces(c),u=t._collapseNewlines(c);let p=!d;const f=i.wordWrapWidth+l,g=t._tokenize(e);for(let e=0;e<g.length;e++){let n=g[e];if(t._isNewline(n)){if(!u){a+=t._addLine(o),p=!d,o="",r=0;continue}n=" "}if(d){const e=t.isBreakingSpace(n),i=t.isBreakingSpace(o[o.length-1]);if(e&&i)continue}const c=t._getFromCache(n,l,h,s);if(c>f)if(""!==o&&(a+=t._addLine(o),o="",r=0),t.canBreakWords(n,i.breakWords)){const e=t.wordWrapSplit(n);for(let c=0;c<e.length;c++){let d=e[c],u=d,g=1;for(;e[c+g];){const s=e[c+g];if(t.canBreakChars(u,s,n,c,i.breakWords))break;d+=s,u=s,g++}c+=g-1;const m=t._getFromCache(d,l,h,s);m+r>f&&(a+=t._addLine(o),p=!1,o="",r=0),o+=d,r+=m}}else{o.length>0&&(a+=t._addLine(o),o="",r=0);const i=e===g.length-1;a+=t._addLine(n,!i),p=!1,o="",r=0}else c+r>f&&(p=!1,a+=t._addLine(o),o="",r=0),(o.length>0||!t.isBreakingSpace(n)||p)&&(o+=n,r+=c)}return a+=t._addLine(o,!1),a}static _addLine(e,i=!0){return e=t._trimRight(e),i?`${e}\n`:e}static _getFromCache(e,i,n,s){let r=n[e];return"number"!=typeof r&&(r=t._measureText(e,i,s)+i,n[e]=r),r}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 s=0;s<e.length;s++){const r=e[s],o=e[s+1];t.isBreakingSpace(r,o)||t._isNewline(r)?(""!==n&&(i.push(n),n=""),"\r"===r&&"\n"===o?(i.push("\r\n"),s++):i.push(r)):n+=r}return""!==n&&i.push(n),i}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,n,s){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),s={ascent:n.actualBoundingBoxAscent,descent:n.actualBoundingBoxDescent,fontSize:n.actualBoundingBoxAscent+n.actualBoundingBoxDescent};return t._fonts[e]=s,s}static clearMetrics(e=""){e?delete t._fonts[e]:t._fonts={}}static get _canvas(){if(!t.__canvas){let e;try{const i=new OffscreenCanvas(0,0),n=i.getContext("2d",Ro);if(n?.measureText)return t.__canvas=i,i;e=qs.get().createCanvas()}catch(t){e=qs.get().createCanvas()}e.width=e.height=10,t.__canvas=e}return t.__canvas}static get _context(){return t.__context||(t.__context=t._canvas.getContext("2d",Ro)),t.__context}};Do.METRICS_STRING="|ÉqÅ",Do.BASELINE_SYMBOL="M",Do.BASELINE_MULTIPLIER=1.4,Do.HEIGHT_MULTIPLIER=2,Do.graphemeSegmenter=(()=>t=>[...t])(),Do.experimentalLetterSpacing=!1,Do._fonts={},Do._newlines=[10,13],Do._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Fo=Do;const Lo=[{offset:0,color:"white"},{offset:1,color:"black"}],jo=class t{constructor(...n){this.uid=e("fillGradient"),this.type="linear",this.colorStops=[];let s=function(t){let e=t[0]??{};return("number"==typeof e||t[1])&&(i(0,"use options object instead"),e={type:"linear",start:{x:t[0],y:t[1]},end:{x:t[2],y:t[3]},textureSpace:t[4],textureSize:t[5]??Go.defaultLinearOptions.textureSize}),e}(n);s={..."radial"===s.type?t.defaultRadialOptions:t.defaultLinearOptions,...r(s)},this._textureSize=s.textureSize,this._wrapMode=s.wrapMode,"radial"===s.type?(this.center=s.center,this.outerCenter=s.outerCenter??this.center,this.innerRadius=s.innerRadius,this.outerRadius=s.outerRadius,this.scale=s.scale,this.rotation=s.rotation):(this.start=s.start,this.end=s.end),this.textureSpace=s.textureSpace,this.type=s.type,s.colorStops.forEach(t=>{this.addColorStop(t.offset,t.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:ps.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:n}=this.end,s=i-t,r=n-e;const o=s<0||r<0;if("clamp-to-edge"===this._wrapMode){if(s<0){const e=t;t=i,i=e,s*=-1}if(r<0){const t=e;e=n,n=t,r*=-1}}const a=this.colorStops.length?this.colorStops:Lo,h=this._textureSize,{canvas:l,context:c}=pt(h,1),d=o?c.createLinearGradient(this._textureSize,0,0,0):c.createLinearGradient(0,0,this._textureSize,0);ut(d,a),c.fillStyle=d,c.fillRect(0,0,h,1),this.texture=new Fn({source:new $s({resource:l,addressMode:this._wrapMode})});const u=Math.sqrt(s*s+r*r),p=Math.atan2(r,s),f=new un;f.scale(u/h,1),f.rotate(p),f.translate(t,e),"local"===this.textureSpace&&f.scale(h,h),this.transform=f}buildGradient(){"linear"===this.type?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Lo,e=this._textureSize,{canvas:i,context:n}=pt(e,e),{x:s,y:r}=this.center,{x:o,y:a}=this.outerCenter,h=this.innerRadius,l=this.outerRadius,c=o-l,d=a-l,u=e/(2*l),p=(s-c)*u,f=(r-d)*u,g=n.createRadialGradient(p,f,h*u,(o-c)*u,(a-d)*u,l*u);ut(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 Fn({source:new $s({resource:i,addressMode:this._wrapMode})});const m=new un;m.scale(1/u,1/u),m.translate(c,d),"local"===this.textureSpace&&m.scale(e,e),this.transform=m}get styleKey(){return this.uid}destroy(){this.texture?.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}};jo.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},jo.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Go=jo;const Uo={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 No{constructor(t,i){this.uid=e("fillPattern"),this.transform=new un,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),i&&(t.source.style.addressModeU=Uo[i].addressModeU,t.source.style.addressModeV=Uo[i].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 zo,Ho;const Vo=t(function(){if(Ho)return zo;Ho=1,zo=function(n){var s=[];return n.replace(e,function(e,n,r){var o=n.toLowerCase();for(r=function(t){var e=t.match(i);return e?e.map(Number):[]}(r),"m"==o&&r.length>2&&(s.push([n].concat(r.splice(0,2))),o="l",n="m"==n?"l":"L");;){if(r.length==t[o])return r.unshift(n),s.push(r);if(r.length<t[o])throw new Error("malformed path data");s.push([n].concat(r.splice(0,t[o])))}}),s};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 zo}());class Wo{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new Wo(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,s=this.y-e;return n*=n,s*=s,n+s<=i}strokeContains(t,e,i,n=.5){if(0===this.radius)return!1;const s=this.x-t,r=this.y-e,o=this.radius,a=(1-n)*i,h=Math.sqrt(s*s+r*r);return h<=o+a&&h>o-(i-a)}getBounds(t){return t||(t=new Sn),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 Zo{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 Zo(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:s,halfHeight:r}=this;if(s<=0||r<=0)return!1;const o=i*(1-n),a=i-o,h=s-a,l=r-a,c=s+o,d=r+o,u=t-this.x,p=e-this.y;return u*u/(h*h)+p*p/(l*l)>1&&u*u/(c*c)+p*p/(d*d)<=1}getBounds(t){return t||(t=new Sn),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}]`}}class Jo{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 s=e[n],r=e[n+1];t+=(e[(n+2)%i]-s)*(e[(n+3)%i]+r)}return t<0}containsPolygon(t){const e=this.getBounds(void 0),i=t.getBounds(void 0);if(!e.containsRect(i))return!1;const n=t.points;for(let t=0;t<n.length;t+=2){const e=n[t],i=n[t+1];if(!this.contains(e,i))return!1}return!0}clone(){const t=this.points.slice(),e=new Jo(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const n=this.points.length/2;for(let s=0,r=n-1;s<n;r=s++){const n=this.points[2*s],o=this.points[2*s+1],a=this.points[2*r],h=this.points[2*r+1];o>e!=h>e&&t<(e-o)/(h-o)*(a-n)+n&&(i=!i)}return i}strokeContains(t,e,i,n=.5){const s=i*i,r=s*(1-n),o=s-r,{points:a}=this,h=a.length-(this.closePath?0:2);for(let i=0;i<h;i+=2){const n=a[i],s=a[i+1],h=a[(i+2)%a.length],l=a[(i+3)%a.length];if(ft(t,e,n,s,h,l)<=(Math.sign((h-n)*(e-s)-(l-s)*(t-n))<0?o:r))return!0}return!1}getBounds(t){t||(t=new Sn);const e=this.points;let i=1/0,n=-1/0,s=1/0,r=-1/0;for(let t=0,o=e.length;t<o;t+=2){const o=e[t],a=e[t+1];i=o<i?o:i,n=o>n?o:n,s=a<s?a:s,r=a>r?a:r}return t.x=i,t.width=n-i,t.y=s,t.height=r-s,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 i(0,"Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return i(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 Xo=(t,e,i,n,s,r,o)=>{const a=t-i,h=e-n,l=Math.sqrt(a*a+h*h);return l>=s-r&&l<=s+o};class Yo{constructor(t=0,e=0,i=0,n=0,s=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=n,this.radius=s}getBounds(t){return t||(t=new Sn),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Yo(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),s=e-(this.y+i);const r=i*i;if(n*n+s*s<=r)return!0;if(n=t-(this.x+this.width-i),n*n+s*s<=r)return!0;if(s=e-(this.y+this.height-i),n*n+s*s<=r)return!0;if(n=t-(this.x+i),n*n+s*s<=r)return!0}return!1}strokeContains(t,e,i,n=.5){const{x:s,y:r,width:o,height:a,radius:h}=this,l=i*(1-n),c=i-l,d=s+h,u=r+h,p=s+o,f=r+a;return(t>=s-l&&t<=s+c||t>=p-c&&t<=p+l)&&e>=u&&e<=u+(a-2*h)||(e>=r-l&&e<=r+c||e>=f-c&&e<=f+l)&&t>=d&&t<=d+(o-2*h)||t<d&&e<u&&Xo(t,e,d,u,h,c,l)||t>p-h&&e<u&&Xo(t,e,p-h,u,h,c,l)||t>p-h&&e>f-h&&Xo(t,e,p-h,f-h,h,c,l)||t<d&&e>f-h&&Xo(t,e,d,f-h,h,c,l)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const Ko={};class qo{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`)}}}const Qo={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var $o=(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))($o||{});const ta=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join("\n");let ea=null;class ia{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 na{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new ia,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const sa=[];let ra=0,oa=0;const aa=class t{constructor(n){this.uid=e("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],(n={...t.defaultOptions,...n}).maxTextures||(i(0,"maxTextures is a required option for Batcher now, please pass it in the options"),n.maxTextures=function(){if(ea)return ea;const t=B();return ea=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),ea=bt(ea,t),t.getExtension("WEBGL_lose_context")?.loseContext(),ea}());const{maxTextures:s,attributesInitialSize:r,indicesInitialSize:o}=n;this.attributeBuffer=new qo(4*r),this.indexBuffer=new Uint16Array(o),this.maxTextures=s}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)vt(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=_t(),n=i.textures;n.clear();const s=e[this.elementStart];let r=yt(s.blendMode,s.texture._source),o=s.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,h=this.attributeBuffer.uint32View,l=this.indexBuffer;let c=this._batchIndexSize,d=this._batchIndexStart,u="startBatch";const p=this.maxTextures;for(let s=this.elementStart;s<this.elementSize;++s){const f=e[s];e[s]=null;const g=f.texture._source,m=yt(f.blendMode,g),y=r!==m||o!==f.topology;g._batchTick!==oa||y?(g._batchTick=oa,(n.count>=p||y)&&(this._finishBatch(i,d,c-d,n,r,o,t,u),u="renderBatch",d=c,r=m,o=f.topology,i=_t(),n=i.textures,n.clear(),++oa),f._textureId=g._textureBindLocation=n.count,n.ids[g.uid]=n.count,n.textures[n.count++]=g,f._batch=i,c+=f.indexSize,f.packAsQuad?(this.packQuadAttributes(f,a,h,f._attributeStart,f._textureId),this.packQuadIndex(l,f._indexStart,f._attributeStart/this.vertexSize)):(this.packAttributes(f,a,h,f._attributeStart,f._textureId),this.packIndex(f,l,f._indexStart,f._attributeStart/this.vertexSize))):(f._textureId=g._textureBindLocation,c+=f.indexSize,f.packAsQuad?(this.packQuadAttributes(f,a,h,f._attributeStart,f._textureId),this.packQuadIndex(l,f._indexStart,f._attributeStart/this.vertexSize)):(this.packAttributes(f,a,h,f._attributeStart,f._textureId),this.packIndex(f,l,f._indexStart,f._attributeStart/this.vertexSize)),f._batch=i)}n.count>0&&(this._finishBatch(i,d,c-d,n,r,o,t,u),d=c,++oa),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=c}_finishBatch(t,e,i,n,s,r,o,a){t.gpuBindGroup=null,t.bindGroup=null,t.action=a,t.batcher=this,t.textures=n,t.blendMode=s,t.topology=r,t.start=e,t.size=i,++oa,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 qo(e);mt(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 t=0;t<e.length;t++)n[t]=e[t];else mt(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 s=t.indices,r=t.indexSize,o=t.indexOffset,a=t.attributeOffset;for(let t=0;t<r;t++)e[i++]=n+s[t+o]-a}destroy(){for(let t=0;t<this.batches.length;t++)vt(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}};aa.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let ha=aa;var la=(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))(la||{});let ca=class extends on{constructor(t){let{data:i,size:n}=t;const{usage:s,label:r,shrinkToFit:o}=t;super(),this.uid=e("buffer"),this._resourceType="buffer",this._resourceId=e("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,i instanceof Array&&(i=new Float32Array(i)),this._data=i,n??(n=i?.byteLength);const a=!!i;this.descriptor={size:n,usage:s,mappedAtCreation:a,label:r},this.shrinkToFit=o??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&la.STATIC)}set static(t){t?this.descriptor.usage|=la.STATIC:this.descriptor.usage&=~la.STATIC}setDataWithSize(t,i,n){if(this._updateID++,this._updateSize=i*t.BYTES_PER_ELEMENT,this._data===t)return void(n&&this.emit("update",this));const s=this._data;this._data=t,this._dataInt32=null,s&&s.length===t.length||!this.shrinkToFit&&s&&t.byteLength<s.byteLength?n&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=e("resource"),this.emit("change",this))}update(t){this._updateSize=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()}};class da extends on{constructor(t={}){super(),this.uid=e("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new jn,this._boundsDirty=!0;const{attributes:i,indexBuffer:n,topology:s}=t;if(this.buffers=[],this.attributes={},i)for(const t in i)this.addAttribute(t,i[t]);this.instanceCount=t.instanceCount??1,n&&this.addIndex(n),this.topology=s||"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 ca||Array.isArray(t)||t.BYTES_PER_ELEMENT)&&(t={buffer:t}),t.buffer=wt(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=wt(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,function(t,e,i){const n=t.getAttribute("aPosition");if(!n)return i.minX=0,i.minY=0,i.maxX=0,i.maxY=0,i;const s=n.buffer.data;let r=1/0,o=1/0,a=-1/0,h=-1/0;const l=s.BYTES_PER_ELEMENT,c=(n.offset||0)/l,d=(n.stride||8)/l;for(let t=c;t<s.length;t+=d){const e=s[t],i=s[t+1];e>a&&(a=e),i>h&&(h=i),e<r&&(r=e),i<o&&(o=i)}return i.minX=r,i.minY=o,i.maxX=a,i.maxY=h,i}(this,0,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 ua=new Float32Array(1),pa=new Uint32Array(1);class fa extends da{constructor(){const t=new ca({data:ua,label:"attribute-batch-buffer",usage:la.VERTEX|la.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 ca({data:pa,label:"index-batch-buffer",usage:la.INDEX|la.COPY_DST,shrinkToFit:!1})})}}const ga=/\{\{(.*?)\}\}/g,ma=Object.create(null),ya=new Map;let xa=0;const ba={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 "}},_a={name:"global-uniforms-bit",vertex:{header:"\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform vec4 uWorldColorAlpha;\n uniform vec2 uResolution;\n "}},va={name:"color-bit",vertex:{header:"\n @in aColor: vec4<f32>;\n ",main:"\n vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);\n "}},wa={name:"color-bit",vertex:{header:"\n in vec4 aColor;\n ",main:"\n vColor *= vec4(aColor.rgb * aColor.a, aColor.a);\n "}},Ca={},Sa={},Aa={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 "}},Ia={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 "}},Ma={};class Ta extends ao{constructor(t){super({glProgram:kt({name:"batch",bits:[wa,jt(t),Ia]}),gpuProgram:Ot({name:"batch",bits:[va,Ft(t),Aa]}),resources:{batchSamplers:Gt(t)}})}}let Pa=null;const Ea=class t extends ha{constructor(e){super(e),this.geometry=new fa,this.name=t.extension.name,this.vertexSize=6,Pa??(Pa=new Ta(e.maxTextures)),this.shader=Pa}packAttributes(t,e,i,n,s){const r=s<<16|65535&t.roundPixels,o=t.transform,a=o.a,h=o.b,l=o.c,c=o.d,d=o.tx,u=o.ty,{positions:p,uvs:f}=t,g=t.color,m=t.attributeOffset,y=m+t.attributeSize;for(let t=m;t<y;t++){const s=2*t,o=p[s],m=p[s+1];e[n++]=a*o+l*m+d,e[n++]=c*m+h*o+u,e[n++]=f[s],e[n++]=f[s+1],i[n++]=g,i[n++]=r}}packQuadAttributes(t,e,i,n,s){const r=t.texture,o=t.transform,a=o.a,h=o.b,l=o.c,c=o.d,d=o.tx,u=o.ty,p=t.bounds,f=p.maxX,g=p.minX,m=p.maxY,y=p.minY,x=r.uvs,b=t.color,_=s<<16|65535&t.roundPixels;e[n+0]=a*g+l*y+d,e[n+1]=c*y+h*g+u,e[n+2]=x.x0,e[n+3]=x.y0,i[n+4]=b,i[n+5]=_,e[n+6]=a*f+l*y+d,e[n+7]=c*y+h*f+u,e[n+8]=x.x1,e[n+9]=x.y1,i[n+10]=b,i[n+11]=_,e[n+12]=a*f+l*m+d,e[n+13]=c*m+h*f+u,e[n+14]=x.x2,e[n+15]=x.y2,i[n+16]=b,i[n+17]=_,e[n+18]=a*g+l*m+d,e[n+19]=c*m+h*g+u,e[n+20]=x.x3,e[n+21]=x.y3,i[n+22]=b,i[n+23]=_}};Ea.extension={type:[Ki.Batcher],name:"default"};let Ba=Ea;const Oa=new un;class ka{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?u(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(255*this.alpha<<24)}get transform(){return this.renderable?.groupTransform||Oa}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 Ra={extension:{type:Ki.ShapeBuilder,name:"circle"},build(t,e){let i,n,s,r,o,a;if("circle"===t.type){const e=t;if(o=a=e.radius,o<=0)return!1;i=e.x,n=e.y,s=r=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,s=r=0}else{const e=t,h=e.width/2,l=e.height/2;i=e.x+h,n=e.y+l,o=a=Math.max(0,Math.min(e.radius,Math.min(h,l))),s=h-o,r=l-a}if(s<0||r<0)return!1;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=8*h+(s?4:0)+(r?4:0);if(0===l)return!1;if(0===h)return e[0]=e[6]=i+s,e[1]=e[3]=n+r,e[2]=e[4]=i-s,e[5]=e[7]=n-r,!0;let c=0,d=4*h+(s?2:0)+2,u=d,p=l,f=s+o,g=r,m=i+f,y=i-f,x=n+g;if(e[c++]=m,e[c++]=x,e[--d]=x,e[--d]=y,r){const t=n-g;e[u++]=y,e[u++]=t,e[--p]=t,e[--p]=m}for(let t=1;t<h;t++){const l=Math.PI/2*(t/h),f=s+Math.cos(l)*o,g=r+Math.sin(l)*a,m=i+f,y=i-f,x=n+g,b=n-g;e[c++]=m,e[c++]=x,e[--d]=x,e[--d]=y,e[u++]=y,e[u++]=b,e[--p]=b,e[--p]=m}f=s,g=r+a,m=i+f,y=i-f,x=n+g;const b=n-g;return e[c++]=m,e[c++]=x,e[--p]=b,e[--p]=m,s&&(e[c++]=y,e[c++]=x,e[--p]=b,e[--p]=y),!0},triangulate(t,e,i,n,s,r){if(0===t.length)return;let o=0,a=0;for(let e=0;e<t.length;e+=2)o+=t[e],a+=t[e+1];o/=t.length/2,a/=t.length/2;let h=n;e[h*i]=o,e[h*i+1]=a;const l=h++;for(let n=0;n<t.length;n+=2)e[h*i]=t[n],e[h*i+1]=t[n+1],n>0&&(s[r++]=h,s[r++]=l,s[r++]=h-1),h++;s[r++]=l+1,s[r++]=l,s[r++]=h-1}},Da={...Ra,extension:{...Ra.extension,name:"ellipse"}},Fa={...Ra,extension:{...Ra.extension,name:"roundedRectangle"}},La=1e-4,ja=[],Ga={extension:{type:Ki.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,s,r){Ht(t,ja,e,i,n,s,r)}},Ua={extension:{type:Ki.ShapeBuilder,name:"rectangle"},build(t,e){const i=t,n=i.x,s=i.y,r=i.width,o=i.height;return r>0&&o>0&&(e[0]=n,e[1]=s,e[2]=n+r,e[3]=s,e[4]=n+r,e[5]=s+o,e[6]=n,e[7]=s+o,!0)},triangulate(t,e,i,n,s,r){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;s[r++]=a,s[r++]=a+1,s[r++]=a+2,s[r++]=a+1,s[r++]=a+3,s[r++]=a+2}},Na={extension:{type:Ki.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,s,r){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;s[r++]=a,s[r++]=a+1,s[r++]=a+2}},za=new un,Ha=new Sn,Va={};$i.handleByMap(Ki.ShapeBuilder,Va),$i.add(Ua,Ga,Na,Ra,Da,Fa);const Wa=new Sn,Za=new un;class Ja{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class Xa{constructor(){this.instructions=new Ds}init(t){this.batcher=new Ba({maxTextures:t}),this.instructions.reset()}get geometry(){return i(0,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}}const Ya=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){t.defaultOptions.bezierSmoothness=e?.bezierSmoothness??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 e=0;e<t.instructions.length;e++){const s=t.instructions[e];if("texture"===s.action)Vt(s.data,n,i);else if("fill"===s.action||"stroke"===s.action){const t="stroke"===s.action,e=s.data.path.shapePath,r=s.data.style,o=s.data.hole;t&&o&&Wt(o.shapePath,r,!0,n,i),o&&(e.shapePrimitives[e.shapePrimitives.length-1].holes=o.shapePath.shapePrimitives),Wt(e,r,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=ms.get(Xa,{maxTextures:this._renderer.limits.maxBatchableTextures}),{batches:i,geometryData:n}=this._gpuContextHash[t.uid],s=n.vertices.length,r=n.indices.length;for(let t=0;t<i.length;t++)i[t].applyTransform=!1;const o=e.batcher;o.ensureAttributeBuffer(s),o.ensureIndexBuffer(r),o.begin();for(let t=0;t<i.length;t++){const e=i[t];o.add(e)}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 h=o.batches;for(let t=0;t<h.length;t++){const e=h[t];e.bindGroup=gt(e.textures.textures,e.textures.count,this._renderer.limits.maxBatchableTextures)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new Ja;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]&&(ms.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(t=>{ms.return(t)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};Ya.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"graphicsContext"},Ya.defaultOptions={bezierSmoothness:.5};let Ka=Ya;const qa=1.1920929e-7,Qa=2*Math.PI,$a={centerX:0,centerY:0,ang1:0,ang2:0},th=({x:t,y:e},i,n,s,r,o,a,h)=>{const l=s*(t*=i)-r*(e*=n),c=r*t+s*e;return h.x=l+o,h.y=c+a,h},eh=(t,e,i,n)=>{let s=t*i+e*n;return s>1&&(s=1),s<-1&&(s=-1),(t*n-e*i<0?-1:1)*Math.acos(s)},ih=new Sn;class nh{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new jn,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],s=i[i.length-1];return n===t&&s===e||i.push(t,e),this}arc(t,e,i,n,s,r){return this._ensurePoly(!1),Kt(this._currentPoly.points,t,e,i,n,s,r),this}arcTo(t,e,i,n,s){return this._ensurePoly(),function(t,e,i,n,s,r){const o=t[t.length-2],a=t[t.length-1]-i,h=o-e,l=s-i,c=n-e,d=Math.abs(a*c-h*l);if(d<1e-8||0===r)return void(t[t.length-2]===e&&t[t.length-1]===i||t.push(e,i));const u=a*a+h*h,p=l*l+c*c,f=a*l+h*c,g=r*Math.sqrt(u)/d,m=r*Math.sqrt(p)/d,y=g*f/u,x=m*f/p,b=g*c+m*h,_=g*l+m*a,v=h*(m+y),w=a*(m+y),C=c*(g+x),S=l*(g+x);Kt(t,b+e,_+i,r,Math.atan2(w-_,v-b),Math.atan2(S-_,C-b),h*l>c*a)}(this._currentPoly.points,t,e,i,n,s),this}arcToSvg(t,e,i,n,s,r,o){return function(t,e,i,n,s,r,o,a=0,h=0,l=0){if(0===r||0===o)return;const c=Math.sin(a*Qa/360),d=Math.cos(a*Qa/360),u=d*(e-n)/2+c*(i-s)/2,p=-c*(e-n)/2+d*(i-s)/2;if(0===u&&0===p)return;r=Math.abs(r),o=Math.abs(o);const f=Math.pow(u,2)/Math.pow(r,2)+Math.pow(p,2)/Math.pow(o,2);f>1&&(r*=Math.sqrt(f),o*=Math.sqrt(f)),((t,e,i,n,s,r,o,a,h,l,c,d,u)=>{const p=Math.pow(s,2),f=Math.pow(r,2),g=Math.pow(c,2),m=Math.pow(d,2);let y=p*f-p*m-f*g;y<0&&(y=0),y/=p*m+f*g,y=Math.sqrt(y)*(o===a?-1:1);const x=y*s/r*d,b=y*-r/s*c,_=l*x-h*b+(t+i)/2,v=h*x+l*b+(e+n)/2,w=(c-x)/s,C=(d-b)/r,S=(-c-x)/s,A=(-d-b)/r,I=eh(1,0,w,C);let M=eh(w,C,S,A);0===a&&M>0&&(M-=Qa),1===a&&M<0&&(M+=Qa),u.centerX=_,u.centerY=v,u.ang1=I,u.ang2=M})(e,i,n,s,r,o,h,l,c,d,u,p,$a);let{ang1:g,ang2:m}=$a;const{centerX:y,centerY:x}=$a;let b=Math.abs(m)/(Qa/4);Math.abs(1-b)<1e-7&&(b=1);const _=Math.max(Math.ceil(b),1);m/=_;let v=t[t.length-2],w=t[t.length-1];const C={x:0,y:0};for(let e=0;e<_;e++){const e=qt(g,m),{x:i,y:n}=th(e[0],r,o,d,c,y,x,C),{x:s,y:a}=th(e[1],r,o,d,c,y,x,C),{x:h,y:l}=th(e[2],r,o,d,c,y,x,C);Zt(t,v,w,i,n,s,a,h,l),v=h,w=l,g+=m}}(this._currentPoly.points,this._currentPoly.lastX,this._currentPoly.lastY,r,o,t,e,i,n,s),this}bezierCurveTo(t,e,i,n,s,r,o){this._ensurePoly();const a=this._currentPoly;return Zt(this._currentPoly.points,a.lastX,a.lastY,t,e,i,n,s,r,o),this}quadraticCurveTo(t,e,i,n,s){this._ensurePoly();const r=this._currentPoly;return Xt(this._currentPoly.points,r.lastX,r.lastY,t,e,i,n,s),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 e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.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 s=n.shape,r=t?.shape;r&&r.containsPolygon(s)?(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,s){return this.drawShape(new Sn(t,e,i,n),s),this}circle(t,e,i,n){return this.drawShape(new Wo(t,e,i),n),this}poly(t,e,i){const n=new Jo(t);return n.closePath=e,this.drawShape(n,i),this}regularPoly(t,e,i,n,s=0,r){n=Math.max(0|n,3);const o=-1*Math.PI/2+s,a=2*Math.PI/n,h=[];for(let s=0;s<n;s++){const n=o-s*a;h.push(t+i*Math.cos(n),e+i*Math.sin(n))}return this.poly(h,!0,r),this}roundPoly(t,e,i,n,s,r=0,o){if(n=Math.max(0|n,3),s<=0)return this.regularPoly(t,e,i,n,r);const a=i*Math.sin(Math.PI/n)-.001;s=Math.min(s,a);const h=-1*Math.PI/2+r,l=2*Math.PI/n,c=(n-2)*Math.PI/n/2;for(let r=0;r<n;r++){const n=r*l+h,a=t+i*Math.cos(n),d=e+i*Math.sin(n),u=n+Math.PI+c,p=n-Math.PI-c,f=a+s*Math.cos(u),g=d+s*Math.sin(u),m=a+s*Math.cos(p),y=d+s*Math.sin(p);0===r?this.moveTo(f,g):this.lineTo(f,g),this.quadraticCurveTo(a,d,m,y,o)}return this.closePath()}roundShape(t,e,i=!1,n){return t.length<3?this:(i?function(t,e,i,n){const s=(t,e)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),r=(t,e,i)=>({x:t.x+(e.x-t.x)*i,y:t.y+(e.y-t.y)*i}),o=e.length;for(let a=0;a<o;a++){const h=e[(a+1)%o],l=h.radius??i;if(l<=0){0===a?t.moveTo(h.x,h.y):t.lineTo(h.x,h.y);continue}const c=e[a],d=e[(a+2)%o],u=s(c,h);let p;p=u<1e-4?h:r(h,c,Math.min(u/2,l)/u);const f=s(d,h);let g;g=f<1e-4?h:r(h,d,Math.min(f/2,l)/f),0===a?t.moveTo(p.x,p.y):t.lineTo(p.x,p.y),t.quadraticCurveTo(h.x,h.y,g.x,g.y,n)}}(this,t,e,n):function(t,e,i){const n=(t,e)=>{const i=e.x-t.x,n=e.y-t.y,s=Math.sqrt(i*i+n*n);return{len:s,nx:i/s,ny:n/s}},s=(e,i)=>{0===e?t.moveTo(i.x,i.y):t.lineTo(i.x,i.y)};let r=e[e.length-1];for(let o=0;o<e.length;o++){const a=e[o%e.length],h=a.radius??i;if(h<=0){s(o,a),r=a;continue}const l=e[(o+1)%e.length],c=n(a,r),d=n(a,l);if(c.len<1e-4||d.len<1e-4){s(o,a),r=a;continue}let u=Math.asin(c.nx*d.ny-c.ny*d.nx),p=1,f=!1;c.nx*d.nx-c.ny*-d.ny<0?u<0?u=Math.PI+u:(u=Math.PI-u,p=-1,f=!0):u>0&&(p=-1,f=!0);const g=u/2;let m,y=Math.abs(Math.cos(g)*h/Math.sin(g));y>Math.min(c.len/2,d.len/2)?(y=Math.min(c.len/2,d.len/2),m=Math.abs(y*Math.sin(g)/Math.cos(g))):m=h;const x=a.x+d.nx*y+-d.ny*m*p,b=a.y+d.ny*y+d.nx*m*p,_=Math.atan2(c.ny,c.nx)+Math.PI/2*p,v=Math.atan2(d.ny,d.nx)-Math.PI/2*p;0===o&&t.moveTo(x+Math.cos(_)*m,b+Math.sin(_)*m),t.arc(x,b,m,_,v,f),r=a}}(this,t,e),this.closePath())}filletRect(t,e,i,n,s){if(0===s)return this.rect(t,e,i,n);const r=Math.min(i,n)/2,o=Math.min(r,Math.max(-r,s)),a=t+i,h=e+n,l=o<0?-o:0,c=Math.abs(o);return this.moveTo(t,e+c).arcTo(t+l,e+l,t+c,e,c).lineTo(a-c,e).arcTo(a-l,e+l,a,e+c,c).lineTo(a,h-c).arcTo(a-l,h-l,t+i-c,h,c).lineTo(t+c,h).arcTo(t+l,h-l,t,h-c,c).closePath()}chamferRect(t,e,i,n,s,r){if(s<=0)return this.rect(t,e,i,n);const o=Math.min(s,Math.min(i,n)/2),a=t+i,h=e+n,l=[t+o,e,a-o,e,a,e+o,a,h-o,a-o,h,t+o,h,t,h-o,t,e+o];for(let t=l.length-1;t>=2;t-=2)l[t]===l[t-2]&&l[t-1]===l[t-3]&&l.splice(t-1,2);return this.poly(l,!0,r)}ellipse(t,e,i,n,s){return this.drawShape(new Zo(t,e,i,n),s),this}roundRect(t,e,i,n,s,r){return this.drawShape(new Yo(t,e,i,n,s),r),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 Jo,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 Jo,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,s=e;e=n.a*e+n.c*i+n.tx,i=n.b*s+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],s=n.shape.getBounds(ih);n.transform?t.addRect(s,n.transform):t.addRect(s)}return t}}class sh{constructor(t,i=!1){this.instructions=[],this.uid=e("graphicsPath"),this._dirty=!0,this.checkForHoles=i,"string"==typeof t?function(t,e){const i=Vo(t),n=[];let s=null,r=0,o=0;for(let t=0;t<i.length;t++){const h=i[t],l=h[0],c=h;switch(l){case"M":r=c[1],o=c[2],e.moveTo(r,o);break;case"m":r+=c[1],o+=c[2],e.moveTo(r,o);break;case"H":r=c[1],e.lineTo(r,o);break;case"h":r+=c[1],e.lineTo(r,o);break;case"V":o=c[1],e.lineTo(r,o);break;case"v":o+=c[1],e.lineTo(r,o);break;case"L":r=c[1],o=c[2],e.lineTo(r,o);break;case"l":r+=c[1],o+=c[2],e.lineTo(r,o);break;case"C":r=c[5],o=c[6],e.bezierCurveTo(c[1],c[2],c[3],c[4],r,o);break;case"c":e.bezierCurveTo(r+c[1],o+c[2],r+c[3],o+c[4],r+c[5],o+c[6]),r+=c[5],o+=c[6];break;case"S":r=c[3],o=c[4],e.bezierCurveToShort(c[1],c[2],r,o);break;case"s":e.bezierCurveToShort(r+c[1],o+c[2],r+c[3],o+c[4]),r+=c[3],o+=c[4];break;case"Q":r=c[3],o=c[4],e.quadraticCurveTo(c[1],c[2],r,o);break;case"q":e.quadraticCurveTo(r+c[1],o+c[2],r+c[3],o+c[4]),r+=c[3],o+=c[4];break;case"T":r=c[1],o=c[2],e.quadraticCurveToShort(r,o);break;case"t":r+=c[1],o+=c[2],e.quadraticCurveToShort(r,o);break;case"A":r=c[6],o=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,o);break;case"a":r+=c[6],o+=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,o);break;case"Z":case"z":e.closePath(),n.length>0&&(s=n.pop(),s?(r=s.startX,o=s.startY):(r=0,o=0)),s=null;break;default:a()}"Z"!==l&&"z"!==l&&null===s&&(s={startX:r,startY:o},n.push(s))}}(t,this):this.instructions=t?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new nh(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,s){const r=this.instructions[this.instructions.length-1],o=this.getLastPoint(cn.shared);let a=0,h=0;if(r&&"bezierCurveTo"===r.action){a=r.data[2],h=r.data[3];const t=o.x,e=o.y;a=t+(t-a),h=e+(e-h)}else a=o.x,h=o.y;return this.instructions.push({action:"bezierCurveTo",data:[a,h,t,e,i,n,s]}),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],s=this.getLastPoint(cn.shared);let r=0,o=0;if(n&&"quadraticCurveTo"===n.action){r=n.data[0],o=n.data[1];const t=s.x,e=s.y;r=t+(t-r),o=e+(e-o)}else r=s.x,o=s.y;return this.instructions.push({action:"quadraticCurveTo",data:[r,o,t,e,i]}),this._dirty=!0,this}rect(t,e,i,n,s){return this.instructions.push({action:"rect",data:[t,e,i,n,s]}),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,s,r,o){s||(s=n/2);const a=-1*Math.PI/2+r,h=2*i,l=2*Math.PI/h,c=[];for(let i=0;i<h;i++){const r=i%2?s:n,o=i*l+a;c.push(t+r*Math.cos(o),e+r*Math.sin(o))}return this.poly(c,!0,o),this}clone(t=!1){const e=new sh;if(e.checkForHoles=this.checkForHoles,t)for(let t=0;t<this.instructions.length;t++){const i=this.instructions[t];e.instructions.push({action:i.action,data:i.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,s=t.d,r=t.tx,o=t.ty;let h=0,l=0,c=0,d=0,u=0,p=0,f=0,g=0;for(let m=0;m<this.instructions.length;m++){const y=this.instructions[m],x=y.data;switch(y.action){case"moveTo":case"lineTo":h=x[0],l=x[1],x[0]=e*h+n*l+r,x[1]=i*h+s*l+o;break;case"bezierCurveTo":c=x[0],d=x[1],u=x[2],p=x[3],h=x[4],l=x[5],x[0]=e*c+n*d+r,x[1]=i*c+s*d+o,x[2]=e*u+n*p+r,x[3]=i*u+s*p+o,x[4]=e*h+n*l+r,x[5]=i*h+s*l+o;break;case"quadraticCurveTo":c=x[0],d=x[1],h=x[2],l=x[3],x[0]=e*c+n*d+r,x[1]=i*c+s*d+o,x[2]=e*h+n*l+r,x[3]=i*h+s*l+o;break;case"arcToSvg":h=x[5],l=x[6],f=x[0],g=x[1],x[0]=e*f+n*g,x[1]=i*f+s*g,x[5]=e*h+n*l+r,x[6]=i*h+s*l+o;break;case"circle":x[4]=Qt(x[3],t);break;case"rect":x[4]=Qt(x[4],t);break;case"ellipse":x[8]=Qt(x[8],t);break;case"roundRect":x[5]=Qt(x[5],t);break;case"addPath":x[0].transform(t);break;case"poly":x[2]=Qt(x[2],t);break;default:a(y.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}}const rh={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}},oh=new cn,ah=new un,hh=class t extends on{constructor(){super(...arguments),this.uid=e("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new sh,this._transform=new un,this._fillStyle={...t.defaultFillStyle},this._strokeStyle={...t.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new jn,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={...this._fillStyle},e._strokeStyle={...this._strokeStyle},e._stateStack=this._stateStack.slice(),e._bounds=this._bounds.clone(),e._boundsDirty=!0,e}get fillStyle(){return this._fillStyle}set fillStyle(e){this._fillStyle=ce(e,t.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=de(e,t.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=ce(e,t.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=ce(e,t.defaultStrokeStyle),this}texture(t,e,i,n,s,r){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:n||0,dw:s||t.frame.width,dh:r||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?ps.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new sh,this}fill(e,n){let s;const r=this.instructions[this.instructions.length-1];return s=0===this._tick&&r&&"stroke"===r.action?r.data.path:this._activePath.clone(),s?(null!=e&&(void 0!==n&&"number"==typeof e&&(i(0,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:n}),this._fillStyle=ce(e,t.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(cn.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=de(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,s,r){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,s,r),this}arcTo(t,e,i,n,s){this._tick++;const r=this._transform;return this._activePath.arcTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty,r.a*i+r.c*n+r.tx,r.b*i+r.d*n+r.ty,s),this}arcToSvg(t,e,i,n,s,r,o){this._tick++;const a=this._transform;return this._activePath.arcToSvg(t,e,i,n,s,a.a*r+a.c*o+a.tx,a.b*r+a.d*o+a.ty),this}bezierCurveTo(t,e,i,n,s,r,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*s+a.c*r+a.tx,a.b*s+a.d*r+a.ty,o),this}closePath(){return this._tick++,this._activePath?.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,s=i.a*t+i.c*e+i.tx,r=i.b*t+i.d*e+i.ty;return 1===n.length&&"moveTo"===n[0].action?(n[0].data[0]=s,n[0].data[1]=r,this):(this._activePath.moveTo(s,r),this)}quadraticCurveTo(t,e,i,n,s){this._tick++;const r=this._transform;return this._activePath.quadraticCurveTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty,r.a*i+r.c*n+r.tx,r.b*i+r.d*n+r.ty,s),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,s){return this._tick++,this._activePath.roundRect(t,e,i,n,s,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,n,s=0,r){return this._tick++,this._activePath.regularPoly(t,e,i,n,s,r),this}roundPoly(t,e,i,n,s,r){return this._tick++,this._activePath.roundPoly(t,e,i,n,s,r),this}roundShape(t,e,i,n){return this._tick++,this._activePath.roundShape(t,e,i,n),this}filletRect(t,e,i,n,s){return this._tick++,this._activePath.filletRect(t,e,i,n,s),this}chamferRect(t,e,i,n,s,r){return this._tick++,this._activePath.chamferRect(t,e,i,n,s,r),this}star(t,e,i,n,s=0,r=0){return this._tick++,this._activePath.star(t,e,i,n,s,r,this._transform.clone()),this}svg(t){return this._tick++,function(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 sh};!function(t,e){const i=t.querySelectorAll("defs");for(let t=0;t<i.length;t++){const n=i[t];for(let t=0;t<n.children.length;t++){const i=n.children[t];switch(i.nodeName.toLowerCase()){case"lineargradient":e.defs[i.id]=te(i);break;case"radialgradient":e.defs[i.id]=ee()}}}}(t,i);const n=t.children,{fillStyle:s,strokeStyle:r}=ne(t,i);for(let t=0;t<n.length;t++){const e=n[t];"defs"!==e.nodeName.toLowerCase()&&re(e,i,s,r)}}(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,n,s,r){return t instanceof un?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,n,s,r),this)}transform(t,e,i,n,s,r){return t instanceof un?(this._transform.append(t),this):(ah.set(t,e,i,n,s,r),this._transform.append(ah),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,s=e.style.width*(1-n),r=e.path.bounds;t.addFrame(r.minX-s,r.minY-s,r.maxX+s,r.maxY+s)}}return t}containsPoint(t){if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let i=!1;for(let n=0;n<e.length;n++){const s=e[n],r=s.data,o=r.path;if(!s.action||!o)continue;const a=r.style,h=o.shapePath.shapePrimitives;for(let e=0;e<h.length;e++){const n=h[e].shape;if(!a||!n)continue;const o=h[e].transform,l=o?o.applyInverse(t,oh):t;if("fill"===s.action)i=n.contains(l.x,l.y);else{const t=a;i=n.strokeContains(l.x,l.y,t.width,t.alignment)}const c=r.hole;if(c){const t=c.shapePath?.shapePrimitives;if(t)for(let e=0;e<t.length;e++)t[e].shape.contains(l.x,l.y)&&(i=!1)}if(i)return!0}}return i}destroy(t=!1){if(this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t: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}};hh.defaultFillStyle={color:16777215,alpha:1,texture:Fn.WHITE,matrix:null,fill:null,textureSpace:"local"},hh.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:Fn.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let lh=hh;const ch=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"],dh=class t extends on{constructor(e={}){super(),function(t){const e=t;if("boolean"==typeof e.dropShadow&&e.dropShadow){const i=uh.defaultDropShadow;t.dropShadow={alpha:e.dropShadowAlpha??i.alpha,angle:e.dropShadowAngle??i.angle,blur:e.dropShadowBlur??i.blur,color:e.dropShadowColor??i.color,distance:e.dropShadowDistance??i.distance}}if(void 0!==e.strokeThickness){i(0,"strokeThickness is now a part of stroke");const n=e.stroke;let s={};if(ps.isColorLike(n))s.color=n;else if(n instanceof Go||n instanceof No)s.fill=n;else{if(!Object.hasOwnProperty.call(n,"color")&&!Object.hasOwnProperty.call(n,"fill"))throw new Error("Invalid stroke value.");s=n}t.stroke={...s,width:e.strokeThickness}}if(Array.isArray(e.fillGradientStops)){if(i(0,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(e.fill)||0===e.fill.length)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");e.fill.length!==e.fillGradientStops.length&&a();const n=new Go({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),s=e.fillGradientStops.slice(),r=e.fill.map(t=>ps.shared.setValue(t).toNumber());s.forEach((t,e)=>{n.addColorStop(t,r[e])}),t.fill={fill:n}}}(e);const n={...t.defaultTextStyle,...e};for(const t in n)this[t]=n[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({...t.defaultDropShadow,...e}):e?this._createProxy({...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({...lh.defaultFillStyle,...t},()=>{this._fill=ce({...this._originalFill},lh.defaultFillStyle)})),this._fill=ce(0===t?"black":t,lh.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...lh.defaultStrokeStyle,...t},()=>{this._stroke=de({...this._originalStroke},lh.defaultStrokeStyle)})),this._stroke=de(t,lh.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=function(t){const e=[];let i=0;for(let n=0;n<ch.length;n++){const s=`_${ch[n]}`;e[i++]=t[s]}return i=ue(t._fill,e,i),i=function(t,e,i){return t?(i=ue(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++]=ps.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("-")}(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?{...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){if(this.removeAllListeners(),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._fill?.texture&&this._fill.texture.destroy(e),this._originalFill?.texture&&this._originalFill.texture.destroy(e),this._stroke?.texture&&this._stroke.texture.destroy(e),this._originalStroke?.texture&&this._originalStroke.texture.destroy(e)}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,e?.(i,n),this.update(),!0)})}_isFillStyle(t){return null!==(t??null)&&!(ps.isColorLike(t)||t instanceof Go||t instanceof No)}};dh.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},dh.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 uh=dh;const ph=new class{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=qs.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 s=((t=n(t))<<17)+((e=n(e))<<1);this._canvasPool[s]||(this._canvasPool[s]=[]);let r=this._canvasPool[s].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:n}=e,s=(i<<17)+(n<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,n),this._canvasPool[s].push(t)}clear(){this._canvasPool={}}},fh=1e5,gh=class t extends Oo{constructor(e){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 i={...t.defaultOptions,...e};this._textureSize=i.textureSize,this._mipmap=i.mipmap;const n=i.style.clone();i.overrideFill&&(n._fill.color=16777215,n._fill.alpha=1,n._fill.texture=Fn.WHITE,n._fill.fill=null),this.applyFillAsTint=i.overrideFill;const s=n.fontSize;n.fontSize=this.baseMeasurementFontSize;const r=dt(n);i.overrideSize?n._stroke&&(n._stroke.width*=this.baseRenderedFontSize/s):n.fontSize=this.baseRenderedFontSize=s,this._style=n,this._skipKerning=i.skipKerning??!1,this.resolution=i.resolution??1,this._padding=i.padding??4,i.textureStyle&&(this._textureStyle=i.textureStyle instanceof En?i.textureStyle:new En(i.textureStyle)),this.fontMetrics=Fo.measureFont(r),this.lineHeight=n.lineHeight||this.fontMetrics.fontSize||n.fontSize}ensureCharacters(t){const e=Fo.graphemeSegmenter(t).filter(t=>!this._currentChars.includes(t)).filter((t,e,i)=>i.indexOf(t)===e);if(!e.length)return;let i;this._currentChars=[...this._currentChars,...e],i=-1===this._currentPageIndex?this._nextPage():this.pages[this._currentPageIndex];let{canvas:n,context:s}=i.canvasAndContext,r=i.texture.source;const o=this._style;let a=this._currentX,h=this._currentY,l=this._currentMaxCharHeight;const c=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=this._padding*c;let u=!1;const p=n.width/this.resolution,f=n.height/this.resolution;for(let t=0;t<e.length;t++){const i=e[t],g=Fo.measureText(i,o,n,!1);g.lineHeight=g.height;const m=g.width*c,y=Math.ceil(("italic"===o.fontStyle?2:1)*m)+2*d,x=g.height*c+2*d;if(u=!1,"\n"!==i&&"\r"!==i&&"\t"!==i&&" "!==i&&(u=!0,l=Math.ceil(Math.max(x,l))),a+y>p&&(h+=l,l=x,a=0,h+l>f)){r.update();const t=this._nextPage();n=t.canvasAndContext.canvas,s=t.canvasAndContext.context,r=t.texture.source,a=0,h=0,l=0}const b=m/c-(o.dropShadow?.distance??0)-(o._stroke?.width??0);if(this.chars[i]={id:i.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:b,kerning:{}},u){this._drawGlyph(s,g,a+d,h+d,c,o);const t=r.width*c,e=r.height*c,n=new Sn(a/t*r.width,h/e*r.height,y/t*r.width,x/e*r.height);this.chars[i].texture=new Fn({source:r,frame:n}),a+=Math.ceil(y)}}r.update(),this._currentX=a,this._currentY=h,this._currentMaxCharHeight=l,this._skipKerning&&this._applyKerning(e,s)}get pageTextures(){return i(0,"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 s=t[n];for(let t=0;t<this._currentChars.length;t++){const n=this._currentChars[t];let r=i[s];r||(r=i[s]=e.measureText(s).width);let o=i[n];o||(o=i[n]=e.measureText(n).width);let a=e.measureText(s+n).width,h=a-(r+o);h&&(this.chars[s].kerning[n]=h),a=e.measureText(s+n).width,h=a-(r+o),h&&(this.chars[n].kerning[s]=h)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=ph.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),n=new Fn({source:new $s({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(n.source.style=this._textureStyle);const s={canvasAndContext:e,texture:n};return this.pages[this._currentPageIndex]=s,s}_setupContext(t,e,i){e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=dt(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const n=e._stroke,s=n?.width??0;if(n&&(t.lineWidth=s,t.lineJoin=n.join,t.miterLimit=n.miterLimit,t.strokeStyle=pe(n,t)),e._fill&&(t.fillStyle=pe(e._fill,t)),e.dropShadow){const n=e.dropShadow,s=ps.shared.setValue(n.color).toArray(),r=n.blur*i,o=n.distance*i;t.shadowColor=`rgba(${255*s[0]},${255*s[1]},${255*s[2]},${n.alpha})`,t.shadowBlur=r,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,s,r){const o=e.text,a=e.fontProperties,h=r._stroke,l=(h?.width??0)*s,c=i+l/2,d=n-l/2,u=a.descent*s,p=e.lineHeight*s;let f=!1;r.stroke&&l&&(f=!0,t.strokeText(o,c,d+p-u));const{shadowBlur:g,shadowOffsetX:m,shadowOffsetY:y}=t;r._fill&&(f&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(o,c,d+p-u)),f&&(t.shadowBlur=g,t.shadowOffsetX=m,t.shadowOffsetY=y)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];ph.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}};gh.defaultOptions={textureSize:512,style:new uh,mipmap:!0};let mh=gh,yh=0;const xh=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){let i=`${e.fontFamily}-bitmap`,n=!0;if(e._fill.fill&&!e._stroke)i+=e._fill.fill.styleKey,n=!1;else if(e._stroke||e.dropShadow){let t=e.styleKey;t=t.substring(0,t.lastIndexOf("-")),i=`${t}-bitmap`,n=!1}if(!hr.has(i)){const t=Object.create(e);t.lineHeight=0;const s=new mh({style:t,overrideFill:n,overrideSize:!0,...this.defaultOptions});yh++,yh>50&&a(),s.once("destroy",()=>{yh--,hr.remove(i)}),hr.set(i,s)}const s=hr.get(i);return s.ensureCharacters?.(t),s}getLayout(t,e,i=!0){const n=this.getFont(t,e);return fe(Fo.graphemeSegmenter(t),e,n,i)}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){let e=t[0];"string"==typeof e&&(e={name:e,style:t[1],chars:t[2]?.chars,resolution:t[2]?.resolution,padding:t[2]?.padding,skipKerning:t[2]?.skipKerning},i(0,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const n=e?.name;if(!n)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const s=e.style,r=s instanceof uh?s:new uh(s),o=e.dynamicFill??this._canUseTintForStyle(r),a=new mh({style:r,overrideFill:o,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1,textureStyle:e.textureStyle}),h=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,s=i;n<=s;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}(e.chars);return a.ensureCharacters(h.join("")),hr.set(`${n}-bitmap`,a),a.once("destroy",()=>hr.remove(`${n}-bitmap`)),a}uninstall(t){const e=`${t}-bitmap`,i=hr.get(e);i&&i.destroy()}_canUseTintForStyle(t){return!(t._stroke||t.dropShadow&&0!==t.dropShadow.color||t._fill.fill||16777215!==t._fill.color)}};class bh extends Oo{constructor(t,e){super();const{textures:i,data:n}=t;Object.keys(n.pages).forEach(t=>{const e=n.pages[parseInt(t,10)],s=i[e.id];this.pages.push({texture:s})}),Object.keys(n.chars).forEach(t=>{const e=n.chars[t],{frame:s,source:r,rotate:o}=i[e.page],a=wn.transformRectCoords(e,s,o,new Sn),h=new Fn({frame:a,orig:new Sn(0,0,e.width,e.height),source:r,rotate:o});this.chars[t]={id:t.codePointAt(0),xOffset:e.xOffset,yOffset:e.yOffset,xAdvance:e.xAdvance,kerning:e.kerning??{},texture:h}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=n.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){xh.install(t)}static uninstall(t){xh.uninstall(t)}}const _h={test:t=>"string"==typeof t&&t.startsWith("info face="),parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const t in e){const n=e[t].match(/^[a-z]+/gm)[0],s=e[t].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),r={};for(const t in s){const e=s[t].split("="),i=e[0],n=e[1].replace(/"/gm,""),o=parseFloat(n),a=isNaN(o)?n:o;r[i]=a}i[n].push(r)}const n={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[s]=i.info,[r]=i.common,[o]=i.distanceField??[];o&&(n.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),n.fontSize=parseInt(s.size,10),n.fontFamily=s.face,n.lineHeight=parseInt(r.lineHeight,10);const a=i.page;for(let t=0;t<a.length;t++)n.pages.push({id:parseInt(a[t].id,10)||0,file:a[t].file});const h={};n.baseLineOffset=n.lineHeight-parseInt(r.base,10);const l=i.char;for(let t=0;t<l.length;t++){const e=l[t],i=parseInt(e.id,10);let s=e.letter??e.char??String.fromCharCode(i);"space"===s&&(s=" "),h[i]=s,n.chars[s]={id:i,page:parseInt(e.page,10)||0,x:parseInt(e.x,10),y:parseInt(e.y,10),width:parseInt(e.width,10),height:parseInt(e.height,10),xOffset:parseInt(e.xoffset,10),yOffset:parseInt(e.yoffset,10),xAdvance:parseInt(e.xadvance,10),kerning:{}}}const c=i.kerning||[];for(let t=0;t<c.length;t++){const e=parseInt(c[t].first,10),i=parseInt(c[t].second,10),s=parseInt(c[t].amount,10);n.chars[h[i]].kerning[h[e]]=s}return n}},vh={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){const e={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},i=t.getElementsByTagName("info")[0],n=t.getElementsByTagName("common")[0],s=t.getElementsByTagName("distanceField")[0];s&&(e.distanceField={type:s.getAttribute("fieldType"),range:parseInt(s.getAttribute("distanceRange"),10)});const r=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning");e.fontSize=parseInt(i.getAttribute("size"),10),e.fontFamily=i.getAttribute("face"),e.lineHeight=parseInt(n.getAttribute("lineHeight"),10);for(let t=0;t<r.length;t++)e.pages.push({id:parseInt(r[t].getAttribute("id"),10)||0,file:r[t].getAttribute("file")});const h={};e.baseLineOffset=e.lineHeight-parseInt(n.getAttribute("base"),10);for(let t=0;t<o.length;t++){const i=o[t],n=parseInt(i.getAttribute("id"),10);let s=i.getAttribute("letter")??i.getAttribute("char")??String.fromCharCode(n);"space"===s&&(s=" "),h[n]=s,e.chars[s]={id:n,page:parseInt(i.getAttribute("page"),10)||0,x:parseInt(i.getAttribute("x"),10),y:parseInt(i.getAttribute("y"),10),width:parseInt(i.getAttribute("width"),10),height:parseInt(i.getAttribute("height"),10),xOffset:parseInt(i.getAttribute("xoffset"),10),yOffset:parseInt(i.getAttribute("yoffset"),10),xAdvance:parseInt(i.getAttribute("xadvance"),10),kerning:{}}}for(let t=0;t<a.length;t++){const i=parseInt(a[t].getAttribute("first"),10),n=parseInt(a[t].getAttribute("second"),10),s=parseInt(a[t].getAttribute("amount"),10);e.chars[h[n]].kerning[h[i]]=s}return e}},wh=[".xml",".fnt"],Ch={extension:{type:Ki.CacheParser,name:"cacheBitmapFont"},test:t=>t instanceof bh,getCacheableAssets(t,e){const i={};return t.forEach(t=>{i[t]=e,i[`${t}-bitmap`]=e}),i[`${e.fontFamily}-bitmap`]=e,i}},Sh={extension:{type:Ki.LoadParser,priority:cr.Normal},name:"loadBitmapFont",id:"bitmap-font",test:t=>wh.includes(dr.extname(t).toLowerCase()),testParse:async t=>_h.test(t)||(t=>!("string"!=typeof t||!t.includes("<font>"))&&vh.test(qs.get().parseXML(t)))(t),async parse(t,e,i){const n=_h.test(t)?_h.parse(t):(t=>vh.parse(qs.get().parseXML(t)))(t),{src:s}=e,{pages:r}=n,o=[],a=n.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let t=0;t<r.length;++t){const e=r[t].file;let i=dr.join(dr.dirname(s),e);i=fr(i,s),o.push({src:i,data:a})}const h=await i.load(o),l=o.map(t=>h[t.src]);return new bh({data:n,textures:l},s)},async load(t,e){const i=await qs.get().fetch(t);return await i.text()},async unload(t,e,i){await Promise.all(t.pages.map(t=>i.unload(t.texture.source._sourceOrigin))),t.destroy()}};class Ah{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,this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const Ih={extension:{type:Ki.CacheParser,name:"cacheTextureArray"},test:t=>Array.isArray(t)&&t.every(t=>t instanceof Fn),getCacheableAssets:(t,e)=>{const i={};return t.forEach(t=>{e.forEach((e,n)=>{i[t+(0===n?"":n+1)]=e})}),i}},Mh={extension:{type:Ki.DetectionParser,priority:1},test:async()=>ge("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async t=>[...t,"avif"],remove:async t=>t.filter(t=>"avif"!==t)},Th=["png","jpg","jpeg"],Ph={extension:{type:Ki.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async t=>[...t,...Th],remove:async t=>t.filter(t=>!Th.includes(t))},Eh="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope,Bh={extension:{type:Ki.DetectionParser,priority:0},test:async()=>me("video/mp4"),add:async t=>[...t,"mp4","m4v"],remove:async t=>t.filter(t=>"mp4"!==t&&"m4v"!==t)},Oh={extension:{type:Ki.DetectionParser,priority:0},test:async()=>me("video/ogg"),add:async t=>[...t,"ogv"],remove:async t=>t.filter(t=>"ogv"!==t)},kh={extension:{type:Ki.DetectionParser,priority:0},test:async()=>me("video/webm"),add:async t=>[...t,"webm"],remove:async t=>t.filter(t=>"webm"!==t)},Rh={extension:{type:Ki.DetectionParser,priority:0},test:async()=>ge("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async t=>[...t,"webp"],remove:async t=>t.filter(t=>"webp"!==t)};class Dh{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{let n=null,s=null;if((e.parser||e.loadParser)&&(s=this._parserHash[e.parser||e.loadParser],e.loadParser&&a(),s||a(e.parser||e.loadParser)),!s){for(let i=0;i<this.parsers.length;i++){const n=this.parsers[i];if(n.load&&n.test?.(t,e,this)){s=n;break}}if(!s)return a(),null}n=await s.load(t,e,this),i.parser=s;for(let t=0;t<this.parsers.length;t++){const s=this.parsers[t];s.parse&&s.parse&&await(s.testParse?.(n,e,this))&&(n=await s.parse(n,e,this)||n,i.parser=s)}return n})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const n={},s=ur(t),r=ar(t,t=>({alias:[t],src:t,data:{}})),o=r.length,a=r.map(async t=>{const s=dr.toAbsolute(t.src);if(!n[t.src])try{this.promiseCache[s]||(this.promiseCache[s]=this._getLoadPromiseAndParser(s,t)),n[t.src]=await this.promiseCache[s].promise,e&&e(++i/o)}catch(e){throw delete this.promiseCache[s],delete n[t.src],new Error(`[Loader.load] Failed to load ${s}.\n${e}`)}});return await Promise.all(a),s?n[r[0].src]:n}async unload(t){const e=ar(t,t=>({alias:[t],src:t})).map(async t=>{const e=dr.toAbsolute(t.src),i=this.promiseCache[e];if(i){const n=await i.promise;delete this.promiseCache[e],await(i.parser?.unload?.(n,t,this))}});await 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])&&a(e.id):a(),t[e.name]=e,e.id&&(t[e.id]=e),t),{})}}const Fh={extension:{type:Ki.LoadParser,priority:cr.Low},name:"loadJson",id:"json",test:t=>ye(t,"application/json")||xe(t,".json"),async load(t){const e=await qs.get().fetch(t);return await e.json()}},Lh={name:"loadTxt",id:"text",extension:{type:Ki.LoadParser,priority:cr.Low,name:"loadTxt"},test:t=>ye(t,"text/plain")||xe(t,".txt"),async load(t){const e=await qs.get().fetch(t);return await e.text()}},jh=["normal","bold","100","200","300","400","500","600","700","800","900"],Gh=[".ttf",".otf",".woff",".woff2"],Uh=["font/ttf","font/otf","font/woff","font/woff2"],Nh=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i,zh=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/,Hh={extension:{type:Ki.LoadParser,priority:cr.Low},name:"loadWebFont",id:"web-font",test:t=>ye(t,Uh)||xe(t,Gh),async load(t,e){const i=qs.get().getFontFaceSet();if(i){const n=[],s=e.data?.family??function(t){const e=dr.extname(t),i=dr.basename(t,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1));let n=i.length>0;for(const t of i)if(!t.match(Nh)){n=!1;break}let s=i.join(" ");return n||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}(t),r=e.data?.weights?.filter(t=>jh.includes(t))??["normal"],o=e.data??{};for(let e=0;e<r.length;e++){const a=r[e],h=new FontFace(s,`url(${be(t)})`,{...o,weight:a});await h.load(),i.add(h),n.push(h)}return hr.has(`${s}-and-url`)?hr.get(`${s}-and-url`).entries.push({url:t,faces:n}):hr.set(`${s}-and-url`,{entries:[{url:t,faces:n}]}),1===n.length?n[0]:n}return a(),null},unload(t){const e=Array.isArray(t)?t:[t],i=e[0].family,n=hr.get(`${i}-and-url`),s=n.entries.find(t=>t.faces.some(t=>-1!==e.indexOf(t)));s.faces=s.faces.filter(t=>-1===e.indexOf(t)),0===s.faces.length&&(n.entries=n.entries.filter(t=>t!==s)),e.forEach(t=>{qs.get().getFontFaceSet().delete(t)}),0===n.entries.length&&hr.remove(`${i}-and-url`)}},Vh={extension:{type:Ki.LoadParser,priority:cr.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test:t=>ye(t,"image/svg+xml")||xe(t,".svg"),async load(t,e,i){return e.data?.parseAsGraphicsContext??this.config.parseAsGraphicsContext?async function(t){const e=await qs.get().fetch(t),i=await e.text(),n=new lh;return n.svg(i),n}(t):async function(t,e,i,n){const s=await qs.get().fetch(t),r=await s.blob(),o=URL.createObjectURL(r),a=qs.get().createImage();a.src=o,a.crossOrigin=n,await a.decode(),URL.revokeObjectURL(o);const h=e.data?.width??a.width,l=e.data?.height??a.height,c=e.data?.resolution||_e(t),d=qs.get().createCanvas(h*c,l*c);d.getContext("2d").drawImage(a,0,0,h*c,l*c);const{parseAsGraphicsContext:u,...p}=e.data??{};return ve(new $s({resource:d,alphaMode:"premultiply-alpha-on-upload",resolution:c,...p}),i,t)}(t,e,i,this.config.crossOrigin)},unload(t){t.destroy(!0)}};let Wh=null,Zh=class{constructor(){Wh||(Wh=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(Wh)}};Zh.revokeObjectURL=function(){Wh&&(URL.revokeObjectURL(Wh),Wh=null)};let Jh=null;class Xh{constructor(){Jh||(Jh=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(Jh)}}Xh.revokeObjectURL=function(){Jh&&(URL.revokeObjectURL(Jh),Jh=null)};let Yh,Kh=0;const qh=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 Zh;e.addEventListener("message",i=>{e.terminate(),Zh.revokeObjectURL(),t(i.data)})})),this._isImageBitmapSupported}loadImageBitmap(t,e){return this._run("loadImageBitmap",[t,e?.data?.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){void 0===Yh&&(Yh=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<Yh&&(this._createdWorkers++,t=(new Xh).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}async _run(t,e){await 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[Kh]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Kh++,id:i})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t?.(new Error("WorkerManager destroyed"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}},Qh=[".jpeg",".jpg",".png",".webp",".avif"],$h=["image/jpeg","image/png","image/webp","image/avif"],tl={name:"loadTextures",id:"texture",extension:{type:Ki.LoadParser,priority:cr.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test:t=>ye(t,$h)||xe(t,Qh),async load(t,e,i){let n=null;return n=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await qh.isImageBitmapSupported()?await qh.loadImageBitmap(t,e):await async function(t,e){const i=await qs.get().fetch(t);if(!i.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${t}: ${i.status} ${i.statusText}`);const n=await i.blob();return"premultiplied-alpha"===e?.data?.alphaMode?createImageBitmap(n,{premultiplyAlpha:"none"}):createImageBitmap(n)}(t,e):await new Promise((e,i)=>{n=qs.get().createImage(),n.crossOrigin=this.config.crossOrigin,n.src=t,n.complete?e(n):(n.onload=()=>{e(n)},n.onerror=i)}),ve(new $s({resource:n,alphaMode:"premultiply-alpha-on-upload",resolution:e.data?.resolution||_e(t),...e.data}),i,t)},unload(t){t.destroy(!0)}},el=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let il,nl;const sl={name:"loadVideo",id:"video",extension:{type:Ki.LoadParser,name:"loadVideo"},test(t){if(!il||!nl){const{validVideoExtensions:t,validVideoMime:e}=function(){const t=[],e=[];for(const i of el){const n=or.MIME_TYPES[i.substring(1)]||`video/${i.substring(1)}`;me(n)&&(t.push(i),e.includes(n)||e.push(n))}return{validVideoExtensions:t,validVideoMime:e}}();il=t,nl=e}const e=ye(t,nl),i=xe(t,il);return e||i},async load(t,e,i){const n={...or.defaultOptions,resolution:e.data?.resolution||_e(t),alphaMode:e.data?.alphaMode||await w(),...e.data},s=document.createElement("video"),r={preload:!1!==n.autoLoad?"auto":void 0,"webkit-playsinline":!1!==n.playsinline?"":void 0,playsinline:!1!==n.playsinline?"":void 0,muted:!0===n.muted?"":void 0,loop:!0===n.loop?"":void 0,autoplay:!1!==n.autoPlay?"":void 0};Object.keys(r).forEach(t=>{const e=r[t];void 0!==e&&s.setAttribute(t,e)}),!0===n.muted&&(s.muted=!0),function(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);return i.hostname!==e.hostname||i.port!==e.port||i.protocol!==e.protocol?"anonymous":""}(e)}(s,t,n.crossorigin);const o=document.createElement("source");let a;if(n.mime)a=n.mime;else if(t.startsWith("data:"))a=t.slice(5,t.indexOf(";"));else if(!t.startsWith("blob:")){const e=t.split("?")[0].slice(t.lastIndexOf(".")+1).toLowerCase();a=or.MIME_TYPES[e]||`video/${e}`}return o.src=t,a&&(o.type=a),new Promise(r=>{const a=async()=>{const o=new or({...n,resource:s});var h;s.removeEventListener("canplay",a),e.data.preload&&await(h=s,new Promise((t,e)=>{function i(){s(),t()}function n(t){s(),e(t)}function s(){h.removeEventListener("canplaythrough",i),h.removeEventListener("error",n)}h.addEventListener("canplaythrough",i),h.addEventListener("error",n),h.load()})),r(ve(o,i,t))};n.preload&&!n.autoPlay&&s.load(),s.addEventListener("canplay",a),s.appendChild(o)})},unload(t){t.destroy(!0)}},rl={extension:{type:Ki.ResolveParser,name:"resolveTexture"},test:tl.test,parse:t=>({resolution:parseFloat(pr.RETINA_PREFIX.exec(t)?.[1]??"1"),format:t.split(".").pop(),src:t})},ol={extension:{type:Ki.ResolveParser,priority:-2,name:"resolveJson"},test:t=>pr.RETINA_PREFIX.test(t)&&t.endsWith(".json"),parse:rl.parse},al=new class{constructor(){this._detections=[],this._initialized=!1,this.resolver=new pr,this.loader=new Dh,this.cache=hr,this._backgroundLoader=new Ah(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){if(this._initialized)return void a();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=await this.load(e)),this.resolver.addManifest(e)}const e=t.texturePreference?.resolution??1,i="number"==typeof e?[e]:e,n=await this._detectFormats({preferredFormats:t.texturePreference?.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=ur(t),n=ar(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}),s=this.resolver.resolve(n),r=await this._mapLoadToResolve(s,e);return i?r[n[0]]:r}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;"string"==typeof t&&(i=!0,t=[t]);const n=this.resolver.resolveBundle(t),s={},r=Object.keys(n);let o=0,a=0;const h=()=>{e?.(++o/a)},l=r.map(t=>{const e=n[t],i=Object.values(e),r=[...new Set(i.flat())];return a+=r.length,this._mapLoadToResolve(e,h).then(e=>{s[t]=e})});return await Promise.all(l),i?s[t[0]]:s}async backgroundLoad(t){this._initialized||await this.init(),"string"==typeof t&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await 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 hr.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=hr.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const s={};return i.forEach(t=>{const e=n[t.src],i=[t.src];t.alias&&i.push(...t.alias),i.forEach(t=>{s[t]=e}),hr.set(i,e)}),s}async unload(t){this._initialized||await this.init();const e=ar(t).map(t=>"string"!=typeof t?t.src:t),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=ar(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(t=>this._unloadFromResolved(e[t]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(t=>{hr.remove(t.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((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]})})}};$i.handleByList(Ki.LoadParser,al.loader.parsers).handleByList(Ki.ResolveParser,al.resolver.parsers).handleByList(Ki.CacheParser,al.cache.parsers).handleByList(Ki.DetectionParser,al.detections),$i.add(Ih,Ph,Mh,Rh,Bh,Oh,kh,Fh,Lh,Hh,Vh,tl,sl,Sh,Ch,rl,ol);const hl={loader:Ki.LoadParser,resolver:Ki.ResolveParser,cache:Ki.CacheParser,detection:Ki.DetectionParser};$i.handle(Ki.Asset,t=>{const e=t.ref;Object.entries(hl).filter(([t])=>!!e[t]).forEach(([t,i])=>$i.add(Object.assign(e[t],{extension:e[t].extension??i})))},t=>{const e=t.ref;Object.keys(hl).filter(t=>!!e[t]).forEach(t=>$i.remove(e[t]))});class ll extends Vs{constructor(t={}){const{element:e,anchor:i,...n}=t;super({label:"DOMContainer",...n}),this.renderPipeId="dom",this.batched=!1,this._anchor=new cn(0,0),i&&(this.anchor=i),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){super.destroy(t),this._element?.parentNode?.removeChild(this._element),this._element=null,this._anchor=null}}class cl{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 br({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)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,s=i.width*e.x,r=i.height*e.y;n.style.transformOrigin=`${s}px ${r}px`,n.style.transform=`matrix(${t.a}, ${t.b}, ${t.c}, ${t.d}, ${t.tx-s}, ${t.ty-r})`,n.style.opacity=i.groupAlpha.toString()}}}else this._domElement.remove()}destroy(){this._renderer.runners.postrender.remove(this);for(let t=0;t<this._attachedDomElements.length;t++){const e=this._attachedDomElements[t];e.element?.remove()}this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}cl.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"dom"};const dl=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&&(sr.system.add(this._tickerUpdate,this,tr.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(sr.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 ul extends _r{constructor(){super(...arguments),this.client=new cn,this.movement=new cn,this.offset=new cn,this.global=new cn,this.screen=new cn}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,s,r,o,a,h,l,c,d,u,p,f){throw new Error("Method not implemented.")}}class pl extends ul{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 fl extends ul{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}fl.DOM_DELTA_PIXEL=0,fl.DOM_DELTA_LINE=1,fl.DOM_DELTA_PAGE=2;const gl=new cn,ml=new cn;class yl{constructor(t){this.dispatch=new on,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 a(t.type)}hitTest(t,e){dl.pauseUpdate=!0;const i=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,gl.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,s=i.length-1;n<s;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 e=i.length-1;e>=0;e--)n.forEach(n=>{t.currentTarget=i[e],this.notifyTarget(t,n)})}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,s,r=!1){let o=!1;if(this._interactivePrune(t))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(dl.pauseUpdate=!1),t.interactiveChildren&&t.children){const a=t.children;for(let h=a.length-1;h>=0;h--){const l=a[h],c=this.hitTestMoveRecursive(l,this._isInteractive(e)?e:l.eventMode,i,n,s,r||s(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),h=t.isInteractive();return h&&h&&this._allInteractiveElements.push(t),r||this._hitElements.length>0?null:o?this._hitElements:a&&!s(t,i)&&n(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,n,s){if(this._interactivePrune(t)||s(t,i))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(dl.pauseUpdate=!1),t.interactiveChildren&&t.children){const r=t.children,o=i;for(let i=r.length-1;i>=0;i--){const a=r[i],h=this.hitTestRecursive(a,this._isInteractive(e)?e:a.eventMode,o,n,s);if(h){if(h.length>0&&!h[h.length-1].parent)continue;const e=t.isInteractive();return(h.length>0||e)&&h.push(t),h}}}const r=this._isInteractive(e),o=t.isInteractive();return r&&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,ml),!t.hitArea.contains(ml.x,ml.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&&!n.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return!!t.hitArea||!!t?.containsPoint&&(t.worldTransform.applyInverse(e,ml),t.containsPoint(ml))}notifyTarget(t,e){if(!t.currentTarget.isInteractive())return;e??(e=t.type);const i=`on${e}`;t.currentTarget[i]?.(t);const n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof pl))return void a();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){if(!(t instanceof pl))return void a();this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i="mouse"===e.pointerType||"pen"===e.pointerType,n=this.trackingData(t.pointerId),s=this.findMountedTarget(n.overTargets);if(n.overTargets?.length>0&&s!==e.target){const n="mousemove"===t.type?"mouseout":"pointerout",r=this.createPointerEvent(t,n,s);if(this.dispatchEvent(r,"pointerout"),i&&this.dispatchEvent(r,"mouseout"),!e.composedPath().includes(s)){const n=this.createPointerEvent(t,"pointerleave",s);for(n.eventPhase=n.AT_TARGET;n.target&&!e.composedPath().includes(n.target);)n.currentTarget=n.target,this.notifyTarget(n),i&&this.notifyTarget(n,"mouseleave"),n.target=n.target.parent;this.freeEvent(n)}this.freeEvent(r)}if(s!==e.target){const n="mousemove"===t.type?"mouseover":"pointerover",r=this.clonePointerEvent(e,n);this.dispatchEvent(r,"pointerover"),i&&this.dispatchEvent(r,"mouseover");let o=s?.parent;for(;o&&o!==this.rootTarget.parent&&o!==e.target;)o=o.parent;if(!o||o===this.rootTarget.parent){const t=this.clonePointerEvent(e,"pointerenter");for(t.eventPhase=t.AT_TARGET;t.target&&t.target!==s&&t.target!==this.rootTarget.parent;)t.currentTarget=t.target,this.notifyTarget(t),i&&this.notifyTarget(t,"mouseenter"),t.target=t.target.parent;this.freeEvent(t)}this.freeEvent(r)}const r=[],o=this.enableGlobalMoveEvents??!0;this.moveOnAll?r.push("pointermove"):this.dispatchEvent(e,"pointermove"),o&&r.push("globalpointermove"),"touch"===e.pointerType&&(this.moveOnAll?r.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),o&&r.push("globaltouchmove")),i&&(this.moveOnAll?r.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),o&&r.push("globalmousemove"),this.cursor=e.target?.cursor),r.length>0&&this.all(e,r),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){if(!(t instanceof pl))return void a();const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),n="mouse"===i.pointerType||"pen"===i.pointerType;this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),"mouse"===i.pointerType&&(this.cursor=i.target?.cursor);const s=this.clonePointerEvent(i,"pointerenter");for(s.eventPhase=s.AT_TARGET;s.target&&s.target!==this.rootTarget.parent;)s.currentTarget=s.target,this.notifyTarget(s),n&&this.notifyTarget(s,"mouseenter"),s.target=s.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(s)}mapPointerOut(t){if(!(t instanceof pl))return void a();const e=this.trackingData(t.pointerId);if(e.overTargets){const i="mouse"===t.pointerType||"pen"===t.pointerType,n=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",n);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const r=this.createPointerEvent(t,"pointerleave",n);for(r.eventPhase=r.AT_TARGET;r.target&&r.target!==this.rootTarget.parent;)r.currentTarget=r.target,this.notifyTarget(r),i&&this.notifyTarget(r,"mouseleave"),r.target=r.target.parent;e.overTargets=null,this.freeEvent(s),this.freeEvent(r)}this.cursor=null}mapPointerUp(t){if(!(t instanceof pl))return void a();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),s=this.findMountedTarget(n.pressTargetsByButton[t.button]);let r=s;if(s&&!i.composedPath().includes(s)){let e=s;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],r=e}if(r){const s=this.clonePointerEvent(i,"click");s.target=r,s.path=null,n.clicksByButton[t.button]||(n.clicksByButton[t.button]={clickCount:0,target:s.target,timeStamp:e});const o=n.clicksByButton[t.button];if(o.target===s.target&&e-o.timeStamp<200?++o.clickCount:o.clickCount=1,o.target=s.target,o.timeStamp=e,s.detail=o.clickCount,"mouse"===s.pointerType){const t=2===s.button;this.dispatchEvent(s,t?"rightclick":"click")}else"touch"===s.pointerType&&this.dispatchEvent(s,"tap");this.dispatchEvent(s,"pointertap"),this.freeEvent(s)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof pl))return void a();const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),n=this.createPointerEvent(t);if(i){let s=i;for(;s;)n.currentTarget=s,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"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(n)}mapWheel(t){if(!(t instanceof fl))return void a();const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const n=this.allocateEvent(pl);return this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.nativeEvent=t.nativeEvent,n.originalEvent=t,n.target=i??this.hitTest(n.global.x,n.global.y)??this._hitElements[0],"string"==typeof e&&(n.type=e),n}createWheelEvent(t){const e=this.allocateEvent(fl);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(pl);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof pl&&e instanceof pl&&(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 ul&&e instanceof ul&&(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,s=i.length;n<s&&!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 xl={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},bl=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 yl(null),dl.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new pl(null),this._rootWheelEvent=new fl(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...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){const{canvas:i,resolution:n}=this.renderer;this.setTargetElement(i),this.resolution=n,t._defaultEventMode=e.eventMode??"passive",Object.assign(this.features,e.eventFeatures??{}),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);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let t=0,i=e.length;t<i;t++){const i=e[t],n=this._bootstrapEvent(this._rootPointerEvent,i);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,dl.pointerMoved();const e=this._normalizeToPointerData(t);for(let t=0,i=e.length;t<i;t++){const i=this._bootstrapEvent(this._rootPointerEvent,e[t]);this.rootBoundary.mapEvent(i)}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 t=0,e=n.length;t<e;t++){const e=this._bootstrapEvent(this._rootPointerEvent,n[t]);e.type+=i,this.rootBoundary.mapEvent(e)}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 t=0,i=e.length;t<i;t++){const i=this._bootstrapEvent(this._rootPointerEvent,e[t]);this.rootBoundary.mapEvent(i)}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,dl.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;dl.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;dl.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},s=1/this.resolution;t.x=(e-n.left)*(this.domElement.width/n.width)*s,t.y=(i-n.top)*(this.domElement.height/n.height)*s}_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)){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)}else e.push(t);return e}normalizeWheelEvent(t){const e=this._rootWheelEvent;return this._transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}_bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this._transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=xl[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}};bl.extension={name:"events",type:[Ki.WebGLSystem,Ki.CanvasSystem,Ki.WebGPUSystem],priority:-1},bl.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let _l=bl;const vl={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(){return this._internalEventMode??_l.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,s="object"==typeof i?i.signal:void 0,r="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,h=this;s&&s.addEventListener("abort",()=>{h.off(t,a,o)}),r?h.once(t,a,o):h.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 _r))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 wl{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}}wl.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"filter"};const Cl=new da({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 Sl{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new jn,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0}}}class Al{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new so({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 ro({}),this.renderer=t}get activeBackTexture(){return this._activeFilterData?.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 s=e.renderTarget.renderTarget.colorTexture.source,r=s.resolution,o=s.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,r,1),n.skip)return;const h=this._getPreviousFilterData(),l=this._findFilterResolution(r);let c=0,d=0;h&&(c=h.bounds.minX,d=h.bounds.minY),this._calculateGlobalFrame(n,c,d,l,s.width,s.height),this._setupFilterTextures(n,a,e,h)}generateFilteredTexture({texture:t,filters:e}){const i=this._pushFilterData();this._activeFilterData=i,i.skip=!1,i.filters=e;const n=t.source,s=n.resolution,r=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,r,s,0),i.skip)return t;const a=s;this._calculateGlobalFrame(i,0,0,a,n.width,n.height),i.outputRenderSurface=Ls.getOptimalTexture(o.width,o.height,i.resolution,i.antialias),i.backTexture=Fn.EMPTY,i.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(i,!0);const h=i.outputRenderSurface;return h.source.alphaMode="premultiplied-alpha",h}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&&Ls.returnTexture(e.backTexture),Ls.returnTexture(e.inputTexture))}getBackTexture(t,e,i){const n=t.colorTexture.source._resolution,s=Ls.getOptimalTexture(e.width,e.height,n,!1);let r=e.minX,o=e.minY;i&&(r-=i.minX,o-=i.minY),r=Math.floor(r*n),o=Math.floor(o*n);const a=Math.ceil(e.width*n),h=Math.ceil(e.height*n);return this.renderer.renderTarget.copyToTexture(t,s,{x:r,y:o},{width:a,height:h},{x:0,y:0}),s}applyFilter(t,e,i,n){const s=this.renderer,r=this._activeFilterData,o=r.outputRenderSurface===i,a=s.renderTarget.rootRenderTarget.colorTexture.source._resolution,h=this._findFilterResolution(a);let l=0,c=0;if(o){const t=this._findPreviousFilterOffset();l=t.x,c=t.y}this._updateFilterUniforms(e,i,r,l,c,h,o,n),this._setupBindGroupsAndRender(t,e,s)}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),s=e.worldTransform.copyTo(un.shared),r=e.renderGroup||e.parentRenderGroup;return r&&r.cacheToLocalTransform&&s.prepend(r.cacheToLocalTransform),s.invert(),n.prepend(s),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:Cl,shader:t,state:t._state,topology:"triangle-list"}),i.type===oo.WEBGL&&i.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,i,n){if(t.backTexture=Fn.EMPTY,t.blendRequired){i.renderTarget.finishRenderPass();const s=i.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(s,e,n?.bounds)}t.inputTexture=Ls.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,s,r){const o=t.globalFrame;o.x=e*n,o.y=i*n,o.width=s*n,o.height=r*n}_updateFilterUniforms(t,e,i,n,s,r,o,a){const h=this._filterGlobalUniforms.uniforms,l=h.uOutputFrame,c=h.uInputSize,d=h.uInputPixel,u=h.uInputClamp,p=h.uGlobalFrame,f=h.uOutputTexture;o?(l[0]=i.bounds.minX-n,l[1]=i.bounds.minY-s):(l[0]=0,l[1]=0),l[2]=t.frame.width,l[3]=t.frame.height,c[0]=t.source.width,c[1]=t.source.height,c[2]=1/c[0],c[3]=1/c[1],d[0]=t.source.pixelWidth,d[1]=t.source.pixelHeight,d[2]=1/d[0],d[3]=1/d[1],u[0]=.5*d[2],u[1]=.5*d[3],u[2]=t.frame.width*c[2]-.5*d[2],u[3]=t.frame.height*c[3]-.5*d[3];const g=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=n*r,p[1]=s*r,p[2]=g.source.width*r,p[3]=g.source.height*r,e instanceof Fn&&(e.source.resource=null);const m=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!a),e instanceof Fn?(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 i=0;i<t.length;i++){const n=t[i];n.globalDisplayStatus<7||(e.matrix=n.worldTransform,e.addBounds(n.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,s=t.filters;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),1===s.length)s[0].apply(this,i,t.outputRenderSurface,e);else{let i=t.inputTexture;const r=Ls.getOptimalTexture(n.width,n.height,i.source._resolution,!1);let o=r,a=0;for(a=0;a<s.length-1;++a){s[a].apply(this,i,o,!0);const t=i;i=o,o=t}s[a].apply(this,i,t.outputRenderSurface,e),Ls.returnTexture(r)}}_calculateFilterBounds(t,e,i,n,s){const r=this.renderer,o=t.bounds,h=t.filters;let l=1/0,c=0,d=!0,u=!1,p=!1,f=!0;for(let t=0;t<h.length;t++){const e=h[t];if(l=Math.min(l,"inherit"===e.resolution?n:e.resolution),c+=e.padding,"off"===e.antialias?d=!1:"inherit"===e.antialias&&d&&(d=i),e.clipToViewport||(f=!1),!(e.compatibleRenderers&r.type)){p=!1;break}if(e.blendRequired&&!(r.backBuffer?.useBackBuffer??1)){a(),p=!1;break}p=e.enabled||p,u||(u=e.blendRequired)}p?(f&&o.fitBounds(0,e.width/n,0,e.height/n),o.scale(l).ceil().scale(1/l).pad((0|c)*s),o.isPositive?(t.antialias=d,t.resolution=l,t.blendRequired=u):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 Sl),this._filterStackIndex++,t}}Al.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem],name:"filter"};var Il="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 Ml extends po{constructor(t){const{sprite:e,...i}=t,n=new Dn(e.texture),s=new so({uFilterMatrix:{value:new un,type:"mat3x3<f32>"},uMaskClamp:{value:n.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"}});super({...i,gpuProgram:to.from({vertex:{source:Il,entryPoint:"mainVertex"},fragment:{source:Il,entryPoint:"mainFragment"}}),glProgram:Yr.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"}),clipToViewport:!1,resources:{filterUniforms:s,uMaskTexture:e.texture.source}}),this.sprite=e,this._textureMatrix=n}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)}}class Tl extends Vs{constructor(t){t instanceof lh&&(t={context:t});const{context:e,roundPixels:i,...n}=t||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",this._context=e||(this._ownedContext=new lh),this._context.on("update",this.onViewUpdate,this),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=i??!1}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!==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){return t?new Tl(this._context.clone()):(this._ownedContext=null,new Tl(this._context))}lineStyle(t,e,n){i(0,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const s={};return t&&(s.width=t),e&&(s.color=e),n&&(s.alpha=n),this.context.strokeStyle=s,this}beginFill(t,e){i(0,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const n={};return void 0!==t&&(n.color=t),void 0!==e&&(n.alpha=e),this.context.fillStyle=n,this}endFill(){i(0,"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===lh.defaultStrokeStyle.width&&t.color===lh.defaultStrokeStyle.color&&t.alpha===lh.defaultStrokeStyle.alpha||this.context.stroke(),this}drawCircle(...t){return i(0,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return i(0,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return i(0,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return i(0,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return i(0,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return i(0,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const Pl=class t extends da{constructor(...e){let n=e[0]??{};n instanceof Float32Array&&(i(0,"use new MeshGeometry({ positions, uvs, indices }) instead"),n={positions:n,uvs:e[1],indices:e[2]}),n={...t.defaultOptions,...n};const s=n.positions||new Float32Array([0,0,1,0,1,1,0,1]);let r=n.uvs;r||(r=n.positions?new Float32Array(s.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 ca({data:s,label:"attribute-mesh-positions",shrinkToFit:a,usage:la.VERTEX|la.COPY_DST}),format:"float32x2",stride:8,offset:0},aUV:{buffer:new ca({data:r,label:"attribute-mesh-uvs",shrinkToFit:a,usage:la.VERTEX|la.COPY_DST}),format:"float32x2",stride:8,offset:0}},indexBuffer:new ca({data:o,label:"index-mesh-buffer",shrinkToFit:a,usage:la.INDEX|la.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}};Pl.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let El=Pl;class Bl extends Vs{constructor(...t){let e=t[0];e instanceof da&&(i(0,"Mesh: use new Mesh({ geometry, shader }) instead"),e={geometry:e,shader:t[1]},t[3]&&(i(0,"Mesh: drawMode argument has been removed, use geometry.topology instead"),e.geometry.topology=t[3]));const{geometry:n,shader:s,texture:r,roundPixels:o,state:a,...h}=e;super({label:"Mesh",...h}),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=s??null,this.texture=r??s?.texture??Fn.WHITE,this.state=a??co.for2d(),this._geometry=n,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=o??!1}get material(){return i(0,"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){this._geometry!==t&&(this._geometry?.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=Fn.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 El&&("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,s="triangle-strip"===this.geometry.topology?3:1;if(this.geometry.getIndex()){const t=this.geometry.getIndex().data,r=t.length;for(let o=0;o+2<r;o+=s){const s=2*t[o],r=2*t[o+1],a=2*t[o+2];if(we(e,i,n[s],n[s+1],n[r],n[r+1],n[a],n[a+1]))return!0}}else{const t=n.length/2;for(let r=0;r+2<t;r+=s){const t=2*r,s=2*(r+1),o=2*(r+2);if(we(e,i,n[t],n[t+1],n[s],n[s+1],n[o],n[o+1]))return!0}}return!1}destroy(t){if(super.destroy(t),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._texture.destroy(e)}this._geometry?.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null,this._gpuData=null}}class Ol extends Ws{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{animationSpeed:i=1,autoPlay:n=!1,autoUpdate:s=!0,loop:r=!0,onComplete:o=null,onFrameChange:a=null,onLoop:h=null,textures:l,updateAnchor:c=!1,...d}=e,[u]=l;super({...d,texture:u instanceof Fn?u:u.texture}),this._textures=null,this._durations=null,this._autoUpdate=s,this._isConnectedToTicker=!1,this.animationSpeed=i,this.loop=r,this.updateAnchor=c,this.onComplete=o,this.onFrameChange=a,this.onLoop=h,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=l,n&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(sr.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(sr.shared.add(this.update,this,tr.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:t?.texture){const e="boolean"==typeof t?t: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(Fn.from(t[i]));return new Ol(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(Fn.from(t[i]));return new Ol(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof Fn)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?(sr.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(sr.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class kl{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t??new un,this.observer=e,this.position=new nn(this,0,0),this.scale=new nn(this,1,1),this.pivot=new nn(this,0,0),this.skew=new nn(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){this.dirty=!0,t===this.skew&&this.updateSkew(),this.observer?._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 Rl=class t extends Vs{constructor(...e){let n=e[0]||{};n instanceof Fn&&(n={texture:n}),e.length>1&&(i(0,"use new TilingSprite({ texture, width:100, height:100 }) instead"),n.width=e[1],n.height=e[2]),n={...t.defaultOptions,...n};const{texture:s,anchor:r,tilePosition:o,tileScale:a,tileRotation:h,width:l,height:c,applyAnchorToTexture:d,roundPixels:u,...p}=n??{};super({label:"TilingSprite",...p}),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new nn({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=d,this.texture=s,this._width=l??s.width,this._height=c??s.height,this._tileTransform=new kl({observer:{_onUpdate:()=>this.onViewUpdate()}}),r&&(this.anchor=r),this.tilePosition=o,this.tileScale=a,this.tileRotation=h,this.roundPixels=u??!1}static from(e,i={}){return new t("string"==typeof e?{texture:hr.get(e),...i}:{texture:e,...i})}get uvRespectAnchor(){return a(),this.applyAnchorToTexture}set uvRespectAnchor(t){a(),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=Fn.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){"object"==typeof t&&(e=t.height??t.width,t=t.width),this._width=t,this._height=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 s=0;return t.x>=n&&t.x<=n+e&&(s=-i*this._anchor._y,t.y>=s&&t.y<=s+i)}destroy(t=!1){if(super.destroy(t),this._anchor=null,this._tileTransform=null,this._bounds=null,"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._texture.destroy(e)}this._texture=null}};Rl.defaultOptions={texture:Fn.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let Dl=Rl;class Fl extends Vs{constructor(t,e){const{text:i,resolution:n,style:s,anchor:r,width:o,height:a,roundPixels:h,...l}=t;super({...l}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i??"",this.style=s,this.resolution=n??null,this.allowChildren=!1,this._anchor=new nn({_onUpdate:()=>{this.onViewUpdate()}}),r&&(this.anchor=r),this.roundPixels=h??!1,void 0!==o&&(this.width=o),void 0!==a&&(this.height=a)}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){t||(t={}),this._style?.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){"object"==typeof t?(e=t.height??t.width,t=t.width):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 s=0;return t.x>=n&&t.x<=n+e&&(s=-i*this.anchor.y,t.y>=s&&t.y<=s+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:t?.style)&&this._style.destroy(t),this._style=null,this._text=null}}let Ll=null,jl=null;const Gl=new Sn,Ul=new class{getCanvasAndContext(t){const{text:e,style:i,resolution:n=1}=t,s=i._getFinalPadding(),r=Fo.measureText(e||" ",i),o=Math.ceil(Math.ceil(Math.max(1,r.width)+2*s)*n),a=Math.ceil(Math.ceil(Math.max(1,r.height)+2*s)*n),h=ph.getOptimalCanvasAndContext(o,a);return this._renderTextToCanvas(e,i,s,n,h),{canvasAndContext:h,frame:i.trim?Ae({canvas:h.canvas,width:o,height:a,resolution:1,output:Gl}):Gl.set(0,0,o,a)}}returnCanvasAndContext(t){ph.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,i,n,s){const{canvas:r,context:o}=s,a=dt(e),h=Fo.measureText(t||" ",e),l=h.lines,c=h.lineHeight,d=h.lineWidths,u=h.maxLineWidth,p=h.fontProperties,f=r.height;if(o.resetTransform(),o.scale(n,n),o.textBaseline=e.textBaseline,e._stroke?.width){const t=e._stroke;o.lineWidth=t.width,o.miterLimit=t.miterLimit,o.lineJoin=t.join,o.lineCap=t.cap}let g,m;o.font=a;const y=e.dropShadow?2:1;for(let t=0;t<y;++t){const r=e.dropShadow&&0===t,a=r?Math.ceil(Math.max(1,f)+2*i):0,y=a*n;if(r){o.fillStyle="black",o.strokeStyle="black";const t=e.dropShadow,i=t.color,s=t.alpha;o.shadowColor=ps.shared.setValue(i).setAlpha(s).toRgbaString();const r=t.blur*n,a=t.distance*n;o.shadowBlur=r,o.shadowOffsetX=Math.cos(t.angle)*a,o.shadowOffsetY=Math.sin(t.angle)*a+y}else{if(o.fillStyle=e._fill?pe(e._fill,o,h,2*i):null,e._stroke?.width){const t=.5*e._stroke.width+2*i;o.strokeStyle=pe(e._stroke,o,h,t)}o.shadowColor="black"}let x=(c-p.fontSize)/2;c-p.fontSize<0&&(x=0);const b=e._stroke?.width??0;for(let t=0;t<l.length;t++)g=b/2,m=b/2+t*c+p.ascent+x,"right"===e.align?g+=u-d[t]:"center"===e.align&&(g+=(u-d[t])/2),e._stroke?.width&&this._drawLetterSpacing(l[t],e,s,g+i,m+i-a,!0),void 0!==e._fill&&this._drawLetterSpacing(l[t],e,s,g+i,m+i-a)}}_drawLetterSpacing(t,e,i,n,s,r=!1){const{context:o}=i,a=e.letterSpacing;let h=!1;if(Fo.experimentalLetterSpacingSupported&&(Fo.experimentalLetterSpacing?(o.letterSpacing=`${a}px`,o.textLetterSpacing=`${a}px`,h=!0):(o.letterSpacing="0px",o.textLetterSpacing="0px")),0===a||h)return void(r?o.strokeText(t,n,s):o.fillText(t,n,s));let l=n;const c=Fo.graphemeSegmenter(t);let d=o.measureText(t).width,u=0;for(let t=0;t<c.length;++t){const e=c[t];r?o.strokeText(e,l,s):o.fillText(e,l,s);let i="";for(let e=t+1;e<c.length;++e)i+=c[e];u=o.measureText(i).width,l+=d-u+a,d=u}}};class Nl extends Fl{constructor(...t){const e=function(t){let e=t[0]??{};return("string"==typeof e||t[1])&&(i(0,'use new Text({ text: "hi!", style }) instead'),e={text:e,style:t[1]}),e}(t);super(e,uh),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof En?e.textureStyle:new En(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,n=0;if(this._style.trim){const{frame:t,canvasAndContext:e}=Ul.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Ul.returnCanvasAndContext(e),i=t.width,n=t.height}else{const t=Fo.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 zl="http://www.w3.org/2000/svg",Hl="http://www.w3.org/1999/xhtml";class Vl{constructor(){this.svgRoot=document.createElementNS(zl,"svg"),this.foreignObject=document.createElementNS(zl,"foreignObject"),this.domElement=document.createElementNS(Hl,"div"),this.styleElement=document.createElementNS(Hl,"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=qs.get().createImage()}}let Wl;class Zl{constructor(){this._tempState=co.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,i){const n=t.renderer,s=this._didUploadHash[i.uid];n.shader.bind(i,s),s||(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 t=0;t<e.textures.count;t++)i.texture.bind(n[t],t);i.geometry.draw(e.topology,e.size,e.start)}}Zl.extension={type:[Ki.WebGLPipesAdaptor],name:"batch"};const Jl=co.for2d();class Xl{start(t,e,i){const n=t.renderer,s=n.encoder,r=i.gpuProgram;this._shader=i,this._geometry=e,s.setGeometry(e,r),Jl.blendMode="normal",n.pipeline.getPipeline(e,r,Jl);const o=n.globalUniforms.bindGroup;s.resetBindGroup(1),s.setBindGroup(0,o,r)}execute(t,e){const i=this._shader.gpuProgram,n=t.renderer,s=n.encoder;if(!e.bindGroup){const t=e.textures;e.bindGroup=gt(t.textures,t.count,n.limits.maxBatchableTextures)}Jl.blendMode=e.blendMode;const r=n.bindGroup.getBindGroup(e.bindGroup,i,1),o=n.pipeline.getPipeline(this._geometry,i,Jl,e.topology);e.bindGroup._touch(n.textureGC.count),s.setPipeline(o),s.renderPassEncoder.setBindGroup(1,r),s.renderPassEncoder.drawIndexed(e.size,1,e.start)}}Xl.extension={type:[Ki.WebGPUPipesAdaptor],name:"batch"};const Yl=class t{constructor(t,e){this.state=co.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init?.(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 Ba({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=e,this._activeBatch=this._activeBatches.default;for(const t in this._activeBatches)this._activeBatches[t].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 t in e){const i=e[t],n=i.geometry;n.indexBuffer.setDataWithSize(i.indexBuffer,i.indexSize,!0),n.buffers[0].setDataWithSize(i.attributeBuffer.float32View,i.attributeSize,!1)}}upload(t){const e=this._batchersByInstructionSet[t.uid];for(const t in e){const i=e[t],n=i.geometry;i.dirty&&(i.dirty=!1,n.buffers[0].update(4*i.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}};Yl.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"batch"},Yl._availableBatchers=Object.create(null);let Kl=Yl;$i.handleByMap(Ki.Batcher,Kl._availableBatchers),$i.add(Ba);const ql={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 "}},Ql={...ql,vertex:{...ql.vertex,header:ql.vertex.header.replace("group(1)","group(2)")}},$l={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 "}},tc={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 "}},ec={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 "}},ic=new jn;class nc extends _s{constructor(){super(),this.filters=[new Ml({sprite:new Ws(Fn.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 sc{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=ms.get(nc);if(n.inverse=t.inverse,i){t.mask.mask.measurable=!0;const i=l(t.mask.mask,!0,ic);t.mask.mask.measurable=!1,i.ceil();const s=e.renderTarget.renderTarget.colorTexture.source,r=Ls.getOptimalTexture(i.width,i.height,s._resolution,s.antialias);e.renderTarget.push(r,!0),e.globalUniforms.push({offset:i,worldColor:4294967295});const o=n.sprite;o.texture=r,o.worldTransform.tx=i.minX,o.worldTransform.ty=i.minY,this._activeMaskStage.push({filterEffect:n,maskedContainer:t.maskedContainer,filterTexture:r})}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===oo.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&&Ls.returnTexture(t.filterTexture),ms.return(t.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}sc.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"alphaMask"};class rc{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 s=this._colorStack[this._colorStackIndex];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;this._colorStackIndex--;const s=n[this._colorStackIndex-1];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._colorStack=null}}rc.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"colorMask"};class oc{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,i){var n;const s=t,r=this._renderer;r.renderPipes.batch.break(i),r.renderPipes.blendMode.setBlendMode(s.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const o=s.mask;o.includeInBuild=!0,this._maskHash.has(s)||this._maskHash.set(s,{instructionsStart:0,instructionsLength:0});const a=this._maskHash.get(s);a.instructionsStart=i.instructionSize,o.collectRenderables(i,r,null),o.includeInBuild=!1,r.renderPipes.batch.break(i),i.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const h=i.instructionSize-a.instructionsStart-1;a.instructionsLength=h;const l=r.renderTarget.renderTarget.uid;(n=this._maskStackHash)[l]??(n[l]=0)}pop(t,e,i){const n=t,s=this._renderer;s.renderPipes.batch.break(i),s.renderPipes.blendMode.setBlendMode(n.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1});const r=this._maskHash.get(t);for(let t=0;t<r.instructionsLength;t++)i.instructions[i.instructionSize++]=i.instructions[r.instructionsStart++];i.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e;const i=this._renderer,n=i.renderTarget.renderTarget.uid;let s=(e=this._maskStackHash)[n]??(e[n]=0);"pushMaskBegin"===t.action?(i.renderTarget.ensureDepthStencil(),i.stencil.setStencilMode($o.RENDERING_MASK_ADD,s),s++,i.colorMask.setMask(0)):"pushMaskEnd"===t.action?(t.inverse?i.stencil.setStencilMode($o.INVERSE_MASK_ACTIVE,s):i.stencil.setStencilMode($o.MASK_ACTIVE,s),i.colorMask.setMask(15)):"popMaskBegin"===t.action?(i.colorMask.setMask(0),0!==s?i.stencil.setStencilMode($o.RENDERING_MASK_REMOVE,s):(i.renderTarget.clear(null,yo.STENCIL),i.stencil.setStencilMode($o.DISABLED,s)),s--):"popMaskEnd"===t.action&&(t.inverse?i.stencil.setStencilMode($o.INVERSE_MASK_ACTIVE,s):i.stencil.setStencilMode($o.MASK_ACTIVE,s),i.colorMask.setMask(15)),this._maskStackHash[n]=s}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}oc.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"stencilMask"};var ac=(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))(ac||{});class hc{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class lc{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:s}=this;i||(i=0),e||(e=0),this._boundBufferBases[e]=null,s.bindBufferRange(s.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,s=t.descriptor.usage&la.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,s)):(i.byteLength=t.descriptor.size,e.bufferData(i.type,i.byteLength,s)),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=ac.ARRAY_BUFFER;t.descriptor.usage&la.INDEX?i=ac.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&la.UNIFORM&&(i=ac.UNIFORM_BUFFER);const n=new hc(e.createBuffer(),i);return this._gpuBuffers[t.uid]=n,t.on("destroy",this.onBufferDestroy,this),n}resetState(){this._boundBufferBases=Object.create(null)}}lc.extension={type:[Ki.WebGLSystem],name:"buffer"};const cc=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){e={...t.defaultOptions,...e};let i=this.multiView=e.multiView;if(e.context&&i&&(a(),i=!1),this.canvas=i?qs.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,i=e.premultipliedAlpha??!0,n=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:t,premultipliedAlpha:i,antialias:n,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(t){if(!this.multiView)return void(t!==this.canvas&&a());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 qs.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={...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={...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(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this._renderer.view.canvas;this._renderer=null,t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&!e.stencil&&a();const i=this.supports,n=2===this.webGLVersion,s=this.extensions;i.uint32Indices=n||!!s.uint32ElementIndex,i.uniformBufferObject=n,i.vertexArrayObject=n||!!s.vertexArrayObject,i.srgbTextures=n||!!s.srgb,i.nonPowOf2wrapping=n,i.nonPowOf2mipmaps=n,i.msaa=n,i.uint32Indices||a()}};cc.extension={type:[Ki.WebGLSystem],name:"context"},cc.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let dc=cc;var uc=(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))(uc||{}),pc=(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))(pc||{}),fc=(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))(fc||{});const gc={uint8x2:fc.UNSIGNED_BYTE,uint8x4:fc.UNSIGNED_BYTE,sint8x2:fc.BYTE,sint8x4:fc.BYTE,unorm8x2:fc.UNSIGNED_BYTE,unorm8x4:fc.UNSIGNED_BYTE,snorm8x2:fc.BYTE,snorm8x4:fc.BYTE,uint16x2:fc.UNSIGNED_SHORT,uint16x4:fc.UNSIGNED_SHORT,sint16x2:fc.SHORT,sint16x4:fc.SHORT,unorm16x2:fc.UNSIGNED_SHORT,unorm16x4:fc.UNSIGNED_SHORT,snorm16x2:fc.SHORT,snorm16x4:fc.SHORT,float16x2:fc.HALF_FLOAT,float16x4:fc.HALF_FLOAT,float32:fc.FLOAT,float32x2:fc.FLOAT,float32x3:fc.FLOAT,float32x4:fc.FLOAT,uint32:fc.UNSIGNED_INT,uint32x2:fc.UNSIGNED_INT,uint32x3:fc.UNSIGNED_INT,uint32x4:fc.UNSIGNED_INT,sint32:fc.INT,sint32x2:fc.INT,sint32x3:fc.INT,sint32x4:fc.INT},mc={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class yc{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,s)=>{i.drawArraysInstancedANGLE(t,e,n,s)},t.drawElementsInstanced=(t,e,n,s,r)=>{i.drawElementsInstancedANGLE(t,e,n,s,r)},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 t in n)if(!i[t])throw new Error(`shader and geometry incompatible, geometry missing the "${t}" attribute`)}getSignature(t,e){const i=t.attributes,n=e._attributeData,s=["g",t.uid];for(const t in i)n[t]&&s.push(t,n[t].location);return s.join("-")}getVao(t,e){return this._geometryVaoHash[t.uid]?.[e._key]||this.initGeometryVao(t,e)}initGeometryVao(t,e,i=!0){const n=this._renderer.gl,s=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const r=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[r];if(a)return o[e._key]=a,a;Ie(t,e._attributeData);const h=t.buffers;a=n.createVertexArray(),n.bindVertexArray(a);for(let t=0;t<h.length;t++){const e=h[t];s.bind(e)}return this.activateVao(t,e),o[e._key]=a,o[r]=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){const i=this._renderer.gl,n=this._renderer.buffer,s=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let r=null;for(const t in s){const o=s[t],a=o.buffer,h=n.getGlBuffer(a),l=e._attributeData[t];if(l){r!==h&&(n.bind(a),r=h);const t=l.location;i.enableVertexAttribArray(t);const e=k(o.format),s=Me(o.format);if("int"===l.format?.substring(1,4)?i.vertexAttribIPointer(t,e.size,s,o.stride,o.offset):i.vertexAttribPointer(t,e.size,s,e.normalised,o.stride,o.offset),o.instance){if(!this.hasInstance)throw new Error("geometry error, GPU Instancing is not supported on this device");{const e=o.divisor??1;i.vertexAttribDivisor(t,e)}}}}}draw(t,e,i,n){const{gl:s}=this._renderer,r=this._activeGeometry,o=mc[t||r.topology];if(n??(n=r.instanceCount),r.indexBuffer){const t=r.indexBuffer.data.BYTES_PER_ELEMENT,a=2===t?s.UNSIGNED_SHORT:s.UNSIGNED_INT;n>1?s.drawElementsInstanced(o,e||r.indexBuffer.data.length,a,(i||0)*t,n):s.drawElements(o,e||r.indexBuffer.data.length,a,(i||0)*t)}else n>1?s.drawArraysInstanced(o,i||0,e||r.getSize(),n):s.drawArrays(o,i||0,e||r.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}}yc.extension={type:[Ki.WebGLSystem],name:"geometry"};const xc=new da({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),bc=class t{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(e={}){const{useBackBuffer:i,antialias:n}={...t.defaultOptions,...e};this.useBackBuffer=i,this._antialias=n,this._renderer.context.supports.msaa||(a(),this._antialias=!1),this._state=co.for2d();const s=new Yr({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 ao({glProgram:s,resources:{uTexture:Fn.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:xc,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new Fn({source:new On({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)}};bc.extension={type:[Ki.WebGLSystem],name:"backBuffer",priority:1},bc.defaultOptions={useBackBuffer:!1};let _c=bc;class vc{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)))}}vc.extension={type:[Ki.WebGLSystem],name:"colorMask"};class wc{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:s,skipSync:r,topology:o,size:a,start:h,instanceCount:l}=t;e.shader.bind(n,r),e.geometry.bind(i,e.shader._activeProgram),s&&e.state.set(s),e.geometry.draw(o,a,h,l??i.instanceCount)}destroy(){this._renderer=null}}wc.extension={type:[Ki.WebGLSystem],name:"encoder"};class Cc{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=bt(this.maxTextures,t),this.maxUniformBindings=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS)}destroy(){}}Cc.extension={type:[Ki.WebGLSystem],name:"limits"};class Sc{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const Ac=[];Ac[$o.NONE]=void 0,Ac[$o.DISABLED]={stencilWriteMask:0,stencilReadMask:0},Ac[$o.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},Ac[$o.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},Ac[$o.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},Ac[$o.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class Ic{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:$o.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:$o.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=$o.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],n=this._gl,s=Ac[t],r=this._stencilCache;i.stencilMode=t,i.stencilReference=e,t!==$o.DISABLED?(this._stencilCache.enabled||(this._stencilCache.enabled=!0,n.enable(n.STENCIL_TEST)),t===r.stencilMode&&r.stencilReference===e||(r.stencilMode=t,r.stencilReference=e,n.stencilFunc(this._comparisonFuncMapping[s.stencilBack.compare],e,255),n.stencilOp(n.KEEP,n.KEEP,this._stencilOpsMapping[s.stencilBack.passOp]))):this._stencilCache.enabled&&(this._stencilCache.enabled=!1,n.disable(n.STENCIL_TEST))}}Ic.extension={type:[Ki.WebGLSystem],name:"stencil"};class Mc{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!F())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 ca({data:new Float32Array(e.layout.size/4),usage:la.UNIFORM|la.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]),s=this._adaptor.createUboElements(n),r=this._generateUboSync(s.uboElements);i=this._syncFunctionHash[e]={layout:s,syncFunction:r}}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 ca({data:new Float32Array(n.layout.size/4),usage:la.UNIFORM|la.COPY_DST}));let s=null;return e||(e=t.buffer.data,s=t.buffer.dataInt32),i||(i=0),n.syncFunction(t.uniforms,e,s,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 Tc={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},Pc=[{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 "}],Ec={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>":Ee(3,2),"mat4x2<f32>":Ee(4,2),"mat2x3<f32>":Ee(2,3),"mat4x3<f32>":Ee(4,3),"mat2x4<f32>":Ee(2,4),"mat3x4<f32>":Ee(3,4)},Bc={...Ec,"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 "};class Oc extends Mc{constructor(){super({createUboElements:Te,generateUboSync:Oe})}}Oc.extension={type:[Ki.WebGLSystem],name:"ubo"};class kc{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Sn}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Sn}copyToTexture(t,e,i,n,s){const r=this._renderTargetSystem,o=this._renderer,a=r.getGpuRenderTarget(t),h=o.gl;return this.finishRenderPass(t),h.bindFramebuffer(h.FRAMEBUFFER,a.resolveTargetFramebuffer),o.texture.bind(e,0),h.copyTexSubImage2D(h.TEXTURE_2D,0,s.x,s.y,i.x,i.y,n.width,n.height),e}startRenderPass(t,e=!0,i,n){const s=this._renderTargetSystem,r=t.colorTexture,o=s.getGpuRenderTarget(t);let a=n.y;t.isRoot&&(a=r.pixelHeight-n.height),t.colorTextures.forEach(t=>{this._renderer.texture.unbind(t)});const h=this._renderer.gl;h.bindFramebuffer(h.FRAMEBUFFER,o.framebuffer);const l=this._viewPortCache;l.x===n.x&&l.y===a&&l.width===n.width&&l.height===n.height||(l.x=n.x,l.y=a,l.width=n.width,l.height=n.height,h.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 Sc;return t.colorTexture instanceof Qs?(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?yo.ALL:yo.NONE);const s=this._renderer.gl;if(e&yo.COLOR){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],s.clearColor(e[0],e[1],e[2],e[3]))}s.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,s=n.createFramebuffer();if(e.resolveTargetFramebuffer=s,n.bindFramebuffer(n.FRAMEBUFFER,s),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((t,s)=>{const r=t.source;r.antialias&&(i.context.supports.msaa?e.msaa=!0:a()),i.texture.bindSource(r,0);const o=i.texture.getGlSource(r).texture;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+s,3553,o,0)}),e.msaa){const i=n.createFramebuffer();e.framebuffer=i,n.bindFramebuffer(n.FRAMEBUFFER,i),t.colorTextures.forEach((t,i)=>{const s=n.createRenderbuffer();e.msaaRenderBuffer[i]=s})}else e.framebuffer=s;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,s=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,s),t.colorTextures.forEach((t,s)=>{const r=t.source;i.texture.bindSource(r,0);const o=i.texture.getGlSource(r).internalFormat,a=e.msaaRenderBuffer[s];n.bindRenderbuffer(n.RENDERBUFFER,a),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,o,r.pixelWidth,r.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+s,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&&Qs.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&Qs.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,i=t.colorTexture;i.context2D.drawImage(e,0,i.pixelHeight-e.height)}}}const Rc=new Map,Dc=class t{constructor(i={}){if(this.uid=e("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,i={...t.defaultOptions,...i},this.stencil=i.stencil,this.depth=i.depth,this.isRoot=i.isRoot,"number"==typeof i.colorTextures){this._managedColorTextures=!0;for(let t=0;t<i.colorTextures;t++)this.colorTextures.push(new On({width:i.width,height:i.height,resolution:i.resolution,antialias:i.antialias}))}else{this.colorTextures=[...i.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),(i.depthStencilTexture||this.stencil)&&(i.depthStencilTexture instanceof Fn||i.depthStencilTexture instanceof On?this.depthStencilTexture=i.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 On({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((s,r)=>{n&&0===r||s.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)}};Dc.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Fc=Dc;class Lc{constructor(t){this.rootViewPort=new Sn,this.viewport=new Sn,this.onRenderTargetChange=new xo("onRenderTargetChange"),this.projectionMatrix=new un,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}){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),this.adaptor.prerender?.(this.rootRenderTarget)}postrender(){this.adaptor.postrender?.(this.rootRenderTarget)}bind(t,e=!0,i,n){const s=this.getRenderTarget(t),r=this.renderTarget!==s;this.renderTarget=s,this.renderSurface=t;const o=this.getGpuRenderTarget(s);s.pixelWidth===o.width&&s.pixelHeight===o.height||(this.adaptor.resizeGpuRenderTarget(s),o.width=s.pixelWidth,o.height=s.pixelHeight);const a=s.colorTexture,h=this.viewport,l=a.pixelWidth,c=a.pixelHeight;if(!n&&t instanceof Fn&&(n=t.frame),n){const t=a._resolution;h.x=n.x*t+.5|0,h.y=n.y*t+.5|0,h.width=n.width*t+.5|0,h.height=n.height*t+.5|0}else h.x=0,h.y=0,h.width=l,h.height=c;return function(t,e,i,n,s,r){const o=r?1:-1;t.identity(),t.a=1/n*2,t.d=o*(1/s*2),t.tx=-1-0*t.a,t.ty=-o-0*t.d}(this.projectionMatrix,0,0,h.width/a.resolution,h.height/a.resolution,!s.isRoot),this.adaptor.startRenderPass(s,e,i,h),r&&this.onRenderTargetChange.emit(s),s}clear(t,e=yo.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=yo.ALL,i,n){const s=this.bind(t,e,i,n);return this._renderTargetStack.push({renderTarget:s,frame:n}),s}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame)}getRenderTarget(t){return t.isTexture&&(t=t.source),this._renderSurfaceToRenderTargetHash.get(t)??this._initRenderTarget(t)}copyToTexture(t,e,i,n,s){i.x<0&&(n.width+=i.x,s.x-=i.x,i.x=0),i.y<0&&(n.height+=i.y,s.y-=i.y,i.y=0);const{pixelWidth:r,pixelHeight:o}=t;return n.width=Math.min(n.width,r-i.x),n.height=Math.min(n.height,o-i.y),this.adaptor.copyToTexture(t,e,i,n,s)}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 Qs.test(t)&&(t=ke(t).source),t instanceof Fc?e=t:t instanceof On&&(e=new Fc({colorTextures:[t]}),t.source instanceof Qs&&(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 jc extends Lc{constructor(t){super(t),this.adaptor=new kc,this.adaptor.init(t,this)}}jc.extension={type:[Ki.WebGLSystem],name:"renderTarget"};class Gc extends on{constructor({buffer:t,offset:i,size:n}){super(),this.uid=e("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=e("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=0|i,this.size=n,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=e("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}class Uc{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}}let Nc=null;const zc={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"},Hc={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"},Vc={textureCount:0,blockIndex:0};class Wc{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;Vc.textureCount=0,Vc.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,Vc)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,Vc)}bindUniformBlock(t,e,i=0){const n=this._renderer.buffer,s=this._getProgramData(this._activeProgram),r=t._bufferResource;r||this._renderer.ubo.updateUniformGroup(t);const o=t.buffer,a=n.updateBuffer(o),h=n.freeLocationForBufferBase(a);if(r){const{offset:e,size:i}=t;0===e&&i===o.data.byteLength?n.bindBufferBase(a,h):n.bindBufferRange(a,h,e)}else n.getLastBindBaseLocation(a)!==h&&n.bindBufferBase(a,h);const l=this._activeProgram._uniformBlockData[e].index;s.uniformBlockBindings[i]!==h&&(s.uniformBlockBindings[i]=h,this._renderer.gl.uniformBlockBinding(s.program,l,h))}_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]=function(t,e){const i=Re(t,t.VERTEX_SHADER,e.vertex),n=Re(t,t.FRAGMENT_SHADER,e.fragment),s=t.createProgram();t.attachShader(s,i),t.attachShader(s,n);const r=e.transformFeedbackVaryings;r&&("function"!=typeof t.transformFeedbackVaryings?a():t.transformFeedbackVaryings(s,r.names,"separate"===r.bufferMode?t.SEPARATE_ATTRIBS:t.INTERLEAVED_ATTRIBS)),t.linkProgram(s),t.getProgramParameter(s,t.LINK_STATUS)||function(t,e,i,n){t.getProgramParameter(e,t.LINK_STATUS)||(t.getShaderParameter(i,t.COMPILE_STATUS)||Ge(t,i),t.getShaderParameter(n,t.COMPILE_STATUS)||Ge(t,n),t.getProgramInfoLog(e))}(t,s,i,n),e._attributeData=function(t,e,i=!1){const n={},s=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i<s;i++){const s=e.getActiveAttrib(t,i);if(s.name.startsWith("gl_"))continue;const r=je(e,s.type);n[s.name]={location:0,format:r,stride:k(r).stride,offset:0,instance:!1,start:0}}const r=Object.keys(n);if(i){r.sort((t,e)=>t>e?1:-1);for(let i=0;i<r.length;i++)n[r[i]].location=i,e.bindAttribLocation(t,i,r[i]);e.linkProgram(t)}else for(let i=0;i<r.length;i++)n[r[i]].location=e.getAttribLocation(t,r[i]);return n}(s,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 s=0;s<n;s++){const n=e.getActiveUniform(t,s),r=n.name.replace(/\[.*?\]$/,""),o=!!n.name.match(/\[.*?\]$/),a=Le(e,n.type);i[r]={name:r,index:s,type:a,size:n.size,isArray:o,value:Fe(a,n.size)}}return i}(s,t),e._uniformBlockData=function(t,e){if(!e.ACTIVE_UNIFORM_BLOCKS)return{};const i={},n=e.getProgramParameter(t,e.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<n;s++){const n=e.getActiveUniformBlockName(t,s),r=e.getUniformBlockIndex(t,n),o=e.getActiveUniformBlockParameter(t,s,e.UNIFORM_BLOCK_DATA_SIZE);i[n]={name:n,index:r,size:o}}return i}(s,t),t.deleteShader(i),t.deleteShader(n);const o={};for(const i in e._uniformData){const n=e._uniformData[i];o[i]={location:t.getUniformLocation(s,i),value:Fe(n.type,n.size)}}return new Uc(s,o)}(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 s=!1,r=0;const o=e._getProgramData(t.glProgram);for(const a in t.groups){const h=t.groups[a];i.push(`\n resources = g[${a}].resources;\n `);for(const l in h.resources){const c=h.resources[l];if(c instanceof so)if(c.ubo){const e=t._uniformBindMap[a][Number(l)];i.push(`\n sS.bindUniformBlock(\n resources[${l}],\n '${e}',\n ${t.glProgram._uniformBlockData[e].index}\n );\n `)}else i.push(`\n ugS.updateUniformGroup(resources[${l}], p, sD);\n `);else if(c instanceof Gc){const e=t._uniformBindMap[a][Number(l)];i.push(`\n sS.bindUniformBlock(\n resources[${l}],\n '${e}',\n ${t.glProgram._uniformBlockData[e].index}\n );\n `)}else if(c instanceof On){const h=t._uniformBindMap[a][l],c=o.uniformData[h];c&&(s||(s=!0,n.push("\n var tS = r.texture;\n ")),e._gl.uniform1i(c.location,r),i.push(`\n tS.bind(resources[${l}], ${r});\n `),r++)}}}const a=[...n,...i].join("\n");return new Function("r","s","sD",a)}(t,e)}resetState(){this._activeProgram=null}}Wc.extension={type:[Ki.WebGLSystem],name:"shader"};const Zc={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);"},Jc={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 Xc{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);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){return this._uniformGroupSyncHash[t._signature]?.[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 so?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 Gc&&i.push(`\n renderer.shader.bindBufferResource(uv.${n}, "${n}");\n `);continue}const s=t.uniformStructures[n];let r=!1;for(let t=0;t<Pc.length;t++){const e=Pc[t];if(s.type===e.type&&e.test(s)){i.push(`name = "${n}";`,Pc[t].uniform),r=!0;break}}if(!r){const t=(1===s.size?Zc:Jc)[s.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,s=[`${i}-`];for(const t in n)s.push(t),e[t]&&s.push(e[t].type);return s.join("-")}destroy(){this._renderer=null,this._cache=null}}Xc.extension={type:[Ki.WebGLSystem],name:"uniformGroup"};const Yc=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=co.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 qs.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}};Yc.extension={type:[Ki.WebGLSystem],name:"state"};let Kc=Yc;class qc{constructor(t){this.target=pc.TEXTURE_2D,this.texture=t,this.width=-1,this.height=-1,this.type=fc.UNSIGNED_BYTE,this.internalFormat=uc.RGBA,this.format=uc.RGBA,this.samplerType=0}}const Qc={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}},$c={"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},td={id:"compressed",upload(t,e,i){i.pixelStorei(i.UNPACK_ALIGNMENT,4);let n=t.pixelWidth,s=t.pixelHeight;const r=!!$c[t.format];for(let o=0;o<t.resource.length;o++){const a=t.resource[o];r?i.compressedTexImage2D(i.TEXTURE_2D,o,e.internalFormat,n,s,0,a):i.texImage2D(i.TEXTURE_2D,o,e.internalFormat,n,s,0,e.format,e.type,a),n=Math.max(n>>1,1),s=Math.max(s>>1,1)}}},ed={id:"image",upload(t,e,i,n){const s=e.width,r=e.height,o=t.pixelWidth,a=t.pixelHeight,h=t.resourceWidth,l=t.resourceHeight;h<o||l<a?(s===o&&r===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,h,l,e.format,e.type,t.resource):i.texSubImage2D(i.TEXTURE_2D,0,0,0,e.format,e.type,t.resource)):s===o&&r===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}},id={id:"video",upload(t,e,i,n){t.isValid?ed.upload(t,e,i,n):i.texImage2D(e.target,0,e.internalFormat,1,1,0,e.format,e.type,null)}},nd={linear:9729,nearest:9728},sd={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},rd={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},od={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};class ad{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:ed,buffer:Qc,video:id,compressed:td},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 qs.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),{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 t=0;t<16;t++)this.bind(Fn.EMPTY,t)}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=Fn.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 t=0;t<i.length;t++)if(i[t]===e){this._activateLocation(t);const s=this.getGlSource(e);n.bindTexture(s.target,null),i[t]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,i=new qc(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,Ue(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,Ue(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),s=qs.get().createCanvas();s.width=i,s.height=n;const r=s.getContext("2d");if(r){const t=r.createImageData(i,n);t.data.set(e),r.putImageData(t,0,0)}return s}getPixels(t){const e=t.source.resolution,i=t.frame,n=Math.max(Math.round(i.width*e),1),s=Math.max(Math.round(i.height*e),1),r=new Uint8Array(4*n*s),o=this._renderer,a=o.renderTarget.getRenderTarget(t),h=o.renderTarget.getGpuRenderTarget(a),l=o.gl;return l.bindFramebuffer(l.FRAMEBUFFER,h.resolveTargetFramebuffer),l.readPixels(Math.round(i.x*e),Math.round(i.y*e),n,s,l.RGBA,l.UNSIGNED_BYTE,r),{pixels:new Uint8ClampedArray(r.buffer),width:n,height:s}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(Fn.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}ad.extension={type:[Ki.WebGLSystem],name:"texture"};class hd{contextChange(t){const e=new so({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new un,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),i=t.limits.maxBatchableTextures,n=kt({name:"graphics",bits:[wa,jt(i),$l,Ia]});this.shader=new ao({glProgram:n,resources:{localUniforms:e,batchSamplers:Gt(i)}})}execute(t,e){const i=e.context,n=i.customShader||this.shader,s=t.renderer,r=s.graphicsContext,{batcher:o,instructions:a}=r.getContextRenderData(i);n.groups[0]=s.globalUniforms.bindGroup,s.state.set(t.state),s.shader.bind(n),s.geometry.bind(o.geometry,n.glProgram);const h=a.instructions;for(let t=0;t<a.instructionSize;t++){const e=h[t];if(e.size){for(let t=0;t<e.textures.count;t++)s.texture.bind(e.textures.textures[t],t);s.geometry.draw(e.topology,e.size,e.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}hd.extension={type:[Ki.WebGLPipesAdaptor],name:"graphics"};class ld{init(){const t=kt({name:"mesh",bits:[$l,ec,Ia]});this._shader=new ao({glProgram:t,resources:{uTexture:Fn.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new un}}}})}execute(t,e){const i=t.renderer;let n=e._shader;if(n){if(!n.glProgram)return void a(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}}ld.extension={type:[Ki.WebGLPipesAdaptor],name:"mesh"};class cd{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}}cd.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"customRender"};class dd{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(){}}const ud=new un;class pd{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&&(ms.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){const i=t._batchableRenderGroup??(t._batchableRenderGroup=ms.get(dd));i.renderable=t.root,i.transform=t.root.relativeGroupTransform,i.texture=t.texture,i.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.batch.addToBatch(i,e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;const e=ud.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}),Ne(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}),Ne(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}pd.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"renderGroup"};const fd=new Hs,gd=new un;class md{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 s=this._renderer;let r=gd;e&&(r=r.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const o=s.renderPipes;this._updateCachedRenderGroups(t.renderGroup,null),this._updateRenderGroups(t.renderGroup),s.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),Ne(t.renderGroup,o),o.uniformBatch&&o.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(r),t.parent=i,t.renderGroup.renderGroupParent=n}destroy(){this._renderer=null}_updateCachedRenderGroups(t,e){if(t.isCachedAsTexture){if(!t.updateCacheTexture)return;e=t}t._parentCacheAsTextureRenderGroup=e;for(let i=t.renderGroupChildren.length-1;i>=0;i--)this._updateCachedRenderGroups(t.renderGroupChildren[i],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const e=t.root.getLocalBounds();e.ceil();const i=t.texture;t.texture&&Ls.returnTexture(t.texture,!0);const n=this._renderer,s=t.textureOptions.resolution||n.view.resolution,r=t.textureOptions.antialias??n.view.antialias,o=t.textureOptions.scaleMode??"linear",a=Ls.getOptimalTexture(e.width,e.height,s,r);a._source.style=new En({scaleMode:o}),t.texture=a,t._textureBounds||(t._textureBounds=new jn),t._textureBounds.copyFrom(e),i!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(Ls.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?ze(t.childrenRenderablesToUpdate.list,0):function(t,e){const{list:i,index:n}=t.childrenRenderablesToUpdate;let s=!1;for(let t=0;t<n;t++){const n=i[t];if(s=e[n.renderPipeId].validateRenderable(n),s)break}t.structureDidChange=s}(t,i),He(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 e=0;e<t.renderGroupChildren.length;e++)this._updateRenderGroups(t.renderGroupChildren[e])}_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)}ze(e,i)}_buildInstructions(t,e){const i=t.root,n=t.instructionSet;n.reset();const s=e.renderPipes?e:e.batch.renderer,r=s.renderPipes;r.batch.buildStart(n),r.blendMode.buildStart(),r.colorMask.buildStart(),i.sortableChildren&&i.sortChildren(),i.collectRenderablesWithEffects(n,s,null),r.batch.buildEnd(n),r.blendMode.buildEnd(n)}}md.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"renderGroup"};class yd{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 dd;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}}yd.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"sprite"};const xd=class t{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new ps(0),this.color=this._backgroundColor,this.alpha=1}init(e){e={...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){ps.shared.setValue(t).alpha<1&&1===this._backgroundColor.alpha&&a(),this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};xd.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"background",priority:0},xd.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let bd=xd;const _d={};$i.handle(Ki.BlendMode,t=>{if(!t.name)throw new Error("BlendMode extension must have a name property");_d[t.name]=t.ref},t=>{delete _d[t.name]});class vd{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=!!_d[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(!_d[e])return void a();let i=this._filterHash[e];i||(i=this._filterHash[e]=new _s,i.filters=[new _d[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}}vd.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"blendMode"};const wd={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Cd=class t{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof Hs||t instanceof Fn?{target:t,...e}:{...e,...t}}async image(t){const e=qs.get().createImage();return e.src=await this.base64(t),e}async base64(e){e=this._normalizeOptions(e,t.defaultImageOptions);const{format:i,quality:n}=e,s=this.canvas(e);if(void 0!==s.toBlob)return new Promise((t,e)=>{s.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)},wd[i],n)});if(void 0!==s.toDataURL)return s.toDataURL(wd[i],n);if(void 0!==s.convertToBlob){const t=await s.convertToBlob({type:wd[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 Fn)return i.texture.generateCanvas(e);const n=i.textureGenerator.generateTexture(t),s=i.texture.generateCanvas(n);return n.destroy(!0),s}pixels(t){const e=(t=this._normalizeOptions(t)).target,i=this._renderer,n=e instanceof Fn?e:i.textureGenerator.generateTexture(t),s=i.texture.getPixels(n);return e instanceof Hs&&n.destroy(!0),s}texture(t){return(t=this._normalizeOptions(t)).target instanceof Fn?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){t=this._normalizeOptions(t);const e=this.canvas(t),i=document.createElement("a");i.download=t.filename??"image.png",i.href=e.toDataURL("image/png"),document.body.appendChild(i),i.click(),document.body.removeChild(i)}log(t){const e=t.width??200;t=this._normalizeOptions(t),["font-size: 1px;",`padding: ${e}px 300px;`,`background: url(${this.canvas(t).toDataURL()}) no-repeat;`,"background-size: contain;"].join(" ")}destroy(){this._renderer=null}};Cd.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem],name:"extract"},Cd.defaultImageOptions={format:"png",quality:1};let Sd=Cd;class Ad extends Fn{static create(t){return new Ad({source:new On(t)})}resize(t,e,i){return this.source.resize(t,e,i),this}}const Id=new Sn,Md=new jn,Td=[0,0,0,0];class Pd{constructor(t){this._renderer=t}generateTexture(t){t instanceof Hs&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const e=t.resolution||this._renderer.resolution,i=t.antialias||this._renderer.view.antialias,n=t.target;let s=t.clearColor;s=s?Array.isArray(s)&&4===s.length?s:ps.shared.setValue(s).toArray():Td;const r=t.frame?.copyTo(Id)||g(n,Md).rectangle;r.width=0|Math.max(r.width,1/e),r.height=0|Math.max(r.height,1/e);const o=Ad.create({...t.textureSourceOptions,width:r.width,height:r.height,resolution:e,antialias:i}),a=un.shared.translate(-r.x,-r.y);return this._renderer.render({container:n,transform:a,target:o,clearColor:s}),o.source.updateMipmaps(),o}destroy(){this._renderer=null}}Pd.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem],name:"textureGenerator"};class Ed{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:s}){const r=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{worldTransformMatrix:new un,worldColor:4294967295,offset:new cn},a={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||r.size,worldTransformMatrix:i||o.worldTransformMatrix,worldColor:n||o.worldColor,offset:s||o.offset,bindGroup:null},h=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(h);const l=h.uniforms;let c;l.uProjectionMatrix=a.projectionMatrix,l.uResolution=a.resolution,l.uWorldTransformMatrix.copyFrom(a.worldTransformMatrix),l.uWorldTransformMatrix.tx-=a.offset.x,l.uWorldTransformMatrix.ty-=a.offset.y,Ze(a.worldColor,l.uWorldColorAlpha,0),h.update(),this._renderer.renderPipes.uniformBatch?c=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(h,!1):(c=this._bindGroupPool.pop()||new ro,this._activeBindGroups.push(c),c.setResource(h,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===oo.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 so({uProjectionMatrix:{value:new un,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new un,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null}}Ed.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"globalUniforms"};let Bd=1;class Od{constructor(){this._tasks=[],this._offset=0}init(){sr.system.add(this._update,this)}repeat(t,e,i=!0){const n=Bd++;let s=0;return i&&(this._offset+=1e3,s=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:s,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(){sr.system.remove(this._update,this),this._tasks.length=0}}Od.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"scheduler",priority:0};let kd=!1;class Rd{constructor(t){this._renderer=t}init(t){if(t.hello){let t=this._renderer.name;this._renderer.type===oo.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),function(t){if(!kd){if(qs.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${Ao} (${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 ${Ao} - ${t} - http://www.pixijs.com/`);kd=!0}}(t)}}}Rd.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"hello",priority:-2},Rd.defaultOptions={hello:!1};let Dd=0;const Fd=class t{constructor(t){this._managedRenderables=[],this._managedHashes=[],this._managedArrays=[],this._renderer=t}init(e){e={...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]=Je(t.context[t.hash])},this._frequency),this._arrayHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedArrays)Xe(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=Dd++,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(){const t=this._now,e=this._managedRenderables,i=this._renderer.renderPipes;let n=0;for(let s=0;s<e.length;s++){const r=e[s];if(null===r){n++;continue}const o=r.renderGroup??r.parentRenderGroup,a=o?.instructionSet?.gcTick??-1;if((o?.gcTick??0)===a&&(r._lastUsed=t),t-r._lastUsed>this.maxUnusedTime){if(!r.destroyed){const t=i;o&&(o.structureDidChange=!0),t[r.renderPipeId].destroyRenderable(r)}r._lastUsed=-1,n++,r.off("destroyed",this._removeRenderable,this)}else e[s-n]=r}e.length-=n}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)}};Fd.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem],name:"renderableGC",priority:0},Fd.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let Ld=Fd;const jd=class t{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(e){e={...t.defaultOptions,...e},this.checkCountMax=e.textureGCCheckCountMax,this.maxIdle=e.textureGCAMaxIdle??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}};jd.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem],name:"textureGC"},jd.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Gd=jd;const Ud=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={...t.defaultOptions,...e}).view&&(i(0,"ViewSystem.view has been renamed to ViewSystem.canvas"),e.canvas=e.view),this.screen=new Sn(0,0,e.width,e.height),this.canvas=e.canvas||qs.get().createCanvas(),this.antialias=!!e.antialias,this.texture=ke(this.canvas,e),this.renderTarget=new Fc({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:t?.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}};Ud.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"view",priority:0},Ud.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};const Nd=[bd,Ed,Rd,Ud,md,Gd,Pd,Sd,Mo,Ld,Od],zd=[vd,Kl,yd,pd,sc,oc,rc,cd],Hd=[...Nd,Oc,_c,dc,Cc,lc,ad,jc,yc,Xc,Wc,wc,Kc,Ic,vc],Vd=[...zd],Wd=[Zl,ld,hd],Zd=[],Jd=[],Xd=[];$i.handleByNamedList(Ki.WebGLSystem,Zd),$i.handleByNamedList(Ki.WebGLPipes,Jd),$i.handleByNamedList(Ki.WebGLPipesAdaptor,Xd),$i.add(...Hd,...Vd,...Wd);const Yd=Object.freeze(Object.defineProperty({__proto__:null,WebGLRenderer:class extends Co{constructor(){super({name:"webgl",type:oo.WEBGL,systems:Zd,renderPipes:Jd,renderPipeAdaptors:Xd})}}},Symbol.toStringTag,{value:"Module"}));class Kd{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){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,i)}_createBindGroup(t,e,i){const n=this._gpu.device,s=e.layout[i],r=[],o=this._renderer;for(const e in s){const i=t.resources[e]??t.resources[s[e]];let n;if("uniformGroup"===i._resourceType){const t=i;o.ubo.updateUniformGroup(t);const e=t.buffer;n={buffer:o.buffer.getGPUBuffer(e),offset:0,size:e.descriptor.size}}else if("buffer"===i._resourceType){const t=i;n={buffer:o.buffer.getGPUBuffer(t),offset:0,size:t.descriptor.size}}else if("bufferResource"===i._resourceType){const t=i;n={buffer:o.buffer.getGPUBuffer(t.buffer),offset:t.offset,size:t.size}}else if("textureSampler"===i._resourceType){const t=i;n=o.texture.getGpuSampler(t)}else if("textureSource"===i._resourceType){const t=i;n=o.texture.getGpuSource(t).createView({})}r.push({binding:s[e],resource:n})}const a=o.shader.getProgramData(e).bindGroups[i],h=n.createBindGroup({layout:a,entries:r});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}}Kd.extension={type:[Ki.WebGPUSystem],name:"bindGroup"};class qd{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&&(mt(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}}qd.extension={type:[Ki.WebGPUSystem],name:"buffer"};class Qd{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 $d{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}}$d.extension={type:[Ki.WebGPUSystem],name:"colorMask"};class tu{constructor(t){this._renderer=t}async init(t){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}async _createDeviceAndAdaptor(t){const e=await qs.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=await e.requestDevice({requiredFeatures:i});return{adapter:e,device:n}}destroy(){this.gpu=null,this._renderer=null}}tu.extension={type:[Ki.WebGPUSystem],name:"device"},tu.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class eu{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 s=this._renderer.pipeline.getPipeline(t,e,i,n);this.setPipeline(s)}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 e in i)this._setVertexBuffer(e,t.attributes[i[e]].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:s,size:r,start:o,instanceCount:a,skipSync:h}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,n,s),this.setGeometry(e,i.gpuProgram),this._setShaderBindGroups(i,h),e.indexBuffer?this.renderPassEncoder.drawIndexed(r||e.indexBuffer.data.length,a??e.instanceCount,o||0):this.renderPassEncoder.draw(r||e.getSize(),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={...this._boundVertexBuffer},n=this._boundIndexBuffer,s={...this._boundBindGroup};this._clearCache();const r=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(r.x,r.y,r.width,r.height,0,1),this.setPipeline(e);for(const t in i)this._setVertexBuffer(t,i[t]);for(const t in s)this.setBindGroup(t,s[t],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}}eu.extension={type:[Ki.WebGPUSystem],name:"encoder",priority:1};class iu{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}iu.extension={type:[Ki.WebGPUSystem],name:"limits"};class nu{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:$o.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}}nu.extension={type:[Ki.WebGPUSystem],name:"stencil"};const su={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}};class ru extends Mc{constructor(){super({createUboElements:Ye,generateUboSync:qe})}}ru.extension={type:[Ki.WebGPUSystem],name:"ubo"};const ou=128;class au{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 Qd({minUniformOffsetAlignment:ou});for(let t=0;t<2;t++){let e=la.UNIFORM|la.COPY_DST;0===t&&(e|=la.COPY_SRC),this._buffers.push(new ca({data:this._batchBuffer.data,usage:e}))}}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/ou),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/ou)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/ou)}getArrayBufferResource(t){const e=this._batchBuffer.addGroup(t)/ou;return this._getBufferResource(e)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new Gc({buffer:e,offset:256*(t/2|0),size:ou})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new ro({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 s=this._buffers[n];i.copyBufferToBuffer(t.getGPUBuffer(e),ou,t.getGPUBuffer(s),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}}au.extension={type:[Ki.WebGPUPipes],name:"uniformBatch"};const hu={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};class lu{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($o.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=Ac[t],this._updatePipeHash())}setPipeline(t,e,i,n){const s=this.getPipeline(t,e,i);n.setPipeline(s)}getPipeline(t,e,i,n){t._layoutKey||(Ie(t,e.attributeData),this._generateBufferKey(t)),n||(n=t.topology);const s=function(t,e,i,n,s){return t<<24|e<<16|i<<10|n<<5|s}(t._layoutKey,e._layoutKey,i.data,i._blendModeId,hu[n]);return this._pipeCache[s]||(this._pipeCache[s]=this._createPipeline(t,e,i,n)),this._pipeCache[s]}_createPipeline(t,e,i,n){const s=this._gpu.device,r=this._createVertexBufferLayouts(t,e),o=this._renderer.state.getColorTargets(i);o[0].writeMask=this._stencilMode===$o.RENDERING_MASK_ADD?0:this._colorMask;const a=this._renderer.shader.getProgramData(e).pipeline,h={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:r},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"};return this._depthStencilAttachment&&(h.depthStencil={...this._stencilState,format:"depth24plus-stencil8",depthWriteEnabled:i.depthTest,depthCompare:i.depthTest?"less":"always"}),s.createRenderPipeline(h)}_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 s=e.join("|");return t._layoutKey=E(s,"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 s=e.join("|");return t._attributeLocationsKey=E(s,"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),s=Object.create(null),r=e.attributeData;for(let t=0;t<n.length;t++){const e=Object.values(n[t].attributes)[0].shaderLocation;for(const i in r)if(r[i].location===e){s[t]=i;break}}return this._bindingNamesCache[i]=s,s}_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=>{const s={arrayStride:0,stepMode:"vertex",attributes:[]},r=s.attributes;for(const n in e.attributeData){const o=t.attributes[n];1!==(o.divisor??1)&&a(o.divisor),o.buffer===i&&(s.arrayStride=o.stride,s.stepMode=o.instance?"instance":"vertex",r.push({shaderLocation:e.attributeData[n].location,offset:o.offset,format:o.format}))}r.length&&n.push(s)}),this._bufferLayoutsCache[i]=n,n}_updatePipeHash(){const t=(e=this._stencilMode,i=this._multisampleCount,this._colorMask<<6|e<<3|this._depthStencilAttachment<<1|i);var e,i;this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}lu.extension={type:[Ki.WebGPUSystem],name:"pipeline"};class cu{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class du{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,n,s){const r=this._renderer,o=this._getGpuColorTexture(t),a=r.texture.getGpuSource(e.source);return r.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:i},{texture:a,origin:s},n),e}startRenderPass(t,e=!0,i,n){const s=this._renderTargetSystem.getGpuRenderTarget(t),r=this.getDescriptor(t,e,i);s.descriptor=r,this._renderer.pipeline.setRenderTarget(s),this._renderer.encoder.beginRenderPass(s),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?yo.ALL:yo.NONE);const n=this._renderTargetSystem,s=n.getGpuRenderTarget(t),r=t.colorTextures.map((t,r)=>{const o=s.contexts[r];let a,h;a=o?o.getCurrentTexture().createView():this._renderer.texture.getGpuSource(t).createView({mipLevelCount:1}),s.msaaTextures[r]&&(h=a,a=this._renderer.texture.getTextureView(s.msaaTextures[r]));const l=e&yo.COLOR?"clear":"load";return i??(i=n.defaultClearColor),{view:a,resolveTarget:h,clearValue:i,storeOp:"store",loadOp:l}});let o;if(!t.stencil&&!t.depth||t.depthStencilTexture||(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=s.msaa?4:1),t.depthStencilTexture){const i=e&yo.STENCIL?"clear":"load",n=e&yo.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:r,depthStencilAttachment:o}}clear(t,e=!0,i,n){if(!e)return;const{gpu:s,encoder:r}=this._renderer,o=s.device;if(null===r.commandEncoder){const s=o.createCommandEncoder(),r=this.getDescriptor(t,e,i),a=s.beginRenderPass(r);a.setViewport(n.x,n.y,n.width,n.height,0,1),a.end();const h=s.finish();o.queue.submit([h])}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 Qs){const n=t.resource.getContext("webgpu"),s=t.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:s})}catch(t){}e.contexts[i]=n}if(e.msaa=t.source.antialias,t.source.antialias){const t=new On({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];n?.resize(t.source.width,t.source.height,t.source._resolution)})}}class uu extends Lc{constructor(t){super(t),this.adaptor=new du,this.adaptor.init(t,this)}}uu.extension={type:[Ki.WebGPUSystem],name:"renderTarget"};class pu{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}}pu.extension={type:[Ki.WebGPUSystem],name:"shader"};const fu={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 gu{constructor(){this.defaultState=new co,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:fu[t.blendMode]||fu.normal}]}destroy(){this.gpu=null}}gu.extension={type:[Ki.WebGPUSystem],name:"state"};const mu={type:"image",upload(t,e,i){const n=t.resource,s=(0|t.pixelWidth)*(0|t.pixelHeight),r=n.byteLength/s;i.device.queue.writeTexture({texture:e},n,{offset:0,rowsPerImage:t.pixelHeight,bytesPerRow:t.pixelHeight*r},{width:t.pixelWidth,height:t.pixelHeight,depthOrArrayLayers:1})}},yu={"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}},xu={blockBytes:4,blockWidth:1,blockHeight:1},bu={type:"compressed",upload(t,e,i){let n=t.pixelWidth,s=t.pixelHeight;const r=yu[t.format]||xu;for(let o=0;o<t.resource.length;o++){const a=t.resource[o],h=Math.ceil(n/r.blockWidth)*r.blockBytes;i.device.queue.writeTexture({texture:e,mipLevel:o},a,{offset:0,bytesPerRow:h},{width:Math.ceil(n/r.blockWidth)*r.blockWidth,height:Math.ceil(s/r.blockHeight)*r.blockHeight,depthOrArrayLayers:1}),n=Math.max(n>>1,1),s=Math.max(s>>1,1)}}},_u={type:"image",upload(t,e,i){const n=t.resource;if(!n)return;if(globalThis.HTMLImageElement&&n instanceof HTMLImageElement){const e=qs.get().createCanvas(n.width,n.height);e.getContext("2d").drawImage(n,0,0,n.width,n.height),t.resource=e,a()}const s=Math.min(e.width,t.resourceWidth||t.pixelWidth),r=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:s,height:r})}},vu={type:"video",upload(t,e,i){_u.upload(t,e,i)}};class wu{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,s=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!s){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 r=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}),h=s?1:0;for(let s=1;s<t.mipLevelCount;++s){const t=i.createView({baseMipLevel:h++,mipLevelCount:1,dimension:"2d",baseArrayLayer:a,arrayLayerCount:1}),s=r.beginRenderPass({colorAttachments:[{view:t,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),l=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.sampler},{binding:1,resource:n}]});s.setPipeline(e),s.setBindGroup(0,l),s.draw(3,1,0,0),s.end(),n=t}}if(!s){const e={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:n};for(let n=1;n<t.mipLevelCount;++n)r.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([r.finish()]),s||i.destroy(),t}}class Cu{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:_u,buffer:mu,video:vu,compressed:bu},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=yu[t.format]||{blockWidth:1,blockHeight:1},n=Math.ceil(t.pixelWidth/i.blockWidth)*i.blockWidth,s=Math.ceil(t.pixelHeight/i.blockHeight)*i.blockHeight,r={label:t.label,size:{width:n,height:s},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},o=this._gpuSources[t.uid]=this._gpu.device.createTexture(r);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 wu(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){return this._bindGroupHash[t.uid]??this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source;return this._bindGroupHash[t.uid]=new ro({0:e,1:e.style,2:new so({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){const e=t.source;return this._textureViewHash[e.uid]??this._createTextureView(e)}_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=qs.get().createCanvas();n.width=t.source.pixelWidth,n.height=t.source.pixelHeight;const s=n.getContext("webgpu");return s.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:qs.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:s.getCurrentTexture()},{width:n.width,height:n.height}),e.gpu.device.queue.submit([i.finish()]),n}getPixels(t){const e=this.generateCanvas(t),i=ph.getOptimalCanvasAndContext(e.width,e.height),n=i.context;n.drawImage(e,0,0);const{width:s,height:r}=e,o=n.getImageData(0,0,s,r),a=new Uint8ClampedArray(o.data.buffer);return ph.returnCanvasAndContext(i),{pixels:a,width:s,height:r}}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];i?.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}Cu.extension={type:[Ki.WebGPUSystem],name:"texture"};class Su{constructor(){this._maxTextures=0}contextChange(t){const e=new so({uTransformMatrix:{value:new un,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=Ot({name:"graphics",bits:[va,Ft(this._maxTextures),Ql,Aa]});this.shader=new ao({gpuProgram:i,resources:{localUniforms:e}})}execute(t,e){const i=e.context,n=i.customShader||this.shader,s=t.renderer,r=s.graphicsContext,{batcher:o,instructions:a}=r.getContextRenderData(i),h=s.encoder;h.setGeometry(o.geometry,n.gpuProgram);const l=s.globalUniforms.bindGroup;h.setBindGroup(0,l,n.gpuProgram);const c=s.renderPipes.uniformBatch.getUniformBindGroup(n.resources.localUniforms,!0);h.setBindGroup(2,c,n.gpuProgram);const d=a.instructions;let u=null;for(let e=0;e<a.instructionSize;e++){const i=d[e];if(i.topology!==u&&(u=i.topology,h.setPipelineFromGeometryProgramAndState(o.geometry,n.gpuProgram,t.state,i.topology)),n.groups[1]=i.bindGroup,!i.gpuBindGroup){const t=i.textures;i.bindGroup=gt(t.textures,t.count,this._maxTextures),i.gpuBindGroup=s.bindGroup.getBindGroup(i.bindGroup,n.gpuProgram,1)}h.setBindGroup(1,i.bindGroup,n.gpuProgram),h.renderPassEncoder.drawIndexed(i.size,1,i.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}Su.extension={type:[Ki.WebGPUPipesAdaptor],name:"graphics"};class Au{init(){const t=Ot({name:"mesh",bits:[ql,tc,Aa]});this._shader=new ao({gpuProgram:t,resources:{uTexture:Fn.EMPTY._source,uSampler:Fn.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new un}}}})}execute(t,e){const i=t.renderer;let n=e._shader;if(n){if(!n.gpuProgram)return void a(e.shader)}else n=this._shader,n.groups[2]=i.texture.getTextureBindGroup(e.texture);const s=n.gpuProgram;if(s.autoAssignGlobalUniforms&&(n.groups[0]=i.globalUniforms.bindGroup),s.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}}Au.extension={type:[Ki.WebGPUPipesAdaptor],name:"mesh"};const Iu=[...Nd,ru,eu,tu,iu,qd,Cu,uu,pu,gu,lu,$d,nu,Kd],Mu=[...zd,au],Tu=[Xl,Au,Su],Pu=[],Eu=[],Bu=[];$i.handleByNamedList(Ki.WebGPUSystem,Pu),$i.handleByNamedList(Ki.WebGPUPipes,Eu),$i.handleByNamedList(Ki.WebGPUPipesAdaptor,Bu),$i.add(...Iu,...Mu,...Tu);const Ou=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:class extends Co{constructor(){super({name:"webgpu",type:oo.WEBGPU,systems:Pu,renderPipes:Eu,renderPipeAdaptors:Bu})}}},Symbol.toStringTag,{value:"Module"}));class ku{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{ms.return(t)}),this.batches.length=0}}class Ru{constructor(t,e){this.state=co.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 t=0;t<e.length;t++){const i=e[t];i._batcher.updateElement(i)}}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 s=n.resources.localUniforms.uniforms;s.uTransformMatrix=t.groupTransform,s.uRound=e._roundPixels|t._roundPixels,Ze(t.groupColorAlpha,s.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 t=0;t<n.length;t++){const s=n[t];i.addToBatch(s,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new ku;return t._gpuData[this.renderer.uid]=e,e}_updateBatchesForRenderable(t,e){const i=t.context,n=this.renderer.graphicsContext.getGpuContext(i),s=this.renderer._roundPixels|t._roundPixels;e.batches=n.batches.map(e=>{const i=ms.get(ka);return e.copyTo(i),i.renderable=t,i.roundPixels=s,i})}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}Ru.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"graphics"};const Du=class t extends El{constructor(...t){super({});let e=t[0]??{};"number"==typeof e&&(i(0,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),e={width:e,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(e)}build(e){e={...t.defaultOptions,...e},this.verticesX=this.verticesX??e.verticesX,this.verticesY=this.verticesY??e.verticesY,this.width=this.width??e.width,this.height=this.height??e.height;const i=this.verticesX*this.verticesY,n=[],s=[],r=[],o=this.verticesX-1,a=this.verticesY-1,h=this.width/o,l=this.height/a;for(let t=0;t<i;t++){const e=t%this.verticesX,i=t/this.verticesX|0;n.push(e*h,i*l),s.push(e/o,i/a)}const c=o*a;for(let t=0;t<c;t++){const e=t%o,i=t/o|0,n=i*this.verticesX+e,s=i*this.verticesX+e+1,a=(i+1)*this.verticesX+e,h=(i+1)*this.verticesX+e+1;r.push(n,s,a,s,h,a)}this.buffers[0].data=new Float32Array(n),this.buffers[1].data=new Float32Array(s),this.indexBuffer.data=new Uint32Array(r),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};Du.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let Fu=Du;class Lu{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 ju{destroy(){}}class Gu{constructor(t,e){this.localUniforms=new so({uTransformMatrix:{value:new un,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new ro({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){const i=this.renderer.renderPipes.batch,n=this._getMeshData(t);if(t.didViewUpdate&&(n.indexSize=t._geometry.indices?.length,n.vertexSize=t._geometry.positions?.length),n.batched){const n=this._getBatchableMesh(t);n.setTexture(t._texture),n.geometry=t._geometry,i.addToBatch(n,e)}else i.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=yt(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),Ze(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 ju),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 ju),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new Lu;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}}Gu.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"mesh"};class Uu{execute(t,e){const i=t.state,n=t.renderer,s=e.shader||t.defaultShader;s.resources.uTexture=e.texture._source,s.resources.uniforms=t.localUniforms;const r=n.gl,o=t.getBuffers(e);n.shader.bind(s),n.state.set(i),n.geometry.bind(o.geometry,s.glProgram);const a=2===o.geometry.indexBuffer.data.BYTES_PER_ELEMENT?r.UNSIGNED_SHORT:r.UNSIGNED_INT;r.drawElements(r.TRIANGLES,6*e.particleChildren.length,a,0)}}class Nu{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 s=t.state,r=t.getBuffers(e);i.encoder.draw({geometry:r.geometry,shader:e.shader||t.defaultShader,state:s,size:6*e.particleChildren.length})}}class zu{constructor(t){this._size=0,this._generateParticleUpdateCache={};const e=this._size=t.size??1e3,i=t.properties;let n=0,s=0;for(const t in i){const e=i[t],r=k(e.format);e.dynamic?s+=r.stride:n+=r.stride}this._dynamicStride=s/4,this._staticStride=n/4,this.staticAttributeBuffer=new qo(4*e*n),this.dynamicAttributeBuffer=new qo(4*e*s),this.indexBuffer=Qe(e);const r=new da;let o=0,a=0;this._staticBuffer=new ca({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:la.VERTEX|la.COPY_DST}),this._dynamicBuffer=new ca({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:la.VERTEX|la.COPY_DST});for(const t in i){const e=i[t],n=k(e.format);e.dynamic?(r.addAttribute(e.attributeName,{buffer:this._dynamicBuffer,stride:4*this._dynamicStride,offset:4*o,format:e.format}),o+=n.size):(r.addAttribute(e.attributeName,{buffer:this._staticBuffer,stride:4*this._staticStride,offset:4*a,format:e.format}),a+=n.size)}r.addIndex(this.indexBuffer);const h=this.getParticleUpdate(i);this._dynamicUpload=h.dynamicUpdate,this._staticUpload=h.staticUpdate,this.geometry=r}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:$e(t,!0),staticUpdate:$e(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 qo(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new qo(this._size*this._dynamicStride*4*4),this.indexBuffer=Qe(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 Hu="\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 Vu extends ao{constructor(){super({glProgram:Yr.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:to.from({fragment:{source:Hu,entryPoint:"mainFragment"},vertex:{source:Hu,entryPoint:"mainVertex"}}),resources:{uTexture:Fn.WHITE.source,uSampler:new En({}),uniforms:{uTranslationMatrix:{value:new un,type:"mat3x3<f32>"},uColor:{value:new ps(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}}class Wu{constructor(t,e){this.state=co.for2d(),this.localUniforms=new so({uTranslationMatrix:{value:new un,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 Vu,this.state=co.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 zu({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 s=this.state;n.update(e,t._childrenDirty),t._childrenDirty=!1,s.blendMode=yt(t.blendMode,t.texture._source);const r=this.localUniforms.uniforms,o=r.uTranslationMatrix;t.worldTransform.copyTo(o),o.prepend(i.globalUniforms.globalUniformData.projectionMatrix),r.uResolution=i.globalUniforms.globalUniformData.resolution,r.uRound=i._roundPixels|t._roundPixels,Ze(t.groupColorAlpha,r.uColor,0),this.adaptor.execute(this,t)}destroy(){this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}class Zu extends Wu{constructor(t){super(t,new Uu)}}Zu.extension={type:[Ki.WebGLPipes],name:"particle"};class Ju extends Wu{constructor(t){super(t,new Nu)}}Ju.extension={type:[Ki.WebGPUPipes],name:"particle"};const Xu=class t extends Fu{constructor(e={}){super({width:(e={...t.defaultOptions,...e}).width,height:e.height,verticesX:4,verticesY:4}),this.update(e)}update(t){this.width=t.width??this.width,this.height=t.height??this.height,this._originalWidth=t.originalWidth??this._originalWidth,this._originalHeight=t.originalHeight??this._originalHeight,this._leftWidth=t.leftWidth??this._leftWidth,this._rightWidth=t.rightWidth??this._rightWidth,this._topHeight=t.topHeight??this._topHeight,this._bottomHeight=t.bottomHeight??this._bottomHeight,this._anchorX=t.anchor?.x,this._anchorY=t.anchor?.y,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:i,_leftWidth:n,_rightWidth:s,_topHeight:r,_bottomHeight:o,_anchorX:a,_anchorY:h}=this,l=n+s,c=e>l?1:e/l,d=r+o,u=i>d?1:i/d,p=Math.min(c,u),f=a*e,g=h*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-s*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]=r*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()}};Xu.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let Yu=Xu;class Ku extends Lu{constructor(){super(),this.geometry=new Yu}destroy(){this.geometry.destroy()}}class qu{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 Ku,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}}qu.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"nineSliceSprite"};const Qu={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 "}},$u={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 tp,ep;class ip extends ao{constructor(){tp??(tp=Ot({name:"tiling-sprite-shader",bits:[ql,Qu,Aa]})),ep??(ep=kt({name:"tiling-sprite-shader",bits:[$l,$u,Ia]}));const t=new so({uMapCoord:{value:new un,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 un,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:ep,gpuProgram:tp,resources:{localUniforms:new so({uTransformMatrix:{value:new un,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:Fn.EMPTY.source,uSampler:Fn.EMPTY.source.style}})}updateUniforms(t,e,i,n,s,r){const o=this.resources.tilingUniforms,a=r.width,h=r.height,l=r.textureMatrix,c=o.uniforms.uTextureTransform;c.set(i.a*a/t,i.b*a/e,i.c*h/t,i.d*h/e,i.tx/t,i.ty/e),c.invert(),o.uniforms.uMapCoord=l.mapCoord,o.uniforms.uClampFrame=l.uClampFrame,o.uniforms.uClampOffset=l.uClampOffset,o.uniforms.uTextureTransform=c,o.uniforms.uSizeAnchor[0]=t,o.uniforms.uSizeAnchor[1]=e,o.uniforms.uSizeAnchor[2]=n,o.uniforms.uSizeAnchor[3]=s,r&&(this.resources.uTexture=r.source,this.resources.uSampler=r.source.style)}}const np=new class extends El{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 sp{constructor(){this.canBatch=!0,this.geometry=new El({indices:np.indices.slice(),positions:np.positions.slice(),uvs:np.uvs.slice()})}destroy(){this.geometry.destroy(),this.shader?.destroy()}}class rp{constructor(t){this._state=co.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:s,canBatch:r}=n;if(r){n.batchableMesh||(n.batchableMesh=new Lu);const r=n.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),r.geometry=s,r.renderable=t,r.transform=t.groupTransform,r.setTexture(t._texture)),r.roundPixels=this._renderer._roundPixels|t._roundPixels,i.addToBatch(r,e)}else i.break(e),n.shader||(n.shader=new ip),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,Ze(t.groupColorAlpha,i.uColor,0),this._state.blendMode=yt(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:np,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 sp;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,s=i.frame.height;let r=0,o=0;t.applyAnchorToTexture&&(r=t.anchor.x,o=t.anchor.y),e[0]=e[6]=-r,e[2]=e[4]=1-r,e[1]=e[3]=-o,e[5]=e[7]=1-o;const a=un.shared;a.copyFrom(t._tileTransform.matrix),a.tx/=t.width,a.ty/=t.height,a.invert(),a.scale(t.width/n,t.height/s),function(t,e,i,n){let s=0;const r=t.length/2,o=n.a,a=n.b,h=n.c,l=n.d,c=n.tx,d=n.ty;for(i*=2;s<r;){const e=t[i],n=t[i+1];t[i]=o*e+h*n+c,t[i+1]=a*e+l*n+d,i+=2,s++}}(e,0,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===oo.WEBGL&&(n=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=i.textureMatrix.isSimple&&(n||i.source.isPowerOfTwo),e.canBatch}}rp.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"tilingSprite"};const op={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 "}},ap={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 "}},hp={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 "}},lp={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 cp,dp;class up extends ao{constructor(t){const e=new so({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new un,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});cp??(cp=Ot({name:"sdf-shader",bits:[va,Ft(t),op,hp,Aa]})),dp??(dp=kt({name:"sdf-shader",bits:[wa,jt(t),ap,lp,Ia]})),super({glProgram:dp,gpuProgram:cp,resources:{localUniforms:e,batchSamplers:Gt(t)}})}}class pp extends Tl{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class fp{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);ti(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);ti(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:i}=e,n=xh.getFont(t.text,t._style);i.clear(),"none"!==n.distanceField.type&&(i.customShader||(i.customShader=new up(this._renderer.limits.maxBatchableTextures)));const s=Fo.graphemeSegmenter(t.text),r=t._style;let o=n.baseLineOffset;const a=fe(s,r,n,!0),h=r.padding,l=a.scale;let c=a.width,d=a.height+a.offsetY;r._stroke&&(c+=r._stroke.width/l,d+=r._stroke.width/l),i.translate(-t._anchor._x*c-h,-t._anchor._y*d-h).scale(l,l);const u=n.applyFillAsTint?r._fill.color:16777215;let p=n.fontMetrics.fontSize,f=n.lineHeight;r.lineHeight&&(p=r.fontSize/l,f=r.lineHeight/l);let g=(f-p)/2;g-n.baseLineOffset<0&&(g=0);for(let t=0;t<a.lines.length;t++){const e=a.lines[t];for(let t=0;t<e.charPositions.length;t++){const s=e.chars[t],r=n.chars[s];if(r?.texture){const n=r.texture;i.texture(n,u||"black",Math.round(e.charPositions[t]+r.xOffset),Math.round(o+r.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 pp;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=hr.get(`${i}-bitmap`),{a:s,b:r,c:o,d:a}=t.groupTransform,h=Math.sqrt(s*s+r*r),l=Math.sqrt(o*o+a*a),c=(Math.abs(h)+Math.abs(l))/2,d=n.baseRenderedFontSize/t._style.fontSize,u=c*n.distanceField.range*(1/d);e.customShader.resources.localUniforms.uniforms.uDistance=u}destroy(){this._renderer=null}}fp.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"bitmapText"};class gp extends dd{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}}class mp{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=>{}),t._didTextUpdate=!1,ei(i,t)),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}async _updateGpuText(t){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=await i;const n=t.renderGroup||t.parentRenderGroup;n&&(n.structureDidChange=!0),e.generatingTexture=!1,ei(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new gp(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.texture=Fn.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}}mp.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"htmlText"};const yp=new jn,xp=new Map;class bp{constructor(t){this._renderer=t,this._createCanvas=t.type===oo.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){const{text:e,style:i,resolution:n,textureStyle:s}=t,r=ms.get(Vl),o=function(t,e){function i(t){r[t]||(s.push(t),r[t]=!0)}const n=e.fontFamily,s=[],r={},o=t.match(/font-family:([^;"\s]+)/g);if(Array.isArray(n))for(let t=0;t<n.length;t++)i(n[t]);else i(n);o&&o.forEach(t=>{i(t.split(":")[1].trim())});for(const t in e.tagStyles)i(e.tagStyles[t].fontFamily);return s}(e,i),a=await async function(t){const e=t.filter(t=>hr.has(`${t}-and-url`)).map(t=>{if(!xp.has(t)){const{entries:e}=hr.get(`${t}-and-url`),i=[];e.forEach(e=>{const n=e.url,s=e.faces.map(t=>({weight:t.weight,style:t.style}));i.push(...s.map(e=>async function(t,e){const i=await async function(t){const e=await qs.get().fetch(t),i=await e.blob(),n=new FileReader;return await 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 }`}({fontWeight:e.weight,fontStyle:e.style,fontFamily:t},n)))}),xp.set(t,Promise.all(i).then(t=>t.join("\n")))}return xp.get(t)});return(await Promise.all(e)).join("\n")}(o),h=function(t,e,i,n){n||(n=Wl||(Wl=new Vl));const{domElement:s,styleElement:r,svgRoot:o}=n;s.innerHTML=`<style>${e.cssStyle};</style><div style='padding:0'>${t}</div>`,s.setAttribute("style","transform-origin: top left; display: inline-block"),i&&(r.textContent=i),document.body.appendChild(o);const a=s.getBoundingClientRect();o.remove();const h=2*e.padding;return{width:a.width-h,height:a.height-h}}(e,i,a,r),l=Math.ceil(Math.ceil(Math.max(1,h.width)+2*i.padding)*n),c=Math.ceil(Math.ceil(Math.max(1,h.height)+2*i.padding)*n),d=r.image;d.width=2+(0|l),d.height=2+(0|c);const u=function(t,e,i,n,s){const{domElement:r,styleElement:o,svgRoot:a}=s;r.innerHTML=`<style>${e.cssStyle}</style><div style='padding:0;'>${t}</div>`,r.setAttribute("style",`transform: scale(${i});transform-origin: top left; display: inline-block`),o.textContent=n;const{width:h,height:l}=s.image;return a.setAttribute("width",h.toString()),a.setAttribute("height",l.toString()),(new XMLSerializer).serializeToString(a)}(e,i,n,a,r);await function(t,e,i){return new Promise(async n=>{i&&await new Promise(t=>setTimeout(t,100)),t.onload=()=>{n()},t.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(e)}`,t.crossOrigin="anonymous"})}(d,u,function(){const{userAgent:t}=qs.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}()&&o.length>0);const p=d;let f;this._createCanvas&&(f=function(t,e){const i=ph.getOptimalCanvasAndContext(t.width,t.height,e),{context:n}=i;return n.clearRect(0,0,t.width,t.height),n.drawImage(t,0,0),i}(d,n));const g=ii(f?f.canvas:p,d.width-2,d.height-2,n);return s&&(g.source.style=s),this._createCanvas&&(this._renderer.texture.initSource(g.source),ph.returnCanvasAndContext(f)),ms.return(r),g}returnTexturePromise(t){t.then(t=>{this._cleanUp(t)}).catch(()=>{a()})}_cleanUp(t){Ls.returnTexture(t,!0),t.source.resource=null,t.source.uploadMethodId="unknown"}destroy(){this._renderer=null}}bp.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"htmlText"};class _p extends dd{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 vp{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),ei(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new _p(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}}vp.extension={type:[Ki.WebGLPipes,Ki.WebGPUPipes,Ki.CanvasPipes],name:"text"};class wp{constructor(t){this._renderer=t}getTexture(t,e,n,s){"string"==typeof t&&(i(0,"CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:n,resolution:e}),t.style instanceof uh||(t.style=new uh(t.style)),t.textureStyle instanceof En||(t.textureStyle=new En(t.textureStyle)),"string"!=typeof t.text&&(t.text=t.text.toString());const{text:r,style:o,textureStyle:a}=t,h=t.resolution??this._renderer.resolution,{frame:l,canvasAndContext:c}=Ul.getCanvasAndContext({text:r,style:o,resolution:h}),d=ii(c.canvas,l.width,l.height,h);if(a&&(d.source.style=a),o.trim&&(l.pad(o.padding),d.frame.copyFrom(l),d.frame.scale(1/h),d.updateUvs()),o.filters){const t=this._applyFilters(d,o.filters);return this.returnTexture(d),Ul.returnCanvasAndContext(c),t}return this._renderer.texture.initSource(d._source),Ul.returnCanvasAndContext(c),d}returnTexture(t){const e=t.source;e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",Ls.returnTexture(t,!0)}renderTextToCanvas(){i(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}}wp.extension={type:[Ki.WebGLSystem,Ki.WebGPUSystem,Ki.CanvasSystem],name:"canvasText"},$i.add(tn,en);var Cp="object"==typeof global&&global&&global.Object===Object&&global,Sp="object"==typeof self&&self&&self.Object===Object&&self,Ap=Cp||Sp||Function("return this")(),Ip=Ap.Symbol,Mp=Object.prototype,Tp=Mp.hasOwnProperty,Pp=Mp.toString,Ep=Ip?Ip.toStringTag:void 0,Bp=Object.prototype.toString,Op=Ip?Ip.toStringTag:void 0,kp=Array.isArray,Rp=/\s/,Dp=/^\s+/,Fp=/^[-+]0x[0-9a-f]+$/i,Lp=/^0b[01]+$/i,jp=/^0o[0-7]+$/i,Gp=parseInt,Up=1/0,Np=Ap["__core-js_shared__"],zp=function(){var t=/[^.]+$/.exec(Np&&Np.keys&&Np.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Hp=Function.prototype.toString,Vp=/^\[object .+?Constructor\]$/,Wp=Function.prototype,Zp=Object.prototype,Jp=Wp.toString,Xp=Zp.hasOwnProperty,Yp=RegExp("^"+Jp.call(Xp).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Kp=ci(Ap,"WeakMap"),qp=Object.create,Qp=function(){function t(){}return function(e){if(!ri(e))return{};if(qp)return qp(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}(),$p=Date.now,tf=function(){try{var t=ci(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),ef=tf?function(t,e){return tf(t,"toString",{configurable:!0,enumerable:!1,value:(i=e,function(){return i}),writable:!0});var i}:ai,nf=function(t){var e=0,i=0;return function(){var n=$p(),s=16-(n-i);if(i=n,s>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(ef),sf=/^(?:0|[1-9]\d*)$/,rf=Object.prototype.hasOwnProperty,of=Math.max,af=Object.prototype,hf=Object.prototype,lf=hf.hasOwnProperty,cf=hf.propertyIsEnumerable,df=xi(function(){return arguments}())?xi:function(t){return si(t)&&lf.call(t,"callee")&&!cf.call(t,"callee")},uf="object"==typeof exports&&exports&&!exports.nodeType&&exports,pf=uf&&"object"==typeof module&&module&&!module.nodeType&&module,ff=pf&&pf.exports===uf?Ap.Buffer:void 0,gf=(ff?ff.isBuffer:void 0)||function(){return!1},mf={};mf["[object Float32Array]"]=mf["[object Float64Array]"]=mf["[object Int8Array]"]=mf["[object Int16Array]"]=mf["[object Int32Array]"]=mf["[object Uint8Array]"]=mf["[object Uint8ClampedArray]"]=mf["[object Uint16Array]"]=mf["[object Uint32Array]"]=!0,mf["[object Arguments]"]=mf["[object Array]"]=mf["[object ArrayBuffer]"]=mf["[object Boolean]"]=mf["[object DataView]"]=mf["[object Date]"]=mf["[object Error]"]=mf["[object Function]"]=mf["[object Map]"]=mf["[object Number]"]=mf["[object Object]"]=mf["[object RegExp]"]=mf["[object Set]"]=mf["[object String]"]=mf["[object WeakMap]"]=!1;var yf,xf="object"==typeof exports&&exports&&!exports.nodeType&&exports,bf=xf&&"object"==typeof module&&module&&!module.nodeType&&module,_f=bf&&bf.exports===xf&&Cp.process,vf=function(){try{return bf&&bf.require&&bf.require("util").types||_f&&_f.binding&&_f.binding("util")}catch(t){}}(),wf=vf&&vf.isTypedArray,Cf=wf?(yf=wf,function(t){return yf(t)}):function(t){return si(t)&&gi(t.length)&&!!mf[ni(t)]},Sf=Object.prototype.hasOwnProperty,Af=_i(Object.keys,Object),If=Object.prototype.hasOwnProperty,Mf=Object.prototype.hasOwnProperty,Tf=ci(Object,"create"),Pf=Object.prototype.hasOwnProperty,Ef=Object.prototype.hasOwnProperty;wi.prototype.clear=function(){this.__data__=Tf?Tf(null):{},this.size=0},wi.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},wi.prototype.get=function(t){var e=this.__data__;if(Tf){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return Pf.call(e,t)?e[t]:void 0},wi.prototype.has=function(t){var e=this.__data__;return Tf?void 0!==e[t]:Ef.call(e,t)},wi.prototype.set=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Tf&&void 0===e?"__lodash_hash_undefined__":e,this};var Bf=Array.prototype.splice;Si.prototype.clear=function(){this.__data__=[],this.size=0},Si.prototype.delete=function(t){var e=this.__data__,i=Ci(e,t);return!(i<0||(i==e.length-1?e.pop():Bf.call(e,i,1),--this.size,0))},Si.prototype.get=function(t){var e=this.__data__,i=Ci(e,t);return i<0?void 0:e[i][1]},Si.prototype.has=function(t){return Ci(this.__data__,t)>-1},Si.prototype.set=function(t,e){var i=this.__data__,n=Ci(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this};var Of=ci(Ap,"Map");Ii.prototype.clear=function(){this.size=0,this.__data__={hash:new wi,map:new(Of||Si),string:new wi}},Ii.prototype.delete=function(t){var e=Ai(this,t).delete(t);return this.size-=e?1:0,e},Ii.prototype.get=function(t){return Ai(this,t).get(t)},Ii.prototype.has=function(t){return Ai(this,t).has(t)},Ii.prototype.set=function(t,e){var i=Ai(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this};var kf=_i(Object.getPrototypeOf,Object),Rf=Function.prototype,Df=Object.prototype,Ff=Rf.toString,Lf=Df.hasOwnProperty,jf=Ff.call(Object),Gf=Math.ceil,Uf=Math.max;Ti.prototype.clear=function(){this.__data__=new Si,this.size=0},Ti.prototype.delete=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i},Ti.prototype.get=function(t){return this.__data__.get(t)},Ti.prototype.has=function(t){return this.__data__.has(t)},Ti.prototype.set=function(t,e){var i=this.__data__;if(i instanceof Si){var n=i.__data__;if(!Of||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new Ii(n)}return i.set(t,e),this.size=i.size,this};var Nf="object"==typeof exports&&exports&&!exports.nodeType&&exports,zf=Nf&&"object"==typeof module&&module&&!module.nodeType&&module,Hf=zf&&zf.exports===Nf?Ap.Buffer:void 0;Hf&&Hf.allocUnsafe;var Vf=Object.prototype.propertyIsEnumerable,Wf=Object.getOwnPropertySymbols,Zf=Wf?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var i=-1,n=null==t?0:t.length,s=0,r=[];++i<n;){var o=t[i];e(o)&&(r[s++]=o)}return r}(Wf(t),function(e){return Vf.call(t,e)}))}:function(){return[]},Jf=ci(Ap,"DataView"),Xf=ci(Ap,"Promise"),Yf=ci(Ap,"Set"),Kf="[object Map]",qf="[object Promise]",Qf="[object Set]",$f="[object WeakMap]",tg="[object DataView]",eg=li(Jf),ig=li(Of),ng=li(Xf),sg=li(Yf),rg=li(Kp),og=ni;(Jf&&og(new Jf(new ArrayBuffer(1)))!=tg||Of&&og(new Of)!=Kf||Xf&&og(Xf.resolve())!=qf||Yf&&og(new Yf)!=Qf||Kp&&og(new Kp)!=$f)&&(og=function(t){var e=ni(t),i="[object Object]"==e?t.constructor:void 0,n=i?li(i):"";if(n)switch(n){case eg:return tg;case ig:return Kf;case ng:return qf;case sg:return Qf;case rg:return $f}return e});var ag=Ap.Uint8Array;Ei.prototype.add=Ei.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Ei.prototype.has=function(t){return this.__data__.has(t)};var hg,lg=Ip?Ip.prototype:void 0,cg=lg?lg.valueOf:void 0,dg=Object.prototype.hasOwnProperty,ug="[object Arguments]",pg="[object Array]",fg="[object Object]",gg=Object.prototype.hasOwnProperty,mg=function(t,e,i){for(var n=-1,s=Object(t),r=i(t),o=r.length;o--;){var a=r[++n];if(!1===e(s[a],a,s))break}return t},yg=function(){return Ap.Date.now()},xg=Math.max,bg=Math.min,_g=(hg=function(t,e,i){Gi(t,e,i)},function(t){return nf(function(t,e,i){return e=of(void 0===e?t.length-1:e,0),function(){for(var n=arguments,s=-1,r=of(n.length-e,0),o=Array(r);++s<r;)o[s]=n[e+s];s=-1;for(var a=Array(e+1);++s<e;)a[s]=n[s];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,void 0,ai),t+"")}(function(t,e){var i=-1,n=e.length,s=n>1?e[n-1]:void 0,r=n>2?e[2]:void 0;for(s=hg.length>3&&"function"==typeof s?(n--,s):void 0,r&&function(t,e,i){if(!ri(i))return!1;var n=typeof e;return!!("number"==n?mi(i)&&di(e,i.length):"string"==n&&e in i)&&pi(i[e],t)}(e[0],e[1],r)&&(s=n<3?void 0:s,n=1),t=Object(t);++i<n;){var o=e[i];o&&hg(t,o,i)}return t}));!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 vg,wg,Cg,Sg={},Ag={},Ig={},Mg=(Cg||(Cg=1,function(t){function e(t){if(t>J)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,i.prototype),e}function i(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 r(t)}return n(t,e,i)}function n(t,n,s){if("string"==typeof t)return function(t,n){if("string"==typeof n&&""!==n||(n="utf8"),!i.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const s=0|l(t,n);let r=e(s);const o=r.write(t,n);return o!==s&&(r=r.slice(0,o)),r}(t,n);if(ArrayBuffer.isView(t))return function(t){if(U(t,Uint8Array)){const e=new Uint8Array(t);return a(e.buffer,e.byteOffset,e.byteLength)}return o(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(U(t,ArrayBuffer)||t&&U(t.buffer,ArrayBuffer))return a(t,n,s);if("undefined"!=typeof SharedArrayBuffer&&(U(t,SharedArrayBuffer)||t&&U(t.buffer,SharedArrayBuffer)))return a(t,n,s);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return i.from(r,n,s);const c=function(t){if(i.isBuffer(t)){const i=0|h(t.length),n=e(i);return 0===n.length||t.copy(n,0,0,i),n}return void 0!==t.length?"number"!=typeof t.length||N(t.length)?e(0):o(t):"Buffer"===t.type&&Array.isArray(t.data)?o(t.data):void 0}(t);if(c)return c;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return i.from(t[Symbol.toPrimitive]("string"),n,s);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function s(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 r(t){return s(t),e(t<0?0:0|h(t))}function o(t){const i=t.length<0?0:0|h(t.length),n=e(i);for(let e=0;e<i;e+=1)n[e]=255&t[e];return n}function a(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let s;return s=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(s,i.prototype),s}function h(t){if(t>=J)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+J.toString(16)+" bytes");return 0|t}function l(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||U(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 n=t.length,s=arguments.length>2&&!0===arguments[2];if(!s&&0===n)return 0;let r=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return j(t).length;default:if(r)return s?-1:L(t).length;e=(""+e).toLowerCase(),r=!0}}function c(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 C(this,e,i);case"utf8":case"utf-8":return _(this,e,i);case"ascii":return v(this,e,i);case"latin1":case"binary":return w(this,e,i);case"base64":return b(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function d(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function u(t,e,n,s,r){if(0===t.length)return-1;if("string"==typeof n?(s=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),N(n=+n)&&(n=r?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(r)return-1;n=t.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof e&&(e=i.from(e,s)),i.isBuffer(e))return 0===e.length?-1:p(t,e,n,s,r);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):p(t,[e],n,s,r);throw new TypeError("val must be string, number or Buffer")}function p(t,e,i,n,s){function r(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}let o,a=1,h=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;a=2,h/=2,l/=2,i/=2}if(s){let n=-1;for(o=i;o<h;o++)if(r(t,o)===r(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===l)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(i+l>h&&(i=h-l),o=i;o>=0;o--){let i=!0;for(let n=0;n<l;n++)if(r(t,o+n)!==r(e,n)){i=!1;break}if(i)return o}return-1}function f(t,e,i,n){i=Number(i)||0;const s=t.length-i;n?(n=Number(n))>s&&(n=s):n=s;const r=e.length;let o;for(n>r/2&&(n=r/2),o=0;o<n;++o){const n=parseInt(e.substr(2*o,2),16);if(N(n))return o;t[i+o]=n}return o}function g(t,e,i,n){return G(L(e,t.length-i),t,i,n)}function m(t,e,i,n){return G(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 y(t,e,i,n){return G(j(e),t,i,n)}function x(t,e,i,n){return G(function(t,e){let i,n,s;const r=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)i=t.charCodeAt(o),n=i>>8,s=i%256,r.push(s),r.push(n);return r}(e,t.length-i),t,i,n)}function b(t,e,i){return 0===e&&i===t.length?V.fromByteArray(t):V.fromByteArray(t.slice(e,i))}function _(t,e,i){i=Math.min(t.length,i);const n=[];let s=e;for(;s<i;){const e=t[s];let r=null,o=e>239?4:e>223?3:e>191?2:1;if(s+o<=i){let i,n,a,h;switch(o){case 1:e<128&&(r=e);break;case 2:i=t[s+1],128==(192&i)&&(h=(31&e)<<6|63&i,h>127&&(r=h));break;case 3:i=t[s+1],n=t[s+2],128==(192&i)&&128==(192&n)&&(h=(15&e)<<12|(63&i)<<6|63&n,h>2047&&(h<55296||h>57343)&&(r=h));break;case 4:i=t[s+1],n=t[s+2],a=t[s+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(h=(15&e)<<18|(63&i)<<12|(63&n)<<6|63&a,h>65535&&h<1114112&&(r=h))}}null===r?(r=65533,o=1):r>65535&&(r-=65536,n.push(r>>>10&1023|55296),r=56320|1023&r),n.push(r),s+=o}return function(t){const e=t.length;if(e<=X)return String.fromCharCode.apply(String,t);let i="",n=0;for(;n<e;)i+=String.fromCharCode.apply(String,t.slice(n,n+=X));return i}(n)}function v(t,e,i){let n="";i=Math.min(t.length,i);for(let s=e;s<i;++s)n+=String.fromCharCode(127&t[s]);return n}function w(t,e,i){let n="";i=Math.min(t.length,i);for(let s=e;s<i;++s)n+=String.fromCharCode(t[s]);return n}function C(t,e,i){const n=t.length;(!e||e<0)&&(e=0),(!i||i<0||i>n)&&(i=n);let s="";for(let n=e;n<i;++n)s+=q[t[n]];return s}function S(t,e,i){const n=t.slice(e,i);let s="";for(let t=0;t<n.length-1;t+=2)s+=String.fromCharCode(n[t]+256*n[t+1]);return s}function A(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 I(t,e,n,s,r,o){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||e<o)throw new RangeError('"value" argument is out of bounds');if(n+s>t.length)throw new RangeError("Index out of range")}function M(t,e,i,n,s){R(e,n,s,t,i,7);let r=Number(e&BigInt(4294967295));t[i++]=r,r>>=8,t[i++]=r,r>>=8,t[i++]=r,r>>=8,t[i++]=r;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 T(t,e,i,n,s){R(e,n,s,t,i,7);let r=Number(e&BigInt(4294967295));t[i+7]=r,r>>=8,t[i+6]=r,r>>=8,t[i+5]=r,r>>=8,t[i+4]=r;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 P(t,e,i,n,s,r){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function E(t,e,i,n,s){return e=+e,i>>>=0,s||P(t,0,i,4),W.write(t,e,i,n,23,4),i+4}function B(t,e,i,n,s){return e=+e,i>>>=0,s||P(t,0,i,8),W.write(t,e,i,n,52,8),i+8}function O(t,e,i){Y[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 k(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 R(t,e,i,n,s,r){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*(r+1)}${i}`:`>= -(2${i} ** ${8*(r+1)-1}${i}) and < 2 ** ${8*(r+1)-1}${i}`,new Y.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,i){D(e,"offset"),void 0!==t[e]&&void 0!==t[e+i]||F(e,t.length-(i+1))}(n,s,r)}function D(t,e){if("number"!=typeof t)throw new Y.ERR_INVALID_ARG_TYPE(e,"number",t)}function F(t,e,i){if(Math.floor(t)!==t)throw D(t,i),new Y.ERR_OUT_OF_RANGE("offset","an integer",t);if(e<0)throw new Y.ERR_BUFFER_OUT_OF_BOUNDS;throw new Y.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}function L(t,e){let i;e=e||1/0;const n=t.length;let s=null;const r=[];for(let o=0;o<n;++o){if(i=t.charCodeAt(o),i>55295&&i<57344){if(!s){if(i>56319){(e-=3)>-1&&r.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&r.push(239,191,189);continue}s=i;continue}if(i<56320){(e-=3)>-1&&r.push(239,191,189),s=i;continue}i=65536+(s-55296<<10|i-56320)}else s&&(e-=3)>-1&&r.push(239,191,189);if(s=null,i<128){if((e-=1)<0)break;r.push(i)}else if(i<2048){if((e-=2)<0)break;r.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;r.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;r.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return r}function j(t){return V.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,i,n){let s;for(s=0;s<n&&!(s+i>=e.length||s>=t.length);++s)e[s+i]=t[s];return s}function U(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function N(t){return t!=t}function z(t){return"undefined"==typeof BigInt?H:t}function H(){throw new Error("BigInt not supported")}const V=function(){function t(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 e(t){return n[t>>18&63]+n[t>>12&63]+n[t>>6&63]+n[63&t]}function i(t,i,n){for(var s,r=[],o=i;o<n;o+=3)s=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),r.push(e(s));return r.join("")}if(vg)return Ag;vg=1,Ag.byteLength=function(e){var i=t(e),n=i[0],s=i[1];return 3*(n+s)/4-s},Ag.toByteArray=function(e){var i,n,o=t(e),a=o[0],h=o[1],l=new r(function(t,e,i){return 3*(e+i)/4-i}(0,a,h)),c=0,d=h>0?a-4:a;for(n=0;n<d;n+=4)i=s[e.charCodeAt(n)]<<18|s[e.charCodeAt(n+1)]<<12|s[e.charCodeAt(n+2)]<<6|s[e.charCodeAt(n+3)],l[c++]=i>>16&255,l[c++]=i>>8&255,l[c++]=255&i;return 2===h&&(i=s[e.charCodeAt(n)]<<2|s[e.charCodeAt(n+1)]>>4,l[c++]=255&i),1===h&&(i=s[e.charCodeAt(n)]<<10|s[e.charCodeAt(n+1)]<<4|s[e.charCodeAt(n+2)]>>2,l[c++]=i>>8&255,l[c++]=255&i),l},Ag.fromByteArray=function(t){for(var e,s=t.length,r=s%3,o=[],a=16383,h=0,l=s-r;h<l;h+=a)o.push(i(t,h,h+a>l?l:h+a));return 1===r?(e=t[s-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[s-2]<<8)+t[s-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),o.join("")};for(var n=[],s=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)n[a]=o[a],s[o.charCodeAt(a)]=a;return s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63,Ag}(),W=(wg||(wg=1,Ig.read=function(t,e,i,n,s){var r,o,a=8*s-n-1,h=(1<<a)-1,l=h>>1,c=-7,d=i?s-1:0,u=i?-1:1,p=t[e+d];for(d+=u,r=p&(1<<-c)-1,p>>=-c,c+=a;c>0;r=256*r+t[e+d],d+=u,c-=8);for(o=r&(1<<-c)-1,r>>=-c,c+=n;c>0;o=256*o+t[e+d],d+=u,c-=8);if(0===r)r=1-l;else{if(r===h)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),r-=l}return(p?-1:1)*o*Math.pow(2,r-n)},Ig.write=function(t,e,i,n,s,r){var o,a,h,l=8*r-s-1,c=(1<<l)-1,d=c>>1,u=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:r-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*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+d>=1?u/h:u*Math.pow(2,1-d))*h>=2&&(o++,h/=2),o+d>=c?(a=0,o=c):o+d>=1?(a=(e*h-1)*Math.pow(2,s),o+=d):(a=e*Math.pow(2,d-1)*Math.pow(2,s),o=0));s>=8;t[i+p]=255&a,p+=f,a/=256,s-=8);for(o=o<<s|a,l+=s;l>0;t[i+p]=255&o,p+=f,o/=256,l-=8);t[i+p-f]|=128*g}),Ig),Z="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=i,t.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},t.INSPECT_MAX_BYTES=50;const J=2147483647;t.kMaxLength=J,i.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}}(),!i.TYPED_ARRAY_SUPPORT&&"undefined"!=typeof console&&console.error,Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}}),i.poolSize=8192,i.from=function(t,e,i){return n(t,e,i)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(t,i,n){return function(t,i,n){return s(t),t<=0?e(t):void 0!==i?"string"==typeof n?e(t).fill(i,n):e(t).fill(i):e(t)}(t,i,n)},i.allocUnsafe=function(t){return r(t)},i.allocUnsafeSlow=function(t){return r(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==i.prototype},i.compare=function(t,e){if(U(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),U(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,s=e.length;for(let i=0,r=Math.min(n,s);i<r;++i)if(t[i]!==e[i]){n=t[i],s=e[i];break}return n<s?-1:s<n?1:0},i.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}},i.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return i.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const s=i.allocUnsafe(e);let r=0;for(n=0;n<t.length;++n){let e=t[n];if(U(e,Uint8Array))r+e.length>s.length?(i.isBuffer(e)||(e=i.from(e)),e.copy(s,r)):Uint8Array.prototype.set.call(s,e,r);else{if(!i.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(s,r)}r+=e.length}return s},i.byteLength=l,i.prototype._isBuffer=!0,i.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)d(this,e,e+1);return this},i.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)d(this,e,e+3),d(this,e+1,e+2);return this},i.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)d(this,e,e+7),d(this,e+1,e+6),d(this,e+2,e+5),d(this,e+3,e+4);return this},i.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?_(this,0,t):c.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.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+">"},Z&&(i.prototype[Z]=i.prototype.inspect),i.prototype.compare=function(t,e,n,s,r){if(U(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.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===n&&(n=t?t.length:0),void 0===s&&(s=0),void 0===r&&(r=this.length),e<0||n>t.length||s<0||r>this.length)throw new RangeError("out of range index");if(s>=r&&e>=n)return 0;if(s>=r)return-1;if(e>=n)return 1;if(this===t)return 0;let o=(r>>>=0)-(s>>>=0),a=(n>>>=0)-(e>>>=0);const h=Math.min(o,a),l=this.slice(s,r),c=t.slice(e,n);for(let t=0;t<h;++t)if(l[t]!==c[t]){o=l[t],a=c[t];break}return o<a?-1:a<o?1:0},i.prototype.includes=function(t,e,i){return-1!==this.indexOf(t,e,i)},i.prototype.indexOf=function(t,e,i){return u(this,t,e,i,!0)},i.prototype.lastIndexOf=function(t,e,i){return u(this,t,e,i,!1)},i.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 s=this.length-e;if((void 0===i||i>s)&&(i=s),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let r=!1;for(;;)switch(n){case"hex":return f(this,t,e,i);case"utf8":case"utf-8":return g(this,t,e,i);case"ascii":case"latin1":case"binary":return m(this,t,e,i);case"base64":return y(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,i);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),r=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const X=4096;i.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const s=this.subarray(t,e);return Object.setPrototypeOf(s,i.prototype),s},i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,i){t>>>=0,e>>>=0,i||A(t,e,this.length);let n=this[t],s=1,r=0;for(;++r<e&&(s*=256);)n+=this[t+r]*s;return n},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,i){t>>>=0,e>>>=0,i||A(t,e,this.length);let n=this[t+--e],s=1;for(;e>0&&(s*=256);)n+=this[t+--e]*s;return n},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t>>>=0,e||A(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||A(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||A(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||A(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readBigUInt64LE=z(function(t){D(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||F(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,s=this[++t]+256*this[++t]+65536*this[++t]+i*2**24;return BigInt(n)+(BigInt(s)<<BigInt(32))}),i.prototype.readBigUInt64BE=z(function(t){D(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||F(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],s=this[++t]*2**24+65536*this[++t]+256*this[++t]+i;return(BigInt(n)<<BigInt(32))+BigInt(s)}),i.prototype.readIntLE=function(t,e,i){t>>>=0,e>>>=0,i||A(t,e,this.length);let n=this[t],s=1,r=0;for(;++r<e&&(s*=256);)n+=this[t+r]*s;return s*=128,n>=s&&(n-=Math.pow(2,8*e)),n},i.prototype.readIntBE=function(t,e,i){t>>>=0,e>>>=0,i||A(t,e,this.length);let n=e,s=1,r=this[t+--n];for(;n>0&&(s*=256);)r+=this[t+--n]*s;return s*=128,r>=s&&(r-=Math.pow(2,8*e)),r},i.prototype.readInt8=function(t,e){return t>>>=0,e||A(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||A(t,2,this.length);const i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},i.prototype.readInt16BE=function(t,e){t>>>=0,e||A(t,2,this.length);const i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readBigInt64LE=z(function(t){D(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||F(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),i.prototype.readBigInt64BE=z(function(t){D(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||F(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+i)}),i.prototype.readFloatLE=function(t,e){return t>>>=0,e||A(t,4,this.length),W.read(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||A(t,4,this.length),W.read(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||A(t,8,this.length),W.read(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||A(t,8,this.length),W.read(this,t,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,i,n){t=+t,e>>>=0,i>>>=0,n||I(this,t,e,i,Math.pow(2,8*i)-1,0);let s=1,r=0;for(this[e]=255&t;++r<i&&(s*=256);)this[e+r]=t/s&255;return e+i},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,i,n){t=+t,e>>>=0,i>>>=0,n||I(this,t,e,i,Math.pow(2,8*i)-1,0);let s=i-1,r=1;for(this[e+s]=255&t;--s>=0&&(r*=256);)this[e+s]=t/r&255;return e+i},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(t,e,i){return t=+t,e>>>=0,i||I(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},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(t,e,i){return t=+t,e>>>=0,i||I(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},i.prototype.writeBigUInt64LE=z(function(t,e=0){return M(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeBigUInt64BE=z(function(t,e=0){return T(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*i-1);I(this,t,e,i,n-1,-n)}let s=0,r=1,o=0;for(this[e]=255&t;++s<i&&(r*=256);)t<0&&0===o&&0!==this[e+s-1]&&(o=1),this[e+s]=(t/r|0)-o&255;return e+i},i.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*i-1);I(this,t,e,i,n-1,-n)}let s=i-1,r=1,o=0;for(this[e+s]=255&t;--s>=0&&(r*=256);)t<0&&0===o&&0!==this[e+s+1]&&(o=1),this[e+s]=(t/r|0)-o&255;return e+i},i.prototype.writeInt8=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,i){return t=+t,e>>>=0,i||I(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},i.prototype.writeInt32BE=function(t,e,i){return t=+t,e>>>=0,i||I(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},i.prototype.writeBigInt64LE=z(function(t,e=0){return M(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeBigInt64BE=z(function(t,e=0){return T(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeFloatLE=function(t,e,i){return E(this,t,e,!0,i)},i.prototype.writeFloatBE=function(t,e,i){return E(this,t,e,!1,i)},i.prototype.writeDoubleLE=function(t,e,i){return B(this,t,e,!0,i)},i.prototype.writeDoubleBE=function(t,e,i){return B(this,t,e,!1,i)},i.prototype.copy=function(t,e,n,s){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),s||0===s||(s=this.length),e>=t.length&&(e=t.length),e||(e=0),s>0&&s<n&&(s=n),s===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),t.length-e<s-n&&(s=t.length-e+n);const r=s-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,s):Uint8Array.prototype.set.call(t,this.subarray(n,s),e),r},i.prototype.fill=function(t,e,n,s){if("string"==typeof t){if("string"==typeof e?(s=e,e=0,n=this.length):"string"==typeof n&&(s=n,n=this.length),void 0!==s&&"string"!=typeof s)throw new TypeError("encoding must be a string");if("string"==typeof s&&!i.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(1===t.length){const e=t.charCodeAt(0);("utf8"===s&&e<128||"latin1"===s)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let r;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(r=e;r<n;++r)this[r]=t;else{const o=i.isBuffer(t)?t:i.from(t,s),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(r=0;r<n-e;++r)this[r+e]=o[r%a]}return this};const Y={};O("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),O("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),O("ERR_OUT_OF_RANGE",function(t,e,i){let n=`The value of "${t}" is out of range.`,s=i;return Number.isInteger(i)&&Math.abs(i)>2**32?s=k(String(i)):"bigint"==typeof i&&(s=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(s=k(s)),s+="n"),n+=` It must be ${e}. Received ${s}`,n},RangeError);const K=/[^+/0-9A-Za-z-_]/g,q=function(){const t="0123456789abcdef",e=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let s=0;s<16;++s)e[n+s]=t[i]+t[s]}return e}()}(Sg)),Sg),Tg=(t,e)=>Number((e/10**t).toFixed(t)),Pg=t=>t>32767?t-65535:t,Eg=(t,e)=>e+(t<<8),Bg=(t,e)=>Tg(t,Pg(e)),Og=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 s=parseInt(e[t],16);s>31&&127!==s&&(i[n++]=s)}let s=i.slice(0,n);return Array.from(s).map(t=>String.fromCharCode(t)).join("")}catch(t){return""}},kg=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{return""}},Rg=(t,e=1)=>{let i=[];for(let n=0;n<t.length;n+=2*e){let s=t.slice(n,n+2*e),r=parseInt(s,16);i.push(r)}return i},Dg=({chargeX:t,chargeY:e},{originX:i,originY:n})=>t<=0&&e<=0?null:{x:t-i,y:e-n},Fg=(t,e)=>parseInt((t+e).slice(-8),2).toString(16).padStart(2,"0"),Lg=t=>{let e=parseInt(t.slice(0,2),16),i=t.slice(0,3===e?52:48),n=2,s=parseInt(i.slice(n,n+4),16);n+=4;let r=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 h=Tg(1,parseInt(i.slice(n,n+4),16));n+=4;let l=Tg(1,parseInt(i.slice(n,n+4),16));n+=4;let c=Tg(2,parseInt(i.slice(n,n+4),16));n+=4;let d=Tg(1,parseInt(i.slice(n,n+4),16));n+=4;let u,p=Tg(1,parseInt(i.slice(n,n+4),16));3===e&&(n+=4,u=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:s,mapStable:r,mapWidth:o,mapHeight:a,originX:h,originY:l,mapResolution:c,chargeX:d,chargeY:p,chargeDirection:u,chargePositionTransformed:Dg({chargeX:d,chargeY:p},{originX:h,originY:l}),dataLengthBeforeCompress:f,dataLengthAfterCompress:g}},jg={"00":"00","01":"f1",10:"f2",11:"ff"},Gg={sweep:"00",barrier:"01",battery:"10",unknown:"11"},Ug={sweep:"111",barrier:"001",carpet:"010",unknown:"000"},Ng={0:{typeMap:Gg},1:{typeMap:Gg},2:{typeMap:Ug},3:{typeMap:Ug}},zg={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 Hg=(t,e=1048576)=>{let i=Mg.Buffer.from(t),n=1073741824,s=e;if(e>n)return s=n,null;let r=Mg.Buffer.alloc(s),o=function(t,e,i,n){for(var s=i=i||0,r=n=n||t.length-i,o=0;s<r;){let i=t[s++],n=i>>4;if(n>0){for(var a=n+240;255===a;)n+=a=t[s++];for(var h=s+n;s<h;)e[o++]=t[s++];if(s===r)return o}let l=t[s++]|t[s++]<<8;if(0===l||l>o)return-(s-2);let c=15&i;for(a=c+240;255===a;)c+=a=t[s++];let d=o-l;for(h=o+c+4;o<h;)e[o++]=e[d++]}return o}(i,r);return r=r.slice(0,o),r},Vg=(t,e=1)=>{if(!t)return[];let i=parseInt(t.slice(2,4),16),n=t.slice(4),s=[],r=0;for(let t=0;t<i;t++){let t=n.slice(r,r+94),i=parseInt(t.slice(0,4),16),o=parseInt(t.slice(4,8),16),a=parseInt(t.slice(8,12),16),h=parseInt(t.slice(12,16),16),l=parseInt(t.slice(16,18),16),c=1===parseInt(t.slice(18,20),16),d=1===parseInt(t.slice(20,22),16),u=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),y=t.slice(54,54+2*m),x=m>0?kg(y):"";r+=2*(47+4*parseInt(t.slice(92,94),16));let b=Fg(i.toString(2),Ng[e].typeMap.sweep);s.push({roomId:i,pointHex:b,name:x,order:o,suction:u,cistern:p,colorOrder:l,sweepTimes:a,mopTimes:h,sweepForbidden:c,mopForbidden:d,yMop:f,floorMaterial:g,originStr:t,reservedStr:t.slice(30,52)})}return s},Wg=(t,e)=>{let{mapWidth:i,mapHeight:n,dataLengthAfterCompress:s,dataLengthBeforeCompress:r,mapHeaderStr:o,version:a}=e,h=o.length,l="",c="",d=i*n,u=[],p=[],f=new Map;if(s>0){let e=4*r,s=Rg(t.slice(h,h+2*r)),o=Hg(s,e);if(!o)return{mapRooms:[],mapPointsStr:"",parsed:{obstacles:new Uint32Array,carpet:new Uint32Array,rooms:new Map,width:i,height:n,totalPixels:d}};let g=Array.from(o);if(0===a){let t=[];f.set(zg.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 s=i.substring(n,n+2),r=jg[s];t.push(r);let o=4*e+n/2;if(o>=d)break;switch(parseInt(s,2)){case 0:f.get(zg.NO_ROOM_DATA).push(o);break;case 1:u.push(o)}}}l=t.join("").slice(0,2*d),c=""}else{let t=g.slice(0,d),e=[];for(let i=0;i<t.length;i++){let n=t[i];e.push(n.toString(16).padStart(2,"0")),1===a?zi(n,i,u,f):Vi(n,i,u,p,f)}l=e.join(""),c=g.slice(d).map(t=>t.toString(16).padStart(2,"0")).join("")}}else if(0===a){let e=[],i=t.slice(h).match(/.{2}/g)||[];f.set(zg.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 s=n.substring(i,i+2);e.push(jg[s]);let r=4*t+i/2;if(r>=d)break;switch(parseInt(s,2)){case 0:f.get(zg.NO_ROOM_DATA).push(r);break;case 1:u.push(r)}}}l=e.join(""),c=""}else{let e=t.slice(h,h+2*d),i=[];for(let t=0;t<d;t++){let n=e.slice(2*t,2*t+2);i.push(n);let s=parseInt(n,16);1===a?zi(s,t,u,f):Vi(s,t,u,p,f)}l=i.join(""),c=t.slice(h+2*d)}l=l.toLowerCase(),i*n*2>l.length&&(l=l.padStart(i*n*2,"f")),i*n*2<l.length&&(l=l.slice(l.length-i*n*2));let g=Vg(c,a),m=new Map;return f.forEach((t,e)=>{t.length>0&&m.set(e,new Uint32Array(t))}),{mapRooms:g,mapPointsStr:l,parsed:{obstacles:new Uint32Array(u),carpet:new Uint32Array(p),rooms:m,width:i,height:n,totalPixels:d}}},Zg=t=>{try{if(!t)return null;let e=Lg(t),{mapWidth:i,mapHeight:n,dataLengthAfterCompress:s,dataLengthBeforeCompress:r,mapHeaderStr:o,version:a}=e,h=o.length,l="",c=i*n;if(s>0){let e=4*r,i=Rg(t.slice(h,h+2*r)),n=Hg(i,e);if(!n)return[];let s=Array.from(n);if(0===a)return[];l=s.slice(c).map(t=>t.toString(16).padStart(2,"0")).join("")}else{if(0===a)return[];l=t.slice(h+2*c)}return Vg(l,a)}catch(t){return null}},Jg={"00":"common",10:"charge","01":"transitions",11:"mop"},Xg=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)}},Yg=(t,e)=>{let{dataLengthAfterCompress:i,count:n}=e,s=[];if(i>0){let e=4*n,i=Rg(t.slice(26)),r=Hg(i,e);if(!r)return[];let o=Array.from(r);for(let t=0;t<o.length;t+=4){let e=Eg(o[t],o[t+1]),i=Eg(o[t+2],o[t+3]);s.push([e,i])}}else s=function(t,e){e=void 0===e?1:Uf(function(t){var e=function(t){return t?(t=oi(t))===Up||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}(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var n=0,s=0,r=Array(Gf(i/e));n<i;)r[s++]=Mi(t,n,n+=e);return r}(Rg(t.slice(26),2),2);let r=[];for(let t=0;t<s.length;t++){let[e,i]=s[t],n=`${1&e}${1&i}`;r.push({x:Bg(1,-2&e),y:-Bg(1,-2&i),type:Jg[n]})}return r};const Kg=Object.freeze(Object.defineProperty({__proto__:null,BITMAP_TYPE_HEX_MAP:jg,BITMAP_TYPE_MAP:Gg,BITMAP_TYPE_MAP_V2:Ug,MAP_VERSION_MAP:Ng,PATH_HEADER_LENGTH:13,PATH_POINT_TYPE_MAP:Jg,SPECIAL_ROOM_IDS:zg,combineTwoBinaryToHex:Fg,dealPL:Pg,decodeMap:t=>{try{if(!t)return null;let e=Lg(t);return{mapHeader:e,mapData:Wg(t,e)}}catch(t){return null}},decodeMapData:Wg,decodeMapHeader:Lg,decodeMapRooms:Zg,decodeMapStructured:t=>{try{return JSON.parse(Og(t))}catch(t){return{}}},decodePath:t=>{let e=Xg(t);return{pathHeader:e,pathPoints:Yg(t,e)}},decodePathData:Yg,decodePathHeader:Xg,hexStringToNumber:Rg,hexToUTF8:Og,hexToUriDecodedString:kg,highLowToInt:Eg,scaleNumber:Tg,transformChargeXY:Dg,transformXY:Bg},Symbol.toStringTag,{value:"Module"})),qg=(t,e)=>(Zg(t)??[]).map(t=>({id:t.roomId,name:t.name,cleanTimes:t.sweepTimes,order:t.order,floorType:t.floorMaterial,yMop:t.yMop?1:0,suction:t.suction,cistern:t.cistern,cleanMode:t.sweepForbidden||t.mopForbidden?t.sweepForbidden?2:1:0,...e?.(t.reservedStr)??{}})),Qg={log(t,...e){},warn(t,...e){},error(t,...e){},debug(t,...e){},success(t,...e){}},$g=t=>{if(t.length<=1)return[...t];const e=tm(t),i=e.slice(1).map((t,i)=>({prev:e[i],current:t})),n=new Map;return i.forEach(({prev:t,current:e})=>{em(t,e).forEach(t=>{const e=`${t.x},${t.y}`;n.has(e)||n.set(e,t)})}),Array.from(n.values())},tm=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]},em=(t,e)=>{const i=[],n=Math.abs(e.x-t.x),s=Math.abs(e.y-t.y),r=t.x<e.x?1:-1,o=t.y<e.y?1:-1;let a=n-s,h=t.x,l=t.y;for(;i.push({x:h,y:l}),h!==e.x||l!==e.y;){const t=2*a;t>-s&&(a-=s,h+=r),t<n&&(a+=n,l+=o)}return i},im=(t,e,i,n,s,r=8)=>{const o={x:(e+n)/2,y:(i+s)/2},a=n-e,h=s-i,l=Math.min(r,.2*Math.min(a,h));return om(o,t)&&sm(o,t)>=l?o:nm(t,o,l)},nm=(t,e,i)=>{const{minX:n,minY:s,maxX:r,maxY:o}=lm(t),a=r-n,h=o-s,l=e.x,c=e.y,d=Math.min(.5,.05*Math.min(a,h)),u=[];if(om({x:l,y:c},t)){const e=sm({x:l,y:c},t);u.push({point:{x:l,y:c},distance:e,centerDistance:0})}const p=.6*Math.max(a,h),f=Math.PI/16;for(let e=d;e<=p;e+=d){const a=f*(1+e/p);for(let h=0;h<2*Math.PI;h+=a){const a=l+e*Math.cos(h),d=c+e*Math.sin(h);if(a>=n&&a<=r&&d>=s&&d<=o){const e={x:a,y:d};if(om(e,t)){const n=sm(e,t),s=pm({x:a,y:d},{x:l,y:c});n>=i&&u.push({point:e,distance:n,centerDistance:s})}}}if(u.length>=15)break}if(u.length>0){const t=u.map(t=>({...t,score:1.5*t.distance-.5*t.centerDistance}));return t.sort((t,e)=>e.score-t.score),t[0].point}if(0===u.length){let e={x:l,y:c},i=0;const a=2*d;for(let h=n;h<=r;h+=a)for(let n=s;n<=o;n+=a){const s={x:h,y:n};if(om(s,t)){const n=sm(s,t);n>i&&(i=n,e=s)}}return e}return{x:l,y:c}},sm=(t,e)=>{let i=1/0;for(let n=0,s=e.length-1;n<e.length;s=n++){const r=e[s],o=e[n],a=rm(t,r,o);i=Math.min(i,a)}return i},rm=(t,e,i)=>{const n=(e.x-i.x)**2+(e.y-i.y)**2;if(0===n)return pm(t,e);const s=Math.max(0,Math.min(1,((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/n)),r=e.x+s*(i.x-e.x),o=e.y+s*(i.y-e.y);return pm(t,{x:r,y:o})},om=(t,e,i=!1)=>{if(e.length<3)return!1;if(i&&am(t,e))return!0;let n=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){const r=e[i].x,o=e[i].y,a=e[s].x,h=e[s].y;o>t.y!=h>t.y&&t.x<(a-r)*(t.y-o)/(h-o)+r&&(n=!n)}return n},am=(t,e)=>{if(e.length<2)return!1;for(let i=0;i<e.length;i++){const n=(i+1)%e.length;if(hm(t,e[i],e[n]))return!0}return!1},hm=(t,e,i,n=.5)=>{if(rm(t,e,i)>n)return!1;const s=Math.min(e.x,i.x)-n,r=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>=s&&t.x<=r&&t.y>=o&&t.y<=a},lm=t=>{if(0===t.length)return{minX:0,minY:0,maxX:0,maxY:0};let e=1/0,i=1/0,n=-1/0,s=-1/0;for(const r of t)e=Math.min(e,r.x),i=Math.min(i,r.y),n=Math.max(n,r.x),s=Math.max(s,r.y);return{minX:e,minY:i,maxX:n,maxY:s}},cm=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=cm(t),i=pm(t[0],t[1]),n=pm(t[1],t[2]),s=Math.atan2(t[1].y-t[0].y,t[1].x-t[0].x),r=[{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(s),a=Math.sin(s);return r.map(t=>({x:t.x*o-t.y*a+e.x,y:t.x*a+t.y*o+e.y}))},um=(t,e,i,n=10)=>{if(0===i)return 1;const s=(t.x*e.x+t.y*e.y)/i/i,r=n/i;return s<=0?r:Math.max(s,r)},pm=(t,e)=>{const i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},fm=t=>Math.sqrt(t.x*t.x+t.y*t.y),gm=(t,e)=>({x:e.x-t.x,y:e.y-t.y}),mm=t=>{const e=fm(t);return 0===e?{x:0,y:0}:{x:t.x/e,y:t.y/e}},ym=(t,e)=>{const i=gm(t,e);return mm(i)},xm=t=>({x:-t.y,y:t.x}),bm=(t,e)=>{const i=ym(t,e);return xm(i)},_m=(t,e)=>{const i=mm(t),n=mm(e),s={x:(i.x+n.x)/2,y:(i.y+n.y)/2};return mm(s)},vm=(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},wm=(t,e,i)=>{if(0===pm(t,e))return[];const n=bm(t,e),s=i/2;return[t.x+n.x*s,t.y+n.y*s,e.x+n.x*s,e.y+n.y*s,e.x-n.x*s,e.y-n.y*s,t.x-n.x*s,t.y-n.y*s]},Cm=(t,e,i,n)=>{const s=gm(t,e),r=gm(t,i),o=_m(s,r),a=-o.x,h=-o.y;return{x:t.x+a*n,y:t.y+h*n}},Sm=(t,e,i,n)=>{const s=(t.x-i.x)*(e.y-i.y)-(t.y-i.y)*(e.x-i.x),r=(t.x-n.x)*(e.y-n.y)-(t.y-n.y)*(e.x-n.x);if(s*r>=0)return null;const o=(i.x-t.x)*(n.y-t.y)-(i.y-t.y)*(n.x-t.x);if(o*(o+s-r)>=0)return null;const a=o/(r-s),h=a*(e.x-t.x),l=a*(e.y-t.y);return{x:t.x+h,y:t.y+l}},Am=(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)}),Im=(t,e,i,n,s)=>t.x>=e&&t.x<=e+n&&t.y>=i&&t.y<=i+s,Mm=(t,e,i,n)=>{const s=i/2;return"horizontal"===n?[{x:t-s,y:e},{x:t+s,y:e}]:[{x:t,y:e-s},{x:t,y:e+s}]},Tm=(t,e,i)=>{const n=lm(t),s=lm(e),r=Math.max(0,Math.max(n.minX,s.minX)-Math.min(n.maxX,s.maxX)),o=Math.max(0,Math.max(n.minY,s.minY)-Math.min(n.maxY,s.maxY));if(r>i||o>i)return!1;let[a,h]=[t,e];e.length>t.length&&([a,h]=[e,t]);const l=Math.max(1,Math.floor(i)),c=new Map;for(const t of a){const e=`${Math.floor(t.x/l)},${Math.floor(t.y/l)}`;c.has(e)||c.set(e,[]),c.get(e).push(t)}const d=i*i;for(const t of h){const e=Math.floor(t.x/l),i=Math.floor(t.y/l);for(let n=-1;n<=1;n++)for(let s=-1;s<=1;s++){const r=`${e+n},${i+s}`,o=c.get(r);if(o)for(const e of o){const i=t.x-e.x,n=t.y-e.y;if(i*i+n*n<=d)return!0}}}return!1},Pm=(t,e,i,n)=>{let[s,r]=[t,e];e.length>t.length&&([s,r]=[e,t]);const o=new Set(s),a=n*n;for(let t=0;t<r.length;t++){const e=r[t],s=e%i,h=Math.floor(e/i);for(let t=-n;t<=n;t++)for(let e=-n;e<=n;e++){const n=(h+e)*i+(s+t);if(o.has(n)&&t*t+e*e<=a)return!0}}return!1},Em=(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),s=t=>(i[t]!==t&&(i[t]=s(i[t])),i[t]),r=(t,e)=>{const r=s(t),o=s(e);r!==o&&(n[r]<n[o]?i[r]=o:n[r]>n[o]?i[o]=r:(i[o]=r,n[r]++))};for(const[t,i]of e)r(t,i);const o=s(0);for(let e=1;e<t;e++)if(s(e)!==o)return!1;return!0};class Bm extends Hs{dragStart=null;initialTouchDistance=null;initialScale=null;activeTouches=new Map;firstTouchId=null;secondTouchId=null;zoomFactor=.8;scaleMin=.2;scaleMax=5;originalPosition={x:0,y:0};targetPosition={x:0,y:0};centerPosition={x:0,y:0};originalScale={x:1,y:1};targetScale={x:1,y:1};defaultScale={x:1,y:1};transitionDuration=500;transitionStartTime=null;initialPinchCenter=null;isGestureValid=!0;lastTapTime=0;doubleTapDelay=300;doubleTapZoomFactor=1.5;lastTapPosition=null;tapDistanceThreshold=20;tapDetectionEnabled=!0;isGestureHijacked=!1;hijackedPointerId=null;isHijackPaused=!1;interactionGraphics;viewportBounds;boundResetAnimation;debouncedStopWheelRender;interactionState={isInteracting:!1,isAnimating:!1,interactionTimer:null,renderReasons:new Set};throttledAntiScale;constructor(){super();const t=Zi().getApp();this.viewportBounds=t.getViewportBounds(),this.eventMode="static",this.interactionGraphics=new Tl,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=Ni(t=>{Zi().emitter.emit("antiScale",t)},16,{leading:!0,trailing:!0}),this.boundResetAnimation=this.resetAnimation.bind(this),this.debouncedStopWheelRender=Fi(()=>{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)),Zi().emitter.on("gestureHijackStart",this.handleGestureHijacked),document.addEventListener("pointercancel",()=>{this.clearTouches()})}resetPan(t){const e=Zi(),i=e.getApp(),n=e.appContainer;null!==this.transitionStartTime&&(i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null);const s=this.centerPosition.x-t.x*n.scale.x,r=this.centerPosition.y-t.y*n.scale.y;this.originalPosition={x:n.x,y:n.y},this.targetPosition={x:s,y:r},this.originalScale={x:n.scale.x,y:n.scale.y},this.targetScale={x:n.scale.x,y:n.scale.y};const o=(a=Math.sqrt((n.x-s)**2+(n.y-r)**2),Math.pow(Math.min(1,a/1e3),.5));var a;this.transitionDuration=500+1e3*Math.min(1,Math.pow(o,2)),this.transitionStartTime=i.ticker.lastTime,i.ticker.add(this.boundResetAnimation)}setPanZoom({targetPosition:t,targetScale:e,setCenter:i=!1,setScale:n=!1}={},s=!0){const r=Zi(),o=r.getApp(),a=r.appContainer;if(i&&t&&(this.centerPosition={x:t.x,y:t.y},Qg.debug("[Interaction] Set center position:",this.centerPosition)),n&&e&&(this.defaultScale={x:e.x,y:e.y},Qg.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,!s)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));var h,l,c;const d=.8*(h=Math.sqrt((a.x-this.targetPosition.x)**2+(a.y-this.targetPosition.y)**2),Math.pow(Math.min(1,h/1e3),.5))+.2*(l=a.scale.x,c=this.targetScale.x,Math.pow(Math.min(1,Math.abs(l-c)/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=Zi().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(),Zi().emitter.off("gestureHijackStart",this.handleGestureHijacked),super.destroy()}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}};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=Zi(),e=t.getApp(),i=t.appContainer;if(null===this.transitionStartTime)return;const{targetPosition:n,targetScale:s}=this,r=e.ticker.lastTime,o=Math.min(1,(r-this.transitionStartTime)/this.transitionDuration);if(o>=1)i.position.set(n.x,n.y),i.scale.set(s.x,s.y),this.antiScale(s.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,r=this.originalPosition.y+(n.y-this.originalPosition.y)*t,h=this.originalScale.x+(s.x-this.originalScale.x)*t,l=this.originalScale.y+(s.y-this.originalScale.y)*t;i.position.set(e,r),i.scale.set(h,l),this.antiScale(h)}var a}onWheel(t){const e=Zi();if(this.isGestureHijacked)return void Qg.warn("⚠️ [onWheel] 被手势劫持阻止执行",{isGestureHijacked:this.isGestureHijacked,hijackedPointerId:this.hijackedPointerId,isHijackPaused:this.isHijackPaused});e.getApp().requestRender("wheel",!0),this.debouncedStopWheelRender();const{scaleMin:i,scaleMax:n}=this,s=e.appContainer;t.preventDefault();const r=t.global.x-this.viewportBounds.x,o=t.global.y-this.viewportBounds.y,a=(r-s.x)/s.scale.x,h=(o-s.y)/s.scale.y,l=t.deltaY>0?.95:1.05;let c=s.scale.x*l,d=s.scale.y*l;if(c=Math.max(i,Math.min(n,c)),d=Math.max(i,Math.min(n,d)),c===s.scale.x&&d===s.scale.y)return;const u=r-a*c,p=o-h*d;try{s.scale.set(c,d),s.position.set(u,p),this.antiScale(c)}catch(t){Qg.error("❌ [onWheel] 应用缩放时发生错误:",t)}}onPointerDown(t){const e=Zi();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 s=t.global.x-this.viewportBounds.x,r=t.global.y-this.viewportBounds.y;if(this.activeTouches.set(t.pointerId,{x:s,y:r}),1===this.activeTouches.size)this.firstTouchId=t.pointerId,this.dragStart={x:s,y:r};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=Zi();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;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=Zi(),{interactionConfig:i}=e;if(!i.enableDoubleTapZoom)return;const n=performance.now(),s={x:t.global.x-this.viewportBounds.x,y:t.global.y-this.viewportBounds.y};n-this.lastTapTime<this.doubleTapDelay&&this.lastTapPosition&&pm(s,this.lastTapPosition)<this.tapDistanceThreshold?(this.handleDoubleTap(s),this.lastTapTime=0,this.lastTapPosition=null):(this.lastTapTime=n,this.lastTapPosition=s)}handleDoubleTap(t){const e=Zi(),i=e.getApp(),n=e.appContainer,{scaleMin:s,scaleMax:r,doubleTapZoomFactor:o}=this,a=t.x,h=t.y,l=(a-n.x)/n.scale.x,c=(h-n.y)/n.scale.y;let d=n.scale.x*o,u=n.scale.y*o;d=Math.max(s,Math.min(r,d)),u=Math.max(s,Math.min(r,u)),this.originalPosition={x:n.x,y:n.y},this.originalScale={x:n.scale.x,y:n.scale.y};const p=a-l*d,f=h-c*u;this.targetPosition={x:p,y:f},this.targetScale={x:d,y:u},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 Zi().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=Zi(),i=this.activeTouches.get(t.pointerId),n=e.appContainer,{x:s,y:r}=this.dragStart;n.position.set(n.x+i.x-s,n.y+i.y-r),this.dragStart={x:i.x,y:i.y}}applyPinchZoom(){const t=Zi().appContainer,e=Array.from(this.activeTouches.values());if(e.length<2||!this.initialTouchDistance||!this.initialScale||!this.initialPinchCenter)return;const i=pm(e[0],e[1]),n={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},s=(n.x-t.position.x)/t.scale.x,r=(n.y-t.position.y)/t.scale.y,o=(i/this.initialTouchDistance)**this.zoomFactor,a=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.x*o)),h=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.y*o));t.scale.set(a,h);let l=n.x-s*a,c=n.y-r*h;l+=n.x-this.initialPinchCenter.x,c+=n.y-this.initialPinchCenter.y,t.position.set(l,c),this.antiScale(a),this.initialPinchCenter=n}setInitialScaleAndDistance(t){const e=Array.from(this.activeTouches.values());e.length<2||(this.initialTouchDistance=pm(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 Om=Symbol(),km=Object.getPrototypeOf,Rm=new WeakMap,Dm=(t,e=!0)=>{Rm.set(t,e)},Fm={},Lm=t=>"object"==typeof t&&null!==t,jm=(t,e)=>{const i=Nm.get(t);if((null==i?void 0:i[0])===e)return i[1];const n=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return Dm(n,!0),Nm.set(t,[e,n]),Reflect.ownKeys(t).forEach(e=>{if(Object.getOwnPropertyDescriptor(n,e))return;const i=Reflect.get(t,e),{enumerable:s}=Reflect.getOwnPropertyDescriptor(t,e),r={value:i,enumerable:s,configurable:!0};if(Um.has(i))Dm(i,!1);else if(Gm.has(i)){const[t,e]=Gm.get(i);r.value=jm(t,e())}Object.defineProperty(n,e,r)}),Object.preventExtensions(n)},Gm=new WeakMap,Um=new WeakSet,Nm=new WeakMap,zm=[1],Hm=new WeakMap;let Vm=Object.is,Wm=(t,e)=>new Proxy(t,e),Zm=jm,Jm=(t,e,i,n)=>({deleteProperty(t,e){const s=Reflect.get(t,e);i(e);const r=Reflect.deleteProperty(t,e);return r&&n(["delete",[e],s]),r},set(s,r,o,a){const h=!t()&&Reflect.has(s,r),l=Reflect.get(s,r,a);if(h&&(Vm(l,o)||Hm.has(o)&&Vm(l,Hm.get(o))))return!0;var c;i(r),Lm(o)&&(o=(t=>t&&(Rm.has(t)?Rm.get(t):km(t)===Object.prototype||km(t)===Array.prototype))(c=o)&&c[Om]||o);const d=Gm.has(o)||!Lm(u=o)||Um.has(u)||!Array.isArray(u)&&Symbol.iterator in u||u instanceof WeakMap||u instanceof WeakSet||u instanceof Error||u instanceof Number||u instanceof Date||u instanceof String||u instanceof RegExp||u instanceof ArrayBuffer||u instanceof Promise?o:Wi(o);var u;return e(r,d),Reflect.set(s,r,d,a),n(["set",[r],o,l]),!0}});const Xm="system-ui, -apple-system, sans-serif",Ym=["#d7bb46","#4990d7","#58a789","#749cd7","#f2646c","#91be76","#4ec7b1","#4bb3c8","#e7858a","#7fa96e","#efa667","#a3d774","#6b82d8","#75b551","#b392cd","#ed5454"],Km={global:{containerTop:"0px",containerLeft:"0px",containerWidth:"100%",containerHeight:"100%",backgroundColor:"#f6f6f6"},map:{autoPaddingPercent:.05,obstacleColor:"#999999",freeColor:"#ebebeb"},room:{colors:{active:["#fae9a3","#a6d0fa","#9ce3c8","#d1e2fa","#fed8da","#d4f0c3","#a1f3e4","#a0e5f3","#fee6e8","#c1e5b1","#fee9d7","#e4fad1","#c8d3fa","#b8ea9c","#f0e5f9","#fdc4c4"],inactive:["#fef5d2","#d5e9fe","#c0f2df","#e7f0fe","#fef0f1","#f0fbe9","#ccfbf3","#caf3fc","#fff3f4","#def5d4","#fef1e6","#f2fee7","#e6ebfe","#d5f7c2","#f3e9fb","#fee2e2"],name:Ym,propertyTheme:Ym,selectionIndicatorBackground:Ym,selectionIndicatorIcon:["#ffffff"],[zg.NO_ROOM_DATA]:"#ebebeb",[zg.ROOM_GAP]:"#ebebeb",[zg.OBSTACLE_ROOM]:"#ebebeb",[zg.UNKNOWN_ROOM]:"#ebebeb"},nameLabel:{fontSize:10,fontFamily:Xm,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:Xm,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,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwAgMAAACTeJdcAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAiSURBVDjLY2hgwA5GJUYliJBYhQMwOAwWF45KDEUJXOkKAA7xNyG+w0wTAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAABgAgMAAAAm4hnjAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAjSURBVDjLY1gFBg4MQMAExGBqlDPKoS0HkuoGjXNGOcOVAwDBxwm1N3ts8gAAAABJRU5ErkJggg==","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAPElEQVR4AezXMQoAMAgDwND//9n2B51EhxNcQ7gtJ7NX0wWiAAECBAgQIECAAAECBAgQWCFQb6G3/Sc7FwAA//+f4+OPAAAABklEQVQDAI04ICFaxIVcAAAAAElFTkSuQmCC"],opacity:.1,scale:.2}},path:{lineWidthFixed:!1,incrementalThreshold:5,commonPath:{color:16777215,width:.5},transitionPath:{color:"transparent",width:.5},chargePath:{color:"transparent",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:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAC0FBMVEUAAABd/v9g//9c/v9c/v9d//9d/P9c//9a//9g//9d//9c/v9c//9c/f9b/f9c//9c/P9d///1+fxdoP5c/v9at/vt8vfv8/hbrvzr8PZcpP3s8fbq7/RcqP3v9PlauftbsPxcqv3p7vTy9/rp7vVatvvp7/Zdo/5bs/vs8ffw9vpauvtbtPtcpv7q8PdatPtdov7z+Pvm6/BcrP3y9vlcqf3n7fTo7fPo7PJbsf3x9vvn7PLy9/3m6vDn7fPz+P3w9fnr7/Zc+P/0+f3v8/ru8/nj6O70+PvT2N3q7vTq7/Lu8vbw9Pfc4OTd4ufc4ebj5+vf5Olyrf3f4+fr8fTY3OFbvvzw9fvl6u/i5+3g5eva3+PZ3eKDtvvb3+TW2+Bc2/7r8Pjt8fRb3f5b0v3s8fnm6/Lk6O/z9/3p7fDk6ezV2t/z+f3u8/fn6u3k6fDR1dpb5f5b4f7h5uvL0NXHy9Bc8/9c7f9c4P9oqP1hpf13sfvJzdJc+v/o7O9d1f9d0P9c9f5c6v7Dx8vAxMj3+/9c5/9b2f1axvxhtPyHyfvV6fji7fbi5unAxspcw/5duP283vqo1PnN5fjO09jN0tezt7ujp6tdrP5b1v1czv1awftiuftau/qGufrk7/itzvXX4e27v8OtsLSeoqZcyf5dxv5ouPxqsvxtrPxnu/uy1fjn8Pfc6/eKu/e71vaexfbR4fOryvHN3O/h5ObY297P0NPFyc22u8CQk5b0+f9c1/5cu/5hqv1by/xjrvx/wft8uvui1Pqb0fqSy/qjy/iTwPi9wcWoq66LjpGGiIqAg4Vuv/t0uPus2PrA4Pmcy/l/tPnE2/Th6fLY5fLc5fDh5+/V19m6vL6ws7aanqOUl5pcy/6My/t2wftvsfuZxfmixvLH2e6+0+3T3euXm59bs/3G4/q13PqMw/qfutReYmWIw/lehat+lKpucXTzEWWjAAAAEnRSTlMA3yDvv59gQDAQj8+vgHBQUGCCCRFYAAATkklEQVRo3rWbh1dcRRTGJVRDjBHXjSuIumwWH8YV1rgL7C6dZbObpUgvgpAAAkJIgFSMplhiiqYbS6JJ7C1RY2Lvvffee/8X/O7M7OMNDwyQeA/mHD1Hf373fnPnzpvhuHHH8THTTpgcEREWFm4whIeFxU6JnBoVc/xx/2/EREXGGkaMsMioScccJ5RGTYFGHnmrVi1ZcvHll1+8ZMmCxXmhfxo+JerYK58WGUJeft2TGWedddb5iFN5nF315bwFeZwdEX0s2ZMimdZFC2+//oILAEUIsiaq5i3MY+zJxyrn0ZFM6tyq0y9AjMY9k+I6zo6IPgbYqAgDYu51pyOOREbMuGbVMUFP4tiM08fGRWRknHJ1HqFjjqq2VNl5GecCOnby2Wdz9OQJ2ywqDP/6Exnnjo+LAHou2WzqxLO8MOO0cxHjU5xxNqJqMeV7AgY/EXIX3XHa+LkIAs+cec1KNLRxm+wEyvJZpyHGrxhB5PPOmEuVHl+aITcPchETV4zYCZPFThofd9GpoE5MsQCfN/O886jSYWMmx4B7BZBHrxjwuSDHjNFW4eAmnzY6+am7fntp86ZNb53/zL0ffnjgwc3vPrd2xBrzuBrrakwWO8lA3ORRuE8999L799m658yZk7Pu/N/ri8s2lPb4/ZYtm59dO4JiwGfM2In/4Elj2BLIVskA68gAP3fv/Up3ANCcHPx171+PHRoY7N/qqyzv9Fesv/dZfY0JPGMeLHbiEesbbsj7GdwRFN/17ofxgemJ0wV3Vk5OzaPBg73bBtesHtzqa9iwouX+d+/U1XgG4po8Q3jMkf18XWrqCIq/ubXNZDSCmwhwCoGHoqLYNwB2fWnLfZvXDq8xkefpva3n3g6uTvHdt643xRsB5ooToXlWCqcm8fA39Pf7Gkr9u59fK9cYccopFx+BHAtfpabqFD/17YcJpnjFaOwmcDdSrYLBFZE2y97V39uwoWLdtTOlGgPMyaNzJxsMlwM7XPHy9525pJcUM8lccIqWC3BRWlpLQ39vZalp051yjQEm8gn/YejFJ5+sU/zyB7NNpngCdxO5EGzUWA9GxKUFuvp99R3rn5VrTOSVsPaoBc67AVxZ8VMPuswJBAZ6OoHBBVivmLiItI7e3q7SLc/LNUbcdNloZY6AsU4ervju79PNCSgwShyvTJ9O7ipMTAE4h4NlwSySglt9xS2/rpVqjIC1I0biTkWBwZUVL78NegEmvVAMMIIEzwmBU7SCEZfirxW9vcGKLTdLNUYsNBii9Nzjww2Lzj15iKxyOZjQRGUrGQHF1cTVgOMEGBHo8tX7192jrTGiaiVLtt7R16tchOCmExieptWkoMZGYAtTCgoo1TkEzpQFi5jV4Gvw/3KzWmM12ZG6VmkwXAUswILMuPZ0pzlhNhQzWyOguBB6C6A4E7keDQyPlfjqQZbBZ1xlMEzSO+sGBv52V0jx0oft6RA8G2DGVQhMAXLKdCimIqtgHbm4K1jx64yZEvgmnb+iubMQD94qFCf/UONKd6abZwtzgUxgKGYhg4lbFDdMc2V5/PMzZMnMX7LgvHM5+MCDQvF3Xgh2mlFjRLyJrSdKNUKQCZwiwDrFWFb1DWWBayXuGTethGRZ8BUn8/joYa74vT67C4pRY/QPAtN6UsEpBYk6xQDLkVNZWbr7TQl8Bjpn9IiCU3s+YtylP9ZAMNWY25qqHKB9QuQ6BWCydWZmpg6shr+pcsU7MvgmydiThgQvK+1MJvJDXrurI50rFuvJiGDgQp5pBCkWkqnGuiitrG/5SiYvgLG1a/hcAV76yIal4L5XV+NyprtI8Gz/bIBJsELdOlTiggIuWXJ1/vAyNzaV33+zhitLRtPCGhbg4CN3p6Yu+97rQYXTHU6zZh2LrpnIUy1ynTQ6GFFR2dSxWQKfs8AQrrHW9Sq4Prg8NfmBOg+sRaZ2mv0JCIChl4HRMwuZaC45ya3mmvdLOcoqS9a/KYFvNBim6awF8MGDu5hge1YWgallcsViIQONplnIwdVUZbdblayPWZWVK96WJV9GuRaZvhhIHhd+8snLqbsgGGBKNc+1ie9PPNSVDMW8a4JMQWC9vxqKd9+j5SLXBn5kj0Kmh8CPPrp/2Q9eu70tywmwmcBmArOFzLdkyMVPgSADDbKYfeRk4+8guaHjeQn8dKh7TTHknTwEHnh0//KydrvHRYotoZZJtmbR3U0LakiyOg5kAlxUNILovnoYWws+Z6VhCgMj0xrw6tUvPVQ7385S7XLQcgI6t0KAFWCZwYTiaoFGUJlHIgcqG/zXSpJXcV9PwsSjAb/yyq0/ej2oscPJwRZaTnzqChgFGKJVyehdgh5KtxxFJZWlmyTF2JZjeIkzNOBPP324rB3cNkdWutNipolL2JqWFMgAUxSEyDmhYGRKuLbEiJrK4Pp7tOBreJEjUWINePv28tp2KOY1BtiSwNgAk6/5OFCIlaxGDiZtRABosEn08BXVhFxrwGJBhRmWaMDL9+6t99ZAscsBMEs1aqxuyfhhq4lyLaIAZ4vuAGJF/8Y1g+W6YQS5bip9W8r1YkMsVjFKrAXv2FHs9bQBnEWpZuCQrZFqAsPXFCEsuMZAoGL1jn17Nm7cePjVNTVJw7aLzqbguuu1iufSSo7B8VADvmjfqyhxm4crtjjJXCBXJOSCC9WhHUp1NswWiK/w7djeW+exKIqjduv2wZyi4buj6R4VLNwlewvgL/b2wVvCXA4HV2w1wddwlzr+hDTjT6TfP7hvoNZhyWozm0w2k7d/T0AeOZu6UGQNGO6aRnN8shb82J4+WCuUagIn+GlbFL6mKUSQYbFC4pr8g59vs1tK6hrrXM66hhqb2bcmR5q+Gn09L2hrXIUDnGxqgF/vr53vYeZywFwAW5Frq4ncJbYokNUgcELwsUMeS2Kjw2JrLVQs7U4loXebVnJRmW/D2yqX23oyGuZiCfxGQy243NVZTjRrgHFaRO+iQO/ScV079nodKUarxWIrKFCsNqVA8WzskDaKrpJ3tOBbFmPkizUskcHF3vlwNYGd2wbbnGaLJYGKrLYQCg3YZG54o9fhMVusVoBbbTZFaW22lfRrwTWwtaSYwGHo1FKqi2kZe1iqfb0OgK2scYnmpaCFDBP86k+1li6nBWSArc3NzTa7teaVJA24o6l+vbbGtywwhOnAr5WjU3u44sE1bdgXheJcJZ4yLfYJwTWaZnu++MzcVga9iAIIttls7e3NA3bUtqejk/ErmuqtkmICh+MIIbm6zAtzMVc7fdvasB1bZnMwJBNaay+Azd5/9lTbra2KYttaZ3b4bM2KYvUqJYNxRR1XXnnlijkM3NAi1Xgh9ieD4UY92M5c7az0uaBYXcgUonkJzUbFZO77Y/vj3urHL812H+o73NerFLS2Gpta7YNxLXFzZs2JKwW4paleAlPrGh2c5XAO7MlywFzItc1q4jMu9ZD46UI09gwGdtcaq92Z1avLttm78rPd7mpPtXcgbs6cK68smtXDwQGpxgDrUo0a1wjFWT4fzT5WgMHl8w8DGxlZgL1v7LGZE6jEJZ5Wc3s+8puT/rjPF1fUsqKlp6eIDbnBgKSYUq03F1PcRoq39meZ0UHI1jYTSbahyuACyshGqrH98x3tZgWmtijVilWpzn78ypru/EOzLoW70ri3/ZUlu1Ww6mr9cpovXJ3VNNCGORNg5NqUm5sr3EVkIwUpTnCtea3Y4TKDjFVsBdnttj/u36htXSsaytfrXB1huEpuICVItVhO5jqa6Dk4F8nOhVw+DYhA2hPMda+vznLWmS3oWABbW6uVAjcyna9pII1lW6QarzLE6sCv+3ivtjvY7CM6CBRTlRlYCRBSI3nPT/UOrw+Cm9FDrLbqgmrvmhzNnFtU2rhhk6R4EebMyfImseu1Q7WqYoAtIbCNvJWrMGML8nQCQ7J33/Y+x/yNXitlOjGttdW+plzeJBp7Nks1ptnnhGHb4heHa9vZ6ONk+yJmENiGu6sC7oJk1r+0kp11+w6XmVo9jX2t1ZmJNmvtxq40IVh8cQv6X9SCsS1OPW7asEFg3946gNkEwlItbA01MBeKLA6OtJanh8jmsh17m5yKLReptnm6DnclSeA5jcGWN3VjJkafJzXg9159tcyr1jjdQnOmVbQQ6l6KYtL6S5Bnu9b8tL2/rq6vrGzg8Ct2jLj5WlM3lu++WTf6HC+3ruWffRakhRwautQik2GpyAopJvZQKPS/lL56777PP9/x2erOFMyZ4Gq8FcRErwVfzY5tsbC1NNAXk7uoZWa50h2iyDgwwq+skzBjGzVkamBsDpxO430KHaKkE3pSY2OHNPngDBOmH+hfWXNbnTc0gjCwk8CzUT34iyTHy5qpdSIC9LER5KQkd1FctvRVoLGk4mtproap9UeY1QP7S7xi6BLriXdrgK3oXbZmLZZ/RwabfdTNRCRlp6Vl50tjdXDDupv1Rxh5sKZj6gM/8FzDXQRWe5cNSwq+bobkITQBKQoht5pxs9Muzc+WFxMyrQWjxJP4MXWJBvzo1l0v97XzfZHmTA624oumDaIBVu0ljlFAEjwFgt1u9yVuOCtfq7ijpPy+NyWw+PyCOXORBtz7ya6lOKcSmI5tZnaK4ZJ5+7Khylyzqhg/BZRoIhNYSnV5cQ9GTA0ZJZ4ywqeITw6+l/pdbWh/IsUIKzKekIs6U8dm9lLELsXPygXgAgzB2VTibA25ori84toRP0VgJWs/vhw8eGHq3be1o8bINbkL9uJTiNijcm3NpFgJSYZeCnBBznZfghIjhgSXd+LEpgUj08cDKy0ogBuCF6YmP1QLMC+yxeHguabDKrNXLnUvlDqUazIWCRaKLyHB+UWC64fgr6RMV12mfsCdhq6pgoMAk+SQu8y0M3JfI6hji1yHJKvf+YRid3Y+kUOfy4s7150yQ0t+mn+/lT+/APzII1CcjCoDzHMNyQCLXFMTsQkyB2MZgypSDbIbVKDFGi4pxydrSfFiNdPItbgXQNxN4NTkZQ/jYyZtyaxdC18jrIysNNMfRvUKjMgFbDWR5EuyAc7ntzHBko5NsuAq7UOJSUP2WrqBfb1NvqjOo+YaYEgG2RKS3ExrWUimb5tcspuKDHY2JZs0JxWXlO6+Z4YEnsu6h17y0s6epakgn/YQk+xwka+ZvSwCTGTYS811NykuwI1QCinmyWbsuKI+JPor+W5AWEt/NbCsp2cZKUay2/kUku6g7sXAZG0h2TZEBpcF5TozG1TCErgjWOzfJHNJcLR8GbJISJ7vEbcwy8tYvxY7FMs1fgC2ypLF5RsVGcHLzNgVweKedfeMJlhElHr9c+BA6N7pgVoPndyIjOkaVAS3F5ayTZVMYLroTFTBtJYvzW5pLO687+uZMnghBI9y4fXgg+pN2/6PaUkNSbYQ2cLnTZstXgUTGT8CjGSnQXJ8Q0mp7Vrt3SJCf+EFY4s96oGX1bvFZQ/VItlOdQCygM2rjFMFqiyWlLgfSUFALzkbiv3g3vfiTJl7xmIatoZFpNiWk9W7RSK327NCAxAniyrncnsr0Awwi8RMSGZc+NoFbjy4MvhpWsP6+3Jc48q3qSDf6vVkYUmZIZn5SyQbfdOk2NTGSVgaBKpT3IS+JKmuvrgz8MLw++OqlZqmpfeXRjHI+5FtNl/z9mURUxBJZsYWmo2FYvKhXHfXN5b3KNeSXkkyltLUUa7qr5MVUzzwMRoJb18OYImMNLOUN5s0yWZFzqTo7Cop89//9UwKLXcnnDX64wT9q4jlD89vc4LMzhR8u7DizIC5QPhL4ZczmAYyMXUlVDaVlLZsuRNQYMfwOAFxIp6P6RTj+cmtWFYg0+cQglv4eI8ygxwPKjQzMN4OmBp9jeUrbM+vld+BUCyiJTz6Q70rdIrx4mbXAY+dkZ1kbnGU4tM9yK1GwNk3bHOjD65q2fLs8Lc+VOD/fL4XBrJOMcjP7P/I43KSXt5JwESyIZyyTZrpo0RdF2H9u19Yy7gstE9uYo/wyIjI+tdN31C+HeASWVhbzEJYUYqzuKu3K1jWU3Hf23fq3nMBvHMsz5vu0Cum+Oalj9gtGJWargtwJiVygr2uyde/zVdfXtoRWL/5Tv17LoDnEXcMD8n0ilk88/L789tcVGgL0JaE9b9/cWjj6oFtvspgWWlHS2DLi2tHeLM3todksLbm6Zz+zd5d377/gQtspwMZf+7vgcaS4rLSzhX+lvgteL2mf7OnPp2LHttjwS85WE9GPPPcS/ce+OADh+Pe8x9w+f3+BPP972z+c+3I7zIJfPWYHgsiovE8cl7yf7/LfOaut97Cu8y7fnvx2bfu+s93mcQNP3HsD0KfYNSje3vLAtywmPE8gV2ccSxeolat5H4eMzkWFvvy6N/ewlbj4iIms2fOR6cYIyXd84wzounF8ZNHU+N5lOYTJ/iU/aqMiSquumqCT9kRU8NZvidS4yrKcljUhH/vhiqdN+/88SquuhpZNkRC7oQjJoKjx0PGh3+e5aOLaKBR66rzx8h9mmNFlo8eTb+Ec2TyNfyXcCKjj9WvHU0O5+wbrx+dW3XjAlQWjfloaqu3WXQE2ARfeOPtT54pk8+uumPnKkhlYukB0f/4q2WLF+BXy3buxK+WrVr1//5qmch5VGSYYcSIjYzS7UHHWnlM1NTIKbGhXx+MiJh8wrSY8Sv9F+RaDBk7fzBtAAAAAElFTkSuQmCC"},speed:0,rotationCorrection:0,sleepAnimation:{jsonSrc:"data:application/json;base64,eyJmcmFtZXMiOiB7Cgoic2xlZXBfMDAwLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDAxLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6ODAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzAwMi5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjE2MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDAzLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMDQucG5nIjoKewoJImZyYW1lIjogeyJ4IjozMjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzAwNS5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjQwMCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDA2LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6ODAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzAwNy5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjgwLCJ5Ijo4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDA4LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MTYwLCJ5Ijo4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDA5LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDEwLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MzIwLCJ5Ijo4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDExLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6NDAwLCJ5Ijo4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDEyLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6MTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMTMucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6MTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMTQucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjE2MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDE1LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5IjoxNjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzAxNi5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6MTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMTcucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjE2MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDE4LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6MjQwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMTkucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6MjQwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMjAucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjI0MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDIxLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5IjoyNDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzAyMi5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6MjQwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMjMucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjI0MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDI0LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6MzIwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMjUucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6MzIwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMjYucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjMyMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDI3LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5IjozMjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzAyOC5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6MzIwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMjkucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjMyMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDMwLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6NDAwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMzEucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6NDAwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMzIucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjQwMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDMzLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo0MDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzAzNC5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6NDAwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMzUucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjQwMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDM2LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6NDgwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMzcucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6NDgwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wMzgucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjQ4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDM5LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo0ODAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA0MC5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6NDgwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNDEucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjQ4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDQyLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6NTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNDMucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6NTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNDQucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjU2MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDQ1LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo1NjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA0Ni5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6NTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNDcucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjU2MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDQ4LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6NjQwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNDkucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6NjQwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNTAucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjY0MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDUxLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo2NDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA1Mi5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6NjQwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNTMucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjY0MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDU0LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6NzIwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNTUucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6NzIwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNTYucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjcyMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDU3LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo3MjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA1OC5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6NzIwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNTkucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjcyMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDYwLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6ODAwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNjEucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6ODAwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNjIucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjgwMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDYzLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo4MDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA2NC5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6ODAwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNjUucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjgwMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDY2LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6ODgwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNjcucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6ODgwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNjgucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjg4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDY5LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo4ODAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA3MC5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6ODgwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNzEucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjg4MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDcyLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6OTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNzMucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo4MCwieSI6OTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNzQucG5nIjoKewoJImZyYW1lIjogeyJ4IjoxNjAsInkiOjk2MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDc1LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5Ijo5NjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA3Ni5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjMyMCwieSI6OTYwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wNzcucG5nIjoKewoJImZyYW1lIjogeyJ4Ijo0MDAsInkiOjk2MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDc4LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6MTA0MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDc5LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6ODAsInkiOjEwNDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA4MC5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjE2MCwieSI6MTA0MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDgxLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5IjoxMDQwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wODIucG5nIjoKewoJImZyYW1lIjogeyJ4IjozMjAsInkiOjEwNDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA4My5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjQwMCwieSI6MTA0MCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDg0LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6MTEyMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDg1LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6ODAsInkiOjExMjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA4Ni5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjE2MCwieSI6MTEyMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDg3LnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5IjoxMTIwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wODgucG5nIjoKewoJImZyYW1lIjogeyJ4IjozMjAsInkiOjExMjAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA4OS5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjQwMCwieSI6MTEyMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDkwLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MCwieSI6MTIwMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDkxLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6ODAsInkiOjEyMDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA5Mi5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjE2MCwieSI6MTIwMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9LAoic2xlZXBfMDkzLnBuZyI6CnsKCSJmcmFtZSI6IHsieCI6MjQwLCJ5IjoxMjAwLCJ3Ijo4MCwiaCI6ODB9LAoJInJvdGF0ZWQiOiBmYWxzZSwKCSJ0cmltbWVkIjogZmFsc2UsCgkic3ByaXRlU291cmNlU2l6ZSI6IHsieCI6MCwieSI6MCwidyI6ODAsImgiOjgwfSwKCSJzb3VyY2VTaXplIjogeyJ3Ijo4MCwiaCI6ODB9LAoJImFuY2hvciI6IHsieCI6MC41LCJ5IjowLjV9Cn0sCiJzbGVlcF8wOTQucG5nIjoKewoJImZyYW1lIjogeyJ4IjozMjAsInkiOjEyMDAsInciOjgwLCJoIjo4MH0sCgkicm90YXRlZCI6IGZhbHNlLAoJInRyaW1tZWQiOiBmYWxzZSwKCSJzcHJpdGVTb3VyY2VTaXplIjogeyJ4IjowLCJ5IjowLCJ3Ijo4MCwiaCI6ODB9LAoJInNvdXJjZVNpemUiOiB7InciOjgwLCJoIjo4MH0sCgkiYW5jaG9yIjogeyJ4IjowLjUsInkiOjAuNX0KfSwKInNsZWVwXzA5NS5wbmciOgp7CgkiZnJhbWUiOiB7IngiOjQwMCwieSI6MTIwMCwidyI6ODAsImgiOjgwfSwKCSJyb3RhdGVkIjogZmFsc2UsCgkidHJpbW1lZCI6IGZhbHNlLAoJInNwcml0ZVNvdXJjZVNpemUiOiB7IngiOjAsInkiOjAsInciOjgwLCJoIjo4MH0sCgkic291cmNlU2l6ZSI6IHsidyI6ODAsImgiOjgwfSwKCSJhbmNob3IiOiB7IngiOjAuNSwieSI6MC41fQp9fSwKImFuaW1hdGlvbnMiOiB7Cgkic2xlZXAiOiBbInNsZWVwXzAwMC5wbmciLCJzbGVlcF8wMDEucG5nIiwic2xlZXBfMDAyLnBuZyIsInNsZWVwXzAwMy5wbmciLCJzbGVlcF8wMDQucG5nIiwic2xlZXBfMDA1LnBuZyIsInNsZWVwXzAwNi5wbmciLCJzbGVlcF8wMDcucG5nIiwic2xlZXBfMDA4LnBuZyIsInNsZWVwXzAwOS5wbmciLCJzbGVlcF8wMTAucG5nIiwic2xlZXBfMDExLnBuZyIsInNsZWVwXzAxMi5wbmciLCJzbGVlcF8wMTMucG5nIiwic2xlZXBfMDE0LnBuZyIsInNsZWVwXzAxNS5wbmciLCJzbGVlcF8wMTYucG5nIiwic2xlZXBfMDE3LnBuZyIsInNsZWVwXzAxOC5wbmciLCJzbGVlcF8wMTkucG5nIiwic2xlZXBfMDIwLnBuZyIsInNsZWVwXzAyMS5wbmciLCJzbGVlcF8wMjIucG5nIiwic2xlZXBfMDIzLnBuZyIsInNsZWVwXzAyNC5wbmciLCJzbGVlcF8wMjUucG5nIiwic2xlZXBfMDI2LnBuZyIsInNsZWVwXzAyNy5wbmciLCJzbGVlcF8wMjgucG5nIiwic2xlZXBfMDI5LnBuZyIsInNsZWVwXzAzMC5wbmciLCJzbGVlcF8wMzEucG5nIiwic2xlZXBfMDMyLnBuZyIsInNsZWVwXzAzMy5wbmciLCJzbGVlcF8wMzQucG5nIiwic2xlZXBfMDM1LnBuZyIsInNsZWVwXzAzNi5wbmciLCJzbGVlcF8wMzcucG5nIiwic2xlZXBfMDM4LnBuZyIsInNsZWVwXzAzOS5wbmciLCJzbGVlcF8wNDAucG5nIiwic2xlZXBfMDQxLnBuZyIsInNsZWVwXzA0Mi5wbmciLCJzbGVlcF8wNDMucG5nIiwic2xlZXBfMDQ0LnBuZyIsInNsZWVwXzA0NS5wbmciLCJzbGVlcF8wNDYucG5nIiwic2xlZXBfMDQ3LnBuZyIsInNsZWVwXzA0OC5wbmciLCJzbGVlcF8wNDkucG5nIiwic2xlZXBfMDUwLnBuZyIsInNsZWVwXzA1MS5wbmciLCJzbGVlcF8wNTIucG5nIiwic2xlZXBfMDUzLnBuZyIsInNsZWVwXzA1NC5wbmciLCJzbGVlcF8wNTUucG5nIiwic2xlZXBfMDU2LnBuZyIsInNsZWVwXzA1Ny5wbmciLCJzbGVlcF8wNTgucG5nIiwic2xlZXBfMDU5LnBuZyIsInNsZWVwXzA2MC5wbmciLCJzbGVlcF8wNjEucG5nIiwic2xlZXBfMDYyLnBuZyIsInNsZWVwXzA2My5wbmciLCJzbGVlcF8wNjQucG5nIiwic2xlZXBfMDY1LnBuZyIsInNsZWVwXzA2Ni5wbmciLCJzbGVlcF8wNjcucG5nIiwic2xlZXBfMDY4LnBuZyIsInNsZWVwXzA2OS5wbmciLCJzbGVlcF8wNzAucG5nIiwic2xlZXBfMDcxLnBuZyIsInNsZWVwXzA3Mi5wbmciLCJzbGVlcF8wNzMucG5nIiwic2xlZXBfMDc0LnBuZyIsInNsZWVwXzA3NS5wbmciLCJzbGVlcF8wNzYucG5nIiwic2xlZXBfMDc3LnBuZyIsInNsZWVwXzA3OC5wbmciLCJzbGVlcF8wNzkucG5nIiwic2xlZXBfMDgwLnBuZyIsInNsZWVwXzA4MS5wbmciLCJzbGVlcF8wODIucG5nIiwic2xlZXBfMDgzLnBuZyIsInNsZWVwXzA4NC5wbmciLCJzbGVlcF8wODUucG5nIiwic2xlZXBfMDg2LnBuZyIsInNsZWVwXzA4Ny5wbmciLCJzbGVlcF8wODgucG5nIiwic2xlZXBfMDg5LnBuZyIsInNsZWVwXzA5MC5wbmciLCJzbGVlcF8wOTEucG5nIiwic2xlZXBfMDkyLnBuZyIsInNsZWVwXzA5My5wbmciLCJzbGVlcF8wOTQucG5nIiwic2xlZXBfMDk1LnBuZyJdCn0sCiJtZXRhIjogewoJImFwcCI6ICJodHRwczovL3d3dy5jb2RlYW5kd2ViLmNvbS90ZXh0dXJlcGFja2VyIiwKCSJ2ZXJzaW9uIjogIjEuMSIsCgkiaW1hZ2UiOiAic2xlZXAucG5nIiwKCSJmb3JtYXQiOiAiUkdCQTg4ODgiLAoJInNpemUiOiB7InciOjQ4MCwiaCI6MTI4MH0sCgkic2NhbGUiOiAiMSIsCgkic21hcnR1cGRhdGUiOiAiJFRleHR1cmVQYWNrZXI6U21hcnRVcGRhdGU6NjYyMDEzY2I2NDMwZGNjYWFjM2ExYTBiYjVlOTc4MzM6NTE3ZDlkN2RjOGI2MDBkMmQ2ZWIyOTVjMzc5ZTJmZmI6ZmViYzA4ZWVlMDM4NjliMDAwNmM5ZmQxNWI3NDMzOTkkIgp9Cn0K",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:Xm,textFontWeight:"400",unitLabel:"m",forbiddenSweepZone:{minSize:1,iconWrapperFillColor:"#ff4444",strokeColor:"#ff4444",strokeWidth:2,fillColor:"rgba(255, 68, 68, 0.1)",outlineOffset:20,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",textColor:"#ff4444",textPosition:"bottom",textOffset:10,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:20,outlineStrokeColor:"#fe8a07",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(254, 138, 7, 0.05)",textColor:"#fe8a07",textPosition:"bottom",textOffset:10,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:20,outlineStrokeColor:"#5d68fe",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(93, 104, 254, 0.05)",textColor:"#5d68fe",textPosition:"bottom",textOffset:10,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},virtualWall:{iconWrapperFillColor:"#ff4444",lineWidth:2,lineColor:"#ff4444",hitAreaThickness:30,outlineOffset:20,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",minWidth:1,textColor:"#ff4444",textOffset:10,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:10,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:window?.devicePixelRatio||1}},qm={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},Qm=["areRoomsAdjacent","resetPanZoom","getForbiddenSweepZones","getForbiddenMopZones","getCleanZones","getVirtualWalls","getSpots","getViewportCenterPoint","getMapCenterPoint","getWallPointsByViewportCenter","getForbiddenSweepZonePointsByViewportCenter","getForbiddenMopZonePointsByViewportCenter","getCleanZonePointsByViewportCenter","getSpotPointByViewportCenter","getEffectiveDividerPoints","getDividerEndPoints","snapshot","snapshotByData"],$m=["onMapFirstDrawed","onMapDrawed","onPathDrawed","onRoomPropertiesDrawed","onClickRoom","onClickRoomProperties","onRemoveForbiddenSweepZone","onRemoveForbiddenMopZone","onRemoveCleanZone","onRemoveVirtualWall","onUpdateForbiddenSweepZone","onUpdateForbiddenMopZone","onUpdateCleanZone","onUpdateVirtualWall","onUpdateSpot","onUpdateDivider","onClickForbiddenSweepZone","onClickForbiddenMopZone","onClickCleanZone","onClickVirtualWall","onClickSpot","onClickDetectedObject","onClickCustomElement"],ty="MAIN",ey=5e3;class iy{static contextStack=[];static instanceMap=new Map;static serviceCache=new WeakMap;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 ny,this.serviceCache.set(t,e)),e}static provide(t,e){this.contextStack.push(t);try{return e()}finally{this.contextStack.pop()}}static async provideAsync(t,e){this.contextStack.push(t);try{return await e()}finally{this.contextStack.pop()}}static useContext(){const t=this.contextStack[this.contextStack.length-1];if(!t){const t=this.instanceMap.get(ty);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(ty)}static clear(){this.contextStack.length=0,this.instanceMap.clear()}}class ny{getApp(){return iy.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=Gm.get(t),[i,n]=e;return Zm(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}}class sy extends Hs{viewportBounds={x:0,y:0,width:0,height:0};maskGraphics=null;containerElement=null;constructor(t,e){super(),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:s}=t,{width:r,height:o}=this.getContainerSize(),a=this.parseSize(i,r),h=this.parseSize(e,o),l=this.parseSize(n,r),c=this.parseSize(s,o);this.viewportBounds={x:a,y:h,width:l,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 Tl,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}return t.endsWith("rpx")?parseFloat(t)*(window.innerWidth/750):t.endsWith("px")||!isNaN(parseFloat(t))?parseFloat(t):(Qg.warn(`Cannot parse size value: ${t}`),0)}getViewportBounds(){return{...this.viewportBounds}}updateViewport(t){this.calculateViewportBounds(t.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),this.maskGraphics?.clear(),this.maskGraphics?.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215)}addContent(t){this.addChild(t)}}const ry="roomFill",oy="free",ay="roomFloorType",hy="carpet",ly="obstacle",cy="heatmap",dy="path",uy="controls",py="roomInfo",fy="detectedObject",gy="customElement",my="customElementGif",yy="chargingStation",xy="robot",by=["interaction",ry,oy,ay,hy,ly,cy,dy,py,fy,gy,my,yy,xy,uy];class _y extends Hs{layers=new Map;constructor(){super();const t=Zi().getApp().getViewportBounds();this.position.set(Math.round(t.width/2),Math.round(t.height/2)),this.initializeLayers()}initializeLayers(){Object.values(by).forEach(t=>{const e=new Hs;e.label=t,t===uy&&(e.isRenderGroup=!0),t!==ay&&t!==hy||(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):(Qg.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 vy extends Tl{constructor(){super(),Zi().appContainer.addToLayer(ly,this)}draw(t){const e=Zi();this.clear(),this.setFillStyle({color:e.mapConfig.obstacleColor});for(const e of t){const t=e.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=Zi();if(this.clear(),0!==t.length){this.setFillStyle({color:i.mapConfig.obstacleColor});for(let n=0;n<t.length;n+=ey){const s=Math.min(n+ey,t.length);for(let i=n;i<s;i++){const n=t[i],s=n%e,r=Math.floor(n/e);this.rect(s,r,1,1)}this.fill(),s<t.length&&this.setFillStyle({color:i.mapConfig.obstacleColor})}}}destroy(t){super.destroy(t)}}class wy extends Tl{constructor(){super(),Zi().appContainer.addToLayer(oy,this)}draw(t){const e=Zi();this.clear(),this.setFillStyle({color:e.mapConfig.freeColor});for(const e of t){const t=e.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 Cy{target;isPointerDown=!1;pointerDownPos=null;clickThreshold;stopPropagation;clickCallback=null;constructor(t,e={}){this.target=t,this.clickThreshold=e.clickThreshold??10,this.stopPropagation=e.stopPropagation??!1,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 Sy extends Hs{roomGraphicsMap=new Map;roomContextMap=new Map;roomClickHandlerMap=new Map;unsubscribeFns=[];mapWidth=0;rasterRoomDataMap=new Map;constructor(){super({isRenderGroup:!0}),Zi().appContainer.addToLayer(ry,this)}draw(t){const e=Zi();this.clearRooms();const i=e.roomConfig,{selectRoomIds:n,enableRoomSelection:s}=e.runtimeSnapshot;t.forEach((t,e)=>{const r=t.id>=255,o=new Tl,a=new lh,h=new lh;if(r)a.setFillStyle({color:t.color}),h.setFillStyle({color:t.color});else{const t=e%i.colors.active.length,n=e%i.colors.inactive.length,s=i.colors.active[t],r=i.colors.inactive[n];a.setFillStyle({color:s}),h.setFillStyle({color:r})}if(a.poly(t.polyPoints).fill(),h.poly(t.polyPoints).fill(),t.outlinePoints.forEach(t=>{a.rect(t.x,t.y,1,1).fill(),h.rect(t.x,t.y,1,1).fill()}),o.context=r?a:s&&!n.includes(t.id)?h:a,!r){const e=new Cy(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:h}),this.addChild(o)})}drawRaster(t){const e=Zi();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:s,activeColor:r,inactiveColor:o}=t,a=new Tl,h=new lh,l=new lh;h.setFillStyle({color:r}),l.setFillStyle({color:o}),this.drawPixelPointsInBatches(h,s,ey,this.mapWidth),this.drawPixelPointsInBatches(l,s,ey,this.mapWidth);const c="number"==typeof n,d=!e||c&&i.includes(n);if(a.context=e&&c&&!d?l:h,c){const t=new Cy(a,{clickThreshold:10,onClick:()=>{this.handleRoomClick(n)}});this.roomClickHandlerMap.set(n,t)}this.roomGraphicsMap.set(n,a),this.roomContextMap.set(n,{activeContext:h,inactiveContext:l}),this.rasterRoomDataMap.set(n,t),this.addChild(a)}drawPixelPointsInBatches(t,e,i,n){for(let s=0;s<e.length;s+=i){const r=Math.min(s+i,e.length);for(let i=s;i<r;i++){const s=e[i],r=s%n,o=Math.floor(s/n);t.rect(r,o,1,1)}t.fill()}}handleRoomClick(t){const e=Zi();e.events?.onClickRoom?.(e.getRoomData(t)??{id:t})}setRoomStateBySelectIds(t){const e=Zi(),{enableRoomSelection:i}=e.runtimeSnapshot;this.roomGraphicsMap.forEach((e,n)=>{if("number"==typeof n){const s=!i||t.includes(n),r=this.roomContextMap.get(n);r&&(e.context=s?r.activeContext:r.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):Qg.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(t){Qg.warn("Error destroying click handler:",t)}}),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 Ay extends Hs{carpetSprite=null;carpetMask=null;constructor(){super({isRenderGroup:!0}),Zi().appContainer.addToLayer(hy,this)}async createCarpetFromRasterData(t,e){const i=Zi();if(!i.runtimeSnapshot.showCarpet)return;if(this.clearCarpet(),0===t.length)return;const{src:n,opacity:s,scale:r}=i.carpetConfig,o=await al.load(n);if(!o)return void Qg.warn(`Carpet texture not found: ${n}`);const a=this.createCarpetGraphics(t,e),h=a.getLocalBounds();if(0===h.width||0===h.height)return;const l=new Dl({texture:o,width:h.width,height:h.height});l.x=h.x,l.y=h.y,l.alpha=s,l.tileScale.set(r);const c=new Hs;c.addChild(a),l.mask=c,this.addChild(l),this.carpetSprite=l,this.carpetMask=c,i.getApp().renderOnceNextFrame()}createCarpetGraphics(t,e){const i=new Tl;for(let n=0;n<t.length;n++){const s=t[n],r=s%e,o=Math.floor(s/e);i.rect(r,o,1,1)}return i.fill(16777215),i}clearCarpet(){if(this.carpetSprite){try{this.removeChild(this.carpetSprite),this.carpetSprite.destroy()}catch(t){Qg.warn("Error destroying carpet sprite:",t)}this.carpetSprite=null}if(this.carpetMask){try{this.carpetMask.destroy()}catch(t){Qg.warn("Error destroying carpet mask:",t)}this.carpetMask=null}}async createCarpetFromStructuredData(t){const e=Zi();if(!e.runtimeSnapshot.showCarpet)return;if(this.clearCarpet(),0===t.length)return;const{src:i,opacity:n,scale:s}=e.carpetConfig,r=await al.load(i);if(!r)return void Qg.warn(`Carpet texture not found: ${i}`);const o=this.createCarpetGraphicsFromStructuredData(t),a=o.getLocalBounds();if(0===a.width||0===a.height)return;const h=new Dl({texture:r,width:a.width,height:a.height});h.x=a.x,h.y=a.y,h.alpha=n,h.tileScale.set(s);const l=new Hs;l.addChild(o),h.mask=l,this.addChild(h),this.carpetSprite=h,this.carpetMask=l,e.getApp().renderOnceNextFrame()}createCarpetGraphicsFromStructuredData(t){const e=new Tl;for(const i of t){const t=i.coordinates;for(let i=0;i<t.length;i+=2){const n=t[i],s=t[i+1];e.rect(n,s,1,1)}}return e.fill(16777215),e}destroy(){this.clearCarpet(),super.destroy()}}class Iy extends Hs{throttledUpdateScale;constructor(){super(),this.throttledUpdateScale=Ni(this.updateScale.bind(this),30,{leading:!0,trailing:!0});const t=Zi();this.updateScale(t.currentScale),this.registerScaleListener()}registerScaleListener(){Zi().emitter.on("antiScale",this.throttledUpdateScale)}updateScale(t){0!==t&&this.scale.set(1/t)}destroy(t){Zi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class My extends Ws{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;sizeFixed=!0;baselineScale=1;constructor(t){super(t),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ni(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?Qg.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置宽度"):this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet?Qg.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置高度"):this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){Zi().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||0===this.texture.width||0===this.texture.height)return;const t=Zi(),e=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const n=t.currentScale;if(0===n)return;const s=e/n,r=i/n;super.scale.set(s,r)}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))}async loadTextureAndSetSize(t,e){try{const i=Zi(),n=await al.load(t);this.texture=n,void 0!==e.sizeFixed&&this.setSizeFixed(e.sizeFixed),this.setFixedSize(e.width,e.height),i.getApp().renderOnceNextFrame()}catch(e){Qg.error(`Failed to load texture "${t}":`,e)}}draw(t,e){const{x:i,y:n,rotation:s=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=s,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){Zi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Ty extends Iy{background;icon;options;constructor(t){super(),this.options=t,this.background=new Tl,this.addChild(this.background),this.icon=new My,this.addChild(this.icon),this.eventMode="static",this.render(),this.setupHitArea(),this.setupEvents()}setupHitArea(){const t=Zi().controlsConfig,e=t.iconWrapperWidth+16,i=t.iconWrapperHeight+16;this.hitArea=new Sn(-e/2,-i/2,e,i)}async render(){this.renderBackground(),this.renderIcon()}renderBackground(){const t=Zi().controlsConfig;this.background.clear(),this.background.roundRect(-t.iconWrapperWidth/2,-t.iconWrapperHeight/2,t.iconWrapperWidth,t.iconWrapperHeight,t.iconWrapperBorderRadius).fill(this.options.backgroundColor)}async renderIcon(){try{const t=Zi().controlsConfig;await this.icon.loadTextureAndSetSize(this.options.iconAlias,{width:t.iconWidth,height:t.iconHeight,sizeFixed:!1}),this.icon.visible=!0}catch(t){Qg.error(`Failed to load icon: ${this.options.iconAlias}`,t)}}destroy(){super.destroy()}}class Py extends Hs{borderOptions;solidLine=null;dashGraphics=null;fillGraphics=null;constructor(t){super(),this.borderOptions={...t},this.drawBorder(),this.setupAntiScaleListener(),this.eventMode="none"}setupAntiScaleListener(){Zi().emitter.on("antiScale",this.handleAntiScale)}handleAntiScale=()=>{this.drawBorder()};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 Tl,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=Zi();this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy()),this.solidLine=new Tl;const s=n.getApp().toFixedSize(i.width);this.solidLine.setStrokeStyle({color:i.color,width:s}),this.solidLine.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)this.solidLine.lineTo(t[e].x,t[e].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 Qg.warn("Invalid dashArray:",i.dashArray);const n=Zi();this.dashGraphics=new Tl;const s=n.getApp().toFixedSize(i.width);this.dashGraphics.setStrokeStyle({color:i.color,width:s});const r=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,r,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 Qg.warn("Invalid dash parameters:",{dashLength:i,gapLength:n});const s=this.calculatePathSegments(e),r=s.reduce((t,e)=>t+e.length,0);if(0===r)return;const o=i+n;let a=0;for(;a<r;){const e=a+i;e<=r?this.drawContinuousDashSegment(t,s,a,e):this.drawContinuousDashSegment(t,s,a,r),a+=o}}calculatePathSegments(t){const e=[];for(let i=0;i<t.length-1;i++){const n=t[i],s=t[i+1],r=s.x-n.x,o=s.y-n.y,a=Math.sqrt(r*r+o*o);e.push({start:n,end:s,length:a})}return e}drawContinuousDashSegment(t,e,i,n){if(i>=n)return;let s=0,r=!1,o=null;for(const a of e){const e=s,h=s+a.length;if(h>i&&e<n){const s=Math.max(i,e),l=Math.min(n,h),c=(s-e)/a.length,d=(l-e)/a.length,u={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)*d,y:a.start.y+(a.end.y-a.start.y)*d};r?o&&Math.sqrt(Math.pow(u.x-o.x,2)+Math.pow(u.y-o.y,2))>.1&&t.lineTo(u.x,u.y):(t.moveTo(u.x,u.y),r=!0),t.lineTo(p.x,p.y),o=p}if(s+=a.length,s>=n)break}}clearBorder(){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy(),this.fillGraphics=null),this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy(),this.solidLine=null),this.dashGraphics&&(this.removeChild(this.dashGraphics),this.dashGraphics.destroy(),this.dashGraphics=null)}updateStyle(t){this.borderOptions.style={...this.borderOptions.style,...t},this.drawBorder()}updatePoints(t){this.borderOptions.points=t,this.drawBorder()}setClosePath(t){this.borderOptions.closePath=t,this.drawBorder()}getOptions(){return{...this.borderOptions}}destroy(){Zi().emitter.off("antiScale",this.handleAntiScale),this.clearBorder(),super.destroy()}}class Ey extends Tl{fillOptions;isDragging=!1;dragStartPosition=null;constructor(t){super(),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}=Zi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Zi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handlePointerDown=t=>{t.stopPropagation(),this.startDragging(t)};startDragging(t){this.isDragging=!0;const e=this.parent.toLocal(t.global);this.dragStartPosition={x:e.x,y:e.y},this.fillOptions.onDragStart?.(t),Zi().emitter.emit("gestureHijackStart",t)}handleDragPointerMove=t=>{this.isDragging&&this.dragStartPosition&&this.fillOptions.onDragMove?.(t)};handleDragPointerUp=()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.fillOptions.onDragEnd?.())};handleDragCancel=()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.fillOptions.onDragEnd?.())};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={...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 By extends Tl{lineOptions;strokeContext=null;constructor(t){super(),this.lineOptions={...t},this.eventMode="static",this.drawDashLine(),this.setupAntiScaleListener()}setupAntiScaleListener(){Zi().emitter.on("antiScale",this.drawDashLine)}drawDashLine=()=>{const{start:t,end:e,style:i}=this.lineOptions;this.clear(),this.strokeContext&&this.strokeContext.destroy();const n=Zi();this.strokeContext=new lh;const s=n.getApp().toFixedSize(i.width);this.strokeContext.setStrokeStyle({color:i.color,width:s}),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};drawDashedLineToContext(t,e,i,n,s,r,o){const a=n-e,h=s-i,l=Math.sqrt(a*a+h*h);if(0===l)return;const c=Zi(),d=c.getApp().toFixedSize(r),u=d+c.getApp().toFixedSize(o),p=l/u,f=Math.round(p);if(0===f)return t.moveTo(e,i),void t.lineTo(n,s);const g=l/f,m=g*(d/u),y=a/l,x=h/l;for(let n=0;n<f;n++){const s=n*g,r=s+m;if(s>=l)break;const o=Math.min(r,l),a=e+s*y,h=i+s*x,c=e+o*y,d=i+o*x;t.moveTo(a,h),t.lineTo(c,d)}}updatePoints(t,e){this.lineOptions.start=t,this.lineOptions.end=e,this.drawDashLine()}updateStyle(t){this.lineOptions.style={...this.lineOptions.style,...t},this.drawDashLine()}getOptions(){return{...this.lineOptions}}destroy(){Zi().emitter.off("antiScale",this.drawDashLine),this.strokeContext&&this.strokeContext.destroy(),super.destroy()}}class Oy extends Tl{constructor(t){super(),this.options=t,this.initialPosition={...t.position},this.position.set(t.position.x,t.position.y),this.eventMode="static",this.cursor="pointer",this.setupEvents(),this.draw(),this.setupDragEventListeners()}isDragging=!1;dragStartPosition=null;initialPosition;draw(){const t=Zi(),{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=Zi(),{config:e}=this.options,i=Math.max(e.endPointSize/2+10,20),n=t.getApp().toFixedSize(i);this.hitArea=new Wo(0,0,n)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}setupDragEventListeners(){const{emitter:t}=Zi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Zi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handlePointerDown(t){t.stopPropagation(),this.startDragging(t)}startDragging(t){const e=Zi();this.isDragging=!0,this.dragStartPosition=this.parent.toLocal(t.global),this.initialPosition={x:this.x,y:this.y},this.options.onDragStart?.(),e.getApp().requestRender("endpoint-drag",!0),Zi().emitter.emit("gestureHijackStart",t)}handleDragPointerMove=t=>{if(!this.isDragging||!this.dragStartPosition)return;const e=this.parent.toLocal(t.global),i=e.x-this.dragStartPosition.x,n=e.y-this.dragStartPosition.y,s={x:this.initialPosition.x+i,y:this.initialPosition.y+n};this.position.set(s.x,s.y),this.options.onDragMove?.(s)};handleDragPointerUp=()=>{if(!this.isDragging)return;const t=Zi();this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("endpoint-drag"),this.options.onDragEnd?.()};handleDragCancel=()=>{if(!this.isDragging)return;const t=Zi();this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("endpoint-drag"),this.options.onDragEnd?.()};updatePosition(t){this.position.set(t.x,t.y),this.initialPosition={...t}}getPosition(){return{x:this.x,y:this.y}}redraw(){this.draw()}destroy(){this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.cleanupDragEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class ky extends ll{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;constructor(t){super(t),this.anchor.set(.5),this.throttledUpdateScale=Ni(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(){Zi().emitter.on("antiScale",this.throttledUpdateScale)}applyFixedSize(){if(!this.isFixedSizeSet)return;const t=Zi().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){Zi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}var Ry,Dy,Fy,Ly,jy,Gy,Uy={},Ny={},zy={},Hy={},Vy={},Wy={},Zy=function(){if(Gy)return Uy;Gy=1,Object.defineProperty(Uy,"__esModule",{value:!0}),Uy.decompressFrames=Uy.decompressFrame=Uy.parseGIF=void 0;var t,e=(Fy||(Fy=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var e=Ji(),i=Xi(),n={blocks:function(t){for(var e=[],n=t.data.length,s=0,r=(0,i.readByte)()(t);0!==r&&r;r=(0,i.readByte)()(t)){if(t.pos+r>=n){var o=n-t.pos;e.push((0,i.readBytes)(o)(t)),s+=o;break}e.push((0,i.readBytes)(r)(t)),s+=r}for(var a=new Uint8Array(s),h=0,l=0;l<e.length;l++)a.set(e[l],h),h+=e[l].length;return a}},s=(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]}),r=(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]}),h=(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]}),l=[{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)([s,a,h,r,o],function(t){var e=(0,i.peekByte)()(t);return 33===e||44===e})}];t.default=l}(Ny)),(t=Ny)&&t.__esModule?t:{default:t}),i=Ji(),n=Xi(),s=(Ly||(Ly=1,Object.defineProperty(Vy,"__esModule",{value:!0}),Vy.deinterlace=void 0,Vy.deinterlace=function(t,e){for(var i=new Array(t.length),n=t.length/e,s=function(n,s){var r=t.slice(s*e,(s+1)*e);i.splice.apply(i,[n*e,e].concat(r))},r=[0,4,2,1],o=[8,8,4,2],a=0,h=0;h<4;h++)for(var l=r[h];l<n;l+=o[h])s(l,a),a++;return i}),Vy),r=(jy||(jy=1,Object.defineProperty(Wy,"__esModule",{value:!0}),Wy.lzw=void 0,Wy.lzw=function(t,e,i){var n,s,r,o,a,h,l,c,d,u,p,f,g,m,y,x,b=4096,_=i,v=new Array(i),w=new Array(b),C=new Array(b),S=new Array(4097);for(a=1+(s=1<<(u=t)),n=s+2,l=-1,r=(1<<(o=u+1))-1,c=0;c<s;c++)w[c]=0,C[c]=c;for(p=f=g=m=y=x=0,d=0;d<_;){if(0===m){if(f<o){p+=e[x]<<f,f+=8,x++;continue}if(c=p&r,p>>=o,f-=o,c>n||c==a)break;if(c==s){r=(1<<(o=u+1))-1,n=s+2,l=-1;continue}if(-1==l){S[m++]=C[c],l=c,g=c;continue}for(h=c,c==n&&(S[m++]=g,c=l);c>s;)S[m++]=C[c],c=w[c];g=255&C[c],S[m++]=g,n<b&&(w[n]=l,C[n]=g,0===(++n&r)&&n<b&&(o++,r+=n)),l=h}m--,v[y++]=S[m],d++}for(d=y;d<_;d++)v[d]=0;return v}),Wy);Uy.parseGIF=function(t){var s=new Uint8Array(t);return(0,i.parse)((0,n.buildStream)(s),e.default)};var o=function(t,e,i){if(t.image){var n=t.image,o=n.descriptor.width*n.descriptor.height,a=(0,r.lzw)(n.data.minCodeSize,n.data.blocks,o);n.descriptor.lct.interlaced&&(a=(0,s.deinterlace)(a,n.descriptor.width));var h={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?h.colorTable=n.lct:h.colorTable=e,t.gce&&(h.delay=10*(t.gce.delay||10),h.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(h.transparentIndex=t.gce.transparentColorIndex)),i&&(h.patch=function(t){for(var e=t.pixels.length,i=new Uint8ClampedArray(4*e),n=0;n<e;n++){var s=4*n,r=t.pixels[n],o=t.colorTable[r]||[0,0,0];i[s]=o[0],i[s+1]=o[1],i[s+2]=o[2],i[s+3]=r!==t.transparentIndex?255:0}return i}(h)),h}};return Uy.decompressFrame=o,Uy.decompressFrames=function(t,e){return t.frames.filter(function(t){return t.image}).map(function(i){return o(i,t.gct,e)})},Uy}();class Jy{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){if(!t||0===t.byteLength)throw new Error("Invalid buffer");const i=Zy.parseGIF(t);(t=>{let e=null;for(const i of t.frames)e=i.gce??e,"image"in i&&!("gce"in i)&&(i.gce=e)})(i);const n=Zy.decompressFrames(i,!0),s=[],r=i.lsd.width,o=i.lsd.height,a=qs.get().createCanvas(r,o),h=a.getContext("2d",{willReadFrequently:!0}),l=qs.get().createCanvas(),c=l.getContext("2d");let d=0,u=null;const p=1e3/(e?.fps??30);for(let t=0;t<n.length;t++){const{disposalType:e=2,delay:i=p,patch:a,dims:{width:f,height:g,left:m,top:y}}=n[t];l.width=f,l.height=g,c.clearRect(0,0,f,g);const x=c.createImageData(f,g);x.data.set(a),c.putImageData(x,0,0),3===e&&(u=h.getImageData(0,0,r,o)),h.drawImage(l,m,y);const b=h.getImageData(0,0,r,o);2===e?h.clearRect(0,0,r,o):3===e&&h.putImageData(u,0,0);const _=qs.get().createCanvas(b.width,b.height);_.getContext("2d").putImageData(b,0,0),s.push({start:d,end:d+i,texture:new Fn({source:new Qs({resource:_})})}),d+=i}return a.width=a.height=0,l.width=l.height=0,new Jy(s)}}const Xy={extension:Ki.Asset,detection:{test:async()=>!0,add:async t=>[...t,"gif"],remove:async t=>t.filter(t=>"gif"!==t)},loader:{name:"gifLoader",id:"gif",test:t=>".gif"===dr.extname(t)||t.startsWith("data:image/gif"),load:async(t,e)=>{const i=await qs.get().fetch(t),n=await i.arrayBuffer();return Jy.from(n,e?.data)},unload:async t=>{t.destroy()}}},Yy=class t extends Ws{constructor(...e){const i=e[0]instanceof Jy?{source:e[0]}:e[0],{scaleMode:n,source:s,fps:r,loop:o,animationSpeed:a,autoPlay:h,autoUpdate:l,onComplete:c,onFrameChange:d,onLoop:u,...p}=Object.assign({},t.defaultOptions,i);super({texture:Fn.EMPTY,...p}),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:r,loop:o,animationSpeed:a,autoPlay:h,autoUpdate:l,onComplete:c,onFrameChange:d,onLoop:u}),this.currentFrame=0,h&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(sr.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(sr.shared.add(this.update,this,tr.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){if(!this._playing)return;const e=this.animationSpeed*t.deltaTime/sr.targetFPMS,i=this._currentTime+e,n=i%this.duration,s=this._source.frames.findIndex(t=>t.start<=n&&t.end>n);i>=this.duration?this.loop?(this._currentTime=n,this._updateFrameIndex(s),this.onLoop?.()):(this._currentTime=this.duration,this._updateFrameIndex(this.totalFrames-1),this.onComplete?.(),this.stop()):(this._currentTime=n,this._updateFrameIndex(s))}_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?(sr.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(sr.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){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,this.onFrameChange?.(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}};Yy.defaultOptions={scaleMode:"linear",fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};let Ky=Yy;$i.add(Xy);class qy extends Ky{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;sizeFixed=!0;baselineScale=1;constructor(t){super(t),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ni(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?Qg.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置宽度"):this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet?Qg.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置高度"):this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){Zi().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||0===this.texture.width||0===this.texture.height)return;const t=Zi(),e=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const n=t.currentScale;if(0===n)return;const s=e/n,r=i/n;super.scale.set(s,r)}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 async createFromSrc(t,e){try{const i=await al.load(t),n=new qy({source:i});return void 0!==e.sizeFixed&&n.setSizeFixed(e.sizeFixed),n.setFixedSize(e.width,e.height),n}catch(e){throw Qg.error(`Failed to load GIF "${t}":`,e),e}}draw(t,e){const{x:i,y:n,rotation:s=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=s,this.position.set(i,n)}destroy(t){Zi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Qy extends Ol{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;sizeFixed=!0;baselineScale=1;static animationTicker=null;static animatedSprites=new Set;constructor(t){super(t||[]),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ni(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(){Zi().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=Zi(),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 s=i/e,r=n/e;super.scale.set(s,r)}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 async loadAnimationTextures(t,e="sleep_",i=96){try{await al.load(t);const n=[];for(let t=0;t<i;t++){const i=`${e}${t.toString().padStart(3,"0")}.png`,s=Fn.from(i);s&&n.push(s)}return n}catch(t){return[]}}setupAnimation(t){void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),this.setFixedSize(t.width,t.height),this.animationSpeed=.5,this.loop=!0,Qg.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:s=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=s,this.position.set(i,n)}play(){this.textures&&this.textures.length>0&&(super.play(),Qy.animatedSprites.add(this),Qy.startAnimationTicker())}stop(){super.stop(),Qy.animatedSprites.delete(this),Qy.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(){Qy.animationTicker?.started||(Qy.animationTicker||(Qy.animationTicker=new sr,Qy.animationTicker.maxFPS=24,Qy.animationTicker.add(()=>{Qy.updateAnimations()})),Qy.animationTicker.start(),Qg.log("🎬 [AnimationTicker] Started animation ticker"))}static updateAnimationTicker(){Qy.animatedSprites.size>0?Qy.startAnimationTicker():Qy.stopAnimationTicker()}static stopAnimationTicker(){Qy.animationTicker?.started&&(Qg.log("⏸️ [AnimationTicker] Stopped animation ticker"),Qy.animationTicker.stop())}static updateAnimations(){if(0===Qy.animatedSprites.size)return;const t=Zi().getApp();t.renderer.render(t.stage)}destroy(t){Qy.animatedSprites.delete(this),Qy.updateAnimationTicker(),Zi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class $y extends Nl{throttledUpdateScale;constructor({text:t,style:e}){super({text:t,style:e}),this.throttledUpdateScale=Ni(this.updateScale.bind(this),20,{leading:!0,trailing:!0}),this.registerScaleListener(),this.updateScale(Zi().currentScale)}registerScaleListener(){Zi().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){Zi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class tx extends Ty{isMoving=!1;dragStartPosition=null;constructor(t){super(t),this.setupMoveEventListeners()}setupMoveEventListeners(){const{emitter:t}=Zi();t.on("gestureHijackPointerMove",this.handleMovePointerMove),t.on("gestureHijackPointerUp",this.handleMovePointerUp),t.on("gestureHijackCancel",this.handleMoveCancel)}cleanupMoveEventListeners(){const{emitter:t}=Zi();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){this.isMoving=!0,this.dragStartPosition=this.parent.toLocal(t.global),this.options.onMoveStart?.(),Zi().emitter.emit("gestureHijackStart",t)}handleMovePointerMove=t=>{this.isMoving&&this.dragStartPosition&&this.options.onMoveMove?.(t)};handleMovePointerUp=()=>{this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,this.options.onMoveEnd?.())};handleMoveCancel=()=>{this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,this.options.onMoveEnd?.())};isCurrentlyMoving(){return this.isMoving}getDragStartPosition(){return this.dragStartPosition?{...this.dragStartPosition}:null}stopMoving(){this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,this.options.onMoveEnd?.())}destroy(){this.stopMoving(),this.cleanupMoveEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class ex extends Ty{clickHandler=null;constructor(t){super(t)}setupEvents(){this.clickHandler=new Cy(this,{onClick:this.options.onClick,stopPropagation:!0})}destroy(){this.clickHandler?.destroy(),super.destroy()}}class ix extends Ty{isRotating=!1;rotationCenter={x:0,y:0};lastAngle=0;constructor(t){super(t),this.setupRotationEventListeners()}setupRotationEventListeners(){const{emitter:t}=Zi();Zi().emitter.on("gestureHijackPointerMove",this.handleRotationPointerMove),t.on("gestureHijackPointerUp",this.handleRotationPointerUp),t.on("gestureHijackCancel",this.handleRotationCancel)}cleanupRotationEventListeners(){const{emitter:t}=Zi();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){this.isRotating=!0;const e=this.options.getTargetPoints();this.rotationCenter=cm(e);const i=this.parent.toLocal(t.global);this.lastAngle=Math.atan2(i.y-this.rotationCenter.y,i.x-this.rotationCenter.x),this.options.onRotationStart?.(this.rotationCenter),Zi().emitter.emit("gestureHijackStart",t)}handleRotationPointerMove=t=>{if(!this.isRotating)return;const e=this.parent.toLocal(t.global),i=Math.atan2(e.y-this.rotationCenter.y,e.x-this.rotationCenter.x),n=i-this.lastAngle;this.options.onRotationMove?.(n),this.lastAngle=i};handleRotationPointerUp=()=>{this.isRotating&&(this.isRotating=!1,this.options.onRotationEnd?.())};handleRotationCancel=()=>{this.isRotating&&(this.isRotating=!1,this.options.onRotationEnd?.())};isCurrentlyRotating(){return this.isRotating}stopRotation(){this.isRotating&&(this.isRotating=!1,this.options.onRotationEnd?.())}destroy(){this.stopRotation(),this.cleanupRotationEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class nx extends Ty{isScaling=!1;initialButtonPosition=null;dragStartPosition=null;constructor(t){super(t),this.setupScaleEventListeners()}setupScaleEventListeners(){const{emitter:t}=Zi();t.on("gestureHijackPointerMove",this.handleScalePointerMove),t.on("gestureHijackPointerUp",this.handleScalePointerUp),t.on("gestureHijackCancel",this.handleScaleCancel)}cleanupScaleEventListeners(){const{emitter:t}=Zi();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){this.isScaling=!0,this.dragStartPosition=this.parent.toLocal(t.global);const e=this.options.getTargetPoints(),i=this.options.getButtonIndex();i>=0&&i<e.length&&(this.initialButtonPosition={...e[i]}),this.options.onScaleStart?.(i),Zi().emitter.emit("gestureHijackStart",t)}handleScalePointerMove=t=>{if(!this.isScaling||!this.initialButtonPosition||!this.dragStartPosition)return;const e=this.parent.toLocal(t.global),i=e.x-this.dragStartPosition.x,n=e.y-this.dragStartPosition.y,s={x:this.initialButtonPosition.x+i,y:this.initialButtonPosition.y+n};this.options.onScaleMove?.(s)};handleScalePointerUp=()=>{this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,this.options.onScaleEnd?.())};handleScaleCancel=()=>{this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,this.options.onScaleEnd?.())};isCurrentlyScaling(){return this.isScaling}stopScaling(){this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,this.options.onScaleEnd?.())}destroy(){this.stopScaling(),this.cleanupScaleEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class sx extends Hs{static BUTTON_INDICES={REMOVE:0,ROTATE:1,SCALE:2,MOVE:3,FIXED:0};zoneData;zoneType;zoneConfig;controlsConfig;zoneEvents;controlFill;zoneBorder;outlineBorder;moveLine;sizeText;controlButtons;deleteButton=null;rotateButton=null;scaleButton=null;moveButton=null;totalRotationAngle=0;rotationCenter=null;initialZonePoints=[];clickHandler=null;throttledUpdateOutline;constructor(t){super();const{zoneData:e,zoneType:i,events:n={}}=t;this.zoneType=i,this.zoneEvents=n,this.zoneConfig=this.getZoneConfig(),this.controlsConfig=this.getControlsConfig();const s=this.validateAndCorrectZoneSize(e.points),r=dm(s);this.zoneData={...e,points:r},this.throttledUpdateOutline=Ni(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.createControlButtons(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){Zi().emitter.on("antiScale",this.throttledUpdateOutline)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition())}getZoneConfig(){const t=Zi(),{controls:e}=t.getConfig();return e[this.zoneType]}getControlsConfig(){const t=Zi(),{controls:e}=t.getConfig();return e}validateAndCorrectZoneSize(t){const e=Zi();if(t.length<4)return t;const i=e.metersToPixels(this.zoneConfig.minSize),[n,s,,r]=t,o=pm(n,s),a=pm(n,r);if(o>=i&&a>=i)return t;const h=cm(t),l=mm(gm(n,s)),c=mm(gm(n,r)),d=Math.max(o,i)/2,u=Math.max(a,i)/2;return[{x:h.x-l.x*d-c.x*u,y:h.y-l.y*d-c.y*u},{x:h.x+l.x*d-c.x*u,y:h.y+l.y*d-c.y*u},{x:h.x+l.x*d+c.x*u,y:h.y+l.y*d+c.y*u},{x:h.x-l.x*d+c.x*u,y:h.y-l.y*d+c.y*u}]}getEditingIdsKey(){switch(this.zoneType){case"forbiddenSweepZone":default:return"editingForbiddenSweepZoneIds";case"forbiddenMopZone":return"editingForbiddenMopZoneIds";case"cleanZone":return"editingCleanZoneIds"}}isEditingEnabled(){const t=this.getEditingIdsKey();return Zi().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 Hs,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.drawZone()}createControlButtons(){const t=this.calculateOutlinePoints();if(t.length<4)return;this.deleteButton=new ex({iconAlias:"deleteIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onClick:this.handleDelete}),this.deleteButton.position.set(t[sx.BUTTON_INDICES.REMOVE].x,t[sx.BUTTON_INDICES.REMOVE].y),this.rotateButton=new ix({iconAlias:"rotateIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,onRotationStart:this.handleRotationStart,onRotationMove:this.handleRotationMove,onRotationEnd:this.handleRotationEnd}),this.rotateButton.position.set(t[sx.BUTTON_INDICES.ROTATE].x,t[sx.BUTTON_INDICES.ROTATE].y),this.scaleButton=new nx({iconAlias:"scaleIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,getButtonIndex:()=>sx.BUTTON_INDICES.SCALE,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(t[sx.BUTTON_INDICES.SCALE].x,t[sx.BUTTON_INDICES.SCALE].y);const e=this.calculateMoveButtonPosition();this.moveButton=new tx({iconAlias:"moveIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(e.x,e.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 Ey({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 Py({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 Py({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 Py({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;return t.length<4?t:((t,e)=>{if(t.length<3)return t;const i=[];for(let n=0;n<t.length;n++){const s=t[n],r=t[(n+1)%t.length],o=t[(n-1+t.length)%t.length],a=gm(s,r);if(0===fm(a)){i.push(s);continue}const h=mm(a),l={x:h.y,y:-h.x},c=gm(o,s);let d={x:0,y:0};if(fm(c)>0){const t=mm(c);d={x:t.y,y:-t.x}}const u=_m(d,l),p=d.x*l.x+d.y*l.y,f=1/Math.max(.1,Math.sqrt((1+p)/2)),g={x:s.x+u.x*e*f,y:s.y+u.y*e*f};i.push(g)}return i})(t,Zi().getApp().toFixedSize(this.zoneConfig.outlineOffset))}calculateMoveLinePoints(t){return t.length<4?[]:[t[sx.BUTTON_INDICES.MOVE],this.calculateMoveButtonPosition()]}createSizeText(){const t=this.calculateZoneSizeText(),e=new $y({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,s=pm(e,i),r=pm(e,n),o=Zi(),a=o.pixelsToMeters(s),h=o.pixelsToMeters(r);return`${a.toFixed(1)}${this.controlsConfig.unitLabel}*${h.toFixed(1)}${this.controlsConfig.unitLabel}`}calculateSizeTextPosition(){const{points:t}=this.zoneData;if(t.length<4)return{x:0,y:0};const[e,i,n,s]=t,{textPosition:r,textOffset:o}=this.zoneConfig,a=Zi().getApp().toFixedSize(o);let h,l;switch(r){case"top":{h={x:(e.x+i.x)/2,y:(e.y+i.y)/2};const t=mm(gm(i,e)),n={x:t.y,y:-t.x};l={x:n.x*a,y:n.y*a};break}case"right":{h={x:(i.x+n.x)/2,y:(i.y+n.y)/2};const t=mm(gm(i,n)),e={x:t.y,y:-t.x};l={x:e.x*a,y:e.y*a};break}case"bottom":{h={x:(s.x+n.x)/2,y:(s.y+n.y)/2};const t=mm(gm(s,n)),e={x:-t.y,y:t.x};l={x:e.x*a,y:e.y*a};break}case"left":{h={x:(e.x+s.x)/2,y:(e.y+s.y)/2};const t=mm(gm(s,e)),i={x:t.y,y:-t.x};l={x:i.x*a,y:i.y*a};break}default:h={x:(e.x+i.x)/2,y:(e.y+i.y)/2},l={x:0,y:a}}return{x:h.x+l.x,y:h.y+l.y}}calculateSizeTextRotation(){const{points:t}=this.zoneData;if(t.length<4)return 0;const[e,i,n,s]=t,{textPosition:r}=this.zoneConfig;let o,a;switch(r){case"top":default:o=e,a=i;break;case"right":o=i,a=n;break;case"bottom":o=n,a=s;break;case"left":o=s,a=e}return vm(o,a)}calculateMoveButtonPosition(){const t=this.calculateOutlinePoints();if(t.length<4)return{x:0,y:0};const e=Zi(),{controls:i}=e.getConfig(),n=t[sx.BUTTON_INDICES.MOVE],s=t[2],r=t[0],o=e.getApp().toFixedSize(i.moveButtonOffset);return Cm(n,s,r,o)}handleDragStart=()=>{if(!this.isEditingEnabled())return;const t=Zi();this.initialZonePoints=this.zoneData.points.map(t=>({...t})),t.getApp().requestRender("zone-drag",!0)};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,s=e.y-i.y;this.applyTranslation(n,s)};handleDragEnd=()=>{const t=Zi();this.initialZonePoints=[],t.getApp().stopRender("zone-drag"),this.zoneEvents.onUpdate?.(this.getZoneData())};applyTranslation(t,e){this.zoneData.points=this.initialZonePoints.map(i=>({x:i.x+t,y:i.y+e})),this.drawZone(),this.updateControlButtonsPosition()}handleRotationStart=t=>{const e=Zi();this.totalRotationAngle=0,this.rotationCenter=t,this.initialZonePoints=this.zoneData.points.map(t=>({...t})),e.getApp().requestRender("zone-rotate",!0)};handleRotationMove=t=>{this.totalRotationAngle+=t,this.applyRotation(t)};handleRotationEnd=()=>{const t=Zi();this.rotationCenter=null,this.totalRotationAngle=0,this.initialZonePoints=[],t.getApp().stopRender("zone-rotate"),this.zoneEvents.onUpdate?.(this.getZoneData())};applyRotation(t){this.rotationCenter&&(this.zoneData.points=((t,e,i)=>t.map(t=>((t,e,i)=>{const n=Math.cos(i),s=Math.sin(i),r=t.x-e.x,o=t.y-e.y;return{x:r*n-o*s+e.x,y:r*s+o*n+e.y}})(t,e,i)))(this.zoneData.points,this.rotationCenter,t),this.drawZone(),this.updateControlButtonsPosition())}handleScaleStart=()=>{const t=Zi();this.initialZonePoints=this.zoneData.points.map(t=>({...t})),t.getApp().requestRender("zone-scale",!0)};handleScaleMove=t=>{0!==this.initialZonePoints.length&&this.applyEdgeBasedScale(t)};handleScaleEnd=()=>{const t=Zi();this.initialZonePoints=[],t.getApp().stopRender("zone-scale"),this.zoneEvents.onUpdate?.(this.getZoneData())};applyEdgeBasedScale(t){if(this.initialZonePoints.length<4)return;const e=Zi(),{FIXED:i}=sx.BUTTON_INDICES,{x:n,y:s}=this.initialZonePoints[i],[,r,,o]=this.initialZonePoints,a={x:n,y:s},h=gm(a,r),l=gm(a,o),c=gm(a,t),d=fm(h),u=fm(l);if(0===d||0===u)return;const p=e.metersToPixels(this.zoneConfig.minSize),[f,g]=[um(c,h,d,p),um(c,l,u,p)];this.zoneData.points=[a,{x:n+h.x*f,y:s+h.y*f},{x:n+h.x*f+l.x*g,y:s+h.y*f+l.y*g},{x:n+l.x*g,y:s+l.y*g}],this.drawZone(),this.updateControlButtonsPosition()}handleMoveStart=()=>{const t=Zi();this.initialZonePoints=this.zoneData.points.map(t=>({...t})),t.getApp().requestRender("zone-move",!0)};handleMove=t=>{if(!this.isEditingEnabled()||0===this.initialZonePoints.length)return;const e=this.parent.toLocal(t.global),i=this.moveButton?.getDragStartPosition();if(!i)return;const n=e.x-i.x,s=e.y-i.y;this.applyTranslation(n,s)};handleMoveEnd=()=>{const t=Zi();this.initialZonePoints=[],t.getApp().stopRender("zone-move"),this.zoneEvents.onUpdate?.(this.getZoneData())};handleDelete=()=>{this.zoneEvents.onRemove?.(this.zoneData.id)};setupClickHandler(){this.clickHandler=new Cy(this,{onClick:()=>{this.isEditingEnabled()||this.zoneEvents?.onClick?.(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 t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:e,ROTATE:i,SCALE:n}=sx.BUTTON_INDICES,s=this.calculateMoveButtonPosition();[{button:this.deleteButton,point:t[e]},{button:this.rotateButton,point:t[i]},{button:this.scaleButton,point:t[n]},{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(){const t=this.controlFill.isCurrentlyDragging(),e=this.scaleButton?.isCurrentlyScaling()||!1,i=this.rotateButton?.isCurrentlyRotating()||!1,n=this.moveButton?.isCurrentlyMoving()||!1;return{isDragging:t,isScaling:e,isRotating:i,isMoving:n,hasAnyOperation:t||e||i||n}}stopAllOperations(){this.controlFill.stopDragging(),this.scaleButton?.stopScaling(),this.rotateButton?.stopRotation(),this.moveButton?.stopMoving()}stopDragging(){this.controlFill.stopDragging()}stopScaling(){this.scaleButton?.stopScaling()}stopRotating(){this.rotateButton?.stopRotation()}stopMoving(){this.moveButton?.stopMoving()}isCurrentlyDragging(){return this.controlFill.isCurrentlyDragging()}isCurrentlyScaling(){return this.scaleButton?.isCurrentlyScaling()||!1}isCurrentlyRotating(){return this.rotateButton?.isCurrentlyRotating()||!1}isCurrentlyMoving(){return this.moveButton?.isCurrentlyMoving()||!1}updateZoneData(t){const e=this.validateAndCorrectZoneSize(t.points),i=dm(e);this.zoneData={...t,points:i},this.drawZone(),this.updateControlButtonsPosition(),this.updateEditState()}getZoneData(){return{...this.zoneData}}destroy(){Zi().emitter.off("antiScale",this.throttledUpdateOutline),this.clickHandler?.destroy(),this.clickHandler=null,this.deleteButton?.destroy(),this.rotateButton?.destroy(),this.scaleButton?.destroy(),this.moveButton?.destroy(),this.deleteButton=null,this.rotateButton=null,this.scaleButton=null,this.moveButton=null,this.zoneBorder?.destroy(),this.outlineBorder?.destroy(),this.moveLine?.destroy(),this.sizeText?.destroy(),this.controlFill?.destroy(),this.controlButtons?.destroy(),super.destroy()}}class rx extends Tl{currentPosition=null;config;constructor(t){super(),this.setupAntiScaleListener(),this.config=t.config}setupAntiScaleListener(){Zi().emitter.on("antiScale",this.handleScaleChange)}handleScaleChange=()=>{this.redraw()};draw(t){const e=Zi();this.currentPosition=t;const{ringSize:i,ringColor:n,ringStrokeWidth:s,ringStrokeColor:r,ringStrokeDashed:o,ringStrokeDashArray:a}=this.config;this.clear();const h=e.metersToPixels(i),l=e.getApp().toFixedSize(s);this.setFillStyle({color:n}),o&&a.length>=2?this.drawDashedCircle(t,h,r,l,a):this.circle(t.x,t.y,h).fill().stroke({color:r,width:l,cap:"round",join:"round"})}drawDashedCircle(t,e,i,n,s){const r=Zi();this.circle(t.x,t.y,e).fill();const o=r.getApp().toFixedSize(s[0]),a=r.getApp().toFixedSize(s[1]),h=2*Math.PI*e,l=o+a,c=Math.floor(h/l);if(0===c)return void this.circle(t.x,t.y,e).stroke({color:i,width:n,cap:"round",join:"round"});const d=h/c,u=d*(o/l);for(let i=0;i<c;i++){const n=i*d/e,s=(i*d+u)/e,r=Math.max(4,Math.ceil(Math.abs(s-n)*e/2)),o=(s-n)/r;for(let i=0;i<=r;i++){const s=n+o*i,r=t.x+e*Math.cos(s),a=t.y+e*Math.sin(s);0===i?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(){Zi().emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class ox extends My{constructor(){super(),this.initializeSprite()}async initializeSprite(){const t=Zi();await this.loadTextureAndSetSize("chargingStation",t.chargingStationConfig.icon)}async draw({x:t,y:e,rotation:i}){const n=Zi();super.draw({x:t,y:e,rotation:i},()=>n.runtimeSnapshot.showChargingStation)}}class ax extends Hs{chargingStation;ring;unsubscribeFns=[];constructor(){super();const t=Zi();t.appContainer.addToLayer(yy,this),this.ring=new rx({config:t.chargingStationConfig}),this.ring.visible=t.runtimeSnapshot.showChargingStationRing,this.addChild(this.ring),this.chargingStation=new ox,this.addChild(this.chargingStation);const e=Yi(t.runtime,"showChargingStationRing",t=>{Qg.log(`[runtime] showChargingStationRing: ${t}`),this.ring.visible=t});this.unsubscribeFns.push(e)}async draw({x:t,y:e,rotation:i}){0===t&&0===e||(this.ring.draw({x:t,y:e}),await this.chargingStation.draw({x:t,y:e,rotation:i}))}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.ring.destroy(),super.destroy()}}class hx{obstacle=new vy;free=new wy;roomFill=new Sy;carpet=new Ay;chargingStation=new ax;mapBounds={minX:0,minY:0,maxX:0,maxY:0};lastMapId=null;roomGeometryMap=new Map;rasterRoomPixelsMap=new Map;carpetData=null;unsubscribeFns=[];constructor(){const t=Zi(),e=Yi(t.runtime,"enableRoomSelection",e=>{if(Qg.log(`[runtime] enableRoomSelection: ${e}`),e){this.roomFill.setAllRoomsState(!1);const e=t.runtimeSnapshot.selectRoomIds;this.roomFill.setRoomStateBySelectIds(e)}else this.roomFill.setAllRoomsState(!0)}),i=Yi(t.runtime,"selectRoomIds",t=>{Qg.log(`[runtime] selectRoomIds: ${t}`),this.roomFill.setRoomStateBySelectIds(t)}),n=Yi(t.runtime,"showChargingStation",t=>{Qg.log(`[runtime] showChargingStation: ${t}`),this.chargingStation.visible=t}),s=Yi(t.runtime,"showCarpet",t=>{Qg.log(`[runtime] showCarpet: ${t}`),t?this.createCarpet():this.carpet.clearCarpet()});this.unsubscribeFns.push(e,i,n,s)}async drawMap(t){const e=Zi(),{id:i,obstacles:n,free:s,rooms:r,charger:o,carpet:a}=t;this.clearComponents(),this.resetGeometryData();const h=this.processRoomsGeometry(r);this.roomFill.draw(h),this.free.draw(s),this.obstacle.draw(n),this.carpetData={type:"structured",carpetData:a},this.createCarpet();const l=this.mergeLayerBounds();Ui(l,this.mapBounds)||(Qg.debug("[Map] Map bounds updated:",l),this.mapBounds=l,this.lastMapId!==i&&(e.getApp().fitMapToView(this.mapBounds),this.lastMapId=i));const c=((t.charger.angle??0)+e.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:o.coordinate[0],y:o.coordinate[1],rotation:c}),e.roomsManager.refresh(),!0}async drawRasterMap(t,e){const i=Zi();this.clearComponents();const{id:n,width:s,height:r,charger:o,chargerDirection:a}=e;Qg.debug("[Map] Parsed Raster Map Data",t),this.obstacle.drawRaster(t.obstacles,s),this.carpetData={type:"raster",carpetPixels:t.carpet,mapWidth:s},this.createCarpet();const h=this.processRasterData(t);this.roomFill.drawRaster(h);const l=((t,e,i)=>{let n=1/0,s=1/0,r=-1/0,o=-1/0;for(let i=0;i<t.obstacles.length;i++){const a=t.obstacles[i],h=a%e,l=Math.floor(a/e);n=Math.min(n,h),s=Math.min(s,l),r=Math.max(r,h),o=Math.max(o,l)}return t.rooms.forEach(t=>{for(let i=0;i<t.length;i++){const a=t[i],h=a%e,l=Math.floor(a/e);n=Math.min(n,h),s=Math.min(s,l),r=Math.max(r,h),o=Math.max(o,l)}}),n===1/0?{minX:0,minY:0,maxX:e,maxY:i}:{minX:Math.max(0,n),minY:Math.max(0,s),maxX:Math.min(e,r),maxY:Math.min(i,o)}})(t,s,r);Ui(l,this.mapBounds)||(Qg.debug("[Map] Raster map bounds updated:",l),this.mapBounds=l,this.lastMapId!==n&&(i.getApp().fitMapToView(this.mapBounds),this.lastMapId=n));const c=(a+i.chargingStationConfig.rotationCorrection)*Math.PI/180;return await 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.mapBounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}async createCarpet(){if(Zi().runtimeSnapshot.showCarpet&&this.carpetData)if("raster"===this.carpetData.type){const{carpetPixels:t,mapWidth:e}=this.carpetData;await this.carpet.createCarpetFromRasterData(t,e)}else if("structured"===this.carpetData.type){const{carpetData:t}=this.carpetData;await this.carpet.createCarpetFromStructuredData(t)}}processRoomsGeometry(t){if(!t)return[];const e=Zi(),{active:i}=e.roomConfig.colors,n=e.roomConfig.colors[zg.UNKNOWN_ROOM];if(0===Object.keys(t).length)return this.mapBounds={minX:0,minY:0,maxX:0,maxY:0},[];const s=Object.keys(t).sort((t,e)=>Number(t)-Number(e)),r=s.filter(t=>Number(t)<255),o=s.filter(t=>Number(t)>=255),a=[];return r.forEach((e,n)=>{const{coordinates:s}=t[e];if(s.length<4)return;const r=Number(e),o=n%i.length,h=i[o];let l=1/0,c=1/0,d=-1/0,u=-1/0;const p=[];for(let t=0;t<s.length;t+=2){const e=s[t],i=s[t+1];l=Math.min(l,e),c=Math.min(c,i),d=Math.max(d,e),u=Math.max(u,i),p.push({x:e,y:i})}const f=new Sn(l,c,d-l+1,u-c+1),g=$g(p),m=g.flatMap(t=>[t.x+.5,t.y+.5]),y={id:r,color:h,boundingBox:f,points:p,outlinePoints:g,polyPoints:m,centerPoint:im(g,l,c,d,u)};this.roomGeometryMap.set(r,y),a.push(y),this.mapBounds.minX=Math.min(this.mapBounds.minX,l),this.mapBounds.minY=Math.min(this.mapBounds.minY,c),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,d),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,u)}),o.forEach(e=>{const{coordinates:i}=t[e];if(i.length<4)return;const s=Number(e);let r=1/0,o=1/0,h=-1/0,l=-1/0;const c=[];for(let t=0;t<i.length;t+=2){const e=i[t],n=i[t+1];r=Math.min(r,e),o=Math.min(o,n),h=Math.max(h,e),l=Math.max(l,n),c.push({x:e,y:n})}const d=new Sn(r,o,h-r+1,l-o+1),u=$g(c),p=u.flatMap(t=>[t.x+.5,t.y+.5]),f=im(u,r,o,h,l),g={id:s,color:n,boundingBox:d,points:c,outlinePoints:u,polyPoints:p,centerPoint:f};a.push(g),this.mapBounds.minX=Math.min(this.mapBounds.minX,r),this.mapBounds.minY=Math.min(this.mapBounds.minY,o),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,h),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,l)}),a}mergeLayerBounds(){let t={...this.mapBounds};if(this.obstacle.bounds&&(t=Am(t,this.obstacle.bounds)),this.roomFill.children.length>0){const e=this.roomFill.getLocalBounds();e.width>0&&e.height>0&&(t=Am(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 vy,this.free.clear(),this.free.destroy(),this.free=new wy,this.carpet.clearCarpet(),this.carpetData=null,this.roomFill.removeChildren(),this.roomFill.destroy(),this.roomFill=new Sy}processRasterData(t){const e=Zi().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 s=[...i.map(([t,i],n)=>{const s=n%e.colors.active.length,r=n%e.colors.inactive.length;return{roomId:t,pixelIndices:i,activeColor:e.colors.active[s],inactiveColor:e.colors.inactive[r]}}),...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:s,width:t.width,height:t.height,totalPixels:t.totalPixels}}generateRoomGeometryFromRaster(t){const e=Zi();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),n.forEach((e,n)=>{const s=t.rooms.get(e);this.rasterRoomPixelsMap.set(e,s);let r=1/0,o=1/0,a=-1/0,h=-1/0;for(let e=0;e<s.length;e++){const i=s[e],n=i%t.width,l=Math.floor(i/t.width);r=Math.min(r,n),o=Math.min(o,l),a=Math.max(a,n),h=Math.max(h,l)}const l=((t,e,i,n,s,r)=>{const o=new Set(t),a=((t,e)=>{let i=0,n=0;for(let s=0;s<t.length;s++){const r=t[s];i+=r%e,n+=Math.floor(r/e)}return{x:i/t.length,y:n/t.length}})(t,e),h=((t,e,i,n,s,r,o)=>{const a={x:n-10,y:t.y},h={x:r+10,y:t.y},l={x:r,y:s},c={x:r,y:o},d=Sm(a,h,{x:n,y:s},{x:n,y:o}),u=Sm(a,h,l,c);if(!d||!u)return null;const p=[],f=Math.max(n,Math.min(d.x,u.x)),g=Math.min(r,Math.max(d.x,u.x)),m=Math.round(t.y);for(let t=Math.round(f);t<=Math.round(g);t++){const n=m*i+t;e.has(n)&&p.push({x:t,y:m})}if(p.length>=2){const t=(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 s=1;s<t.length;s++){const r=t[s];n(r)<n(e)&&(e=r),n(r)>n(i)&&(i=r)}return{min:e,max:i}})(p),n={x:(t.min.x+t.max.x)/2,y:(t.min.y+t.max.y)/2},s=Math.round(n.y)*i+Math.round(n.x);if(e.has(s))return n}return null})(a,o,e,i,n,s,r);return h||a})(s,t.width,r,o,a,h),c=n%i.length,d={id:e,color:i[c],boundingBox:new Sn(r,o,a-r+1,h-o+1),points:[],outlinePoints:[],polyPoints:[],centerPoint:l};this.roomGeometryMap.set(e,d)})}getRasterRoomPixels(t){return this.rasterRoomPixelsMap.get(t)}destroy(){this.obstacle.destroy(),this.free.destroy(),this.roomFill.destroy(),this.carpet.destroy(),this.chargingStation.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}class lx extends Hs{commonPath;chargePath;transitionsPath;mopPath;pathData=null;lastPointCount=0;lastDrawnPosition=null;isRealTimeDrawing=!1;throttledUpdateLineWidth;throttledHandleRobotPosition;constructor(){super({isRenderGroup:!0});const t=Zi();t.appContainer.addToLayer(dy,this),this.eventMode="none",this.commonPath=new Tl,this.chargePath=new Tl,this.transitionsPath=new Tl,this.mopPath=new Tl,this.addChild(this.commonPath),this.addChild(this.chargePath),this.addChild(this.transitionsPath),this.addChild(this.mopPath),this.visible=t.runtimeSnapshot.showPath,this.chargePath.visible=!1,this.transitionsPath.visible=!1,this.mopPath.visible=!1,this.throttledUpdateLineWidth=Ni(()=>{this.updateLineWidth()},50,{leading:!0,trailing:!0}),this.throttledHandleRobotPosition=Ni(this.handleRobotPositionUpdate.bind(this),0),this.registerEventListeners()}registerEventListeners(){const{emitter:t}=Zi();t.on("antiScale",this.throttledUpdateLineWidth),t.on("robotPositionUpdate",this.throttledHandleRobotPosition),t.on("robotAnimationComplete",this.handleRobotAnimationComplete)}handleRobotAnimationComplete=()=>{this.isRealTimeDrawing&&this.stopRealTimeDrawing()};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=Zi();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=Zi(),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 s=t[n],r=s.type||"common";let o;switch(r){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||r!==e?o.moveTo(s.x,s.y):o===i&&o.lineTo(s.x,s.y),e=r,i=o}}updatePositionByOrigin(t,e){this.position.set(t,e)}drawFull(t){Qg.debug("[Path] Draw Full Path",t),this.pathData=t,this.redrawPaths(t),this.lastPointCount=t.pathPoints?.length||0}drawIncremental(t){const e=Zi(),i=this.lastPointCount,n=t.pathPoints?.slice(i)||[];if(n.length>0)if(this.setupPathStyles(),Qg.debug("[Path] Draw Incremental Path",n),e.robotConfig.speed>0){if(this.isRealTimeDrawing=!0,i>0&&this.pathData?.pathPoints){const t=this.pathData.pathPoints[i-1];this.lastDrawnPosition={x:t.x,y:t.y}}}else this.drawNewPathSegments(n,i,t.pathPoints,this.pathData?.pathPoints);this.pathData=t,this.lastPointCount=t.pathPoints?.length||0}drawNewPathSegments(t,e,i,n){if(!i||0===t.length)return;let s=null;e>0&&(n&&n[e-1]?s=n[e-1]:i[e-1]&&(s=i[e-1]));let r=null,o=null,a=!1;for(let e=0;e<t.length;e++){const i=t[e],n=i.type||"common";let h;switch(n){case"common":default:h=this.commonPath;break;case"charge":h=this.chargePath;break;case"transitions":h=this.transitionsPath;break;case"mop":h=this.mopPath}n!==r||0===e?(o&&a&&o.stroke(),r=n,o=h,a=!0,s&&0===e&&s.type===n?(h.moveTo(s.x,s.y),h.lineTo(i.x,i.y)):h.moveTo(i.x,i.y)):h.lineTo(i.x,i.y)}o&&a&&o.stroke()}stopRealTimeDrawing(){this.isRealTimeDrawing=!1,this.lastDrawnPosition=null}destroy(t){const{emitter:e}=Zi();e.off("antiScale",this.throttledUpdateLineWidth),e.off("robotPositionUpdate",this.throttledHandleRobotPosition),e.off("robotAnimationComplete",this.handleRobotAnimationComplete),this.stopRealTimeDrawing(),super.destroy(t)}}class cx extends My{constructor(){super(),this.initializeSprite()}async initializeSprite(){const t=Zi();await this.loadTextureAndSetSize("robot",t.robotConfig.icon)}async draw({x:t,y:e,rotation:i}){super.draw({x:t,y:e,rotation:i})}}class dx extends Qy{unsubscribeFns=[];throttledUpdateOffset;fixedOffsetX=0;fixedOffsetY=0;constructor(t){super(t),this.throttledUpdateOffset=Ni(this.updateOffset.bind(this),30,{leading:!0,trailing:!0}),this.initializeAnimation()}static async create(){const t=Zi().robotConfig,e=await Qy.loadAnimationTextures(t.sleepAnimation.jsonSrc,t.sleepAnimation.framePrefix,t.sleepAnimation.frameCount);0===e.length&&(Qg.warn("No textures loaded for sleep animation"),e.push(Fn.EMPTY));const i=new dx(e);return i.setupAnimation({width:t.sleepAnimation.width,height:t.sleepAnimation.height,sizeFixed:t.sleepAnimation.sizeFixed}),i}initializeAnimation(){const t=Zi();this.visible=!1,this.fixedOffsetX=t.robotConfig.sleepAnimation.offsetX,this.fixedOffsetY=t.robotConfig.sleepAnimation.offsetY,t.emitter.on("antiScale",this.throttledUpdateOffset);const e=Yi(t.runtime,"showRobotSleepAnimation",t=>{Qg.log(`[runtime] showRobotSleepAnimation: ${t}`),this.updateVisibility()});this.unsubscribeFns.push(e)}shouldShow(){const t=Zi().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=Zi(),i=e.getApp().toFixedSize(e.robotConfig.sleepAnimation.offsetX),n=e.getApp().toFixedSize(e.robotConfig.sleepAnimation.offsetY),s={...t,x:t.x+i,y:t.y+n};super.draw(s,()=>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){Zi().emitter.off("antiScale",this.throttledUpdateOffset),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.stop(),super.destroy(t)}}class ux extends Hs{robot;ring;sleepAnimation=null;unsubscribeFns=[];targetPosition=null;targetRotation=null;isMoving=!1;pathQueue=[];lastPosition=null;currentPathType=void 0;lastUpdateTime=0;constructor(){super();const t=Zi();t.appContainer.addToLayer(xy,this),this.visible=t.runtimeSnapshot.showPath,this.ring=new rx({config:t.robotConfig}),this.ring.visible=t.runtimeSnapshot.showRobotRing,this.addChild(this.ring),this.robot=new cx,this.addChild(this.robot),this.lastUpdateTime=Date.now(),t.robotConfig.speed>0&&t.getApp().ticker.add(this.update,this);const e=Yi(t.runtime,"showRobotRing",t=>{Qg.log(`[runtime] showRobotRing: ${t}`),this.ring.visible=t});this.unsubscribeFns.push(e)}async initializeSleepAnimation(){try{this.sleepAnimation=await dx.create(),this.addChild(this.sleepAnimation),Qg.log("Sleep animation added to robot")}catch(t){Qg.error("Failed to initialize sleep animation:",t)}}updatePositionByOrigin(t,e){this.position.set(t,e)}async draw({x:t,y:e,rotation:i}){this.ring.draw({x:t,y:e}),await this.robot.draw({x:t,y:e,rotation:i}),this.sleepAnimation||await 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 Zi().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=Zi(),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,s=Math.sqrt(e*e+n*n),r=t.robotConfig.speed,o=t.getApp().metersToPixels(r);if(0===r)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);s<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/s),this.robot.y+=n*(a/s),Zi().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(){Zi().getApp().requestRender("robot-animation",!0)}set visible(t){super.visible=t,this.sleepAnimation&&this.sleepAnimation.onRobotVisibilityChanged()}get visible(){return super.visible}stopRobotAnimation(){Zi().getApp().stopRender("robot-animation")}remove(){this.pathQueue=[],this.isMoving=!1,this.targetPosition=null,this.stopRobotAnimation()}destroy(t){const e=Zi();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 px{path;robot;unsubscribeFns=[];lastDrawnPathData=null;constructor(){const t=Zi();this.path=new lx,this.robot=new ux;const e=Yi(t.runtime,"showPath",t=>{Qg.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){const e=Zi();if(!this.lastDrawnPathData)return!1;const i=t.pathHeader?.pathId,n=this.lastDrawnPathData.pathHeader?.pathId;if(i!==n)return!1;const s=(t.pathPoints?.length||0)-(this.lastDrawnPathData.pathPoints?.length||0),r=e.pathConfig.incrementalThreshold;return!(s<=0||s>r)}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+Zi().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){const e=Zi();if(!this.lastDrawnPathData||!t.pathPoints)return;this.path.drawIncremental(t);const i=this.lastDrawnPathData.pathPoints?.length||0,n=t.pathPoints.slice(i);if(0!==n.length)if(e.robotConfig.speed>0)n.forEach(e=>{this.moveRobotToPoint(e,t.pathHeader.direction,!0)});else{const e=n[n.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 fx extends Hs{colorGradients=[];cellSize=2;constructor(){super();const t=Zi();t.appContainer.addToLayer(cy,this);const e=t.heatMapConfig;this.colorGradients=e.colorGradients.map(t=>new ps(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=Zi().mapManager.roomFill.children.filter(t=>t instanceof Tl),i=new Tl;for(const t of e)i.context.instructions.push(...t.context.instructions);i.context.dirty=!0,t.setMask({mask:i}),this.addChild(i)}gridDrawing(t){const e=[],i=[],n=t.length,s=t[0].length;for(let r=0;r<n;r++)for(let n=0;n<s;n++){const s=t[r][n],o=this.cellSize/2,a=s.x-o,h=s.y-o,l=s.x+o,c=s.y+o;e.push(a,h),i.push(s.signal),e.push(l,h),i.push(s.signal),e.push(l,c),i.push(s.signal),e.push(a,h),i.push(s.signal),e.push(l,c),i.push(s.signal),e.push(a,c),i.push(s.signal)}const r=new da({attributes:{aPosition:new Float32Array(e),aSignal:new Float32Array(i)}}),o=new ao({glProgram:new Yr({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 Bl({geometry:r,shader:o});return a.alpha=.8,a}gradientDrawing(t){const e=[],i=[],n=t.length,s=t[0].length;for(let r=0;r<n;r++)for(let o=0;o<s;o++){const a=t[r][o],h=this.cellSize/2,l=(e,i)=>e<0||e>=n||i<0||i>=s?a.signal:t[e][i].signal,c=(l(r-1,o-1)+l(r-1,o)+l(r,o-1)+a.signal)/4,d=(l(r-1,o)+l(r-1,o+1)+a.signal+l(r,o+1))/4,u=(a.signal+l(r,o+1)+l(r+1,o)+l(r+1,o+1))/4,p=(l(r,o-1)+a.signal+l(r+1,o-1)+l(r+1,o))/4,f=a.x-h,g=a.y-h,m=a.x+h,y=a.y+h;e.push(f,g,m,g,m,y),i.push(c,d,u),e.push(f,g,m,y,f,y),i.push(c,u,p)}const r=new da({attributes:{aPosition:new Float32Array(e),aSignal:new Float32Array(i)}}),o=new ao({glProgram:new Yr({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 Bl({geometry:r,shader:o});return a.alpha=.8,a}}class gx{heatmap=new fx;pointsTopLeftOrigin=[];signalGrid=[];cellSize=2;maxDistance=14;smoothIterations=10;heatmapAlpha=.8;constructor(){const t=Zi().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=Zi(),s=t.origin[0],r=t.origin[1],{minX:o,minY:a}=n.mapManager.mapBounds,h=e.map(t=>({x:+(s+t.x-o).toFixed(0),y:+(r+t.y-a).toFixed(0),signal:t.signal}));this.signalGrid=this.calculateInterpolatedSignal(h),this.heatmap.draw(this.signalGrid,i,this.heatmapAlpha)}calculateInterpolatedSignal(t){const e=Zi(),{minX:i,minY:n,maxX:s,maxY:r}=e.mapManager.mapBounds,o=Math.ceil((r-n)/this.cellSize),a=Math.ceil((s-i)/this.cellSize),h=Array(o).fill(null).map(()=>Array(a).fill(null));for(let e=0;e<o;e++){const o=n+e*this.cellSize+this.cellSize/2,l=Math.min(this.cellSize,r-(o-this.cellSize/2));for(let n=0;n<a;n++){const r=i+n*this.cellSize+this.cellSize/2,a=Math.min(this.cellSize,s-(r-this.cellSize/2));let c=0,d=!1;for(let e=0;e<t.length;e++){const i=t[e];if(Math.abs(r-i.x)<=a/2&&Math.abs(o-i.y)<=l/2){const t=1-i.signal/7;c=Math.round(10*Math.max(c,t))/10,d=!0}}h[e][n]={x:r,y:o,signal:c,hasPoint:d}}}const l=(e,i)=>{if(0===t.length)return 0;let n=0,s=0;for(const r of t){const t=Math.sqrt((e-r.x)**2+(i-r.y)**2);if(t<=this.maxDistance){const e=1/(1+t);s+=e*(1-r.signal/7),n+=e}}return 0===n?0:Math.round(s/n*1e3)/1e3};for(let t=0;t<o;t++)for(let e=0;e<a;e++){const i=h[t][e];i.hasPoint||(i.signal=l(i.x,i.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 s=0,r=0;const h=4;for(let e=-h;e<=h;e++)for(let l=-h;l<=h;l++){if(0===e&&0===l)continue;const h=i+e,c=n+l;if(h>=0&&h<o&&c>=0&&c<a){const i=1/(1+.3*Math.sqrt(e*e+l*l));s+=t[h][c].signal*i,r+=i}}if(r>0){const o=s/r,a=.6,h=.4;e[i][n].signal=t[i][n].signal*a+o*h,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}})(h,this.smoothIterations),h}}class mx extends sx{constructor(t){const e=Zi();super({zoneData:t.zoneData,zoneType:"forbiddenSweepZone",events:{onRemove:t=>{e.events?.onRemoveForbiddenSweepZone?.(t)},onUpdate:t=>{e.events?.onUpdateForbiddenSweepZone?.(t)},onClick:t=>{e.events?.onClickForbiddenSweepZone?.(t)}}})}static create(t){return new mx({zoneData:t})}}class yx extends sx{constructor(t){const e=Zi();super({zoneData:t.zoneData,zoneType:"forbiddenMopZone",events:{onRemove:t=>{e.events?.onRemoveForbiddenMopZone?.(t)},onUpdate:t=>{e.events?.onUpdateForbiddenMopZone?.(t)},onClick:t=>{e.events?.onClickForbiddenMopZone?.(t)}}})}static create(t){return new yx({zoneData:t})}}class xx extends sx{constructor(t){const e=Zi();super({zoneData:t.zoneData,zoneType:"cleanZone",events:{onRemove:t=>{e.events?.onRemoveCleanZone?.(t)},onUpdate:t=>{e.events?.onUpdateCleanZone?.(t)},onClick:t=>{e.events?.onClickCleanZone?.(t)}}})}static create(t){return new xx({zoneData:t})}}class bx extends Hs{static BUTTON_INDICES={REMOVE:0,SCALE:2,MOVE:3};wallData;wallConfig;controlsConfig;wallEvents;wallLine;outlineBorder;moveLine;lengthText;controlButtons;removeButton=null;scaleButton=null;moveButton=null;initialWallPoints=[];isDragging=!1;dragStartPosition=null;throttledUpdateOutline;throttledHandleScaleChange;wallLineClickHandler=null;constructor(t){super();const{wallData:e,events:i={}}=t;this.wallEvents=i;const n=Zi();this.wallConfig=n.controlsConfig.virtualWall,this.controlsConfig=n.controlsConfig,this.wallData={...e,points:this.validateAndCorrectWallLength(e.points)},this.throttledHandleScaleChange=Ni(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.throttledUpdateOutline=Ni(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.registerScaleListener(),this.setupDragEventListeners()}validateAndCorrectWallLength(t){const e=Zi();if(t.length<2)return t;const[i,n]=t,s=e.metersToPixels(this.wallConfig.minWidth),r=pm(i,n);if(r>=s)return t;if(0===r)return[i,{x:i.x+s,y:i.y}];const o=mm(gm(i,n));return[i,{x:i.x+o.x*s,y:i.y+o.y*s}]}isEditingEnabled(){return Zi().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 Hs,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:s,normal:r}=this.wallConfig,o=this.isEditingEnabled()?s:r;o.isDashed?this.wallLine=new By({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 $y({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 s=this.calculateTextRotation();return i.rotation=s,i.eventMode="none",i}calculateWallLengthInMeters(){const t=Zi(),{points:e}=this.wallData;if(e.length<2)return 0;const i=pm(e[0],e[1]);return t.pixelsToMeters(i)}formatLengthText(t){return`${t.toFixed(1)}${this.controlsConfig.unitLabel}`}calculateTextPosition(){const t=Zi(),{points:e}=this.wallData;if(e.length<2)return{x:0,y:0};const[i,n]=e;return((t,e,i)=>{const n=cm([t,e]),s=bm(t,e);return{x:n.x+s.x*i,y:n.y+s.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 vm(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 Py({points:t,closePath:!0,style:this.getOutlineStyle()})}createMoveLine(){const t=this.calculateOutlinePoints(),e=this.calculateMoveLinePoints(t);return new Py({points:e,closePath:!1,style:this.getOutlineStyle()})}calculateOutlinePoints(t){const e=Zi(),i=t||this.wallData.points;if(i.length<2)return i;const n=e.getApp().toFixedSize(this.wallConfig.outlineOffset),s=((t,e,i)=>{if(0===pm(t,e))return[t,t,t,t];const n=ym(t,e),s=xm(n),r=t.x-n.x*i,o=t.y-n.y*i,a=e.x+n.x*i,h=e.y+n.y*i;return[{x:r+s.x*i,y:o+s.y*i},{x:a+s.x*i,y:h+s.y*i},{x:a-s.x*i,y:h-s.y*i},{x:r-s.x*i,y:o-s.y*i}]})(i[0],i[1],n);return[s[3],s[2],s[1],s[0]]}calculateMoveLinePoints(t){if(t.length<4)return[];const{MOVE:e}=bx.BUTTON_INDICES;return[t[e],this.calculateMoveButtonPosition()]}calculateMoveButtonPosition(){const t=Zi(),{moveButtonOffset:e}=this.controlsConfig,i=this.calculateOutlinePoints();if(i.length<4)return{x:0,y:0};const{MOVE:n}=bx.BUTTON_INDICES,s=i[n],r=i[(n+3)%4],o=i[(n+1)%4],a=t.getApp().toFixedSize(e);return Cm(s,o,r,a)}createControlButtons(){const t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:e,SCALE:i}=bx.BUTTON_INDICES;this.removeButton=new ex({iconAlias:"deleteIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onClick:this.handleRemove}),this.removeButton.position.set(t[e].x,t[e].y),this.scaleButton=new nx({iconAlias:"scaleIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,getTargetPoints:()=>this.calculateOutlinePoints(),getButtonIndex:()=>i,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(t[i].x,t[i].y);const n=this.calculateMoveButtonPosition();this.moveButton=new tx({iconAlias:"moveIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(n.x,n.y),this.controlButtons.addChild(this.removeButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}handleRemove=()=>{this.wallEvents.onRemove?.(this.wallData.id)};initializeOperation=()=>{this.initialWallPoints=this.wallData.points.map(t=>({...t}))};finalizeOperation=()=>{this.initialWallPoints=[],this.wallEvents.onUpdate?.(this.getWallData())};handleScaleStart=()=>{const t=Zi();this.initializeOperation(),t.getApp().requestRender("virtualwall-scale",!0)};handleScaleMove=t=>{0!==this.initialWallPoints.length&&this.applyScaleAndRotation(t)};handleScaleEnd=()=>{const t=Zi();this.finalizeOperation(),t.getApp().stopRender("virtualwall-scale")};handleMoveStart=()=>{const t=Zi();this.initializeOperation(),t.getApp().requestRender("virtualwall-move",!0)};handleMove=t=>{if(0===this.initialWallPoints.length)return;const e=this.parent.toLocal(t.global),i=this.getDragStartPosition()||this.moveButton?.getDragStartPosition();if(!i)return;const n=e.x-i.x,s=e.y-i.y;this.applyTranslation(n,s)};handleMoveEnd=()=>{const t=Zi();this.finalizeOperation(),t.getApp().stopRender("virtualwall-move")};applyScaleAndRotation(t){const e=Zi();if(this.initialWallPoints.length<2)return;const[i,n]=this.initialWallPoints,s=i,r=this.calculateOutlinePoints(this.initialWallPoints);if(r.length<4)return;const o=r[bx.BUTTON_INDICES.SCALE],a=gm(n,o),h={x:t.x-a.x,y:t.y-a.y},l=gm(s,h),c=pm(s,h),d=e.metersToPixels(this.wallConfig.minWidth);let u;if(c<d)if(0===c)u={x:s.x+d,y:s.y};else{const t=mm(l);u={x:s.x+t.x*d,y:s.y+t.y*d}}else u=h;this.wallData.points=[s,u],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 By?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 t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:e,SCALE:i}=bx.BUTTON_INDICES,n=this.calculateMoveButtonPosition();this.removeButton.position.set(t[e].x,t[e].y),this.scaleButton.position.set(t[i].x,t[i].y),this.moveButton.position.set(n.x,n.y)}updateEditState(){const t=this.isEditingEnabled();this.controlButtons.visible=t,this.outlineBorder.visible=t,this.moveLine.visible=t,this.lengthText&&(this.lengthText.visible=t),t&&(this.updateOutlineComponents(),this.updateControlButtonsPosition(),this.updateLengthTextPosition()),this.updateWallLineStyle(),this.setupWallLineInteraction(),this.zIndex=t?1e3:0}createSolidLine(t,e,i,n){const s=Zi(),r=new Tl;r.eventMode="static";const o=s.getApp().toFixedSize(i);return r.moveTo(t.x,t.y),r.lineTo(e.x,e.y),r.stroke({color:n,width:o}),r}updateWallLineStyle(){const t=this.isEditingEnabled(),{editing:e,normal:i,lineWidth:n,lineColor:s}=this.wallConfig,r=t?e:i;this.wallLine instanceof By!==r.isDashed?(this.removeChild(this.wallLine),this.wallLine.destroy(),this.createWallLine(!1),this.addChild(this.wallLine)):this.wallLine instanceof By?this.wallLine.updateStyle({color:s.toString(),width:n,dashArray:r.dashArray}):this.redrawSolidLine()}registerScaleListener(){const{emitter:t}=Zi();t.on("antiScale",this.throttledUpdateOutline),t.on("antiScale",this.throttledHandleScaleChange)}redrawSolidLine(){const t=Zi();if(!this.wallLine||this.wallLine instanceof By)return;const{points:e}=this.wallData;if(e.length<2)return;const{lineWidth:i,lineColor:n}=this.wallConfig,s=t.getApp().toFixedSize(i);this.wallLine.clear(),this.wallLine.setStrokeStyle({color:n.toString(),width:s}).moveTo(e[0].x,e[0].y).lineTo(e[1].x,e[1].y).stroke()}handleScaleChange=()=>{this.redrawSolidLine(),this.setupWallLineHitArea()};setupWallLineInteraction(){if(!this.wallLine)return;this.setupWallLineHitArea();const t=this.isEditingEnabled();this.wallLineClickHandler?.destroy(),this.wallLineClickHandler=null,this.wallLine.off("pointerdown",this.handleWallLinePointerDown),t?this.wallLine.on("pointerdown",this.handleWallLinePointerDown):this.wallLineClickHandler=new Cy(this.wallLine,{onClick:()=>{this.wallEvents?.onClick?.(this.getWallData())},stopPropagation:!1})}setupDragEventListeners(){const{emitter:t}=Zi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Zi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handleWallLinePointerDown=t=>{this.isEditingEnabled()&&(t.stopPropagation(),this.startDragging(t))};startDragging(t){const e=Zi();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),Zi().emitter.emit("gestureHijackStart",t)}handleDragPointerMove=t=>{this.isDragging&&this.dragStartPosition&&this.handleMove(t)};handleDragPointerUp=()=>{const t=Zi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("virtualwall-drag"),this.finalizeOperation())};handleDragCancel=()=>{const t=Zi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("virtualwall-drag"),this.handleMoveEnd())};getDragStartPosition(){return this.dragStartPosition}setupWallLineHitArea(){const t=Zi();if(!this.wallLine)return;const{points:e}=this.wallData;if(e.length<2)return;const{hitAreaThickness:i}=this.wallConfig,n=t.getApp().toFixedSize(i),s=wm(e[0],e[1],n);if(0===s.length)return;const r=new Jo(s);this.wallLine.hitArea=r}getWallData(){return{...this.wallData}}updateWallData(t){this.wallData={...t,points:this.validateAndCorrectWallLength(t.points)},this.updateAllComponents(),this.updateControlButtonsPosition()}updateEditingState(){this.updateEditState()}destroy(){Zi().emitter.off("antiScale",this.throttledUpdateOutline),Zi().emitter.off("antiScale",this.throttledHandleScaleChange),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.wallLine&&this.wallLine.off("pointerdown",this.handleWallLinePointerDown),this.wallLineClickHandler?.destroy(),this.wallLineClickHandler=null,this.wallLine?.destroy(),this.lengthText?.destroy(),this.outlineBorder?.destroy(),this.moveLine?.destroy(),this.controlButtons?.destroy(),this.removeButton?.destroy(),this.scaleButton?.destroy(),this.moveButton?.destroy(),this.removeButton=null,this.scaleButton=null,this.moveButton=null,super.destroy()}}class _x extends Hs{spotData;spotConfig;controlsConfig;spotEvents;controlFill;spotBorder;centerIcon;sizeText;clickHandler=null;initialSpotPoint=null;throttledUpdateScale;constructor(t){super();const{spotData:e,events:i={}}=t,n=Zi();this.spotData=e,this.spotEvents=i,this.controlsConfig=n.controlsConfig,this.spotConfig=n.controlsConfig.spot,this.throttledUpdateScale=Ni(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){Zi().emitter.on("antiScale",this.throttledUpdateScale)}updateScale(){this.isEditingEnabled()&&this.updateSizeTextPosition()}isEditingEnabled(){return Zi().runtimeSnapshot.editingSpotIds.includes(this.spotData.id)}calculateRectanglePoints(){const t=Zi(),{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 Ey({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 Py({points:t,closePath:!0,style:{color:this.spotConfig.strokeColor,width:this.spotConfig.strokeWidth,isDashed:e.isDashed,dashArray:e.dashArray}})}createCenterIcon(){const t=new My;return this.loadIconTexture(t),t.position.set(this.spotData.point.x,this.spotData.point.y),t.eventMode="none",t.visible=!1,t}async loadIconTexture(t){const{iconSize:e}=this.spotConfig;await t.loadTextureAndSetSize("spotIcon",{width:e,height:e,sizeFixed:!1}),t.visible=this.isEditingEnabled()}createSizeText(){const t=this.calculateSpotSizeText(),e=new $y({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=Zi(),e=this.calculateRectanglePoints();if(e.length<4)return{x:0,y:0};const[i,n,s,r]=e,{textPosition:o,textOffset:a}=this.spotConfig,h=t.getApp().toFixedSize(a);let l,c;switch(o){case"top":default:l={x:(i.x+n.x)/2,y:(i.y+n.y)/2},c={x:l.x,y:l.y+h};break;case"right":l={x:(n.x+s.x)/2,y:(n.y+s.y)/2},c={x:l.x+h,y:l.y};break;case"bottom":l={x:(r.x+s.x)/2,y:(r.y+s.y)/2},c={x:l.x,y:l.y+h};break;case"left":l={x:(i.x+r.x)/2,y:(i.y+r.y)/2},c={x:l.x-h,y:l.y}}return c}handleDragStart=()=>{const t=Zi();this.isEditingEnabled()&&(this.initialSpotPoint={...this.spotData.point},t.getApp().requestRender("spot-drag",!0))};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,s=e.y-i.y;this.applyTranslation(n,s)};handleDragEnd=()=>{const t=Zi();this.initialSpotPoint=null,t.getApp().stopRender("spot-drag"),this.spotEvents.onUpdate?.(this.getSpotData())};applyTranslation(t,e){this.initialSpotPoint&&(this.spotData.point={x:this.initialSpotPoint.x+t,y:this.initialSpotPoint.y+e},this.drawSpot())}setupClickHandler(){this.clickHandler=new Cy(this,{onClick:()=>{this.isEditingEnabled()||this.spotEvents?.onClick?.(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={...t},this.drawSpot(),this.updateEditState()}getSpotData(){return{...this.spotData}}destroy(){Zi().emitter.off("antiScale",this.throttledUpdateScale),this.clickHandler?.destroy(),this.clickHandler=null,this.controlFill?.destroy(),this.spotBorder?.destroy(),this.centerIcon?.destroy(),this.sizeText?.destroy(),super.destroy()}static create(t){const e=Zi();return new _x({spotData:t,events:{onUpdate:t=>{e.events?.onUpdateSpot?.(t)},onClick:t=>{e.events?.onClickSpot?.(t)}}})}}class vx extends Hs{endPoints;dividerConfig;dividerEvents;roomId;roomGeometry=null;dashLine;solidLine=null;startEndPoint;endEndPoint;solidLinePoints=null;initialDividerPoints=[];isDragging=!1;dragStartPosition=null;throttledHandleScaleChange;constructor(t){super();const{endPoints:e,roomId:i,events:n={}}=t;this.dividerEvents=n,this.roomId=i;const s=Zi();this.dividerConfig=s.dividerConfig,this.roomGeometry=s.mapManager.getRoomById(this.roomId)||null,this.endPoints=e?this.validateDividerPoints(e):this.createDefaultdividerPoints(),this.throttledHandleScaleChange=Ni(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 Qg.warn("Room geometry not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const t=Zi(),e=t.getApp().mapState;if(!e)return Qg.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),s=this.dividerConfig.defaultDirection,r=i.x+i.width/2,o=i.y+i.height/2,a="horizontal"===s?i.width+2*n:i.height+2*n;return Mm(r,o,a,s).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 By({start:t[0],end:t[1],style:{color:n.toString(),width:e,dashArray:i}})}createEndPoints(){const t=this.endPoints;this.startEndPoint=new Oy({position:t[0],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:t=>this.handleEndPointDragMove(0,t),onDragEnd:this.handleEndPointDragEnd}),this.endEndPoint=new Oy({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=Zi();if(!this.dashLine)return;const e=this.endPoints;if(e.length<2)return;const{hitAreaThickness:i}=this.dividerConfig,n=t.getApp().toFixedSize(i),s=wm(e[0],e[1],n);if(0===s.length)return;const r=new Jo(s);this.dashLine.hitArea=r}handleEndPointDragStart=()=>{const t=Zi();this.initialDividerPoints=this.endPoints.map(t=>({...t})),this.clearSolidLine(),t.getApp().requestRender("divider-endpoint-drag",!0)};handleEndPointDragMove=(t,e)=>{0!==this.initialDividerPoints.length&&(this.endPoints[t]=e,this.updateDashLine(),this.updateSolidLine(),this.setupDashLineHitArea())};handleEndPointDragEnd=()=>{const t=Zi();this.initialDividerPoints=[],t.getApp().stopRender("divider-endpoint-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),this.dividerEvents.onUpdate?.(this.getDividerEndPoints())};handleDashLinePointerDown=t=>{t.stopPropagation(),this.startDragging(t)};startDragging(t){const e=Zi();this.isDragging=!0;const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},this.initialDividerPoints=this.endPoints.map(t=>({...t})),this.clearSolidLine(),e.getApp().requestRender("divider-drag",!0),Zi().emitter.emit("gestureHijackStart",t)}setupDragEventListeners(){const{emitter:t}=Zi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Zi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}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()};handleDragPointerUp=()=>{const t=Zi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],t.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),this.dividerEvents.onUpdate?.(this.getDividerEndPoints()))};handleDragCancel=()=>{const t=Zi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],t.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),this.dividerEvents.onUpdate?.(this.getDividerEndPoints()))};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=Zi().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}=Zi();t.on("antiScale",this.throttledHandleScaleChange)}handleScaleChange=()=>{this.startEndPoint?.redraw(),this.endEndPoint?.redraw(),this.updateSolidLine(),this.setupDashLineHitArea()};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=Zi().mapManager.roomFill;return t&&this.roomId&&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),s=this.isPointInRoomFill(i);if(n||s)return null;const r=((t,e,i=1,n=2e3)=>{const s=[],r=e.x-t.x,o=e.y-t.y,a=Math.sqrt(r*r+o*o);if(0===a)return[t];const h=Math.min(Math.max(Math.ceil(a/i),2),n);for(let e=0;e<=h;e++){const i=e/h,n={x:t.x+i*r,y:t.y+i*o};s.push(n)}return s})(e,i),o=[];for(const t of r)this.isPointInRoomFill(t)&&o.push(t);if(0===o.length)return null;const a=o[0],h=o[o.length-1];if(pm(a,h)<3)return null;const l=((t,e,i)=>{const n=e.x-t.x,s=e.y-t.y,r=Math.sqrt(n*n+s*s);if(0===r)return[t,e];const o=n/r,a=s/r;return[{x:t.x-o*i,y:t.y-a*i},{x:e.x+o*i,y:e.y+a*i}]})(a,h,.5);return l}isPointInRoomFill(t){if(!this.roomId)return!1;const e=Zi().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=Zi(),i=e.getApp().mapState,n=e.mapManager.roomFill;if(!i||!n)return!1;const s=n.getRasterRoomData(this.roomId);if(!s)return!1;const r=n.getMapWidth();if(0===r)return!1;const o=Math.round(t.y)*r+Math.round(t.x);for(let t=0;t<s.pixelIndices.length;t++)if(s.pixelIndices[t]===o)return!0;return!1}isPointInStructuredRoomFill(t){const e={x:Math.round(t.x),y:Math.round(t.y)},i=Zi(),n=i.getApp().mapState,s=i.mapManager.getRoomById(this.roomId);return!!(n&&s&&s.outlinePoints)&&om(e,s.outlinePoints,!0)}isRasterData(){const t=Zi().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=Zi().getApp().mapState;return!!i&&!((t,e,i,n,s,r)=>{const o=i+s,a=n+r,h=Math.min(t.x,e.x),l=Math.max(t.x,e.x),c=Math.min(t.y,e.y),d=Math.max(t.y,e.y);if(l<i||h>o||d<n||c>a)return!1;if(Im(t,i,n,s,r)||Im(e,i,n,s,r))return!0;const u=[{x:i,y:n},{x:o,y:n},{x:o,y:a},{x:i,y:a}];for(let i=0;i<4;i++)if(Sm(t,e,u[i],u[(i+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=Zi(),{resetDividerWhenOutOfRoom:e}=t.dividerConfig;e&&this.isDividerCompletelyOutOfRoom()&&this.resetToDefaultState()}resetToDefaultState(){this.endPoints=this.createDefaultdividerPoints(),this.calculateAndCreateSolidLine(),this.updateComponents(),this.dividerEvents.onUpdate?.(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=Zi();this.solidLine=new Tl,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(){Zi().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(),this.dashLine?.destroy(),this.startEndPoint?.destroy(),this.endEndPoint?.destroy(),super.destroy()}}class wx{forbiddenSweepZoneMap=new Map;forbiddenMopZoneMap=new Map;cleanZoneMap=new Map;virtualWallMap=new Map;spotMap=new Map;divider=null;unsubscribeFns=[];constructor(){const t=Zi(),e=Yi(t.runtime,"editingForbiddenSweepZoneIds",t=>{Qg.log(`[runtime] editingForbiddenSweepZoneIds: ${t}`),this.updateZonesEditState(this.forbiddenSweepZoneMap)}),i=Yi(t.runtime,"editingForbiddenMopZoneIds",t=>{Qg.log(`[runtime] editingForbiddenMopZoneIds: ${t}`),this.updateZonesEditState(this.forbiddenMopZoneMap)}),n=Yi(t.runtime,"editingCleanZoneIds",t=>{Qg.log(`[runtime] editingCleanZoneIds: ${t}`),this.updateZonesEditState(this.cleanZoneMap)}),s=Yi(t.runtime,"editingVirtualWallIds",t=>{Qg.log(`[runtime] editingVirtualWallIds: ${t}`),this.updateVirtualWallsEditState(this.virtualWallMap)}),r=Yi(t.runtime,"editingSpotIds",t=>{Qg.log(`[runtime] editingSpotIds: ${t}`),this.updateSpotsEditState(this.spotMap)}),o=Yi(t.runtime,"dividingRoomId",t=>{Qg.log(`[runtime] dividingRoomId: ${t}`),this.handleDividingRoomIdChange(t)});this.unsubscribeFns.push(e,i,n,s,r,o)}updatePositionByOrigin(t,e){const i=Zi().appContainer.getLayer(uy);i&&i.position.set(t,e)}drawForbiddenSweepZones(t){this.drawZones(t,this.forbiddenSweepZoneMap,t=>mx.create(t))}getForbiddenSweepZones(){return this.getZonesData(this.forbiddenSweepZoneMap)}clearAllForbiddenSweepZones(){this.clearAllZones(this.forbiddenSweepZoneMap)}drawForbiddenMopZones(t){this.drawZones(t,this.forbiddenMopZoneMap,t=>yx.create(t))}getForbiddenMopZones(){return this.getZonesData(this.forbiddenMopZoneMap)}clearAllForbiddenMopZones(){this.clearAllZones(this.forbiddenMopZoneMap)}drawCleanZones(t){this.drawZones(t,this.cleanZoneMap,t=>xx.create(t))}getCleanZones(){return this.getZonesData(this.cleanZoneMap)}clearAllCleanZones(){this.clearAllZones(this.cleanZoneMap)}drawVirtualWalls(t){const e=Zi(),i=this.virtualWallMap,n=new Set(t.map(t=>t.id));for(const[t,s]of i)n.has(t)||(e.appContainer.removeFromLayer(uy,s),s.destroy(),i.delete(t));t.forEach(t=>{const n=i.get(t.id);if(n)this.isWallDataEqual(n.getWallData(),t)||n.updateWallData(t);else{const n=new bx({wallData:t,events:{onRemove:t=>{e.events?.onRemoveVirtualWall?.(t)},onUpdate:t=>{e.events?.onUpdateVirtualWall?.(t)},onClick:t=>{e.events?.onClickVirtualWall?.(t)}}});i.set(t.id,n),e.appContainer.addToLayer(uy,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 t of i)n.has(t)||this.removeSpot(t,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()),s=new Set(t.map(t=>t.id));for(const t of n)s.has(t)||this.removeZone(t,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=Zi(),s=i(t);e.set(t.id,s),n.appContainer.addToLayer(uy,s)}removeZone(t,e){const i=Zi(),n=e.get(t);n&&(i.appContainer.removeFromLayer(uy,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)=>{const n=t.get(i);n&&(n.parent?.removeChild(n),n.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],s=e.points[i];if(Math.abs(n.x-s.x)>.1||Math.abs(n.y-s.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],s=e.points[i];if(Math.abs(n.x-s.x)>.1||Math.abs(n.y-s.y)>.1)return!1}return!0}addNewSpot(t,e){const i=Zi(),n=_x.create(t);e.set(t.id,n),i.appContainer.addToLayer(uy,n)}removeSpot(t,e){const i=Zi(),n=e.get(t);n&&(i.appContainer.removeFromLayer(uy,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)=>{const n=t.get(i);n&&(n.parent?.removeChild(n),n.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){null!=t&&this.getRoomGeometry(t)?this.createDefaultDivider(t):this.clearDivider()}getRoomGeometry(t){return Zi().mapManager.getRoomById(t)}createDefaultDivider(t){const e=Zi();this.clearDivider(),this.divider=new vx({roomId:t,events:{onUpdate:t=>{e.events?.onUpdateDivider?.(t)}}}),e.appContainer.addToLayer(uy,this.divider)}clearDivider(){this.divider&&(Zi().appContainer.removeFromLayer(uy,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 Cx extends My{objectData;clickHandler=null;constructor(t){super(),this.objectData=t}async initializeSprite(){const t=Zi().detectedObjectConfig,e=this.objectData.width||t.width,i=this.objectData.height||t.height;await 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 Cy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){const t=Zi();t.events?.onClickDetectedObject?.(this.getObjectData())}getObjectData(){return{...this.objectData}}async updateObjectData(t){const e=Zi(),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;await 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 Sx{detectedObjectMap=new Map;updatePositionByOrigin(t,e){const i=Zi().appContainer.getLayer(fy);i&&i.position.set(t,e)}async drawDetectedObjects(t){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 e of t){const t=this.detectedObjectMap.get(e.id);t?t.isSameData(e)||await t.updateObjectData(e):await this.addNewDetectedObject(e)}}clearAllDetectedObjects(){const t=Zi();this.detectedObjectMap.forEach(e=>{t.appContainer.removeFromLayer(fy,e),e.destroy()}),this.detectedObjectMap.clear()}async addNewDetectedObject(t){const e=Zi(),i=new Cx(t);await i.initializeSprite(),this.detectedObjectMap.set(t.id,i),e.appContainer.addToLayer(fy,i)}removeDetectedObject(t){const e=Zi(),i=this.detectedObjectMap.get(t);i&&(e.appContainer.removeFromLayer(fy,i),i.destroy(),this.detectedObjectMap.delete(t))}destroy(){this.clearAllDetectedObjects()}}class Ax extends My{elementData;clickHandler=null;constructor(t){super(),this.elementData=t}async initialize(){await this.loadTextureAndSetSize(this.elementData.src,{width:this.elementData.width,height: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 Cy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){const t=Zi();t.events?.onClickCustomElement?.(this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const e=this.elementData;this.elementData=t,e.src!==t.src&&await this.loadTextureAndSetSize(t.src,{width:t.width,height:t.height}),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}destroy(){this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class Ix extends qy{elementData;clickHandler=null;constructor(t,e){super({source:t}),this.elementData=e}async initialize(){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 Cy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){const t=Zi();t.events?.onClickCustomElement?.(this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const e=this.elementData;if(this.elementData=t,e.src!==t.src)throw new Error("GIF source change requires recreation of instance");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}destroy(){this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class Mx extends ky{elementData;domClickHandler=null;resizeObserver=null;constructor(t){const e=document.createElement("div");Mx.setupDefaultStyles(e,t),e.innerHTML=t.htmlContent,super({element:e}),this.elementData=t}async initialize(){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=>{const e=t[0];e&&e.contentRect.width>0&&e.contentRect.height>0&&(this.setFixedSize(e.contentRect.width,e.contentRect.height),0===this.alpha&&this.showElement(),this.resizeObserver?.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(){this.alpha=this.elementData.opacity??1,this.element.style.pointerEvents=this.elementData.interactive?"auto":"none",this.interactive=this.elementData.interactive??!1,this.elementData.interactive&&this.element&&(this.element.style.setProperty("-webkit-tap-highlight-color","transparent"),this.element.style.setProperty("-webkit-touch-callout","none"))}setupClickHandler(){this.element&&(this.domClickHandler=t=>{t.preventDefault(),t.stopPropagation(),this.handleClick()},this.element.addEventListener("click",this.domClickHandler))}handleClick(){const t=Zi();t.events?.onClickCustomElement?.(this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const e=this.elementData;this.elementData=t,e.htmlContent!==t.htmlContent&&this.element&&(this.element.innerHTML=t.htmlContent,t.width&&t.height||this.waitForElementDimensions()),e.width===t.width&&e.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=t.rotation??0,this.alpha=t.opacity??1,t.interactive?this.domClickHandler||this.setupClickHandler():(this.eventMode="none",this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null))}isSameData(t){return this.elementData.id===t.id&&this.elementData.type===t.type&&this.elementData.htmlContent===t.htmlContent&&this.elementData.x===t.x&&this.elementData.y===t.y&&this.elementData.width===t.width&&this.elementData.height===t.height&&this.elementData.rotation===t.rotation&&this.elementData.opacity===t.opacity&&this.elementData.interactive===t.interactive}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 Tx{customElementsMap=new Map;gifTicker=null;gifElements=new Set;constructor(){}updatePositionByOrigin(t,e){const i=Zi(),n=i.appContainer.getLayer(gy),s=i.appContainer.getLayer(my);n&&n.position.set(t,e),s&&s.position.set(t,e)}async drawCustomElements(t){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(async t=>{const e=this.customElementsMap.get(t.id);e?this.isSameData(e,t)||("gif"===t.type&&e.getElementData().src!==t.src?(this.removeCustomElement(t.id),await this.addNewCustomElement(t)):await this.updateElementData(e,t)):await this.addNewCustomElement(t)});await Promise.all(n),this.updateGifTicker()}clearAllCustomElements(){const t=Zi();this.customElementsMap.forEach(e=>{e instanceof Ix?t.appContainer.removeFromLayer(my,e):t.appContainer.removeFromLayer(gy,e),e.destroy()}),this.customElementsMap.clear(),this.gifElements.clear(),this.stopGifTicker()}async addNewCustomElement(t){const e=Zi();let i;switch(t.type){case"image":i=new Ax(t);break;case"gif":{const e=await al.load(t.src);i=new Ix(e,t);break}case"html":i=new Mx(t);break;default:throw new Error(`Unsupported custom element type: ${t.type}`)}await i.initialize(),this.customElementsMap.set(t.id,i),i instanceof Ix?(e.appContainer.addToLayer(my,i),this.gifElements.add(i)):e.appContainer.addToLayer(gy,i)}removeCustomElement(t){const e=Zi(),i=this.customElementsMap.get(t);i&&(i instanceof Ix?(this.gifElements.delete(i),e.appContainer.removeFromLayer(my,i)):e.appContainer.removeFromLayer(gy,i),i.destroy(),this.customElementsMap.delete(t))}isSameData(t,e){return t.getElementData().type===e.type&&("image"===e.type&&t instanceof Ax||"gif"===e.type&&t instanceof Ix||"html"===e.type&&t instanceof Mx)&&t.isSameData(e)}async updateElementData(t,e){if("image"===e.type&&t instanceof Ax)await t.updateElementData(e);else if("gif"===e.type&&t instanceof Ix)await t.updateElementData(e);else{if(!("html"===e.type&&t instanceof Mx))throw new Error("Element type mismatch during update");await t.updateElementData(e)}}updateGifTicker(){this.gifElements.size>0?this.startGifTicker():this.stopGifTicker()}startGifTicker(){this.gifTicker?.started||(this.gifTicker?this.gifTicker.maxFPS=1:(this.gifTicker=new sr,this.gifTicker.maxFPS=1,this.gifTicker.add(()=>{this.renderGifContainer()})),this.gifTicker.start())}stopGifTicker(){this.gifTicker?.started&&(Qg.log("⏸️ [GifTicker] 停止 GIF 专用渲染"),this.gifTicker.stop())}renderGifContainer(){const t=Zi();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 Px extends Nl{roomId;roomIndex;constructor(t){const e=Zi(),{nameLabel:i,colors:n}=e.roomConfig,s=n.name[t.index%n.name.length],r=new uh({fontSize:i.fontSize,fontFamily:i.fontFamily,fontWeight:i.fontWeight,fill:s,align:"center"});super({text:t.name||"Unknown",style:r}),this.roomId=t.id,this.roomIndex=t.index,this.anchor.set(.5)}updateName(t){this.text=t}updateColor(t){const e=Zi(),{colors:i}=e.roomConfig,n=t??i.name[this.roomIndex%i.name.length];this.style.fill=n}}class Ex extends Hs{background;cleanModeIcon;suctionIcon;cisternIcon;cleanTimesIcon;orderContainer;orderBackground;orderText;bubble=null;isFolded=!1;roomId;constructor(t){super();const e=Zi(),i=e.roomConfig;this.roomId=t.id,this.background=new Tl;const{property:n,colors:{propertyTheme:s}}=i;i.property.foldable&&(this.bubble=new Tl);const r=s[t.index%s.length];this.cleanModeIcon=new My,this.cleanModeIcon.tint=r,this.cleanModeIcon.anchor.set(0,0),this.suctionIcon=new My,this.suctionIcon.tint=r,this.suctionIcon.anchor.set(0,0),this.cisternIcon=new My,this.cisternIcon.tint=r,this.cisternIcon.anchor.set(0,0),this.cleanTimesIcon=new My,this.cleanTimesIcon.tint=r,this.cleanTimesIcon.anchor.set(0,0),this.orderContainer=new Hs,this.orderBackground=new Tl,this.orderText=new Nl({text:"",style:new uh({fontSize:n.cleanOrder.fontSize,fontFamily:n.cleanOrder.fontFamily,fontWeight:n.cleanOrder.fontWeight,fill:n.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=e.runtimeSnapshot.showRoomProperty,this.updateProperty(t)}async updateProperty(t){await this.updateIcons(t),this.updateBackground()}getDisplayElements(t){const e=Zi(),{displayOrders:i}=e.roomConfig.property,{showRoomOrder:n,showRoomProperty:s}=e.runtimeSnapshot,r=t.order||0,o=n&&r>0,a=s&&i.includes("cleanMode"),h=s&&i.includes("suction"),l=s&&i.includes("cistern"),c=s&&i.includes("cleanTimes")&&t.cleanTimes>0,d={cleanMode:{element:this.cleanModeIcon,show:a,isOrder:!1},suction:{element:this.suctionIcon,show:h,isOrder:!1},cistern:{element:this.cisternIcon,show:l,isOrder:!1},cleanTimes:{element:this.cleanTimesIcon,show:c,isOrder:!1}},u=[];return o&&u.push({element:this.orderContainer,show:!0,isOrder:!0}),i.forEach(t=>{const e=d[t];e&&e.show&&u.push(e)}),{shouldShowOrder:o,shouldShowCleanMode:a,shouldShowSuction:h,shouldShowCistern:l,shouldShowCleanTimes:c,elementsToShow:u,orderValue:r}}async updateIcons(t){const e=Zi(),{iconWidth:i,iconHeight:n,container:s,cleanOrder:r,foldable:o,iconGap:a}=e.roomConfig.property,{propertyTheme:h}=e.roomConfig.colors,{paddingHorizontal:l,paddingVertical:c}=s,{shouldShowOrder:d,shouldShowCleanMode:u,shouldShowSuction:p,shouldShowCistern:f,shouldShowCleanTimes:g,elementsToShow:m,orderValue:y}=this.getDisplayElements(t);this.orderContainer.visible=d,this.cleanModeIcon.visible=u,this.suctionIcon.visible=p,this.cisternIcon.visible=f,this.cleanTimesIcon.visible=g,o&&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(u&&x.push(this.cleanModeIcon.loadTextureAndSetSize(`cleanMode_${t.cleanMode}`,{width:i,height:n,sizeFixed:!1})),p&&x.push(this.suctionIcon.loadTextureAndSetSize(`fan_${t.suction}`,{width:i,height:n,sizeFixed:!1})),f&&x.push(this.cisternIcon.loadTextureAndSetSize(`water_${t.cistern}`,{width:i,height:n,sizeFixed:!1})),g){const e=t.cleanTimes||1;x.push(this.cleanTimesIcon.loadTextureAndSetSize(`cleanTimes${e}`,{width:i,height:n,sizeFixed:!1}))}await Promise.all(x),d&&(this.orderText.text=y.toString(),this.orderBackground.clear(),this.orderBackground.setFillStyle({color:h[t.index%h.length]}),this.orderBackground.circle(i/2,n/2,i/2).fill(),this.orderText.position.set(i/2,n/2));let b=l;m.forEach((t,e)=>{const{element:n,isOrder:s}=t;n.position.set(b,c),b+=i,e<m.length-1&&(b+=s?r.gapRight:a)})}updateBackground(){const t=Zi().roomConfig,{container:e,foldable:i}=t.property,{borderRadius:n,tailHeight:s,tailWidth:r,backgroundColor:o}=e,a=this.calculateContentWidth(),h=this.calculateContentHeight(),l=Math.min(r,a/2);if(this.background.clear(),this.bubble&&this.bubble.clear(),this.background.setFillStyle({color:o}),this.background.roundRect(0,0,a,h,n).fill(),i&&this.bubble){const t=(a-l)/2;this.bubble.setFillStyle({color:o}),this.bubble.poly([t,h-1,t+l,h-1,t+l/2,h+s]).fill()}}calculateContentWidth(){const t=Zi(),{iconWidth:e,container:i,cleanOrder:n,iconGap:s}=t.roomConfig.property,{paddingHorizontal:r}=i,o=t.getRoomData(this.roomId);if(!o)return 2*r;const{elementsToShow:a}=this.getDisplayElements(o);let h=r;return a.forEach((t,i)=>{const{isOrder:r}=t;h+=e,i<a.length-1&&(h+=r?n.gapRight:s)}),h+=r,h}calculateContentHeight(){const t=Zi().roomConfig,{iconHeight:e,container:i}=t.property;return i.paddingVertical+e+i.paddingVertical}getTotalHeight(){const t=Zi(),{foldable:e,container:i}=t.roomConfig.property,{tailHeight:n}=i;return this.calculateContentHeight()+(e?n:0)}getTotalWidth(){return this.calculateContentWidth()}setFolded(t){const e=Zi(),{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=Zi(),{foldable:e}=t.roomConfig.property;return!!e&&this.isFolded}repositionFoldedBubble(){const t=Zi(),{foldable:e}=t.roomConfig.property;if(!e||!this.bubble)return;const i=t.roomConfig,{tailHeight:n}=i.property.container,s=this.calculateContentWidth(),r=this.calculateContentHeight(),o=s/2;this.bubble.position.set(o,r+n/2)}destroy(){this.cleanModeIcon?.destroy(),this.suctionIcon?.destroy(),this.cisternIcon?.destroy(),this.cleanTimesIcon?.destroy(),super.destroy()}}class Bx extends Hs{background;checkmarkIcon;bubble;roomId;constructor(t){super();const e=Zi().roomConfig;this.roomId=t.id,this.background=new Tl,this.bubble=new Tl;const{colors:{selectionIndicatorIcon:i}}=e;this.checkmarkIcon=new My,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)}async updateIndicator(t){const e=Zi(),{roomSelectionMode:i,enableRoomSelection:n,selectRoomIds:s}=e.runtimeSnapshot;if(!n||"checkmark"!==i)return void(this.visible=!1);const r=s.includes(t.id);await this.showCheckmarkMode(r),this.updateBackground()}async showCheckmarkMode(t){const e=Zi(),{selectionIndicator:i}=e.roomConfig,{iconWidth:n,iconHeight:s}=i;if(t){this.visible=!0,this.checkmarkIcon.visible=!0,await this.checkmarkIcon.loadTextureAndSetSize("checkmark",{width:n,height:s,sizeFixed:!1});const t=i.containerWidth/2,e=i.containerHeight/2;this.checkmarkIcon.position.set(t-n/2,e-s/2)}else this.visible=!1}updateBackground(){const t=Zi(),{selectionIndicator:e,colors:i}=t.roomConfig,{containerWidth:n,containerHeight:s,strokeWidth:r,strokeColor:o,borderRadius:a,tailHeight:h,tailWidth:l}=e,c=t.getRoomData(this.roomId);if(!c)return;const d=i.selectionIndicatorBackground[c.index%i.selectionIndicatorBackground.length];if(this.background.clear(),this.bubble.clear(),this.background.setFillStyle({color:d}).roundRect(0,0,n,s,a).fill().setStrokeStyle({color:o,width:r,alignment:0}).stroke(),h>0&&l>0){const t=(n-l)/2;this.bubble.setFillStyle({color:o});const e=s+r;this.bubble.poly([t,e-1,t+l,e-1,t+l/2,e+h]).fill()}}getTotalHeight(){const t=Zi(),{selectionIndicator:e}=t.roomConfig,{containerHeight:i,tailHeight:n,strokeWidth:s}=e;return i+s+(n>0?n:0)}getTotalWidth(){const t=Zi(),{selectionIndicator:e}=t.roomConfig;return e.containerWidth}destroy(){this.checkmarkIcon?.destroy(),super.destroy()}}class Ox extends Iy{roomId;roomName;roomProperty=null;roomSelectionIndicator=null;clickHandler=null;constructor(t){super();const e=Zi();this.enableRenderGroup(),this.roomId=t.id,t.centerPoint&&this.position.set(t.centerPoint.x,t.centerPoint.y),this.roomName=new Px(t),this.roomName.visible=e.runtimeSnapshot.showRoomName,this.createRoomProperty(t),this.createRoomSelectionIndicator(t),this.updateLayout(),this.clickHandler=new Cy(this,{onClick:()=>{e.events?.onClickRoomProperties?.(t)}})}shouldShowRoomProperty(){const t=Zi(),{showRoomOrder:e,showRoomProperty:i,selectRoomIds:n,enableRoomSelection:s,roomSelectionMode:r}=t.runtimeSnapshot,o=t.getRoomData(this.roomId);if(!o)return!1;if(s&&"checkmark"===r&&n.includes(this.roomId))return!1;const a=e&&(o.order||0)>0,h=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||h}shouldShowRoomSelectionIndicator(){const t=Zi(),{enableRoomSelection:e,roomSelectionMode:i}=t.runtimeSnapshot;return e&&"checkmark"===i}updateRoomPropertyVisibility(){const t=Zi();if(this.roomProperty){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()}}async updateRoomSelectionIndicatorVisibility(){const t=Zi();if(this.roomSelectionIndicator){if(this.shouldShowRoomSelectionIndicator()){const e=t.getRoomData(this.roomId);e&&await this.roomSelectionIndicator.updateIndicator(e)}else this.roomSelectionIndicator.visible=!1;this.updateLayout()}}async createRoomProperty(t){const e=Zi();this.roomProperty&&(this.removeChild(this.roomProperty),this.roomProperty.destroy()),this.roomProperty=new Ex(t),await this.roomProperty.updateProperty(t),this.addChild(this.roomProperty),this.addChild(this.roomName),this.roomName.visible=e.runtimeSnapshot.showRoomName,this.updateRoomPropertyVisibility()}async createRoomSelectionIndicator(t){this.roomSelectionIndicator&&(this.removeChild(this.roomSelectionIndicator),this.roomSelectionIndicator.destroy()),this.roomSelectionIndicator=new Bx(t),this.addChild(this.roomSelectionIndicator),await this.updateRoomSelectionIndicatorVisibility()}updateLayout(){const t=Zi(),{property:{offsetY:e,offsetX:i},selectionIndicator:{offsetY:n,offsetX:s}}=t.roomConfig,r=this.roomProperty?.visible||!1,o=this.roomName.visible,a=this.roomSelectionIndicator?.visible||!1;if(r&&this.roomProperty)if(this.roomProperty.isFoldedState())this.roomProperty.position.set(i,-e);else{const t=this.roomProperty.getTotalHeight(),n=this.roomProperty.getTotalWidth();o?(this.roomProperty.position.set(-n/2+i,-e-t),this.roomName.position.set(0,0)):this.roomProperty.position.set(-n/2+i,-t/2-e)}if(a&&this.roomSelectionIndicator){const t=this.roomSelectionIndicator.getTotalHeight(),e=this.roomSelectionIndicator.getTotalWidth();o?(this.roomSelectionIndicator.position.set(-e/2+s,-n-t),this.roomName.position.set(0,0)):this.roomSelectionIndicator.position.set(-e/2+s,-t/2-n)}!o||r||a||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)}destroy(){this.clickHandler?.destroy(),this.clickHandler=null,this.roomProperty?.destroy(),this.roomProperty=null,this.roomSelectionIndicator?.destroy(),this.roomSelectionIndicator=null,this.roomName?.destroy(),super.destroy()}}class kx extends Hs{floorTypeMap=new Map;floorTypeMasks=new Map;floorTypeToRooms=new Map;constructor(){super({isRenderGroup:!0}),Zi().appContainer.addToLayer(ay,this)}async createFloorTypes(t){if(!Zi().runtimeSnapshot.showRoomFloorType)return;this.clearFloorTypes();const e=this.groupRoomsByFloorType(t),i=[];for(const[t,n]of e)i.push(this.createMergedFloorType(t,n));await Promise.all(i)}groupRoomsByFloorType(t){const e=new Map,i=Zi();return t.forEach((t,n)=>{const s=i.getRoomData(n),r=s?.floorType||0;r>=0&&(e.has(r)||e.set(r,[]),e.get(r).push({roomId:n,graphics:t}))}),e}async createMergedFloorType(t,e){const i=Zi(),{assets:n,opacity:s,scale:r}=i.roomConfig.floorType,o="floorType"+t%n.length;if(!o)return void Qg.warn(`No texture asset configured for floorType: ${t}`);const a=await al.load(o);if(!a)return void Qg.warn(`Floor material texture not found: ${o}`);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,s=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),s=Math.max(s,t.y+t.height)}),{x:e,y:i,width:n-e,height:s-i}})(e.map(({graphics:t})=>t.getLocalBounds())),l=new Dl({texture:a,width:h.width,height:h.height});l.x=h.x,l.y=h.y,l.alpha=s,l.tileScale.set(r);const c=this.createMergedMask(e.map(({graphics:t})=>t));l.mask=c,this.addChild(l),this.floorTypeMap.set(t,l),this.floorTypeMasks.set(t,c),this.floorTypeToRooms.set(t,new Set(e.map(({roomId:t})=>t)))}createMergedMask(t){const e=new Hs;return t.forEach(t=>{const i=new Tl;i.context=t.context.clone(),e.addChild(i)}),e}clearFloorTypes(){this.floorTypeMap.forEach(t=>{try{this.removeChild(t),t.destroy()}catch(t){Qg.warn("Error destroying floor material:",t)}}),this.floorTypeMap.clear(),this.floorTypeMasks.forEach(t=>{try{t.destroy()}catch(t){Qg.warn("Error destroying floor mask:",t)}}),this.floorTypeMasks.clear(),this.floorTypeToRooms.clear()}destroy(){this.clearFloorTypes(),super.destroy()}}class Rx{unsubscribeFns=[];roomInfoContainer=new Hs;roomInfoMap=new Map;roomDisplayMap=new Map;roomFloorType=new kx;constructor(){const t=Zi();t.appContainer.addToLayer(py,this.roomInfoContainer);const e=Yi(t.runtime,"showRoomFloorType",t=>{Qg.log(`[runtime] showRoomFloorType: ${t}`),t?this.updateFloorTypes():this.roomFloorType.clearFloorTypes()}),i=Yi(t.runtime,"showRoomProperty",t=>{Qg.log(`[runtime] showRoomProperty: ${t}`),this.updateAllRoomPropertyVisibility()}),n=Yi(t.runtime,"showRoomOrder",t=>{Qg.log(`[runtime] showRoomOrder: ${t}`),this.updateAllRoomPropertyVisibility()}),s=Yi(t.runtime,"roomPropertyFoldIds",t=>{Qg.log(`[runtime] roomPropertyFoldIds: ${t}`),this.updateAllRoomPropertyVisibility()}),r=Yi(t.runtime,"showRoomName",t=>{Qg.log(`[runtime] showRoomName: ${t}`),this.updateAllRoomNameVisibility(t)}),o=Yi(t.runtime,"enableRoomSelection",t=>{Qg.log(`[runtime] enableRoomSelection: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),a=Yi(t.runtime,"selectRoomIds",t=>{Qg.log(`[runtime] selectRoomIds: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),h=Yi(t.runtime,"roomSelectionMode",t=>{Qg.log(`[runtime] roomSelectionMode: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()});this.unsubscribeFns.push(e,i,n,s,r,o,a,h)}drawRoomProperty(t){const e=Zi();return this.roomDisplayMap.clear(),t.forEach((t,i)=>{const n=e.mapManager.getRoomById(t.id),s={...t,centerPoint:n?.centerPoint||null,index:i};this.roomDisplayMap.set(t.id,s)}),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 Ox(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=Zi();this.roomFloorType.clearFloorTypes(),this.roomDisplayMap.forEach((e,i)=>{const n=t.mapManager.getRoomById(i),s=n?.centerPoint||null;if(e.centerPoint!==s){e.centerPoint=s;const t=this.roomInfoMap.get(i);t&&s&&t.updatePosition(s)}}),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()})}async updateFloorTypes(){const t=Zi(),e=t.mapManager.roomFill.getRoomGraphicsMap();e.size>0&&(await this.roomFloorType.createFloorTypes(e),t.getApp().renderOnceNextFrame())}destroy(){this.clearRoomInfos(),this.roomInfoContainer.destroy(),this.roomFloorType.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}navigator?.userAgent?.includes("tuya-ark-ide")||navigator?.userAgent?.includes("miniProgram");const Dx=()=>{if(!Lr.any)return!0;const t=navigator.userAgent.toLowerCase();let e=!1;if(/iphone|ipad|ipod/.test(t)){const i=t.match(/os (\d+)_/)?.[1];e=(i?parseInt(i):0)>=12}else if(/android/.test(t)){const i=t.match(/android (\d+)/)?.[1];e=(i?parseInt(i):0)>=10}return e&&(()=>{const t=navigator.deviceMemory;return!t||t>=4})()};class Fx extends Po{mapState=null;components={};managers={};config=Km;runtime;scaleMin=.5;scaleMax=5;events={};instanceKey;containerElement;emitter=function(t){return{all:t=t||new Map,on:function(e,i){var n=t.get(e);n?n.push(i):t.set(e,[i])},off:function(e,i){var n=t.get(e);n&&(i?n.splice(n.indexOf(i)>>>0,1):t.set(e,[]))},emit:function(e,i){var n=t.get(e);n&&n.slice().map(function(t){t(i)}),(n=t.get("*"))&&n.slice().map(function(t){t(e,i)})}}}();tickerState={renderReasons:new Set,renderTimer:null};pendingAsyncRender=!1;isFirstMapDraw=!0;constructor(t=ty){super(),this.instanceKey=t,iy.registerInstance(t,this),globalThis.__PIXI_APP__=this}async initialize(t){return iy.provideAsync(this,async()=>{const{resizeTo:e,events:i,config:n,runtime:s={},...r}=t;this.config=_g(this.config,n??{}),this.runtime=Wi(Object.assign({},qm,s));const o=this.instanceKey===ty;this.containerElement=e;const a=o?{textureGCMaxIdle:Lr.any?180:3600,textureGCCheckCountMax:Lr.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}};await this.init({resizeTo:o?e:void 0,preferWebGLVersion:2,resolution:window.devicePixelRatio||1,antialias:Dx(),autoDensity:!0,backgroundColor:this.config.global.backgroundColor,...a,...r}),this.preloadAssets(),this.scaleMax=this.config.interaction.zoomRange.max,this.scaleMin=this.config.interaction.zoomRange.min,this.events=i,this.initializeViewportContainer(),this.initializeInteraction(),this.initializeAppContainer(),this.managers.mapManager=new hx,this.managers.heatmapManager=new gx,this.managers.pathManager=new px,this.managers.controlsManager=new wx,this.managers.detectedObjectManager=new Sx,this.managers.customElementsManager=new Tx,this.managers.roomsManager=new Rx,document.addEventListener("visibilitychange",this.onVisibilityChange)})}async drawMap(t){return iy.provideAsync(this,async()=>{Qg.log("[Map] drawMap",t);const{size:e,resolution:i,origin:n}=t;n[0]===this.mapState?.origin.x&&n[1]===this.mapState?.origin.y||(this.managers.pathManager.updatePositionByOrigin(...n),this.managers.controlsManager.updatePositionByOrigin(...n),this.managers.detectedObjectManager.updatePositionByOrigin(...n),this.managers.customElementsManager.updatePositionByOrigin(...n)),this.mapState={id:t.id,status:1===t.status,origin:{x:n[0],y:n[1]},charger:{x:t.charger.coordinate[0],y:t.charger.coordinate[1]},chargerDirection:t.charger.angle??0,resolution:i,width:e[0],height:e[1]},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,this.events?.onMapFirstDrawed?.(this.mapState)),this.events?.onMapDrawed?.(this.mapState),await this.managers.mapManager.drawMap(t),this.renderOnce()})}async drawRasterMap(t){return iy.provideAsync(this,async()=>{Qg.log("[Map] drawRasterMap",t);const{mapHeader:e,mapData:i}=t,{originX:n,originY:s}=e;n===this.mapState?.origin.x&&s===this.mapState?.origin.y||(this.managers.pathManager.updatePositionByOrigin(n,s),this.managers.controlsManager.updatePositionByOrigin(n,s),this.managers.detectedObjectManager.updatePositionByOrigin(n,s),this.managers.customElementsManager.updatePositionByOrigin(n,s)),this.mapState={id:e.id,status:e.mapStable,origin:{x:n,y:s},charger:{x:e.chargeX,y:e.chargeY},chargerDirection:e.chargeDirection??0,resolution:100*e.mapResolution,width:e.mapWidth,height:e.mapHeight,version:e.version},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,this.events?.onMapFirstDrawed?.(this.mapState)),this.events?.onMapDrawed?.(this.mapState),await this.managers.mapManager.drawRasterMap(i.parsed,this.mapState),this.renderOnce()})}drawPath(t){return iy.provide(this,()=>{Qg.log("[Path] drawPath",t),this.events?.onPathDrawed?.({id:t.pathHeader.pathId,type:t.pathHeader.type,direction:t.pathHeader.direction,count:t.pathHeader.count,initFlag:t.pathHeader.initFlag,robotPosition:t.pathPoints[t.pathPoints.length-1]??null}),this.managers.pathManager.draw(t),this.renderOnce()})}async drawRoomProperty(t){return iy.provide(this,()=>{Qg.log("[Room] drawRoomProperty",t),this.events?.onRoomPropertiesDrawed?.(t),this.managers.roomsManager.drawRoomProperty(t),this.renderOnceNextFrame()})}drawHeatmap({mapData:t,heatmapPoints:e,useGradient:i=!0}){return iy.provide(this,()=>{Qg.log("[Heatmap] drawHeatmap",e),this.managers.heatmapManager.draw({mapData:t,heatmapPoints:e,useGradient:i}),this.renderOnce()})}drawForbiddenSweepZones(t){return iy.provide(this,()=>{Qg.log("[Controls] drawForbiddenSweepZones",t),this.managers.controlsManager.drawForbiddenSweepZones(t),this.renderOnceNextFrame()})}drawForbiddenMopZones(t){return iy.provide(this,()=>{Qg.log("[Controls] drawForbiddenMopZones",t),this.managers.controlsManager.drawForbiddenMopZones(t),this.renderOnceNextFrame()})}drawCleanZones(t){return iy.provide(this,()=>{Qg.log("[Controls] drawCleanZones",t),this.managers.controlsManager.drawCleanZones(t),this.renderOnceNextFrame()})}drawVirtualWalls(t){return iy.provide(this,()=>{Qg.log("[Controls] drawVirtualWalls",t),this.managers.controlsManager.drawVirtualWalls(t),this.renderOnceNextFrame()})}drawSpots(t){return iy.provide(this,()=>{Qg.log("[Controls] drawSpots",t),this.managers.controlsManager.drawSpots(t),this.renderOnceNextFrame()})}async drawDetectedObjects(t){return iy.provideAsync(this,async()=>{Qg.log("[DetectedObject] drawDetectedObjects",t),await this.managers.detectedObjectManager.drawDetectedObjects(t),this.renderOnceNextFrame()})}async drawCustomElements(t){return iy.provideAsync(this,async()=>{Qg.log("[CustomElements] drawCustomElements",t),await this.managers.customElementsManager.drawCustomElements(t),this.renderOnceNextFrame()})}getForbiddenSweepZones(){return this.managers.controlsManager.getForbiddenSweepZones()}getForbiddenMopZones(){return this.managers.controlsManager.getForbiddenMopZones()}getCleanZones(){return this.managers.controlsManager.getCleanZones()}getVirtualWalls(){return this.managers.controlsManager.getVirtualWalls()}getSpots(){return this.managers.controlsManager.getSpots()}getEffectiveDividerPoints(){return this.managers.controlsManager.getEffectiveDividerPoints()}getDividerEndPoints(){return this.managers.controlsManager.getDividerEndPoints()}resetPanZoom(){this.components.interaction.setPanZoom()}fitMapToView(t,e=!1){return iy.provide(this,()=>{if(!t||t.minX===t.maxX||t.minY===t.maxY)return void Qg.warn("地图边界无效,无法自动适配视图");const i=this.config.map.autoPaddingPercent||.1,n=this.getViewportBounds(),s=t.maxX-t.minX,r=t.maxY-t.minY,o=n.width,a=n.height,h=o*(1-2*i)/s,l=a*(1-2*i)/r,c=Math.min(h,l),d=Math.max(this.config.interaction.fitMinScale,this.scaleMin),u=Math.min(this.config.interaction.fitMaxScale,this.scaleMax),p=Math.max(d,Math.min(u,c)),f=o/2-(t.minX+s/2)*p,g=a/2-(t.minY+r/2)*p;this.components.interaction.setPanZoom({targetPosition:{x:f,y:g},targetScale:{x:p,y:p},setCenter:!0,setScale:!0},e)})}getViewportBounds(){return this.components.viewportContainer?.getViewportBounds()||{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}updateRuntime(t){Object.assign(this.runtime,t),this.renderOnceNextFrame()}metersToPixels(t){return this.mapState?.resolution?t*(1/(this.mapState.resolution/100)):(Qg.warn("Map resolution not available, using default resolution (5cm/pixel)"),20*t)}pixelsToMeters(t){return this.mapState?.resolution?t*(this.mapState.resolution/100):(Qg.warn("Map resolution not available, using default resolution (5cm/pixel)"),.05*t)}toFixedSize(t,e){return t/(e??this.components.appContainer.scale.x)}fromFixedSize(t,e){return t*(e??this.components.appContainer.scale.x)}getViewportCenterPoint(){if(!this.mapState)return Qg.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,s=n.scale.x,r=(e-n.x)/s,o=(i-n.y)/s;return{x:r-this.mapState.origin.x,y:o-this.mapState.origin.y}}getMapCenterPoint(){if(!this.mapState)return Qg.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 Qg.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:s=0}=t||{},r=this.getViewportCenterPoint()||{x:0,y:0},o=this.metersToPixels(e);return Mm(r.x,r.y,o,i).map(t=>({x:t.x+n,y:t.y+s}))}getForbiddenSweepZonePointsByViewportCenter(t){const e=this.config.controls.forbiddenSweepZone,{size:i=e.minSize,offsetX:n=0,offsetY:s=0}=t||{};return this.generateZonePoints(i,n,s)}getForbiddenMopZonePointsByViewportCenter(t){const e=this.config.controls.forbiddenMopZone,{size:i=e.minSize,offsetX:n=0,offsetY:s=0}=t||{};return this.generateZonePoints(i,n,s)}getCleanZonePointsByViewportCenter(t){const e=this.config.controls.cleanZone,{size:i=e.minSize,offsetX:n=0,offsetY:s=0}=t||{};return this.generateZonePoints(i,n,s)}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,e=3){return iy.provide(this,()=>{if(!t||0===t.length)return Qg.warn("[Room] No room IDs provided"),!1;if(1===t.length)return!0;const i=Array.from(new Set(t));return 1===i.length||(void 0!==this.mapState?.version?this.areRasterRoomsAdjacentInternal(i,e):this.areStructuredRoomsAdjacentInternal(i,e))})}areStructuredRoomsAdjacentInternal(t,e){const i=[];for(const e of t){const t=this.managers.mapManager.getRoomById(e);if(!t)return Qg.warn(`[Room] Room ${e} not found in map`),!1;if(!t.outlinePoints||0===t.outlinePoints.length)return Qg.warn(`[Room] Room ${e} has no outline points`),!1;i.push({id:e,points:t.outlinePoints})}const n=[];for(let t=0;t<i.length;t++)for(let s=t+1;s<i.length;s++){const r=i[t],o=i[s];Tm(r.points,o.points,e)&&n.push([t,s])}return Em(i.length,n)}areRasterRoomsAdjacentInternal(t,e){if(!this.mapState)return Qg.warn("[Room] Map state not available"),!1;const i=this.mapState.width,n=[];for(const e of t){const t=this.managers.mapManager.getRasterRoomPixels(e);if(!t)return Qg.warn(`[Room] Room ${e} pixel data not found in raster map`),!1;n.push({id:e,pixels:t})}const s=[];for(let t=0;t<n.length;t++)for(let r=t+1;r<n.length;r++){const o=n[t],a=n[r];Pm(o.pixels,a.pixels,i,e)&&s.push([t,r])}return Em(n.length,s)}async snapshot(){this.render(),await new Promise(t=>setTimeout(t,0));const{snapshot:t}=this.config;return await this.renderer.extract.base64({target:this.components.appContainer,format:t.format,quality:t.quality,resolution:t.resolution,antialias:t.antialias})}async snapshotByData({map:t,path:e,roomProperties:i,customElements:n,forbiddenSweepZones:s,forbiddenMopZones:r,virtualWalls:o,detectedObjects:a},h={}){const l=`SNAPSHOT_${((t=21)=>{let e="",i=0|t;for(;i--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return e})()}`;Qg.log(`[MapApplication] ${l} snapshot start`);const c=new Fx(l);try{if(await c.initialize({config:this.config,runtime:h}),!t)throw new Error("Map data is required");if(t.startsWith("7b22")){const{decodeMapStructured:e}=await Promise.resolve().then(()=>Kg),i=e(t);await c.drawMap(i)}else{const{decodeMap:e}=await Promise.resolve().then(()=>Kg),i=e(t);if(!i)throw new Error("Failed to decode raster map data");await c.drawRasterMap(i)}if(e){const{decodePath:t}=await Promise.resolve().then(()=>Kg),i=t(e);c.drawPath(i)}i&&i.length>0&&c.drawRoomProperty(i),s&&s.length>0&&c.drawForbiddenSweepZones(s),r&&r.length>0&&c.drawForbiddenMopZones(r),o&&o.length>0&&c.drawVirtualWalls(o),a&&a.length>0&&await c.drawDetectedObjects(a),n&&n.length>0&&await c.drawCustomElements(n);const d=await c.snapshot();return Qg.log(`[MapApplication] ${l} snapshot completed successfully`),d}catch(t){throw Qg.error(`[MapApplication] ${l} snapshot other map failed:`,t),t}finally{Qg.log(`[MapApplication] ${l} destroy`),c.destroy()}}renderOnce(){Qg.log("[Pixi] renderOnce"),this.render()}renderOnceNextFrame(){this.pendingAsyncRender||(this.pendingAsyncRender=!0,requestAnimationFrame(()=>{Qg.log("[Pixi] renderOnceNextFrame"),this.render(),this.pendingAsyncRender=!1}))}requestRender(t,e=!1){e?(this.tickerState.renderReasons.add(t),this.ticker.started||(Qg.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(){iy.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 sy(this.config,this.containerElement),this.stage.addChild(this.components.viewportContainer)}initializeAppContainer(){this.components.appContainer=new _y,this.components.interaction.addChild(this.components.appContainer)}initializeInteraction(){this.components.interaction=new Bm,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&&(Qg.debug("⏸️ [Ticker] STOP"),this.ticker.stop())},e)}generateZonePoints(t,e,i){const n=this.getViewportCenterPoint()||{x:0,y:0},s=this.metersToPixels(t)/2,r=n.x+e,o=n.y+i;return[{x:r-s,y:o-s},{x:r+s,y:o-s},{x:r+s,y:o+s},{x:r-s,y:o+s}]}preloadAssets(){const t=this.config.robot.icon.src,e=this.config.chargingStation.icon.src,i=[];al.add({alias:"robot",src:t}),i.push("robot"),al.add({alias:"chargingStation",src:e}),i.push("chargingStation"),al.add({alias:"deleteIcon",src:this.config.controls.deleteIconSrc}),i.push("deleteIcon"),al.add({alias:"rotateIcon",src:this.config.controls.rotateIconSrc}),i.push("rotateIcon"),al.add({alias:"scaleIcon",src:this.config.controls.scaleIconSrc}),i.push("scaleIcon"),al.add({alias:"moveIcon",src:this.config.controls.moveIconSrc}),i.push("moveIcon"),al.add({alias:"checkmark",src:this.config.room.selectionIndicator.iconSrc}),i.push("checkmark"),al.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}`;al.add({alias:n,src:t}),i.push(n)}),this.config.room.property.suction.assets.forEach((t,e)=>{const n=`fan_${e}`;al.add({alias:n,src:t}),i.push(n)}),this.config.room.property.cistern.assets.forEach((t,e)=>{const n=`water_${e}`;al.add({alias:n,src:t}),i.push(n)}),this.config.room.property.cleanTimes.assets.forEach((t,e)=>{const n=`cleanTimes${e+1}`;al.add({alias:n,src:t}),i.push(n)}),this.config.room.floorType.assets.forEach((t,e)=>{if(!t)return;const n=`floorType${e}`;al.add({alias:n,src:t}),i.push(n)}),al.backgroundLoad(i)}onVisibilityChange=()=>{"visible"===document.visibilityState||this.components.interaction?.clearTouches()}}$i.add(Gr),$i.mixin(Hs,{accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1}),$i.add(Eo),$i.add(Bo),$i.add(_l),$i.mixin(Hs,vl),$i.add(cl),$i.add(Ru),$i.add(Ka),$i.add(Gu),$i.add(Zu),$i.add(Ju),$i.add(wp),$i.add(vp),$i.add(fp),$i.add(bp),$i.add(mp),$i.add(rp),$i.add(qu),$i.add(Al),$i.add(wl);const Lx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),jx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{iy as AppContext,Qm as MAP_API_METHODS,$m as MAP_CALLBACK_METHODS,Fx as MapApplication,qg as decodeRoomProperties,Zi as useAppService};
|