var l0=Object.defineProperty;var th=Object.getOwnPropertySymbols;var u0=Object.prototype.hasOwnProperty,h0=Object.prototype.propertyIsEnumerable;var eh=(r,t,e)=>t in r?l0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rh=(r,t)=>{for(var e in t||(t={}))u0.call(t,e)&&eh(r,e,t[e]);if(th)for(var e of th(t))h0.call(t,e)&&eh(r,e,t[e]);return r};/*!
* PixiJS - v8.14.3
* Compiled Thu, 20 Nov 2025 12:37:45 UTC
*
* PixiJS is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/var c0=Object.defineProperty,d0=Object.defineProperties,p0=Object.getOwnPropertyDescriptors,sh=Object.getOwnPropertySymbols,f0=Object.prototype.hasOwnProperty,m0=Object.prototype.propertyIsEnumerable,ih=(r,t,e)=>t in r?c0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nh=(r,t)=>{for(var e in t||(t={}))f0.call(t,e)&&ih(r,e,t[e]);if(sh)for(var e of sh(t))m0.call(t,e)&&ih(r,e,t[e]);return r},g0=(r,t)=>d0(r,p0(t)),y=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(y||{});const yn=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){const t=typeof r.extension!="object"?{type:r.extension}:r.extension;r=g0(nh({},t),{ref:r})}if(typeof r=="object")r=nh({},r);else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},br=(r,t)=>{var e;return(e=yn(r).priority)!=null?e:t},F={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(yn).forEach(t=>{t.type.forEach(e=>{var s,i;return(i=(s=this._removeHandlers)[e])==null?void 0:i.call(s,t)})}),this},add(...r){return r.map(yn).forEach(t=>{t.type.forEach(e=>{var s,i;const n=this._addHandlers,o=this._queue;n[e]?(i=n[e])==null||i.call(n,t):(o[e]=o[e]||[],(s=o[e])==null||s.push(t))})}),this},handle(r,t,e){var s;const i=this._addHandlers,n=this._removeHandlers;i[r]=t,n[r]=e;const o=this._queue;return o[r]&&((s=o[r])==null||s.forEach(a=>t(a)),delete o[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(r,t,e=-1){return this.handle(r,s=>{t.findIndex(i=>i.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((i,n)=>br(n.value,e)-br(i.value,e)))},s=>{const i=t.findIndex(n=>n.name===s.name);i!==-1&&t.splice(i,1)})},handleByList(r,t,e=-1){return this.handle(r,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((i,n)=>br(n,e)-br(i,e)))},s=>{const i=t.indexOf(s.ref);i!==-1&&t.splice(i,1)})},mixin(r,...t){for(const e of t)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(e))}};var KM=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function oh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function qM(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function ZM(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function QM(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function s(){return this instanceof s?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(s){var i=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:function(){return r[s]}})}),e}var Tn={exports:{}},JM=Tn.exports;(function(r){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function i(l,u,h){this.fn=l,this.context=u,this.once=h||!1}function n(l,u,h,c,d){if(typeof h!="function")throw new TypeError("The listener must be a function");var p=new i(h,c||l,d),f=e?e+u:u;return l._events[f]?l._events[f].fn?l._events[f]=[l._events[f],p]:l._events[f].push(p):(l._events[f]=p,l._eventsCount++),l}function o(l,u){--l._eventsCount===0?l._events=new s:delete l._events[u]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var u=[],h,c;if(this._eventsCount===0)return u;for(c in h=this._events)t.call(h,c)&&u.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(h)):u},a.prototype.listeners=function(u){var h=e?e+u:u,c=this._events[h];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,p=c.length,f=new Array(p);d
0:typeof r=="number"},at=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},Mt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},ah=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},lh=function(r){return{r:Mt(r.r,0,255),g:Mt(r.g,0,255),b:Mt(r.b,0,255),a:Mt(r.a)}},Sn=function(r){return{r:at(r.r),g:at(r.g),b:at(r.b),a:at(r.a,3)}},b0=/^#([0-9a-f]{3,8})$/i,Ts=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},uh=function(r){var t=r.r,e=r.g,s=r.b,i=r.a,n=Math.max(t,e,s),o=n-Math.min(t,e,s),a=o?n===t?(e-s)/o:n===e?2+(s-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:i}},hh=function(r){var t=r.h,e=r.s,s=r.v,i=r.a;t=t/360*6,e/=100,s/=100;var n=Math.floor(t),o=s*(1-e),a=s*(1-(t-n)*e),l=s*(1-(1-t+n)*e),u=n%6;return{r:255*[s,a,o,o,l,s][u],g:255*[l,s,s,a,o,o][u],b:255*[o,o,l,s,s,a][u],a:i}},ch=function(r){return{h:ah(r.h),s:Mt(r.s,0,100),l:Mt(r.l,0,100),a:Mt(r.a)}},dh=function(r){return{h:at(r.h),s:at(r.s),l:at(r.l),a:at(r.a,3)}},ph=function(r){return hh((e=(t=r).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},vr=function(r){return{h:(t=uh(r)).h,s:(i=(200-(e=t.s))*(s=t.v)/100)>0&&i<200?e*s/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,e,s,i},v0=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y0=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,T0=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,S0=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wn={string:[[function(r){var t=b0.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?at(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?at(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=T0.exec(r)||S0.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:lh({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(r){var t=v0.exec(r)||y0.exec(r);if(!t)return null;var e,s,i=ch({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(x0[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return ph(i)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,s=r.b,i=r.a,n=i===void 0?1:i;return Qt(t)&&Qt(e)&&Qt(s)?lh({r:Number(t),g:Number(e),b:Number(s),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,s=r.l,i=r.a,n=i===void 0?1:i;if(!Qt(t)||!Qt(e)||!Qt(s))return null;var o=ch({h:Number(t),s:Number(e),l:Number(s),a:Number(n)});return ph(o)},"hsl"],[function(r){var t=r.h,e=r.s,s=r.v,i=r.a,n=i===void 0?1:i;if(!Qt(t)||!Qt(e)||!Qt(s))return null;var o=function(a){return{h:ah(a.h),s:Mt(a.s,0,100),v:Mt(a.v,0,100),a:Mt(a.a)}}({h:Number(t),s:Number(e),v:Number(s),a:Number(n)});return hh(o)},"hsv"]]},fh=function(r,t){for(var e=0;e=.5},r.prototype.toHex=function(){return t=Sn(this.rgba),e=t.r,s=t.g,i=t.b,o=(n=t.a)<1?Ts(at(255*n)):"","#"+Ts(e)+Ts(s)+Ts(i)+o;var t,e,s,i,n,o},r.prototype.toRgb=function(){return Sn(this.rgba)},r.prototype.toRgbString=function(){return t=Sn(this.rgba),e=t.r,s=t.g,i=t.b,(n=t.a)<1?"rgba("+e+", "+s+", "+i+", "+n+")":"rgb("+e+", "+s+", "+i+")";var t,e,s,i,n},r.prototype.toHsl=function(){return dh(vr(this.rgba))},r.prototype.toHslString=function(){return t=dh(vr(this.rgba)),e=t.h,s=t.s,i=t.l,(n=t.a)<1?"hsla("+e+", "+s+"%, "+i+"%, "+n+")":"hsl("+e+", "+s+"%, "+i+"%)";var t,e,s,i,n},r.prototype.toHsv=function(){return t=uh(this.rgba),{h:at(t.h),s:at(t.s),v:at(t.v),a:at(t.a,3)};var t},r.prototype.invert=function(){return Lt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),Lt(En(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),Lt(En(this.rgba,-t))},r.prototype.grayscale=function(){return Lt(En(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),Lt(gh(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),Lt(gh(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?Lt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):at(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=vr(this.rgba);return typeof t=="number"?Lt({h:t,s:e.s,l:e.l,a:e.a}):at(e.h)},r.prototype.isEqual=function(t){return this.toHex()===Lt(t).toHex()},r}(),Lt=function(r){return r instanceof Ss?r:new Ss(r)},_h=[],w0=function(r){r.forEach(function(t){_h.indexOf(t)<0&&(t(Ss,wn),_h.push(t))})},e3=function(){return new Ss({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function E0(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var i in e)s[e[i]]=i;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,u=s[this.toHex()];if(u)return u;if(o!=null&&o.closest){var h=this.toRgb(),c=1/0,d="black";if(!n.length)for(var p in e)n[p]=new r(e[p]).toRgb();for(var f in e){var g=(a=h,l=n[f],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));gt in r?A0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,C0=(r,t)=>{for(var e in t||(t={}))P0.call(t,e)&&bh(r,e,t[e]);if(xh)for(var e of xh(t))R0.call(t,e)&&bh(r,e,t[e]);return r};w0([E0]);const Be=class ms{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof ms)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?C0({},t):t}_isSourceEqual(t,e){const s=typeof t;if(s!==typeof e)return!1;if(s==="number"||s==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((i,n)=>i===e[n]);if(t!==null&&e!==null){const i=Object.keys(t),n=Object.keys(e);return i.length!==n.length?!1:i.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,s,i]=this._components;return{r:t,g:e,b:s,a:i}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,i]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(i*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,s,i,n]=this._components;return t[0]=e,t[1]=s,t[2]=i,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,s,i]=this._components;return t[0]=e,t[1]=s,t[2]=i,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,i,n]=ms._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=i,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,i=this._int>>8&255,n=this._int&255;return e&&(s=s*t+.5|0,i=i*t+.5|0,n=n*t+.5|0),(t*255<<24)+(s<<16)+(i<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,s,i,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,s=(o>>8&255)/255,i=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,i,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,i,n=255]=t,e/=255,s/=255,i/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=ms.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=Lt(t);o.isValid()&&({r:e,g:s,b:i,a:n}=o.rgba,e/=255,s/=255,i/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=i,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((i,n)=>{t[n]=Math.min(Math.max(i,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof ms||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};Be.shared=new Be,Be._temp=new Be,Be.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let X=Be;const vh={cullArea:null,cullable:!1,cullableChildren:!0},yh=Math.PI*2,Th=180/Math.PI,Sh=Math.PI/180;class V{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new V(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}static get shared(){return Pn.x=0,Pn.y=0,Pn}}const Pn=new V;class R{constructor(t=1,e=0,s=0,i=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=s,this.d=i,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,s,i,n,o){return this.a=t,this.b=e,this.c=s,this.d=i,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const s=e||this.array;return t?(s[0]=this.a,s[1]=this.b,s[2]=0,s[3]=this.c,s[4]=this.d,s[5]=0,s[6]=this.tx,s[7]=this.ty,s[8]=1):(s[0]=this.a,s[1]=this.c,s[2]=this.tx,s[3]=this.b,s[4]=this.d,s[5]=this.ty,s[6]=0,s[7]=0,s[8]=1),s}apply(t,e){e=e||new V;const s=t.x,i=t.y;return e.x=this.a*s+this.c*i+this.tx,e.y=this.b*s+this.d*i+this.ty,e}applyInverse(t,e){e=e||new V;const s=this.a,i=this.b,n=this.c,o=this.d,a=this.tx,l=this.ty,u=1/(s*o+n*-i),h=t.x,c=t.y;return e.x=o*u*h+-n*u*c+(l*n-a*o)*u,e.y=s*u*c+-i*u*h+(-l*s+a*i)*u,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),s=Math.sin(t),i=this.a,n=this.c,o=this.tx;return this.a=i*e-this.b*s,this.b=i*s+this.b*e,this.c=n*e-this.d*s,this.d=n*s+this.d*e,this.tx=o*e-this.ty*s,this.ty=o*s+this.ty*e,this}append(t){const e=this.a,s=this.b,i=this.c,n=this.d;return this.a=t.a*e+t.b*i,this.b=t.a*s+t.b*n,this.c=t.c*e+t.d*i,this.d=t.c*s+t.d*n,this.tx=t.tx*e+t.ty*i+this.tx,this.ty=t.tx*s+t.ty*n+this.ty,this}appendFrom(t,e){const s=t.a,i=t.b,n=t.c,o=t.d,a=t.tx,l=t.ty,u=e.a,h=e.b,c=e.c,d=e.d;return this.a=s*u+i*c,this.b=s*h+i*d,this.c=n*u+o*c,this.d=n*h+o*d,this.tx=a*u+l*c+e.tx,this.ty=a*h+l*d+e.ty,this}setTransform(t,e,s,i,n,o,a,l,u){return this.a=Math.cos(a+u)*n,this.b=Math.sin(a+u)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(s*this.a+i*this.c),this.ty=e-(s*this.b+i*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const s=this.a,i=this.c;this.a=s*t.a+this.b*t.c,this.b=s*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,s=this.b,i=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-i,n),l=Math.atan2(s,e),u=Math.abs(a+l);return u<1e-5||Math.abs(yh-u)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=l),t.scale.x=Math.sqrt(e*e+s*s),t.scale.y=Math.sqrt(i*i+n*n),t.position.x=this.tx+(o.x*e+o.y*i),t.position.y=this.ty+(o.x*s+o.y*n),t}invert(){const t=this.a,e=this.b,s=this.c,i=this.d,n=this.tx,o=t*i-e*s;return this.a=i/o,this.b=-e/o,this.c=-s/o,this.d=t/o,this.tx=(s*this.ty-i*n)/o,this.ty=-(t*this.ty-e*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new R;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}static get IDENTITY(){return O0.identity()}static get shared(){return M0.identity()}}const M0=new R,O0=new R;class q{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new q(t!=null?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}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))}}const yr={default:-1};function W(r="default"){return yr[r]===void 0&&(yr[r]=-1),++yr[r]}function G0(){for(const r in yr)delete yr[r]}const ge={_registeredResources:new Set,register(r){this._registeredResources.add(r)},unregister(r){this._registeredResources.delete(r)},release(){this._registeredResources.forEach(r=>r.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(r){return this._registeredResources.has(r)},reset(){this._registeredResources.clear()}};class wh{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e0?s=this._pool[--this._index]:(s=new this._classType,this._count++),(e=s.init)==null||e.call(s,t),s}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const st=new Eh;ge.register(st);const Ah={get isCachedAsTexture(){var r;return!!((r=this.renderGroup)!=null&&r.isCachedAsTexture)},cacheAsTexture(r){typeof r=="boolean"&&r===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(r===!0?{}:r))},updateCacheTexture(){var r;(r=this.renderGroup)==null||r.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(r){this.cacheAsTexture(r)}};function Rn(r,t,e){const s=r.length;let i;if(t>=s||e===0)return;e=t+e>s?s-t:e;const n=s-e;for(i=t;i0&&i<=s){for(let a=s-1;a>=r;a--){const l=this.children[a];l&&(n.push(l),l.parent=null)}Rn(this.children,r,s);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(n);for(let a=0;a0&&this._didViewChangeTick++,n}else if(i===0&&this.children.length===0)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){const t=this.getChildAt(r);return this.removeChild(t)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,t)},getChildIndex(r){const t=this.children.indexOf(r);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(r,t){const{children:e}=this;if(t<0||t>e.length)throw new Error(`${r}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(r.parent){const i=r.parent.children.indexOf(r);if(r.parent===this&&i===t)return r;i!==-1&&r.parent.children.splice(i,1)}t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(r),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",r,this,t),r.emit("added",this),r},swapChildren(r,t){if(r===t)return;const e=this.getChildIndex(r),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=r;const i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(t=>this.reparentChildAt(t,this.children.length)),r[0])},reparentChildAt(r,t){if(r.parent===this)return this.setChildIndex(r,t),r;const e=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),r.setFromMatrix(e),r},replaceChild(r,t){r.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(r)),t.setFromMatrix(r.localTransform),t.updateLocalTransform(),this.removeChild(r)}},Rh={collectRenderables(r,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,t,e))},collectRenderablesSimple(r,t,e){const s=this.children,i=s.length;for(let n=0;n=0;i--){const n=this.effects[i];s[n.pipe].pop(n,this,r)}}};class Tr{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;et in r?I0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Gh=(r,t)=>{for(var e in t||(t={}))B0.call(t,e)&&Oh(r,e,t[e]);if(Mh)for(var e of Mh(t))F0.call(t,e)&&Oh(r,e,t[e]);return r};const Ih={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0)},addEffect(r){this.effects.indexOf(r)===-1&&(this.effects.push(r),this.effects.sort((t,e)=>t.priority-e.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(r){const t=this.effects.indexOf(r);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(r){const t=this._maskEffect;(t==null?void 0:t.mask)!==r&&(t&&(this.removeEffect(t),ws.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=ws.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions=Gh(Gh({},this._maskOptions),r),r.mask&&(this.mask=r.mask),this._markStructureAsChanged()},set filters(r){var t;!Array.isArray(r)&&r&&(r=[r]);const e=this._filterEffect||(this._filterEffect=new Tr);r=r;const s=(r==null?void 0:r.length)>0,i=((t=e.filters)==null?void 0:t.length)>0,n=s!==i;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),n&&(s?this.addEffect(e):(this.removeEffect(e),e.filters=r!=null?r:null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new Tr),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},Bh={label:null,get name(){return this.label},set name(r){this.label=r},getChildByName(r,t=!1){return this.getChildByLabel(r,t)},getChildByLabel(r,t=!1){const e=this.children;for(let s=0;s=this.x&&t=this.y&&e=c&&t<=d&&e>=p&&e<=f&&!(t>g&&t_&&et.right?t.right:this.right)<=C)return!1;const M=this.yt.bottom?t.bottom:this.bottom)>M}const s=this.left,i=this.right,n=this.top,o=this.bottom;if(i<=s||o<=n)return!1;const a=Es[0].set(t.left,t.top),l=Es[1].set(t.left,t.bottom),u=Es[2].set(t.right,t.top),h=Es[3].set(t.right,t.bottom);if(u.x<=a.x||l.y<=a.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(a,a),e.apply(l,l),e.apply(u,u),e.apply(h,h),Math.max(a.x,l.x,u.x,h.x)<=s||Math.min(a.x,l.x,u.x,h.x)>=i||Math.max(a.y,l.y,u.y,h.y)<=n||Math.min(a.y,l.y,u.y,h.y)>=o))return!1;const d=c*(l.y-a.y),p=c*(a.x-l.x),f=d*s+p*n,g=d*i+p*n,m=d*s+p*o,_=d*i+p*o;if(Math.max(f,g,m,_)<=d*a.x+p*a.y||Math.min(f,g,m,_)>=d*h.x+p*h.y)return!1;const b=c*(a.y-u.y),x=c*(u.x-a.x),v=b*s+x*n,S=b*i+x*n,T=b*s+x*o,w=b*i+x*o;return!(Math.max(v,S,T,w)<=b*a.x+x*a.y||Math.min(v,S,T,w)>=b*h.x+x*h.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),i=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=i,this.height=Math.max(n-i,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,i=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=s-this.x,this.height=i-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),s=Math.max(this.x+this.width,t.x+t.width),i=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=i,this.height=n-i,this}getBounds(t){return t||(t=new j),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,s=t.y,i=t.x+t.width,n=t.y+t.height;return e>=this.x&&e=this.y&&s=this.x&&i=this.y&&nthis.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new j);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=Fh,this}set(t,e,s,i){this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}addFrame(t,e,s,i,n){n||(n=this.matrix);const o=n.a,a=n.b,l=n.c,u=n.d,h=n.tx,c=n.ty;let d=this.minX,p=this.minY,f=this.maxX,g=this.maxY,m=o*t+l*e+h,_=a*t+u*e+c;mf&&(f=m),_>g&&(g=_),m=o*s+l*e+h,_=a*s+u*e+c,mf&&(f=m),_>g&&(g=_),m=o*t+l*i+h,_=a*t+u*i+c,mf&&(f=m),_>g&&(g=_),m=o*s+l*i+h,_=a*s+u*i+c,mf&&(f=m),_>g&&(g=_),this.minX=d,this.minY=p,this.maxX=f,this.maxY=g}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxXthis.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*e+l*n+h,p=a*e+u*n+c,this.minX=dthis.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*i+l*n+h,p=a*i+u*n+c,this.minX=dthis.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,i){return this.minXe&&(this.maxX=e),this.minYi&&(this.maxY=i),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 ot(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,s,i){let n=this.minX,o=this.minY,a=this.maxX,l=this.maxY;i||(i=this.matrix);const u=i.a,h=i.b,c=i.c,d=i.d,p=i.tx,f=i.ty;for(let g=e;ga?b:a,l=x>l?x:l}this.minX=n,this.minY=o,this.maxX=a,this.maxY=l}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}}const ut=st.getPool(R),Nt=st.getPool(ot),D0=new R,Dh={getFastGlobalBounds(r,t){t||(t=new ot),t.clear(),this._getGlobalBoundsRecursive(!!r,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(r,t,e){let s=t;if(r&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const i=!!this.effects.length;if((this.renderGroup||i)&&(s=Nt.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;s.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const n=this.children;for(let o=0;o>16&255,s=r>>8&255,i=r&255,n=t>>16&255,o=t>>8&255,a=t&255,l=e*n/255|0,u=s*o/255|0,h=i*a/255|0;return(l<<16)+(u<<8)+h}const kh=16777215;function wr(r,t){return r===kh?t:t===kh?r:Cn(r,t)}function Fe(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const $h={getGlobalAlpha(r){if(r)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(r=new R,t){if(t)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const e=As(this,ut.get().identity());return r.appendFrom(this.localTransform,e),ut.return(e),r},getGlobalTint(r){if(r)return this.renderGroup?Fe(this.renderGroup.worldColor):this.parentRenderGroup?Fe(wr(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=wr(t,e.localColor),e=e.parent;return Fe(t)}};function Ps(r,t,e){return t.clear(),e||(e=R.IDENTITY),Lh(r,t,e,r,!0),t.isValid||t.set(0,0,0,0),t}function Lh(r,t,e,s,i){var n,o;let a;if(i)a=ut.get(),a=e.copyTo(a);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const h=r.localTransform;a=ut.get(),a.appendFrom(h,e)}const l=t,u=!!r.effects.length;if(u&&(t=Nt.get().clear()),r.boundsArea)t.addRect(r.boundsArea,a);else{r.renderPipeId&&(t.matrix=a,t.addBounds(r.bounds));const h=r.children;for(let c=0;c>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function Gn(r){return!(r&r-1)&&!!r}function $0(r){let t=(r>65535?1:0)<<4;r>>>=t;let e=(r>255?1:0)<<3;return r>>>=e,t|=e,e=(r>15?1:0)<<2,r>>>=e,t|=e,e=(r>3?1:0)<<1,r>>>=e,t|=e,t|r>>1}function Bt(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}var L0=Object.defineProperty,zh=Object.getOwnPropertySymbols,N0=Object.prototype.hasOwnProperty,X0=Object.prototype.propertyIsEnumerable,Vh=(r,t,e)=>t in r?L0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Wh=(r,t)=>{for(var e in t||(t={}))N0.call(t,e)&&Vh(r,e,t[e]);if(zh)for(var e of zh(t))X0.call(t,e)&&Vh(r,e,t[e]);return r};const Yh=Object.create(null);function H0(r){const t=Yh[r];return t===void 0&&(Yh[r]=W("resource")),t}const Kh=class Cy extends mt{constructor(t={}){var e,s,i,n,o,a,l;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t=Wh(Wh({},Cy.defaultOptions),t),this.addressMode=t.addressMode,this.addressModeU=(e=t.addressModeU)!=null?e:this.addressModeU,this.addressModeV=(s=t.addressModeV)!=null?s:this.addressModeV,this.addressModeW=(i=t.addressModeW)!=null?i:this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=(n=t.magFilter)!=null?n:this.magFilter,this.minFilter=(o=t.minFilter)!=null?o:this.minFilter,this.mipmapFilter=(a=t.mipmapFilter)!=null?a:this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=(l=t.maxAnisotropy)!=null?l:1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){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=H0(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Kh.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let St=Kh;var j0=Object.defineProperty,qh=Object.getOwnPropertySymbols,z0=Object.prototype.hasOwnProperty,V0=Object.prototype.propertyIsEnumerable,Zh=(r,t,e)=>t in r?j0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qh=(r,t)=>{for(var e in t||(t={}))z0.call(t,e)&&Zh(r,e,t[e]);if(qh)for(var e of qh(t))V0.call(t,e)&&Zh(r,e,t[e]);return r};const Jh=class My extends mt{constructor(t={}){var e,s,i;super(),this.options=t,this.uid=W("textureSource"),this._resourceType="textureSource",this._resourceId=W("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,t=Qh(Qh({},My.defaultOptions),t),this.label=(e=t.label)!=null?e:"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource&&(s=this.resourceWidth)!=null?s:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&(i=this.resourceHeight)!=null?i:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new St(Bt(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.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=W("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,s){s||(s=this._resolution),t||(t=this.width),e||(e=this.height);const i=Math.round(t*s),n=Math.round(e*s);return this.width=i/s,this.height=n/s,this._resolution=s,this.pixelWidth===i&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=i,this.pixelHeight=n,this.emit("resize",this),this._resourceId=W("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=Gn(this.pixelWidth)&&Gn(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Jh.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Z=Jh;const xe=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],be=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],ve=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ye=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],In=[],tc=[],Rs=Math.sign;function W0(){for(let r=0;r<16;r++){const t=[];In.push(t);for(let e=0;e<16;e++){const s=Rs(xe[r]*xe[e]+ve[r]*be[e]),i=Rs(be[r]*xe[e]+ye[r]*be[e]),n=Rs(xe[r]*ve[e]+ve[r]*ye[e]),o=Rs(be[r]*ve[e]+ye[r]*ye[e]);for(let a=0;a<16;a++)if(xe[a]===s&&be[a]===i&&ve[a]===n&&ye[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new R;t.set(xe[r],be[r],ve[r],ye[r],0,0),tc.push(t)}}W0();const L={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>xe[r],uY:r=>be[r],vX:r=>ve[r],vY:r=>ye[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>In[r][t],sub:(r,t)=>In[r][L.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?L.S:L.N:Math.abs(t)*2<=Math.abs(r)?r>0?L.E:L.W:t>0?r>0?L.SE:L.SW:r>0?L.NE:L.NW,matrixAppendRotationInv:(r,t,e=0,s=0)=>{const i=tc[L.inv(t)];i.tx=e,i.ty=s,r.append(i)},transformRectCoords:(r,t,e,s)=>{const{x:i,y:n,width:o,height:a}=r,{x:l,y:u,width:h,height:c}=t;return e===L.E?(s.set(i+l,n+u,o,a),s):e===L.S?s.set(h-n-a+l,i+u,a,o):e===L.W?s.set(h-i-o+l,c-n-a+u,o,a):e===L.N?s.set(n+l,c-i-o+u,a,o):s.set(i+l,n+u,o,a)}},Bn=()=>{};var Y0=Object.defineProperty,K0=Object.defineProperties,q0=Object.getOwnPropertyDescriptors,ec=Object.getOwnPropertySymbols,Z0=Object.prototype.hasOwnProperty,Q0=Object.prototype.propertyIsEnumerable,rc=(r,t,e)=>t in r?Y0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,J0=(r,t)=>{for(var e in t||(t={}))Z0.call(t,e)&&rc(r,e,t[e]);if(ec)for(var e of ec(t))Q0.call(t,e)&&rc(r,e,t[e]);return r},t1=(r,t)=>K0(r,q0(t));class Cs extends Z{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super(t1(J0({},t),{resource:e,format:s})),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}}Cs.extension=y.TextureSource;const sc=new R;class Fn{constructor(t,e){this.mapCoord=new R,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e=="undefined"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let i=0;it in r?e1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,o1=(r,t)=>{for(var e in t||(t={}))i1.call(t,e)&&nc(r,e,t[e]);if(ic)for(var e of ic(t))n1.call(t,e)&&nc(r,e,t[e]);return r},a1=(r,t)=>r1(r,s1(t));let l1=0;class oc{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new St(this.textureOptions)}createTexture(t,e,s){const i=new Z(a1(o1({},this.textureOptions),{width:t,height:e,resolution:1,antialias:s,autoGarbageCollect:!1}));return new A({source:i,label:`texturePool_${l1++}`})}getOptimalTexture(t,e,s=1,i){let n=Math.ceil(t*s-1e-6),o=Math.ceil(e*s-1e-6);n=_e(n),o=_e(o);const a=(n<<17)+(o<<1)+(i?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let l=this._texturePool[a].pop();return l||(l=this.createTexture(n,o,i)),l.source._resolution=s,l.source.width=n/s,l.source.height=o/s,l.source.pixelWidth=n,l.source.pixelHeight=o,l.frame.x=0,l.frame.y=0,l.frame.width=t,l.frame.height=e,l.updateUvs(),this._poolKeyHash[l.uid]=a,l}getSameSizeTexture(t,e=!1){const s=t.source;return this.getOptimalTexture(t.width,t.height,s._resolution,e)}returnTexture(t,e=!1){const s=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[s].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const s=this._texturePool[e];if(s)for(let i=0;i-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;ethis.addChild(i)),(s=t.parent)==null||s.addChild(this)}static mixin(t){F.mixin(K,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(t.length>1){for(let i=0;i1){for(let i=0;i-1&&(this._didViewChangeTick++,this.children.splice(s,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,s),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=st.get(Ms,this),this.groupTransform=R.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),st.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new R),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*Th}set angle(t){this.rotation=t*Sh}get pivot(){return this._pivot===Un&&(this._pivot=new q(this,0,0)),this._pivot}set pivot(t){this._pivot===Un&&(this._pivot=new q(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Dn&&(this._skew=new q(this,0,0)),this._skew}set skew(t){this._skew===Dn&&(this._skew=new q(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===kn&&(this._scale=new q(this,1,1)),this._scale}set scale(t){this._scale===kn&&(this._scale=new q(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===$n&&(this._origin=new q(this,0,0)),this._origin}set origin(t){this._origin===$n&&(this._origin=new q(this,0,0)),typeof t=="number"?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){var s;const i=this.getLocalBounds();typeof t=="object"?(e=(s=t.height)!=null?s:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,i=this._pivot,n=this._origin,o=this._position,a=s._x,l=s._y,u=i._x,h=i._y,c=-n._x,d=-n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*l,e.d=this._sy*l,e.tx=o._x-(u*e.a+h*e.c)+(c*e.a+d*e.c)-c,e.ty=o._y-(u*e.b+h*e.d)+(c*e.b+d*e.d)-d}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=Er,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=X.shared.setValue(t!=null?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=Er,this._onUpdate())}get tint(){return Fe(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Gs,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=De,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=De,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=De,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var e;if(this.destroyed)return;this.destroyed=!0;let s;if(this.children.length&&(s=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&s)for(let i=0;i(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(Xt||{});class Is{constructor(t,e=null,s=0,i=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=i}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 ac=class Rt{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 Is(null,null,1/0),this.deltaMS=1/Rt.targetFPMS,this.elapsedMS=1/Rt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=Xt.NORMAL){return this._addListener(new Is(t,e,s))}addOnce(t,e,s=Xt.NORMAL){return this._addListener(new Is(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n{if(!this._canvas)return;const e=this._canvas.getBoundingClientRect(),s=this._canvas.width,i=this._canvas.height,n=e.width/s*this._renderer.resolution,o=e.height/i*this._renderer.resolution,a=e.left,l=e.top,u=`translate(${a}px, ${l}px) scale(${n}, ${o})`;u!==this._lastTransform&&(this._domElement.style.transform=u,this._lastTransform=u)},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 s=this.canvas.width,i=this.canvas.height,n=e.contentRect.width/s*this._renderer.resolution,o=e.contentRect.height/i*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||nt.shared.add(this.updateTranslation,this,Xt.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&nt.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 dr{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=dr.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new V,this.page=new V,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,s){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,s,i,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var Nn=/iPhone/i,lc=/iPod/i,uc=/iPad/i,hc=/\biOS-universal(?:.+)Mac\b/i,Xn=/\bAndroid(?:.+)Mobile\b/i,cc=/Android/i,Ue=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Bs=/Silk/i,Jt=/Windows Phone/i,dc=/\bWindows(?:.+)ARM\b/i,pc=/BlackBerry/i,fc=/BB10/i,mc=/Opera Mini/i,gc=/\b(CriOS|Chrome)(?:.+)Mobile/i,_c=/Mobile(?:.+)Firefox\b/i,xc=function(r){return typeof r!="undefined"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream=="undefined"};function h1(r){return function(t){return t.test(r)}}function bc(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator!="undefined"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,s=e.split("[FBAN");typeof s[1]!="undefined"&&(e=s[0]),s=e.split("Twitter"),typeof s[1]!="undefined"&&(e=s[0]);var i=h1(e),n={apple:{phone:i(Nn)&&!i(Jt),ipod:i(lc),tablet:!i(Nn)&&(i(uc)||xc(t))&&!i(Jt),universal:i(hc),device:(i(Nn)||i(lc)||i(uc)||i(hc)||xc(t))&&!i(Jt)},amazon:{phone:i(Ue),tablet:!i(Ue)&&i(Bs),device:i(Ue)||i(Bs)},android:{phone:!i(Jt)&&i(Ue)||!i(Jt)&&i(Xn),tablet:!i(Jt)&&!i(Ue)&&!i(Xn)&&(i(Bs)||i(cc)),device:!i(Jt)&&(i(Ue)||i(Bs)||i(Xn)||i(cc))||i(/\bokhttp\b/i)},windows:{phone:i(Jt),tablet:i(dc),device:i(Jt)||i(dc)},other:{blackberry:i(pc),blackberry10:i(fc),opera:i(mc),firefox:i(_c),chrome:i(gc),device:i(pc)||i(fc)||i(mc)||i(_c)||i(gc)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}var vc;const c1=(vc=bc.default)!=null?vc:bc,yc=c1(globalThis.navigator);var d1=Object.defineProperty,Tc=Object.getOwnPropertySymbols,p1=Object.prototype.hasOwnProperty,f1=Object.prototype.propertyIsEnumerable,Sc=(r,t,e)=>t in r?d1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wc=(r,t)=>{for(var e in t||(t={}))p1.call(t,e)&&Sc(r,e,t[e]);if(Tc)for(var e of Tc(t))f1.call(t,e)&&Sc(r,e,t[e]);return r};const m1=9,Ec=100,g1=0,_1=0,Ac=2,Pc=1,x1=-1e3,b1=-1e3,v1=2,Hn=class Oy{constructor(t,e=yc){this._mobileInfo=e,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),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}get div(){return this._div}_createTouchHook(){const t=document.createElement("button");t.style.width=`${Pc}px`,t.style.height=`${Pc}px`,t.style.position="absolute",t.style.top=`${x1}px`,t.style.left=`${b1}px`,t.style.zIndex=v1.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=`${g1}px`,this._div.style.left=`${_1}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=Ac.toString(),this._canvasObserver=new Ln({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!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(){var t,e;if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const s of this._children)(t=s._accessibleDiv)!=null&&t.parentNode&&(s._accessibleDiv.parentNode.removeChild(s._accessibleDiv),s._accessibleDiv=null),s._accessibleActive=!1;for(const s in this._pools)this._pools[s].forEach(i=>{i.parentNode&&i.parentNode.removeChild(i)}),delete this._pools[s];(e=this._div)!=null&&e.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},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 s=0;s=0;s--){const i=this._children[s];e.has(s)||(i._accessibleDiv&&i._accessibleDiv.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),this._getPool(i.accessibleType).push(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1,Rn(this._children,s,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let s=0;s title : ${t.title} 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:s}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>s&&(t.height=s-t.y)}_addChild(t){let e=this._getPool(t.accessibleType).pop();e?(e.innerHTML="",e.removeAttribute("title"),e.removeAttribute("aria-label"),e.tabIndex=0):(t.accessibleType==="button"?e=document.createElement("button"):(e=document.createElement(t.accessibleType),e.style.cssText=`
color: transparent;
pointer-events: none;
padding: 0;
margin: 0;
border: 0;
outline: 0;
background: transparent;
box-sizing: border-box;
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
`,t.accessibleText&&(e.innerText=t.accessibleText)),e.style.width=`${Ec}px`,e.style.height=`${Ec}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Ac.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&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`container ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),t.interactive?e.tabIndex=t.tabIndex:e.tabIndex=0,this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv)}_dispatchEvent(t,e){const{container:s}=t.target,i=this._renderer.events.rootBoundary,n=Object.assign(new dr(i),{target:s});i.rootTarget=this._renderer.lastObjectRendered,e.forEach(o=>i.dispatchEvent(n,o))}_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){t.keyCode!==m1||!this._activateOnTab||this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this._deactivate()}destroy(){var t;this._deactivate(),this._destroyTouchHook(),(t=this._canvasObserver)==null||t.destroy(),this._canvasObserver=null,this._div=null,this._pools=null,this._children=null,this._renderer=null,this._hookDiv=null,globalThis.removeEventListener("keydown",this._boundOnKeyDown),this._boundOnKeyDown=null,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._boundOnMouseMove=null}setAccessibilityEnabled(t){t?this._activate():this._deactivate()}_getPool(t){return this._pools[t]||(this._pools[t]=[]),this._pools[t]}};Hn.extension={type:[y.WebGLSystem,y.WebGPUSystem],name:"accessibility"},Hn.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let Rc=Hn;const Cc={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1};F.add(Rc),F.mixin(K,Cc);class jn{static init(t){Object.defineProperty(this,"resizeTo",{configurable:!0,set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,s;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,s=globalThis.innerHeight;else{const{clientWidth:i,clientHeight:n}=this._resizeTo;e=i,s=n}this.renderer.resize(e,s),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}}jn.extension=y.Application;class zn{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{configurable:!0,set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Xt.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?nt.shared:new nt,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}zn.extension=y.Application,F.add(jn),F.add(zn);let y1=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||(nt.system.add(this._tickerUpdate,this,Xt.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(nt.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||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._deltaTimes.priority-i.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 s=0,i=e.length;s=0;i--)if(t.currentTarget=s[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,s=this._allInteractiveElements){if(s.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const i=Array.isArray(e)?e:[e];for(let n=s.length-1;n>=0;n--)i.forEach(o=>{t.currentTarget=s[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let s=0;s=0;c--){const d=h[c],p=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,s,i,n,o||n(t,s));if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();(p.length>0||f)&&(f&&this._allInteractiveElements.push(t),p.push(t)),this._hitElements.length===0&&(this._hitElements=p),a=!0}}}const l=this._isInteractive(e),u=t.isInteractive();return u&&u&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,s)&&i(t,s)?u?[t]:[]:null}hitTestRecursive(t,e,s,i,n){if(this._interactivePrune(t)||n(t,s))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Ht.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children,u=s;for(let h=l.length-1;h>=0;h--){const c=l[h],d=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,u,i,n);if(d){if(d.length>0&&!d[d.length-1].parent)continue;const p=t.isInteractive();return(d.length>0||p)&&d.push(t),d}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&i(t,s)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!t||!t.visible||!t.renderable||!t.measurable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,Pr),!t.hitArea.contains(Pr.x,Pr.y)))return!0;if(t.effects&&t.effects.length)for(let s=0;s0&&l!==n.target){const c=t.type==="mousemove"?"mouseout":"pointerout",d=this.createPointerEvent(t,c,l);if(this.dispatchEvent(d,"pointerout"),o&&this.dispatchEvent(d,"mouseout"),!n.composedPath().includes(l)){const p=this.createPointerEvent(t,"pointerleave",l);for(p.eventPhase=p.AT_TARGET;p.target&&!n.composedPath().includes(p.target);)p.currentTarget=p.target,this.notifyTarget(p),o&&this.notifyTarget(p,"mouseleave"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(d)}if(l!==n.target){const c=t.type==="mousemove"?"mouseover":"pointerover",d=this.clonePointerEvent(n,c);this.dispatchEvent(d,"pointerover"),o&&this.dispatchEvent(d,"mouseover");let p=l==null?void 0:l.parent;for(;p&&p!==this.rootTarget.parent&&p!==n.target;)p=p.parent;if(!p||p===this.rootTarget.parent){const f=this.clonePointerEvent(n,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==l&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(d)}const u=[],h=(s=this.enableGlobalMoveEvents)!=null?s:!0;this.moveOnAll?u.push("pointermove"):this.dispatchEvent(n,"pointermove"),h&&u.push("globalpointermove"),n.pointerType==="touch"&&(this.moveOnAll?u.splice(1,0,"touchmove"):this.dispatchEvent(n,"touchmove"),h&&u.push("globaltouchmove")),o&&(this.moveOnAll?u.splice(1,0,"mousemove"):this.dispatchEvent(n,"mousemove"),h&&u.push("globalmousemove"),this.cursor=(i=n.target)==null?void 0:i.cursor),u.length>0&&this.all(n,u),this._allInteractiveElements.length=0,this._hitElements.length=0,a.overTargets=n.composedPath(),this.freeEvent(n)}mapPointerOver(t){var e;if(!(t instanceof Ot))return;const s=this.trackingData(t.pointerId),i=this.createPointerEvent(t),n=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(e=i.target)==null?void 0:e.cursor);const o=this.clonePointerEvent(i,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),n&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;s.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof Ot))return;const e=this.trackingData(t.pointerId);if(e.overTargets){const s=t.pointerType==="mouse"||t.pointerType==="pen",i=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(n),s&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",i);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof Ot))return;const e=performance.now(),s=this.createPointerEvent(t);if(this.dispatchEvent(s,"pointerup"),s.pointerType==="touch")this.dispatchEvent(s,"touchend");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const a=s.button===2;this.dispatchEvent(s,a?"rightup":"mouseup")}const i=this.trackingData(t.pointerId),n=this.findMountedTarget(i.pressTargetsByButton[t.button]);let o=n;if(n&&!s.composedPath().includes(n)){let a=n;for(;a&&!s.composedPath().includes(a);){if(s.currentTarget=a,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch")this.notifyTarget(s,"touchendoutside");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const l=s.button===2;this.notifyTarget(s,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete i.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(s,"click");a.target=o,a.path=null,i.clicksByButton[t.button]||(i.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=i.clicksByButton[t.button];if(l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,a.detail=l.clickCount,a.pointerType==="mouse"){const u=a.button===2;this.dispatchEvent(a,u?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(s)}mapPointerUpOutside(t){if(!(t instanceof Ot))return;const e=this.trackingData(t.pointerId),s=this.findMountedTarget(e.pressTargetsByButton[t.button]),i=this.createPointerEvent(t);if(s){let n=s;for(;n;)i.currentTarget=n,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch"?this.notifyTarget(i,"touchendoutside"):(i.pointerType==="mouse"||i.pointerType==="pen")&&this.notifyTarget(i,i.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(i)}mapWheel(t){if(!(t instanceof Te))return;const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let s=1;st in r?w1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,P1=(r,t)=>{for(var e in t||(t={}))E1.call(t,e)&&Gc(r,e,t[e]);if(Oc)for(var e of Oc(t))A1.call(t,e)&&Gc(r,e,t[e]);return r};const R1=1,C1={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Vn=class Lu{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Mc(null),Ht.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Ot(null),this._rootWheelEvent=new Te(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(P1({},Lu.defaultEventFeatures),{set:(e,s,i)=>(s==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=i),e[s]=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(t){var e,s;const{canvas:i,resolution:n}=this.renderer;this.setTargetElement(i),this.resolution=n,Lu._defaultEventMode=(e=t.eventMode)!=null?e:"passive",Object.assign(this.features,(s=t.eventFeatures)!=null?s:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){Ht.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 s=this.cursorStyles[t];if(s)switch(typeof s){case"string":e&&(this.domElement.style.cursor=s);break;case"function":s(t);break;case"object":e&&Object.assign(this.domElement.style,s);break}else e&&typeof t=="string"&&!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 s=0,i=e.length;s0&&(e=t.composedPath()[0]);const s=e!==this.domElement?"outside":"",i=this._normalizeToPointerData(t);for(let n=0,o=i.length;n{l.off(r,a,o)}),n?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,t,e){const s=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,i=typeof t=="function"?void 0:t;r=s?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,i)},dispatchEvent(r){if(!(r instanceof dr))throw new Error("Container cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};F.add(Wn),F.mixin(K,Ic);class Yn{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 Ln({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(t.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let e=0;e=e.minX&&s<=e.maxX&&i>=e.minY&&i<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){var e,s;super.destroy(t),this._bounds=null;for(const i in this._gpuData)(s=(e=this._gpuData[i]).destroy)==null||s.call(e);this._gpuData=null}collectRenderablesSimple(t,e,s){const{renderPipes:i}=e;i.blendMode.pushBlendMode(this,this.groupBlendMode,t),i[this.renderPipeId].addRenderable(this,t),this.didViewUpdate=!1;const n=this.children,o=n.length;for(let a=0;at in r?M1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,O1=(r,t)=>{for(var e in t||(t={}))Bc.call(t,e)&&Dc(r,e,t[e]);if(Fs)for(var e of Fs(t))Fc.call(t,e)&&Dc(r,e,t[e]);return r},G1=(r,t)=>{var e={};for(var s in r)Bc.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Fs)for(var s of Fs(r))t.indexOf(s)<0&&Fc.call(r,s)&&(e[s]=r[s]);return e};class I1 extends jt{constructor(t={}){const e=t,{element:s,anchor:i}=e,n=G1(e,["element","anchor"]);super(O1({label:"DOMContainer"},n)),this.renderPipeId="dom",this.batched=!1,this._anchor=new V(0,0),i&&(this.anchor=i),this.element=t.element||document.createElement("div")}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?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){t.minX=0,t.minY=0,t.maxX=0,t.maxY=0;return}const{offsetWidth:s,offsetHeight:i}=e;t.minX=0,t.maxX=s,t.minY=0,t.maxY=i}destroy(t=!1){var e,s;super.destroy(t),(s=(e=this._element)==null?void 0:e.parentNode)==null||s.removeChild(this._element),this._element=null,this._anchor=null}}F.add(Yn);var wt=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(wt||{});const Uc={createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var r;return(r=document.baseURI)!=null?r:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};let kc=Uc;const $={get(){return kc},set(r){kc=r}};function Ft(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function Rr(r){return r.split("?")[0].split("#")[0]}function B1(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function F1(r,t,e){return r.replace(new RegExp(B1(t),"g"),e)}function D1(r,t){let e="",s=0,i=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",s=0):(e=e.slice(0,l),s=e.length-1-e.lastIndexOf("/")),i=a,n=0;continue}}else if(e.length===2||e.length===1){e="",s=0,i=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",s=2)}else e.length>0?e+=`/${r.slice(i+1,a)}`:e=r.slice(i+1,a),s=a-i-1;i=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const gt={toPosix(r){return F1(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){Ft(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(Ft(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const s=Rr(this.toPosix(t!=null?t:$.get().getBaseUrl())),i=Rr(this.toPosix(e!=null?e:this.rootname(s)));return r=this.toPosix(r),r.startsWith("/")?gt.join(i,r.slice(1)):this.isAbsolute(r)?r:this.join(s,r)},normalize(r){if(Ft(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const s=r.endsWith("/");return r=D1(r,!1),r.length>0&&s&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return Ft(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){var t;if(r.length===0)return".";let e;for(let s=0;s0)if(e===void 0)e=i;else{const n=(t=r[s-1])!=null?t:"";this.joinExtensions.includes(this.extname(n).toLowerCase())?e+=`/../${i}`:e+=`/${i}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(Ft(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let s=-1,i=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!i){s=a;break}}else i=!1;return s===-1?e?"/":this.isUrl(o)?n+r:n:e&&s===1?"//":n+r.slice(0,s)},rootname(r){Ft(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){Ft(r),t&&Ft(t),r=Rr(this.toPosix(r));let e=0,s=-1,i=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!i){e=n+1;break}}else a===-1&&(i=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(s=n):(o=-1,s=a))}return e===s?s=a:s===-1&&(s=r.length),r.slice(e,s)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!i){e=n+1;break}}else s===-1&&(i=!1,s=n+1);return s===-1?"":r.slice(e,s)},extname(r){Ft(r),r=Rr(this.toPosix(r));let t=-1,e=0,s=-1,i=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!i){e=o+1;break}continue}s===-1&&(i=!1,s=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||s===-1||n===0||n===1&&t===s-1&&t===e+1?"":r.slice(t,s)},parse(r){Ft(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=Rr(this.toPosix(r));let e=r.charCodeAt(0);const s=this.isAbsolute(r);let i;const n="";t.root=this.rootname(r),s||this.hasProtocol(r)?i=1:i=0;let o=-1,a=0,l=-1,u=!0,h=r.length-1,c=0;for(;h>=i;--h){if(e=r.charCodeAt(h),e===47){if(!u){a=h+1;break}continue}l===-1&&(u=!1,l=h+1),e===46?o===-1?o=h:c!==1&&(c=1):o!==-1&&(c=-1)}return o===-1||l===-1||c===0||c===1&&o===l-1&&o===a+1?l!==-1&&(a===0&&s?t.base=t.name=r.slice(1,l):t.base=t.name=r.slice(a,l)):(a===0&&s?(t.name=r.slice(1,o),t.base=r.slice(1,l)):(t.name=r.slice(a,o),t.base=r.slice(a,l)),t.ext=r.slice(o,l)),t.dir=this.dirname(r),n&&(t.dir=n+t.dir),t},sep:"/",delimiter:":",joinExtensions:[".html"]},Gt=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(s=>typeof s=="string"||e?t(s):s):r);function $c(r,t,e,s,i){const n=t[e];for(let o=0;o{const o=n.substring(1,n.length-1).split(",");i.push(o)}),$c(r,i,0,e,s)}else s.push(r);return s}const Cr=r=>!Array.isArray(r);var U1=Object.defineProperty,k1=Object.defineProperties,$1=Object.getOwnPropertyDescriptors,Nc=Object.getOwnPropertySymbols,L1=Object.prototype.hasOwnProperty,N1=Object.prototype.propertyIsEnumerable,Xc=(r,t,e)=>t in r?U1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Se=(r,t)=>{for(var e in t||(t={}))L1.call(t,e)&&Xc(r,e,t[e]);if(Nc)for(var e of Nc(t))N1.call(t,e)&&Xc(r,e,t[e]);return r},Hc=(r,t)=>k1(r,$1(t));class ie{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){var e,s,i;if(this._bundleIdConnector=(e=t.connector)!=null?e:this._bundleIdConnector,this._createBundleAssetId=(s=t.createBundleAssetId)!=null?s:this._createBundleAssetId,this._extractAssetIdFromBundle=(i=t.extractAssetIdFromBundle)!=null?i:this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return Gt(e||s,i=>typeof i=="string"?i:Array.isArray(i)?i.map(n=>{var o;return(o=n==null?void 0:n.src)!=null?o:n}):i!=null&&i.src?i.src:i,!0)}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];let i=e;Array.isArray(e)||(i=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:Se({alias:n},o))),i.forEach(n=>{const o=n.src,a=n.alias;let l;if(typeof a=="string"){const u=this._createBundleAssetId(t,a);s.push(u),l=[a,u]}else{const u=a.map(h=>this._createBundleAssetId(t,h));s.push(...u),l=[...a,...u]}this.add(Hc(Se({},n),{alias:l,src:o}))}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;Gt(e).forEach(i=>{const{src:n}=i;let{data:o,format:a,loadParser:l,parser:u}=i;const h=Gt(n).map(f=>typeof f=="string"?Lc(f):Array.isArray(f)?f:[f]),c=this.getAlias(i),d=[],p=f=>{const g=this._parsers.find(m=>m.test(f));return Hc(Se({},g==null?void 0:g.parse(f)),{src:f})};h.forEach(f=>{f.forEach(g=>{var m,_,b,x;let v={};if(typeof g!="object"?v=p(g):(o=(m=g.data)!=null?m:o,a=(_=g.format)!=null?_:a,(g.loadParser||g.parser)&&(l=(b=g.loadParser)!=null?b:l,u=(x=g.parser)!=null?x:u),v=Se(Se({},p(g.src)),g)),!c)throw new Error(`[Resolver] alias is undefined for this asset: ${v.src}`);v=this._buildResolvedAsset(v,{aliases:c,data:o,format:a,loadParser:l,parser:u,progressSize:i.progressSize}),d.push(v)})}),c.forEach(f=>{this._assetMap[f]=d})})}resolveBundle(t){const e=Cr(t);t=Gt(t);const s={};return t.forEach(i=>{const n=this._bundles[i];if(n){const o=this.resolve(n),a={};for(const l in o){const u=o[l];a[this._extractAssetIdFromBundle(i,l)]=u}s[i]=a}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const i in e)s[i]=e[i].src;return s}return e.src}resolve(t){const e=Cr(t);t=Gt(t);const s={};return t.forEach(i=>{if(!this._resolverHash[i])if(this._assetMap[i]){let n=this._assetMap[i];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(l=>{const u=n.filter(h=>h[a]?h[a]===l:!1);u.length&&(n=u)})}),this._resolverHash[i]=n[0]}else this._resolverHash[i]=this._buildResolvedAsset({alias:[i],src:i},{});s[i]=this._resolverHash[i]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;en.params.format.includes(s.format));if(i)return i}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){var s,i;const{aliases:n,data:o,loadParser:a,parser:l,format:u,progressSize:h}=e;return(this._basePath||this._rootPath)&&(t.src=gt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=(s=n!=null?n:t.alias)!=null?s:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=Se(Se({},o||{}),t.data),t.loadParser=a!=null?a:t.loadParser,t.parser=l!=null?l:t.parser,t.format=(i=u!=null?u:t.format)!=null?i:jc(t.src),h!==void 0&&(t.progressSize=h),t}}ie.RETINA_PREFIX=/@([0-9\.]+)x/;function jc(r){return r.split(".").pop().split("?").shift().split("#").shift()}const Ds=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r},zc=class gs{constructor(t,e){this.linkedSheets=[];let s=t;(t==null?void 0:t.source)instanceof Z&&(s={texture:t,data:e});const{texture:i,data:n,cachePrefix:o=""}=s;this.cachePrefix=o,this._texture=i instanceof A?i:null,this.textureSource=i.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,i.source.resolution=this.resolution):this.resolution=i.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=gs.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const s=gs.BATCH_SIZE;for(;e-t{this._batchIndex*gs.BATCH_SIZE{s[i]=t}),Object.keys(t.textures).forEach(i=>{s[`${t.cachePrefix}${i}`]=t.textures[i]}),!e){const i=gt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=Vc([`${i}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(s,a)})}return s}const Wc={extension:y.Asset,cache:{test:r=>r instanceof Kn,getCacheableAssets:(r,t)=>Vc(r,t,!1)},resolver:{extension:{type:y.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),s=t.pop();return e==="json"&&X1.includes(s)},parse:r=>{var t,e;const s=r.split(".");return{resolution:parseFloat((e=(t=ie.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:s[s.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:y.LoadParser,priority:wt.Normal,name:"spritesheetLoader"},async testParse(r,t){return gt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var s,i,n;const{texture:o,imageFilename:a,textureOptions:l,cachePrefix:u}=(s=t==null?void 0:t.data)!=null?s:{};let h=gt.dirname(t.src);h&&h.lastIndexOf("/")!==h.length-1&&(h+="/");let c;if(o instanceof A)c=o;else{const f=Ds(h+(a!=null?a:r.meta.image),t.src);c=(await e.load([{src:f,data:l}]))[f]}const d=new Kn({texture:c.source,data:r,cachePrefix:u});await d.parse();const p=(i=r==null?void 0:r.meta)==null?void 0:i.related_multi_packs;if(Array.isArray(p)){const f=[];for(const m of p){if(typeof m!="string")continue;let _=h+m;(n=t.data)!=null&&n.ignoreMultiPack||(_=Ds(_,t.src),f.push(e.load({src:_,data:{textureOptions:l,ignoreMultiPack:!0}})))}const g=await Promise.all(f);d.linkedSheets=g,g.forEach(m=>{m.linkedSheets=[d].concat(d.linkedSheets.filter(_=>_!==m))})}return d},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};F.add(Wc);function qn(r,t,e){const{width:s,height:i}=e.orig,n=e.trim;if(n){const o=n.width,a=n.height;r.minX=n.x-t._x*s,r.maxX=r.minX+o,r.minY=n.y-t._y*i,r.maxY=r.minY+a}else r.minX=-t._x*s,r.maxX=r.minX+s,r.minY=-t._y*i,r.maxY=r.minY+i}var H1=Object.defineProperty,Us=Object.getOwnPropertySymbols,Yc=Object.prototype.hasOwnProperty,Kc=Object.prototype.propertyIsEnumerable,qc=(r,t,e)=>t in r?H1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,j1=(r,t)=>{for(var e in t||(t={}))Yc.call(t,e)&&qc(r,e,t[e]);if(Us)for(var e of Us(t))Kc.call(t,e)&&qc(r,e,t[e]);return r},z1=(r,t)=>{var e={};for(var s in r)Yc.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Us)for(var s of Us(r))t.indexOf(s)<0&&Kc.call(r,s)&&(e[s]=r[s]);return e};class $t extends jt{constructor(t=A.EMPTY){t instanceof A&&(t={texture:t});const e=t,{texture:s=A.EMPTY,anchor:i,roundPixels:n,width:o,height:a}=e,l=z1(e,["texture","anchor","roundPixels","width","height"]);super(j1({label:"Sprite"},l)),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new q({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:s.defaultAnchor&&(this.anchor=s.defaultAnchor),this.texture=s,this.allowChildren=!1,this.roundPixels=n!=null?n:!1,o!==void 0&&(this.width=o),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof A?new $t(t):new $t(A.from(t,e))}set texture(t){t||(t=A.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 qn(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,s=this._bounds,{width:i,height:n}=e.orig;s.minX=-t._x*i,s.maxX=s.minX+i,s.minY=-t._y*n,s.maxY=s.minY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null,this._gpuData=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){var s;typeof t=="object"?(e=(s=t.height)!=null?s:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const V1=new ot;function ks(r,t,e){const s=V1;r.measurable=!0,Sr(r,e,s),t.addBoundsMask(s),r.measurable=!1}function $s(r,t,e){const s=Nt.get();r.measurable=!0;const i=ut.get().identity(),n=Zc(r,e,i);Ps(r,s,n),r.measurable=!1,t.addBoundsMask(s),ut.return(i),Nt.return(s)}function Zc(r,t,e){return r&&r!==t&&(Zc(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class Zn{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof $t),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(t,e){this.inverse||ks(this.mask,t,e)}addLocalBounds(t,e){$s(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof $t}}Zn.extension=y.MaskEffect;class Qn{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}Qn.extension=y.MaskEffect;class Jn{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,e){ks(this.mask,t,e)}addLocalBounds(t,e){$s(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof K}}Jn.extension=y.MaskEffect;class zt extends Z{constructor(t){t.resource||(t.resource=$.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,s=this._resolution){const i=super.resize(t,e,s);return i&&this.resizeCanvas(),i}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"))}}zt.extension=y.TextureSource;class ne extends Z{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}ne.extension=y.TextureSource;let to;async function eo(){return to!=null||(to=(async()=>{var r;const t=$.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!e)return"premultiply-alpha-on-upload";const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,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 n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(i),t.deleteTexture(s),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),to}var W1=Object.defineProperty,Y1=Object.defineProperties,K1=Object.getOwnPropertyDescriptors,Qc=Object.getOwnPropertySymbols,q1=Object.prototype.hasOwnProperty,Z1=Object.prototype.propertyIsEnumerable,Jc=(r,t,e)=>t in r?W1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ro=(r,t)=>{for(var e in t||(t={}))q1.call(t,e)&&Jc(r,e,t[e]);if(Qc)for(var e of Qc(t))Z1.call(t,e)&&Jc(r,e,t[e]);return r},Q1=(r,t)=>Y1(r,K1(t));const Ls=class Gy extends Z{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=ro(ro({},Gy.defaultOptions),t),this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=(e=t.alphaMode)!=null?e:"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=nt.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 eo(),this._load=new Promise((s,i)=>{this.isValid?s(this):(this._resolve=s,this._reject=i,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.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&&(nt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(nt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(nt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Ls.extension=y.TextureSource,Ls.defaultOptions=Q1(ro({},Z.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),Ls.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let ke=Ls,J1=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){return this._cache.get(t)}set(t,e){const s=Gt(t);let i;for(let l=0;l{n.set(l,e)});const o=[...n.keys()],a={cacheKeys:o,keys:s};s.forEach(l=>{this._cacheMap.set(l,a)}),o.forEach(l=>{const u=i?i[l]:e;this._cache.has(l)&&this._cache.get(l),this._cache.set(l,n.get(l))})}remove(t){if(!this._cacheMap.has(t))return;const e=this._cacheMap.get(t);e.cacheKeys.forEach(s=>{this._cache.delete(s)}),e.keys.forEach(s=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}};const z=new J1,so=[];F.handleByList(y.TextureSource,so);function tT(r={}){return io(r)}function io(r={}){const t=r&&r.resource,e=t?r.resource:r,s=t?r:{resource:r};for(let i=0;i{z.has(s)&&z.remove(s)}),t||z.set(s,n),n}function ed(r,t=!1){return typeof r=="string"?z.get(r):r instanceof Z?new A({source:r}):td(r,t)}A.from=ed,Z.from=io,F.add(Zn,Qn,Jn,ke,ne,zt,Cs);class Vt{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const i=t[s];this.setResource(i,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){var s,i;const n=this.resources[e];t!==n&&(n&&((s=t.off)==null||s.call(t,"change",this.onResourceChange,this)),(i=t.on)==null||i.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const s in e)e[s]._touched=t}destroy(){var t;const e=this.resources;for(const s in e){const i=e[s];(t=i==null?void 0:i.off)==null||t.call(i,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const s in e)e[s]===t&&(e[s]=null)}else this._updateKey()}}const rd={};function Ns(r,t,e){let s=2166136261;for(let i=0;i>>=0;return rd[s]||eT(r,t,s,e)}function eT(r,t,e,s){const i={};let n=0;for(let a=0;a{if($e.quiet||sd.has(t))return;let s=new Error().stack;const i=`${t}
Deprecated since v${r}`,n=typeof console.groupCollapsed=="function"&&!$e.noColor;typeof s=="undefined"?console.warn("PixiJS Deprecation Warning: ",i):(s=s.split(`
`).splice(e).join(`
`),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",i),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",i),console.warn(s))),sd.add(t)};Object.defineProperties(Mr,{quiet:{get:()=>$e.quiet,set:r=>{$e.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>$e.noColor,set:r=>{$e.noColor=r},enumerable:!0,configurable:!1}});function Xs(r,t){const e=r.byteLength/8|0,s=new Float64Array(r,0,e);new Float64Array(t,0,e).set(s);const i=r.byteLength-e*8;if(i>0){const n=new Uint8Array(r,e*8,i);new Uint8Array(t,e*8,i).set(n)}}const id={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var et=(r=>(r[r.DISABLED=0]="DISABLED",r[r.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",r[r.MASK_ACTIVE=2]="MASK_ACTIVE",r[r.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",r[r.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",r[r.NONE=5]="NONE",r))(et||{});function Le(r,t){return t.alphaMode==="no-premultiply-alpha"&&id[r]||r}let Or;function oo(){return(!Or||Or!=null&&Or.isContextLost())&&(Or=$.get().createCanvas().getContext("webgl",{})),Or}const sT=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
`);function iT(r){let t="";for(let e=0;e0&&(t+=`
else `),et in r?nT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ud=(r,t)=>{for(var e in t||(t={}))oT.call(t,e)&&ld(r,e,t[e]);if(ad)for(var e of ad(t))aT.call(t,e)&&ld(r,e,t[e]);return r};class hd{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new od,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const Gr=[];let Hs=0;ge.register({clear:()=>{if(Gr.length>0)for(const r of Gr)r&&r.destroy();Gr.length=0,Hs=0}});function cd(){return Hs>0?Gr[--Hs]:new hd}function dd(r){Gr[Hs++]=r}let Ir=0;const pd=class Iy{constructor(t){this.uid=W("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t=ud(ud({},Iy.defaultOptions),t),t.maxTextures||(Mr("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=nd());const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:i}=t;this.attributeBuffer=new we(s*4),this.indexBuffer=new Uint16Array(i),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;tthis.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const l=this.attributeBuffer.float32View,u=this.attributeBuffer.uint32View,h=this.indexBuffer;let c=this._batchIndexSize,d=this._batchIndexStart,p="startBatch";const f=this.maxTextures;for(let g=this.elementStart;g=f||x)&&(this._finishBatch(s,d,c-d,i,o,a,t,p),p="renderBatch",d=c,o=b,a=m.topology,s=cd(),i=s.textures,i.clear(),++Ir),m._textureId=_._textureBindLocation=i.count,i.ids[_.uid]=i.count,i.textures[i.count++]=_,m._batch=s,c+=m.indexSize,m.packAsQuad?(this.packQuadAttributes(m,l,u,m._attributeStart,m._textureId),this.packQuadIndex(h,m._indexStart,m._attributeStart/this.vertexSize)):(this.packAttributes(m,l,u,m._attributeStart,m._textureId),this.packIndex(m,h,m._indexStart,m._attributeStart/this.vertexSize))}i.count>0&&(this._finishBatch(s,d,c-d,i,o,a,t,p),d=c,++Ir),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=c}_finishBatch(t,e,s,i,n,o,a,l){t.gpuBindGroup=null,t.bindGroup=null,t.action=l,t.batcher=this,t.textures=i,t.blendMode=n,t.topology=o,t.start=e,t.size=s,++Ir,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),s=new we(e);Xs(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const i=s>65535?new Uint32Array(s):new Uint16Array(s);if(i.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n(r[r.MAP_READ=1]="MAP_READ",r[r.MAP_WRITE=2]="MAP_WRITE",r[r.COPY_SRC=4]="COPY_SRC",r[r.COPY_DST=8]="COPY_DST",r[r.INDEX=16]="INDEX",r[r.VERTEX=32]="VERTEX",r[r.UNIFORM=64]="UNIFORM",r[r.STORAGE=128]="STORAGE",r[r.INDIRECT=256]="INDIRECT",r[r.QUERY_RESOLVE=512]="QUERY_RESOLVE",r[r.STATIC=1024]="STATIC",r))(N||{});class _t extends mt{constructor(t){let{data:e,size:s}=t;const{usage:i,label:n,shrinkToFit:o}=t;super(),this.uid=W("buffer"),this._resourceType="buffer",this._resourceId=W("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s!=null||(s=e==null?void 0:e.byteLength);const a=!!e;this.descriptor={size:s,usage:i,mappedAtCreation:a,label:n},this.shrinkToFit=o!=null?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&N.STATIC)}set static(t){t?this.descriptor.usage|=N.STATIC:this.descriptor.usage&=~N.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const i=this._data;if(this._data=t,this._dataInt32=null,!i||i.length!==t.length){!this.shrinkToFit&&i&&t.byteLengtha&&(a=p),f>l&&(l=f),ps.destroy()),(e=this.indexBuffer)==null||e.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const uT=new Float32Array(1),hT=new Uint32Array(1);class gd extends Ee{constructor(){const t=new _t({data:uT,label:"attribute-batch-buffer",usage:N.VERTEX|N.COPY_DST,shrinkToFit:!1}),e=new _t({data:hT,label:"index-batch-buffer",usage:N.INDEX|N.COPY_DST,shrinkToFit:!1}),s=6*4;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:s,offset:0},aUV:{buffer:t,format:"float32x2",stride:s,offset:2*4},aColor:{buffer:t,format:"unorm8x4",stride:s,offset:4*4},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:s,offset:5*4}},indexBuffer:e})}}const uo=Object.create(null),_d=Object.create(null);function Xe(r,t){let e=_d[r];return e===void 0&&(uo[t]===void 0&&(uo[t]=1),_d[r]=e=uo[t]++),e}let js;function xd(){if(!js){js="mediump";const r=oo();r&&r.getShaderPrecisionFormat&&(js=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return js}function bd(r,t,e){return t?r:e?(r=r.replace("out vec4 finalColor;",""),`
#ifdef GL_ES // This checks if it is WebGL1
#define in varying
#define finalColor gl_FragColor
#define texture texture2D
#endif
${r}
`):`
#ifdef GL_ES // This checks if it is WebGL1
#define in attribute
#define out varying
#endif
${r}
`}function vd(r,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let i=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return i==="highp"&&s!=="highp"&&(i="mediump"),`precision ${i} float;
${r}`}else if(s!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function yd(r,t){return t?`#version 300 es
${r}`:r}const cT={},dT={};function Td(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?cT:dT;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`}
${r}`}function Sd(r,t){return t?r.replace("#version 300 es",""):r}var pT=Object.defineProperty,wd=Object.getOwnPropertySymbols,fT=Object.prototype.hasOwnProperty,mT=Object.prototype.propertyIsEnumerable,Ed=(r,t,e)=>t in r?pT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ad=(r,t)=>{for(var e in t||(t={}))fT.call(t,e)&&Ed(r,e,t[e]);if(wd)for(var e of wd(t))mT.call(t,e)&&Ed(r,e,t[e]);return r};const ho={stripVersion:Sd,ensurePrecision:vd,addProgramDefines:bd,setProgramName:Td,insertVersion:yd},Br=Object.create(null),Pd=class Nu{constructor(t){t=Ad(Ad({},Nu.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:xd()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let i=t.fragment,n=t.vertex;Object.keys(ho).forEach(o=>{const a=s[o];i=ho[o](i,a,!0),n=ho[o](n,a,!1)}),this.fragment=i,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Xe(`${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,Br[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Br[e]||(Br[e]=new Nu(t),Br[e]._cacheKey=e),Br[e]}};Pd.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let xt=Pd;const Rd={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function te(r){var t;return(t=Rd[r])!=null?t:Rd.float32}const gT={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"};function Cd({source:r,entryPoint:t}){var e;const s={},i=r.indexOf(`fn ${t}`);if(i!==-1){const n=r.indexOf("->",i);if(n!==-1){const o=r.substring(i,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let l;for(;(l=a.exec(o))!==null;){const u=(e=gT[l[3]])!=null?e:"float32";s[l[2]]={location:parseInt(l[1],10),format:u,stride:te(u).stride,offset:0,instance:!1,start:0}}}}return s}function zs(r){var t,e,s;const i=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,o=/@binding\((\d+)\)/,a=/var(<[^>]+>)? (\w+)/,l=/:\s*(\w+)/,u=/struct\s+(\w+)\s*{([^}]+)}/g,h=/(\w+)\s*:\s*([\w\<\>]+)/g,c=/struct\s+(\w+)/,d=(t=r.match(i))==null?void 0:t.map(f=>({group:parseInt(f.match(n)[1],10),binding:parseInt(f.match(o)[1],10),name:f.match(a)[2],isUniform:f.match(a)[1]==="",type:f.match(l)[1]}));if(!d)return{groups:[],structs:[]};const p=(s=(e=r.match(u))==null?void 0:e.map(f=>{const g=f.match(c)[1],m=f.match(h).reduce((_,b)=>{const[x,v]=b.split(":");return _[x.trim()]=v.trim(),_},{});return m?{name:g,members:m}:null}).filter(({name:f})=>d.some(g=>g.type===f)))!=null?s:[];return{groups:d,structs:p}}var He=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(He||{});function Md({groups:r}){const t=[];for(let e=0;ee.has(o.name)?!1:(e.add(o.name),!0)),n=[...r.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return s.has(a)?!1:(s.add(a),!0)});return{structs:i,groups:n}}const Fr=Object.create(null);class ft{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;var e,s;const{fragment:i,vertex:n,layout:o,gpuLayout:a,name:l}=t;if(this.name=l,this.fragment=i,this.vertex=n,i.source===n.source){const u=zs(i.source);this.structsAndGroups=u}else{const u=zs(n.source),h=zs(i.source);this.structsAndGroups=Gd(u,h)}this.layout=o!=null?o:Od(this.structsAndGroups),this.gpuLayout=a!=null?a:Md(this.structsAndGroups),this.autoAssignGlobalUniforms=((e=this.layout[0])==null?void 0:e.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((s=this.layout[1])==null?void 0:s.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Xe(s,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=Cd(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,Fr[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return Fr[e]||(Fr[e]=new ft(t),Fr[e]._cacheKey=e),Fr[e]}}function co(r,t,e){if(r)for(const s in r){const i=s.toLocaleLowerCase(),n=t[i];if(n){let o=r[s];s==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}}}const _T=/\{\{(.*?)\}\}/g;function po(r){var t,e;const s={};return((e=(t=r.match(_T))==null?void 0:t.map(i=>i.replace(/[{()}]/g,"")))!=null?e:[]).forEach(i=>{s[i]=[]}),s}function Id(r,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function fo(r,t,e=!1){const s=[];Id(t,s),r.forEach(a=>{a.header&&Id(a.header,s)});const i=s;e&&i.sort();const n=i.map((a,l)=>` @location(${l}) ${a},`).join(`
`);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
${n}
`),o}function Bd(r,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function xT(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function bT(r){const t=/@.*?\s+/g;return r.replace(t,"")}function Fd(r,t){const e=[];Bd(t,e),r.forEach(l=>{l.header&&Bd(l.header,e)});let s=0;const i=e.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${s++}) ${l}`).join(`,
`),n=e.sort().map(l=>` var ${bT(l)};`).join(`
`),o=`return VSOutput(
${e.sort().map(l=>` ${xT(l)}`).join(`,
`)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
${i}
`),a=a.replace("{{start}}",`
${n}
`),a=a.replace("{{return}}",`
${o}
`),a}function mo(r,t){let e=r;for(const s in t){const i=t[s];i.join(`
`).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----//
${i.join(`
`)}
//----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const Ae=Object.create(null),go=new Map;let vT=0;function Dd({template:r,bits:t}){const e=kd(r,t);if(Ae[e])return Ae[e];const{vertex:s,fragment:i}=yT(r,t);return Ae[e]=$d(s,i,t),Ae[e]}function Ud({template:r,bits:t}){const e=kd(r,t);return Ae[e]||(Ae[e]=$d(r.vertex,r.fragment,t)),Ae[e]}function yT(r,t){const e=t.map(o=>o.vertex).filter(o=>!!o),s=t.map(o=>o.fragment).filter(o=>!!o);let i=fo(e,r.vertex,!0);i=Fd(e,i);const n=fo(s,r.fragment,!0);return{vertex:i,fragment:n}}function kd(r,t){return t.map(e=>(go.has(e)||go.set(e,vT++),go.get(e))).sort((e,s)=>e-s).join("-")+r.vertex+r.fragment}function $d(r,t,e){const s=po(r),i=po(t);return e.forEach(n=>{co(n.vertex,s,n.name),co(n.fragment,i,n.name)}),{vertex:mo(r,s),fragment:mo(t,i)}}const Ld=`
@in aPosition: vec2;
@in aUV: vec2;
@out @builtin(position) vPosition: vec4;
@out vUV : vec2;
@out vColor : vec4;
{{header}}
struct VSOutput {
{{struct}}
};
@vertex
fn main( {{in}} ) -> VSOutput {
var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
var modelMatrix = mat3x3(
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0
);
var position = aPosition;
var uv = aUV;
{{start}}
vColor = vec4(1., 1., 1., 1.);
{{main}}
vUV = uv;
var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
vPosition = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
vColor *= globalUniforms.uWorldColorAlpha;
{{end}}
{{return}}
};
`,Nd=`
@in vUV : vec2;
@in vColor : vec4;
{{header}}
@fragment
fn main(
{{in}}
) -> @location(0) vec4 {
{{start}}
var outColor:vec4;
{{main}}
var finalColor:vec4 = outColor * vColor;
{{end}}
return finalColor;
};
`,Xd=`
in vec2 aPosition;
in vec2 aUV;
out vec4 vColor;
out vec2 vUV;
{{header}}
void main(void){
mat3 worldTransformMatrix = uWorldTransformMatrix;
mat3 modelMatrix = mat3(
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0
);
vec2 position = aPosition;
vec2 uv = aUV;
{{start}}
vColor = vec4(1.);
{{main}}
vUV = uv;
mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
vColor *= uWorldColorAlpha;
{{end}}
}
`,Hd=`
in vec4 vColor;
in vec2 vUV;
out vec4 finalColor;
{{header}}
void main(void) {
{{start}}
vec4 outColor;
{{main}}
finalColor = outColor * vColor;
{{end}}
}
`,jd={name:"global-uniforms-bit",vertex:{header:`
struct GlobalUniforms {
uProjectionMatrix:mat3x3,
uWorldTransformMatrix:mat3x3,
uWorldColorAlpha: vec4,
uResolution: vec2,
}
@group(0) @binding(0) var globalUniforms : GlobalUniforms;
`}},TT={name:"global-uniforms-ubo-bit",vertex:{header:`
uniform globalUniforms {
mat3 uProjectionMatrix;
mat3 uWorldTransformMatrix;
vec4 uWorldColorAlpha;
vec2 uResolution;
};
`}},zd={name:"global-uniforms-bit",vertex:{header:`
uniform mat3 uProjectionMatrix;
uniform mat3 uWorldTransformMatrix;
uniform vec4 uWorldColorAlpha;
uniform vec2 uResolution;
`}};var ST=Object.defineProperty,Vd=Object.getOwnPropertySymbols,wT=Object.prototype.hasOwnProperty,ET=Object.prototype.propertyIsEnumerable,Wd=(r,t,e)=>t in r?ST(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,AT=(r,t)=>{for(var e in t||(t={}))wT.call(t,e)&&Wd(r,e,t[e]);if(Vd)for(var e of Vd(t))ET.call(t,e)&&Wd(r,e,t[e]);return r};function je({bits:r,name:t}){const e=Dd({template:{fragment:Nd,vertex:Ld},bits:[jd,...r]});return ft.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function ze({bits:r,name:t}){return new xt(AT({name:t},Ud({template:{vertex:Xd,fragment:Hd},bits:[zd,...r]})))}const Vs={name:"color-bit",vertex:{header:`
@in aColor: vec4;
`,main:`
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
`}},Ws={name:"color-bit",vertex:{header:`
in vec4 aColor;
`,main:`
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
`}},_o={};function PT(r){const t=[];if(r===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let s=0;s;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(`
`)}function RT(r){const t=[];if(r===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e;
@out @interpolate(flat) vTextureId : u32;
`,main:`
vTextureId = aTextureIdAndRound.y;
`,end:`
if(aTextureIdAndRound.x == 1)
{
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
}
`},fragment:{header:`
@in @interpolate(flat) vTextureId: u32;
${PT(r)}
`,main:`
var uvDx = dpdx(vUV);
var uvDy = dpdy(vUV);
${RT(r)}
`}}),_o[r]}const xo={};function CT(r){const t=[];for(let e=0;e0&&t.push("else"),e, targetSize: vec2) -> vec2
{
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
}
`}},We={name:"round-pixels-bit",vertex:{header:`
vec2 roundPixels(vec2 position, vec2 targetSize)
{
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
}
`}},bo=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4","vec2","vec3","vec4"],Yd=bo.reduce((r,t)=>(r[t]=!0,r),{});function Kd(r,t){switch(r){case"f32":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"mat2x2":return new Float32Array([1,0,0,1]);case"mat3x3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var MT=Object.defineProperty,qd=Object.getOwnPropertySymbols,OT=Object.prototype.hasOwnProperty,GT=Object.prototype.propertyIsEnumerable,Zd=(r,t,e)=>t in r?MT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qd=(r,t)=>{for(var e in t||(t={}))OT.call(t,e)&&Zd(r,e,t[e]);if(qd)for(var e of qd(t))GT.call(t,e)&&Zd(r,e,t[e]);return r};const Jd=class By{constructor(t,e){this._touched=0,this.uid=W("uniform"),this._resourceType="uniformGroup",this._resourceId=W("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1;var s,i;e=Qd(Qd({},By.defaultOptions),e),this.uniformStructures=t;const n={};for(const o in t){const a=t[o];if(a.name=o,a.size=(s=a.size)!=null?s:1,!Yd[a.type]){const l=a.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(l){const[,u,h]=l;throw new Error(`Uniform type ${a.type} is not supported. Use type: '${u}', size: ${h} instead.`)}throw new Error(`Uniform type ${a.type} is not supported. Supported uniform types are: ${bo.join(", ")}`)}(i=a.value)!=null||(a.value=Kd(a.type,a.size)),n[o]=a.value}this.uniforms=n,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Xe(Object.keys(n).map(o=>`${o}-${t[o].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Jd.defaultOptions={ubo:!1,isStatic:!1};let it=Jd;const tp={};function qs(r){let t=tp[r];if(t)return t;const e=new Int32Array(r);for(let s=0;s(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.BOTH=3]="BOTH",r))(bt||{}),IT=Object.defineProperty,Zs=Object.getOwnPropertySymbols,ep=Object.prototype.hasOwnProperty,rp=Object.prototype.propertyIsEnumerable,sp=(r,t,e)=>t in r?IT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,BT=(r,t)=>{for(var e in t||(t={}))ep.call(t,e)&&sp(r,e,t[e]);if(Zs)for(var e of Zs(t))rp.call(t,e)&&sp(r,e,t[e]);return r},FT=(r,t)=>{var e={};for(var s in r)ep.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Zs)for(var s of Zs(r))t.indexOf(s)<0&&rp.call(r,s)&&(e[s]=r[s]);return e};class Ct extends mt{constructor(t){super(),this.uid=W("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:s,groups:i,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=s,o===void 0&&(o=0,e&&(o|=bt.WEBGPU),s&&(o|=bt.WEBGL)),this.compatibleRenderers=o;const l={};if(!n&&!i&&(n={}),n&&i)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&i&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&i&&a)for(const u in a)for(const h in a[u]){const c=a[u][h];l[c]={group:u,binding:h,name:c}}else if(e&&i&&!a){const u=e.structsAndGroups.groups;a={},u.forEach(h=>{a[h.group]=a[h.group]||{},a[h.group][h.binding]=h.name,l[h.name]=h})}else if(n){i={},a={},e&&e.structsAndGroups.groups.forEach(h=>{a[h.group]=a[h.group]||{},a[h.group][h.binding]=h.name,l[h.name]=h});let u=0;for(const h in n)l[h]||(i[99]||(i[99]=new Vt,this._ownedBindGroups.push(i[99])),l[h]={group:99,binding:u,name:h},a[99]=a[99]||{},a[99][u]=h,u++);for(const h in n){const c=h;let d=n[h];!d.source&&!d._resourceType&&(d=new it(d));const p=l[c];p&&(i[p.group]||(i[p.group]=new Vt,this._ownedBindGroups.push(i[p.group])),i[p.group].setResource(d,p.binding))}}this.groups=i,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(i,l)}addResource(t,e,s){var i,n;(i=this._uniformBindMap)[e]||(i[e]={}),(n=this._uniformBindMap[e])[s]||(n[s]=t),this.groups[e]||(this.groups[e]=new Vt,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const i in e){const n=e[i];Object.defineProperty(s,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return s}destroy(t=!1){var e,s;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(i=>{i.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const e=t,{gpu:s,gl:i}=e,n=FT(e,["gpu","gl"]);let o,a;return s&&(o=ft.from(s)),i&&(a=xt.from(i)),new Ct(BT({gpuProgram:o,glProgram:a},n))}}class vo extends Ct{constructor(t){const e=ze({name:"batch",bits:[Ws,Ks(t),We]}),s=je({name:"batch",bits:[Vs,Ys(t),Ve]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:qs(t)}}),this.maxTextures=t}}let Dr=null;const ip=class Fy extends fd{constructor(t){super(t),this.geometry=new gd,this.name=Fy.extension.name,this.vertexSize=6,Dr!=null||(Dr=new vo(t.maxTextures)),this.shader=Dr}packAttributes(t,e,s,i,n){const o=n<<16|t.roundPixels&65535,a=t.transform,l=a.a,u=a.b,h=a.c,c=a.d,d=a.tx,p=a.ty,{positions:f,uvs:g}=t,m=t.color,_=t.attributeOffset,b=_+t.attributeSize;for(let x=_;x>16|t&65280|(t&255)<<16,s=this.renderable;return s?Cn(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||DT}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}var UT=Object.defineProperty,kT=Object.defineProperties,$T=Object.getOwnPropertyDescriptors,np=Object.getOwnPropertySymbols,LT=Object.prototype.hasOwnProperty,NT=Object.prototype.propertyIsEnumerable,op=(r,t,e)=>t in r?UT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ei=(r,t)=>{for(var e in t||(t={}))LT.call(t,e)&&op(r,e,t[e]);if(np)for(var e of np(t))NT.call(t,e)&&op(r,e,t[e]);return r},ri=(r,t)=>kT(r,$T(t));const Ye={extension:{type:y.ShapeBuilder,name:"circle"},build(r,t){let e,s,i,n,o,a;if(r.type==="circle"){const v=r;if(o=a=v.radius,o<=0)return!1;e=v.x,s=v.y,i=n=0}else if(r.type==="ellipse"){const v=r;if(o=v.halfWidth,a=v.halfHeight,o<=0||a<=0)return!1;e=v.x,s=v.y,i=n=0}else{const v=r,S=v.width/2,T=v.height/2;e=v.x+S,s=v.y+T,o=a=Math.max(0,Math.min(v.radius,Math.min(S,T))),i=S-o,n=T-a}if(i<0||n<0)return!1;const l=Math.ceil(2.3*Math.sqrt(o+a)),u=l*8+(i?4:0)+(n?4:0);if(u===0)return!1;if(l===0)return t[0]=t[6]=e+i,t[1]=t[3]=s+n,t[2]=t[4]=e-i,t[5]=t[7]=s-n,!0;let h=0,c=l*4+(i?2:0)+2,d=c,p=u,f=i+o,g=n,m=e+f,_=e-f,b=s+g;if(t[h++]=m,t[h++]=b,t[--c]=b,t[--c]=_,n){const v=s-g;t[d++]=_,t[d++]=v,t[--p]=v,t[--p]=m}for(let v=1;v0&&(i[n++]=l,i[n++]=u,i[n++]=l-1),l++;i[n++]=u+1,i[n++]=u,i[n++]=l-1}},ap=ri(ei({},Ye),{extension:ri(ei({},Ye.extension),{name:"ellipse"})}),lp=ri(ei({},Ye),{extension:ri(ei({},Ye.extension),{name:"roundedRectangle"})}),So=1e-4,wo=1e-4;function up(r){const t=r.length;if(t<6)return 1;let e=0;for(let s=0,i=r[t-2],n=r[t-1];sc&&(c+=Math.PI*2);let d=h;const p=c-h,f=Math.abs(p),g=Math.sqrt(l*l+u*u),m=(15*f*Math.sqrt(g)/Math.PI>>0)+1,_=p/m;if(d+=_,a){o.push(r,t),o.push(e,s);for(let b=1,x=d;b=0&&(a.join==="round"?g+=Pe(T,w,T-E*I,w-P*I,T-D*I,w-U*I,p,!1)+4:g+=2,p.push(T-D*B,w-U*B),p.push(T+D*I,w+U*I));continue}const Zu=(-E+v)*(-P+w)-(-E+T)*(-P+S),Qu=(-D+C)*(-U+w)-(-D+T)*(-U+M),vs=(se*Qu-gr*Zu)/bs,ys=(_r*Zu-mr*Qu)/bs,vn=(vs-T)*(vs-T)+(ys-w)*(ys-w),de=T+(vs-T)*I,pe=w+(ys-w)*I,fe=T-(vs-T)*B,me=w-(ys-w)*B,o0=Math.min(se*se+mr*mr,gr*gr+_r*_r),Ju=xr?I:B,a0=o0+Ju*Ju*b;vn<=a0?a.join==="bevel"||vn/b>x?(xr?(p.push(de,pe),p.push(T+E*B,w+P*B),p.push(de,pe),p.push(T+D*B,w+U*B)):(p.push(T-E*I,w-P*I),p.push(fe,me),p.push(T-D*I,w-U*I),p.push(fe,me)),g+=2):a.join==="round"?xr?(p.push(de,pe),p.push(T+E*B,w+P*B),g+=Pe(T,w,T+E*B,w+P*B,T+D*B,w+U*B,p,!0)+4,p.push(de,pe),p.push(T+D*B,w+U*B)):(p.push(T-E*I,w-P*I),p.push(fe,me),g+=Pe(T,w,T-E*I,w-P*I,T-D*I,w-U*I,p,!1)+4,p.push(T-D*I,w-U*I),p.push(fe,me)):(p.push(de,pe),p.push(fe,me)):(p.push(T-E*I,w-P*I),p.push(T+E*B,w+P*B),a.join==="round"?xr?g+=Pe(T,w,T+E*B,w+P*B,T+D*B,w+U*B,p,!0)+2:g+=Pe(T,w,T-E*I,w-P*I,T-D*I,w-U*I,p,!1)+2:a.join==="miter"&&vn/b<=x&&(xr?(p.push(fe,me),p.push(fe,me)):(p.push(de,pe),p.push(de,pe)),g+=2),p.push(T-D*I,w-U*I),p.push(T+D*B,w+U*B),g+=2)}v=r[(f-2)*2],S=r[(f-2)*2+1],T=r[(f-1)*2],w=r[(f-1)*2+1],E=-(S-w),P=v-T,G=Math.sqrt(E*E+P*P),E/=G,P/=G,E*=_,P*=_,p.push(T-E*I,w-P*I),p.push(T+E*B,w+P*B),c||(a.cap==="round"?g+=Pe(T-E*(I-B)*.5,w-P*(I-B)*.5,T-E*I,w-P*I,T+E*B,w+P*B,p,!1)+2:a.cap==="square"&&(g+=hp(T,w,E,P,I,B,!1,p)));const xs=wo*wo;for(let Y=m;Y80*e){a=r[0],l=r[1];let h=a,c=l;for(let d=e;dh&&(h=p),f>c&&(c=f)}u=Math.max(h-a,c-l),u=u!==0?32767/u:0}return Ur(n,o,e,a,l,u,0),o}function fp(r,t,e,s,i){let n;if(i===Po(r,t,e,s)>0)for(let o=t;o=t;o-=s)n=xp(o/s|0,r[o],r[o+1],n);return n&&Ke(n,n.next)&&(Lr(n),n=n.next),n}function Re(r,t){if(!r)return r;t||(t=r);let e=r,s;do if(s=!1,!e.steiner&&(Ke(e,e.next)||Q(e.prev,e,e.next)===0)){if(Lr(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function Ur(r,t,e,s,i,n,o){if(!r)return;!o&&n&&ZT(r,s,i,n);let a=r;for(;r.prev!==r.next;){const l=r.prev,u=r.next;if(n?HT(r,s,i,n):XT(r)){t.push(l.i,r.i,u.i),Lr(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=jT(Re(r),t),Ur(r,t,e,s,i,n,2)):o===2&&zT(r,t,e,s,i,n):Ur(Re(r),t,e,s,i,n,1);break}}}function XT(r){const t=r.prev,e=r,s=r.next;if(Q(t,e,s)>=0)return!1;const i=t.x,n=e.x,o=s.x,a=t.y,l=e.y,u=s.y,h=Math.min(i,n,o),c=Math.min(a,l,u),d=Math.max(i,n,o),p=Math.max(a,l,u);let f=s.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=c&&f.y<=p&&kr(i,a,n,l,o,u,f.x,f.y)&&Q(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function HT(r,t,e,s){const i=r.prev,n=r,o=r.next;if(Q(i,n,o)>=0)return!1;const a=i.x,l=n.x,u=o.x,h=i.y,c=n.y,d=o.y,p=Math.min(a,l,u),f=Math.min(h,c,d),g=Math.max(a,l,u),m=Math.max(h,c,d),_=Eo(p,f,t,e,s),b=Eo(g,m,t,e,s);let x=r.prevZ,v=r.nextZ;for(;x&&x.z>=_&&v&&v.z<=b;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==i&&x!==o&&kr(a,h,l,c,u,d,x.x,x.y)&&Q(x.prev,x,x.next)>=0||(x=x.prevZ,v.x>=p&&v.x<=g&&v.y>=f&&v.y<=m&&v!==i&&v!==o&&kr(a,h,l,c,u,d,v.x,v.y)&&Q(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;x&&x.z>=_;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==i&&x!==o&&kr(a,h,l,c,u,d,x.x,x.y)&&Q(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=b;){if(v.x>=p&&v.x<=g&&v.y>=f&&v.y<=m&&v!==i&&v!==o&&kr(a,h,l,c,u,d,v.x,v.y)&&Q(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function jT(r,t){let e=r;do{const s=e.prev,i=e.next.next;!Ke(s,i)&&gp(s,e,e.next,i)&&$r(s,i)&&$r(i,s)&&(t.push(s.i,e.i,i.i),Lr(e),Lr(e.next),e=r=i),e=e.next}while(e!==r);return Re(e)}function zT(r,t,e,s,i,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&tS(o,a)){let l=_p(o,a);o=Re(o,o.next),l=Re(l,l.next),Ur(o,t,e,s,i,n,0),Ur(l,t,e,s,i,n,0);return}a=a.next}o=o.next}while(o!==r)}function VT(r,t,e,s){const i=[];for(let n=0,o=t.length;n=e.next.y&&e.next.y!==e.y){const c=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(c<=s&&c>n&&(n=c,o=e.x=e.x&&e.x>=l&&s!==e.x&&mp(io.x||e.x===o.x&&qT(o,e)))&&(o=e,h=c)}e=e.next}while(e!==a);return o}function qT(r,t){return Q(r.prev,r,t.prev)<0&&Q(t.next,r,r.next)<0}function ZT(r,t,e,s){let i=r;do i.z===0&&(i.z=Eo(i.x,i.y,t,e,s)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,QT(i)}function QT(r){let t,e=1;do{let s=r,i;r=null;let n=null;for(t=0;s;){t++;let o=s,a=0;for(let u=0;u0||l>0&&o;)a!==0&&(l===0||!o||s.z<=o.z)?(i=s,s=s.nextZ,a--):(i=o,o=o.nextZ,l--),n?n.nextZ=i:r=i,i.prevZ=n,n=i;s=o}n.nextZ=null,e*=2}while(t>1);return r}function Eo(r,t,e,s,i){return r=(r-e)*i|0,t=(t-s)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function JT(r){let t=r,e=r;do(t.x=(r-o)*(n-a)&&(r-o)*(s-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(i-o)*(s-a)}function kr(r,t,e,s,i,n,o,a){return!(r===o&&t===a)&&mp(r,t,e,s,i,n,o,a)}function tS(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!eS(r,t)&&($r(r,t)&&$r(t,r)&&rS(r,t)&&(Q(r.prev,r,t.prev)||Q(r,t.prev,t))||Ke(r,t)&&Q(r.prev,r,r.next)>0&&Q(t.prev,t,t.next)>0)}function Q(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Ke(r,t){return r.x===t.x&&r.y===t.y}function gp(r,t,e,s){const i=ii(Q(r,t,e)),n=ii(Q(r,t,s)),o=ii(Q(e,s,r)),a=ii(Q(e,s,t));return!!(i!==n&&o!==a||i===0&&si(r,e,t)||n===0&&si(r,s,t)||o===0&&si(e,r,s)||a===0&&si(e,t,s))}function si(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function ii(r){return r>0?1:r<0?-1:0}function eS(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&gp(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function $r(r,t){return Q(r.prev,r,r.next)<0?Q(r,t,r.next)>=0&&Q(r,r.prev,t)>=0:Q(r,t,r.prev)<0||Q(r,r.next,t)<0}function rS(r,t){let e=r,s=!1;const i=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&i<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==r);return s}function _p(r,t){const e=Ao(r.i,r.x,r.y),s=Ao(t.i,t.x,t.y),i=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,s.next=e,e.prev=s,n.next=s,s.prev=n,s}function xp(r,t,e,s){const i=Ao(r,t,e);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function Lr(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Ao(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function i3(r,t,e,s){const i=t&&t.length,n=i?t[0]*e:r.length;let o=Math.abs(Po(r,0,n,e));if(i)for(let l=0,u=t.length;l0&&o>0?(t[0]=s,t[1]=i,t[2]=s+n,t[3]=i,t[4]=s+n,t[5]=i+o,t[6]=s,t[7]=i+o,!0):!1},triangulate(r,t,e,s,i,n){let o=0;s*=e,t[s+o]=r[0],t[s+o+1]=r[1],o+=e,t[s+o]=r[2],t[s+o+1]=r[3],o+=e,t[s+o]=r[6],t[s+o+1]=r[7],o+=e,t[s+o]=r[4],t[s+o+1]=r[5],o+=e;const a=s/e;i[n++]=a,i[n++]=a+1,i[n++]=a+2,i[n++]=a+1,i[n++]=a+3,i[n++]=a+2}},Tp={extension:{type:y.ShapeBuilder,name:"triangle"},build(r,t){return t[0]=r.x,t[1]=r.y,t[2]=r.x2,t[3]=r.y2,t[4]=r.x3,t[5]=r.y3,!0},triangulate(r,t,e,s,i,n){let o=0;s*=e,t[s+o]=r[0],t[s+o+1]=r[1],o+=e,t[s+o]=r[2],t[s+o+1]=r[3],o+=e,t[s+o]=r[4],t[s+o+1]=r[5];const a=s/e;i[n++]=a,i[n++]=a+1,i[n++]=a+2}};var iS=Object.defineProperty,Sp=Object.getOwnPropertySymbols,nS=Object.prototype.hasOwnProperty,oS=Object.prototype.propertyIsEnumerable,wp=(r,t,e)=>t in r?iS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ep=(r,t)=>{for(var e in t||(t={}))nS.call(t,e)&&wp(r,e,t[e]);if(Sp)for(var e of Sp(t))oS.call(t,e)&&wp(r,e,t[e]);return r};const Ap=[{offset:0,color:"white"},{offset:1,color:"black"}],Co=class Xu{constructor(...t){this.uid=W("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];var e;let s=aS(t);const i=s.type==="radial"?Xu.defaultRadialOptions:Xu.defaultLinearOptions;s=Ep(Ep({},i),Bt(s)),this._textureSize=s.textureSize,this._wrapMode=s.wrapMode,s.type==="radial"?(this.center=s.center,this.outerCenter=(e=s.outerCenter)!=null?e: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(n=>{this.addColorStop(n.offset,n.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:X.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:s,y:i}=this.end,n=s-t,o=i-e;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const m=t;t=s,s=m,n*=-1}if(o<0){const m=e;e=i,i=m,o*=-1}}const l=this.colorStops.length?this.colorStops:Ap,u=this._textureSize,{canvas:h,context:c}=Rp(u,1),d=a?c.createLinearGradient(this._textureSize,0,0,0):c.createLinearGradient(0,0,this._textureSize,0);Pp(d,l),c.fillStyle=d,c.fillRect(0,0,u,1),this.texture=new A({source:new ne({resource:h,addressMode:this._wrapMode})});const p=Math.sqrt(n*n+o*o),f=Math.atan2(o,n),g=new R;g.scale(p/u,1),g.rotate(f),g.translate(t,e),this.textureSpace==="local"&&g.scale(u,u),this.transform=g}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Ap,e=this._textureSize,{canvas:s,context:i}=Rp(e,e),{x:n,y:o}=this.center,{x:a,y:l}=this.outerCenter,u=this.innerRadius,h=this.outerRadius,c=a-h,d=l-h,p=e/(h*2),f=(n-c)*p,g=(o-d)*p,m=i.createRadialGradient(f,g,u*p,(a-c)*p,(l-d)*p,h*p);Pp(m,t),i.fillStyle=t[t.length-1].color,i.fillRect(0,0,e,e),i.fillStyle=m,i.translate(f,g),i.rotate(this.rotation),i.scale(1,this.scale),i.translate(-f,-g),i.fillRect(0,0,e,e),this.texture=new A({source:new ne({resource:s,addressMode:this._wrapMode})});const _=new R;_.scale(1/p,1/p),_.translate(c,d),this.textureSpace==="local"&&_.scale(e,e),this.transform=_}destroy(){var t;(t=this.texture)==null||t.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};Co.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},Co.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Wt=Co;function Pp(r,t){for(let e=0;e{var c;const d=[],p=qe[l.type];if(!p.build(l,d))return;const f=a.length,g=n.length/2;let m="triangle-list";if(u&&Js(d,u),e){const v=(c=l.closePath)!=null?c:!0,S=t;S.pixelLine?(dp(d,v,n,a),m="line-list"):cp(d,S,!1,v,n,a)}else if(h){const v=[],S=d.slice();pS(h).forEach(T=>{v.push(S.length/2),S.push(...T)}),Ro(S,v,n,2,g,a,f)}else p.triangulate(d,n,2,g,a,f);const _=o.length/2,b=t.texture;if(b!==A.WHITE){const v=Cp(cS,t,l,u);yo(n,2,g,o,_,2,n.length/2-g,v)}else To(o,_,2,n.length/2-g);const x=st.get(ti);x.indexOffset=f,x.indexSize=a.length-f,x.attributeOffset=g,x.attributeSize=n.length/2-g,x.baseColor=t.color,x.alpha=t.alpha,x.texture=b,x.geometryData=i,x.topology=m,s.push(x)})}function pS(r){const t=[];for(let e=0;e{st.return(s)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context);this._gpuContextHash={},this._graphicsDataContextHash={},this._renderer=null}};Mo.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"graphicsContext"},Mo.defaultOptions={bezierSmoothness:.5};let ni=Mo;const fS={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},Oo=0,Go=1,Io=2,Bo=3,Fo=4,Do=5,Uo=class Dy{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<>16&255)/255,e[s++]=(r>>8&255)/255,e[s++]=(r&255)/255,e[s++]=t}function Ze(r,t,e){const s=(r>>24&255)/255;t[e++]=(r&255)/255*s,t[e++]=(r>>8&255)/255*s,t[e++]=(r>>16&255)/255*s,t[e++]=s}class Bp{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{st.return(t)}),this.batches.length=0}}class ko{constructor(t,e){this.state=Et.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,s=!!t._gpuData,i=this.renderer.graphicsContext.updateGpuContext(e);return!!(i.isBatchable||s!==i.isBatchable)}addRenderable(t,e){const s=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),s.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._getGpuDataForRenderable(t).batches;for(let s=0;s{const a=st.get(ti);return o.copyTo(a),a.renderable=t,a.roundPixels=n,a})}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}ko.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"graphics"},F.add(ko),F.add(ni);class oi{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 s=e;const i=this.texture.textureMatrix;return i.isSimple||(s=this._transformedUvs,(this._textureMatrixUpdateId!==i._updateID||this._uvUpdateId!==t._updateID)&&((!s||s.length"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Vt({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),s=e.batched,i=t.batched;if(e.batched=i,s!==i)return!0;if(i){const n=t._geometry;if(n.indices.length!==e.indexSize||n.positions.length!==e.vertexSize)return e.indexSize=n.indices.length,e.vertexSize=n.positions.length,!0;const o=this._getBatchableMesh(t);return o.texture.uid!==t._texture.uid&&(o._textureMatrixUpdateId=-1),!o._batcher.checkAndUpdateTexture(o,t._texture)}return!1}addRenderable(t,e){var s,i;const n=this.renderer.renderPipes.batch,o=this._getMeshData(t);if(t.didViewUpdate&&(o.indexSize=(s=t._geometry.indices)==null?void 0:s.length,o.vertexSize=(i=t._geometry.positions)==null?void 0:i.length),o.batched){const a=this._getBatchableMesh(t);a.setTexture(t._texture),a.geometry=t._geometry,n.addToBatch(a,e)}else n.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=Le(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,s;return(e=t._gpuData)[s=this.renderer.uid]||(e[s]=new $o),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,s;return(e=t._gpuData)[s=this.renderer.uid]||(e[s]=new $o),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new oi;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}}Lo.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"mesh"},F.add(Lo);class Fp{execute(t,e){const s=t.state,i=t.renderer,n=e.shader||t.defaultShader;n.resources.uTexture=e.texture._source,n.resources.uniforms=t.localUniforms;const o=i.gl,a=t.getBuffers(e);i.shader.bind(n),i.state.set(s),i.geometry.bind(a.geometry,n.glProgram);const l=a.geometry.indexBuffer.data.BYTES_PER_ELEMENT===2?o.UNSIGNED_SHORT:o.UNSIGNED_INT;o.drawElements(o.TRIANGLES,e.particleChildren.length*6,l,0)}}function No(r,t=null){const e=r*6;if(e>65535?t||(t=new Uint32Array(e)):t||(t=new Uint16Array(e)),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let s=0,i=0;sthis._size&&(e=!0,this._size=Math.max(t.length,this._size*1.5|0),this.staticAttributeBuffer=new we(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new we(this._size*this._dynamicStride*4*4),this.indexBuffer=No(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const s=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,s.float32View,s.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){const i=this.staticAttributeBuffer;this._staticUpload(t,i.float32View,i.uint32View),this._staticBuffer.setDataWithSize(i.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}function gS(r){const t=[];for(const e in r){const s=r[e];t.push(e,s.code,s.dynamic?"d":"s")}return t.join("_")}var $p=`varying vec2 vUV;
varying vec4 vColor;
uniform sampler2D uTexture;
void main(void){
vec4 color = texture2D(uTexture, vUV) * vColor;
gl_FragColor = color;
}`,Lp=`attribute vec2 aVertex;
attribute vec2 aUV;
attribute vec4 aColor;
attribute vec2 aPosition;
attribute float aRotation;
uniform mat3 uTranslationMatrix;
uniform float uRound;
uniform vec2 uResolution;
uniform vec4 uColor;
varying vec2 vUV;
varying vec4 vColor;
vec2 roundPixels(vec2 position, vec2 targetSize)
{
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
}
void main(void){
float cosRotation = cos(aRotation);
float sinRotation = sin(aRotation);
float x = aVertex.x * cosRotation - aVertex.y * sinRotation;
float y = aVertex.x * sinRotation + aVertex.y * cosRotation;
vec2 v = vec2(x, y);
v = v + aPosition;
gl_Position = vec4((uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
if(uRound == 1.0)
{
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
}
vUV = aUV;
vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor;
}
`,Xo=`
struct ParticleUniforms {
uTranslationMatrix:mat3x3,
uColor:vec4,
uRound:f32,
uResolution:vec2,
};
fn roundPixels(position: vec2, targetSize: vec2) -> vec2
{
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
}
@group(0) @binding(0) var uniforms: ParticleUniforms;
@group(1) @binding(0) var uTexture: texture_2d;
@group(1) @binding(1) var uSampler : sampler;
struct VSOutput {
@builtin(position) position: vec4,
@location(0) uv : vec2,
@location(1) color : vec4,
};
@vertex
fn mainVertex(
@location(0) aVertex: vec2,
@location(1) aPosition: vec2,
@location(2) aUV: vec2,
@location(3) aColor: vec4,
@location(4) aRotation: f32,
) -> VSOutput {
let v = vec2(
aVertex.x * cos(aRotation) - aVertex.y * sin(aRotation),
aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation)
) + aPosition;
var position = vec4((uniforms.uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
if(uniforms.uRound == 1.0) {
position = vec4(roundPixels(position.xy, uniforms.uResolution), position.zw);
}
let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor;
return VSOutput(
position,
aUV,
vColor,
);
}
@fragment
fn mainFragment(
@location(0) uv: vec2,
@location(1) color: vec4,
@builtin(position) position: vec4,
) -> @location(0) vec4 {
var sample = textureSample(uTexture, uSampler, uv) * color;
return sample;
}`;class Np extends Ct{constructor(){const t=xt.from({vertex:Lp,fragment:$p}),e=ft.from({fragment:{source:Xo,entryPoint:"mainFragment"},vertex:{source:Xo,entryPoint:"mainVertex"}});super({glProgram:t,gpuProgram:e,resources:{uTexture:A.WHITE.source,uSampler:new St({}),uniforms:{uTranslationMatrix:{value:new R,type:"mat3x3"},uColor:{value:new X(16777215),type:"vec4"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2"}}}})}}class Ho{constructor(t,e){this.state=Et.for2d(),this.localUniforms=new it({uTranslationMatrix:{value:new R,type:"mat3x3"},uColor:{value:new Float32Array(4),type:"vec4"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new Np,this.state=Et.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 kp({size:t.particleChildren.length,properties:t._properties}),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){const e=t.particleChildren;if(e.length===0)return;const s=this.renderer,i=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const n=this.state;i.update(e,t._childrenDirty),t._childrenDirty=!1,n.blendMode=Le(t.blendMode,t.texture._source);const o=this.localUniforms.uniforms,a=o.uTranslationMatrix;t.worldTransform.copyTo(a),a.prepend(s.globalUniforms.globalUniformData.projectionMatrix),o.uResolution=s.globalUniforms.globalUniformData.resolution,o.uRound=s._roundPixels|t._roundPixels,Ze(t.groupColorAlpha,o.uColor,0),this.adaptor.execute(this,t)}destroy(){this.renderer=null,this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}class jo extends Ho{constructor(t){super(t,new Fp)}}jo.extension={type:[y.WebGLPipes],name:"particle"};class Xp{execute(t,e){const s=t.renderer,i=e.shader||t.defaultShader;i.groups[0]=s.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),i.groups[1]=s.texture.getTextureBindGroup(e.texture);const n=t.state,o=t.getBuffers(e);s.encoder.draw({geometry:o.geometry,shader:e.shader||t.defaultShader,state:n,size:e.particleChildren.length*6})}}class zo extends Ho{constructor(t){super(t,new Xp)}}zo.extension={type:[y.WebGPUPipes],name:"particle"},F.add(jo),F.add(zo);function ai(r,t){const{texture:e,bounds:s}=r,i=t._style._getFinalPadding();qn(s,t._anchor,e);const n=t._anchor._x*i*2,o=t._anchor._y*i*2;s.minX-=i-n,s.minY-=i-o,s.maxX-=i-n,s.maxY-=i-o}class Nr{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(){}}class Hp extends Nr{constructor(t){super(),this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){const{canvasText:t}=this._renderer;t.getReferenceCount(this.currentKey)>0?t.decreaseReferenceCount(this.currentKey):this.texture&&t.returnTexture(this.texture),this._renderer.runners.resolutionChange.remove(this),this._renderer=null}}class Vo{constructor(t){this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),s=t.styleKey;return e.currentKey!==s?!0:t._didTextUpdate}addRenderable(t,e){const s=this._getGpuText(t);if(t._didTextUpdate){const i=t._autoResolution?this._renderer.resolution:t.resolution;(s.currentKey!==t.styleKey||t.resolution!==i)&&this._updateGpuText(t),t._didTextUpdate=!1,ai(s,t)}this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Hp(this._renderer);return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Vo.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"text"};const jp={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 Xr{constructor(t,e){this.uid=W("fillPattern"),this._tick=0,this.transform=new R,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=jp[e].addressModeU,t.source.style.addressModeV=jp[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._tick++}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture=t,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}var _S=bS,Wo={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},xS=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function bS(r){var t=[];return r.replace(xS,function(e,s,i){var n=s.toLowerCase();for(i=yS(i),n=="m"&&i.length>2&&(t.push([s].concat(i.splice(0,2))),n="l",s=s=="m"?"l":"L");;){if(i.length==Wo[n])return i.unshift(s),t.push(i);if(i.length0&&(i=s.pop(),i?(n=i.startX,o=i.startY):(n=0,o=0)),i=null;break;default:}u!=="Z"&&u!=="z"&&i===null&&(i={startX:n,startY:o},s.push(i))}return t}class mn{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new mn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let i=this.x-t,n=this.y-e;return i*=i,n*=n,i+n<=s}strokeContains(t,e,s,i=.5){if(this.radius===0)return!1;const n=this.x-t,o=this.y-e,a=this.radius,l=(1-i)*s,u=Math.sqrt(n*n+o*o);return u<=a+l&&u>a-(s-l)}getBounds(t){return t||(t=new j),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}}class gn{constructor(t=0,e=0,s=0,i=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=i}clone(){return new gn(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,i=(e-this.y)/this.halfHeight;return s*=s,i*=i,s+i<=1}strokeContains(t,e,s,i=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=s*(1-i),l=s-a,u=n-l,h=o-l,c=n+a,d=o+a,p=t-this.x,f=e-this.y,g=p*p/(u*u)+f*f/(h*h),m=p*p/(c*c)+f*f/(d*d);return g>1&&m<=1}getBounds(t){return t||(t=new j),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}}function Hr(r,t,e,s,i,n){const o=r-e,a=t-s,l=i-e,u=n-s,h=o*l+a*u,c=l*l+u*u;let d=-1;c!==0&&(d=h/c);let p,f;d<0?(p=e,f=s):d>1?(p=i,f=n):(p=e+d*l,f=s+d*u);const g=r-p,m=t-f;return g*g+m*m}let SS,wS;class pr{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let i=0,n=e.length;ie!=h>e&&t<(u-a)*((e-l)/(h-l))+a&&(s=!s)}return s}strokeContains(t,e,s,i=.5){const n=s*s,o=n*(1-i),a=n-o,{points:l}=this,u=l.length-(this.closePath?0:2);for(let h=0;hi?u:i,n=ho?h:o}return t.x=s,t.width=i-s,t.y=n,t.height=o-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const li=(r,t,e,s,i,n,o)=>{const a=r-e,l=t-s,u=Math.sqrt(a*a+l*l);return u>=i-n&&u<=i+o};class _n{constructor(t=0,e=0,s=0,i=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=i,this.radius=n}getBounds(t){return t||(t=new j),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new _n(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 s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let i=t-(this.x+s),n=e-(this.y+s);const o=s*s;if(i*i+n*n<=o||(i=t-(this.x+this.width-s),i*i+n*n<=o)||(n=e-(this.y+this.height-s),i*i+n*n<=o)||(i=t-(this.x+s),i*i+n*n<=o))return!0}return!1}strokeContains(t,e,s,i=.5){const{x:n,y:o,width:a,height:l,radius:u}=this,h=s*(1-i),c=s-h,d=n+u,p=o+u,f=a-u*2,g=l-u*2,m=n+a,_=o+l;return(t>=n-h&&t<=n+c||t>=m-c&&t<=m+h)&&e>=p&&e<=p+g||(e>=o-h&&e<=o+c||e>=_-c&&e<=_+h)&&t>=d&&t<=d+f?!0:tm-u&&em-u&&e>_-u&&li(t,e,m-u,_-u,u,c,h)||t_-u&&li(t,e,d,_-u,u,c,h)}}const ES=8,ui=11920929e-14,AS=1,Yo=.01,Qe=0,Ce=0;function Ko(r,t,e,s,i,n,o,a,l,u){const h=Math.min(.99,Math.max(0,u!=null?u:ni.defaultOptions.bezierSmoothness));let c=(AS-h)/1;return c*=c,PS(t,e,s,i,n,o,a,l,r,c),r}function PS(r,t,e,s,i,n,o,a,l,u){qo(r,t,e,s,i,n,o,a,l,u,0),l.push(o,a)}function qo(r,t,e,s,i,n,o,a,l,u,h){if(h>ES)return;const c=Math.PI,d=(r+e)/2,p=(t+s)/2,f=(e+i)/2,g=(s+n)/2,m=(i+o)/2,_=(n+a)/2,b=(d+f)/2,x=(p+g)/2,v=(f+m)/2,S=(g+_)/2,T=(b+v)/2,w=(x+S)/2;if(h>0){let C=o-r,M=a-t;const E=Math.abs((e-o)*M-(s-a)*C),P=Math.abs((i-o)*M-(n-a)*C);let D,U;if(E>ui&&P>ui){if((E+P)*(E+P)<=u*(C*C+M*M)){if(Qe=c&&(D=2*c-D),U>=c&&(U=2*c-U),D+UCe){l.push(e,s);return}if(U>Ce){l.push(i,n);return}}}}else if(E>ui){if(E*E<=u*(C*C+M*M)){if(Qe=c&&(D=2*c-D),DCe){l.push(e,s);return}}}else if(P>ui){if(P*P<=u*(C*C+M*M)){if(Qe=c&&(D=2*c-D),DCe){l.push(i,n);return}}}else if(C=T-(r+o)/2,M=w-(t+a)/2,C*C+M*M<=u){l.push(T,w);return}}qo(r,t,d,p,b,x,T,w,l,u,h+1),qo(T,w,v,S,m,_,o,a,l,u,h+1)}const RS=8,CS=11920929e-14,MS=1,OS=.01,Vp=0;function Wp(r,t,e,s,i,n,o,a){const l=Math.min(.99,Math.max(0,a!=null?a:ni.defaultOptions.bezierSmoothness));let u=(MS-l)/1;return u*=u,GS(t,e,s,i,n,o,r,u),r}function GS(r,t,e,s,i,n,o,a){Zo(o,r,t,e,s,i,n,a,0),o.push(i,n)}function Zo(r,t,e,s,i,n,o,a,l){if(l>RS)return;const u=Math.PI,h=(t+s)/2,c=(e+i)/2,d=(s+n)/2,p=(i+o)/2,f=(h+d)/2,g=(c+p)/2;let m=n-t,_=o-e;const b=Math.abs((s-n)*_-(i-o)*m);if(b>CS){if(b*b<=a*(m*m+_*_)){if(Vp=u&&(x=2*u-x),xn||o&&n>i)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(l/Math.PI)))),a=Math.max(a,3);let u=l/a,h=i;u*=o?-1:1;for(let c=0;ch*a)}const jr=Math.PI*2,Jo={centerX:0,centerY:0,ang1:0,ang2:0},ta=({x:r,y:t},e,s,i,n,o,a,l)=>{r*=e,t*=s;const u=i*r-n*t,h=n*r+i*t;return l.x=u+o,l.y=h+a,l};function IS(r,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,i=Math.cos(r),n=Math.sin(r),o=Math.cos(r+t),a=Math.sin(r+t);return[{x:i-n*s,y:n+i*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}const Kp=(r,t,e,s)=>{const i=r*s-t*e<0?-1:1;let n=r*e+t*s;return n>1&&(n=1),n<-1&&(n=-1),i*Math.acos(n)},BS=(r,t,e,s,i,n,o,a,l,u,h,c,d)=>{const p=Math.pow(i,2),f=Math.pow(n,2),g=Math.pow(h,2),m=Math.pow(c,2);let _=p*f-p*m-f*g;_<0&&(_=0),_/=p*m+f*g,_=Math.sqrt(_)*(o===a?-1:1);const b=_*i/n*c,x=_*-n/i*h,v=u*b-l*x+(r+e)/2,S=l*b+u*x+(t+s)/2,T=(h-b)/i,w=(c-x)/n,C=(-h-b)/i,M=(-c-x)/n,E=Kp(1,0,T,w);let P=Kp(T,w,C,M);a===0&&P>0&&(P-=jr),a===1&&P<0&&(P+=jr),d.centerX=v,d.centerY=S,d.ang1=E,d.ang2=P};function qp(r,t,e,s,i,n,o,a=0,l=0,u=0){if(n===0||o===0)return;const h=Math.sin(a*jr/360),c=Math.cos(a*jr/360),d=c*(t-s)/2+h*(e-i)/2,p=-h*(t-s)/2+c*(e-i)/2;if(d===0&&p===0)return;n=Math.abs(n),o=Math.abs(o);const f=Math.pow(d,2)/Math.pow(n,2)+Math.pow(p,2)/Math.pow(o,2);f>1&&(n*=Math.sqrt(f),o*=Math.sqrt(f)),BS(t,e,s,i,n,o,l,u,h,c,d,p,Jo);let{ang1:g,ang2:m}=Jo;const{centerX:_,centerY:b}=Jo;let x=Math.abs(m)/(jr/4);Math.abs(1-x)<1e-7&&(x=1);const v=Math.max(Math.ceil(x),1);m/=v;let S=r[r.length-2],T=r[r.length-1];const w={x:0,y:0};for(let C=0;C{const u=l.x-a.x,h=l.y-a.y,c=Math.sqrt(u*u+h*h),d=u/c,p=h/c;return{len:c,nx:d,ny:p}},n=(a,l)=>{a===0?r.moveTo(l.x,l.y):r.lineTo(l.x,l.y)};let o=t[t.length-1];for(let a=0;a0&&(f=-1,g=!0);const m=p/2;let _,b=Math.abs(Math.cos(m)*u/Math.sin(m));b>Math.min(c.len/2,d.len/2)?(b=Math.min(c.len/2,d.len/2),_=Math.abs(b*Math.sin(m)/Math.cos(m))):_=u;const x=l.x+d.nx*b+-d.ny*_*f,v=l.y+d.ny*b+d.nx*_*f,S=Math.atan2(c.ny,c.nx)+Math.PI/2*f,T=Math.atan2(d.ny,d.nx)-Math.PI/2*f;a===0&&r.moveTo(x+Math.cos(S)*_,v+Math.sin(S)*_),r.arc(x,v,_,S,T,g),o=l}}function Qp(r,t,e,s){var i;const n=(l,u)=>Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2),o=(l,u,h)=>({x:l.x+(u.x-l.x)*h,y:l.y+(u.y-l.y)*h}),a=t.length;for(let l=0;l1){let n=null;for(let o=i;o=2;c-=2)h[c]===h[c-2]&&h[c-1]===h[c-3]&&h.splice(c-1,2);return this.poly(h,!0,o)}ellipse(t,e,s,i,n){return this.drawShape(new gn(t,e,s,i),n),this}roundRect(t,e,s,i,n,o){return this.drawShape(new _n(t,e,s,i,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new pr,s.points.push(t,e),this._currentPoly=s,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 pr,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,i=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,o=s;s=n.a*s+n.c*i+n.tx,i=n.b*o+n.d*i+n.ty}this._currentPoly.points.push(s,i)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;ea.area).sort((a,l)=>l-a),[e,s]=t,i=t[t.length-1],n=e/s,o=s/i;return!(n>3&&o<2)}function kS(r,t=0){const e=r.instructions[t];if(!e||e.action!=="fill")throw new Error(`Expected fill instruction at index ${t}, got ${(e==null?void 0:e.action)||"undefined"}`);return e.data}function nf(r){return r.split(/(?=[Mm])/).filter(t=>t.trim().length>0)}function of(r){const t=r.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),s=[],i=[];for(let u=0;ut in r?$S(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hi=(r,t)=>{for(var e in t||(t={}))LS.call(t,e)&&lf(r,e,t[e]);if(af)for(var e of af(t))NS.call(t,e)&&lf(r,e,t[e]);return r};function uf(r,t){if(typeof r=="string"){const o=document.createElement("div");o.innerHTML=r.trim(),r=o.querySelector("svg")}const e={context:t,defs:{},path:new kt};ef(r,e);const s=r.children,{fillStyle:i,strokeStyle:n}=ia(r,e);for(let o=0;o1;if(P&&D){const U=E.map(G=>({path:G,area:of(G)}));if(U.sort((G,ct)=>ct.area-G.area),E.length>3||!sf(U))for(let G=0;GparseInt(M,10)),t.context.poly(x,!0),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"polyline":v=r.getAttribute("points"),x=v.match(/\d+/g).map(M=>parseInt(M,10)),t.context.poly(x,!1),s&&t.context.stroke(s);break;case"g":case"svg":break;default:{Yt(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}a&&(e=null);for(let M=0;Mt in r?XS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Dt=(r,t)=>{for(var e in t||(t={}))cf.call(t,e)&&pf(r,e,t[e]);if(ci)for(var e of ci(t))df.call(t,e)&&pf(r,e,t[e]);return r},HS=(r,t)=>{var e={};for(var s in r)cf.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&ci)for(var s of ci(r))t.indexOf(s)<0&&df.call(r,s)&&(e[s]=r[s]);return e};function jS(r){return X.isColorLike(r)}function ff(r){return r instanceof Xr}function mf(r){return r instanceof Wt}function zS(r){return r instanceof A}function VS(r,t,e){const s=X.shared.setValue(t!=null?t:0);return r.color=s.toNumber(),r.alpha=s.alpha===1?e.alpha:s.alpha,r.texture=A.WHITE,Dt(Dt({},e),r)}function WS(r,t,e){return r.texture=t,Dt(Dt({},e),r)}function gf(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,Dt(Dt({},e),r)}function _f(r,t,e){return t.buildGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,Dt(Dt({},e),r)}function YS(r,t){const e=Dt(Dt({},t),r),s=X.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e}function oe(r,t){if(r==null)return null;const e={},s=r;return jS(r)?VS(e,r,t):zS(r)?WS(e,r,t):ff(r)?gf(e,r,t):mf(r)?_f(e,r,t):s.fill&&ff(s.fill)?gf(s,s.fill,t):s.fill&&mf(s.fill)?_f(s,s.fill,t):YS(s,t)}function Vr(r,t){const e=t,{width:s,alignment:i,miterLimit:n,cap:o,join:a,pixelLine:l}=e,u=HS(e,["width","alignment","miterLimit","cap","join","pixelLine"]),h=oe(r,u);return h?Dt({width:s,alignment:i,miterLimit:n,cap:o,join:a,pixelLine:l},h):null}var KS=Object.defineProperty,xf=Object.getOwnPropertySymbols,qS=Object.prototype.hasOwnProperty,ZS=Object.prototype.propertyIsEnumerable,bf=(r,t,e)=>t in r?KS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Je=(r,t)=>{for(var e in t||(t={}))qS.call(t,e)&&bf(r,e,t[e]);if(xf)for(var e of xf(t))ZS.call(t,e)&&bf(r,e,t[e]);return r};const QS=new V,vf=new R,oa=class Zt extends mt{constructor(){super(...arguments),this.uid=W("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new kt,this._transform=new R,this._fillStyle=Je({},Zt.defaultFillStyle),this._strokeStyle=Je({},Zt.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new ot,this._boundsDirty=!0}clone(){const t=new Zt;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=Je({},this._fillStyle),t._strokeStyle=Je({},this._strokeStyle),t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=oe(t,Zt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Vr(t,Zt.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=oe(t,Zt.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=oe(t,Zt.defaultStrokeStyle),this}texture(t,e,s,i,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:i||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?X.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new kt,this}fill(t,e){let s;const i=this.instructions[this.instructions.length-1];return this._tick===0&&(i==null?void 0:i.action)==="stroke"?s=i.data.path:s=this._activePath.clone(),s?(t!=null&&(e!==void 0&&typeof t=="number"&&(t={color:t,alpha:e}),this._fillStyle=oe(t,Zt.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(V.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const s=this.instructions[this.instructions.length-1];return this._tick===0&&(s==null?void 0:s.action)==="fill"?e=s.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Vr(t,Zt.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],s=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(s);else{e.data.hole=s;break}}return this._initNextPathLocation(),this}arc(t,e,s,i,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,s,i,n,o),this}arcTo(t,e,s,i,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*s+o.c*i+o.tx,o.b*s+o.d*i+o.ty,n),this}arcToSvg(t,e,s,i,n,o,a){this._tick++;const l=this._transform;return this._activePath.arcToSvg(t,e,s,i,n,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(t,e,s,i,n,o,a){this._tick++;const l=this._transform;return this._activePath.bezierCurveTo(l.a*t+l.c*e+l.tx,l.b*t+l.d*e+l.ty,l.a*s+l.c*i+l.tx,l.b*s+l.d*i+l.ty,l.a*n+l.c*o+l.tx,l.b*n+l.d*o+l.ty,a),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,s,i){return this._tick++,this._activePath.ellipse(t,e,s,i,this._transform.clone()),this}circle(t,e,s){return this._tick++,this._activePath.circle(t,e,s,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const s=this._transform;return this._activePath.lineTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty),this}moveTo(t,e){this._tick++;const s=this._transform,i=this._activePath.instructions,n=s.a*t+s.c*e+s.tx,o=s.b*t+s.d*e+s.ty;return i.length===1&&i[0].action==="moveTo"?(i[0].data[0]=n,i[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,s,i,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*s+o.c*i+o.tx,o.b*s+o.d*i+o.ty,n),this}rect(t,e,s,i){return this._tick++,this._activePath.rect(t,e,s,i,this._transform.clone()),this}roundRect(t,e,s,i,n){return this._tick++,this._activePath.roundRect(t,e,s,i,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,s,i,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,s,i,n,o),this}roundPoly(t,e,s,i,n,o){return this._tick++,this._activePath.roundPoly(t,e,s,i,n,o),this}roundShape(t,e,s,i){return this._tick++,this._activePath.roundShape(t,e,s,i),this}filletRect(t,e,s,i,n){return this._tick++,this._activePath.filletRect(t,e,s,i,n),this}chamferRect(t,e,s,i,n,o){return this._tick++,this._activePath.chamferRect(t,e,s,i,n,o),this}star(t,e,s,i,n=0,o=0){return this._tick++,this._activePath.star(t,e,s,i,n,o,this._transform.clone()),this}svg(t){return this._tick++,uf(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:Je({},this._fillStyle),strokeStyle:Je({},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,s,i,n,o){return t instanceof R?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,s,i,n,o),this)}transform(t,e,s,i,n,o){return t instanceof R?(this._transform.append(t),this):(vf.set(t,e,s,i,n,o),this._transform.append(vf),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,!this.dirty&&(this.emit("update",this,16),this.dirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;et in r?JS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,At=(r,t)=>{for(var e in t||(t={}))r2.call(t,e)&&Tf(r,e,t[e]);if(yf)for(var e of yf(t))s2.call(t,e)&&Tf(r,e,t[e]);return r},i2=(r,t)=>t2(r,e2(t));const aa=class cr extends mt{constructor(t={}){super(),this.uid=W("textStyle"),this._tick=0,n2(t);const e=At(At({},cr.defaultTextStyle),t);for(const s in e){const i=s;this[i]=e[s]}this.update(),this._tick=0}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.update())}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(t!==null&&typeof t=="object"?this._dropShadow=this._createProxy(At(At({},cr.defaultDropShadow),t)):this._dropShadow=t?this._createProxy(At({},cr.defaultDropShadow)):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.update())}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.update())}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.update())}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.update())}get filters(){return this._filters}set filters(t){this._filters!==t&&(this._filters=Object.freeze(t),this.update())}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.update())}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy(At(At({},dt.defaultFillStyle),t),()=>{this._fill=oe(At({},this._originalFill),dt.defaultFillStyle)})),this._fill=oe(t===0?"black":t,dt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy(At(At({},dt.defaultStrokeStyle),t),()=>{this._stroke=Vr(At({},this._originalStroke),dt.defaultStrokeStyle)})),this._stroke=Vr(t,dt.defaultStrokeStyle),this.update())}update(){this._tick++,this.emit("update",this)}reset(){const t=cr.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return`${this.uid}-${this._tick}`}clone(){return new cr({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?At({},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(s[i]===n||(s[i]=n,e==null||e(i,n),this.update()),!0)})}_isFillStyle(t){return(t!=null?t:null)!==null&&!(X.isColorLike(t)||t instanceof Wt||t instanceof Xr)}};aa.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},aa.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 Pt=aa;function n2(r){var t,e,s,i,n;const o=r;if(typeof o.dropShadow=="boolean"&&o.dropShadow){const a=Pt.defaultDropShadow;r.dropShadow={alpha:(t=o.dropShadowAlpha)!=null?t:a.alpha,angle:(e=o.dropShadowAngle)!=null?e:a.angle,blur:(s=o.dropShadowBlur)!=null?s:a.blur,color:(i=o.dropShadowColor)!=null?i:a.color,distance:(n=o.dropShadowDistance)!=null?n:a.distance}}if(o.strokeThickness!==void 0){const a=o.stroke;let l={};if(X.isColorLike(a))l.color=a;else if(a instanceof Wt||a instanceof Xr)l.fill=a;else if(Object.hasOwnProperty.call(a,"color")||Object.hasOwnProperty.call(a,"fill"))l=a;else throw new Error("Invalid stroke value.");r.stroke=i2(At({},l),{width:o.strokeThickness})}if(Array.isArray(o.fillGradientStops)){if(!Array.isArray(o.fill)||o.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");o.fill.length,o.fillGradientStops.length;const a=new Wt({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),l=o.fillGradientStops.slice(),u=o.fill.map(h=>X.shared.setValue(h).toNumber());l.forEach((h,c)=>{a.addColorStop(h,u[c])}),r.fill={fill:a}}}const o2=new ot;function la(r,t,e,s){const i=o2;i.minX=0,i.minY=0,i.maxX=r.width/s|0,i.maxY=r.height/s|0;const n=tt.getOptimalTexture(i.width,i.height,s,!1);return n.source.uploadMethodId="image",n.source.resource=r,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=t/s,n.frame.height=e/s,n.source.emit("update",n.source),n.updateUvs(),n}class Sf{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=$.get().createCanvas();s.width=t,s.height=e;const i=s.getContext("2d");return{canvas:s,context:i}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=_e(t),e=_e(e);const i=(t<<17)+(e<<1);this._canvasPool[i]||(this._canvasPool[i]=[]);let n=this._canvasPool[i].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:i}=e,n=(s<<17)+(i<<1);t.context.resetTransform(),t.context.clearRect(0,0,s,i),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Kt=new Sf;ge.register(Kt);let Me=null,ee=null;function a2(r,t){Me||(Me=$.get().createCanvas(256,128),ee=Me.getContext("2d",{willReadFrequently:!0}),ee.globalCompositeOperation="copy",ee.globalAlpha=1),(Me.width
* @license BSD-3-Clause
* @version 11.4.5
*/class l2{constructor(t=0,e=0,s=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=s,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map(e=>[e,this.get(e)])}evict(t=!1){if(t||this.size>0){const e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t))}keys(){const t=[];let e=this.first;for(;e!==null;)t.push(e.key),e=e.next;return t}setWithEvicted(t,e,s=this.resetTtl){let i=null;if(this.has(t))this.set(t,e,!0,s);else{this.max>0&&this.size===this.max&&(i=rh({},this.first),this.evict(!0));let n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=n:this.last.next=n,this.last=n}return i}set(t,e,s=!1,i=this.resetTtl){let n=this.items[t];return s||n!==void 0?(n.value=e,s===!1&&i&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(t=this.keys()){return t.map(e=>this.get(e))}}function Pf(r=1e3,t=0,e=!1){if(isNaN(r)||r<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof e!="boolean")throw new TypeError("Invalid resetTtl value");return new l2(r,t,e)}const u2=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Wr(r){const t=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let e=r.fontFamily;Array.isArray(r.fontFamily)||(e=r.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let i=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(i)&&!u2.includes(i)&&(i=`"${i}"`),e[s]=i}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const ua={willReadFrequently:!0},Ut=class O{static get experimentalLetterSpacingSupported(){let t=O._experimentalLetterSpacingSupported;if(t===void 0){const e=$.get().getCanvasRenderingContext2D().prototype;t=O._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,i,n,o,a,l,u){this.text=t,this.style=e,this.width=s,this.height=i,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=u}static measureText(t=" ",e,s=O._canvas,i=e.wordWrap){var n;const o=`${t}-${e.styleKey}-wordWrap-${i}`;if(O._measurementCache.has(o))return O._measurementCache.get(o);const a=Wr(e),l=O.measureFont(a);l.fontSize===0&&(l.fontSize=e.fontSize,l.ascent=e.fontSize);const u=O.__context;u.font=a;const h=(i?O._wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),c=new Array(h.length);let d=0;for(let b=0;b0)if(i)o-=e,l-=e;else{const u=(O.graphemeSegmenter(t).length-1)*e;o+=u,l+=u}return Math.max(o,l)}static _wordWrap(t,e,s=O._canvas){const i=s.getContext("2d",ua);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:u,whiteSpace:h}=e,c=O._collapseSpaces(h),d=O._collapseNewlines(h);let p=!c;const f=e.wordWrapWidth+u,g=O._tokenize(t);for(let m=0;mf)if(o!==""&&(a+=O._addLine(o),o="",n=0),O.canBreakWords(_,e.breakWords)){const x=O.wordWrapSplit(_);for(let v=0;vf&&(a+=O._addLine(o),p=!1,o="",n=0),o+=S,n+=C}}else{o.length>0&&(a+=O._addLine(o),o="",n=0);const x=m===g.length-1;a+=O._addLine(_,!x),p=!1,o="",n=0}else b+n>f&&(p=!1,a+=O._addLine(o),o="",n=0),(o.length>0||!O.isBreakingSpace(_)||p)&&(o+=_,n+=b)}return a+=O._addLine(o,!1),a}static _addLine(t,e=!0){return t=O._trimRight(t),t=e?`${t}
`:t,t}static _getFromCache(t,e,s,i){let n=s[t];return typeof n!="number"&&(n=O._measureText(t,e,i)+e,s[t]=n),n}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const s=t[e];if(!O.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:O._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:O._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let i=0;i{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>{const e=r.segment(t),s=[];let i=0;for(const n of e)s[i++]=n.segment;return s}}return r=>[...r]})(),Ut.experimentalLetterSpacing=!1,Ut._fonts={},Ut._newlines=[10,13],Ut._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Ut._measurementCache=Pf(1e3);let ht=Ut;const Rf=1e5;function Yr(r,t,e,s=0){var i;if(r.texture===A.WHITE&&!r.fill)return X.shared.setValue(r.color).setAlpha((i=r.alpha)!=null?i:1).toHexa();if(r.fill){if(r.fill instanceof Xr){const n=r.fill,o=t.createPattern(n.texture.source.resource,"repeat"),a=n.transform.copyTo(R.shared);return a.scale(n.texture.frame.width,n.texture.frame.height),o.setTransform(a),o}else if(r.fill instanceof Wt){const n=r.fill,o=n.type==="linear",a=n.textureSpace==="local";let l=1,u=1;a&&e&&(l=e.width+s,u=e.height+s);let h,c=!1;if(o){const{start:d,end:p}=n;h=t.createLinearGradient(d.x*l,d.y*u,p.x*l,p.y*u),c=Math.abs(p.x-d.x){const m=f+g.offset*d;h.addColorStop(Math.floor(m*Rf)/Rf,X.shared.setValue(g.color).toHex())})}}else n.colorStops.forEach(d=>{h.addColorStop(d.offset,X.shared.setValue(d.color).toHex())});return h}}else{const n=t.createPattern(r.texture.source.resource,"repeat"),o=r.matrix.copyTo(R.shared);return o.scale(r.texture.frame.width,r.texture.frame.height),n.setTransform(o),n}return"red"}const Cf=new j;let h2=class{getCanvasAndContext(t){const{text:e,style:s,resolution:i=1}=t,n=s._getFinalPadding(),o=ht.measureText(e||" ",s),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*i),l=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*i),u=Kt.getOptimalCanvasAndContext(a,l);this._renderTextToCanvas(e,s,n,i,u);const h=s.trim?Af({canvas:u.canvas,width:a,height:l,resolution:1,output:Cf}):Cf.set(0,0,a,l);return{canvasAndContext:u,frame:h}}returnCanvasAndContext(t){Kt.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,s,i,n){var o,a,l,u,h;const{canvas:c,context:d}=n,p=Wr(e),f=ht.measureText(t||" ",e),g=f.lines,m=f.lineHeight,_=f.lineWidths,b=f.maxLineWidth,x=f.fontProperties,v=c.height;if(d.resetTransform(),d.scale(i,i),d.textBaseline=e.textBaseline,(o=e._stroke)!=null&&o.width){const C=e._stroke;d.lineWidth=C.width,d.miterLimit=C.miterLimit,d.lineJoin=C.join,d.lineCap=C.cap}d.font=p;let S,T;const w=e.dropShadow?2:1;for(let C=0;Ct in r?c2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,d2=(r,t)=>{for(var e in t||(t={}))Mf.call(t,e)&&Gf(r,e,t[e]);if(di)for(var e of di(t))Of.call(t,e)&&Gf(r,e,t[e]);return r},p2=(r,t)=>{var e={};for(var s in r)Mf.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&di)for(var s of di(r))t.indexOf(s)<0&&Of.call(r,s)&&(e[s]=r[s]);return e};class fr extends jt{constructor(t){t instanceof dt&&(t={context:t});const e=t||{},{context:s,roundPixels:i}=e,n=p2(e,["context","roundPixels"]);super(d2({label:"Graphics"},n)),this.renderPipeId="graphics",s?this._context=s:this._context=this._ownedContext=new dt,this._context.on("update",this.onViewUpdate,this),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=i!=null?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):(t===!0||(t==null?void 0:t.context)===!0)&&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 fr(this._context.clone()):(this._ownedContext=null,new fr(this._context))}lineStyle(t,e,s){const i={};return t&&(i.width=t),e&&(i.color=e),s&&(i.alpha=s),this.context.strokeStyle=i,this}beginFill(t,e){const s={};return t!==void 0&&(s.color=t),e!==void 0&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){this.context.fill();const t=this.context.strokeStyle;return(t.width!==dt.defaultStrokeStyle.width||t.color!==dt.defaultStrokeStyle.color||t.alpha!==dt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return this._callContextMethod("circle",t)}drawEllipse(...t){return this._callContextMethod("ellipse",t)}drawPolygon(...t){return this._callContextMethod("poly",t)}drawRect(...t){return this._callContextMethod("rect",t)}drawRoundedRect(...t){return this._callContextMethod("roundRect",t)}drawStar(...t){return this._callContextMethod("star",t)}}const If={name:"local-uniform-msdf-bit",vertex:{header:`
struct LocalUniforms {
uColor:vec4,
uTransformMatrix:mat3x3,
uDistance: f32,
uRound:f32,
}
@group(2) @binding(0) var localUniforms : LocalUniforms;
`,main:`
vColor *= localUniforms.uColor;
modelMatrix *= localUniforms.uTransformMatrix;
`,end:`
if(localUniforms.uRound == 1)
{
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
}
`},fragment:{header:`
struct LocalUniforms {
uColor:vec4,
uTransformMatrix:mat3x3,
uDistance: f32
}
@group(2) @binding(0) var localUniforms : LocalUniforms;
`,main:`
outColor = vec4(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));
`}},Bf={name:"local-uniform-msdf-bit",vertex:{header:`
uniform mat3 uTransformMatrix;
uniform vec4 uColor;
uniform float uRound;
`,main:`
vColor *= uColor;
modelMatrix *= uTransformMatrix;
`,end:`
if(uRound == 1.)
{
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
}
`},fragment:{header:`
uniform float uDistance;
`,main:`
outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));
`}},Ff={name:"msdf-bit",fragment:{header:`
fn calculateMSDFAlpha(msdfColor:vec4, shapeColor:vec4, distance:f32) -> f32 {
// MSDF
var median = msdfColor.r + msdfColor.g + msdfColor.b -
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
// SDF
median = min(median, msdfColor.a);
var screenPxDistance = distance * (median - 0.5);
var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
if (median < 0.01) {
alpha = 0.0;
} else if (median > 0.99) {
alpha = 1.0;
}
// Gamma correction for coverage-like alpha
var luma: f32 = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));
var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);
var coverage: f32 = pow(shapeColor.a * alpha, gamma);
return coverage;
}
`}},Df={name:"msdf-bit",fragment:{header:`
float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {
// MSDF
float median = msdfColor.r + msdfColor.g + msdfColor.b -
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
// SDF
median = min(median, msdfColor.a);
float screenPxDistance = distance * (median - 0.5);
float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
if (median < 0.01) {
alpha = 0.0;
} else if (median > 0.99) {
alpha = 1.0;
}
// Gamma correction for coverage-like alpha
float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));
float gamma = mix(1.0, 1.0 / 2.2, luma);
float coverage = pow(shapeColor.a * alpha, gamma);
return coverage;
}
`}};let ca,da;class Uf extends Ct{constructor(t){const e=new it({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new R,type:"mat3x3"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});ca!=null||(ca=je({name:"sdf-shader",bits:[Vs,Ys(t),If,Ff,Ve]})),da!=null||(da=ze({name:"sdf-shader",bits:[Ws,Ks(t),Bf,Df,We]})),super({glProgram:da,gpuProgram:ca,resources:{localUniforms:e,batchSamplers:qs(t)}})}}class pa extends mt{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 this.fontFamily}get pageTextures(){return this.pages}get size(){return this.fontMetrics.fontSize}get distanceFieldRange(){return this.distanceField.range}get distanceFieldType(){return this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const s in this.chars)(e=this.chars[s].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(s=>s.texture.destroy(!0)),this.pages=null)}}var f2=Object.defineProperty,kf=Object.getOwnPropertySymbols,m2=Object.prototype.hasOwnProperty,g2=Object.prototype.propertyIsEnumerable,$f=(r,t,e)=>t in r?f2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Lf=(r,t)=>{for(var e in t||(t={}))m2.call(t,e)&&$f(r,e,t[e]);if(kf)for(var e of kf(t))g2.call(t,e)&&$f(r,e,t[e]);return r};const Nf=class Uy extends pa{constructor(t){var e,s,i;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 n=Lf(Lf({},Uy.defaultOptions),t);this._textureSize=n.textureSize,this._mipmap=n.mipmap;const o=n.style.clone();n.overrideFill&&(o._fill.color=16777215,o._fill.alpha=1,o._fill.texture=A.WHITE,o._fill.fill=null),this.applyFillAsTint=n.overrideFill;const a=o.fontSize;o.fontSize=this.baseMeasurementFontSize;const l=Wr(o);n.overrideSize?o._stroke&&(o._stroke.width*=this.baseRenderedFontSize/a):o.fontSize=this.baseRenderedFontSize=a,this._style=o,this._skipKerning=(e=n.skipKerning)!=null?e:!1,this.resolution=(s=n.resolution)!=null?s:1,this._padding=(i=n.padding)!=null?i:4,n.textureStyle&&(this._textureStyle=n.textureStyle instanceof St?n.textureStyle:new St(n.textureStyle)),this.fontMetrics=ht.measureFont(l),this.lineHeight=o.lineHeight||this.fontMetrics.fontSize||o.fontSize}ensureCharacters(t){var e,s,i,n;const o=ht.graphemeSegmenter(t).filter(v=>!this._currentChars.includes(v)).filter((v,S,T)=>T.indexOf(v)===S);if(!o.length)return;this._currentChars=[...this._currentChars,...o];let a;this._currentPageIndex===-1?a=this._nextPage():a=this.pages[this._currentPageIndex];let{canvas:l,context:u}=a.canvasAndContext,h=a.texture.source;const c=this._style;let d=this._currentX,p=this._currentY,f=this._currentMaxCharHeight;const g=this.baseRenderedFontSize/this.baseMeasurementFontSize,m=this._padding*g;let _=!1;const b=l.width/this.resolution,x=l.height/this.resolution;for(let v=0;vb&&(p+=f,f=P,d=0,p+f>x)){h.update();const U=this._nextPage();l=U.canvasAndContext.canvas,u=U.canvasAndContext.context,h=U.texture.source,d=0,p=0,f=0}const D=w/g-((s=(e=c.dropShadow)==null?void 0:e.distance)!=null?s:0)-((n=(i=c._stroke)==null?void 0:i.width)!=null?n:0);if(this.chars[S]={id:S.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:D,kerning:{}},_){this._drawGlyph(u,T,d+m,p+m,g,c);const U=h.width*g,G=h.height*g,ct=new j(d/U*h.width,p/G*h.height,E/U*h.width,P/G*h.height);this.chars[S].texture=new A({source:h,frame:ct}),d+=Math.ceil(E)}}h.update(),this._currentX=d,this._currentY=p,this._currentMaxCharHeight=f,this._skipKerning&&this._applyKerning(o,u)}get pageTextures(){return this.pages}_applyKerning(t,e){const s=this._measureCache;for(let i=0;i{const b=n.width;for(let x=0;x{let _=n.chars.length-1;if(s){let b=n.chars[_];for(;b===" ";)n.width-=e.chars[b].xAdvance,b=n.chars[--_]}i.width=Math.max(i.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,i.lines.push(n),i.height+=d},m=_=>_-h>c;for(let _=0;_t in r?v2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ma=(r,t)=>{for(var e in t||(t={}))y2.call(t,e)&&jf(r,e,t[e]);if(Hf)for(var e of Hf(t))T2.call(t,e)&&jf(r,e,t[e]);return r};let fi=0,S2=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},this.measureCache=Pf(1e3)}getFont(t,e){var s;let i=`${e.fontFamily}-bitmap`,n=!0;if(e._fill.fill&&!e._stroke?(i+=e._fill.fill.styleKey,n=!1):(e._stroke||e.dropShadow)&&(i=`${e.styleKey}-bitmap`,n=!1),!z.has(i)){const a=Object.create(e);a.lineHeight=0;const l=new fa(ma({style:a,overrideFill:n,overrideSize:!0},this.defaultOptions));fi++,fi>50&&Yt("BitmapText",`You have dynamically created ${fi} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),l.once("destroy",()=>{fi--,z.remove(i)}),z.set(i,l)}const o=z.get(i);return(s=o.ensureCharacters)==null||s.call(o,t),o}getLayout(t,e,s=!0){const i=this.getFont(t,e),n=`${t}-${e.styleKey}-${s}`;if(this.measureCache.has(n))return this.measureCache.get(n);const o=ht.graphemeSegmenter(t),a=pi(o,e,i,s);return this.measureCache.set(n,a),a}measureText(t,e,s=!0){return this.getLayout(t,e,s)}install(...t){var e,s,i,n,o;let a=t[0];typeof a=="string"&&(a={name:a,style:t[1],chars:(e=t[2])==null?void 0:e.chars,resolution:(s=t[2])==null?void 0:s.resolution,padding:(i=t[2])==null?void 0:i.padding,skipKerning:(n=t[2])==null?void 0:n.skipKerning});const l=a==null?void 0:a.name;if(!l)throw new Error("[BitmapFontManager] Property `name` is required.");a=ma(ma({},this.defaultOptions),a);const u=a.style,h=u instanceof Pt?u:new Pt(u),c=(o=a.dynamicFill)!=null?o:this._canUseTintForStyle(h),d=new fa({style:h,overrideFill:c,skipKerning:a.skipKerning,padding:a.padding,resolution:a.resolution,overrideSize:!1,textureStyle:a.textureStyle}),p=Xf(a.chars);return d.ensureCharacters(p.join("")),z.set(`${l}-bitmap`,d),d.once("destroy",()=>z.remove(`${l}-bitmap`)),d}uninstall(t){const e=`${t}-bitmap`,s=z.get(e);s&&s.destroy()}_canUseTintForStyle(t){return!t._stroke&&(!t.dropShadow||t.dropShadow.color===0)&&!t._fill.fill&&t._fill.color===16777215}};const er=new S2;class zf extends fr{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class ga{constructor(t){this._renderer=t}validateRenderable(t){const e=this._getGpuBitmapText(t);return this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const s=this._getGpuBitmapText(t);Vf(t,s),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,s)),this._renderer.renderPipes.graphics.addRenderable(s,e),s.context.customShader&&this._updateDistanceField(t)}updateRenderable(t){const e=this._getGpuBitmapText(t);Vf(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:s}=e,i=er.getFont(t.text,t._style);s.clear(),i.distanceField.type!=="none"&&(s.customShader||(s.customShader=new Uf(this._renderer.limits.maxBatchableTextures)));const n=ht.graphemeSegmenter(t.text),o=t._style;let a=i.baseLineOffset;const l=pi(n,o,i,!0),u=o.padding,h=l.scale;let c=l.width,d=l.height+l.offsetY;o._stroke&&(c+=o._stroke.width/h,d+=o._stroke.width/h),s.translate(-t._anchor._x*c-u,-t._anchor._y*d-u).scale(h,h);const p=i.applyFillAsTint?o._fill.color:16777215;let f=i.fontMetrics.fontSize,g=i.lineHeight;o.lineHeight&&(f=o.fontSize/h,g=o.lineHeight/h);let m=(g-f)/2;m-i.baseLineOffset<0&&(m=0);for(let _=0;_{console.error(n)}),t._didTextUpdate=!1,ai(s,t)}this._renderer.renderPipes.batch.addToBatch(s,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;const s=e.texturePromise;e.texturePromise=null,e.generatingTexture=!0,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;let i=this._renderer.htmlText.getTexturePromise(t);s&&(i=i.finally(()=>{this._renderer.htmlText.decreaseReferenceCount(e.currentKey),this._renderer.htmlText.returnTexturePromise(s)})),e.texturePromise=i,e.currentKey=t.styleKey,e.texture=await i;const n=t.renderGroup||t.parentRenderGroup;n&&(n.structureDidChange=!0),e.generatingTexture=!1,ai(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Wf(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.texture=A.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}}_a.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"htmlText"};function Yf(){const{userAgent:r}=$.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}const Kf="http://www.w3.org/2000/svg",qf="http://www.w3.org/1999/xhtml";class xa{constructor(){this.svgRoot=document.createElementNS(Kf,"svg"),this.foreignObject=document.createElementNS(Kf,"foreignObject"),this.domElement=document.createElementNS(qf,"div"),this.styleElement=document.createElementNS(qf,"style");const{foreignObject:t,svgRoot:e,styleElement:s,domElement:i}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(s),t.appendChild(i),this.image=$.get().createImage()}destroy(){this.svgRoot.remove(),this.foreignObject.remove(),this.styleElement.remove(),this.domElement.remove(),this.image.src="",this.image.remove(),this.svgRoot=null,this.foreignObject=null,this.styleElement=null,this.domElement=null,this.image=null,this.canvasAndContext=null}}function Zf(r,t){const e=t.fontFamily,s=[],i={},n=/font-family:([^;"\s]+)/g,o=r.match(n);function a(l){i[l]||(s.push(l),i[l]=!0)}if(Array.isArray(e))for(let l=0;l{const u=l.split(":")[1].trim();a(u)});for(const l in t.tagStyles){const u=t.tagStyles[l].fontFamily;a(u)}return s}async function Qf(r){const t=await(await $.get().fetch(r)).blob(),e=new FileReader;return await new Promise((s,i)=>{e.onloadend=()=>s(e.result),e.onerror=i,e.readAsDataURL(t)})}async function Jf(r,t){const e=await Qf(t);return`@font-face {
font-family: "${r.fontFamily}";
font-weight: ${r.fontWeight};
font-style: ${r.fontStyle};
src: url('${e}');
}`}const mi=new Map;async function tm(r){const t=r.filter(e=>z.has(`${e}-and-url`)).map(e=>{if(!mi.has(e)){const{entries:s}=z.get(`${e}-and-url`),i=[];s.forEach(n=>{const o=n.url,a=n.faces.map(l=>({weight:l.weight,style:l.style}));i.push(...a.map(l=>Jf({fontWeight:l.weight,fontStyle:l.style,fontFamily:e},o)))}),mi.set(e,Promise.all(i).then(n=>n.join(`
`)))}return mi.get(e)});return(await Promise.all(t)).join(`
`)}function em(r,t,e,s,i){const{domElement:n,styleElement:o,svgRoot:a}=i;n.innerHTML=`${r}
`,n.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),o.textContent=s;const{width:l,height:u}=i.image;return a.setAttribute("width",l.toString()),a.setAttribute("height",u.toString()),new XMLSerializer().serializeToString(a)}function rm(r,t){const e=Kt.getOptimalCanvasAndContext(r.width,r.height,t),{context:s}=e;return s.clearRect(0,0,r.width,r.height),s.drawImage(r,0,0),e}function sm(r,t,e){return new Promise(async s=>{e&&await new Promise(i=>setTimeout(i,100)),r.onload=()=>{s()},r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,r.crossOrigin="anonymous"})}let im;function ba(r,t,e,s){s||(s=im||(im=new xa));const{domElement:i,styleElement:n,svgRoot:o}=s;i.innerHTML=`${r}
`,i.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(n.textContent=e),document.body.appendChild(o);const a=i.getBoundingClientRect();o.remove();const l=t.padding*2;return{width:a.width-l,height:a.height-l}}class va{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===bt.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getManagedTexture(t){const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].promise;const s=this._buildTexturePromise(t).then(i=>(this._activeTextures[e].texture=i,i));return this._activeTextures[e]={texture:null,promise:s,usageCount:1},s}getReferenceCount(t){var e,s;return(s=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?s:null}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e.texture):e.promise.then(s=>{e.texture=s,this._cleanUp(e.texture)}).catch(()=>{}),this._activeTextures[t]=null))}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){const{text:e,style:s,resolution:i,textureStyle:n}=t,o=st.get(xa),a=Zf(e,s),l=await tm(a),u=ba(e,s,l,o),h=Math.ceil(Math.ceil(Math.max(1,u.width)+s.padding*2)*i),c=Math.ceil(Math.ceil(Math.max(1,u.height)+s.padding*2)*i),d=o.image,p=2;d.width=(h|0)+p,d.height=(c|0)+p;const f=em(e,s,i,l,o);await sm(d,f,Yf()&&a.length>0);const g=d;let m;this._createCanvas&&(m=rm(d,i));const _=la(m?m.canvas:g,d.width-p,d.height-p,i);return n&&(_.source.style=n),this._createCanvas&&(this._renderer.texture.initSource(_.source),Kt.returnCanvasAndContext(m)),st.return(o),_}returnTexturePromise(t){t.then(e=>{this._cleanUp(e)}).catch(()=>{})}_cleanUp(t){tt.returnTexture(t,!0),t.source.resource=null,t.source.uploadMethodId="unknown"}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexturePromise(this._activeTextures[t].promise);this._activeTextures=null}}va.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"htmlText"},F.add(va),F.add(_a);var w2=Object.defineProperty,nm=Object.getOwnPropertySymbols,E2=Object.prototype.hasOwnProperty,A2=Object.prototype.propertyIsEnumerable,om=(r,t,e)=>t in r?w2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,am=(r,t)=>{for(var e in t||(t={}))E2.call(t,e)&&om(r,e,t[e]);if(nm)for(var e of nm(t))A2.call(t,e)&&om(r,e,t[e]);return r};const lm=class ky extends Ee{constructor(...t){var e;let s=(e=t[0])!=null?e:{};s instanceof Float32Array&&(s={positions:s,uvs:t[1],indices:t[2]}),s=am(am({},ky.defaultOptions),s);const i=s.positions||new Float32Array([0,0,1,0,1,1,0,1]);let n=s.uvs;n||(s.positions?n=new Float32Array(i.length):n=new Float32Array([0,0,1,0,1,1,0,1]));const o=s.indices||new Uint32Array([0,1,2,0,2,3]),a=s.shrinkBuffersToFit,l=new _t({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:N.VERTEX|N.COPY_DST}),u=new _t({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:N.VERTEX|N.COPY_DST}),h=new _t({data:o,label:"index-mesh-buffer",shrinkToFit:a,usage:N.INDEX|N.COPY_DST});super({attributes:{aPosition:{buffer:l,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:u,format:"float32x2",stride:2*4,offset:0}},indexBuffer:h,topology:s.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}};lm.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let ae=lm;var P2=Object.defineProperty,R2=Object.defineProperties,C2=Object.getOwnPropertyDescriptors,um=Object.getOwnPropertySymbols,M2=Object.prototype.hasOwnProperty,O2=Object.prototype.propertyIsEnumerable,hm=(r,t,e)=>t in r?P2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cm=(r,t)=>{for(var e in t||(t={}))M2.call(t,e)&&hm(r,e,t[e]);if(um)for(var e of um(t))O2.call(t,e)&&hm(r,e,t[e]);return r},dm=(r,t)=>R2(r,C2(t));const rr={name:"local-uniform-bit",vertex:{header:`
struct LocalUniforms {
uTransformMatrix:mat3x3,
uColor:vec4,
uRound:f32,
}
@group(1) @binding(0) var localUniforms : LocalUniforms;
`,main:`
vColor *= localUniforms.uColor;
modelMatrix *= localUniforms.uTransformMatrix;
`,end:`
if(localUniforms.uRound == 1)
{
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
}
`}},pm=dm(cm({},rr),{vertex:dm(cm({},rr.vertex),{header:rr.vertex.header.replace("group(1)","group(2)")})}),gi={name:"local-uniform-bit",vertex:{header:`
uniform mat3 uTransformMatrix;
uniform vec4 uColor;
uniform float uRound;
`,main:`
vColor *= uColor;
modelMatrix = uTransformMatrix;
`,end:`
if(uRound == 1.)
{
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
}
`}},fm={name:"tiling-bit",vertex:{header:`
struct TilingUniforms {
uMapCoord:mat3x3,
uClampFrame:vec4,
uClampOffset:vec2,
uTextureTransform:mat3x3,
uSizeAnchor:vec4
};
@group(2) @binding(0) var tilingUniforms: TilingUniforms;
@group(2) @binding(1) var uTexture: texture_2d;
@group(2) @binding(2) var uSampler: sampler;
`,main:`
uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;
position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
`},fragment:{header:`
struct TilingUniforms {
uMapCoord:mat3x3,
uClampFrame:vec4,
uClampOffset:vec2,
uTextureTransform:mat3x3,
uSizeAnchor:vec4
};
@group(2) @binding(0) var tilingUniforms: TilingUniforms;
@group(2) @binding(1) var uTexture: texture_2d;
@group(2) @binding(2) var uSampler: sampler;
`,main:`
var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
var unclamped = coord;
coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);
var bias = 0.;
if(unclamped.x == coord.x && unclamped.y == coord.y)
{
bias = -32.;
}
outColor = textureSampleBias(uTexture, uSampler, coord, bias);
`}},mm={name:"tiling-bit",vertex:{header:`
uniform mat3 uTextureTransform;
uniform vec4 uSizeAnchor;
`,main:`
uv = (uTextureTransform * vec3(aUV, 1.0)).xy;
position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
`},fragment:{header:`
uniform sampler2D uTexture;
uniform mat3 uMapCoord;
uniform vec4 uClampFrame;
uniform vec2 uClampOffset;
`,main:`
vec2 coord = vUV + ceil(uClampOffset - vUV);
coord = (uMapCoord * vec3(coord, 1.0)).xy;
vec2 unclamped = coord;
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
`}};let ya,Ta;class gm extends Ct{constructor(){ya!=null||(ya=je({name:"tiling-sprite-shader",bits:[rr,fm,Ve]})),Ta!=null||(Ta=ze({name:"tiling-sprite-shader",bits:[gi,mm,We]}));const t=new it({uMapCoord:{value:new R,type:"mat3x3"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2"},uTextureTransform:{value:new R,type:"mat3x3"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4