pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
2,313 lines • 717 kB
JavaScript
var YM=Object.defineProperty;var kx=Object.getOwnPropertySymbols;var KM=Object.prototype.hasOwnProperty,qM=Object.prototype.propertyIsEnumerable;var $x=(d,Gt,Bt)=>Gt in d?YM(d,Gt,{enumerable:!0,configurable:!0,writable:!0,value:Bt}):d[Gt]=Bt,Lx=(d,Gt)=>{for(var Bt in Gt||(Gt={}))KM.call(Gt,Bt)&&$x(d,Bt,Gt[Bt]);if(kx)for(var Bt of kx(Gt))qM.call(Gt,Bt)&&$x(d,Bt,Gt[Bt]);return d};/*!
* PixiJS - v8.15.0
* Compiled Mon, 05 Jan 2026 10:10:58 UTC
*
* PixiJS is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/var PIXI=function(d){"use strict";"use strict";var Gt=Object.defineProperty,Bt=Object.defineProperties,b0=Object.getOwnPropertyDescriptors,rc=Object.getOwnPropertySymbols,v0=Object.prototype.hasOwnProperty,y0=Object.prototype.propertyIsEnumerable,ic=(r,t,e)=>t in r?Gt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,sc=(r,t)=>{for(var e in t||(t={}))v0.call(t,e)&&ic(r,e,t[e]);if(rc)for(var e of rc(t))y0.call(t,e)&&ic(r,e,t[e]);return r},x0=(r,t)=>Bt(r,b0(t)),T=(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))(T||{});const En=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){const t=typeof r.extension!="object"?{type:r.extension}:r.extension;r=x0(sc({},t),{ref:r})}if(typeof r=="object")r=sc({},r);else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},vr=(r,t)=>{var e;return(e=En(r).priority)!=null?e:t},F={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(En).forEach(t=>{t.type.forEach(e=>{var i,s;return(s=(i=this._removeHandlers)[e])==null?void 0:s.call(i,t)})}),this},add(...r){return r.map(En).forEach(t=>{t.type.forEach(e=>{var i,s;const n=this._addHandlers,o=this._queue;n[e]?(s=n[e])==null||s.call(n,t):(o[e]=o[e]||[],(i=o[e])==null||i.push(t))})}),this},handle(r,t,e){var i;const s=this._addHandlers,n=this._removeHandlers;s[r]=t,n[r]=e;const o=this._queue;return o[r]&&((i=o[r])==null||i.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,i=>{t.findIndex(s=>s.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((s,n)=>vr(n.value,e)-vr(s.value,e)))},i=>{const s=t.findIndex(n=>n.name===i.name);s!==-1&&t.splice(s,1)})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>vr(n,e)-vr(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})},mixin(r,...t){for(const e of t)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(e))}};var ZM=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function nc(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 JM(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function tO(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?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(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var Pn={exports:{}},eO=Pn.exports;(function(r){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(l,u,c){this.fn=l,this.context=u,this.once=c||!1}function n(l,u,c,h,p){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,h||l,p),m=e?e+u:u;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function o(l,u){--l._eventsCount===0?l._events=new i:delete l._events[u]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var u=[],c,h;if(this._eventsCount===0)return u;for(h in c=this._events)t.call(c,h)&&u.push(e?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(c)):u},a.prototype.listeners=function(u){var c=e?e+u:u,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,f=h.length,m=new Array(f);p<f;p++)m[p]=h[p].fn;return m},a.prototype.listenerCount=function(u){var c=e?e+u:u,h=this._events[c];return h?h.fn?1:h.length:0},a.prototype.emit=function(u,c,h,p,f,m){var _=e?e+u:u;if(!this._events[_])return!1;var g=this._events[_],b=arguments.length,y,v;if(g.fn){switch(g.once&&this.removeListener(u,g.fn,void 0,!0),b){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,h),!0;case 4:return g.fn.call(g.context,c,h,p),!0;case 5:return g.fn.call(g.context,c,h,p,f),!0;case 6:return g.fn.call(g.context,c,h,p,f,m),!0}for(v=1,y=new Array(b-1);v<b;v++)y[v-1]=arguments[v];g.fn.apply(g.context,y)}else{var x=g.length,A;for(v=0;v<x;v++)switch(g[v].once&&this.removeListener(u,g[v].fn,void 0,!0),b){case 1:g[v].fn.call(g[v].context);break;case 2:g[v].fn.call(g[v].context,c);break;case 3:g[v].fn.call(g[v].context,c,h);break;case 4:g[v].fn.call(g[v].context,c,h,p);break;default:if(!y)for(A=1,y=new Array(b-1);A<b;A++)y[A-1]=arguments[A];g[v].fn.apply(g[v].context,y)}}return!0},a.prototype.on=function(u,c,h){return n(this,u,c,h,!1)},a.prototype.once=function(u,c,h){return n(this,u,c,h,!0)},a.prototype.removeListener=function(u,c,h,p){var f=e?e+u:u;if(!this._events[f])return this;if(!c)return o(this,f),this;var m=this._events[f];if(m.fn)m.fn===c&&(!p||m.once)&&(!h||m.context===h)&&o(this,f);else{for(var _=0,g=[],b=m.length;_<b;_++)(m[_].fn!==c||p&&!m[_].once||h&&m[_].context!==h)&&g.push(m[_]);g.length?this._events[f]=g.length===1?g[0]:g:o(this,f)}return this},a.prototype.removeAllListeners=function(u){var c;return u?(c=e?e+u:u,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(Pn);var T0=Pn.exports,gt=nc(T0),S0={grad:.9,turn:360,rad:360/(2*Math.PI)},re=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},lt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},It=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},oc=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},ac=function(r){return{r:It(r.r,0,255),g:It(r.g,0,255),b:It(r.b,0,255),a:It(r.a)}},wn=function(r){return{r:lt(r.r),g:lt(r.g),b:lt(r.b),a:lt(r.a,3)}},A0=/^#([0-9a-f]{3,8})$/i,Ti=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},lc=function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-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:s}},uc=function(r){var t=r.h,e=r.s,i=r.v,s=r.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),l=i*(1-(1-t+n)*e),u=n%6;return{r:255*[i,a,o,o,l,i][u],g:255*[l,i,i,a,o,o][u],b:255*[o,o,l,i,i,a][u],a:s}},cc=function(r){return{h:oc(r.h),s:It(r.s,0,100),l:It(r.l,0,100),a:It(r.a)}},hc=function(r){return{h:lt(r.h),s:lt(r.s),l:lt(r.l),a:lt(r.a,3)}},dc=function(r){return uc((e=(t=r).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},yr=function(r){return{h:(t=lc(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},E0=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,P0=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,w0=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,R0=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Rn={string:[[function(r){var t=A0.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?lt(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?lt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=w0.exec(r)||R0.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:ac({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=E0.exec(r)||P0.exec(r);if(!t)return null;var e,i,s=cc({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(S0[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return dc(s)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return re(t)&&re(e)&&re(i)?ac({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!re(t)||!re(e)||!re(i))return null;var o=cc({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return dc(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!re(t)||!re(e)||!re(i))return null;var o=function(a){return{h:oc(a.h),s:It(a.s,0,100),v:It(a.v,0,100),a:It(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return uc(o)},"hsv"]]},pc=function(r,t){for(var e=0;e<t.length;e++){var i=t[e][0](r);if(i)return[i,t[e][1]]}return[null,void 0]},fc=function(r){return typeof r=="string"?pc(r.trim(),Rn.string):typeof r=="object"&&r!==null?pc(r,Rn.object):[null,void 0]},rO=function(r){return fc(r)[1]},Cn=function(r,t){var e=yr(r);return{h:e.h,s:It(e.s+100*t,0,100),l:e.l,a:e.a}},Mn=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},mc=function(r,t){var e=yr(r);return{h:e.h,s:e.s,l:It(e.l+100*t,0,100),a:e.a}},Si=function(){function r(t){this.parsed=fc(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return lt(Mn(this.rgba),2)},r.prototype.isDark=function(){return Mn(this.rgba)<.5},r.prototype.isLight=function(){return Mn(this.rgba)>=.5},r.prototype.toHex=function(){return t=wn(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?Ti(lt(255*n)):"","#"+Ti(e)+Ti(i)+Ti(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return wn(this.rgba)},r.prototype.toRgbString=function(){return t=wn(this.rgba),e=t.r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},r.prototype.toHsl=function(){return hc(yr(this.rgba))},r.prototype.toHslString=function(){return t=hc(yr(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=lc(this.rgba),{h:lt(t.h),s:lt(t.s),v:lt(t.v),a:lt(t.a,3)};var t},r.prototype.invert=function(){return zt({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),zt(Cn(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),zt(Cn(this.rgba,-t))},r.prototype.grayscale=function(){return zt(Cn(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),zt(mc(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),zt(mc(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"?zt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):lt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=yr(this.rgba);return typeof t=="number"?zt({h:t,s:e.s,l:e.l,a:e.a}):lt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===zt(t).toHex()},r}(),zt=function(r){return r instanceof Si?r:new Si(r)},gc=[],C0=function(r){r.forEach(function(t){gc.indexOf(t)<0&&(t(Si,Rn),gc.push(t))})},iO=function(){return new Si({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function M0(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"},i={};for(var s in e)i[e[s]]=s;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,u=i[this.toHex()];if(u)return u;if(o!=null&&o.closest){var c=this.toRgb(),h=1/0,p="black";if(!n.length)for(var f in e)n[f]=new r(e[f]).toRgb();for(var m in e){var _=(a=c,l=n[m],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));_<h&&(h=_,p=m)}return p}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new r(l).toRgb():null},"name"])}var O0=Object.defineProperty,_c=Object.getOwnPropertySymbols,G0=Object.prototype.hasOwnProperty,B0=Object.prototype.propertyIsEnumerable,bc=(r,t,e)=>t in r?O0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,I0=(r,t)=>{for(var e in t||(t={}))G0.call(t,e)&&bc(r,e,t[e]);if(_c)for(var e of _c(t))B0.call(t,e)&&bc(r,e,t[e]);return r};C0([M0]);const ke=class yi{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 yi)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?I0({},t):t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,s]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,s,n]=yi._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=s,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 i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(s<<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,i,s,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,s=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,s,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,s,n=255]=t,e/=255,i/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=yi.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=zt(t);o.isValid()&&({r:e,g:i,b:s,a:n}=o.rgba,e/=255,i/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=s,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof yi||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}};ke.shared=new ke,ke._temp=new ke,ke.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let H=ke;const vc={cullArea:null,cullable:!1,cullableChildren:!0},yc=Math.PI*2,xc=180/Math.PI,Tc=Math.PI/180;class W{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new W(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 On.x=0,On.y=0,On}}const On=new W;class C{constructor(t=1,e=0,i=0,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,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,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new W;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new W;const i=this.a,s=this.b,n=this.c,o=this.d,a=this.tx,l=this.ty,u=1/(i*o+n*-s),c=t.x,h=t.y;return e.x=o*u*c+-n*u*h+(l*n-a*o)*u,e.y=i*u*h+-s*u*c+(-l*i+a*s)*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),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}appendFrom(t,e){const i=t.a,s=t.b,n=t.c,o=t.d,a=t.tx,l=t.ty,u=e.a,c=e.b,h=e.c,p=e.d;return this.a=i*u+s*h,this.b=i*c+s*p,this.c=n*u+o*h,this.d=n*c+o*p,this.tx=a*u+l*h+e.tx,this.ty=a*c+l*p+e.ty,this}setTransform(t,e,i,s,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-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,s=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),l=Math.atan2(i,e),u=Math.abs(a+l);return u<1e-5||Math.abs(yc-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+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(o.x*e+o.y*s),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,o=t*s-e*i;return this.a=s/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-s*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 C;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 D0.identity()}static get shared(){return F0.identity()}}const F0=new C,D0=new C;class Z{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new Z(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 xr={default:-1};function Y(r="default"){return xr[r]===void 0&&(xr[r]=-1),++xr[r]}function U0(){for(const r in xr)delete xr[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 Sc{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var e;let i;return this._index>0?i=this._pool[--this._index]:(i=new this._classType,this._count++),(e=i.init)==null||e.call(i,t),i}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0}}class Ac{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new Sc(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const st=new Ac;ge.register(st);const Ec={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 Gn(r,t,e){const i=r.length;let s;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(s=t;s<n;++s)r[s]=r[s+e];r.length=n}const Pc={allowChildren:!0,removeChildren(r=0,t){var e;const i=t!=null?t:this.children.length,s=i-r,n=[];if(s>0&&s<=i){for(let a=i-1;a>=r;a--){const l=this.children[a];l&&(n.push(l),l.parent=null)}Gn(this.children,r,i);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(n);for(let a=0;a<n.length;++a){const l=n[a];(e=l.parentRenderLayer)==null||e.detach(l),this.emit("childRemoved",l,this,a),n[a].emit("removed",this)}return n.length>0&&this._didViewChangeTick++,n}else if(s===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 s=r.parent.children.indexOf(r);if(r.parent===this&&s===t)return r;s!==-1&&r.parent.children.splice(s,1)}t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(r),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",r,this,t),r.emit("added",this),r},swapChildren(r,t){if(r===t)return;const e=this.getChildIndex(r),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=r;const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(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 i=this.worldTransform.clone();return i.invert(),e.prepend(i),r.setFromMatrix(e),r},replaceChild(r,t){r.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(r)),t.setFromMatrix(r.localTransform),t.updateLocalTransform(),this.removeChild(r)}},wc={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 i=this.children,s=i.length;for(let n=0;n<s;n++)i[n].collectRenderables(r,t,e)},collectRenderablesWithEffects(r,t,e){const{renderPipes:i}=t;for(let s=0;s<this.effects.length;s++){const n=this.effects[s];i[n.pipe].push(n,this,r)}this.collectRenderablesSimple(r,t,e);for(let s=this.effects.length-1;s>=0;s--){const n=this.effects[s];i[n.pipe].pop(n,this,r)}}};class Tr{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}class Rc{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const i=this._tests[e];if(i.test(t))return st.get(i.maskClass,t)}return t}returnMaskEffect(t){st.return(t)}}const Ai=new Rc;F.handleByList(T.MaskEffect,Ai._effectClasses);var k0=Object.defineProperty,Cc=Object.getOwnPropertySymbols,$0=Object.prototype.hasOwnProperty,L0=Object.prototype.propertyIsEnumerable,Mc=(r,t,e)=>t in r?k0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Oc=(r,t)=>{for(var e in t||(t={}))$0.call(t,e)&&Mc(r,e,t[e]);if(Cc)for(var e of Cc(t))L0.call(t,e)&&Mc(r,e,t[e]);return r};const Gc={_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),Ai.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=Ai.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions=Oc(Oc({},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 i=(r==null?void 0:r.length)>0,s=((t=e.filters)==null?void 0:t.length)>0,n=i!==s;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),n&&(i?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}},Bc={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 i=0;i<e.length;i++){const s=e[i];if(s.label===r||r instanceof RegExp&&r.test(s.label))return s}if(t)for(let i=0;i<e.length;i++){const s=e[i].getChildByLabel(r,!0);if(s)return s}return null},getChildrenByLabel(r,t=!1,e=[]){const i=this.children;for(let s=0;s<i.length;s++){const n=i[s];(n.label===r||r instanceof RegExp&&r.test(n.label))&&e.push(n)}if(t)for(let s=0;s<i.length;s++)i[s].getChildrenByLabel(r,!0,e);return e}},Ei=[new W,new W,new W,new W];class z{constructor(t=0,e=0,i=0,s=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new z(0,0,0,0)}clone(){return new z(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i,s=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,l=this.y,u=i*(1-s),c=i-u,h=a-u,p=a+n+u,f=l-u,m=l+o+u,_=a+c,g=a+n-c,b=l+c,y=l+o-c;return t>=h&&t<=p&&e>=f&&e<=m&&!(t>_&&t<g&&e>b&&e<y)}intersects(t,e){if(!e){const M=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=M)return!1;const O=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>O}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=Ei[0].set(t.left,t.top),l=Ei[1].set(t.left,t.bottom),u=Ei[2].set(t.right,t.top),c=Ei[3].set(t.right,t.bottom);if(u.x<=a.x||l.y<=a.y)return!1;const h=Math.sign(e.a*e.d-e.b*e.c);if(h===0||(e.apply(a,a),e.apply(l,l),e.apply(u,u),e.apply(c,c),Math.max(a.x,l.x,u.x,c.x)<=i||Math.min(a.x,l.x,u.x,c.x)>=s||Math.max(a.y,l.y,u.y,c.y)<=n||Math.min(a.y,l.y,u.y,c.y)>=o))return!1;const p=h*(l.y-a.y),f=h*(a.x-l.x),m=p*i+f*n,_=p*s+f*n,g=p*i+f*o,b=p*s+f*o;if(Math.max(m,_,g,b)<=p*a.x+f*a.y||Math.min(m,_,g,b)>=p*c.x+f*c.y)return!1;const y=h*(a.y-u.y),v=h*(u.x-a.x),x=y*i+v*n,A=y*s+v*n,S=y*i+v*o,E=y*s+v*o;return!(Math.max(x,A,S,E)<=y*a.x+v*a.y||Math.min(x,A,S,E)>=y*c.x+v*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),s=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(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=s-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=s,this.height=n-s,this}getBounds(t){return t||(t=new z),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,s=t.x+t.width,n=t.y+t.height;return e>=this.x&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&s>=this.x&&s<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this}}const Ic=new C;class ot{constructor(t=1/0,e=1/0,i=-1/0,s=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Ic,this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new z);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=Ic,this}set(t,e,i,s){this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}addFrame(t,e,i,s,n){n||(n=this.matrix);const o=n.a,a=n.b,l=n.c,u=n.d,c=n.tx,h=n.ty;let p=this.minX,f=this.minY,m=this.maxX,_=this.maxY,g=o*t+l*e+c,b=a*t+u*e+h;g<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),g=o*i+l*e+c,b=a*i+u*e+h,g<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),g=o*t+l*s+c,b=a*t+u*s+h,g<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),g=o*i+l*s+c,b=a*i+u*s+h,g<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),this.minX=p,this.minY=f,this.maxX=m,this.maxY=_}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,i=this.minY,s=this.maxX,n=this.maxY,{a:o,b:a,c:l,d:u,tx:c,ty:h}=t;let p=o*e+l*i+c,f=a*e+u*i+h;this.minX=p,this.minY=f,this.maxX=p,this.maxY=f,p=o*s+l*i+c,f=a*s+u*i+h,this.minX=p<this.minX?p:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=p>this.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY,p=o*e+l*n+c,f=a*e+u*n+h,this.minX=p<this.minX?p:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=p>this.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY,p=o*s+l*n+c,f=a*s+u*n+h,this.minX=p<this.minX?p:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=p>this.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,s){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>s&&(this.maxY=s),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,i,s){let n=this.minX,o=this.minY,a=this.maxX,l=this.maxY;s||(s=this.matrix);const u=s.a,c=s.b,h=s.c,p=s.d,f=s.tx,m=s.ty;for(let _=e;_<i;_+=2){const g=t[_],b=t[_+1],y=u*g+h*b+f,v=c*g+p*b+m;n=y<n?y:n,o=v<o?v:o,a=y>a?y:a,l=v>l?v: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 ct=st.getPool(C),Vt=st.getPool(ot),N0=new C,Fc={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 i=t;if(r&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const s=!!this.effects.length;if((this.renderGroup||s)&&(i=Vt.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;i.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(r,i,e)}if(s){let n=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(n||(n=!0,i.applyMatrix(o.worldTransform)),this.effects[a].addBounds(i,!0));n&&i.applyMatrix(o.worldTransform.copyTo(N0).invert()),t.addBounds(i),Vt.return(i)}else this.renderGroup&&(t.addBounds(i,this.relativeGroupTransform),Vt.return(i))}};function Sr(r,t,e){e.clear();let i,s;return r.parent?t?i=r.parent.worldTransform:(s=ct.get().identity(),i=Pi(r,s)):i=C.IDENTITY,Dc(r,e,i,t),s&&ct.return(s),e.isValid||e.set(0,0,0,0),e}function Dc(r,t,e,i){var s,n;if(!r.visible||!r.measurable)return;let o;i?o=r.worldTransform:(r.updateLocalTransform(),o=ct.get(),o.appendFrom(r.localTransform,e));const a=t,l=!!r.effects.length;if(l&&(t=Vt.get().clear()),r.boundsArea)t.addRect(r.boundsArea,o);else{const u=r.bounds;u&&!u.isEmpty()&&(t.matrix=o,t.addBounds(u));for(let c=0;c<r.children.length;c++)Dc(r.children[c],t,o,i)}if(l){for(let u=0;u<r.effects.length;u++)(n=(s=r.effects[u]).addBounds)==null||n.call(s,t);a.addBounds(t,C.IDENTITY),Vt.return(t)}i||ct.return(o)}function Pi(r,t){const e=r.parent;return e&&(Pi(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function Bn(r,t){if(r===16777215||!t)return t;if(t===16777215||!r)return r;const e=r>>16&255,i=r>>8&255,s=r&255,n=t>>16&255,o=t>>8&255,a=t&255,l=e*n/255|0,u=i*o/255|0,c=s*a/255|0;return(l<<16)+(u<<8)+c}const Uc=16777215;function Ar(r,t){return r===Uc?t:t===Uc?r:Bn(r,t)}function $e(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const kc={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 C,t){if(t)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const e=Pi(this,ct.get().identity());return r.appendFrom(this.localTransform,e),ct.return(e),r},getGlobalTint(r){if(r)return this.renderGroup?$e(this.renderGroup.worldColor):this.parentRenderGroup?$e(Ar(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=Ar(t,e.localColor),e=e.parent;return $e(t)}};function wi(r,t,e){return t.clear(),e||(e=C.IDENTITY),$c(r,t,e,r,!0),t.isValid||t.set(0,0,0,0),t}function $c(r,t,e,i,s){var n,o;let a;if(s)a=ct.get(),a=e.copyTo(a);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const c=r.localTransform;a=ct.get(),a.appendFrom(c,e)}const l=t,u=!!r.effects.length;if(u&&(t=Vt.get().clear()),r.boundsArea)t.addRect(r.boundsArea,a);else{r.renderPipeId&&(t.matrix=a,t.addBounds(r.bounds));const c=r.children;for(let h=0;h<c.length;h++)$c(c[h],t,a,i,!1)}if(u){for(let c=0;c<r.effects.length;c++)(o=(n=r.effects[c]).addLocalBounds)==null||o.call(n,t,i);l.addBounds(t,C.IDENTITY),Vt.return(t)}ct.return(a)}function In(r,t){const e=r.children;for(let i=0;i<e.length;i++){const s=e[i],n=s.uid,o=(s._didViewChangeTick&65535)<<16|s._didContainerChangeTick&65535,a=t.index;(t.data[a]!==n||t.data[a+1]!==o)&&(t.data[t.index]=n,t.data[t.index+1]=o,t.didChange=!0),t.index=a+2,s.children.length&&In(s,t)}return t.didChange}const X0=new C,Lc={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(r,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=r/t*e:this.scale.x=e},_setHeight(r,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=r/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new ot});const r=this._localBoundsCacheData;return r.index=1,r.didChange=!1,r.data[0]!==this._didViewChangeTick&&(r.didChange=!0,r.data[0]=this._didViewChangeTick),In(this,r),r.didChange&&wi(this,r.localBounds,X0),r.localBounds},getBounds(r,t){return Sr(this,r,t||new ot)}},Nc={_onRender:null,set onRender(r){const t=this.renderGroup||this.parentRenderGroup;if(!r){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=r},get onRender(){return this._onRender}},Xc={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(r){this._zIndex!==r&&(this._zIndex=r,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(H0))}};function H0(r,t){return r._zIndex-t._zIndex}const Hc={getGlobalPosition(r=new W,t=!1){return this.parent?this.parent.toGlobal(this._position,r,t):(r.x=this._position.x,r.y=this._position.y),r},toGlobal(r,t,e=!1){const i=this.getGlobalTransform(ct.get(),e);return t=i.apply(r,t),ct.return(i),t},toLocal(r,t,e,i){t&&(r=t.toGlobal(r,e,i));const s=this.getGlobalTransform(ct.get(),i);return e=s.applyInverse(r,e),ct.return(s),e}};class Fn{constructor(){this.uid=Y("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}function _e(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function Dn(r){return!(r&r-1)&&!!r}function j0(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 kt(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}var z0=Object.defineProperty,jc=Object.getOwnPropertySymbols,V0=Object.prototype.hasOwnProperty,W0=Object.prototype.propertyIsEnumerable,zc=(r,t,e)=>t in r?z0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vc=(r,t)=>{for(var e in t||(t={}))V0.call(t,e)&&zc(r,e,t[e]);if(jc)for(var e of jc(t))W0.call(t,e)&&zc(r,e,t[e]);return r};const Wc=Object.create(null);function Y0(r){const t=Wc[r];return t===void 0&&(Wc[r]=Y("resource")),t}const Yc=class Nx extends gt{constructor(t={}){var e,i,s,n,o,a,l;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t=Vc(Vc({},Nx.defaultOptions),t),this.addressMode=t.addressMode,this.addressModeU=(e=t.addressModeU)!=null?e:this.addressModeU,this.addressModeV=(i=t.addressModeV)!=null?i:this.addressModeV,this.addressModeW=(s=t.addressModeW)!=null?s: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._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=Y0(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Yc.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Et=Yc;var K0=Object.defineProperty,Kc=Object.getOwnPropertySymbols,q0=Object.prototype.hasOwnProperty,Z0=Object.prototype.propertyIsEnumerable,qc=(r,t,e)=>t in r?K0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Zc=(r,t)=>{for(var e in t||(t={}))q0.call(t,e)&&qc(r,e,t[e]);if(Kc)for(var e of Kc(t))Z0.call(t,e)&&qc(r,e,t[e]);return r};const Qc=class Xx extends gt{constructor(t={}){var e,i,s;super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=Y("textureSource"),this._resourceType="textureSource",this._resourceId=Y("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=Zc(Zc({},Xx.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&&(i=this.resourceWidth)!=null?i:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&(s=this.resourceHeight)!=null?s: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 Et(kt(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){var t,e;this._resourceId=Y("resource"),this.emit("change",this),this.emit("unload",this);for(const i in this._gpuData)(e=(t=this._gpuData[i])==null?void 0:t.destroy)==null||e.call(t);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i||(i=this._resolution),t||(t=this.width),e||(e=this.height);const s=Math.round(t*i),n=Math.round(e*i);return this.width=s/i,this.height=n/i,this._resolution=i,this.pixelWidth===s&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=s,this.pixelHeight=n,this.emit("resize",this),this._resourceId=Y("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=Dn(this.pixelWidth)&&Dn(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Qc.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Q=Qc;const be=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],ve=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],ye=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],xe=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Un=[],Jc=[],Ri=Math.sign;function Q0(){for(let r=0;r<16;r++){const t=[];Un.push(t);for(let e=0;e<16;e++){const i=Ri(be[r]*be[e]+ye[r]*ve[e]),s=Ri(ve[r]*be[e]+xe[r]*ve[e]),n=Ri(be[r]*ye[e]+ye[r]*xe[e]),o=Ri(ve[r]*ye[e]+xe[r]*xe[e]);for(let a=0;a<16;a++)if(be[a]===i&&ve[a]===s&&ye[a]===n&&xe[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new C;t.set(be[r],ve[r],ye[r],xe[r],0,0),Jc.push(t)}}Q0();const N={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=>be[r],uY:r=>ve[r],vX:r=>ye[r],vY:r=>xe[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Un[r][t],sub:(r,t)=>Un[r][N.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?N.S:N.N:Math.abs(t)*2<=Math.abs(r)?r>0?N.E:N.W:t>0?r>0?N.SE:N.SW:r>0?N.NE:N.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=Jc[N.inv(t)];s.tx=e,s.ty=i,r.append(s)},transformRectCoords:(r,t,e,i)=>{const{x:s,y:n,width:o,height:a}=r,{x:l,y:u,width:c,height:h}=t;return e===N.E?(i.set(s+l,n+u,o,a),i):e===N.S?i.set(c-n-a+l,s+u,a,o):e===N.W?i.set(c-s-o+l,h-n-a+u,o,a):e===N.N?i.set(n+l,h-s-o+u,a,o):i.set(s+l,n+u,o,a)}},kn=()=>{};var J0=Object.defineProperty,tT=Object.defineProperties,eT=Object.getOwnPropertyDescriptors,th=Object.getOwnPropertySymbols,rT=Object.prototype.hasOwnProperty,iT=Object.prototype.propertyIsEnumerable,eh=(r,t,e)=>t in r?J0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,sT=(r,t)=>{for(var e in t||(t={}))rT.call(t,e)&&eh(r,e,t[e]);if(th)for(var e of th(t))iT.call(t,e)&&eh(r,e,t[e]);return r},nT=(r,t)=>tT(r,eT(t));class Ci extends Q{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super(nT(sT({},t),{resource:e,format:i})),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}Ci.extension=T.TextureSource;const rh=new C;class $n{constructor(t,e){this.mapCoord=new C,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 i=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],o=t[s+1];e[s]=n*i.a+o*i.c+i.tx,e[s+1]=n*i.b+o*i.d+i.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const i=t.orig,s=t.trim;s&&(rh.set(i.width/s.width,0,0,i.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(rh));const n=t.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,l=this.clampOffset/n._resolution;return o[0]=(t.frame.x+a+l)/n.width,o[1]=(t.frame.y+a+l)/n.height,o[2]=(t.frame.x+t.frame.width-a+l)/n.width,o[3]=(t.frame.y+t.frame.height-a+l)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&t.rotate===0,!0}}class w extends gt{constructor({source:t,label:e,frame:i,orig:s,trim:n,defaultAnchor:o,defaultBorders:a,rotate:l,dynamic:u}={}){var c;if(super(),this.uid=Y("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new z,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(c=t==null?void 0:t.source)!=null?c:new Q,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:h,height:p}=this._source;this.frame.width=h,this.frame.height=p}this.orig=s||this.frame,this.trim=n,this.rotate=l!=null?l:0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=u||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new $n(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:i,height:s}=this._source,n=e.x/i,o=e.y/s,a=e.width/i,l=e.height/s;let u=this.rotate;if(u){const c=a/2,h=l/2,p=n+c,f=o+h;u=N.add(u,N.NW),t.x0=p+c*N.uX(u),t.y0=f+h*N.uY(u),u=N.add(u,2),t.x1=p+c*N.uX(u),t.y1=f+h*N.uY(u),u=N.add(u,2),t.x2=p+c*N.uX(u),t.y2=f+h*N.uY(u),u=N.add(u,2),t.x3=p+c*N.uX(u),t.y3=f+h*N.uY(u)}else t.x0=n,t.y0=o,t.x1=n+a,t.y1=o,t.x2=n+a,t.y2=o+l,t.x3=n,t.y3=o+l}destroy(t=!1){this._source&&(this._source.off("resize",this.update,this),t&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return this._source}}w.EMPTY=new w({label:"EMPTY",source:new Q({label:"EMPTY"})}),w.EMPTY.destroy=kn,w.WHITE=new w({source:new Ci({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),w.WHITE.destroy=kn;var oT=Object.defineProperty,aT=Object.defineProperties,lT=Object.getOwnPropertyDescriptors,ih=Object.getOwnPropertySymbols,uT=Object.prototype.hasOwnProperty,cT=Object.prototype.propertyIsEnumerable,sh=(r,t,e)=>t in r?oT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hT=(r,t)=>{for(var e in t||(t={}))uT.call(t,e)&&sh(r,e,t[e]);if(ih)for(var e of ih(t))cT.call(t,e)&&sh(r,e,t[e]);return r},dT=(r,t)=>aT(r,lT(t));let pT=0;class nh{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new Et(this.textureOptions)}createTexture(t,e,i){const s=new Q(dT(hT({},this.textureOptions),{width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1}));return new w({source:s,label:`texturePool_${pT++}`})}getOptimalTexture(t,e,i=1,s){let n=Math.ceil(t*i-1e-6),o=Math.ceil(e*i-1e-6);n=_e(n),o=_e(o);const a=(n<<17)+(o<<1)+(s?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let l=this._texturePool[a].pop();return l||(l=this.createTexture(n,o,s)),l.source._resolution=i,l.source.width=n/i,l.source.height=o/i,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 i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t,e=!1){const i=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[i].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const i=this._texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this._texturePool={}}}const et=new nh;ge.register(et);class Mi{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new C,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new Fn,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let i=0;i<e.length;i++){const s=e[i];s._updateFlags=15,this.addChild(s)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(et.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let i=0;i<e.length;i++)this.removeChild(e[i])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let i=0;i<e.length;i++)this._getChildren(e[i],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const i=t.children;for(let s=0;s<i.length;s++)this._getChildren(i[s],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return this._matrixDirty&1?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new C),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return this._matrixDirty&2?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new C),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(this._matrixDirty&4))return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new C),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function Oi(r,t,e={}){for(const i in t)!e[i]&&t[i]!==void 0&&(r[i]=t[i])}const Ln=new Z(null),Nn=new Z(null),Xn=new Z(null,1,1),Hn=new Z(null),Er=1,Gi=2,Le=4,fT=8;class q extends gt{constructor(t={}){var e,i;super(),this.uid=Y("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new C,this.relativeGroupTransform=new C,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Z(this,0,0),this._scale=Xn,this._pivot=Nn,this._origin=Hn,this._skew=Ln,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],Oi(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(s=>this.addChild(s)),(i=t.parent)==null||i.addChild(this)}static mixin(t){F.mixin(q,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 s=0;s<t.length;s++)this.addChild(t[s]);return t[0]}const e=t[0],i=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),i&&(i.structureDidChange=!0),e):(e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e._updateFlags=15,i&&i.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,e._zIndex!==0&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let s=0;s<t.length;s++)this.removeChild(t[s]);return t[0]}const e=t[0],i=this.children.indexOf(e);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=st.get(Mi,this),this.groupTransform=C.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 C),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*xc}set angle(t){this.rotation=t*Tc}get pivot(){return this._pivot===Nn&&(this._pivot=new Z(this,0,0)),this._pivot}set pivot(t){this._pivot===Nn&&(this._pivot=new Z(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Ln&&(this._skew=new Z(this,0,0)),this._skew}set skew(t){this._skew===Ln&&(this._skew=new Z(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Xn&&(this._scale=new Z(this,1,1)),this._scale}set scale(t){this._scale===Xn&&(this._scale=new Z(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===Hn&&(this._origin=new Z(this,0,0)),this._origin}set origin(t){this._origin===Hn&&(this._origin=new Z(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 i;const s=this.getLocalBounds();typeof t=="object"?(e=(i=t.height)!=null?i:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,s.width),e!==void 0&&this._setHeight(e,s.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,i=this._scale,s=this._pivot,n=this._origin,o=this._position,a=i._x,l=i._y,u=s._x,c=s._y,h=-n._x,p=-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+c*e.c)+(h*e.a+p*e.c)-h,e.ty=o._y-(u*e.b+c*e.d)+(h*e.b+p*e.d)-p}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=Er,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=H.shared.setValue(t!=null?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=Er,this._onUpdate())}get tint(){return $e(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Gi,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|=Le,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|=Le,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|=Le,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 i;if(this.children.length&&(i=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&i)for(let s=0;s<i.length;++s)i[s].destroy(t);(e=this.renderGroup)==null||e.destroy(),this.renderGroup=null}}F.mixin(q,Pc,Fc,Hc,Nc,Lc,Gc,Bc,Xc,vc,Ec,kc,wc);var Wt=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(Wt||{});class Bi{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=s}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 oh=class Ot{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 Bi(null,null,1/0),this.deltaMS=1/Ot.targetFPMS,this.elapsedMS=1/Ot.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=Wt.NORMAL){return this._addListener(new Bi(t,e,i))}addOnce(t,e,i=Wt.NORMAL){return this._addListener(new Bi(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Ot.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,Ot.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!Ot._shared){const t=Ot._shared=new Ot;t.autoStart=!0,t._protected=!0}return Ot._shared}static get system(){if(!Ot._system){const t=Ot._system=new Ot;t.autoStart=!0,t._protected=!0}return Ot._system}};oh.targetFPMS=.06;let at=oh;class jn{constructor(t){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const e=this._canvas.getBoundingClientRect(),i=this._canvas.width,s=this._canvas.height,n=e.width/i*this._renderer.resolution,o=e.height/s*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 i=this.canvas.width,s=this.canvas.height,n=e.contentRect.width/i*this._renderer.resolution,o=e.contentRect.height/s*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||at.shared.add(this.updateTranslation,this,Wt.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&at.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 Ne{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Ne.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new W,this.page=new W,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var zn=/iPhone/i,ah=/iPod/i,lh=/iPad/i,uh=/\biOS-universal(?:.+)Mac\b/i,Vn=/\bAndroid(?:.+)Mobile\b/i,ch=/Android/i,Xe=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ii=/Silk/i,ie=/Windows Phone/i,hh=/\bWindows(?:.+)ARM\b/i,dh=/BlackBerry/i,ph=/BB10/i,fh=/Opera Mini/i,mh=/\b(CriOS|Chrome)(?:.+)Mobile/i,gh=/Mobile(?:.+)Firefox\b/i,_h=function(r){return typeof r!="undefined"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream=="undefined"};function mT(r){return function(t){return t.test(r)}}function bh(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,i=e.split("[FBAN");typeof i[1]!="undefined"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]!="undefined"&&(e=i[0]);var s=mT(e),n={apple:{phone:s(zn)&&!s(ie),ipod:s(ah),tablet:!s(zn)&&(s(lh)||_h(t))&&!s(ie),universal:s(uh),device:(s(zn)||s(ah)||s(lh)||s(uh)||_h(t))&&!s(ie)},amazon:{phone:s(Xe),tablet:!s(Xe)&&s(Ii),device:s(Xe)||s(Ii)},android:{phone:!s(ie)&&s(Xe)||!s(ie)&&s(Vn),tablet:!s(ie)&&!s(Xe)&&!s(Vn)&&(s(Ii)||s(ch)),device:!s(ie)&&(s(Xe)||s(Ii)||s(Vn)||s(ch))||s(/\bokhttp\b/i)},windows:{phone:s(ie),tablet:s(hh),device:s(ie)||s(hh)},other:{blackberry:s(dh),blackberry10:s(ph),opera:s(fh),firefox:s(gh),chrome:s(mh),device:s(dh)||s(ph)||s(fh)||s(gh)||s(mh)},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 vh;const yh=((vh=bh.default)!=null?vh:bh)(globalThis.navigator);var gT=Object.defineProperty,xh=Object.getOwnPropertySymbols,_T=Object.prototype.hasOwnProperty,bT=Object.prototype.propertyIsEnumerable,Th=(r,t,e)=>t in r?gT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Sh=(r,t)=>{for(var e in t||(t={}))_T.call(t,e)&&Th(r,e,t[e]);if(xh)for(var e of xh(t))bT.call(t,e)&&Th(r,e,t[e]);return r};const vT=9,Ah=100,yT=0,xT=0,Eh=2,Ph=1,TT=-1e3,ST=-1e3,AT=2,Wn=class Hx{constructor(t,e=yh){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=`${Ph}px`,t.style.height=`${Ph}px`,t.style.position="absolute",t.style.top=`${TT}px`,t.style.left=`${ST}px`,t.style.zIndex=AT.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=`${yT}px`,this._div.style.left=`${xT}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=Eh.toString(),this._canvasObserver=new jn({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 i of this._children)(t=i._accessibleDiv)!=null&&t.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1;for(const i in this._pools)this._pools[i].forEach(s=>{s.parentNode&&s.parentNode.removeChild(s)}),delete this._pools[i];(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 i=0;i<e.length;i++)this._updateAccessibleObjects(e[i])}init(t){const e=Hx.defaultOptions,i={accessibilityOptions:Sh(Sh({},e),(t==null?void 0:t.accessibilityOptions)||{})};this.debug=i.accessibilityOptions.debug,this._activateOnTab=i.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=i.accessibilityOptions.deactivateOnMouseMove,i.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){const t=performance.now();if(this._mobileInfo.android.device&&t<this._androidUpdateCount||(this._androidUpdateCount=t+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;const e=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const i of this._children)i._renderId===this._renderId&&e.add(this._children.indexOf(i))}for(let i=this._children.length-1;i>=0;i--){const s=this._children[i];e.has(i)||(s._accessibleDiv&&s._accessibleDiv.parentNode&&(s._accessibleDiv.parentNode.removeChild(s._accessibleDiv),this._getPool(s.accessibleType).push(s._accessibleDiv),s._accessibleDiv=null),s._accessibleActive=!1,Gn(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i<this._children.length;i++){const s=this._children[i];if(!s._accessibleActive||!s._accessibleDiv)continue;const n=s._accessibleDiv,o=s.hitArea||s.getBounds().rectangle;if(s.hitArea){const a=s.worldTransform;n.style.left=`${a.tx+o.x*a.a}px`,n.style.top=`${a.ty+o.y*a.d}px`,n.style.width=`${o.width*a.a}px`,n.style.height=`${o.height*a.d}px`}else this._capHitArea(o),n.style.left=`${o.x}px`,n.style.top=`${o.y}px`,n.style.width=`${o.width}px`,n.style.height=`${o.height}px`}this._renderId++}_updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}_capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}_addChild(t){let e=this._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=`${Ah}px`,e.style.height=`${Ah}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Eh.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:i}=t.target,s=this._renderer.events.rootBoundary,n=Object.assign(new Ne(s),{target:i});s.rootTarget=this._renderer.lastObjectRendered,e.forEach(o=>s.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!==vT||!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]}};Wn.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"accessibility"},Wn.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let wh=Wn;const Rh={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1};F.add(wh),F.mixin(q,Rh);class Yn{static init(t){Object.defineProperty(this,"resizeTo",{configurable:!0,set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Yn.extension=T.Application;class Kn{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,Wt.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?at.shared:new at,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Kn.extension=T.Application,F.add(Yn),F.add(Kn);let ET=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||(at.system.add(this._tickerUpdate,this,Wt.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(at.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._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this._update())}destroy(){this.removeTickerListener(),this.events=null,this.domElement=null,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}};const Yt=new ET;class Pr extends Ne{constructor(){super(...arguments),this.client=new W,this.movement=new W,this.offset=new W,this.global=new W,this.screen=new W}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,s,n,o,a,l,u,c,h,p,f,m,_){throw new Error("Method not implemented.")}}class Ft extends Pr{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Te extends Pr{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Te.DOM_DELTA_PIXEL=0,Te.DOM_DELTA_LINE=1,Te.DOM_DELTA_PAGE=2;const PT=2048,wT=new W,wr=new W;class Ch{constructor(t){this.dispatch=new gt,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,s)=>i.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i<s;i++)e[i].fn(t)}hitTest(t,e){Yt.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,wT.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let s=i.length-2;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)s.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<PT&&t!==this.rootTarget&&t.parent;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,s,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Yt.pauseUpdate=!1),t.interactiveChildren&&t.children){const c=t.children;for(let h=c.length-1;h>=0;h--){const p=c[h],f=this.hitTestMoveRecursive(p,this._isInteractive(e)?e:p.eventMode,i,s,n,o||n(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const m=t.isInteractive();(f.length>0||m)&&(m&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),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,i)&&s(t,i)?u?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Yt.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children,u=i;for(let c=l.length-1;c>=0;c--){const h=l[c],p=this.hitTestRecursive(h,this._isInteractive(e)?e:h.eventMode,u,s,n);if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();return(p.length>0||f)&&p.push(t),p}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&s(t,i)?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,wr),!t.hitArea.contains(wr.x,wr.y)))return!0;if(t.effects&&t.effects.length)for(let i=0;i<t.effects.length;i++){const s=t.effects[i];if(s.containsPoint&&!s.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return t.hitArea?!0:t!=null&&t.containsPoint?(t.worldTransform.applyInverse(e,wr),t.containsPoint(wr)):!1}notifyTarget(t,e){var i,s;if(!t.currentTarget.isInteractive())return;e!=null||(e=t.type);const n=`on${e}`;(s=(i=t.currentTarget)[n])==null||s.call(i,t);const o=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,o),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof Ft))return;const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const s=e.button===2;this.dispatchEvent(e,s?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,i,s;if(!(t instanceof Ft))return;this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const n=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const o=n.pointerType==="mouse"||n.pointerType==="pen",a=this.trackingData(t.pointerId),l=this.findMountedTarget(a.overTargets);if(((e=a.overTargets)==null?void 0:e.length)>0&&l!==n.target){const h=t.type==="mousemove"?"mouseout":"pointerout",p=this.createPointerEvent(t,h,l);if(this.dispatchEvent(p,"pointerout"),o&&this.dispatchEvent(p,"mouseout"),!n.composedPath().includes(l)){const f=this.createPointerEvent(t,"pointerleave",l);for(f.eventPhase=f.AT_TARGET;f.target&&!n.composedPath().includes(f.target);)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseleave"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(p)}if(l!==n.target){const h=t.type==="mousemove"?"mouseover":"pointerover",p=this.clonePointerEvent(n,h);this.dispatchEvent(p,"pointerover"),o&&this.dispatchEvent(p,"mouseover");let f=l==null?void 0:l.parent;for(;f&&f!==this.rootTarget.parent&&f!==n.target;)f=f.parent;if(!f||f===this.rootTarget.parent){const m=this.clonePointerEvent(n,"pointerenter");for(m.eventPhase=m.AT_TARGET;m.target&&m.target!==l&&m.target!==this.rootTarget.parent;)m.currentTarget=m.target,this.notifyTarget(m),o&&this.notifyTarget(m,"mouseenter"),m.target=m.target.parent;this.freeEvent(m)}this.freeEvent(p)}const u=[],c=(i=this.enableGlobalMoveEvents)!=null?i:!0;this.moveOnAll?u.push("pointermove"):this.dispatchEvent(n,"pointermove"),c&&u.push("globalpointermove"),n.pointerType==="touch"&&(this.moveOnAll?u.splice(1,0,"touchmove"):this.dispatchEvent(n,"touchmove"),c&&u.push("globaltouchmove")),o&&(this.moveOnAll?u.splice(1,0,"mousemove"):this.dispatchEvent(n,"mousemove"),c&&u.push("globalmousemove"),this.cursor=(s=n.target)==null?void 0:s.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 Ft))return;const i=this.trackingData(t.pointerId),s=this.createPointerEvent(t),n=s.pointerType==="mouse"||s.pointerType==="pen";this.dispatchEvent(s,"pointerover"),n&&this.dispatchEvent(s,"mouseover"),s.pointerType==="mouse"&&(this.cursor=(e=s.target)==null?void 0:e.cursor);const o=this.clonePointerEvent(s,"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;i.overTargets=s.composedPath(),this.freeEvent(s),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof Ft))return;const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",s);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&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 Ft))return;const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let o=n;if(n&&!i.composedPath().includes(n)){let a=n;for(;a&&!i.composedPath().includes(a);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=s.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(i)}mapPointerUpOutside(t){if(!(t instanceof Ft))return;const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}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 i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){var s;const n=this.allocateEvent(Ft);return this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.nativeEvent=t.nativeEvent,n.originalEvent=t,n.target=(s=i!=null?i:this.hitTest(n.global.x,n.global.y))!=null?s:this._hitElements[0],typeof e=="string"&&(n.type=e),n}createWheelEvent(t){const e=this.allocateEvent(Te);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(Ft);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e!=null?e:i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Ft&&e instanceof Ft&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof Pr&&e instanceof Pr&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.defaultPrevented=!1,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}_notifyListeners(t,e){const i=t.currentTarget._events[e];if(i)if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}var RT=Object.defineProperty,Mh=Object.getOwnPropertySymbols,CT=Object.prototype.hasOwnProperty,MT=Object.prototype.propertyIsEnumerable,Oh=(r,t,e)=>t in r?RT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,OT=(r,t)=>{for(var e in t||(t={}))CT.call(t,e)&&Oh(r,e,t[e]);if(Mh)for(var e of Mh(t))MT.call(t,e)&&Oh(r,e,t[e]);return r};const GT=1,BT={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},qn=class Wu{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Ch(null),Yt.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Ft(null),this._rootWheelEvent=new Te(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(OT({},Wu.defaultEventFeatures),{set:(e,i,s)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[i]=s,!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,i;const{canvas:s,resolution:n}=this.renderer;this.setTargetElement(s),this.resolution=n,Wu._defaultEventMode=(e=t.eventMode)!=null?e:"passive",Object.assign(this.features,(i=t.eventFeatures)!=null?i:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){Yt.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t||(t="default");let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);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 i=0,s=e.length;i<s;i++){const n=e[i],o=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Yt.pointerMoved();const e=this._normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",s=this._normalizeToPointerData(t);for(let n=0,o=s.length;n<o;n++){const a=this._bootstrapEvent(this._rootPointerEvent,s[n]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this._removeEvents(),this.domElement=t,Yt.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;Yt.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;Yt.removeTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(t,e,i){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(i-s.top)*(this.domElement.height/s.height)*n}_normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const n=t.changedTouches[i];typeof n.button=="undefined"&&(n.button=0),typeof n.buttons=="undefined"&&(n.buttons=1),typeof n.isPrimary=="undefined"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width=="undefined"&&(n.width=n.radiusX||1),typeof n.height=="undefined"&&(n.height=n.radiusY||1),typeof n.tiltX=="undefined"&&(n.tiltX=0),typeof n.tiltY=="undefined"&&(n.tiltY=0),typeof n.pointerType=="undefined"&&(n.pointerType="touch"),typeof n.pointerId=="undefined"&&(n.pointerId=n.identifier||0),typeof n.pressure=="undefined"&&(n.pressure=n.force||.5),typeof n.twist=="undefined"&&(n.twist=0),typeof n.tangentialPressure=="undefined"&&(n.tangentialPressure=0),typeof n.layerX=="undefined"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY=="undefined"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary=="undefined"&&(i.isPrimary=!0),typeof i.width=="undefined"&&(i.width=1),typeof i.height=="undefined"&&(i.height=1),typeof i.tiltX=="undefined"&&(i.tiltX=0),typeof i.tiltY=="undefined"&&(i.tiltY=0),typeof i.pointerType=="undefined"&&(i.pointerType="mouse"),typeof i.pointerId=="undefined"&&(i.pointerId=GT),typeof i.pressure=="undefined"&&(i.pressure=.5),typeof i.twist=="undefined"&&(i.twist=0),typeof i.tangentialPressure=="undefined"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}else e.push(t);return e}normalizeWheelEvent(t){const e=this._rootWheelEvent;return this._transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}_bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this._transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=BT[t.type]||t.type),t}_transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};qn.extension={name:"events",type:[T.WebGLSystem,T.CanvasSystem,T.WebGPUSystem],priority:-1},qn.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Zn=qn;const Gh={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(r){this.eventMode=r?"static":"passive"},_internalEventMode:void 0,get eventMode(){var r;return(r=this._internalEventMode)!=null?r:Zn.defaultEventMode},set eventMode(r){this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;r=i?`${r}capture`:r;const a=typeof t=="function"?t:t.handleEvent,l=this;s&&s.addEventListener("abort",()=>{l.off(r,a,o)}),n?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,s)},dispatchEvent(r){if(!(r instanceof Ne))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(Zn),F.mixin(q,Gh);class Qn{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 jn({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<t.length;e++){const i=t[e],s=i.element;if(!i.parent||i.globalDisplayStatus<7)s==null||s.remove(),t.splice(e,1),e--;else{this._domElement.contains(s)||(s.style.position="absolute",s.style.pointerEvents="auto",this._domElement.appendChild(s));const n=i.worldTransform,o=i._anchor,a=i.width*o.x,l=i.height*o.y;s.style.transformOrigin=`${a}px ${l}px`,s.style.transform=`matrix(${n.a}, ${n.b}, ${n.c}, ${n.d}, ${n.tx-a}, ${n.ty-l})`,s.style.opacity=i.groupAlpha.toString()}}}destroy(){var t;this._renderer.runners.postrender.remove(this);for(let e=0;e<this._attachedDomElements.length;e++)(t=this._attachedDomElements[e].element)==null||t.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}Qn.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"dom"};class Kt extends q{constructor(t){var e;super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new ot(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=(e=t.autoGarbageCollect)!=null?e:!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:i,y:s}=t;return i>=e.minX&&i<=e.maxX&&s>=e.minY&&s<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(t){this.unload(),super.destroy(t),this._bounds=null}collectRenderablesSimple(t,e,i){const{renderPipes:s}=e;s.blendMode.pushBlendMode(this,this.groupBlendMode,t),s[this.renderPipeId].addRenderable(this,t),this.didViewUpdate=!1;const n=this.children,o=n.length;for(let a=0;a<o;a++)n[a].collectRenderables(t,e,i);s.blendMode.popBlendMode(t)}}var IT=Object.defineProperty,Fi=Object.getOwnPropertySymbols,Bh=Object.prototype.hasOwnProperty,Ih=Object.prototype.propertyIsEnumerable,Fh=(r,t,e)=>t in r?IT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,FT=(r,t)=>{for(var e in t||(t={}))Bh.call(t,e)&&Fh(r,e,t[e]);if(Fi)for(var e of Fi(t))Ih.call(t,e)&&Fh(r,e,t[e]);return r},DT=(r,t)=>{var e={};for(var i in r)Bh.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Fi)for(var i of Fi(r))t.indexOf(i)<0&&Ih.call(r,i)&&(e[i]=r[i]);return e};class UT extends Kt{constructor(t={}){const e=t,{element:i,anchor:s}=e,n=DT(e,["element","anchor"]);super(FT({label:"DOMContainer"},n)),this.renderPipeId="dom",this.batched=!1,this._anchor=new W(0,0),s&&(this.anchor=s),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:i,offsetHeight:s}=e;t.minX=0,t.maxX=i,t.minY=0,t.maxY=s}destroy(t=!1){var e,i;super.destroy(t),(i=(e=this._element)==null?void 0:e.parentNode)==null||i.removeChild(this._element),this._element=null,this._anchor=null}}F.add(Qn);var Pt=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Pt||{});const Dh={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 Uh=Dh;const L={get(){return Uh},set(r){Uh=r}};function $t(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 kT(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $T(r,t,e){return r.replace(new RegExp(kT(t),"g"),e)}function LT(r,t){let e="",i=0,s=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+=`/${r.slice(s+1,a)}`:e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const _t={toPosix(r){return $T(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){$t(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($t(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=Rr(this.toPosix(t!=null?t:L.get().getBaseUrl())),s=Rr(this.toPosix(e!=null?e:this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?_t.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if($t(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 i=r.endsWith("/");return r=LT(r,!1),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return $t(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){var t;if(r.length===0)return".";let e;for(let i=0;i<r.length;++i){const s=r[i];if($t(s),s.length>0)if(e===void 0)e=s;else{const n=(t=r[i-1])!=null?t:"";this.joinExtensions.includes(this.extname(n).toLowerCase())?e+=`/../${s}`:e+=`/${s}`}}return e===void 0?".":this.normalize(e)},dirname(r){if($t(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!s){i=a;break}}else s=!1;return i===-1?e?"/":this.isUrl(o)?n+r:n:e&&i===1?"//":n+r.slice(0,i)},rootname(r){$t(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){$t(r),t&&$t(t),r=Rr(this.toPosix(r));let e=0,i=-1,s=!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(!s){e=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){e=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(e,i)},extname(r){$t(r),r=Rr(this.toPosix(r));let t=-1,e=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}i===-1&&(s=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){$t(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 i=this.isAbsolute(r);let s;const n="";t.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let o=-1,a=0,l=-1,u=!0,c=r.length-1,h=0;for(;c>=s;--c){if(e=r.charCodeAt(c),e===47){if(!u){a=c+1;break}continue}l===-1&&(u=!1,l=c+1),e===46?o===-1?o=c:h!==1&&(h=1):o!==-1&&(h=-1)}return o===-1||l===-1||h===0||h===1&&o===l-1&&o===a+1?l!==-1&&(a===0&&i?t.base=t.name=r.slice(1,l):t.base=t.name=r.slice(a,l)):(a===0&&i?(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"]},Dt=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r);function kh(r,t,e,i,s){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?kh(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function $h(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const s=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),kh(r,s,0,e,i)}else i.push(r);return i}const Cr=r=>!Array.isArray(r);var NT=Object.defineProperty,XT=Object.defineProperties,HT=Object.getOwnPropertyDescriptors,Lh=Object.getOwnPropertySymbols,jT=Object.prototype.hasOwnProperty,zT=Object.prototype.propertyIsEnumerable,Nh=(r,t,e)=>t in r?NT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Se=(r,t)=>{for(var e in t||(t={}))jT.call(t,e)&&Nh(r,e,t[e]);if(Lh)for(var e of Lh(t))zT.call(t,e)&&Nh(r,e,t[e]);return r},Xh=(r,t)=>XT(r,HT(t));class ae{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){var e,i,s;if(this._bundleIdConnector=(e=t.connector)!=null?e:this._bundleIdConnector,this._createBundleAssetId=(i=t.createBundleAssetId)!=null?i:this._createBundleAssetId,this._extractAssetIdFromBundle=(s=t.extractAssetIdFromBundle)!=null?s:this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return Dt(e||i,s=>typeof s=="string"?s:Array.isArray(s)?s.map(n=>{var o;return(o=n==null?void 0:n.src)!=null?o:n}):s!=null&&s.src?s.src:s,!0)}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let s=e;Array.isArray(e)||(s=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:Se({alias:n},o))),s.forEach(n=>{const o=n.src,a=n.alias;let l;if(typeof a=="string"){const u=this._createBundleAssetId(t,a);i.push(u),l=[a,u]}else{const u=a.map(c=>this._createBundleAssetId(t,c));i.push(...u),l=[...a,...u]}this.add(Xh(Se({},n),{alias:l,src:o}))}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;Dt(e).forEach(s=>{const{src:n}=s;let{data:o,format:a,loadParser:l,parser:u}=s;const c=Dt(n).map(m=>typeof m=="string"?$h(m):Array.isArray(m)?m:[m]),h=this.getAlias(s),p=[],f=m=>{const _=this._parsers.find(g=>g.test(m));return Xh(Se({},_==null?void 0:_.parse(m)),{src:m})};c.forEach(m=>{m.forEach(_=>{var g,b,y,v;let x={};if(typeof _!="object"?x=f(_):(o=(g=_.data)!=null?g:o,a=(b=_.format)!=null?b:a,(_.loadParser||_.parser)&&(l=(y=_.loadParser)!=null?y:l,u=(v=_.parser)!=null?v:u),x=Se(Se({},f(_.src)),_)),!h)throw new Error(`[Resolver] alias is undefined for this asset: ${x.src}`);x=this._buildResolvedAsset(x,{aliases:h,data:o,format:a,loadParser:l,parser:u,progressSize:s.progressSize}),p.push(x)})}),h.forEach(m=>{this._assetMap[m]=p})})}resolveBundle(t){const e=Cr(t);t=Dt(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const l in o){const u=o[l];a[this._extractAssetIdFromBundle(s,l)]=u}i[s]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const s in e)i[s]=e[s].src;return i}return e.src}resolve(t){const e=Cr(t);t=Dt(t);const i={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(l=>{const u=n.filter(c=>c[a]?c[a]===l:!1);u.length&&(n=u)})}),this._resolverHash[s]=n[0]}else this._resolverHash[s]=this._buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[e],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){var i,s;const{aliases:n,data:o,loadParser:a,parser:l,format:u,progressSize:c}=e;return(this._basePath||this._rootPath)&&(t.src=_t.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=(i=n!=null?n:t.alias)!=null?i:[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=(s=u!=null?u:t.format)!=null?s:Hh(t.src),c!==void 0&&(t.progressSize=c),t}}ae.RETINA_PREFIX=/@([0-9\.]+)x/;function Hh(r){return r.split(".").pop().split("?").shift().split("#").shift()}const Di=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r},jh=class xi{constructor(t,e){this.linkedSheets=[];let i=t;(t==null?void 0:t.source)instanceof Q&&(i={texture:t,data:e});const{texture:s,data:n,cachePrefix:o=""}=i;this.cachePrefix=o,this._texture=s instanceof w?s:null,this.textureSource=s.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,s.source.resolution=this.resolution):this.resolution=s.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=xi.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=xi.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const s=this._frameKeys[e],n=this._frames[s],o=n.frame;if(o){let a=null,l=null;const u=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,c=new z(0,0,Math.floor(u.w)/this.resolution,Math.floor(u.h)/this.resolution);n.rotated?a=new z(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):a=new z(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(l=new z(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[s]=new w({source:this.textureSource,frame:a,orig:c,trim:l,rotate:n.rotated?2:0,defaultAnchor:n.anchor,defaultBorders:n.borders,label:s.toString()})}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*xi.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*xi.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};jh.BATCH_SIZE=1e3;let Jn=jh;const VT=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function zh(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[`${t.cachePrefix}${s}`]=t.textures[s]}),!e){const s=_t.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=zh([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const Vh={extension:T.Asset,cache:{test:r=>r instanceof Jn,getCacheableAssets:(r,t)=>zh(r,t,!1)},resolver:{extension:{type:T.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&VT.includes(i)},parse:r=>{var t,e;const i=r.split(".");return{resolution:parseFloat((e=(t=ae.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:i[i.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:T.LoadParser,priority:Pt.Normal,name:"spritesheetLoader"},async testParse(r,t){return _t.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var i,s,n;const{texture:o,imageFilename:a,textureOptions:l,cachePrefix:u}=(i=t==null?void 0:t.data)!=null?i:{};let c=_t.dirname(t.src);c&&c.lastIndexOf("/")!==c.length-1&&(c+="/");let h;if(o instanceof w)h=o;else{const m=Di(c+(a!=null?a:r.meta.image),t.src);h=(await e.load([{src:m,data:l}]))[m]}const p=new Jn({texture:h.source,data:r,cachePrefix:u});await p.parse();const f=(s=r==null?void 0:r.meta)==null?void 0:s.related_multi_packs;if(Array.isArray(f)){const m=[];for(const g of f){if(typeof g!="string")continue;let b=c+g;(n=t.data)!=null&&n.ignoreMultiPack||(b=Di(b,t.src),m.push(e.load({src:b,data:{textureOptions:l,ignoreMultiPack:!0}})))}const _=await Promise.all(m);p.linkedSheets=_,_.forEach(g=>{g.linkedSheets=[p].concat(p.linkedSheets.filter(b=>b!==g))})}return p},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};F.add(Vh);function to(r,t,e){const{width:i,height:s}=e.orig,n=e.trim;if(n){const o=n.width,a=n.height;r.minX=n.x-t._x*i,r.maxX=r.minX+o,r.minY=n.y-t._y*s,r.maxY=r.minY+a}else r.minX=-t._x*i,r.maxX=r.minX+i,r.minY=-t._y*s,r.maxY=r.minY+s}var WT=Object.defineProperty,Ui=Object.getOwnPropertySymbols,Wh=Object.prototype.hasOwnProperty,Yh=Object.prototype.propertyIsEnumerable,Kh=(r,t,e)=>t in r?WT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,YT=(r,t)=>{for(var e in t||(t={}))Wh.call(t,e)&&Kh(r,e,t[e]);if(Ui)for(var e of Ui(t))Yh.call(t,e)&&Kh(r,e,t[e]);return r},KT=(r,t)=>{var e={};for(var i in r)Wh.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ui)for(var i of Ui(r))t.indexOf(i)<0&&Yh.call(r,i)&&(e[i]=r[i]);return e};class Lt extends Kt{constructor(t=w.EMPTY){t instanceof w&&(t={texture:t});const e=t,{texture:i=w.EMPTY,anchor:s,roundPixels:n,width:o,height:a}=e,l=KT(e,["texture","anchor","roundPixels","width","height"]);super(YT({label:"Sprite"},l)),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new Z({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:i.defaultAnchor&&(this.anchor=i.defaultAnchor),this.texture=i,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 w?new Lt(t):new Lt(w.from(t,e))}set texture(t){t||(t=w.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 to(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:s,height:n}=e.orig;i.minX=-t._x*s,i.maxX=i.minX+s,i.minY=-t._y*n,i.maxY=i.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}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 i;typeof t=="object"?(e=(i=t.height)!=null?i: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 qT=new ot;function ki(r,t,e){const i=qT;r.measurable=!0,Sr(r,e,i),t.addBoundsMask(i),r.measurable=!1}function $i(r,t,e){const i=Vt.get();r.measurable=!0;const s=ct.get().identity(),n=qh(r,e,s);wi(r,i,n),r.measurable=!1,t.addBoundsMask(i),ct.return(s),Vt.return(i)}function qh(r,t,e){return r&&r!==t&&(qh(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class eo{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 Lt),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||ki(this.mask,t,e)}addLocalBounds(t,e){$i(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof Lt}}eo.extension=T.MaskEffect;class ro{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"}}ro.extension=T.MaskEffect;class io{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){ki(this.mask,t,e)}addLocalBounds(t,e){$i(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof q}}io.extension=T.MaskEffect;class qt extends Q{constructor(t){t.resource||(t.resource=L.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,i=this._resolution){const s=super.resize(t,e,i);return s&&this.resizeCanvas(),s}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"))}}qt.extension=T.TextureSource;class le extends Q{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}}le.extension=T.TextureSource;let so;async function no(){return so!=null||(so=(async()=>{var r;const t=L.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 i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const s=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,s),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(s),t.deleteTexture(i),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),so}var ZT=Object.defineProperty,QT=Object.defineProperties,JT=Object.getOwnPropertyDescriptors,Zh=Object.getOwnPropertySymbols,t1=Object.prototype.hasOwnProperty,e1=Object.prototype.propertyIsEnumerable,Qh=(r,t,e)=>t in r?ZT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,oo=(r,t)=>{for(var e in t||(t={}))t1.call(t,e)&&Qh(r,e,t[e]);if(Zh)for(var e of Zh(t))e1.call(t,e)&&Qh(r,e,t[e]);return r},r1=(r,t)=>QT(r,JT(t));const Li=class jx extends Q{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=oo(oo({},jx.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=at.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 no(),this._load=new Promise((i,s)=>{this.isValid?i(this):(this._resolve=i,this._reject=s,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&&(at.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||(at.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(at.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Li.extension=T.TextureSource,Li.defaultOptions=r1(oo({},Q.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),Li.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let He=Li,i1=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 i=Dt(t);let s;for(let l=0;l<this.parsers.length;l++){const u=this.parsers[l];if(u.test(e)){s=u.getCacheableAssets(i,e);break}}const n=new Map(Object.entries(s||{}));s||i.forEach(l=>{n.set(l,e)});const o=[...n.keys()],a={cacheKeys:o,keys:i};i.forEach(l=>{this._cacheMap.set(l,a)}),o.forEach(l=>{const u=s?s[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(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}};const V=new i1,ao=[];F.handleByList(T.TextureSource,ao);function s1(r={}){return lo(r)}function lo(r={}){const t=r&&r.resource,e=t?r.resource:r,i=t?r:{resource:r};for(let s=0;s<ao.length;s++){const n=ao[s];if(n.test(e))return new n(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function Jh(r={},t=!1){const e=r&&r.resource,i=e?r.resource:r,s=e?r:{resource:r};if(!t&&V.has(i))return V.get(i);const n=new w({source:lo(s)});return n.on("destroy",()=>{V.has(i)&&V.remove(i)}),t||V.set(i,n),n}function td(r,t=!1){return typeof r=="string"?V.get(r):r instanceof Q?new w({source:r}):Jh(r,t)}w.from=td,Q.from=lo,F.add(eo,ro,io,He,le,qt,Ci);class Zt{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const s=t[i];this.setResource(s,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var i,s;const n=this.resources[e];t!==n&&(n&&((i=t.off)==null||i.call(t,"change",this.onResourceChange,this)),(s=t.on)==null||s.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t,e){const i=this.resources;for(const s in i)i[s]._gcLastUsed=t,i[s]._touched=e}destroy(){var t;const e=this.resources;for(const i in e){const s=e[i];(t=s==null?void 0:s.off)==null||t.call(s,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}const ed={};function Ni(r,t,e){let i=2166136261;for(let s=0;s<t;s++)i^=r[s].uid,i=Math.imul(i,16777619),i>>>=0;return ed[i]||n1(r,t,i,e)}function n1(r,t,e,i){const s={};let n=0;for(let a=0;a<i;a++){const l=a<t?r[a]:w.EMPTY.source;s[n++]=l.source,s[n++]=l.style}const o=new Zt(s);return ed[e]=o,o}class Ae{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const rd=new Set,uo="8.0.0",o1="8.3.4",je={quiet:!1,noColor:!1},Mr=(r,t,e=3)=>{if(je.quiet||rd.has(t))return;let i=new Error().stack;const s=`${t}
Deprecated since v${r}`,n=typeof console.groupCollapsed=="function"&&!je.noColor;typeof i=="undefined"?console.warn("PixiJS Deprecation Warning: ",s):(i=i.split(`
`).splice(e).join(`
`),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",s),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",s),console.warn(i))),rd.add(t)};Object.defineProperties(Mr,{quiet:{get:()=>je.quiet,set:r=>{je.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>je.noColor,set:r=>{je.noColor=r},enumerable:!0,configurable:!1}});function Xi(r,t){const e=r.byteLength/8|0,i=new Float64Array(r,0,e);new Float64Array(t,0,e).set(i);const s=r.byteLength-e*8;if(s>0){const n=new Uint8Array(r,e*8,s);new Uint8Array(t,e*8,s).set(n)}}const id={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var rt=(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))(rt||{});function ze(r,t){return t.alphaMode==="no-premultiply-alpha"&&id[r]||r}let Or;function co(){return(!Or||Or!=null&&Or.isContextLost())&&(Or=L.get().createCanvas().getContext("webgl",{})),Or}const a1=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
`);function l1(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function ho(r,t){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const i=a1.replace(/%forloop%/gi,l1(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}}finally{t.deleteShader(e)}return r}let Ve=null;function sd(){var r;if(Ve)return Ve;const t=co();return Ve=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Ve=ho(Ve,t),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),Ve}class nd{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}var u1=Object.defineProperty,od=Object.getOwnPropertySymbols,c1=Object.prototype.hasOwnProperty,h1=Object.prototype.propertyIsEnumerable,ad=(r,t,e)=>t in r?u1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ld=(r,t)=>{for(var e in t||(t={}))c1.call(t,e)&&ad(r,e,t[e]);if(od)for(var e of od(t))h1.call(t,e)&&ad(r,e,t[e]);return r};class ud{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new nd,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 Hi=0;ge.register({clear:()=>{if(Gr.length>0)for(const r of Gr)r&&r.destroy();Gr.length=0,Hi=0}});function cd(){return Hi>0?Gr[--Hi]:new ud}function hd(r){Gr[Hi++]=r}let Br=0;const dd=class zx{constructor(t){this.uid=Y("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t=ld(ld({},zx.defaultOptions),t),t.maxTextures||(Mr("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=sd());const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:s}=t;this.attributeBuffer=new Ae(i*4),this.indexBuffer=new Uint16Array(s),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)hd(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const i=t._batch.textures.ids[e._source.uid];return!i&&i!==0?!1:(t._textureId=i,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let i=cd(),s=i.textures;s.clear();const n=e[this.elementStart];let o=ze(n.blendMode,n.texture._source),a=n.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const l=this.attributeBuffer.float32View,u=this.attributeBuffer.uint32View,c=this.indexBuffer;let h=this._batchIndexSize,p=this._batchIndexStart,f="startBatch";const m=this.maxTextures;for(let _=this.elementStart;_<this.elementSize;++_){const g=e[_];e[_]=null;const b=g.texture._source,y=ze(g.blendMode,b),v=o!==y||a!==g.topology;if(b._batchTick===Br&&!v){g._textureId=b._textureBindLocation,h+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,l,u,g._attributeStart,g._textureId),this.packQuadIndex(c,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,l,u,g._attributeStart,g._textureId),this.packIndex(g,c,g._indexStart,g._attributeStart/this.vertexSize)),g._batch=i;continue}b._batchTick=Br,(s.count>=m||v)&&(this._finishBatch(i,p,h-p,s,o,a,t,f),f="renderBatch",p=h,o=y,a=g.topology,i=cd(),s=i.textures,s.clear(),++Br),g._textureId=b._textureBindLocation=s.count,s.ids[b.uid]=s.count,s.textures[s.count++]=b,g._batch=i,h+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,l,u,g._attributeStart,g._textureId),this.packQuadIndex(c,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,l,u,g._attributeStart,g._textureId),this.packIndex(g,c,g._indexStart,g._attributeStart/this.vertexSize))}s.count>0&&(this._finishBatch(i,p,h-p,s,o,a,t,f),p=h,++Br),this.elementStart=this.elementSize,this._batchIndexStart=p,this._batchIndexSize=h}_finishBatch(t,e,i,s,n,o,a,l){t.gpuBindGroup=null,t.bindGroup=null,t.action=l,t.batcher=this,t.textures=s,t.blendMode=n,t.topology=o,t.start=e,t.size=i,++Br,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new Ae(e);Xi(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const s=i>65535?new Uint32Array(i):new Uint16Array(i);if(s.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)s[n]=e[n];else Xi(e.buffer,s.buffer);this.indexBuffer=s}packQuadIndex(t,e,i){t[e]=i+0,t[e+1]=i+1,t[e+2]=i+2,t[e+3]=i+0,t[e+4]=i+2,t[e+5]=i+3}packIndex(t,e,i,s){const n=t.indices,o=t.indexSize,a=t.indexOffset,l=t.attributeOffset;for(let u=0;u<o;u++)e[i++]=s+n[u+a]-l}destroy(t={}){var e;if(this.batches!==null){for(let i=0;i<this.batchIndex;i++)hd(this.batches[i]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,t.shader&&((e=this.shader)==null||e.destroy(),this.shader=null);for(let i=0;i<this._elements.length;i++)this._elements[i]&&(this._elements[i]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};dd.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let pd=dd;var X=(r=>(r[r.MAP_READ=1]="MAP_READ",r[r.MAP_WRITE=2]="MAP_WRITE",r[r.COPY_SRC=4]="COPY_SRC",r[r.COPY_DST=8]="COPY_DST",r[r.INDEX=16]="INDEX",r[r.VERTEX=32]="VERTEX",r[r.UNIFORM=64]="UNIFORM",r[r.STORAGE=128]="STORAGE",r[r.INDIRECT=256]="INDIRECT",r[r.QUERY_RESOLVE=512]="QUERY_RESOLVE",r[r.STATIC=1024]="STATIC",r))(X||{});class bt extends gt{constructor(t){let{data:e,size:i}=t;const{usage:s,label:n,shrinkToFit:o}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=Y("buffer"),this._resourceType="buffer",this._resourceId=Y("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i!=null||(i=e==null?void 0:e.byteLength);const a=!!e;this.descriptor={size:i,usage:s,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&X.STATIC)}set static(t){t?this.descriptor.usage|=X.STATIC:this.descriptor.usage&=~X.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const s=this._data;if(this._data=t,this._dataInt32=null,!s||s.length!==t.length){!this.shrinkToFit&&s&&t.byteLength<s.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=Y("resource"),this.emit("change",this));return}i&&this.emit("update",this)}update(t){this._updateSize=t!=null?t:this._updateSize,this._updateID++,this.emit("update",this)}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function po(r,t){if(!(r instanceof bt)){let e=t?X.INDEX:X.VERTEX;r instanceof Array&&(t?(r=new Uint32Array(r),e=X.INDEX|X.COPY_DST):(r=new Float32Array(r),e=X.VERTEX|X.COPY_DST)),r=new bt({data:r,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return r}function fd(r,t,e){const i=r.getAttribute(t);if(!i)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const s=i.buffer.data;let n=1/0,o=1/0,a=-1/0,l=-1/0;const u=s.BYTES_PER_ELEMENT,c=(i.offset||0)/u,h=(i.stride||2*4)/u;for(let p=c;p<s.length;p+=h){const f=s[p],m=s[p+1];f>a&&(a=f),m>l&&(l=m),f<n&&(n=f),m<o&&(o=m)}return e.minX=n,e.minY=o,e.maxX=a,e.maxY=l,e}function d1(r){return(r instanceof bt||Array.isArray(r)||r.BYTES_PER_ELEMENT)&&(r={buffer:r}),r.buffer=po(r.buffer,!1),r}class Ee extends gt{constructor(t={}){var e;super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=Y("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new ot,this._boundsDirty=!0;const{attributes:i,indexBuffer:s,topology:n}=t;if(this.buffers=[],this.attributes={},i)for(const o in i)this.addAttribute(o,i[o]);this.instanceCount=(e=t.instanceCount)!=null?e:1,s&&this.addIndex(s),this.topology=n||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){const i=d1(e);this.buffers.indexOf(i.buffer)===-1&&(this.buffers.push(i.buffer),i.buffer.on("update",this.onBufferUpdate,this),i.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=i}addIndex(t){this.indexBuffer=po(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,fd(this,"aPosition",this._bounds)):this._bounds}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(i=>i.destroy()),this.unload(),(e=this.indexBuffer)==null||e.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const p1=new Float32Array(1),f1=new Uint32Array(1);class md extends Ee{constructor(){const t=new bt({data:p1,label:"attribute-batch-buffer",usage:X.VERTEX|X.COPY_DST,shrinkToFit:!1}),e=new bt({data:f1,label:"index-batch-buffer",usage:X.INDEX|X.COPY_DST,shrinkToFit:!1}),i=6*4;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:i,offset:0},aUV:{buffer:t,format:"float32x2",stride:i,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:i,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:i,offset:20}},indexBuffer:e})}}const fo=Object.create(null),gd=Object.create(null);function We(r,t){let e=gd[r];return e===void 0&&(fo[t]===void 0&&(fo[t]=1),gd[r]=e=fo[t]++),e}let ji;function _d(){if(!ji){ji="mediump";const r=co();r&&r.getShaderPrecisionFormat&&(ji=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return ji}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 i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let s=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return s==="highp"&&i!=="highp"&&(s="mediump"),`precision ${s} float;
${r}`}else if(i!=="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 m1={},g1={};function xd(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?m1:g1;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`}
${r}`}function Td(r,t){return t?r.replace("#version 300 es",""):r}var _1=Object.defineProperty,Sd=Object.getOwnPropertySymbols,b1=Object.prototype.hasOwnProperty,v1=Object.prototype.propertyIsEnumerable,Ad=(r,t,e)=>t in r?_1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ed=(r,t)=>{for(var e in t||(t={}))b1.call(t,e)&&Ad(r,e,t[e]);if(Sd)for(var e of Sd(t))v1.call(t,e)&&Ad(r,e,t[e]);return r};const mo={stripVersion:Td,ensurePrecision:vd,addProgramDefines:bd,setProgramName:xd,insertVersion:yd},Ir=Object.create(null),Pd=class Yu{constructor(t){t=Ed(Ed({},Yu.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:_d()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let s=t.fragment,n=t.vertex;Object.keys(mo).forEach(o=>{const a=i[o];s=mo[o](s,a,!0),n=mo[o](n,a,!1)}),this.fragment=s,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=We(`${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,Ir[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Ir[e]||(Ir[e]=new Yu(t),Ir[e]._cacheKey=e),Ir[e]}};Pd.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let vt=Pd;const wd={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 se(r){var t;return(t=wd[r])!=null?t:wd.float32}const y1={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"};function Rd({source:r,entryPoint:t}){var e;const i={},s=r.indexOf(`fn ${t}`);if(s!==-1){const n=r.indexOf("->",s);if(n!==-1){const o=r.substring(s,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=y1[l[3]])!=null?e:"float32";i[l[2]]={location:parseInt(l[1],10),format:u,stride:se(u).stride,offset:0,instance:!1,start:0}}}}return i}function zi(r){var t,e,i;const s=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,o=/@binding\((\d+)\)/,a=/var(<[^>]+>)? (\w+)/,l=/:\s*(\w+)/,u=/struct\s+(\w+)\s*{([^}]+)}/g,c=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,p=(t=r.match(s))==null?void 0:t.map(m=>({group:parseInt(m.match(n)[1],10),binding:parseInt(m.match(o)[1],10),name:m.match(a)[2],isUniform:m.match(a)[1]==="<uniform>",type:m.match(l)[1]}));if(!p)return{groups:[],structs:[]};const f=(i=(e=r.match(u))==null?void 0:e.map(m=>{const _=m.match(h)[1],g=m.match(c).reduce((b,y)=>{const[v,x]=y.split(":");return b[v.trim()]=x.trim(),b},{});return g?{name:_,members:g}:null}).filter(({name:m})=>p.some(_=>_.type===m)))!=null?i:[];return{groups:p,structs:f}}var Ye=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(Ye||{});function Cd({groups:r}){const t=[];for(let e=0;e<r.length;e++){const i=r[e];t[i.group]||(t[i.group]=[]),i.isUniform?t[i.group].push({binding:i.binding,visibility:Ye.VERTEX|Ye.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:Ye.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"&&t[i.group].push({binding:i.binding,visibility:Ye.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return t}function Md({groups:r}){const t=[];for(let e=0;e<r.length;e++){const i=r[e];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding}return t}function Od(r,t){const e=new Set,i=new Set,s=[...r.structs,...t.structs].filter(o=>e.has(o.name)?!1:(e.add(o.name),!0)),n=[...r.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:s,groups:n}}const Fr=Object.create(null);class dt{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;var e,i;const{fragment:s,vertex:n,layout:o,gpuLayout:a,name:l}=t;if(this.name=l,this.fragment=s,this.vertex=n,s.source===n.source){const u=zi(s.source);this.structsAndGroups=u}else{const u=zi(n.source),c=zi(s.source);this.structsAndGroups=Od(u,c)}this.layout=o!=null?o:Md(this.structsAndGroups),this.gpuLayout=a!=null?a:Cd(this.structsAndGroups),this.autoAssignGlobalUniforms=((e=this.layout[0])==null?void 0:e.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((i=this.layout[1])==null?void 0:i.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=We(i,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=Rd(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 dt(t),Fr[e]._cacheKey=e),Fr[e]}}function go(r,t,e){if(r)for(const i in r){const s=i.toLocaleLowerCase(),n=t[s];if(n){let o=r[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}}}const x1=/\{\{(.*?)\}\}/g;function _o(r){var t,e;const i={};return((e=(t=r.match(x1))==null?void 0:t.map(s=>s.replace(/[{()}]/g,"")))!=null?e:[]).forEach(s=>{i[s]=[]}),i}function Gd(r,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function bo(r,t,e=!1){const i=[];Gd(t,i),r.forEach(a=>{a.header&&Gd(a.header,i)});const s=i;e&&s.sort();const n=s.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 i=/@out\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function T1(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function S1(r){const t=/@.*?\s+/g;return r.replace(t,"")}function Id(r,t){const e=[];Bd(t,e),r.forEach(l=>{l.header&&Bd(l.header,e)});let i=0;const s=e.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${i++}) ${l}`).join(`,
`),n=e.sort().map(l=>` var ${S1(l)};`).join(`
`),o=`return VSOutput(
${e.sort().map(l=>` ${T1(l)}`).join(`,
`)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
${s}
`),a=a.replace("{{start}}",`
${n}
`),a=a.replace("{{return}}",`
${o}
`),a}function vo(r,t){let e=r;for(const i in t){const s=t[i];s.join(`
`).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----//
${s.join(`
`)}
//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const Pe=Object.create(null),yo=new Map;let A1=0;function Fd({template:r,bits:t}){const e=Ud(r,t);if(Pe[e])return Pe[e];const{vertex:i,fragment:s}=E1(r,t);return Pe[e]=kd(i,s,t),Pe[e]}function Dd({template:r,bits:t}){const e=Ud(r,t);return Pe[e]||(Pe[e]=kd(r.vertex,r.fragment,t)),Pe[e]}function E1(r,t){const e=t.map(o=>o.vertex).filter(o=>!!o),i=t.map(o=>o.fragment).filter(o=>!!o);let s=bo(e,r.vertex,!0);s=Id(e,s);const n=bo(i,r.fragment,!0);return{vertex:s,fragment:n}}function Ud(r,t){return t.map(e=>(yo.has(e)||yo.set(e,A1++),yo.get(e))).sort((e,i)=>e-i).join("-")+r.vertex+r.fragment}function kd(r,t,e){const i=_o(r),s=_o(t);return e.forEach(n=>{go(n.vertex,i,n.name),go(n.fragment,s,n.name)}),{vertex:vo(r,i),fragment:vo(t,s)}}const $d=`
@in aPosition: vec2<f32>;
@in aUV: vec2<f32>;
@out @builtin(position) vPosition: vec4<f32>;
@out vUV : vec2<f32>;
@out vColor : vec4<f32>;
{{header}}
struct VSOutput {
{{struct}}
};
@vertex
fn main( {{in}} ) -> VSOutput {
var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
var modelMatrix = mat3x3<f32>(
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<f32>(1., 1., 1., 1.);
{{main}}
vUV = uv;
var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
vColor *= globalUniforms.uWorldColorAlpha;
{{end}}
{{return}}
};
`,Ld=`
@in vUV : vec2<f32>;
@in vColor : vec4<f32>;
{{header}}
@fragment
fn main(
{{in}}
) -> @location(0) vec4<f32> {
{{start}}
var outColor:vec4<f32>;
{{main}}
var finalColor:vec4<f32> = outColor * vColor;
{{end}}
return finalColor;
};
`,Nd=`
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}}
}
`,Xd=`
in vec4 vColor;
in vec2 vUV;
out vec4 finalColor;
{{header}}
void main(void) {
{{start}}
vec4 outColor;
{{main}}
finalColor = outColor * vColor;
{{end}}
}
`,Hd={name:"global-uniforms-bit",vertex:{header:`
struct GlobalUniforms {
uProjectionMatrix:mat3x3<f32>,
uWorldTransformMatrix:mat3x3<f32>,
uWorldColorAlpha: vec4<f32>,
uResolution: vec2<f32>,
}
@group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
`}},P1={name:"global-uniforms-ubo-bit",vertex:{header:`
uniform globalUniforms {
mat3 uProjectionMatrix;
mat3 uWorldTransformMatrix;
vec4 uWorldColorAlpha;
vec2 uResolution;
};
`}},jd={name:"global-uniforms-bit",vertex:{header:`
uniform mat3 uProjectionMatrix;
uniform mat3 uWorldTransformMatrix;
uniform vec4 uWorldColorAlpha;
uniform vec2 uResolution;
`}};var w1=Object.defineProperty,zd=Object.getOwnPropertySymbols,R1=Object.prototype.hasOwnProperty,C1=Object.prototype.propertyIsEnumerable,Vd=(r,t,e)=>t in r?w1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,M1=(r,t)=>{for(var e in t||(t={}))R1.call(t,e)&&Vd(r,e,t[e]);if(zd)for(var e of zd(t))C1.call(t,e)&&Vd(r,e,t[e]);return r};function Ke({bits:r,name:t}){const e=Fd({template:{fragment:Ld,vertex:$d},bits:[Hd,...r]});return dt.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function qe({bits:r,name:t}){return new vt(M1({name:t},Dd({template:{vertex:Nd,fragment:Xd},bits:[jd,...r]})))}const Vi={name:"color-bit",vertex:{header:`
@in aColor: vec4<f32>;
`,main:`
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
`}},Wi={name:"color-bit",vertex:{header:`
in vec4 aColor;
`,main:`
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
`}},xo={};function O1(r){const t=[];if(r===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let i=0;i<r;i++)t.push(`@group(1) @binding(${e++}) var textureSource${i+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(`
`)}function G1(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<r;e++)e===r-1?t.push(" default:{"):t.push(` case ${e}:{`),t.push(` outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push(" break;}");t.push("}")}return t.join(`
`)}function Yi(r){return xo[r]||(xo[r]={name:"texture-batch-bit",vertex:{header:`
@in aTextureIdAndRound: vec2<u32>;
@out @interpolate(flat) vTextureId : u32;
`,main:`
vTextureId = aTextureIdAndRound.y;
`,end:`
if(aTextureIdAndRound.x == 1)
{
vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
}
`},fragment:{header:`
@in @interpolate(flat) vTextureId: u32;
${O1(r)}
`,main:`
var uvDx = dpdx(vUV);
var uvDy = dpdy(vUV);
${G1(r)}
`}}),xo[r]}const To={};function B1(r){const t=[];for(let e=0;e<r;e++)e>0&&t.push("else"),e<r-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
`)}function Ki(r){return To[r]||(To[r]={name:"texture-batch-bit",vertex:{header:`
in vec2 aTextureIdAndRound;
out float vTextureId;
`,main:`
vTextureId = aTextureIdAndRound.y;
`,end:`
if(aTextureIdAndRound.x == 1.)
{
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
}
`},fragment:{header:`
in float vTextureId;
uniform sampler2D uTextures[${r}];
`,main:`
${B1(r)}
`}}),To[r]}const Ze={name:"round-pixels-bit",vertex:{header:`
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
{
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
}
`}},Qe={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;
}
`}},So=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],Wd=So.reduce((r,t)=>(r[t]=!0,r),{});function Yd(r,t){switch(r){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var I1=Object.defineProperty,Kd=Object.getOwnPropertySymbols,F1=Object.prototype.hasOwnProperty,D1=Object.prototype.propertyIsEnumerable,qd=(r,t,e)=>t in r?I1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Zd=(r,t)=>{for(var e in t||(t={}))F1.call(t,e)&&qd(r,e,t[e]);if(Kd)for(var e of Kd(t))D1.call(t,e)&&qd(r,e,t[e]);return r};const Qd=class Vx{constructor(t,e){this._touched=0,this.uid=Y("uniform"),this._resourceType="uniformGroup",this._resourceId=Y("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1;var i,s;e=Zd(Zd({},Vx.defaultOptions),e),this.uniformStructures=t;const n={};for(const o in t){const a=t[o];if(a.name=o,a.size=(i=a.size)!=null?i:1,!Wd[a.type]){const l=a.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(l){const[,u,c]=l;throw new Error(`Uniform type ${a.type} is not supported. Use type: '${u}', size: ${c} instead.`)}throw new Error(`Uniform type ${a.type} is not supported. Supported uniform types are: ${So.join(", ")}`)}(s=a.value)!=null||(a.value=Yd(a.type,a.size)),n[o]=a.value}this.uniforms=n,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=We(Object.keys(n).map(o=>`${o}-${t[o].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Qd.defaultOptions={ubo:!1,isStatic:!1};let nt=Qd;const Jd={};function qi(r){let t=Jd[r];if(t)return t;const e=new Int32Array(r);for(let i=0;i<r;i++)e[i]=i;return t=Jd[r]=new nt({uTextures:{value:e,type:"i32",size:r}},{isStatic:!0}),t}var yt=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.BOTH=3]="BOTH",r))(yt||{}),U1=Object.defineProperty,Zi=Object.getOwnPropertySymbols,tp=Object.prototype.hasOwnProperty,ep=Object.prototype.propertyIsEnumerable,rp=(r,t,e)=>t in r?U1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,k1=(r,t)=>{for(var e in t||(t={}))tp.call(t,e)&&rp(r,e,t[e]);if(Zi)for(var e of Zi(t))ep.call(t,e)&&rp(r,e,t[e]);return r},$1=(r,t)=>{var e={};for(var i in r)tp.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Zi)for(var i of Zi(r))t.indexOf(i)<0&&ep.call(r,i)&&(e[i]=r[i]);return e};class wt extends gt{constructor(t){super(),this.uid=Y("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:i,groups:s,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=i,o===void 0&&(o=0,e&&(o|=yt.WEBGPU),i&&(o|=yt.WEBGL)),this.compatibleRenderers=o;const l={};if(!n&&!s&&(n={}),n&&s)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&s&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&s&&a)for(const u in a)for(const c in a[u]){const h=a[u][c];l[h]={group:u,binding:c,name:h}}else if(e&&s&&!a){const u=e.structsAndGroups.groups;a={},u.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,l[c.name]=c})}else if(n){s={},a={},e&&e.structsAndGroups.groups.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,l[c.name]=c});let u=0;for(const c in n)l[c]||(s[99]||(s[99]=new Zt,this._ownedBindGroups.push(s[99])),l[c]={group:99,binding:u,name:c},a[99]=a[99]||{},a[99][u]=c,u++);for(const c in n){const h=c;let p=n[c];!p.source&&!p._resourceType&&(p=new nt(p));const f=l[h];f&&(s[f.group]||(s[f.group]=new Zt,this._ownedBindGroups.push(s[f.group])),s[f.group].setResource(p,f.binding))}}this.groups=s,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(s,l)}addResource(t,e,i){var s,n;(s=this._uniformBindMap)[e]||(s[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new Zt,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const s in e){const n=e[s];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return i}destroy(t=!1){var e,i;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(s=>{s.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const e=t,{gpu:i,gl:s}=e,n=$1(e,["gpu","gl"]);let o,a;return i&&(o=dt.from(i)),s&&(a=vt.from(s)),new wt(k1({gpuProgram:o,glProgram:a},n))}}class Ao extends wt{constructor(t){const e=qe({name:"batch",bits:[Wi,Ki(t),Qe]}),i=Ke({name:"batch",bits:[Vi,Yi(t),Ze]});super({glProgram:e,gpuProgram:i,resources:{batchSamplers:qi(t)}}),this.maxTextures=t}}let Dr=null;const ip=class Wx extends pd{constructor(t){super(t),this.geometry=new md,this.name=Wx.extension.name,this.vertexSize=6,Dr!=null||(Dr=new Ao(t.maxTextures)),this.shader=Dr}packAttributes(t,e,i,s,n){const o=n<<16|t.roundPixels&65535,a=t.transform,l=a.a,u=a.b,c=a.c,h=a.d,p=a.tx,f=a.ty,{positions:m,uvs:_}=t,g=t.color,b=t.attributeOffset,y=b+t.attributeSize;for(let v=b;v<y;v++){const x=v*2,A=m[x],S=m[x+1];e[s++]=l*A+c*S+p,e[s++]=h*S+u*A+f,e[s++]=_[x],e[s++]=_[x+1],i[s++]=g,i[s++]=o}}packQuadAttributes(t,e,i,s,n){const o=t.texture,a=t.transform,l=a.a,u=a.b,c=a.c,h=a.d,p=a.tx,f=a.ty,m=t.bounds,_=m.maxX,g=m.minX,b=m.maxY,y=m.minY,v=o.uvs,x=t.color,A=n<<16|t.roundPixels&65535;e[s+0]=l*g+c*y+p,e[s+1]=h*y+u*g+f,e[s+2]=v.x0,e[s+3]=v.y0,i[s+4]=x,i[s+5]=A,e[s+6]=l*_+c*y+p,e[s+7]=h*y+u*_+f,e[s+8]=v.x1,e[s+9]=v.y1,i[s+10]=x,i[s+11]=A,e[s+12]=l*_+c*b+p,e[s+13]=h*b+u*_+f,e[s+14]=v.x2,e[s+15]=v.y2,i[s+16]=x,i[s+17]=A,e[s+18]=l*g+c*b+p,e[s+19]=h*b+u*g+f,e[s+20]=v.x3,e[s+21]=v.y3,i[s+22]=x,i[s+23]=A}_updateMaxTextures(t){this.shader.maxTextures!==t&&(Dr=new Ao(t),this.shader=Dr)}destroy(){this.shader=null,super.destroy()}};ip.extension={type:[T.Batcher],name:"default"};let Qi=ip;class xt{constructor(t){this.items=Object.create(null);const{renderer:e,type:i,onUnload:s,priority:n,name:o}=t;this._renderer=e,e.gc.addResourceHash(this,"items",i,n!=null?n:0),this._onUnload=s,this.name=o}add(t){return this.items[t.uid]?!1:(this.items[t.uid]=t,t.once("unload",this.remove,this),t._gcLastUsed=this._renderer.gc.now,!0)}remove(t,...e){var i;if(!this.items[t.uid])return;const s=t._gpuData[this._renderer.uid];s&&((i=this._onUnload)==null||i.call(this,t,...e),s.destroy(),t._gpuData[this._renderer.uid]=null,this.items[t.uid]=null)}removeAll(...t){Object.values(this.items).forEach(e=>e&&this.remove(e,...t))}destroy(...t){this.removeAll(...t),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function Eo(r,t,e,i,s,n,o,a=null){let l=0;e*=t,s*=n;const u=a.a,c=a.b,h=a.c,p=a.d,f=a.tx,m=a.ty;for(;l<o;){const _=r[e],g=r[e+1];i[s]=u*_+h*g+f,i[s+1]=c*_+p*g+m,s+=n,e+=t,l++}}function Po(r,t,e,i){let s=0;for(t*=e;s<i;)r[t]=0,r[t+1]=0,t+=e,s++}function Ji(r,t,e,i,s){const n=t.a,o=t.b,a=t.c,l=t.d,u=t.tx,c=t.ty;e||(e=0),i||(i=2),s||(s=r.length/i-e);let h=e*i;for(let p=0;p<s;p++){const f=r[h],m=r[h+1];r[h]=n*f+a*m+u,r[h+1]=o*f+l*m+c,h+=i}}const L1=new C;class ts{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,i=this.renderable;return i?Bn(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||L1}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 N1=Object.defineProperty,X1=Object.defineProperties,H1=Object.getOwnPropertyDescriptors,sp=Object.getOwnPropertySymbols,j1=Object.prototype.hasOwnProperty,z1=Object.prototype.propertyIsEnumerable,np=(r,t,e)=>t in r?N1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,es=(r,t)=>{for(var e in t||(t={}))j1.call(t,e)&&np(r,e,t[e]);if(sp)for(var e of sp(t))z1.call(t,e)&&np(r,e,t[e]);return r},rs=(r,t)=>X1(r,H1(t));const Je={extension:{type:T.ShapeBuilder,name:"circle"},build(r,t){let e,i,s,n,o,a;if(r.type==="circle"){const x=r;if(o=a=x.radius,o<=0)return!1;e=x.x,i=x.y,s=n=0}else if(r.type==="ellipse"){const x=r;if(o=x.halfWidth,a=x.halfHeight,o<=0||a<=0)return!1;e=x.x,i=x.y,s=n=0}else{const x=r,A=x.width/2,S=x.height/2;e=x.x+A,i=x.y+S,o=a=Math.max(0,Math.min(x.radius,Math.min(A,S))),s=A-o,n=S-a}if(s<0||n<0)return!1;const l=Math.ceil(2.3*Math.sqrt(o+a)),u=l*8+(s?4:0)+(n?4:0);if(u===0)return!1;if(l===0)return t[0]=t[6]=e+s,t[1]=t[3]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n,!0;let c=0,h=l*4+(s?2:0)+2,p=h,f=u,m=s+o,_=n,g=e+m,b=e-m,y=i+_;if(t[c++]=g,t[c++]=y,t[--h]=y,t[--h]=b,n){const x=i-_;t[p++]=b,t[p++]=x,t[--f]=x,t[--f]=g}for(let x=1;x<l;x++){const A=Math.PI/2*(x/l),S=s+Math.cos(A)*o,E=n+Math.sin(A)*a,M=e+S,O=e-S,P=i+E,R=i-E;t[c++]=M,t[c++]=P,t[--h]=P,t[--h]=O,t[p++]=O,t[p++]=R,t[--f]=R,t[--f]=M}m=s,_=n+a,g=e+m,b=e-m,y=i+_;const v=i-_;return t[c++]=g,t[c++]=y,t[--f]=v,t[--f]=g,s&&(t[c++]=b,t[c++]=y,t[--f]=v,t[--f]=b),!0},triangulate(r,t,e,i,s,n){if(r.length===0)return;let o=0,a=0;for(let c=0;c<r.length;c+=2)o+=r[c],a+=r[c+1];o/=r.length/2,a/=r.length/2;let l=i;t[l*e]=o,t[l*e+1]=a;const u=l++;for(let c=0;c<r.length;c+=2)t[l*e]=r[c],t[l*e+1]=r[c+1],c>0&&(s[n++]=l,s[n++]=u,s[n++]=l-1),l++;s[n++]=u+1,s[n++]=u,s[n++]=l-1}},op=rs(es({},Je),{extension:rs(es({},Je.extension),{name:"ellipse"})}),ap=rs(es({},Je),{extension:rs(es({},Je.extension),{name:"roundedRectangle"})}),wo=1e-4,Ro=1e-4;function lp(r){const t=r.length;if(t<6)return 1;let e=0;for(let i=0,s=r[t-2],n=r[t-1];i<t;i+=2){const o=r[i],a=r[i+1];e+=(o-s)*(a+n),s=o,n=a}return e<0?-1:1}function up(r,t,e,i,s,n,o,a){const l=r-e*s,u=t-i*s,c=r+e*n,h=t+i*n;let p,f;o?(p=i,f=-e):(p=-i,f=e);const m=l+p,_=u+f,g=c+p,b=h+f;return a.push(m,_),a.push(g,b),2}function we(r,t,e,i,s,n,o,a){const l=e-r,u=i-t;let c=Math.atan2(l,u),h=Math.atan2(s-r,n-t);a&&c<h?c+=Math.PI*2:!a&&c>h&&(h+=Math.PI*2);let p=c;const f=h-c,m=Math.abs(f),_=Math.sqrt(l*l+u*u),g=(15*m*Math.sqrt(_)/Math.PI>>0)+1,b=f/g;if(p+=b,a){o.push(r,t),o.push(e,i);for(let y=1,v=p;y<g;y++,v+=b)o.push(r,t),o.push(r+Math.sin(v)*_,t+Math.cos(v)*_);o.push(r,t),o.push(s,n)}else{o.push(e,i),o.push(r,t);for(let y=1,v=p;y<g;y++,v+=b)o.push(r+Math.sin(v)*_,t+Math.cos(v)*_),o.push(r,t);o.push(s,n),o.push(r,t)}return g*2}function cp(r,t,e,i,s,n){const o=wo;if(r.length===0)return;const a=t;let l=a.alignment;if(t.alignment!==.5){let K=lp(r);e&&(K*=-1),l=(l-.5)*K+.5}const u=new W(r[0],r[1]),c=new W(r[r.length-2],r[r.length-1]),h=i,p=Math.abs(u.x-c.x)<o&&Math.abs(u.y-c.y)<o;if(h){r=r.slice(),p&&(r.pop(),r.pop(),c.set(r[r.length-2],r[r.length-1]));const K=(u.x+c.x)*.5,me=(c.y+u.y)*.5;r.unshift(K,me),r.push(K,me)}const f=s,m=r.length/2;let _=r.length;const g=f.length/2,b=a.width/2,y=b*b,v=a.miterLimit*a.miterLimit;let x=r[0],A=r[1],S=r[2],E=r[3],M=0,O=0,P=-(A-E),R=x-S,U=0,k=0,B=Math.sqrt(P*P+R*R);P/=B,R/=B,P*=b,R*=b;const mt=l,I=(1-mt)*2,D=mt*2;h||(a.cap==="round"?_+=we(x-P*(I-D)*.5,A-R*(I-D)*.5,x-P*I,A-R*I,x+P*D,A+R*D,f,!0)+2:a.cap==="square"&&(_+=up(x,A,P,R,I,D,!0,f))),f.push(x-P*I,A-R*I),f.push(x+P*D,A+R*D);for(let K=1;K<m-1;++K){x=r[(K-1)*2],A=r[(K-1)*2+1],S=r[K*2],E=r[K*2+1],M=r[(K+1)*2],O=r[(K+1)*2+1],P=-(A-E),R=x-S,B=Math.sqrt(P*P+R*R),P/=B,R/=B,P*=b,R*=b,U=-(E-O),k=S-M,B=Math.sqrt(U*U+k*k),U/=B,k/=B,U*=b,k*=b;const me=S-x,gi=A-E,_i=S-M,bi=O-E,Ix=me*_i+gi*bi,_n=gi*_i-bi*me,vi=_n<0;if(Math.abs(_n)<.001*Math.abs(Ix)){f.push(S-P*I,E-R*I),f.push(S+P*D,E+R*D),Ix>=0&&(a.join==="round"?_+=we(S,E,S-P*I,E-R*I,S-U*I,E-k*I,f,!1)+4:_+=2,f.push(S-U*D,E-k*D),f.push(S+U*I,E+k*I));continue}const Fx=(-P+x)*(-R+E)-(-P+S)*(-R+A),Dx=(-U+M)*(-k+E)-(-U+S)*(-k+O),bn=(me*Dx-_i*Fx)/_n,vn=(bi*Fx-gi*Dx)/_n,Vu=(bn-S)*(bn-S)+(vn-E)*(vn-E),Ie=S+(bn-S)*I,Fe=E+(vn-E)*I,De=S-(bn-S)*D,Ue=E-(vn-E)*D,VM=Math.min(me*me+gi*gi,_i*_i+bi*bi),Ux=vi?I:D,WM=VM+Ux*Ux*y;Vu<=WM?a.join==="bevel"||Vu/y>v?(vi?(f.push(Ie,Fe),f.push(S+P*D,E+R*D),f.push(Ie,Fe),f.push(S+U*D,E+k*D)):(f.push(S-P*I,E-R*I),f.push(De,Ue),f.push(S-U*I,E-k*I),f.push(De,Ue)),_+=2):a.join==="round"?vi?(f.push(Ie,Fe),f.push(S+P*D,E+R*D),_+=we(S,E,S+P*D,E+R*D,S+U*D,E+k*D,f,!0)+4,f.push(Ie,Fe),f.push(S+U*D,E+k*D)):(f.push(S-P*I,E-R*I),f.push(De,Ue),_+=we(S,E,S-P*I,E-R*I,S-U*I,E-k*I,f,!1)+4,f.push(S-U*I,E-k*I),f.push(De,Ue)):(f.push(Ie,Fe),f.push(De,Ue)):(f.push(S-P*I,E-R*I),f.push(S+P*D,E+R*D),a.join==="round"?vi?_+=we(S,E,S+P*D,E+R*D,S+U*D,E+k*D,f,!0)+2:_+=we(S,E,S-P*I,E-R*I,S-U*I,E-k*I,f,!1)+2:a.join==="miter"&&Vu/y<=v&&(vi?(f.push(De,Ue),f.push(De,Ue)):(f.push(Ie,Fe),f.push(Ie,Fe)),_+=2),f.push(S-U*I,E-k*I),f.push(S+U*D,E+k*D),_+=2)}x=r[(m-2)*2],A=r[(m-2)*2+1],S=r[(m-1)*2],E=r[(m-1)*2+1],P=-(A-E),R=x-S,B=Math.sqrt(P*P+R*R),P/=B,R/=B,P*=b,R*=b,f.push(S-P*I,E-R*I),f.push(S+P*D,E+R*D),h||(a.cap==="round"?_+=we(S-P*(I-D)*.5,E-R*(I-D)*.5,S-P*I,E-R*I,S+P*D,E+R*D,f,!1)+2:a.cap==="square"&&(_+=up(S,E,P,R,I,D,!1,f)));const gn=Ro*Ro;for(let K=g;K<_+g-2;++K)x=f[K*2],A=f[K*2+1],S=f[(K+1)*2],E=f[(K+1)*2+1],M=f[(K+2)*2],O=f[(K+2)*2+1],!(Math.abs(x*(E-O)+S*(O-A)+M*(A-E))<gn)&&n.push(K,K+1,K+2)}function hp(r,t,e,i){const s=wo;if(r.length===0)return;const n=r[0],o=r[1],a=r[r.length-2],l=r[r.length-1],u=t||Math.abs(n-a)<s&&Math.abs(o-l)<s,c=e,h=r.length/2,p=c.length/2;for(let f=0;f<h;f++)c.push(r[f*2]),c.push(r[f*2+1]);for(let f=0;f<h-1;f++)i.push(p+f,p+f+1);u&&i.push(p+h-1,p)}function dp(r,t,e=2){const i=t&&t.length,s=i?t[0]*e:r.length;let n=pp(r,0,s,e,!0);const o=[];if(!n||n.next===n.prev)return o;let a,l,u;if(i&&(n=q1(r,t,n,e)),r.length>80*e){a=r[0],l=r[1];let c=a,h=l;for(let p=e;p<s;p+=e){const f=r[p],m=r[p+1];f<a&&(a=f),m<l&&(l=m),f>c&&(c=f),m>h&&(h=m)}u=Math.max(c-a,h-l),u=u!==0?32767/u:0}return Ur(n,o,e,a,l,u,0),o}function pp(r,t,e,i,s){let n;if(s===Oo(r,t,e,i)>0)for(let o=t;o<e;o+=i)n=_p(o/i|0,r[o],r[o+1],n);else for(let o=e-i;o>=t;o-=i)n=_p(o/i|0,r[o],r[o+1],n);return n&&tr(n,n.next)&&(Lr(n),n=n.next),n}function Re(r,t){if(!r)return r;t||(t=r);let e=r,i;do if(i=!1,!e.steiner&&(tr(e,e.next)||J(e.prev,e,e.next)===0)){if(Lr(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Ur(r,t,e,i,s,n,o){if(!r)return;!o&&n&&eS(r,i,s,n);let a=r;for(;r.prev!==r.next;){const l=r.prev,u=r.next;if(n?W1(r,i,s,n):V1(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=Y1(Re(r),t),Ur(r,t,e,i,s,n,2)):o===2&&K1(r,t,e,i,s,n):Ur(Re(r),t,e,i,s,n,1);break}}}function V1(r){const t=r.prev,e=r,i=r.next;if(J(t,e,i)>=0)return!1;const s=t.x,n=e.x,o=i.x,a=t.y,l=e.y,u=i.y,c=Math.min(s,n,o),h=Math.min(a,l,u),p=Math.max(s,n,o),f=Math.max(a,l,u);let m=i.next;for(;m!==t;){if(m.x>=c&&m.x<=p&&m.y>=h&&m.y<=f&&kr(s,a,n,l,o,u,m.x,m.y)&&J(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function W1(r,t,e,i){const s=r.prev,n=r,o=r.next;if(J(s,n,o)>=0)return!1;const a=s.x,l=n.x,u=o.x,c=s.y,h=n.y,p=o.y,f=Math.min(a,l,u),m=Math.min(c,h,p),_=Math.max(a,l,u),g=Math.max(c,h,p),b=Co(f,m,t,e,i),y=Co(_,g,t,e,i);let v=r.prevZ,x=r.nextZ;for(;v&&v.z>=b&&x&&x.z<=y;){if(v.x>=f&&v.x<=_&&v.y>=m&&v.y<=g&&v!==s&&v!==o&&kr(a,c,l,h,u,p,v.x,v.y)&&J(v.prev,v,v.next)>=0||(v=v.prevZ,x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==s&&x!==o&&kr(a,c,l,h,u,p,x.x,x.y)&&J(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;v&&v.z>=b;){if(v.x>=f&&v.x<=_&&v.y>=m&&v.y<=g&&v!==s&&v!==o&&kr(a,c,l,h,u,p,v.x,v.y)&&J(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==s&&x!==o&&kr(a,c,l,h,u,p,x.x,x.y)&&J(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Y1(r,t){let e=r;do{const i=e.prev,s=e.next.next;!tr(i,s)&&mp(i,e,e.next,s)&&$r(i,s)&&$r(s,i)&&(t.push(i.i,e.i,s.i),Lr(e),Lr(e.next),e=r=s),e=e.next}while(e!==r);return Re(e)}function K1(r,t,e,i,s,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&sS(o,a)){let l=gp(o,a);o=Re(o,o.next),l=Re(l,l.next),Ur(o,t,e,i,s,n,0),Ur(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function q1(r,t,e,i){const s=[];for(let n=0,o=t.length;n<o;n++){const a=t[n]*i,l=n<o-1?t[n+1]*i:r.length,u=pp(r,a,l,i,!1);u===u.next&&(u.steiner=!0),s.push(iS(u))}s.sort(Z1);for(let n=0;n<s.length;n++)e=Q1(s[n],e);return e}function Z1(r,t){let e=r.x-t.x;if(e===0&&(e=r.y-t.y,e===0)){const i=(r.next.y-r.y)/(r.next.x-r.x),s=(t.next.y-t.y)/(t.next.x-t.x);e=i-s}return e}function Q1(r,t){const e=J1(r,t);if(!e)return t;const i=gp(e,r);return Re(i,i.next),Re(e,e.next)}function J1(r,t){let e=t;const i=r.x,s=r.y;let n=-1/0,o;if(tr(r,e))return e;do{if(tr(r,e.next))return e.next;if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){const h=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=i&&h>n&&(n=h,o=e.x<e.next.x?e:e.next,h===i))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,l=o.x,u=o.y;let c=1/0;e=o;do{if(i>=e.x&&e.x>=l&&i!==e.x&&fp(s<u?i:n,s,l,u,s<u?n:i,s,e.x,e.y)){const h=Math.abs(s-e.y)/(i-e.x);$r(e,r)&&(h<c||h===c&&(e.x>o.x||e.x===o.x&&tS(o,e)))&&(o=e,c=h)}e=e.next}while(e!==a);return o}function tS(r,t){return J(r.prev,r,t.prev)<0&&J(t.next,r,r.next)<0}function eS(r,t,e,i){let s=r;do s.z===0&&(s.z=Co(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,rS(s)}function rS(r){let t,e=1;do{let i=r,s;r=null;let n=null;for(t=0;i;){t++;let o=i,a=0;for(let u=0;u<e&&(a++,o=o.nextZ,!!o);u++);let l=e;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||i.z<=o.z)?(s=i,i=i.nextZ,a--):(s=o,o=o.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;i=o}n.nextZ=null,e*=2}while(t>1);return r}function Co(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|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 iS(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function fp(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function kr(r,t,e,i,s,n,o,a){return!(r===o&&t===a)&&fp(r,t,e,i,s,n,o,a)}function sS(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!nS(r,t)&&($r(r,t)&&$r(t,r)&&oS(r,t)&&(J(r.prev,r,t.prev)||J(r,t.prev,t))||tr(r,t)&&J(r.prev,r,r.next)>0&&J(t.prev,t,t.next)>0)}function J(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function tr(r,t){return r.x===t.x&&r.y===t.y}function mp(r,t,e,i){const s=ss(J(r,t,e)),n=ss(J(r,t,i)),o=ss(J(e,i,r)),a=ss(J(e,i,t));return!!(s!==n&&o!==a||s===0&&is(r,e,t)||n===0&&is(r,i,t)||o===0&&is(e,r,i)||a===0&&is(e,t,i))}function is(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 ss(r){return r>0?1:r<0?-1:0}function nS(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&&mp(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function $r(r,t){return J(r.prev,r,r.next)<0?J(r,t,r.next)>=0&&J(r,r.prev,t)>=0:J(r,t,r.prev)<0||J(r,r.next,t)<0}function oS(r,t){let e=r,i=!1;const s=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function gp(r,t){const e=Mo(r.i,r.x,r.y),i=Mo(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function _p(r,t,e,i){const s=Mo(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}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 Mo(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function nO(r,t,e,i){const s=t&&t.length,n=s?t[0]*e:r.length;let o=Math.abs(Oo(r,0,n,e));if(s)for(let l=0,u=t.length;l<u;l++){const c=t[l]*e,h=l<u-1?t[l+1]*e:r.length;o-=Math.abs(Oo(r,c,h,e))}let a=0;for(let l=0;l<i.length;l+=3){const u=i[l]*e,c=i[l+1]*e,h=i[l+2]*e;a+=Math.abs((r[u]-r[h])*(r[c+1]-r[u+1])-(r[u]-r[c])*(r[h+1]-r[u+1]))}return o===0&&a===0?0:Math.abs((a-o)/o)}function Oo(r,t,e,i){let s=0;for(let n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}function oO(r){const t=[],e=[],i=r[0][0].length;let s=0,n=0;for(const o of r){for(const a of o)for(let l=0;l<i;l++)t.push(a[l]);n&&(s+=n,e.push(s)),n=o.length}return{vertices:t,holes:e,dimensions:i}}const bp=dp.default||dp;function Go(r,t,e,i,s,n,o){const a=bp(r,t,2);if(!a)return;for(let u=0;u<a.length;u+=3)n[o++]=a[u]+s,n[o++]=a[u+1]+s,n[o++]=a[u+2]+s;let l=s*i;for(let u=0;u<r.length;u+=2)e[l]=r[u],e[l+1]=r[u+1],l+=i}const aS=[],vp={extension:{type:T.ShapeBuilder,name:"polygon"},build(r,t){for(let e=0;e<r.points.length;e++)t[e]=r.points[e];return!0},triangulate(r,t,e,i,s,n){Go(r,aS,t,e,i,s,n)}},yp={extension:{type:T.ShapeBuilder,name:"rectangle"},build(r,t){const e=r,i=e.x,s=e.y,n=e.width,o=e.height;return n>0&&o>0?(t[0]=i,t[1]=s,t[2]=i+n,t[3]=s,t[4]=i+n,t[5]=s+o,t[6]=i,t[7]=s+o,!0):!1},triangulate(r,t,e,i,s,n){let o=0;i*=e,t[i+o]=r[0],t[i+o+1]=r[1],o+=e,t[i+o]=r[2],t[i+o+1]=r[3],o+=e,t[i+o]=r[6],t[i+o+1]=r[7],o+=e,t[i+o]=r[4],t[i+o+1]=r[5],o+=e;const a=i/e;s[n++]=a,s[n++]=a+1,s[n++]=a+2,s[n++]=a+1,s[n++]=a+3,s[n++]=a+2}},xp={extension:{type:T.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,i,s,n){let o=0;i*=e,t[i+o]=r[0],t[i+o+1]=r[1],o+=e,t[i+o]=r[2],t[i+o+1]=r[3],o+=e,t[i+o]=r[4],t[i+o+1]=r[5];const a=i/e;s[n++]=a,s[n++]=a+1,s[n++]=a+2}};var lS=Object.defineProperty,Tp=Object.getOwnPropertySymbols,uS=Object.prototype.hasOwnProperty,cS=Object.prototype.propertyIsEnumerable,Sp=(r,t,e)=>t in r?lS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ap=(r,t)=>{for(var e in t||(t={}))uS.call(t,e)&&Sp(r,e,t[e]);if(Tp)for(var e of Tp(t))cS.call(t,e)&&Sp(r,e,t[e]);return r};const Ep=[{offset:0,color:"white"},{offset:1,color:"black"}],Bo=class Ku{constructor(...t){this.uid=Y("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];var e;let i=hS(t);const s=i.type==="radial"?Ku.defaultRadialOptions:Ku.defaultLinearOptions;i=Ap(Ap({},s),kt(i)),this._textureSize=i.textureSize,this._wrapMode=i.wrapMode,i.type==="radial"?(this.center=i.center,this.outerCenter=(e=i.outerCenter)!=null?e:this.center,this.innerRadius=i.innerRadius,this.outerRadius=i.outerRadius,this.scale=i.scale,this.rotation=i.rotation):(this.start=i.start,this.end=i.end),this.textureSpace=i.textureSpace,this.type=i.type,i.colorStops.forEach(n=>{this.addColorStop(n.offset,n.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:H.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:s}=this.end,n=i-t,o=s-e;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const g=t;t=i,i=g,n*=-1}if(o<0){const g=e;e=s,s=g,o*=-1}}const l=this.colorStops.length?this.colorStops:Ep,u=this._textureSize,{canvas:c,context:h}=wp(u,1),p=a?h.createLinearGradient(this._textureSize,0,0,0):h.createLinearGradient(0,0,this._textureSize,0);Pp(p,l),h.fillStyle=p,h.fillRect(0,0,u,1),this.texture=new w({source:new le({resource:c,addressMode:this._wrapMode})});const f=Math.sqrt(n*n+o*o),m=Math.atan2(o,n),_=new C;_.scale(f/u,1),_.rotate(m),_.translate(t,e),this.textureSpace==="local"&&_.scale(u,u),this.transform=_}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Ep,e=this._textureSize,{canvas:i,context:s}=wp(e,e),{x:n,y:o}=this.center,{x:a,y:l}=this.outerCenter,u=this.innerRadius,c=this.outerRadius,h=a-c,p=l-c,f=e/(c*2),m=(n-h)*f,_=(o-p)*f,g=s.createRadialGradient(m,_,u*f,(a-h)*f,(l-p)*f,c*f);Pp(g,t),s.fillStyle=t[t.length-1].color,s.fillRect(0,0,e,e),s.fillStyle=g,s.translate(m,_),s.rotate(this.rotation),s.scale(1,this.scale),s.translate(-m,-_),s.fillRect(0,0,e,e),this.texture=new w({source:new le({resource:i,addressMode:this._wrapMode})});const b=new C;b.scale(1/f,1/f),b.translate(h,p),this.textureSpace==="local"&&b.scale(e,e),this.transform=b}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}`}};Bo.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},Bo.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Qt=Bo;function Pp(r,t){for(let e=0;e<t.length;e++){const i=t[e];r.addColorStop(i.offset,i.color)}}function wp(r,t){const e=L.get().createCanvas(r,t),i=e.getContext("2d");return{canvas:e,context:i}}function hS(r){var t,e;let i=(t=r[0])!=null?t:{};return(typeof i=="number"||r[1])&&(i={type:"linear",start:{x:r[0],y:r[1]},end:{x:r[2],y:r[3]},textureSpace:r[4],textureSize:(e=r[5])!=null?e:Qt.defaultLinearOptions.textureSize}),i}const dS=new C,pS=new z;function Rp(r,t,e,i){const s=t.matrix?r.copyFrom(t.matrix).invert():r.identity();if(t.textureSpace==="local"){const o=e.getBounds(pS);t.width&&o.pad(t.width);const{x:a,y:l}=o,u=1/o.width,c=1/o.height,h=-a*u,p=-l*c,f=s.a,m=s.b,_=s.c,g=s.d;s.a*=u,s.b*=u,s.c*=c,s.d*=c,s.tx=h*f+p*_+s.tx,s.ty=h*m+p*g+s.ty}else s.translate(t.texture.frame.x,t.texture.frame.y),s.scale(1/t.texture.source.width,1/t.texture.source.height);const n=t.texture.source.style;return!(t.fill instanceof Qt)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),i&&s.append(dS.copyFrom(i).invert()),s}const er={};F.handleByMap(T.ShapeBuilder,er),F.add(yp,vp,xp,Je,op,ap);const fS=new z,mS=new C;function Cp(r,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let s=0;s<r.instructions.length;s++){const n=r.instructions[s];if(n.action==="texture")gS(n.data,i,e);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,l=n.data.style,u=n.data.hole;o&&u&&Mp(u.shapePath,l,!0,i,e),u&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=u.shapePath.shapePrimitives),Mp(a,l,o,i,e)}}}function gS(r,t,e){const i=[],s=er.rectangle,n=fS;n.x=r.dx,n.y=r.dy,n.width=r.dw,n.height=r.dh;const o=r.transform;if(!s.build(n,i))return;const{vertices:a,uvs:l,indices:u}=e,c=u.length,h=a.length/2;o&&Ji(i,o),s.triangulate(i,a,2,h,u,c);const p=r.image,f=p.uvs;l.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const m=st.get(ts);m.indexOffset=c,m.indexSize=u.length-c,m.attributeOffset=h,m.attributeSize=a.length/2-h,m.baseColor=r.style,m.alpha=r.alpha,m.texture=p,m.geometryData=e,t.push(m)}function Mp(r,t,e,i,s){const{vertices:n,uvs:o,indices:a}=s;r.shapePrimitives.forEach(({shape:l,transform:u,holes:c})=>{var h;const p=[],f=er[l.type];if(!f.build(l,p))return;const m=a.length,_=n.length/2;let g="triangle-list";if(u&&Ji(p,u),e){const x=(h=l.closePath)!=null?h:!0,A=t;A.pixelLine?(hp(p,x,n,a),g="line-list"):cp(p,A,!1,x,n,a)}else if(c){const x=[],A=p.slice();_S(c).forEach(S=>{x.push(A.length/2),A.push(...S)}),Go(A,x,n,2,_,a,m)}else f.triangulate(p,n,2,_,a,m);const b=o.length/2,y=t.texture;if(y!==w.WHITE){const x=Rp(mS,t,l,u);Eo(n,2,_,o,b,2,n.length/2-_,x)}else Po(o,b,2,n.length/2-_);const v=st.get(ts);v.indexOffset=m,v.indexSize=a.length-m,v.attributeOffset=_,v.attributeSize=n.length/2-_,v.baseColor=t.color,v.alpha=t.alpha,v.texture=y,v.geometryData=s,v.topology=g,i.push(v)})}function _S(r){const t=[];for(let e=0;e<r.length;e++){const i=r[e].shape,s=[];er[i.type].build(i,s)&&t.push(s)}return t}class Op{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(t=>{st.return(t)}),this.graphicsData&&st.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class Gp{constructor(){this.instructions=new Fn}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Qi({maxTextures:e}),this.instructions.reset()}get geometry(){return this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const Io=class qu{constructor(t){this._renderer=t,this._managedContexts=new xt({renderer:t,type:"resource",name:"graphicsContext"})}init(t){var e;qu.defaultOptions.bezierSmoothness=(e=t==null?void 0:t.bezierSmoothness)!=null?e:qu.defaultOptions.bezierSmoothness}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=!!t._gpuData[this._renderer.uid],i=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!e){e&&i.reset(),Cp(t,i);const s=t.batchMode;t.customShader||s==="no-batch"?i.isBatchable=!1:s==="auto"?i.isBatchable=i.geometryData.vertices.length<400:i.isBatchable=!0,t.dirty=!1}return i}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=st.get(Gp,{maxTextures:this._renderer.limits.maxBatchableTextures}),i=t._gpuData[this._renderer.uid],{batches:s,geometryData:n}=i;i.graphicsData=e;const o=n.vertices.length,a=n.indices.length;for(let h=0;h<s.length;h++)s[h].applyTransform=!1;const l=e.batcher;l.ensureAttributeBuffer(o),l.ensureIndexBuffer(a),l.begin();for(let h=0;h<s.length;h++){const p=s[h];l.add(p)}l.finish(e.instructions);const u=l.geometry;u.indexBuffer.setDataWithSize(l.indexBuffer,l.indexSize,!0),u.buffers[0].setDataWithSize(l.attributeBuffer.float32View,l.attributeSize,!0);const c=l.batches;for(let h=0;h<c.length;h++){const p=c[h];p.bindGroup=Ni(p.textures.textures,p.textures.count,this._renderer.limits.maxBatchableTextures)}return e}_initContext(t){const e=new Op;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};Io.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"graphicsContext"},Io.defaultOptions={bezierSmoothness:.5};let ns=Io;const bS={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},Fo=0,Do=1,Uo=2,ko=3,$o=4,Lo=5,No=class Yx{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Fo)}set blend(t){!!(this.data&1<<Fo)!==t&&(this.data^=1<<Fo)}get offsets(){return!!(this.data&1<<Do)}set offsets(t){!!(this.data&1<<Do)!==t&&(this.data^=1<<Do)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<Uo)}set culling(t){!!(this.data&1<<Uo)!==t&&(this.data^=1<<Uo)}get depthTest(){return!!(this.data&1<<ko)}set depthTest(t){!!(this.data&1<<ko)!==t&&(this.data^=1<<ko)}get depthMask(){return!!(this.data&1<<Lo)}set depthMask(t){!!(this.data&1<<Lo)!==t&&(this.data^=1<<Lo)}get clockwiseFrontFace(){return!!(this.data&1<<$o)}set clockwiseFrontFace(t){!!(this.data&1<<$o)!==t&&(this.data^=1<<$o)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=bS[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Yx;return t.depthTest=!1,t.blend=!0,t}};No.default2d=No.for2d();let Rt=No;function vS(r,t,e,i){e[i++]=(r>>16&255)/255,e[i++]=(r>>8&255)/255,e[i++]=(r&255)/255,e[i++]=t}function rr(r,t,e){const i=(r>>24&255)/255;t[e++]=(r&255)/255*i,t[e++]=(r>>8&255)/255*i,t[e++]=(r>>16&255)/255*i,t[e++]=i}class Bp{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{st.return(t)}),this.batches.length=0}}class Xo{constructor(t,e){this.state=Rt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new xt({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,i=!!t._gpuData,s=this.renderer.graphicsContext.updateGpuContext(e);return!!(s.isBatchable||i!==s.isBatchable)}addRenderable(t,e){const i=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),i.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._getGpuDataForRenderable(t).batches;for(let i=0;i<e.length;i++){const s=e[i];s._batcher.updateElement(s)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,i=t.context;if(!e.graphicsContext.getGpuContext(i).batches.length)return;const s=i.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const n=s.resources.localUniforms.uniforms;n.uTransformMatrix=t.groupTransform,n.uRound=e._roundPixels|t._roundPixels,rr(t.groupColorAlpha,n.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),i=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),i.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const i=this.renderer.renderPipes.batch,s=this._getGpuDataForRenderable(t).batches;for(let n=0;n<s.length;n++){const o=s[n];i.addToBatch(o,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new Bp;return t._gpuData[this.renderer.uid]=e,this._managedGraphics.add(t),e}_updateBatchesForRenderable(t,e){const i=t.context,s=this.renderer.graphicsContext.getGpuContext(i),n=this.renderer._roundPixels|t._roundPixels;e.batches=s.batches.map(o=>{const a=st.get(ts);return o.copyTo(a),a.renderable=t,a.roundPixels=n,a})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}Xo.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"graphics"},F.add(Xo),F.add(ns);class os{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(t){this._topology=t}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(t){this.texture!==t&&(this.texture=t,this._textureMatrixUpdateId=-1)}get uvs(){const t=this.geometry.getBuffer("aUV"),e=t.data;let i=e;const s=this.texture.textureMatrix;return s.isSimple||(i=this._transformedUvs,(this._textureMatrixUpdateId!==s._updateID||this._uvUpdateId!==t._updateID)&&((!i||i.length<e.length)&&(i=this._transformedUvs=new Float32Array(e.length)),this._textureMatrixUpdateId=s._updateID,this._uvUpdateId=t._updateID,s.multiplyUvs(e,i))),i}get positions(){return this.geometry.positions}get indices(){return this.geometry.indices}get color(){return this.renderable.groupColorAlpha}get groupTransform(){return this.renderable.groupTransform}get attributeSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class Ho{destroy(){}}class jo{constructor(t,e){this.localUniforms=new nt({uTransformMatrix:{value:new C,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Zt({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),i=e.batched,s=t.batched;if(e.batched=s,i!==s)return!0;if(s){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 i,s;const n=this.renderer.renderPipes.batch,o=this._getMeshData(t);if(t.didViewUpdate&&(o.indexSize=(i=t._geometry.indices)==null?void 0:i.length,o.vertexSize=(s=t._geometry.positions)==null?void 0:s.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=ze(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),rr(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new Ho),t._gpuData[this.renderer.uid].meshData||this._initMeshData(t)}_initMeshData(t){return t._gpuData[this.renderer.uid].meshData={batched:t.batched,indexSize:0,vertexSize:0},t._gpuData[this.renderer.uid].meshData}_getBatchableMesh(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new Ho),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new os;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}}jo.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"mesh"},F.add(jo);class Ip{execute(t,e){const i=t.state,s=t.renderer,n=e.shader||t.defaultShader;n.resources.uTexture=e.texture._source,n.resources.uniforms=t.localUniforms;const o=s.gl,a=t.getBuffers(e);s.shader.bind(n),s.state.set(i),s.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 zo(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 i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}function Fp(r){return{dynamicUpdate:Dp(r,!0),staticUpdate:Dp(r,!1)}}function Dp(r,t){const e=[];e.push(`
var index = 0;
for (let i = 0; i < ps.length; ++i)
{
const p = ps[i];
`);let i=0;for(const n in r){const o=r[n];if(t!==o.dynamic)continue;e.push(`offset = index + ${i}`),e.push(o.code);const a=se(o.format);i+=a.stride/4}e.push(`
index += stride * 4;
}
`),e.unshift(`
var stride = ${i};
`);const s=e.join(`
`);return new Function("ps","f32v","u32v",s)}class Up{constructor(t){this._size=0,this._generateParticleUpdateCache={};var e;const i=this._size=(e=t.size)!=null?e:1e3,s=t.properties;let n=0,o=0;for(const h in s){const p=s[h],f=se(p.format);p.dynamic?o+=f.stride:n+=f.stride}this._dynamicStride=o/4,this._staticStride=n/4,this.staticAttributeBuffer=new Ae(i*4*n),this.dynamicAttributeBuffer=new Ae(i*4*o),this.indexBuffer=zo(i);const a=new Ee;let l=0,u=0;this._staticBuffer=new bt({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:X.VERTEX|X.COPY_DST}),this._dynamicBuffer=new bt({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:X.VERTEX|X.COPY_DST});for(const h in s){const p=s[h],f=se(p.format);p.dynamic?(a.addAttribute(p.attributeName,{buffer:this._dynamicBuffer,stride:this._dynamicStride*4,offset:l*4,format:p.format}),l+=f.size):(a.addAttribute(p.attributeName,{buffer:this._staticBuffer,stride:this._staticStride*4,offset:u*4,format:p.format}),u+=f.size)}a.addIndex(this.indexBuffer);const c=this.getParticleUpdate(s);this._dynamicUpload=c.dynamicUpdate,this._staticUpload=c.staticUpdate,this.geometry=a}getParticleUpdate(t){const e=yS(t);return this._generateParticleUpdateCache[e]?this._generateParticleUpdateCache[e]:(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t),this._generateParticleUpdateCache[e])}generateParticleUpdate(t){return Fp(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,this._size*1.5|0),this.staticAttributeBuffer=new Ae(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new Ae(this._size*this._dynamicStride*4*4),this.indexBuffer=zo(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const i=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,i.float32View,i.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){const s=this.staticAttributeBuffer;this._staticUpload(t,s.float32View,s.uint32View),this._staticBuffer.setDataWithSize(s.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}function yS(r){const t=[];for(const e in r){const i=r[e];t.push(e,i.code,i.dynamic?"d":"s")}return t.join("_")}var kp=`varying vec2 vUV;
varying vec4 vColor;
uniform sampler2D uTexture;
void main(void){
vec4 color = texture2D(uTexture, vUV) * vColor;
gl_FragColor = color;
}`,$p=`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;
}
`,Vo=`
struct ParticleUniforms {
uTranslationMatrix:mat3x3<f32>,
uColor:vec4<f32>,
uRound:f32,
uResolution:vec2<f32>,
};
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
{
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
}
@group(0) @binding(0) var<uniform> uniforms: ParticleUniforms;
@group(1) @binding(0) var uTexture: texture_2d<f32>;
@group(1) @binding(1) var uSampler : sampler;
struct VSOutput {
@builtin(position) position: vec4<f32>,
@location(0) uv : vec2<f32>,
@location(1) color : vec4<f32>,
};
@vertex
fn mainVertex(
@location(0) aVertex: vec2<f32>,
@location(1) aPosition: vec2<f32>,
@location(2) aUV: vec2<f32>,
@location(3) aColor: vec4<f32>,
@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<f32>,
@location(1) color: vec4<f32>,
@builtin(position) position: vec4<f32>,
) -> @location(0) vec4<f32> {
var sample = textureSample(uTexture, uSampler, uv) * color;
return sample;
}`;class Lp extends wt{constructor(){const t=vt.from({vertex:$p,fragment:kp}),e=dt.from({fragment:{source:Vo,entryPoint:"mainFragment"},vertex:{source:Vo,entryPoint:"mainVertex"}});super({glProgram:t,gpuProgram:e,resources:{uTexture:w.WHITE.source,uSampler:new Et({}),uniforms:{uTranslationMatrix:{value:new C,type:"mat3x3<f32>"},uColor:{value:new H(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}}class Wo{constructor(t,e){this.state=Rt.for2d(),this.localUniforms=new nt({uTranslationMatrix:{value:new C,type:"mat3x3<f32>"},uColor:{value:new Float32Array(4),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new Lp,this.state=Rt.for2d(),this._managedContainers=new xt({renderer:t,type:"renderable",name:"particleContainer"})}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 Up({size:t.particleChildren.length,properties:t._properties}),this._managedContainers.add(t),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){const e=t.particleChildren;if(e.length===0)return;const i=this.renderer,s=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const n=this.state;s.update(e,t._childrenDirty),t._childrenDirty=!1,n.blendMode=ze(t.blendMode,t.texture._source);const o=this.localUniforms.uniforms,a=o.uTranslationMatrix;t.worldTransform.copyTo(a),a.prepend(i.globalUniforms.globalUniformData.projectionMatrix),o.uResolution=i.globalUniforms.globalUniformData.resolution,o.uRound=i._roundPixels|t._roundPixels,rr(t.groupColorAlpha,o.uColor,0),this.adaptor.execute(this,t)}destroy(){this._managedContainers.destroy(),this.renderer=null,this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}class Yo extends Wo{constructor(t){super(t,new Ip)}}Yo.extension={type:[T.WebGLPipes],name:"particle"};class Np{execute(t,e){const i=t.renderer,s=e.shader||t.defaultShader;s.groups[0]=i.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),s.groups[1]=i.texture.getTextureBindGroup(e.texture);const n=t.state,o=t.getBuffers(e);i.encoder.draw({geometry:o.geometry,shader:e.shader||t.defaultShader,state:n,size:e.particleChildren.length*6})}}class Ko extends Wo{constructor(t){super(t,new Np)}}Ko.extension={type:[T.WebGPUPipes],name:"particle"},F.add(Yo),F.add(Ko);function as(r,t){const{texture:e,bounds:i}=r,s=t._style._getFinalPadding();to(i,t._anchor,e);const n=t._anchor._x*s*2,o=t._anchor._y*s*2;i.minX-=s-n,i.minY-=s-o,i.maxX-=s-n,i.maxY-=s-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(){this.reset()}}class Xp extends Nr{}class qo{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new xt({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i?!0:t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const s=t._autoResolution?this._renderer.resolution:t.resolution;(i.currentKey!==t.styleKey||t.resolution!==s)&&this._updateGpuText(t),t._didTextUpdate=!1,as(i,t)}this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Xp;return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{canvasText:i}=this._renderer;i.getReferenceCount(e.currentKey)>0?i.decreaseReferenceCount(e.currentKey):e.texture&&i.returnTexture(e.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}qo.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"text"};const Hp={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=Y("fillPattern"),this._tick=0,this.transform=new C,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Hp[e].addressModeU,t.source.style.addressModeV=Hp[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 xS=SS,Zo={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},TS=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function SS(r){var t=[];return r.replace(TS,function(e,i,s){var n=i.toLowerCase();for(s=ES(s),n=="m"&&s.length>2&&(t.push([i].concat(s.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(s.length==Zo[n])return s.unshift(i),t.push(s);if(s.length<Zo[n])throw new Error("malformed path data");t.push([i].concat(s.splice(0,Zo[n])))}}),t}var AS=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function ES(r){var t=r.match(AS);return t?t.map(Number):[]}var PS=nc(xS);function jp(r,t){const e=PS(r),i=[];let s=null,n=0,o=0;for(let a=0;a<e.length;a++){const l=e[a],u=l[0],c=l;switch(u){case"M":n=c[1],o=c[2],t.moveTo(n,o);break;case"m":n+=c[1],o+=c[2],t.moveTo(n,o);break;case"H":n=c[1],t.lineTo(n,o);break;case"h":n+=c[1],t.lineTo(n,o);break;case"V":o=c[1],t.lineTo(n,o);break;case"v":o+=c[1],t.lineTo(n,o);break;case"L":n=c[1],o=c[2],t.lineTo(n,o);break;case"l":n+=c[1],o+=c[2],t.lineTo(n,o);break;case"C":n=c[5],o=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],n,o);break;case"c":t.bezierCurveTo(n+c[1],o+c[2],n+c[3],o+c[4],n+c[5],o+c[6]),n+=c[5],o+=c[6];break;case"S":n=c[3],o=c[4],t.bezierCurveToShort(c[1],c[2],n,o);break;case"s":t.bezierCurveToShort(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"Q":n=c[3],o=c[4],t.quadraticCurveTo(c[1],c[2],n,o);break;case"q":t.quadraticCurveTo(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"T":n=c[1],o=c[2],t.quadraticCurveToShort(n,o);break;case"t":n+=c[1],o+=c[2],t.quadraticCurveToShort(n,o);break;case"A":n=c[6],o=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"a":n+=c[6],o+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"Z":case"z":t.closePath(),i.length>0&&(s=i.pop(),s?(n=s.startX,o=s.startY):(n=0,o=0)),s=null;break;default:}u!=="Z"&&u!=="z"&&s===null&&(s={startX:n,startY:o},i.push(s))}return t}class ls{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new ls(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}strokeContains(t,e,i,s=.5){if(this.radius===0)return!1;const n=this.x-t,o=this.y-e,a=this.radius,l=(1-s)*i,u=Math.sqrt(n*n+o*o);return u<=a+l&&u>a-(i-l)}getBounds(t){return t||(t=new z),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 us{constructor(t=0,e=0,i=0,s=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=s}clone(){return new us(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,s=(e-this.y)/this.halfHeight;return i*=i,s*=s,i+s<=1}strokeContains(t,e,i,s=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=i*(1-s),l=i-a,u=n-l,c=o-l,h=n+a,p=o+a,f=t-this.x,m=e-this.y,_=f*f/(u*u)+m*m/(c*c),g=f*f/(h*h)+m*m/(p*p);return _>1&&g<=1}getBounds(t){return t||(t=new z),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,i,s,n){const o=r-e,a=t-i,l=s-e,u=n-i,c=o*l+a*u,h=l*l+u*u;let p=-1;h!==0&&(p=c/h);let f,m;p<0?(f=e,m=i):p>1?(f=s,m=n):(f=e+p*l,m=i+p*u);const _=r-f,g=t-m;return _*_+g*g}let wS,RS;class ir{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,i=e.length;for(let s=0;s<i;s+=2){const n=e[s],o=e[s+1],a=e[(s+2)%i],l=e[(s+3)%i];t+=(a-n)*(l+o)}return t<0}containsPolygon(t){const e=this.getBounds(wS),i=t.getBounds(RS);if(!e.containsRect(i))return!1;const s=t.points;for(let n=0;n<s.length;n+=2){const o=s[n],a=s[n+1];if(!this.contains(o,a))return!1}return!0}clone(){const t=this.points.slice(),e=new ir(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],l=this.points[n*2+1],u=this.points[o*2],c=this.points[o*2+1];l>e!=c>e&&t<(u-a)*((e-l)/(c-l))+a&&(i=!i)}return i}strokeContains(t,e,i,s=.5){const n=i*i,o=n*(1-s),a=n-o,{points:l}=this,u=l.length-(this.closePath?0:2);for(let c=0;c<u;c+=2){const h=l[c],p=l[c+1],f=l[(c+2)%l.length],m=l[(c+3)%l.length],_=Hr(t,e,h,p,f,m),g=Math.sign((f-h)*(e-p)-(m-p)*(t-h));if(_<=(g<0?a:o))return!0}return!1}getBounds(t){t||(t=new z);const e=this.points;let i=1/0,s=-1/0,n=1/0,o=-1/0;for(let a=0,l=e.length;a<l;a+=2){const u=e[a],c=e[a+1];i=u<i?u:i,s=u>s?u:s,n=c<n?c:n,o=c>o?c:o}return t.x=i,t.width=s-i,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 cs=(r,t,e,i,s,n,o)=>{const a=r-e,l=t-i,u=Math.sqrt(a*a+l*l);return u>=s-n&&u<=s+o};class hs{constructor(t=0,e=0,i=0,s=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n}getBounds(t){return t||(t=new z),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new hs(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let s=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=t-(this.x+this.width-i),s*s+n*n<=o)||(n=e-(this.y+this.height-i),s*s+n*n<=o)||(s=t-(this.x+i),s*s+n*n<=o))return!0}return!1}strokeContains(t,e,i,s=.5){const{x:n,y:o,width:a,height:l,radius:u}=this,c=i*(1-s),h=i-c,p=n+u,f=o+u,m=a-u*2,_=l-u*2,g=n+a,b=o+l;return(t>=n-c&&t<=n+h||t>=g-h&&t<=g+c)&&e>=f&&e<=f+_||(e>=o-c&&e<=o+h||e>=b-h&&e<=b+c)&&t>=p&&t<=p+m?!0:t<p&&e<f&&cs(t,e,p,f,u,h,c)||t>g-u&&e<f&&cs(t,e,g-u,f,u,h,c)||t>g-u&&e>b-u&&cs(t,e,g-u,b-u,u,h,c)||t<p&&e>b-u&&cs(t,e,p,b-u,u,h,c)}}const CS=8,ds=11920929e-14,MS=1,Qo=.01,sr=0,Ce=0;function Jo(r,t,e,i,s,n,o,a,l,u){const c=Math.min(.99,Math.max(0,u!=null?u:ns.defaultOptions.bezierSmoothness));let h=(MS-c)/1;return h*=h,OS(t,e,i,s,n,o,a,l,r,h),r}function OS(r,t,e,i,s,n,o,a,l,u){ta(r,t,e,i,s,n,o,a,l,u,0),l.push(o,a)}function ta(r,t,e,i,s,n,o,a,l,u,c){if(c>CS)return;const h=Math.PI,p=(r+e)/2,f=(t+i)/2,m=(e+s)/2,_=(i+n)/2,g=(s+o)/2,b=(n+a)/2,y=(p+m)/2,v=(f+_)/2,x=(m+g)/2,A=(_+b)/2,S=(y+x)/2,E=(v+A)/2;if(c>0){let M=o-r,O=a-t;const P=Math.abs((e-o)*O-(i-a)*M),R=Math.abs((s-o)*O-(n-a)*M);let U,k;if(P>ds&&R>ds){if((P+R)*(P+R)<=u*(M*M+O*O)){if(sr<Qo){l.push(S,E);return}const B=Math.atan2(n-i,s-e);if(U=Math.abs(B-Math.atan2(i-t,e-r)),k=Math.abs(Math.atan2(a-n,o-s)-B),U>=h&&(U=2*h-U),k>=h&&(k=2*h-k),U+k<sr){l.push(S,E);return}if(Ce!==0){if(U>Ce){l.push(e,i);return}if(k>Ce){l.push(s,n);return}}}}else if(P>ds){if(P*P<=u*(M*M+O*O)){if(sr<Qo){l.push(S,E);return}if(U=Math.abs(Math.atan2(n-i,s-e)-Math.atan2(i-t,e-r)),U>=h&&(U=2*h-U),U<sr){l.push(e,i),l.push(s,n);return}if(Ce!==0&&U>Ce){l.push(e,i);return}}}else if(R>ds){if(R*R<=u*(M*M+O*O)){if(sr<Qo){l.push(S,E);return}if(U=Math.abs(Math.atan2(a-n,o-s)-Math.atan2(n-i,s-e)),U>=h&&(U=2*h-U),U<sr){l.push(e,i),l.push(s,n);return}if(Ce!==0&&U>Ce){l.push(s,n);return}}}else if(M=S-(r+o)/2,O=E-(t+a)/2,M*M+O*O<=u){l.push(S,E);return}}ta(r,t,p,f,y,v,S,E,l,u,c+1),ta(S,E,x,A,g,b,o,a,l,u,c+1)}const GS=8,BS=11920929e-14,IS=1,FS=.01,zp=0;function Vp(r,t,e,i,s,n,o,a){const l=Math.min(.99,Math.max(0,a!=null?a:ns.defaultOptions.bezierSmoothness));let u=(IS-l)/1;return u*=u,DS(t,e,i,s,n,o,r,u),r}function DS(r,t,e,i,s,n,o,a){ea(o,r,t,e,i,s,n,a,0),o.push(s,n)}function ea(r,t,e,i,s,n,o,a,l){if(l>GS)return;const u=Math.PI,c=(t+i)/2,h=(e+s)/2,p=(i+n)/2,f=(s+o)/2,m=(c+p)/2,_=(h+f)/2;let g=n-t,b=o-e;const y=Math.abs((i-n)*b-(s-o)*g);if(y>BS){if(y*y<=a*(g*g+b*b)){if(zp<FS){r.push(m,_);return}let v=Math.abs(Math.atan2(o-s,n-i)-Math.atan2(s-e,i-t));if(v>=u&&(v=2*u-v),v<zp){r.push(m,_);return}}}else if(g=m-(t+n)/2,b=_-(e+o)/2,g*g+b*b<=a){r.push(m,_);return}ea(r,t,e,c,h,m,_,a,l+1),ea(r,m,_,p,f,n,o,a,l+1)}function ra(r,t,e,i,s,n,o,a){let l=Math.abs(s-n);(!o&&s>n||o&&n>s)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(i,.3333333333333333)*(l/Math.PI)))),a=Math.max(a,3);let u=l/a,c=s;u*=o?-1:1;for(let h=0;h<a+1;h++){const p=Math.cos(c),f=Math.sin(c),m=t+p*i,_=e+f*i;r.push(m,_),c+=u}}function Wp(r,t,e,i,s,n){const o=r[r.length-2],a=r[r.length-1]-e,l=o-t,u=s-e,c=i-t,h=Math.abs(a*c-l*u);if(h<1e-8||n===0){(r[r.length-2]!==t||r[r.length-1]!==e)&&r.push(t,e);return}const p=a*a+l*l,f=u*u+c*c,m=a*u+l*c,_=n*Math.sqrt(p)/h,g=n*Math.sqrt(f)/h,b=_*m/p,y=g*m/f,v=_*c+g*l,x=_*u+g*a,A=l*(g+b),S=a*(g+b),E=c*(_+y),M=u*(_+y),O=Math.atan2(S-x,A-v),P=Math.atan2(M-x,E-v);ra(r,v+t,x+e,n,O,P,l*u>c*a)}const jr=Math.PI*2,ia={centerX:0,centerY:0,ang1:0,ang2:0},sa=({x:r,y:t},e,i,s,n,o,a,l)=>{r*=e,t*=i;const u=s*r-n*t,c=n*r+s*t;return l.x=u+o,l.y=c+a,l};function US(r,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,s=Math.cos(r),n=Math.sin(r),o=Math.cos(r+t),a=Math.sin(r+t);return[{x:s-n*i,y:n+s*i},{x:o+a*i,y:a-o*i},{x:o,y:a}]}const Yp=(r,t,e,i)=>{const s=r*i-t*e<0?-1:1;let n=r*e+t*i;return n>1&&(n=1),n<-1&&(n=-1),s*Math.acos(n)},kS=(r,t,e,i,s,n,o,a,l,u,c,h,p)=>{const f=Math.pow(s,2),m=Math.pow(n,2),_=Math.pow(c,2),g=Math.pow(h,2);let b=f*m-f*g-m*_;b<0&&(b=0),b/=f*g+m*_,b=Math.sqrt(b)*(o===a?-1:1);const y=b*s/n*h,v=b*-n/s*c,x=u*y-l*v+(r+e)/2,A=l*y+u*v+(t+i)/2,S=(c-y)/s,E=(h-v)/n,M=(-c-y)/s,O=(-h-v)/n,P=Yp(1,0,S,E);let R=Yp(S,E,M,O);a===0&&R>0&&(R-=jr),a===1&&R<0&&(R+=jr),p.centerX=x,p.centerY=A,p.ang1=P,p.ang2=R};function Kp(r,t,e,i,s,n,o,a=0,l=0,u=0){if(n===0||o===0)return;const c=Math.sin(a*jr/360),h=Math.cos(a*jr/360),p=h*(t-i)/2+c*(e-s)/2,f=-c*(t-i)/2+h*(e-s)/2;if(p===0&&f===0)return;n=Math.abs(n),o=Math.abs(o);const m=Math.pow(p,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(o,2);m>1&&(n*=Math.sqrt(m),o*=Math.sqrt(m)),kS(t,e,i,s,n,o,l,u,c,h,p,f,ia);let{ang1:_,ang2:g}=ia;const{centerX:b,centerY:y}=ia;let v=Math.abs(g)/(jr/4);Math.abs(1-v)<1e-7&&(v=1);const x=Math.max(Math.ceil(v),1);g/=x;let A=r[r.length-2],S=r[r.length-1];const E={x:0,y:0};for(let M=0;M<x;M++){const O=US(_,g),{x:P,y:R}=sa(O[0],n,o,h,c,b,y,E),{x:U,y:k}=sa(O[1],n,o,h,c,b,y,E),{x:B,y:mt}=sa(O[2],n,o,h,c,b,y,E);Jo(r,A,S,P,R,U,k,B,mt),A=B,S=mt,_+=g}}function qp(r,t,e){var i;const s=(a,l)=>{const u=l.x-a.x,c=l.y-a.y,h=Math.sqrt(u*u+c*c),p=u/h,f=c/h;return{len:h,nx:p,ny:f}},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;a<t.length;a++){const l=t[a%t.length],u=(i=l.radius)!=null?i:e;if(u<=0){n(a,l),o=l;continue}const c=t[(a+1)%t.length],h=s(l,o),p=s(l,c);if(h.len<1e-4||p.len<1e-4){n(a,l),o=l;continue}let f=Math.asin(h.nx*p.ny-h.ny*p.nx),m=1,_=!1;h.nx*p.nx-h.ny*-p.ny<0?f<0?f=Math.PI+f:(f=Math.PI-f,m=-1,_=!0):f>0&&(m=-1,_=!0);const g=f/2;let b,y=Math.abs(Math.cos(g)*u/Math.sin(g));y>Math.min(h.len/2,p.len/2)?(y=Math.min(h.len/2,p.len/2),b=Math.abs(y*Math.sin(g)/Math.cos(g))):b=u;const v=l.x+p.nx*y+-p.ny*b*m,x=l.y+p.ny*y+p.nx*b*m,A=Math.atan2(h.ny,h.nx)+Math.PI/2*m,S=Math.atan2(p.ny,p.nx)-Math.PI/2*m;a===0&&r.moveTo(v+Math.cos(A)*b,x+Math.sin(A)*b),r.arc(v,x,b,A,S,_),o=l}}function Zp(r,t,e,i){var s;const n=(l,u)=>Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2),o=(l,u,c)=>({x:l.x+(u.x-l.x)*c,y:l.y+(u.y-l.y)*c}),a=t.length;for(let l=0;l<a;l++){const u=t[(l+1)%a],c=(s=u.radius)!=null?s:e;if(c<=0){l===0?r.moveTo(u.x,u.y):r.lineTo(u.x,u.y);continue}const h=t[l],p=t[(l+2)%a],f=n(h,u);let m;if(f<1e-4)m=u;else{const b=Math.min(f/2,c);m=o(u,h,b/f)}const _=n(p,u);let g;if(_<1e-4)g=u;else{const b=Math.min(_/2,c);g=o(u,p,b/_)}l===0?r.moveTo(m.x,m.y):r.lineTo(m.x,m.y),r.quadraticCurveTo(u.x,u.y,g.x,g.y,i)}}const $S=new z;class Qp{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new ot,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const i=this._currentPoly.points,s=i[i.length-2],n=i[i.length-1];return(s!==t||n!==e)&&i.push(t,e),this}arc(t,e,i,s,n,o){this._ensurePoly(!1);const a=this._currentPoly.points;return ra(a,t,e,i,s,n,o),this}arcTo(t,e,i,s,n){this._ensurePoly();const o=this._currentPoly.points;return Wp(o,t,e,i,s,n),this}arcToSvg(t,e,i,s,n,o,a){const l=this._currentPoly.points;return Kp(l,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o,a){this._ensurePoly();const l=this._currentPoly;return Jo(this._currentPoly.points,l.lastX,l.lastY,t,e,i,s,n,o,a),this}quadraticCurveTo(t,e,i,s,n){this._ensurePoly();const o=this._currentPoly;return Vp(this._currentPoly.points,o.lastX,o.lastY,t,e,i,s,n),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));const i=this.shapePrimitives,s=i.length;for(let n=0;n<t.instructions.length;n++){const o=t.instructions[n];this[o.action](...o.data)}if(t.checkForHoles&&i.length-s>1){let n=null;for(let o=s;o<i.length;o++){const a=i[o];if(a.shape.type==="polygon"){const l=a.shape,u=n==null?void 0:n.shape;u&&u.containsPolygon(l)?(n.holes||(n.holes=[]),n.holes.push(a),i.copyWithin(o,o+1),i.length--,o--):n=a}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,s,n){return this.drawShape(new z(t,e,i,s),n),this}circle(t,e,i,s){return this.drawShape(new ls(t,e,i),s),this}poly(t,e,i){const s=new ir(t);return s.closePath=e,this.drawShape(s,i),this}regularPoly(t,e,i,s,n=0,o){s=Math.max(s|0,3);const a=-1*Math.PI/2+n,l=Math.PI*2/s,u=[];for(let c=0;c<s;c++){const h=a-c*l;u.push(t+i*Math.cos(h),e+i*Math.sin(h))}return this.poly(u,!0,o),this}roundPoly(t,e,i,s,n,o=0,a){if(s=Math.max(s|0,3),n<=0)return this.regularPoly(t,e,i,s,o);const l=i*Math.sin(Math.PI/s)-.001;n=Math.min(n,l);const u=-1*Math.PI/2+o,c=Math.PI*2/s,h=(s-2)*Math.PI/s/2;for(let p=0;p<s;p++){const f=p*c+u,m=t+i*Math.cos(f),_=e+i*Math.sin(f),g=f+Math.PI+h,b=f-Math.PI-h,y=m+n*Math.cos(g),v=_+n*Math.sin(g),x=m+n*Math.cos(b),A=_+n*Math.sin(b);p===0?this.moveTo(y,v):this.lineTo(y,v),this.quadraticCurveTo(m,_,x,A,a)}return this.closePath()}roundShape(t,e,i=!1,s){return t.length<3?this:(i?Zp(this,t,e,s):qp(this,t,e),this.closePath())}filletRect(t,e,i,s,n){if(n===0)return this.rect(t,e,i,s);const o=Math.min(i,s)/2,a=Math.min(o,Math.max(-o,n)),l=t+i,u=e+s,c=a<0?-a:0,h=Math.abs(a);return this.moveTo(t,e+h).arcTo(t+c,e+c,t+h,e,h).lineTo(l-h,e).arcTo(l-c,e+c,l,e+h,h).lineTo(l,u-h).arcTo(l-c,u-c,t+i-h,u,h).lineTo(t+h,u).arcTo(t+c,u-c,t,u-h,h).closePath()}chamferRect(t,e,i,s,n,o){if(n<=0)return this.rect(t,e,i,s);const a=Math.min(n,Math.min(i,s)/2),l=t+i,u=e+s,c=[t+a,e,l-a,e,l,e+a,l,u-a,l-a,u,t+a,u,t,u-a,t,e+a];for(let h=c.length-1;h>=2;h-=2)c[h]===c[h-2]&&c[h-1]===c[h-3]&&c.splice(h-1,2);return this.poly(c,!0,o)}ellipse(t,e,i,s,n){return this.drawShape(new us(t,e,i,s),n),this}roundRect(t,e,i,s,n,o){return this.drawShape(new hs(t,e,i,s,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new ir,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new ir,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,s=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,o=i;i=n.a*i+n.c*s+n.tx,s=n.b*o+n.d*s+n.ty}this._currentPoly.points.push(i,s)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let i=0;i<e.length;i++){const s=e[i],n=s.shape.getBounds($S);s.transform?t.addRect(n,s.transform):t.addRect(n)}return t}}class Nt{constructor(t,e=!1){this.instructions=[],this.uid=Y("graphicsPath"),this._dirty=!0;var i;this.checkForHoles=e,typeof t=="string"?jp(t,this):this.instructions=(i=t==null?void 0:t.slice())!=null?i:[]}get shapePath(){return this._shapePath||(this._shapePath=new Qp(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,i,s,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(W.shared);let l=0,u=0;if(!o||o.action!=="bezierCurveTo")l=a.x,u=a.y;else{l=o.data[2],u=o.data[3];const c=a.x,h=a.y;l=c+(c-l),u=h+(h-u)}return this.instructions.push({action:"bezierCurveTo",data:[l,u,t,e,i,s,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,i){const s=this.instructions[this.instructions.length-1],n=this.getLastPoint(W.shared);let o=0,a=0;if(!s||s.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=s.data[0],a=s.data[1];const l=n.x,u=n.y;o=l+(l-o),a=u+(u-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,t,e,i]}),this._dirty=!0,this}rect(t,e,i,s,n){return this.instructions.push({action:"rect",data:[t,e,i,s,n]}),this._dirty=!0,this}circle(t,e,i,s){return this.instructions.push({action:"circle",data:[t,e,i,s]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,i,s,n,o,a){n||(n=s/2);const l=-1*Math.PI/2+o,u=i*2,c=Math.PI*2/u,h=[];for(let p=0;p<u;p++){const f=p%2?n:s,m=p*c+l;h.push(t+f*Math.cos(m),e+f*Math.sin(m))}return this.poly(h,!0,a),this}clone(t=!1){const e=new Nt;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const s=this.instructions[i];e.instructions.push({action:s.action,data:s.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,i=t.b,s=t.c,n=t.d,o=t.tx,a=t.ty;let l=0,u=0,c=0,h=0,p=0,f=0,m=0,_=0;for(let g=0;g<this.instructions.length;g++){const b=this.instructions[g],y=b.data;switch(b.action){case"moveTo":case"lineTo":l=y[0],u=y[1],y[0]=e*l+s*u+o,y[1]=i*l+n*u+a;break;case"bezierCurveTo":c=y[0],h=y[1],p=y[2],f=y[3],l=y[4],u=y[5],y[0]=e*c+s*h+o,y[1]=i*c+n*h+a,y[2]=e*p+s*f+o,y[3]=i*p+n*f+a,y[4]=e*l+s*u+o,y[5]=i*l+n*u+a;break;case"quadraticCurveTo":c=y[0],h=y[1],l=y[2],u=y[3],y[0]=e*c+s*h+o,y[1]=i*c+n*h+a,y[2]=e*l+s*u+o,y[3]=i*l+n*u+a;break;case"arcToSvg":l=y[5],u=y[6],m=y[0],_=y[1],y[0]=e*m+s*_,y[1]=i*m+n*_,y[5]=e*l+s*u+o,y[6]=i*l+n*u+a;break;case"circle":y[4]=zr(y[3],t);break;case"rect":y[4]=zr(y[4],t);break;case"ellipse":y[8]=zr(y[8],t);break;case"roundRect":y[5]=zr(y[5],t);break;case"addPath":y[0].transform(t);break;case"poly":y[2]=zr(y[2],t);break;default:break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,i=this.instructions[e];if(!i)return t.x=0,t.y=0,t;for(;i.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;i=this.instructions[e]}switch(i.action){case"moveTo":case"lineTo":t.x=i.data[0],t.y=i.data[1];break;case"quadraticCurveTo":t.x=i.data[2],t.y=i.data[3];break;case"bezierCurveTo":t.x=i.data[4],t.y=i.data[5];break;case"arc":case"arcToSvg":t.x=i.data[5],t.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(t);break}return t}}function zr(r,t){return r?r.prepend(t):t.clone()}let na=0;const Jp=500;function Xt(...r){na!==Jp&&(na++,na===Jp?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}function tt(r,t,e){const i=r.getAttribute(t);return i?Number(i):e}function tf(r,t){const e=r.querySelectorAll("defs");for(let i=0;i<e.length;i++){const s=e[i];for(let n=0;n<s.children.length;n++){const o=s.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":t.defs[o.id]=LS(o);break;case"radialgradient":t.defs[o.id]=NS(o);break;default:break}}}}function LS(r){const t=tt(r,"x1",0),e=tt(r,"y1",0),i=tt(r,"x2",1),s=tt(r,"y2",0),n=r.getAttribute("gradientUnits")||"objectBoundingBox",o=new Qt(t,e,i,s,n==="objectBoundingBox"?"local":"global");for(let a=0;a<r.children.length;a++){const l=r.children[a],u=tt(l,"offset",0),c=H.shared.setValue(l.getAttribute("stop-color")).toNumber();o.addColorStop(u,c)}return o}function NS(r){return new Qt(0,0,1,0)}function oa(r){const t=r.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const aa={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}};function la(r,t){const e=r.getAttribute("style"),i={},s={},n={strokeStyle:i,fillStyle:s,useFill:!1,useStroke:!1};for(const o in aa){const a=r.getAttribute(o);a&&ef(t,n,o,a.trim())}if(e){const o=e.split(";");for(let a=0;a<o.length;a++){const l=o[a].trim(),[u,c]=l.split(":");aa[u]&&ef(t,n,u,c.trim())}}return{strokeStyle:n.useStroke?i:null,fillStyle:n.useFill?s:null,useFill:n.useFill,useStroke:n.useStroke}}function ef(r,t,e,i){switch(e){case"stroke":if(i!=="none"){if(i.startsWith("url(")){const s=oa(i);t.strokeStyle.fill=r.defs[s]}else t.strokeStyle.color=H.shared.setValue(i).toNumber();t.useStroke=!0}break;case"stroke-width":t.strokeStyle.width=Number(i);break;case"fill":if(i!=="none"){if(i.startsWith("url(")){const s=oa(i);t.fillStyle.fill=r.defs[s]}else t.fillStyle.color=H.shared.setValue(i).toNumber();t.useFill=!0}break;case"fill-opacity":t.fillStyle.alpha=Number(i);break;case"stroke-opacity":t.strokeStyle.alpha=Number(i);break;case"opacity":t.fillStyle.alpha=Number(i),t.strokeStyle.alpha=Number(i);break}}function rf(r){if(r.length<=2)return!0;const t=r.map(a=>a.area).sort((a,l)=>l-a),[e,i]=t,s=t[t.length-1],n=e/i,o=i/s;return!(n>3&&o<2)}function XS(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 sf(r){return r.split(/(?=[Mm])/).filter(t=>t.trim().length>0)}function nf(r){const t=r.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),i=[],s=[];for(let u=0;u<e.length;u+=2)u+1<e.length&&(i.push(e[u]),s.push(e[u+1]));if(i.length===0||s.length===0)return 0;const n=Math.min(...i),o=Math.max(...i),a=Math.min(...s),l=Math.max(...s);return(o-n)*(l-a)}function ua(r,t){const e=new Nt(r,!1);for(const i of e.instructions)t.instructions.push(i)}var HS=Object.defineProperty,of=Object.getOwnPropertySymbols,jS=Object.prototype.hasOwnProperty,zS=Object.prototype.propertyIsEnumerable,af=(r,t,e)=>t in r?HS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ps=(r,t)=>{for(var e in t||(t={}))jS.call(t,e)&&af(r,e,t[e]);if(of)for(var e of of(t))zS.call(t,e)&&af(r,e,t[e]);return r};function lf(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 Nt};tf(r,e);const i=r.children,{fillStyle:s,strokeStyle:n}=la(r,e);for(let o=0;o<i.length;o++){const a=i[o];a.nodeName.toLowerCase()!=="defs"&&uf(a,e,s,n)}return t}function uf(r,t,e,i){const s=r.children,{fillStyle:n,strokeStyle:o}=la(r,t);n&&e?e=ps(ps({},e),n):n&&(e=n),o&&i?i=ps(ps({},i),o):o&&(i=o);const a=!e&&!i;a&&(e={color:0});let l,u,c,h,p,f,m,_,g,b,y,v,x,A,S,E,M;switch(r.nodeName.toLowerCase()){case"path":{A=r.getAttribute("d");const O=r.getAttribute("fill-rule"),P=sf(A),R=O==="evenodd",U=P.length>1;if(R&&U){const k=P.map(B=>({path:B,area:nf(B)}));if(k.sort((B,mt)=>mt.area-B.area),P.length>3||!rf(k))for(let B=0;B<k.length;B++){const mt=k[B],I=B===0;t.context.beginPath();const D=new Nt(void 0,!0);ua(mt.path,D),t.context.path(D),I?(e&&t.context.fill(e),i&&t.context.stroke(i)):t.context.cut()}else for(let B=0;B<k.length;B++){const mt=k[B],I=B%2===1;t.context.beginPath();const D=new Nt(void 0,!0);ua(mt.path,D),t.context.path(D),I?t.context.cut():(e&&t.context.fill(e),i&&t.context.stroke(i))}}else{const k=O?O==="evenodd":!0;S=new Nt(A,k),t.context.path(S),e&&t.context.fill(e),i&&t.context.stroke(i)}break}case"circle":m=tt(r,"cx",0),_=tt(r,"cy",0),g=tt(r,"r",0),t.context.ellipse(m,_,g,g),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"rect":l=tt(r,"x",0),u=tt(r,"y",0),E=tt(r,"width",0),M=tt(r,"height",0),b=tt(r,"rx",0),y=tt(r,"ry",0),b||y?t.context.roundRect(l,u,E,M,b||y):t.context.rect(l,u,E,M),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"ellipse":m=tt(r,"cx",0),_=tt(r,"cy",0),b=tt(r,"rx",0),y=tt(r,"ry",0),t.context.beginPath(),t.context.ellipse(m,_,b,y),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"line":c=tt(r,"x1",0),h=tt(r,"y1",0),p=tt(r,"x2",0),f=tt(r,"y2",0),t.context.beginPath(),t.context.moveTo(c,h),t.context.lineTo(p,f),i&&t.context.stroke(i);break;case"polygon":x=r.getAttribute("points"),v=x.match(/-?\d+/g).map(O=>parseInt(O,10)),t.context.poly(v,!0),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"polyline":x=r.getAttribute("points"),v=x.match(/-?\d+/g).map(O=>parseInt(O,10)),t.context.poly(v,!1),i&&t.context.stroke(i);break;case"g":case"svg":break;default:{Xt(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}a&&(e=null);for(let O=0;O<s.length;O++)uf(s[O],t,e,i)}var VS=Object.defineProperty,fs=Object.getOwnPropertySymbols,cf=Object.prototype.hasOwnProperty,hf=Object.prototype.propertyIsEnumerable,df=(r,t,e)=>t in r?VS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ht=(r,t)=>{for(var e in t||(t={}))cf.call(t,e)&&df(r,e,t[e]);if(fs)for(var e of fs(t))hf.call(t,e)&&df(r,e,t[e]);return r},WS=(r,t)=>{var e={};for(var i in r)cf.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&fs)for(var i of fs(r))t.indexOf(i)<0&&hf.call(r,i)&&(e[i]=r[i]);return e};function YS(r){return H.isColorLike(r)}function pf(r){return r instanceof Xr}function ff(r){return r instanceof Qt}function KS(r){return r instanceof w}function qS(r,t,e){const i=H.shared.setValue(t!=null?t:0);return r.color=i.toNumber(),r.alpha=i.alpha===1?e.alpha:i.alpha,r.texture=w.WHITE,Ht(Ht({},e),r)}function ZS(r,t,e){return r.texture=t,Ht(Ht({},e),r)}function mf(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,Ht(Ht({},e),r)}function gf(r,t,e){return t.buildGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,Ht(Ht({},e),r)}function QS(r,t){const e=Ht(Ht({},t),r),i=H.shared.setValue(e.color);return e.alpha*=i.alpha,e.color=i.toNumber(),e}function ue(r,t){if(r==null)return null;const e={},i=r;return YS(r)?qS(e,r,t):KS(r)?ZS(e,r,t):pf(r)?mf(e,r,t):ff(r)?gf(e,r,t):i.fill&&pf(i.fill)?mf(i,i.fill,t):i.fill&&ff(i.fill)?gf(i,i.fill,t):QS(i,t)}function Vr(r,t){const e=t,{width:i,alignment:s,miterLimit:n,cap:o,join:a,pixelLine:l}=e,u=WS(e,["width","alignment","miterLimit","cap","join","pixelLine"]),c=ue(r,u);return c?Ht({width:i,alignment:s,miterLimit:n,cap:o,join:a,pixelLine:l},c):null}var JS=Object.defineProperty,_f=Object.getOwnPropertySymbols,t2=Object.prototype.hasOwnProperty,e2=Object.prototype.propertyIsEnumerable,bf=(r,t,e)=>t in r?JS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nr=(r,t)=>{for(var e in t||(t={}))t2.call(t,e)&&bf(r,e,t[e]);if(_f)for(var e of _f(t))e2.call(t,e)&&bf(r,e,t[e]);return r};const r2=new W,vf=new C,ca=class ee extends gt{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=Y("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new Nt,this._transform=new C,this._fillStyle=nr({},ee.defaultFillStyle),this._strokeStyle=nr({},ee.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new ot,this._boundsDirty=!0}clone(){const t=new ee;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=nr({},this._fillStyle),t._strokeStyle=nr({},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=ue(t,ee.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Vr(t,ee.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=ue(t,ee.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=ue(t,ee.defaultStrokeStyle),this}texture(t,e,i,s,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:s||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?H.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Nt,this}fill(t,e){let i;const s=this.instructions[this.instructions.length-1];return this._tick===0&&(s==null?void 0:s.action)==="stroke"?i=s.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(t={color:t,alpha:e}),this._fillStyle=ue(t,ee.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(W.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&(i==null?void 0:i.action)==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Vr(t,ee.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(i);else{e.data.hole=i;break}}return this._initNextPathLocation(),this}arc(t,e,i,s,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,i,s,n,o),this}arcTo(t,e,i,s,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*i+o.c*s+o.tx,o.b*i+o.d*s+o.ty,n),this}arcToSvg(t,e,i,s,n,o,a){this._tick++;const l=this._transform;return this._activePath.arcToSvg(t,e,i,s,n,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(t,e,i,s,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*i+l.c*s+l.tx,l.b*i+l.d*s+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,i,s){return this._tick++,this._activePath.ellipse(t,e,i,s,this._transform.clone()),this}circle(t,e,i){return this._tick++,this._activePath.circle(t,e,i,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;const i=this._transform,s=this._activePath.instructions,n=i.a*t+i.c*e+i.tx,o=i.b*t+i.d*e+i.ty;return s.length===1&&s[0].action==="moveTo"?(s[0].data[0]=n,s[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,i,s,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*i+o.c*s+o.tx,o.b*i+o.d*s+o.ty,n),this}rect(t,e,i,s){return this._tick++,this._activePath.rect(t,e,i,s,this._transform.clone()),this}roundRect(t,e,i,s,n){return this._tick++,this._activePath.roundRect(t,e,i,s,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,s,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,i,s,n,o),this}roundPoly(t,e,i,s,n,o){return this._tick++,this._activePath.roundPoly(t,e,i,s,n,o),this}roundShape(t,e,i,s){return this._tick++,this._activePath.roundShape(t,e,i,s),this}filletRect(t,e,i,s,n){return this._tick++,this._activePath.filletRect(t,e,i,s,n),this}chamferRect(t,e,i,s,n,o){return this._tick++,this._activePath.chamferRect(t,e,i,s,n,o),this}star(t,e,i,s,n=0,o=0){return this._tick++,this._activePath.star(t,e,i,s,n,o,this._transform.clone()),this}svg(t){return this._tick++,lf(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:nr({},this._fillStyle),strokeStyle:nr({},this._strokeStyle)}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,s,n,o){return t instanceof C?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,s,n,o),this)}transform(t,e,i,s,n,o){return t instanceof C?(this._transform.append(t),this):(vf.set(t,e,i,s,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;e<this.instructions.length;e++){const i=this.instructions[e],s=i.action;if(s==="fill"){const n=i.data;t.addBounds(n.path.bounds)}else if(s==="texture"){const n=i.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(s==="stroke"){const n=i.data,o=n.style.alignment,a=n.style.width*(1-o),l=n.path.bounds;t.addFrame(l.minX-a,l.minY-a,l.maxX+a,l.maxY+a)}}return t}containsPoint(t){var e;if(!this.bounds.containsPoint(t.x,t.y))return!1;const i=this.instructions;let s=!1;for(let n=0;n<i.length;n++){const o=i[n],a=o.data,l=a.path;if(!o.action||!l)continue;const u=a.style,c=l.shapePath.shapePrimitives;for(let h=0;h<c.length;h++){const p=c[h].shape;if(!u||!p)continue;const f=c[h].transform,m=f?f.applyInverse(t,r2):t;if(o.action==="fill")s=p.contains(m.x,m.y);else{const g=u;s=p.strokeContains(m.x,m.y,g.width,g.alignment)}const _=a.hole;if(_){const g=(e=_.shapePath)==null?void 0:e.shapePrimitives;if(g)for(let b=0;b<g.length;b++)g[b].shape.contains(m.x,m.y)&&(s=!1)}if(s)return!0}}return s}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(t=!1){if(!this.destroyed){if(this.destroyed=!0,this._stateStack.length=0,this._transform=null,this.unload(),this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(e)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(e))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}}};ca.defaultFillStyle={color:16777215,alpha:1,texture:w.WHITE,matrix:null,fill:null,textureSpace:"local"},ca.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:w.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let pt=ca;var i2=Object.defineProperty,s2=Object.defineProperties,n2=Object.getOwnPropertyDescriptors,yf=Object.getOwnPropertySymbols,o2=Object.prototype.hasOwnProperty,a2=Object.prototype.propertyIsEnumerable,xf=(r,t,e)=>t in r?i2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ct=(r,t)=>{for(var e in t||(t={}))o2.call(t,e)&&xf(r,e,t[e]);if(yf)for(var e of yf(t))a2.call(t,e)&&xf(r,e,t[e]);return r},l2=(r,t)=>s2(r,n2(t));const ha=class br extends gt{constructor(t={}){super(),this.uid=Y("textStyle"),this._tick=0,u2(t);const e=Ct(Ct({},br.defaultTextStyle),t);for(const i in e){const s=i;this[s]=e[i]}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(Ct(Ct({},br.defaultDropShadow),t)):this._dropShadow=t?this._createProxy(Ct({},br.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(Ct(Ct({},pt.defaultFillStyle),t),()=>{this._fill=ue(Ct({},this._originalFill),pt.defaultFillStyle)})),this._fill=ue(t===0?"black":t,pt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy(Ct(Ct({},pt.defaultStrokeStyle),t),()=>{this._stroke=Vr(Ct({},this._originalStroke),pt.defaultStrokeStyle)})),this._stroke=Vr(t,pt.defaultStrokeStyle),this.update())}update(){this._tick++,this.emit("update",this)}reset(){const t=br.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return`${this.uid}-${this._tick}`}clone(){return new br({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?Ct({},this._dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0})}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){var e,i,s,n;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(e=this._fill)!=null&&e.texture&&this._fill.texture.destroy(o),(i=this._originalFill)!=null&&i.texture&&this._originalFill.texture.destroy(o),(s=this._stroke)!=null&&s.texture&&this._stroke.texture.destroy(o),(n=this._originalStroke)!=null&&n.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(i,s,n)=>(i[s]===n||(i[s]=n,e==null||e(s,n),this.update()),!0)})}_isFillStyle(t){return(t!=null?t:null)!==null&&!(H.isColorLike(t)||t instanceof Qt||t instanceof Xr)}};ha.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},ha.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 Mt=ha;function u2(r){var t,e,i,s,n;const o=r;if(typeof o.dropShadow=="boolean"&&o.dropShadow){const a=Mt.defaultDropShadow;r.dropShadow={alpha:(t=o.dropShadowAlpha)!=null?t:a.alpha,angle:(e=o.dropShadowAngle)!=null?e:a.angle,blur:(i=o.dropShadowBlur)!=null?i:a.blur,color:(s=o.dropShadowColor)!=null?s:a.color,distance:(n=o.dropShadowDistance)!=null?n:a.distance}}if(o.strokeThickness!==void 0){const a=o.stroke;let l={};if(H.isColorLike(a))l.color=a;else if(a instanceof Qt||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=l2(Ct({},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 Qt({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),l=o.fillGradientStops.slice(),u=o.fill.map(c=>H.shared.setValue(c).toNumber());l.forEach((c,h)=>{a.addColorStop(c,u[h])}),r.fill={fill:a}}}const c2=new ot;function da(r,t,e,i){const s=c2;s.minX=0,s.minY=0,s.maxX=r.width/i|0,s.maxY=r.height/i|0;const n=et.getOptimalTexture(s.width,s.height,i,!1);return n.source.uploadMethodId="image",n.source.resource=r,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=t/i,n.frame.height=e/i,n.source.emit("update",n.source),n.updateUvs(),n}class Tf{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=L.get().createCanvas();i.width=t,i.height=e;const s=i.getContext("2d");return{canvas:i,context:s}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=_e(t),e=_e(e);const s=(t<<17)+(e<<1);this._canvasPool[s]||(this._canvasPool[s]=[]);let n=this._canvasPool[s].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:s}=e,n=(i<<17)+(s<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,s),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Jt=new Tf;ge.register(Jt);let Me=null,ne=null;function h2(r,t){Me||(Me=L.get().createCanvas(256,128),ne=Me.getContext("2d",{willReadFrequently:!0}),ne.globalCompositeOperation="copy",ne.globalAlpha=1),(Me.width<r||Me.height<t)&&(Me.width=_e(r),Me.height=_e(t))}function Sf(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function Af(r,t,e,i,s){const n=4*t;for(let o=i,a=i*n+4*e;o<=s;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function Ef(...r){var t,e,i;let s=r[0];s.canvas||(s={canvas:r[0],resolution:r[1]});const{canvas:n}=s,o=Math.min((t=s.resolution)!=null?t:1,1),a=(e=s.width)!=null?e:n.width,l=(i=s.height)!=null?i:n.height;let u=s.output;if(h2(a,l),!ne)throw new TypeError("Failed to get canvas 2D context");ne.drawImage(n,0,0,a,l,0,0,a*o,l*o);const c=ne.getImageData(0,0,a,l).data;let h=0,p=0,f=a-1,m=l-1;for(;p<l&&Sf(c,a,p);)++p;if(p===l)return z.EMPTY;for(;Sf(c,a,m);)--m;for(;Af(c,a,h,p,m);)++h;for(;Af(c,a,f,p,m);)--f;return++f,++m,ne.globalCompositeOperation="source-over",ne.strokeRect(h,p,f-h,m-p),ne.globalCompositeOperation="copy",u!=null||(u=new z),u.set(h/o,p/o,(f-h)/o,(m-p)/o),u}/**
* tiny-lru
*
* @copyright 2025 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 11.4.5
*/class d2{constructor(t=0,e=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){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,i=this.resetTtl){let s=null;if(this.has(t))this.set(t,e,!0,i);else{this.max>0&&this.size===this.max&&(s=Lx({},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 s}set(t,e,i=!1,s=this.resetTtl){let n=this.items[t];return i||n!==void 0?(n.value=e,i===!1&&s&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[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 d2(r,t,e)}const p2=["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 i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!p2.includes(s)&&(s=`"${s}"`),e[i]=s}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const pa={willReadFrequently:!0},jt=class G{static get experimentalLetterSpacingSupported(){let t=G._experimentalLetterSpacingSupported;if(t===void 0){const e=L.get().getCanvasRenderingContext2D().prototype;t=G._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,s,n,o,a,l,u){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=u}static measureText(t=" ",e,i=G._canvas,s=e.wordWrap){var n;const o=`${t}-${e.styleKey}-wordWrap-${s}`;if(G._measurementCache.has(o))return G._measurementCache.get(o);const a=Wr(e),l=G.measureFont(a);l.fontSize===0&&(l.fontSize=e.fontSize,l.ascent=e.fontSize);const u=G.__context;u.font=a;const c=(s?G._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),h=new Array(c.length);let p=0;for(let y=0;y<c.length;y++){const v=G._measureText(c[y],e.letterSpacing,u);h[y]=v,p=Math.max(p,v)}const f=((n=e._stroke)==null?void 0:n.width)||0;let m=p+f;e.dropShadow&&(m+=e.dropShadow.distance);const _=e.lineHeight||l.fontSize;let g=Math.max(_,l.fontSize+f)+(c.length-1)*(_+e.leading);e.dropShadow&&(g+=e.dropShadow.distance);const b=new G(t,e,m,g,c,h,_+e.leading,p,l);return G._measurementCache.set(o,b),b}static _measureText(t,e,i){let s=!1;G.experimentalLetterSpacingSupported&&(G.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const n=i.measureText(t);let o=n.width;const a=-n.actualBoundingBoxLeft;let l=n.actualBoundingBoxRight-a;if(o>0)if(s)o-=e,l-=e;else{const u=(G.graphemeSegmenter(t).length-1)*e;o+=u,l+=u}return Math.max(o,l)}static _wordWrap(t,e,i=G._canvas){const s=i.getContext("2d",pa);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:u,whiteSpace:c}=e,h=G._collapseSpaces(c),p=G._collapseNewlines(c);let f=!h;const m=e.wordWrapWidth+u,_=G._tokenize(t);for(let g=0;g<_.length;g++){let b=_[g];if(G._isNewline(b)){if(!p){a+=G._addLine(o),f=!h,o="",n=0;continue}b=" "}if(h){const v=G.isBreakingSpace(b),x=G.isBreakingSpace(o[o.length-1]);if(v&&x)continue}const y=G._getFromCache(b,u,l,s);if(y>m)if(o!==""&&(a+=G._addLine(o),o="",n=0),G.canBreakWords(b,e.breakWords)){const v=G.wordWrapSplit(b);for(let x=0;x<v.length;x++){let A=v[x],S=A,E=1;for(;v[x+E];){const O=v[x+E];if(!G.canBreakChars(S,O,b,x,e.breakWords))A+=O;else break;S=O,E++}x+=E-1;const M=G._getFromCache(A,u,l,s);M+n>m&&(a+=G._addLine(o),f=!1,o="",n=0),o+=A,n+=M}}else{o.length>0&&(a+=G._addLine(o),o="",n=0);const v=g===_.length-1;a+=G._addLine(b,!v),f=!1,o="",n=0}else y+n>m&&(f=!1,a+=G._addLine(o),o="",n=0),(o.length>0||!G.isBreakingSpace(b)||f)&&(o+=b,n+=y)}return a+=G._addLine(o,!1),a}static _addLine(t,e=!0){return t=G._trimRight(t),t=e?`${t}
`:t,t}static _getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=G._measureText(t,e,s)+e,i[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 i=t[e];if(!G.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:G._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:G._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){const n=t[s],o=t[s+1];if(G.isBreakingSpace(n,o)||G._isNewline(n)){i!==""&&(e.push(i),i=""),n==="\r"&&o===`
`?(e.push(`\r
`),s++):e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return G.graphemeSegmenter(t)}static measureFont(t){if(G._fonts[t])return G._fonts[t];const e=G._context;e.font=t;const i=e.measureText(G.METRICS_STRING+G.BASELINE_SYMBOL),s={ascent:i.actualBoundingBoxAscent,descent:i.actualBoundingBoxDescent,fontSize:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent};return G._fonts[t]=s,s}static clearMetrics(t=""){t?delete G._fonts[t]:G._fonts={}}static get _canvas(){if(!G.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",pa);if(i!=null&&i.measureText)return G.__canvas=e,e;t=L.get().createCanvas()}catch(e){t=L.get().createCanvas()}t.width=t.height=10,G.__canvas=t}return G.__canvas}static get _context(){return G.__context||(G.__context=G._canvas.getContext("2d",pa)),G.__context}};jt.METRICS_STRING="|\xC9q\xC5",jt.BASELINE_SYMBOL="M",jt.BASELINE_MULTIPLIER=1.4,jt.HEIGHT_MULTIPLIER=2,jt.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>{const e=r.segment(t),i=[];let s=0;for(const n of e)i[s++]=n.segment;return i}}return r=>[...r]})(),jt.experimentalLetterSpacing=!1,jt._fonts={},jt._newlines=[10,13],jt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],jt._measurementCache=Pf(1e3);let ht=jt;const wf=1e5;function Yr(r,t,e,i=0){var s;if(r.texture===w.WHITE&&!r.fill)return H.shared.setValue(r.color).setAlpha((s=r.alpha)!=null?s: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(C.shared);return a.scale(n.texture.frame.width,n.texture.frame.height),o.setTransform(a),o}else if(r.fill instanceof Qt){const n=r.fill,o=n.type==="linear",a=n.textureSpace==="local";let l=1,u=1;a&&e&&(l=e.width+i,u=e.height+i);let c,h=!1;if(o){const{start:p,end:f}=n;c=t.createLinearGradient(p.x*l,p.y*u,f.x*l,f.y*u),h=Math.abs(f.x-p.x)<Math.abs((f.y-p.y)*.1)}else{const{center:p,innerRadius:f,outerCenter:m,outerRadius:_}=n;c=t.createRadialGradient(p.x*l,p.y*u,f*l,m.x*l,m.y*u,_*l)}if(h&&a&&e){const p=e.lineHeight/u;for(let f=0;f<e.lines.length;f++){const m=(f*e.lineHeight+i/2)/u;n.colorStops.forEach(_=>{const g=m+_.offset*p;c.addColorStop(Math.floor(g*wf)/wf,H.shared.setValue(_.color).toHex())})}}else n.colorStops.forEach(p=>{c.addColorStop(p.offset,H.shared.setValue(p.color).toHex())});return c}}else{const n=t.createPattern(r.texture.source.resource,"repeat"),o=r.matrix.copyTo(C.shared);return o.scale(r.texture.frame.width,r.texture.frame.height),n.setTransform(o),n}return"red"}const Rf=new z;let f2=class{getCanvasAndContext(t){const{text:e,style:i,resolution:s=1}=t,n=i._getFinalPadding(),o=ht.measureText(e||" ",i),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*s),l=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*s),u=Jt.getOptimalCanvasAndContext(a,l);this._renderTextToCanvas(e,i,n,s,u);const c=i.trim?Ef({canvas:u.canvas,width:a,height:l,resolution:1,output:Rf}):Rf.set(0,0,a,l);return{canvasAndContext:u,frame:c}}returnCanvasAndContext(t){Jt.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,i,s,n){var o,a,l,u,c;const{canvas:h,context:p}=n,f=Wr(e),m=ht.measureText(t||" ",e),_=m.lines,g=m.lineHeight,b=m.lineWidths,y=m.maxLineWidth,v=m.fontProperties,x=h.height;if(p.resetTransform(),p.scale(s,s),p.textBaseline=e.textBaseline,(o=e._stroke)!=null&&o.width){const M=e._stroke;p.lineWidth=M.width,p.miterLimit=M.miterLimit,p.lineJoin=M.join,p.lineCap=M.cap}p.font=f;let A,S;const E=e.dropShadow?2:1;for(let M=0;M<E;++M){const O=e.dropShadow&&M===0,P=O?Math.ceil(Math.max(1,x)+i*2):0,R=P*s;if(O){p.fillStyle="black",p.strokeStyle="black";const B=e.dropShadow,mt=B.color,I=B.alpha;p.shadowColor=H.shared.setValue(mt).setAlpha(I).toRgbaString();const D=B.blur*s,gn=B.distance*s;p.shadowBlur=D,p.shadowOffsetX=Math.cos(B.angle)*gn,p.shadowOffsetY=Math.sin(B.angle)*gn+R}else{if(p.fillStyle=e._fill?Yr(e._fill,p,m,i*2):null,(a=e._stroke)!=null&&a.width){const B=e._stroke.width*.5+i*2;p.strokeStyle=Yr(e._stroke,p,m,B)}p.shadowColor="black"}let U=(g-v.fontSize)/2;g-v.fontSize<0&&(U=0);const k=(u=(l=e._stroke)==null?void 0:l.width)!=null?u:0;for(let B=0;B<_.length;B++)A=k/2,S=k/2+B*g+v.ascent+U,e.align==="right"?A+=y-b[B]:e.align==="center"&&(A+=(y-b[B])/2),(c=e._stroke)!=null&&c.width&&this._drawLetterSpacing(_[B],e,n,A+i,S+i-P,!0),e._fill!==void 0&&this._drawLetterSpacing(_[B],e,n,A+i,S+i-P)}}_drawLetterSpacing(t,e,i,s,n,o=!1){const{context:a}=i,l=e.letterSpacing;let u=!1;if(ht.experimentalLetterSpacingSupported&&(ht.experimentalLetterSpacing?(a.letterSpacing=`${l}px`,a.textLetterSpacing=`${l}px`,u=!0):(a.letterSpacing="0px",a.textLetterSpacing="0px")),l===0||u){o?a.strokeText(t,s,n):a.fillText(t,s,n);return}let c=s;const h=ht.graphemeSegmenter(t);let p=a.measureText(t).width,f=0;for(let m=0;m<h.length;++m){const _=h[m];o?a.strokeText(_,c,n):a.fillText(_,c,n);let g="";for(let b=m+1;b<h.length;++b)g+=h[b];f=a.measureText(g).width,c+=p-f+l,p=f}}};const or=new f2;class fa{constructor(t){this._activeTextures={},this._renderer=t}getTexture(t,e,i,s){var n;typeof t=="string"&&(t={text:t,style:i,resolution:e}),t.style instanceof Mt||(t.style=new Mt(t.style)),t.textureStyle instanceof Et||(t.textureStyle=new Et(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:o,style:a,textureStyle:l}=t,u=(n=t.resolution)!=null?n:this._renderer.resolution,{frame:c,canvasAndContext:h}=or.getCanvasAndContext({text:o,style:a,resolution:u}),p=da(h.canvas,c.width,c.height,u);if(l&&(p.source.style=l),a.trim&&(c.pad(a.padding),p.frame.copyFrom(c),p.frame.scale(1/u),p.updateUvs()),a.filters){const f=this._applyFilters(p,a.filters);return this.returnTexture(p),or.returnCanvasAndContext(h),f}return this._renderer.texture.initSource(p._source),or.returnCanvasAndContext(h),p}returnTexture(t){const e=t.source;e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",et.returnTexture(t,!0)}renderTextToCanvas(){}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const i=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle});return this._activeTextures[e]={texture:i,usageCount:1},i}decreaseReferenceCount(t){const e=this._activeTextures[t];e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null)}getReferenceCount(t){var e,i;return(i=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?i:0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const i=this._renderer.renderTarget.renderTarget,s=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(i,!1),s}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}fa.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"canvasText"},F.add(fa),F.add(qo);var m2=Object.defineProperty,ms=Object.getOwnPropertySymbols,Cf=Object.prototype.hasOwnProperty,Mf=Object.prototype.propertyIsEnumerable,Of=(r,t,e)=>t in r?m2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,g2=(r,t)=>{for(var e in t||(t={}))Cf.call(t,e)&&Of(r,e,t[e]);if(ms)for(var e of ms(t))Mf.call(t,e)&&Of(r,e,t[e]);return r},_2=(r,t)=>{var e={};for(var i in r)Cf.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ms)for(var i of ms(r))t.indexOf(i)<0&&Mf.call(r,i)&&(e[i]=r[i]);return e};class ar extends Kt{constructor(t){t instanceof pt&&(t={context:t});const e=t||{},{context:i,roundPixels:s}=e,n=_2(e,["context","roundPixels"]);super(g2({label:"Graphics"},n)),this.renderPipeId="graphics",i?this.context=i:(this.context=this._ownedContext=new pt,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=s!=null?s:!1}set context(t){t!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=t,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_onTouch(t){this._gcLastUsed=t,this._context._gcLastUsed=t}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new ar(this._context.clone()):(this._ownedContext=null,new ar(this._context))}lineStyle(t,e,i){const s={};return t&&(s.width=t),e&&(s.color=e),i&&(s.alpha=i),this.context.strokeStyle=s,this}beginFill(t,e){const i={};return t!==void 0&&(i.color=t),e!==void 0&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){this.context.fill();const t=this.context.strokeStyle;return(t.width!==pt.defaultStrokeStyle.width||t.color!==pt.defaultStrokeStyle.color||t.alpha!==pt.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 Gf={name:"local-uniform-msdf-bit",vertex:{header:`
struct LocalUniforms {
uColor:vec4<f32>,
uTransformMatrix:mat3x3<f32>,
uDistance: f32,
uRound:f32,
}
@group(2) @binding(0) var<uniform> 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<f32>,
uTransformMatrix:mat3x3<f32>,
uDistance: f32
}
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
`,main:`
outColor = vec4<f32>(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));
`}},If={name:"msdf-bit",fragment:{header:`
fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, 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<f32>(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;
}
`}},Ff={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 ma,ga;class Df extends wt{constructor(t){const e=new nt({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new C,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});ma!=null||(ma=Ke({name:"sdf-shader",bits:[Vi,Yi(t),Gf,If,Ze]})),ga!=null||(ga=qe({name:"sdf-shader",bits:[Wi,Ki(t),Bf,Ff,Qe]})),super({glProgram:ga,gpuProgram:ma,resources:{localUniforms:e,batchSamplers:qi(t)}})}}class _a extends gt{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 i in this.chars)(e=this.chars[i].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(i=>i.texture.destroy(!0)),this.pages=null)}}var b2=Object.defineProperty,Uf=Object.getOwnPropertySymbols,v2=Object.prototype.hasOwnProperty,y2=Object.prototype.propertyIsEnumerable,kf=(r,t,e)=>t in r?b2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$f=(r,t)=>{for(var e in t||(t={}))v2.call(t,e)&&kf(r,e,t[e]);if(Uf)for(var e of Uf(t))y2.call(t,e)&&kf(r,e,t[e]);return r};const Lf=class Kx extends _a{constructor(t){var e,i,s;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=$f($f({},Kx.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=w.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=(i=n.resolution)!=null?i:1,this._padding=(s=n.padding)!=null?s:4,n.textureStyle&&(this._textureStyle=n.textureStyle instanceof Et?n.textureStyle:new Et(n.textureStyle)),this.fontMetrics=ht.measureFont(l),this.lineHeight=o.lineHeight||this.fontMetrics.fontSize||o.fontSize}ensureCharacters(t){var e,i,s,n;const o=ht.graphemeSegmenter(t).filter(x=>!this._currentChars.includes(x)).filter((x,A,S)=>S.indexOf(x)===A);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,c=a.texture.source;const h=this._style;let p=this._currentX,f=this._currentY,m=this._currentMaxCharHeight;const _=this.baseRenderedFontSize/this.baseMeasurementFontSize,g=this._padding*_;let b=!1;const y=l.width/this.resolution,v=l.height/this.resolution;for(let x=0;x<o.length;x++){const A=o[x],S=ht.measureText(A,h,l,!1);S.lineHeight=S.height;const E=S.width*_,M=Math.ceil((h.fontStyle==="italic"?2:1)*E),O=S.height*_,P=M+g*2,R=O+g*2;if(b=!1,A!==`
`&&A!=="\r"&&A!==" "&&A!==" "&&(b=!0,m=Math.ceil(Math.max(R,m))),p+P>y&&(f+=m,m=R,p=0,f+m>v)){c.update();const k=this._nextPage();l=k.canvasAndContext.canvas,u=k.canvasAndContext.context,c=k.texture.source,p=0,f=0,m=0}const U=E/_-((i=(e=h.dropShadow)==null?void 0:e.distance)!=null?i:0)-((n=(s=h._stroke)==null?void 0:s.width)!=null?n:0);if(this.chars[A]={id:A.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:U,kerning:{}},b){this._drawGlyph(u,S,p+g,f+g,_,h);const k=c.width*_,B=c.height*_,mt=new z(p/k*c.width,f/B*c.height,P/k*c.width,R/B*c.height);this.chars[A].texture=new w({source:c,frame:mt}),p+=Math.ceil(P)}}c.update(),this._currentX=p,this._currentY=f,this._currentMaxCharHeight=m,this._skipKerning&&this._applyKerning(o,u)}get pageTextures(){return this.pages}_applyKerning(t,e){const i=this._measureCache;for(let s=0;s<t.length;s++){const n=t[s];for(let o=0;o<this._currentChars.length;o++){const a=this._currentChars[o];let l=i[n];l||(l=i[n]=e.measureText(n).width);let u=i[a];u||(u=i[a]=e.measureText(a).width);let c=e.measureText(n+a).width,h=c-(l+u);h&&(this.chars[n].kerning[a]=h),c=e.measureText(n+a).width,h=c-(l+u),h&&(this.chars[a].kerning[n]=h)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=Jt.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),s=new w({source:new le({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(s.source.style=this._textureStyle);const n={canvasAndContext:e,texture:s};return this.pages[this._currentPageIndex]=n,n}_setupContext(t,e,i){var s;e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=Wr(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const n=e._stroke,o=(s=n==null?void 0:n.width)!=null?s:0;if(n&&(t.lineWidth=o,t.lineJoin=n.join,t.miterLimit=n.miterLimit,t.strokeStyle=Yr(n,t)),e._fill&&(t.fillStyle=Yr(e._fill,t)),e.dropShadow){const a=e.dropShadow,l=H.shared.setValue(a.color).toArray(),u=a.blur*i,c=a.distance*i;t.shadowColor=`rgba(${l[0]*255},${l[1]*255},${l[2]*255},${a.alpha})`,t.shadowBlur=u,t.shadowOffsetX=Math.cos(a.angle)*c,t.shadowOffsetY=Math.sin(a.angle)*c}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,i,s,n,o){var a;const l=e.text,u=e.fontProperties,c=o._stroke,h=((a=c==null?void 0:c.width)!=null?a:0)*n,p=i+h/2,f=s-h/2,m=u.descent*n,_=e.lineHeight*n;let g=!1;o.stroke&&h&&(g=!0,t.strokeText(l,p,f+_-m));const{shadowBlur:b,shadowOffsetX:y,shadowOffsetY:v}=t;o._fill&&(g&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(l,p,f+_-m)),g&&(t.shadowBlur=b,t.shadowOffsetX=y,t.shadowOffsetY=v)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];Jt.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}};Lf.defaultOptions={textureSize:512,style:new Mt,mipmap:!0};let ba=Lf;function gs(r,t,e,i){const s={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};s.offsetY=e.baseLineOffset;let n=s.lines[0],o=null,a=!0;const l={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},u=e.baseMeasurementFontSize/t.fontSize,c=t.letterSpacing*u,h=t.wordWrapWidth*u,p=t.lineHeight?t.lineHeight*u:e.lineHeight,f=t.wordWrap&&t.breakWords,m=b=>{const y=n.width;for(let v=0;v<l.index;v++){const x=b.positions[v];n.chars.push(b.chars[v]),n.charPositions.push(x+y)}n.width+=b.width,a=!1,l.width=0,l.index=0,l.chars.length=0},_=()=>{let b=n.chars.length-1;if(i){let y=n.chars[b];for(;y===" ";)n.width-=e.chars[y].xAdvance,y=n.chars[--b]}s.width=Math.max(s.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,s.lines.push(n),s.height+=p},g=b=>b-c>h;for(let b=0;b<r.length+1;b++){let y;const v=b===r.length;v||(y=r[b]);const x=e.chars[y]||e.chars[" "];if(/(?:\s)/.test(y)||y==="\r"||y===`
`||v){if(!a&&t.wordWrap&&g(n.width+l.width)?(_(),m(l),v||n.charPositions.push(0)):(l.start=n.width,m(l),v||n.charPositions.push(0)),y==="\r"||y===`
`)_();else if(!v){const A=x.xAdvance+(x.kerning[o]||0)+c;n.width+=A,n.spaceWidth=A,n.spacesIndex.push(n.charPositions.length),n.chars.push(y)}}else{const A=x.kerning[o]||0,S=x.xAdvance+A+c;f&&g(n.width+l.width+S)&&(m(l),_()),l.positions[l.index++]=l.width+A,l.chars.push(y),l.width+=S}o=y}return _(),t.align==="center"?x2(s):t.align==="right"?T2(s):t.align==="justify"&&S2(s),s}function x2(r){for(let t=0;t<r.lines.length;t++){const e=r.lines[t],i=r.width/2-e.width/2;for(let s=0;s<e.charPositions.length;s++)e.charPositions[s]+=i}}function T2(r){for(let t=0;t<r.lines.length;t++){const e=r.lines[t],i=r.width-e.width;for(let s=0;s<e.charPositions.length;s++)e.charPositions[s]+=i}}function S2(r){const t=r.width;for(let e=0;e<r.lines.length;e++){const i=r.lines[e];let s=0,n=i.spacesIndex[s++],o=0;const a=i.spacesIndex.length,l=(t-i.width)/a;for(let u=0;u<i.charPositions.length;u++)u===n&&(n=i.spacesIndex[s++],o+=l),i.charPositions[u]+=o}}function Nf(r){if(r==="")return[];typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const s=r[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);if(s[0].length===0||s[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const n=s[0].charCodeAt(0),o=s[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...Array.from(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}var A2=Object.defineProperty,Xf=Object.getOwnPropertySymbols,E2=Object.prototype.hasOwnProperty,P2=Object.prototype.propertyIsEnumerable,Hf=(r,t,e)=>t in r?A2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,va=(r,t)=>{for(var e in t||(t={}))E2.call(t,e)&&Hf(r,e,t[e]);if(Xf)for(var e of Xf(t))P2.call(t,e)&&Hf(r,e,t[e]);return r};let _s=0,w2=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 i;let s=`${e.fontFamily}-bitmap`,n=!0;if(e._fill.fill&&!e._stroke?(s+=e._fill.fill.styleKey,n=!1):(e._stroke||e.dropShadow)&&(s=`${e.styleKey}-bitmap`,n=!1),!V.has(s)){const a=Object.create(e);a.lineHeight=0;const l=new ba(va({style:a,overrideFill:n,overrideSize:!0},this.defaultOptions));_s++,_s>50&&Xt("BitmapText",`You have dynamically created ${_s} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),l.once("destroy",()=>{_s--,V.remove(s)}),V.set(s,l)}const o=V.get(s);return(i=o.ensureCharacters)==null||i.call(o,t),o}getLayout(t,e,i=!0){const s=this.getFont(t,e),n=`${t}-${e.styleKey}-${i}`;if(this.measureCache.has(n))return this.measureCache.get(n);const o=ht.graphemeSegmenter(t),a=gs(o,e,s,i);return this.measureCache.set(n,a),a}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var e,i,s,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:(i=t[2])==null?void 0:i.resolution,padding:(s=t[2])==null?void 0:s.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=va(va({},this.defaultOptions),a);const u=a.style,c=u instanceof Mt?u:new Mt(u),h=(o=a.dynamicFill)!=null?o:this._canUseTintForStyle(c),p=new ba({style:c,overrideFill:h,skipKerning:a.skipKerning,padding:a.padding,resolution:a.resolution,overrideSize:!1,textureStyle:a.textureStyle}),f=Nf(a.chars);return p.ensureCharacters(f.join("")),V.set(`${l}-bitmap`,p),p.once("destroy",()=>V.remove(`${l}-bitmap`)),p}uninstall(t){const e=`${t}-bitmap`,i=V.get(e);i&&i.destroy()}_canUseTintForStyle(t){return!t._stroke&&(!t.dropShadow||t.dropShadow.color===0)&&!t._fill.fill&&t._fill.color===16777215}};const lr=new w2;class jf extends ar{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class ya{constructor(t){this._renderer=t,this._managedBitmapTexts=new xt({renderer:t,type:"renderable",priority:-2,name:"bitmapText"})}validateRenderable(t){const e=this._getGpuBitmapText(t);return this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const i=this._getGpuBitmapText(t);zf(t,i),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,i)),this._renderer.renderPipes.graphics.addRenderable(i,e),i.context.customShader&&this._updateDistanceField(t)}updateRenderable(t){const e=this._getGpuBitmapText(t);zf(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:i}=e,s=lr.getFont(t.text,t._style);i.clear(),s.distanceField.type!=="none"&&(i.customShader||(i.customShader=new Df(this._renderer.limits.maxBatchableTextures)));const n=ht.graphemeSegmenter(t.text),o=t._style;let a=s.baseLineOffset;const l=gs(n,o,s,!0),u=o.padding,c=l.scale;let h=l.width,p=l.height+l.offsetY;o._stroke&&(h+=o._stroke.width/c,p+=o._stroke.width/c),i.translate(-t._anchor._x*h-u,-t._anchor._y*p-u).scale(c,c);const f=s.applyFillAsTint?o._fill.color:16777215;let m=s.fontMetrics.fontSize,_=s.lineHeight;o.lineHeight&&(m=o.fontSize/c,_=o.lineHeight/c);let g=(_-m)/2;g-s.baseLineOffset<0&&(g=0);for(let b=0;b<l.lines.length;b++){const y=l.lines[b];for(let v=0;v<y.charPositions.length;v++){const x=y.chars[v],A=s.chars[x];if(A!=null&&A.texture){const S=A.texture;i.texture(S,f||"black",Math.round(y.charPositions[v]+A.xOffset),Math.round(a+A.yOffset+g),S.orig.width,S.orig.height)}}a+=_}}_getGpuBitmapText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new jf;return t._gpuData[this._renderer.uid]=e,this._updateContext(t,e),this._managedBitmapTexts.add(t),e}_updateDistanceField(t){const e=this._getGpuBitmapText(t).context,i=t._style.fontFamily,s=V.get(`${i}-bitmap`),{a:n,b:o,c:a,d:l}=t.groupTransform,u=Math.sqrt(n*n+o*o),c=Math.sqrt(a*a+l*l),h=(Math.abs(u)+Math.abs(c))/2,p=s.baseRenderedFontSize/t._style.fontSize,f=h*s.distanceField.range*(1/p);e.customShader.resources.localUniforms.uniforms.uDistance=f}destroy(){this._managedBitmapTexts.destroy(),this._renderer=null,this._managedBitmapTexts=null}}ya.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"bitmapText"};function zf(r,t){t.groupTransform=r.groupTransform,t.groupColorAlpha=r.groupColorAlpha,t.groupColor=r.groupColor,t.groupBlendMode=r.groupBlendMode,t.globalDisplayStatus=r.globalDisplayStatus,t.groupTransform=r.groupTransform,t.localDisplayStatus=r.localDisplayStatus,t.groupAlpha=r.groupAlpha,t._roundPixels=r._roundPixels}F.add(ya);class Vf extends Nr{constructor(){super(...arguments),this.generatingTexture=!1,this.currentKey="--"}destroy(){this.texturePromise=null,this.generatingTexture=!1,this.currentKey="--",super.destroy()}}class xa{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new xt({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"htmlText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const s=t._autoResolution?this._renderer.resolution:t.resolution;(i.currentKey!==t.styleKey||t.resolution!==s)&&this._updateGpuText(t).catch(n=>{console.error(n)}),t._didTextUpdate=!1,as(i,t)}this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}async _updateGpuText(t){t._didTextUpdate=!1;const e=this._getGpuText(t);if(e.generatingTexture)return;const i=e.texturePromise;e.texturePromise=null,e.generatingTexture=!0,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;let s=this._renderer.htmlText.getTexturePromise(t);i&&(s=s.finally(()=>{this._renderer.htmlText.decreaseReferenceCount(e.currentKey),this._renderer.htmlText.returnTexturePromise(i)})),e.texturePromise=s,e.currentKey=t.styleKey,e.texture=await s;const n=t.renderGroup||t.parentRenderGroup;n&&(n.structureDidChange=!0),e.generatingTexture=!1,as(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Vf;return e.renderable=t,e.transform=t.groupTransform,e.texture=w.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,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{htmlText:i}=this._renderer;i.getReferenceCount(e.currentKey)===null?i.returnTexturePromise(e.texturePromise):i.decreaseReferenceCount(e.currentKey)}destroy(){this._managedTexts.destroy(),this._renderer=null}}xa.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"htmlText"};function Wf(){const{userAgent:r}=L.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}const Yf="http://www.w3.org/2000/svg",Kf="http://www.w3.org/1999/xhtml";class Ta{constructor(){this.svgRoot=document.createElementNS(Yf,"svg"),this.foreignObject=document.createElementNS(Yf,"foreignObject"),this.domElement=document.createElementNS(Kf,"div"),this.styleElement=document.createElementNS(Kf,"style");const{foreignObject:t,svgRoot:e,styleElement:i,domElement:s}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(i),t.appendChild(s),this.image=L.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 qf(r,t){const e=t.fontFamily,i=[],s={},n=/font-family:([^;"\s]+)/g,o=r.match(n);function a(l){s[l]||(i.push(l),s[l]=!0)}if(Array.isArray(e))for(let l=0;l<e.length;l++)a(e[l]);else a(e);o&&o.forEach(l=>{const u=l.split(":")[1].trim();a(u)});for(const l in t.tagStyles){const u=t.tagStyles[l].fontFamily;a(u)}return i}async function Zf(r){const t=await(await L.get().fetch(r)).blob(),e=new FileReader;return await new Promise((i,s)=>{e.onloadend=()=>i(e.result),e.onerror=s,e.readAsDataURL(t)})}async function Qf(r,t){const e=await Zf(t);return`@font-face {
font-family: "${r.fontFamily}";
font-weight: ${r.fontWeight};
font-style: ${r.fontStyle};
src: url('${e}');
}`}const bs=new Map;async function Jf(r){const t=r.filter(e=>V.has(`${e}-and-url`)).map(e=>{if(!bs.has(e)){const{entries:i}=V.get(`${e}-and-url`),s=[];i.forEach(n=>{const o=n.url,a=n.faces.map(l=>({weight:l.weight,style:l.style}));s.push(...a.map(l=>Qf({fontWeight:l.weight,fontStyle:l.style,fontFamily:e},o)))}),bs.set(e,Promise.all(s).then(n=>n.join(`
`)))}return bs.get(e)});return(await Promise.all(t)).join(`
`)}function tm(r,t,e,i,s){const{domElement:n,styleElement:o,svgRoot:a}=s;n.innerHTML=`<style>${t.cssStyle}</style><div style='padding:0;'>${r}</div>`,n.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),o.textContent=i;const{width:l,height:u}=s.image;return a.setAttribute("width",l.toString()),a.setAttribute("height",u.toString()),new XMLSerializer().serializeToString(a)}function em(r,t){const e=Jt.getOptimalCanvasAndContext(r.width,r.height,t),{context:i}=e;return i.clearRect(0,0,r.width,r.height),i.drawImage(r,0,0),e}function rm(r,t,e){return new Promise(async i=>{e&&await new Promise(s=>setTimeout(s,100)),r.onload=()=>{i()},r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,r.crossOrigin="anonymous"})}let im;function Sa(r,t,e,i){i||(i=im||(im=new Ta));const{domElement:s,styleElement:n,svgRoot:o}=i;s.innerHTML=`<style>${t.cssStyle};</style><div style='padding:0'>${r}</div>`,s.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(n.textContent=e),document.body.appendChild(o);const a=s.getBoundingClientRect();o.remove();const l=t.padding*2;return{width:a.width-l,height:a.height-l}}class Aa{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===yt.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 i=this._buildTexturePromise(t).then(s=>(this._activeTextures[e].texture=s,s));return this._activeTextures[e]={texture:null,promise:i,usageCount:1},i}getReferenceCount(t){var e,i;return(i=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?i: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(i=>{e.texture=i,this._cleanUp(e.texture)}).catch(()=>{}),this._activeTextures[t]=null))}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){const{text:e,style:i,resolution:s,textureStyle:n}=t,o=st.get(Ta),a=qf(e,i),l=await Jf(a),u=Sa(e,i,l,o),c=Math.ceil(Math.ceil(Math.max(1,u.width)+i.padding*2)*s),h=Math.ceil(Math.ceil(Math.max(1,u.height)+i.padding*2)*s),p=o.image,f=2;p.width=(c|0)+f,p.height=(h|0)+f;const m=tm(e,i,s,l,o);await rm(p,m,Wf()&&a.length>0);const _=p;let g;this._createCanvas&&(g=em(p,s));const b=da(g?g.canvas:_,p.width-f,p.height-f,s);return n&&(b.source.style=n),this._createCanvas&&(this._renderer.texture.initSource(b.source),Jt.returnCanvasAndContext(g)),st.return(o),b}returnTexturePromise(t){t.then(e=>{this._cleanUp(e)}).catch(()=>{})}_cleanUp(t){et.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}}Aa.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"htmlText"},F.add(Aa),F.add(xa);var R2=Object.defineProperty,sm=Object.getOwnPropertySymbols,C2=Object.prototype.hasOwnProperty,M2=Object.prototype.propertyIsEnumerable,nm=(r,t,e)=>t in r?R2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,om=(r,t)=>{for(var e in t||(t={}))C2.call(t,e)&&nm(r,e,t[e]);if(sm)for(var e of sm(t))M2.call(t,e)&&nm(r,e,t[e]);return r};const am=class qx extends Ee{constructor(...t){var e;let i=(e=t[0])!=null?e:{};i instanceof Float32Array&&(i={positions:i,uvs:t[1],indices:t[2]}),i=om(om({},qx.defaultOptions),i);const s=i.positions||new Float32Array([0,0,1,0,1,1,0,1]);let n=i.uvs;n||(i.positions?n=new Float32Array(s.length):n=new Float32Array([0,0,1,0,1,1,0,1]));const o=i.indices||new Uint32Array([0,1,2,0,2,3]),a=i.shrinkBuffersToFit,l=new bt({data:s,label:"attribute-mesh-positions",shrinkToFit:a,usage:X.VERTEX|X.COPY_DST}),u=new bt({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:X.VERTEX|X.COPY_DST}),c=new bt({data:o,label:"index-mesh-buffer",shrinkToFit:a,usage:X.INDEX|X.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:c,topology:i.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}};am.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let ce=am;var O2=Object.defineProperty,G2=Object.defineProperties,B2=Object.getOwnPropertyDescriptors,lm=Object.getOwnPropertySymbols,I2=Object.prototype.hasOwnProperty,F2=Object.prototype.propertyIsEnumerable,um=(r,t,e)=>t in r?O2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cm=(r,t)=>{for(var e in t||(t={}))I2.call(t,e)&&um(r,e,t[e]);if(lm)for(var e of lm(t))F2.call(t,e)&&um(r,e,t[e]);return r},hm=(r,t)=>G2(r,B2(t));const ur={name:"local-uniform-bit",vertex:{header:`
struct LocalUniforms {
uTransformMatrix:mat3x3<f32>,
uColor:vec4<f32>,
uRound:f32,
}
@group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
`,main:`
vColor *= localUniforms.uColor;
modelMatrix *= localUniforms.uTransformMatrix;
`,end:`
if(localUniforms.uRound == 1)
{
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
}
`}},dm=hm(cm({},ur),{vertex:hm(cm({},ur.vertex),{header:ur.vertex.header.replace("group(1)","group(2)")})}),vs={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);
}
`}},pm={name:"tiling-bit",vertex:{header:`
struct TilingUniforms {
uMapCoord:mat3x3<f32>,
uClampFrame:vec4<f32>,
uClampOffset:vec2<f32>,
uTextureTransform:mat3x3<f32>,
uSizeAnchor:vec4<f32>
};
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
@group(2) @binding(1) var uTexture: texture_2d<f32>;
@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<f32>,
uClampFrame:vec4<f32>,
uClampOffset:vec2<f32>,
uTextureTransform:mat3x3<f32>,
uSizeAnchor:vec4<f32>
};
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
@group(2) @binding(1) var uTexture: texture_2d<f32>;
@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);
`}},fm={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 Ea,Pa;class mm extends wt{constructor(){Ea!=null||(Ea=Ke({name:"tiling-sprite-shader",bits:[ur,pm,Ze]})),Pa!=null||(Pa=qe({name:"tiling-sprite-shader",bits:[vs,fm,Qe]}));const t=new nt({uMapCoord:{value:new C,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new C,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:Pa,gpuProgram:Ea,resources:{localUniforms:new nt({uTransformMatrix:{value:new C,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:w.EMPTY.source,uSampler:w.EMPTY.source.style}})}updateUniforms(t,e,i,s,n,o){const a=this.resources.tilingUniforms,l=o.width,u=o.height,c=o.textureMatrix,h=a.uniforms.uTextureTransform;h.set(i.a*l/t,i.b*l/e,i.c*u/t,i.d*u/e,i.tx/t,i.ty/e),h.invert(),a.uniforms.uMapCoord=c.mapCoord,a.uniforms.uClampFrame=c.uClampFrame,a.uniforms.uClampOffset=c.uClampOffset,a.uniforms.uTextureTransform=h,a.uniforms.uSizeAnchor[0]=t,a.uniforms.uSizeAnchor[1]=e,a.uniforms.uSizeAnchor[2]=s,a.uniforms.uSizeAnchor[3]=n,o&&(this.resources.uTexture=o.source,this.resources.uSampler=o.source.style)}}class gm extends ce{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}}function _m(r,t){const e=r.anchor.x,i=r.anchor.y;t[0]=-e*r.width,t[1]=-i*r.height,t[2]=(1-e)*r.width,t[3]=-i*r.height,t[4]=(1-e)*r.width,t[5]=(1-i)*r.height,t[6]=-e*r.width,t[7]=(1-i)*r.height}function bm(r,t,e,i){let s=0;const n=r.length/(t||2),o=i.a,a=i.b,l=i.c,u=i.d,c=i.tx,h=i.ty;for(e*=t;s<n;){const p=r[e],f=r[e+1];r[e]=o*p+l*f+c,r[e+1]=a*p+u*f+h,e+=t,s++}}function vm(r,t){const e=r.texture,i=e.frame.width,s=e.frame.height;let n=0,o=0;r.applyAnchorToTexture&&(n=r.anchor.x,o=r.anchor.y),t[0]=t[6]=-n,t[2]=t[4]=1-n,t[1]=t[3]=-o,t[5]=t[7]=1-o;const a=C.shared;a.copyFrom(r._tileTransform.matrix),a.tx/=r.width,a.ty/=r.height,a.invert(),a.scale(r.width/i,r.height/s),bm(t,2,0,a)}const ys=new gm;class ym{constructor(){this.canBatch=!0,this.geometry=new ce({indices:ys.indices.slice(),positions:ys.positions.slice(),uvs:ys.uvs.slice()})}destroy(){var t;this.geometry.destroy(),(t=this.shader)==null||t.destroy()}}class wa{constructor(t){this._state=Rt.default2d,this._renderer=t,this._managedTilingSprites=new xt({renderer:t,type:"renderable",name:"tilingSprite"})}validateRenderable(t){const e=this._getTilingSpriteData(t),i=e.canBatch;this._updateCanBatch(t);const s=e.canBatch;if(s&&s===i){const{batchableMesh:n}=e;return!n._batcher.checkAndUpdateTexture(n,t.texture)}return i!==s}addRenderable(t,e){const i=this._renderer.renderPipes.batch;this._updateCanBatch(t);const s=this._getTilingSpriteData(t),{geometry:n,canBatch:o}=s;if(o){s.batchableMesh||(s.batchableMesh=new os);const a=s.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),a.geometry=n,a.renderable=t,a.transform=t.groupTransform,a.setTexture(t._texture)),a.roundPixels=this._renderer._roundPixels|t._roundPixels,i.addToBatch(a,e)}else i.break(e),s.shader||(s.shader=new mm),this.updateRenderable(t),e.add(t)}execute(t){const{shader:e}=this._getTilingSpriteData(t);e.groups[0]=this._renderer.globalUniforms.bindGroup;const i=e.resources.localUniforms.uniforms;i.uTransformMatrix=t.groupTransform,i.uRound=this._renderer._roundPixels|t._roundPixels,rr(t.groupColorAlpha,i.uColor,0),this._state.blendMode=ze(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:ys,shader:e,state:this._state})}updateRenderable(t){const e=this._getTilingSpriteData(t),{canBatch:i}=e;if(i){const{batchableMesh:s}=e;t.didViewUpdate&&this._updateBatchableMesh(t),s._batcher.updateElement(s)}else if(t.didViewUpdate){const{shader:s}=e;s.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}}_getTilingSpriteData(t){return t._gpuData[this._renderer.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){const e=new ym;return e.renderable=t,t._gpuData[this._renderer.uid]=e,this._managedTilingSprites.add(t),e}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:i}=e,s=t.texture.source.style;s.addressMode!=="repeat"&&(s.addressMode="repeat",s.update()),vm(t,i.uvs),_m(t,i.positions)}destroy(){this._managedTilingSprites.destroy(),this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),i=t.texture;let s=!0;return this._renderer.type===yt.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=i.textureMatrix.isSimple&&(s||i.source.isPowerOfTwo),e.canBatch}}wa.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"tilingSprite"},F.add(wa);var D2=Object.defineProperty,xm=Object.getOwnPropertySymbols,U2=Object.prototype.hasOwnProperty,k2=Object.prototype.propertyIsEnumerable,Tm=(r,t,e)=>t in r?D2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Sm=(r,t)=>{for(var e in t||(t={}))U2.call(t,e)&&Tm(r,e,t[e]);if(xm)for(var e of xm(t))k2.call(t,e)&&Tm(r,e,t[e]);return r};const Am=class Zx extends ce{constructor(...t){var e;super({});let i=(e=t[0])!=null?e:{};typeof i=="number"&&(i={width:i,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(i)}build(t){var e,i,s,n;t=Sm(Sm({},Zx.defaultOptions),t),this.verticesX=(e=this.verticesX)!=null?e:t.verticesX,this.verticesY=(i=this.verticesY)!=null?i:t.verticesY,this.width=(s=this.width)!=null?s:t.width,this.height=(n=this.height)!=null?n:t.height;const o=this.verticesX*this.verticesY,a=[],l=[],u=[],c=this.verticesX-1,h=this.verticesY-1,p=this.width/c,f=this.height/h;for(let _=0;_<o;_++){const g=_%this.verticesX,b=_/this.verticesX|0;a.push(g*p,b*f),l.push(g/c,b/h)}const m=c*h;for(let _=0;_<m;_++){const g=_%c,b=_/c|0,y=b*this.verticesX+g,v=b*this.verticesX+g+1,x=(b+1)*this.verticesX+g,A=(b+1)*this.verticesX+g+1;u.push(y,v,x,v,A,x)}this.buffers[0].data=new Float32Array(a),this.buffers[1].data=new Float32Array(l),this.indexBuffer.data=new Uint32Array(u),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};Am.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let xs=Am;var $2=Object.defineProperty,Em=Object.getOwnPropertySymbols,L2=Object.prototype.hasOwnProperty,N2=Object.prototype.propertyIsEnumerable,Pm=(r,t,e)=>t in r?$2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wm=(r,t)=>{for(var e in t||(t={}))L2.call(t,e)&&Pm(r,e,t[e]);if(Em)for(var e of Em(t))N2.call(t,e)&&Pm(r,e,t[e]);return r};const Rm=class Qx extends xs{constructor(t={}){t=wm(wm({},Qx.defaultOptions),t),super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){var e,i,s,n,o,a,l,u,c,h;this.width=(e=t.width)!=null?e:this.width,this.height=(i=t.height)!=null?i:this.height,this._originalWidth=(s=t.originalWidth)!=null?s:this._originalWidth,this._originalHeight=(n=t.originalHeight)!=null?n:this._originalHeight,this._leftWidth=(o=t.leftWidth)!=null?o:this._leftWidth,this._rightWidth=(a=t.rightWidth)!=null?a:this._rightWidth,this._topHeight=(l=t.topHeight)!=null?l:this._topHeight,this._bottomHeight=(u=t.bottomHeight)!=null?u:this._bottomHeight,this._anchorX=(c=t.anchor)==null?void 0:c.x,this._anchorY=(h=t.anchor)==null?void 0:h.y,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:i,_leftWidth:s,_rightWidth:n,_topHeight:o,_bottomHeight:a,_anchorX:l,_anchorY:u}=this,c=s+n,h=e>c?1:e/c,p=o+a,f=i>p?1:i/p,m=Math.min(h,f),_=l*e,g=u*i;t[0]=t[8]=t[16]=t[24]=-_,t[2]=t[10]=t[18]=t[26]=s*m-_,t[4]=t[12]=t[20]=t[28]=e-n*m-_,t[6]=t[14]=t[22]=t[30]=e-_,t[1]=t[3]=t[5]=t[7]=-g,t[9]=t[11]=t[13]=t[15]=o*m-g,t[17]=t[19]=t[21]=t[23]=i-a*m-g,t[25]=t[27]=t[29]=t[31]=i-g,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}};Rm.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let he=Rm;class Cm extends os{constructor(){super(),this.geometry=new he}destroy(){this.geometry.destroy()}}class Ra{constructor(t){this._renderer=t,this._managedSprites=new xt({renderer:t,type:"renderable",name:"nineSliceSprite"})}addRenderable(t,e){const i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture)}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=t._gpuData[this._renderer.uid]=new Cm,i=e;return i.renderable=t,i.transform=t.groupTransform,i.texture=t._texture,i.roundPixels=this._renderer._roundPixels|t._roundPixels,this._managedSprites.add(t),t.didViewUpdate||this._updateBatchableSprite(t,i),e}destroy(){this._managedSprites.destroy(),this._renderer=null}}Ra.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"nineSliceSprite"},F.add(Ra);class Ca{constructor(t){this._renderer=t}push(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}Ca.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"filter"};var X2=Object.defineProperty,Ts=Object.getOwnPropertySymbols,Mm=Object.prototype.hasOwnProperty,Om=Object.prototype.propertyIsEnumerable,Gm=(r,t,e)=>t in r?X2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ma=(r,t)=>{for(var e in t||(t={}))Mm.call(t,e)&&Gm(r,e,t[e]);if(Ts)for(var e of Ts(t))Om.call(t,e)&&Gm(r,e,t[e]);return r},H2=(r,t)=>{var e={};for(var i in r)Mm.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ts)for(var i of Ts(r))t.indexOf(i)<0&&Om.call(r,i)&&(e[i]=r[i]);return e};const Bm=class Zu extends wt{constructor(t){t=Ma(Ma({},Zu.defaultOptions),t),super(t),this.enabled=!0,this._state=Rt.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(t,e,i,s){t.applyFilter(this,e,i,s)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const e=t,{gpu:i,gl:s}=e,n=H2(e,["gpu","gl"]);let o,a;return i&&(o=dt.from(i)),s&&(a=vt.from(s)),new Zu(Ma({gpuProgram:o,glProgram:a},n))}};Bm.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let te=Bm;var Kr=`in vec2 aPosition;
out vec2 vTextureCoord;
uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;
vec4 filterVertexPosition( void )
{
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
vec2 filterTextureCoord( void )
{
return aPosition * (uOutputFrame.zw * uInputSize.zw);
}
void main(void)
{
gl_Position = filterVertexPosition();
vTextureCoord = filterTextureCoord();
}
`,Im=`in vec2 vTextureCoord;
out vec4 finalColor;
uniform sampler2D uTexture;
void main() {
finalColor = texture(uTexture, vTextureCoord);
}
`,Oa=`struct GlobalFilterUniforms {
uInputSize: vec4<f32>,
uInputPixel: vec4<f32>,
uInputClamp: vec4<f32>,
uOutputFrame: vec4<f32>,
uGlobalFrame: vec4<f32>,
uOutputTexture: vec4<f32>,
};
@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler: sampler;
struct VSOutput {
@builtin(position) position: vec4<f32>,
@location(0) uv: vec2<f32>
};
fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
{
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
{
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}
@vertex
fn mainVertex(
@location(0) aPosition: vec2<f32>,
) -> VSOutput {
return VSOutput(
filterVertexPosition(aPosition),
filterTextureCoord(aPosition)
);
}
@fragment
fn mainFragment(
@location(0) uv: vec2<f32>,
) -> @location(0) vec4<f32> {
return textureSample(uTexture, uSampler, uv);
}
`;class Fm extends te{constructor(){const t=dt.from({vertex:{source:Oa,entryPoint:"mainVertex"},fragment:{source:Oa,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=vt.from({vertex:Kr,fragment:Im,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}}function Ga(r,t,e,i,s,n,o,a){const l=o-e,u=a-i,c=s-e,h=n-i,p=r-e,f=t-i,m=l*l+u*u,_=l*c+u*h,g=l*p+u*f,b=c*c+h*h,y=c*p+h*f,v=1/(m*b-_*_),x=(b*g-_*y)*v,A=(m*y-_*g)*v;return x>=0&&A>=0&&x+A<1}class Ba{constructor(t=0,e=0,i=0,s=0,n=0,o=0){this.type="triangle",this.x=t,this.y=e,this.x2=i,this.y2=s,this.x3=n,this.y3=o}contains(t,e){const i=(this.x-this.x3)*(e-this.y3)-(this.y-this.y3)*(t-this.x3),s=(this.x2-this.x)*(e-this.y)-(this.y2-this.y)*(t-this.x);if(i<0!=s<0&&i!==0&&s!==0)return!1;const n=(this.x3-this.x2)*(e-this.y2)-(this.y3-this.y2)*(t-this.x2);return n===0||n<0==i+s<=0}strokeContains(t,e,i,s=.5){const n=i/2,o=n*n,{x:a,x2:l,x3:u,y:c,y2:h,y3:p}=this;return Hr(t,e,a,c,l,p)<=o||Hr(t,e,l,h,u,p)<=o||Hr(t,e,u,p,a,c)<=o}clone(){return new Ba(this.x,this.y,this.x2,this.y2,this.x3,this.y3)}copyFrom(t){return this.x=t.x,this.y=t.y,this.x2=t.x2,this.y2=t.y2,this.x3=t.x3,this.y3=t.y3,this}copyTo(t){return t.copyFrom(this),t}getBounds(t){t||(t=new z);const e=Math.min(this.x,this.x2,this.x3),i=Math.max(this.x,this.x2,this.x3),s=Math.min(this.y,this.y2,this.y3),n=Math.max(this.y,this.y2,this.y3);return t.x=e,t.y=s,t.width=i-e,t.height=n-s,t}}const Dm=new C;function Um(r,t){var e;t.clear();const i=t.matrix;for(let s=0;s<r.length;s++){const n=r[s];if(n.globalDisplayStatus<7)continue;const o=(e=n.renderGroup)!=null?e:n.parentRenderGroup;o!=null&&o.isCachedAsTexture?t.matrix=Dm.copyFrom(o.textureOffsetInverseTransform).append(n.worldTransform):o!=null&&o._parentCacheAsTextureRenderGroup?t.matrix=Dm.copyFrom(o._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(n.groupTransform):t.matrix=n.worldTransform,t.addBounds(n.bounds)}return t.matrix=i,t}const j2=new Ee({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:2*4,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});let z2=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new ot,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}};class Ia{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new nt({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new Zt({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){const e=this.renderer,i=t.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=i,s.container=t.container,s.outputRenderSurface=e.renderTarget.renderSurface;const n=e.renderTarget.renderTarget.colorTexture.source,o=n.resolution,a=n.antialias;if(i.every(f=>!f.enabled)){s.skip=!0;return}const l=s.bounds;if(this._calculateFilterArea(t,l),this._calculateFilterBounds(s,e.renderTarget.rootViewPort,a,o,1),s.skip)return;const u=this._getPreviousFilterData(),c=this._findFilterResolution(o);let h=0,p=0;u&&(h=u.bounds.minX,p=u.bounds.minY),this._calculateGlobalFrame(s,h,p,c,n.width,n.height),this._setupFilterTextures(s,l,e,u)}generateFilteredTexture({texture:t,filters:e}){const i=this._pushFilterData();this._activeFilterData=i,i.skip=!1,i.filters=e;const s=t.source,n=s.resolution,o=s.antialias;if(e.every(p=>!p.enabled))return i.skip=!0,t;const a=i.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(i,a.rectangle,o,n,0),i.skip)return t;const l=n,u=0,c=0;this._calculateGlobalFrame(i,u,c,l,s.width,s.height),i.outputRenderSurface=et.getOptimalTexture(a.width,a.height,i.resolution,i.antialias),i.backTexture=w.EMPTY,i.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(i,!0);const h=i.outputRenderSurface;return h.source.alphaMode="premultiplied-alpha",h}pop(){const t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&et.returnTexture(e.backTexture),et.returnTexture(e.inputTexture))}getBackTexture(t,e,i){const s=t.colorTexture.source._resolution,n=et.getOptimalTexture(e.width,e.height,s,!1);let o=e.minX,a=e.minY;i&&(o-=i.minX,a-=i.minY),o=Math.floor(o*s),a=Math.floor(a*s);const l=Math.ceil(e.width*s),u=Math.ceil(e.height*s);return this.renderer.renderTarget.copyToTexture(t,n,{x:o,y:a},{width:l,height:u},{x:0,y:0}),n}applyFilter(t,e,i,s){const n=this.renderer,o=this._activeFilterData,a=o.outputRenderSurface===i,l=n.renderTarget.rootRenderTarget.colorTexture.source._resolution,u=this._findFilterResolution(l);let c=0,h=0;if(a){const f=this._findPreviousFilterOffset();c=f.x,h=f.y}this._updateFilterUniforms(e,i,o,c,h,u,a,s);const p=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(p,e,n)}calculateSpriteMatrix(t,e){const i=this._activeFilterData,s=t.set(i.inputTexture._source.width,0,0,i.inputTexture._source.height,i.bounds.minX,i.bounds.minY),n=e.worldTransform.copyTo(C.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&n.prepend(o.cacheToLocalTransform),n.invert(),s.prepend(n),s.scale(1/e.texture.orig.width,1/e.texture.orig.height),s.translate(e.anchor.x,e.anchor.y),s}destroy(){var t;(t=this._passthroughFilter)==null||t.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){var t;return(t=this._passthroughFilter)!=null||(this._passthroughFilter=new Fm),this._passthroughFilter}_setupBindGroupsAndRender(t,e,i){if(i.renderPipes.uniformBatch){const s=i.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(s,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,i.encoder.draw({geometry:j2,shader:t,state:t._state,topology:"triangle-list"}),i.type===yt.WEBGL&&i.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,i,s){if(t.backTexture=w.EMPTY,t.inputTexture=et.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){i.renderTarget.finishRenderPass();const n=i.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(n,e,s==null?void 0:s.bounds)}i.renderTarget.bind(t.inputTexture,!0),i.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,i,s,n,o){const a=t.globalFrame;a.x=e*s,a.y=i*s,a.width=n*s,a.height=o*s}_updateFilterUniforms(t,e,i,s,n,o,a,l){const u=this._filterGlobalUniforms.uniforms,c=u.uOutputFrame,h=u.uInputSize,p=u.uInputPixel,f=u.uInputClamp,m=u.uGlobalFrame,_=u.uOutputTexture;a?(c[0]=i.bounds.minX-s,c[1]=i.bounds.minY-n):(c[0]=0,c[1]=0),c[2]=t.frame.width,c[3]=t.frame.height,h[0]=t.source.width,h[1]=t.source.height,h[2]=1/h[0],h[3]=1/h[1],p[0]=t.source.pixelWidth,p[1]=t.source.pixelHeight,p[2]=1/p[0],p[3]=1/p[1],f[0]=.5*p[2],f[1]=.5*p[3],f[2]=t.frame.width*h[2]-.5*p[2],f[3]=t.frame.height*h[3]-.5*p[3];const g=this.renderer.renderTarget.rootRenderTarget.colorTexture;m[0]=s*o,m[1]=n*o,m[2]=g.source.width*o,m[3]=g.source.height*o,e instanceof w&&(e.source.resource=null);const b=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!l),e instanceof w?(_[0]=e.frame.width,_[1]=e.frame.height):(_[0]=b.width,_[1]=b.height),_[2]=b.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,i=this._filterStackIndex;for(;i>0;){i--;const s=this._filterStack[i];if(!s.skip){t=s.bounds.minX,e=s.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?Um(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){const i=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;i&&e.applyMatrix(i)}}_applyFiltersToTexture(t,e){const i=t.inputTexture,s=t.bounds,n=t.filters,o=t.firstEnabledIndex,a=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),o===a)n[o].apply(this,i,t.outputRenderSurface,e);else{let l=t.inputTexture;const u=et.getOptimalTexture(s.width,s.height,l.source._resolution,!1);let c=u;for(let h=o;h<a;h++){const p=n[h];if(!p.enabled)continue;p.apply(this,l,c,!0);const f=l;l=c,c=f}n[a].apply(this,l,t.outputRenderSurface,e),et.returnTexture(u)}}_calculateFilterBounds(t,e,i,s,n){var o,a;const l=this.renderer,u=t.bounds,c=t.filters;let h=1/0,p=0,f=!0,m=!1,_=!1,g=!0,b=-1,y=-1;for(let v=0;v<c.length;v++){const x=c[v];if(x.enabled){if(b===-1&&(b=v),y=v,h=Math.min(h,x.resolution==="inherit"?s:x.resolution),p+=x.padding,x.antialias==="off"?f=!1:x.antialias==="inherit"&&f&&(f=i),x.clipToViewport||(g=!1),!(x.compatibleRenderers&l.type)){_=!1;break}if(x.blendRequired&&!((a=(o=l.backBuffer)==null?void 0:o.useBackBuffer)==null||a)){_=!1;break}_=!0,m||(m=x.blendRequired)}}if(!_){t.skip=!0;return}if(g&&u.fitBounds(0,e.width/s,0,e.height/s),u.scale(h).ceil().scale(1/h).pad((p|0)*n),!u.isPositive){t.skip=!0;return}t.antialias=f,t.resolution=h,t.blendRequired=m,t.firstEnabledIndex=b,t.lastEnabledIndex=y}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>0&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new z2),this._filterStackIndex++,t}}Ia.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"filter"},F.add(Ia),F.add(Ca);var V2={__proto__:null};const Fa=[];F.handleByNamedList(T.Environment,Fa);async function Da(r){if(!r)for(let t=0;t<Fa.length;t++){const e=Fa[t];if(e.value.test()){await e.value.load();return}}}async function W2(r){return Da(!r)}let qr;function Ua(){if(typeof qr=="boolean")return qr;try{qr=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch(r){qr=!1}return qr}var Tt=(r=>(r[r.NONE=0]="NONE",r[r.COLOR=16384]="COLOR",r[r.STENCIL=1024]="STENCIL",r[r.DEPTH=256]="DEPTH",r[r.COLOR_DEPTH=16640]="COLOR_DEPTH",r[r.COLOR_STENCIL=17408]="COLOR_STENCIL",r[r.DEPTH_STENCIL=1280]="DEPTH_STENCIL",r[r.ALL=17664]="ALL",r))(Tt||{});class ka{constructor(t){this.items=[],this._name=t}emit(t,e,i,s,n,o,a,l){const{name:u,items:c}=this;for(let h=0,p=c.length;h<p;h++)c[h][u](t,e,i,s,n,o,a,l);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}var Y2=Object.defineProperty,km=Object.getOwnPropertySymbols,K2=Object.prototype.hasOwnProperty,q2=Object.prototype.propertyIsEnumerable,$m=(r,t,e)=>t in r?Y2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ss=(r,t)=>{for(var e in t||(t={}))K2.call(t,e)&&$m(r,e,t[e]);if(km)for(var e of km(t))q2.call(t,e)&&$m(r,e,t[e]);return r};const Z2=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Lm=class Jx extends gt{constructor(t){var e;super(),this.tick=0,this.uid=Y("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const i=[...Z2,...(e=this.config.runners)!=null?e:[]];this._addRunners(...i),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Da(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash){const s=this._systemsHash[i].constructor.defaultOptions;t=Ss(Ss({},s),t)}t=Ss(Ss({},Jx.defaultOptions),t),this._roundPixels=t.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(t);this._initOptions=t}render(t,e){var i,s;this.tick++;let n=t;if(n instanceof q&&(n={container:n},e&&(n.target=e.renderTexture)),n.target||(n.target=this.view.renderTarget),n.target===this.view.renderTarget&&(this._lastObjectRendered=n.container,(i=n.clearColor)!=null||(n.clearColor=this.background.colorRgba),(s=n.clear)!=null||(n.clear=this.background.clearBeforeRender)),n.clearColor){const o=Array.isArray(n.clearColor)&&n.clearColor.length===4;n.clearColor=o?n.clearColor:H.shared.setValue(n.clearColor).toArray()}n.transform||(n.container.updateLocalTransform(),n.transform=n.container.localTransform),n.container.visible&&(n.container.enableRenderGroup(),this.runners.prerender.emit(n),this.runners.renderStart.emit(n),this.runners.render.emit(n),this.runners.renderEnd.emit(n),this.runners.postrender.emit(n))}resize(t,e,i){const s=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==s&&this.runners.resolutionChange.emit(i)}clear(t={}){var e;const i=this;t.target||(t.target=i.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),(e=t.clear)!=null||(t.clear=Tt.ALL);const{clear:s,clearColor:n,target:o}=t;H.shared.setValue(n!=null?n:this.background.colorRgba),i.renderTarget.clear(o,s,H.shared.toArray())}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new ka(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const s in this.runners)this.runners[s].add(i);return this}_addPipes(t,e){const i=e.reduce((s,n)=>(s[n.name]=n.value,s),{});t.forEach(s=>{const n=s.value,o=s.name,a=i[o];this.renderPipes[o]=new n(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&ge.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Ua())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};Lm.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Zr=Lm,$a;function Qr(r){return $a!==void 0||($a=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r!=null?r:Zr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!L.get().getWebGLRenderingContext())return!1;let i=L.get().createCanvas().getContext("webgl",e);const s=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,s}catch(i){return!1}})()),$a}let La;async function Jr(r={}){return La!==void 0||(La=await(async()=>{const t=L.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch(e){return!1}})()),La}var Q2=Object.defineProperty,Nm=Object.getOwnPropertySymbols,J2=Object.prototype.hasOwnProperty,tA=Object.prototype.propertyIsEnumerable,Xm=(r,t,e)=>t in r?Q2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ti=(r,t)=>{for(var e in t||(t={}))J2.call(t,e)&&Xm(r,e,t[e]);if(Nm)for(var e of Nm(t))tA.call(t,e)&&Xm(r,e,t[e]);return r};const Hm=["webgl","webgpu","canvas"];async function jm(r){var t;let e=[];r.preference?(e.push(r.preference),Hm.forEach(o=>{o!==r.preference&&e.push(o)})):e=Hm.slice();let i,s={};for(let o=0;o<e.length;o++){const a=e[o];if(a==="webgpu"&&await Jr()){const{WebGPURenderer:l}=await Promise.resolve().then(function(){return JR});i=l,s=ti(ti({},r),r.webgpu);break}else if(a==="webgl"&&Qr((t=r.failIfMajorPerformanceCaveat)!=null?t:Zr.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:l}=await Promise.resolve().then(function(){return FR});i=l,s=ti(ti({},r),r.webgl);break}else if(a==="canvas")throw s=ti({},r),new Error("CanvasRenderer is not yet implemented")}if(delete s.webgpu,delete s.webgl,!i)throw new Error("No available renderer for the current environment");const n=new i;return await n.init(s),n}const eA=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i,ei="8.15.0";class Na{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,ei)}static destroy(){}}Na.extension=T.Application;class Xa{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,ei)}destroy(){this._renderer=null}}Xa.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"initHook",priority:-10};var rA=Object.defineProperty,zm=Object.getOwnPropertySymbols,iA=Object.prototype.hasOwnProperty,sA=Object.prototype.propertyIsEnumerable,Vm=(r,t,e)=>t in r?rA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nA=(r,t)=>{for(var e in t||(t={}))iA.call(t,e)&&Vm(r,e,t[e]);if(zm)for(var e of zm(t))sA.call(t,e)&&Vm(r,e,t[e]);return r};const Wm=class Qu{constructor(...t){this.stage=new q}async init(t){t=nA({},t),this.stage||(this.stage=new q),this.renderer=await jm(t),Qu._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const i=Qu._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Wm._plugins=[];let Ym=Wm;F.handleByList(T.Application,Ym._plugins),F.add(Na);class Ha extends _a{constructor(t,e){var i;super();const{textures:s,data:n}=t;Object.keys(n.pages).forEach(o=>{const a=n.pages[parseInt(o,10)],l=s[a.id];this.pages.push({texture:l})}),Object.keys(n.chars).forEach(o=>{var a;const l=n.chars[o],{frame:u,source:c,rotate:h}=s[l.page],p=N.transformRectCoords(l,u,h,new z),f=new w({frame:p,orig:new z(0,0,l.width,l.height),source:c,rotate:h});this.chars[o]={id:o.codePointAt(0),xOffset:l.xOffset,yOffset:l.yOffset,xAdvance:l.xAdvance,kerning:(a=l.kerning)!=null?a:{},texture:f}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=(i=n.distanceField)!=null?i:{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){lr.install(t)}static uninstall(t){lr.uninstall(t)}}const As={test(r){return typeof r=="string"&&r.startsWith("info face=")},parse(r){var t,e,i;const s=r.match(/^[a-z]+\s+.+$/gm),n={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const m in s){const _=s[m].match(/^[a-z]+/gm)[0],g=s[m].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),b={};for(const y in g){const v=g[y].split("="),x=v[0],A=v[1].replace(/"/gm,""),S=parseFloat(A),E=isNaN(S)?A:S;b[x]=E}n[_].push(b)}const o={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[a]=n.info,[l]=n.common,[u]=(t=n.distanceField)!=null?t:[];u&&(o.distanceField={range:parseInt(u.distanceRange,10),type:u.fieldType}),o.fontSize=parseInt(a.size,10),o.fontFamily=a.face,o.lineHeight=parseInt(l.lineHeight,10);const c=n.page;for(let m=0;m<c.length;m++)o.pages.push({id:parseInt(c[m].id,10)||0,file:c[m].file});const h={};o.baseLineOffset=o.lineHeight-parseInt(l.base,10);const p=n.char;for(let m=0;m<p.length;m++){const _=p[m],g=parseInt(_.id,10);let b=(i=(e=_.letter)!=null?e:_.char)!=null?i:String.fromCharCode(g);b==="space"&&(b=" "),h[g]=b,o.chars[b]={id:g,page:parseInt(_.page,10)||0,x:parseInt(_.x,10),y:parseInt(_.y,10),width:parseInt(_.width,10),height:parseInt(_.height,10),xOffset:parseInt(_.xoffset,10),yOffset:parseInt(_.yoffset,10),xAdvance:parseInt(_.xadvance,10),kerning:{}}}const f=n.kerning||[];for(let m=0;m<f.length;m++){const _=parseInt(f[m].first,10),g=parseInt(f[m].second,10),b=parseInt(f[m].amount,10);o.chars[h[g]].kerning[h[_]]=b}return o}},ja={test(r){const t=r;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(r){var t,e;const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},s=r.getElementsByTagName("info")[0],n=r.getElementsByTagName("common")[0],o=r.getElementsByTagName("distanceField")[0];o&&(i.distanceField={type:o.getAttribute("fieldType"),range:parseInt(o.getAttribute("distanceRange"),10)});const a=r.getElementsByTagName("page"),l=r.getElementsByTagName("char"),u=r.getElementsByTagName("kerning");i.fontSize=parseInt(s.getAttribute("size"),10),i.fontFamily=s.getAttribute("face"),i.lineHeight=parseInt(n.getAttribute("lineHeight"),10);for(let h=0;h<a.length;h++)i.pages.push({id:parseInt(a[h].getAttribute("id"),10)||0,file:a[h].getAttribute("file")});const c={};i.baseLineOffset=i.lineHeight-parseInt(n.getAttribute("base"),10);for(let h=0;h<l.length;h++){const p=l[h],f=parseInt(p.getAttribute("id"),10);let m=(e=(t=p.getAttribute("letter"))!=null?t:p.getAttribute("char"))!=null?e:String.fromCharCode(f);m==="space"&&(m=" "),c[f]=m,i.chars[m]={id:f,page:parseInt(p.getAttribute("page"),10)||0,x:parseInt(p.getAttribute("x"),10),y:parseInt(p.getAttribute("y"),10),width:parseInt(p.getAttribute("width"),10),height:parseInt(p.getAttribute("height"),10),xOffset:parseInt(p.getAttribute("xoffset"),10),yOffset:parseInt(p.getAttribute("yoffset"),10),xAdvance:parseInt(p.getAttribute("xadvance"),10),kerning:{}}}for(let h=0;h<u.length;h++){const p=parseInt(u[h].getAttribute("first"),10),f=parseInt(u[h].getAttribute("second"),10),m=parseInt(u[h].getAttribute("amount"),10);i.chars[c[f]].kerning[c[p]]=m}return i}},za={test(r){return typeof r=="string"&&r.match(/<font(\s|>)/)?ja.test(L.get().parseXML(r)):!1},parse(r){return ja.parse(L.get().parseXML(r))}},oA=[".xml",".fnt"],Km={extension:{type:T.CacheParser,name:"cacheBitmapFont"},test:r=>r instanceof Ha,getCacheableAssets(r,t){const e={};return r.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},qm={extension:{type:T.LoadParser,priority:Pt.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return oA.includes(_t.extname(r).toLowerCase())},async testParse(r){return As.test(r)||za.test(r)},async parse(r,t,e){const i=As.test(r)?As.parse(r):za.parse(r),{src:s}=t,{pages:n}=i,o=[],a=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let c=0;c<n.length;++c){const h=n[c].file;let p=_t.join(_t.dirname(s),h);p=Di(p,s),o.push({src:p,data:a})}const l=await e.load(o),u=o.map(c=>l[c.src]);return new Ha({data:i,textures:u},s)},async load(r,t){return await(await L.get().fetch(r)).text()},async unload(r,t,e){await Promise.all(r.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),r.destroy()}};class Zm{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const Qm={extension:{type:T.CacheParser,name:"cacheTextureArray"},test:r=>Array.isArray(r)&&r.every(t=>t instanceof w),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};async function Va(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch(t){return!1}return!0}return!1}const Jm={extension:{type:T.DetectionParser,priority:1},test:async()=>Va("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},tg=["png","jpg","jpeg"],eg={extension:{type:T.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...tg],remove:async r=>r.filter(t=>!tg.includes(t))},aA="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function ri(r){return aA?!1:document.createElement("video").canPlayType(r)!==""}const rg={extension:{type:T.DetectionParser,priority:0},test:async()=>ri("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},ig={extension:{type:T.DetectionParser,priority:0},test:async()=>ri("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},sg={extension:{type:T.DetectionParser,priority:0},test:async()=>ri("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},ng={extension:{type:T.DetectionParser,priority:0},test:async()=>Va("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};var lA=Object.defineProperty,uA=Object.defineProperties,cA=Object.getOwnPropertyDescriptors,og=Object.getOwnPropertySymbols,hA=Object.prototype.hasOwnProperty,dA=Object.prototype.propertyIsEnumerable,ag=(r,t,e)=>t in r?lA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cr=(r,t)=>{for(var e in t||(t={}))hA.call(t,e)&&ag(r,e,t[e]);if(og)for(var e of og(t))dA.call(t,e)&&ag(r,e,t[e]);return r},pA=(r,t)=>uA(r,cA(t));const lg=class yn{constructor(){this.loadOptions=cr({},yn.defaultOptions),this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var s,n;let o=null,a=null;if((e.parser||e.loadParser)&&(a=this._parserHash[e.parser||e.loadParser]),!a){for(let l=0;l<this.parsers.length;l++){const u=this.parsers[l];if(u.load&&(s=u.test)!=null&&s.call(u,t,e,this)){a=u;break}}if(!a)return null}o=await a.load(t,e,this),i.parser=a;for(let l=0;l<this.parsers.length;l++){const u=this.parsers[l];u.parse&&u.parse&&await((n=u.testParse)==null?void 0:n.call(u,o,e,this))&&(o=await u.parse(o,e,this)||o,i.parser=u)}return o})(),i}async load(t,e){this._parsersValidated||this._validateParsers();const i=typeof e=="function"?pA(cr(cr({},yn.defaultOptions),this.loadOptions),{onProgress:e}):cr(cr(cr({},yn.defaultOptions),this.loadOptions),e||{}),{onProgress:s,onError:n,strategy:o,retryCount:a,retryDelay:l}=i;let u=0;const c={},h=Cr(t),p=Dt(t,_=>({alias:[_],src:_,data:{}})),f=p.reduce((_,g)=>_+(g.progressSize||1),0),m=p.map(async _=>{const g=_t.toAbsolute(_.src);c[_.src]||(await this._loadAssetWithRetry(g,_,{onProgress:s,onError:n,strategy:o,retryCount:a,retryDelay:l},c),u+=_.progressSize||1,s&&s(u/f))});return await Promise.all(m),h?c[p[0].src]:c}async unload(t){const e=Dt(t,i=>({alias:[i],src:i})).map(async i=>{var s,n;const o=_t.toAbsolute(i.src),a=this.promiseCache[o];if(a){const l=await a.promise;delete this.promiseCache[o],await((n=(s=a.parser)==null?void 0:s.unload)==null?void 0:n.call(s,l,i,this))}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(!e.name&&!e.id||t[e.name]||t[e.id],t[e.name]=e,e.id&&(t[e.id]=e),t),{})}async _loadAssetWithRetry(t,e,i,s){let n=0;const{onError:o,strategy:a,retryCount:l,retryDelay:u}=i,c=h=>new Promise(p=>setTimeout(p,h));for(;;)try{this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),s[e.src]=await this.promiseCache[t].promise;return}catch(h){delete this.promiseCache[t],delete s[e.src],n++;const p=a!=="retry"||n>l;if(a==="retry"&&!p){o&&o(h,e),await c(u);continue}if(a==="skip"){o&&o(h,e);return}o&&o(h,e);const f=new Error(`[Loader.load] Failed to load ${t}.
${h}`);throw h instanceof Error&&h.stack&&(f.stack=h.stack),f}}};lg.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let ug=lg;function Oe(r,t){if(Array.isArray(t)){for(const e of t)if(r.startsWith(`data:${e}`))return!0;return!1}return r.startsWith(`data:${t}`)}function Ut(r,t){const e=r.split("?")[0],i=_t.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const fA=".json",mA="application/json",cg={extension:{type:T.LoadParser,priority:Pt.Low},name:"loadJson",id:"json",test(r){return Oe(r,mA)||Ut(r,fA)},async load(r){return await(await L.get().fetch(r)).json()}},gA=".txt",_A="text/plain",hg={name:"loadTxt",id:"text",extension:{type:T.LoadParser,priority:Pt.Low,name:"loadTxt"},test(r){return Oe(r,_A)||Ut(r,gA)},async load(r){return await(await L.get().fetch(r)).text()}};var bA=Object.defineProperty,vA=Object.defineProperties,yA=Object.getOwnPropertyDescriptors,dg=Object.getOwnPropertySymbols,xA=Object.prototype.hasOwnProperty,TA=Object.prototype.propertyIsEnumerable,pg=(r,t,e)=>t in r?bA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,SA=(r,t)=>{for(var e in t||(t={}))xA.call(t,e)&&pg(r,e,t[e]);if(dg)for(var e of dg(t))TA.call(t,e)&&pg(r,e,t[e]);return r},AA=(r,t)=>vA(r,yA(t));const EA=["normal","bold","100","200","300","400","500","600","700","800","900"],PA=[".ttf",".otf",".woff",".woff2"],wA=["font/ttf","font/otf","font/woff","font/woff2"],RA=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function fg(r){const t=_t.extname(r),e=_t.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match(RA)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const CA=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function MA(r){return CA.test(r)?r:encodeURI(r)}const mg={extension:{type:T.LoadParser,priority:Pt.Low},name:"loadWebFont",id:"web-font",test(r){return Oe(r,wA)||Ut(r,PA)},async load(r,t){var e,i,s,n,o,a;const l=L.get().getFontFaceSet();if(l){const u=[],c=(i=(e=t.data)==null?void 0:e.family)!=null?i:fg(r),h=(o=(n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(f=>EA.includes(f)))!=null?o:["normal"],p=(a=t.data)!=null?a:{};for(let f=0;f<h.length;f++){const m=h[f],_=new FontFace(c,`url(${MA(r)})`,AA(SA({},p),{weight:m}));await _.load(),l.add(_),u.push(_)}return V.has(`${c}-and-url`)?V.get(`${c}-and-url`).entries.push({url:r,faces:u}):V.set(`${c}-and-url`,{entries:[{url:r,faces:u}]}),u.length===1?u[0]:u}return null},unload(r){const t=Array.isArray(r)?r:[r],e=t[0].family,i=V.get(`${e}-and-url`),s=i.entries.find(n=>n.faces.some(o=>t.indexOf(o)!==-1));s.faces=s.faces.filter(n=>t.indexOf(n)===-1),s.faces.length===0&&(i.entries=i.entries.filter(n=>n!==s)),t.forEach(n=>{L.get().getFontFaceSet().delete(n)}),i.entries.length===0&&V.remove(`${e}-and-url`)}};function Es(r,t=1){var e;const i=(e=ae.RETINA_PREFIX)==null?void 0:e.exec(r);return i?parseFloat(i[1]):t}function de(r,t,e){r.label=e,r._sourceOrigin=e;const i=new w({source:r,label:e}),s=()=>{delete t.promiseCache[e],V.has(e)&&V.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&s()}),i.once("destroy",()=>{r.destroyed||s()}),i}var OA=Object.defineProperty,Ps=Object.getOwnPropertySymbols,gg=Object.prototype.hasOwnProperty,_g=Object.prototype.propertyIsEnumerable,bg=(r,t,e)=>t in r?OA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,GA=(r,t)=>{for(var e in t||(t={}))gg.call(t,e)&&bg(r,e,t[e]);if(Ps)for(var e of Ps(t))_g.call(t,e)&&bg(r,e,t[e]);return r},BA=(r,t)=>{var e={};for(var i in r)gg.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ps)for(var i of Ps(r))t.indexOf(i)<0&&_g.call(r,i)&&(e[i]=r[i]);return e};const IA=".svg",FA="image/svg+xml",vg={extension:{type:T.LoadParser,priority:Pt.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return Oe(r,FA)||Ut(r,IA)},async load(r,t,e){var i,s;return((s=(i=t.data)==null?void 0:i.parseAsGraphicsContext)!=null?s:this.config.parseAsGraphicsContext)?UA(r):DA(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function DA(r,t,e,i){var s,n,o,a,l,u;const c=await L.get().fetch(r),h=L.get().createImage();h.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await c.text())}`,h.crossOrigin=i,await h.decode();const p=(n=(s=t.data)==null?void 0:s.width)!=null?n:h.width,f=(a=(o=t.data)==null?void 0:o.height)!=null?a:h.height,m=((l=t.data)==null?void 0:l.resolution)||Es(r),_=Math.ceil(p*m),g=Math.ceil(f*m),b=L.get().createCanvas(_,g),y=b.getContext("2d");y.imageSmoothingEnabled=!0,y.imageSmoothingQuality="high",y.drawImage(h,0,0,p*m,f*m);const v=(u=t.data)!=null?u:{},{parseAsGraphicsContext:x}=v,A=BA(v,["parseAsGraphicsContext"]),S=new le(GA({resource:b,alphaMode:"premultiply-alpha-on-upload",resolution:m},A));return de(S,e,r)}async function UA(r){const t=await(await L.get().fetch(r)).text(),e=new pt;return e.svg(t),e}const kA=`(function(){"use strict";const e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";async function a(){try{if(typeof createImageBitmap!="function")return!1;const A=await(await fetch(e)).blob(),t=await createImageBitmap(A);return t.width===1&&t.height===1}catch(A){return!1}}a().then(A=>{self.postMessage(A)})})();
`;let hr=null,Wa=class{constructor(){hr||(hr=URL.createObjectURL(new Blob([kA],{type:"application/javascript"}))),this.worker=new Worker(hr)}};Wa.revokeObjectURL=function(){hr&&(URL.revokeObjectURL(hr),hr=null)};const $A='(function(){"use strict";async function s(a,t){const e=await fetch(a);if(!e.ok)throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${a}: ${e.status} ${e.statusText}`);const i=await e.blob();return t==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}self.onmessage=async a=>{try{const t=await s(a.data.data[0],a.data.data[1]);self.postMessage({data:t,uuid:a.data.uuid,id:a.data.id},[t])}catch(t){self.postMessage({error:t,uuid:a.data.uuid,id:a.data.id})}}})();\n';let dr=null,yg=class{constructor(){dr||(dr=URL.createObjectURL(new Blob([$A],{type:"application/javascript"}))),this.worker=new Worker(dr)}};yg.revokeObjectURL=function(){dr&&(URL.revokeObjectURL(dr),dr=null)};let xg=0,Ya,LA=class{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new Wa;e.addEventListener("message",i=>{e.terminate(),Wa.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var i;return this._run("loadImageBitmap",[t,(i=e==null?void 0:e.data)==null?void 0:i.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Ya===void 0&&(Ya=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<Ya&&(this._createdWorkers++,t=new yg().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){this._resolveHash[t.uuid]&&(t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),delete this._resolveHash[t.uuid])}async _run(t,e){await this._initWorkers();const i=new Promise((s,n)=>{this._queue.push({id:t,arguments:e,resolve:s,reject:n})});return this._next(),i}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[xg]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:xg++,id:i})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t==null||t(new Error("WorkerManager has been reset before completion"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}};const Ka=new LA;var NA=Object.defineProperty,Tg=Object.getOwnPropertySymbols,XA=Object.prototype.hasOwnProperty,HA=Object.prototype.propertyIsEnumerable,Sg=(r,t,e)=>t in r?NA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jA=(r,t)=>{for(var e in t||(t={}))XA.call(t,e)&&Sg(r,e,t[e]);if(Tg)for(var e of Tg(t))HA.call(t,e)&&Sg(r,e,t[e]);return r};const zA=[".jpeg",".jpg",".png",".webp",".avif"],VA=["image/jpeg","image/png","image/webp","image/avif"];async function Ag(r,t){var e;const i=await L.get().fetch(r);if(!i.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${i.status} ${i.statusText}`);const s=await i.blob();return((e=t==null?void 0:t.data)==null?void 0:e.alphaMode)==="premultiplied-alpha"?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}const qa={name:"loadTextures",id:"texture",extension:{type:T.LoadParser,priority:Pt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Oe(r,VA)||Ut(r,zA)},async load(r,t,e){var i;let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Ka.isImageBitmapSupported()?s=await Ka.loadImageBitmap(r,t):s=await Ag(r,t):s=await new Promise((o,a)=>{s=L.get().createImage(),s.crossOrigin=this.config.crossOrigin,s.src=r,s.complete?o(s):(s.onload=()=>{o(s)},s.onerror=a)});const n=new le(jA({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:((i=t.data)==null?void 0:i.resolution)||Es(r)},t.data));return de(n,e,r)},unload(r){r.destroy(!0)}};var WA=Object.defineProperty,YA=Object.defineProperties,KA=Object.getOwnPropertyDescriptors,Eg=Object.getOwnPropertySymbols,qA=Object.prototype.hasOwnProperty,ZA=Object.prototype.propertyIsEnumerable,Pg=(r,t,e)=>t in r?WA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Za=(r,t)=>{for(var e in t||(t={}))qA.call(t,e)&&Pg(r,e,t[e]);if(Eg)for(var e of Eg(t))ZA.call(t,e)&&Pg(r,e,t[e]);return r},wg=(r,t)=>YA(r,KA(t));const QA=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let Qa,Ja;function Rg(r,t,e){e===void 0&&!t.startsWith("data:")?r.crossOrigin=Mg(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}function Cg(r){return new Promise((t,e)=>{r.addEventListener("canplaythrough",i),r.addEventListener("error",s),r.load();function i(){n(),t()}function s(o){n(),e(o)}function n(){r.removeEventListener("canplaythrough",i),r.removeEventListener("error",s)}})}function Mg(r,t=globalThis.location){if(r.startsWith("data:"))return"";t||(t=globalThis.location);const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function JA(){const r=[],t=[];for(const e of QA){const i=He.MIME_TYPES[e.substring(1)]||`video/${e.substring(1)}`;ri(i)&&(r.push(e),t.includes(i)||t.push(i))}return{validVideoExtensions:r,validVideoMime:t}}const Og={name:"loadVideo",id:"video",extension:{type:T.LoadParser,name:"loadVideo"},test(r){if(!Qa||!Ja){const{validVideoExtensions:i,validVideoMime:s}=JA();Qa=i,Ja=s}const t=Oe(r,Ja),e=Ut(r,Qa);return t||e},async load(r,t,e){var i,s;const n=Za(wg(Za({},He.defaultOptions),{resolution:((i=t.data)==null?void 0:i.resolution)||Es(r),alphaMode:((s=t.data)==null?void 0:s.alphaMode)||await no()}),t.data),o=document.createElement("video"),a={preload:n.autoLoad!==!1?"auto":void 0,"webkit-playsinline":n.playsinline!==!1?"":void 0,playsinline:n.playsinline!==!1?"":void 0,muted:n.muted===!0?"":void 0,loop:n.loop===!0?"":void 0,autoplay:n.autoPlay!==!1?"":void 0};Object.keys(a).forEach(c=>{const h=a[c];h!==void 0&&o.setAttribute(c,h)}),n.muted===!0&&(o.muted=!0),Rg(o,r,n.crossorigin);const l=document.createElement("source");let u;if(n.mime)u=n.mime;else if(r.startsWith("data:"))u=r.slice(5,r.indexOf(";"));else if(!r.startsWith("blob:")){const c=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase();u=He.MIME_TYPES[c]||`video/${c}`}return l.src=r,u&&(l.type=u),new Promise(c=>{const h=async()=>{const p=new He(wg(Za({},n),{resource:o}));o.removeEventListener("canplay",h),t.data.preload&&await Cg(o),c(de(p,e,r))};n.preload&&!n.autoPlay&&o.load(),o.addEventListener("canplay",h),o.appendChild(l)})},unload(r){r.destroy(!0)}},tl={extension:{type:T.ResolveParser,name:"resolveTexture"},test:qa.test,parse:r=>{var t,e;return{resolution:parseFloat((e=(t=ae.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:r.split(".").pop(),src:r}}},Gg={extension:{type:T.ResolveParser,priority:-2,name:"resolveJson"},test:r=>ae.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:tl.parse};var tE=Object.defineProperty,Bg=Object.getOwnPropertySymbols,eE=Object.prototype.hasOwnProperty,rE=Object.prototype.propertyIsEnumerable,Ig=(r,t,e)=>t in r?tE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fg=(r,t)=>{for(var e in t||(t={}))eE.call(t,e)&&Ig(r,e,t[e]);if(Bg)for(var e of Bg(t))rE.call(t,e)&&Ig(r,e,t[e]);return r};class Dg{constructor(){this._detections=[],this._initialized=!1,this.resolver=new ae,this.loader=new ug,this.cache=V,this._backgroundLoader=new Zm(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var e,i,s;if(this._initialized)return;if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let l=t.manifest;typeof l=="string"&&(l=await this.load(l)),this.resolver.addManifest(l)}const n=(i=(e=t.texturePreference)==null?void 0:e.resolution)!=null?i:1,o=typeof n=="number"?[n]:n,a=await this._detectFormats({preferredFormats:(s=t.texturePreference)==null?void 0:s.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:a,resolution:o}}),t.preferences&&this.setPreferences(t.preferences),t.loadOptions&&(this.loader.loadOptions=Fg(Fg({},this.loader.loadOptions),t.loadOptions))}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=Cr(t),s=Dt(t).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(u=>!this.resolver.hasKey(u))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(s),o=await this._mapLoadToResolve(n,e);return i?o[s[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},o=Object.keys(s);let a=0;const l=[],u=()=>{e==null||e(l.reduce((h,p)=>h+p,0)/a)},c=o.map((h,p)=>{const f=s[h],m=Object.values(f),_=[...new Set(m.flat())].reduce((g,b)=>g+(b.progressSize||1),0);return l.push(0),a+=_,this._mapLoadToResolve(f,g=>{l[p]=g*_,u()}).then(g=>{n[h]=g})});return await Promise.all(c),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return V.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=V.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const s=await this.loader.load(i,e);this._backgroundLoader.active=!0;const n={};return i.forEach(o=>{const a=s[o.src],l=[o.src];o.alias&&l.push(...o.alias),l.forEach(u=>{n[u]=a}),V.set(l,a)}),n}async unload(t){this._initialized||await this.init();const e=Dt(t).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=Dt(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{V.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,s)=>e.indexOf(i)===s),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const ii=new Dg;F.handleByList(T.LoadParser,ii.loader.parsers).handleByList(T.ResolveParser,ii.resolver.parsers).handleByList(T.CacheParser,ii.cache.parsers).handleByList(T.DetectionParser,ii.detections),F.add(Qm,eg,Jm,ng,rg,ig,sg,cg,hg,mg,vg,qa,Og,qm,Km,tl,Gg);const Ug={loader:T.LoadParser,resolver:T.ResolveParser,cache:T.CacheParser,detection:T.DetectionParser};F.handle(T.Asset,r=>{const t=r.ref;Object.entries(Ug).filter(([e])=>!!t[e]).forEach(([e,i])=>{var s;return F.add(Object.assign(t[e],{extension:(s=t[e].extension)!=null?s:i}))})},r=>{const t=r.ref;Object.keys(Ug).filter(e=>!!t[e]).forEach(e=>F.remove(t[e]))});const iE={extension:{type:T.DetectionParser,priority:3},test:async()=>!!(await Jr()||Qr()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>t!=="basis")};class si extends Q{constructor(t){super(t),this.uploadMethodId="compressed",this.resource=t.resource,this.mipLevelCount=this.resource.length}}let ws;function el(){if(ws)return ws;const r=L.get().createCanvas(1,1).getContext("webgl");return r?(ws=[...r.getExtension("EXT_texture_compression_bptc")?["bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"]:[],...r.getExtension("WEBGL_compressed_texture_s3tc")?["bc1-rgba-unorm","bc2-rgba-unorm","bc3-rgba-unorm"]:[],...r.getExtension("WEBGL_compressed_texture_s3tc_srgb")?["bc1-rgba-unorm-srgb","bc2-rgba-unorm-srgb","bc3-rgba-unorm-srgb"]:[],...r.getExtension("EXT_texture_compression_rgtc")?["bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm"]:[],...r.getExtension("WEBGL_compressed_texture_etc")?["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","eac-r11unorm","eac-rg11unorm"]:[],...r.getExtension("WEBGL_compressed_texture_astc")?["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]:[]],ws):[]}let Rs;async function rl(){if(Rs)return Rs;const r=await L.get().getNavigator().gpu.requestAdapter();return Rs=[...r.features.has("texture-compression-bc")?["bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb","bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm","bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"]:[],...r.features.has("texture-compression-etc2")?["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"]:[],...r.features.has("texture-compression-astc")?["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]:[]],Rs}let il;async function sl(){return il!==void 0||(il=await(async()=>{const r=await Jr(),t=Qr();if(r&&t){const e=await rl(),i=el();return e.filter(s=>i.includes(s))}else{if(r)return await rl();if(t)return el()}return[]})()),il}const kg=["r8unorm","r8snorm","r8uint","r8sint","r16uint","r16sint","r16float","rg8unorm","rg8snorm","rg8uint","rg8sint","r32uint","r32sint","r32float","rg16uint","rg16sint","rg16float","rgba8unorm","rgba8unorm-srgb","rgba8snorm","rgba8uint","rgba8sint","bgra8unorm","bgra8unorm-srgb","rgb9e5ufloat","rgb10a2unorm","rg11b10ufloat","rg32uint","rg32sint","rg32float","rgba16uint","rgba16sint","rgba16float","rgba32uint","rgba32sint","rgba32float","stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"];let Cs;async function ni(){if(Cs!==void 0)return Cs;const r=await sl();return Cs=[...kg,...r],Cs}const sE='(function(){"use strict";function g(r,a){const t=r.getNumImages(),s=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const m=[];for(let e=0;e<s;++e)for(let o=0;o<t;++o){const B=r.getImageTranscodedSizeInBytes(o,e,a),f=new Uint8Array(B);if(!r.transcodeImage(f,o,e,a,1,0))throw new Error("transcodeImage failed");m.push(f)}return m}const w={"bc3-rgba-unorm":3,"bc7-rgba-unorm":6,"etc2-rgba8unorm":1,"astc-4x4-unorm":10,rgba8unorm:13,rgba4unorm:16};function d(r){const a=w[r];if(a)return a;throw new Error(`Unsupported transcoderFormat: ${r}`)}const n={jsUrl:"basis/basis_transcoder.js",wasmUrl:"basis/basis_transcoder.wasm"};let u,i,c;async function l(){if(!c){const r=new URL(n.jsUrl,location.origin).href,a=new URL(n.wasmUrl,location.origin).href;importScripts(r),c=new Promise(t=>{BASIS({locateFile:s=>a}).then(s=>{s.initializeBasis(),t(s.BasisFile)})})}return c}async function b(r,a){const t=await fetch(r);if(t.ok){const s=await t.arrayBuffer();return new a(new Uint8Array(s))}throw new Error(`Failed to load Basis texture: ${r}`)}const h=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function p(r){const a=await l(),t=await b(r,a),s=g(t,u);return{width:t.getImageWidth(0,0),height:t.getImageHeight(0,0),format:i,resource:s,alphaMode:"no-premultiply-alpha"}}async function y(r,a,t){r&&(n.jsUrl=r),a&&(n.wasmUrl=a),i=h.filter(s=>t.includes(s))[0],u=d(i),await l()}const U={init:async r=>{const{jsUrl:a,wasmUrl:t,supportedTextures:s}=r;await y(a,t,s)},load:async r=>{var a;try{const t=await p(r.url);return{type:"load",url:r.url,success:!0,textureOptions:t,transferables:(a=t.resource)==null?void 0:a.map(s=>s.buffer)}}catch(t){throw t}}};self.onmessage=async r=>{const a=r.data,t=await U[a.type](a);t&&self.postMessage(t,t.transferables)}})();\n';let pr=null,$g=class{constructor(){pr||(pr=URL.createObjectURL(new Blob([sE],{type:"application/javascript"}))),this.worker=new Worker(pr)}};$g.revokeObjectURL=function(){pr&&(URL.revokeObjectURL(pr),pr=null)};const Ms={jsUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/basis/basis_transcoder.js",wasmUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/basis/basis_transcoder.wasm"};function nE(r){Object.assign(Ms,r)}let oi;const Lg={};function oE(r){return oi||(oi=new $g().worker,oi.onmessage=t=>{const{success:e,url:i,textureOptions:s}=t.data;e||console.warn("Failed to load Basis texture",i),Lg[i](s)},oi.postMessage({type:"init",jsUrl:Ms.jsUrl,wasmUrl:Ms.wasmUrl,supportedTextures:r})),oi}function Ng(r,t){const e=oE(t);return new Promise(i=>{Lg[r]=i,e.postMessage({type:"load",url:r})})}const aE={extension:{type:T.LoadParser,priority:Pt.High,name:"loadBasis"},name:"loadBasis",id:"basis",test(r){return Ut(r,[".basis"])},async load(r,t,e){const i=await ni(),s=await Ng(r,i),n=new si(s);return de(n,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};function lE(r,t){const e=r.getNumImages(),i=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const s=[];for(let n=0;n<i;++n)for(let o=0;o<e;++o){const a=r.getImageTranscodedSizeInBytes(o,n,t),l=new Uint8Array(a);if(!r.transcodeImage(l,o,n,t,1,0))throw new Error("transcodeImage failed");s.push(l)}return s}const uE={"bc3-rgba-unorm":3,"bc7-rgba-unorm":6,"etc2-rgba8unorm":1,"astc-4x4-unorm":10,rgba8unorm:13,rgba4unorm:16};function cE(r){const t=uE[r];if(t)return t;throw new Error(`Unsupported transcoderFormat: ${r}`)}const hE={MAGIC:0,SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19,PF_FLAGS:20,FOURCC:21,RGB_BITCOUNT:22,R_BIT_MASK:23,G_BIT_MASK:24,B_BIT_MASK:25,A_BIT_MASK:26},dE={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4};var nl=(r=>(r[r.DXGI_FORMAT_UNKNOWN=0]="DXGI_FORMAT_UNKNOWN",r[r.DXGI_FORMAT_R32G32B32A32_TYPELESS=1]="DXGI_FORMAT_R32G32B32A32_TYPELESS",r[r.DXGI_FORMAT_R32G32B32A32_FLOAT=2]="DXGI_FORMAT_R32G32B32A32_FLOAT",r[r.DXGI_FORMAT_R32G32B32A32_UINT=3]="DXGI_FORMAT_R32G32B32A32_UINT",r[r.DXGI_FORMAT_R32G32B32A32_SINT=4]="DXGI_FORMAT_R32G32B32A32_SINT",r[r.DXGI_FORMAT_R32G32B32_TYPELESS=5]="DXGI_FORMAT_R32G32B32_TYPELESS",r[r.DXGI_FORMAT_R32G32B32_FLOAT=6]="DXGI_FORMAT_R32G32B32_FLOAT",r[r.DXGI_FORMAT_R32G32B32_UINT=7]="DXGI_FORMAT_R32G32B32_UINT",r[r.DXGI_FORMAT_R32G32B32_SINT=8]="DXGI_FORMAT_R32G32B32_SINT",r[r.DXGI_FORMAT_R16G16B16A16_TYPELESS=9]="DXGI_FORMAT_R16G16B16A16_TYPELESS",r[r.DXGI_FORMAT_R16G16B16A16_FLOAT=10]="DXGI_FORMAT_R16G16B16A16_FLOAT",r[r.DXGI_FORMAT_R16G16B16A16_UNORM=11]="DXGI_FORMAT_R16G16B16A16_UNORM",r[r.DXGI_FORMAT_R16G16B16A16_UINT=12]="DXGI_FORMAT_R16G16B16A16_UINT",r[r.DXGI_FORMAT_R16G16B16A16_SNORM=13]="DXGI_FORMAT_R16G16B16A16_SNORM",r[r.DXGI_FORMAT_R16G16B16A16_SINT=14]="DXGI_FORMAT_R16G16B16A16_SINT",r[r.DXGI_FORMAT_R32G32_TYPELESS=15]="DXGI_FORMAT_R32G32_TYPELESS",r[r.DXGI_FORMAT_R32G32_FLOAT=16]="DXGI_FORMAT_R32G32_FLOAT",r[r.DXGI_FORMAT_R32G32_UINT=17]="DXGI_FORMAT_R32G32_UINT",r[r.DXGI_FORMAT_R32G32_SINT=18]="DXGI_FORMAT_R32G32_SINT",r[r.DXGI_FORMAT_R32G8X24_TYPELESS=19]="DXGI_FORMAT_R32G8X24_TYPELESS",r[r.DXGI_FORMAT_D32_FLOAT_S8X24_UINT=20]="DXGI_FORMAT_D32_FLOAT_S8X24_UINT",r[r.DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS=21]="DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS",r[r.DXGI_FORMAT_X32_TYPELESS_G8X24_UINT=22]="DXGI_FORMAT_X32_TYPELESS_G8X24_UINT",r[r.DXGI_FORMAT_R10G10B10A2_TYPELESS=23]="DXGI_FORMAT_R10G10B10A2_TYPELESS",r[r.DXGI_FORMAT_R10G10B10A2_UNORM=24]="DXGI_FORMAT_R10G10B10A2_UNORM",r[r.DXGI_FORMAT_R10G10B10A2_UINT=25]="DXGI_FORMAT_R10G10B10A2_UINT",r[r.DXGI_FORMAT_R11G11B10_FLOAT=26]="DXGI_FORMAT_R11G11B10_FLOAT",r[r.DXGI_FORMAT_R8G8B8A8_TYPELESS=27]="DXGI_FORMAT_R8G8B8A8_TYPELESS",r[r.DXGI_FORMAT_R8G8B8A8_UNORM=28]="DXGI_FORMAT_R8G8B8A8_UNORM",r[r.DXGI_FORMAT_R8G8B8A8_UNORM_SRGB=29]="DXGI_FORMAT_R8G8B8A8_UNORM_SRGB",r[r.DXGI_FORMAT_R8G8B8A8_UINT=30]="DXGI_FORMAT_R8G8B8A8_UINT",r[r.DXGI_FORMAT_R8G8B8A8_SNORM=31]="DXGI_FORMAT_R8G8B8A8_SNORM",r[r.DXGI_FORMAT_R8G8B8A8_SINT=32]="DXGI_FORMAT_R8G8B8A8_SINT",r[r.DXGI_FORMAT_R16G16_TYPELESS=33]="DXGI_FORMAT_R16G16_TYPELESS",r[r.DXGI_FORMAT_R16G16_FLOAT=34]="DXGI_FORMAT_R16G16_FLOAT",r[r.DXGI_FORMAT_R16G16_UNORM=35]="DXGI_FORMAT_R16G16_UNORM",r[r.DXGI_FORMAT_R16G16_UINT=36]="DXGI_FORMAT_R16G16_UINT",r[r.DXGI_FORMAT_R16G16_SNORM=37]="DXGI_FORMAT_R16G16_SNORM",r[r.DXGI_FORMAT_R16G16_SINT=38]="DXGI_FORMAT_R16G16_SINT",r[r.DXGI_FORMAT_R32_TYPELESS=39]="DXGI_FORMAT_R32_TYPELESS",r[r.DXGI_FORMAT_D32_FLOAT=40]="DXGI_FORMAT_D32_FLOAT",r[r.DXGI_FORMAT_R32_FLOAT=41]="DXGI_FORMAT_R32_FLOAT",r[r.DXGI_FORMAT_R32_UINT=42]="DXGI_FORMAT_R32_UINT",r[r.DXGI_FORMAT_R32_SINT=43]="DXGI_FORMAT_R32_SINT",r[r.DXGI_FORMAT_R24G8_TYPELESS=44]="DXGI_FORMAT_R24G8_TYPELESS",r[r.DXGI_FORMAT_D24_UNORM_S8_UINT=45]="DXGI_FORMAT_D24_UNORM_S8_UINT",r[r.DXGI_FORMAT_R24_UNORM_X8_TYPELESS=46]="DXGI_FORMAT_R24_UNORM_X8_TYPELESS",r[r.DXGI_FORMAT_X24_TYPELESS_G8_UINT=47]="DXGI_FORMAT_X24_TYPELESS_G8_UINT",r[r.DXGI_FORMAT_R8G8_TYPELESS=48]="DXGI_FORMAT_R8G8_TYPELESS",r[r.DXGI_FORMAT_R8G8_UNORM=49]="DXGI_FORMAT_R8G8_UNORM",r[r.DXGI_FORMAT_R8G8_UINT=50]="DXGI_FORMAT_R8G8_UINT",r[r.DXGI_FORMAT_R8G8_SNORM=51]="DXGI_FORMAT_R8G8_SNORM",r[r.DXGI_FORMAT_R8G8_SINT=52]="DXGI_FORMAT_R8G8_SINT",r[r.DXGI_FORMAT_R16_TYPELESS=53]="DXGI_FORMAT_R16_TYPELESS",r[r.DXGI_FORMAT_R16_FLOAT=54]="DXGI_FORMAT_R16_FLOAT",r[r.DXGI_FORMAT_D16_UNORM=55]="DXGI_FORMAT_D16_UNORM",r[r.DXGI_FORMAT_R16_UNORM=56]="DXGI_FORMAT_R16_UNORM",r[r.DXGI_FORMAT_R16_UINT=57]="DXGI_FORMAT_R16_UINT",r[r.DXGI_FORMAT_R16_SNORM=58]="DXGI_FORMAT_R16_SNORM",r[r.DXGI_FORMAT_R16_SINT=59]="DXGI_FORMAT_R16_SINT",r[r.DXGI_FORMAT_R8_TYPELESS=60]="DXGI_FORMAT_R8_TYPELESS",r[r.DXGI_FORMAT_R8_UNORM=61]="DXGI_FORMAT_R8_UNORM",r[r.DXGI_FORMAT_R8_UINT=62]="DXGI_FORMAT_R8_UINT",r[r.DXGI_FORMAT_R8_SNORM=63]="DXGI_FORMAT_R8_SNORM",r[r.DXGI_FORMAT_R8_SINT=64]="DXGI_FORMAT_R8_SINT",r[r.DXGI_FORMAT_A8_UNORM=65]="DXGI_FORMAT_A8_UNORM",r[r.DXGI_FORMAT_R1_UNORM=66]="DXGI_FORMAT_R1_UNORM",r[r.DXGI_FORMAT_R9G9B9E5_SHAREDEXP=67]="DXGI_FORMAT_R9G9B9E5_SHAREDEXP",r[r.DXGI_FORMAT_R8G8_B8G8_UNORM=68]="DXGI_FORMAT_R8G8_B8G8_UNORM",r[r.DXGI_FORMAT_G8R8_G8B8_UNORM=69]="DXGI_FORMAT_G8R8_G8B8_UNORM",r[r.DXGI_FORMAT_BC1_TYPELESS=70]="DXGI_FORMAT_BC1_TYPELESS",r[r.DXGI_FORMAT_BC1_UNORM=71]="DXGI_FORMAT_BC1_UNORM",r[r.DXGI_FORMAT_BC1_UNORM_SRGB=72]="DXGI_FORMAT_BC1_UNORM_SRGB",r[r.DXGI_FORMAT_BC2_TYPELESS=73]="DXGI_FORMAT_BC2_TYPELESS",r[r.DXGI_FORMAT_BC2_UNORM=74]="DXGI_FORMAT_BC2_UNORM",r[r.DXGI_FORMAT_BC2_UNORM_SRGB=75]="DXGI_FORMAT_BC2_UNORM_SRGB",r[r.DXGI_FORMAT_BC3_TYPELESS=76]="DXGI_FORMAT_BC3_TYPELESS",r[r.DXGI_FORMAT_BC3_UNORM=77]="DXGI_FORMAT_BC3_UNORM",r[r.DXGI_FORMAT_BC3_UNORM_SRGB=78]="DXGI_FORMAT_BC3_UNORM_SRGB",r[r.DXGI_FORMAT_BC4_TYPELESS=79]="DXGI_FORMAT_BC4_TYPELESS",r[r.DXGI_FORMAT_BC4_UNORM=80]="DXGI_FORMAT_BC4_UNORM",r[r.DXGI_FORMAT_BC4_SNORM=81]="DXGI_FORMAT_BC4_SNORM",r[r.DXGI_FORMAT_BC5_TYPELESS=82]="DXGI_FORMAT_BC5_TYPELESS",r[r.DXGI_FORMAT_BC5_UNORM=83]="DXGI_FORMAT_BC5_UNORM",r[r.DXGI_FORMAT_BC5_SNORM=84]="DXGI_FORMAT_BC5_SNORM",r[r.DXGI_FORMAT_B5G6R5_UNORM=85]="DXGI_FORMAT_B5G6R5_UNORM",r[r.DXGI_FORMAT_B5G5R5A1_UNORM=86]="DXGI_FORMAT_B5G5R5A1_UNORM",r[r.DXGI_FORMAT_B8G8R8A8_UNORM=87]="DXGI_FORMAT_B8G8R8A8_UNORM",r[r.DXGI_FORMAT_B8G8R8X8_UNORM=88]="DXGI_FORMAT_B8G8R8X8_UNORM",r[r.DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM=89]="DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM",r[r.DXGI_FORMAT_B8G8R8A8_TYPELESS=90]="DXGI_FORMAT_B8G8R8A8_TYPELESS",r[r.DXGI_FORMAT_B8G8R8A8_UNORM_SRGB=91]="DXGI_FORMAT_B8G8R8A8_UNORM_SRGB",r[r.DXGI_FORMAT_B8G8R8X8_TYPELESS=92]="DXGI_FORMAT_B8G8R8X8_TYPELESS",r[r.DXGI_FORMAT_B8G8R8X8_UNORM_SRGB=93]="DXGI_FORMAT_B8G8R8X8_UNORM_SRGB",r[r.DXGI_FORMAT_BC6H_TYPELESS=94]="DXGI_FORMAT_BC6H_TYPELESS",r[r.DXGI_FORMAT_BC6H_UF16=95]="DXGI_FORMAT_BC6H_UF16",r[r.DXGI_FORMAT_BC6H_SF16=96]="DXGI_FORMAT_BC6H_SF16",r[r.DXGI_FORMAT_BC7_TYPELESS=97]="DXGI_FORMAT_BC7_TYPELESS",r[r.DXGI_FORMAT_BC7_UNORM=98]="DXGI_FORMAT_BC7_UNORM",r[r.DXGI_FORMAT_BC7_UNORM_SRGB=99]="DXGI_FORMAT_BC7_UNORM_SRGB",r[r.DXGI_FORMAT_AYUV=100]="DXGI_FORMAT_AYUV",r[r.DXGI_FORMAT_Y410=101]="DXGI_FORMAT_Y410",r[r.DXGI_FORMAT_Y416=102]="DXGI_FORMAT_Y416",r[r.DXGI_FORMAT_NV12=103]="DXGI_FORMAT_NV12",r[r.DXGI_FORMAT_P010=104]="DXGI_FORMAT_P010",r[r.DXGI_FORMAT_P016=105]="DXGI_FORMAT_P016",r[r.DXGI_FORMAT_420_OPAQUE=106]="DXGI_FORMAT_420_OPAQUE",r[r.DXGI_FORMAT_YUY2=107]="DXGI_FORMAT_YUY2",r[r.DXGI_FORMAT_Y210=108]="DXGI_FORMAT_Y210",r[r.DXGI_FORMAT_Y216=109]="DXGI_FORMAT_Y216",r[r.DXGI_FORMAT_NV11=110]="DXGI_FORMAT_NV11",r[r.DXGI_FORMAT_AI44=111]="DXGI_FORMAT_AI44",r[r.DXGI_FORMAT_IA44=112]="DXGI_FORMAT_IA44",r[r.DXGI_FORMAT_P8=113]="DXGI_FORMAT_P8",r[r.DXGI_FORMAT_A8P8=114]="DXGI_FORMAT_A8P8",r[r.DXGI_FORMAT_B4G4R4A4_UNORM=115]="DXGI_FORMAT_B4G4R4A4_UNORM",r[r.DXGI_FORMAT_P208=116]="DXGI_FORMAT_P208",r[r.DXGI_FORMAT_V208=117]="DXGI_FORMAT_V208",r[r.DXGI_FORMAT_V408=118]="DXGI_FORMAT_V408",r[r.DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE=119]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE",r[r.DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE=120]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE",r[r.DXGI_FORMAT_FORCE_UINT=121]="DXGI_FORMAT_FORCE_UINT",r))(nl||{}),ol=(r=>(r[r.DDS_DIMENSION_TEXTURE1D=2]="DDS_DIMENSION_TEXTURE1D",r[r.DDS_DIMENSION_TEXTURE2D=3]="DDS_DIMENSION_TEXTURE2D",r[r.DDS_DIMENSION_TEXTURE3D=6]="DDS_DIMENSION_TEXTURE3D",r))(ol||{});function ut(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var St=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.R8G8B8=20]="R8G8B8",r[r.A8R8G8B8=21]="A8R8G8B8",r[r.X8R8G8B8=22]="X8R8G8B8",r[r.R5G6B5=23]="R5G6B5",r[r.X1R5G5B5=24]="X1R5G5B5",r[r.A1R5G5B5=25]="A1R5G5B5",r[r.A4R4G4B4=26]="A4R4G4B4",r[r.R3G3B2=27]="R3G3B2",r[r.A8=28]="A8",r[r.A8R3G3B2=29]="A8R3G3B2",r[r.X4R4G4B4=30]="X4R4G4B4",r[r.A2B10G10R10=31]="A2B10G10R10",r[r.A8B8G8R8=32]="A8B8G8R8",r[r.X8B8G8R8=33]="X8B8G8R8",r[r.G16R16=34]="G16R16",r[r.A2R10G10B10=35]="A2R10G10B10",r[r.A16B16G16R16=36]="A16B16G16R16",r[r.A8P8=40]="A8P8",r[r.P8=41]="P8",r[r.L8=50]="L8",r[r.A8L8=51]="A8L8",r[r.A4L4=52]="A4L4",r[r.V8U8=60]="V8U8",r[r.L6V5U5=61]="L6V5U5",r[r.X8L8V8U8=62]="X8L8V8U8",r[r.Q8W8V8U8=63]="Q8W8V8U8",r[r.V16U16=64]="V16U16",r[r.A2W10V10U10=67]="A2W10V10U10",r[r.Q16W16V16U16=110]="Q16W16V16U16",r[r.R16F=111]="R16F",r[r.G16R16F=112]="G16R16F",r[r.A16B16G16R16F=113]="A16B16G16R16F",r[r.R32F=114]="R32F",r[r.G32R32F=115]="G32R32F",r[r.A32B32G32R32F=116]="A32B32G32R32F",r[r.UYVY=ut("UYVY")]="UYVY",r[r.R8G8_B8G8=ut("RGBG")]="R8G8_B8G8",r[r.YUY2=ut("YUY2")]="YUY2",r[r.D3DFMT_G8R8_G8B8=ut("GRGB")]="D3DFMT_G8R8_G8B8",r[r.DXT1=ut("DXT1")]="DXT1",r[r.DXT2=ut("DXT2")]="DXT2",r[r.DXT3=ut("DXT3")]="DXT3",r[r.DXT4=ut("DXT4")]="DXT4",r[r.DXT5=ut("DXT5")]="DXT5",r[r.ATI1=ut("ATI1")]="ATI1",r[r.AT1N=ut("AT1N")]="AT1N",r[r.ATI2=ut("ATI2")]="ATI2",r[r.AT2N=ut("AT2N")]="AT2N",r[r.BC4U=ut("BC4U")]="BC4U",r[r.BC4S=ut("BC4S")]="BC4S",r[r.BC5U=ut("BC5U")]="BC5U",r[r.BC5S=ut("BC5S")]="BC5S",r[r.DX10=ut("DX10")]="DX10",r))(St||{});const al={[St.DXT1]:"bc1-rgba-unorm",[St.DXT2]:"bc2-rgba-unorm",[St.DXT3]:"bc2-rgba-unorm",[St.DXT4]:"bc3-rgba-unorm",[St.DXT5]:"bc3-rgba-unorm",[St.ATI1]:"bc4-r-unorm",[St.BC4U]:"bc4-r-unorm",[St.BC4S]:"bc4-r-snorm",[St.ATI2]:"bc5-rg-unorm",[St.BC5U]:"bc5-rg-unorm",[St.BC5S]:"bc5-rg-snorm",36:"rgba16uint",110:"rgba16sint",111:"r16float",112:"rg16float",113:"rgba16float",114:"r32float",115:"rg32float",116:"rgba32float"},At={70:"bc1-rgba-unorm",71:"bc1-rgba-unorm",72:"bc1-rgba-unorm-srgb",73:"bc2-rgba-unorm",74:"bc2-rgba-unorm",75:"bc2-rgba-unorm-srgb",76:"bc3-rgba-unorm",77:"bc3-rgba-unorm",78:"bc3-rgba-unorm-srgb",79:"bc4-r-unorm",80:"bc4-r-unorm",81:"bc4-r-snorm",82:"bc5-rg-unorm",83:"bc5-rg-unorm",84:"bc5-rg-snorm",94:"bc6h-rgb-ufloat",95:"bc6h-rgb-ufloat",96:"bc6h-rgb-float",97:"bc7-rgba-unorm",98:"bc7-rgba-unorm",99:"bc7-rgba-unorm-srgb",28:"rgba8unorm",29:"rgba8unorm-srgb",87:"bgra8unorm",91:"bgra8unorm-srgb",41:"r32float",49:"rg8unorm",56:"r16uint",61:"r8unorm",24:"rgb10a2unorm",11:"rgba16uint",13:"rgba16sint",10:"rgba16float",54:"r16float",34:"rg16float",16:"rg32float",2:"rgba32float"},$={MAGIC_VALUE:542327876,MAGIC_SIZE:4,HEADER_SIZE:124,HEADER_DX10_SIZE:20,PIXEL_FORMAT_FLAGS:{ALPHAPIXELS:1,ALPHA:2,FOURCC:4,RGB:64,RGBA:65,YUV:512,LUMINANCE:131072,LUMINANCEA:131073},RESOURCE_MISC_TEXTURECUBE:4,HEADER_FIELDS:hE,HEADER_DX10_FIELDS:dE,DXGI_FORMAT:nl,D3D10_RESOURCE_DIMENSION:ol,D3DFMT:St},Xg={"bc1-rgba-unorm":8,"bc1-rgba-unorm-srgb":8,"bc2-rgba-unorm":16,"bc2-rgba-unorm-srgb":16,"bc3-rgba-unorm":16,"bc3-rgba-unorm-srgb":16,"bc4-r-unorm":8,"bc4-r-snorm":8,"bc5-rg-unorm":16,"bc5-rg-snorm":16,"bc6h-rgb-ufloat":16,"bc6h-rgb-float":16,"bc7-rgba-unorm":16,"bc7-rgba-unorm-srgb":16};function Hg(r,t){const{format:e,fourCC:i,width:s,height:n,dataOffset:o,mipmapCount:a}=fE(r);if(!t.includes(e))throw new Error(`Unsupported texture format: ${i} ${e}, supported: ${t}`);if(a<=1)return{format:e,width:s,height:n,resource:[new Uint8Array(r,o)],alphaMode:"no-premultiply-alpha"};const l=pE(e,s,n,o,a,r);return{format:e,width:s,height:n,resource:l,alphaMode:"no-premultiply-alpha"}}function pE(r,t,e,i,s,n){const o=[],a=Xg[r];let l=t,u=e,c=i;for(let h=0;h<s;++h){const p=Math.ceil(Math.max(4,l)/4)*4,f=Math.ceil(Math.max(4,u)/4)*4,m=a?p/4*f/4*a:l*u*4,_=new Uint8Array(n,c,m);o.push(_),c+=m,l=Math.max(l>>1,1),u=Math.max(u>>1,1)}return o}function fE(r){const t=new Uint32Array(r,0,$.HEADER_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(t[$.HEADER_FIELDS.MAGIC]!==$.MAGIC_VALUE)throw new Error("Invalid magic number in DDS header");const e=t[$.HEADER_FIELDS.HEIGHT],i=t[$.HEADER_FIELDS.WIDTH],s=Math.max(1,t[$.HEADER_FIELDS.MIPMAP_COUNT]),n=t[$.HEADER_FIELDS.PF_FLAGS],o=t[$.HEADER_FIELDS.FOURCC],a=mE(t,n,o,r),l=$.MAGIC_SIZE+$.HEADER_SIZE+(o===$.D3DFMT.DX10?$.HEADER_DX10_SIZE:0);return{format:a,fourCC:o,width:i,height:e,dataOffset:l,mipmapCount:s}}function mE(r,t,e,i){if(t&$.PIXEL_FORMAT_FLAGS.FOURCC){if(e===$.D3DFMT.DX10){const s=new Uint32Array(i,$.MAGIC_SIZE+$.HEADER_SIZE,$.HEADER_DX10_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(s[$.HEADER_DX10_FIELDS.MISC_FLAG]===$.RESOURCE_MISC_TEXTURECUBE)throw new Error("DDSParser does not support cubemap textures");if(s[$.HEADER_DX10_FIELDS.RESOURCE_DIMENSION]===$.D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D)throw new Error("DDSParser does not supported 3D texture data");const n=s[$.HEADER_DX10_FIELDS.DXGI_FORMAT];if(n in At)return At[n];throw new Error(`DDSParser cannot parse texture data with DXGI format ${n}`)}if(e in al)return al[e];throw new Error(`DDSParser cannot parse texture data with fourCC format ${e}`)}if(t&$.PIXEL_FORMAT_FLAGS.RGB||t&$.PIXEL_FORMAT_FLAGS.RGBA)return gE(r);throw t&$.PIXEL_FORMAT_FLAGS.YUV?new Error("DDSParser does not supported YUV uncompressed texture data."):t&$.PIXEL_FORMAT_FLAGS.LUMINANCE||t&$.PIXEL_FORMAT_FLAGS.LUMINANCEA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):t&$.PIXEL_FORMAT_FLAGS.ALPHA||t&$.PIXEL_FORMAT_FLAGS.ALPHAPIXELS?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}function gE(r){const t=r[$.HEADER_FIELDS.RGB_BITCOUNT],e=r[$.HEADER_FIELDS.R_BIT_MASK],i=r[$.HEADER_FIELDS.G_BIT_MASK],s=r[$.HEADER_FIELDS.B_BIT_MASK],n=r[$.HEADER_FIELDS.A_BIT_MASK];switch(t){case 32:if(e===255&&i===65280&&s===16711680&&n===4278190080)return At[$.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(e===16711680&&i===65280&&s===255&&n===4278190080)return At[$.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(e===1072693248&&i===1047552&&s===1023&&n===3221225472)return At[$.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(e===65535&&i===4294901760&&s===0&&n===0)return At[$.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(e===4294967295&&i===0&&s===0&&n===0)return At[$.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(e===31744&&i===992&&s===31&&n===32768)return At[$.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(e===63488&&i===2016&&s===31&&n===0)return At[$.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(e===3840&&i===240&&s===15&&n===61440)return At[$.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(e===255&&i===0&&s===0&&n===65280)return At[$.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(e===65535&&i===0&&s===0&&n===0)return At[$.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(e===255&&i===0&&s===0&&n===0)return At[$.DXGI_FORMAT.DXGI_FORMAT_R8_UNORM];break}throw new Error(`DDSParser does not support uncompressed texture with configuration:
bitCount = ${t}, rBitMask = ${e}, gBitMask = ${i}, aBitMask = ${n}`)}const _E={extension:{type:T.LoadParser,priority:Pt.High,name:"loadDDS"},name:"loadDDS",id:"dds",test(r){return Ut(r,[".dds"])},async load(r,t,e){const i=await ni(),s=await(await fetch(r)).arrayBuffer(),n=Hg(s,i),o=new si(n);return de(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};var jg=(r=>(r[r.RGBA8_SNORM=36759]="RGBA8_SNORM",r[r.RGBA=6408]="RGBA",r[r.RGBA8UI=36220]="RGBA8UI",r[r.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",r[r.RGBA8I=36238]="RGBA8I",r[r.RGBA8=32856]="RGBA8",r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",r[r.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",r[r.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",r[r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",r[r.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r[r.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",r[r.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",r[r.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",r[r.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",r[r.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",r[r.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",r[r.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",r[r.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",r[r.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",r[r.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",r[r.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",r[r.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",r[r.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",r[r.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",r[r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",r[r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",r[r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",r))(jg||{}),bE=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(bE||{}),vE=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(vE||{});const it={FILE_HEADER_SIZE:64,FILE_IDENTIFIER:[171,75,84,88,32,49,49,187,13,10,26,10],FORMATS_TO_COMPONENTS:{6408:4,6407:3,33319:2,6403:1,6409:1,6410:2,6406:1},INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:{33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,36283:.5,36284:.5,36285:1,36286:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,37808:1,37840:1,37809:.8,37841:.8,37810:.64,37842:.64,37811:.53375,37843:.53375,37812:.445,37844:.445,37813:.4,37845:.4,37814:.33375,37846:.33375,37815:.25,37847:.25,37816:.32,37848:.32,37817:.26625,37849:.26625,37818:.2,37850:.2,37819:.16,37851:.16,37820:.13375,37852:.13375,37821:.11125,37853:.11125,36492:1,36493:1,36494:1,36495:1},INTERNAL_FORMAT_TO_TEXTURE_FORMATS:{33776:"bc1-rgba-unorm",33777:"bc1-rgba-unorm",33778:"bc2-rgba-unorm",33779:"bc3-rgba-unorm",35916:"bc1-rgba-unorm-srgb",35917:"bc1-rgba-unorm-srgb",35918:"bc2-rgba-unorm-srgb",35919:"bc3-rgba-unorm-srgb",36283:"bc4-r-unorm",36284:"bc4-r-snorm",36285:"bc5-rg-unorm",36286:"bc5-rg-snorm",37488:"eac-r11unorm",37490:"eac-rg11snorm",37492:"etc2-rgb8unorm",37496:"etc2-rgba8unorm",37493:"etc2-rgb8unorm-srgb",37497:"etc2-rgba8unorm-srgb",37494:"etc2-rgb8a1unorm",37495:"etc2-rgb8a1unorm-srgb",37808:"astc-4x4-unorm",37840:"astc-4x4-unorm-srgb",37809:"astc-5x4-unorm",37841:"astc-5x4-unorm-srgb",37810:"astc-5x5-unorm",37842:"astc-5x5-unorm-srgb",37811:"astc-6x5-unorm",37843:"astc-6x5-unorm-srgb",37812:"astc-6x6-unorm",37844:"astc-6x6-unorm-srgb",37813:"astc-8x5-unorm",37845:"astc-8x5-unorm-srgb",37814:"astc-8x6-unorm",37846:"astc-8x6-unorm-srgb",37815:"astc-8x8-unorm",37847:"astc-8x8-unorm-srgb",37816:"astc-10x5-unorm",37848:"astc-10x5-unorm-srgb",37817:"astc-10x6-unorm",37849:"astc-10x6-unorm-srgb",37818:"astc-10x8-unorm",37850:"astc-10x8-unorm-srgb",37819:"astc-10x10-unorm",37851:"astc-10x10-unorm-srgb",37820:"astc-12x10-unorm",37852:"astc-12x10-unorm-srgb",37821:"astc-12x12-unorm",37853:"astc-12x12-unorm-srgb",36492:"bc7-rgba-unorm",36493:"bc7-rgba-unorm-srgb",36494:"bc6h-rgb-float",36495:"bc6h-rgb-ufloat",35907:"rgba8unorm-srgb",36759:"rgba8snorm",36220:"rgba8uint",36238:"rgba8sint",6408:"rgba8unorm"},FIELDS:{FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},TYPES_TO_BYTES_PER_COMPONENT:{5121:1,5123:2,5124:4,5125:4,5126:4,36193:8},TYPES_TO_BYTES_PER_PIXEL:{32819:2,32820:2,33635:2},ENDIANNESS:67305985};function zg(r,t){const e=new DataView(r);if(!SE(e))throw new Error("Invalid KTX identifier in header");const{littleEndian:i,glType:s,glFormat:n,glInternalFormat:o,pixelWidth:a,pixelHeight:l,numberOfMipmapLevels:u,offset:c}=TE(e),h=it.INTERNAL_FORMAT_TO_TEXTURE_FORMATS[o];if(!h)throw new Error(`Unknown texture format ${o}`);if(!t.includes(h))throw new Error(`Unsupported texture format: ${h}, supportedFormats: ${t}`);const p=xE(s,n,o),f=yE(e,s,p,a,l,c,u,i);return{format:h,width:a,height:l,resource:f,alphaMode:"no-premultiply-alpha"}}function yE(r,t,e,i,s,n,o,a){const l=i+3&-4,u=s+3&-4;let c=i*s;t===0&&(c=l*u);let h=c*e,p=i,f=s,m=l,_=u,g=n;const b=new Array(o);for(let y=0;y<o;y++){const v=r.getUint32(g,a);let x=g+4;b[y]=new Uint8Array(r.buffer,x,h),x+=h,g+=v+4,g=g%4!==0?g+4-g%4:g,p=p>>1||1,f=f>>1||1,m=p+4-1&-4,_=f+4-1&-4,h=m*_*e}return b}function xE(r,t,e){let i=it.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e];if(r!==0&&(it.TYPES_TO_BYTES_PER_COMPONENT[r]?i=it.TYPES_TO_BYTES_PER_COMPONENT[r]*it.FORMATS_TO_COMPONENTS[t]:i=it.TYPES_TO_BYTES_PER_PIXEL[r]),i===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");return i}function TE(r){const t=r.getUint32(it.FIELDS.ENDIANNESS,!0)===it.ENDIANNESS,e=r.getUint32(it.FIELDS.GL_TYPE,t),i=r.getUint32(it.FIELDS.GL_FORMAT,t),s=r.getUint32(it.FIELDS.GL_INTERNAL_FORMAT,t),n=r.getUint32(it.FIELDS.PIXEL_WIDTH,t),o=r.getUint32(it.FIELDS.PIXEL_HEIGHT,t)||1,a=r.getUint32(it.FIELDS.PIXEL_DEPTH,t)||1,l=r.getUint32(it.FIELDS.NUMBER_OF_ARRAY_ELEMENTS,t)||1,u=r.getUint32(it.FIELDS.NUMBER_OF_FACES,t),c=r.getUint32(it.FIELDS.NUMBER_OF_MIPMAP_LEVELS,t),h=r.getUint32(it.FIELDS.BYTES_OF_KEY_VALUE_DATA,t);if(o===0||a!==1)throw new Error("Only 2D textures are supported");if(u!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(l!==1)throw new Error("WebGL does not support array textures");return{littleEndian:t,glType:e,glFormat:i,glInternalFormat:s,pixelWidth:n,pixelHeight:o,numberOfMipmapLevels:c,offset:it.FILE_HEADER_SIZE+h}}function SE(r){for(let t=0;t<it.FILE_IDENTIFIER.length;t++)if(r.getUint8(t)!==it.FILE_IDENTIFIER[t])return!1;return!0}const AE={extension:{type:T.LoadParser,priority:Pt.High,name:"loadKTX"},name:"loadKTX",id:"ktx",test(r){return Ut(r,".ktx")},async load(r,t,e){const i=await ni(),s=await(await fetch(r)).arrayBuffer(),n=zg(s,i),o=new si(n);return de(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},EE='(function(){"use strict";const s={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:i},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:i}};function f(r){const t=r.format;if(s[t]){const n=s[t].convertFunction,o=r.resource;for(let e=0;e<o.length;e++)o[e]=n(o[e]);r.format=s[t].convertedFormat}}function i(r){const t=r.byteLength/3,n=new Uint32Array(t);for(let o=0;o<t;++o)n[o]=r[o*3]+(r[o*3+1]<<8)+(r[o*3+2]<<16)+4278190080;return new Uint8Array(n.buffer)}function d(r){const t=[];for(let n=0;n<r.numLevels;n++){const o=r.getImageData(n,0,0),e=new Uint8Array(o.byteLength);e.set(o),t.push(e)}return t}const w={6408:"rgba8unorm",32856:"bgra8unorm",32857:"rgb10a2unorm",33189:"depth16unorm",33190:"depth24plus",33321:"r8unorm",33323:"rg8unorm",33325:"r16float",33326:"r32float",33327:"rg16float",33328:"rg32float",33329:"r8sint",33330:"r8uint",33331:"r16sint",33332:"r16uint",33333:"r32sint",33334:"r32uint",33335:"rg8sint",33336:"rg8uint",33337:"rg16sint",33338:"rg16uint",33339:"rg32sint",33340:"rg32uint",33778:"bc2-rgba-unorm",33779:"bc3-rgba-unorm",34836:"rgba32float",34842:"rgba16float",35056:"depth24plus-stencil8",35898:"rg11b10ufloat",35901:"rgb9e5ufloat",35907:"rgba8unorm-srgb",36012:"depth32float",36013:"depth32float-stencil8",36168:"stencil8",36208:"rgba32uint",36214:"rgba16uint",36220:"rgba8uint",36226:"rgba32sint",36232:"rgba16sint",36238:"rgba8sint",36492:"bc7-rgba-unorm",36756:"r8snorm",36757:"rg8snorm",36759:"rgba8snorm",37496:"etc2-rgba8unorm",37808:"astc-4x4-unorm"};function p(r){const t=w[r];if(t)return t;throw new Error(`Unsupported glInternalFormat: ${r}`)}const h={23:"rgb8unorm",37:"rgba8unorm",43:"rgba8unorm-srgb"};function F(r){const t=h[r];if(t)return t;throw new Error(`Unsupported VkFormat: ${r}`)}function U(r){return r.classId===2?F(r.vkFormat):p(r.glInternalformat)}const y={"bc3-rgba-unorm":"BC3_RGBA","bc7-rgba-unorm":"BC7_M5_RGBA","etc2-rgba8unorm":"ETC2_RGBA","astc-4x4-unorm":"ASTC_4x4_RGBA",rgba8unorm:"RGBA32",rg11b10ufloat:"R11F_G11F_B10F"};function T(r){const t=y[r];if(t)return t;throw new Error(`Unsupported transcoderFormat: ${r}`)}const a={jsUrl:"",wasmUrl:""};let l,u,c;async function g(){if(!c){const r=new URL(a.jsUrl,location.origin).href,t=new URL(a.wasmUrl,location.origin).href;importScripts(r),c=new Promise(n=>{LIBKTX({locateFile:o=>t}).then(o=>{n(o)})})}return c}async function v(r,t){const n=await fetch(r);if(n.ok){const o=await n.arrayBuffer();return new t.ktxTexture(new Uint8Array(o))}throw new Error(`Failed to load KTX(2) texture: ${r}`)}const x=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function B(r){const t=await g(),n=await v(r,t);let o;if(n.needsTranscoding){o=u;const R=t.TranscodeTarget[l];if(n.transcodeBasis(R,0)!==t.ErrorCode.SUCCESS)throw new Error("Unable to transcode basis texture.")}else o=U(n);const e=d(n),b={width:n.baseWidth,height:n.baseHeight,format:o,mipLevelCount:n.numLevels,resource:e,alphaMode:"no-premultiply-alpha"};return f(b),b}async function A(r,t,n){r&&(a.jsUrl=r),t&&(a.wasmUrl=t),u=x.filter(o=>n.includes(o))[0],l=T(u),await g()}const m={init:async r=>{const{jsUrl:t,wasmUrl:n,supportedTextures:o}=r;await A(t,n,o)},load:async r=>{var t;try{const n=await B(r.url);return{type:"load",url:r.url,success:!0,textureOptions:n,transferables:(t=n.resource)==null?void 0:t.map(o=>o.buffer)}}catch(n){throw n}}};self.onmessage=async r=>{var t;const n=r.data;try{const o=await((t=m[n.type])==null?void 0:t.call(m,n));o&&self.postMessage(o,o.transferables)}catch(o){self.postMessage({type:"error",err:o,url:n.url})}}})();\n';let fr=null;class Vg{constructor(){fr||(fr=URL.createObjectURL(new Blob([EE],{type:"application/javascript"}))),this.worker=new Worker(fr)}}Vg.revokeObjectURL=function(){fr&&(URL.revokeObjectURL(fr),fr=null)};const Os={jsUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/ktx/libktx.js",wasmUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/ktx/libktx.wasm"};function PE(r){Object.assign(Os,r)}let ai;const Wg={},Yg={};function wE(r){return ai||(ai=new Vg().worker,ai.onmessage=t=>{const{err:e,success:i,url:s,textureOptions:n}=t.data;if(e){Yg[s](e);return}i||console.warn("Failed to load KTX texture",s),Wg[s](n)},ai.postMessage({type:"init",jsUrl:Os.jsUrl,wasmUrl:Os.wasmUrl,supportedTextures:r})),ai}function Kg(r,t){const e=wE(t);return new Promise((i,s)=>{Wg[r]=i,Yg[r]=s,e.postMessage({type:"load",url:r})})}const RE={extension:{type:T.LoadParser,priority:Pt.High,name:"loadKTX2"},name:"loadKTX2",id:"ktx2",test(r){return Ut(r,".ktx2")},async load(r,t,e){const i=await ni(),s=await Kg(r,i),n=new si(s);return de(n,e,r)},async unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},ll={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:qg},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:qg}};function CE(r){const t=r.format;if(ll[t]){const e=ll[t].convertFunction,i=r.resource;for(let s=0;s<i.length;s++)i[s]=e(i[s]);r.format=ll[t].convertedFormat}}function qg(r){const t=r.byteLength/3,e=new Uint32Array(t);for(let i=0;i<t;++i)e[i]=r[i*3]+(r[i*3+1]<<8)+(r[i*3+2]<<16)+4278190080;return new Uint8Array(e.buffer)}function ME(r){const t=[];for(let e=0;e<r.numLevels;e++){const i=r.getImageData(e,0,0),s=new Uint8Array(i.byteLength);s.set(i),t.push(s)}return t}const OE={6408:"rgba8unorm",32856:"bgra8unorm",32857:"rgb10a2unorm",33189:"depth16unorm",33190:"depth24plus",33321:"r8unorm",33323:"rg8unorm",33325:"r16float",33326:"r32float",33327:"rg16float",33328:"rg32float",33329:"r8sint",33330:"r8uint",33331:"r16sint",33332:"r16uint",33333:"r32sint",33334:"r32uint",33335:"rg8sint",33336:"rg8uint",33337:"rg16sint",33338:"rg16uint",33339:"rg32sint",33340:"rg32uint",33778:"bc2-rgba-unorm",33779:"bc3-rgba-unorm",34836:"rgba32float",34842:"rgba16float",35056:"depth24plus-stencil8",35898:"rg11b10ufloat",35901:"rgb9e5ufloat",35907:"rgba8unorm-srgb",36012:"depth32float",36013:"depth32float-stencil8",36168:"stencil8",36208:"rgba32uint",36214:"rgba16uint",36220:"rgba8uint",36226:"rgba32sint",36232:"rgba16sint",36238:"rgba8sint",36492:"bc7-rgba-unorm",36756:"r8snorm",36757:"rg8snorm",36759:"rgba8snorm",37496:"etc2-rgba8unorm",37808:"astc-4x4-unorm"};function Zg(r){const t=OE[r];if(t)return t;throw new Error(`Unsupported glInternalFormat: ${r}`)}const GE={23:"rgb8unorm",37:"rgba8unorm",43:"rgba8unorm-srgb"};function Qg(r){const t=GE[r];if(t)return t;throw new Error(`Unsupported VkFormat: ${r}`)}function BE(r){return r.classId===2?Qg(r.vkFormat):Zg(r.glInternalformat)}const IE={"bc3-rgba-unorm":"BC3_RGBA","bc7-rgba-unorm":"BC7_M5_RGBA","etc2-rgba8unorm":"ETC2_RGBA","astc-4x4-unorm":"ASTC_4x4_RGBA",rgba8unorm:"RGBA32",rg11b10ufloat:"R11F_G11F_B10F"};function FE(r){const t=IE[r];if(t)return t;throw new Error(`Unsupported transcoderFormat: ${r}`)}const Gs=["basis","bc7","bc6h","astc","etc2","bc5","bc4","bc3","bc2","bc1","eac"],DE={extension:T.ResolveParser,test:r=>Ut(r,[".ktx",".ktx2",".dds"]),parse:r=>{var t,e;let i;const s=r.split(".");if(s.length>2){const n=s[s.length-2];Gs.includes(n)&&(i=n)}else i=s[s.length-1];return{resolution:parseFloat((e=(t=ae.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:i,src:r}}};let Bs;const UE={extension:{type:T.DetectionParser,priority:2},test:async()=>!!(await Jr()||Qr()),add:async r=>{const t=await sl();return Bs=kE(t),[...Bs,...r]},remove:async r=>Bs?r.filter(t=>!(t in Bs)):r};function kE(r){const t=["basis"],e={};return r.forEach(i=>{const s=i.split("-")[0];s&&!e[s]&&(e[s]=!0,t.push(s))}),t.sort((i,s)=>{const n=Gs.indexOf(i),o=Gs.indexOf(s);return n===-1?1:o===-1?-1:n-o}),t}const $E=new ot,ul=class{cull(t,e,i=!0){this._cullRecursive(t,e,i)}_cullRecursive(t,e,i=!0){var s;if(t.cullable&&t.measurable&&t.includeInBuild){const n=(s=t.cullArea)!=null?s:Sr(t,i,$E);t.culled=n.x>=e.x+e.width||n.y>=e.y+e.height||n.x+n.width<=e.x||n.y+n.height<=e.y}else t.culled=!1;if(!(!t.cullableChildren||t.culled||!t.renderable||!t.measurable||!t.includeInBuild))for(let n=0;n<t.children.length;n++)this._cullRecursive(t.children[n],e,i)}};ul.shared=new ul;let Jg=ul;class t_{static init(t){this._renderRef=this.render.bind(this),this.render=()=>{var e;const i=((e=t==null?void 0:t.culler)==null?void 0:e.updateTransform)!==!0;Jg.shared.cull(this.stage,this.renderer.screen,i),this.renderer.render({container:this.stage})}}static destroy(){this.render=this._renderRef}}t_.extension={priority:10,type:T.Application,name:"culler"};const LE={extension:{type:T.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(function(){return V2})}};var e_=`
in vec2 vTextureCoord;
in vec4 vColor;
out vec4 finalColor;
uniform float uBlend;
uniform sampler2D uTexture;
uniform sampler2D uBackTexture;
{FUNCTIONS}
void main()
{
vec4 back = texture(uBackTexture, vTextureCoord);
vec4 front = texture(uTexture, vTextureCoord);
float blendedAlpha = front.a + back.a * (1.0 - front.a);
{MAIN}
}
`,r_=`in vec2 aPosition;
out vec2 vTextureCoord;
out vec2 backgroundUv;
uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;
vec4 filterVertexPosition( void )
{
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
vec2 filterTextureCoord( void )
{
return aPosition * (uOutputFrame.zw * uInputSize.zw);
}
void main(void)
{
gl_Position = filterVertexPosition();
vTextureCoord = filterTextureCoord();
}
`,i_=`
struct GlobalFilterUniforms {
uInputSize:vec4<f32>,
uInputPixel:vec4<f32>,
uInputClamp:vec4<f32>,
uOutputFrame:vec4<f32>,
uGlobalFrame:vec4<f32>,
uOutputTexture:vec4<f32>,
};
struct BlendUniforms {
uBlend:f32,
};
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;
@group(0) @binding(3) var uBackTexture: texture_2d<f32>;
@group(1) @binding(0) var<uniform> blendUniforms : BlendUniforms;
struct VSOutput {
@builtin(position) position: vec4<f32>,
@location(0) uv : vec2<f32>
};
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
}
@vertex
fn mainVertex(
@location(0) aPosition : vec2<f32>,
) -> VSOutput {
return VSOutput(
filterVertexPosition(aPosition),
filterTextureCoord(aPosition)
);
}
{FUNCTIONS}
@fragment
fn mainFragment(
@location(0) uv: vec2<f32>
) -> @location(0) vec4<f32> {
var back = textureSample(uBackTexture, uSampler, uv);
var front = textureSample(uTexture, uSampler, uv);
var blendedAlpha = front.a + back.a * (1.0 - front.a);
var out = vec4<f32>(0.0,0.0,0.0,0.0);
{MAIN}
return out;
}`,NE=Object.defineProperty,s_=Object.getOwnPropertySymbols,XE=Object.prototype.hasOwnProperty,HE=Object.prototype.propertyIsEnumerable,n_=(r,t,e)=>t in r?NE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,o_=(r,t)=>{for(var e in t||(t={}))XE.call(t,e)&&n_(r,e,t[e]);if(s_)for(var e of s_(t))HE.call(t,e)&&n_(r,e,t[e]);return r};class jE extends te{constructor(t){const e=t.gpu,i=a_(o_({source:i_},e)),s=dt.from({vertex:{source:i,entryPoint:"mainVertex"},fragment:{source:i,entryPoint:"mainFragment"}}),n=t.gl,o=a_(o_({source:e_},n)),a=vt.from({vertex:r_,fragment:o}),l=new nt({uBlend:{value:1,type:"f32"}});super({gpuProgram:s,glProgram:a,blendRequired:!0,resources:{blendUniforms:l,uBackTexture:w.EMPTY}})}}function a_(r){const{source:t,functions:e,main:i}=r;return t.replace("{FUNCTIONS}",e).replace("{MAIN}",i)}const zE=`
float getLuminosity(vec3 c) {
return 0.3 * c.r + 0.59 * c.g + 0.11 * c.b;
}
vec3 setLuminosity(vec3 c, float lum) {
float modLum = lum - getLuminosity(c);
vec3 color = c.rgb + vec3(modLum);
// clip back into legal range
modLum = getLuminosity(color);
vec3 modLumVec = vec3(modLum);
float cMin = min(color.r, min(color.g, color.b));
float cMax = max(color.r, max(color.g, color.b));
if(cMin < 0.0) {
color = mix(modLumVec, color, modLum / (modLum - cMin));
}
if(cMax > 1.0) {
color = mix(modLumVec, color, (1.0 - modLum) / (cMax - modLum));
}
return color;
}
float getSaturation(vec3 c) {
return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b));
}
vec3 setSaturationMinMidMax(vec3 cSorted, float s) {
vec3 colorSorted = cSorted;
if(colorSorted.z > colorSorted.x) {
colorSorted.y = (((colorSorted.y - colorSorted.x) * s) / (colorSorted.z - colorSorted.x));
colorSorted.z = s;
}
else {
colorSorted.y = 0.0;
colorSorted.z = 0.0;
}
colorSorted.x = 0.0;
return colorSorted;
}
vec3 setSaturation(vec3 c, float s) {
vec3 color = c;
if(color.r <= color.g && color.r <= color.b) {
if(color.g <= color.b) {
color = setSaturationMinMidMax(color.rgb, s).rgb;
}
else {
color = setSaturationMinMidMax(color.rbg, s).rbg;
}
}
else if(color.g <= color.r && color.g <= color.b) {
if(color.r <= color.b) {
color = setSaturationMinMidMax(color.grb, s).grb;
}
else {
color = setSaturationMinMidMax(color.gbr, s).gbr;
}
}
else {
// Using bgr for both fixes part of hue
if(color.r <= color.g) {
color = setSaturationMinMidMax(color.brg, s).brg;
}
else {
color = setSaturationMinMidMax(color.bgr, s).bgr;
}
}
return color;
}
`,VE=`
fn getLuminosity(c: vec3<f32>) -> f32
{
return 0.3*c.r + 0.59*c.g + 0.11*c.b;
}
fn setLuminosity(c: vec3<f32>, lum: f32) -> vec3<f32>
{
var modLum: f32 = lum - getLuminosity(c);
var color: vec3<f32> = c.rgb + modLum;
// clip back into legal range
modLum = getLuminosity(color);
let modLumVec = vec3<f32>(modLum);
let cMin: f32 = min(color.r, min(color.g, color.b));
let cMax: f32 = max(color.r, max(color.g, color.b));
if(cMin < 0.0)
{
color = mix(modLumVec, color, modLum / (modLum - cMin));
}
if(cMax > 1.0)
{
color = mix(modLumVec, color, (1 - modLum) / (cMax - modLum));
}
return color;
}
fn getSaturation(c: vec3<f32>) -> f32
{
return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b));
}
fn setSaturationMinMidMax(cSorted: vec3<f32>, s: f32) -> vec3<f32>
{
var colorSorted = cSorted;
if(colorSorted.z > colorSorted.x)
{
colorSorted.y = (((colorSorted.y - colorSorted.x) * s) / (colorSorted.z - colorSorted.x));
colorSorted.z = s;
}
else
{
colorSorted.y = 0;
colorSorted.z = 0;
}
colorSorted.x = 0;
return colorSorted;
}
fn setSaturation(c: vec3<f32>, s: f32) -> vec3<f32>
{
var color = c;
if (color.r <= color.g && color.r <= color.b)
{
if (color.g <= color.b)
{
color = vec3<f32>(setSaturationMinMidMax(color.rgb, s)).rgb;
}
else
{
color = vec3<f32>(setSaturationMinMidMax(color.rbg, s)).rbg;
}
}
else if (color.g <= color.r && color.g <= color.b)
{
if (color.r <= color.b)
{
color = vec3<f32>(setSaturationMinMidMax(color.grb, s)).grb;
}
else
{
color = vec3<f32>(setSaturationMinMidMax(color.gbr, s)).gbr;
}
}
else
{
// Using bgr for both fixes part of hue
if (color.r <= color.g)
{
color = vec3<f32>(setSaturationMinMidMax(color.brg, s)).brg;
}
else
{
color = vec3<f32>(setSaturationMinMidMax(color.bgr, s)).bgr;
}
}
return color;
}
`;var l_=`
in vec2 vTextureCoord;
out vec4 finalColor;
uniform float uAlpha;
uniform sampler2D uTexture;
void main()
{
finalColor = texture(uTexture, vTextureCoord) * uAlpha;
}
`,cl=`struct GlobalFilterUniforms {
uInputSize:vec4<f32>,
uInputPixel:vec4<f32>,
uInputClamp:vec4<f32>,
uOutputFrame:vec4<f32>,
uGlobalFrame:vec4<f32>,
uOutputTexture:vec4<f32>,
};
struct AlphaUniforms {
uAlpha:f32,
};
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;
@group(1) @binding(0) var<uniform> alphaUniforms : AlphaUniforms;
struct VSOutput {
@builtin(position) position: vec4<f32>,
@location(0) uv : vec2<f32>
};
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
}
fn getSize() -> vec2<f32>
{
return gfu.uGlobalFrame.zw;
}
@vertex
fn mainVertex(
@location(0) aPosition : vec2<f32>,
) -> VSOutput {
return VSOutput(
filterVertexPosition(aPosition),
filterTextureCoord(aPosition)
);
}
@fragment
fn mainFragment(
@location(0) uv: vec2<f32>,
@builtin(position) position: vec4<f32>
) -> @location(0) vec4<f32> {
var sample = textureSample(uTexture, uSampler, uv);
return sample * alphaUniforms.uAlpha;
}`,WE=Object.defineProperty,YE=Object.defineProperties,KE=Object.getOwnPropertyDescriptors,Is=Object.getOwnPropertySymbols,u_=Object.prototype.hasOwnProperty,c_=Object.prototype.propertyIsEnumerable,h_=(r,t,e)=>t in r?WE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hl=(r,t)=>{for(var e in t||(t={}))u_.call(t,e)&&h_(r,e,t[e]);if(Is)for(var e of Is(t))c_.call(t,e)&&h_(r,e,t[e]);return r},qE=(r,t)=>YE(r,KE(t)),ZE=(r,t)=>{var e={};for(var i in r)u_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Is)for(var i of Is(r))t.indexOf(i)<0&&c_.call(r,i)&&(e[i]=r[i]);return e};const d_=class t0 extends te{constructor(t){t=hl(hl({},t0.defaultOptions),t);const e=dt.from({vertex:{source:cl,entryPoint:"mainVertex"},fragment:{source:cl,entryPoint:"mainFragment"}}),i=vt.from({vertex:Kr,fragment:l_,name:"alpha-filter"}),s=t,{alpha:n}=s,o=ZE(s,["alpha"]),a=new nt({uAlpha:{value:n,type:"f32"}});super(qE(hl({},o),{gpuProgram:e,glProgram:i,resources:{alphaUniforms:a}}))}get alpha(){return this.resources.alphaUniforms.uniforms.uAlpha}set alpha(t){this.resources.alphaUniforms.uniforms.uAlpha=t}};d_.defaultOptions={alpha:1};let QE=d_;const dl={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},JE=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," finalColor = vec4(0.0);"," %blur%","}"].join(`
`);function p_(r){const t=dl[r],e=t.length;let i=JE,s="";const n="finalColor += texture(uTexture, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<r;a++){let l=n.replace("%index%",a.toString());o=a,a>=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),s+=l,s+=`
`}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const tP=`
in vec2 aPosition;
uniform float uStrength;
out vec2 vBlurTexCoords[%size%];
uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;
vec4 filterVertexPosition( void )
{
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
vec2 filterTextureCoord( void )
{
return aPosition * (uOutputFrame.zw * uInputSize.zw);
}
void main(void)
{
gl_Position = filterVertexPosition();
float pixelStrength = uInputSize.%dimension% * uStrength;
vec2 textureCoord = filterTextureCoord();
%blur%
}`;function f_(r,t){const e=Math.ceil(r/2);let i=tP,s="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * pixelStrength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * pixelStrength);";for(let o=0;o<r;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),s+=a,s+=`
`}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i=i.replace("%dimension%",t?"z":"w"),i}function m_(r,t){const e=f_(t,r),i=p_(t);return vt.from({vertex:e,fragment:i,name:`blur-${r?"horizontal":"vertical"}-pass-filter`})}var g_=`
struct GlobalFilterUniforms {
uInputSize:vec4<f32>,
uInputPixel:vec4<f32>,
uInputClamp:vec4<f32>,
uOutputFrame:vec4<f32>,
uGlobalFrame:vec4<f32>,
uOutputTexture:vec4<f32>,
};
struct BlurUniforms {
uStrength:f32,
};
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;
@group(1) @binding(0) var<uniform> blurUniforms : BlurUniforms;
struct VSOutput {
@builtin(position) position: vec4<f32>,
%blur-struct%
};
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
}
fn getSize() -> vec2<f32>
{
return gfu.uGlobalFrame.zw;
}
@vertex
fn mainVertex(
@location(0) aPosition : vec2<f32>,
) -> VSOutput {
let filteredCord = filterTextureCoord(aPosition);
let pixelStrength = gfu.uInputSize.%dimension% * blurUniforms.uStrength;
return VSOutput(
filterVertexPosition(aPosition),
%blur-vertex-out%
);
}
@fragment
fn mainFragment(
@builtin(position) position: vec4<f32>,
%blur-fragment-in%
) -> @location(0) vec4<f32> {
var finalColor = vec4(0.0);
%blur-sampling%
return finalColor;
}`;function __(r,t){const e=dl[t],i=e.length,s=[],n=[],o=[];for(let h=0;h<t;h++){s[h]=`@location(${h}) offset${h}: vec2<f32>,`,r?n[h]=`filteredCord + vec2(${h-i+1} * pixelStrength, 0.0),`:n[h]=`filteredCord + vec2(0.0, ${h-i+1} * pixelStrength),`;const p=h<i?h:t-h-1,f=e[p].toString();o[h]=`finalColor += textureSample(uTexture, uSampler, offset${h}) * ${f};`}const a=s.join(`
`),l=n.join(`
`),u=o.join(`
`),c=g_.replace("%blur-struct%",a).replace("%blur-vertex-out%",l).replace("%blur-fragment-in%",a).replace("%blur-sampling%",u).replace("%dimension%",r?"z":"w");return dt.from({vertex:{source:c,entryPoint:"mainVertex"},fragment:{source:c,entryPoint:"mainFragment"}})}var eP=Object.defineProperty,b_=Object.getOwnPropertySymbols,rP=Object.prototype.hasOwnProperty,iP=Object.prototype.propertyIsEnumerable,v_=(r,t,e)=>t in r?eP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pl=(r,t)=>{for(var e in t||(t={}))rP.call(t,e)&&v_(r,e,t[e]);if(b_)for(var e of b_(t))iP.call(t,e)&&v_(r,e,t[e]);return r};const y_=class e0 extends te{constructor(t){t=pl(pl({},e0.defaultOptions),t);const e=m_(t.horizontal,t.kernelSize),i=__(t.horizontal,t.kernelSize);super(pl({glProgram:e,gpuProgram:i,resources:{blurUniforms:{uStrength:{value:0,type:"f32"}}}},t)),this.horizontal=t.horizontal,this._quality=0,this.quality=t.quality,this.blur=t.strength,this._uniforms=this.resources.blurUniforms.uniforms}apply(t,e,i,s){if(this._uniforms.uStrength=this.strength/this.passes,this.passes===1)t.applyFilter(this,e,i,s);else{const n=et.getSameSizeTexture(e);let o=e,a=n;this._state.blend=!1;const l=t.renderer.type===yt.WEBGPU;for(let u=0;u<this.passes-1;u++){t.applyFilter(this,o,a,u===0?!0:l);const c=a;a=o,o=c}this._state.blend=!0,t.applyFilter(this,o,i,s),et.returnTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}};y_.defaultOptions={strength:8,quality:4,kernelSize:5};let Fs=y_;var sP=Object.defineProperty,nP=Object.defineProperties,oP=Object.getOwnPropertyDescriptors,Ds=Object.getOwnPropertySymbols,x_=Object.prototype.hasOwnProperty,T_=Object.prototype.propertyIsEnumerable,S_=(r,t,e)=>t in r?sP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,li=(r,t)=>{for(var e in t||(t={}))x_.call(t,e)&&S_(r,e,t[e]);if(Ds)for(var e of Ds(t))T_.call(t,e)&&S_(r,e,t[e]);return r},aP=(r,t)=>nP(r,oP(t)),lP=(r,t)=>{var e={};for(var i in r)x_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ds)for(var i of Ds(r))t.indexOf(i)<0&&T_.call(r,i)&&(e[i]=r[i]);return e};class A_ extends te{constructor(...t){var e;let i=(e=t[0])!=null?e:{};typeof i=="number"&&(i={strength:i},t[1]!==void 0&&(i.quality=t[1]),t[2]!==void 0&&(i.resolution=t[2]||"inherit"),t[3]!==void 0&&(i.kernelSize=t[3])),i=li(li({},Fs.defaultOptions),i);const s=i,{strength:n,strengthX:o,strengthY:a,quality:l}=s,u=lP(s,["strength","strengthX","strengthY","quality"]);super(aP(li({},u),{compatibleRenderers:yt.BOTH,resources:{}})),this._repeatEdgePixels=!1,this.blurXFilter=new Fs(li({horizontal:!0},i)),this.blurYFilter=new Fs(li({horizontal:!1},i)),this.quality=l,this.strengthX=o!=null?o:n,this.strengthY=a!=null?a:n,this.repeatEdgePixels=!1}apply(t,e,i,s){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=et.getSameSizeTexture(e);this.blurXFilter.blendMode="normal",this.blurXFilter.apply(t,e,a,!0),this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,a,i,s),et.returnTexture(a)}else o?(this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,e,i,s)):(this.blurXFilter.blendMode=this.blendMode,this.blurXFilter.apply(t,e,i,s))}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.blur),Math.abs(this.blurYFilter.blur))*2}get strength(){if(this.strengthX!==this.strengthY)throw new Error("BlurFilter's strengthX and strengthY are different");return this.strengthX}set strength(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get strengthX(){return this.blurXFilter.blur}set strengthX(t){this.blurXFilter.blur=t,this.updatePadding()}get strengthY(){return this.blurYFilter.blur}set strengthY(t){this.blurYFilter.blur=t,this.updatePadding()}get blur(){return this.strength}set blur(t){this.strength=t}get blurX(){return this.strengthX}set blurX(t){this.strengthX=t}get blurY(){return this.strengthY}set blurY(t){this.strengthY=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}A_.defaultOptions={strength:8,quality:4,kernelSize:5};var E_=`
in vec2 vTextureCoord;
in vec4 vColor;
out vec4 finalColor;
uniform float uColorMatrix[20];
uniform float uAlpha;
uniform sampler2D uTexture;
float rand(vec2 co)
{
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}
void main()
{
vec4 color = texture(uTexture, vTextureCoord);
float randomValue = rand(gl_FragCoord.xy * 0.2);
float diff = (randomValue - 0.5) * 0.5;
if (uAlpha == 0.0) {
finalColor = color;
return;
}
if (color.a > 0.0) {
color.rgb /= color.a;
}
vec4 result;
result.r = (uColorMatrix[0] * color.r);
result.r += (uColorMatrix[1] * color.g);
result.r += (uColorMatrix[2] * color.b);
result.r += (uColorMatrix[3] * color.a);
result.r += uColorMatrix[4];
result.g = (uColorMatrix[5] * color.r);
result.g += (uColorMatrix[6] * color.g);
result.g += (uColorMatrix[7] * color.b);
result.g += (uColorMatrix[8] * color.a);
result.g += uColorMatrix[9];
result.b = (uColorMatrix[10] * color.r);
result.b += (uColorMatrix[11] * color.g);
result.b += (uColorMatrix[12] * color.b);
result.b += (uColorMatrix[13] * color.a);
result.b += uColorMatrix[14];
result.a = (uColorMatrix[15] * color.r);
result.a += (uColorMatrix[16] * color.g);
result.a += (uColorMatrix[17] * color.b);
result.a += (uColorMatrix[18] * color.a);
result.a += uColorMatrix[19];
vec3 rgb = mix(color.rgb, result.rgb, uAlpha);
// Premultiply alpha again.
rgb *= result.a;
finalColor = vec4(rgb, result.a);
}
`,fl=`struct GlobalFilterUniforms {
uInputSize:vec4<f32>,
uInputPixel:vec4<f32>,
uInputClamp:vec4<f32>,
uOutputFrame:vec4<f32>,
uGlobalFrame:vec4<f32>,
uOutputTexture:vec4<f32>,
};
struct ColorMatrixUniforms {
uColorMatrix:array<vec4<f32>, 5>,
uAlpha:f32,
};
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;
@group(1) @binding(0) var<uniform> colorMatrixUniforms : ColorMatrixUniforms;
struct VSOutput {
@builtin(position) position: vec4<f32>,
@location(0) uv : vec2<f32>,
};
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}
@vertex
fn mainVertex(
@location(0) aPosition : vec2<f32>,
) -> VSOutput {
return VSOutput(
filterVertexPosition(aPosition),
filterTextureCoord(aPosition),
);
}
@fragment
fn mainFragment(
@location(0) uv: vec2<f32>,
) -> @location(0) vec4<f32> {
var c = textureSample(uTexture, uSampler, uv);
if (colorMatrixUniforms.uAlpha == 0.0) {
return c;
}
// Un-premultiply alpha before applying the color matrix. See issue #3539.
if (c.a > 0.0) {
c.r /= c.a;
c.g /= c.a;
c.b /= c.a;
}
var cm = colorMatrixUniforms.uColorMatrix;
var result = vec4<f32>(0.);
result.r = (cm[0][0] * c.r);
result.r += (cm[0][1] * c.g);
result.r += (cm[0][2] * c.b);
result.r += (cm[0][3] * c.a);
result.r += cm[1][0];
result.g = (cm[1][1] * c.r);
result.g += (cm[1][2] * c.g);
result.g += (cm[1][3] * c.b);
result.g += (cm[2][0] * c.a);
result.g += cm[2][1];
result.b = (cm[2][2] * c.r);
result.b += (cm[2][3] * c.g);
result.b += (cm[3][0] * c.b);
result.b += (cm[3][1] * c.a);
result.b += cm[3][2];
result.a = (cm[3][3] * c.r);
result.a += (cm[4][0] * c.g);
result.a += (cm[4][1] * c.b);
result.a += (cm[4][2] * c.a);
result.a += cm[4][3];
var rgb = mix(c.rgb, result.rgb, colorMatrixUniforms.uAlpha);
rgb.r *= result.a;
rgb.g *= result.a;
rgb.b *= result.a;
return vec4(rgb, result.a);
}`,uP=Object.defineProperty,cP=Object.defineProperties,hP=Object.getOwnPropertyDescriptors,P_=Object.getOwnPropertySymbols,dP=Object.prototype.hasOwnProperty,pP=Object.prototype.propertyIsEnumerable,w_=(r,t,e)=>t in r?uP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fP=(r,t)=>{for(var e in t||(t={}))dP.call(t,e)&&w_(r,e,t[e]);if(P_)for(var e of P_(t))pP.call(t,e)&&w_(r,e,t[e]);return r},mP=(r,t)=>cP(r,hP(t));class gP extends te{constructor(t={}){const e=new nt({uColorMatrix:{value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],type:"f32",size:20},uAlpha:{value:1,type:"f32"}}),i=dt.from({vertex:{source:fl,entryPoint:"mainVertex"},fragment:{source:fl,entryPoint:"mainFragment"}}),s=vt.from({vertex:Kr,fragment:E_,name:"color-matrix-filter"});super(mP(fP({},t),{gpuProgram:i,glProgram:s,resources:{colorMatrixUniforms:e}})),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.matrix,t),i=this._colorMatrix(i)),this.resources.colorMatrixUniforms.uniforms.uColorMatrix=i,this.resources.colorMatrixUniforms.update()}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,s,n]=H.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}grayscale(t,e){this.greyscale(t,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),s=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),l=i+(1-i)*o,u=o*(1-i)-a*s,c=o*(1-i)+a*s,h=o*(1-i)+a*s,p=i+o*(1-i),f=o*(1-i)-a*s,m=o*(1-i)-a*s,_=o*(1-i)+a*s,g=i+o*(1-i),b=[l,u,c,0,0,h,p,f,0,0,m,_,g,0,0,0,0,0,1,0];this._loadMatrix(b,e)}contrast(t,e){const i=(t||0)+1,s=-.5*(i-1),n=[i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,s=(i-1)*-.5,n=[i,s,s,0,0,s,i,s,0,0,s,s,i,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,s,n){t||(t=.2),e||(e=.15),i||(i=16770432),s||(s=3375104);const o=H.shared,[a,l,u]=o.setValue(i).toArray(),[c,h,p]=o.setValue(s).toArray(),f=[.3,.59,.11,0,0,a,l,u,t,0,c,h,p,e,0,a-c,l-h,u-p,0,0];this._loadMatrix(f,n)}night(t,e){t||(t=.1);const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.resources.colorMatrixUniforms.uniforms.uColorMatrix}set matrix(t){this.resources.colorMatrixUniforms.uniforms.uColorMatrix=t}get alpha(){return this.resources.colorMatrixUniforms.uniforms.uAlpha}set alpha(t){this.resources.colorMatrixUniforms.uniforms.uAlpha=t}}var R_=`
in vec2 vTextureCoord;
in vec2 vFilterUv;
out vec4 finalColor;
uniform sampler2D uTexture;
uniform sampler2D uMapTexture;
uniform vec4 uInputClamp;
uniform highp vec4 uInputSize;
uniform mat2 uRotation;
uniform vec2 uScale;
void main()
{
vec4 map = texture(uMapTexture, vFilterUv);
vec2 offset = uInputSize.zw * (uRotation * (map.xy - 0.5)) * uScale;
finalColor = texture(uTexture, clamp(vTextureCoord + offset, uInputClamp.xy, uInputClamp.zw));
}
`,C_=`in vec2 aPosition;
out vec2 vTextureCoord;
out vec2 vFilterUv;
uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;
uniform mat3 uFilterMatrix;
vec4 filterVertexPosition( void )
{
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
vec2 filterTextureCoord( void )
{
return aPosition * (uOutputFrame.zw * uInputSize.zw);
}
vec2 getFilterCoord( void )
{
return ( uFilterMatrix * vec3( filterTextureCoord(), 1.0) ).xy;
}
void main(void)
{
gl_Position = filterVertexPosition();
vTextureCoord = filterTextureCoord();
vFilterUv = getFilterCoord();
}
`,ml=`
struct GlobalFilterUniforms {
uInputSize:vec4<f32>,
uInputPixel:vec4<f32>,
uInputClamp:vec4<f32>,
uOutputFrame:vec4<f32>,
uGlobalFrame:vec4<f32>,
uOutputTexture:vec4<f32>,
};
struct DisplacementUniforms {
uFilterMatrix:mat3x3<f32>,
uScale:vec2<f32>,
uRotation:mat2x2<f32>
};
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;
@group(1) @binding(0) var<uniform> filterUniforms : DisplacementUniforms;
@group(1) @binding(1) var uMapTexture: texture_2d<f32>;
@group(1) @binding(2) var uMapSampler : sampler;
struct VSOutput {
@builtin(position) position: vec4<f32>,
@location(0) uv : vec2<f32>,
@location(1) filterUv : vec2<f32>,
};
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
}
fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
{
return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
}
fn getSize() -> vec2<f32>
{
return gfu.uGlobalFrame.zw;
}
@vertex
fn mainVertex(
@location(0) aPosition : vec2<f32>,
) -> VSOutput {
return VSOutput(
filterVertexPosition(aPosition),
filterTextureCoord(aPosition),
getFilterCoord(aPosition)
);
}
@fragment
fn mainFragment(
@location(0) uv: vec2<f32>,
@location(1) filterUv: vec2<f32>,
@builtin(position) position: vec4<f32>
) -> @location(0) vec4<f32> {
var map = textureSample(uMapTexture, uMapSampler, filterUv);
var offset = gfu.uInputSize.zw * (filterUniforms.uRotation * (map.xy - 0.5)) * filterUniforms.uScale;
return textureSample(uTexture, uSampler, clamp(uv + offset, gfu.uInputClamp.xy, gfu.uInputClamp.zw));
}`,_P=Object.defineProperty,bP=Object.defineProperties,vP=Object.getOwnPropertyDescriptors,Us=Object.getOwnPropertySymbols,M_=Object.prototype.hasOwnProperty,O_=Object.prototype.propertyIsEnumerable,G_=(r,t,e)=>t in r?_P(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yP=(r,t)=>{for(var e in t||(t={}))M_.call(t,e)&&G_(r,e,t[e]);if(Us)for(var e of Us(t))O_.call(t,e)&&G_(r,e,t[e]);return r},xP=(r,t)=>bP(r,vP(t)),TP=(r,t)=>{var e={};for(var i in r)M_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Us)for(var i of Us(r))t.indexOf(i)<0&&O_.call(r,i)&&(e[i]=r[i]);return e};class SP extends te{constructor(...t){let e=t[0];e instanceof Lt&&(e={sprite:e,scale:t[1]});const i=e,{sprite:s,scale:n}=i,o=TP(i,["sprite","scale"]);let a=n!=null?n:20;typeof a=="number"&&(a=new W(a,a));const l=new nt({uFilterMatrix:{value:new C,type:"mat3x3<f32>"},uScale:{value:a,type:"vec2<f32>"},uRotation:{value:new Float32Array([0,0,0,0]),type:"mat2x2<f32>"}}),u=vt.from({vertex:C_,fragment:R_,name:"displacement-filter"}),c=dt.from({vertex:{source:ml,entryPoint:"mainVertex"},fragment:{source:ml,entryPoint:"mainFragment"}}),h=s.texture.source;super(xP(yP({},o),{gpuProgram:c,glProgram:u,resources:{filterUniforms:l,uMapTexture:h,uMapSampler:h.style}})),this._sprite=e.sprite,this._sprite.renderable=!1}apply(t,e,i,s){const n=this.resources.filterUniforms.uniforms;t.calculateSpriteMatrix(n.uFilterMatrix,this._sprite);const o=this._sprite.worldTransform,a=Math.sqrt(o.a*o.a+o.b*o.b),l=Math.sqrt(o.c*o.c+o.d*o.d);a!==0&&l!==0&&(n.uRotation[0]=o.a/a,n.uRotation[1]=o.b/a,n.uRotation[2]=o.c/l,n.uRotation[3]=o.d/l),this.resources.uMapTexture=this._sprite.texture.source,t.applyFilter(this,e,i,s)}get scale(){return this.resources.filterUniforms.uniforms.uScale}}var B_=`
in vec2 vTextureCoord;
in vec4 vColor;
out vec4 finalColor;
uniform float uNoise;
uniform float uSeed;
uniform sampler2D uTexture;
float rand(vec2 co)
{
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}
void main()
{
vec4 color = texture(uTexture, vTextureCoord);
float randomValue = rand(gl_FragCoord.xy * uSeed);
float diff = (randomValue - 0.5) * uNoise;
// Un-premultiply alpha before applying the color matrix. See issue #3539.
if (color.a > 0.0) {
color.rgb /= color.a;
}
color.r += diff;
color.g += diff;
color.b += diff;
// Premultiply alpha again.
color.rgb *= color.a;
finalColor = color;
}
`,gl=`
struct GlobalFilterUniforms {
uInputSize:vec4<f32>,
uInputPixel:vec4<f32>,
uInputClamp:vec4<f32>,
uOutputFrame:vec4<f32>,
uGlobalFrame:vec4<f32>,
uOutputTexture:vec4<f32>,
};
struct NoiseUniforms {
uNoise:f32,
uSeed:f32,
};
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;
@group(1) @binding(0) var<uniform> noiseUniforms : NoiseUniforms;
struct VSOutput {
@builtin(position) position: vec4<f32>,
@location(0) uv : vec2<f32>
};
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
}
fn getSize() -> vec2<f32>
{
return gfu.uGlobalFrame.zw;
}
@vertex
fn mainVertex(
@location(0) aPosition : vec2<f32>,
) -> VSOutput {
return VSOutput(
filterVertexPosition(aPosition),
filterTextureCoord(aPosition)
);
}
fn rand(co:vec2<f32>) -> f32
{
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}
@fragment
fn mainFragment(
@location(0) uv: vec2<f32>,
@builtin(position) position: vec4<f32>
) -> @location(0) vec4<f32> {
var pixelPosition = globalTextureCoord(position.xy);// / (getSize());//- gfu.uOutputFrame.xy);
var sample = textureSample(uTexture, uSampler, uv);
var randomValue = rand(pixelPosition.xy * noiseUniforms.uSeed);
var diff = (randomValue - 0.5) * noiseUniforms.uNoise;
// Un-premultiply alpha before applying the color matrix. See issue #3539.
if (sample.a > 0.0) {
sample.r /= sample.a;
sample.g /= sample.a;
sample.b /= sample.a;
}
sample.r += diff;
sample.g += diff;
sample.b += diff;
// Premultiply alpha again.
sample.r *= sample.a;
sample.g *= sample.a;
sample.b *= sample.a;
return sample;
}`,AP=Object.defineProperty,EP=Object.defineProperties,PP=Object.getOwnPropertyDescriptors,ks=Object.getOwnPropertySymbols,I_=Object.prototype.hasOwnProperty,F_=Object.prototype.propertyIsEnumerable,D_=(r,t,e)=>t in r?AP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_l=(r,t)=>{for(var e in t||(t={}))I_.call(t,e)&&D_(r,e,t[e]);if(ks)for(var e of ks(t))F_.call(t,e)&&D_(r,e,t[e]);return r},wP=(r,t)=>EP(r,PP(t)),RP=(r,t)=>{var e={};for(var i in r)I_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ks)for(var i of ks(r))t.indexOf(i)<0&&F_.call(r,i)&&(e[i]=r[i]);return e};const U_=class r0 extends te{constructor(t={}){t=_l(_l({},r0.defaultOptions),t);const e=dt.from({vertex:{source:gl,entryPoint:"mainVertex"},fragment:{source:gl,entryPoint:"mainFragment"}}),i=vt.from({vertex:Kr,fragment:B_,name:"noise-filter"}),s=t,{noise:n,seed:o}=s,a=RP(s,["noise","seed"]);super(wP(_l({},a),{gpuProgram:e,glProgram:i,resources:{noiseUniforms:new nt({uNoise:{value:1,type:"f32"},uSeed:{value:1,type:"f32"}})}})),this.noise=n,this.seed=o!=null?o:Math.random()}get noise(){return this.resources.noiseUniforms.uniforms.uNoise}set noise(t){this.resources.noiseUniforms.uniforms.uNoise=t}get seed(){return this.resources.noiseUniforms.uniforms.uSeed}set seed(t){this.resources.noiseUniforms.uniforms.uSeed=t}};U_.defaultOptions={noise:.5};let CP=U_;var k_=`in vec2 vMaskCoord;
in vec2 vTextureCoord;
uniform sampler2D uTexture;
uniform sampler2D uMaskTexture;
uniform float uAlpha;
uniform vec4 uMaskClamp;
uniform float uInverse;
out vec4 finalColor;
void main(void)
{
float clip = step(3.5,
step(uMaskClamp.x, vMaskCoord.x) +
step(uMaskClamp.y, vMaskCoord.y) +
step(vMaskCoord.x, uMaskClamp.z) +
step(vMaskCoord.y, uMaskClamp.w));
// TODO look into why this is needed
float npmAlpha = uAlpha;
vec4 original = texture(uTexture, vTextureCoord);
vec4 masky = texture(uMaskTexture, vMaskCoord);
float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
float a = alphaMul * masky.r * npmAlpha * clip;
if (uInverse == 1.0) {
a = 1.0 - a;
}
finalColor = original * a;
}
`,$_=`in vec2 aPosition;
out vec2 vTextureCoord;
out vec2 vMaskCoord;
uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;
uniform mat3 uFilterMatrix;
vec4 filterVertexPosition( vec2 aPosition )
{
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
vec2 filterTextureCoord( vec2 aPosition )
{
return aPosition * (uOutputFrame.zw * uInputSize.zw);
}
vec2 getFilterCoord( vec2 aPosition )
{
return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
}
void main(void)
{
gl_Position = filterVertexPosition(aPosition);
vTextureCoord = filterTextureCoord(aPosition);
vMaskCoord = getFilterCoord(aPosition);
}
`,bl=`struct GlobalFilterUniforms {
uInputSize:vec4<f32>,
uInputPixel:vec4<f32>,
uInputClamp:vec4<f32>,
uOutputFrame:vec4<f32>,
uGlobalFrame:vec4<f32>,
uOutputTexture:vec4<f32>,
};
struct MaskUniforms {
uFilterMatrix:mat3x3<f32>,
uMaskClamp:vec4<f32>,
uAlpha:f32,
uInverse:f32,
};
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;
@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
struct VSOutput {
@builtin(position) position: vec4<f32>,
@location(0) uv : vec2<f32>,
@location(1) filterUv : vec2<f32>,
};
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
}
fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
{
return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
}
fn getSize() -> vec2<f32>
{
return gfu.uGlobalFrame.zw;
}
@vertex
fn mainVertex(
@location(0) aPosition : vec2<f32>,
) -> VSOutput {
return VSOutput(
filterVertexPosition(aPosition),
filterTextureCoord(aPosition),
getFilterCoord(aPosition)
);
}
@fragment
fn mainFragment(
@location(0) uv: vec2<f32>,
@location(1) filterUv: vec2<f32>,
@builtin(position) position: vec4<f32>
) -> @location(0) vec4<f32> {
var maskClamp = filterUniforms.uMaskClamp;
var uAlpha = filterUniforms.uAlpha;
var clip = step(3.5,
step(maskClamp.x, filterUv.x) +
step(maskClamp.y, filterUv.y) +
step(filterUv.x, maskClamp.z) +
step(filterUv.y, maskClamp.w));
var mask = textureSample(uMaskTexture, uSampler, filterUv);
var source = textureSample(uTexture, uSampler, uv);
var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
var a: f32 = alphaMul * mask.r * uAlpha * clip;
if (filterUniforms.uInverse == 1.0) {
a = 1.0 - a;
}
return source * a;
}
`,MP=Object.defineProperty,OP=Object.defineProperties,GP=Object.getOwnPropertyDescriptors,$s=Object.getOwnPropertySymbols,L_=Object.prototype.hasOwnProperty,N_=Object.prototype.propertyIsEnumerable,X_=(r,t,e)=>t in r?MP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,BP=(r,t)=>{for(var e in t||(t={}))L_.call(t,e)&&X_(r,e,t[e]);if($s)for(var e of $s(t))N_.call(t,e)&&X_(r,e,t[e]);return r},IP=(r,t)=>OP(r,GP(t)),FP=(r,t)=>{var e={};for(var i in r)L_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&$s)for(var i of $s(r))t.indexOf(i)<0&&N_.call(r,i)&&(e[i]=r[i]);return e};class H_ extends te{constructor(t){const e=t,{sprite:i}=e,s=FP(e,["sprite"]),n=new $n(i.texture),o=new nt({uFilterMatrix:{value:new C,type:"mat3x3<f32>"},uMaskClamp:{value:n.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"}}),a=dt.from({vertex:{source:bl,entryPoint:"mainVertex"},fragment:{source:bl,entryPoint:"mainFragment"}}),l=vt.from({vertex:$_,fragment:k_,name:"mask-filter"});super(IP(BP({},s),{gpuProgram:a,glProgram:l,clipToViewport:!1,resources:{filterUniforms:o,uMaskTexture:i.texture.source}})),this.sprite=i,this._textureMatrix=n}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}apply(t,e,i,s){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,i,s)}}var DP=`fn getLuminosity(c: vec3<f32>) -> f32 {
return 0.3 * c.r + 0.59 * c.g + 0.11 * c.b;
}
fn setLuminosity(c: vec3<f32>, lum: f32) -> vec3<f32> {
let d: f32 = lum - getLuminosity(c);
let newColor: vec3<f32> = c.rgb + vec3<f32>(d, d, d);
// clip back into legal range
let newLum: f32 = getLuminosity(newColor);
let cMin: f32 = min(newColor.r, min(newColor.g, newColor.b));
let cMax: f32 = max(newColor.r, max(newColor.g, newColor.b));
let t1: f32 = newLum / (newLum - cMin);
let t2: f32 = (1.0 - newLum) / (cMax - newLum);
let finalColor = mix(vec3<f32>(newLum, newLum, newLum), newColor, select(select(1.0, t2, cMax > 1.0), t1, cMin < 0.0));
return finalColor;
}
fn getSaturation(c: vec3<f32>) -> f32 {
return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b));
}
// Set saturation if color components are sorted in ascending order.
fn setSaturationMinMidMax(cSorted: vec3<f32>, s: f32) -> vec3<f32> {
var result: vec3<f32>;
if (cSorted.z > cSorted.x) {
let newY = (((cSorted.y - cSorted.x) * s) / (cSorted.z - cSorted.x));
result = vec3<f32>(0.0, newY, s);
} else {
result = vec3<f32>(0.0, 0.0, 0.0);
}
return vec3<f32>(result.x, result.y, result.z);
}
fn setSaturation(c: vec3<f32>, s: f32) -> vec3<f32> {
var result: vec3<f32> = c;
if (c.r <= c.g && c.r <= c.b) {
if (c.g <= c.b) {
result = setSaturationMinMidMax(result, s);
} else {
var temp: vec3<f32> = vec3<f32>(result.r, result.b, result.g);
temp = setSaturationMinMidMax(temp, s);
result = vec3<f32>(temp.r, temp.b, temp.g);
}
} else if (c.g <= c.r && c.g <= c.b) {
if (c.r <= c.b) {
var temp: vec3<f32> = vec3<f32>(result.g, result.r, result.b);
temp = setSaturationMinMidMax(temp, s);
result = vec3<f32>(temp.g, temp.r, temp.b);
} else {
var temp: vec3<f32> = vec3<f32>(result.g, result.b, result.r);
temp = setSaturationMinMidMax(temp, s);
result = vec3<f32>(temp.g, temp.b, temp.r);
}
} else {
if (c.r <= c.g) {
var temp: vec3<f32> = vec3<f32>(result.b, result.r, result.g);
temp = setSaturationMinMidMax(temp, s);
result = vec3<f32>(temp.b, temp.r, temp.g);
} else {
var temp: vec3<f32> = vec3<f32>(result.b, result.g, result.r);
temp = setSaturationMinMidMax(temp, s);
result = vec3<f32>(temp.b, temp.g, temp.r);
}
}
return result;
}`;const j_=class i0{constructor(t){this._tick=()=>{this._destroyed||(this.timeout=setTimeout(this._processQueue,0))},this._processQueue=()=>{if(this._destroyed)return;const{queue:e}=this;let i=0;for(;e.length&&i<i0.uploadsPerFrame;){const s=e.shift();this.uploadQueueItem(s),i++}e.length?at.system.addOnce(this._tick,this,Wt.UTILITY):this._resolve()},this.renderer=t,this.queue=[],this.resolves=[]}getQueue(){return[...this.queue]}add(t){const e=Array.isArray(t)?t:[t];for(const i of e)i instanceof q?this._addContainer(i):this.resolveQueueItem(i,this.queue);return this}_addContainer(t){this.resolveQueueItem(t,this.queue);for(const e of t.children)this._addContainer(e)}upload(t){return t&&this.add(t),new Promise(e=>{this.queue.length?(this.resolves.push(e),this.dedupeQueue(),at.system.addOnce(this._tick,this,Wt.UTILITY)):e()})}dedupeQueue(){const t=Object.create(null);let e=0;for(let i=0;i<this.queue.length;i++){const s=this.queue[i];t[s.uid]||(t[s.uid]=!0,this.queue[e++]=s)}this.queue.length=e}destroy(){this._destroyed=!0,clearTimeout(this.timeout)}_resolve(){const{resolves:t}=this,e=t.slice(0);t.length=0;for(const i of e)i()}};j_.uploadsPerFrame=4;let z_=j_;var UP=Object.defineProperty,Ls=Object.getOwnPropertySymbols,V_=Object.prototype.hasOwnProperty,W_=Object.prototype.propertyIsEnumerable,Y_=(r,t,e)=>t in r?UP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,kP=(r,t)=>{for(var e in t||(t={}))V_.call(t,e)&&Y_(r,e,t[e]);if(Ls)for(var e of Ls(t))W_.call(t,e)&&Y_(r,e,t[e]);return r},$P=(r,t)=>{var e={};for(var i in r)V_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ls)for(var i of Ls(r))t.indexOf(i)<0&&W_.call(r,i)&&(e[i]=r[i]);return e};class mr extends Kt{constructor(...t){var e;let i=t[0];i instanceof Ee&&(i={geometry:i,shader:t[1]},t[3]&&(i.geometry.topology=t[3]));const s=i,{geometry:n,shader:o,texture:a,roundPixels:l,state:u}=s,c=$P(s,["geometry","shader","texture","roundPixels","state"]);super(kP({label:"Mesh"},c)),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=o!=null?o:null,this.texture=(e=a!=null?a:o==null?void 0:o.texture)!=null?e:w.WHITE,this.state=u!=null?u:Rt.for2d(),this._geometry=n,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=l!=null?l:!1}get material(){return this._shader}set shader(t){this._shader!==t&&(this._shader=t,this.onViewUpdate())}get shader(){return this._shader}set geometry(t){var e;this._geometry!==t&&((e=this._geometry)==null||e.off("update",this.onViewUpdate,this),t.on("update",this.onViewUpdate,this),this._geometry=t,this.onViewUpdate())}get geometry(){return this._geometry}set texture(t){t||(t=w.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this.shader&&(this.shader.texture=t),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get batched(){return this._shader||this.state.data&12?!1:this._geometry instanceof ce?this._geometry.batchMode==="auto"?this._geometry.positions.length/2<=100:this._geometry.batchMode==="batch":!1}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(t){const{x:e,y:i}=t;if(!this.bounds.containsPoint(e,i))return!1;const s=this.geometry.getBuffer("aPosition").data,n=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){const o=this.geometry.getIndex().data,a=o.length;for(let l=0;l+2<a;l+=n){const u=o[l]*2,c=o[l+1]*2,h=o[l+2]*2;if(Ga(e,i,s[u],s[u+1],s[c],s[c+1],s[h],s[h+1]))return!0}}else{const o=s.length/2;for(let a=0;a+2<o;a+=n){const l=a*2,u=(a+1)*2,c=(a+2)*2;if(Ga(e,i,s[l],s[l+1],s[u],s[u+1],s[c],s[c+1]))return!0}}return!1}destroy(t){var e;if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}(e=this._geometry)==null||e.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null}}var LP=Object.defineProperty,NP=Object.defineProperties,XP=Object.getOwnPropertyDescriptors,Ns=Object.getOwnPropertySymbols,K_=Object.prototype.hasOwnProperty,q_=Object.prototype.propertyIsEnumerable,Z_=(r,t,e)=>t in r?LP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,HP=(r,t)=>{for(var e in t||(t={}))K_.call(t,e)&&Z_(r,e,t[e]);if(Ns)for(var e of Ns(t))q_.call(t,e)&&Z_(r,e,t[e]);return r},jP=(r,t)=>NP(r,XP(t)),zP=(r,t)=>{var e={};for(var i in r)K_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ns)for(var i of Ns(r))t.indexOf(i)<0&&q_.call(r,i)&&(e[i]=r[i]);return e};class ui extends Lt{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const i=e,{animationSpeed:s=1,autoPlay:n=!1,autoUpdate:o=!0,loop:a=!0,onComplete:l=null,onFrameChange:u=null,onLoop:c=null,textures:h,updateAnchor:p=!1}=i,f=zP(i,["animationSpeed","autoPlay","autoUpdate","loop","onComplete","onFrameChange","onLoop","textures","updateAnchor"]),[m]=h;super(jP(HP({},f),{texture:m instanceof w?m:m.texture})),this._textures=null,this._durations=null,this._autoUpdate=o,this._isConnectedToTicker=!1,this.animationSpeed=s,this.loop=a,this.updateAnchor=p,this.onComplete=l,this.onFrameChange=u,this.onLoop=c,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=h,n&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(at.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(at.shared.add(this.update,this,Wt.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,i=this.animationSpeed*e,s=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=i/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];const o=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*o,this._currentTime+=o;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=i;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):s!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<s||this.animationSpeed<0&&this.currentFrame>s)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.texture.defaultAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t=!1){if(typeof t=="boolean"?t:t!=null&&t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._textures.forEach(i=>{this.texture!==i&&i.destroy(e)})}this._textures=[],this._durations=null,this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;i<t.length;++i)e.push(w.from(t[i]));return new ui(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(w.from(t[i]));return new ui(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof w)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(let e=0;e<t.length;e++)this._textures.push(t[e].texture),this._durations.push(t[e].time)}this._previousFrame=null,this.gotoAndStop(0),this._updateTexture()}get currentFrame(){let t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}set currentFrame(t){if(t<0||t>this.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(at.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(at.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class Q_{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t!=null?t:new C,this.observer=e,this.position=new Z(this,0,0),this.scale=new Z(this,1,1),this.pivot=new Z(this,0,0),this.skew=new Z(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){const t=this._matrix;return this.dirty&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this.dirty=!1),t}_onUpdate(t){var e;this.dirty=!0,t===this.skew&&this.updateSkew(),(e=this.observer)==null||e._onUpdate(this)}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this.dirty=!0}setFromMatrix(t){t.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this.skew))}}var VP=Object.defineProperty,Xs=Object.getOwnPropertySymbols,J_=Object.prototype.hasOwnProperty,tb=Object.prototype.propertyIsEnumerable,eb=(r,t,e)=>t in r?VP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ci=(r,t)=>{for(var e in t||(t={}))J_.call(t,e)&&eb(r,e,t[e]);if(Xs)for(var e of Xs(t))tb.call(t,e)&&eb(r,e,t[e]);return r},WP=(r,t)=>{var e={};for(var i in r)J_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Xs)for(var i of Xs(r))t.indexOf(i)<0&&tb.call(r,i)&&(e[i]=r[i]);return e};const rb=class xn extends Kt{constructor(...t){let e=t[0]||{};e instanceof w&&(e={texture:e}),t.length>1&&(e.width=t[1],e.height=t[2]),e=ci(ci({},xn.defaultOptions),e);const i=e!=null?e:{},{texture:s,anchor:n,tilePosition:o,tileScale:a,tileRotation:l,width:u,height:c,applyAnchorToTexture:h,roundPixels:p}=i,f=WP(i,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(ci({label:"TilingSprite"},f)),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new Z({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=h,this.texture=s,this._width=u!=null?u:s.width,this._height=c!=null?c:s.height,this._tileTransform=new Q_({observer:{_onUpdate:()=>this.onViewUpdate()}}),n&&(this.anchor=n),this.tilePosition=o,this.tileScale=a,this.tileRotation=l,this.roundPixels=p!=null?p:!1}static from(t,e={}){return typeof t=="string"?new xn(ci({texture:V.get(t)},e)):new xn(ci({texture:t},e))}get uvRespectAnchor(){return Mr(uo,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(t){Mr(uo,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture=t}get clampMargin(){return this._texture.textureMatrix.clampMargin}set clampMargin(t){this._texture.textureMatrix.clampMargin=t}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get tilePosition(){return this._tileTransform.position}set tilePosition(t){this._tileTransform.position.copyFrom(t)}get tileScale(){return this._tileTransform.scale}set tileScale(t){typeof t=="number"?this._tileTransform.scale.set(t):this._tileTransform.scale.copyFrom(t)}set tileRotation(t){this._tileTransform.rotation=t}get tileRotation(){return this._tileTransform.rotation}get tileTransform(){return this._tileTransform}set texture(t){t||(t=w.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}set width(t){this._width=t,this.onViewUpdate()}get width(){return this._width}set height(t){this._height=t,this.onViewUpdate()}get height(){return this._height}setSize(t,e){var i;typeof t=="object"&&(e=(i=t.height)!=null?i:t.width,t=t.width),this._width=t,this._height=e!=null?e:t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}updateBounds(){const t=this._bounds,e=this._anchor,i=this._width,s=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}containsPoint(t){const e=this._width,i=this._height,s=-e*this._anchor._x;let n=0;return t.x>=s&&t.x<=s+e&&(n=-i*this._anchor._y,t.y>=n&&t.y<=n+i)}destroy(t=!1){if(super.destroy(t),this._anchor=null,this._tileTransform=null,this._bounds=null,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}};rb.defaultOptions={texture:w.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let ib=rb;var YP=Object.defineProperty,Hs=Object.getOwnPropertySymbols,sb=Object.prototype.hasOwnProperty,nb=Object.prototype.propertyIsEnumerable,ob=(r,t,e)=>t in r?YP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,KP=(r,t)=>{for(var e in t||(t={}))sb.call(t,e)&&ob(r,e,t[e]);if(Hs)for(var e of Hs(t))nb.call(t,e)&&ob(r,e,t[e]);return r},qP=(r,t)=>{var e={};for(var i in r)sb.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Hs)for(var i of Hs(r))t.indexOf(i)<0&&nb.call(r,i)&&(e[i]=r[i]);return e};class js extends Kt{constructor(t,e){const i=t,{text:s,resolution:n,style:o,anchor:a,width:l,height:u,roundPixels:c}=i,h=qP(i,["text","resolution","style","anchor","width","height","roundPixels"]);super(KP({},h)),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=s!=null?s:"",this.style=o,this.resolution=n!=null?n:null,this.allowChildren=!1,this._anchor=new Z({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c!=null?c:!1,l!==void 0&&(this.width=l),u!==void 0&&(this.height=u)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t||(t={}),(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){var i;typeof t=="object"?(e=(i=t.height)!=null?i:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,s=-e*this.anchor.x;let n=0;return t.x>=s&&t.x<=s+e&&(n=-i*this.anchor.y,t.y>=n&&t.y<=n+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function zs(r,t){var e;let i=(e=r[0])!=null?e:{};return(typeof i=="string"||r[1])&&(i={text:i,style:r[1]}),i}class Vs extends js{constructor(...t){const e=zs(t,"Text");super(e,Mt),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof Et?e.textureStyle:new Et(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,s=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=or.getCanvasAndContext({text:this.text,style:this._style,resolution:1});or.returnCanvasAndContext(o),i=n.width,s=n.height}else{const n=ht.measureText(this._text,this._style);i=n.width,s=n.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}}class ab extends z_{resolveQueueItem(t,e){return t instanceof q?this.resolveContainerQueueItem(t,e):t instanceof Q||t instanceof w?e.push(t.source):t instanceof pt&&e.push(t),null}resolveContainerQueueItem(t,e){t instanceof Lt||t instanceof ib||t instanceof mr?e.push(t.texture.source):t instanceof Vs?e.push(t):t instanceof ar?e.push(t.context):t instanceof ui&&t.textures.forEach(i=>{i.source?e.push(i.source):e.push(i.texture.source)})}resolveGraphicsContextQueueItem(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const i of e)if(i.action==="texture"){const{image:s}=i.data;return s.source}else if(i.action==="fill"){const{texture:s}=i.data.style;return s.source}return null}}class vl extends js{constructor(...t){var e,i,s;const n=zs(t,"BitmapText");(e=n.style)!=null||(n.style=n.style||{}),(s=(i=n.style).fill)!=null||(i.fill=16777215),super(n,Mt),this.renderPipeId="bitmapText"}_onTouch(t){var e;this._gcLastUsed=t;for(const i in this._gpuData)(e=this._gpuData[i])==null||e._onTouch(t)}updateBounds(){const t=this._bounds,e=this._anchor,i=lr.measureText(this.text,this._style),s=i.scale,n=i.offsetY*s;let o=i.width*s,a=i.height*s;const l=this._style._stroke;l&&(o+=l.width,a+=l.width),t.minX=-e._x*o,t.maxX=t.minX+o,t.minY=-e._y*(a+n),t.maxY=t.minY+a}set resolution(t){}get resolution(){return this._resolution}}function lb(r){const t=r._stroke,e=r._fill,i=[`div { ${[`color: ${H.shared.setValue(e.color).toHex()}`,`font-size: ${r.fontSize}px`,`font-family: ${r.fontFamily}`,`font-weight: ${r.fontWeight}`,`font-style: ${r.fontStyle}`,`font-variant: ${r.fontVariant}`,`letter-spacing: ${r.letterSpacing}px`,`text-align: ${r.align}`,`padding: ${r.padding}px`,`white-space: ${r.whiteSpace==="pre"&&r.wordWrap?"pre-wrap":r.whiteSpace}`,...r.lineHeight?[`line-height: ${r.lineHeight}px`]:[],...r.wordWrap?[`word-wrap: ${r.breakWords?"break-all":"break-word"}`,`max-width: ${r.wordWrapWidth}px`]:[],...t?[cb(t)]:[],...r.dropShadow?[ub(r.dropShadow)]:[],...r.cssOverrides].join(";")} }`];return ZP(r.tagStyles,i),i.join(" ")}function ub(r){const t=H.shared.setValue(r.color).setAlpha(r.alpha).toHexa(),e=Math.round(Math.cos(r.angle)*r.distance),i=Math.round(Math.sin(r.angle)*r.distance),s=`${e}px ${i}px`;return r.blur>0?`text-shadow: ${s} ${r.blur}px ${t}`:`text-shadow: ${s} ${t}`}function cb(r){return[`-webkit-text-stroke-width: ${r.width}px`,`-webkit-text-stroke-color: ${H.shared.setValue(r.color).toHex()}`,`text-stroke-width: ${r.width}px`,`text-stroke-color: ${H.shared.setValue(r.color).toHex()}`,"paint-order: stroke"].join(";")}const hb={fontSize:"font-size: {{VALUE}}px",fontFamily:"font-family: {{VALUE}}",fontWeight:"font-weight: {{VALUE}}",fontStyle:"font-style: {{VALUE}}",fontVariant:"font-variant: {{VALUE}}",letterSpacing:"letter-spacing: {{VALUE}}px",align:"text-align: {{VALUE}}",padding:"padding: {{VALUE}}px",whiteSpace:"white-space: {{VALUE}}",lineHeight:"line-height: {{VALUE}}px",wordWrapWidth:"max-width: {{VALUE}}px"},db={fill:r=>`color: ${H.shared.setValue(r).toHex()}`,breakWords:r=>`word-wrap: ${r?"break-all":"break-word"}`,stroke:cb,dropShadow:ub};function ZP(r,t){for(const e in r){const i=r[e],s=[];for(const n in i)db[n]?s.push(db[n](i[n])):hb[n]&&s.push(hb[n].replace("{{VALUE}}",i[n]));t.push(`${e} { ${s.join(";")} }`)}}var QP=Object.defineProperty,pb=Object.getOwnPropertySymbols,JP=Object.prototype.hasOwnProperty,tw=Object.prototype.propertyIsEnumerable,fb=(r,t,e)=>t in r?QP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mb=(r,t)=>{for(var e in t||(t={}))JP.call(t,e)&&fb(r,e,t[e]);if(pb)for(var e of pb(t))tw.call(t,e)&&fb(r,e,t[e]);return r};class Ws extends Mt{constructor(t={}){var e,i;super(t),this._cssOverrides=[],this.cssOverrides=(e=t.cssOverrides)!=null?e:[],this.tagStyles=(i=t.tagStyles)!=null?i:{}}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}update(){this._cssStyle=null,super.update()}clone(){return new Ws({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?mb({},this.dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides,tagStyles:mb({},this.tagStyles)})}get cssStyle(){return this._cssStyle||(this._cssStyle=lb(this)),this._cssStyle}addOverride(...t){const e=t.filter(i=>!this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides.push(...e),this.update())}removeOverride(...t){const e=t.filter(i=>this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides=this.cssOverrides.filter(i=>!e.includes(i)),this.update())}set fill(t){super.fill=t}set stroke(t){super.stroke=t}}class gb extends js{constructor(...t){const e=zs(t,"HtmlText");super(e,Ws),this.renderPipeId="htmlText",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof Et?e.textureStyle:new Et(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor,i=Sa(this.text,this._style),{width:s,height:n}=i;t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*n,t.maxY=t.minY+n}get text(){return this._text}set text(t){const e=this._sanitiseText(t.toString());super.text=e}_sanitiseText(t){return this._removeInvalidHtmlTags(t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," "))}_removeInvalidHtmlTags(t){const e=/<[^>]*?(?=<|$)/g;return t.replace(e,"")}}class _b extends ab{uploadQueueItem(t){t instanceof Q?this.uploadTextureSource(t):t instanceof Vs?this.uploadText(t):t instanceof gb?this.uploadHTMLText(t):t instanceof vl?this.uploadBitmapText(t):t instanceof pt&&this.uploadGraphicsContext(t)}uploadTextureSource(t){this.renderer.texture.initSource(t)}uploadText(t){this.renderer.renderPipes.text.initGpuText(t)}uploadBitmapText(t){this.renderer.renderPipes.bitmapText.initGpuText(t)}uploadHTMLText(t){this.renderer.renderPipes.htmlText.initGpuText(t)}uploadGraphicsContext(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const i of e)if(i.action==="texture"){const{image:s}=i.data;this.uploadTextureSource(s.source)}else if(i.action==="fill"){const{texture:s}=i.data.style;this.uploadTextureSource(s.source)}return null}}class bb extends _b{destroy(){super.destroy(),clearTimeout(this.timeout),this.renderer=null,this.queue=null,this.resolves=null}}bb.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"prepare"};class yl{constructor(){this._tempState=Rt.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,i){const s=t.renderer,n=this._didUploadHash[i.uid];s.shader.bind(i,n),n||(this._didUploadHash[i.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(e,i.glProgram)}execute(t,e){const i=t.renderer;this._tempState.blendMode=e.blendMode,i.state.set(this._tempState);const s=e.textures.textures;for(let n=0;n<e.textures.count;n++)i.texture.bind(s[n],n);i.geometry.draw(e.topology,e.size,e.start)}}yl.extension={type:[T.WebGLPipesAdaptor],name:"batch"};function ew(r){const t=[];let e=0;for(let i=0;i<r;i++)t[e]={texture:{sampleType:"float",viewDimension:"2d",multisampled:!1},binding:e,visibility:GPUShaderStage.FRAGMENT},e++,t[e]={sampler:{type:"filtering"},binding:e,visibility:GPUShaderStage.FRAGMENT},e++;return t}function rw(r){const t={};let e=0;for(let i=0;i<r;i++)t[`textureSource${i+1}`]=e++,t[`textureSampler${i+1}`]=e++;return t}const Ys=Rt.for2d();class xl{start(t,e,i){const s=t.renderer,n=s.encoder,o=i.gpuProgram;this._shader=i,this._geometry=e,n.setGeometry(e,o),Ys.blendMode="normal",s.pipeline.getPipeline(e,o,Ys);const a=s.globalUniforms.bindGroup;n.resetBindGroup(1),n.setBindGroup(0,a,o)}execute(t,e){const i=this._shader.gpuProgram,s=t.renderer,n=s.encoder;if(!e.bindGroup){const l=e.textures;e.bindGroup=Ni(l.textures,l.count,s.limits.maxBatchableTextures)}Ys.blendMode=e.blendMode;const o=s.bindGroup.getBindGroup(e.bindGroup,i,1),a=s.pipeline.getPipeline(this._geometry,i,Ys,e.topology);e.bindGroup._touch(s.gc.now,s.tick),n.setPipeline(a),n.renderPassEncoder.setBindGroup(1,o),n.renderPassEncoder.drawIndexed(e.size,1,e.start)}}xl.extension={type:[T.WebGPUPipesAdaptor],name:"batch"};const Tl=class s0{constructor(t,e){this.state=Rt.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null);var i,s;this.renderer=t,this._adaptor=e,(s=(i=this._adaptor).init)==null||s.call(i,this)}static getBatcher(t){return new this._availableBatchers[t]}buildStart(t){let e=this._batchersByInstructionSet[t.uid];e||(e=this._batchersByInstructionSet[t.uid]=Object.create(null),e.default||(e.default=new Qi({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=e,this._activeBatch=this._activeBatches.default;for(const i in this._activeBatches)this._activeBatches[i].begin()}addToBatch(t,e){if(this._activeBatch.name!==t.batcherName){this._activeBatch.break(e);let i=this._activeBatches[t.batcherName];i||(i=this._activeBatches[t.batcherName]=s0.getBatcher(t.batcherName),i.begin()),this._activeBatch=i}this._activeBatch.add(t)}break(t){this._activeBatch.break(t)}buildEnd(t){this._activeBatch.break(t);const e=this._activeBatches;for(const i in e){const s=e[i],n=s.geometry;n.indexBuffer.setDataWithSize(s.indexBuffer,s.indexSize,!0),n.buffers[0].setDataWithSize(s.attributeBuffer.float32View,s.attributeSize,!1)}}upload(t){const e=this._batchersByInstructionSet[t.uid];for(const i in e){const s=e[i],n=s.geometry;s.dirty&&(s.dirty=!1,n.buffers[0].update(s.attributeSize*4))}}execute(t){if(t.action==="startBatch"){const e=t.batcher,i=e.geometry,s=e.shader;this._adaptor.start(this,i,s)}this._adaptor.execute(this,t)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const t in this._activeBatches)this._activeBatches[t].destroy();this._activeBatches=null}};Tl.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"batch"},Tl._availableBatchers=Object.create(null);let Sl=Tl;F.handleByMap(T.Batcher,Sl._availableBatchers),F.add(Qi);function iw(r){const t=r.split(/([\n{}])/g).map(i=>i.trim()).filter(i=>i.length);let e="";return t.map(i=>{let s=e+i;return i==="{"?e+=" ":i==="}"&&(e=e.substr(0,e.length-4),s=e+i),s}).join(`
`)}const vb={name:"texture-bit",vertex:{header:`
struct TextureUniforms {
uTextureMatrix:mat3x3<f32>,
}
@group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
`,main:`
uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
`},fragment:{header:`
@group(2) @binding(0) var uTexture: texture_2d<f32>;
@group(2) @binding(1) var uSampler: sampler;
`,main:`
outColor = textureSample(uTexture, uSampler, vUV);
`}},yb={name:"texture-bit",vertex:{header:`
uniform mat3 uTextureMatrix;
`,main:`
uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
`},fragment:{header:`
uniform sampler2D uTexture;
`,main:`
outColor = texture(uTexture, vUV);
`}},sw=new ot;let nw=class extends Tr{constructor(){super(),this.filters=[new H_({sprite:new Lt(w.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}get inverse(){return this.filters[0].inverse}set inverse(t){this.filters[0].inverse=t}};class Al{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,i){const s=this._renderer;if(s.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1,maskedContainer:e}),t.inverse=e._maskOptions.inverse,t.renderMaskToTexture){const n=t.mask;n.includeInBuild=!0,n.collectRenderables(i,s,null),n.includeInBuild=!1}s.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){const e=this._renderer,i=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){const s=st.get(nw);if(s.inverse=t.inverse,i){t.mask.mask.measurable=!0;const n=Sr(t.mask.mask,!0,sw);t.mask.mask.measurable=!1,n.ceil();const o=e.renderTarget.renderTarget.colorTexture.source,a=et.getOptimalTexture(n.width,n.height,o._resolution,o.antialias);e.renderTarget.push(a,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});const l=s.sprite;l.texture=a,l.worldTransform.tx=n.minX,l.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer,filterTexture:a})}else s.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){const s=this._activeMaskStage[this._activeMaskStage.length-1];i&&(e.type===yt.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:s.maskedContainer,filterEffect:s.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();const s=this._activeMaskStage.pop();i&&et.returnTexture(s.filterTexture),st.return(s.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}Al.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"alphaMask"};class El{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,i){this._renderer.renderPipes.batch.break(i);const s=this._colorStack;s[this._colorStackIndex]=s[this._colorStackIndex-1]&t.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,i.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const s=this._colorStack;this._colorStackIndex--;const n=s[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,i.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}El.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"colorMask"};class ow{constructor(t){this.priority=0,this.pipe="scissorMask",this.mask=t,this.mask.renderable=!1,this.mask.measurable=!1}addBounds(t,e){ki(this.mask,t,e)}addLocalBounds(t,e){$i(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}destroy(){this.reset()}}class Pl{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,i){var s,n;const o=t,a=this._renderer;a.renderPipes.batch.break(i),a.renderPipes.blendMode.setBlendMode(o.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const l=o.mask;l.includeInBuild=!0,this._maskHash.has(o)||this._maskHash.set(o,{instructionsStart:0,instructionsLength:0});const u=this._maskHash.get(o);u.instructionsStart=i.instructionSize,l.collectRenderables(i,a,null),l.includeInBuild=!1,a.renderPipes.batch.break(i),i.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const c=i.instructionSize-u.instructionsStart-1;u.instructionsLength=c;const h=a.renderTarget.renderTarget.uid;(n=(s=this._maskStackHash)[h])!=null||(s[h]=0)}pop(t,e,i){const s=t,n=this._renderer;n.renderPipes.batch.break(i),n.renderPipes.blendMode.setBlendMode(s.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1});const o=this._maskHash.get(t);for(let a=0;a<o.instructionsLength;a++)i.instructions[i.instructionSize++]=i.instructions[o.instructionsStart++];i.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e,i;const s=this._renderer,n=s.renderTarget.renderTarget.uid;let o=(i=(e=this._maskStackHash)[n])!=null?i:e[n]=0;t.action==="pushMaskBegin"?(s.renderTarget.ensureDepthStencil(),s.stencil.setStencilMode(rt.RENDERING_MASK_ADD,o),o++,s.colorMask.setMask(0)):t.action==="pushMaskEnd"?(t.inverse?s.stencil.setStencilMode(rt.INVERSE_MASK_ACTIVE,o):s.stencil.setStencilMode(rt.MASK_ACTIVE,o),s.colorMask.setMask(15)):t.action==="popMaskBegin"?(s.colorMask.setMask(0),o!==0?s.stencil.setStencilMode(rt.RENDERING_MASK_REMOVE,o):(s.renderTarget.clear(null,Tt.STENCIL),s.stencil.setStencilMode(rt.DISABLED,o)),o--):t.action==="popMaskEnd"&&(t.inverse?s.stencil.setStencilMode(rt.INVERSE_MASK_ACTIVE,o):s.stencil.setStencilMode(rt.MASK_ACTIVE,o),s.colorMask.setMask(15)),this._maskStackHash[n]=o}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}Pl.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"stencilMask"};var hi=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(hi||{});class xb{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class wl{constructor(t){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._managedBuffers=new xt({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]||this.createGLBuffer(t)}bind(t){const{_gl:e}=this,i=this.getGlBuffer(t);e.bindBuffer(i.type,i.buffer)}bindBufferBase(t,e){const{_gl:i}=this;this._boundBufferBases[e]!==t&&(this._boundBufferBases[e]=t,t._lastBindBaseLocation=e,i.bindBufferBase(i.UNIFORM_BUFFER,e,t.buffer))}nextBindBase(t){this._bindCallId++,this._minBaseLocation=0,t&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(t){let e=this.getLastBindBaseLocation(t);if(e>=this._minBaseLocation)return t._lastBindCallId=this._bindCallId,e;let i=0,s=this._nextBindBaseIndex;for(;i<2;){s>=this._maxBindings&&(s=this._minBaseLocation,i++);const n=this._boundBufferBases[s];if(n&&n._lastBindCallId===this._bindCallId){s++;continue}break}return e=s,this._nextBindBaseIndex=s+1,i>=2?-1:(t._lastBindCallId=this._bindCallId,this._boundBufferBases[e]=null,e)}getLastBindBaseLocation(t){const e=t._lastBindBaseLocation;return this._boundBufferBases[e]===t?e:-1}bindBufferRange(t,e,i,s){const{_gl:n}=this;i||(i=0),e||(e=0),this._boundBufferBases[e]=null,n.bindBufferRange(n.UNIFORM_BUFFER,e||0,t.buffer,i*256,s||256)}updateBuffer(t){const{_gl:e}=this,i=this.getGlBuffer(t);if(t._updateID===i.updateID)return i;i.updateID=t._updateID,e.bindBuffer(i.type,i.buffer);const s=t.data,n=t.descriptor.usage&X.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return s?i.byteLength>=s.byteLength?e.bufferSubData(i.type,0,s,0,t._updateSize/s.BYTES_PER_ELEMENT):(i.byteLength=s.byteLength,e.bufferData(i.type,s,n)):(i.byteLength=t.descriptor.size,e.bufferData(i.type,i.byteLength,n)),i}destroyAll(t=!1){this._managedBuffers.removeAll(t)}onBufferUnload(t,e=!1){const i=t._gpuData[this._renderer.uid];i&&(e||this._gl.deleteBuffer(i.buffer))}createGLBuffer(t){const{_gl:e}=this;let i=hi.ARRAY_BUFFER;t.descriptor.usage&X.INDEX?i=hi.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&X.UNIFORM&&(i=hi.UNIFORM_BUFFER);const s=new xb(e.createBuffer(),i);return t._gpuData[this._renderer.uid]=s,this._managedBuffers.add(t),s}resetState(){this._boundBufferBases=Object.create(null)}}wl.extension={type:[T.WebGLSystem],name:"buffer"};var aw=Object.defineProperty,lw=Object.defineProperties,uw=Object.getOwnPropertyDescriptors,Tb=Object.getOwnPropertySymbols,cw=Object.prototype.hasOwnProperty,hw=Object.prototype.propertyIsEnumerable,Sb=(r,t,e)=>t in r?aw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ks=(r,t)=>{for(var e in t||(t={}))cw.call(t,e)&&Sb(r,e,t[e]);if(Tb)for(var e of Tb(t))hw.call(t,e)&&Sb(r,e,t[e]);return r},Ab=(r,t)=>lw(r,uw(t));const Rl=class n0{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(t){var e,i;t=Ks(Ks({},n0.defaultOptions),t);let s=this.multiView=t.multiView;if(t.context&&s&&(Xt("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),s=!1),s?this.canvas=L.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,t.context)this.initFromContext(t.context);else{const n=this._renderer.background.alpha<1,o=(e=t.premultipliedAlpha)!=null?e:!0,a=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:n,premultipliedAlpha:o,antialias:a,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:(i=t.powerPreference)!=null?i:"default"})}}ensureCanvasSize(t){if(!this.multiView){t!==this.canvas&&Xt("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:e}=this;(e.width<t.width||e.height<t.height)&&(e.width=Math.max(t.width,t.width),e.height=Math.max(t.height,t.height))}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof L.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let i;const s=this.canvas;if(t===2&&(i=s.getContext("webgl2",e)),!i&&(i=s.getContext("webgl",e),!i))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=i,this.initFromContext(this.gl)}getExtensions(){const{gl:t}=this,e={anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc"),rgtc:t.getExtension("EXT_texture_compression_rgtc"),loseContext:t.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions=Ab(Ks({},e),{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:t.getExtension("ANGLE_instanced_arrays"),srgb:t.getExtension("EXT_sRGB")});else{this.extensions=Ab(Ks({},e),{colorBufferFloat:t.getExtension("EXT_color_buffer_float")});const i=t.getExtension("WEBGL_provoking_vertex");i&&i.provokingVertexWEBGL(i.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var e;this.gl.isContextLost()&&((e=this.extensions.loseContext)==null||e.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(t=this.extensions.loseContext)==null||t.loseContext()}forceContextLoss(){var t;(t=this.extensions.loseContext)==null||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&e.stencil;const i=this.supports,s=this.webGLVersion===2,n=this.extensions;i.uint32Indices=s||!!n.uint32ElementIndex,i.uniformBufferObject=s,i.vertexArrayObject=s||!!n.vertexArrayObject,i.srgbTextures=s||!!n.srgb,i.nonPowOf2wrapping=s,i.nonPowOf2mipmaps=s,i.msaa=s,i.uint32Indices}};Rl.extension={type:[T.WebGLSystem],name:"context"},Rl.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let Eb=Rl;function Cl(r,t){var e,i,s;for(const n in r.attributes){const o=r.attributes[n],a=t[n];a?((e=o.format)!=null||(o.format=a.format),(i=o.offset)!=null||(o.offset=a.offset),(s=o.instance)!=null||(o.instance=a.instance)):Xt(`Attribute ${n} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}dw(r)}function dw(r){var t,e;const{buffers:i,attributes:s}=r,n={},o={};for(const a in i){const l=i[a];n[l.uid]=0,o[l.uid]=0}for(const a in s){const l=s[a];n[l.buffer.uid]+=se(l.format).stride}for(const a in s){const l=s[a];(t=l.stride)!=null||(l.stride=n[l.buffer.uid]),(e=l.start)!=null||(l.start=o[l.buffer.uid]),o[l.buffer.uid]+=se(l.format).stride}}var qs=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(qs||{}),Ml=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(Ml||{}),Pb=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Pb||{}),j=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(j||{});const wb={uint8x2:j.UNSIGNED_BYTE,uint8x4:j.UNSIGNED_BYTE,sint8x2:j.BYTE,sint8x4:j.BYTE,unorm8x2:j.UNSIGNED_BYTE,unorm8x4:j.UNSIGNED_BYTE,snorm8x2:j.BYTE,snorm8x4:j.BYTE,uint16x2:j.UNSIGNED_SHORT,uint16x4:j.UNSIGNED_SHORT,sint16x2:j.SHORT,sint16x4:j.SHORT,unorm16x2:j.UNSIGNED_SHORT,unorm16x4:j.UNSIGNED_SHORT,snorm16x2:j.SHORT,snorm16x4:j.SHORT,float16x2:j.HALF_FLOAT,float16x4:j.HALF_FLOAT,float32:j.FLOAT,float32x2:j.FLOAT,float32x3:j.FLOAT,float32x4:j.FLOAT,uint32:j.UNSIGNED_INT,uint32x2:j.UNSIGNED_INT,uint32x3:j.UNSIGNED_INT,uint32x4:j.UNSIGNED_INT,sint32:j.INT,sint32x2:j.INT,sint32x3:j.INT,sint32x4:j.INT};function Rb(r){var t;return(t=wb[r])!=null?t:wb.float32}const pw={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class Cb{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class Ol{constructor(t){this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new xt({renderer:t,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=s=>e.bindVertexArrayOES(s),t.deleteVertexArray=s=>e.deleteVertexArrayOES(s));const i=this._renderer.context.extensions.vertexAttribDivisorANGLE;i&&(t.drawArraysInstanced=(s,n,o,a)=>{i.drawArraysInstancedANGLE(s,n,o,a)},t.drawElementsInstanced=(s,n,o,a,l)=>{i.drawElementsInstancedANGLE(s,n,o,a,l)},t.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n)),this._activeGeometry=null,this._activeVao=null}bind(t,e){const i=this.gl;this._activeGeometry=t;const s=this.getVao(t,e);this._activeVao!==s&&(this._activeVao=s,i.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.updateBuffer(s)}t._gcLastUsed=this._renderer.gc.now}checkCompatibility(t,e){const i=t.attributes,s=e._attributeData;for(const n in s)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,s=e._attributeData,n=["g",t.uid];for(const o in i)s[o]&&n.push(o,s[o].location);return n.join("-")}getVao(t,e){var i;return((i=t._gpuData[this._renderer.uid])==null?void 0:i.vaoCache[e._key])||this.initGeometryVao(t,e)}initGeometryVao(t,e,i=!0){const s=this._renderer.gl,n=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const o=this.getSignature(t,e),a=new Cb;t._gpuData[this._renderer.uid]=a,this._managedGeometries.add(t);const l=a.vaoCache;let u=l[o];if(u)return l[e._key]=u,u;Cl(t,e._attributeData);const c=t.buffers;u=s.createVertexArray(),s.bindVertexArray(u);for(let h=0;h<c.length;h++){const p=c[h];n.bind(p)}return this.activateVao(t,e),l[e._key]=u,l[o]=u,s.bindVertexArray(null),u}onGeometryUnload(t,e=!1){const i=t._gpuData[this._renderer.uid];if(!i)return;const s=i.vaoCache;if(!e)for(const n in s)this._activeVao!==s[n]&&this.resetState(),this.gl.deleteVertexArray(s[n])}destroyAll(t=!1){this._managedGeometries.removeAll(t)}activateVao(t,e){var i,s;const n=this._renderer.gl,o=this._renderer.buffer,a=t.attributes;t.indexBuffer&&o.bind(t.indexBuffer);let l=null;for(const u in a){const c=a[u],h=c.buffer,p=o.getGlBuffer(h),f=e._attributeData[u];if(f){l!==p&&(o.bind(h),l=p);const m=f.location;n.enableVertexAttribArray(m);const _=se(c.format),g=Rb(c.format);if(((i=f.format)==null?void 0:i.substring(1,4))==="int"?n.vertexAttribIPointer(m,_.size,g,c.stride,c.offset):n.vertexAttribPointer(m,_.size,g,_.normalised,c.stride,c.offset),c.instance)if(this.hasInstance){const b=(s=c.divisor)!=null?s:1;n.vertexAttribDivisor(m,b)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,s){const{gl:n}=this._renderer,o=this._activeGeometry,a=pw[t||o.topology];if(s!=null||(s=o.instanceCount),o.indexBuffer){const l=o.indexBuffer.data.BYTES_PER_ELEMENT,u=l===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;s!==1?n.drawElementsInstanced(a,e||o.indexBuffer.data.length,u,(i||0)*l,s):n.drawElements(a,e||o.indexBuffer.data.length,u,(i||0)*l)}else s!==1?n.drawArraysInstanced(a,i||0,e||o.getSize(),s):n.drawArrays(a,i||0,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}Ol.extension={type:[T.WebGLSystem],name:"geometry"};var fw=Object.defineProperty,Mb=Object.getOwnPropertySymbols,mw=Object.prototype.hasOwnProperty,gw=Object.prototype.propertyIsEnumerable,Ob=(r,t,e)=>t in r?fw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Gb=(r,t)=>{for(var e in t||(t={}))mw.call(t,e)&&Ob(r,e,t[e]);if(Mb)for(var e of Mb(t))gw.call(t,e)&&Ob(r,e,t[e]);return r};const _w=new Ee({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),Gl=class o0{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:i}=Gb(Gb({},o0.defaultOptions),t);this.useBackBuffer=e,this._antialias=i,this._renderer.context.supports.msaa||(Xt("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Rt.for2d();const s=new vt({vertex:`
attribute vec2 aPosition;
out vec2 vUv;
void main() {
gl_Position = vec4(aPosition, 0.0, 1.0);
vUv = (aPosition + 1.0) / 2.0;
// flip dem UVs
vUv.y = 1.0 - vUv.y;
}`,fragment:`
in vec2 vUv;
out vec4 finalColor;
uniform sampler2D uTexture;
void main() {
finalColor = texture(uTexture, vUv);
}`,name:"big-triangle"});this._bigTriangleShader=new wt({glProgram:s,resources:{uTexture:w.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const i=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=i.colorTexture,t.target=this._getBackBufferTexture(i.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:_w,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new w({source:new Q({width:t.width,height:t.height,resolution:t._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(t.width,t.height,t._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};Gl.extension={type:[T.WebGLSystem],name:"backBuffer",priority:1},Gl.defaultOptions={useBackBuffer:!1};let Bb=Gl;class Bl{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(t&8),!!(t&4),!!(t&2),!!(t&1)))}}Bl.extension={type:[T.WebGLSystem],name:"colorMask"};class Il{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){const e=this._renderer,{geometry:i,shader:s,state:n,skipSync:o,topology:a,size:l,start:u,instanceCount:c}=t;e.shader.bind(s,o),e.geometry.bind(i,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(a,l,u,c!=null?c:i.instanceCount)}destroy(){this._renderer=null}}Il.extension={type:[T.WebGLSystem],name:"encoder"};class Fl{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=ho(this.maxTextures,t);const e=this._renderer.context.webGLVersion===2;this.maxUniformBindings=e?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}Fl.extension={type:[T.WebGLSystem],name:"limits"};class Ib{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const oe=[];oe[rt.NONE]=void 0,oe[rt.DISABLED]={stencilWriteMask:0,stencilReadMask:0},oe[rt.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},oe[rt.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},oe[rt.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},oe[rt.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class Dl{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:rt.NONE},this._renderTargetStencilState=Object.create(null),t.renderTarget.onRenderTargetChange.add(this)}contextChange(t){this._gl=t,this._comparisonFuncMapping={always:t.ALWAYS,never:t.NEVER,equal:t.EQUAL,"not-equal":t.NOTEQUAL,less:t.LESS,"less-equal":t.LEQUAL,greater:t.GREATER,"greater-equal":t.GEQUAL},this._stencilOpsMapping={keep:t.KEEP,zero:t.ZERO,replace:t.REPLACE,invert:t.INVERT,"increment-clamp":t.INCR,"decrement-clamp":t.DECR,"increment-wrap":t.INCR_WRAP,"decrement-wrap":t.DECR_WRAP},this.resetState()}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:rt.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=rt.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],s=this._gl,n=oe[t],o=this._stencilCache;if(i.stencilMode=t,i.stencilReference=e,t===rt.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,s.disable(s.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,s.enable(s.STENCIL_TEST)),(t!==o.stencilMode||o.stencilReference!==e)&&(o.stencilMode=t,o.stencilReference=e,s.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),s.stencilOp(s.KEEP,s.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}}Dl.extension={type:[T.WebGLSystem],name:"stencil"};class Ul{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!Ua())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const e=this.getUniformGroupData(t);t.buffer||(t.buffer=new bt({data:new Float32Array(e.layout.size/4),usage:X.UNIFORM|X.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let i=this._syncFunctionHash[e];if(!i){const s=Object.keys(t.uniformStructures).map(a=>t.uniformStructures[a]),n=this._adaptor.createUboElements(s),o=this._generateUboSync(n.uboElements);i=this._syncFunctionHash[e]={layout:n,syncFunction:o}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,i){const s=this.getUniformGroupData(t);t.buffer||(t.buffer=new bt({data:new Float32Array(s.layout.size/4),usage:X.UNIFORM|X.COPY_DST}));let n=null;return e||(e=t.buffer.data,n=t.buffer.dataInt32),i||(i=0),s.syncFunction(t.uniforms,e,n,i),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}const kl={f32:4,i32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"vec2<i32>":8,"vec3<i32>":12,"vec4<i32>":16,"mat2x2<f32>":32,"mat3x3<f32>":48,"mat4x4<f32>":64};function Fb(r){const t=r.map(n=>({data:n,offset:0,size:0})),e=16;let i=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(i=kl[o.data.type],!i)throw new Error(`Unknown type ${o.data.type}`);o.data.size>1&&(i=Math.max(i,e)*o.data.size);const a=i===12?16:i;o.size=i;const l=s%e;l>0&&e-l<a?s+=(e-l)%16:s+=(i-l%i)%i,o.offset=s,s+=i}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}const pe=[{type:"mat3x3<f32>",test:r=>r.value.a!==void 0,ubo:`
var matrix = uv[name].toArray(true);
data[offset] = matrix[0];
data[offset + 1] = matrix[1];
data[offset + 2] = matrix[2];
data[offset + 4] = matrix[3];
data[offset + 5] = matrix[4];
data[offset + 6] = matrix[5];
data[offset + 8] = matrix[6];
data[offset + 9] = matrix[7];
data[offset + 10] = matrix[8];
`,uniform:`
gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
`},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.width!==void 0,ubo:`
v = uv[name];
data[offset] = v.x;
data[offset + 1] = v.y;
data[offset + 2] = v.width;
data[offset + 3] = v.height;
`,uniform:`
cv = ud[name].value;
v = uv[name];
if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
cv[0] = v.x;
cv[1] = v.y;
cv[2] = v.width;
cv[3] = v.height;
gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
}
`},{type:"vec2<f32>",test:r=>r.type==="vec2<f32>"&&r.size===1&&r.value.x!==void 0,ubo:`
v = uv[name];
data[offset] = v.x;
data[offset + 1] = v.y;
`,uniform:`
cv = ud[name].value;
v = uv[name];
if (cv[0] !== v.x || cv[1] !== v.y) {
cv[0] = v.x;
cv[1] = v.y;
gl.uniform2f(ud[name].location, v.x, v.y);
}
`},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
v = uv[name];
data[offset] = v.red;
data[offset + 1] = v.green;
data[offset + 2] = v.blue;
data[offset + 3] = v.alpha;
`,uniform:`
cv = ud[name].value;
v = uv[name];
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
cv[0] = v.red;
cv[1] = v.green;
cv[2] = v.blue;
cv[3] = v.alpha;
gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
}
`},{type:"vec3<f32>",test:r=>r.type==="vec3<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
v = uv[name];
data[offset] = v.red;
data[offset + 1] = v.green;
data[offset + 2] = v.blue;
`,uniform:`
cv = ud[name].value;
v = uv[name];
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
cv[0] = v.red;
cv[1] = v.green;
cv[2] = v.blue;
gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
}
`}];function $l(r,t,e,i){const s=[`
var v = null;
var v2 = null;
var t = 0;
var index = 0;
var name = null;
var arrayOffset = null;
`];let n=0;for(let a=0;a<r.length;a++){const l=r[a],u=l.data.name;let c=!1,h=0;for(let p=0;p<pe.length;p++)if(pe[p].test(l.data)){h=l.offset/4,s.push(`name = "${u}";`,`offset += ${h-n};`,pe[p][t]||pe[p].ubo),c=!0;break}if(!c)if(l.data.size>1)h=l.offset/4,s.push(e(l,h-n));else{const p=i[l.data.type];h=l.offset/4,s.push(`
v = uv.${u};
offset += ${h-n};
${p};
`)}n=h}const o=s.join(`
`);return new Function("uv","data","dataInt32","offset",o)}var bw=Object.defineProperty,vw=Object.defineProperties,yw=Object.getOwnPropertyDescriptors,Db=Object.getOwnPropertySymbols,xw=Object.prototype.hasOwnProperty,Tw=Object.prototype.propertyIsEnumerable,Ub=(r,t,e)=>t in r?bw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Sw=(r,t)=>{for(var e in t||(t={}))xw.call(t,e)&&Ub(r,e,t[e]);if(Db)for(var e of Db(t))Tw.call(t,e)&&Ub(r,e,t[e]);return r},Aw=(r,t)=>vw(r,yw(t));function gr(r,t){return`
for (let i = 0; i < ${r*t}; i++) {
data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i];
}
`}const Ll={f32:`
data[offset] = v;`,i32:`
dataInt32[offset] = v;`,"vec2<f32>":`
data[offset] = v[0];
data[offset + 1] = v[1];`,"vec3<f32>":`
data[offset] = v[0];
data[offset + 1] = v[1];
data[offset + 2] = v[2];`,"vec4<f32>":`
data[offset] = v[0];
data[offset + 1] = v[1];
data[offset + 2] = v[2];
data[offset + 3] = v[3];`,"vec2<i32>":`
dataInt32[offset] = v[0];
dataInt32[offset + 1] = v[1];`,"vec3<i32>":`
dataInt32[offset] = v[0];
dataInt32[offset + 1] = v[1];
dataInt32[offset + 2] = v[2];`,"vec4<i32>":`
dataInt32[offset] = v[0];
dataInt32[offset + 1] = v[1];
dataInt32[offset + 2] = v[2];
dataInt32[offset + 3] = v[3];`,"mat2x2<f32>":`
data[offset] = v[0];
data[offset + 1] = v[1];
data[offset + 4] = v[2];
data[offset + 5] = v[3];`,"mat3x3<f32>":`
data[offset] = v[0];
data[offset + 1] = v[1];
data[offset + 2] = v[2];
data[offset + 4] = v[3];
data[offset + 5] = v[4];
data[offset + 6] = v[5];
data[offset + 8] = v[6];
data[offset + 9] = v[7];
data[offset + 10] = v[8];`,"mat4x4<f32>":`
for (let i = 0; i < 16; i++) {
data[offset + i] = v[i];
}`,"mat3x2<f32>":gr(3,2),"mat4x2<f32>":gr(4,2),"mat2x3<f32>":gr(2,3),"mat4x3<f32>":gr(4,3),"mat2x4<f32>":gr(2,4),"mat3x4<f32>":gr(3,4)},kb=Aw(Sw({},Ll),{"mat2x2<f32>":`
data[offset] = v[0];
data[offset + 1] = v[1];
data[offset + 2] = v[2];
data[offset + 3] = v[3];
`});function $b(r,t){const e=Math.max(kl[r.data.type]/16,1),i=r.data.value.length/r.data.size,s=(4-i%4)%4,n=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
v = uv.${r.data.name};
offset += ${t};
arrayOffset = offset;
t = 0;
for(var i=0; i < ${r.data.size*e}; i++)
{
for(var j = 0; j < ${i}; j++)
{
${n}[arrayOffset++] = v[t++];
}
${s!==0?`arrayOffset += ${s};`:""}
}
`}function Lb(r){return $l(r,"uboStd40",$b,Ll)}class Nl extends Ul{constructor(){super({createUboElements:Fb,generateUboSync:Lb})}}Nl.extension={type:[T.WebGLSystem],name:"ubo"};class Nb{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new z}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new z;const t=this._renderer.gl;this._drawBuffersCache=[];for(let e=1;e<=16;e++)this._drawBuffersCache[e]=Array.from({length:e},(i,s)=>t.COLOR_ATTACHMENT0+s)}copyToTexture(t,e,i,s,n){const o=this._renderTargetSystem,a=this._renderer,l=o.getGpuRenderTarget(t),u=a.gl;return this.finishRenderPass(t),u.bindFramebuffer(u.FRAMEBUFFER,l.resolveTargetFramebuffer),a.texture.bind(e,0),u.copyTexSubImage2D(u.TEXTURE_2D,0,n.x,n.y,i.x,i.y,s.width,s.height),e}startRenderPass(t,e=!0,i,s){const n=this._renderTargetSystem,o=t.colorTexture,a=n.getGpuRenderTarget(t);let l=s.y;t.isRoot&&(l=o.pixelHeight-s.height-s.y),t.colorTextures.forEach(h=>{this._renderer.texture.unbind(h)});const u=this._renderer.gl;u.bindFramebuffer(u.FRAMEBUFFER,a.framebuffer),t.colorTextures.length>1&&this._setDrawBuffers(t,u);const c=this._viewPortCache;(c.x!==s.x||c.y!==l||c.width!==s.width||c.height!==s.height)&&(c.x=s.x,c.y=l,c.width=s.width,c.height=s.height,u.viewport(s.x,l,s.width,s.height)),!a.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(a),this.clear(t,e,i)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)return;const i=this._renderer.gl;i.bindFramebuffer(i.FRAMEBUFFER,e.resolveTargetFramebuffer),i.bindFramebuffer(i.READ_FRAMEBUFFER,e.framebuffer),i.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,i.COLOR_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.FRAMEBUFFER,e.framebuffer)}initGpuRenderTarget(t){const e=this._renderer.gl,i=new Ib;return t.colorTexture instanceof qt?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),i.framebuffer=null,i):(this._initColor(t,i),e.bindFramebuffer(e.FRAMEBUFFER,null),i)}destroyGpuRenderTarget(t){const e=this._renderer.gl;t.framebuffer&&(e.deleteFramebuffer(t.framebuffer),t.framebuffer=null),t.resolveTargetFramebuffer&&(e.deleteFramebuffer(t.resolveTargetFramebuffer),t.resolveTargetFramebuffer=null),t.depthStencilRenderBuffer&&(e.deleteRenderbuffer(t.depthStencilRenderBuffer),t.depthStencilRenderBuffer=null),t.msaaRenderBuffer.forEach(i=>{e.deleteRenderbuffer(i)}),t.msaaRenderBuffer=null}clear(t,e,i){if(!e)return;const s=this._renderTargetSystem;typeof e=="boolean"&&(e=e?Tt.ALL:Tt.NONE);const n=this._renderer.gl;if(e&Tt.COLOR){i!=null||(i=s.defaultClearColor);const o=this._clearColorCache,a=i;(o[0]!==a[0]||o[1]!==a[1]||o[2]!==a[2]||o[3]!==a[3])&&(o[0]=a[0],o[1]=a[1],o[2]=a[2],o[3]=a[3],n.clearColor(a[0],a[1],a[2],a[3]))}n.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const i=this._renderer,s=i.gl,n=s.createFramebuffer();if(e.resolveTargetFramebuffer=n,s.bindFramebuffer(s.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((o,a)=>{const l=o.source;l.antialias&&(i.context.supports.msaa?e.msaa=!0:Xt("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),i.texture.bindSource(l,0);const u=i.texture.getGlSource(l).texture;s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+a,3553,u,0)}),e.msaa){const o=s.createFramebuffer();e.framebuffer=o,s.bindFramebuffer(s.FRAMEBUFFER,o),t.colorTextures.forEach((a,l)=>{const u=s.createRenderbuffer();e.msaaRenderBuffer[l]=u})}else e.framebuffer=n;this._resizeColor(t,e)}_resizeColor(t,e){const i=t.colorTexture.source;if(e.width=i.pixelWidth,e.height=i.pixelHeight,t.colorTextures.forEach((s,n)=>{n!==0&&s.source.resize(i.width,i.height,i._resolution)}),e.msaa){const s=this._renderer,n=s.gl,o=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,o),t.colorTextures.forEach((a,l)=>{const u=a.source;s.texture.bindSource(u,0);const c=s.texture.getGlSource(u).internalFormat,h=e.msaaRenderBuffer[l];n.bindRenderbuffer(n.RENDERBUFFER,h),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,c,u.pixelWidth,u.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+l,n.RENDERBUFFER,h)})}}_initStencil(t){if(t.framebuffer===null)return;const e=this._renderer.gl,i=e.createRenderbuffer();t.depthStencilRenderBuffer=i,e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,i),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,this._renderer.context.webGLVersion===2?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}prerender(t){const e=t.colorTexture.resource;this._renderer.context.multiView&&qt.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&qt.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,i=t.colorTexture;i.context2D.drawImage(e,0,i.pixelHeight-e.height)}}_setDrawBuffers(t,e){const i=t.colorTextures.length,s=this._drawBuffersCache[i];if(this._renderer.context.webGLVersion===1){const n=this._renderer.context.extensions.drawBuffers;n?n.drawBuffersWEBGL(s):Xt("[RenderTexture] This WebGL1 context does not support rendering to multiple targets")}else e.drawBuffers(s)}}function Xb(r,t,e,i,s,n){const o=n?1:-1;return r.identity(),r.a=1/i*2,r.d=o*(1/s*2),r.tx=-1-t*r.a,r.ty=-o-e*r.d,r}var Ew=Object.defineProperty,Hb=Object.getOwnPropertySymbols,Pw=Object.prototype.hasOwnProperty,ww=Object.prototype.propertyIsEnumerable,jb=(r,t,e)=>t in r?Ew(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Rw=(r,t)=>{for(var e in t||(t={}))Pw.call(t,e)&&jb(r,e,t[e]);if(Hb)for(var e of Hb(t))ww.call(t,e)&&jb(r,e,t[e]);return r};const Ge=new Map;ge.register(Ge);function Xl(r,t){if(!Ge.has(r)){const e=new w({source:new qt(Rw({resource:r},t))}),i=()=>{Ge.get(r)===e&&Ge.delete(r)};e.once("destroy",i),e.source.once("destroy",i),Ge.set(r,e)}return Ge.get(r)}function Cw(r){return Ge.has(r)}function zb(r){const t=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var Mw=Object.defineProperty,Vb=Object.getOwnPropertySymbols,Ow=Object.prototype.hasOwnProperty,Gw=Object.prototype.propertyIsEnumerable,Wb=(r,t,e)=>t in r?Mw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yb=(r,t)=>{for(var e in t||(t={}))Ow.call(t,e)&&Wb(r,e,t[e]);if(Vb)for(var e of Vb(t))Gw.call(t,e)&&Wb(r,e,t[e]);return r};const Kb=class a0{constructor(t={}){if(this.uid=Y("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t=Yb(Yb({},a0.defaultOptions),t),this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,typeof t.colorTextures=="number"){this._managedColorTextures=!0;for(let e=0;e<t.colorTextures;e++)this.colorTextures.push(new Q({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}))}else{this.colorTextures=[...t.colorTextures.map(i=>i.source)];const e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof w||t.depthStencilTexture instanceof Q?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new Q({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,i=this.resolution,s=!1){this.dirtyId++,this.colorTextures.forEach((n,o)=>{s&&o===0||n.source.resize(t,e,i)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,i)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(t=>{t.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};Kb.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Zs=Kb;class Hl{constructor(t){this.rootViewPort=new z,this.viewport=new z,this.onRenderTargetChange=new ka("onRenderTargetChange"),this.projectionMatrix=new C,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuRenderTargetHash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:i,frame:s}){var n,o;this._renderTargetStack.length=0,this.push(t,e,i,s),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=zb(this.rootRenderTarget),(o=(n=this.adaptor).prerender)==null||o.call(n,this.rootRenderTarget)}postrender(){var t,e;(e=(t=this.adaptor).postrender)==null||e.call(t,this.rootRenderTarget)}bind(t,e=!0,i,s){const n=this.getRenderTarget(t),o=this.renderTarget!==n;this.renderTarget=n,this.renderSurface=t;const a=this.getGpuRenderTarget(n);(n.pixelWidth!==a.width||n.pixelHeight!==a.height)&&(this.adaptor.resizeGpuRenderTarget(n),a.width=n.pixelWidth,a.height=n.pixelHeight);const l=n.colorTexture,u=this.viewport,c=l.pixelWidth,h=l.pixelHeight;if(!s&&t instanceof w&&(s=t.frame),s){const p=l._resolution;u.x=s.x*p+.5|0,u.y=s.y*p+.5|0,u.width=s.width*p+.5|0,u.height=s.height*p+.5|0}else u.x=0,u.y=0,u.width=c,u.height=h;return Xb(this.projectionMatrix,0,0,u.width/l.resolution,u.height/l.resolution,!n.isRoot),this.adaptor.startRenderPass(n,e,i,u),o&&this.onRenderTargetChange.emit(n),n}clear(t,e=Tt.ALL,i){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,i,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=Tt.ALL,i,s){const n=this.bind(t,e,i,s);return this._renderTargetStack.push({renderTarget:n,frame:s}),n}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame)}getRenderTarget(t){var e;return t.isTexture&&(t=t.source),(e=this._renderSurfaceToRenderTargetHash.get(t))!=null?e:this._initRenderTarget(t)}copyToTexture(t,e,i,s,n){i.x<0&&(s.width+=i.x,n.x-=i.x,i.x=0),i.y<0&&(s.height+=i.y,n.y-=i.y,i.y=0);const{pixelWidth:o,pixelHeight:a}=t;return s.width=Math.min(s.width,o-i.x),s.height=Math.min(s.height,a-i.y),this.adaptor.copyToTexture(t,e,i,s,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((t,e)=>{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return qt.test(t)&&(t=Xl(t).source),t instanceof Zs?e=t:t instanceof Q&&(e=new Zs({colorTextures:[t]}),t.source instanceof qt&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);const i=this._gpuRenderTargetHash[e.uid];i&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(i))})),this._renderSurfaceToRenderTargetHash.set(t,e),e}getGpuRenderTarget(t){return this._gpuRenderTargetHash[t.uid]||(this._gpuRenderTargetHash[t.uid]=this.adaptor.initGpuRenderTarget(t))}resetState(){this.renderTarget=null,this.renderSurface=null}}class jl extends Hl{constructor(t){super(t),this.adaptor=new Nb,this.adaptor.init(t,this)}}jl.extension={type:[T.WebGLSystem],name:"renderTarget"};class Qs extends gt{constructor({buffer:t,offset:e,size:i}){super(),this.uid=Y("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=Y("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=i,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=Y("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}function qb(r,t){const e=[],i=[`
var g = s.groups;
var sS = r.shader;
var p = s.glProgram;
var ugS = r.uniformGroup;
var resources;
`];let s=!1,n=0;const o=t._getProgramData(r.glProgram);for(const l in r.groups){const u=r.groups[l];e.push(`
resources = g[${l}].resources;
`);for(const c in u.resources){const h=u.resources[c];if(h instanceof nt)if(h.ubo){const p=r._uniformBindMap[l][Number(c)];e.push(`
sS.bindUniformBlock(
resources[${c}],
'${p}',
${r.glProgram._uniformBlockData[p].index}
);
`)}else e.push(`
ugS.updateUniformGroup(resources[${c}], p, sD);
`);else if(h instanceof Qs){const p=r._uniformBindMap[l][Number(c)];e.push(`
sS.bindUniformBlock(
resources[${c}],
'${p}',
${r.glProgram._uniformBlockData[p].index}
);
`)}else if(h instanceof Q){const p=r._uniformBindMap[l][c],f=o.uniformData[p];f&&(s||(s=!0,i.push(`
var tS = r.texture;
`)),t._gl.uniform1i(f.location,n),e.push(`
tS.bind(resources[${c}], ${n});
`),n++)}}}const a=[...i,...e].join(`
`);return new Function("r","s","sD",a)}class Bw{}class Zb{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function zl(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function Vl(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Wl(r,t){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Vl(2*t);case"bvec3":return Vl(3*t);case"bvec4":return Vl(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}let Js=null;const Qb={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"},Iw={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"};function Yl(r,t){if(!Js){const e=Object.keys(Qb);Js={};for(let i=0;i<e.length;++i){const s=e[i];Js[r[s]]=Qb[s]}}return Js[t]}function Jb(r,t){const e=Yl(r,t);return Iw[e]||"float32"}function tv(r,t,e=!1){const i={},s=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let o=0;o<s;o++){const a=t.getActiveAttrib(r,o);if(a.name.startsWith("gl_"))continue;const l=Jb(t,a.type);i[a.name]={location:0,format:l,stride:se(l).stride,offset:0,instance:!1,start:0}}const n=Object.keys(i);if(e){n.sort((o,a)=>o>a?1:-1);for(let o=0;o<n.length;o++)i[n[o]].location=o,t.bindAttribLocation(r,o,n[o]);t.linkProgram(r)}else for(let o=0;o<n.length;o++)i[n[o]].location=t.getAttribLocation(r,n[o]);return i}function ev(r,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<i;s++){const n=t.getActiveUniformBlockName(r,s),o=t.getUniformBlockIndex(r,n),a=t.getActiveUniformBlockParameter(r,s,t.UNIFORM_BLOCK_DATA_SIZE);e[n]={name:n,index:o,size:a}}return e}function rv(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let s=0;s<i;s++){const n=t.getActiveUniform(r,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=Yl(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:Wl(l,n.size)}}return e}function iv(r,t){const e=r.getShaderSource(t).split(`
`).map((u,c)=>`${c}: ${u}`),i=r.getShaderInfoLog(t),s=i.split(`
`),n={},o=s.map(u=>parseFloat(u.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(u=>u&&!n[u]?(n[u]=!0,!0):!1),a=[""];o.forEach(u=>{e[u-1]=`%c${e[u-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=e.join(`
`);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function sv(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||iv(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||iv(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}function nv(r,t){const e=zl(r,r.VERTEX_SHADER,t.vertex),i=zl(r,r.FRAGMENT_SHADER,t.fragment),s=r.createProgram();r.attachShader(s,e),r.attachShader(s,i);const n=t.transformFeedbackVaryings;n&&(typeof r.transformFeedbackVaryings!="function"||r.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||sv(r,s,e,i),t._attributeData=tv(s,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=rv(s,r),t._uniformBlockData=ev(s,r),r.deleteShader(e),r.deleteShader(i);const o={};for(const a in t._uniformData){const l=t._uniformData[a];o[a]={location:r.getUniformLocation(s,a),value:Wl(l.type,l.size)}}return new Zb(s,o)}const tn={textureCount:0,blockIndex:0};class Kl{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t}contextChange(t){this._gl=t,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;tn.textureCount=0,tn.blockIndex=0;let i=this._shaderSyncFunctions[t.glProgram._key];i||(i=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),i(this._renderer,t,tn)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,tn)}bindUniformBlock(t,e,i=0){const s=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=t._bufferResource;o||this._renderer.ubo.updateUniformGroup(t);const a=t.buffer,l=s.updateBuffer(a),u=s.freeLocationForBufferBase(l);if(o){const{offset:h,size:p}=t;h===0&&p===a.data.byteLength?s.bindBufferBase(l,u):s.bindBufferRange(l,u,h)}else s.getLastBindBaseLocation(l)!==u&&s.bindBufferBase(l,u);const c=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[i]!==u&&(n.uniformBlockBindings[i]=u,this._renderer.gl.uniformBlockBinding(n.program,c,u))}_setProgram(t){if(this._activeProgram===t)return;this._activeProgram=t;const e=this._getProgramData(t);this._gl.useProgram(e.program)}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){const e=t._key;return this._programDataHash[e]=nv(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash))this._programDataHash[t].destroy();this._programDataHash=null,this._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(t,e){return qb(t,e)}resetState(){this._activeProgram=null}}Kl.extension={type:[T.WebGLSystem],name:"shader"};const ov={f32:`if (cv !== v) {
cu.value = v;
gl.uniform1f(location, v);
}`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
cv[0] = v[0];
cv[1] = v[1];
gl.uniform2f(location, v[0], v[1]);
}`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
cv[0] = v[0];
cv[1] = v[1];
cv[2] = v[2];
gl.uniform3f(location, v[0], v[1], v[2]);
}`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
cv[0] = v[0];
cv[1] = v[1];
cv[2] = v[2];
cv[3] = v[3];
gl.uniform4f(location, v[0], v[1], v[2], v[3]);
}`,i32:`if (cv !== v) {
cu.value = v;
gl.uniform1i(location, v);
}`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
cv[0] = v[0];
cv[1] = v[1];
gl.uniform2i(location, v[0], v[1]);
}`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
cv[0] = v[0];
cv[1] = v[1];
cv[2] = v[2];
gl.uniform3i(location, v[0], v[1], v[2]);
}`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
cv[0] = v[0];
cv[1] = v[1];
cv[2] = v[2];
cv[3] = v[3];
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
}`,u32:`if (cv !== v) {
cu.value = v;
gl.uniform1ui(location, v);
}`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
cv[0] = v[0];
cv[1] = v[1];
gl.uniform2ui(location, v[0], v[1]);
}`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
cv[0] = v[0];
cv[1] = v[1];
cv[2] = v[2];
gl.uniform3ui(location, v[0], v[1], v[2]);
}`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
cv[0] = v[0];
cv[1] = v[1];
cv[2] = v[2];
cv[3] = v[3];
gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
}`,bool:`if (cv !== v) {
cu.value = v;
gl.uniform1i(location, v);
}`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
cv[0] = v[0];
cv[1] = v[1];
gl.uniform2i(location, v[0], v[1]);
}`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
cv[0] = v[0];
cv[1] = v[1];
cv[2] = v[2];
gl.uniform3i(location, v[0], v[1], v[2]);
}`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
cv[0] = v[0];
cv[1] = v[1];
cv[2] = v[2];
cv[3] = v[3];
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
}`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},av={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"};function lv(r,t){const e=[`
var v = null;
var cv = null;
var cu = null;
var t = 0;
var gl = renderer.gl;
var name = null;
`];for(const i in r.uniforms){if(!t[i]){r.uniforms[i]instanceof nt?r.uniforms[i].ubo?e.push(`
renderer.shader.bindUniformBlock(uv.${i}, "${i}");
`):e.push(`
renderer.shader.updateUniformGroup(uv.${i});
`):r.uniforms[i]instanceof Qs&&e.push(`
renderer.shader.bindBufferResource(uv.${i}, "${i}");
`);continue}const s=r.uniformStructures[i];let n=!1;for(let o=0;o<pe.length;o++){const a=pe[o];if(s.type===a.type&&a.test(s)){e.push(`name = "${i}";`,pe[o].uniform),n=!0;break}}if(!n){const o=(s.size===1?ov:av)[s.type].replace("location",`ud["${i}"].location`);e.push(`
cu = ud["${i}"];
cv = cu.value;
v = uv["${i}"];
${o};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
`))}class ql{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,i){const s=this._renderer.shader._getProgramData(e);(!t.isStatic||t._dirtyId!==s.uniformDirtyGroups[t.uid])&&(s.uniformDirtyGroups[t.uid]=t._dirtyId,this._getUniformSyncFunction(t,e)(s.uniformData,t.uniforms,this._renderer,i))}_getUniformSyncFunction(t,e){var i;return((i=this._uniformGroupSyncHash[t._signature])==null?void 0:i[e._key])||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){const i=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),s=this._getSignature(t,e._uniformData,"u");return this._cache[s]||(this._cache[s]=this._generateUniformsSync(t,e._uniformData)),i[e._key]=this._cache[s],i[e._key]}_generateUniformsSync(t,e){return lv(t,e)}_getSignature(t,e,i){const s=t.uniforms,n=[`${i}-`];for(const o in s)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}}ql.extension={type:[T.WebGLSystem],name:"uniformGroup"};function Fw(r){return r=r.replaceAll("texture2D","texture").replaceAll("gl_FragColor","finalColor").replaceAll("varying","in"),r=`
out vec4 finalColor;
${r}
`,r}const Dw={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function Uw(r){return Dw[r]}function uv(r){const t={};if(t.normal=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t.add=[r.ONE,r.ONE],t.multiply=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.screen=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t["screen-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.erase=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],!(r instanceof L.get().getWebGLRenderingContext()))t.min=[r.ONE,r.ONE,r.ONE,r.ONE,r.MIN,r.MIN],t.max=[r.ONE,r.ONE,r.ONE,r.ONE,r.MAX,r.MAX];else{const e=r.getExtension("EXT_blend_minmax");e&&(t.min=[r.ONE,r.ONE,r.ONE,r.ONE,e.MIN_EXT,e.MIN_EXT],t.max=[r.ONE,r.ONE,r.ONE,r.ONE,e.MAX_EXT,e.MAX_EXT])}return t}const kw=0,$w=1,Lw=2,Nw=3,Xw=4,Hw=5,cv=class Ju{constructor(t){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[kw]=this.setBlend,this.map[$w]=this.setOffset,this.map[Lw]=this.setCullFace,this.map[Nw]=this.setDepthTest,this.map[Xw]=this.setFrontFace,this.map[Hw]=this.setDepthMask,this.checks=[],this.defaultState=Rt.for2d(),t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){this._invertFrontFace=!t.isRoot,this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(t){this.gl=t,this.blendModesMap=uv(t),this.resetState()}set(t){if(t||(t=this.defaultState),this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e>>=1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t||(t=this.defaultState);for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this._updateCheck(Ju._checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this._updateCheck(Ju._checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this._cullFace=t,this.gl[t?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(t){this._frontFace=t,this._frontFaceDirty=!1;const e=this._invertFrontFace?!t:t;this._glFrontFace!==e&&(this._glFrontFace=e,this.gl.frontFace(this.gl[e?"CW":"CCW"]))}setBlendMode(t){if(this.blendModesMap[t]||(t="normal"),t===this.blendMode)return;this.blendMode=t;const e=this.blendModesMap[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}resetState(){this._glFrontFace=!1,this._frontFace=!1,this._cullFace=!1,this._frontFaceDirty=!1,this._invertFrontFace=!1,this.gl.frontFace(this.gl.CCW),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode="",this.setBlendMode("normal")}_updateCheck(t,e){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static _checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static _checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};cv.extension={type:[T.WebGLSystem],name:"state"};let hv=cv;class dv{constructor(t){this.target=Ml.TEXTURE_2D,this.texture=t,this.width=-1,this.height=-1,this.type=j.UNSIGNED_BYTE,this.internalFormat=qs.RGBA,this.format=qs.RGBA,this.samplerType=0}destroy(){}}const pv={id:"buffer",upload(r,t,e){t.width===r.width||t.height===r.height?e.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,t.format,t.type,r.resource):e.texImage2D(t.target,0,t.internalFormat,r.width,r.height,0,t.format,t.type,r.resource),t.width=r.width,t.height=r.height}},jw={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},fv={id:"compressed",upload(r,t,e){e.pixelStorei(e.UNPACK_ALIGNMENT,4);let i=r.pixelWidth,s=r.pixelHeight;const n=!!jw[r.format];for(let o=0;o<r.resource.length;o++){const a=r.resource[o];n?e.compressedTexImage2D(e.TEXTURE_2D,o,t.internalFormat,i,s,0,a):e.texImage2D(e.TEXTURE_2D,o,t.internalFormat,i,s,0,t.format,t.type,a),i=Math.max(i>>1,1),s=Math.max(s>>1,1)}}},Zl={id:"image",upload(r,t,e,i){const s=t.width,n=t.height,o=r.pixelWidth,a=r.pixelHeight,l=r.resourceWidth,u=r.resourceHeight;l<o||u<a?((s!==o||n!==a)&&e.texImage2D(t.target,0,t.internalFormat,o,a,0,t.format,t.type,null),i===2?e.texSubImage2D(e.TEXTURE_2D,0,0,0,l,u,t.format,t.type,r.resource):e.texSubImage2D(e.TEXTURE_2D,0,0,0,t.format,t.type,r.resource)):s===o&&n===a?e.texSubImage2D(e.TEXTURE_2D,0,0,0,t.format,t.type,r.resource):i===2?e.texImage2D(t.target,0,t.internalFormat,o,a,0,t.format,t.type,r.resource):e.texImage2D(t.target,0,t.internalFormat,t.format,t.type,r.resource),t.width=o,t.height=a}},mv={id:"video",upload(r,t,e,i){if(!r.isValid){e.texImage2D(t.target,0,t.internalFormat,1,1,0,t.format,t.type,null);return}Zl.upload(r,t,e,i)}},Ql={linear:9729,nearest:9728},gv={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},en={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},_v={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function Jl(r,t,e,i,s,n,o,a){const l=n;if(!a||r.addressModeU!=="repeat"||r.addressModeV!=="repeat"||r.addressModeW!=="repeat"){const u=en[o?"clamp-to-edge":r.addressModeU],c=en[o?"clamp-to-edge":r.addressModeV],h=en[o?"clamp-to-edge":r.addressModeW];t[s](l,t.TEXTURE_WRAP_S,u),t[s](l,t.TEXTURE_WRAP_T,c),t.TEXTURE_WRAP_R&&t[s](l,t.TEXTURE_WRAP_R,h)}if((!a||r.magFilter!=="linear")&&t[s](l,t.TEXTURE_MAG_FILTER,Ql[r.magFilter]),e){if(!a||r.mipmapFilter!=="linear"){const u=gv[r.minFilter][r.mipmapFilter];t[s](l,t.TEXTURE_MIN_FILTER,u)}}else t[s](l,t.TEXTURE_MIN_FILTER,Ql[r.minFilter]);if(i&&r.maxAnisotropy>1){const u=Math.min(r.maxAnisotropy,t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[s](l,i.TEXTURE_MAX_ANISOTROPY_EXT,u)}r.compare&&t[s](l,t.TEXTURE_COMPARE_FUNC,_v[r.compare])}function bv(r){return{r8unorm:r.RED,r8snorm:r.RED,r8uint:r.RED,r8sint:r.RED,r16uint:r.RED,r16sint:r.RED,r16float:r.RED,rg8unorm:r.RG,rg8snorm:r.RG,rg8uint:r.RG,rg8sint:r.RG,r32uint:r.RED,r32sint:r.RED,r32float:r.RED,rg16uint:r.RG,rg16sint:r.RG,rg16float:r.RG,rgba8unorm:r.RGBA,"rgba8unorm-srgb":r.RGBA,rgba8snorm:r.RGBA,rgba8uint:r.RGBA,rgba8sint:r.RGBA,bgra8unorm:r.RGBA,"bgra8unorm-srgb":r.RGBA,rgb9e5ufloat:r.RGB,rgb10a2unorm:r.RGBA,rg11b10ufloat:r.RGB,rg32uint:r.RG,rg32sint:r.RG,rg32float:r.RG,rgba16uint:r.RGBA,rgba16sint:r.RGBA,rgba16float:r.RGBA,rgba32uint:r.RGBA,rgba32sint:r.RGBA,rgba32float:r.RGBA,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT,depth24plus:r.DEPTH_COMPONENT,"depth24plus-stencil8":r.DEPTH_STENCIL,depth32float:r.DEPTH_COMPONENT,"depth32float-stencil8":r.DEPTH_STENCIL}}var zw=Object.defineProperty,Vw=Object.defineProperties,Ww=Object.getOwnPropertyDescriptors,vv=Object.getOwnPropertySymbols,Yw=Object.prototype.hasOwnProperty,Kw=Object.prototype.propertyIsEnumerable,yv=(r,t,e)=>t in r?zw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Be=(r,t)=>{for(var e in t||(t={}))Yw.call(t,e)&&yv(r,e,t[e]);if(vv)for(var e of vv(t))Kw.call(t,e)&&yv(r,e,t[e]);return r},qw=(r,t)=>Vw(r,Ww(t));function xv(r,t){let e={},i=r.RGBA;return r instanceof L.get().getWebGLRenderingContext()?t.srgb&&(e={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(e={"rgba8unorm-srgb":r.SRGB8_ALPHA8,"bgra8unorm-srgb":r.SRGB8_ALPHA8},i=r.RGBA8),Be(Be(Be(Be(Be(Be(qw(Be({r8unorm:r.R8,r8snorm:r.R8_SNORM,r8uint:r.R8UI,r8sint:r.R8I,r16uint:r.R16UI,r16sint:r.R16I,r16float:r.R16F,rg8unorm:r.RG8,rg8snorm:r.RG8_SNORM,rg8uint:r.RG8UI,rg8sint:r.RG8I,r32uint:r.R32UI,r32sint:r.R32I,r32float:r.R32F,rg16uint:r.RG16UI,rg16sint:r.RG16I,rg16float:r.RG16F,rgba8unorm:r.RGBA},e),{rgba8snorm:r.RGBA8_SNORM,rgba8uint:r.RGBA8UI,rgba8sint:r.RGBA8I,bgra8unorm:i,rgb9e5ufloat:r.RGB9_E5,rgb10a2unorm:r.RGB10_A2,rg11b10ufloat:r.R11F_G11F_B10F,rg32uint:r.RG32UI,rg32sint:r.RG32I,rg32float:r.RG32F,rgba16uint:r.RGBA16UI,rgba16sint:r.RGBA16I,rgba16float:r.RGBA16F,rgba32uint:r.RGBA32UI,rgba32sint:r.RGBA32I,rgba32float:r.RGBA32F,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT16,depth24plus:r.DEPTH_COMPONENT24,"depth24plus-stencil8":r.DEPTH24_STENCIL8,depth32float:r.DEPTH_COMPONENT32F,"depth32float-stencil8":r.DEPTH32F_STENCIL8}),t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{}),t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{}),t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{}),t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{}),t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{}),t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{})}function Tv(r){return{r8unorm:r.UNSIGNED_BYTE,r8snorm:r.BYTE,r8uint:r.UNSIGNED_BYTE,r8sint:r.BYTE,r16uint:r.UNSIGNED_SHORT,r16sint:r.SHORT,r16float:r.HALF_FLOAT,rg8unorm:r.UNSIGNED_BYTE,rg8snorm:r.BYTE,rg8uint:r.UNSIGNED_BYTE,rg8sint:r.BYTE,r32uint:r.UNSIGNED_INT,r32sint:r.INT,r32float:r.FLOAT,rg16uint:r.UNSIGNED_SHORT,rg16sint:r.SHORT,rg16float:r.HALF_FLOAT,rgba8unorm:r.UNSIGNED_BYTE,"rgba8unorm-srgb":r.UNSIGNED_BYTE,rgba8snorm:r.BYTE,rgba8uint:r.UNSIGNED_BYTE,rgba8sint:r.BYTE,bgra8unorm:r.UNSIGNED_BYTE,"bgra8unorm-srgb":r.UNSIGNED_BYTE,rgb9e5ufloat:r.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:r.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:r.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:r.UNSIGNED_INT,rg32sint:r.INT,rg32float:r.FLOAT,rgba16uint:r.UNSIGNED_SHORT,rgba16sint:r.SHORT,rgba16float:r.HALF_FLOAT,rgba32uint:r.UNSIGNED_INT,rgba32sint:r.INT,rgba32float:r.FLOAT,stencil8:r.UNSIGNED_BYTE,depth16unorm:r.UNSIGNED_SHORT,depth24plus:r.UNSIGNED_INT,"depth24plus-stencil8":r.UNSIGNED_INT_24_8,depth32float:r.FLOAT,"depth32float-stencil8":r.FLOAT_32_UNSIGNED_INT_24_8_REV}}function Zw(r){r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));const t=r.length;for(let e=0;e<t;e+=4){const i=r[e+3];if(i!==0){const s=255.001/i;r[e]=r[e]*s+.5,r[e+1]=r[e+1]*s+.5,r[e+2]=r[e+2]*s+.5}}}const Qw=4;class tu{constructor(t){this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._uploads={image:Zl,buffer:pv,video:mv,compressed:fv},this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._managedTextures=new xt({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"})}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=xv(t,this._renderer.context.extensions),this._mapFormatToType=Tv(t),this._mapFormatToFormat=bv(t)),this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let e=0;e<16;e++)this.bind(w.EMPTY,e)}initSource(t){this.bind(t)}bind(t,e=0){const i=t.source;t?(this.bindSource(i,e),this._useSeparateSamplers&&this._bindSampler(i.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){const i=this._gl;if(t._gcLastUsed=this._renderer.gc.now,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t||(t=w.EMPTY.source);const s=this.getGlSource(t);i.bindTexture(s.target,s.texture)}}_bindSampler(t,e=0){const i=this._gl;if(!t){this._boundSamplers[e]=null,i.bindSampler(e,null);return}const s=this._getGlSampler(t);this._boundSamplers[e]!==s&&(this._boundSamplers[e]=s,i.bindSampler(e,s))}unbind(t){const e=t.source,i=this._boundTextures,s=this._gl;for(let n=0;n<i.length;n++)if(i[n]===e){this._activateLocation(n);const o=this.getGlSource(e);s.bindTexture(o.target,null),i[n]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,i=new dv(e.createTexture());if(i.type=this._mapFormatToType[t.format],i.internalFormat=this._mapFormatToInternalFormat[t.format],i.format=this._mapFormatToFormat[t.format],t.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||t.isPowerOfTwo)){const s=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(s))+1}return t._gpuData[this._renderer.uid]=i,this._managedTextures.add(t)&&(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceUpdate,this),t.on("styleChange",this.onStyleChange,this),t.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(t),this.updateStyle(t,!1),i}onStyleChange(t){this.updateStyle(t,!1)}updateStyle(t,e){const i=this._gl,s=this.getGlSource(t);i.bindTexture(i.TEXTURE_2D,s.texture),this._boundTextures[this._activeTextureLocation]=t,Jl(t.style,i,t.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t,e=!1){const i=t._gpuData[this._renderer.uid];i&&(e||(this.unbind(t),this._gl.deleteTexture(i.texture)),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this))}onSourceUpdate(t){const e=this._gl,i=this.getGlSource(t);e.bindTexture(e.TEXTURE_2D,i.texture),this._boundTextures[this._activeTextureLocation]=t;const s=t.alphaMode==="premultiply-alpha-on-upload";this._premultiplyAlpha!==s&&(this._premultiplyAlpha=s,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s)),this._uploads[t.uploadMethodId]?this._uploads[t.uploadMethodId].upload(t,i,e,this._renderer.context.webGLVersion):e.texImage2D(e.TEXTURE_2D,0,i.internalFormat,t.pixelWidth,t.pixelHeight,0,i.format,i.type,null),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const i=this.getGlSource(t);this._gl.generateMipmap(i.target)}_initSampler(t){const e=this._gl,i=this._gl.createSampler();return this._glSamplers[t._resourceId]=i,Jl(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",i,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:i,height:s}=this.getPixels(t),n=L.get().createCanvas();n.width=i,n.height=s;const o=n.getContext("2d");if(o){const a=o.createImageData(i,s);a.data.set(e),o.putImageData(a,0,0)}return n}getPixels(t){const e=t.source.resolution,i=t.frame,s=Math.max(Math.round(i.width*e),1),n=Math.max(Math.round(i.height*e),1),o=new Uint8Array(Qw*s*n),a=this._renderer,l=a.renderTarget.getRenderTarget(t),u=a.renderTarget.getGpuRenderTarget(l),c=a.gl;return c.bindFramebuffer(c.FRAMEBUFFER,u.resolveTargetFramebuffer),c.readPixels(Math.round(i.x*e),Math.round(i.y*e),s,n,c.RGBA,c.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:s,height:n}}destroy(){this._managedTextures.destroy(),this._glSamplers=null,this._boundTextures=null,this._boundSamplers=null,this._mapFormatToInternalFormat=null,this._mapFormatToType=null,this._mapFormatToFormat=null,this._uploads=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(w.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}tu.extension={type:[T.WebGLSystem],name:"texture"};class eu{contextChange(t){const e=new nt({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new C,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),i=t.limits.maxBatchableTextures,s=qe({name:"graphics",bits:[Wi,Ki(i),vs,Qe]});this.shader=new wt({glProgram:s,resources:{localUniforms:e,batchSamplers:qi(i)}})}execute(t,e){const i=e.context,s=i.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(i);s.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(s),n.geometry.bind(a.geometry,s.glProgram);const u=l.instructions;for(let c=0;c<l.instructionSize;c++){const h=u[c];if(h.size){for(let p=0;p<h.textures.count;p++)n.texture.bind(h.textures.textures[p],p);n.geometry.draw(h.topology,h.size,h.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}eu.extension={type:[T.WebGLPipesAdaptor],name:"graphics"};class ru{init(){const t=qe({name:"mesh",bits:[vs,yb,Qe]});this._shader=new wt({glProgram:t,resources:{uTexture:w.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new C}}}})}execute(t,e){const i=t.renderer;let s=e._shader;if(s){if(!s.glProgram)return}else{s=this._shader;const n=e.texture,o=n.source;s.resources.uTexture=o,s.resources.uSampler=o.style,s.resources.textureUniforms.uniforms.uTextureMatrix=n.textureMatrix.mapCoord}s.groups[100]=i.globalUniforms.bindGroup,s.groups[101]=t.localUniformsBindGroup,i.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}ru.extension={type:[T.WebGLPipesAdaptor],name:"mesh"};class iu{constructor(t){this._renderer=t}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}iu.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"customRender"};function rn(r,t){const e=r.instructionSet,i=e.instructions;for(let s=0;s<e.instructionSize;s++){const n=i[s];t[n.renderPipeId].execute(n)}}const Jw=new C;class su{constructor(t){this._renderer=t}addRenderGroup(t,e){t.isCachedAsTexture?this._addRenderableCacheAsTexture(t,e):this._addRenderableDirect(t,e)}execute(t){t.isRenderable&&(t.isCachedAsTexture?this._executeCacheAsTexture(t):this._executeDirect(t))}destroy(){this._renderer=null}_addRenderableDirect(t,e){this._renderer.renderPipes.batch.break(e),t._batchableRenderGroup&&(st.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){var i;const s=(i=t._batchableRenderGroup)!=null?i:t._batchableRenderGroup=st.get(Nr);s.renderable=t.root,s.transform=t.root.relativeGroupTransform,s.texture=t.texture,s.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.blendMode.pushBlendMode(t,t.root.groupBlendMode,e),this._renderer.renderPipes.batch.addToBatch(s,e),this._renderer.renderPipes.blendMode.popBlendMode(e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;const e=Jw.identity().translate(-t._textureBounds.x,-t._textureBounds.y);this._renderer.renderTarget.push(t.texture,!0,null,t.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:e,worldColor:4294967295,offset:{x:0,y:0}}),rn(t,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}t._batchableRenderGroup._batcher.updateElement(t._batchableRenderGroup),t._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(t){this._renderer.globalUniforms.push({worldTransformMatrix:t.inverseParentTextureTransform,worldColor:t.worldColorAlpha}),rn(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}su.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"renderGroup"};function sn(r,t){t||(t=0);for(let e=t;e<r.length&&r[e];e++)r[e]=null}const tR=new q,Sv=Le|Er|Gi;function nu(r,t=!1){Av(r);const e=r.childrenToUpdate,i=r.updateTick++;for(const s in e){const n=Number(s),o=e[s],a=o.list,l=o.index;for(let u=0;u<l;u++){const c=a[u];c.parentRenderGroup===r&&c.relativeRenderGroupDepth===n&&ou(c,i,0)}sn(a,l),o.index=0}if(t)for(let s=0;s<r.renderGroupChildren.length;s++)nu(r.renderGroupChildren[s],t)}function Av(r){const t=r.root;let e;if(r.renderGroupParent){const i=r.renderGroupParent;r.worldTransform.appendFrom(t.relativeGroupTransform,i.worldTransform),r.worldColor=Ar(t.groupColor,i.worldColor),e=t.groupAlpha*i.worldAlpha}else r.worldTransform.copyFrom(t.localTransform),r.worldColor=t.localColor,e=t.localAlpha;e=e<0?0:e>1?1:e,r.worldAlpha=e,r.worldColorAlpha=r.worldColor+((e*255|0)<<24)}function ou(r,t,e){if(t===r.updateTick)return;r.updateTick=t,r.didChange=!1;const i=r.localTransform;r.updateLocalTransform();const s=r.parent;if(s&&!s.renderGroup?(e|=r._updateFlags,r.relativeGroupTransform.appendFrom(i,s.relativeGroupTransform),e&Sv&&Ev(r,s,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(i),e&Sv&&Ev(r,tR,e)),!r.renderGroup){const n=r.children,o=n.length;for(let u=0;u<o;u++)ou(n[u],t,e);const a=r.parentRenderGroup,l=r;l.renderPipeId&&!a.structureDidChange&&a.updateRenderable(l)}}function Ev(r,t,e){if(e&Er){r.groupColor=Ar(r.localColor,t.groupColor);let i=r.localAlpha*t.groupAlpha;i=i<0?0:i>1?1:i,r.groupAlpha=i,r.groupColorAlpha=r.groupColor+((i*255|0)<<24)}e&Gi&&(r.groupBlendMode=r.localBlendMode==="inherit"?t.groupBlendMode:r.localBlendMode),e&Le&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function Pv(r,t){const{list:e}=r.childrenRenderablesToUpdate;let i=!1;for(let s=0;s<r.childrenRenderablesToUpdate.index;s++){const n=e[s];if(i=t[n.renderPipeId].validateRenderable(n),i)break}return r.structureDidChange=i,i}const eR=new C;class au{constructor(t){this._renderer=t}render({container:t,transform:e}){const i=t.parent,s=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;const n=this._renderer,o=eR;e&&(o.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const a=n.renderPipes;this._updateCachedRenderGroups(t.renderGroup,null),this._updateRenderGroups(t.renderGroup),n.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),rn(t.renderGroup,a),a.uniformBatch&&a.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(o),t.parent=i,t.renderGroup.renderGroupParent=s}destroy(){this._renderer=null}_updateCachedRenderGroups(t,e){var i,s;if(t._parentCacheAsTextureRenderGroup=e,t.isCachedAsTexture){if(!t.textureNeedsUpdate)return;e=t}for(let n=t.renderGroupChildren.length-1;n>=0;n--)this._updateCachedRenderGroups(t.renderGroupChildren[n],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const n=t.root.getLocalBounds();n.ceil();const o=t.texture;t.texture&&et.returnTexture(t.texture,!0);const a=this._renderer,l=t.textureOptions.resolution||a.view.resolution,u=(i=t.textureOptions.antialias)!=null?i:a.view.antialias,c=(s=t.textureOptions.scaleMode)!=null?s:"linear",h=et.getOptimalTexture(n.width,n.height,l,u);h._source.style=new Et({scaleMode:c}),t.texture=h,t._textureBounds||(t._textureBounds=new ot),t._textureBounds.copyFrom(n),o!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(et.returnTexture(t.texture,!0),t.texture=null)}_updateRenderGroups(t){const e=this._renderer,i=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=i,t.structureDidChange?sn(t.childrenRenderablesToUpdate.list,0):Pv(t,i),nu(t),t.structureDidChange?(t.structureDidChange=!1,this._buildInstructions(t,e)):this._updateRenderables(t),t.childrenRenderablesToUpdate.index=0,e.renderPipes.batch.upload(t.instructionSet),!(t.isCachedAsTexture&&!t.textureNeedsUpdate))for(let s=0;s<t.renderGroupChildren.length;s++)this._updateRenderGroups(t.renderGroupChildren[s])}_updateRenderables(t){const{list:e,index:i}=t.childrenRenderablesToUpdate;for(let s=0;s<i;s++){const n=e[s];n.didViewUpdate&&t.updateRenderable(n)}sn(e,i)}_buildInstructions(t,e){const i=t.root,s=t.instructionSet;s.reset();const n=e.renderPipes?e:e.batch.renderer,o=n.renderPipes;o.batch.buildStart(s),o.blendMode.buildStart(),o.colorMask.buildStart(),i.sortableChildren&&i.sortChildren(),i.collectRenderablesWithEffects(s,n,null),o.batch.buildEnd(s),o.blendMode.buildEnd(s)}}au.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"renderGroup"};class lu{constructor(t){this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.bounds=t.visualBounds,e.texture=t._texture}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=new Nr;return e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.bounds=t.visualBounds,e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}lu.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"sprite"};var rR=Object.defineProperty,wv=Object.getOwnPropertySymbols,iR=Object.prototype.hasOwnProperty,sR=Object.prototype.propertyIsEnumerable,Rv=(r,t,e)=>t in r?rR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Cv=(r,t)=>{for(var e in t||(t={}))iR.call(t,e)&&Rv(r,e,t[e]);if(wv)for(var e of wv(t))sR.call(t,e)&&Rv(r,e,t[e]);return r};const uu=class l0{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new H(0),this.color=this._backgroundColor,this.alpha=1}init(t){t=Cv(Cv({},l0.defaultOptions),t),this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};uu.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"background",priority:0},uu.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let Mv=uu;const di={};F.handle(T.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");di[r.name]=r.ref},r=>{delete di[r.name]});class cu{constructor(t){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(t,e,i){this._blendModeStack.push(e),this.setBlendMode(t,e,i)}popBlendMode(t){var e;this._blendModeStack.pop();const i=(e=this._blendModeStack[this._activeBlendMode.length-1])!=null?e:"normal";this.setBlendMode(null,i,t)}setBlendMode(t,e,i){var s;const n=t instanceof Mi;if(this._activeBlendMode===e){this._isAdvanced&&t&&!n&&((s=this._renderableList)==null||s.push(t));return}this._isAdvanced&&this._endAdvancedBlendMode(i),this._activeBlendMode=e,t&&(this._isAdvanced=!!di[e],this._isAdvanced&&this._beginAdvancedBlendMode(t,i))}_beginAdvancedBlendMode(t,e){this._renderer.renderPipes.batch.break(e);const i=this._activeBlendMode;if(!di[i])return;const s=this._ensureFilterEffect(i),n=t instanceof Mi,o={renderPipeId:"filter",action:"pushFilter",filterEffect:s,renderables:n?null:[t],container:n?t.root:null,canBundle:!1};this._renderableList=o.renderables,e.add(o)}_ensureFilterEffect(t){let e=this._filterHash[t];return e||(e=this._filterHash[t]=new Tr,e.filters=[new di[t]]),e}_endAdvancedBlendMode(t){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(t){this._isAdvanced&&this._endAdvancedBlendMode(t)}destroy(){this._renderer=null,this._renderableList=null;for(const t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}}cu.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"blendMode"};var nR=Object.defineProperty,Ov=Object.getOwnPropertySymbols,oR=Object.prototype.hasOwnProperty,aR=Object.prototype.propertyIsEnumerable,Gv=(r,t,e)=>t in r?nR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hu=(r,t)=>{for(var e in t||(t={}))oR.call(t,e)&&Gv(r,e,t[e]);if(Ov)for(var e of Ov(t))aR.call(t,e)&&Gv(r,e,t[e]);return r};const du={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},pu=class u0{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof q||t instanceof w?hu({target:t},e):hu(hu({},e),t)}async image(t){const e=L.get().createImage();return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,u0.defaultImageOptions);const{format:e,quality:i}=t,s=this.canvas(t);if(s.toBlob!==void 0)return new Promise((n,o)=>{s.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>n(l.result),l.onerror=o,l.readAsDataURL(a)},du[e],i)});if(s.toDataURL!==void 0)return s.toDataURL(du[e],i);if(s.convertToBlob!==void 0){const n=await s.convertToBlob({type:du[e],quality:i});return new Promise((o,a)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=a,l.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer;if(e instanceof w)return i.texture.generateCanvas(e);const s=i.textureGenerator.generateTexture(t),n=i.texture.generateCanvas(s);return s.destroy(!0),n}pixels(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer,s=e instanceof w?e:i.textureGenerator.generateTexture(t),n=i.texture.getPixels(s);return e instanceof q&&s.destroy(!0),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof w?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){var e;t=this._normalizeOptions(t);const i=this.canvas(t),s=document.createElement("a");s.download=(e=t.filename)!=null?e:"image.png",s.href=i.toDataURL("image/png"),document.body.appendChild(s),s.click(),document.body.removeChild(s)}log(t){var e;const i=(e=t.width)!=null?e:200;t=this._normalizeOptions(t);const s=this.canvas(t),n=s.toDataURL();console.log(`[Pixi Texture] ${s.width}px ${s.height}px`);const o=["font-size: 1px;",`padding: ${i}px 300px;`,`background: url(${n}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",o)}destroy(){this._renderer=null}};pu.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"extract"},pu.defaultImageOptions={format:"png",quality:1};let Bv=pu;var Iv=Object.getOwnPropertySymbols,lR=Object.prototype.hasOwnProperty,uR=Object.prototype.propertyIsEnumerable,cR=(r,t)=>{var e={};for(var i in r)lR.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Iv)for(var i of Iv(r))t.indexOf(i)<0&&uR.call(r,i)&&(e[i]=r[i]);return e};class nn extends w{static create(t){const e=t,{dynamic:i}=e,s=cR(e,["dynamic"]);return new nn({source:new Q(s),dynamic:i!=null?i:!1})}resize(t,e,i){return this.source.resize(t,e,i),this}}var hR=Object.defineProperty,dR=Object.defineProperties,pR=Object.getOwnPropertyDescriptors,Fv=Object.getOwnPropertySymbols,fR=Object.prototype.hasOwnProperty,mR=Object.prototype.propertyIsEnumerable,Dv=(r,t,e)=>t in r?hR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,gR=(r,t)=>{for(var e in t||(t={}))fR.call(t,e)&&Dv(r,e,t[e]);if(Fv)for(var e of Fv(t))mR.call(t,e)&&Dv(r,e,t[e]);return r},_R=(r,t)=>dR(r,pR(t));const bR=new z,vR=new ot,yR=[0,0,0,0];class fu{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof q&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const i=t.resolution||this._renderer.resolution,s=t.antialias||this._renderer.view.antialias,n=t.target;let o=t.clearColor;o?o=Array.isArray(o)&&o.length===4?o:H.shared.setValue(o).toArray():o=yR;const a=((e=t.frame)==null?void 0:e.copyTo(bR))||wi(n,vR).rectangle;a.width=Math.max(a.width,1/i)|0,a.height=Math.max(a.height,1/i)|0;const l=nn.create(_R(gR({},t.textureSourceOptions),{width:a.width,height:a.height,resolution:i,antialias:s})),u=C.shared.translate(-a.x,-a.y);return this._renderer.render({container:n,transform:u,target:l,clearColor:o}),l.source.updateMipmaps(),l}destroy(){this._renderer=null}}fu.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"textureGenerator"};var xR=Object.defineProperty,Uv=Object.getOwnPropertySymbols,TR=Object.prototype.hasOwnProperty,SR=Object.prototype.propertyIsEnumerable,kv=(r,t,e)=>t in r?xR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$v=(r,t)=>{for(var e in t||(t={}))TR.call(t,e)&&kv(r,e,t[e]);if(Uv)for(var e of Uv(t))SR.call(t,e)&&kv(r,e,t[e]);return r};const mu=class c0{constructor(t){this._managedResources=[],this._managedResourceHashes=[],this._ready=!1,this._renderer=t}init(t){t=$v($v({},c0.defaultOptions),t),this.maxUnusedTime=t.gcMaxUnusedTime,this._frequency=t.gcFrequency,this.enabled=t.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1):(this._renderer.scheduler.cancel(this._handler),this._handler=0))}prerender({container:t}){this.now=performance.now(),t.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}postrender(){!this._ready||!this.enabled||(this.run(),this._ready=!1)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e;for(const i of t.renderGroupChildren)this._updateInstructionGCTick(i,e)}addResource(t,e){var i,s;if(t._gcLastUsed!==-1){t._gcLastUsed=this.now,(i=t._onTouch)==null||i.call(t,this.now);return}const n=this._managedResources.length;t._gcData={index:n,type:e},t._gcLastUsed=this.now,(s=t._onTouch)==null||s.call(t,this.now),t.once("unload",this.removeResource,this),this._managedResources.push(t)}removeResource(t){const e=t._gcData;if(!e)return;const i=e.index,s=this._managedResources.length-1;if(i!==s){const n=this._managedResources[s];this._managedResources[i]=n,n._gcData.index=i}this._managedResources.length--,t._gcData=null,t._gcLastUsed=-1}addResourceHash(t,e,i,s=0){this._managedResourceHashes.push({context:t,hash:e,type:i,priority:s}),this._managedResourceHashes.sort((n,o)=>n.priority-o.priority)}run(){const t=performance.now(),e=this._managedResourceHashes;for(const s of e)this.runOnHash(s,t);let i=0;for(let s=0;s<this._managedResources.length;s++){const n=this._managedResources[s];i=this.runOnResource(n,t,i)}this._managedResources.length=i}updateRenderableGCTick(t,e){var i,s,n,o,a;const l=(i=t.renderGroup)!=null?i:t.parentRenderGroup,u=(n=(s=l==null?void 0:l.instructionSet)==null?void 0:s.gcTick)!=null?n:-1;((o=l==null?void 0:l.gcTick)!=null?o:0)===u&&(t._gcLastUsed=e,(a=t._onTouch)==null||a.call(t,e))}runOnResource(t,e,i){const s=t._gcData;return s.type==="renderable"&&this.updateRenderableGCTick(t,e),e-t._gcLastUsed<this.maxUnusedTime||!t.autoGarbageCollect?(this._managedResources[i]=t,s.index=i,i++):(t.unload(),t._gcData=null,t._gcLastUsed=-1,t.off("unload",this.removeResource,this)),i}_createHashClone(t,e){const i=Object.create(null);for(const s in t){if(s===e)break;t[s]!==null&&(i[s]=t[s])}return i}runOnHash(t,e){var i;const{context:s,hash:n,type:o}=t,a=s[n];let l=null,u=0;for(const c in a){const h=a[c];if(h===null){u++,u===1e4&&!l&&(l=this._createHashClone(a,c));continue}if(h._gcLastUsed===-1){h._gcLastUsed=e,(i=h._onTouch)==null||i.call(h,e),l&&(l[c]=h);continue}o==="renderable"&&this.updateRenderableGCTick(h,e),!(e-h._gcLastUsed<this.maxUnusedTime)&&h.autoGarbageCollect?(l||(u+1!==1e4?(a[c]=null,u++):l=this._createHashClone(a,c)),h.unload(),h._gcData=null,h._gcLastUsed=-1):l&&(l[c]=h)}l&&(s[n]=l)}destroy(){this.enabled=!1,this._managedResources.forEach(t=>{t.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._renderer=null}};mu.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"gc",priority:0},mu.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let Lv=mu;class gu{constructor(t){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=t}reset(){this._stackIndex=0;for(let t=0;t<this._activeUniforms.length;t++)this._uniformsPool.push(this._activeUniforms[t]);for(let t=0;t<this._activeBindGroups.length;t++)this._bindGroupPool.push(this._activeBindGroups[t]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(t){this.reset(),this.push(t)}bind({size:t,projectionMatrix:e,worldTransformMatrix:i,worldColor:s,offset:n}){const o=this._renderer.renderTarget.renderTarget,a=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:o,worldTransformMatrix:new C,worldColor:4294967295,offset:new W},l={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||o.size,worldTransformMatrix:i||a.worldTransformMatrix,worldColor:s||a.worldColor,offset:n||a.offset,bindGroup:null},u=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(u);const c=u.uniforms;c.uProjectionMatrix=l.projectionMatrix,c.uResolution=l.resolution,c.uWorldTransformMatrix.copyFrom(l.worldTransformMatrix),c.uWorldTransformMatrix.tx-=l.offset.x,c.uWorldTransformMatrix.ty-=l.offset.y,rr(l.worldColor,c.uWorldColorAlpha,0),u.update();let h;this._renderer.renderPipes.uniformBatch?h=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(u,!1):(h=this._bindGroupPool.pop()||new Zt,this._activeBindGroups.push(h),h.setResource(u,0)),l.bindGroup=h,this._currentGlobalUniformData=l}push(t){this.bind(t),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===yt.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new nt({uProjectionMatrix:{value:new C,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new C,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}gu.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"globalUniforms"};let AR=1;class _u{constructor(){this._tasks=[],this._offset=0}init(){at.system.add(this._update,this)}repeat(t,e,i=!0){const s=AR++;let n=0;return i&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:s}),s}cancel(t){for(let e=0;e<this._tasks.length;e++)if(this._tasks[e].id===t){this._tasks.splice(e,1);return}}_update(){const t=performance.now();for(let e=0;e<this._tasks.length;e++){const i=this._tasks[e];if(t-i.offset-i.last>=i.duration){const s=t-i.start;i.func(s),i.last=t}}}destroy(){at.system.remove(this._update,this),this._tasks.length=0}}_u.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"scheduler",priority:0};let Nv=!1;function Xv(r){if(!Nv){if(L.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${ei} (${r}) http://www.pixijs.com/
`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${ei} - ${r} - http://www.pixijs.com/`);Nv=!0}}class on{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===yt.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),Xv(e)}}}on.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"hello",priority:-2},on.defaultOptions={hello:!1};function Hv(r){let t=!1;for(const i in r)if(r[i]==null){t=!0;break}if(!t)return r;const e=Object.create(null);for(const i in r){const s=r[i];s&&(e[i]=s)}return e}function jv(r){let t=0;for(let e=0;e<r.length;e++)r[e]==null?t++:r[e-t]=r[e];return r.length-=t,r}var ER=Object.defineProperty,zv=Object.getOwnPropertySymbols,PR=Object.prototype.hasOwnProperty,wR=Object.prototype.propertyIsEnumerable,Vv=(r,t,e)=>t in r?ER(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Wv=(r,t)=>{for(var e in t||(t={}))PR.call(t,e)&&Vv(r,e,t[e]);if(zv)for(var e of zv(t))wR.call(t,e)&&Vv(r,e,t[e]);return r};let RR=0;const bu=class h0{constructor(t){this._managedRenderables=[],this._managedHashes=[],this._managedArrays=[],this._renderer=t}init(t){t=Wv(Wv({},h0.defaultOptions),t),this.maxUnusedTime=t.renderableGCMaxUnusedTime,this._frequency=t.renderableGCFrequency,this.enabled=t.renderableGCActive}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>this.run(),this._frequency,!1),this._hashHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedHashes)e.context[e.hash]=Hv(e.context[e.hash])},this._frequency),this._arrayHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedArrays)jv(e.context[e.hash])},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._hashHandler),this._renderer.scheduler.cancel(this._arrayHandler)))}addManagedHash(t,e){this._managedHashes.push({context:t,hash:e})}addManagedArray(t,e){this._managedArrays.push({context:t,hash:e})}prerender({container:t}){this._now=performance.now(),t.renderGroup.gcTick=RR++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}addRenderable(t){this.enabled&&(t._lastUsed===-1&&(this._managedRenderables.push(t),t.once("destroyed",this._removeRenderable,this)),t._lastUsed=this._now)}run(){var t,e,i,s;const n=this._now,o=this._managedRenderables,a=this._renderer.renderPipes;let l=0;for(let u=0;u<o.length;u++){const c=o[u];if(c===null){l++;continue}const h=(t=c.renderGroup)!=null?t:c.parentRenderGroup,p=(i=(e=h==null?void 0:h.instructionSet)==null?void 0:e.gcTick)!=null?i:-1;if(((s=h==null?void 0:h.gcTick)!=null?s:0)===p&&(c._lastUsed=n),n-c._lastUsed>this.maxUnusedTime){if(!c.destroyed){const f=a;h&&(h.structureDidChange=!0),f[c.renderPipeId].destroyRenderable(c)}c._lastUsed=-1,l++,c.off("destroyed",this._removeRenderable,this)}else o[u-l]=c}o.length-=l}destroy(){this.enabled=!1,this._renderer=null,this._managedRenderables.length=0,this._managedHashes.length=0,this._managedArrays.length=0}_removeRenderable(t){const e=this._managedRenderables.indexOf(t);e>=0&&(t.off("destroyed",this._removeRenderable,this),this._managedRenderables[e]=null)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e;for(const i of t.renderGroupChildren)this._updateInstructionGCTick(i,e)}};bu.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"renderableGC",priority:0},bu.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let Yv=bu;const vu=class Tn{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(t){this._checkCount=t}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(t){this._renderer.gc.maxUnusedTime=t/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(t){}get active(){return this._renderer.gc.enabled}set active(t){this._renderer.gc.enabled=t}constructor(t){this._renderer=t,this._checkCount=0}init(t){t.textureGCActive!==Tn.defaultOptions.textureGCActive&&(this.active=t.textureGCActive),t.textureGCMaxIdle!==Tn.defaultOptions.textureGCMaxIdle&&(this.maxIdle=t.textureGCMaxIdle),t.textureGCCheckCountMax!==Tn.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=t.textureGCCheckCountMax)}run(){this._renderer.gc.run()}destroy(){this._renderer=null}};vu.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"textureGC"},vu.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Kv=vu;var CR=Object.defineProperty,qv=Object.getOwnPropertySymbols,MR=Object.prototype.hasOwnProperty,OR=Object.prototype.propertyIsEnumerable,Zv=(r,t,e)=>t in r?CR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qv=(r,t)=>{for(var e in t||(t={}))MR.call(t,e)&&Zv(r,e,t[e]);if(qv)for(var e of qv(t))OR.call(t,e)&&Zv(r,e,t[e]);return r};const yu=class d0{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(t){this.texture.source.autoDensity=t}get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}init(t){t=Qv(Qv({},d0.defaultOptions),t),t.view&&(t.canvas=t.view),this.screen=new z(0,0,t.width,t.height),this.canvas=t.canvas||L.get().createCanvas(),this.antialias=!!t.antialias,this.texture=Xl(this.canvas,t),this.renderTarget=new Zs({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.resolution=t.resolution}resize(t,e,i){this.texture.source.resize(t,e,i),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){(typeof t=="boolean"?t:t!=null&&t.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};yu.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"view",priority:0},yu.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let Jv=yu;const xu=[Mv,gu,on,Jv,au,Lv,Kv,fu,Bv,Xa,Yv,_u],Tu=[cu,Sl,lu,su,Al,Pl,El,iu],GR=[...xu,Nl,Bb,Eb,Fl,wl,tu,jl,Ol,ql,Kl,Il,hv,Dl,Bl],BR=[...Tu],IR=[yl,ru,eu],ty=[],ey=[],ry=[];F.handleByNamedList(T.WebGLSystem,ty),F.handleByNamedList(T.WebGLPipes,ey),F.handleByNamedList(T.WebGLPipesAdaptor,ry),F.add(...GR,...BR,...IR);class iy extends Zr{constructor(){const t={name:"webgl",type:yt.WEBGL,systems:ty,renderPipes:ey,renderPipeAdaptors:ry};super(t)}}var FR={__proto__:null,WebGLRenderer:iy};class Su{constructor(t){this._hash=Object.create(null),this._renderer=t}contextChange(t){this._gpu=t}getBindGroup(t,e,i){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,i)}_createBindGroup(t,e,i){var s;const n=this._gpu.device,o=e.layout[i],a=[],l=this._renderer;for(const h in o){const p=(s=t.resources[h])!=null?s:t.resources[o[h]];let f;if(p._resourceType==="uniformGroup"){const m=p;l.ubo.updateUniformGroup(m);const _=m.buffer;f={buffer:l.buffer.getGPUBuffer(_),offset:0,size:_.descriptor.size}}else if(p._resourceType==="buffer"){const m=p;f={buffer:l.buffer.getGPUBuffer(m),offset:0,size:m.descriptor.size}}else if(p._resourceType==="bufferResource"){const m=p;f={buffer:l.buffer.getGPUBuffer(m.buffer),offset:m.offset,size:m.size}}else if(p._resourceType==="textureSampler"){const m=p;f=l.texture.getGpuSampler(m)}else if(p._resourceType==="textureSource"){const m=p;f=l.texture.getGpuSource(m).createView()}a.push({binding:o[h],resource:f})}const u=l.shader.getProgramData(e).bindGroups[i],c=n.createBindGroup({layout:u,entries:a});return this._hash[t._key]=c,c}destroy(){this._hash=null,this._renderer=null}}Su.extension={type:[T.WebGPUSystem],name:"bindGroup"};class sy{constructor(t){this.gpuBuffer=t}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class Au{constructor(t){this._renderer=t,this._managedBuffers=new xt({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(t){this._gpu=t}getGPUBuffer(t){var e;return t._gcLastUsed=this._renderer.gc.now,((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuBuffer)||this.createGPUBuffer(t)}updateBuffer(t){const e=this.getGPUBuffer(t),i=t.data;return t._updateID&&i&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,i.buffer,0,(t._updateSize||i.byteLength)+3&-4)),e}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(t){t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this)}createGPUBuffer(t){const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t._resourceId=Y("resource"),t.data&&(Xi(t.data.buffer,e.getMappedRange()),e.unmap()),t._gpuData[this._renderer.uid]=new sy(e),this._managedBuffers.add(t)&&(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this)),e}onBufferChange(t){this._managedBuffers.remove(t),t._updateID=0,this.createGPUBuffer(t)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}Au.extension={type:[T.WebGPUSystem],name:"buffer"};class ny{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${t*4}`);const e=this.byteIndex;let i=e+t*4;if(i=Math.ceil(i/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,i>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=i,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let i=0;i<t.length;i++)this.data[e/4+i]=t[i];return e}destroy(){this.data=null}}class Eu{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.pipeline.setColorMask(t))}destroy(){this._renderer=null,this._colorMaskCache=null}}Eu.extension={type:[T.WebGPUSystem],name:"colorMask"};class an{constructor(t){this._renderer=t}async init(t){return this._initPromise?this._initPromise:(this._initPromise=(t.gpu?Promise.resolve(t.gpu):this._createDeviceAndAdaptor(t)).then(e=>{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await L.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),i=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>e.features.has(n)),s=await e.requestDevice({requiredFeatures:i});return{adapter:e,device:s}}destroy(){this.gpu=null,this._renderer=null}}an.extension={type:[T.WebGPUSystem],name:"device"},an.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var DR=Object.defineProperty,oy=Object.getOwnPropertySymbols,UR=Object.prototype.hasOwnProperty,kR=Object.prototype.propertyIsEnumerable,ay=(r,t,e)=>t in r?DR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ly=(r,t)=>{for(var e in t||(t={}))UR.call(t,e)&&ay(r,e,t[e]);if(oy)for(var e of oy(t))kR.call(t,e)&&ay(r,e,t[e]);return r};class Pu{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(t.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(t){this.renderPassEncoder.setViewport(t.x,t.y,t.width,t.height,0,1)}setPipelineFromGeometryProgramAndState(t,e,i,s){const n=this._renderer.pipeline.getPipeline(t,e,i,s);this.setPipeline(n)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=t.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,i){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.gc.now,this._renderer.tick);const s=this._renderer.bindGroup.getBindGroup(e,i,t);this.renderPassEncoder.setBindGroup(t,s)}setGeometry(t,e){const i=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const s in i)this._setVertexBuffer(parseInt(s,10),t.attributes[i[s]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const i in t.groups){const s=t.groups[i];e||this._syncBindGroup(s),this.setBindGroup(i,s,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const i=t.resources[e];i.isUniformGroup&&this._renderer.ubo.updateUniformGroup(i)}}draw(t){const{geometry:e,shader:i,state:s,topology:n,size:o,start:a,instanceCount:l,skipSync:u}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,s,n),this.setGeometry(e,i.gpuProgram),this._setShaderBindGroups(i,u),e.indexBuffer?this.renderPassEncoder.drawIndexed(o||e.indexBuffer.data.length,l!=null?l:e.instanceCount,a||0):this.renderPassEncoder.draw(o||e.getSize(),l!=null?l:e.instanceCount,a||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,i=ly({},this._boundVertexBuffer),s=this._boundIndexBuffer,n=ly({},this._boundBindGroup);this._clearCache();const o=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(o.x,o.y,o.width,o.height,0,1),this.setPipeline(e);for(const a in i)this._setVertexBuffer(a,i[a]);for(const a in n)this.setBindGroup(a,n[a],null);this._setIndexBuffer(s)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}}Pu.extension={type:[T.WebGPUSystem],name:"encoder",priority:1};class wu{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}wu.extension={type:[T.WebGPUSystem],name:"limits"};class Ru{constructor(t){this._renderTargetStencilState=Object.create(null),this._renderer=t,t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:rt.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid];i.stencilMode=t,i.stencilReference=e;const s=this._renderer;s.pipeline.setStencilMode(t),s.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}Ru.extension={type:[T.WebGPUSystem],name:"stencil"};const pi={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function uy(r){const t=r.map(i=>({data:i,offset:0,size:0}));let e=0;for(let i=0;i<t.length;i++){const s=t[i];let n=pi[s.data.type].size;const o=pi[s.data.type].align;if(!pi[s.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(n=Math.max(n,o)*s.data.size),e=Math.ceil(e/o)*o,s.size=n,s.offset=e,e+=n}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function cy(r,t){const{size:e,align:i}=pi[r.data.type],s=(i-e)/4,n=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
v = uv.${r.data.name};
${t!==0?`offset += ${t};`:""}
arrayOffset = offset;
t = 0;
for(var i=0; i < ${r.data.size*(e/4)}; i++)
{
for(var j = 0; j < ${e/4}; j++)
{
${n}[arrayOffset++] = v[t++];
}
${s!==0?`arrayOffset += ${s};`:""}
}
`}function hy(r){return $l(r,"uboWgsl",cy,kb)}class Cu extends Ul{constructor(){super({createUboElements:uy,generateUboSync:hy})}}Cu.extension={type:[T.WebGPUSystem],name:"ubo"};const fe=128;class Mu{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._batchBuffer=new ny({minUniformOffsetAlignment:fe});const e=256/fe;for(let i=0;i<e;i++){let s=X.UNIFORM|X.COPY_DST;i===0&&(s|=X.COPY_SRC),this._buffers.push(new bt({data:this._batchBuffer.data,usage:s}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){this._bindGroupHash=Object.create(null),this._batchBuffer.clear()}getUniformBindGroup(t,e){if(!e&&this._bindGroupHash[t.uid])return this._bindGroupHash[t.uid];this._renderer.ubo.ensureUniformGroup(t);const i=t.buffer.data,s=this._batchBuffer.addEmptyGroup(i.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,s/4),this._bindGroupHash[t.uid]=this._getBindGroup(s/fe),this._bindGroupHash[t.uid]}getUboResource(t){this._renderer.ubo.updateUniformGroup(t);const e=t.buffer.data,i=this._batchBuffer.addGroup(e);return this._getBufferResource(i/fe)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/fe)}getArrayBufferResource(t){const e=this._batchBuffer.addGroup(t)/fe;return this._getBufferResource(e)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new Qs({buffer:e,offset:(t/2|0)*256,size:fe})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new Zt({0:this._getBufferResource(t)});this._bindGroups[t]=e}return this._bindGroups[t]}_uploadBindGroups(){const t=this._renderer.buffer,e=this._buffers[0];e.update(this._batchBuffer.byteIndex),t.updateBuffer(e);const i=this._renderer.gpu.device.createCommandEncoder();for(let s=1;s<this._buffers.length;s++){const n=this._buffers[s];i.copyBufferToBuffer(t.getGPUBuffer(e),fe,t.getGPUBuffer(n),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([i.finish()])}destroy(){var t;for(let e=0;e<this._bindGroups.length;e++)(t=this._bindGroups[e])==null||t.destroy();this._bindGroups=null,this._bindGroupHash=null;for(let e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers=null;for(let e=0;e<this._bufferResources.length;e++)this._bufferResources[e].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._renderer=null}}Mu.extension={type:[T.WebGPUPipes],name:"uniformBatch"};var $R=Object.defineProperty,LR=Object.defineProperties,NR=Object.getOwnPropertyDescriptors,dy=Object.getOwnPropertySymbols,XR=Object.prototype.hasOwnProperty,HR=Object.prototype.propertyIsEnumerable,py=(r,t,e)=>t in r?$R(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jR=(r,t)=>{for(var e in t||(t={}))XR.call(t,e)&&py(r,e,t[e]);if(dy)for(var e of dy(t))HR.call(t,e)&&py(r,e,t[e]);return r},zR=(r,t)=>LR(r,NR(t));const VR={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function WR(r,t,e,i,s){return r<<24|t<<16|e<<10|i<<5|s}function YR(r,t,e,i,s){return e<<8|r<<5|i<<3|s<<1|t}class Ou{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._colorTargetCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(rt.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._colorTargetCount=t.colorTargetCount,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=oe[t],this._updatePipeHash())}setPipeline(t,e,i,s){const n=this.getPipeline(t,e,i);s.setPipeline(n)}getPipeline(t,e,i,s){t._layoutKey||(Cl(t,e.attributeData),this._generateBufferKey(t)),s||(s=t.topology);const n=WR(t._layoutKey,e._layoutKey,i.data,i._blendModeId,VR[s]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(t,e,i,s),this._pipeCache[n])}_createPipeline(t,e,i,s){const n=this._gpu.device,o=this._createVertexBufferLayouts(t,e),a=this._renderer.state.getColorTargets(i,this._colorTargetCount),l=this._stencilMode===rt.RENDERING_MASK_ADD?0:this._colorMask;for(let h=0;h<a.length;h++)a[h].writeMask=l;const u=this._renderer.shader.getProgramData(e).pipeline,c={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:o},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:a},primitive:{topology:s,cullMode:i.cullMode},layout:u,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(c.depthStencil=zR(jR({},this._stencilState),{format:"depth24plus-stencil8",depthWriteEnabled:i.depthTest,depthCompare:i.depthTest?"less":"always"})),n.createRenderPipeline(c)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){const e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){const e=[];let i=0;const s=Object.keys(t.attributes).sort();for(let o=0;o<s.length;o++){const a=t.attributes[s[o]];e[i++]=a.offset,e[i++]=a.format,e[i++]=a.stride,e[i++]=a.instance}const n=e.join("|");return t._layoutKey=We(n,"geometry"),t._layoutKey}_generateAttributeLocationsKey(t){const e=[];let i=0;const s=Object.keys(t.attributeData).sort();for(let o=0;o<s.length;o++){const a=t.attributeData[s[o]];e[i++]=a.location}const n=e.join("|");return t._attributeLocationsKey=We(n,"programAttributes"),t._attributeLocationsKey}getBufferNamesToBind(t,e){const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bindingNamesCache[i])return this._bindingNamesCache[i];const s=this._createVertexBufferLayouts(t,e),n=Object.create(null),o=e.attributeData;for(let a=0;a<s.length;a++){const l=Object.values(s[a].attributes)[0].shaderLocation;for(const u in o)if(o[u].location===l){n[a]=u;break}}return this._bindingNamesCache[i]=n,n}_createVertexBufferLayouts(t,e){e._attributeLocationsKey||this._generateAttributeLocationsKey(e);const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bufferLayoutsCache[i])return this._bufferLayoutsCache[i];const s=[];return t.buffers.forEach(n=>{var o;const a={arrayStride:0,stepMode:"vertex",attributes:[]},l=a.attributes;for(const u in e.attributeData){const c=t.attributes[u];((o=c.divisor)!=null?o:1)!==1&&Xt(`Attribute ${u} has an invalid divisor value of '${c.divisor}'. WebGPU only supports a divisor value of 1`),c.buffer===n&&(a.arrayStride=c.stride,a.stepMode=c.instance?"instance":"vertex",l.push({shaderLocation:e.attributeData[u].location,offset:c.offset,format:c.format}))}l.length&&s.push(a)}),this._bufferLayoutsCache[i]=s,s}_updatePipeHash(){const t=YR(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment,this._colorTargetCount);this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}Ou.extension={type:[T.WebGPUSystem],name:"pipeline"};class fy{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class my{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,s,n){const o=this._renderer,a=this._getGpuColorTexture(t),l=o.texture.getGpuSource(e.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:i},{texture:l,origin:n},s),e}startRenderPass(t,e=!0,i,s){const n=this._renderTargetSystem.getGpuRenderTarget(t),o=this.getDescriptor(t,e,i);n.descriptor=o,this._renderer.pipeline.setRenderTarget(n),this._renderer.encoder.beginRenderPass(n),this._renderer.encoder.setViewport(s)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,i){typeof e=="boolean"&&(e=e?Tt.ALL:Tt.NONE);const s=this._renderTargetSystem,n=s.getGpuRenderTarget(t),o=t.colorTextures.map((l,u)=>{const c=n.contexts[u];let h,p;c?h=c.getCurrentTexture().createView():h=this._renderer.texture.getGpuSource(l).createView({mipLevelCount:1}),n.msaaTextures[u]&&(p=h,h=this._renderer.texture.getTextureView(n.msaaTextures[u]));const f=e&Tt.COLOR?"clear":"load";return i!=null||(i=s.defaultClearColor),{view:h,resolveTarget:p,clearValue:i,storeOp:"store",loadOp:f}});let a;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=n.msaa?4:1),t.depthStencilTexture){const l=e&Tt.STENCIL?"clear":"load",u=e&Tt.DEPTH?"clear":"load";a={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:l,depthClearValue:1,depthLoadOp:u,depthStoreOp:"store"}}return{colorAttachments:o,depthStencilAttachment:a}}clear(t,e=!0,i,s){if(!e)return;const{gpu:n,encoder:o}=this._renderer,a=n.device;if(o.commandEncoder===null){const l=a.createCommandEncoder(),u=this.getDescriptor(t,e,i),c=l.beginRenderPass(u);c.setViewport(s.x,s.y,s.width,s.height,0,1),c.end();const h=l.finish();a.queue.submit([h])}else this.startRenderPass(t,e,i,s)}initGpuRenderTarget(t){t.isRoot=!0;const e=new fy;return e.colorTargetCount=t.colorTextures.length,t.colorTextures.forEach((i,s)=>{if(i instanceof qt){const n=i.resource.getContext("webgpu"),o=i.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:o})}catch(a){console.error(a)}e.contexts[s]=n}if(e.msaa=i.source.antialias,i.source.antialias){const n=new Q({width:0,height:0,sampleCount:4});e.msaaTextures[s]=n}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(e=>{e.unconfigure()}),t.msaaTextures.forEach(e=>{e.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((i,s)=>{const n=e.msaaTextures[s];n==null||n.resize(i.source.width,i.source.height,i.source._resolution)})}}class Gu extends Hl{constructor(t){super(t),this.adaptor=new my,this.adaptor.init(t,this)}}Gu.extension={type:[T.WebGPUSystem],name:"renderTarget"};class Bu{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,i=t.gpuLayout.map(n=>e.createBindGroupLayout({entries:n})),s={bindGroupLayouts:i};return this._gpuProgramData[t._layoutKey]={bindGroups:i,pipeline:e.createPipelineLayout(s)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}Bu.extension={type:[T.WebGPUSystem],name:"shader"};const ft={};ft.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},ft.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},ft.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},ft.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},ft.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},ft.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},ft["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},ft["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},ft["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},ft.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},ft.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},ft.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class Iu{constructor(){this.defaultState=new Rt,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t,e){const i=ft[t.blendMode]||ft.normal,s=[],n={format:"bgra8unorm",writeMask:0,blend:i};for(let o=0;o<e;o++)s[o]=n;return s}destroy(){this.gpu=null}}Iu.extension={type:[T.WebGPUSystem],name:"state"};const gy={type:"image",upload(r,t,e){const i=r.resource,s=(r.pixelWidth|0)*(r.pixelHeight|0),n=i.byteLength/s;e.device.queue.writeTexture({texture:t},i,{offset:0,rowsPerImage:r.pixelHeight,bytesPerRow:r.pixelWidth*n},{width:r.pixelWidth,height:r.pixelHeight,depthOrArrayLayers:1})}},Fu={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},KR={blockBytes:4,blockWidth:1,blockHeight:1},_y={type:"compressed",upload(r,t,e){let i=r.pixelWidth,s=r.pixelHeight;const n=Fu[r.format]||KR;for(let o=0;o<r.resource.length;o++){const a=r.resource[o],l=Math.ceil(i/n.blockWidth)*n.blockBytes;e.device.queue.writeTexture({texture:t,mipLevel:o},a,{offset:0,bytesPerRow:l},{width:Math.ceil(i/n.blockWidth)*n.blockWidth,height:Math.ceil(s/n.blockHeight)*n.blockHeight,depthOrArrayLayers:1}),i=Math.max(i>>1,1),s=Math.max(s>>1,1)}}},Du={type:"image",upload(r,t,e){const i=r.resource;if(!i)return;if(globalThis.HTMLImageElement&&i instanceof HTMLImageElement){const a=L.get().createCanvas(i.width,i.height);a.getContext("2d").drawImage(i,0,0,i.width,i.height),r.resource=a}const s=Math.min(t.width,r.resourceWidth||r.pixelWidth),n=Math.min(t.height,r.resourceHeight||r.pixelHeight),o=r.alphaMode==="premultiply-alpha-on-upload";e.device.queue.copyExternalImageToTexture({source:i},{texture:t,premultipliedAlpha:o},{width:s,height:n})}},by={type:"video",upload(r,t,e){Du.upload(r,t,e)}};class vy{constructor(t){this.device=t,this.sampler=t.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(t){let e=this.pipelines[t];return e||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:`
var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
struct VertexOutput {
@builtin(position) position : vec4<f32>,
@location(0) texCoord : vec2<f32>,
};
@vertex
fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
var output : VertexOutput;
output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
return output;
}
@group(0) @binding(0) var imgSampler : sampler;
@group(0) @binding(1) var img : texture_2d<f32>;
@fragment
fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
return textureSample(img, imgSampler, texCoord);
}
`})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){const e=this._getMipmapPipeline(t.format);if(t.dimension==="3d"||t.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let i=t;const s=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){const l={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:s},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};i=this.device.createTexture(l)}const o=this.device.createCommandEncoder({}),a=e.getBindGroupLayout(0);for(let l=0;l<s;++l){let u=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,arrayLayerCount:1}),c=n?1:0;for(let h=1;h<t.mipLevelCount;++h){const p=i.createView({baseMipLevel:c++,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,arrayLayerCount:1}),f=o.beginRenderPass({colorAttachments:[{view:p,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),m=this.device.createBindGroup({layout:a,entries:[{binding:0,resource:this.sampler},{binding:1,resource:u}]});f.setPipeline(e),f.setBindGroup(0,m),f.draw(3,1,0,0),f.end(),u=p}}if(!n){const l={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:s};for(let u=1;u<t.mipLevelCount;++u)o.copyTextureToTexture({texture:i,mipLevel:u-1},{texture:t,mipLevel:u},l),l.width=Math.ceil(l.width/2),l.height=Math.ceil(l.height/2)}return this.device.queue.submit([o.finish()]),n||i.destroy(),t}}class yy{constructor(t){this.textureView=null,this.gpuTexture=t}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}}class Uu{constructor(t){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._uploads={image:Du,buffer:gy,video:by,compressed:_y},this._renderer=t,t.renderableGC.addManagedHash(this,"_bindGroupHash"),this._managedTextures=new xt({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"gpuTextureSource"})}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gpu=t}initSource(t){var e;return((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuTexture)||this._initSource(t)}_initSource(t){if(t.autoGenerateMipmaps){const l=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(l))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;t.uploadMethodId!=="compressed"&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const i=Fu[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},s=Math.ceil(t.pixelWidth/i.blockWidth)*i.blockWidth,n=Math.ceil(t.pixelHeight/i.blockHeight)*i.blockHeight,o={label:t.label,size:{width:s,height:n},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},a=this._gpu.device.createTexture(o);return t._gpuData[this._renderer.uid]=new yy(a),this._managedTextures.add(t)&&(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(t),a}onSourceUpdate(t){const e=this.getGpuSource(t);e&&(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t))}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new vy(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceUnload(t){t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this)}onSourceResize(t){t._gcLastUsed=this._renderer.gc.now;const e=t._gpuData[this._renderer.uid],i=e==null?void 0:e.gpuTexture;i?(i.width!==t.pixelWidth||i.height!==t.pixelHeight)&&(e.destroy(),this._bindGroupHash[t.uid]=null,t._gpuData[this._renderer.uid]=null,this.initSource(t)):this.initSource(t)}_initSampler(t){return this._gpuSamplers[t._resourceId]=this._gpu.device.createSampler(t),this._gpuSamplers[t._resourceId]}getGpuSampler(t){return this._gpuSamplers[t._resourceId]||this._initSampler(t)}getGpuSource(t){var e;return t._gcLastUsed=this._renderer.gc.now,((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuTexture)||this.initSource(t)}getTextureBindGroup(t){return this._bindGroupHash[t.uid]||this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source;return this._bindGroupHash[t.uid]=new Zt({0:e,1:e.style,2:new nt({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){const e=t.source;e._gcLastUsed=this._renderer.gc.now;let i=e._gpuData[this._renderer.uid],s=null;return i||(this.initSource(e),i=e._gpuData[this._renderer.uid]),s=i.textureView||i.gpuTexture.createView(),s}generateCanvas(t){const e=this._renderer,i=e.gpu.device.createCommandEncoder(),s=L.get().createCanvas();s.width=t.source.pixelWidth,s.height=t.source.pixelHeight;const n=s.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:L.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:s.width,height:s.height}),e.gpu.device.queue.submit([i.finish()]),s}getPixels(t){const e=this.generateCanvas(t),i=Jt.getOptimalCanvasAndContext(e.width,e.height),s=i.context;s.drawImage(e,0,0);const{width:n,height:o}=e,a=s.getImageData(0,0,n,o),l=new Uint8ClampedArray(a.data.buffer);return Jt.returnCanvasAndContext(i),{pixels:l,width:n,height:o}}destroy(){this._managedTextures.destroy();for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),i=this._bindGroupHash[e];i==null||i.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}}Uu.extension={type:[T.WebGPUSystem],name:"texture"};class ku{constructor(){this._maxTextures=0}contextChange(t){const e=new nt({uTransformMatrix:{value:new C,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;const i=Ke({name:"graphics",bits:[Vi,Yi(this._maxTextures),dm,Ze]});this.shader=new wt({gpuProgram:i,resources:{localUniforms:e}})}execute(t,e){const i=e.context,s=i.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(i),u=n.encoder;u.setGeometry(a.geometry,s.gpuProgram);const c=n.globalUniforms.bindGroup;u.setBindGroup(0,c,s.gpuProgram);const h=n.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms,!0);u.setBindGroup(2,h,s.gpuProgram);const p=l.instructions;let f=null;for(let m=0;m<l.instructionSize;m++){const _=p[m];if(_.topology!==f&&(f=_.topology,u.setPipelineFromGeometryProgramAndState(a.geometry,s.gpuProgram,t.state,_.topology)),s.groups[1]=_.bindGroup,!_.gpuBindGroup){const g=_.textures;_.bindGroup=Ni(g.textures,g.count,this._maxTextures),_.gpuBindGroup=n.bindGroup.getBindGroup(_.bindGroup,s.gpuProgram,1)}u.setBindGroup(1,_.bindGroup,s.gpuProgram),u.renderPassEncoder.drawIndexed(_.size,1,_.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}ku.extension={type:[T.WebGPUPipesAdaptor],name:"graphics"};class $u{init(){const t=Ke({name:"mesh",bits:[ur,vb,Ze]});this._shader=new wt({gpuProgram:t,resources:{uTexture:w.EMPTY._source,uSampler:w.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new C}}}})}execute(t,e){const i=t.renderer;let s=e._shader;if(!s)s=this._shader,s.groups[2]=i.texture.getTextureBindGroup(e.texture);else if(!s.gpuProgram)return;const n=s.gpuProgram;if(n.autoAssignGlobalUniforms&&(s.groups[0]=i.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const o=t.localUniforms;s.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}i.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}$u.extension={type:[T.WebGPUPipesAdaptor],name:"mesh"};const qR=[...xu,Cu,Pu,an,wu,Au,Uu,Gu,Bu,Iu,Ou,Eu,Ru,Su],ZR=[...Tu,Mu],QR=[xl,$u,ku],xy=[],Ty=[],Sy=[];F.handleByNamedList(T.WebGPUSystem,xy),F.handleByNamedList(T.WebGPUPipes,Ty),F.handleByNamedList(T.WebGPUPipesAdaptor,Sy),F.add(...qR,...ZR,...QR);class Ay extends Zr{constructor(){const t={name:"webgpu",type:yt.WEBGPU,systems:xy,renderPipes:Ty,renderPipeAdaptors:Sy};super(t)}}var JR={__proto__:null,WebGPURenderer:Ay};const tC={POINTS:"point-list",LINES:"line-list",LINE_STRIP:"line-strip",TRIANGLES:"triangle-list",TRIANGLE_STRIP:"triangle-strip"},eC=new Proxy(tC,{get(r,t){return r[t]}});var Lu=(r=>(r.CLAMP="clamp-to-edge",r.REPEAT="repeat",r.MIRRORED_REPEAT="mirror-repeat",r))(Lu||{});const rC=new Proxy(Lu,{get(r,t){return r[t]}});var Nu=(r=>(r.NEAREST="nearest",r.LINEAR="linear",r))(Nu||{});const iC=new Proxy(Nu,{get(r,t){return r[t]}});class sC{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const s=e.width,n=e.height;if(i){const o=t.width/2/s,a=t.height/2/n,l=t.x/s+o,u=t.y/n+a;i=N.add(i,N.NW),this.x0=l+o*N.uX(i),this.y0=u+a*N.uY(i),i=N.add(i,2),this.x1=l+o*N.uX(i),this.y1=u+a*N.uY(i),i=N.add(i,2),this.x2=l+o*N.uX(i),this.y2=u+a*N.uY(i),i=N.add(i,2),this.x3=l+o*N.uX(i),this.y3=u+a*N.uY(i)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}function nC(r){const t=r.toString(),e=t.indexOf("{"),i=t.lastIndexOf("}");if(e===-1||i===-1)throw new Error("getFunctionBody: No body found in function definition");return t.slice(e+1,i).trim()}function oC(r,t){return r.getFastGlobalBounds(!0,t)}var aC=Object.defineProperty,ln=Object.getOwnPropertySymbols,Ey=Object.prototype.hasOwnProperty,Py=Object.prototype.propertyIsEnumerable,wy=(r,t,e)=>t in r?aC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,lC=(r,t)=>{for(var e in t||(t={}))Ey.call(t,e)&&wy(r,e,t[e]);if(ln)for(var e of ln(t))Py.call(t,e)&&wy(r,e,t[e]);return r},uC=(r,t)=>{var e={};for(var i in r)Ey.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ln)for(var i of ln(r))t.indexOf(i)<0&&Py.call(r,i)&&(e[i]=r[i]);return e};class cC extends Kt{constructor(t){var e,i;typeof t=="function"&&(t={render:t});const s=t,{render:n}=s,o=uC(s,["render"]);super(lC({label:"RenderContainer"},o)),this.renderPipeId="customRender",this.batched=!1,n&&(this.render=n),this.containsPoint=(e=t.containsPoint)!=null?e:()=>!1,this.addBounds=(i=t.addBounds)!=null?i:()=>!1}updateBounds(){this._bounds.clear(),this.addBounds(this._bounds)}render(t){}}function hC(r,t,e){const i=e.renderPipes?e:e.batch.renderer;return r.collectRenderables(t,i,null)}function dC(r,t){const e=t._scale,i=t._pivot,s=t._position,n=e._x,o=e._y,a=i._x,l=i._y;r.a=t._cx*n,r.b=t._sx*n,r.c=t._cy*o,r.d=t._sy*o,r.tx=s._x-(a*r.a+l*r.c),r.ty=s._y-(a*r.b+l*r.d)}function pC(r,t,e){const i=r.a,s=r.b,n=r.c,o=r.d,a=r.tx,l=r.ty,u=t.a,c=t.b,h=t.c,p=t.d;e.a=i*u+s*h,e.b=i*c+s*p,e.c=n*u+o*h,e.d=n*c+o*p,e.tx=a*u+l*h+t.tx,e.ty=a*c+l*p+t.ty}function fC(r){r instanceof Nt&&(r={path:r,textureMatrix:null,out:null});const t=[],e=[],i=[],s=r.path.shapePath,n=r.textureMatrix;s.shapePrimitives.forEach(({shape:a,transform:l})=>{const u=i.length,c=t.length/2,h=[],p=er[a.type];p.build(a,h),l&&Ji(h,l),p.triangulate(h,t,2,c,i,u);const f=e.length/2;n?(l&&n.append(l.clone().invert()),Eo(t,2,c,e,f,2,t.length/2-c,n)):Po(e,f,2,t.length/2-c)});const o=r.out;return o?(o.positions=new Float32Array(t),o.uvs=new Float32Array(e),o.indices=new Uint32Array(i),o):new ce({positions:new Float32Array(t),uvs:new Float32Array(e),indices:new Uint32Array(i)})}var mC=Object.defineProperty,Ry=Object.getOwnPropertySymbols,gC=Object.prototype.hasOwnProperty,_C=Object.prototype.propertyIsEnumerable,Cy=(r,t,e)=>t in r?mC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,My=(r,t)=>{for(var e in t||(t={}))gC.call(t,e)&&Cy(r,e,t[e]);if(Ry)for(var e of Ry(t))_C.call(t,e)&&Cy(r,e,t[e]);return r};const Oy=class p0 extends q{constructor(t={}){t=My(My({},p0.defaultOptions),t),super(),this.renderLayerChildren=[],this.sortableChildren=t.sortableChildren,this.sortFunction=t.sortFunction}attach(...t){for(let e=0;e<t.length;e++){const i=t[e];if(i.parentRenderLayer){if(i.parentRenderLayer===this)continue;i.parentRenderLayer.detach(i)}this.renderLayerChildren.push(i),i.parentRenderLayer=this;const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0)}return t[0]}detach(...t){for(let e=0;e<t.length;e++){const i=t[e],s=this.renderLayerChildren.indexOf(i);s!==-1&&this.renderLayerChildren.splice(s,1),i.parentRenderLayer=null;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0)}return t[0]}detachAll(){const t=this.renderLayerChildren;for(let e=0;e<t.length;e++)t[e].parentRenderLayer=null;this.renderLayerChildren.length=0}collectRenderables(t,e,i){const s=this.renderLayerChildren,n=s.length;this.sortableChildren&&this.sortRenderLayerChildren();for(let o=0;o<n;o++)s[o].parent||Xt("Container must be added to both layer and scene graph. Layers only handle render order - the scene graph is required for transforms (addChild)",s[o]),s[o].collectRenderables(t,e,this)}sortRenderLayerChildren(){this.renderLayerChildren.sort(this.sortFunction)}_getGlobalBoundsRecursive(t,e,i){if(!t)return;const s=this.renderLayerChildren;for(let n=0;n<s.length;n++)s[n]._getGlobalBoundsRecursive(!0,e,this)}getFastGlobalBounds(t,e){return super.getFastGlobalBounds(t,e)}addChild(...t){throw new Error("RenderLayer.addChild() is not available. Please use RenderLayer.attach()")}removeChild(...t){throw new Error("RenderLayer.removeChild() is not available. Please use RenderLayer.detach()")}removeChildren(t,e){throw new Error("RenderLayer.removeChildren() is not available. Please use RenderLayer.detach()")}removeChildAt(t){throw new Error("RenderLayer.removeChildAt() is not available")}getChildAt(t){throw new Error("RenderLayer.getChildAt() is not available")}setChildIndex(t,e){throw new Error("RenderLayer.setChildIndex() is not available")}getChildIndex(t){throw new Error("RenderLayer.getChildIndex() is not available")}addChildAt(t,e){throw new Error("RenderLayer.addChildAt() is not available")}swapChildren(t,e){throw new Error("RenderLayer.swapChildren() is not available")}reparentChild(...t){throw new Error("RenderLayer.reparentChild() is not available with the render layer")}reparentChildAt(t,e){throw new Error("RenderLayer.reparentChildAt() is not available with the render layer")}};Oy.defaultOptions={sortableChildren:!1,sortFunction:(r,t)=>r.zIndex-t.zIndex};let bC=Oy;function Gy(r,t,e,i){const s=e.buffers[0],n=s.data,{verticesX:o,verticesY:a}=e,l=r/(o-1),u=t/(a-1);let c=0;const h=i[0],p=i[1],f=i[2],m=i[3],_=i[4],g=i[5],b=i[6],y=i[7],v=i[8];for(let x=0;x<n.length;x+=2){const A=c%o*l,S=(c/o|0)*u,E=h*A+p*S+f,M=m*A+_*S+g,O=b*A+y*S+v;n[x]=E/O,n[x+1]=M/O,c++}s.update()}function By(r,t){const e=t[0],i=t[1],s=t[2],n=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8];return r[0]=o*c-a*u,r[1]=s*u-i*c,r[2]=i*a-s*o,r[3]=a*l-n*c,r[4]=e*c-s*l,r[5]=s*n-e*a,r[6]=n*u-o*l,r[7]=i*l-e*u,r[8]=e*o-i*n,r}function Iy(r,t,e){const i=t[0],s=t[1],n=t[2],o=t[3],a=t[4],l=t[5],u=t[6],c=t[7],h=t[8],p=e[0],f=e[1],m=e[2],_=e[3],g=e[4],b=e[5],y=e[6],v=e[7],x=e[8];return r[0]=p*i+f*o+m*u,r[1]=p*s+f*a+m*c,r[2]=p*n+f*l+m*h,r[3]=_*i+g*o+b*u,r[4]=_*s+g*a+b*c,r[5]=_*n+g*l+b*h,r[6]=y*i+v*o+x*u,r[7]=y*s+v*a+x*c,r[8]=y*n+v*l+x*h,r}function vC(r,t,e){const i=e[0],s=e[1],n=e[2];return r[0]=t[0]*i+t[1]*s+t[2]*n,r[1]=t[3]*i+t[4]*s+t[5]*n,r[2]=t[6]*i+t[7]*s+t[8]*n,r}const yC=[0,0,0,0,0,0,0,0,0],xC=[0,0,0],un=[0,0,0];function Fy(r,t,e,i,s,n,o,a,l){const u=yC;u[0]=t,u[1]=i,u[2]=n,u[3]=e,u[4]=s,u[5]=o,u[6]=1,u[7]=1,u[8]=1;const c=By(r,u);un[0]=a,un[1]=l,un[2]=1;const h=vC(xC,c,un),p=r;return r[0]=h[0],r[1]=0,r[2]=0,r[3]=0,r[4]=h[1],r[5]=0,r[6]=0,r[7]=0,r[8]=h[2],Iy(r,p,u)}const TC=[0,0,0,0,0,0,0,0,0],SC=[0,0,0,0,0,0,0,0,0];function Dy(r,t,e,i,s,n,o,a,l,u,c,h,p,f,m,_,g){const b=Fy(TC,t,e,n,o,u,c,f,m),y=Fy(SC,i,s,a,l,h,p,_,g);return Iy(r,By(b,b),y)}class Uy extends xs{constructor(t){super(t),this._projectionMatrix=[0,0,0,0,0,0,0,0,0];const{width:e,height:i}=t;this.corners=[0,0,e,0,e,i,0,i]}setCorners(t,e,i,s,n,o,a,l){const u=this.corners;u[0]=t,u[1]=e,u[2]=i,u[3]=s,u[4]=n,u[5]=o,u[6]=a,u[7]=l,this.updateProjection()}updateProjection(){const{width:t,height:e}=this,i=this.corners,s=Dy(this._projectionMatrix,0,0,i[0],i[1],t,0,i[2],i[3],t,e,i[4],i[5],0,e,i[6],i[7]);Gy(t,e,this,s)}}var AC=Object.defineProperty,EC=Object.defineProperties,PC=Object.getOwnPropertyDescriptors,cn=Object.getOwnPropertySymbols,ky=Object.prototype.hasOwnProperty,$y=Object.prototype.propertyIsEnumerable,Ly=(r,t,e)=>t in r?AC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xu=(r,t)=>{for(var e in t||(t={}))ky.call(t,e)&&Ly(r,e,t[e]);if(cn)for(var e of cn(t))$y.call(t,e)&&Ly(r,e,t[e]);return r},wC=(r,t)=>EC(r,PC(t)),RC=(r,t)=>{var e={};for(var i in r)ky.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&cn)for(var i of cn(r))t.indexOf(i)<0&&$y.call(r,i)&&(e[i]=r[i]);return e};const Ny=class f0 extends mr{constructor(t){t=Xu(Xu({},f0.defaultOptions),t);const e=t,{texture:i,verticesX:s,verticesY:n}=e,o=RC(e,["texture","verticesX","verticesY"]),a=new Uy(kt({width:i.width,height:i.height,verticesX:s,verticesY:n}));super(kt(wC(Xu({},o),{geometry:a}))),this._texture=i,this.geometry.setCorners(t.x0,t.y0,t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}textureUpdated(){const t=this.geometry;if(!t)return;const{width:e,height:i}=this.texture;(t.width!==e||t.height!==i)&&(t.width=e,t.height=i,t.updateProjection())}set texture(t){this._texture!==t&&(super.texture=t,this.textureUpdated())}get texture(){return this._texture}setCorners(t,e,i,s,n,o,a,l){this.geometry.setCorners(t,e,i,s,n,o,a,l)}};Ny.defaultOptions={texture:w.WHITE,verticesX:10,verticesY:10,x0:0,y0:0,x1:100,y1:0,x2:100,y2:100,x3:0,y3:100};let CC=Ny;var MC=Object.defineProperty,OC=Object.defineProperties,GC=Object.getOwnPropertyDescriptors,hn=Object.getOwnPropertySymbols,Xy=Object.prototype.hasOwnProperty,Hy=Object.prototype.propertyIsEnumerable,jy=(r,t,e)=>t in r?MC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,BC=(r,t)=>{for(var e in t||(t={}))Xy.call(t,e)&&jy(r,e,t[e]);if(hn)for(var e of hn(t))Hy.call(t,e)&&jy(r,e,t[e]);return r},IC=(r,t)=>OC(r,GC(t)),FC=(r,t)=>{var e={};for(var i in r)Xy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&hn)for(var i of hn(r))t.indexOf(i)<0&&Hy.call(r,i)&&(e[i]=r[i]);return e};class DC extends mr{constructor(t){const e=t,{texture:i,verticesX:s,verticesY:n}=e,o=FC(e,["texture","verticesX","verticesY"]),a=new xs(kt({width:i.width,height:i.height,verticesX:s,verticesY:n}));super(kt(IC(BC({},o),{geometry:a,texture:i}))),this.texture=i,this.autoResize=!0}textureUpdated(){const t=this.geometry,{width:e,height:i}=this.texture;this.autoResize&&(t.width!==e||t.height!==i)&&(t.width=e,t.height=i,t.build({}))}set texture(t){var e;(e=this._texture)==null||e.off("update",this.textureUpdated,this),super.texture=t,t.on("update",this.textureUpdated,this),this.textureUpdated()}get texture(){return this._texture}destroy(t){this.texture.off("update",this.textureUpdated,this),super.destroy(t)}}var UC=Object.defineProperty,zy=Object.getOwnPropertySymbols,kC=Object.prototype.hasOwnProperty,$C=Object.prototype.propertyIsEnumerable,Vy=(r,t,e)=>t in r?UC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Wy=(r,t)=>{for(var e in t||(t={}))kC.call(t,e)&&Vy(r,e,t[e]);if(zy)for(var e of zy(t))$C.call(t,e)&&Vy(r,e,t[e]);return r};const Yy=class m0 extends ce{constructor(t){const{width:e,points:i,textureScale:s}=Wy(Wy({},m0.defaultOptions),t);super({positions:new Float32Array(i.length*4),uvs:new Float32Array(i.length*4),indices:new Uint32Array((i.length-1)*6)}),this.points=i,this._width=e,this.textureScale=s,this._build()}get width(){return this._width}_build(){const t=this.points;if(!t)return;const e=this.getBuffer("aPosition"),i=this.getBuffer("aUV"),s=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),s.data=new Uint16Array((t.length-1)*6));const n=i.data,o=s.data;n[0]=0,n[1]=0,n[2]=0,n[3]=1;let a=0,l=t[0];const u=this._width*this.textureScale,c=t.length;for(let p=0;p<c;p++){const f=p*4;if(this.textureScale>0){const m=l.x-t[p].x,_=l.y-t[p].y,g=Math.sqrt(m*m+_*_);l=t[p],a+=g/u}else a=p/(c-1);n[f]=a,n[f+1]=0,n[f+2]=a,n[f+3]=1}let h=0;for(let p=0;p<c-1;p++){const f=p*2;o[h++]=f,o[h++]=f+1,o[h++]=f+2,o[h++]=f+2,o[h++]=f+1,o[h++]=f+3}i.update(),s.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let e=t[0],i,s=0,n=0;const o=this.buffers[0].data,a=t.length,l=this.textureScale>0?this.textureScale*this._width/2:this._width/2;for(let u=0;u<a;u++){const c=t[u],h=u*4;u<t.length-1?i=t[u+1]:i=c,n=-(i.x-e.x),s=i.y-e.y;let p=(1-u/(a-1))*10;p>1&&(p=1);const f=Math.sqrt(s*s+n*n);f<1e-6?(s=0,n=0):(s/=f,n/=f,s*=l,n*=l),o[h]=c.x+s,o[h+1]=c.y+n,o[h+2]=c.x-s,o[h+3]=c.y-n,e=c}this.buffers[0].update()}update(){this.textureScale>0?this._build():this.updateVertices()}};Yy.defaultOptions={width:200,points:[],textureScale:0};let Ky=Yy;var LC=Object.defineProperty,NC=Object.defineProperties,XC=Object.getOwnPropertyDescriptors,dn=Object.getOwnPropertySymbols,qy=Object.prototype.hasOwnProperty,Zy=Object.prototype.propertyIsEnumerable,Qy=(r,t,e)=>t in r?LC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hu=(r,t)=>{for(var e in t||(t={}))qy.call(t,e)&&Qy(r,e,t[e]);if(dn)for(var e of dn(t))Zy.call(t,e)&&Qy(r,e,t[e]);return r},HC=(r,t)=>NC(r,XC(t)),jC=(r,t)=>{var e={};for(var i in r)qy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&dn)for(var i of dn(r))t.indexOf(i)<0&&Zy.call(r,i)&&(e[i]=r[i]);return e};const Jy=class g0 extends mr{constructor(t){const e=Hu(Hu({},g0.defaultOptions),t),{texture:i,points:s,textureScale:n}=e,o=jC(e,["texture","points","textureScale"]),a=new Ky(kt({width:i.height,points:s,textureScale:n}));n>0&&(i.source.style.addressMode="repeat"),super(kt(HC(Hu({},o),{texture:i,geometry:a}))),this.autoUpdate=!0,this.onRender=this._render}_render(){const t=this.geometry;(this.autoUpdate||t._width!==this.texture.height)&&(t._width=this.texture.height,t.update())}};Jy.defaultOptions={textureScale:0};let zC=Jy;var VC=Object.defineProperty,WC=Object.defineProperties,YC=Object.getOwnPropertyDescriptors,pn=Object.getOwnPropertySymbols,tx=Object.prototype.hasOwnProperty,ex=Object.prototype.propertyIsEnumerable,rx=(r,t,e)=>t in r?VC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,KC=(r,t)=>{for(var e in t||(t={}))tx.call(t,e)&&rx(r,e,t[e]);if(pn)for(var e of pn(t))ex.call(t,e)&&rx(r,e,t[e]);return r},qC=(r,t)=>WC(r,YC(t)),ZC=(r,t)=>{var e={};for(var i in r)tx.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&pn)for(var i of pn(r))t.indexOf(i)<0&&ex.call(r,i)&&(e[i]=r[i]);return e};class QC extends mr{constructor(t){const e=t,{texture:i,vertices:s,uvs:n,indices:o,topology:a}=e,l=ZC(e,["texture","vertices","uvs","indices","topology"]),u=new ce(kt({positions:s,uvs:n,indices:o,topology:a}));super(kt(qC(KC({},l),{texture:i,geometry:u}))),this.autoUpdate=!0,this.onRender=this._render}get vertices(){return this.geometry.getBuffer("aPosition").data}set vertices(t){this.geometry.getBuffer("aPosition").data=t}_render(){this.autoUpdate&&this.geometry.getBuffer("aPosition").update()}}function JC(r,t){const{width:e,height:i}=r.frame;return t.scale(1/e,1/i),t}var tM=Object.defineProperty,ix=Object.getOwnPropertySymbols,eM=Object.prototype.hasOwnProperty,rM=Object.prototype.propertyIsEnumerable,sx=(r,t,e)=>t in r?tM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nx=(r,t)=>{for(var e in t||(t={}))eM.call(t,e)&&sx(r,e,t[e]);if(ix)for(var e of ix(t))rM.call(t,e)&&sx(r,e,t[e]);return r};const ox=class tc{constructor(t){if(t instanceof w)this.texture=t,Oi(this,tc.defaultOptions,{});else{const e=nx(nx({},tc.defaultOptions),t);Oi(this,e,{})}}get alpha(){return this._alpha}set alpha(t){this._alpha=Math.min(Math.max(t,0),1),this._updateColor()}get tint(){return $e(this._tint)}set tint(t){this._tint=H.shared.setValue(t!=null?t:16777215).toBgrNumber(),this._updateColor()}_updateColor(){this.color=this._tint+((this._alpha*255|0)<<24)}};ox.defaultOptions={anchorX:0,anchorY:0,x:0,y:0,scaleX:1,scaleY:1,rotation:0,tint:16777215,alpha:1};let iM=ox;const ju={vertex:{attributeName:"aVertex",format:"float32x2",code:`
const texture = p.texture;
const sx = p.scaleX;
const sy = p.scaleY;
const ax = p.anchorX;
const ay = p.anchorY;
const trim = texture.trim;
const orig = texture.orig;
if (trim)
{
w1 = trim.x - (ax * orig.width);
w0 = w1 + trim.width;
h1 = trim.y - (ay * orig.height);
h0 = h1 + trim.height;
}
else
{
w1 = -ax * (orig.width);
w0 = w1 + orig.width;
h1 = -ay * (orig.height);
h0 = h1 + orig.height;
}
f32v[offset] = w1 * sx;
f32v[offset + 1] = h1 * sy;
f32v[offset + stride] = w0 * sx;
f32v[offset + stride + 1] = h1 * sy;
f32v[offset + (stride * 2)] = w0 * sx;
f32v[offset + (stride * 2) + 1] = h0 * sy;
f32v[offset + (stride * 3)] = w1 * sx;
f32v[offset + (stride * 3) + 1] = h0 * sy;
`,dynamic:!1},position:{attributeName:"aPosition",format:"float32x2",code:`
var x = p.x;
var y = p.y;
f32v[offset] = x;
f32v[offset + 1] = y;
f32v[offset + stride] = x;
f32v[offset + stride + 1] = y;
f32v[offset + (stride * 2)] = x;
f32v[offset + (stride * 2) + 1] = y;
f32v[offset + (stride * 3)] = x;
f32v[offset + (stride * 3) + 1] = y;
`,dynamic:!0},rotation:{attributeName:"aRotation",format:"float32",code:`
var rotation = p.rotation;
f32v[offset] = rotation;
f32v[offset + stride] = rotation;
f32v[offset + (stride * 2)] = rotation;
f32v[offset + (stride * 3)] = rotation;
`,dynamic:!1},uvs:{attributeName:"aUV",format:"float32x2",code:`
var uvs = p.texture.uvs;
f32v[offset] = uvs.x0;
f32v[offset + 1] = uvs.y0;
f32v[offset + stride] = uvs.x1;
f32v[offset + stride + 1] = uvs.y1;
f32v[offset + (stride * 2)] = uvs.x2;
f32v[offset + (stride * 2) + 1] = uvs.y2;
f32v[offset + (stride * 3)] = uvs.x3;
f32v[offset + (stride * 3) + 1] = uvs.y3;
`,dynamic:!1},color:{attributeName:"aColor",format:"unorm8x4",code:`
const c = p.color;
u32v[offset] = c;
u32v[offset + stride] = c;
u32v[offset + (stride * 2)] = c;
u32v[offset + (stride * 3)] = c;
`,dynamic:!1}};var sM=Object.defineProperty,nM=Object.defineProperties,oM=Object.getOwnPropertyDescriptors,fn=Object.getOwnPropertySymbols,ax=Object.prototype.hasOwnProperty,lx=Object.prototype.propertyIsEnumerable,ux=(r,t,e)=>t in r?sM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_r=(r,t)=>{for(var e in t||(t={}))ax.call(t,e)&&ux(r,e,t[e]);if(fn)for(var e of fn(t))lx.call(t,e)&&ux(r,e,t[e]);return r},cx=(r,t)=>nM(r,oM(t)),aM=(r,t)=>{var e={};for(var i in r)ax.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&fn)for(var i of fn(r))t.indexOf(i)<0&&lx.call(r,i)&&(e[i]=r[i]);return e};const lM=new ot(0,0,0,0),hx=class ec extends Kt{constructor(t={}){t=cx(_r(_r({},ec.defaultOptions),t),{dynamicProperties:_r(_r({},ec.defaultOptions.dynamicProperties),t==null?void 0:t.dynamicProperties)});const e=t,{dynamicProperties:i,shader:s,roundPixels:n,texture:o,particles:a}=e,l=aM(e,["dynamicProperties","shader","roundPixels","texture","particles"]);super(_r({label:"ParticleContainer"},l)),this.renderPipeId="particle",this.batched=!1,this._childrenDirty=!1,this.texture=o||null,this.shader=s,this._properties={};for(const u in ju){const c=ju[u],h=i[u];this._properties[u]=cx(_r({},c),{dynamic:h})}this.allowChildren=!0,this.roundPixels=n!=null?n:!1,this.particleChildren=a!=null?a:[]}addParticle(...t){for(let e=0;e<t.length;e++)this.particleChildren.push(t[e]);return this.onViewUpdate(),t[0]}removeParticle(...t){let e=!1;for(let i=0;i<t.length;i++){const s=this.particleChildren.indexOf(t[i]);s>-1&&(this.particleChildren.splice(s,1),e=!0)}return e&&this.onViewUpdate(),t[0]}update(){this._childrenDirty=!0}onViewUpdate(){this._childrenDirty=!0,super.onViewUpdate()}get bounds(){return lM}updateBounds(){}destroy(t=!1){var e,i,s;if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const n=typeof t=="boolean"?t:t==null?void 0:t.textureSource,o=(i=this.texture)!=null?i:(e=this.particleChildren[0])==null?void 0:e.texture;o&&o.destroy(n)}this.texture=null,(s=this.shader)==null||s.destroy()}removeParticles(t,e){t!=null||(t=0),e!=null||(e=this.particleChildren.length);const i=this.particleChildren.splice(t,e-t);return this.onViewUpdate(),i}removeParticleAt(t){const e=this.particleChildren.splice(t,1);return this.onViewUpdate(),e[0]}addParticleAt(t,e){return this.particleChildren.splice(e,0,t),this.onViewUpdate(),t}addChild(...t){throw new Error("ParticleContainer.addChild() is not available. Please use ParticleContainer.addParticle()")}removeChild(...t){throw new Error("ParticleContainer.removeChild() is not available. Please use ParticleContainer.removeParticle()")}removeChildren(t,e){throw new Error("ParticleContainer.removeChildren() is not available. Please use ParticleContainer.removeParticles()")}removeChildAt(t){throw new Error("ParticleContainer.removeChildAt() is not available. Please use ParticleContainer.removeParticleAt()")}getChildAt(t){throw new Error("ParticleContainer.getChildAt() is not available. Please use ParticleContainer.getParticleAt()")}setChildIndex(t,e){throw new Error("ParticleContainer.setChildIndex() is not available. Please use ParticleContainer.setParticleIndex()")}getChildIndex(t){throw new Error("ParticleContainer.getChildIndex() is not available. Please use ParticleContainer.getParticleIndex()")}addChildAt(t,e){throw new Error("ParticleContainer.addChildAt() is not available. Please use ParticleContainer.addParticleAt()")}swapChildren(t,e){throw new Error("ParticleContainer.swapChildren() is not available. Please use ParticleContainer.swapParticles()")}reparentChild(...t){throw new Error("ParticleContainer.reparentChild() is not available with the particle container")}reparentChildAt(t,e){throw new Error("ParticleContainer.reparentChildAt() is not available with the particle container")}};hx.defaultOptions={dynamicProperties:{vertex:!1,position:!0,rotation:!1,uvs:!1,color:!1},roundPixels:!1};let uM=hx;var cM=Object.defineProperty,mn=Object.getOwnPropertySymbols,dx=Object.prototype.hasOwnProperty,px=Object.prototype.propertyIsEnumerable,fx=(r,t,e)=>t in r?cM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hM=(r,t)=>{for(var e in t||(t={}))dx.call(t,e)&&fx(r,e,t[e]);if(mn)for(var e of mn(t))px.call(t,e)&&fx(r,e,t[e]);return r},dM=(r,t)=>{var e={};for(var i in r)dx.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&mn)for(var i of mn(r))t.indexOf(i)<0&&px.call(r,i)&&(e[i]=r[i]);return e};const mx=class _0 extends Kt{constructor(t){var e,i,s,n,o,a,l,u,c,h;t instanceof w&&(t={texture:t});const p=t,{width:f,height:m,anchor:_,leftWidth:g,rightWidth:b,topHeight:y,bottomHeight:v,texture:x,roundPixels:A}=p,S=dM(p,["width","height","anchor","leftWidth","rightWidth","topHeight","bottomHeight","texture","roundPixels"]);super(hM({label:"NineSliceSprite"},S)),this.renderPipeId="nineSliceSprite",this.batched=!0,this._leftWidth=(i=g!=null?g:(e=x==null?void 0:x.defaultBorders)==null?void 0:e.left)!=null?i:he.defaultOptions.leftWidth,this._topHeight=(n=y!=null?y:(s=x==null?void 0:x.defaultBorders)==null?void 0:s.top)!=null?n:he.defaultOptions.topHeight,this._rightWidth=(a=b!=null?b:(o=x==null?void 0:x.defaultBorders)==null?void 0:o.right)!=null?a:he.defaultOptions.rightWidth,this._bottomHeight=(u=v!=null?v:(l=x==null?void 0:x.defaultBorders)==null?void 0:l.bottom)!=null?u:he.defaultOptions.bottomHeight,this._width=(c=f!=null?f:x.width)!=null?c:he.defaultOptions.width,this._height=(h=m!=null?m:x.height)!=null?h:he.defaultOptions.height,this.allowChildren=!1,this.texture=x!=null?x:_0.defaultOptions.texture,this.roundPixels=A!=null?A:!1,this._anchor=new Z({_onUpdate:()=>{this.onViewUpdate()}}),_?this.anchor=_:this.texture.defaultAnchor&&(this.anchor=this.texture.defaultAnchor)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return this._width}set width(t){this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this._height=t,this.onViewUpdate()}setSize(t,e){var i;typeof t=="object"&&(e=(i=t.height)!=null?i:t.width,t=t.width),this._width=t,this._height=e!=null?e:t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this.onViewUpdate()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this.onViewUpdate()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this.onViewUpdate()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this.onViewUpdate()}get texture(){return this._texture}set texture(t){t||(t=w.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}destroy(t){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}updateBounds(){const t=this._bounds,e=this._anchor,i=this._width,s=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}};mx.defaultOptions={texture:w.EMPTY};let gx=mx;class pM extends gx{constructor(...t){let e=t[0];e instanceof w&&(e={texture:e,leftWidth:t[1],topHeight:t[2],rightWidth:t[3],bottomHeight:t[4]}),super(e)}}function _x(r){const{text:t,style:e,chars:i}=r,s=e,n=lr.getFont(t,s),o=ht.graphemeSegmenter(t),a=gs(o,s,n,!0),l=a.scale,u=[],c=[],h=[],p=e.lineHeight?e.lineHeight:n.lineHeight*l;let f=0;for(const m of a.lines){if(m.chars.length===0)continue;const _=new q({label:"line"});_.y=f,h.push(_);let g=new q({label:"word"}),b=0;for(let y=0;y<m.chars.length;y++){const v=m.chars[y];if(!v||!n.chars[v])continue;const x=v===" ",A=y===m.chars.length-1;let S;i.length>0?(S=i.shift(),S.text=v,S.style=s,S.label=`char-${v}`,S.x=m.charPositions[y]*l-m.charPositions[b]*l):S=new vl({text:v,style:s,label:`char-${v}`,x:m.charPositions[y]*l-m.charPositions[b]*l}),x||(u.push(S),g.addChild(S)),(x||A)&&g.children.length>0&&(g.x=m.charPositions[b]*l,c.push(g),_.addChild(g),g=new q({label:"word"}),b=y+1)}f+=p}return{chars:u,lines:h,words:c}}var bx=Object.getOwnPropertySymbols,fM=Object.prototype.hasOwnProperty,mM=Object.prototype.propertyIsEnumerable,gM=(r,t)=>{var e={};for(var i in r)fM.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&bx)for(var i of bx(r))t.indexOf(i)<0&&mM.call(r,i)&&(e[i]=r[i]);return e};class zu extends q{constructor(t){const e=t,{text:i,style:s,autoSplit:n,lineAnchor:o,wordAnchor:a,charAnchor:l}=e,u=gM(e,["text","style","autoSplit","lineAnchor","wordAnchor","charAnchor"]);super(u),this._dirty=!1,this._canReuseChars=!1,this.chars=[],this.words=[],this.lines=[],this._originalText=i,this._autoSplit=n,this._lineAnchor=o,this._wordAnchor=a,this._charAnchor=l,this.style=s}split(){const t=this.splitFn();this.chars=t.chars,this.words=t.words,this.lines=t.lines,this.addChild(...this.lines),this.charAnchor=this._charAnchor,this.wordAnchor=this._wordAnchor,this.lineAnchor=this._lineAnchor,this._dirty=!1,this._canReuseChars=!0}get text(){return this._originalText}set text(t){this._originalText=t,this.lines.forEach(e=>e.destroy({children:!0})),this.lines.length=0,this.words.length=0,this.chars.length=0,this._canReuseChars=!1,this.onTextUpdate()}_setOrigin(t,e,i){let s;typeof t=="number"?s={x:t,y:t}:s={x:t.x,y:t.y},e.forEach(n=>{const o=n.getLocalBounds(),a=o.minX+o.width*s.x,l=o.minY+o.height*s.y;n.origin.set(a,l)}),this[i]=t}get lineAnchor(){return this._lineAnchor}set lineAnchor(t){this._setOrigin(t,this.lines,"_lineAnchor")}get wordAnchor(){return this._wordAnchor}set wordAnchor(t){this._setOrigin(t,this.words,"_wordAnchor")}get charAnchor(){return this._charAnchor}set charAnchor(t){this._setOrigin(t,this.chars,"_charAnchor")}get style(){return this._style}set style(t){t||(t={}),this._style=new Mt(t),this.words.forEach(e=>e.destroy()),this.words.length=0,this.lines.forEach(e=>e.destroy()),this.lines.length=0,this._canReuseChars=!0,this.onTextUpdate()}onTextUpdate(){this._dirty=!0,this._autoSplit&&this.split()}destroy(t){super.destroy(t),this.chars=[],this.words=[],this.lines=[],(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._originalText=""}}var _M=Object.defineProperty,bM=Object.defineProperties,vM=Object.getOwnPropertyDescriptors,vx=Object.getOwnPropertySymbols,yM=Object.prototype.hasOwnProperty,xM=Object.prototype.propertyIsEnumerable,yx=(r,t,e)=>t in r?_M(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fi=(r,t)=>{for(var e in t||(t={}))yM.call(t,e)&&yx(r,e,t[e]);if(vx)for(var e of vx(t))xM.call(t,e)&&yx(r,e,t[e]);return r},TM=(r,t)=>bM(r,vM(t));const xx=class Sn extends zu{constructor(t){const e=fi(fi({},Sn.defaultOptions),t);super(e)}static from(t,e){const i=TM(fi(fi({},Sn.defaultOptions),e),{text:t.text,style:new Mt(t.style)});return new Sn(fi({},i))}splitFn(){return _x({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};xx.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let SM=xx;function AM(r,t,e){switch(r){case"center":return(e-t)/2;case"right":return e-t;case"left":default:return 0}}function Tx(r){return r==="\r"||r===`
`||r===`\r
`}function EM(r,t,e){const i=[];let s=t.lines[0],n="",o=[],a=0;return e.wordWrap=!1,r.forEach(l=>{const u=/^\s*$/.test(l),c=Tx(l),h=n.length===0&&u;if(u&&!c&&h)return;c||(n+=l);const p=ht.measureText(l,e);o.push({char:l,metric:p}),n.length>=s.length&&(i.push({line:n,chars:o,width:o.reduce((f,m)=>f+m.metric.width,0)}),o=[],n="",a++,s=t.lines[a])}),i}function Sx(r){var t,e;const{text:i,style:s,chars:n}=r,o=s,a=ht.measureText(i,o),l=ht.graphemeSegmenter(i),u=EM(l,a,o.clone()),c=o.align,h=a.lineWidths.reduce((y,v)=>Math.max(y,v),0),p=[],f=[],m=[];let _=0;const g=((t=o.stroke)==null?void 0:t.width)||0,b=((e=o.dropShadow)==null?void 0:e.distance)||0;return u.forEach((y,v)=>{const x=new q({label:`line-${v}`});x.y=_,f.push(x);const A=a.lineWidths[v];let S=AM(c,A,h),E=new q({label:"word"});E.x=S,y.chars.forEach((M,O)=>{if(M.metric.width!==0){if(Tx(M.char)){S+=M.metric.width-g;return}if(M.char===" ")E.children.length>0&&(m.push(E),x.addChild(E)),S+=M.metric.width+o.letterSpacing-g,E=new q({label:"word"}),E.x=S;else{let P;n.length>0?(P=n.shift(),P.text=M.char,P.style=o,P.setFromMatrix(C.IDENTITY),P.x=S-E.x-b*O):P=new Vs({text:M.char,style:o,x:S-E.x-b*O}),p.push(P),E.addChild(P),S+=M.metric.width+o.letterSpacing-g}}}),E.children.length>0&&(m.push(E),x.addChild(E)),_+=a.lineHeight}),{chars:p,lines:f,words:m}}var PM=Object.defineProperty,wM=Object.defineProperties,RM=Object.getOwnPropertyDescriptors,Ax=Object.getOwnPropertySymbols,CM=Object.prototype.hasOwnProperty,MM=Object.prototype.propertyIsEnumerable,Ex=(r,t,e)=>t in r?PM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mi=(r,t)=>{for(var e in t||(t={}))CM.call(t,e)&&Ex(r,e,t[e]);if(Ax)for(var e of Ax(t))MM.call(t,e)&&Ex(r,e,t[e]);return r},OM=(r,t)=>wM(r,RM(t));const Px=class An extends zu{constructor(t){const e=mi(mi({},An.defaultOptions),t);super(e)}static from(t,e){const i=OM(mi(mi({},An.defaultOptions),e),{text:t.text,style:new Mt(t.style)});return new An(mi({},i))}splitFn(){return Sx({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};Px.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let GM=Px;const wx=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function BM(r){const t=[];let e=0;for(let i=0;i<wx.length;i++){const s=`_${wx[i]}`;t[e++]=r[s]}return e=Rx(r._fill,t,e),e=FM(r._stroke,t,e),e=DM(r.dropShadow,t,e),e=IM(r.filters,t,e),t.join("-")}function IM(r,t,e){if(!r)return e;for(const i of r)t[e++]=i.uid;return e}function Rx(r,t,e){var i;return r&&(t[e++]=r.color,t[e++]=r.alpha,t[e++]=(i=r.fill)==null?void 0:i.styleKey),e}function FM(r,t,e){return r&&(e=Rx(r,t,e),t[e++]=r.width,t[e++]=r.alignment,t[e++]=r.cap,t[e++]=r.join,t[e++]=r.miterLimit),e}function DM(r,t,e){return r&&(t[e++]=r.alpha,t[e++]=r.angle,t[e++]=r.blur,t[e++]=r.distance,t[e++]=H.shared.setValue(r.color).toNumber()),e}async function UM(r,t,e=200){const i=await t.extract.base64(r);await t.encoder.commandFinished;const s=e;console.log(`logging texture ${r.source.width}px ${r.source.height}px`);const n=["font-size: 1px;",`padding: ${s}px 300px;`,`background: url(${i}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}var kM=Object.defineProperty,$M=Object.defineProperties,LM=Object.getOwnPropertyDescriptors,Cx=Object.getOwnPropertySymbols,NM=Object.prototype.hasOwnProperty,XM=Object.prototype.propertyIsEnumerable,Mx=(r,t,e)=>t in r?kM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ox=(r,t)=>{for(var e in t||(t={}))NM.call(t,e)&&Mx(r,e,t[e]);if(Cx)for(var e of Cx(t))XM.call(t,e)&&Mx(r,e,t[e]);return r},HM=(r,t)=>$M(r,LM(t));const jM=["#000080","#228B22","#8B0000","#4169E1","#008080","#800000","#9400D3","#FF8C00","#556B2F","#8B008B"];let zM=0;function Gx(r,t=0,e={color:"#000000"}){r.renderGroup&&(e.color=jM[zM++]);let i="";for(let o=0;o<t;o++)i+=" ";let s=r.label;!s&&r instanceof Lt&&(s=`sprite:${r.texture.label}`);let n=`%c ${i}|- ${s} (worldX:${r.worldTransform.tx}, relativeRenderX:${r.relativeGroupTransform.tx}, renderX:${r.groupTransform.tx}, localX:${r.x})`;r.renderGroup&&(n+=" (RenderGroup)"),r.filters&&(n+="(*filters)"),console.log(n,`color:${e.color}; font-weight:bold;`),t++;for(let o=0;o<r.children.length;o++){const a=r.children[o];Gx(a,t,Ox({},e))}}function Bx(r,t=0,e={index:0,color:"#000000"}){let i="";for(let n=0;n<t;n++)i+=" ";const s=`%c ${i}- ${e.index}: ${r.root.label} worldX:${r.worldTransform.tx}`;console.log(s,`color:${e.color}; font-weight:bold;`),t++;for(let n=0;n<r.renderGroupChildren.length;n++){const o=r.renderGroupChildren[n];Bx(o,t,HM(Ox({},e),{index:n}))}}return d.AbstractBitmapFont=_a,d.AbstractRenderer=Zr,d.AbstractSplitText=zu,d.AbstractText=js,d.AccessibilitySystem=wh,d.AlphaFilter=QE,d.AlphaMask=eo,d.AlphaMaskPipe=Al,d.AnimatedSprite=ui,d.Application=Ym,d.ApplicationInitHook=Na,d.Assets=ii,d.AssetsClass=Dg,d.BLEND_TO_NPM=id,d.BUFFER_TYPE=hi,d.BackgroundLoader=Zm,d.BackgroundSystem=Mv,d.Batch=ud,d.BatchGeometry=md,d.BatchTextureArray=nd,d.BatchableGraphics=ts,d.BatchableHTMLText=Vf,d.BatchableMesh=os,d.BatchableSprite=Nr,d.BatchableText=Xp,d.Batcher=pd,d.BatcherPipe=Sl,d.BigPool=st,d.BindGroup=Zt,d.BindGroupSystem=Su,d.BitmapFont=Ha,d.BitmapFontManager=lr,d.BitmapText=vl,d.BitmapTextGraphics=jf,d.BitmapTextPipe=ya,d.BlendModeFilter=jE,d.BlendModePipe=cu,d.BlurFilter=A_,d.BlurFilterPass=Fs,d.Bounds=ot,d.BrowserAdapter=Dh,d.Buffer=bt,d.BufferImageSource=Ci,d.BufferResource=Qs,d.BufferUsage=X,d.CLEAR=Tt,d.Cache=V,d.CanvasObserver=jn,d.CanvasPool=Jt,d.CanvasPoolClass=Tf,d.CanvasSource=qt,d.CanvasTextGenerator=or,d.CanvasTextMetrics=ht,d.CanvasTextPipe=qo,d.CanvasTextSystem=fa,d.Circle=ls,d.Color=H,d.ColorMask=ro,d.ColorMaskPipe=El,d.ColorMatrixFilter=gP,d.CompressedSource=si,d.Container=q,d.Culler=Jg,d.CullerPlugin=t_,d.CustomRenderPipe=iu,d.D3D10_RESOURCE_DIMENSION=ol,d.D3DFMT=St,d.DATA_URI=eA,d.DDS=$,d.DEG_TO_RAD=Tc,d.DEPRECATED_SCALE_MODES=Nu,d.DEPRECATED_WRAP_MODES=Lu,d.DOMAdapter=L,d.DOMContainer=UT,d.DOMPipe=Qn,d.DRAW_MODES=eC,d.DXGI_FORMAT=nl,d.DXGI_TO_TEXTURE_FORMAT=At,d.DefaultBatcher=Qi,d.DefaultShader=Ao,d.DisplacementFilter=SP,d.DynamicBitmapFont=ba,d.Ellipse=us,d.EventBoundary=Ch,d.EventEmitter=gt,d.EventSystem=Zn,d.EventsTicker=Yt,d.ExtensionType=T,d.ExtractSystem=Bv,d.FOURCC_TO_TEXTURE_FORMAT=al,d.FederatedContainer=Gh,d.FederatedEvent=Ne,d.FederatedMouseEvent=Pr,d.FederatedPointerEvent=Ft,d.FederatedWheelEvent=Te,d.FillGradient=Qt,d.FillPattern=Xr,d.Filter=te,d.FilterEffect=Tr,d.FilterPipe=Ca,d.FilterSystem=Ia,d.FontStylePromiseCache=bs,d.GAUSSIAN_VALUES=dl,d.GCManagedHash=xt,d.GCSystem=Lv,d.GL_FORMATS=qs,d.GL_INTERNAL_FORMAT=jg,d.GL_TARGETS=Ml,d.GL_TYPES=j,d.GL_WRAP_MODES=Pb,d.GPUTextureGpuData=yy,d.GenerateTextureSystem=fu,d.Geometry=Ee,d.GlBackBufferSystem=Bb,d.GlBatchAdaptor=yl,d.GlBuffer=xb,d.GlBufferSystem=wl,d.GlColorMaskSystem=Bl,d.GlContextSystem=Eb,d.GlEncoderSystem=Il,d.GlGeometryGpuData=Cb,d.GlGeometrySystem=Ol,d.GlGraphicsAdaptor=eu,d.GlLimitsSystem=Fl,d.GlMeshAdaptor=ru,d.GlParticleContainerAdaptor=Ip,d.GlParticleContainerPipe=Yo,d.GlProgram=vt,d.GlProgramData=Zb,d.GlRenderTarget=Ib,d.GlRenderTargetAdaptor=Nb,d.GlRenderTargetSystem=jl,d.GlShaderSystem=Kl,d.GlStateSystem=hv,d.GlStencilSystem=Dl,d.GlTexture=dv,d.GlTextureSystem=tu,d.GlUboSystem=Nl,d.GlUniformGroupSystem=ql,d.GlobalResourceRegistry=ge,d.GlobalUniformSystem=gu,d.GpuBatchAdaptor=xl,d.GpuBlendModesToPixi=ft,d.GpuBufferData=sy,d.GpuBufferSystem=Au,d.GpuColorMaskSystem=Eu,d.GpuDeviceSystem=an,d.GpuEncoderSystem=Pu,d.GpuGraphicsAdaptor=ku,d.GpuGraphicsContext=Op,d.GpuLimitsSystem=wu,d.GpuMeshAdapter=$u,d.GpuMipmapGenerator=vy,d.GpuParticleContainerAdaptor=Np,d.GpuParticleContainerPipe=Ko,d.GpuProgram=dt,d.GpuRenderTarget=fy,d.GpuRenderTargetAdaptor=my,d.GpuRenderTargetSystem=Gu,d.GpuShaderSystem=Bu,d.GpuStateSystem=Iu,d.GpuStencilModesToPixi=oe,d.GpuStencilSystem=Ru,d.GpuTextureSystem=Uu,d.GpuUboSystem=Cu,d.GpuUniformBatchPipe=Mu,d.Graphics=ar,d.GraphicsContext=pt,d.GraphicsContextRenderData=Gp,d.GraphicsContextSystem=ns,d.GraphicsGpuData=Bp,d.GraphicsPath=Nt,d.GraphicsPipe=Xo,d.HTMLText=gb,d.HTMLTextPipe=xa,d.HTMLTextRenderData=Ta,d.HTMLTextStyle=Ws,d.HTMLTextSystem=Aa,d.HelloSystem=on,d.IGLUniformData=Bw,d.ImageSource=le,d.InstructionSet=Fn,d.KTX=it,d.Loader=ug,d.LoaderParserPriority=Pt,d.MaskEffectManager=Ai,d.MaskEffectManagerClass=Rc,d.MaskFilter=H_,d.Matrix=C,d.Mesh=mr,d.MeshGeometry=ce,d.MeshGpuData=Ho,d.MeshPipe=jo,d.MeshPlane=DC,d.MeshRope=zC,d.MeshSimple=QC,d.NOOP=kn,d.NineSliceGeometry=he,d.NineSlicePlane=pM,d.NineSliceSprite=gx,d.NineSliceSpriteGpuData=Cm,d.NineSliceSpritePipe=Ra,d.NoiseFilter=CP,d.ObservablePoint=Z,d.PI_2=yc,d.Particle=iM,d.ParticleBuffer=Up,d.ParticleContainer=uM,d.ParticleContainerPipe=Wo,d.ParticleShader=Lp,d.PassthroughFilter=Fm,d.PerspectiveMesh=CC,d.PerspectivePlaneGeometry=Uy,d.PipelineSystem=Ou,d.PlaneGeometry=xs,d.Point=W,d.Polygon=ir,d.Pool=Sc,d.PoolGroupClass=Ac,d.PrepareBase=z_,d.PrepareQueue=ab,d.PrepareSystem=bb,d.PrepareUpload=_b,d.QuadGeometry=gm,d.RAD_TO_DEG=xc,d.Rectangle=z,d.RenderContainer=cC,d.RenderGroup=Mi,d.RenderGroupPipe=su,d.RenderGroupSystem=au,d.RenderLayer=bC,d.RenderTarget=Zs,d.RenderTargetSystem=Hl,d.RenderTexture=nn,d.RenderableGCSystem=Yv,d.RendererInitHook=Xa,d.RendererType=yt,d.ResizePlugin=Yn,d.Resolver=ae,d.RopeGeometry=Ky,d.RoundedRectangle=hs,d.SCALE_MODES=iC,d.STENCIL_MODES=rt,d.SVGParser=lf,d.SchedulerSystem=_u,d.ScissorMask=ow,d.SdfShader=Df,d.Shader=wt,d.ShaderStage=Ye,d.ShapePath=Qp,d.SharedRenderPipes=Tu,d.SharedSystems=xu,d.SplitBitmapText=SM,d.SplitText=GM,d.Sprite=Lt,d.SpritePipe=lu,d.Spritesheet=Jn,d.State=Rt,d.StencilMask=io,d.StencilMaskPipe=Pl,d.SystemRunner=ka,d.TEXTURE_FORMAT_BLOCK_SIZE=Xg,d.Text=Vs,d.TextStyle=Mt,d.Texture=w,d.TextureGCSystem=Kv,d.TextureMatrix=$n,d.TexturePool=et,d.TexturePoolClass=nh,d.TextureSource=Q,d.TextureStyle=Et,d.TextureUvs=sC,d.Ticker=at,d.TickerListener=Bi,d.TickerPlugin=Kn,d.TilingSprite=ib,d.TilingSpriteGpuData=ym,d.TilingSpritePipe=wa,d.TilingSpriteShader=mm,d.Transform=Q_,d.Triangle=Ba,d.UNIFORM_TO_ARRAY_SETTERS=av,d.UNIFORM_TO_SINGLE_SETTERS=ov,d.UNIFORM_TYPES_MAP=Wd,d.UNIFORM_TYPES_VALUES=So,d.UPDATE_BLEND=Gi,d.UPDATE_COLOR=Er,d.UPDATE_PRIORITY=Wt,d.UPDATE_TRANSFORM=fT,d.UPDATE_VISIBLE=Le,d.UboBatch=ny,d.UboSystem=Ul,d.UniformGroup=nt,d.VERSION=ei,d.VideoSource=He,d.ViewContainer=Kt,d.ViewSystem=Jv,d.ViewableBuffer=Ae,d.WGSL_ALIGN_SIZE_DATA=pi,d.WGSL_TO_STD40_SIZE=kl,d.WRAP_MODES=rC,d.WebGLRenderer=iy,d.WebGPURenderer=Ay,d.WorkerManager=Ka,d.accessibilityTarget=Rh,d.addBits=go,d.addMaskBounds=ki,d.addMaskLocalBounds=$i,d.addProgramDefines=bd,d.alphaFrag=l_,d.alphaWgsl=cl,d.appendSVGPath=ua,d.applyMatrix=bm,d.applyProjectiveTransformationToPlane=Gy,d.applyStyleParams=Jl,d.assignWithIgnore=Oi,d.autoDetectEnvironment=W2,d.autoDetectRenderer=jm,d.autoDetectSource=s1,d.basisTranscoderUrls=Ms,d.bgr2rgb=$e,d.bitmapFontCachePlugin=Km,d.bitmapFontTextParser=As,d.bitmapFontXMLParser=ja,d.bitmapFontXMLStringParser=za,d.bitmapTextSplit=_x,d.blendTemplateFrag=e_,d.blendTemplateVert=r_,d.blendTemplateWgsl=i_,d.blockDataMap=Fu,d.blurTemplateWgsl=g_,d.boundsPool=Vt,d.browserExt=LE,d.buildAdaptiveBezier=Jo,d.buildAdaptiveQuadratic=Vp,d.buildArc=ra,d.buildArcTo=Wp,d.buildArcToSvg=Kp,d.buildCircle=Je,d.buildContextBatches=Cp,d.buildEllipse=op,d.buildGeometryFromPath=fC,d.buildLine=cp,d.buildPixelLine=hp,d.buildPolygon=vp,d.buildRectangle=yp,d.buildRoundedRectangle=ap,d.buildSimpleUvs=Po,d.buildTriangle=xp,d.buildUvs=Eo,d.cacheAsTextureMixin=Ec,d.cacheTextureArray=Qm,d.calculatePathArea=nf,d.calculateProjection=Xb,d.canvasTextSplit=Sx,d.checkChildrenDidChange=In,d.checkDataUrl=Oe,d.checkExtension=Ut,d.checkForNestedPattern=rf,d.checkMaxIfStatementsInShader=ho,d.childrenHelperMixin=Pc,d.cleanArray=jv,d.cleanHash=Hv,d.clearList=sn,d.closePointEps=wo,d.collectAllRenderables=hC,d.collectRenderablesMixin=wc,d.color32BitToUniform=rr,d.colorBit=Vi,d.colorBitGl=Wi,d.colorMatrixFilterFrag=E_,d.colorMatrixFilterWgsl=fl,d.colorToUniform=vS,d.compareModeToGlCompare=_v,d.compileHighShader=Fd,d.compileHighShaderGl=Dd,d.compileHighShaderGlProgram=qe,d.compileHighShaderGpuProgram=Ke,d.compileHooks=_o,d.compileInputs=bo,d.compileOutputs=Id,d.compileShader=zl,d.compute2DProjection=Dy,d.convertFormatIfRequired=CE,d.convertToList=Dt,d.copySearchParams=Di,d.createIdFromString=We,d.createIndicesForQuads=zo,d.createLevelBuffers=lE,d.createLevelBuffersFromKTX=ME,d.createStringVariations=$h,d.createTexture=de,d.createUboElementsSTD40=Fb,d.createUboElementsWGSL=uy,d.createUboSyncFunction=$l,d.createUboSyncFunctionSTD40=Lb,d.createUboSyncFunctionWGSL=hy,d.crossOrigin=Rg,d.cullingMixin=vc,d.curveEps=Ro,d.defaultFilterVert=Kr,d.defaultValue=Wl,d.definedProps=kt,d.deprecation=Mr,d.detectAvif=Jm,d.detectBasis=iE,d.detectCompressed=UE,d.detectDefaults=eg,d.detectMp4=rg,d.detectOgv=ig,d.detectVideoAlphaMode=no,d.detectWebm=sg,d.detectWebp=ng,d.determineCrossOrigin=Mg,d.displacementFrag=R_,d.displacementVert=C_,d.displacementWgsl=ml,d.earcut=bp,d.effectsMixin=Gc,d.ensureAttributes=Cl,d.ensureIsBuffer=po,d.ensurePrecision=vd,d.ensureTextOptions=zs,d.executeInstructions=rn,d.extensions=F,d.extractAttributesFromGlProgram=tv,d.extractAttributesFromGpuProgram=Rd,d.extractFontFamilies=qf,d.extractStructAndGroups=zi,d.extractSubpaths=sf,d.extractSvgUrlId=oa,d.fastCopy=Xi,d.findMixin=Bc,d.fontStringFromTextStyle=Wr,d.formatShader=iw,d.fragmentGPUTemplate=Ld,d.fragmentGlTemplate=Xd,d.generateArraySyncSTD40=$b,d.generateArraySyncWGSL=cy,d.generateBlurFragSource=p_,d.generateBlurGlProgram=m_,d.generateBlurProgram=__,d.generateBlurVertSource=f_,d.generateGPULayout=ew,d.generateGpuLayoutGroups=Cd,d.generateLayout=rw,d.generateLayoutHash=Md,d.generateParticleUpdateFunction=Fp,d.generateProgram=nv,d.generateShaderSyncCode=qb,d.generateTextStyleKey=BM,d.generateTextureBatchBit=Yi,d.generateTextureBatchBitGl=Ki,d.generateTextureMatrix=Rp,d.generateUniformsSync=lv,d.getAdjustedBlendModeBlend=ze,d.getAttributeInfoFromFormat=se,d.getBatchSamplersUniformGroup=qi,d.getBitmapTextLayout=gs,d.getCanvasBoundingBox=Ef,d.getCanvasFillStyle=Yr,d.getCanvasTexture=Xl,d.getDefaultUniformValue=Yd,d.getFastGlobalBounds=oC,d.getFastGlobalBoundsMixin=Fc,d.getFillInstructionData=XS,d.getFontCss=Jf,d.getFontFamilyName=fg,d.getGeometryBounds=fd,d.getGlTypeFromFormat=Rb,d.getGlobalBounds=Sr,d.getGlobalMixin=kc,d.getGlobalRenderableBounds=Um,d.getLocalBounds=wi,d.getMaxFragmentPrecision=_d,d.getMaxTexturesPerBatch=sd,d.getOrientationOfPoints=lp,d.getPo2TextureFromSource=da,d.getResolutionOfUrl=Es,d.getSVGUrl=tm,d.getSupportedCompressedTextureFormats=sl,d.getSupportedGPUCompressedTextureFormats=rl,d.getSupportedGlCompressedTextureFormats=el,d.getSupportedTextureFormats=ni,d.getTemporaryCanvasFromImage=em,d.getTestContext=co,d.getTextureBatchBindGroup=Ni,d.getTextureDefaultMatrix=JC,d.getTextureFormatFromKTXTexture=BE,d.getUboData=ev,d.getUniformData=rv,d.getUrlExtension=Hh,d.glFormatToGPUFormat=Zg,d.glUploadBufferImageResource=pv,d.glUploadCompressedTextureResource=fv,d.glUploadImageResource=Zl,d.glUploadVideoResource=mv,d.globalUniformsBit=Hd,d.globalUniformsBitGl=jd,d.globalUniformsUBOBitGl=P1,d.gpuFormatToBasisTranscoderFormat=cE,d.gpuFormatToKTXBasisTranscoderFormat=FE,d.gpuUploadBufferImageResource=gy,d.gpuUploadCompressedTextureResource=_y,d.gpuUploadImageResource=Du,d.gpuUploadVideoResource=by,d.groupD8=N,d.hasCachedCanvasTexture=Cw,d.hslWgsl=DP,d.hslgl=zE,d.hslgpu=VE,d.injectBits=vo,d.insertVersion=yd,d.isMobile=yh,d.isPow2=Dn,d.isRenderingToScreen=zb,d.isSafari=Wf,d.isSingleItem=Cr,d.isWebGLSupported=Qr,d.isWebGPUSupported=Jr,d.ktxTranscoderUrls=Os,d.loadBasis=aE,d.loadBasisOnWorker=Ng,d.loadBitmapFont=qm,d.loadDDS=_E,d.loadEnvironmentExtensions=Da,d.loadFontAsBase64=Zf,d.loadFontCSS=Qf,d.loadImageBitmap=Ag,d.loadJson=cg,d.loadKTX=AE,d.loadKTX2=RE,d.loadKTX2onWorker=Kg,d.loadSVGImage=rm,d.loadSvg=vg,d.loadTextures=qa,d.loadTxt=hg,d.loadVideoTextures=Og,d.loadWebFont=mg,d.localUniformBit=ur,d.localUniformBitGl=vs,d.localUniformBitGroup2=dm,d.localUniformMSDFBit=Gf,d.localUniformMSDFBitGl=Bf,d.log2=j0,d.logDebugTexture=UM,d.logProgramError=sv,d.logRenderGroupScene=Bx,d.logScene=Gx,d.mSDFBit=If,d.mSDFBitGl=Ff,d.mapFormatToGlFormat=bv,d.mapFormatToGlInternalFormat=xv,d.mapFormatToGlType=Tv,d.mapGlToVertexFormat=Jb,d.mapSize=Uw,d.mapType=Yl,d.mapWebGLBlendModesToPixi=uv,d.maskFrag=k_,d.maskVert=$_,d.maskWgsl=bl,d.matrixPool=ct,d.measureHtmlText=Sa,d.measureMixin=Lc,d.migrateFragmentFromV7toV8=Fw,d.mipmapScaleModeToGlFilter=gv,d.multiplyColors=Ar,d.multiplyHexColors=Bn,d.nextPow2=_e,d.noiseFrag=B_,d.noiseWgsl=gl,d.nonCompressedFormats=kg,d.normalizeExtensionPriority=vr,d.onRenderMixin=Nc,d.parseDDS=Hg,d.parseFunctionBody=nC,d.parseKTX=zg,d.parseSVGDefinitions=tf,d.parseSVGFloatAttribute=tt,d.parseSVGPath=jp,d.parseSVGStyle=la,d.particleData=ju,d.particlesFrag=kp,d.particlesVert=$p,d.particlesWgsl=Vo,d.passthroughFrag=Im,d.passthroughWgsl=Oa,d.path=_t,d.pointInTriangle=Ga,d.preloadVideo=Cg,d.removeItems=Gn,d.removeStructAndGroupDuplicates=Od,d.resetUids=U0,d.resolveCharacters=Nf,d.resolveCompressedTextureUrl=DE,d.resolveJsonUrl=Gg,d.resolveTextureUrl=tl,d.resourceToTexture=Jh,d.roundPixelsBit=Ze,d.roundPixelsBitGl=Qe,d.roundedShapeArc=qp,d.roundedShapeQuadraticCurve=Zp,d.sayHello=Xv,d.scaleModeToGlFilter=Ql,d.setBasisTranscoderPath=nE,d.setKTXTranscoderPath=PE,d.setPositions=_m,d.setProgramName=xd,d.setUvs=vm,d.shapeBuilders=er,d.sortMixin=Xc,d.spritesheetAsset=Vh,d.squaredDistanceToLineSegment=Hr,d.stripVersion=Td,d.styleAttributes=aa,d.testImageFormat=Va,d.testVideoFormat=ri,d.textStyleToCSS=lb,d.textureBit=vb,d.textureBitGl=yb,d.textureFrom=td,d.tilingBit=pm,d.tilingBitGl=fm,d.toFillStyle=ue,d.toLocalGlobalMixin=Hc,d.toStrokeStyle=Vr,d.transformVertices=Ji,d.triangulateWithHoles=Go,d.uboSyncFunctionsSTD40=Ll,d.uboSyncFunctionsWGSL=kb,d.uid=Y,d.uniformParsers=pe,d.unpremultiplyAlpha=Zw,d.unsafeEvalSupported=Ua,d.updateLocalTransform=dC,d.updateQuadBounds=to,d.updateRenderGroupTransform=Av,d.updateRenderGroupTransforms=nu,d.updateTextBounds=as,d.updateTransformAndChildren=ou,d.updateTransformBackwards=Pi,d.updateWorldTransform=pC,d.v8_0_0=uo,d.v8_3_4=o1,d.validFormats=Gs,d.validateRenderables=Pv,d.vertexGPUTemplate=$d,d.vertexGlTemplate=Nd,d.vkFormatToGPUFormat=Qg,d.warn=Xt,d.wrapModeToGlAddress=en,d}({});
//# sourceMappingURL=pixi.min.js.map