var IS=Object.defineProperty;var Zc=Object.getOwnPropertySymbols;var FS=Object.prototype.hasOwnProperty,BS=Object.prototype.propertyIsEnumerable;var Qc=(r,t,e)=>t in r?IS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jc=(r,t)=>{for(var e in t||(t={}))FS.call(t,e)&&Qc(r,e,t[e]);if(Zc)for(var e of Zc(t))BS.call(t,e)&&Qc(r,e,t[e]);return r};/*! * PixiJS - v8.21.0 * Compiled Thu, 17 Sep 2026 07:42:29 UTC * * PixiJS is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license */var DS=Object.defineProperty,$S=Object.defineProperties,US=Object.getOwnPropertyDescriptors,td=Object.getOwnPropertySymbols,kS=Object.prototype.hasOwnProperty,LS=Object.prototype.propertyIsEnumerable,ed=(r,t,e)=>t in r?DS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rd=(r,t)=>{for(var e in t||(t={}))kS.call(t,e)&&ed(r,e,t[e]);if(td)for(var e of td(t))LS.call(t,e)&&ed(r,e,t[e]);return r},NS=(r,t)=>$S(r,US(t)),T=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGLLoader="webgl-loader",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.WebGPULoader="webgpu-loader",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.CanvasLoader="canvas-loader",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.TextureUploaderWebGL="texture-uploader-webgl",r.TextureUploaderWebGPU="texture-uploader-webgpu",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(T||{});const No=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){const t=typeof r.extension!="object"?{type:r.extension}:r.extension;r=NS(rd({},t),{ref:r})}if(typeof r=="object")r=rd({},r);else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},ds=(r,t)=>{var e;return(e=No(r).priority)!=null?e:t},L={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(No).forEach(t=>{t.type.forEach(e=>{var s,i;return(i=(s=this._removeHandlers)[e])==null?void 0:i.call(s,t)})}),this},add(...r){return r.map(No).forEach(t=>{t.type.forEach(e=>{var s,i;const n=this._addHandlers,o=this._queue;n[e]?(i=n[e])==null||i.call(n,t):(o[e]=o[e]||[],(s=o[e])==null||s.push(t))})}),this},handle(r,t,e){var s;const i=this._addHandlers,n=this._removeHandlers;i[r]=t,n[r]=e;const o=this._queue;return o[r]&&((s=o[r])==null||s.forEach(a=>t(a)),delete o[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(r,t,e=-1){return this.handle(r,s=>{t.findIndex(i=>i.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((i,n)=>ds(n.value,e)-ds(i.value,e)))},s=>{const i=t.findIndex(n=>n.name===s.name);i!==-1&&t.splice(i,1)})},handleByList(r,t,e=-1){return this.handle(r,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((i,n)=>ds(n,e)-ds(i,e)))},s=>{const i=t.indexOf(s.ref);i!==-1&&t.splice(i,1)})},mixin(r,...t){for(const e of t)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(e))}};var $B=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function jS(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function UB(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function kB(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function LB(r){if(Object.prototype.hasOwnProperty.call(r,"__esModule"))return r;var t=r.default;if(typeof t=="function"){var e=function s(){var i=!1;try{i=this instanceof s}catch(n){}return 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(s){var i=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:function(){return r[s]}})}),e}var fi={exports:{}},NB=fi.exports,sd;function XS(){return sd||(sd=1,(function(r){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function i(l,u,h){this.fn=l,this.context=u,this.once=h||!1}function n(l,u,h,c,d){if(typeof h!="function")throw new TypeError("The listener must be a function");var p=new i(h,c||l,d),f=e?e+u:u;return l._events[f]?l._events[f].fn?l._events[f]=[l._events[f],p]:l._events[f].push(p):(l._events[f]=p,l._eventsCount++),l}function o(l,u){--l._eventsCount===0?l._events=new s:delete l._events[u]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var u=[],h,c;if(this._eventsCount===0)return u;for(c in h=this._events)t.call(h,c)&&u.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(h)):u},a.prototype.listeners=function(u){var h=e?e+u:u,c=this._events[h];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,p=c.length,f=new Array(p);d0:typeof r=="number"},Ft=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},oe=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},id=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},nd=function(r){return{r:oe(r.r,0,255),g:oe(r.g,0,255),b:oe(r.b,0,255),a:oe(r.a)}},jo=function(r){return{r:Ft(r.r),g:Ft(r.g),b:Ft(r.b),a:Ft(r.a,3)}},WS=/^#([0-9a-f]{3,8})$/i,mi=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},od=function(r){var t=r.r,e=r.g,s=r.b,i=r.a,n=Math.max(t,e,s),o=n-Math.min(t,e,s),a=o?n===t?(e-s)/o:n===e?2+(s-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:i}},ad=function(r){var t=r.h,e=r.s,s=r.v,i=r.a;t=t/360*6,e/=100,s/=100;var n=Math.floor(t),o=s*(1-e),a=s*(1-(t-n)*e),l=s*(1-(1-t+n)*e),u=n%6;return{r:255*[s,a,o,o,l,s][u],g:255*[l,s,s,a,o,o][u],b:255*[o,o,l,s,s,a][u],a:i}},ld=function(r){return{h:id(r.h),s:oe(r.s,0,100),l:oe(r.l,0,100),a:oe(r.a)}},ud=function(r){return{h:Ft(r.h),s:Ft(r.s),l:Ft(r.l),a:Ft(r.a,3)}},hd=function(r){return ad((e=(t=r).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},ps=function(r){return{h:(t=od(r)).h,s:(i=(200-(e=t.s))*(s=t.v)/100)>0&&i<200?e*s/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,e,s,i},VS=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,YS=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,KS=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,qS=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Xo={string:[[function(r){var t=WS.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?Ft(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?Ft(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=KS.exec(r)||qS.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:nd({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=VS.exec(r)||YS.exec(r);if(!t)return null;var e,s,i=ld({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(zS[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return hd(i)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,s=r.b,i=r.a,n=i===void 0?1:i;return Ie(t)&&Ie(e)&&Ie(s)?nd({r:Number(t),g:Number(e),b:Number(s),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,s=r.l,i=r.a,n=i===void 0?1:i;if(!Ie(t)||!Ie(e)||!Ie(s))return null;var o=ld({h:Number(t),s:Number(e),l:Number(s),a:Number(n)});return hd(o)},"hsl"],[function(r){var t=r.h,e=r.s,s=r.v,i=r.a,n=i===void 0?1:i;if(!Ie(t)||!Ie(e)||!Ie(s))return null;var o=(function(a){return{h:id(a.h),s:oe(a.s,0,100),v:oe(a.v,0,100),a:oe(a.a)}})({h:Number(t),s:Number(e),v:Number(s),a:Number(n)});return ad(o)},"hsv"]]},cd=function(r,t){for(var e=0;e=.5},r.prototype.toHex=function(){return t=jo(this.rgba),e=t.r,s=t.g,i=t.b,o=(n=t.a)<1?mi(Ft(255*n)):"","#"+mi(e)+mi(s)+mi(i)+o;var t,e,s,i,n,o},r.prototype.toRgb=function(){return jo(this.rgba)},r.prototype.toRgbString=function(){return t=jo(this.rgba),e=t.r,s=t.g,i=t.b,(n=t.a)<1?"rgba("+e+", "+s+", "+i+", "+n+")":"rgb("+e+", "+s+", "+i+")";var t,e,s,i,n},r.prototype.toHsl=function(){return ud(ps(this.rgba))},r.prototype.toHslString=function(){return t=ud(ps(this.rgba)),e=t.h,s=t.s,i=t.l,(n=t.a)<1?"hsla("+e+", "+s+"%, "+i+"%, "+n+")":"hsl("+e+", "+s+"%, "+i+"%)";var t,e,s,i,n},r.prototype.toHsv=function(){return t=od(this.rgba),{h:Ft(t.h),s:Ft(t.s),v:Ft(t.v),a:Ft(t.a,3)};var t},r.prototype.invert=function(){return xe({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),xe(Ho(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),xe(Ho(this.rgba,-t))},r.prototype.grayscale=function(){return xe(Ho(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),xe(pd(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),xe(pd(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"?xe({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Ft(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=ps(this.rgba);return typeof t=="number"?xe({h:t,s:e.s,l:e.l,a:e.a}):Ft(e.h)},r.prototype.isEqual=function(t){return this.toHex()===xe(t).toHex()},r})(),xe=function(r){return r instanceof gi?r:new gi(r)},fd=[],ZS=function(r){r.forEach(function(t){fd.indexOf(t)<0&&(t(gi,Xo),fd.push(t))})},XB=function(){return new gi({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function QS(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var i in e)s[e[i]]=i;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,u=s[this.toHex()];if(u)return u;if(o!=null&&o.closest){var h=this.toRgb(),c=1/0,d="black";if(!n.length)for(var p in e)n[p]=new r(e[p]).toRgb();for(var f in e){var m=(a=h,l=n[f],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));mt in r?JS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,r2=(r,t)=>{for(var e in t||(t={}))t2.call(t,e)&&gd(r,e,t[e]);if(md)for(var e of md(t))e2.call(t,e)&&gd(r,e,t[e]);return r};ZS([QS]);const Ar=class li{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 li)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?r2({},t):t}_isSourceEqual(t,e){const s=typeof t;if(s!==typeof e)return!1;if(s==="number"||s==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((i,n)=>i===e[n]);if(t!==null&&e!==null){const i=Object.keys(t),n=Object.keys(e);return i.length!==n.length?!1:i.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,s,i]=this._components;return{r:t,g:e,b:s,a:i}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,i]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(i*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,s,i,n]=this._components;return t[0]=e,t[1]=s,t[2]=i,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,s,i]=this._components;return t[0]=e,t[1]=s,t[2]=i,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,i,n]=li._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=i,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,i=this._int>>8&255,n=this._int&255;return e&&(s=s*t+.5|0,i=i*t+.5|0,n=n*t+.5|0),(t*255<<24)+(s<<16)+(i<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this._value=null,this}_normalize(t){let e,s,i,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,s=(o>>8&255)/255,i=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,i,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,i,n=255]=t,e/=255,s/=255,i/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=li.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=xe(t);o.isValid()&&({r:e,g:s,b:i,a:n}=o.rgba,e/=255,s/=255,i/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=i,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((i,n)=>{t[n]=Math.min(Math.max(i,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof li||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}};Ar.shared=new Ar,Ar._temp=new Ar,Ar.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let tt=Ar;const _d={cullArea:null,cullable:!1,cullableChildren:!0},xd=Math.PI*2,vd=180/Math.PI,bd=Math.PI/180;class lt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new lt(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 Wo.x=0,Wo.y=0,Wo}}const Wo=new lt;class D{constructor(t=1,e=0,s=0,i=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=s,this.d=i,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,s,i,n,o){return this.a=t,this.b=e,this.c=s,this.d=i,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const s=e||this.array;return t?(s[0]=this.a,s[1]=this.b,s[2]=0,s[3]=this.c,s[4]=this.d,s[5]=0,s[6]=this.tx,s[7]=this.ty,s[8]=1):(s[0]=this.a,s[1]=this.c,s[2]=this.tx,s[3]=this.b,s[4]=this.d,s[5]=this.ty,s[6]=0,s[7]=0,s[8]=1),s}apply(t,e){e=e||new lt;const s=t.x,i=t.y;return e.x=this.a*s+this.c*i+this.tx,e.y=this.b*s+this.d*i+this.ty,e}applyInverse(t,e){e=e||new lt;const s=this.a,i=this.b,n=this.c,o=this.d,a=this.tx,l=this.ty,u=1/(s*o+n*-i),h=t.x,c=t.y;return e.x=o*u*h+-n*u*c+(l*n-a*o)*u,e.y=s*u*c+-i*u*h+(-l*s+a*i)*u,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),s=Math.sin(t),i=this.a,n=this.c,o=this.tx;return this.a=i*e-this.b*s,this.b=i*s+this.b*e,this.c=n*e-this.d*s,this.d=n*s+this.d*e,this.tx=o*e-this.ty*s,this.ty=o*s+this.ty*e,this}append(t){const e=this.a,s=this.b,i=this.c,n=this.d;return this.a=t.a*e+t.b*i,this.b=t.a*s+t.b*n,this.c=t.c*e+t.d*i,this.d=t.c*s+t.d*n,this.tx=t.tx*e+t.ty*i+this.tx,this.ty=t.tx*s+t.ty*n+this.ty,this}appendFrom(t,e){const s=t.a,i=t.b,n=t.c,o=t.d,a=t.tx,l=t.ty,u=e.a,h=e.b,c=e.c,d=e.d;return this.a=s*u+i*c,this.b=s*h+i*d,this.c=n*u+o*c,this.d=n*h+o*d,this.tx=a*u+l*c+e.tx,this.ty=a*h+l*d+e.ty,this}setTransform(t,e,s,i,n,o,a,l,u){return this.a=Math.cos(a+u)*n,this.b=Math.sin(a+u)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(s*this.a+i*this.c),this.ty=e-(s*this.b+i*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const s=this.a,i=this.c;this.a=s*t.a+this.b*t.c,this.b=s*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,s=this.b,i=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-i,n),l=Math.atan2(s,e),u=Math.abs(a+l);let h=Math.sqrt(e*e+s*s);return u<1e-5||Math.abs(xd-u)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):Math.abs(Math.PI-u)<1e-5?(t.rotation=l-Math.PI,t.skew.x=t.skew.y=0,h=-h):(t.rotation=0,t.skew.x=a,t.skew.y=l),t.scale.x=h,t.scale.y=Math.sqrt(i*i+n*n),t.position.x=this.tx+(o.x*e+o.y*i),t.position.y=this.ty+(o.x*s+o.y*n),t}invert(){const t=this.a,e=this.b,s=this.c,i=this.d,n=this.tx,o=t*i-e*s;return this.a=i/o,this.b=-e/o,this.c=-s/o,this.d=t/o,this.tx=(s*this.ty-i*n)/o,this.ty=-(t*this.ty-e*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new D;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 i2.identity()}static get shared(){return s2.identity()}}const s2=new D,i2=new D;class gt{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new gt(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 fs={default:-1};function ut(r="default"){return fs[r]===void 0&&(fs[r]=-1),++fs[r]}function n2(){for(const r in fs)delete fs[r]}const tr={_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 yd{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e0?s=this._pool[--this._index]:(s=new this._classType,this._count++),(e=s.init)==null||e.call(s,t),s}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const St=new Td;tr.register(St);const Sd={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 Vo(r,t,e){const s=r.length;let i;if(t>=s||e===0)return;e=t+e>s?s-t:e;const n=s-e;for(i=t;i0&&i<=s){for(let a=s-1;a>=r;a--){const l=this.children[a];l&&(n.push(l),l.parent=null)}Vo(this.children,r,s);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(n);for(let a=0;a0&&this._didViewChangeTick++,n}else if(i===0&&this.children.length===0)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){const t=this.getChildAt(r);return this.removeChild(t)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,t)},getChildIndex(r){const t=this.children.indexOf(r);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(r,t){const{children:e}=this;if(t<0||t>e.length)throw new Error(`${r}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);const s=r.parent===this;if(r.parent){const n=r.parent.children.indexOf(r);if(s){if(n===t)return r;r.parent.children.splice(n,1)}else r.removeFromParent()}t===e.length?e.push(r):e.splice(t,0,r);const i=this.renderGroup||this.parentRenderGroup;return this.sortableChildren&&(this.sortDirty=!0),s?(i&&(i.structureDidChange=!0),r):(r.parent=this,r.didChange=!0,r._updateFlags=15,i&&i.addChild(r),this.emit("childAdded",r,this,t),r.emit("added",this),r)},swapChildren(r,t){if(r===t)return;const e=this.getChildIndex(r),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=r;const i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(t=>this.reparentChildAt(t,this.children.length)),r[0])},reparentChildAt(r,t){if(r.parent===this)return this.setChildIndex(r,t),r;const e=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),r.setFromMatrix(e),r},replaceChild(r,t){r.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(r)),t.setFromMatrix(r.localTransform),t.updateLocalTransform(),this.removeChild(r)}},Ed={collectRenderables(r,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,t,e))},collectRenderablesSimple(r,t,e){const s=this.children,i=s.length;for(let n=0;n=0;i--){const n=this.effects[i];s[n.pipe].pop(n,this,r)}}};class ms{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;et in r?o2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Rd=(r,t)=>{for(var e in t||(t={}))a2.call(t,e)&&Cd(r,e,t[e]);if(Pd)for(var e of Pd(t))l2.call(t,e)&&Cd(r,e,t[e]);return r};const Md={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_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),_i.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=_i.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions=Rd(Rd({},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 ms);r=r;const s=(r==null?void 0:r.length)>0,i=((t=e.filters)==null?void 0:t.length)>0,n=s!==i;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),n&&(s?this.addEffect(e):(this.removeEffect(e),e.filters=r!=null?r:null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new ms),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},Od={label:null,get name(){return this.label},set name(r){this.label=r},getChildByName(r,t=!1){return this.getChildByLabel(r,t)},getChildByLabel(r,t=!1){const e=this.children;for(let s=0;s=this.x&&t=this.y&&e=c&&t<=d&&e>=p&&e<=f&&!(t>m&&t_&&et.right?t.right:this.right)<=E)return!1;const A=this.yt.bottom?t.bottom:this.bottom)>A}const s=this.left,i=this.right,n=this.top,o=this.bottom;if(i<=s||o<=n)return!1;const a=xi[0].set(t.left,t.top),l=xi[1].set(t.left,t.bottom),u=xi[2].set(t.right,t.top),h=xi[3].set(t.right,t.bottom);if(u.x<=a.x||l.y<=a.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(a,a),e.apply(l,l),e.apply(u,u),e.apply(h,h),Math.max(a.x,l.x,u.x,h.x)<=s||Math.min(a.x,l.x,u.x,h.x)>=i||Math.max(a.y,l.y,u.y,h.y)<=n||Math.min(a.y,l.y,u.y,h.y)>=o))return!1;const d=c*(l.y-a.y),p=c*(a.x-l.x),f=d*s+p*n,m=d*i+p*n,g=d*s+p*o,_=d*i+p*o;if(Math.max(f,m,g,_)<=d*a.x+p*a.y||Math.min(f,m,g,_)>=d*h.x+p*h.y)return!1;const x=c*(a.y-u.y),v=c*(u.x-a.x),b=x*s+v*n,S=x*i+v*n,y=x*s+v*o,w=x*i+v*o;return!(Math.max(b,S,y,w)<=x*a.x+v*a.y||Math.min(b,S,y,w)>=x*h.x+v*h.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),i=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=i,this.height=Math.max(n-i,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,i=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=i-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),i=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=i,this.height=n-i,this}getBounds(t){return t||(t=new it),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,s=t.y,i=t.x+t.width,n=t.y+t.height;return e>=this.x&&e=this.y&&s=this.x&&i<=this.x+this.width&&n>=this.y&&n<=this.y+this.height}set(t,e,s,i){return this.x=t,this.y=e,this.width=s,this.height=i,this}}const Gd=new D;class Ct{constructor(t=1/0,e=1/0,s=-1/0,i=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Gd,this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new it);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=Gd,this}set(t,e,s,i){this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}addFrame(t,e,s,i,n){n||(n=this.matrix);const o=n.a,a=n.b,l=n.c,u=n.d,h=n.tx,c=n.ty;let d=this.minX,p=this.minY,f=this.maxX,m=this.maxY,g=o*t+l*e+h,_=a*t+u*e+c;gf&&(f=g),_>m&&(m=_),g=o*s+l*e+h,_=a*s+u*e+c,gf&&(f=g),_>m&&(m=_),g=o*t+l*i+h,_=a*t+u*i+c,gf&&(f=g),_>m&&(m=_),g=o*s+l*i+h,_=a*s+u*i+c,gf&&(f=g),_>m&&(m=_),this.minX=d,this.minY=p,this.maxX=f,this.maxY=m}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxXthis.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*e+l*n+h,p=a*e+u*n+c,this.minX=dthis.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*i+l*n+h,p=a*i+u*n+c,this.minX=dthis.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,i){return this.minXe&&(this.maxX=e),this.minYi&&(this.maxY=i),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new Ct(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,s,i){let n=this.minX,o=this.minY,a=this.maxX,l=this.maxY;i||(i=this.matrix);const u=i.a,h=i.b,c=i.c,d=i.d,p=i.tx,f=i.ty;for(let m=e;ma?x: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 Ut=St.getPool(D),ve=St.getPool(Ct),u2=new D,Id={getFastGlobalBounds(r,t){t||(t=new Ct),t.clear(),this._getGlobalBoundsRecursive(!!r,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(r,t,e){let s=t;if(r&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const i=!!this.effects.length;if((this.renderGroup||i)&&(s=ve.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;s.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const n=this.children;for(let o=0;o>16&255,s=r>>8&255,i=r&255,n=t>>16&255,o=t>>8&255,a=t&255,l=e*n/255|0,u=s*o/255|0,h=i*a/255|0;return(l<<16)+(u<<8)+h}const Bd=16777215;function _s(r,t){return r===Bd?t:t===Bd?r:be(r,t)}function ye(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const Dd={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 D,t){if(t)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const e=vi(this,Ut.get().identity());return r.appendFrom(this.localTransform,e),Ut.return(e),r},getGlobalTint(r){if(r)return this.renderGroup?ye(this.renderGroup.worldColor):this.parentRenderGroup?ye(_s(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=_s(t,e.localColor),e=e.parent;return ye(t)}};function bi(r,t,e){return t.clear(),e||(e=D.IDENTITY),$d(r,t,e,r,!0),t.isValid||t.set(0,0,0,0),t}function $d(r,t,e,s,i){var n,o;let a;if(i)a=Ut.get(),a=e.copyTo(a);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const h=r.localTransform;a=Ut.get(),a.appendFrom(h,e)}const l=t,u=!!r.effects.length;if(u&&(t=ve.get().clear()),r.boundsArea)t.addRect(r.boundsArea,a);else{r.renderPipeId&&(t.matrix=a,t.addBounds(r.bounds));const h=r.children;for(let c=0;c>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function rr(r){return!(r&r-1)&&!!r}function d2(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 ce(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}var p2=Object.defineProperty,jd=Object.getOwnPropertySymbols,f2=Object.prototype.hasOwnProperty,m2=Object.prototype.propertyIsEnumerable,Xd=(r,t,e)=>t in r?p2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hd=(r,t)=>{for(var e in t||(t={}))f2.call(t,e)&&Xd(r,e,t[e]);if(jd)for(var e of jd(t))m2.call(t,e)&&Xd(r,e,t[e]);return r};const zd=Object.create(null);function g2(r){const t=zd[r];return t===void 0&&(zd[r]=ut("resource")),t}const Wd=class JT extends It{constructor(t={}){var e,s,i,n,o,a,l;super(),this._resourceType="textureSampler",this._maxAnisotropy=1,this.destroyed=!1,t=Hd(Hd({},JT.defaultOptions),t),this.addressMode=t.addressMode,this.addressModeU=(e=t.addressModeU)!=null?e:this.addressModeU,this.addressModeV=(s=t.addressModeV)!=null?s:this.addressModeV,this.addressModeW=(i=t.addressModeW)!=null?i:this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=(n=t.magFilter)!=null?n:this.magFilter,this.minFilter=(o=t.minFilter)!=null?o:this.minFilter,this.mipmapFilter=(a=t.mipmapFilter)!=null?a:this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=(l=t.maxAnisotropy)!=null?l:1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._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=g2(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Wd.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let ae=Wd;var _2=Object.defineProperty,Vd=Object.getOwnPropertySymbols,x2=Object.prototype.hasOwnProperty,v2=Object.prototype.propertyIsEnumerable,Yd=(r,t,e)=>t in r?_2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Kd=(r,t)=>{for(var e in t||(t={}))x2.call(t,e)&&Yd(r,e,t[e]);if(Vd)for(var e of Vd(t))v2.call(t,e)&&Yd(r,e,t[e]);return r};const qd=class tS extends It{constructor(t={}){var e,s,i,n,o;super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=ut("textureSource"),this._resourceType="textureSource",this._resourceId=ut("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this._ownsStyle=!1,this.antialias=!1,this.transient=!1,this._batchTick=-1,this._textureBindLocation=-1,t=Kd(Kd({},tS.defaultOptions),t),this.label=(e=t.label)!=null?e:"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource&&(s=this.resourceWidth)!=null?s:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&(i=this.resourceHeight)!=null?i:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.viewDimension=(n=t.viewDimension)!=null?n:t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.transient=(o=t.transient)!=null?o:!1,this.alphaMode=t.alphaMode,this.style=new ae(ce(t)),this._ownsStyle=!0,this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&(this._ownsStyle=!1,(e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._ownsStyle&&this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){var t,e;this._resourceId=ut("resource"),this.emit("change",this),this.emit("unload",this);for(const s in this._gpuData)(e=(t=this._gpuData[s])==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,s){s||(s=this._resolution),t||(t=this.width),e||(e=this.height);const i=Math.round(t*s),n=Math.round(e*s);return this.width=i/s,this.height=n/s,this._resolution=s,this.pixelWidth===i&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=i,this.pixelHeight=n,this.emit("resize",this),this._resourceId=ut("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=rr(this.pixelWidth)&&rr(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};qd.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let ct=qd;const sr=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],ir=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],nr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],or=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Ko=[],Zd=[],Ti=Math.sign;function b2(){for(let r=0;r<16;r++){const t=[];Ko.push(t);for(let e=0;e<16;e++){const s=Ti(sr[r]*sr[e]+nr[r]*ir[e]),i=Ti(ir[r]*sr[e]+or[r]*ir[e]),n=Ti(sr[r]*nr[e]+nr[r]*or[e]),o=Ti(ir[r]*nr[e]+or[r]*or[e]);for(let a=0;a<16;a++)if(sr[a]===s&&ir[a]===i&&nr[a]===n&&or[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new D;t.set(sr[r],ir[r],nr[r],or[r],0,0),Zd.push(t)}}b2();const H={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=>sr[r],uY:r=>ir[r],vX:r=>nr[r],vY:r=>or[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Ko[r][t],sub:(r,t)=>Ko[r][H.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?H.S:H.N:Math.abs(t)*2<=Math.abs(r)?r>0?H.E:H.W:t>0?r>0?H.SE:H.SW:r>0?H.NE:H.NW,matrixAppendRotationInv:(r,t,e=0,s=0,i=0,n=0)=>{const o=Zd[H.inv(t)],a=o.a,l=o.b,u=o.c,h=o.d,c=e-Math.min(0,a*i,u*n,a*i+u*n),d=s-Math.min(0,l*i,h*n,l*i+h*n),p=r.a,f=r.b,m=r.c,g=r.d;r.a=a*p+l*m,r.b=a*f+l*g,r.c=u*p+h*m,r.d=u*f+h*g,r.tx=c*p+d*m+r.tx,r.ty=c*f+d*g+r.ty},transformRectCoords:(r,t,e,s)=>{const{x:i,y:n,width:o,height:a}=r,{x:l,y:u,width:h,height:c}=t;return e===H.E?(s.set(i+l,n+u,o,a),s):e===H.S?s.set(h-n-a+l,i+u,a,o):e===H.W?s.set(h-i-o+l,c-n-a+u,o,a):e===H.N?s.set(n+l,c-i-o+u,a,o):s.set(i+l,n+u,o,a)}},qo=()=>{};var y2=Object.defineProperty,T2=Object.defineProperties,S2=Object.getOwnPropertyDescriptors,Qd=Object.getOwnPropertySymbols,w2=Object.prototype.hasOwnProperty,E2=Object.prototype.propertyIsEnumerable,Jd=(r,t,e)=>t in r?y2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,A2=(r,t)=>{for(var e in t||(t={}))w2.call(t,e)&&Jd(r,e,t[e]);if(Qd)for(var e of Qd(t))E2.call(t,e)&&Jd(r,e,t[e]);return r},P2=(r,t)=>T2(r,S2(t));class Si extends ct{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super(P2(A2({},t),{resource:e,format:s})),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}Si.extension=T.TextureSource;const tp=new D;class Zo{constructor(t,e){this.mapCoord=new D,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),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()}destroy(){var t;(t=this._texture)==null||t.removeListener("update",this.update,this),this._texture=null}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let i=0;i=t)return i}}_update(){this._widths=[...this._screenSizes.values()].map(t=>t.pixelWidth).filter((t,e,s)=>s.indexOf(t)===e).sort((t,e)=>t-e),this._heights=[...this._screenSizes.values()].map(t=>t.pixelHeight).filter((t,e,s)=>s.indexOf(t)===e).sort((t,e)=>t-e)}}var C2=Object.defineProperty,R2=Object.defineProperties,M2=Object.getOwnPropertyDescriptors,ep=Object.getOwnPropertySymbols,O2=Object.prototype.hasOwnProperty,G2=Object.prototype.propertyIsEnumerable,rp=(r,t,e)=>t in r?C2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,I2=(r,t)=>{for(var e in t||(t={}))O2.call(t,e)&&rp(r,e,t[e]);if(ep)for(var e of ep(t))G2.call(t,e)&&rp(r,e,t[e]);return r},F2=(r,t)=>R2(r,M2(t));let B2=0;const HB=32767,D2=4294967296,$2=8589934592,sp=Object.create(null);let U2=0;function k2(r){const t=sp[r];return t!==void 0?t:sp[r]=U2++}function L2(r,t,e,s,i,n){return(r<<17)+(t<<2)+((s?1:0)<<1)+(e?1:0)+(n==="nearest"?1:0)*D2+k2(i)*$2}class ip{constructor(t){this._buckets=new Map,this._poolKey=Object.create(null),this._poolStyle=Object.create(null),this._screens=new Qo,this._enableFullScreen=!1,this.textureOptions=t||{}}get textureStyle(){return this._textureStyle||(this._textureStyle=new ae(this.textureOptions)),this._textureStyle}set textureStyle(t){this._textureStyle=t}get enableFullScreen(){return this._enableFullScreen}set enableFullScreen(t){this._enableFullScreen=t}createTexture(...t){var e,s,i,n,o,a,l,u;let h=t[0];typeof h=="number"&&(h={width:h,height:t[1],antialias:(e=t[2])!=null?e:!1,autoGenerateMipmaps:(s=t[3])!=null?s:!1});const c=(n=(i=h.format)!=null?i:this.textureOptions.format)!=null?n:ct.defaultOptions.format,d=(a=(o=h.scaleMode)!=null?o:this.textureOptions.scaleMode)!=null?a:ae.defaultOptions.scaleMode,p=new ct(F2(I2({},this.textureOptions),{width:h.width,height:h.height,resolution:1,antialias:(l=h.antialias)!=null?l:!1,autoGarbageCollect:!1,autoGenerateMipmaps:(u=h.autoGenerateMipmaps)!=null?u:!1,format:c,scaleMode:d}));return new B({source:p,label:`texturePool_${B2++}`})}getOptimalTexture(...t){var e,s,i,n,o,a,l,u,h,c;let d=t[0];typeof d=="number"&&(d={width:d,height:t[1],resolution:(e=t[2])!=null?e:1,antialias:(s=t[3])!=null?s:!1,autoGenerateMipmaps:(i=t[4])!=null?i:!1});const p=d.width,f=d.height,m=(n=d.resolution)!=null?n:1,g=(o=d.antialias)!=null?o:!1,_=(a=d.autoGenerateMipmaps)!=null?a:!1,x=(u=(l=d.format)!=null?l:this.textureOptions.format)!=null?u:ct.defaultOptions.format,v=(c=(h=d.scaleMode)!=null?h:this.textureOptions.scaleMode)!=null?c:ae.defaultOptions.scaleMode,{width:b,height:S}=this.getOptimalSize(p,f,m),y=L2(b,S,g,_,x,v);let w=this._buckets.get(y);w||(w=[],this._buckets.set(y,w));let E=w.pop();return E||(E=this.createTexture({width:b,height:S,antialias:g,autoGenerateMipmaps:_,format:x,scaleMode:v}),this._poolStyle[E.uid]=E.source.style),E.source._resolution=m,E.source.width=b/m,E.source.height=S/m,E.source.pixelWidth=b,E.source.pixelHeight=S,E.frame.x=0,E.frame.y=0,E.frame.width=p,E.frame.height=f,E.updateUvs(),this._poolKey[E.uid]=y,E}getOptimalSize(t,e,s=1){const i=Math.ceil(t*s-1e-6),n=Math.ceil(e*s-1e-6),o=er(i),a=this._screens.getFittingWidth(i),l=er(n),u=this._screens.getFittingHeight(n);return{width:a!==void 0?Math.min(a,o):o,height:u!==void 0?Math.min(u,l):l}}getSameSizeTexture(t,e=!1){const s=t.source;return this.getOptimalTexture({width:t.width,height:t.height,resolution:s._resolution,antialias:e})}returnTexture(t,e=!1){const s=t.uid,i=this._poolKey[s];if(i===void 0)return;const n=this._poolStyle[s];e&&t.source.style!==n&&(t.source.style=n);const o=this._buckets.get(i);if(!o){delete this._poolKey[s],delete this._poolStyle[s],t.destroy(!0);return}o.push(t)}setScreenSize(t,e,s){this._screens.set(t,e,s)&&this._pruneScreenTextures()}removeScreen(t){this._screens.remove(t)&&this._pruneScreenTextures()}_pruneScreenTextures(){for(const[t,e]of this._buckets){const s=t>>>0,i=s>>>17,n=s>>>2&32767;(rr(i)||this._screens.hasWidth(i))&&(rr(n)||this._screens.hasHeight(n))||(this._dropTextures(e,!0),this._buckets.delete(t))}}_dropTextures(t,e){for(let s=0;s-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s0}addOnRender(t){this._onRenderContainers.indexOf(t)===-1&&this._onRenderContainers.push(t)}removeOnRender(t){const e=this._onRenderContainers.indexOf(t);e!==-1&&this._onRenderContainers.splice(e,1)}runOnRender(t){for(let e=0;ethis.addChild(i)),(s=t.parent)==null||s.addChild(this)}static mixin(t){L.mixin(dt,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(t.length>1){for(let i=0;i1){for(let i=0;i-1&&(this._didViewChangeTick++,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,s),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=St.get(wi,this),this.groupTransform=D.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 D),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*vd}set angle(t){this.rotation=t*bd}get pivot(){return this._pivot===ta&&(this._pivot=new gt(this,0,0)),this._pivot}set pivot(t){this._pivot===ta&&(this._pivot=new gt(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Jo&&(this._skew=new gt(this,0,0)),this._skew}set skew(t){this._skew===Jo&&(this._skew=new gt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===ea&&(this._scale=new gt(this,1,1)),this._scale}set scale(t){this._scale===ea&&(this._scale=new gt(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===ra&&(this._origin=new gt(this,0,0)),this._origin}set origin(t){this._origin===ra&&(this._origin=new gt(this,0,0)),typeof t=="number"?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){var s;const i=this.getLocalBounds();typeof t=="object"?(e=(s=t.height)!=null?s:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX:this.scale.x,typeof t.scaleY=="number"?t.scaleY:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,i=this._pivot,n=this._origin,o=this._position,a=s._x,l=s._y,u=i._x,h=i._y,c=-n._x,d=-n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*l,e.d=this._sy*l,e.tx=o._x-(u*e.a+h*e.c)+(c*e.a+d*e.c)-c,e.ty=o._y-(u*e.b+h*e.d)+(c*e.b+d*e.d)-d}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=xs,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=tt.shared.setValue(t!=null?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=xs,this._onUpdate())}get tint(){return ye(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Ai,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|=Pr,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",t))}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|=Pr,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|=Pr,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var e;if(this.destroyed)return;this.destroyed=!0;let s;if(this.children.length&&(s=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&s)for(let i=0;i(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(Te||{});class Pi{constructor(t,e=null,s=0,i=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=i}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const np=class ie{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 Pi(null,null,1/0),this.deltaMS=1/ie.targetFPMS,this.elapsedMS=1/ie.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=Te.NORMAL){return this._addListener(new Pi(t,e,s))}addOnce(t,e,s=Te.NORMAL){return this._addListener(new Pi(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(nthis.maxFPS&&(this.maxFPS=t)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){t===0?this._minElapsedMS=0:(t{if(!this._canvas)return;const e=this._canvas.getBoundingClientRect(),s=this._canvas.width,i=this._canvas.height,n=e.width/s*this._renderer.resolution,o=e.height/i*this._renderer.resolution,a=e.left,l=e.top,u=`translate(${a}px, ${l}px) scale(${n}, ${o})`;u!==this._lastTransform&&(this._domElement.style.transform=u,this._lastTransform=u)},this._domElement=t.domElement,this._renderer=t.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(t=>{for(const e of t){if(e.target!==this._canvas)continue;const s=this.canvas.width,i=this.canvas.height,n=e.contentRect.width/s*this._renderer.resolution,o=e.contentRect.height/i*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||Rt.shared.add(this.updateTranslation,this,Te.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&Rt.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 ns{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=ns.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new lt,this.page=new lt,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,s){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,s,i,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var ia=/iPhone/i,op=/iPod/i,ap=/iPad/i,lp=/\biOS-universal(?:.+)Mac\b/i,na=/\bAndroid(?:.+)Mobile\b/i,up=/Android/i,Cr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ci=/Silk/i,Fe=/Windows Phone/i,hp=/\bWindows(?:.+)ARM\b/i,cp=/BlackBerry/i,dp=/BB10/i,pp=/Opera Mini/i,fp=/\b(CriOS|Chrome)(?:.+)Mobile/i,mp=/Mobile(?:.+)Firefox\b/i,gp=function(r){return typeof r!="undefined"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream=="undefined"};function j2(r){return function(t){return t.test(r)}}function _p(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator!="undefined"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,s=e.split("[FBAN");typeof s[1]!="undefined"&&(e=s[0]),s=e.split("Twitter"),typeof s[1]!="undefined"&&(e=s[0]);var i=j2(e),n={apple:{phone:i(ia)&&!i(Fe),ipod:i(op),tablet:!i(ia)&&(i(ap)||gp(t))&&!i(Fe),universal:i(lp),device:(i(ia)||i(op)||i(ap)||i(lp)||gp(t))&&!i(Fe)},amazon:{phone:i(Cr),tablet:!i(Cr)&&i(Ci),device:i(Cr)||i(Ci)},android:{phone:!i(Fe)&&i(Cr)||!i(Fe)&&i(na),tablet:!i(Fe)&&!i(Cr)&&!i(na)&&(i(Ci)||i(up)),device:!i(Fe)&&(i(Cr)||i(Ci)||i(na)||i(up))||i(/\bokhttp\b/i)},windows:{phone:i(Fe),tablet:i(hp),device:i(Fe)||i(hp)},other:{blackberry:i(cp),blackberry10:i(dp),opera:i(pp),firefox:i(mp),chrome:i(fp),device:i(cp)||i(dp)||i(pp)||i(mp)||i(fp)},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 xp;const X2=(xp=_p.default)!=null?xp:_p,vp=X2(globalThis.navigator);var H2=Object.defineProperty,bp=Object.getOwnPropertySymbols,z2=Object.prototype.hasOwnProperty,W2=Object.prototype.propertyIsEnumerable,yp=(r,t,e)=>t in r?H2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Tp=(r,t)=>{for(var e in t||(t={}))z2.call(t,e)&&yp(r,e,t[e]);if(bp)for(var e of bp(t))W2.call(t,e)&&yp(r,e,t[e]);return r};const V2=9,Sp=100,Y2=0,K2=0,wp=2,Ep=1,q2=-1e3,Z2=-1e3,Q2=2,oa=class eS{constructor(t,e=vp){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=`${Ep}px`,t.style.height=`${Ep}px`,t.style.position="absolute",t.style.top=`${q2}px`,t.style.left=`${Z2}px`,t.style.zIndex=Q2.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=`${Y2}px`,this._div.style.left=`${K2}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=wp.toString(),this._canvasObserver=new sa({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const t=this._renderer.view.canvas;if(t.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const e=new MutationObserver(()=>{t.parentNode&&(e.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});e.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){var t,e;if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const s of this._children)(t=s._accessibleDiv)!=null&&t.parentNode&&(s._accessibleDiv.parentNode.removeChild(s._accessibleDiv),s._accessibleDiv=null),s._accessibleActive=!1;for(const s in this._pools)this._pools[s].forEach(i=>{i.parentNode&&i.parentNode.removeChild(i)}),delete this._pools[s];(e=this._div)!=null&&e.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let s=0;s=0;s--){const i=this._children[s];e.has(s)||(i._accessibleDiv&&i._accessibleDiv.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),this._getPool(i.accessibleType).push(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1,Vo(this._children,s,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let s=0;s title : ${t.title}
tabIndex: ${t.tabIndex}`}_capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:s}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>s&&(t.height=s-t.y)}_addChild(t){let e=this._getPool(t.accessibleType).pop();e?(e.innerHTML="",e.removeAttribute("title"),e.removeAttribute("aria-label"),e.tabIndex=0):(t.accessibleType==="button"?e=document.createElement("button"):(e=document.createElement(t.accessibleType),e.style.cssText=` color: transparent; pointer-events: none; padding: 0; margin: 0; border: 0; outline: 0; background: transparent; box-sizing: border-box; user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; `,t.accessibleText&&(e.innerText=t.accessibleText)),e.style.width=`${Sp}px`,e.style.height=`${Sp}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=wp.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`container ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),t.interactive?e.tabIndex=t.tabIndex:e.tabIndex=0,this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv)}_dispatchEvent(t,e){const{container:s}=t.target,i=this._renderer.events.rootBoundary,n=Object.assign(new ns(i),{target:s});i.rootTarget=this._renderer.lastObjectRendered,e.forEach(o=>i.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode!==V2||!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]}};oa.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"accessibility"},oa.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let Ap=oa;const Pp={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1};L.add(Ap),L.mixin(dt,Pp);class aa{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 sa({domElement:this._domElement,renderer:this._renderer})}addRenderable(t,e){this._attachedDomElements.includes(t)||this._attachedDomElements.push(t)}updateRenderable(t){}validateRenderable(t){return!0}postrender(){const t=this._attachedDomElements;if(t.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let e=0;e=e.minX&&s<=e.maxX&&i>=e.minY&&i<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}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,s){const{renderPipes:i}=e;i.blendMode.pushBlendMode(this,this.groupBlendMode,t);const n=i[this.renderPipeId];n!=null&&n.addRenderable&&n.addRenderable(this,t),this.didViewUpdate=!1;const o=this.children,a=o.length;for(let l=0;lt in r?J2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,tw=(r,t)=>{for(var e in t||(t={}))Cp.call(t,e)&&Mp(r,e,t[e]);if(Ri)for(var e of Ri(t))Rp.call(t,e)&&Mp(r,e,t[e]);return r},ew=(r,t)=>{var e={};for(var s in r)Cp.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Ri)for(var s of Ri(r))t.indexOf(s)<0&&Rp.call(r,s)&&(e[s]=r[s]);return e};class rw extends Se{constructor(t={}){const e=t,{element:s,anchor:i}=e,n=ew(e,["element","anchor"]);super(tw({label:"DOMContainer"},n)),this.renderPipeId="dom",this.batched=!1,this._anchor=new lt(0,0),i&&(this.anchor=i),this.element=t.element||document.createElement("div")}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set element(t){this._element!==t&&(this._element=t,this.onViewUpdate())}get element(){return this._element}updateBounds(){const t=this._bounds,e=this._element;if(!e){t.minX=0,t.minY=0,t.maxX=0,t.maxY=0;return}const{offsetWidth:s,offsetHeight:i}=e;t.minX=0,t.maxX=s,t.minY=0,t.maxY=i}destroy(t=!1){var e,s;super.destroy(t),(s=(e=this._element)==null?void 0:e.parentNode)==null||s.removeChild(this._element),this._element=null,this._anchor=null}}L.add(aa);let sw=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||(Rt.system.add(this._tickerUpdate,this,Te.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(Rt.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}):new MouseEvent("mousemove",{clientX:t.clientX,clientY:t.clientY}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,!(this._deltaTimes.priority-i.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let s=0,i=e.length;s=0;i--)if(t.currentTarget=s[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,s=this._allInteractiveElements){if(s.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const i=Array.isArray(e)?e:[e];for(let n=s.length-1;n>=0;n--)i.forEach(o=>{t.currentTarget=s[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let s=0;s=0;c--){const d=h[c],p=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,s,i,n,o||n(t,s));if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();(p.length>0||f)&&(f&&this._allInteractiveElements.push(t),p.push(t)),this._hitElements.length===0&&(this._hitElements=p),a=!0}}}const l=this._isInteractive(e),u=t.isInteractive();return u&&u&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,s)&&i(t,s)?u?[t]:[]:null}hitTestRecursive(t,e,s,i,n){if(this._interactivePrune(t)||n(t,s))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(we.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children,u=s;for(let h=l.length-1;h>=0;h--){const c=l[h],d=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,u,i,n);if(d){if(d.length>0&&!d[d.length-1].parent)continue;const p=t.isInteractive();return(d.length>0||p)&&d.push(t),d}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&i(t,s)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!t||!t.visible||!t.renderable||!t.measurable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,bs),!t.hitArea.contains(bs.x,bs.y)))return!0;if(t.effects&&t.effects.length)for(let s=0;s0&&l!==n.target){const c=t.type==="mousemove"?"mouseout":"pointerout",d=this.createPointerEvent(t,c,l);if(this.dispatchEvent(d,"pointerout"),o&&this.dispatchEvent(d,"mouseout"),!n.composedPath().includes(l)){const p=this.createPointerEvent(t,"pointerleave",l);for(p.eventPhase=p.AT_TARGET;p.target&&!n.composedPath().includes(p.target);)p.currentTarget=p.target,this.notifyTarget(p),o&&this.notifyTarget(p,"mouseleave"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(d)}if(l!==n.target){const c=t.type==="mousemove"?"mouseover":"pointerover",d=this.clonePointerEvent(n,c);this.dispatchEvent(d,"pointerover"),o&&this.dispatchEvent(d,"mouseover");let p=l==null?void 0:l.parent;for(;p&&p!==this.rootTarget.parent&&p!==n.target;)p=p.parent;if(!p||p===this.rootTarget.parent){const f=this.clonePointerEvent(n,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==l&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(d)}const u=[],h=(s=this.enableGlobalMoveEvents)!=null?s:!0;this.moveOnAll?u.push("pointermove"):this.dispatchEvent(n,"pointermove"),h&&u.push("globalpointermove"),n.pointerType==="touch"&&(this.moveOnAll?u.splice(1,0,"touchmove"):this.dispatchEvent(n,"touchmove"),h&&u.push("globaltouchmove")),o&&(this.moveOnAll?u.splice(1,0,"mousemove"):this.dispatchEvent(n,"mousemove"),h&&u.push("globalmousemove"),this.cursor=(i=n.target)==null?void 0:i.cursor),u.length>0&&this.all(n,u),this._allInteractiveElements.length=0,this._hitElements.length=0,a.overTargets=n.composedPath(),this.freeEvent(n)}mapPointerOver(t){var e;if(!(t instanceof le))return;const s=this.trackingData(t.pointerId),i=this.createPointerEvent(t),n=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(e=i.target)==null?void 0:e.cursor);const o=this.clonePointerEvent(i,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),n&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;s.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof le))return;const e=this.trackingData(t.pointerId);if(e.overTargets){const s=t.pointerType==="mouse"||t.pointerType==="pen",i=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(n),s&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",i);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof le))return;const e=performance.now(),s=this.createPointerEvent(t);if(this.dispatchEvent(s,"pointerup"),s.pointerType==="touch")this.dispatchEvent(s,"touchend");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const a=s.button===2;this.dispatchEvent(s,a?"rightup":"mouseup")}const i=this.trackingData(t.pointerId),n=this.findMountedTarget(i.pressTargetsByButton[t.button]);let o=n;if(n&&!s.composedPath().includes(n)){let a=n;for(;a&&!s.composedPath().includes(a);){if(s.currentTarget=a,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch")this.notifyTarget(s,"touchendoutside");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const l=s.button===2;this.notifyTarget(s,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete i.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(s,"click");a.target=o,a.path=null,i.clicksByButton[t.button]||(i.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=i.clicksByButton[t.button];if(l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,a.detail=l.clickCount,a.pointerType==="mouse"){const u=a.button===2;this.dispatchEvent(a,u?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(s)}mapPointerUpOutside(t){if(!(t instanceof le))return;const e=this.trackingData(t.pointerId),s=this.findMountedTarget(e.pressTargetsByButton[t.button]),i=this.createPointerEvent(t);if(s){let n=s;for(;n;)i.currentTarget=n,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch"?this.notifyTarget(i,"touchendoutside"):(i.pointerType==="mouse"||i.pointerType==="pen")&&this.notifyTarget(i,i.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(i)}mapWheel(t){if(!(t instanceof ar))return;const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let s=1;st in r?ow(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,uw=(r,t)=>{for(var e in t||(t={}))aw.call(t,e)&&Ip(r,e,t[e]);if(Gp)for(var e of Gp(t))lw.call(t,e)&&Ip(r,e,t[e]);return r};const hw=1,cw={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},la=class Dc{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Op(null),we.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new le(null),this._rootWheelEvent=new ar(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(uw({},Dc.defaultEventFeatures),{set:(e,s,i)=>(s==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=i),e[s]=i,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){var e,s;const{canvas:i,resolution:n}=this.renderer;this.setTargetElement(i),this.resolution=n,Dc._defaultEventMode=(e=t.eventMode)!=null?e:"passive",Object.assign(this.features,(s=t.eventFeatures)!=null?s:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){we.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t||(t="default");let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const s=this.cursorStyles[t];if(s)switch(typeof s){case"string":e&&(this.domElement.style.cursor=s);break;case"function":s(t);break;case"object":e&&Object.assign(this.domElement.style,s);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let s=0,i=e.length;s0&&(e=t.composedPath()[0]);const s=e!==this.domElement?"outside":"",i=this._normalizeToPointerData(t);for(let n=0,o=i.length;n{l.off(r,a,o)}),n?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,t,e){const s=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,i=typeof t=="function"?void 0:t;r=s?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,i)},dispatchEvent(r){if(!(r instanceof ns))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}};L.add(ua),L.mixin(dt,Fp);var ee=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(ee||{});const Bp={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 Dp=Bp;const X={get(){return Dp},set(r){Dp=r}};function de(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function ys(r){return r.split("?")[0].split("#")[0]}function dw(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pw(r,t,e){return r.replace(new RegExp(dw(t),"g"),e)}function fw(r,t){let e="",s=0,i=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",s=0):(e=e.slice(0,l),s=e.length-1-e.lastIndexOf("/")),i=a,n=0;continue}}else if(e.length===2||e.length===1){e="",s=0,i=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",s=2)}else e.length>0?e+=`/${r.slice(i+1,a)}`:e=r.slice(i+1,a),s=a-i-1;i=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const Vt={toPosix(r){return pw(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){de(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(de(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const s=ys(this.toPosix(t!=null?t:X.get().getBaseUrl())),i=ys(this.toPosix(e!=null?e:this.rootname(s)));return r=this.toPosix(r),r.startsWith("/")?Vt.join(i,r.slice(1)):this.isAbsolute(r)?r:this.join(s,r)},normalize(r){if(de(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const s=r.endsWith("/");return r=fw(r,!1),r.length>0&&s&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return de(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){var t;if(r.length===0)return".";let e;for(let s=0;s0)if(e===void 0)e=i;else{const n=(t=r[s-1])!=null?t:"";this.joinExtensions.includes(this.extname(n).toLowerCase())?e+=`/../${i}`:e+=`/${i}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(de(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let s=-1,i=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!i){s=a;break}}else i=!1;return s===-1?e?"/":this.isUrl(o)?n+r:n:e&&s===1?"//":n+r.slice(0,s)},rootname(r){de(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){de(r),t&&de(t),r=ys(this.toPosix(r));let e=0,s=-1,i=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!i){e=n+1;break}}else a===-1&&(i=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(s=n):(o=-1,s=a))}return e===s?s=a:s===-1&&(s=r.length),r.slice(e,s)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!i){e=n+1;break}}else s===-1&&(i=!1,s=n+1);return s===-1?"":r.slice(e,s)},extname(r){de(r),r=ys(this.toPosix(r));let t=-1,e=0,s=-1,i=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!i){e=o+1;break}continue}s===-1&&(i=!1,s=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||s===-1||n===0||n===1&&t===s-1&&t===e+1?"":r.slice(t,s)},parse(r){de(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=ys(this.toPosix(r));let e=r.charCodeAt(0);const s=this.isAbsolute(r);let i;const n="";t.root=this.rootname(r),s||this.hasProtocol(r)?i=1:i=0;let o=-1,a=0,l=-1,u=!0,h=r.length-1,c=0;for(;h>=i;--h){if(e=r.charCodeAt(h),e===47){if(!u){a=h+1;break}continue}l===-1&&(u=!1,l=h+1),e===46?o===-1?o=h:c!==1&&(c=1):o!==-1&&(c=-1)}return o===-1||l===-1||c===0||c===1&&o===l-1&&o===a+1?l!==-1&&(a===0&&s?t.base=t.name=r.slice(1,l):t.base=t.name=r.slice(a,l)):(a===0&&s?(t.name=r.slice(1,o),t.base=r.slice(1,l)):(t.name=r.slice(a,o),t.base=r.slice(a,l)),t.ext=r.slice(o,l)),t.dir=this.dirname(r),n&&(t.dir=n+t.dir),t},sep:"/",delimiter:":",joinExtensions:[".html"]},ue=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(s=>typeof s=="string"||e?t(s):s):r);function $p(r,t,e,s,i){const n=t[e];for(let o=0;o{const o=n.substring(1,n.length-1).split(",");i.push(o)}),$p(r,i,0,e,s)}else s.push(r);return s}const Ts=r=>!Array.isArray(r);var mw=Object.defineProperty,gw=Object.defineProperties,_w=Object.getOwnPropertyDescriptors,kp=Object.getOwnPropertySymbols,xw=Object.prototype.hasOwnProperty,vw=Object.prototype.propertyIsEnumerable,Lp=(r,t,e)=>t in r?mw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,lr=(r,t)=>{for(var e in t||(t={}))xw.call(t,e)&&Lp(r,e,t[e]);if(kp)for(var e of kp(t))vw.call(t,e)&&Lp(r,e,t[e]);return r},bw=(r,t)=>gw(r,_w(t));class Ne{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){var e,s,i;if(this._bundleIdConnector=(e=t.connector)!=null?e:this._bundleIdConnector,this._createBundleAssetId=(s=t.createBundleAssetId)!=null?s:this._createBundleAssetId,this._extractAssetIdFromBundle=(i=t.extractAssetIdFromBundle)!=null?i:this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return ue(e||s,i=>typeof i=="string"?i:Array.isArray(i)?i.map(n=>{var o;return(o=n==null?void 0:n.src)!=null?o:n}):i!=null&&i.src?i.src:i,!0)}removeAlias(t,e){this._assetMap[t]&&(e&&e!==this._resolverHash[t]||(delete this._resolverHash[t],delete this._assetMap[t]))}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];let i=e;Array.isArray(e)||(i=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:lr({alias:n},o))),i.forEach(n=>{const o=n.src,a=n.alias;let l;if(typeof a=="string"){const u=this._createBundleAssetId(t,a);s.push(u),l=[a,u]}else{const u=a.map(h=>this._createBundleAssetId(t,h));s.push(...u),l=[...a,...u]}this.add(bw(lr({},n),{alias:l,src:o}))}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;ue(e).forEach(i=>{const{src:n}=i;let{data:o,format:a,loadParser:l,parser:u}=i;const h=ue(n).map(f=>typeof f=="string"?Up(f):Array.isArray(f)?f:[f]),c=this.getAlias(i),d=[],p=f=>{const m=this._parsers.find(g=>g.test(f));return lr({src:f},m==null?void 0:m.parse(f))};h.forEach(f=>{f.forEach(m=>{var g,_,x,v;let b={};if(typeof m!="object"?b=p(m):(o=(g=m.data)!=null?g:o,a=(_=m.format)!=null?_:a,(m.loadParser||m.parser)&&(l=(x=m.loadParser)!=null?x:l,u=(v=m.parser)!=null?v:u),b=lr(lr({},p(m.src)),m)),!c)throw new Error(`[Resolver] alias is undefined for this asset: ${b.src}`);b=this._buildResolvedAsset(b,{aliases:c,data:o,format:a,loadParser:l,parser:u,progressSize:i.progressSize}),d.push(b)})}),c.forEach(f=>{this._assetMap[f]=d})})}resolveBundle(t){const e=Ts(t);t=ue(t);const s={};return t.forEach(i=>{const n=this._bundles[i];if(n){const o=this.resolve(n),a={};for(const l in o){const u=o[l];a[this._extractAssetIdFromBundle(i,l)]=u}s[i]=a}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const i in e)s[i]=e[i].src;return s}return e.src}resolve(t){const e=Ts(t);t=ue(t);const s={};return t.forEach(i=>{if(!this._resolverHash[i])if(this._assetMap[i]){let n=this._assetMap[i];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(l=>{const u=n.filter(h=>h[a]?h[a]===l:!1);u.length&&(n=u)})}),this._resolverHash[i]=n[0]}else this._resolverHash[i]=this._buildResolvedAsset({alias:[i],src:i},{});s[i]=this._resolverHash[i]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;en.params.format.includes(s.format));if(i)return i}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){var s,i;const{aliases:n,data:o,loadParser:a,parser:l,format:u,progressSize:h}=e;return(this._basePath||this._rootPath)&&(t.src=Vt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=(s=n!=null?n:t.alias)!=null?s:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=lr(lr({},o||{}),t.data),t.loadParser=a!=null?a:t.loadParser,t.parser=l!=null?l:t.parser,t.format=(i=u!=null?u:t.format)!=null?i:Np(t.src),h!==void 0&&(t.progressSize=h),t}}Ne.RETINA_PREFIX=/@([0-9\.]+)x/;function Np(r){return r.split(".").pop().split("?").shift().split("#").shift()}const Mi=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r},jp=class ui{constructor(t,e){this.linkedSheets=[];let s=t;(t==null?void 0:t.source)instanceof ct&&(s={texture:t,data:e});const{texture:i,data:n,cachePrefix:o=""}=s;this.cachePrefix=o,this._texture=i instanceof B?i:null,this.textureSource=i.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,i.source.resolution=this.resolution):this.resolution=i.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=ui.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,e=!1){let s=t;const i=e?1/0:ui.BATCH_SIZE;for(;s-t{this._batchIndex*ui.BATCH_SIZE{s[i]=t}),Object.keys(t.textures).forEach(i=>{s[`${t.cachePrefix}${i}`]=t.textures[i]}),!e){const i=Vt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=Xp([`${i}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(s,a)})}return s}const Hp={extension:T.Asset,cache:{test:r=>r instanceof ha,getCacheableAssets:(r,t)=>Xp(r,t,!1)},resolver:{extension:{type:T.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),s=t.pop();return e==="json"&&yw.includes(s)},parse:r=>{var t,e;const s=r.split(".");return{resolution:parseFloat((e=(t=Ne.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:s[s.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:T.LoadParser,priority:ee.Normal,name:"spritesheetLoader"},async testParse(r,t){return Vt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var s,i,n;const{texture:o,imageFilename:a,textureOptions:l,cachePrefix:u}=(s=t==null?void 0:t.data)!=null?s:{};let h=Vt.dirname(t.src);h&&h.lastIndexOf("/")!==h.length-1&&(h+="/");let c;if(o instanceof B)c=o;else{const f=Mi(h+(a!=null?a:r.meta.image),t.src);c=(await e.load([{src:f,data:l}]))[f]}const d=new ha({texture:c.source,data:r,cachePrefix:u});await d.parse();const p=(i=r==null?void 0:r.meta)==null?void 0:i.related_multi_packs;if(Array.isArray(p)){const f=[];for(const g of p){if(typeof g!="string")continue;let _=h+g;(n=t.data)!=null&&n.ignoreMultiPack||(_=Mi(_,t.src),f.push(e.load({src:_,data:{textureOptions:l,ignoreMultiPack:!0}})))}const m=await Promise.all(f);d.linkedSheets=m,m.forEach(g=>{g.linkedSheets=[d].concat(d.linkedSheets.filter(_=>_!==g))})}return d},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};L.add(Hp);function ca(r,t,e){const{width:s,height:i}=e.orig,n=e.trim;if(n){const o=n.width,a=n.height;r.minX=n.x-t._x*s,r.maxX=r.minX+o,r.minY=n.y-t._y*i,r.maxY=r.minY+a}else r.minX=-t._x*s,r.maxX=r.minX+s,r.minY=-t._y*i,r.maxY=r.minY+i}var Tw=Object.defineProperty,Oi=Object.getOwnPropertySymbols,zp=Object.prototype.hasOwnProperty,Wp=Object.prototype.propertyIsEnumerable,Vp=(r,t,e)=>t in r?Tw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Sw=(r,t)=>{for(var e in t||(t={}))zp.call(t,e)&&Vp(r,e,t[e]);if(Oi)for(var e of Oi(t))Wp.call(t,e)&&Vp(r,e,t[e]);return r},ww=(r,t)=>{var e={};for(var s in r)zp.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Oi)for(var s of Oi(r))t.indexOf(s)<0&&Wp.call(r,s)&&(e[s]=r[s]);return e};class _e extends Se{constructor(t=B.EMPTY){t instanceof B&&(t={texture:t});const e=t,{texture:s=B.EMPTY,anchor:i,roundPixels:n,width:o,height:a}=e,l=ww(e,["texture","anchor","roundPixels","width","height"]);super(Sw({label:"Sprite"},l)),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new gt({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:s.defaultAnchor&&(this.anchor=s.defaultAnchor),this.texture=s,this.allowChildren=!1,this.roundPixels=n!=null?n:!1,o!==void 0&&(this.width=o),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof B?new _e(t):new _e(B.from(t,e))}set texture(t){t||(t=B.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 ca(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,s=this._bounds,{width:i,height:n}=e.orig;s.minX=-t._x*i,s.maxX=s.minX+i,s.minY=-t._y*n,s.maxY=s.minY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){var s;typeof t=="object"?(e=(s=t.height)!=null?s:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const Ew=new Ct;function Gi(r,t,e){const s=Ew;r.measurable=!0,gs(r,e,s),t.addBoundsMask(s),r.measurable=!1}function Ii(r,t,e){const s=ve.get();r.measurable=!0;const i=Ut.get().identity(),n=Yp(r,e,i);bi(r,s,n),r.measurable=!1,t.addBoundsMask(s),Ut.return(i),ve.return(s)}function Yp(r,t,e){return r&&r!==t&&(Yp(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class da{constructor(t){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof _e),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||Gi(this.mask,t,e)}addLocalBounds(t,e){Ii(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof _e}}da.extension=T.MaskEffect;class pa{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"}}pa.extension=T.MaskEffect;class fa{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){Gi(this.mask,t,e)}addLocalBounds(t,e){Ii(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof dt}}fa.extension=T.MaskEffect;class re extends ct{constructor(t){t.resource||(t.resource=X.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,s=this._resolution){const i=super.resize(t,e,s);return i&&this.resizeCanvas(),i}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}re.extension=T.TextureSource;class je extends ct{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}}je.extension=T.TextureSource;let ma;async function ga(){return ma!=null||(ma=(async()=>{var r;const t=X.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!e)return"premultiply-alpha-on-upload";const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(i),t.deleteTexture(s),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),ma}var Aw=Object.defineProperty,Pw=Object.defineProperties,Cw=Object.getOwnPropertyDescriptors,Kp=Object.getOwnPropertySymbols,Rw=Object.prototype.hasOwnProperty,Mw=Object.prototype.propertyIsEnumerable,qp=(r,t,e)=>t in r?Aw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_a=(r,t)=>{for(var e in t||(t={}))Rw.call(t,e)&&qp(r,e,t[e]);if(Kp)for(var e of Kp(t))Mw.call(t,e)&&qp(r,e,t[e]);return r},Ow=(r,t)=>Pw(r,Cw(t));const Fi=class rS extends ct{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=_a(_a({},rS.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),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=Rt.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.isValid||t.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await ga(),this._load=new Promise((s,i)=>{this.isValid?s(this):(this._resolve=s,this._reject=i,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),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.isValid&&(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("loadedmetadata",this._onLoadedMetadata),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&&(Rt.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||(Rt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Rt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Fi.extension=T.TextureSource,Fi.defaultOptions=Ow(_a({},ct.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),Fi.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Rr=Fi,Gw=class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){return this._cache.get(t)}set(t,e){const s=ue(t);let i;for(let l=0;l{n.set(l,e)});const o=[...n.keys()],a={cacheKeys:o,keys:s};s.forEach(l=>{this._cacheMap.set(l,a)}),o.forEach(l=>{const u=i?i[l]:e;this._cache.has(l)&&this._cache.get(l),this._cache.set(l,n.get(l))})}remove(t){if(!this._cacheMap.has(t))return;const e=this._cacheMap.get(t);e.cacheKeys.forEach(s=>{this._cache.delete(s)}),e.keys.forEach(s=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}};const rt=new Gw,xa=[];L.handleByList(T.TextureSource,xa);function Iw(r={}){return va(r)}function va(r={}){const t=r&&r.resource,e=t?r.resource:r,s=t?r:{resource:r};for(let i=0;i{rt.has(s)&&rt.remove(s)}),t||rt.set(s,n),n}function Qp(r,t=!1){return typeof r=="string"?rt.get(r):r instanceof ct?new B({source:r}):Zp(r,t)}B.from=Qp,ct.from=va,L.add(da,pa,fa,Rr,je,re,Si);let Mr;function Jp(r){const t=X.get().createCanvas(6,1),e=t.getContext("2d");return e.fillStyle=r,e.fillRect(0,0,6,1),t}function ba(){if(Mr!==void 0)return Mr;try{const r=Jp("#ff00ff"),t=Jp("#ffff00"),e=X.get().createCanvas(6,1).getContext("2d");e.globalCompositeOperation="multiply",e.drawImage(r,0,0),e.drawImage(t,2,0);const s=e.getImageData(2,0,1,1);if(!s)Mr=!1;else{const i=s.data;Mr=i[0]===255&&i[1]===0&&i[2]===0}}catch(r){Mr=!1}return Mr}const Z={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:ba(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:r=>{var t,e;const s=r.source,i=s==null?void 0:s.resource;if(!i)return null;const n=s.alphaMode==="premultiplied-alpha",o=(t=s.resourceWidth)!=null?t:s.pixelWidth,a=(e=s.resourceHeight)!=null?e:s.pixelHeight,l=o!==s.pixelWidth||a!==s.pixelHeight;if(n){if((i instanceof HTMLCanvasElement||typeof OffscreenCanvas!="undefined"&&i instanceof OffscreenCanvas)&&!l)return i;const u=Z._unpremultipliedCache.get(s);if((u==null?void 0:u.resourceId)===s._resourceId)return u.canvas}if(i instanceof Uint8Array||i instanceof Uint8ClampedArray||i instanceof Int8Array||i instanceof Uint16Array||i instanceof Int16Array||i instanceof Uint32Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof ArrayBuffer){const u=Z._canvasSourceCache.get(s);if((u==null?void 0:u.resourceId)===s._resourceId)return u.canvas;const h=X.get().createCanvas(s.pixelWidth,s.pixelHeight),c=h.getContext("2d"),d=c.createImageData(s.pixelWidth,s.pixelHeight),p=d.data,f=i instanceof ArrayBuffer?new Uint8Array(i):new Uint8Array(i.buffer,i.byteOffset,i.byteLength);if(s.format==="bgra8unorm")for(let m=0;m0){const m=255/f;d[p]=Math.min(255,d[p]*m+.5),d[p+1]=Math.min(255,d[p+1]*m+.5),d[p+2]=Math.min(255,d[p+2]*m+.5)}}return h.putImageData(c,0,0),Z._unpremultipliedCache.set(s,{canvas:u,resourceId:s._resourceId}),u}if(l){const u=Z._canvasSourceCache.get(s);if((u==null?void 0:u.resourceId)===s._resourceId)return u.canvas;const h=X.get().createCanvas(s.pixelWidth,s.pixelHeight),c=h.getContext("2d");return h.width=s.pixelWidth,h.height=s.pixelHeight,c.drawImage(i,0,0),Z._canvasSourceCache.set(s,{canvas:h,resourceId:s._resourceId}),h}return i},getTintedCanvas:(r,t)=>{const e=r.texture,s=tt.shared.setValue(t).toHex(),i=e.tintCache||(e.tintCache={}),n=i[s],o=e.source._resourceId;if((n==null?void 0:n.tintId)===o)return n;const a=n&&"getContext"in n?n:X.get().createCanvas();if(Z.tintMethod(e,t,a),a.tintId=o,Z.convertTintToImage&&a.toDataURL!==void 0){const l=X.get().createImage();l.src=a.toDataURL(),l.tintId=o,i[s]=l}else i[s]=a;return i[s]},getTintedPattern:(r,t)=>{const e=tt.shared.setValue(t).toHex(),s=r.patternCache||(r.patternCache={}),i=r.source._resourceId;let n=s[e];return(n==null?void 0:n.tintId)===i||(Z.canvas||(Z.canvas=X.get().createCanvas()),Z.tintMethod(r,t,Z.canvas),n=Z.canvas.getContext("2d").createPattern(Z.canvas,"repeat"),n.tintId=i,s[e]=n),n},applyPatternTransform:(r,t,e=!0)=>{if(!t)return;const s=r;if(!s.setTransform)return;const i=globalThis.DOMMatrix;if(!i)return;const n=new i([t.a,t.b,t.c,t.d,t.tx,t.ty]);s.setTransform(e?n.inverse():n)},tintWithMultiply:(r,t,e)=>{var s,i;const n=e.getContext("2d"),o=r.frame.clone(),a=(i=(s=r.source._resolution)!=null?s:r.source.resolution)!=null?i:1,l=r.rotate;o.x*=a,o.y*=a,o.width*=a,o.height*=a;const u=H.isVertical(l),h=u?o.height:o.width,c=u?o.width:o.height;e.width=Math.ceil(h),e.height=Math.ceil(c),n.save(),t!==16777215&&(n.fillStyle=tt.shared.setValue(t).toHex(),n.fillRect(0,0,h,c),n.globalCompositeOperation="multiply");const d=Z.getCanvasSource(r);if(!d){n.restore();return}l&&Z._applyInverseRotation(n,l,o.width,o.height),n.drawImage(d,o.x,o.y,o.width,o.height,0,0,o.width,o.height),t!==16777215&&(n.globalCompositeOperation="destination-atop",n.drawImage(d,o.x,o.y,o.width,o.height,0,0,o.width,o.height)),n.restore()},tintWithOverlay:(r,t,e)=>{var s,i;const n=e.getContext("2d"),o=r.frame.clone(),a=(i=(s=r.source._resolution)!=null?s:r.source.resolution)!=null?i:1,l=r.rotate;o.x*=a,o.y*=a,o.width*=a,o.height*=a;const u=H.isVertical(l),h=u?o.height:o.width,c=u?o.width:o.height;e.width=Math.ceil(h),e.height=Math.ceil(c),n.save(),n.globalCompositeOperation="copy",n.fillStyle=tt.shared.setValue(t).toHex(),n.fillRect(0,0,h,c),n.globalCompositeOperation="destination-atop";const d=Z.getCanvasSource(r);if(!d){n.restore();return}l&&Z._applyInverseRotation(n,l,o.width,o.height),n.drawImage(d,o.x,o.y,o.width,o.height,0,0,o.width,o.height),n.restore()},tintWithPerPixel:(r,t,e)=>{var s,i;const n=e.getContext("2d"),o=r.frame.clone(),a=(i=(s=r.source._resolution)!=null?s:r.source.resolution)!=null?i:1,l=r.rotate;o.x*=a,o.y*=a,o.width*=a,o.height*=a;const u=H.isVertical(l),h=u?o.height:o.width,c=u?o.width:o.height;e.width=Math.ceil(h),e.height=Math.ceil(c),n.save(),n.globalCompositeOperation="copy";const d=Z.getCanvasSource(r);if(!d){n.restore();return}l&&Z._applyInverseRotation(n,l,o.width,o.height),n.drawImage(d,o.x,o.y,o.width,o.height,0,0,o.width,o.height),n.restore();const p=t>>16&255,f=t>>8&255,m=t&255,g=n.getImageData(0,0,h,c),_=g.data;for(let x=0;x<_.length;x+=4)_[x]=_[x]*p/255,_[x+1]=_[x+1]*f/255,_[x+2]=_[x+2]*m/255;n.putImageData(g,0,0)},_applyInverseRotation:(r,t,e,s)=>{const i=H.inv(t),n=H.uX(i),o=H.uY(i),a=H.vX(i),l=H.vY(i),u=-Math.min(0,n*e,a*s,n*e+a*s),h=-Math.min(0,o*e,l*s,o*e+l*s);r.transform(n,o,a,l,u,h)}};Z.tintMethod=Z.canUseMultiply?Z.tintWithMultiply:Z.tintWithPerPixel;const VB=32767;function tf(r,t){return(r<<17)+(t<<2)}class ef{constructor(t){this._buckets=new Map,this._screens=new Qo,this._enableFullScreen=!1,this.canvasOptions=t||{}}get enableFullScreen(){return this._enableFullScreen}set enableFullScreen(t){this._enableFullScreen=t}_createCanvasAndContext(t,e){const s=X.get().createCanvas();s.width=t,s.height=e;const i=s.getContext("2d");return{canvas:s,context:i}}getOptimalCanvasAndContext(t,e,s=1){const{width:i,height:n}=this.getOptimalSize(t,e,s),o=tf(i,n);let a=this._buckets.get(o);a||(a=[],this._buckets.set(o,a));let l=a.pop();return l||(l=this._createCanvasAndContext(i,n)),l}getOptimalSize(t,e,s=1){const i=Math.ceil(t*s-1e-6),n=Math.ceil(e*s-1e-6),o=er(i),a=this._screens.getFittingWidth(i),l=er(n),u=this._screens.getFittingHeight(n);return{width:a!==void 0?Math.min(a,o):o,height:u!==void 0?Math.min(u,l):l}}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:i}=e,n=this._buckets.get(tf(s,i));n&&(t.context.resetTransform(),t.context.clearRect(0,0,s,i),n.push(t))}setScreenSize(t,e,s){this._screens.set(t,e,s)&&this._pruneScreenCanvases()}removeScreen(t){this._screens.remove(t)&&this._pruneScreenCanvases()}clear(){this._buckets.clear()}_pruneScreenCanvases(){for(const[t]of this._buckets){const e=t>>>17,s=t>>>2&32767;(rr(e)||this._screens.hasWidth(e))&&(rr(s)||this._screens.hasHeight(s))||this._buckets.delete(t)}}}const se=new ef;tr.register(se);function ya(r){const t=r.length;if(t<6)return 1;let e=0;for(let s=0,i=r[t-2],n=r[t-1];s1?(p=i,f=n):(p=e+d*l,f=s+d*u);const m=r-p,g=t-f;return m*m+g*g}function Ta(r,t,e,s,i,n,o,a){const l=o-e,u=a-s,h=i-e,c=n-s,d=r-e,p=t-s,f=l*l+u*u,m=l*h+u*c,g=l*d+u*p,_=h*h+c*c,x=h*d+c*p,v=1/(f*_-m*m),b=(_*g-m*x)*v,S=(f*x-m*g)*v;return b>=0&&S>=0&&b+S<1}class Io{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new Io(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let i=this.x-t,n=this.y-e;return i*=i,n*=n,i+n<=s}strokeContains(t,e,s,i=.5){if(this.radius===0)return!1;const n=this.x-t,o=this.y-e,a=this.radius,l=(1-i)*s,u=Math.sqrt(n*n+o*o);return u<=a+l&&u>a-(s-l)}getBounds(t){return t||(t=new it),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 Fo{constructor(t=0,e=0,s=0,i=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=i}clone(){return new Fo(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,i=(e-this.y)/this.halfHeight;return s*=s,i*=i,s+i<=1}strokeContains(t,e,s,i=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=s*(1-i),l=s-a,u=n-l,h=o-l,c=n+a,d=o+a,p=t-this.x,f=e-this.y;return p*p/(c*c)+f*f/(d*d)>1?!1:u<=0||h<=0?!0:p*p/(u*u)+f*f/(h*h)>1}getBounds(t){return t||(t=new it),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}}let Fw,Bw;class os{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let i=0,n=e.length;ie!=h>e&&t<(u-a)*((e-l)/(h-l))+a&&(s=!s)}return s}strokeContains(t,e,s,i=.5){const{points:n}=this,o=i===.5?i:(i-.5)*ya(n)+.5,a=s*o,l=s-a,u=a*a,h=l*l,c=n.length-(this.closePath?0:2);for(let d=0;di?u:i,n=ho?h:o}return t.x=s,t.width=i-s,t.y=n,t.height=o-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const Bi=(r,t,e,s,i,n,o)=>{const a=r-e,l=t-s,u=Math.sqrt(a*a+l*l);return u>=i-n&&u<=i+o};class Bo{constructor(t=0,e=0,s=0,i=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=i,this.radius=n}getBounds(t){return t||(t=new it),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Bo(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.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let i=t-(this.x+s),n=e-(this.y+s);const o=s*s;if(i*i+n*n<=o||(i=t-(this.x+this.width-s),i*i+n*n<=o)||(n=e-(this.y+this.height-s),i*i+n*n<=o)||(i=t-(this.x+s),i*i+n*n<=o))return!0}return!1}strokeContains(t,e,s,i=.5){const{x:n,y:o,width:a,height:l,radius:u}=this,h=s*(1-i),c=s-h,d=n+u,p=o+u,f=a-u*2,m=l-u*2,g=n+a,_=o+l;return(t>=n-h&&t<=n+c||t>=g-c&&t<=g+h)&&e>=p&&e<=p+m||(e>=o-h&&e<=o+c||e>=_-c&&e<=_+h)&&t>=d&&t<=d+f?!0:tg-u&&eg-u&&e>_-u&&Bi(t,e,g-u,_-u,u,c,h)||t_-u&&Bi(t,e,d,_-u,u,c,h)}}class Wc{constructor(t=0,e=0,s=0,i=0,n=0,o=0){this.type="triangle",this.x=t,this.y=e,this.x2=s,this.y2=i,this.x3=n,this.y3=o}contains(t,e){const s=(this.x-this.x3)*(e-this.y3)-(this.y-this.y3)*(t-this.x3),i=(this.x2-this.x)*(e-this.y)-(this.y2-this.y)*(t-this.x);if(s<0!=i<0&&s!==0&&i!==0)return!1;const n=(this.x3-this.x2)*(e-this.y2)-(this.y3-this.y2)*(t-this.x2);return n===0||n<0==s+i<=0}strokeContains(t,e,s,i=.5){const n=s/2,o=n*n,{x:a,x2:l,x3:u,y:h,y2:c,y3:d}=this;return Ss(t,e,a,h,l,c)<=o||Ss(t,e,l,c,u,d)<=o||Ss(t,e,u,d,a,h)<=o}clone(){return new Wc(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 it);const e=Math.min(this.x,this.x2,this.x3),s=Math.max(this.x,this.x2,this.x3),i=Math.min(this.y,this.y2,this.y3),n=Math.max(this.y,this.y2,this.y3);return t.x=e,t.y=i,t.width=s-e,t.height=n-i,t}}const rf=new D;function Sa(r,t){var e;t.clear();const s=t.matrix;for(let i=0;i!l.enabled)){e.skip=!0;return}const i=[],n=1;for(const l of s){if(!l.enabled)continue;if(!wa(l)){this._warnUnsupportedFilter(l);continue}const u=l.getCanvasFilterString();if(u===null){this._warnUnsupportedFilter(l);continue}u&&i.push(u)}if(i.length===0&&n===1){e.skip=!0;return}e.cssFilterString=i.join(" "),this._calculateFilterArea(t,e.bounds),e.useClip=!!t.filterEffect.filterArea;const o=this.renderer.canvasContext.activeContext,a=o.filter||"none";if(this._savedStates.push({filter:a,alphaMultiplier:this._alphaMultiplier}),e.useClip&&Number.isFinite(e.bounds.width)&&Number.isFinite(e.bounds.height)&&e.bounds.width>0&&e.bounds.height>0){const l=this.renderer.canvasContext.activeResolution||1;o.save(),o.setTransform(1,0,0,1,0,0),o.beginPath(),o.rect(e.bounds.x*l,e.bounds.y*l,e.bounds.width*l,e.bounds.height*l),o.clip()}else e.useClip=!1;n!==1&&(this._alphaMultiplier*=n),e.cssFilterString&&(o.filter=a!=="none"?`${a} ${e.cssFilterString}`:e.cssFilterString)}pop(){const t=this._popFilterFrame();if(t.skip)return;const e=this._savedStates.pop();if(!e)return;const s=this.renderer.canvasContext.activeContext;t.useClip?s.restore():s.filter=e.filter,this._alphaMultiplier=e.alphaMultiplier}generateFilteredTexture({texture:t,filters:e}){var s,i;if(!(e!=null&&e.length)||e.every(v=>!v.enabled))return t;const n=[],o=1;for(const v of e){if(!v.enabled)continue;if(!wa(v)){this._warnUnsupportedFilter(v);continue}const b=v.getCanvasFilterString();if(b===null){this._warnUnsupportedFilter(v);continue}b&&n.push(b)}if(n.length===0&&o===1)return t;const a=Z.getCanvasSource(t);if(!a)return t;const l=t.frame,u=(i=(s=t.source._resolution)!=null?s:t.source.resolution)!=null?i:1,h=l.width,c=l.height,d=se.getOptimalCanvasAndContext(h,c,u),{canvas:p,context:f}=d;f.setTransform(1,0,0,1,0,0),f.clearRect(0,0,p.width,p.height),n.length&&(f.filter=n.join(" ")),o!==1&&(f.globalAlpha=o);const m=l.x*u,g=l.y*u,_=h*u,x=c*u;return f.drawImage(a,m,g,_,x,0,0,_,x),f.filter="none",f.globalAlpha=1,Di(p,h,c,u)}_calculateFilterArea(t,e){if(t.renderables?Sa(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 s=t.container.renderGroup||t.container.parentRenderGroup,i=s==null?void 0:s.cacheToLocalTransform;i&&e.applyMatrix(i)}}_warnUnsupportedFilter(t){var e;const s=((e=t==null?void 0:t.constructor)==null?void 0:e.name)||"Filter";this._warnedFilterTypes.has(s)||(this._warnedFilterTypes.add(s),console.warn(`CanvasRenderer: filter "${s}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new $w),this._filterStackIndex++,t}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}}Ea.extension={type:[T.CanvasSystem],name:"filter"};class Aa{constructor(t){this._renderer=t}push(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.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}}Aa.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"filter"};const Pa=Object.create(null),sf=Object.create(null);function ur(r,t){let e=sf[r];return e===void 0&&(Pa[t]===void 0&&(Pa[t]=1),sf[r]=e=Pa[t]++),e}let ws;function Ca(){return(!ws||ws!=null&&ws.isContextLost())&&(ws=X.get().createCanvas().getContext("webgl",{})),ws}let $i;function nf(){if(!$i){$i="mediump";const r=Ca();r&&r.getShaderPrecisionFormat&&($i=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return $i}function of(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 af(r,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let i=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return i==="highp"&&s!=="highp"&&(i="mediump"),`precision ${i} float; ${r}`}else if(s!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function lf(r,t){return t?`#version 300 es ${r}`:r}const Uw={},kw={};function uf(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?Uw:kw;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`} ${r}`}function hf(r,t){return t?r.replace("#version 300 es",""):r}var Lw=Object.defineProperty,cf=Object.getOwnPropertySymbols,Nw=Object.prototype.hasOwnProperty,jw=Object.prototype.propertyIsEnumerable,df=(r,t,e)=>t in r?Lw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pf=(r,t)=>{for(var e in t||(t={}))Nw.call(t,e)&&df(r,e,t[e]);if(cf)for(var e of cf(t))jw.call(t,e)&&df(r,e,t[e]);return r};const Ra={stripVersion:hf,ensurePrecision:af,addProgramDefines:of,setProgramName:uf,insertVersion:lf},Es=Object.create(null),ff=class $c{constructor(t){t=pf(pf({},$c.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:nf()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let i=t.fragment,n=t.vertex;Object.keys(Ra).forEach(o=>{const a=s[o];i=Ra[o](i,a,!0),n=Ra[o](n,a,!1)}),this.fragment=i,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=ur(`${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,Es[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Es[e]||(Es[e]=new $c(t),Es[e]._cacheKey=e),Es[e]}};ff.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Yt=ff;const mf={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 Be(r){var t;return(t=mf[r])!=null?t:mf.float32}const Xw={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"},gf=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function _f(r,t){var e;let s;for(;(s=gf.exec(r))!==null;){const i=(e=Xw[s[3]])!=null?e:"float32";t[s[2]]={location:parseInt(s[1],10),format:i,stride:Be(i).stride,offset:0,instance:!1,start:0}}gf.lastIndex=0}function Hw(r){return r.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function xf({source:r,entryPoint:t}){const e={},s=Hw(r),i=s.indexOf(`fn ${t}(`);if(i===-1)return e;const n=s.indexOf("->",i);if(n===-1)return e;const o=s.substring(i,n);if(_f(o,e),Object.keys(e).length===0){const a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){const l=a[1],u=new RegExp(`struct\\s+${l}\\s*\\{([^}]+)\\}`,"s"),h=s.match(u);h&&_f(h[1],e)}}return e}function Ui(r){var t,e,s;const i=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,o=/@binding\((\d+)\)/,a=/var(<[^>]+>)? (\w+)/,l=/:\s*([\w<>]+)/,u=/struct\s+(\w+)\s*{([^}]+)}/g,h=/(\w+)\s*:\s*([\w\<\>]+)/g,c=/struct\s+(\w+)/,d=(t=r.match(i))==null?void 0:t.map(f=>{var m;const g=f.match(a),_=(m=g==null?void 0:g[1])!=null?m:"";let x;return _===""?x="uniform":_.startsWith("{const m=f.match(c)[1],g=f.match(h).reduce((_,x)=>{const[v,b]=x.split(":");return _[v.trim()]=b.trim(),_},{});return g?{name:m,members:g}:null}).filter(({name:f})=>d.some(m=>m.type===f||m.type.includes(`<${f}>`))))!=null?s:[];return{groups:d,structs:p}}var At=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(At||{});function vf({groups:r}){const t=[];for(let e=0;ee.has(o.name)?!1:(e.add(o.name),!0)),n=[...r.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return s.has(a)?!1:(s.add(a),!0)});return{structs:i,groups:n}}const As=Object.create(null);class zt{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;var e,s;const{fragment:i,vertex:n,layout:o,gpuLayout:a,name:l}=t;if(this.name=l,this.fragment=i,this.vertex=n,i.source===n.source){const u=Ui(i.source);this.structsAndGroups=u}else{const u=Ui(n.source),h=Ui(i.source);this.structsAndGroups=yf(u,h)}this.layout=o!=null?o:bf(this.structsAndGroups),this.gpuLayout=a!=null?a:vf(this.structsAndGroups),this.autoAssignGlobalUniforms=((e=this.layout[0])==null?void 0:e.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((s=this.layout[1])==null?void 0:s.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=ur(s,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=xf(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,As[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return As[e]||(As[e]=new zt(t),As[e]._cacheKey=e),As[e]}}class Ee{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const i=t[s];this.setResource(i,e++)}}get _key(){if(this._dirty){this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]?this.resources[s]._resourceId:-1;this._keyValue=t.join("|")}return this._keyValue}setResource(t,e){var s,i;const n=this.resources[e];t!==n&&(n&&((s=n.off)==null||s.call(n,"change",this.onResourceChange,this)),(i=t.on)==null||i.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const s in e){const i=e[s];i&&(i._gcLastUsed=t)}}destroy(){var t;const e=this.resources;for(const s in e){const i=e[s];(t=i==null?void 0:i.off)==null||t.call(i,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const s in e)e[s]===t&&(e[s]=null)}}}var Mt=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.CANVAS=4]="CANVAS",r[r.BOTH=3]="BOTH",r))(Mt||{}),zw=Object.defineProperty,Tf=Object.getOwnPropertySymbols,Ww=Object.prototype.hasOwnProperty,Vw=Object.prototype.propertyIsEnumerable,Sf=(r,t,e)=>t in r?zw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yw=(r,t)=>{for(var e in t||(t={}))Ww.call(t,e)&&Sf(r,e,t[e]);if(Tf)for(var e of Tf(t))Vw.call(t,e)&&Sf(r,e,t[e]);return r};class as{constructor(t){this.data=Yw({},t);const e=Object.keys(t).sort().map(s=>`${s}:${t[s]}`).join("|");this.id=ur(e,"shader-overrides")}static from(t){return t instanceof as?t:new as(t)}}const Ma=["f32","i32","u32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4","vec2","vec3","vec4","vec2","vec3","vec4"],wf=Ma.reduce((r,t)=>(r[t]=!0,r),{});function Ef(r,t){switch(r){case"f32":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"mat2x2":return new Float32Array([1,0,0,1]);case"mat3x3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var Kw=Object.defineProperty,Af=Object.getOwnPropertySymbols,qw=Object.prototype.hasOwnProperty,Zw=Object.prototype.propertyIsEnumerable,Pf=(r,t,e)=>t in r?Kw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Cf=(r,t)=>{for(var e in t||(t={}))qw.call(t,e)&&Pf(r,e,t[e]);if(Af)for(var e of Af(t))Zw.call(t,e)&&Pf(r,e,t[e]);return r};const Rf=class sS extends It{constructor(t,e){var s,i;super(),this.uid=ut("uniform"),this._resourceType="uniformGroup",this._resourceId=ut("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e=Cf(Cf({},sS.defaultOptions),e),this.uniformStructures=t;const n={};for(const o in t){const a=t[o];if(a.name=o,a.size=(s=a.size)!=null?s:1,!wf[a.type]){const l=a.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(l){const[,u,h]=l;throw new Error(`Uniform type ${a.type} is not supported. Use type: '${u}', size: ${h} instead.`)}throw new Error(`Uniform type ${a.type} is not supported. Supported uniform types are: ${Ma.join(", ")}`)}(i=a.value)!=null||(a.value=Ef(a.type,a.size)),n[o]=a.value}this.uniforms=n,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=ur(Object.keys(n).map(o=>`${o}-${t[o].type}`).join("-"),"uniform-group")}get buffer(){return this._buffer}set buffer(t){var e;this._buffer!==t&&((e=this._buffer)==null||e.off("change",this.onBufferChange,this),this._buffer=t,t==null||t.on("change",this.onBufferChange,this))}get _gcLastUsed(){var t,e;return(e=(t=this._buffer)==null?void 0:t._gcLastUsed)!=null?e:-1}set _gcLastUsed(t){this._buffer&&(this._buffer._gcLastUsed=t)}onBufferChange(){this._resourceId=ut("resource"),this.emit("change",this)}update(){this._dirtyId++}};Rf.defaultOptions={ubo:!1,isStatic:!1};let wt=Rf;var Qw=Object.defineProperty,ki=Object.getOwnPropertySymbols,Mf=Object.prototype.hasOwnProperty,Of=Object.prototype.propertyIsEnumerable,Gf=(r,t,e)=>t in r?Qw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jw=(r,t)=>{for(var e in t||(t={}))Mf.call(t,e)&&Gf(r,e,t[e]);if(ki)for(var e of ki(t))Of.call(t,e)&&Gf(r,e,t[e]);return r},tE=(r,t)=>{var e={};for(var s in r)Mf.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&ki)for(var s of ki(r))t.indexOf(s)<0&&Of.call(r,s)&&(e[s]=r[s]);return e};class ne extends It{constructor(t){super(),this.uid=ut("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:s,groups:i,resources:n,compatibleRenderers:o,groupMap:a,overrides:l}=t;this._overrides=l?as.from(l):null,this.gpuProgram=e,this.glProgram=s,o===void 0&&(o=0,e&&(o|=Mt.WEBGPU),s&&(o|=Mt.WEBGL)),this.compatibleRenderers=o;const u={};if(a)for(const h in a)for(const c in a[h]){const d=a[h][c];u[d]={group:h,binding:c,name:d}}if(!n&&!i&&(n={}),n&&i)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&i&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(e&&i&&!a){const h=e.structsAndGroups.groups;a={},h.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,u[c.name]=c})}else if(n){i={},a||(a={}),e&&e.structsAndGroups.groups.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,u[c.name]=c});let h=0;for(const c in n)u[c]||(i[99]||(i[99]=new Ee,this._ownedBindGroups.push(i[99])),u[c]={group:99,binding:h,name:c},a[99]=a[99]||{},a[99][h]=c,h++);for(const c in n){const d=c;let p=n[c];!p.source&&!p._resourceType&&(p=new wt(p));const f=u[d];f&&(i[f.group]||(i[f.group]=new Ee,this._ownedBindGroups.push(i[f.group])),i[f.group].setResource(p,f.binding))}}this.groups=i,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(i,u)}addResource(t,e,s){var i,n;(i=this._uniformBindMap)[e]||(i[e]={}),(n=this._uniformBindMap[e])[s]||(n[s]=t),this.groups[e]||(this.groups[e]=new Ee,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const i in e){const n=e[i];Object.defineProperty(s,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return s}destroy(t=!1){var e,s;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(i=>{i.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null,this._overrides=null)}static from(t){const e=t,{gpu:s,gl:i}=e,n=tE(e,["gpu","gl"]);let o,a;return s&&(o=zt.from(s)),i&&(a=Yt.from(i)),new ne(Jw({gpuProgram:o,glProgram:a},n))}}const eE={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},Oa={BLEND:0,OFFSET:1,CULLING:2,DEPTH_TEST:3,WINDING:4,DEPTH_MASK:5},{BLEND:Ga,OFFSET:Ia,CULLING:Fa,DEPTH_TEST:Ba,WINDING:Da,DEPTH_MASK:$a}=Oa,Ua=class iS{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<t in r?rE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ka=(r,t)=>{for(var e in t||(t={}))If.call(t,e)&&Bf(r,e,t[e]);if(Li)for(var e of Li(t))Ff.call(t,e)&&Bf(r,e,t[e]);return r},sE=(r,t)=>{var e={};for(var s in r)If.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Li)for(var s of Li(r))t.indexOf(s)<0&&Ff.call(r,s)&&(e[s]=r[s]);return e};const Df=class Uc extends ne{constructor(t){t=ka(ka({},Uc.defaultOptions),t),super(t),this.enabled=!0,this._state=Kt.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,s,i){t.applyFilter(this,e,s,i)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const e=t,{gpu:s,gl:i}=e,n=sE(e,["gpu","gl"]);let o,a;return s&&(o=zt.from(s)),i&&(a=Yt.from(i)),new Uc(ka({gpuProgram:o,glProgram:a},n))}};Df.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Ae=Df;var Ps=`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(); } `,$f=`in vec2 vTextureCoord; out vec4 finalColor; uniform sampler2D uTexture; void main() { finalColor = texture(uTexture, vTextureCoord); } `,La=`struct GlobalFilterUniforms { uInputSize: vec4, uInputPixel: vec4, uInputClamp: vec4, uOutputFrame: vec4, uGlobalFrame: vec4, uOutputTexture: vec4, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler: sampler; struct VSOutput { @builtin(position) position: vec4, @location(0) uv: vec2 }; fn filterVertexPosition(aPosition: vec2) -> vec4 { 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) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } @vertex fn mainVertex( @location(0) aPosition: vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition) ); } @fragment fn mainFragment( @location(0) uv: vec2, ) -> @location(0) vec4 { return textureSample(uTexture, uSampler, uv); } `;class Uf extends Ae{constructor(){const t=zt.from({vertex:{source:La,entryPoint:"mainVertex"},fragment:{source:La,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=Yt.from({vertex:Ps,fragment:$f,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}}var st=(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))(st||{});class qt extends It{constructor(t){let{data:e,size:s}=t;const{usage:i,label:n,shrinkToFit:o}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=ut("buffer"),this._resourceType="buffer",this._resourceId=ut("resource"),this._updateID=1,this._updateOffset=0,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s!=null||(s=e==null?void 0:e.byteLength);const a=!!e;this.descriptor={size:s,usage:i,mappedAtCreation:a,label:n},this.shrinkToFit=o!=null?o:!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&st.STATIC)}set static(t){t?this.descriptor.usage|=st.STATIC:this.descriptor.usage&=~st.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._updateOffset=0,this._data===t){s&&this.emit("update",this);return}const i=this._data;if(this._data=t,this._dataInt32=null,!i||i.length!==t.length){!this.shrinkToFit&&i&&t.byteLengtha&&(a=p),f>l&&(l=f),p"},uInputPixel:{value:new Float32Array(4),type:"vec4"},uInputClamp:{value:new Float32Array(4),type:"vec4"},uOutputFrame:{value:new Float32Array(4),type:"vec4"},uGlobalFrame:{value:new Float32Array(4),type:"vec4"},uOutputTexture:{value:new Float32Array(4),type:"vec4"}}),this._globalFilterBindGroup=new Ee({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){const e=this.renderer,s=t.filterEffect.filters,i=this._pushFilterData();i.skip=!1,i.filters=s,i.container=t.container,i.outputRenderSurface=e.renderTarget.renderSurface;const n=e.renderTarget.renderTarget.colorTexture.source,o=n.resolution,a=n.antialias;if(s.every(p=>!p.enabled)){i.skip=!0;return}const l=i.bounds;if(this._calculateFilterArea(t,l),this._calculateFilterBounds(i,e.renderTarget.rootViewPort,a,o,1),i.skip)return;const u=this._getPreviousFilterData(),h=this._findFilterResolution(o);let c=0,d=0;u&&(c=u.bounds.minX,d=u.bounds.minY),this._calculateGlobalFrame(i,c,d,h,n.width,n.height),this._setupFilterTextures(i,l,e,u)}generateFilteredTexture({texture:t,filters:e}){const s=this._pushFilterData();this._activeFilterData=s,s.skip=!1,s.filters=e;const i=t.source,n=i.resolution,o=i.antialias;if(e.every(h=>!h.enabled))return s.skip=!0,t;const a=s.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(s,a.rectangle,o,n,0),s.skip)return t;const l=n;this._calculateGlobalFrame(s,0,0,l,i.width,i.height),s.outputRenderSurface=ft.getOptimalTexture({width:a.width,height:a.height,resolution:s.resolution,antialias:s.antialias}),s.backTexture=B.EMPTY,s.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(s,!0);const u=s.outputRenderSurface;return u.source.alphaMode="premultiplied-alpha",u}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&&ft.returnTexture(e.backTexture),ft.returnTexture(e.inputTexture))}getBackTexture(t,e,s){const i=t.colorTexture.source._resolution,n=ft.getOptimalTexture({width:e.width,height:e.height,resolution:i});let o=e.minX,a=e.minY;s&&(o-=s.minX,a-=s.minY),o=Math.floor(o*i),a=Math.floor(a*i);const l=Math.ceil(e.width*i),u=Math.ceil(e.height*i);return this.renderer.renderTarget.copyToTexture(t,n,{x:o,y:a},{width:l,height:u},{x:0,y:0}),n}applyFilter(t,e,s,i){const n=this.renderer,o=this._activeFilterData,a=o.outputRenderSurface===s,l=n.renderTarget.rootRenderTarget.colorTexture.source._resolution,u=this._findFilterResolution(l);let h=0,c=0;if(a){const p=this._findPreviousFilterOffset();h=p.x,c=p.y}this._updateFilterUniforms(e,s,o,h,c,u,a,i);const d=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,e,n)}calculateSpriteMatrix(t,e){const s=this._activeFilterData,i=t.set(s.inputTexture._source.width,0,0,s.inputTexture._source.height,s.bounds.minX,s.bounds.minY),n=e.worldTransform.copyTo(D.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&n.prepend(o.cacheToLocalTransform),n.invert(),i.prepend(n),i.scale(1/e.texture.orig.width,1/e.texture.orig.height),i.translate(e.anchor.x,e.anchor.y),i}destroy(){var t;(t=this._passthroughFilter)==null||t.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){var t;return(t=this._passthroughFilter)!=null||(this._passthroughFilter=new Uf),this._passthroughFilter}_setupBindGroupsAndRender(t,e,s){if(s.renderPipes.uniformBatch){const i=s.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(i,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,s.encoder.draw({geometry:nE,shader:t,state:t._state,topology:"triangle-list"}),s.type===Mt.WEBGL&&s.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,s,i){if(t.backTexture=B.EMPTY,t.inputTexture=ft.getOptimalTexture({width:e.width,height:e.height,resolution:t.resolution,antialias:t.antialias}),t.blendRequired){s.renderTarget.finishRenderPass();const n=s.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(n,e,i==null?void 0:i.bounds)}s.renderTarget.bind({target:t.inputTexture,clear:!0}),s.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,s,i,n,o){const a=t.globalFrame;a.x=e*i,a.y=s*i,a.width=n*i,a.height=o*i}_updateFilterUniforms(t,e,s,i,n,o,a,l){const u=this._filterGlobalUniforms.uniforms,h=u.uOutputFrame,c=u.uInputSize,d=u.uInputPixel,p=u.uInputClamp,f=u.uGlobalFrame,m=u.uOutputTexture;a?(h[0]=s.bounds.minX-i,h[1]=s.bounds.minY-n):(h[0]=0,h[1]=0),h[2]=t.frame.width,h[3]=t.frame.height,c[0]=t.source.width,c[1]=t.source.height,c[2]=1/c[0],c[3]=1/c[1],d[0]=t.source.pixelWidth,d[1]=t.source.pixelHeight,d[2]=1/d[0],d[3]=1/d[1],p[0]=.5*d[2],p[1]=.5*d[3],p[2]=t.frame.width*c[2]-.5*d[2],p[3]=t.frame.height*c[3]-.5*d[3];const g=this.renderer.renderTarget.rootRenderTarget.colorTexture;f[0]=i*o,f[1]=n*o,f[2]=g.source.width*o,f[3]=g.source.height*o,e instanceof B&&(e.source.resource=null);const _=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind({target:e,clear:!!l}),e instanceof B?(m[0]=e.frame.width,m[1]=e.frame.height):(m[0]=_.width,m[1]=_.height),m[2]=_.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,s=this._filterStackIndex;for(;s>0;){s--;const i=this._filterStack[s];if(!i.skip){t=i.bounds.minX,e=i.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?Sa(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 s=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;s&&e.applyMatrix(s)}}_applyFiltersToTexture(t,e){const s=t.inputTexture,i=t.bounds,n=t.filters,o=t.firstEnabledIndex,a=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(s.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),o===a)n[o].apply(this,s,t.outputRenderSurface,e);else{let l=t.inputTexture;const u=ft.getOptimalTexture({width:i.width,height:i.height,resolution:l.source._resolution});let h=u;for(let c=o;c0&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new oE),this._filterStackIndex++,t}}ja.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"filter"},L.add(ja,Ea),L.add(Aa);var aE={__proto__:null};const Xa=[];L.handleByNamedList(T.Environment,Xa);async function Ha(r){if(!r)for(let t=0;t80*e){a=r[0],l=r[1];let h=a,c=l;for(let d=e;dh&&(h=p),f>c&&(c=f)}u=Math.max(h-a,c-l),u=u!==0?32767/u:0}return Rs(n,o,e,a,l,u,0),o}function Nf(r,t,e,s,i){let n;if(i===Ya(r,t,e,s)>0)for(let o=t;o=t;o-=s)n=zf(o/s|0,r[o],r[o+1],n);return n&&Or(n,n.next)&&(Gs(n),n=n.next),n}function cr(r,t){if(!r)return r;t||(t=r);let e=r,s;do if(s=!1,!e.steiner&&(Or(e,e.next)||xt(e.prev,e,e.next)===0)){if(Gs(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function Rs(r,t,e,s,i,n,o){if(!r)return;!o&&n&&xE(r,s,i,n);let a=r;for(;r.prev!==r.next;){const l=r.prev,u=r.next;if(n?hE(r,s,i,n):uE(r)){t.push(l.i,r.i,u.i),Gs(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=cE(cr(r),t),Rs(r,t,e,s,i,n,2)):o===2&&dE(r,t,e,s,i,n):Rs(cr(r),t,e,s,i,n,1);break}}}function uE(r){const t=r.prev,e=r,s=r.next;if(xt(t,e,s)>=0)return!1;const i=t.x,n=e.x,o=s.x,a=t.y,l=e.y,u=s.y,h=Math.min(i,n,o),c=Math.min(a,l,u),d=Math.max(i,n,o),p=Math.max(a,l,u);let f=s.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=c&&f.y<=p&&Ms(i,a,n,l,o,u,f.x,f.y)&&xt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function hE(r,t,e,s){const i=r.prev,n=r,o=r.next;if(xt(i,n,o)>=0)return!1;const a=i.x,l=n.x,u=o.x,h=i.y,c=n.y,d=o.y,p=Math.min(a,l,u),f=Math.min(h,c,d),m=Math.max(a,l,u),g=Math.max(h,c,d),_=Wa(p,f,t,e,s),x=Wa(m,g,t,e,s);let v=r.prevZ,b=r.nextZ;for(;v&&v.z>=_&&b&&b.z<=x;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==i&&v!==o&&Ms(a,h,l,c,u,d,v.x,v.y)&&xt(v.prev,v,v.next)>=0||(v=v.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==i&&b!==o&&Ms(a,h,l,c,u,d,b.x,b.y)&&xt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=_;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==i&&v!==o&&Ms(a,h,l,c,u,d,v.x,v.y)&&xt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=x;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==i&&b!==o&&Ms(a,h,l,c,u,d,b.x,b.y)&&xt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function cE(r,t){let e=r;do{const s=e.prev,i=e.next.next;!Or(s,i)&&Xf(s,e,e.next,i)&&Os(s,i)&&Os(i,s)&&(t.push(s.i,e.i,i.i),Gs(e),Gs(e.next),e=r=i),e=e.next}while(e!==r);return cr(e)}function dE(r,t,e,s,i,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&yE(o,a)){let l=Hf(o,a);o=cr(o,o.next),l=cr(l,l.next),Rs(o,t,e,s,i,n,0),Rs(l,t,e,s,i,n,0);return}a=a.next}o=o.next}while(o!==r)}function pE(r,t,e,s){const i=[];for(let n=0,o=t.length;n=e.next.y&&e.next.y!==e.y){const c=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(c<=s&&c>n&&(n=c,o=e.x=e.x&&e.x>=l&&s!==e.x&&jf(io.x||e.x===o.x&&_E(o,e)))&&(o=e,h=c)}e=e.next}while(e!==a);return o}function _E(r,t){return xt(r.prev,r,t.prev)<0&&xt(t.next,r,r.next)<0}function xE(r,t,e,s){let i=r;do i.z===0&&(i.z=Wa(i.x,i.y,t,e,s)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,vE(i)}function vE(r){let t,e=1;do{let s=r,i;r=null;let n=null;for(t=0;s;){t++;let o=s,a=0;for(let u=0;u0||l>0&&o;)a!==0&&(l===0||!o||s.z<=o.z)?(i=s,s=s.nextZ,a--):(i=o,o=o.nextZ,l--),n?n.nextZ=i:r=i,i.prevZ=n,n=i;s=o}n.nextZ=null,e*=2}while(t>1);return r}function Wa(r,t,e,s,i){return r=(r-e)*i|0,t=(t-s)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function bE(r){let t=r,e=r;do(t.x=(r-o)*(n-a)&&(r-o)*(s-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(i-o)*(s-a)}function Ms(r,t,e,s,i,n,o,a){return!(r===o&&t===a)&&jf(r,t,e,s,i,n,o,a)}function yE(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!TE(r,t)&&(Os(r,t)&&Os(t,r)&&SE(r,t)&&(xt(r.prev,r,t.prev)||xt(r,t.prev,t))||Or(r,t)&&xt(r.prev,r,r.next)>0&&xt(t.prev,t,t.next)>0)}function xt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Or(r,t){return r.x===t.x&&r.y===t.y}function Xf(r,t,e,s){const i=ji(xt(r,t,e)),n=ji(xt(r,t,s)),o=ji(xt(e,s,r)),a=ji(xt(e,s,t));return!!(i!==n&&o!==a||i===0&&Ni(r,e,t)||n===0&&Ni(r,s,t)||o===0&&Ni(e,r,s)||a===0&&Ni(e,t,s))}function Ni(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 ji(r){return r>0?1:r<0?-1:0}function TE(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&&Xf(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Os(r,t){return xt(r.prev,r,r.next)<0?xt(r,t,r.next)>=0&&xt(r,r.prev,t)>=0:xt(r,t,r.prev)<0||xt(r,r.next,t)<0}function SE(r,t){let e=r,s=!1;const i=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&i<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==r);return s}function Hf(r,t){const e=Va(r.i,r.x,r.y),s=Va(t.i,t.x,t.y),i=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,s.next=e,e.prev=s,n.next=s,s.prev=n,s}function zf(r,t,e,s){const i=Va(r,t,e);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function Gs(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 Va(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function qB(r,t,e,s){const i=t&&t.length,n=i?t[0]*e:r.length;let o=Math.abs(Ya(r,0,n,e));if(i)for(let l=0,u=t.length;l(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))(Pt||{});class Ka{constructor(t){this.items=[],this._name=t}emit(t,e,s,i,n,o,a,l){const{name:u,items:h}=this;for(let c=0,d=h.length;ct in r?wE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xi=(r,t)=>{for(var e in t||(t={}))EE.call(t,e)&&Yf(r,e,t[e]);if(Vf)for(var e of Vf(t))AE.call(t,e)&&Yf(r,e,t[e]);return r};const PE=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Kf=class nS extends It{constructor(t){var e;super(),this.tick=0,this.uid=ut("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 s=[...PE,...(e=this.config.runners)!=null?e:[]];this._addRunners(...s),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Ha(e),!e&&this.config.loaders&&await Promise.all(this.config.loaders.map(s=>s.value.load())),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const s in this._systemsHash){const i=this._systemsHash[s].constructor.defaultOptions;t=Xi(Xi({},i),t)}t=Xi(Xi({},nS.defaultOptions),t),this._roundPixels=t.roundPixels?1:0;for(let s=0;s{this.runners[e]=new Ka(e)})}_addSystems(t){let e;for(e in t){const s=t[e];this._addSystem(s.value,s.name)}}_addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const i in this.runners)this.runners[i].add(s);return this}_addPipes(t,e){const s=e.reduce((i,n)=>(i[n.name]=n.value,i),{});t.forEach(i=>{const n=i.value,o=i.name,a=s[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)&&tr.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!za())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()}};Kf.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Gr=Kf,qa;function Is(r){return qa!==void 0||(qa=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r!=null?r:Gr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!X.get().getWebGLRenderingContext())return!1;let s=X.get().createCanvas().getContext("webgl",e);const i=!!((t=s==null?void 0:s.getContextAttributes())!=null&&t.stencil);if(s){const n=s.getExtension("WEBGL_lose_context");n&&n.loseContext()}return s=null,i}catch(s){return!1}})()),qa}let Za;async function Fs(r={}){return Za!==void 0||(Za=await(async()=>{const t=X.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch(e){return!1}})()),Za}var CE=Object.defineProperty,qf=Object.getOwnPropertySymbols,RE=Object.prototype.hasOwnProperty,ME=Object.prototype.propertyIsEnumerable,Zf=(r,t,e)=>t in r?CE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ir=(r,t)=>{for(var e in t||(t={}))RE.call(t,e)&&Zf(r,e,t[e]);if(qf)for(var e of qf(t))ME.call(t,e)&&Zf(r,e,t[e]);return r};const Qf=["webgl","webgpu","canvas"];async function Jf(r){var t;let e=[];r.preference?Array.isArray(r.preference)?e=r.preference.slice():(e.push(r.preference),Qf.forEach(o=>{o!==r.preference&&e.push(o)})):e=Qf.slice();let s,i={};for(let o=0;o{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,s;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,s=globalThis.innerHeight;else{const{clientWidth:i,clientHeight:n}=this._resizeTo;e=i,s=n}this.renderer.resize(e,s),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}tl.extension=T.Application;class el{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,Te.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Rt.shared:new Rt,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}el.extension=T.Application,L.add(tl),L.add(el);var GE=Object.defineProperty,tm=Object.getOwnPropertySymbols,IE=Object.prototype.hasOwnProperty,FE=Object.prototype.propertyIsEnumerable,em=(r,t,e)=>t in r?GE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,BE=(r,t)=>{for(var e in t||(t={}))IE.call(t,e)&&em(r,e,t[e]);if(tm)for(var e of tm(t))FE.call(t,e)&&em(r,e,t[e]);return r};const rm=class kc{constructor(...t){this.stage=new dt}async init(t){t=BE({},t),this.stage||(this.stage=new dt),this.renderer=await Jf(t),kc._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}get domContainerRoot(){var t;return(t=this.renderer.renderPipes.dom)==null?void 0:t._domElement}destroy(t=!1,e=!1){const s=kc._plugins.slice(0);s.reverse(),s.forEach(i=>{i.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};rm._plugins=[];let sm=rm;L.handleByList(T.Application,sm._plugins),L.add(Qa);const Hi={test(r){return typeof r=="string"&&r.startsWith("info face=")},parse(r){var t,e,s;const i=r.match(/^[a-z]+\s+.+$/gm),n={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const f in i){const m=i[f].match(/^[a-z]+/gm)[0],g=i[f].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),_={};for(const x in g){const v=g[x].split("="),b=v[0],S=v[1].replace(/"/gm,""),y=parseFloat(S),w=isNaN(y)?S:y;_[b]=w}n[m].push(_)}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 h=n.page;for(let f=0;f)/)?rl.test(X.get().parseXML(r)):!1},parse(r){return rl.parse(X.get().parseXML(r))}},DE=[".xml",".fnt"],im={extension:{type:T.CacheParser,name:"cacheBitmapFont"},test:r=>!!(r!=null&&r.pages)&&!!(r!=null&&r.chars)&&typeof(r==null?void 0:r.fontFamily)=="string"&&r.fontFamily!=="",getCacheableAssets(r,t){const e={};return r.forEach(s=>{e[s]=t,e[`${s}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},nm={extension:{type:T.LoadParser,priority:ee.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return DE.includes(Vt.extname(r).toLowerCase())},async testParse(r){return Hi.test(r)||sl.test(r)},async parse(r,t,e){const s=Hi.test(r)?Hi.parse(r):sl.parse(r),{src:i}=t,{pages:n}=s,o=[],a=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let c=0;cl[c.src]);return new u({data:s,textures:h},i)},async load(r,t){return await(await X.get().fetch(r)).text()},async unload(r,t,e){await Promise.all(r.pages.map(s=>e.unload(s.texture.source._sourceOrigin))),r.destroy()}};class om{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 s=0;sArray.isArray(r)&&r.every(t=>t instanceof B),getCacheableAssets:(r,t)=>{const e={};return r.forEach(s=>{t.forEach((i,n)=>{e[s+(n===0?"":n+1)]=i})}),e}};async function il(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 lm={extension:{type:T.DetectionParser,priority:1},test:async()=>il("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},um=["png","jpg","jpeg"],hm={extension:{type:T.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...um],remove:async r=>r.filter(t=>!um.includes(t))},$E="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Ds(r){return $E?!1:document.createElement("video").canPlayType(r)!==""}const cm={extension:{type:T.DetectionParser,priority:0},test:async()=>Ds("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},dm={extension:{type:T.DetectionParser,priority:0},test:async()=>Ds("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},pm={extension:{type:T.DetectionParser,priority:0},test:async()=>Ds("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},fm={extension:{type:T.DetectionParser,priority:0},test:async()=>il("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};var UE=Object.defineProperty,kE=Object.defineProperties,LE=Object.getOwnPropertyDescriptors,mm=Object.getOwnPropertySymbols,NE=Object.prototype.hasOwnProperty,jE=Object.prototype.propertyIsEnumerable,gm=(r,t,e)=>t in r?UE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fr=(r,t)=>{for(var e in t||(t={}))NE.call(t,e)&&gm(r,e,t[e]);if(mm)for(var e of mm(t))jE.call(t,e)&&gm(r,e,t[e]);return r},XE=(r,t)=>kE(r,LE(t));const _m=class Po{constructor(){this.loadOptions=Fr({},Po.defaultOptions),this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,s)=>(this._parsersValidated=!1,t[e]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var i,n;let o=null,a=null;if((e.parser||e.loadParser)&&(a=this._parserHash[e.parser||e.loadParser]),!a){for(let l=0;l({alias:[m],src:m,data:{}})),p=d.reduce((m,g)=>m+(g.progressSize||1),0),f=d.map(async m=>{const g=Vt.toAbsolute(m.src);h[m.src]||(await this._loadAssetWithRetry(g,m,{onProgress:i,onError:n,strategy:o,retryCount:a,retryDelay:l},h),u+=m.progressSize||1,i&&i(u/p))});return await Promise.all(f),c?h[d[0].src]:h}async unload(t){const e=ue(t,s=>({alias:[s],src:s})).map(async s=>{var i,n;const o=Vt.toAbsolute(s.src),a=this.promiseCache[o];if(a){const l=await a.promise;delete this.promiseCache[o],await((n=(i=a.parser)==null?void 0:i.unload)==null?void 0:n.call(i,l,s,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,s,i){let n=0;const{onError:o,strategy:a,retryCount:l,retryDelay:u}=s,h=c=>new Promise(d=>setTimeout(d,c));for(;;)try{this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),i[e.src]=await this.promiseCache[t].promise;return}catch(c){delete this.promiseCache[t],delete i[e.src],n++;const d=a!=="retry"||n>l;if(a==="retry"&&!d){o&&o(c,e),await h(u);continue}if(a==="skip"){o&&o(c,e);return}o&&o(c,e);const p=new Error(`[Loader.load] Failed to load ${t}. ${c}`);throw c instanceof Error&&c.stack&&(p.stack=c.stack),p}}};_m.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let xm=_m;function dr(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 he(r,t){const e=r.split("?")[0],s=Vt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const HE=".json",zE="application/json",vm={extension:{type:T.LoadParser,priority:ee.Low},name:"loadJson",id:"json",test(r){return dr(r,zE)||he(r,HE)},async load(r){return await(await X.get().fetch(r)).json()}},WE=".txt",VE="text/plain",bm={name:"loadTxt",id:"text",extension:{type:T.LoadParser,priority:ee.Low,name:"loadTxt"},test(r){return dr(r,VE)||he(r,WE)},async load(r){return await(await X.get().fetch(r)).text()}};var YE=Object.defineProperty,KE=Object.defineProperties,qE=Object.getOwnPropertyDescriptors,ym=Object.getOwnPropertySymbols,ZE=Object.prototype.hasOwnProperty,QE=Object.prototype.propertyIsEnumerable,Tm=(r,t,e)=>t in r?YE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,JE=(r,t)=>{for(var e in t||(t={}))ZE.call(t,e)&&Tm(r,e,t[e]);if(ym)for(var e of ym(t))QE.call(t,e)&&Tm(r,e,t[e]);return r},tA=(r,t)=>KE(r,qE(t));const eA=["normal","bold","100","200","300","400","500","600","700","800","900"],rA=[".ttf",".otf",".woff",".woff2"],sA=["font/ttf","font/otf","font/woff","font/woff2"],iA=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Sm(r){const t=Vt.extname(r),e=Vt.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let s=e.length>0;for(const n of e)if(!n.match(iA)){s=!1;break}let i=e.join(" ");return s||(i=`"${i.replace(/[\\"]/g,"\\$&")}"`),i}const nA=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function oA(r){return nA.test(r)?r:encodeURI(r)}const wm={extension:{type:T.LoadParser,priority:ee.Low},name:"loadWebFont",id:"web-font",test(r){return dr(r,sA)||he(r,rA)},async load(r,t){var e,s,i,n,o,a;const l=X.get().getFontFaceSet();if(l){const u=[],h=(s=(e=t.data)==null?void 0:e.family)!=null?s:Sm(r),c=(o=(n=(i=t.data)==null?void 0:i.weights)==null?void 0:n.filter(p=>eA.includes(p)))!=null?o:["normal"],d=(a=t.data)!=null?a:{};for(let p=0;pn.faces.some(o=>t.indexOf(o)!==-1));i.faces=i.faces.filter(n=>t.indexOf(n)===-1),i.faces.length===0&&(s.entries=s.entries.filter(n=>n!==i)),t.forEach(n=>{X.get().getFontFaceSet().delete(n)}),s.entries.length===0&&rt.remove(`${e}-and-url`)}},nl={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},aA=/([astvzqmhlc])([^astvzqmhlc]*)/gi,lA=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;function uA(r){const t=[];return r.replace(aA,(e,s,i)=>{let n=s.toLowerCase(),o=s;const a=hA(i);for(n==="m"&&a.length>2&&(t.push([o,...a.splice(0,2)]),n="l",o=o==="m"?"l":"L");;){if(a.length===nl[n])return t.push([o,...a]),"";if(a.length0&&(i=s.pop(),i?(n=i.startX,o=i.startY):(n=0,o=0)),i=null;break;default:}u!=="Z"&&u!=="z"&&i===null&&(i={startX:n,startY:o},s.push(i))}return t}const Am={};function zi(r,t,e){let s=2166136261;for(let i=0;i>>=0;return Am[s]||cA(r,t,s,e)}function cA(r,t,e,s){const i={};let n=0;for(let a=0;a{if(Br.quiet||Pm.has(t))return;let s=new Error().stack;const i=`${t} Deprecated since v${r}`,n=typeof console.groupCollapsed=="function"&&!Br.noColor;typeof s=="undefined"?console.warn("PixiJS Deprecation Warning: ",i):(s=s.split(` `).splice(e).join(` `),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",i),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",i),console.warn(s))),Pm.add(t)});Object.defineProperties($s,{quiet:{get:()=>Br.quiet,set:r=>{Br.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>Br.noColor,set:r=>{Br.noColor=r},enumerable:!0,configurable:!1}});function Wi(r,t,e,s){if(e!=null||(e=0),s!=null||(s=Math.min(r.byteLength-e,t.byteLength)),!(e&7)&&!(s&7)){const i=s/8;new Float64Array(t,0,i).set(new Float64Array(r,e,i))}else if(!(e&3)&&!(s&3)){const i=s/4;new Float32Array(t,0,i).set(new Float32Array(r,e,i))}else new Uint8Array(t).set(new Uint8Array(r,e,s))}const Cm={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var bt=(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))(bt||{});function Dr(r,t){return t.alphaMode==="no-premultiply-alpha"&&Cm[r]||r}const fA=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` `);function mA(r){let t="";for(let e=0;e0&&(t+=` else `),et in r?gA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Im=(r,t)=>{for(var e in t||(t={}))_A.call(t,e)&&Gm(r,e,t[e]);if(Om)for(var e of Om(t))xA.call(t,e)&&Gm(r,e,t[e]);return r};class Fm{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Mm,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}const Us=[];let Vi=0;tr.register({clear:()=>{if(Us.length>0)for(const r of Us)r&&r.destroy();Us.length=0,Vi=0}});function Bm(){return Vi>0?Us[--Vi]:new Fm}function Dm(r){r.elements=null,Us[Vi++]=r}let ks=0;const $m=class oS{constructor(t){this.uid=ut("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t=Im(Im({},oS.defaultOptions),t),t.maxTextures||($s("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=Rm());const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:i}=t;this.attributeBuffer=new pr(s*4),this.indexBuffer=new Uint16Array(i),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;tthis.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const l=this.attributeBuffer.float32View,u=this.attributeBuffer.uint32View,h=this.indexBuffer;let c=this._batchIndexSize,d=this._batchIndexStart,p="startBatch",f=[];const m=this.maxTextures;for(let g=this.elementStart;g=m||b)&&(this._finishBatch(s,d,c-d,i,o,a,t,p,f),p="renderBatch",d=c,o=v,a=_.topology,s=Bm(),i=s.textures,i.clear(),f=[],++ks),_._textureId=x._textureBindLocation=i.count,i.ids[x.uid]=i.count,i.textures[i.count++]=x,_._batch=s,f.push(_),c+=_.indexSize,_.packAsQuad?(this.packQuadAttributes(_,l,u,_._attributeStart,_._textureId),this.packQuadIndex(h,_._indexStart,_._attributeStart/this.vertexSize)):(this.packAttributes(_,l,u,_._attributeStart,_._textureId),this.packIndex(_,h,_._indexStart,_._attributeStart/this.vertexSize))}i.count>0&&(this._finishBatch(s,d,c-d,i,o,a,t,p,f),d=c,++ks),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=c}_finishBatch(t,e,s,i,n,o,a,l,u){t.gpuBindGroup=null,t.bindGroup=null,t.action=l,t.batcher=this,t.textures=i,t.blendMode=n,t.topology=o,t.start=e,t.size=s,t.elements=u,++ks,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),s=new pr(e);Wi(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const i=s>65535?new Uint32Array(s):new Uint16Array(s);if(i.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;ni.replace(/[{()}]/g,"")))!=null?e:[]).forEach(i=>{s[i]=[]}),s}function Lm(r,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function hl(r,t,e=!1){const s=[];Lm(t,s),r.forEach(a=>{a.header&&Lm(a.header,s)});const i=s;e&&i.sort();const n=i.map((a,l)=>` @location(${l}) ${a},`).join(` `);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",` ${n} `),o}function Nm(r,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function TA(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function SA(r){const t=/@.*?\s+/g;return r.replace(t,"")}function jm(r,t){const e=[];Nm(t,e),r.forEach(l=>{l.header&&Nm(l.header,e)});let s=0;const i=e.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${s++}) ${l}`).join(`, `),n=e.sort().map(l=>` var ${SA(l)};`).join(` `),o=`return VSOutput( ${e.sort().map(l=>` ${TA(l)}`).join(`, `)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",` ${i} `),a=a.replace("{{start}}",` ${n} `),a=a.replace("{{return}}",` ${o} `),a}function cl(r,t){let e=r;for(const s in t){const i=t[s];i.join(` `).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----// ${i.join(` `)} //----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const fr=Object.create(null),dl=new Map;let wA=0;function Xm({template:r,bits:t}){const e=zm(r,t);if(fr[e])return fr[e];const{vertex:s,fragment:i}=EA(r,t);return fr[e]=Wm(s,i,t),fr[e]}function Hm({template:r,bits:t}){const e=zm(r,t);return fr[e]||(fr[e]=Wm(r.vertex,r.fragment,t)),fr[e]}function EA(r,t){const e=t.map(o=>o.vertex).filter(o=>!!o),s=t.map(o=>o.fragment).filter(o=>!!o);let i=hl(e,r.vertex,!0);i=jm(e,i);const n=hl(s,r.fragment,!0);return{vertex:i,fragment:n}}function zm(r,t){return t.map(e=>(dl.has(e)||dl.set(e,wA++),dl.get(e))).sort((e,s)=>e-s).join("-")+r.vertex+r.fragment}function Wm(r,t,e){const s=ul(r),i=ul(t);return e.forEach(n=>{ll(n.vertex,s,n.name),ll(n.fragment,i,n.name)}),{vertex:cl(r,s),fragment:cl(t,i)}}const Vm=` @in aPosition: vec2; @in aUV: vec2; @out @builtin(position) vPosition: vec4; @out vUV : vec2; @out vColor : vec4; {{header}} struct VSOutput { {{struct}} }; @vertex fn main( {{in}} ) -> VSOutput { var worldTransformMatrix = globalUniforms.uWorldTransformMatrix; var modelMatrix = mat3x3( 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ); var position = aPosition; var uv = aUV; {{start}} vColor = vec4(1., 1., 1., 1.); {{main}} vUV = uv; var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix; vPosition = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); vColor *= globalUniforms.uWorldColorAlpha; {{end}} {{return}} }; `,Ym=` @in vUV : vec2; @in vColor : vec4; {{header}} @fragment fn main( {{in}} ) -> @location(0) vec4 { {{start}} var outColor:vec4; {{main}} var finalColor:vec4 = outColor * vColor; {{end}} return finalColor; }; `,Km=` 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}} } `,qm=` in vec4 vColor; in vec2 vUV; out vec4 finalColor; {{header}} void main(void) { {{start}} vec4 outColor; {{main}} finalColor = outColor * vColor; {{end}} } `,Zm={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, uWorldColorAlpha: vec4, uResolution: vec2, } @group(0) @binding(0) var globalUniforms : GlobalUniforms; `}},AA={name:"global-uniforms-ubo-bit",vertex:{header:` uniform globalUniforms { mat3 uProjectionMatrix; mat3 uWorldTransformMatrix; vec4 uWorldColorAlpha; vec2 uResolution; }; `}},Qm={name:"global-uniforms-bit",vertex:{header:` uniform mat3 uProjectionMatrix; uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; `}};var PA=Object.defineProperty,Jm=Object.getOwnPropertySymbols,CA=Object.prototype.hasOwnProperty,RA=Object.prototype.propertyIsEnumerable,tg=(r,t,e)=>t in r?PA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,MA=(r,t)=>{for(var e in t||(t={}))CA.call(t,e)&&tg(r,e,t[e]);if(Jm)for(var e of Jm(t))RA.call(t,e)&&tg(r,e,t[e]);return r};function Ur({bits:r,name:t}){const e=Xm({template:{fragment:Ym,vertex:Vm},bits:[Zm,...r]});return zt.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function kr({bits:r,name:t}){return new Yt(MA({name:t},Hm({template:{vertex:Km,fragment:qm},bits:[Qm,...r]})))}const Yi={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},Ki={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},pl={};function OA(r){const t=[];if(r===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let s=0;s;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(` `)}function GA(r){const t=[];if(r===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e; @out @interpolate(flat) vTextureId : u32; `,main:` vTextureId = aTextureIdAndRound.y; `,end:` if(aTextureIdAndRound.x == 1) { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } `},fragment:{header:` @in @interpolate(flat) vTextureId: u32; ${OA(r)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); ${GA(r)} `}}),pl[r]}const fl={};function IA(r){const t=[];for(let e=0;e0&&t.push("else"),e, targetSize: vec2) -> vec2 { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } `}},Nr={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; } `}},eg={};function Qi(r){let t=eg[r];if(t)return t;const e=new Int32Array(r);for(let s=0;se&&this.remove(e,...t))}destroy(...t){this.removeAll(...t),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function gl(r,t,e,s,i,n,o,a=null){let l=0;e*=t,i*=n;const u=a.a,h=a.b,c=a.c,d=a.d,p=a.tx,f=a.ty;for(;l>16|t&65280|(t&255)<<16,s=this.renderable;return s?be(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||FA}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 BA=Object.defineProperty,DA=Object.defineProperties,$A=Object.getOwnPropertyDescriptors,sg=Object.getOwnPropertySymbols,UA=Object.prototype.hasOwnProperty,kA=Object.prototype.propertyIsEnumerable,ig=(r,t,e)=>t in r?BA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rn=(r,t)=>{for(var e in t||(t={}))UA.call(t,e)&&ig(r,e,t[e]);if(sg)for(var e of sg(t))kA.call(t,e)&&ig(r,e,t[e]);return r},sn=(r,t)=>DA(r,$A(t));const jr={extension:{type:T.ShapeBuilder,name:"circle"},build(r,t){let e,s,i,n,o,a;if(r.type==="circle"){const b=r;if(o=a=b.radius,o<=0)return!1;e=b.x,s=b.y,i=n=0}else if(r.type==="ellipse"){const b=r;if(o=b.halfWidth,a=b.halfHeight,o<=0||a<=0)return!1;e=b.x,s=b.y,i=n=0}else{const b=r,S=b.width/2,y=b.height/2;e=b.x+S,s=b.y+y,o=a=Math.max(0,Math.min(b.radius,Math.min(S,y))),i=S-o,n=y-a}if(i<0||n<0)return!1;const l=Math.ceil(2.3*Math.sqrt(o+a)),u=l*8+(i?4:0)+(n?4:0);if(u===0)return!1;if(l===0)return t[0]=t[6]=e+i,t[1]=t[3]=s+n,t[2]=t[4]=e-i,t[5]=t[7]=s-n,!0;let h=0,c=l*4+(i?2:0)+2,d=c,p=u,f=i+o,m=n,g=e+f,_=e-f,x=s+m;if(t[h++]=g,t[h++]=x,t[--c]=x,t[--c]=_,n){const b=s-m;t[d++]=_,t[d++]=b,t[--p]=b,t[--p]=g}for(let b=1;b0&&(i[n++]=l,i[n++]=u,i[n++]=l-1),l++;i[n++]=u+1,i[n++]=u,i[n++]=l-1}},ng=sn(rn({},jr),{extension:sn(rn({},jr.extension),{name:"ellipse"})}),og=sn(rn({},jr),{extension:sn(rn({},jr.extension),{name:"roundedRectangle"})}),xl=1e-4,vl=1e-4;function ag(r,t,e,s,i,n,o,a){const l=r-e*i,u=t-s*i,h=r+e*n,c=t+s*n;let d,p;o?(d=s,p=-e):(d=-s,p=e);const f=l+d,m=u+p,g=h+d,_=c+p;return a.push(f,m),a.push(g,_),2}function mr(r,t,e,s,i,n,o,a){const l=e-r,u=s-t;let h=Math.atan2(l,u),c=Math.atan2(i-r,n-t);a&&hc&&(c+=Math.PI*2);let d=h;const p=c-h,f=Math.abs(p),m=Math.sqrt(l*l+u*u),g=(15*f*Math.sqrt(m)/Math.PI>>0)+1,_=p/g;if(d+=_,a){o.push(r,t),o.push(e,s);for(let x=1,v=d;x=0&&(a.join==="round"?m+=mr(y,w,y-P*M,w-C*M,y-O*M,w-F*M,p,!1)+4:m+=2,p.push(y-O*I,w-F*I),p.push(y+O*M,w+F*M));continue}const mt=(-P+b)*(-C+w)-(-P+y)*(-C+S),J=(-O+E)*(-F+w)-(-O+y)*(-F+A),ot=(Q*J-N*mt)/z,nt=(k*mt-K*J)/z,ht=(ot-y)*(ot-y)+(nt-w)*(nt-w),Tt=y+(ot-y)*M,Et=w+(nt-w)*M,_t=y-(ot-y)*I,q=w-(nt-w)*I,Wt=Math.min(Q*Q+K*K,N*N+k*k),Gt=et?M:I,Me=Wt+Gt*Gt*x;ht<=Me?a.join==="bevel"||ht/x>v?(et?(p.push(Tt,Et),p.push(y+P*I,w+C*I),p.push(Tt,Et),p.push(y+O*I,w+F*I)):(p.push(y-P*M,w-C*M),p.push(_t,q),p.push(y-O*M,w-F*M),p.push(_t,q)),m+=2):a.join==="round"?et?(p.push(Tt,Et),p.push(y+P*I,w+C*I),m+=mr(y,w,y+P*I,w+C*I,y+O*I,w+F*I,p,!0)+4,p.push(Tt,Et),p.push(y+O*I,w+F*I)):(p.push(y-P*M,w-C*M),p.push(_t,q),m+=mr(y,w,y-P*M,w-C*M,y-O*M,w-F*M,p,!1)+4,p.push(y-O*M,w-F*M),p.push(_t,q)):(p.push(Tt,Et),p.push(_t,q)):(p.push(y-P*M,w-C*M),p.push(y+P*I,w+C*I),a.join==="round"?et?m+=mr(y,w,y+P*I,w+C*I,y+O*I,w+F*I,p,!0)+2:m+=mr(y,w,y-P*M,w-C*M,y-O*M,w-F*M,p,!1)+2:a.join==="miter"&&ht/x<=v&&(et?(p.push(_t,q),p.push(_t,q)):(p.push(Tt,Et),p.push(Tt,Et)),m+=2),p.push(y-O*M,w-F*M),p.push(y+O*I,w+F*I),m+=2)}b=r[(f-2)*2],S=r[(f-2)*2+1],y=r[(f-1)*2],w=r[(f-1)*2+1],P=-(S-w),C=b-y,R=Math.sqrt(P*P+C*C),P/=R,C/=R,P*=_,C*=_,p.push(y-P*M,w-C*M),p.push(y+P*I,w+C*I),c||(a.cap==="round"?m+=mr(y-P*(M-I)*.5,w-C*(M-I)*.5,y-P*M,w-C*M,y+P*I,w+C*I,p,!1)+2:a.cap==="square"&&(m+=ag(y,w,P,C,M,I,!1,p)));const U=vl*vl;for(let j=g;j0&&o>0?(t[0]=s,t[1]=i,t[2]=s+n,t[3]=i,t[4]=s+n,t[5]=i+o,t[6]=s,t[7]=i+o,!0):!1},triangulate(r,t,e,s,i,n){let o=0;s*=e,t[s+o]=r[0],t[s+o+1]=r[1],o+=e,t[s+o]=r[2],t[s+o+1]=r[3],o+=e,t[s+o]=r[6],t[s+o+1]=r[7],o+=e,t[s+o]=r[4],t[s+o+1]=r[5],o+=e;const a=s/e;i[n++]=a,i[n++]=a+1,i[n++]=a+2,i[n++]=a+1,i[n++]=a+3,i[n++]=a+2}},cg={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,s,i,n){let o=0;s*=e,t[s+o]=r[0],t[s+o+1]=r[1],o+=e,t[s+o]=r[2],t[s+o+1]=r[3],o+=e,t[s+o]=r[4],t[s+o+1]=r[5];const a=s/e;i[n++]=a,i[n++]=a+1,i[n++]=a+2}};var NA=Object.defineProperty,dg=Object.getOwnPropertySymbols,jA=Object.prototype.hasOwnProperty,XA=Object.prototype.propertyIsEnumerable,pg=(r,t,e)=>t in r?NA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fg=(r,t)=>{for(var e in t||(t={}))jA.call(t,e)&&pg(r,e,t[e]);if(dg)for(var e of dg(t))XA.call(t,e)&&pg(r,e,t[e]);return r};const mg=[{offset:0,color:"white"},{offset:1,color:"black"}],yl=class Lc{constructor(...t){this.uid=ut("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];var e;let s=HA(t);const i=s.type==="radial"?Lc.defaultRadialOptions:Lc.defaultLinearOptions;s=fg(fg({},i),ce(s)),this._textureSize=s.textureSize,this._wrapMode=s.wrapMode,s.type==="radial"?(this.center=s.center,this.outerCenter=(e=s.outerCenter)!=null?e:this.center,this.innerRadius=s.innerRadius,this.outerRadius=s.outerRadius,this.scale=s.scale,this.rotation=s.rotation):(this.start=s.start,this.end=s.end),this.textureSpace=s.textureSpace,this.type=s.type,s.colorStops.forEach(n=>{this.addColorStop(n.offset,n.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:tt.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:s,y:i}=this.end,n=s-t,o=i-e;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const g=t;t=s,s=g,n*=-1}if(o<0){const g=e;e=i,i=g,o*=-1}}const l=this.colorStops.length?this.colorStops:mg,u=this._textureSize,{canvas:h,context:c}=_g(u,1),d=a?c.createLinearGradient(this._textureSize,0,0,0):c.createLinearGradient(0,0,this._textureSize,0);gg(d,l),c.fillStyle=d,c.fillRect(0,0,u,1),this.texture=new B({source:new je({resource:h,addressMode:this._wrapMode})});const p=Math.sqrt(n*n+o*o),f=Math.atan2(o,n),m=new D;m.scale(p/u,1),m.rotate(f),m.translate(t,e),this.textureSpace==="local"&&m.scale(u,u),this.transform=m}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:mg,e=this._textureSize,{canvas:s,context:i}=_g(e,e),{x:n,y:o}=this.center,{x:a,y:l}=this.outerCenter,u=this.innerRadius,h=this.outerRadius,c=a-h,d=l-h,p=e/(h*2),f=(n-c)*p,m=(o-d)*p,g=i.createRadialGradient(f,m,u*p,(a-c)*p,(l-d)*p,h*p);gg(g,t),i.fillStyle=t[t.length-1].color,i.fillRect(0,0,e,e),i.fillStyle=g,i.translate(f,m),i.rotate(this.rotation),i.scale(1,this.scale),i.translate(-f,-m),i.fillRect(0,0,e,e),this.texture=new B({source:new je({resource:s,addressMode:this._wrapMode})});const _=new D;this.textureSpace==="local"?_.scale(2*h,2*h):_.scale(1/p,1/p),_.translate(c,d),this.transform=_}destroy(){var t;(t=this.texture)==null||t.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};yl.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},yl.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,rotation:0,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Lt=yl;function gg(r,t){for(let e=0;e{var c;const d=[],p=Xe[l.type];if(!p.build(l,d))return;const f=a.length,m=n.length/2;let g="triangle-list";if(u&&tn(d,u),e){const b=(c=l.closePath)!=null?c:!0,S=t;S.pixelLine?(lg(d,b,n,a),g="line-list"):nn(d,S,!1,b,n,a)}else if(h){const b=[],S=d.slice();ZA(h).forEach(y=>{b.push(S.length/2),S.push(...y)}),bl(S,b,n,2,m,a,f)}else p.triangulate(d,n,2,m,a,f);const _=o.length/2,x=t.texture;if(x!==B.WHITE){const b=Tl(KA,t,l,u);gl(n,2,m,o,_,2,n.length/2-m,b)}else _l(o,_,2,n.length/2-m);const v=St.get(en);v.indexOffset=f,v.indexSize=a.length-f,v.attributeOffset=m,v.attributeSize=n.length/2-m,v.baseColor=t.color,v.alpha=t.alpha,v.texture=x,v.geometryData=i,v.topology=g,s.push(v)})}function ZA(r){const t=[];for(let e=0;e{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 yg{constructor(){this.instructions=new yi}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Ji({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 Sl=class Nc{constructor(t){this._renderer=t,this._managedContexts=new kt({renderer:t,type:"resource",name:"graphicsContext"})}init(t){var e;Nc.defaultOptions.bezierSmoothness=(e=t==null?void 0:t.bezierSmoothness)!=null?e:Nc.defaultOptions.bezierSmoothness}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=!!t._gpuData[this._renderer.uid],s=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!e){e&&s.reset(),xg(t,s);const i=t.batchMode;t.customShader||i==="no-batch"?s.isBatchable=!1:i==="auto"?s.isBatchable=s.geometryData.vertices.length<400:s.isBatchable=!0,t.dirty=!1}return s}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=St.get(yg,{maxTextures:this._renderer.limits.maxBatchableTextures}),s=t._gpuData[this._renderer.uid],{batches:i,geometryData:n}=s;s.graphicsData=e;const o=n.vertices.length,a=n.indices.length;for(let c=0;cQA)return;const c=Math.PI,d=(r+e)/2,p=(t+s)/2,f=(e+i)/2,m=(s+n)/2,g=(i+o)/2,_=(n+a)/2,x=(d+f)/2,v=(p+m)/2,b=(f+g)/2,S=(m+_)/2,y=(x+b)/2,w=(v+S)/2;if(h>0){let E=o-r,A=a-t;const P=Math.abs((e-o)*A-(s-a)*E),C=Math.abs((i-o)*A-(n-a)*E);let O,F;if(P>an&&C>an){if((P+C)*(P+C)<=u*(E*E+A*A)){if(Xr=c&&(O=2*c-O),F>=c&&(F=2*c-F),O+Fgr){l.push(e,s);return}if(F>gr){l.push(i,n);return}}}}else if(P>an){if(P*P<=u*(E*E+A*A)){if(Xr=c&&(O=2*c-O),Ogr){l.push(e,s);return}}}else if(C>an){if(C*C<=u*(E*E+A*A)){if(Xr=c&&(O=2*c-O),Ogr){l.push(i,n);return}}}else if(E=y-(r+o)/2,A=w-(t+a)/2,E*E+A*A<=u){l.push(y,w);return}}Al(r,t,d,p,x,v,y,w,l,u,h+1),Al(y,w,b,S,g,_,o,a,l,u,h+1)}const eP=8,rP=11920929e-14,sP=1,iP=.01,Tg=0;function Sg(r,t,e,s,i,n,o,a){const l=Math.min(.99,Math.max(0,a!=null?a:on.defaultOptions.bezierSmoothness));let u=(sP-l)/1;return u*=u,nP(t,e,s,i,n,o,r,u),r}function nP(r,t,e,s,i,n,o,a){Pl(o,r,t,e,s,i,n,a,0),o.push(i,n)}function Pl(r,t,e,s,i,n,o,a,l){if(l>eP)return;const u=Math.PI,h=(t+s)/2,c=(e+i)/2,d=(s+n)/2,p=(i+o)/2,f=(h+d)/2,m=(c+p)/2;let g=n-t,_=o-e;const x=Math.abs((s-n)*_-(i-o)*g);if(x>rP){if(x*x<=a*(g*g+_*_)){if(Tg=u&&(v=2*u-v),vn||o&&n>i)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(l/Math.PI)))),a=Math.max(a,3);let u=l/a,h=i;u*=o?-1:1;for(let c=0;ch*a)}const Ns=Math.PI*2,Rl={centerX:0,centerY:0,ang1:0,ang2:0},Ml=({x:r,y:t},e,s,i,n,o,a,l)=>{r*=e,t*=s;const u=i*r-n*t,h=n*r+i*t;return l.x=u+o,l.y=h+a,l};function oP(r,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,i=Math.cos(r),n=Math.sin(r),o=Math.cos(r+t),a=Math.sin(r+t);return[{x:i-n*s,y:n+i*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}const Eg=(r,t,e,s)=>{const i=r*s-t*e<0?-1:1;let n=r*e+t*s;return n>1&&(n=1),n<-1&&(n=-1),i*Math.acos(n)},aP=(r,t,e,s,i,n,o,a,l,u,h,c,d)=>{const p=Math.pow(i,2),f=Math.pow(n,2),m=Math.pow(h,2),g=Math.pow(c,2);let _=p*f-p*g-f*m;_<0&&(_=0),_/=p*g+f*m,_=Math.sqrt(_)*(o===a?-1:1);const x=_*i/n*c,v=_*-n/i*h,b=u*x-l*v+(r+e)/2,S=l*x+u*v+(t+s)/2,y=(h-x)/i,w=(c-v)/n,E=(-h-x)/i,A=(-c-v)/n,P=Eg(1,0,y,w);let C=Eg(y,w,E,A);a===0&&C>0&&(C-=Ns),a===1&&C<0&&(C+=Ns),d.centerX=b,d.centerY=S,d.ang1=P,d.ang2=C};function Ag(r,t,e,s,i,n,o,a=0,l=0,u=0){if(n===0||o===0)return;const h=Math.sin(a*Ns/360),c=Math.cos(a*Ns/360),d=c*(t-s)/2+h*(e-i)/2,p=-h*(t-s)/2+c*(e-i)/2;if(d===0&&p===0)return;n=Math.abs(n),o=Math.abs(o);const f=Math.pow(d,2)/Math.pow(n,2)+Math.pow(p,2)/Math.pow(o,2);f>1&&(n*=Math.sqrt(f),o*=Math.sqrt(f)),aP(t,e,s,i,n,o,l,u,h,c,d,p,Rl);let{ang1:m,ang2:g}=Rl;const{centerX:_,centerY:x}=Rl;let v=Math.abs(g)/(Ns/4);Math.abs(1-v)<1e-7&&(v=1);const b=Math.max(Math.ceil(v),1);g/=b;let S=r[r.length-2],y=r[r.length-1];const w={x:0,y:0};for(let E=0;E{const u=l.x-a.x,h=l.y-a.y,c=Math.sqrt(u*u+h*h),d=u/c,p=h/c;return{len:c,nx:d,ny:p}},n=(a,l)=>{a===0?r.moveTo(l.x,l.y):r.lineTo(l.x,l.y)};let o=t[t.length-1];for(let a=0;a0&&(f=-1,m=!0);const g=p/2;let _,x=Math.abs(Math.cos(g)*u/Math.sin(g));x>Math.min(c.len/2,d.len/2)?(x=Math.min(c.len/2,d.len/2),_=Math.abs(x*Math.sin(g)/Math.cos(g))):_=u;const v=l.x+d.nx*x+-d.ny*_*f,b=l.y+d.ny*x+d.nx*_*f,S=Math.atan2(c.ny,c.nx)+Math.PI/2*f,y=Math.atan2(d.ny,d.nx)-Math.PI/2*f;a===0&&r.moveTo(v+Math.cos(S)*_,b+Math.sin(S)*_),r.arc(v,b,_,S,y,m),o=l}}function Cg(r,t,e,s){var i;const n=(l,u)=>Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2),o=(l,u,h)=>({x:l.x+(u.x-l.x)*h,y:l.y+(u.y-l.y)*h}),a=t.length;for(let l=0;l1){let n=null;for(let o=i;o=2;c-=2)h[c]===h[c-2]&&h[c-1]===h[c-3]&&h.splice(c-1,2);return this.poly(h,!0,o)}ellipse(t,e,s,i,n){return this.drawShape(new Fo(t,e,s,i),n),this}roundRect(t,e,s,i,n,o){return this.drawShape(new Bo(t,e,s,i,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new os,s.points.push(t,e),this._currentPoly=s,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new os,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,i=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,o=s;s=n.a*s+n.c*i+n.tx,i=n.b*o+n.d*i+n.ty}this._currentPoly.points.push(s,i)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;ea.area).sort((a,l)=>l-a),[e,s]=t,i=t[t.length-1],n=e/s,o=s/i;return!(n>3&&o<2)}function cP(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 Dg(r){return r.split(/(?=[Mm])/).filter(t=>t.trim().length>0)}function $g(r){const t=r.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),s=[],i=[];for(let u=0;ut in r?dP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ln=(r,t)=>{for(var e in t||(t={}))pP.call(t,e)&&kg(r,e,t[e]);if(Ug)for(var e of Ug(t))fP.call(t,e)&&kg(r,e,t[e]);return r};function Lg(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 ge};Og(r,e);const s=r.children,{fillStyle:i,strokeStyle:n}=Fl(r,e);for(let o=0;o1;if(C&&O){const F=P.map(R=>({path:R,area:$g(R)}));if(F.sort((R,G)=>G.area-R.area),P.length>3||!Bg(F))for(let R=0;RparseInt(A,10)),t.context.poly(v,!0),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"polyline":b=r.getAttribute("points"),v=b.match(/-?\d+/g).map(A=>parseInt(A,10)),t.context.poly(v,!1),s&&t.context.stroke(s);break;case"g":case"svg":break;default:{Bt(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}a&&(e=null);for(let A=0;At in r?gP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fe=(r,t)=>{for(var e in t||(t={}))Xg.call(t,e)&&zg(r,e,t[e]);if(un)for(var e of un(t))Hg.call(t,e)&&zg(r,e,t[e]);return r},_P=(r,t)=>{var e={};for(var s in r)Xg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&un)for(var s of un(r))t.indexOf(s)<0&&Hg.call(r,s)&&(e[s]=r[s]);return e};function xP(r){return tt.isColorLike(r)}function Wg(r){return r instanceof zr}function Vg(r){return r instanceof Lt}function vP(r){return r instanceof B}function bP(r,t,e){const s=tt.shared.setValue(t!=null?t:0);return r.color=s.toNumber(),r.alpha=s.alpha===1?e.alpha:s.alpha,r.texture=B.WHITE,fe(fe({},e),r)}function yP(r,t,e){return r.texture=t,fe(fe({},e),r)}function Yg(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,fe(fe({},e),r)}function Kg(r,t,e){return t.buildGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,fe(fe({},e),r)}function TP(r,t){const e=fe(fe({},t),r),s=tt.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e}function He(r,t){if(r==null)return null;const e={},s=r;return xP(r)?bP(e,r,t):vP(r)?yP(e,r,t):Wg(r)?Yg(e,r,t):Vg(r)?Kg(e,r,t):s.fill&&Wg(s.fill)?Yg(s,s.fill,t):s.fill&&Vg(s.fill)?Kg(s,s.fill,t):TP(s,t)}function js(r,t){const e=t,{width:s,alignment:i,miterLimit:n,cap:o,join:a,pixelLine:l}=e,u=_P(e,["width","alignment","miterLimit","cap","join","pixelLine"]),h=He(r,u);return h?fe({width:s,alignment:i,miterLimit:n,cap:o,join:a,pixelLine:l},h):null}function qg(r,t){let e=1;const s=r.shapePath.shapePrimitives;for(let i=0;i1&&(E=1);const A=Math.sqrt((1-E)*.5);if(A<1e-6)continue;const P=Math.min(1/A,t);P>e&&(e=P)}}return e}var SP=Object.defineProperty,Zg=Object.getOwnPropertySymbols,wP=Object.prototype.hasOwnProperty,EP=Object.prototype.propertyIsEnumerable,Qg=(r,t,e)=>t in r?SP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Wr=(r,t)=>{for(var e in t||(t={}))wP.call(t,e)&&Qg(r,e,t[e]);if(Zg)for(var e of Zg(t))EP.call(t,e)&&Qg(r,e,t[e]);return r};const AP=new lt,Jg=new D,Dl=class Re extends It{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ut("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new ge,this._transform=new D,this._fillStyle=Wr({},Re.defaultFillStyle),this._strokeStyle=Wr({},Re.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new Ct,this._boundsDirty=!0}clone(){const t=new Re;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=Wr({},this._fillStyle),t._strokeStyle=Wr({},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=He(t,Re.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=js(t,Re.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=He(t,Re.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=He(t,Re.defaultStrokeStyle),this}texture(t,e,s,i,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:i||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e||e===0?tt.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new ge,this}fill(t,e){let s;const i=this.instructions[this.instructions.length-1];return this._tick===0&&(i==null?void 0:i.action)==="stroke"?s=i.data.path:s=this._activePath.clone(),s?(t!=null&&(e!==void 0&&typeof t=="number"&&(t={color:t,alpha:e}),this._fillStyle=He(t,Re.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(lt.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const s=this.instructions[this.instructions.length-1];return this._tick===0&&(s==null?void 0:s.action)==="fill"?e=s.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=js(t,Re.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],s=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(s);else{e.data.hole=s;break}}return this._initNextPathLocation(),this}arc(t,e,s,i,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,s,i,n,o),this}arcTo(t,e,s,i,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*s+o.c*i+o.tx,o.b*s+o.d*i+o.ty,n),this}arcToSvg(t,e,s,i,n,o,a){this._tick++;const l=this._transform;return this._activePath.arcToSvg(t,e,s,i,n,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(t,e,s,i,n,o,a){this._tick++;const l=this._transform;return this._activePath.bezierCurveTo(l.a*t+l.c*e+l.tx,l.b*t+l.d*e+l.ty,l.a*s+l.c*i+l.tx,l.b*s+l.d*i+l.ty,l.a*n+l.c*o+l.tx,l.b*n+l.d*o+l.ty,a),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,s,i){return this._tick++,this._activePath.ellipse(t,e,s,i,this._transform.clone()),this}circle(t,e,s){return this._tick++,this._activePath.circle(t,e,s,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const s=this._transform;return this._activePath.lineTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty),this}moveTo(t,e){this._tick++;const s=this._transform,i=this._activePath.instructions,n=s.a*t+s.c*e+s.tx,o=s.b*t+s.d*e+s.ty;return i.length===1&&i[0].action==="moveTo"?(i[0].data[0]=n,i[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,s,i,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*s+o.c*i+o.tx,o.b*s+o.d*i+o.ty,n),this}rect(t,e,s,i){return this._tick++,this._activePath.rect(t,e,s,i,this._transform.clone()),this}roundRect(t,e,s,i,n){return this._tick++,this._activePath.roundRect(t,e,s,i,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,s,i,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,s,i,n,o),this}roundPoly(t,e,s,i,n,o){return this._tick++,this._activePath.roundPoly(t,e,s,i,n,o),this}roundShape(t,e,s,i){return this._tick++,this._activePath.roundShape(t,e,s,i),this}filletRect(t,e,s,i,n){return this._tick++,this._activePath.filletRect(t,e,s,i,n),this}chamferRect(t,e,s,i,n,o){return this._tick++,this._activePath.chamferRect(t,e,s,i,n,o),this}star(t,e,s,i,n=0,o=0){return this._tick++,this._activePath.star(t,e,s,i,n,o,this._transform.clone()),this}svg(t){return this._tick++,Lg(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:Wr({},this._fillStyle),strokeStyle:Wr({},this._strokeStyle)}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,s,i,n,o){return t instanceof D?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,s,i,n,o),this)}transform(t,e,s,i,n,o){return t instanceof D?(this._transform.append(t),this):(Jg.set(t,e,s,i,n,o),this._transform.append(Jg),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=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e{delete t.promiseCache[e],rt.has(e)&&rt.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&i()}),s.once("destroy",()=>{r.destroyed||i()}),s}var PP=Object.defineProperty,hn=Object.getOwnPropertySymbols,t_=Object.prototype.hasOwnProperty,e_=Object.prototype.propertyIsEnumerable,r_=(r,t,e)=>t in r?PP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,CP=(r,t)=>{for(var e in t||(t={}))t_.call(t,e)&&r_(r,e,t[e]);if(hn)for(var e of hn(t))e_.call(t,e)&&r_(r,e,t[e]);return r},RP=(r,t)=>{var e={};for(var s in r)t_.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&hn)for(var s of hn(r))t.indexOf(s)<0&&e_.call(r,s)&&(e[s]=r[s]);return e};const MP=".svg",OP="image/svg+xml",s_={extension:{type:T.LoadParser,priority:ee.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return dr(r,OP)||he(r,MP)},async load(r,t,e){var s,i;return((i=(s=t.data)==null?void 0:s.parseAsGraphicsContext)!=null?i:this.config.parseAsGraphicsContext)?IP(r):GP(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function GP(r,t,e,s){var i,n,o,a,l,u;const h=await X.get().fetch(r),c=X.get().createImage();c.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await h.text())}`,c.crossOrigin=s,await c.decode();const d=(n=(i=t.data)==null?void 0:i.width)!=null?n:c.width,p=(a=(o=t.data)==null?void 0:o.height)!=null?a:c.height,f=((l=t.data)==null?void 0:l.resolution)||ze(r),m=Math.ceil(d*f),g=Math.ceil(p*f),_=X.get().createCanvas(m,g),x=_.getContext("2d");x.imageSmoothingEnabled=!0,x.imageSmoothingQuality="high",x.drawImage(c,0,0,d*f,p*f);const v=(u=t.data)!=null?u:{},{parseAsGraphicsContext:b}=v,S=RP(v,["parseAsGraphicsContext"]),y=new je(CP({resource:_,alphaMode:"premultiply-alpha-on-upload",resolution:f},S));return We(y,e,r)}async function IP(r){const t=await(await X.get().fetch(r)).text(),e=new Nt;return e.svg(t),e}const FP=`(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 Vr=null,$l=class{constructor(){Vr||(Vr=URL.createObjectURL(new Blob([FP],{type:"application/javascript"}))),this.worker=new Worker(Vr)}};$l.revokeObjectURL=function(){Vr&&(URL.revokeObjectURL(Vr),Vr=null)};const BP='(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 Yr=null,i_=class{constructor(){Yr||(Yr=URL.createObjectURL(new Blob([BP],{type:"application/javascript"}))),this.worker=new Worker(Yr)}};i_.revokeObjectURL=function(){Yr&&(URL.revokeObjectURL(Yr),Yr=null)};let n_=0,Ul,DP=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 $l;e.addEventListener("message",s=>{e.terminate(),$l.revokeObjectURL(),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var s;return this._run("loadImageBitmap",[t,(s=e==null?void 0:e.data)==null?void 0:s.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Ul===void 0&&(Ul=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers{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 s=new Promise((i,n)=>{this._queue.push({id:t,arguments:e,resolve:i,reject:n})});return this._next(),s}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),s=e.id;this._resolveHash[n_]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:n_++,id:s})}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 kl=new DP;var $P=Object.defineProperty,o_=Object.getOwnPropertySymbols,UP=Object.prototype.hasOwnProperty,kP=Object.prototype.propertyIsEnumerable,a_=(r,t,e)=>t in r?$P(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,LP=(r,t)=>{for(var e in t||(t={}))UP.call(t,e)&&a_(r,e,t[e]);if(o_)for(var e of o_(t))kP.call(t,e)&&a_(r,e,t[e]);return r};const NP=[".jpeg",".jpg",".png",".webp",".avif"],jP=["image/jpeg","image/png","image/webp","image/avif"];async function l_(r,t){var e;const s=await X.get().fetch(r);if(!s.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${s.status} ${s.statusText}`);const i=await s.blob();return((e=t==null?void 0:t.data)==null?void 0:e.alphaMode)==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}const Ll={name:"loadTextures",id:"texture",extension:{type:T.LoadParser,priority:ee.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return dr(r,jP)||he(r,NP)},async load(r,t,e){var s;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await kl.isImageBitmapSupported()?i=await kl.loadImageBitmap(r,t):i=await l_(r,t):i=await new Promise((o,a)=>{i=X.get().createImage(),i.crossOrigin=this.config.crossOrigin,i.src=r,i.complete?o(i):(i.onload=()=>{o(i)},i.onerror=a)});const n=new je(LP({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((s=t.data)==null?void 0:s.resolution)||ze(r)},t.data));return We(n,e,r)},unload(r){r.destroy(!0)}};var XP=Object.defineProperty,HP=Object.defineProperties,zP=Object.getOwnPropertyDescriptors,u_=Object.getOwnPropertySymbols,WP=Object.prototype.hasOwnProperty,VP=Object.prototype.propertyIsEnumerable,h_=(r,t,e)=>t in r?XP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nl=(r,t)=>{for(var e in t||(t={}))WP.call(t,e)&&h_(r,e,t[e]);if(u_)for(var e of u_(t))VP.call(t,e)&&h_(r,e,t[e]);return r},c_=(r,t)=>HP(r,zP(t));const YP=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let jl,Xl;function d_(r,t,e){e===void 0&&!t.startsWith("data:")?r.crossOrigin=f_(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}function p_(r){return new Promise((t,e)=>{r.addEventListener("canplaythrough",s),r.addEventListener("error",i),r.load();function s(){n(),t()}function i(o){n(),e(o)}function n(){r.removeEventListener("canplaythrough",s),r.removeEventListener("error",i)}})}function f_(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 KP(){const r=[],t=[];for(const e of YP){const s=Rr.MIME_TYPES[e.substring(1)]||`video/${e.substring(1)}`;Ds(s)&&(r.push(e),t.includes(s)||t.push(s))}return{validVideoExtensions:r,validVideoMime:t}}const m_={name:"loadVideo",id:"video",extension:{type:T.LoadParser,name:"loadVideo"},test(r){if(!jl||!Xl){const{validVideoExtensions:s,validVideoMime:i}=KP();jl=s,Xl=i}const t=dr(r,Xl),e=he(r,jl);return t||e},async load(r,t,e){var s,i;const n=Nl(c_(Nl({},Rr.defaultOptions),{resolution:((s=t.data)==null?void 0:s.resolution)||ze(r),alphaMode:((i=t.data)==null?void 0:i.alphaMode)||await ga()}),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(h=>{const c=a[h];c!==void 0&&o.setAttribute(h,c)}),n.muted===!0&&(o.muted=!0),d_(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 h=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase();u=Rr.MIME_TYPES[h]||`video/${h}`}return l.src=r,u&&(l.type=u),new Promise((h,c)=>{n.preload&&!n.autoPlay&&o.load(),o.addEventListener("canplay",d),o.addEventListener("error",p),l.addEventListener("error",p),o.appendChild(l);async function d(){const m=new Rr(c_(Nl({},n),{resource:o}));f(),t.data.preload&&await p_(o),h(We(m,e,r))}function p(m){f(),c(m)}function f(){o.removeEventListener("canplay",d),o.removeEventListener("error",p),l.removeEventListener("error",p)}})},unload(r){r.destroy(!0)}},Hl={extension:{type:T.ResolveParser,name:"resolveTexture"},test:Ll.test,parse:r=>{var t,e;return{resolution:parseFloat((e=(t=Ne.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:r.split(".").pop(),src:r}}},g_={extension:{type:T.ResolveParser,priority:-2,name:"resolveJson"},test:r=>Ne.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:Hl.parse};var qP=Object.defineProperty,__=Object.getOwnPropertySymbols,ZP=Object.prototype.hasOwnProperty,QP=Object.prototype.propertyIsEnumerable,x_=(r,t,e)=>t in r?qP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,v_=(r,t)=>{for(var e in t||(t={}))ZP.call(t,e)&&x_(r,e,t[e]);if(__)for(var e of __(t))QP.call(t,e)&&x_(r,e,t[e]);return r};class b_{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Ne,this.loader=new xm,this.cache=rt,this._backgroundLoader=new om(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var e,s,i;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=(s=(e=t.texturePreference)==null?void 0:e.resolution)!=null?s:1,o=typeof n=="number"?[n]:n,a=await this._detectFormats({preferredFormats:(i=t.texturePreference)==null?void 0:i.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=v_(v_({},this.loader.loadOptions),t.loadOptions))}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const s=Ts(t),i=ue(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(i),o=await this._mapLoadToResolve(n,e);return s?o[i[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;typeof t=="string"&&(s=!0,t=[t]);const i=this.resolver.resolveBundle(t),n={},o=Object.keys(i);let a=0;const l=[],u=()=>{e==null||e(l.reduce((c,d)=>c+d,0)/a)},h=o.map((c,d)=>{const p=i[c],f=Object.values(p),m=[...new Set(f.flat())].reduce((g,_)=>g+(_.progressSize||1),0);return l.push(0),a+=m,this._mapLoadToResolve(p,g=>{l[d]=g*m,u()}).then(g=>{n[c]=g})});return await Promise.all(h),s?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(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return rt.get(t);const e={};for(let s=0;s{const a=i[o.src],l=[o.src];o.alias&&l.push(...o.alias),l.forEach(u=>{n[u]=a}),rt.set(l,a)}),n}async unload(t){this._initialized||await this.init();const e=ue(t).map(i=>typeof i!="string"?i.src:i),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=ue(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(i=>this._unloadFromResolved(e[i]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{rt.remove(s.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const s of t.detections)t.skipDetections||await s.test()?e=await s.add(e):t.skipDetections||(e=await s.remove(e));return e=e.filter((s,i)=>e.indexOf(s)===i),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(s=>s in t).forEach(s=>{e.config[s]=t[s]})})}}const Xs=new b_;L.handleByList(T.LoadParser,Xs.loader.parsers).handleByList(T.ResolveParser,Xs.resolver.parsers).handleByList(T.CacheParser,Xs.cache.parsers).handleByList(T.DetectionParser,Xs.detections),L.add(am,hm,lm,fm,cm,dm,pm,vm,bm,wm,s_,Ll,m_,nm,im,Hl,g_);const y_={loader:T.LoadParser,resolver:T.ResolveParser,cache:T.CacheParser,detection:T.DetectionParser};L.handle(T.Asset,r=>{const t=r.ref;Object.entries(y_).filter(([e])=>!!t[e]).forEach(([e,s])=>{var i;return L.add(Object.assign(t[e],{extension:(i=t[e].extension)!=null?i:s}))})},r=>{const t=r.ref;Object.keys(y_).filter(e=>!!t[e]).forEach(e=>L.remove(t[e]))});const JP={extension:{type:T.DetectionParser,priority:3},test:async()=>!!(await Fs()||Is()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>t!=="basis")};var tC=Object.defineProperty,eC=Object.defineProperties,rC=Object.getOwnPropertyDescriptors,T_=Object.getOwnPropertySymbols,sC=Object.prototype.hasOwnProperty,iC=Object.prototype.propertyIsEnumerable,S_=(r,t,e)=>t in r?tC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nC=(r,t)=>{for(var e in t||(t={}))sC.call(t,e)&&S_(r,e,t[e]);if(T_)for(var e of T_(t))iC.call(t,e)&&S_(r,e,t[e]);return r},oC=(r,t)=>eC(r,rC(t));class Hs extends ct{constructor(t){super(oC(nC({},t),{mipLevelCount:t.resource.length})),this.uploadMethodId="compressed"}}let cn;function zl(){if(cn)return cn;const r=X.get().createCanvas(1,1).getContext("webgl");return r?(cn=[...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"]:[]],cn):[]}let dn;async function Wl(){if(dn)return dn;const r=await X.get().getNavigator().gpu.requestAdapter();return dn=[...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"]:[]],dn}let Vl;async function Yl(){return Vl!==void 0||(Vl=await(async()=>{const r=await Fs(),t=Is();if(r&&t){const e=await Wl(),s=zl();return e.filter(i=>s.includes(i))}else{if(r)return await Wl();if(t)return zl()}return[]})()),Vl}const w_=["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 pn;async function zs(){if(pn!==void 0)return pn;const r=await Yl();return pn=[...w_,...r],pn}const aC='(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{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 Kr=null,E_=class{constructor(){Kr||(Kr=URL.createObjectURL(new Blob([aC],{type:"application/javascript"}))),this.worker=new Worker(Kr)}};E_.revokeObjectURL=function(){Kr&&(URL.revokeObjectURL(Kr),Kr=null)};const fn={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 lC(r){Object.assign(fn,r)}let Ws;const A_={};function uC(r){return Ws||(Ws=new E_().worker,Ws.onmessage=t=>{const{success:e,url:s,textureOptions:i}=t.data;e||console.warn("Failed to load Basis texture",s),A_[s](i)},Ws.postMessage({type:"init",jsUrl:fn.jsUrl,wasmUrl:fn.wasmUrl,supportedTextures:r})),Ws}function P_(r,t){const e=uC(t);return new Promise(s=>{A_[r]=s,e.postMessage({type:"load",url:r})})}var hC=Object.defineProperty,cC=Object.defineProperties,dC=Object.getOwnPropertyDescriptors,C_=Object.getOwnPropertySymbols,pC=Object.prototype.hasOwnProperty,fC=Object.prototype.propertyIsEnumerable,R_=(r,t,e)=>t in r?hC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mC=(r,t)=>{for(var e in t||(t={}))pC.call(t,e)&&R_(r,e,t[e]);if(C_)for(var e of C_(t))fC.call(t,e)&&R_(r,e,t[e]);return r},gC=(r,t)=>cC(r,dC(t));const _C={extension:{type:T.LoadParser,priority:ee.High,name:"loadBasis"},name:"loadBasis",id:"basis",test(r){return he(r,[".basis"])},async load(r,t,e){var s;const i=await zs(),n=await P_(r,i),o=new Hs(gC(mC({},n),{resolution:((s=t.data)==null?void 0:s.resolution)||ze(r)}));return We(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};function xC(r,t){const e=r.getNumImages(),s=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const i=[];for(let n=0;n(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))(Kl||{}),ql=(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))(ql||{});function Dt(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var Zt=(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=Dt("UYVY")]="UYVY",r[r.R8G8_B8G8=Dt("RGBG")]="R8G8_B8G8",r[r.YUY2=Dt("YUY2")]="YUY2",r[r.D3DFMT_G8R8_G8B8=Dt("GRGB")]="D3DFMT_G8R8_G8B8",r[r.DXT1=Dt("DXT1")]="DXT1",r[r.DXT2=Dt("DXT2")]="DXT2",r[r.DXT3=Dt("DXT3")]="DXT3",r[r.DXT4=Dt("DXT4")]="DXT4",r[r.DXT5=Dt("DXT5")]="DXT5",r[r.ATI1=Dt("ATI1")]="ATI1",r[r.AT1N=Dt("AT1N")]="AT1N",r[r.ATI2=Dt("ATI2")]="ATI2",r[r.AT2N=Dt("AT2N")]="AT2N",r[r.BC4U=Dt("BC4U")]="BC4U",r[r.BC4S=Dt("BC4S")]="BC4S",r[r.BC5U=Dt("BC5U")]="BC5U",r[r.BC5S=Dt("BC5S")]="BC5S",r[r.DX10=Dt("DX10")]="DX10",r))(Zt||{});const Zl={[Zt.DXT1]:"bc1-rgba-unorm",[Zt.DXT2]:"bc2-rgba-unorm",[Zt.DXT3]:"bc2-rgba-unorm",[Zt.DXT4]:"bc3-rgba-unorm",[Zt.DXT5]:"bc3-rgba-unorm",[Zt.ATI1]:"bc4-r-unorm",[Zt.BC4U]:"bc4-r-unorm",[Zt.BC4S]:"bc4-r-snorm",[Zt.ATI2]:"bc5-rg-unorm",[Zt.BC5U]:"bc5-rg-unorm",[Zt.BC5S]:"bc5-rg-snorm",36:"rgba16uint",110:"rgba16sint",111:"r16float",112:"rg16float",113:"rgba16float",114:"r32float",115:"rg32float",116:"rgba32float"},Qt={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"},Y={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:yC,HEADER_DX10_FIELDS:TC,DXGI_FORMAT:Kl,D3D10_RESOURCE_DIMENSION:ql,D3DFMT:Zt},M_={"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 O_(r,t){const{format:e,fourCC:s,width:i,height:n,dataOffset:o,mipmapCount:a}=wC(r);if(!t.includes(e))throw new Error(`Unsupported texture format: ${s} ${e}, supported: ${t}`);if(a<=1)return{format:e,width:i,height:n,resource:[new Uint8Array(r,o)],alphaMode:"no-premultiply-alpha"};const l=SC(e,i,n,o,a,r);return{format:e,width:i,height:n,resource:l,alphaMode:"no-premultiply-alpha"}}function SC(r,t,e,s,i,n){const o=[],a=M_[r];let l=t,u=e,h=s;for(let c=0;c>1,1),u=Math.max(u>>1,1)}return o}function wC(r){const t=new Uint32Array(r,0,Y.HEADER_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(t[Y.HEADER_FIELDS.MAGIC]!==Y.MAGIC_VALUE)throw new Error("Invalid magic number in DDS header");const e=t[Y.HEADER_FIELDS.HEIGHT],s=t[Y.HEADER_FIELDS.WIDTH],i=Math.max(1,t[Y.HEADER_FIELDS.MIPMAP_COUNT]),n=t[Y.HEADER_FIELDS.PF_FLAGS],o=t[Y.HEADER_FIELDS.FOURCC],a=EC(t,n,o,r),l=Y.MAGIC_SIZE+Y.HEADER_SIZE+(o===Y.D3DFMT.DX10?Y.HEADER_DX10_SIZE:0);return{format:a,fourCC:o,width:s,height:e,dataOffset:l,mipmapCount:i}}function EC(r,t,e,s){if(t&Y.PIXEL_FORMAT_FLAGS.FOURCC){if(e===Y.D3DFMT.DX10){const i=new Uint32Array(s,Y.MAGIC_SIZE+Y.HEADER_SIZE,Y.HEADER_DX10_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(i[Y.HEADER_DX10_FIELDS.MISC_FLAG]===Y.RESOURCE_MISC_TEXTURECUBE)throw new Error("DDSParser does not support cubemap textures");if(i[Y.HEADER_DX10_FIELDS.RESOURCE_DIMENSION]===Y.D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D)throw new Error("DDSParser does not supported 3D texture data");const n=i[Y.HEADER_DX10_FIELDS.DXGI_FORMAT];if(n in Qt)return Qt[n];throw new Error(`DDSParser cannot parse texture data with DXGI format ${n}`)}if(e in Zl)return Zl[e];throw new Error(`DDSParser cannot parse texture data with fourCC format ${e}`)}if(t&Y.PIXEL_FORMAT_FLAGS.RGB||t&Y.PIXEL_FORMAT_FLAGS.RGBA)return AC(r);throw t&Y.PIXEL_FORMAT_FLAGS.YUV?new Error("DDSParser does not supported YUV uncompressed texture data."):t&Y.PIXEL_FORMAT_FLAGS.LUMINANCE||t&Y.PIXEL_FORMAT_FLAGS.LUMINANCEA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):t&Y.PIXEL_FORMAT_FLAGS.ALPHA||t&Y.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 AC(r){const t=r[Y.HEADER_FIELDS.RGB_BITCOUNT],e=r[Y.HEADER_FIELDS.R_BIT_MASK],s=r[Y.HEADER_FIELDS.G_BIT_MASK],i=r[Y.HEADER_FIELDS.B_BIT_MASK],n=r[Y.HEADER_FIELDS.A_BIT_MASK];switch(t){case 32:if(e===255&&s===65280&&i===16711680&&n===4278190080)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(e===16711680&&s===65280&&i===255&&n===4278190080)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(e===1072693248&&s===1047552&&i===1023&&n===3221225472)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(e===65535&&s===4294901760&&i===0&&n===0)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(e===4294967295&&s===0&&i===0&&n===0)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(e===31744&&s===992&&i===31&&n===32768)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(e===63488&&s===2016&&i===31&&n===0)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(e===3840&&s===240&&i===15&&n===61440)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(e===255&&s===0&&i===0&&n===65280)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(e===65535&&s===0&&i===0&&n===0)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(e===255&&s===0&&i===0&&n===0)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_R8_UNORM];break}throw new Error(`DDSParser does not support uncompressed texture with configuration: bitCount = ${t}, rBitMask = ${e}, gBitMask = ${s}, aBitMask = ${n}`)}var PC=Object.defineProperty,CC=Object.defineProperties,RC=Object.getOwnPropertyDescriptors,G_=Object.getOwnPropertySymbols,MC=Object.prototype.hasOwnProperty,OC=Object.prototype.propertyIsEnumerable,I_=(r,t,e)=>t in r?PC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,GC=(r,t)=>{for(var e in t||(t={}))MC.call(t,e)&&I_(r,e,t[e]);if(G_)for(var e of G_(t))OC.call(t,e)&&I_(r,e,t[e]);return r},IC=(r,t)=>CC(r,RC(t));const FC={extension:{type:T.LoadParser,priority:ee.High,name:"loadDDS"},name:"loadDDS",id:"dds",test(r){return he(r,[".dds"])},async load(r,t,e){var s;const i=await zs(),n=await(await fetch(r)).arrayBuffer(),o=O_(n,i),a=new Hs(IC(GC({},o),{resolution:((s=t.data)==null?void 0:s.resolution)||ze(r)}));return We(a,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};var F_=(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))(F_||{}),BC=(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))(BC||{}),DC=(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))(DC||{});const $C={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"},UC=[171,75,84,88,32,49,49,187,13,10,26,10],kC={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},LC=64,NC=67305985,jC={5121:1,5123:2,5124:4,5125:4,5126:4,36193:8},XC={6408:4,6407:3,33319:2,6403:1,6409:1,6410:2,6406:1},HC={32819:2,32820:2,33635:2},zC={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},yt={FILE_HEADER_SIZE:LC,FILE_IDENTIFIER:UC,FORMATS_TO_COMPONENTS:XC,INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:zC,INTERNAL_FORMAT_TO_TEXTURE_FORMATS:$C,FIELDS:kC,TYPES_TO_BYTES_PER_COMPONENT:jC,TYPES_TO_BYTES_PER_PIXEL:HC,ENDIANNESS:NC};function B_(r,t){const e=new DataView(r);if(!KC(e))throw new Error("Invalid KTX identifier in header");const{littleEndian:s,glType:i,glFormat:n,glInternalFormat:o,pixelWidth:a,pixelHeight:l,numberOfMipmapLevels:u,offset:h}=YC(e),c=yt.INTERNAL_FORMAT_TO_TEXTURE_FORMATS[o];if(!c)throw new Error(`Unknown texture format ${o}`);if(!t.includes(c))throw new Error(`Unsupported texture format: ${c}, supportedFormats: ${t}`);const d=VC(i,n,o),p=WC(e,i,d,a,l,h,u,s);return{format:c,width:a,height:l,resource:p,alphaMode:"no-premultiply-alpha"}}function WC(r,t,e,s,i,n,o,a){const l=s+3&-4,u=i+3&-4;let h=s*i;t===0&&(h=l*u);let c=h*e,d=s,p=i,f=l,m=u,g=n;const _=new Array(o);for(let x=0;x>1||1,p=p>>1||1,f=d+4-1&-4,m=p+4-1&-4,c=f*m*e}return _}function VC(r,t,e){let s=yt.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e];if(r!==0&&(yt.TYPES_TO_BYTES_PER_COMPONENT[r]?s=yt.TYPES_TO_BYTES_PER_COMPONENT[r]*yt.FORMATS_TO_COMPONENTS[t]:s=yt.TYPES_TO_BYTES_PER_PIXEL[r]),s===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");return s}function YC(r){const t=r.getUint32(yt.FIELDS.ENDIANNESS,!0)===yt.ENDIANNESS,e=r.getUint32(yt.FIELDS.GL_TYPE,t),s=r.getUint32(yt.FIELDS.GL_FORMAT,t),i=r.getUint32(yt.FIELDS.GL_INTERNAL_FORMAT,t),n=r.getUint32(yt.FIELDS.PIXEL_WIDTH,t),o=r.getUint32(yt.FIELDS.PIXEL_HEIGHT,t)||1,a=r.getUint32(yt.FIELDS.PIXEL_DEPTH,t)||1,l=r.getUint32(yt.FIELDS.NUMBER_OF_ARRAY_ELEMENTS,t)||1,u=r.getUint32(yt.FIELDS.NUMBER_OF_FACES,t),h=r.getUint32(yt.FIELDS.NUMBER_OF_MIPMAP_LEVELS,t),c=r.getUint32(yt.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:s,glInternalFormat:i,pixelWidth:n,pixelHeight:o,numberOfMipmapLevels:h,offset:yt.FILE_HEADER_SIZE+c}}function KC(r){for(let t=0;tt in r?qC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,eR=(r,t)=>{for(var e in t||(t={}))JC.call(t,e)&&$_(r,e,t[e]);if(D_)for(var e of D_(t))tR.call(t,e)&&$_(r,e,t[e]);return r},rR=(r,t)=>ZC(r,QC(t));const sR={extension:{type:T.LoadParser,priority:ee.High,name:"loadKTX"},name:"loadKTX",id:"ktx",test(r){return he(r,".ktx")},async load(r,t,e){var s;const i=await zs(),n=await(await fetch(r)).arrayBuffer(),o=B_(n,i),a=new Hs(rR(eR({},o),{resolution:((s=t.data)==null?void 0:s.resolution)||ze(r)}));return We(a,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},iR='(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{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 qr=null;class U_{constructor(){qr||(qr=URL.createObjectURL(new Blob([iR],{type:"application/javascript"}))),this.worker=new Worker(qr)}}U_.revokeObjectURL=function(){qr&&(URL.revokeObjectURL(qr),qr=null)};const mn={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 nR(r){Object.assign(mn,r)}let Vs;const k_={},L_={};function oR(r){return Vs||(Vs=new U_().worker,Vs.onmessage=t=>{const{err:e,success:s,url:i,textureOptions:n}=t.data;if(e){L_[i](e);return}s||console.warn("Failed to load KTX texture",i),k_[i](n)},Vs.postMessage({type:"init",jsUrl:mn.jsUrl,wasmUrl:mn.wasmUrl,supportedTextures:r})),Vs}function N_(r,t){const e=oR(t);return new Promise((s,i)=>{k_[r]=s,L_[r]=i,e.postMessage({type:"load",url:r})})}var aR=Object.defineProperty,lR=Object.defineProperties,uR=Object.getOwnPropertyDescriptors,j_=Object.getOwnPropertySymbols,hR=Object.prototype.hasOwnProperty,cR=Object.prototype.propertyIsEnumerable,X_=(r,t,e)=>t in r?aR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,dR=(r,t)=>{for(var e in t||(t={}))hR.call(t,e)&&X_(r,e,t[e]);if(j_)for(var e of j_(t))cR.call(t,e)&&X_(r,e,t[e]);return r},pR=(r,t)=>lR(r,uR(t));const fR={extension:{type:T.LoadParser,priority:ee.High,name:"loadKTX2"},name:"loadKTX2",id:"ktx2",test(r){return he(r,".ktx2")},async load(r,t,e){var s;const i=await zs(),n=await N_(r,i),o=new Hs(pR(dR({},n),{resolution:((s=t.data)==null?void 0:s.resolution)||ze(r)}));return We(o,e,r)},async unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},Ql={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:H_},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:H_}};function mR(r){const t=r.format;if(Ql[t]){const e=Ql[t].convertFunction,s=r.resource;for(let i=0;ihe(r,[".ktx",".ktx2",".dds"]),parse:r=>{var t,e;let s;const i=r.split(".");if(i.length>2){const n=i[i.length-2];gn.includes(n)&&(s=n)}else s=i[i.length-1];return{resolution:parseFloat((e=(t=Ne.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:s,src:r}}};let _n;const SR={extension:{type:T.DetectionParser,priority:2},test:async()=>!!(await Fs()||Is()),add:async r=>{const t=await Yl();return _n=wR(t),[..._n,...r]},remove:async r=>_n?r.filter(t=>!(t in _n)):r};function wR(r){const t=["basis"],e={};return r.forEach(s=>{const i=s.split("-")[0];i&&!e[i]&&(e[i]=!0,t.push(i))}),t.sort((s,i)=>{const n=gn.indexOf(s),o=gn.indexOf(i);return n===-1?1:o===-1?-1:n-o}),t}const ER=new Ct,AR=new D,Ys=new it,Jl=class{cull(t,e,s=!0){this._cullRecursive(t,e,s)}_cullRecursive(t,e,s=!0){if(t.cullable&&t.measurable&&t.includeInBuild)if(t.cullArea){Ys.x=e.x,Ys.y=e.y,Ys.width=e.width,Ys.height=e.height;const i=s?t.worldTransform:t.getGlobalTransform(AR,s);t.culled=!Ys.intersects(t.cullArea,i)}else{const i=gs(t,s,ER);t.culled=i.x>=e.x+e.width||i.y>=e.y+e.height||i.x+i.width<=e.x||i.y+i.height<=e.y}else t.culled=!1;if(!(!t.cullableChildren||t.culled||!t.renderable||!t.measurable||!t.includeInBuild))for(let i=0;i{var e;const s=((e=t==null?void 0:t.culler)==null?void 0:e.updateTransform)!==!0;V_.shared.cull(this.stage,this.renderer.screen,s),this.renderer.render({container:this.stage})}}static destroy(){this.render=this._renderRef}}Y_.extension={priority:10,type:T.Application,name:"culler"};const PR={extension:{type:T.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(function(){return aE})}};var K_=` 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} } `,q_=`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(); } `,Z_=` struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct BlendUniforms { uBlend:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(0) @binding(3) var uBackTexture: texture_2d; @group(1) @binding(0) var blendUniforms : BlendUniforms; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2 }; fn filterVertexPosition(aPosition:vec2) -> vec4 { 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 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition) ); } {FUNCTIONS} @fragment fn mainFragment( @location(0) uv: vec2 ) -> @location(0) vec4 { 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(0.0,0.0,0.0,0.0); {MAIN} return out; }`,CR=Object.defineProperty,Q_=Object.getOwnPropertySymbols,RR=Object.prototype.hasOwnProperty,MR=Object.prototype.propertyIsEnumerable,J_=(r,t,e)=>t in r?CR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,tx=(r,t)=>{for(var e in t||(t={}))RR.call(t,e)&&J_(r,e,t[e]);if(Q_)for(var e of Q_(t))MR.call(t,e)&&J_(r,e,t[e]);return r};class OR extends Ae{constructor(t){const e=t.gpu,s=ex(tx({source:Z_},e)),i=zt.from({vertex:{source:s,entryPoint:"mainVertex"},fragment:{source:s,entryPoint:"mainFragment"}}),n=t.gl,o=ex(tx({source:K_},n)),a=Yt.from({vertex:q_,fragment:o}),l=new wt({uBlend:{value:1,type:"f32"}});super({gpuProgram:i,glProgram:a,blendRequired:!0,resources:{blendUniforms:l,uBackTexture:B.EMPTY}})}}function ex(r){const{source:t,functions:e,main:s}=r;return t.replace("{FUNCTIONS}",e).replace("{MAIN}",s)}const GR=` 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; } `,IR=` fn getLuminosity(c: vec3) -> f32 { return 0.3*c.r + 0.59*c.g + 0.11*c.b; } fn setLuminosity(c: vec3, lum: f32) -> vec3 { var modLum: f32 = lum - getLuminosity(c); var color: vec3 = c.rgb + modLum; // clip back into legal range modLum = getLuminosity(color); let modLumVec = vec3(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 { return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b)); } fn setSaturationMinMidMax(cSorted: vec3, s: f32) -> vec3 { 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, s: f32) -> vec3 { var color = c; if (color.r <= color.g && color.r <= color.b) { if (color.g <= color.b) { color = vec3(setSaturationMinMidMax(color.rgb, s)).rgb; } else { color = vec3(setSaturationMinMidMax(color.rbg, s)).rbg; } } else if (color.g <= color.r && color.g <= color.b) { if (color.r <= color.b) { color = vec3(setSaturationMinMidMax(color.grb, s)).grb; } else { color = vec3(setSaturationMinMidMax(color.gbr, s)).gbr; } } else { // Using bgr for both fixes part of hue if (color.r <= color.g) { color = vec3(setSaturationMinMidMax(color.brg, s)).brg; } else { color = vec3(setSaturationMinMidMax(color.bgr, s)).bgr; } } return color; } `;var rx=` in vec2 vTextureCoord; out vec4 finalColor; uniform float uAlpha; uniform sampler2D uTexture; void main() { finalColor = texture(uTexture, vTextureCoord) * uAlpha; } `,tu=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct AlphaUniforms { uAlpha:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var alphaUniforms : AlphaUniforms; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2 }; fn filterVertexPosition(aPosition:vec2) -> vec4 { 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 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition) ); } @fragment fn mainFragment( @location(0) uv: vec2, @builtin(position) position: vec4 ) -> @location(0) vec4 { var sample = textureSample(uTexture, uSampler, uv); return sample * alphaUniforms.uAlpha; }`,FR=Object.defineProperty,BR=Object.defineProperties,DR=Object.getOwnPropertyDescriptors,xn=Object.getOwnPropertySymbols,sx=Object.prototype.hasOwnProperty,ix=Object.prototype.propertyIsEnumerable,nx=(r,t,e)=>t in r?FR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,eu=(r,t)=>{for(var e in t||(t={}))sx.call(t,e)&&nx(r,e,t[e]);if(xn)for(var e of xn(t))ix.call(t,e)&&nx(r,e,t[e]);return r},$R=(r,t)=>BR(r,DR(t)),UR=(r,t)=>{var e={};for(var s in r)sx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&xn)for(var s of xn(r))t.indexOf(s)<0&&ix.call(r,s)&&(e[s]=r[s]);return e};const ox=class lS extends Ae{constructor(t){t=eu(eu({},lS.defaultOptions),t);const e=zt.from({vertex:{source:tu,entryPoint:"mainVertex"},fragment:{source:tu,entryPoint:"mainFragment"}}),s=Yt.from({vertex:Ps,fragment:rx,name:"alpha-filter"}),i=t,{alpha:n}=i,o=UR(i,["alpha"]),a=new wt({uAlpha:{value:n,type:"f32"}});super($R(eu({},o),{gpuProgram:e,glProgram:s,resources:{alphaUniforms:a}}))}get alpha(){return this.resources.alphaUniforms.uniforms.uAlpha}set alpha(t){this.resources.alphaUniforms.uniforms.uAlpha=t}};ox.defaultOptions={alpha:1};let kR=ox;const ru={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]},LR=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","uniform vec4 uInputClamp;","out vec4 finalColor;","void main(void)","{"," %blur%","}"].join(` `);function ax(r){const t=ru[r],e=t.length;let s="";const i="finalColor = ",n=" + ",o="texture(uTexture, clamp(vBlurTexCoords[%index%], uInputClamp.xy, uInputClamp.zw)) * %value%";for(let a=0;a, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct BlurUniforms { uStrength:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var blurUniforms : BlurUniforms; struct VSOutput { @builtin(position) position: vec4, %blur-struct% }; fn filterVertexPosition(aPosition:vec2) -> vec4 { 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 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> 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, %blur-fragment-in% ) -> @location(0) vec4 { var finalColor = vec4(0.0); %blur-sampling% return finalColor; } `;function cx(r,t){const e=ru[t],s=e.length,i=[],n=[],o=[];for(let c=0;c,`,r?n[c]=`filteredCord + vec2(${c-s+1} * pixelStrength, 0.0),`:n[c]=`filteredCord + vec2(0.0, ${c-s+1} * pixelStrength),`;const d=ct in r?jR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,su=(r,t)=>{for(var e in t||(t={}))XR.call(t,e)&&px(r,e,t[e]);if(dx)for(var e of dx(t))HR.call(t,e)&&px(r,e,t[e]);return r};const fx=class uS extends Ae{constructor(t){var e;t=su(su({},uS.defaultOptions),t);const s=ux(t.horizontal,t.kernelSize),i=cx(t.horizontal,t.kernelSize);super(su({glProgram:s,gpuProgram:i,resources:{blurUniforms:{uStrength:{value:0,type:"f32"}}}},t)),this.horizontal=t.horizontal,this.legacy=(e=t.legacy)!=null?e:!1,this._quality=0,this.quality=t.quality,this.blur=t.strength,this._blurUniforms=this.resources.blurUniforms,this._uniforms=this._blurUniforms.uniforms}apply(t,e,s,i){this.legacy?this._applyLegacy(t,e,s,i):this._applyOptimized(t,e,s,i)}_applyLegacy(t,e,s,i){if(this._uniforms.uStrength=this.strength/this.passes,this.passes===1)t.applyFilter(this,e,s,i);else{const n=ft.getSameSizeTexture(e);let o=e,a=n;this._state.blend=!1;const l=t.renderer.type===Mt.WEBGPU;for(let u=0;ut in r?zR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ks=(r,t)=>{for(var e in t||(t={}))mx.call(t,e)&&_x(r,e,t[e]);if(bn)for(var e of bn(t))gx.call(t,e)&&_x(r,e,t[e]);return r},YR=(r,t)=>WR(r,VR(t)),KR=(r,t)=>{var e={};for(var s in r)mx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&bn)for(var s of bn(r))t.indexOf(s)<0&&gx.call(r,s)&&(e[s]=r[s]);return e};class xx extends Ae{constructor(...t){var e;let s=(e=t[0])!=null?e:{};typeof s=="number"&&(s={strength:s},t[1]!==void 0&&(s.quality=t[1]),t[2]!==void 0&&(s.resolution=t[2]||"inherit"),t[3]!==void 0&&(s.kernelSize=t[3])),s=Ks(Ks({},vn.defaultOptions),s);const i=s,{strength:n,strengthX:o,strengthY:a,quality:l}=i,u=KR(i,["strength","strengthX","strengthY","quality"]);super(YR(Ks({},u),{compatibleRenderers:Mt.BOTH,resources:{}})),this._repeatEdgePixels=!1,this.blurXFilter=new vn(Ks({horizontal:!0},s)),this.blurYFilter=new vn(Ks({horizontal:!1},s)),this.quality=l,this.strengthX=o!=null?o:n,this.strengthY=a!=null?a:n,this.repeatEdgePixels=!1}apply(t,e,s,i){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=ft.getSameSizeTexture(e);this.blurXFilter.blendMode="normal",this.blurXFilter.apply(t,e,a,!0),this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,a,s,i),ft.returnTexture(a)}else o?(this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,e,s,i)):(this.blurXFilter.blendMode=this.blendMode,this.blurXFilter.apply(t,e,s,i))}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()}}xx.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};var vx=` 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); } `,iu=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct ColorMatrixUniforms { uColorMatrix:array, 5>, uAlpha:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var colorMatrixUniforms : ColorMatrixUniforms; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2, }; fn filterVertexPosition(aPosition:vec2) -> vec4 { 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 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition), ); } @fragment fn mainFragment( @location(0) uv: vec2, ) -> @location(0) vec4 { 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(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); }`,qR=Object.defineProperty,ZR=Object.defineProperties,QR=Object.getOwnPropertyDescriptors,bx=Object.getOwnPropertySymbols,JR=Object.prototype.hasOwnProperty,tM=Object.prototype.propertyIsEnumerable,yx=(r,t,e)=>t in r?qR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,eM=(r,t)=>{for(var e in t||(t={}))JR.call(t,e)&&yx(r,e,t[e]);if(bx)for(var e of bx(t))tM.call(t,e)&&yx(r,e,t[e]);return r},rM=(r,t)=>ZR(r,QR(t));class sM extends Ae{constructor(t={}){const e=new wt({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"}}),s=zt.from({vertex:{source:iu,entryPoint:"mainVertex"},fragment:{source:iu,entryPoint:"mainFragment"}}),i=Yt.from({vertex:Ps,fragment:vx,name:"color-matrix-filter"});super(rM(eM({},t),{gpuProgram:s,glProgram:i,resources:{colorMatrixUniforms:e}})),this.alpha=1}_loadMatrix(t,e=!1){if(e){const s=[...t];this._multiply(s,this.matrix,t),this.resources.colorMatrixUniforms.uniforms.uColorMatrix=s}else this.resources.colorMatrixUniforms.uniforms.uColorMatrix=t;this.resources.colorMatrixUniforms.update()}_multiply(t,e,s){return t[0]=e[0]*s[0]+e[1]*s[5]+e[2]*s[10]+e[3]*s[15],t[1]=e[0]*s[1]+e[1]*s[6]+e[2]*s[11]+e[3]*s[16],t[2]=e[0]*s[2]+e[1]*s[7]+e[2]*s[12]+e[3]*s[17],t[3]=e[0]*s[3]+e[1]*s[8]+e[2]*s[13]+e[3]*s[18],t[4]=e[0]*s[4]+e[1]*s[9]+e[2]*s[14]+e[3]*s[19]+e[4],t[5]=e[5]*s[0]+e[6]*s[5]+e[7]*s[10]+e[8]*s[15],t[6]=e[5]*s[1]+e[6]*s[6]+e[7]*s[11]+e[8]*s[16],t[7]=e[5]*s[2]+e[6]*s[7]+e[7]*s[12]+e[8]*s[17],t[8]=e[5]*s[3]+e[6]*s[8]+e[7]*s[13]+e[8]*s[18],t[9]=e[5]*s[4]+e[6]*s[9]+e[7]*s[14]+e[8]*s[19]+e[9],t[10]=e[10]*s[0]+e[11]*s[5]+e[12]*s[10]+e[13]*s[15],t[11]=e[10]*s[1]+e[11]*s[6]+e[12]*s[11]+e[13]*s[16],t[12]=e[10]*s[2]+e[11]*s[7]+e[12]*s[12]+e[13]*s[17],t[13]=e[10]*s[3]+e[11]*s[8]+e[12]*s[13]+e[13]*s[18],t[14]=e[10]*s[4]+e[11]*s[9]+e[12]*s[14]+e[13]*s[19]+e[14],t[15]=e[15]*s[0]+e[16]*s[5]+e[17]*s[10]+e[18]*s[15],t[16]=e[15]*s[1]+e[16]*s[6]+e[17]*s[11]+e[18]*s[16],t[17]=e[15]*s[2]+e[16]*s[7]+e[17]*s[12]+e[18]*s[17],t[18]=e[15]*s[3]+e[16]*s[8]+e[17]*s[13]+e[18]*s[18],t[19]=e[15]*s[4]+e[16]*s[9]+e[17]*s[14]+e[18]*s[19]+e[19],t}brightness(t,e){const s=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}tint(t,e){const[s,i,n]=tt.shared.setValue(t).toArray(),o=[s,0,0,0,0,0,i,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const s=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(s,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 s=Math.cos(t),i=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),l=s+(1-s)*o,u=o*(1-s)-a*i,h=o*(1-s)+a*i,c=o*(1-s)+a*i,d=s+o*(1-s),p=o*(1-s)-a*i,f=o*(1-s)-a*i,m=o*(1-s)+a*i,g=s+o*(1-s),_=[l,u,h,0,0,c,d,p,0,0,f,m,g,0,0,0,0,0,1,0];this._loadMatrix(_,e)}contrast(t,e){const s=(t||0)+1,i=-.5*(s-1),n=[s,0,0,0,i,0,s,0,0,i,0,0,s,0,i,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const s=t*2/3+1,i=(s-1)*-.5,n=[s,i,i,0,0,i,s,i,0,0,i,i,s,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,.046249425232852304,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-.2758903984886823,-.231103377548616,-.7501899197440212,1.847597816108189,0,.12137623870388682,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,.24991995145868634,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,.09698983488904393,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,.13972481597886063,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,.1860075629647401,-.037703249837783157,.8609577587992641,.15059552388459913,0,-.14497417640467167,.24113635128153335,-.07441037908422492,.44972182064877153,0,-.029655197167024642,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,.037848179746251466,.02578397704808868,.6441188644374771,.03259127616149294,0,.029265996770472907,.0466055556782719,-.0851232987247891,.5241648018700465,0,.020232119953863904,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,s,i,n){t||(t=.2),e||(e=.15),s||(s=16770432),i||(i=3375104);const o=tt.shared,[a,l,u]=o.setValue(s).toArray(),[h,c,d]=o.setValue(i).toArray(),p=[.3,.59,.11,0,0,a,l,u,t,0,h,c,d,e,0,a-h,l-c,u-d,0,0];this._loadMatrix(p,n)}night(t,e){t||(t=.1);const s=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(s,e)}predator(t,e){const s=[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(s,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 Tx=` 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)); } `,Sx=`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(); } `,nu=` struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct DisplacementUniforms { uFilterMatrix:mat3x3, uScale:vec2, uRotation:mat2x2 }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var filterUniforms : DisplacementUniforms; @group(1) @binding(1) var uMapTexture: texture_2d; @group(1) @binding(2) var uMapSampler : sampler; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2, @location(1) filterUv : vec2, }; fn filterVertexPosition(aPosition:vec2) -> vec4 { 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 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getFilterCoord(aPosition:vec2 ) -> vec2 { return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy; } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition), getFilterCoord(aPosition) ); } @fragment fn mainFragment( @location(0) uv: vec2, @location(1) filterUv: vec2, @builtin(position) position: vec4 ) -> @location(0) vec4 { 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)); }`,iM=Object.defineProperty,nM=Object.defineProperties,oM=Object.getOwnPropertyDescriptors,yn=Object.getOwnPropertySymbols,wx=Object.prototype.hasOwnProperty,Ex=Object.prototype.propertyIsEnumerable,Ax=(r,t,e)=>t in r?iM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,aM=(r,t)=>{for(var e in t||(t={}))wx.call(t,e)&&Ax(r,e,t[e]);if(yn)for(var e of yn(t))Ex.call(t,e)&&Ax(r,e,t[e]);return r},lM=(r,t)=>nM(r,oM(t)),uM=(r,t)=>{var e={};for(var s in r)wx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&yn)for(var s of yn(r))t.indexOf(s)<0&&Ex.call(r,s)&&(e[s]=r[s]);return e};class hM extends Ae{constructor(...t){let e=t[0];e instanceof _e&&(e={sprite:e,scale:t[1]});const s=e,{sprite:i,scale:n}=s,o=uM(s,["sprite","scale"]);let a=n!=null?n:20;typeof a=="number"&&(a=new lt(a,a));const l=new wt({uFilterMatrix:{value:new D,type:"mat3x3"},uScale:{value:a,type:"vec2"},uRotation:{value:new Float32Array([0,0,0,0]),type:"mat2x2"}}),u=Yt.from({vertex:Sx,fragment:Tx,name:"displacement-filter"}),h=zt.from({vertex:{source:nu,entryPoint:"mainVertex"},fragment:{source:nu,entryPoint:"mainFragment"}}),c=i.texture.source;super(lM(aM({},o),{gpuProgram:h,glProgram:u,resources:{filterUniforms:l,uMapTexture:c,uMapSampler:c.style}})),this._sprite=e.sprite,this._sprite.renderable=!1}apply(t,e,s,i){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,s,i)}get scale(){return this.resources.filterUniforms.uniforms.uScale}}var Px=` 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; } `,ou=` struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct NoiseUniforms { uNoise:f32, uSeed:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var noiseUniforms : NoiseUniforms; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2 }; fn filterVertexPosition(aPosition:vec2) -> vec4 { 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 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition) ); } fn rand(co:vec2) -> f32 { return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); } @fragment fn mainFragment( @location(0) uv: vec2, @builtin(position) position: vec4 ) -> @location(0) vec4 { 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; }`,cM=Object.defineProperty,dM=Object.defineProperties,pM=Object.getOwnPropertyDescriptors,Tn=Object.getOwnPropertySymbols,Cx=Object.prototype.hasOwnProperty,Rx=Object.prototype.propertyIsEnumerable,Mx=(r,t,e)=>t in r?cM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,au=(r,t)=>{for(var e in t||(t={}))Cx.call(t,e)&&Mx(r,e,t[e]);if(Tn)for(var e of Tn(t))Rx.call(t,e)&&Mx(r,e,t[e]);return r},fM=(r,t)=>dM(r,pM(t)),mM=(r,t)=>{var e={};for(var s in r)Cx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Tn)for(var s of Tn(r))t.indexOf(s)<0&&Rx.call(r,s)&&(e[s]=r[s]);return e};const Ox=class hS extends Ae{constructor(t={}){t=au(au({},hS.defaultOptions),t);const e=zt.from({vertex:{source:ou,entryPoint:"mainVertex"},fragment:{source:ou,entryPoint:"mainFragment"}}),s=Yt.from({vertex:Ps,fragment:Px,name:"noise-filter"}),i=t,{noise:n,seed:o}=i,a=mM(i,["noise","seed"]);super(fM(au({},a),{gpuProgram:e,glProgram:s,resources:{noiseUniforms:new wt({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}};Ox.defaultOptions={noise:.5};let gM=Ox;var Gx=`in vec2 vMaskCoord; in vec2 vTextureCoord; uniform sampler2D uTexture; uniform sampler2D uMaskTexture; uniform float uAlpha; uniform vec4 uMaskClamp; uniform float uInverse; uniform float uChannel; 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 a; if (uChannel == 1.0) { a = masky.a * npmAlpha * clip; } else { float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a); a = alphaMul * masky.r * npmAlpha * clip; } if (uInverse == 1.0) { a = 1.0 - a; } finalColor = original * a; } `,Ix=`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); } `,lu=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct MaskUniforms { uFilterMatrix:mat3x3, uMaskClamp:vec4, uAlpha:f32, uInverse:f32, uChannel:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var filterUniforms : MaskUniforms; @group(1) @binding(1) var uMaskTexture: texture_2d; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2, @location(1) filterUv : vec2, }; fn filterVertexPosition(aPosition:vec2) -> vec4 { 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 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getFilterCoord(aPosition:vec2 ) -> vec2 { return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy; } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition), getFilterCoord(aPosition) ); } @fragment fn mainFragment( @location(0) uv: vec2, @location(1) filterUv: vec2, @builtin(position) position: vec4 ) -> @location(0) vec4 { 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 a: f32; if (filterUniforms.uChannel == 1.0) { a = mask.a * uAlpha * clip; } else { var alphaMul = 1.0 - uAlpha * (1.0 - mask.a); a = alphaMul * mask.r * uAlpha * clip; } if (filterUniforms.uInverse == 1.0) { a = 1.0 - a; } return source * a; } `,_M=Object.defineProperty,xM=Object.defineProperties,vM=Object.getOwnPropertyDescriptors,Sn=Object.getOwnPropertySymbols,Fx=Object.prototype.hasOwnProperty,Bx=Object.prototype.propertyIsEnumerable,Dx=(r,t,e)=>t in r?_M(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,bM=(r,t)=>{for(var e in t||(t={}))Fx.call(t,e)&&Dx(r,e,t[e]);if(Sn)for(var e of Sn(t))Bx.call(t,e)&&Dx(r,e,t[e]);return r},yM=(r,t)=>xM(r,vM(t)),TM=(r,t)=>{var e={};for(var s in r)Fx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Sn)for(var s of Sn(r))t.indexOf(s)<0&&Bx.call(r,s)&&(e[s]=r[s]);return e};class $x extends Ae{constructor(t){const e=t,{sprite:s}=e,i=TM(e,["sprite"]),n=new Zo(s.texture),o=new wt({uFilterMatrix:{value:new D,type:"mat3x3"},uMaskClamp:{value:n.uClampFrame,type:"vec4"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"},uChannel:{value:t.channel==="alpha"?1:0,type:"f32"}}),a=zt.from({vertex:{source:lu,entryPoint:"mainVertex"},fragment:{source:lu,entryPoint:"mainFragment"}}),l=Yt.from({vertex:Ix,fragment:Gx,name:"mask-filter"});super(yM(bM({},i),{gpuProgram:a,glProgram:l,clipToViewport:!1,resources:{filterUniforms:o,uMaskTexture:s.texture.source}})),this.sprite=s,this._textureMatrix=n}setSprite(t){this.sprite=t;const e=this._getSafeTexture();this._textureMatrix.texture=e,this.resources.uMaskTexture=e.source}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}set channel(t){this.resources.filterUniforms.uniforms.uChannel=t==="alpha"?1:0}get channel(){return this.resources.filterUniforms.uniforms.uChannel===1?"alpha":"red"}apply(t,e,s,i){const n=this._getSafeTexture();this._textureMatrix.texture=n,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=n.source,t.applyFilter(this,e,s,i)}_getSafeTexture(){const t=this.sprite.texture;return t.destroyed||!t.source||t.source.destroyed?B.EMPTY:t}destroy(t=!1){this._textureMatrix.destroy(),super.destroy(t)}}var SM=`fn getLuminosity(c: vec3) -> f32 { return 0.3 * c.r + 0.59 * c.g + 0.11 * c.b; } fn setLuminosity(c: vec3, lum: f32) -> vec3 { let d: f32 = lum - getLuminosity(c); let newColor: vec3 = c.rgb + vec3(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(newLum, newLum, newLum), newColor, select(select(1.0, t2, cMax > 1.0), t1, cMin < 0.0)); return finalColor; } fn getSaturation(c: vec3) -> 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, s: f32) -> vec3 { var result: vec3; if (cSorted.z > cSorted.x) { let newY = (((cSorted.y - cSorted.x) * s) / (cSorted.z - cSorted.x)); result = vec3(0.0, newY, s); } else { result = vec3(0.0, 0.0, 0.0); } return vec3(result.x, result.y, result.z); } fn setSaturation(c: vec3, s: f32) -> vec3 { var result: vec3 = c; if (c.r <= c.g && c.r <= c.b) { if (c.g <= c.b) { result = setSaturationMinMidMax(result, s); } else { var temp: vec3 = vec3(result.r, result.b, result.g); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.r, temp.b, temp.g); } } else if (c.g <= c.r && c.g <= c.b) { if (c.r <= c.b) { var temp: vec3 = vec3(result.g, result.r, result.b); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.g, temp.r, temp.b); } else { var temp: vec3 = vec3(result.g, result.b, result.r); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.g, temp.b, temp.r); } } else { if (c.r <= c.g) { var temp: vec3 = vec3(result.b, result.r, result.g); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.b, temp.r, temp.g); } else { var temp: vec3 = vec3(result.b, result.g, result.r); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.b, temp.g, temp.r); } } return result; }`;const Ux=class cS{constructor(t){this._tick=()=>{this._destroyed||(this.timeout=setTimeout(this._processQueue,0))},this._processQueue=()=>{if(this._destroyed)return;const{queue:e}=this;let s=0;for(;e.length&&s{this.queue.length?(this.resolves.push(e),this.dedupeQueue(),Rt.system.addOnce(this._tick,this,Te.UTILITY)):e()})}dedupeQueue(){const t=Object.create(null);let e=0;for(let s=0;s>16&255)/255,e[s++]=(r>>8&255)/255,e[s++]=(r&255)/255,e[s++]=t}function Zr(r,t,e){const s=(r>>24&255)/255;t[e++]=(r&255)/255*s,t[e++]=(r>>8&255)/255*s,t[e++]=(r>>16&255)/255*s,t[e++]=s}class Nx{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{St.return(t)}),this.batches.length=0}}class cu{constructor(t,e){this.state=Kt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new kt({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,s=!!t._gpuData,i=this.renderer.graphicsContext.updateGpuContext(e);return!!(i.isBatchable||s!==i.isBatchable)}addRenderable(t,e){const s=this.renderer.graphicsContext.updateGpuContext(t.context);(t.didViewUpdate||!t._gpuData[this.renderer.uid])&&this._rebuild(t),s.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._getGpuDataForRenderable(t).batches;for(let s=0;s{const a=St.get(en);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}}cu.extension={type:[T.WebGLPipes,T.WebGPUPipes],name:"graphics"},L.add(hu),L.add(cu),L.add(Lx),L.add(on);var PM=Object.defineProperty,wn=Object.getOwnPropertySymbols,jx=Object.prototype.hasOwnProperty,Xx=Object.prototype.propertyIsEnumerable,Hx=(r,t,e)=>t in r?PM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,CM=(r,t)=>{for(var e in t||(t={}))jx.call(t,e)&&Hx(r,e,t[e]);if(wn)for(var e of wn(t))Xx.call(t,e)&&Hx(r,e,t[e]);return r},RM=(r,t)=>{var e={};for(var s in r)jx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&wn)for(var s of wn(r))t.indexOf(s)<0&&Xx.call(r,s)&&(e[s]=r[s]);return e};class Er extends Se{constructor(t){t instanceof Nt&&(t={context:t});const e=t||{},{context:s,roundPixels:i}=e,n=RM(e,["context","roundPixels"]);super(CM({label:"Graphics"},n)),this.renderPipeId="graphics",s?this.context=s:(this.context=this._ownedContext=new Nt,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=i!=null?i:!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){var e,s;this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),(e=this._context)==null||e.off("update",this.onViewUpdate,this),(s=this._context)==null||s.off("unload",this.unload,this),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 Er(this._context.clone()):(this._ownedContext=null,new Er(this._context))}lineStyle(t,e,s){const i={};return t&&(i.width=t),e&&(i.color=e),s&&(i.alpha=s),this.context.strokeStyle=i,this}beginFill(t,e){const s={};return t!==void 0&&(s.color=t),e!==void 0&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){this.context.fill();const t=this.context.strokeStyle;return(t.width!==Nt.defaultStrokeStyle.width||t.color!==Nt.defaultStrokeStyle.color||t.alpha!==Nt.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)}}var MM=Object.defineProperty,zx=Object.getOwnPropertySymbols,OM=Object.prototype.hasOwnProperty,GM=Object.prototype.propertyIsEnumerable,Wx=(r,t,e)=>t in r?MM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vx=(r,t)=>{for(var e in t||(t={}))OM.call(t,e)&&Wx(r,e,t[e]);if(zx)for(var e of zx(t))GM.call(t,e)&&Wx(r,e,t[e]);return r};const Yx=class dS extends hr{constructor(...t){var e;let s=(e=t[0])!=null?e:{};s instanceof Float32Array&&(s={positions:s,uvs:t[1],indices:t[2]}),s=Vx(Vx({},dS.defaultOptions),s);const i=s.positions||new Float32Array([0,0,1,0,1,1,0,1]);let n=s.uvs;n||(s.positions?n=new Float32Array(i.length):n=new Float32Array([0,0,1,0,1,1,0,1]));const o=s.indices||new Uint32Array([0,1,2,0,2,3]),a=s.shrinkBuffersToFit,l=new qt({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:st.VERTEX|st.COPY_DST}),u=new qt({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:st.VERTEX|st.COPY_DST}),h=new qt({data:o,label:"index-mesh-buffer",shrinkToFit:a,usage:st.INDEX|st.COPY_DST});super({attributes:{aPosition:{buffer:l,format:"float32x2",stride:8,offset:0},aUV:{buffer:u,format:"float32x2",stride:8,offset:0}},indexBuffer:h,topology:s.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};Yx.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Ve=Yx;class En{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(t){this._topology=t}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(t){this.texture!==t&&(this.texture=t,this._textureMatrixUpdateId=-1)}get uvs(){const t=this.geometry.getBuffer("aUV"),e=t.data;let s=e;const i=this.texture.textureMatrix;return i.isSimple||(s=this._transformedUvs,(this._textureMatrixUpdateId!==i._updateID||this._uvUpdateId!==t._updateID)&&((!s||s.length"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Ee({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),s=e.batched,i=t.batched;if(e.batched=i,s!==i)return!0;if(i){const n=t._geometry;if(n.indices.length!==e.indexSize||n.positions.length!==e.vertexSize)return e.indexSize=n.indices.length,e.vertexSize=n.positions.length,!0;const o=this._getBatchableMesh(t);return o.texture.uid!==t._texture.uid&&(o._textureMatrixUpdateId=-1),!o._batcher.checkAndUpdateTexture(o,t._texture)}return!1}addRenderable(t,e){var s,i;const n=this.renderer.renderPipes.batch,o=this._getMeshData(t);if(t.didViewUpdate&&(o.indexSize=(s=t._geometry.indices)==null?void 0:s.length,o.vertexSize=(i=t._geometry.positions)==null?void 0:i.length),o.batched){const a=this._getBatchableMesh(t);a.setTexture(t._texture),a.geometry=t._geometry,n.addToBatch(a,e)}else n.break(e),e.add(t)}updateRenderable(t){if(t.batched){const e=this._getBatchableMesh(t);e.setTexture(t._texture),e.geometry=t._geometry,e._batcher.updateElement(e)}}execute(t){if(!t.isRenderable)return;t.state.blend&&(t.state.blendMode=Dr(t.groupBlendMode,t.texture._source));const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),Zr(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){var e,s;return(e=t._gpuData)[s=this.renderer.uid]||(e[s]=new du),t._gpuData[this.renderer.uid].meshData||this._initMeshData(t)}_initMeshData(t){return t._gpuData[this.renderer.uid].meshData={batched:t.batched,indexSize:0,vertexSize:0},t._gpuData[this.renderer.uid].meshData}_getBatchableMesh(t){var e,s;return(e=t._gpuData)[s=this.renderer.uid]||(e[s]=new du),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new En;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}}pu.extension={type:[T.WebGLPipes,T.WebGPUPipes],name:"mesh"},L.add(pu);var IM=Object.defineProperty,An=Object.getOwnPropertySymbols,Kx=Object.prototype.hasOwnProperty,qx=Object.prototype.propertyIsEnumerable,Zx=(r,t,e)=>t in r?IM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,FM=(r,t)=>{for(var e in t||(t={}))Kx.call(t,e)&&Zx(r,e,t[e]);if(An)for(var e of An(t))qx.call(t,e)&&Zx(r,e,t[e]);return r},BM=(r,t)=>{var e={};for(var s in r)Kx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&An)for(var s of An(r))t.indexOf(s)<0&&qx.call(r,s)&&(e[s]=r[s]);return e};class Qr extends Se{constructor(...t){var e;let s=t[0];s instanceof hr&&(s={geometry:s,shader:t[1]},t[3]&&(s.geometry.topology=t[3]));const i=s,{geometry:n,shader:o,texture:a,roundPixels:l,state:u}=i,h=BM(i,["geometry","shader","texture","roundPixels","state"]);super(FM({label:"Mesh"},h)),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:B.WHITE,this.state=u!=null?u:Kt.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=B.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)!==0?!1:this._geometry instanceof Ve?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:s}=t;if(!this.bounds.containsPoint(e,s))return!1;const i=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+2t in r?DM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,kM=(r,t)=>{for(var e in t||(t={}))Qx.call(t,e)&&tv(r,e,t[e]);if(Pn)for(var e of Pn(t))Jx.call(t,e)&&tv(r,e,t[e]);return r},LM=(r,t)=>$M(r,UM(t)),NM=(r,t)=>{var e={};for(var s in r)Qx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Pn)for(var s of Pn(r))t.indexOf(s)<0&&Jx.call(r,s)&&(e[s]=r[s]);return e};class hi extends _e{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const s=e,{animationSpeed:i=1,autoPlay:n=!1,autoUpdate:o=!0,loop:a=!0,onComplete:l=null,onFrameChange:u=null,onLoop:h=null,textures:c,updateAnchor:d=!1}=s,p=NM(s,["animationSpeed","autoPlay","autoUpdate","loop","onComplete","onFrameChange","onLoop","textures","updateAnchor"]),[f]=c;super(LM(kM({},p),{texture:f instanceof B?f:f.texture})),this._textures=null,this._durations=null,this._autoUpdate=o,this._isConnectedToTicker=!1,this.animationSpeed=i,this.loop=a,this.updateAnchor=d,this.onComplete=l,this.onFrameChange=u,this.onLoop=h,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=c,n&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(Rt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Rt.shared.add(this.update,this,Te.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,s=this.animationSpeed*e,i=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=s/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+=s;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()):i!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFramei)&&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(s=>{this.texture!==s&&s.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 s=0;sthis.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?(Rt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Rt.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class ev{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t!=null?t:new D,this.observer=e,this.position=new gt(this,0,0),this.scale=new gt(this,1,1),this.pivot=new gt(this,0,0),this.skew=new gt(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))}}const Cn=new D,De=new D,Pe=[new lt,new lt,new lt,new lt];class fu{constructor(t){this._renderer=t}validateRenderable(t){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){var e,s,i,n,o,a;const l=this._renderer,u=l.canvasContext,h=u.activeContext;h.save(),u.setBlendMode(t.groupBlendMode);const c=(s=(e=l.globalUniforms.globalUniformData)==null?void 0:e.worldColor)!=null?s:4294967295,d=t.groupColorAlpha,p=(c>>>24&255)/255,f=(d>>>24&255)/255,m=(n=(i=l.filter)==null?void 0:i.alphaMultiplier)!=null?n:1,g=p*f*m;if(g<=0){h.restore();return}h.globalAlpha=g;const _=c&16777215,x=d&16777215,v=ye(be(x,_)),b=t.texture,S=Z.getTintedPattern(b,v),y=t.width,w=t.height,E=t.groupTransform,A=(a=(o=b.source._resolution)!=null?o:b.source.resolution)!=null?a:1;De.copyFrom(t._tileTransform.matrix),t.applyAnchorToTexture||De.translate(-t.anchor.x*y,-t.anchor.y*w);const P=De.tx,C=De.ty;De.scale(1/A,1/A),De.tx=P,De.ty=C,Cn.identity(),Cn.prepend(De),Cn.prepend(E);const O=l._roundPixels|t._roundPixels;u.setContextTransform(Cn,O===1),h.fillStyle=S;const F=t.anchor.x*-y,R=t.anchor.y*-w;Pe[0].set(F,R),Pe[1].set(F+y,R),Pe[2].set(F+y,R+w),Pe[3].set(F,R+w);for(let G=0;G<4;G++)De.applyInverse(Pe[G],Pe[G]);h.beginPath(),h.moveTo(Pe[0].x,Pe[0].y);for(let G=1;G<4;G++)h.lineTo(Pe[G].x,Pe[G].y);h.closePath(),h.fill(),h.restore()}destroy(){this._renderer=null}}fu.extension={type:[T.CanvasPipes],name:"tilingSprite"};var jM=Object.defineProperty,XM=Object.defineProperties,HM=Object.getOwnPropertyDescriptors,rv=Object.getOwnPropertySymbols,zM=Object.prototype.hasOwnProperty,WM=Object.prototype.propertyIsEnumerable,sv=(r,t,e)=>t in r?jM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,iv=(r,t)=>{for(var e in t||(t={}))zM.call(t,e)&&sv(r,e,t[e]);if(rv)for(var e of rv(t))WM.call(t,e)&&sv(r,e,t[e]);return r},nv=(r,t)=>XM(r,HM(t));const Jr={name:"local-uniform-bit",vertex:{header:` struct LocalUniforms { uTransformMatrix:mat3x3, uColor:vec4, uRound:f32, } @group(1) @binding(0) var localUniforms : LocalUniforms; `,main:` vColor *= localUniforms.uColor; modelMatrix *= localUniforms.uTransformMatrix; `,end:` if(localUniforms.uRound == 1) { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } `}},ov=nv(iv({},Jr),{vertex:nv(iv({},Jr.vertex),{header:Jr.vertex.header.replace("group(1)","group(2)")})}),Rn={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); } `}},av={name:"tiling-bit",vertex:{header:` struct TilingUniforms { uMapCoord:mat3x3, uClampFrame:vec4, uClampOffset:vec2, uTextureTransform:mat3x3, uSizeAnchor:vec4 }; @group(2) @binding(0) var tilingUniforms: TilingUniforms; @group(2) @binding(1) var uTexture: texture_2d; @group(2) @binding(2) var uSampler: sampler; `,main:` uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy; position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy; `},fragment:{header:` struct TilingUniforms { uMapCoord:mat3x3, uClampFrame:vec4, uClampOffset:vec2, uTextureTransform:mat3x3, uSizeAnchor:vec4 }; @group(2) @binding(0) var tilingUniforms: TilingUniforms; @group(2) @binding(1) var uTexture: texture_2d; @group(2) @binding(2) var uSampler: sampler; `,main:` var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV); coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy; var unclamped = coord; coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw); var bias = 0.; if(unclamped.x == coord.x && unclamped.y == coord.y) { bias = -32.; } outColor = textureSampleBias(uTexture, uSampler, coord, bias); `}},lv={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 mu,gu;class uv extends ne{constructor(){mu!=null||(mu=Ur({name:"tiling-sprite-shader",bits:[Jr,av,Lr]})),gu!=null||(gu=kr({name:"tiling-sprite-shader",bits:[Rn,lv,Nr]}));const t=new wt({uMapCoord:{value:new D,type:"mat3x3"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2"},uTextureTransform:{value:new D,type:"mat3x3"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4"}});super({glProgram:gu,gpuProgram:mu,resources:{localUniforms:new wt({uTransformMatrix:{value:new D,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:B.EMPTY.source,uSampler:B.EMPTY.source.style}})}updateUniforms(t,e,s,i,n,o){const a=this.resources.tilingUniforms,l=o.width,u=o.height,h=o.textureMatrix,c=a.uniforms.uTextureTransform;c.set(s.a*l/t,s.b*l/e,s.c*u/t,s.d*u/e,s.tx/t,s.ty/e),c.invert(),a.uniforms.uMapCoord=h.mapCoord,a.uniforms.uClampFrame=h.uClampFrame,a.uniforms.uClampOffset=h.uClampOffset,a.uniforms.uTextureTransform=c,a.uniforms.uSizeAnchor[0]=t,a.uniforms.uSizeAnchor[1]=e,a.uniforms.uSizeAnchor[2]=i,a.uniforms.uSizeAnchor[3]=n,o&&(this.resources.uTexture=o.source,this.resources.uSampler=o.source.style)}}class hv extends Ve{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 cv(r,t){const e=r.anchor.x,s=r.anchor.y;t[0]=-e*r.width,t[1]=-s*r.height,t[2]=(1-e)*r.width,t[3]=-s*r.height,t[4]=(1-e)*r.width,t[5]=(1-s)*r.height,t[6]=-e*r.width,t[7]=(1-s)*r.height}function dv(r,t,e,s){let i=0;const n=r.length/(t||2),o=s.a,a=s.b,l=s.c,u=s.d,h=s.tx,c=s.ty;for(e*=t;it in r?VM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qs=(r,t)=>{for(var e in t||(t={}))mv.call(t,e)&&_v(r,e,t[e]);if(On)for(var e of On(t))gv.call(t,e)&&_v(r,e,t[e]);return r},YM=(r,t)=>{var e={};for(var s in r)mv.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&On)for(var s of On(r))t.indexOf(s)<0&&gv.call(r,s)&&(e[s]=r[s]);return e};const xv=class Co extends Se{constructor(...t){let e=t[0]||{};e instanceof B&&(e={texture:e}),t.length>1&&(e.width=t[1],e.height=t[2]),e=qs(qs({},Co.defaultOptions),e);const s=e!=null?e:{},{texture:i,anchor:n,tilePosition:o,tileScale:a,tileRotation:l,width:u,height:h,applyAnchorToTexture:c,roundPixels:d}=s,p=YM(s,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(qs({label:"TilingSprite"},p)),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new gt({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=c,this.texture=i,this._width=u!=null?u:i.width,this._height=h!=null?h:i.height,this._tileTransform=new ev({observer:{_onUpdate:()=>this.onViewUpdate()}}),n&&(this.anchor=n),this.tilePosition=o,this.tileScale=a,this.tileRotation=l,this.roundPixels=d!=null?d:!1}static from(t,e={}){return typeof t=="string"?new Co(qs({texture:rt.get(t)},e)):new Co(qs({texture:t},e))}get uvRespectAnchor(){return $s(ol,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(t){$s(ol,"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=B.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 s;typeof t=="object"&&(e=(s=t.height)!=null?s: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,s=this._width,i=this._height;t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*i,t.maxY=t.minY+i}containsPoint(t){const e=this._width,s=this._height,i=-e*this._anchor._x;let n=0;return t.x>=i&&t.x<=i+e&&(n=-s*this._anchor._y,t.y>=n&&t.y<=n+s)}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}};xv.defaultOptions={texture:B.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let vv=xv;var KM=Object.defineProperty,Gn=Object.getOwnPropertySymbols,bv=Object.prototype.hasOwnProperty,yv=Object.prototype.propertyIsEnumerable,Tv=(r,t,e)=>t in r?KM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qM=(r,t)=>{for(var e in t||(t={}))bv.call(t,e)&&Tv(r,e,t[e]);if(Gn)for(var e of Gn(t))yv.call(t,e)&&Tv(r,e,t[e]);return r},ZM=(r,t)=>{var e={};for(var s in r)bv.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Gn)for(var s of Gn(r))t.indexOf(s)<0&&yv.call(r,s)&&(e[s]=r[s]);return e};class In extends Se{constructor(t,e){const s=t,{text:i,resolution:n,style:o,anchor:a,width:l,height:u,roundPixels:h}=s,c=ZM(s,["text","resolution","style","anchor","width","height","roundPixels"]);super(qM({},c)),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i!=null?i:"",this.style=o,this.resolution=n!=null?n:null,this.allowChildren=!1,this._anchor=new gt({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=h!=null?h:!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 s;typeof t=="object"?(e=(s=t.height)!=null?s:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,s=this.bounds.height,i=-e*this.anchor.x;let n=0;return t.x>=i&&t.x<=i+e&&(n=-s*this.anchor.y,t.y>=n&&t.y<=n+s)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){var e;(e=this._style)==null||e.off("update",this.onViewUpdate,this),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 Fn(r,t){var e;let s=(e=r[0])!=null?e:{};return(typeof s=="string"||r[1])&&(s={text:s,style:r[1]}),s}let _r=null,$e=null;function QM(r,t){_r||(_r=X.get().createCanvas(256,128),$e=_r.getContext("2d",{willReadFrequently:!0}),$e.globalCompositeOperation="copy",$e.globalAlpha=1),(_r.width * @license BSD-3-Clause * @version 11.4.7 */class JM{constructor(t=0,e=0,s=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=s,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){const e=new Array(t.length);for(let s=0;s0){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=new Array(this.size);let e=this.first,s=0;for(;e!==null;)t[s++]=e.key,e=e.next;return t}setWithEvicted(t,e,s=this.resetTtl){let i=null;if(this.has(t))this.set(t,e,!0,s);else{this.max>0&&this.size===this.max&&(i=Jc({},this.first),this.evict(!0));let n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=n:this.last.next=n,this.last=n}return i}set(t,e,s=!1,i=this.resetTtl){let n=this.items[t];return s||n!==void 0?(n.value=e,s===!1&&i&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(t=this.keys()){const e=new Array(t.length);for(let s=0;s0}function Dn(r){return r.includes("<")}function tO(r,t){return r.clone().assign(t)}function xu(r,t){const e=[],s=t.tagStyles;if(!Bn(t)||!Dn(r))return e.push({text:r,style:t}),e;const i=[t],n=[];let o="",a=0;for(;a",a);if(u===-1){o+=l,a++;continue}const h=r.indexOf("<",a+1);if(h!==-1&&h0&&n[n.length-1]===d){o.length>0&&(e.push({text:o,style:i[i.length-1]}),o=""),i.pop(),n.pop(),a=u+1;continue}else{o+=r.slice(a,u+1),a=u+1;continue}}else{const d=c.trim();if(s[d]){o.length>0&&(e.push({text:o,style:i[i.length-1]}),o="");const p=i[i.length-1],f=tO(p,s[d]);i.push(f),n.push(d),a=u+1;continue}else{o+=r.slice(a,u+1),a=u+1;continue}}}else o+=l,a++}return o.length>0&&e.push({text:o,style:i[i.length-1]}),e}function eO(r,t){return!Bn(t)||!Dn(r)?r:xu(r,t).map(e=>e.text).join("")}const Pv=[10,13],Cv=new Set(Pv),Rv=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Mv=new Set(Rv),Ov=[9,32],Gv=new Set(Ov),Iv=[45,8208,8211,8212,173],Fv=new Set(Iv),Bv=/(\r\n|\r|\n)/,Dv=/(?:\r\n|\r|\n)/;function Zs(r){return typeof r!="string"?!1:Cv.has(r.charCodeAt(0))}function Jt(r,t){return typeof r!="string"?!1:Mv.has(r.charCodeAt(0))}function vu(r){return typeof r!="string"?!1:Gv.has(r.charCodeAt(0))}function bu(r){return typeof r!="string"?!1:Fv.has(r.charCodeAt(0))}function $n(r){return r==="normal"||r==="pre-line"}function Un(r){return r==="normal"}function Ce(r){if(typeof r!="string")return"";let t=r.length-1;for(;t>=0&&Jt(r[t]);)t--;return t0&&(t.push(e.join("")),e.length=0),i==="\r"&&n===` `?(t.push(`\r `),s++):t.push(i);continue}e.push(i),bu(i)&&n&&!Jt(n)&&!Zs(n)&&(t.push(e.join("")),e.length=0)}return e.length>0&&t.push(e.join("")),t}function Tu(r,t,e,s){const i=e(r),n=[];for(let o=0;o0&&p.push({text:U,style:G.style})}}(p.length>0||d.length===0)&&d.push(p);const f=e?Uv(d,t,s,n,a,l):d,m=[],g=[],_=[],x=[],v=[];let b=0;const S=t._fontString,y=o(S);y.fontSize===0&&(y.fontSize=t.fontSize,y.ascent=t.fontSize);let w="",E=!!t.dropShadow,A=((u=t._stroke)==null?void 0:u.width)||0;for(const G of f){let M=0,I=y.ascent,U=y.descent,j="";for(const K of G){const N=K.style._fontString,k=o(N);N!==w&&(s.font=N,w=N);const $=i(K.text,K.style.letterSpacing,s);M+=$,I=Math.max(I,k.ascent),U=Math.max(U,k.descent),j+=K.text;const z=((h=K.style._stroke)==null?void 0:h.width)||0;z>A&&(A=z),!E&&K.style.dropShadow&&(E=!0)}G.length===0&&(I=y.ascent,U=y.descent),m.push(M),g.push(I),_.push(U),v.push(j);const Q=t.lineHeight||I+U;x.push(Q+t.leading),b=Math.max(b,M)}const P=A,C=b+P+(t.dropShadow?t.dropShadow.distance:0);let O=0;for(let G=0;G{const S=`${v}|${b.styleKey}`;let y=m[S];if(y===void 0){const w=b._fontString;w!==g&&(e.font=w,g=w),y=s(v,b.letterSpacing,e)+b.letterSpacing,m[S]=y}return y},x=[];for(const v of r){const b=kv(v),S=x.length,y=R=>{let G=0,M=R;do{const{token:I,style:U}=b[M];G+=_(I,U),M++}while(M{const G=[];let M=R;do G.push({token:b[M].token,style:b[M].style}),M++;while(M{C&&C.text.length>0&&E.push(C),C=null},F=()=>{if(O(),E.length>0){const R=E[E.length-1];R.text=Ce(R.text),R.text.length===0&&E.pop()}x.push(E),E=[],A=0,P=!1};for(let R=0;Rf&&j)if(A>0&&F(),d){const K=w(R);for(let N=0;Nf&&F(),!C||C.style!==$?(O(),C={text:et,style:$}):C.text+=et,A+=mt}}R+=K.length-1}else{const K=w(R);O(),x.push(K.map(N=>({text:N.token,style:N.style}))),P=!1,R+=K.length-1}else if(Q+A>f&&j){if(Jt(G)){P=!1;continue}F(),C={text:G,style:M},A=U}else if(I&&!d)!C||C.style!==M?(O(),C={text:G,style:M}):C.text+=G,A+=U;else{const K=Jt(G);if(A===0&&K&&!P)continue;!C||C.style!==M?(O(),C={text:G,style:M}):C.text+=G,A+=U}}if(O(),E.length>0){const R=E[E.length-1];R.text=Ce(R.text),R.text.length===0&&E.pop()}(E.length>0||x.length===S)&&x.push(E)}return x}function kv(r){const t=[];let e=!1;for(const s of r){const i=yu(s.text);let n=!0;for(const o of i){const a=Jt(o)||Zs(o),l=n&&e&&!a;t.push({token:o,style:s.style,continuesFromPrevious:l}),e=!a,n=!1}}return t}const sO={willReadFrequently:!0};function Lv(r,t,e,s,i){let n=e[r];return typeof n!="number"&&(n=i(r,t,s)+t,e[r]=n),n}function Nv(r,t,e,s,i,n,o){const a=e.getContext("2d",sO);a.font=t._fontString;let l=0,u="";const h=[],c=Object.create(null),{letterSpacing:d,whiteSpace:p}=t,f=$n(p),m=Un(p);let g=!f;const _=t.wordWrapWidth+d,x=yu(r);for(let b=0;b_)if(u!==""&&(h.push(Ce(u)),u="",l=0),i(S,t.breakWords)){const w=Tu(S,t.breakWords,o,n);for(const E of w){const A=Lv(E,d,c,a,s);A+l>_&&(h.push(Ce(u)),g=!1,u="",l=0),u+=E,l+=A}}else u.length>0&&(h.push(Ce(u)),u="",l=0),h.push(Ce(S)),g=!1,u="",l=0;else y+l>_&&(g=!1,h.push(Ce(u)),u="",l=0),(u.length>0||!Jt(S)||g)&&(u+=S,l+=y)}const v=Ce(u);return v.length>0&&h.push(v),h.join(` `)}const jv={willReadFrequently:!0},Ue=class V{static get experimentalLetterSpacingSupported(){let t=V._experimentalLetterSpacingSupported;if(t===void 0){const e=X.get().getCanvasRenderingContext2D().prototype;t=V._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,i,n,o,a,l,u,h){this.text=t,this.style=e,this.width=s,this.height=i,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=u,h&&(this.runsByLine=h.runsByLine,this.lineAscents=h.lineAscents,this.lineDescents=h.lineDescents,this.lineHeights=h.lineHeights,this.hasDropShadow=h.hasDropShadow)}static measureText(t=" ",e,s=V._canvas,i=e.wordWrap){var n,o;const a=`${t}-${e.styleKey}-wordWrap-${i}`;if(V._measurementCache.has(a))return V._measurementCache.get(a);if(Bn(e)&&Dn(t)){const b=$v(t,e,i,V._context,V._measureText,V._measureTextAdvance,V.measureFont,V.canBreakChars,V.wordWrapSplit),S=new V(t,e,b.width,b.height,b.lines,b.lineWidths,b.lineHeight,b.maxLineWidth,b.fontProperties,{runsByLine:b.runsByLine,lineAscents:b.lineAscents,lineDescents:b.lineDescents,lineHeights:b.lineHeights,hasDropShadow:b.hasDropShadow});return V._measurementCache.set(a,S),S}const l=e._fontString,u=V.measureFont(l);u.fontSize===0&&(u.fontSize=e.fontSize,u.ascent=e.fontSize,u.descent=0);const h=V._context;h.font=l;const c=(i?V._wordWrap(t,e,s):t).split(Dv),d=new Array(c.length);let p=0;for(let b=0;b0&&(h+=l),Math.max(o,h)}static _measureTextAdvance(t,e,s){return V._measureTextCore(t,e,s).metricWidth}static _measureTextCore(t,e,s){let i=!1;V.experimentalLetterSpacingSupported&&(V.experimentalLetterSpacing?(s.letterSpacing=`${e}px`,s.textLetterSpacing=`${e}px`,i=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));const n=s.measureText(t);let o=n.width,a=0;return o>0&&(i?a=-e:a=(V.graphemeSegmenter(t).length-1)*e,o+=a),{metricWidth:o,metrics:n,letterSpacingVal:a}}static _wordWrap(t,e,s=V._canvas){return Nv(t,e,s,V._measureTextAdvance,V.canBreakWords,V.canBreakChars,V.wordWrapSplit)}static isBreakingSpace(t,e){return Jt(t,e)}static canBreakWords(t,e){return e}static canBreakChars(t,e,s,i,n){return!0}static wordWrapSplit(t){return V.graphemeSegmenter(t)}static measureFont(t){var e,s;if(V._fonts[t])return V._fonts[t];const i=V._context;i.font=t;const n=i.measureText(V.METRICS_STRING+V.BASELINE_SYMBOL),o=(e=n.actualBoundingBoxAscent)!=null?e:0,a=(s=n.actualBoundingBoxDescent)!=null?s:0,l={ascent:o,descent:a,fontSize:o+a};return V._fonts[t]=l,l}static clearMetrics(t=""){t?delete V._fonts[t]:V._fonts={}}static get _canvas(){if(!V.__canvas){let t;try{const e=new OffscreenCanvas(0,0),s=e.getContext("2d",jv);if(s!=null&&s.measureText)return V.__canvas=e,e;t=X.get().createCanvas()}catch(e){t=X.get().createCanvas()}t.width=t.height=10,V.__canvas=t}return V.__canvas}static get _context(){return V.__context||(V.__context=V._canvas.getContext("2d",jv)),V.__context}};Ue.METRICS_STRING="|\xC9q\xC5",Ue.BASELINE_SYMBOL="M",Ue.BASELINE_MULTIPLIER=1.4,Ue.HEIGHT_MULTIPLIER=2,Ue.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>{const e=r.segment(t),s=[];let i=0;for(const n of e)s[i++]=n.segment;return s}}return r=>[...r]})(),Ue.experimentalLetterSpacing=!1,Ue._fonts={},Ue._measurementCache=Av(1e3);let vt=Ue;const iO=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function ts(r){const t=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let e=r.fontFamily;Array.isArray(r.fontFamily)||(e=r.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let i=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(i)&&!iO.includes(i)&&(i=`"${i}"`),e[s]=i}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const Xv=1e5;function xr(r,t,e,s=0,i=0,n=0){var o;if(r.texture===B.WHITE&&!r.fill)return tt.shared.setValue(r.color).setAlpha((o=r.alpha)!=null?o:1).toHexa();if(r.fill){if(r.fill instanceof zr){const a=r.fill,l=t.createPattern(a.texture.source.resource,"repeat");return Z.applyPatternTransform(l,a.transform,!1),l}else if(r.fill instanceof Lt){const a=r.fill,l=a.type==="linear",u=a.textureSpace==="local";let h=1,c=1;u&&e&&(h=e.width+s,c=e.height+s);let d,p=!1;if(l){const{start:f,end:m}=a;d=t.createLinearGradient(f.x*h+i,f.y*c+n,m.x*h+i,m.y*c+n),p=Math.abs(m.x-f.x){let x=g+_.offset*f;x=Math.max(0,Math.min(1,x)),d.addColorStop(Math.floor(x*Xv)/Xv,tt.shared.setValue(_.color).toHex())})}}else a.colorStops.forEach(f=>{d.addColorStop(f.offset,tt.shared.setValue(f.color).toHex())});return d}}else{const a=t.createPattern(r.texture.source.resource,"repeat"),l=r.matrix.copyTo(D.shared);return l.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),a.setTransform(l),a}return"red"}const Hv=new it;function es(r){let t=0;for(let e=0;e0){this._renderTaggedTextToCanvas(n,t,e,s,i);return}const{canvas:d,context:p}=i,f=ts(t),m=n.lines,g=n.lineHeight,_=n.lineWidths,x=n.maxLineWidth,v=n.fontProperties,b=d.height;if(p.resetTransform(),p.scale(s,s),p.textBaseline=t.textBaseline,(o=t._stroke)!=null&&o.width){const P=t._stroke;p.lineWidth=P.width,p.miterLimit=P.miterLimit,p.lineJoin=P.join,p.lineCap=P.cap}p.font=f;let S,y;const w=t.dropShadow?2:1,E=((l=(a=t._stroke)==null?void 0:a.width)!=null?l:0)/2;let A=(g-v.fontSize)/2;g-v.fontSize<0&&(A=0);for(let P=0;P0&&(G=(x-_[R])/M)}(c=t._stroke)!=null&&c.width&&this._drawLetterSpacing(m[R],t,i,S+e,y+e-O,!0,G),t._fill!==void 0&&this._drawLetterSpacing(m[R],t,i,S+e,y+e-O,!1,G)}}}_renderTaggedTextToCanvas(t,e,s,i,n){var o,a,l,u,h;const{canvas:c,context:d}=n,{runsByLine:p,lineWidths:f,maxLineWidth:m,lineAscents:g,lineHeights:_,hasDropShadow:x}=t,v=c.height;d.resetTransform(),d.scale(i,i),d.textBaseline=e.textBaseline;const b=x?2:1;let S=(a=(o=e._stroke)==null?void 0:o.width)!=null?a:0;for(const E of p)for(const A of E){const P=(u=(l=A.style._stroke)==null?void 0:l.width)!=null?u:0;P>S&&(S=P)}const y=S/2,w=[];for(let E=0;E0&&(Q=(m-G)/k)}const K=O+M;let N=j+s;for(let k=0;kt in r?oO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jt=(r,t)=>{for(var e in t||(t={}))uO.call(t,e)&&Wv(r,e,t[e]);if(zv)for(var e of zv(t))hO.call(t,e)&&Wv(r,e,t[e]);return r},cO=(r,t)=>aO(r,lO(t));const Su=class Sr extends It{constructor(t={}){var e;super(),this.uid=ut("textStyle"),this._tick=0,this._cachedFontString=null,dO(t),t instanceof Sr&&(t=t._toObject());const s=jt(jt({},Sr.defaultTextStyle),t);for(const i in s){const n=i;this[n]=s[i]}this._tagStyles=(e=t.tagStyles)!=null?e:void 0,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(jt(jt({},Sr.defaultDropShadow),t)):this._dropShadow=t?this._createProxy(jt({},Sr.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(jt(jt({},Nt.defaultFillStyle),t),()=>{this._fill=He(jt({},this._originalFill),Nt.defaultFillStyle)})),this._fill=He(t===0?"black":t,Nt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy(jt(jt({},Nt.defaultStrokeStyle),t),()=>{this._stroke=js(jt({},this._originalStroke),Nt.defaultStrokeStyle)})),this._stroke=js(t,Nt.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t!=null?t:void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const t=Sr.defaultTextStyle;for(const e in t)this[e]=t[e]}assign(t){for(const e in t){const s=e;this[s]=t[e]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=ts(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?jt({},this._dropShadow):null,fill:this._fill?jt({},this._fill):void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?jt({},this._stroke):void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?jt({},this._tagStyles):void 0}}clone(){return new Sr(this._toObject())}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e(s[i]===n||(s[i]=n,e==null||e(i,n),this.update()),!0)})}_isFillStyle(t){return(t!=null?t:null)!==null&&!(tt.isColorLike(t)||t instanceof Lt||t instanceof zr)}};Su.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},Su.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 Xt=Su;function dO(r){var t,e,s,i,n;const o=r;if(typeof o.dropShadow=="boolean"&&o.dropShadow){const a=Xt.defaultDropShadow;r.dropShadow={alpha:(t=o.dropShadowAlpha)!=null?t:a.alpha,angle:(e=o.dropShadowAngle)!=null?e:a.angle,blur:(s=o.dropShadowBlur)!=null?s:a.blur,color:(i=o.dropShadowColor)!=null?i:a.color,distance:(n=o.dropShadowDistance)!=null?n:a.distance}}if(o.strokeThickness!==void 0){const a=o.stroke;let l={};if(tt.isColorLike(a))l.color=a;else if(a instanceof Lt||a instanceof zr)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=cO(jt({},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 Lt({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),l=o.fillGradientStops.slice(),u=o.fill.map(h=>tt.shared.setValue(h).toNumber());l.forEach((h,c)=>{a.addColorStop(h,u[c])}),r.fill={fill:a}}}let oD=!1;function pO(r){}function kn(r,t){const{texture:e,bounds:s}=r,i=t._style._getFinalPadding();ca(s,t._anchor,e);const n=t._anchor._x*i*2,o=t._anchor._y*i*2;s.minX-=i-n,s.minY-=i-o,s.maxX-=i-n,s.maxY-=i-o}class Qs{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 Vv extends Qs{}class wu{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),t.runners.contextChange.add(this),this._managedTexts=new kt({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()}}contextChange(){var t;for(const e in this._managedTexts.items)(t=this._managedTexts.items[e])==null||t.unload()}validateRenderable(t){const e=this._getGpuText(t),s=t.styleKey;return e.currentKey!==s?!0:t._didTextUpdate}addRenderable(t,e){const s=this._getGpuText(t);if(t._didTextUpdate||s.currentKey!==t.styleKey){const i=t._autoResolution?this._renderer.resolution:t.resolution;(s.currentKey!==t.styleKey||t._resolution!==i)&&this._updateGpuText(t),t._didTextUpdate=!1,kn(s,t)}this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Vv;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:s}=this._renderer;s.getReferenceCount(e.currentKey)>0?s.decreaseReferenceCount(e.currentKey):e.texture&&s.returnTexture(e.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}wu.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"text"};class Eu{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,s,i){var n;typeof t=="string"&&(t={text:t,style:s,resolution:e}),t.style instanceof Xt||(t.style=new Xt(t.style)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:o,style:a,textureStyle:l,autoGenerateMipmaps:u}=t,h=(n=t.resolution)!=null?n:this._renderer.resolution,{frame:c,canvasAndContext:d}=me.getCanvasAndContext({text:o,style:a,resolution:h}),p=Di(d.canvas,c.width,c.height,h,u,l==null?void 0:l.scaleMode);if(a.trim&&(c.pad(a.padding),p.frame.copyFrom(c),p.frame.scale(1/h),p.updateUvs()),a.filters){const f=this._applyFilters(p,a.filters);return this.returnTexture(p),me.returnCanvasAndContext(d),f}return this._renderer.texture.initSource(p._source),this._retainCanvasContext||me.returnCanvasAndContext(d),p}returnTexture(t){const e=t.source,s=e.resource;if(this._retainCanvasContext&&s!=null&&s.getContext){const i=s.getContext("2d");i&&me.returnCanvasAndContext({canvas:s,context:i})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",ft.returnTexture(t)}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 s=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle,autoGenerateMipmaps:t.autoGenerateMipmaps});return this._activeTextures[e]={texture:s,usageCount:1},s}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null))}getReferenceCount(t){var e,s;return(s=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?s:0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const s=this._renderer.renderTarget.renderTarget,i=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind({target:s,clear:!1}),i}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}class Au extends Eu{constructor(t){super(t,!0)}}Au.extension={type:[T.CanvasSystem],name:"canvasText"};class Pu extends Eu{constructor(t){super(t,!1)}}Pu.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"canvasText"},L.add(Au),L.add(Pu),L.add(wu);class Js extends In{constructor(...t){var e;const s=Fn(t,"Text");super(s,Xt),this.renderPipeId="text",s.textureStyle&&(this.textureStyle=s.textureStyle instanceof ae?s.textureStyle:new ae(s.textureStyle),this.textureStyle,void 0),this.autoGenerateMipmaps=(e=s.autoGenerateMipmaps)!=null?e:ct.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor;let s=0,i=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=me.getCanvasAndContext({text:this.text,style:this._style,resolution:1});me.returnCanvasAndContext(o),s=n.width,i=n.height}else{const n=vt.measureText(this._text,this._style);s=n.width,i=n.height}t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*i,t.maxY=t.minY+i}}class Yv extends kx{resolveQueueItem(t,e){return t instanceof dt?this.resolveContainerQueueItem(t,e):t instanceof ct||t instanceof B?e.push(t.source):t instanceof Nt&&e.push(t),null}resolveContainerQueueItem(t,e){t instanceof _e||t instanceof vv||t instanceof Qr?e.push(t.texture.source):t instanceof Js?e.push(t):t instanceof Er?e.push(t.context):t instanceof hi&&t.textures.forEach(s=>{s.source?e.push(s.source):e.push(s.texture.source)})}resolveGraphicsContextQueueItem(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const s of e)if(s.action==="texture"){const{image:i}=s.data;return i.source}else if(s.action==="fill"){const{texture:i}=s.data.style;return i.source}return null}}class Cu extends It{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return this.fontFamily}get pageTextures(){return this.pages}get size(){return this.fontMetrics.fontSize}get distanceFieldRange(){return this.distanceField.range}get distanceFieldType(){return this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const s in this.chars)(e=this.chars[s].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(s=>s.texture.destroy(!0)),this.pages=null)}}var fO=Object.defineProperty,Kv=Object.getOwnPropertySymbols,mO=Object.prototype.hasOwnProperty,gO=Object.prototype.propertyIsEnumerable,qv=(r,t,e)=>t in r?fO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Zv=(r,t)=>{for(var e in t||(t={}))mO.call(t,e)&&qv(r,e,t[e]);if(Kv)for(var e of Kv(t))gO.call(t,e)&&qv(r,e,t[e]);return r};const Qv=class pS extends Cu{constructor(t){var e,s,i;super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;const n=Zv(Zv({},pS.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=B.WHITE,o._fill.fill=null),this.applyFillAsTint=n.overrideFill;const a=o.fontSize;o.fontSize=this.baseMeasurementFontSize;const l=ts(o);n.overrideSize?(o._stroke&&(o._stroke.width*=this.baseRenderedFontSize/a),o.dropShadow&&(o.dropShadow.blur*=this.baseRenderedFontSize/a,o.dropShadow.distance*=this.baseRenderedFontSize/a)):o.fontSize=this.baseRenderedFontSize=a,this._style=o,this._skipKerning=(e=n.skipKerning)!=null?e:!1,this.resolution=(s=n.resolution)!=null?s:1,this._padding=(i=n.padding)!=null?i:4,n.textureStyle&&(this._textureStyle=n.textureStyle instanceof ae?n.textureStyle:new ae(n.textureStyle)),this.fontMetrics=vt.measureFont(l),this.lineHeight=o.lineHeight||this.fontMetrics.fontSize||o.fontSize}ensureCharacters(t){var e,s,i,n;const o=vt.graphemeSegmenter(t).filter(S=>!this._currentChars.includes(S)).filter((S,y,w)=>w.indexOf(S)===y);if(!o.length)return;this._currentChars=[...this._currentChars,...o];let a;this._currentPageIndex===-1?a=this._nextPage():a=this.pages[this._currentPageIndex];let{canvas:l,context:u}=a.canvasAndContext,h=a.texture.source;const c=this._style;let d=this._currentX,p=this._currentY,f=this._currentMaxCharHeight;const m=this.baseRenderedFontSize/this.baseMeasurementFontSize,g=((s=(e=c.dropShadow)==null?void 0:e.distance)!=null?s:0)+((n=(i=c._stroke)==null?void 0:i.width)!=null?n:0),_=this._padding+g;let x=!1;const v=l.width/this.resolution,b=l.height/this.resolution;for(let S=0;Sv&&(p+=f,f=O,d=0,p+f>b)){h.update();const R=this._nextPage();l=R.canvasAndContext.canvas,u=R.canvasAndContext.context,h=R.texture.source,d=0,p=0,f=0}const F=u.measureText(y).width/m;if(this.chars[y]={id:y.codePointAt(0),xOffset:-(_/m),yOffset:-(_/m),xAdvance:F,kerning:{}},x){this._drawGlyph(u,w,d+_,p+_,m,c);const R=h.width*m,G=h.height*m,M=new it(d/R*h.width,p/G*h.height,C/R*h.width,O/G*h.height);this.chars[y].texture=new B({source:h,frame:M}),d+=Math.ceil(C)}}h.update(),this._currentX=d,this._currentY=p,this._currentMaxCharHeight=f,this._skipKerning||this._applyKerning(o,u,m)}get pageTextures(){return this.pages}_applyKerning(t,e,s){const i=this._measureCache;for(let n=0;n{const y=a.width;for(let w=0;w0||!g)&&(u=!1),h.width=0,h.index=0,h.chars.length=0},v=()=>{let S=a.chars.length-1;if(s){let y=a.chars[S];for(;vu(y);)a.width-=e.chars[y].xAdvance,a.spacesIndex.pop(),y=a.chars[--S]}o.width=Math.max(o.width,a.width),a={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},u=!0,o.lines.push(a),o.height+=f},b=S=>S-d>p;for(let S=0;St in r?bO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Mu=(r,t)=>{for(var e in t||(t={}))yO.call(t,e)&&eb(r,e,t[e]);if(tb)for(var e of tb(t))TO.call(t,e)&&eb(r,e,t[e]);return r};let Nn=0,SO=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=Av(1e3)}getFont(t,e){var s,i;let n=`${e.fontFamily}-bitmap`,o=!0;if(rt.has(n)){const l=rt.get(n);return(s=l.ensureCharacters)==null||s.call(l,t),l}if(e._fill.fill&&!e._stroke?(n+=e._fill.fill.styleKey,o=!1):(e._stroke||e.dropShadow)&&(n=`${e.styleKey}-bitmap`,o=!1),n+=`-${e.fontStyle}`,n+=`-${e.fontVariant}`,n+=`-${e.fontWeight}`,!rt.has(n)){const l=Object.create(e);l._lineHeight=0;const u=new Ru(Mu({style:l,overrideFill:o,overrideSize:!0},this.defaultOptions));Nn++,Nn>50&&Bt("BitmapText",`You have dynamically created ${Nn} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),u.once("destroy",()=>{Nn--,rt.remove(n)}),rt.set(n,u)}const a=rt.get(n);return(i=a.ensureCharacters)==null||i.call(a,t),a}getLayout(t,e,s=!0){const i=this.getFont(t,e),n=`${t}-${e.styleKey}-${s}`;if(this.measureCache.has(n))return this.measureCache.get(n);const o=vt.graphemeSegmenter(t),a=Ln(o,e,i,s);return this.measureCache.set(n,a),a}measureText(t,e,s=!0){return this.getLayout(t,e,s)}install(...t){var e,s,i,n,o;let a=t[0];typeof a=="string"&&(a={name:a,style:t[1],chars:(e=t[2])==null?void 0:e.chars,resolution:(s=t[2])==null?void 0:s.resolution,padding:(i=t[2])==null?void 0:i.padding,skipKerning:(n=t[2])==null?void 0:n.skipKerning});const l=a==null?void 0:a.name;if(!l)throw new Error("[BitmapFontManager] Property `name` is required.");a=Mu(Mu({},this.defaultOptions),a);const u=a.style,h=u instanceof Xt?u:new Xt(u),c=(o=a.dynamicFill)!=null?o:this._canUseTintForStyle(h),d=new Ru({style:h,overrideFill:c,skipKerning:a.skipKerning,padding:a.padding,resolution:a.resolution,overrideSize:!1,textureStyle:a.textureStyle}),p=Jv(a.chars);return d.ensureCharacters(p.join("")),rt.set(`${l}-bitmap`,d),d.once("destroy",()=>rt.remove(`${l}-bitmap`)),d}uninstall(t){const e=`${t}-bitmap`,s=rt.get(e);s&&s.destroy()}_canUseTintForStyle(t){return!t._stroke&&(!t.dropShadow||t.dropShadow.color===0)&&!t._fill.fill&&t._fill.color===16777215}};const rs=new SO;class rb extends Er{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class Ou{constructor(t){this._renderer=t,this._managedBitmapTexts=new kt({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 s=this._getGpuBitmapText(t);sb(t,s),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,s)),this._renderer.renderPipes.graphics.addRenderable(s,e),s.context.customShader&&this._updateDistanceField(t)}updateRenderable(t){const e=this._getGpuBitmapText(t);sb(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:s}=e,i=rs.getFont(t.text,t._style);if(s.clear(),i.distanceField.type!=="none"){const _=this.getSdfShader();_&&(s.customShader||(s.customShader=_))}const n=vt.graphemeSegmenter(t.text),o=t._style;let a=i.baseLineOffset;const l=Ln(n,o,i,!0),u=o.padding,h=l.scale;let c=l.width,d=l.height+l.offsetY;o._stroke&&(c+=o._stroke.width/h,d+=o._stroke.width/h),s.translate(-t._anchor._x*c-u,-t._anchor._y*d-u).scale(h,h);const p=i.applyFillAsTint?o._fill.color:16777215;let f=i.fontMetrics.fontSize,m=i.lineHeight;o.lineHeight&&(f=o.fontSize/h,m=o.lineHeight/h);let g=(m-f)/2;g-i.baseLineOffset<0&&(g=0);for(let _=0;_, uTransformMatrix:mat3x3, uDistance: f32, uRound:f32, } @group(2) @binding(0) var localUniforms : LocalUniforms; `,main:` vColor *= localUniforms.uColor; modelMatrix *= localUniforms.uTransformMatrix; `,end:` if(localUniforms.uRound == 1) { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } `},fragment:{header:` struct LocalUniforms { uColor:vec4, uTransformMatrix:mat3x3, uDistance: f32 } @group(2) @binding(0) var localUniforms : LocalUniforms; `,main:` outColor = vec4(calculateMSDFAlpha(outColor, vColor, localUniforms.uDistance)); `}},nb={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)); `}},ob={name:"msdf-bit",fragment:{header:` fn calculateMSDFAlpha(msdfColor:vec4, shapeColor:vec4, distance:f32) -> f32 { // MSDF var median = msdfColor.r + msdfColor.g + msdfColor.b - min(msdfColor.r, min(msdfColor.g, msdfColor.b)) - max(msdfColor.r, max(msdfColor.g, msdfColor.b)); // SDF median = min(median, msdfColor.a); var screenPxDistance = distance * (median - 0.5); var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0); if (median < 0.01) { alpha = 0.0; } else if (median > 0.99) { alpha = 1.0; } // Gamma correction for coverage-like alpha var luma: f32 = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114)); var gamma: f32 = mix(1.0, 1.0 / 2.2, luma); var coverage: f32 = pow(shapeColor.a * alpha, gamma); return coverage; } `}},ab={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 Iu,Fu;class lb extends ne{constructor(t){const e=new wt({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new D,type:"mat3x3"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});Iu!=null||(Iu=Ur({name:"sdf-shader",bits:[Yi,qi(t),ib,ob,Lr]})),Fu!=null||(Fu=kr({name:"sdf-shader",bits:[Ki,Zi(t),nb,ab,Nr]})),super({glProgram:Fu,gpuProgram:Iu,resources:{localUniforms:e,batchSamplers:Qi(t)}})}}class Bu extends Ou{getSdfShader(){return new lb(this._renderer.limits.maxBatchableTextures)}}Bu.extension={type:[T.WebGLPipes,T.WebGPUPipes],name:"bitmapText"},L.add(Gu),L.add(Bu);class Du extends In{constructor(...t){var e,s,i;const n=Fn(t,"BitmapText");(e=n.style)!=null||(n.style=n.style||{}),(i=(s=n.style).fill)!=null||(s.fill=16777215),super(n,Xt),this.renderPipeId="bitmapText"}_onTouch(t){var e;this._gcLastUsed=t;for(const s in this._gpuData)(e=this._gpuData[s])==null||e._onTouch(t)}updateBounds(){const t=this._bounds,e=this._anchor,s=rs.measureText(this.text,this._style),i=s.scale,n=s.offsetY*i;let o=s.width*i,a=s.height*i;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}}var wO=Object.defineProperty,ub=Object.getOwnPropertySymbols,EO=Object.prototype.hasOwnProperty,AO=Object.prototype.propertyIsEnumerable,hb=(r,t,e)=>t in r?wO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$u=(r,t)=>{for(var e in t||(t={}))EO.call(t,e)&&hb(r,e,t[e]);if(ub)for(var e of ub(t))AO.call(t,e)&&hb(r,e,t[e]);return r};function cb(r){var t;const e=r._stroke,s=r._fill,i=[`div { ${[`color: ${tt.shared.setValue(s.color).setAlpha((t=s.alpha)!=null?t:1).toHexa()}`,`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-break: ${r.breakWords?"break-word":"normal"}`,`max-width: ${r.wordWrapWidth}px`]:[],...e?[db(e)]:[],...r.dropShadow?[Uu(r.dropShadow)]:[],...r.cssOverrides].join(";")} }`];return PO(r.tagStyles,i),i.join(" ")}function Uu(r){var t;const e=$u({},r),s=tt.shared.setValue(e.color).setAlpha((t=e.alpha)!=null?t:1).toHexa(),i=Math.round(Math.cos(e.angle)*e.distance),n=Math.round(Math.sin(e.angle)*e.distance),o=`${i}px ${n}px`;return e.blur>0?`text-shadow: ${o} ${e.blur}px ${s}`:`text-shadow: ${o} ${s}`}function db(r){var t;const e=tt.shared.setValue(r.color).setAlpha((t=r.alpha)!=null?t:1).toHexa();return[`-webkit-text-stroke-width: ${r.width}px`,`-webkit-text-stroke-color: ${e}`,`text-stroke-width: ${r.width}px`,`text-stroke-color: ${e}`,"paint-order: stroke"].join(";")}const pb={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"},fb={fill:r=>`color: ${tt.shared.setValue(r).toHexa()}`,breakWords:r=>`word-break: ${r?"break-all":"normal"}`,stroke:db,dropShadow:r=>r===!0?Uu(Xt.defaultDropShadow):r&&typeof r=="object"?Uu($u($u({},Xt.defaultDropShadow),r)):""};function PO(r,t){for(const e in r){const s=r[e],i=[];for(const n in s)fb[n]?i.push(fb[n](s[n])):pb[n]&&i.push(pb[n].replace("{{VALUE}}",s[n]));t.push(`${e} { ${i.join(";")} }`)}}var CO=Object.defineProperty,mb=Object.getOwnPropertySymbols,RO=Object.prototype.hasOwnProperty,MO=Object.prototype.propertyIsEnumerable,gb=(r,t,e)=>t in r?CO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_b=(r,t)=>{for(var e in t||(t={}))RO.call(t,e)&&gb(r,e,t[e]);if(mb)for(var e of mb(t))MO.call(t,e)&&gb(r,e,t[e]);return r};class Do extends Xt{constructor(t={}){var e,s;super(t),this._cssOverrides=[],this.cssOverrides=(e=t.cssOverrides)!=null?e:[],this.tagStyles=(s=t.tagStyles)!=null?s:{}}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t!=null?t:{},this.update())}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 Do({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?_b({},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:_b({},this.tagStyles)})}get cssStyle(){return this._cssStyle||(this._cssStyle=cb(this)),this._cssStyle}addOverride(...t){const e=t.filter(s=>!this.cssOverrides.includes(s));e.length>0&&(this.cssOverrides.push(...e),this.update())}removeOverride(...t){const e=t.filter(s=>this.cssOverrides.includes(s));e.length>0&&(this.cssOverrides=this.cssOverrides.filter(s=>!e.includes(s)),this.update())}set fill(t){super.fill=t}set stroke(t){super.stroke=t}}const xb="http://www.w3.org/2000/svg",vb="http://www.w3.org/1999/xhtml";class ku{constructor(){this.svgRoot=document.createElementNS(xb,"svg"),this.foreignObject=document.createElementNS(xb,"foreignObject"),this.domElement=document.createElementNS(vb,"div"),this.styleElement=document.createElementNS(vb,"style");const{foreignObject:t,svgRoot:e,styleElement:s,domElement:i}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(s),t.appendChild(i),this.image=X.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}}let bb;function Lu(r,t,e,s){s||(s=bb||(bb=new ku));const{domElement:i,styleElement:n,svgRoot:o}=s;i.innerHTML=`
${r}
`,i.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(n.textContent=e),document.body.appendChild(o);let a=i.scrollWidth,l=i.scrollHeight;if(o.remove(),t.dropShadow){const{distance:h,angle:c,blur:d}=t.dropShadow,p=Math.abs(Math.round(Math.cos(c)*h)),f=Math.abs(Math.round(Math.sin(c)*h));a+=p+d,l+=f+d}const u=t.padding*2;return{width:a-u,height:l-u}}class yb extends Qs{constructor(){super(...arguments),this.generatingTexture=!1,this.currentKey="--"}destroy(){this.texturePromise=null,this.generatingTexture=!1,this.currentKey="--",super.destroy()}}class Nu{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),t.runners.contextChange.add(this),this._managedTexts=new kt({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()}}contextChange(){var t;for(const e in this._managedTexts.items)(t=this._managedTexts.items[e])==null||t.unload()}validateRenderable(t){const e=this._getGpuText(t),s=t.styleKey;return e.currentKey!==s}addRenderable(t,e){const s=this._getGpuText(t);if(t._didTextUpdate||s.currentKey!==t.styleKey){const i=t._autoResolution?this._renderer.resolution:t.resolution;(s.currentKey!==t.styleKey||t.resolution!==i)&&this._updateGpuText(t).catch(n=>{console.error(n)}),t._didTextUpdate=!1,kn(s,t)}this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}async _updateGpuText(t){t._didTextUpdate=!1;const e=this._getGpuText(t);if(e.generatingTexture)return;const s=e.texturePromise;e.texturePromise=null,e.generatingTexture=!0,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;let i=this._renderer.htmlText.getTexturePromise(t);s&&(i=i.finally(()=>{this._renderer.htmlText.decreaseReferenceCount(e.currentKey),this._renderer.htmlText.returnTexturePromise(s)})),e.texturePromise=i,e.currentKey=t.styleKey;const n=await i;if(!e.renderable)return;e.texture=n;const o=t.renderGroup||t.parentRenderGroup;o&&(o.structureDidChange=!0),e.generatingTexture=!1,kn(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new yb;return e.renderable=t,e.transform=t.groupTransform,e.texture=B.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!=null&&e.texturePromise))return;const{htmlText:s}=this._renderer;s.getReferenceCount(e.currentKey)===null?s.returnTexturePromise(e.texturePromise):s.decreaseReferenceCount(e.currentKey)}destroy(){this._managedTexts.destroy(),this._renderer=null}}Nu.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"htmlText"};function ju(){const{userAgent:r}=X.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}function Tb(r,t){const e=t.fontFamily,s=[],i={},n=/font-family:([^;"\s]+)/g,o=r.match(n);function a(l){i[l]||(s.push(l),i[l]=!0)}if(Array.isArray(e))for(let l=0;l{const u=l.split(":")[1].trim();a(u)});for(const l in t.tagStyles){const u=t.tagStyles[l].fontFamily;a(u)}return s}async function Sb(r){const t=await(await X.get().fetch(r)).blob(),e=new FileReader;return await new Promise((s,i)=>{e.onloadend=()=>s(e.result),e.onerror=i,e.readAsDataURL(t)})}async function wb(r,t){const e=await Sb(t);return`@font-face { font-family: "${r.fontFamily}"; font-weight: ${r.fontWeight}; font-style: ${r.fontStyle}; src: url('${e}'); }`}const jn=new Map;async function Eb(r){const t=r.filter(e=>rt.has(`${e}-and-url`)).map(e=>{if(!jn.has(e)){const{entries:s}=rt.get(`${e}-and-url`),i=[];s.forEach(n=>{const o=n.url,a=n.faces.map(l=>({weight:l.weight,style:l.style}));i.push(...a.map(l=>wb({fontWeight:l.weight,fontStyle:l.style,fontFamily:e},o)))}),jn.set(e,Promise.all(i).then(n=>n.join(` `)))}return jn.get(e)});return(await Promise.all(t)).join(` `)}function Ab(r,t,e,s,i){const{domElement:n,styleElement:o,svgRoot:a}=i;n.innerHTML=`
${r}
`,n.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),o.textContent=s;const{width:l,height:u}=i.image;return a.setAttribute("width",l.toString()),a.setAttribute("height",u.toString()),new XMLSerializer().serializeToString(a)}function Pb(r,t){const e=se.getOptimalCanvasAndContext(r.width,r.height,t),{context:s}=e;return s.clearRect(0,0,r.width,r.height),s.drawImage(r,0,0),e}function Cb(r,t,e){return new Promise(async s=>{e&&await new Promise(i=>setTimeout(i,100)),r.onload=()=>{s()},r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,r.crossOrigin="anonymous"})}class Xu{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===Mt.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getManagedTexture(t){const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].promise;const s=this._buildTexturePromise(t).then(i=>(this._activeTextures[e].texture=i,i));return this._activeTextures[e]={texture:null,promise:s,usageCount:1},s}getReferenceCount(t){var e,s;return(s=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?s:null}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e.texture):e.promise.then(s=>{e.texture=s,this._cleanUp(e.texture)}).catch(()=>{}),this._activeTextures[t]=null))}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){var e;const{text:s,style:i,resolution:n,textureStyle:o,autoGenerateMipmaps:a}=t,l=St.get(ku),u=Tb(s,i),h=await Eb(u),c=Lu(s,i,h,l),d=Math.ceil(Math.ceil(Math.max(1,c.width)+i.padding*2)*n),p=Math.ceil(Math.ceil(Math.max(1,c.height)+i.padding*2)*n),f=l.image,m=2;f.width=(d|0)+m,f.height=(p|0)+m;const g=Ab(s,i,n,h,l);await Cb(f,g,ju()&&u.length>0);const _=f;let x;this._createCanvas&&(x=Pb(f,n));const v=Di(x?x.canvas:_,f.width-m,f.height-m,n,a,o==null?void 0:o.scaleMode);return(e=this._renderer)==null||e.texture.initSource(v.source),this._createCanvas&&se.returnCanvasAndContext(x),St.return(l),v}returnTexturePromise(t){t.then(e=>{this._cleanUp(e)}).catch(()=>{})}_cleanUp(t){const e=t.source;ft.returnTexture(t),e.resource=null,e.uploadMethodId="unknown"}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexturePromise(this._activeTextures[t].promise);this._activeTextures=null}}Xu.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"htmlText"},L.add(Xu),L.add(Nu);class Rb extends In{constructor(...t){var e;const s=Fn(t,"HtmlText");super(s,Do),this.renderPipeId="htmlText",s.textureStyle&&(this.textureStyle=s.textureStyle instanceof ae?s.textureStyle:new ae(s.textureStyle),this.textureStyle,void 0),this.autoGenerateMipmaps=(e=s.autoGenerateMipmaps)!=null?e:ct.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor,s=Lu(this.text,this._style),{width:i,height:n}=s;t.minX=-e._x*i,t.maxX=t.minX+i,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(/
/gi,"
").replace(/
/gi,"
").replace(/ /gi," "))}_removeInvalidHtmlTags(t){const e=/<[^>]*?(?=<|$)/g;return t.replace(e,"")}}class Mb extends Yv{uploadQueueItem(t){t instanceof ct?this.uploadTextureSource(t):t instanceof Js?this.uploadText(t):t instanceof Rb?this.uploadHTMLText(t):t instanceof Du?this.uploadBitmapText(t):t instanceof Nt&&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 s of e)if(s.action==="texture"){const{image:i}=s.data;this.uploadTextureSource(i.source)}else if(s.action==="fill"){const{texture:i}=s.data.style;this.uploadTextureSource(i.source)}return null}}class Ob extends Mb{destroy(){super.destroy(),clearTimeout(this.timeout),this.renderer=null,this.queue=null,this.resolves=null}}Ob.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"prepare"};const Hu=class wr{static _getPatternRepeat(t,e){const s=t&&t!=="clamp-to-edge",i=e&&e!=="clamp-to-edge";return s&&i?"repeat":s?"repeat-x":i?"repeat-y":"no-repeat"}start(t,e,s){}execute(t,e){var s,i,n,o,a,l,u,h,c,d;const p=e.elements;if(!p||!p.length)return;const f=t.renderer,m=f.canvasContext,g=m.activeContext;for(let _=0;_>>24&255)/255,O=(P>>>24&255)/255,F=(o=(n=f.filter)==null?void 0:n.alphaMultiplier)!=null?o:1,R=C*O*F;if(R<=0)continue;g.globalAlpha=R;const G=A&16777215,M=P&16777215,I=ye(be(M,G)),U=b.frame,j=(a=y.addressModeU)!=null?a:y.addressMode,Q=(l=y.addressModeV)!=null?l:y.addressMode,K=wr._getPatternRepeat(j,Q),N=(h=(u=b.source._resolution)!=null?u:b.source.resolution)!=null?h:1,k=(d=(c=v.renderable)==null?void 0:c.renderGroup)==null?void 0:d.isCachedAsTexture,$=U.x*N,z=U.y*N,et=U.width*N,mt=U.height*N,J=v.bounds,ot=f.renderTarget.renderTarget.isRoot,nt=J.minX,ht=J.minY,Tt=J.maxX-J.minX,Et=J.maxY-J.minY,_t=b.rotate,q=b.uvs,Wt=Math.min(q.x0,q.x1,q.x2,q.x3,q.y0,q.y1,q.y2,q.y3),Gt=Math.max(q.x0,q.x1,q.x2,q.x3,q.y0,q.y1,q.y2,q.y3),Me=K!=="no-repeat"&&(Wt<0||Gt>1),Le=_t&&!(!Me&&(I!==16777215||_t));Le?(wr._tempPatternMatrix.copyFrom(v.transform),H.matrixAppendRotationInv(wr._tempPatternMatrix,_t,nt,ht,Tt,Et),m.setContextTransform(wr._tempPatternMatrix,v.roundPixels===1,void 0,k&&ot)):m.setContextTransform(v.transform,v.roundPixels===1,void 0,k&&ot);const Ze=Tt,us=Et;let Qe=Le?0:nt,Je=Le?0:ht;if(!Le&&v.roundPixels===1&&(Qe|=0,Je|=0),Me){let Oe=S;const te=I!==16777215&&!_t,ci=U.width<=b.source.width&&U.height<=b.source.height;te&&ci&&(Oe=Z.getTintedCanvas({texture:b},I));const hs=g.createPattern(Oe,K);if(!hs)continue;const di=Ze,pi=us;if(di===0||pi===0)continue;const Ge=1/di,cs=1/pi,Vc=(q.x1-q.x0)*Ge,Yc=(q.y1-q.y0)*Ge,Kc=(q.x3-q.x0)*cs,qc=(q.y3-q.y0)*cs,OS=q.x0-Vc*Qe-Kc*Je,GS=q.y0-Yc*Qe-qc*Je,ko=b.source.pixelWidth,Lo=b.source.pixelHeight;wr._tempPatternMatrix.set(Vc*ko,Yc*Lo,Kc*ko,qc*Lo,OS*ko,GS*Lo),Z.applyPatternTransform(hs,wr._tempPatternMatrix),g.fillStyle=hs,g.fillRect(Qe,Je,Ze,us)}else{const Oe=I!==16777215||_t?Z.getTintedCanvas({texture:b},I):S,te=Oe!==S;g.drawImage(Oe,te?0:$,te?0:z,te?Oe.width:et,te?Oe.height:mt,Qe,Je,Ze,us)}}}};Hu._tempPatternMatrix=new D,Hu.extension={type:[T.CanvasPipesAdaptor],name:"batch"};let Gb=Hu;class zu{constructor(){this._tempState=Kt.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,s){const i=t.renderer,n=this._didUploadHash[s.uid];i.shader.bind(s,n),n||(this._didUploadHash[s.uid]=!0),i.shader.updateUniformGroup(i.globalUniforms.uniformGroup),i.geometry.bind(e,s.glProgram)}execute(t,e){const s=t.renderer;this._tempState.blendMode=e.blendMode,s.state.set(this._tempState);const i=e.textures.textures;for(let n=0;ns.trim()).filter(s=>s.length);let e="";return t.map(s=>{let i=e+s;return s==="{"?e+=" ":s==="}"&&(e=e.substr(0,e.length-4),i=e+s),i}).join(` `)}const Ib={name:"texture-bit",vertex:{header:` struct TextureUniforms { uTextureMatrix:mat3x3, } @group(2) @binding(2) var textureUniforms : TextureUniforms; `,main:` uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy; `},fragment:{header:` @group(2) @binding(0) var uTexture: texture_2d; @group(2) @binding(1) var uSampler: sampler; `,main:` outColor = textureSample(uTexture, uSampler, vUV); `}},Fb={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); `}},FO=new Ct;let BO=class extends ms{constructor(){super(),this._placeholderSprite=new _e(B.EMPTY),this.filters=[new $x({sprite:this._placeholderSprite,inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].setSprite(t)}get inverse(){return this.filters[0].inverse}set inverse(t){this.filters[0].inverse=t}get channel(){return this.filters[0].channel}set channel(t){this.filters[0].channel=t}reset(){this._placeholderSprite.texture=B.EMPTY,this.sprite=this._placeholderSprite}};class zn{constructor(t){this._activeMaskStage=[],this._usedEffects=[],this._renderer=t,t.runners.postrender.add(this)}push(t,e,s){var i;const n=this._renderer;if(n.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1,maskedContainer:e}),t.inverse=e._maskOptions.inverse,t.channel=(i=e._maskOptions.channel)!=null?i:"red",t.renderMaskToTexture){const o=t.mask;o.includeInBuild=!0,o.collectRenderables(s,n,null),o.includeInBuild=!1}n.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){const e=this._renderer,s=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){const i=St.get(BO);if(i.inverse=t.inverse,i.channel=t.mask.channel,s){t.mask.mask.measurable=!0;const n=gs(t.mask.mask,!0,FO);t.mask.mask.measurable=!1,n.ceil();const o=e.renderTarget.renderTarget.colorTexture.source,a=ft.getOptimalTexture({width:n.width,height:n.height,resolution:o._resolution,antialias:o.antialias});e.renderTarget.push({target:a,clear:!0}),e.globalUniforms.push({offset:n,worldColor:4294967295});const l=i.sprite;l.texture=a,l.worldTransform.tx=n.minX,l.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer,filterTexture:a})}else i.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){const i=this._activeMaskStage[this._activeMaskStage.length-1];s&&(e.type===Mt.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:i.maskedContainer,filterEffect:i.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();const i=this._activeMaskStage.pop();s&&ft.returnTexture(i.filterTexture),this._usedEffects.push(i.filterEffect)}}postrender(){const t=this._usedEffects;for(let e=0;e>>24&255)/255,y=(b>>>24&255)/255,w=(o=(n=m.filter)==null?void 0:n.alphaMultiplier)!=null?o:1,E=S*y*w;if(E<=0)return;const A=v&16777215,P=b&16777215,C=ye(be(P,A)),O=m._roundPixels|e._roundPixels;_.save(),g.setContextTransform(x,O===1),g.setBlendMode(e.groupBlendMode);const F=e.context.instructions;for(let R=0;R{if(!r.name)throw new Error("BlendMode extension must have a name property");ti[r.name]=r.ref},r=>{delete ti[r.name]});class Qn{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,s){this._blendModeStack.push(e),this.setBlendMode(t,e,s)}popBlendMode(t){var e;this._blendModeStack.pop();const s=(e=this._blendModeStack[this._activeBlendMode.length-1])!=null?e:"normal";this.setBlendMode(null,s,t)}setBlendMode(t,e,s){var i;const n=t instanceof wi;if(this._activeBlendMode===e){this._isAdvanced&&t&&!n&&((i=this._renderableList)==null||i.push(t));return}this._isAdvanced&&this._endAdvancedBlendMode(s),this._activeBlendMode=e,t&&(this._isAdvanced=!!ti[e],this._isAdvanced&&this._beginAdvancedBlendMode(t,s))}_beginAdvancedBlendMode(t,e){this._renderer.renderPipes.batch.break(e);const s=this._activeBlendMode;if(!ti[s])return;const i=this._ensureFilterEffect(s),n=t instanceof wi,o={renderPipeId:"filter",action:"pushFilter",filterEffect:i,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 ms,e.filters=[new ti[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}}Qn.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"blendMode"};function Jn(r,t){t||(t=0);for(let e=t;e1?1:e,r.worldAlpha=e,r.worldColorAlpha=r.worldColor+((e*255|0)<<24)}function sh(r,t,e){if(t===r.updateTick)return;r.updateTick=t,r.didChange=!1;const s=r.localTransform;r.updateLocalTransform();const i=r.parent;if(i&&!i.renderGroup?(e|=r._updateFlags,r.relativeGroupTransform.appendFrom(s,i.relativeGroupTransform),e&$b&&kb(r,i,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(s),e&$b&&kb(r,qO,e)),!r.renderGroup){const n=r.children,o=n.length;for(let u=0;u1?1:s,r.groupAlpha=s,r.groupColorAlpha=r.groupColor+((s*255|0)<<24)}e&Ai&&(r.groupBlendMode=r.localBlendMode==="inherit"?t.groupBlendMode:r.localBlendMode),e&Pr&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function Lb(r,t){const{list:e}=r.childrenRenderablesToUpdate;let s=!1;for(let i=0;i=0;n--)this._updateCachedRenderGroups(t.renderGroupChildren[n],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const n=t.root.getLocalBounds(),o=this._renderer,a=t.textureOptions.resolution||o.view.resolution,l=(s=t.textureOptions.antialias)!=null?s:o.view.antialias,u=(i=t.textureOptions.scaleMode)!=null?i:"linear",h=t.texture;n.ceil(),t.texture&&ft.returnTexture(t.texture);const c=ft.getOptimalTexture({width:n.width,height:n.height,resolution:a,antialias:l,scaleMode:u});t.texture=c,t._textureBounds||(t._textureBounds=new Ct),t._textureBounds.copyFrom(n),h!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(ft.returnTexture(t.texture),t.texture=null)}_updateRenderGroups(t){const e=this._renderer,s=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=s,t.structureDidChange?Jn(t.childrenRenderablesToUpdate.list,0):Lb(t,s),rh(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 i=0;it in r?QO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xb=(r,t)=>{for(var e in t||(t={}))JO.call(t,e)&&jb(r,e,t[e]);if(Nb)for(var e of Nb(t))t3.call(t,e)&&jb(r,e,t[e]);return r};const nh=class mS{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new tt(0),this.color=this._backgroundColor,this.alpha=1}init(t){t=Xb(Xb({},mS.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(){}};nh.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"background",priority:0},nh.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let Hb=nh;var e3=Object.defineProperty,zb=Object.getOwnPropertySymbols,r3=Object.prototype.hasOwnProperty,s3=Object.prototype.propertyIsEnumerable,Wb=(r,t,e)=>t in r?e3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,oh=(r,t)=>{for(var e in t||(t={}))r3.call(t,e)&&Wb(r,e,t[e]);if(zb)for(var e of zb(t))s3.call(t,e)&&Wb(r,e,t[e]);return r};const ah={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},lh=class gS{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof dt||t instanceof B?oh({target:t},e):oh(oh({},e),t)}async image(t){const e=X.get().createImage();return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,gS.defaultImageOptions);const{format:e,quality:s}=t,i=this.canvas(t);if(i.toBlob!==void 0)return new Promise((n,o)=>{i.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)},ah[e],s)});if(i.toDataURL!==void 0)return i.toDataURL(ah[e],s);if(i.convertToBlob!==void 0){const n=await i.convertToBlob({type:ah[e],quality:s});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,s=this._renderer;if(e instanceof B)return s.texture.generateCanvas(e);const i=s.textureGenerator.generateTexture(t),n=s.texture.generateCanvas(i);return i.destroy(!0),n}pixels(t){t=this._normalizeOptions(t);const e=t.target,s=this._renderer,i=e instanceof B?e:s.textureGenerator.generateTexture(t),n=s.texture.getPixels(i);return e instanceof dt&&i.destroy(!0),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof B?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){var e;t=this._normalizeOptions(t);const s=this.canvas(t),i=document.createElement("a");i.download=(e=t.filename)!=null?e:"image.png",i.href=s.toDataURL("image/png"),document.body.appendChild(i),i.click(),document.body.removeChild(i)}log(t){var e;const s=(e=t.width)!=null?e:200;t=this._normalizeOptions(t);const i=this.canvas(t),n=i.toDataURL();console.log(`[Pixi Texture] ${i.width}px ${i.height}px`);const o=["font-size: 1px;",`padding: ${s}px 300px;`,`background: url(${n}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",o)}destroy(){this._renderer=null}};lh.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"extract"},lh.defaultImageOptions={format:"png",quality:1};let Vb=lh;var i3=Object.defineProperty,n3=Object.defineProperties,o3=Object.getOwnPropertyDescriptors,to=Object.getOwnPropertySymbols,Yb=Object.prototype.hasOwnProperty,Kb=Object.prototype.propertyIsEnumerable,qb=(r,t,e)=>t in r?i3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,a3=(r,t)=>{for(var e in t||(t={}))Yb.call(t,e)&&qb(r,e,t[e]);if(to)for(var e of to(t))Kb.call(t,e)&&qb(r,e,t[e]);return r},l3=(r,t)=>n3(r,o3(t)),u3=(r,t)=>{var e={};for(var s in r)Yb.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&to)for(var s of to(r))t.indexOf(s)<0&&Kb.call(r,s)&&(e[s]=r[s]);return e};class $o extends B{static create(t){const e=t,{dynamic:s,textureOptions:i}=e,n=u3(e,["dynamic","textureOptions"]);return new $o(l3(a3({},i),{source:new ct(n),dynamic:s!=null?s:!1}))}resize(t,e,s){return this.source.resize(t,e,s),this}}var h3=Object.defineProperty,c3=Object.defineProperties,d3=Object.getOwnPropertyDescriptors,Zb=Object.getOwnPropertySymbols,p3=Object.prototype.hasOwnProperty,f3=Object.prototype.propertyIsEnumerable,Qb=(r,t,e)=>t in r?h3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,m3=(r,t)=>{for(var e in t||(t={}))p3.call(t,e)&&Qb(r,e,t[e]);if(Zb)for(var e of Zb(t))f3.call(t,e)&&Qb(r,e,t[e]);return r},g3=(r,t)=>c3(r,d3(t));const _3=new it,x3=new Ct,v3=[0,0,0,0];class uh{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof dt&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const s=t.resolution||this._renderer.resolution,i=t.antialias||this._renderer.view.antialias,n=t.target;let o=t.clearColor;o?o=Array.isArray(o)&&o.length===4?o:tt.shared.setValue(o).toArray():o=v3;const a=((e=t.frame)==null?void 0:e.copyTo(_3))||bi(n,x3).rectangle,l=t.defaultAnchor&&{defaultAnchor:t.defaultAnchor};a.width=Math.max(a.width,1/s)|0,a.height=Math.max(a.height,1/s)|0;const u=$o.create(g3(m3({},t.textureSourceOptions),{width:a.width,height:a.height,resolution:s,antialias:i,textureOptions:l})),h=D.shared.translate(-a.x,-a.y);return this._renderer.render({container:n,transform:h,target:u,clearColor:o}),u.source.updateMipmaps(),u}destroy(){this._renderer=null}}uh.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"textureGenerator"};function Jb(r){let t=!1;for(const s in r)if(r[s]==null){t=!0;break}if(!t)return r;const e=Object.create(null);for(const s in r){const i=r[s];i&&(e[s]=i)}return e}function ty(r){let t=0;for(let e=0;et in r?b3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,sy=(r,t)=>{for(var e in t||(t={}))y3.call(t,e)&&ry(r,e,t[e]);if(ey)for(var e of ey(t))T3.call(t,e)&&ry(r,e,t[e]);return r};const hh=class _S{constructor(t){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._running=!1,this._renderer=t}init(t){t=sy(sy({},_S.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._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedCollections){const{context:s,collection:i,type:n}=e;n==="hash"?s[i]=Jb(s[i]):s[i]=ty(s[i])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=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,t.gcTick=e;for(const s of t.renderGroupChildren)this._updateInstructionGCTick(s,e)}addCollection(t,e,s){this._managedCollections.push({context:t,collection:e,type:s})}addResource(t,e){var s,i;if(t._gcLastUsed!==-1){t._gcLastUsed=this.now,(s=t._onTouch)==null||s.call(t,this.now);return}const n=this._managedResources.length;t._gcData={index:n,type:e},t._gcLastUsed=this.now,(i=t._onTouch)==null||i.call(t,this.now),t.once("unload",this.removeResource,this),this._managedResources.push(t)}removeResource(t){const e=t._gcData;if(!e)return;const s=e.index,i=this._managedResources.length-1;if(this._running)this._managedResources[s]=null;else{if(s!==i){const n=this._managedResources[i];this._managedResources[s]=n,n._gcData.index=s}this._managedResources.length--}t._gcData=null,t._gcLastUsed=-1}addResourceHash(t,e,s,i=0){this._managedResourceHashes.push({context:t,hash:e,type:s,priority:i}),this._managedResourceHashes.sort((n,o)=>n.priority-o.priority)}run(){if(this._running)return;const t=performance.now(),e=this._managedResourceHashes,s=this._managedResources;this._running=!0;try{for(const n of e)this.runOnHash(n,t);const i=s.length;for(let n=0;n{t==null||t.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};hh.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"gc",priority:0},hh.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let iy=hh;class ch{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"},uWorldTransformMatrix:{value:new D,type:"mat3x3"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4"},uResolution:{value:[0,0],type:"vec2"}},{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}}ch.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"globalUniforms"};let S3=1;class dh{constructor(){this._tasks=[],this._offset=0}init(){Rt.system.add(this._update,this)}repeat(t,e,s=!0){const i=S3++;let n=0;return s&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:i}),i}cancel(t){for(let e=0;e=s.duration){const i=t-s.start;s.func(i),s.last=t}}}destroy(){Rt.system.remove(this._update,this),this._tasks.length=0}}dh.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"scheduler",priority:0};let ny=!1;function oy(r){if(!ny){if(X.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${Bs} (${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 ${Bs} - ${r} - http://www.pixijs.com/`);ny=!0}}class eo{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===Mt.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),oy(e)}}}eo.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"hello",priority:-2},eo.defaultOptions={hello:!1};var w3=Object.defineProperty,ay=Object.getOwnPropertySymbols,E3=Object.prototype.hasOwnProperty,A3=Object.prototype.propertyIsEnumerable,ly=(r,t,e)=>t in r?w3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,uy=(r,t)=>{for(var e in t||(t={}))E3.call(t,e)&&ly(r,e,t[e]);if(ay)for(var e of ay(t))A3.call(t,e)&&ly(r,e,t[e]);return r};const ph=class xS{constructor(t){this._renderer=t}init(t){t=uy(uy({},xS.defaultOptions),t),this.maxUnusedTime=t.renderableGCMaxUnusedTime}get enabled(){return this._renderer.gc.enabled}set enabled(t){this._renderer.gc.enabled=t}addManagedHash(t,e){this._renderer.gc.addCollection(t,e,"hash")}addManagedArray(t,e){this._renderer.gc.addCollection(t,e,"array")}addRenderable(t){this._renderer.gc.addResource(t,"renderable")}run(){this._renderer.gc.run()}destroy(){this._renderer=null}};ph.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"renderableGC",priority:0},ph.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let hy=ph;const fh=class Ro{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!==Ro.defaultOptions.textureGCActive&&(this.active=t.textureGCActive),t.textureGCMaxIdle!==Ro.defaultOptions.textureGCMaxIdle&&(this.maxIdle=t.textureGCMaxIdle),t.textureGCCheckCountMax!==Ro.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=t.textureGCCheckCountMax)}run(){this._renderer.gc.run()}destroy(){this._renderer=null}};fh.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"textureGC"},fh.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let cy=fh;var P3=Object.defineProperty,dy=Object.getOwnPropertySymbols,C3=Object.prototype.hasOwnProperty,R3=Object.prototype.propertyIsEnumerable,py=(r,t,e)=>t in r?P3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fy=(r,t)=>{for(var e in t||(t={}))C3.call(t,e)&&py(r,e,t[e]);if(dy)for(var e of dy(t))R3.call(t,e)&&py(r,e,t[e]);return r};const my=class vS extends It{constructor(t={}){var e;super(),this.uid=ut("renderTarget"),this.colorAttachments=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,this._depth=!1,this._stencil=!1,this._colorTextures=null;const s="colorAttachments"in t?t:this._normalizeOptions(t);if(this.isRoot=(e=s.isRoot)!=null?e:!1,this.label=s.label,this.colorAttachments=s.colorAttachments,this.depthStencilAttachment=s.depthStencilAttachment,this.depthStencilAttachment){const i=this.depthStencilAttachment.texture.format;this._depth||(this._depth=i.includes("depth")),this._stencil||(this._stencil=i.includes("stencil"))}if(this.colorAttachments.length===0&&!this.depthStencilAttachment)throw new Error("[RenderTarget] no color textures or depth textures were provided. Provide a depthStencilTexture or set depth/stencil to true when using colorTextures: 0.");if(this.colorAttachments.length>0){const i=this.colorTexture;this.resize(i.width,i.height,i._resolution)}this.sizeSource&&this.sizeSource.on("resize",this.onSourceResize,this)}_normalizeOptions(t){const e=fy(fy({},vS.defaultOptions),t),s=[];let i;if(typeof e.colorTextures=="number"){if(e.colorTextures>0){this._managedColorTextures=!0;for(let o=0;o{s.push({texture:o.source,loadOp:"clear",storeOp:"store"})});const n=e.depthStencilTexture===!0;if(this._depth=!!(e.depth||n),this._stencil=!!(e.stencil||n),e.depthStencilTexture instanceof B||e.depthStencilTexture instanceof ct){if(e.isRoot)throw new Error("[RenderTarget] cannot attach a depth-stencil texture to the screen \u2014 the canvas owns its own depth/stencil buffers. Render to a texture target instead.");i={texture:e.depthStencilTexture.source}}else(n&&!e.isRoot||(e.stencil||e.depth)&&s.length===0)&&(i=this._createDepthStencilTexture(e.width,e.height,e.resolution));return{colorAttachments:s,depthStencilAttachment:i,isRoot:e.isRoot,label:e.label}}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.sizeSource.width}get height(){return this.sizeSource.height}get pixelWidth(){return this.sizeSource.pixelWidth}get pixelHeight(){return this.sizeSource.pixelHeight}get resolution(){return this.sizeSource._resolution}get colorTextures(){return this._colorTextures||(this._colorTextures=this.colorAttachments.map(t=>t.texture)),this._colorTextures}get depthStencilTexture(){var t,e;return(e=(t=this.depthStencilAttachment)==null?void 0:t.texture)!=null?e:null}get depth(){return this._depth}get stencil(){return this._stencil}get colorTexture(){var t;return(t=this.colorAttachments[0])==null?void 0:t.texture}get sizeSource(){var t,e,s;return(s=(t=this.colorAttachments[0])==null?void 0:t.texture)!=null?s:(e=this.depthStencilAttachment)==null?void 0:e.texture}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this._createDepthStencilTexture(this.sizeSource.width,this.sizeSource.height,this.sizeSource._resolution),this._depth=!0,this._stencil=!0}resize(t,e,s=this.resolution,i=!1){if(this.dirtyId++,this.colorAttachments.forEach((n,o)=>{i&&o===0||n.texture.resize(t,e,s)}),this.depthStencilAttachment){if(i&&this.colorAttachments.length===0)return;this.depthStencilAttachment.texture.resize(t,e,s)}}destroy(){!this.colorAttachments&&!this.depthStencilAttachment||(this.emit("destroy",this),this.sizeSource.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorAttachments.forEach(t=>{t.texture.destroy()}),this.depthStencilAttachment&&(this.depthStencilAttachment.texture.destroy(),delete this.depthStencilAttachment),this.colorAttachments=null,this._colorTextures=null,this.removeAllListeners())}_createDepthStencilTexture(t,e,s){var i;return(i=this.depthStencilAttachment)!=null||(this.depthStencilAttachment={texture:new ct({width:t,height:e,resolution:s,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1})}),this.depthStencilAttachment}};my.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let ei=my;var M3=Object.defineProperty,gy=Object.getOwnPropertySymbols,O3=Object.prototype.hasOwnProperty,G3=Object.prototype.propertyIsEnumerable,_y=(r,t,e)=>t in r?M3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,I3=(r,t)=>{for(var e in t||(t={}))O3.call(t,e)&&_y(r,e,t[e]);if(gy)for(var e of gy(t))G3.call(t,e)&&_y(r,e,t[e]);return r};const vr=new Map;tr.register(vr);function mh(r,t){if(!vr.has(r)){const e=new B({source:new re(I3({resource:r},t))}),s=()=>{vr.get(r)===e&&vr.delete(r)};e.once("destroy",s),e.source.once("destroy",s),vr.set(r,e)}return vr.get(r)}function F3(r){return vr.has(r)}var B3=Object.defineProperty,xy=Object.getOwnPropertySymbols,D3=Object.prototype.hasOwnProperty,$3=Object.prototype.propertyIsEnumerable,vy=(r,t,e)=>t in r?B3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,by=(r,t)=>{for(var e in t||(t={}))D3.call(t,e)&&vy(r,e,t[e]);if(xy)for(var e of xy(t))$3.call(t,e)&&vy(r,e,t[e]);return r};const gh=class bS{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)}constructor(t){this._renderer=t}init(t){t=by(by({},bS.defaultOptions),t),t.view&&(t.canvas=t.view),this.screen=new it(0,0,t.width,t.height),this.canvas=t.canvas||X.get().createCanvas(),this.antialias=!!t.antialias,this.texture=mh(this.canvas,t),this.renderTarget=new ei({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.texture.source.on("resize",this._updateScreenSize,this),this.resolution=t.resolution,this._updateScreenSize()}resize(t,e,s){this.texture.source.resize(t,e,s),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.source.off("resize",this._updateScreenSize,this),ft.removeScreen(this._renderer.uid),se.removeScreen(this._renderer.uid),this.texture.destroy()}_updateScreenSize(){const{pixelWidth:t,pixelHeight:e}=this.texture.source,s=this._renderer.uid;ft.setScreenSize(s,t,e),se.setScreenSize(s,t,e)}};gh.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"view",priority:0},gh.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let yy=gh;const ro=[Hb,ch,eo,yy,ih,iy,cy,uh,Vb,Ja,hy,dh],_h=[Qn,Hn,Zn,Yn,zn,Zu,Ku,Wn];function Ty(r,t,e,s,i,n){const o=n?1:-1;return r.identity(),r.a=1/s*2,r.d=o*(1/i*2),r.tx=-1-t*r.a,r.ty=-o-e*r.d,r}function Sy(r){if(r.colorAttachments.length===0)return!1;const t=r.colorTexture.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}class so{constructor(t){this.rootViewPort=new it,this.viewport=new it,this.onRenderTargetChange=new Ka("onRenderTargetChange"),this.projectionMatrix=new D,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._bindState={target:null,frame:void 0,mipLevel:0,layer:0,flipY:!1},this._bindFrame=new it,this._renderer=t,t.gc.addCollection(this,"_gpuRenderTargetHash","hash")}get renderSurface(){return this._bindState.target}get mipLevel(){return this._bindState.mipLevel}get layer(){return this._bindState.layer}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart(t){var e,s;this._renderTargetStack.length=0,this.push(t),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=Sy(this.rootRenderTarget),(s=(e=this.adaptor).prerender)==null||s.call(e,this.rootRenderTarget)}postrender(){var t,e;(e=(t=this.adaptor).postrender)==null||e.call(t,this.rootRenderTarget)}bind(t,e=!0,s,i,n=0,o=0,a){var l,u,h,c,d;let p;"target"in t?p=t:p={target:t,clear:e,clearColor:s,frame:i,mipLevel:n,layer:o,flipY:a};const f=p.target;e=(l=p.clear)!=null?l:!0,s=p.clearColor,n=((u=p.mipLevel)!=null?u:0)|0,o=((h=p.layer)!=null?h:0)|0,a=p.flipY,i=p.frame;const m=this.getRenderTarget(f),g=this.renderTarget!==m||!!m.flipY!=!!a;this.renderTarget=m;const _=this.getGpuRenderTarget(m);(m.pixelWidth!==_.width||m.pixelHeight!==_.height)&&(this.adaptor.resizeGpuRenderTarget(m),_.width=m.pixelWidth,_.height=m.pixelHeight);const x=((c=m.colorAttachments[0])==null?void 0:c.texture)||((d=m.depthStencilAttachment)==null?void 0:d.texture),v=this.viewport,b=x.arrayLayerCount||1;if(o<0||o>=b)throw new Error(`[RenderTargetSystem] layer ${o} is out of bounds (arrayLayerCount=${b}).`);const S=this._bindState;S.target=f,S.frame=i?this._bindFrame.copyFrom(i):void 0,S.mipLevel=n,S.layer=o,S.flipY=a;const y=Math.max(x.pixelWidth>>n,1),w=Math.max(x.pixelHeight>>n,1);if(!i&&f instanceof B&&(i=f.frame),i){const E=x._resolution,A=1<{t!==e?this._releaseRenderTarget(e,t):t.off("destroy",this._onRenderTargetDestroy,this)}),this._renderSurfaceToRenderTargetHash.clear();for(const t of Object.values(this._gpuRenderTargetHash))t&&this.adaptor.destroyGpuRenderTarget(t);this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;if(re.test(t)&&(t=mh(t).source),t instanceof ei)e=t,t.once("destroy",this._onRenderTargetDestroy,this);else if(t instanceof ct){const s=t.format;e=s.includes("depth")||s.includes("stencil")?new ei({colorTextures:0,depthStencilTexture:t}):new ei({colorTextures:[t]}),t.source instanceof re&&(e.isRoot=!0),t.once("destroy",this._onRenderSurfaceDestroy,this)}return this._renderSurfaceToRenderTargetHash.set(t,e),e}_onRenderSurfaceDestroy(t){const e=this._renderSurfaceToRenderTargetHash.get(t);e&&this._releaseRenderTarget(t,e)}_onRenderTargetDestroy(t){this._renderSurfaceToRenderTargetHash.delete(t),this._releaseGpuRenderTarget(t)}_releaseRenderTarget(t,e){e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t),t.off("destroy",this._onRenderSurfaceDestroy,this),this._releaseGpuRenderTarget(e)}_releaseGpuRenderTarget(t){const e=this._gpuRenderTargetHash[t.uid];e&&(this._gpuRenderTargetHash[t.uid]=null,this.adaptor.destroyGpuRenderTarget(e))}getGpuRenderTarget(t){return this._gpuRenderTargetHash[t.uid]||(this._gpuRenderTargetHash[t.uid]=this.adaptor.initGpuRenderTarget(t))}resetState(){this.renderTarget=null,this._bindState.target=null}}class wy{init(t,e){this._renderer=t,this._renderTargetSystem=e}initGpuRenderTarget(t){const e=t.colorTexture,{canvas:s,context:i}=this._ensureCanvas(e);return{canvas:s,context:i,width:s.width,height:s.height}}resizeGpuRenderTarget(t){const e=t.colorTexture,{canvas:s}=this._ensureCanvas(e);s.width=t.pixelWidth,s.height=t.pixelHeight}startRenderPass(t,e,s,i){const n=this._renderTargetSystem.getGpuRenderTarget(t);this._renderer.canvasContext.activeContext=n.context,this._renderer.canvasContext.activeResolution=t.resolution,e&&this.clear(t,e,s,i)}clear(t,e,s,i){const n=this._renderTargetSystem.getGpuRenderTarget(t).context,o=i||{x:0,y:0,width:t.pixelWidth,height:t.pixelHeight};if(n.setTransform(1,0,0,1,0,0),n.clearRect(o.x,o.y,o.width,o.height),s){const a=tt.shared.setValue(s);a.alpha>0&&(n.globalAlpha=a.alpha,n.fillStyle=a.toHex(),n.fillRect(o.x,o.y,o.width,o.height),n.globalAlpha=1)}}finishRenderPass(){}copyToTexture(t,e,s,i,n){var o,a;const l=this._renderTargetSystem.getGpuRenderTarget(t).canvas,u=e.source,{context:h}=this._ensureCanvas(u),c=(o=n==null?void 0:n.x)!=null?o:0,d=(a=n==null?void 0:n.y)!=null?a:0;return h.drawImage(l,s.x,s.y,i.width,i.height,c,d,i.width,i.height),u.update(),e}copyDepthTexture(t,e,s,i,n){Bt("[CanvasRenderTargetAdaptor] copyDepthTexture is not supported in the canvas renderer")}destroyGpuRenderTarget(t){}_ensureCanvas(t){let e=t.resource;(!e||!re.test(e))&&(e=X.get().createCanvas(t.pixelWidth,t.pixelHeight),t.resource=e),(e.width!==t.pixelWidth||e.height!==t.pixelHeight)&&(e.width=t.pixelWidth,e.height=t.pixelHeight);const s=e.getContext("2d");return{canvas:e,context:s}}}class xh extends so{constructor(t){super(t),this.adaptor=new wy,this.adaptor.init(t,this)}}xh.extension={type:[T.CanvasSystem],name:"renderTarget"};class vh{constructor(t){}init(){}initSource(t){}generateCanvas(t){var e,s;const i=X.get().createCanvas(),n=i.getContext("2d"),o=Z.getCanvasSource(t);if(!o)return i;const a=t.frame,l=(s=(e=t.source._resolution)!=null?e:t.source.resolution)!=null?s:1,u=a.x*l,h=a.y*l,c=a.width*l,d=a.height*l;return i.width=Math.ceil(c),i.height=Math.ceil(d),n.drawImage(o,u,h,c,d,0,0,c,d),i}getPixels(t){const e=this.generateCanvas(t);return{pixels:e.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,e.width,e.height).data,width:e.width,height:e.height}}destroy(){}}vh.extension={type:[T.CanvasSystem],name:"texture"};const U3=[...ro,Qu,Ju,vh,xh],k3=[Qn,Hn,Zn,Yn,zn,qu,Yu,Wn],L3=[Gb,eh],Ey=[],Ay=[],Py=[],Cy=[];L.handleByNamedList(T.CanvasSystem,Ey),L.handleByNamedList(T.CanvasPipes,Ay),L.handleByNamedList(T.CanvasPipesAdaptor,Py),L.handleByNamedList(T.CanvasLoader,Cy),L.add(...U3,...k3,...L3);class Ry extends Gr{constructor(){const t={name:"canvas",type:Mt.CANVAS,systems:Ey,renderPipes:Ay,renderPipeAdaptors:Py,loaders:Cy};super(t)}}var N3={__proto__:null,CanvasRenderer:Ry},ri=(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))(ri||{});class My{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 bh{constructor(t){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._managedBuffers=new kt({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,s=this.getGlBuffer(t);e.bindBuffer(s.type,s.buffer)}bindBufferBase(t,e){const{_gl:s}=this;this._boundBufferBases[e]!==t&&(this._boundBufferBases[e]=t,t._lastBindBaseLocation=e,s.bindBufferBase(s.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 s=0,i=this._nextBindBaseIndex;for(;s<2;){i>=this._maxBindings&&(i=this._minBaseLocation,s++);const n=this._boundBufferBases[i];if(n&&n._lastBindCallId===this._bindCallId){i++;continue}break}return e=i,this._nextBindBaseIndex=i+1,s>=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,s,i){const{_gl:n}=this;s||(s=0),e||(e=0),this._boundBufferBases[e]=null,n.bindBufferRange(n.UNIFORM_BUFFER,e||0,t.buffer,s*256,i||256)}updateBuffer(t){const{_gl:e}=this,s=this.getGlBuffer(t);if(t._updateID===s.updateID)return s;s.updateID=t._updateID,e.bindBuffer(s.type,s.buffer);const i=t.data,n=t.descriptor.usage&st.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return i?s.byteLength>=i.byteLength?e.bufferSubData(s.type,t._updateOffset,i,t._updateOffset/i.BYTES_PER_ELEMENT,(t._updateSize||i.byteLength)/i.BYTES_PER_ELEMENT):(s.byteLength=i.byteLength,e.bufferData(s.type,i,n)):(s.byteLength=t.descriptor.size,e.bufferData(s.type,s.byteLength,n)),s}destroyAll(t=!1){this._managedBuffers.removeAll(t)}onBufferUnload(t,e=!1){const s=t._gpuData[this._renderer.uid];s&&(e||this._gl.deleteBuffer(s.buffer))}createGLBuffer(t){const{_gl:e}=this;let s=ri.ARRAY_BUFFER;t.descriptor.usage&st.INDEX?s=ri.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&st.UNIFORM&&(s=ri.UNIFORM_BUFFER);const i=new My(e.createBuffer(),s);return t._gpuData[this._renderer.uid]=i,this._managedBuffers.add(t),i}resetState(){this._boundBufferBases=Object.create(null)}}bh.extension={type:[T.WebGLSystem],name:"buffer"};var j3=Object.defineProperty,X3=Object.defineProperties,H3=Object.getOwnPropertyDescriptors,Oy=Object.getOwnPropertySymbols,z3=Object.prototype.hasOwnProperty,W3=Object.prototype.propertyIsEnumerable,Gy=(r,t,e)=>t in r?j3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,io=(r,t)=>{for(var e in t||(t={}))z3.call(t,e)&&Gy(r,e,t[e]);if(Oy)for(var e of Oy(t))W3.call(t,e)&&Gy(r,e,t[e]);return r},Iy=(r,t)=>X3(r,H3(t));const yh=class yS{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,s;t=io(io({},yS.defaultOptions),t);let i=this.multiView=t.multiView;if(t.context&&i&&(Bt("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),i=!1),i?this.canvas=X.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:(s=t.powerPreference)!=null?s:"default"})}}ensureCanvasSize(t){if(!this.multiView){t!==this.canvas&&Bt("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:e}=this;(e.width{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 s=this.supports,i=this.webGLVersion===2,n=this.extensions;s.uint32Indices=i||!!n.uint32ElementIndex,s.uniformBufferObject=i,s.vertexArrayObject=i||!!n.vertexArrayObject,s.srgbTextures=i||!!n.srgb,s.nonPowOf2wrapping=i,s.nonPowOf2mipmaps=i,s.msaa=i,s.uint32Indices}};yh.extension={type:[T.WebGLSystem],name:"context"},yh.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let Fy=yh;function no(r,t){var e,s,i;for(const n in r.attributes){const o=r.attributes[n],a=t[n];a?((e=o.format)!=null||(o.format=a.format),(s=o.offset)!=null||(o.offset=a.offset),(i=o.instance)!=null||(o.instance=a.instance)):Bt(`Attribute ${n} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}V3(r)}function V3(r){var t,e;const{buffers:s,attributes:i}=r,n={},o={};for(const a in s){const l=s[a];n[l.uid]=0,o[l.uid]=0}for(const a in i){const l=i[a];n[l.buffer.uid]+=Be(l.format).stride}for(const a in i){const l=i[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]+=Be(l.format).stride}}var oo=(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))(oo||{}),ao=(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))(ao||{}),By=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(By||{}),at=(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))(at||{});const Dy={uint8x2:at.UNSIGNED_BYTE,uint8x4:at.UNSIGNED_BYTE,sint8x2:at.BYTE,sint8x4:at.BYTE,unorm8x2:at.UNSIGNED_BYTE,unorm8x4:at.UNSIGNED_BYTE,snorm8x2:at.BYTE,snorm8x4:at.BYTE,uint16x2:at.UNSIGNED_SHORT,uint16x4:at.UNSIGNED_SHORT,sint16x2:at.SHORT,sint16x4:at.SHORT,unorm16x2:at.UNSIGNED_SHORT,unorm16x4:at.UNSIGNED_SHORT,snorm16x2:at.SHORT,snorm16x4:at.SHORT,float16x2:at.HALF_FLOAT,float16x4:at.HALF_FLOAT,float32:at.FLOAT,float32x2:at.FLOAT,float32x3:at.FLOAT,float32x4:at.FLOAT,uint32:at.UNSIGNED_INT,uint32x2:at.UNSIGNED_INT,uint32x3:at.UNSIGNED_INT,uint32x4:at.UNSIGNED_INT,sint32:at.INT,sint32x2:at.INT,sint32x3:at.INT,sint32x4:at.INT};function $y(r){var t;return(t=Dy[r])!=null?t:Dy.float32}const Y3={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class Uy{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class Th{constructor(t){this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new kt({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=i=>e.bindVertexArrayOES(i),t.deleteVertexArray=i=>e.deleteVertexArrayOES(i));const s=this._renderer.context.extensions.vertexAttribDivisorANGLE;s&&(t.drawArraysInstanced=(i,n,o,a)=>{s.drawArraysInstancedANGLE(i,n,o,a)},t.drawElementsInstanced=(i,n,o,a,l)=>{s.drawElementsInstancedANGLE(i,n,o,a,l)},t.vertexAttribDivisor=(i,n)=>s.vertexAttribDivisorANGLE(i,n)),this._activeGeometry=null,this._activeVao=null}bind(t,e){const s=this.gl;this._activeGeometry=t;const i=this.getVao(t,e);this._activeVao!==i&&(this._activeVao=i,s.bindVertexArray(i)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let s=0;st in r?K3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ny=(r,t)=>{for(var e in t||(t={}))q3.call(t,e)&&Ly(r,e,t[e]);if(ky)for(var e of ky(t))Z3.call(t,e)&&Ly(r,e,t[e]);return r};const Q3=new hr({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),Sh=class TS{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:s}=Ny(Ny({},TS.defaultOptions),t);this.useBackBuffer=e,this._antialias=s,this._renderer.context.supports.msaa||(Bt("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Kt.for2d();const i=new Yt({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 ne({glProgram:i,resources:{uTexture:B.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const s=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=s.colorTexture,t.target=this._getBackBufferTexture(s.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind({target:this._targetTexture,clear:!1}),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:Q3,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new B({source:new ct({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)}};Sh.extension={type:[T.WebGLSystem],name:"backBuffer",priority:1},Sh.defaultOptions={useBackBuffer:!1};let jy=Sh;class wh{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)))}}wh.extension={type:[T.WebGLSystem],name:"colorMask"};class Eh{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:s,shader:i,state:n,skipSync:o,topology:a,size:l,start:u,instanceCount:h}=t;e.shader.bind(i,o),e.geometry.bind(s,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(a,l,u,h!=null?h:s.instanceCount)}destroy(){this._renderer=null}}Eh.extension={type:[T.WebGLSystem],name:"encoder"};class Ah{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=al(this.maxTextures,t);const e=this._renderer.context.webGLVersion===2;this.maxUniformBindings=e?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}Ah.extension={type:[T.WebGLSystem],name:"limits"};class Xy{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[],this.stencilMode=bt.DISABLED,this.stencilReference=0,this.maskStackIndex=0}}const ke=[];ke[bt.NONE]=void 0,ke[bt.DISABLED]={stencilWriteMask:0,stencilReadMask:0},ke[bt.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},ke[bt.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},ke[bt.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},ke[bt.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class Ph{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:bt.NONE},this._renderer=t,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._activeGpuRenderTarget=null,this.resetState()}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;const e=this._renderer.renderTarget.getGpuRenderTarget(t);this._activeGpuRenderTarget=e,this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=bt.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){var s;const i=(s=this._activeGpuRenderTarget)!=null?s:this._activeGpuRenderTarget=this._renderer.renderTarget.getGpuRenderTarget(this._activeRenderTarget),n=this._gl,o=ke[t],a=this._stencilCache;if(i.stencilMode=t,i.stencilReference=e,t===bt.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,n.disable(n.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,n.enable(n.STENCIL_TEST)),(t!==a.stencilMode||a.stencilReference!==e)&&(a.stencilMode=t,a.stencilReference=e,n.stencilFunc(this._comparisonFuncMapping[o.stencilBack.compare],e,255),n.stencilOp(n.KEEP,n.KEEP,this._stencilOpsMapping[o.stencilBack.passOp]))}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._gl=null,this._activeRenderTarget=null,this._activeGpuRenderTarget=null}}Ph.extension={type:[T.WebGLSystem],name:"stencil"};class Ch{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!za())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 qt({data:new Float32Array(e.layout.size/4),usage:st.UNIFORM|st.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let s=this._syncFunctionHash[e];if(!s){const i=Object.keys(t.uniformStructures).map(a=>t.uniformStructures[a]),n=this._adaptor.createUboElements(i),o=this._generateUboSync(n.uboElements);s=this._syncFunctionHash[e]={layout:n,syncFunction:o}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,s){const i=this.getUniformGroupData(t);t.buffer||(t.buffer=new qt({data:new Float32Array(i.layout.size/4),usage:st.UNIFORM|st.COPY_DST}));let n=null;return e||(e=t.buffer.data,n=t.buffer.dataInt32),s||(s=0),i.syncFunction(t.uniforms,e,n,s),!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 Rh={f32:4,i32:4,"vec2":8,"vec3":12,"vec4":16,"vec2":8,"vec3":12,"vec4":16,u32:4,"vec2":8,"vec3":12,"vec4":16,"mat2x2":32,"mat3x3":48,"mat4x4":64};function Hy(r){const t=r.map(n=>({data:n,offset:0,size:0})),e=16;let s=0,i=0;for(let n=0;n1&&(s=Math.max(s,e)*o.data.size);const a=s===12?16:s;o.size=s;const l=i%e;l>0&&e-l",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",test:r=>r.type==="vec4"&&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",test:r=>r.type==="vec2"&&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",test:r=>r.type==="vec4"&&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",test:r=>r.type==="vec3"&&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 Mh(r,t,e){const s=[` var v = null; var v2 = null; var t = 0; var index = 0; var name = null; var arrayOffset = null; `];let i=0;for(let o=0;o1)h=a.offset/4,s.push(e(a,h-i));else{const c=t[a.data.type];h=a.offset/4,s.push(` v = uv.${l}; offset += ${h-i}; ${c}; `)}i=h}const n=s.join(` `);return new Function("uv","data","dataInt32","offset",n)}var J3=Object.defineProperty,tG=Object.defineProperties,eG=Object.getOwnPropertyDescriptors,zy=Object.getOwnPropertySymbols,rG=Object.prototype.hasOwnProperty,sG=Object.prototype.propertyIsEnumerable,Wy=(r,t,e)=>t in r?J3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,iG=(r,t)=>{for(var e in t||(t={}))rG.call(t,e)&&Wy(r,e,t[e]);if(zy)for(var e of zy(t))sG.call(t,e)&&Wy(r,e,t[e]);return r},nG=(r,t)=>tG(r,eG(t));function ss(r,t){return` for (let i = 0; i < ${r*t}; i++) { data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i]; } `}const Oh={f32:` data[offset] = v;`,i32:` dataInt32[offset] = v;`,u32:` dataInt32[offset] = v;`,"vec2":` data[offset] = v[0]; data[offset + 1] = v[1];`,"vec3":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2];`,"vec4":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2]; data[offset + 3] = v[3];`,"vec2":` dataInt32[offset] = v[0]; dataInt32[offset + 1] = v[1];`,"vec3":` dataInt32[offset] = v[0]; dataInt32[offset + 1] = v[1]; dataInt32[offset + 2] = v[2];`,"vec4":` dataInt32[offset] = v[0]; dataInt32[offset + 1] = v[1]; dataInt32[offset + 2] = v[2]; dataInt32[offset + 3] = v[3];`,"vec2":` dataInt32[offset] = v[0]; dataInt32[offset + 1] = v[1];`,"vec3":` dataInt32[offset] = v[0]; dataInt32[offset + 1] = v[1]; dataInt32[offset + 2] = v[2];`,"vec4":` dataInt32[offset] = v[0]; dataInt32[offset + 1] = v[1]; dataInt32[offset + 2] = v[2]; dataInt32[offset + 3] = v[3];`,"mat2x2":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 4] = v[2]; data[offset + 5] = v[3];`,"mat3x3":` 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":` for (let i = 0; i < 16; i++) { data[offset + i] = v[i]; }`,"mat3x2":ss(3,2),"mat4x2":ss(4,2),"mat2x3":ss(2,3),"mat4x3":ss(4,3),"mat2x4":ss(2,4),"mat3x4":ss(3,4)},Vy=nG(iG({},Oh),{"mat2x2":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2]; data[offset + 3] = v[3]; `});function Yy(r,t){const e=Math.max(Rh[r.data.type]/16,1),s=r.data.value.length/r.data.size,i=(4-s%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 < ${s}; j++) { ${n}[arrayOffset++] = v[t++]; } ${i!==0?`arrayOffset += ${i};`:""} } `}function Ky(r){return Mh(r,Oh,Yy)}class Gh extends Ch{constructor(){super({createUboElements:Hy,generateUboSync:Ky})}}Gh.extension={type:[T.WebGLSystem],name:"ubo"};class qy{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new it,this._boundFramebuffer=void 0}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new it,this._boundFramebuffer=void 0;const t=this._renderer.gl;this._drawBuffersCache=[];for(let e=1;e<=16;e++)this._drawBuffersCache[e]=Array.from({length:e},(s,i)=>t.COLOR_ATTACHMENT0+i)}copyToTexture(t,e,s,i,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),this._boundFramebuffer=l.resolveTargetFramebuffer,a.texture.bind(e,0),u.copyTexSubImage2D(u.TEXTURE_2D,0,n.x,n.y,s.x,s.y,i.width,i.height),e}copyDepthTexture(t,e,s,i,n){const o=this._renderTargetSystem,a=this._renderer.gl;this.finishRenderPass(t);const l=o.getRenderTarget(e),u=o.getGpuRenderTarget(t),h=o.getGpuRenderTarget(l);a.bindFramebuffer(a.READ_FRAMEBUFFER,u.framebuffer),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,h.framebuffer),this._boundFramebuffer=void 0,a.blitFramebuffer(s.x,s.y,s.x+i.width,s.y+i.height,n.x,n.y,n.x+i.width,n.y+i.height,a.DEPTH_BUFFER_BIT,a.NEAREST)}startRenderPass(t,e=!0,s,i,n=0,o=0){const a=this._renderTargetSystem.getGpuRenderTarget(t);if(o!==0&&this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to array layers requires WebGL2.");if(n>0){if(a.msaa)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to mip levels requires WebGL2.")}t.colorAttachments.forEach(c=>{this._renderer.texture.unbind(c.texture)});const l=this._renderer.gl;this.bindFramebuffer(a.framebuffer),!t.isRoot&&t.colorAttachments.length>0&&(a._attachedMipLevel!==n||a._attachedLayer!==o)&&(t.colorAttachments.forEach((c,d)=>{const p=c.texture,f=this._renderer.texture.getGlSource(p);if(f.target===l.TEXTURE_2D){if(o!==0)throw new Error("[RenderTargetSystem] layer must be 0 when rendering to 2D textures in WebGL.");l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0+d,l.TEXTURE_2D,f.texture,n)}else if(f.target===l.TEXTURE_2D_ARRAY){if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to 2D array textures requires WebGL2.");l.framebufferTextureLayer(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0+d,f.texture,n,o)}else if(f.target===l.TEXTURE_CUBE_MAP){if(o<0||o>5)throw new Error("[RenderTargetSystem] Cube map layer must be between 0 and 5.");l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0+d,l.TEXTURE_CUBE_MAP_POSITIVE_X+o,f.texture,n)}else throw new Error("[RenderTargetSystem] Unsupported texture target for render-to-layer in WebGL.")}),a._attachedMipLevel=n,a._attachedLayer=o),a.framebuffer&&(t.depthStencilAttachment?this._attachDepthStencilTexture(t,n,o):!a.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(a)),t.colorAttachments.length>1&&this._setDrawBuffers(t,l);let u=i.y;t.isRoot&&(u=t.pixelHeight-i.height-i.y);const h=this._viewPortCache;(h.x!==i.x||h.y!==u||h.width!==i.width||h.height!==i.height)&&(h.x=i.x,h.y=u,h.width=i.width,h.height=i.height,l.viewport(i.x,u,i.width,i.height)),this.clear(t,e,s)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa||t.colorAttachments.length===0)return;const s=this._renderer.gl;s.bindFramebuffer(s.FRAMEBUFFER,e.resolveTargetFramebuffer),s.bindFramebuffer(s.READ_FRAMEBUFFER,e.framebuffer),s.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,s.COLOR_BUFFER_BIT,s.NEAREST),s.bindFramebuffer(s.FRAMEBUFFER,e.framebuffer),this._boundFramebuffer=e.framebuffer}initGpuRenderTarget(t){const e=this._renderer.gl,s=new Xy;s._attachedMipLevel=0,s._attachedLayer=0;const i=t.colorTexture;return i instanceof re?(this._renderer.context.ensureCanvasSize(i.resource),s.framebuffer=null,s):(s.width=t.pixelWidth,s.height=t.pixelHeight,t.colorAttachments.length===0?this._initDepth(t,s):this._initColor(t,s),t.depthStencilAttachment&&this._attachDepthStencilTexture(t,0,0),e.bindFramebuffer(e.FRAMEBUFFER,null),this._boundFramebuffer=null,s)}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(s=>{e.deleteRenderbuffer(s)}),t.msaaRenderBuffer.length=0}clear(t,e,s,i,n=0,o=0){if(!e)return;if(o!==0)throw new Error("[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.");const a=this._renderTargetSystem;if(typeof e=="boolean"&&(e=e?Pt.ALL:Pt.NONE),t.colorAttachments.length===0&&(e&=~Pt.COLOR,!e))return;const l=this._renderer.gl,u=!!(e&Pt.DEPTH)&&!this._renderer.state.depthMaskEnabled;if(e&Pt.COLOR){s!=null||(s=a.defaultClearColor);const h=this._clearColorCache,c=s;(h[0]!==c[0]||h[1]!==c[1]||h[2]!==c[2]||h[3]!==c[3])&&(h[0]=c[0],h[1]=c[1],h[2]=c[2],h[3]=c[3],l.clearColor(c[0],c[1],c[2],c[3]))}u&&l.depthMask(!0),l.clear(e),u&&l.depthMask(!1)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.pixelWidth,e.height=t.pixelHeight,t.colorAttachments.length>0&&this._resizeColor(t,e),e.depthStencilRenderBuffer&&this._resizeStencil(e),this._boundFramebuffer=void 0}_initColor(t,e){const s=this._renderer,i=s.gl,n=i.createFramebuffer();if(e.resolveTargetFramebuffer=n,i.bindFramebuffer(i.FRAMEBUFFER,n),t.colorAttachments.forEach((o,a)=>{const l=o.texture;l.antialias&&(s.context.supports.msaa?e.msaa=!0:Bt("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),s.texture.bindSource(l,0);const u=s.texture.getGlSource(l),h=u.texture;if(u.target===i.TEXTURE_2D)i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+a,i.TEXTURE_2D,h,0);else if(u.target===i.TEXTURE_2D_ARRAY){if(s.context.webGLVersion<2)throw new Error("[RenderTargetSystem] TEXTURE_2D_ARRAY requires WebGL2.");i.framebufferTextureLayer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+a,h,0,0)}else if(u.target===i.TEXTURE_CUBE_MAP)i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+a,i.TEXTURE_CUBE_MAP_POSITIVE_X,h,0);else throw new Error("[RenderTargetSystem] Unsupported texture target for framebuffer attachment.")}),e.msaa){const o=i.createFramebuffer();e.framebuffer=o,i.bindFramebuffer(i.FRAMEBUFFER,o),t.colorAttachments.forEach((a,l)=>{const u=i.createRenderbuffer();e.msaaRenderBuffer[l]=u})}else e.framebuffer=n;this._resizeColor(t,e)}_initDepth(t,e){const s=this._renderer;if(s.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Depth-only render targets require WebGL2.");const i=s.gl,n=i.createFramebuffer();e.resolveTargetFramebuffer=n,e.framebuffer=n,i.bindFramebuffer(i.FRAMEBUFFER,n),i.drawBuffers([i.NONE]),i.readBuffer(i.NONE)}_resizeColor(t,e){const s=t.colorAttachments[0].texture;if(e._attachedMipLevel=0,e._attachedLayer=0,t.colorAttachments.forEach((i,n)=>{n!==0&&i.texture.resize(s.width,s.height,s._resolution)}),e.msaa){const i=this._renderer,n=i.gl,o=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,o),t.colorAttachments.forEach((a,l)=>{const u=a.texture;i.texture.bindSource(u,0);const h=i.texture.getGlSource(u).internalFormat,c=e.msaaRenderBuffer[l];n.bindRenderbuffer(n.RENDERBUFFER,c),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,h,u.pixelWidth,u.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+l,n.RENDERBUFFER,c)})}}_attachDepthStencilTexture(t,e,s){const i=this._renderer,n=i.gl,o=t.depthStencilAttachment.texture,a=i.texture.getGlSource(o),l=a.texture,u=o.format;let h;u==="depth24plus-stencil8"||u==="depth32float-stencil8"?h=n.DEPTH_STENCIL_ATTACHMENT:u==="stencil8"?h=n.STENCIL_ATTACHMENT:h=n.DEPTH_ATTACHMENT,a.target===n.TEXTURE_2D?n.framebufferTexture2D(n.FRAMEBUFFER,h,n.TEXTURE_2D,l,e):a.target===n.TEXTURE_2D_ARRAY?n.framebufferTextureLayer(n.FRAMEBUFFER,h,l,e,s):a.target===n.TEXTURE_CUBE_MAP&&n.framebufferTexture2D(n.FRAMEBUFFER,h,n.TEXTURE_CUBE_MAP_POSITIVE_X+s,l,e)}_initStencil(t){if(t.framebuffer===null)return;const e=this._renderer.gl,s=e.createRenderbuffer();t.depthStencilRenderBuffer=s,e.bindRenderbuffer(e.RENDERBUFFER,s),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,s),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){if(t.colorAttachments.length===0)return;const e=t.colorAttachments[0].texture.resource;this._renderer.context.multiView&&re.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(!this._renderer.context.multiView||t.colorAttachments.length===0)return;const e=t.colorAttachments[0].texture;if(re.test(e.resource)){const s=this._renderer.context.canvas,i=e;i.context2D.drawImage(s,0,i.pixelHeight-s.height)}}_setDrawBuffers(t,e){const s=t.colorAttachments.length,i=this._drawBuffersCache[s];if(this._renderer.context.webGLVersion===1){const n=this._renderer.context.extensions.drawBuffers;n?n.drawBuffersWEBGL(i):Bt("[RenderTexture] This WebGL1 context does not support rendering to multiple targets")}else e.drawBuffers(i)}resetState(){this._boundFramebuffer=void 0,this._viewPortCache=new it,this._clearColorCache=[0,0,0,0]}bindFramebuffer(t){this._boundFramebuffer!==t&&(this._boundFramebuffer=t,this._renderer.gl.bindFramebuffer(this._renderer.gl.FRAMEBUFFER,t))}}class Ih extends so{constructor(t){super(t),this.adaptor=new qy,this.adaptor.init(t,this)}resetState(){this.adaptor.resetState()}}Ih.extension={type:[T.WebGLSystem],name:"renderTarget"};class lo extends It{constructor({buffer:t,offset:e,size:s}){super(),this.uid=ut("buffer"),this._resourceType="bufferResource",this._resourceId=ut("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=s,this.buffer.on("change",this.onBufferChange,this)}get _gcLastUsed(){var t,e;return(e=(t=this.buffer)==null?void 0:t._gcLastUsed)!=null?e:-1}set _gcLastUsed(t){this.buffer&&(this.buffer._gcLastUsed=t)}onBufferChange(){this._resourceId=ut("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}class Zy extends It{constructor(t,e){super(),this._resourceType="textureView",this._resourceId=ut("resource"),this.source=t,this.viewDescriptor=e,this._onChange=this._onChange.bind(this),this._onDestroy=this._onDestroy.bind(this),this.source.on("change",this._onChange),this.source.on("destroy",this._onDestroy)}_onChange(){this.emit("change",this)}_onDestroy(){this.destroy()}get destroyed(){return this.source.destroyed}destroy(){this.source&&(this.source.off("change",this._onChange),this.source.off("destroy",this._onDestroy)),this.emit("destroy",this),this.removeAllListeners()}}function Qy(r,t){const e=[],s=[` var g = s.groups; var sS = r.shader; var p = s.glProgram; var ugS = r.uniformGroup; var resources; `];let i=!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 h in u.resources){const c=u.resources[h];if(c instanceof wt)if(c.ubo){const d=r._uniformBindMap[l][Number(h)];e.push(` sS.bindUniformBlock( resources[${h}], '${d}', ${r.glProgram._uniformBlockData[d].index} ); `)}else e.push(` ugS.updateUniformGroup(resources[${h}], p, sD); `);else if(c instanceof lo){const d=r._uniformBindMap[l][Number(h)];e.push(` sS.bindUniformBlock( resources[${h}], '${d}', ${r.glProgram._uniformBlockData[d].index} ); `)}else if(c instanceof ct||c instanceof Zy){const d=r._uniformBindMap[l][h],p=o.uniformData[d];p&&(i||(i=!0,s.push(` var tS = r.texture; `)),t._gl.uniform1i(p.location,n),e.push(` tS.bind(resources[${h}], ${n}); `),n++)}}}const a=[...s,...e].join(` `);return new Function("r","s","sD",a)}class oG{}class Jy{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 Fh(r,t,e){const s=r.createShader(t);return r.shaderSource(s,e),r.compileShader(s),s}function Bh(r){const t=new Array(r);for(let e=0;eo>a?1:-1);for(let o=0;o`${d}: ${c}`),n=(e=r.getShaderInfoLog(t))!=null?e:"",o=n.split(` `),a={},l=o.map(c=>parseFloat(c.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(c=>c&&!a[c]?(a[c]=!0,!0):!1),u=[""];l.forEach(c=>{i[c-1]=`%c${i[c-1]}%c`,u.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const h=i.join(` `);u[0]=h,console.error(n),console.groupCollapsed("click to view full shader code"),console.warn(...u),console.groupEnd()}function o0(r,t,e,s){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||n0(r,e),r.getShaderParameter(s,r.COMPILE_STATUS)||n0(r,s),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}function a0(r,t){const e=Fh(r,r.VERTEX_SHADER,t.vertex),s=Fh(r,r.FRAGMENT_SHADER,t.fragment),i=r.createProgram();r.attachShader(i,e),r.attachShader(i,s);const n=t.transformFeedbackVaryings;n&&(typeof r.transformFeedbackVaryings!="function"||r.transformFeedbackVaryings(i,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(i),r.getProgramParameter(i,r.LINK_STATUS)||o0(r,i,e,s),t._attributeData=r0(i,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=i0(i,r),t._uniformBlockData=s0(i,r),r.deleteShader(e),r.deleteShader(s);const o={};for(const a in t._uniformData){const l=t._uniformData[a];o[a]={location:r.getUniformLocation(i,a),value:Dh(l.type,l.size)}}return new Jy(i,o)}const ho={textureCount:0,blockIndex:0};class Uh{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;ho.textureCount=0,ho.blockIndex=0;let s=this._shaderSyncFunctions[t.glProgram._key];s||(s=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),s(this._renderer,t,ho)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,ho)}bindUniformBlock(t,e,s=0){const i=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=t._bufferResource;o||this._renderer.ubo.updateUniformGroup(t);const a=t.buffer,l=i.updateBuffer(a),u=i.freeLocationForBufferBase(l);if(o){const{offset:c,size:d}=t;c===0&&d===a.data.byteLength?i.bindBufferBase(l,u):i.bindBufferRange(l,u,c)}else i.getLastBindBaseLocation(l)!==u&&i.bindBufferBase(l,u);const h=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[s]!==u&&(n.uniformBlockBindings[s]=u,this._renderer.gl.uniformBlockBinding(n.program,h,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]=a0(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 Qy(t,e)}resetState(){this._activeProgram=null}}Uh.extension={type:[T.WebGLSystem],name:"shader"};const l0={f32:`if (cv !== v) { cu.value = v; gl.uniform1f(location, v); }`,"vec2":`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":`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":`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":`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":`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":`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":`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":`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":`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":`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":`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":`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":"gl.uniformMatrix2fv(location, false, v);","mat3x3":"gl.uniformMatrix3fv(location, false, v);","mat4x4":"gl.uniformMatrix4fv(location, false, v);"},u0={f32:"gl.uniform1fv(location, v);","vec2":"gl.uniform2fv(location, v);","vec3":"gl.uniform3fv(location, v);","vec4":"gl.uniform4fv(location, v);","mat2x2":"gl.uniformMatrix2fv(location, false, v);","mat3x3":"gl.uniformMatrix3fv(location, false, v);","mat4x4":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);"};function h0(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 s in r.uniforms){if(!t[s]){r.uniforms[s]instanceof wt?r.uniforms[s].ubo?e.push(` renderer.shader.bindUniformBlock(uv.${s}, "${s}"); `):e.push(` renderer.shader.updateUniformGroup(uv.${s}); `):r.uniforms[s]instanceof lo&&e.push(` renderer.shader.bindBufferResource(uv.${s}, "${s}"); `);continue}const i=r.uniformStructures[s];let n=!1;for(let o=0;o>=1,s++;this.stateId=t.data}for(let e=0;e>1,1),l=Math.max(l>>1,1)}}},_0=["right","left","top","bottom","front","back"];function x0(r){return{id:"cube",upload(t,e,s,i){const n=t.faces;for(let o=0;o<_0.length;o++){const a=_0[o],l=n[a];l.resource&&((r[l.uploadMethodId]||r.image).upload(l,e,s,i,ao.TEXTURE_CUBE_MAP_POSITIVE_X+o,(e._layerInitMask&1<=a&&h>=l,f=r.resource;(c?_G:xG)(e,o,t,a,l,u,h,f,d,p),t.width=a,t.height=l}};function _G(r,t,e,s,i,n,o,a,l,u){if(!u){l&&r.texImage2D(t,0,e.internalFormat,s,i,0,e.format,e.type,null),r.texSubImage2D(t,0,0,0,n,o,e.format,e.type,a);return}if(!l){r.texSubImage2D(t,0,0,0,e.format,e.type,a);return}r.texImage2D(t,0,e.internalFormat,s,i,0,e.format,e.type,a)}function xG(r,t,e,s,i,n,o,a,l,u){if(!u){l&&r.texImage2D(t,0,e.internalFormat,s,i,0,e.format,e.type,null),r.texSubImage2D(t,0,0,0,e.format,e.type,a);return}if(!l){r.texSubImage2D(t,0,0,0,e.format,e.type,a);return}r.texImage2D(t,0,e.internalFormat,e.format,e.type,a)}const vG=ju(),v0={id:"video",upload(r,t,e,s,i,n=vG){if(!r.isValid){const o=i!=null?i:t.target;e.texImage2D(o,0,t.internalFormat,1,1,0,t.format,t.type,null);return}Nh.upload(r,t,e,s,i,n)}},jh={linear:9729,nearest:9728},b0={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},co={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},y0={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function Xh(r,t,e,s,i,n,o,a){const l=n;if(!a||r.addressModeU!=="repeat"||r.addressModeV!=="repeat"||r.addressModeW!=="repeat"){const u=co[o?"clamp-to-edge":r.addressModeU],h=co[o?"clamp-to-edge":r.addressModeV],c=co[o?"clamp-to-edge":r.addressModeW];t[i](l,t.TEXTURE_WRAP_S,u),t[i](l,t.TEXTURE_WRAP_T,h),t.TEXTURE_WRAP_R&&t[i](l,t.TEXTURE_WRAP_R,c)}if((!a||r.magFilter!=="linear")&&t[i](l,t.TEXTURE_MAG_FILTER,jh[r.magFilter]),e){if(!a||r.mipmapFilter!=="linear"){const u=b0[r.minFilter][r.mipmapFilter];t[i](l,t.TEXTURE_MIN_FILTER,u)}}else t[i](l,t.TEXTURE_MIN_FILTER,jh[r.minFilter]);if(s&&r.maxAnisotropy>1){const u=Math.min(r.maxAnisotropy,t.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[i](l,s.TEXTURE_MAX_ANISOTROPY_EXT,u)}r.compare?(t[i](l,t.TEXTURE_COMPARE_FUNC,y0[r.compare]),t[i](l,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE)):a||t[i](l,t.TEXTURE_COMPARE_MODE,t.NONE)}function T0(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 bG=Object.defineProperty,yG=Object.defineProperties,TG=Object.getOwnPropertyDescriptors,S0=Object.getOwnPropertySymbols,SG=Object.prototype.hasOwnProperty,wG=Object.prototype.propertyIsEnumerable,w0=(r,t,e)=>t in r?bG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yr=(r,t)=>{for(var e in t||(t={}))SG.call(t,e)&&w0(r,e,t[e]);if(S0)for(var e of S0(t))wG.call(t,e)&&w0(r,e,t[e]);return r},EG=(r,t)=>yG(r,TG(t));function E0(r,t){let e={},s=r.RGBA;return r instanceof X.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},s=r.RGBA8),yr(yr(yr(yr(yr(yr(EG(yr({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:s,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 A0(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 P0(r){return{"2d":r.TEXTURE_2D,cube:r.TEXTURE_CUBE_MAP,"1d":null,"3d":(r==null?void 0:r.TEXTURE_3D)||null,"2d-array":(r==null?void 0:r.TEXTURE_2D_ARRAY)||null,"cube-array":(r==null?void 0:r.TEXTURE_CUBE_MAP_ARRAY)||null}}function AG(r){r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));const t=r.length;for(let e=0;et in r?PG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,M0=(r,t)=>{for(var e in t||(t={}))MG.call(t,e)&&R0(r,e,t[e]);if(C0)for(var e of C0(t))OG.call(t,e)&&R0(r,e,t[e]);return r},GG=(r,t)=>CG(r,RG(t));const IG=4,Hh=class SS{constructor(t){this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._managedTextures=new kt({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});const e=M0({image:Nh,buffer:m0,video:v0,compressed:g0},SS.uploadExtensions);this._uploads=GG(M0({},e),{cube:x0(e)})}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=E0(t,this._renderer.context.extensions),this._mapFormatToType=A0(t),this._mapFormatToFormat=T0(t),this._mapViewDimensionToGlTarget=P0(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(B.EMPTY,e)}initSource(t){this.bind(t)}bind(t,e=0){const s=t.source;t?(this.bindSource(s,e),this._useSeparateSamplers&&this._bindSampler(s.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){const s=this._gl;if(t._gcLastUsed=this._renderer.gc.now,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t||(t=B.EMPTY.source);const i=this.getGlSource(t);s.bindTexture(i.target,i.texture)}}_bindSampler(t,e=0){const s=this._gl;if(!t){this._boundSamplers[e]=null,s.bindSampler(e,null);return}const i=this._getGlSampler(t);this._boundSamplers[e]!==i&&(this._boundSamplers[e]=i,s.bindSampler(e,i))}unbind(t){const e=t.source,s=this._boundTextures,i=this._gl;for(let n=0;n1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.target,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t,e=!1){const s=t._gpuData[this._renderer.uid];s&&(e||(this.unbind(t),this._gl.deleteTexture(s.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,s=this.getGlSource(t);e.bindTexture(s.target,s.texture),this._boundTextures[this._activeTextureLocation]=t;const i=t.alphaMode==="premultiply-alpha-on-upload";if(this._premultiplyAlpha!==i&&(this._premultiplyAlpha=i,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i)),this._uploads[t.uploadMethodId])this._uploads[t.uploadMethodId].upload(t,s,e,this._renderer.context.webGLVersion);else if(s.target===e.TEXTURE_2D)this._initEmptyTexture2D(s,t);else if(s.target===e.TEXTURE_2D_ARRAY)this._initEmptyTexture2DArray(s,t);else if(s.target===e.TEXTURE_CUBE_MAP)this._initEmptyTextureCube(s,t);else throw new Error("[GlTextureSystem] Unsupported texture target for empty allocation.");this._applyMipRange(s,t),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const s=this.getGlSource(t);this._gl.generateMipmap(s.target)}_initEmptyTexture2D(t,e){const s=this._gl;s.texImage2D(s.TEXTURE_2D,0,t.internalFormat,e.pixelWidth,e.pixelHeight,0,t.format,t.type,null);let i=Math.max(e.pixelWidth>>1,1),n=Math.max(e.pixelHeight>>1,1);for(let o=1;o>1,1),n=Math.max(n>>1,1)}_initEmptyTexture2DArray(t,e){if(this._renderer.context.webGLVersion!==2)throw new Error("[GlTextureSystem] TEXTURE_2D_ARRAY requires WebGL2.");const s=this._gl,i=Math.max(e.arrayLayerCount|0,1);s.texImage3D(s.TEXTURE_2D_ARRAY,0,t.internalFormat,e.pixelWidth,e.pixelHeight,i,0,t.format,t.type,null);let n=Math.max(e.pixelWidth>>1,1),o=Math.max(e.pixelHeight>>1,1);for(let a=1;a>1,1),o=Math.max(o>>1,1)}_initEmptyTextureCube(t,e){const s=this._gl,i=6;for(let a=0;a>1,1),o=Math.max(e.pixelHeight>>1,1);for(let a=1;a>1,1),o=Math.max(o>>1,1)}}_applyMipRange(t,e){if(this._renderer.context.webGLVersion!==2||e.mipLevelCount<=1)return;const s=this._gl,i=Math.max((e.mipLevelCount|0)-1,0);s.texParameteri(t.target,s.TEXTURE_BASE_LEVEL,0),s.texParameteri(t.target,s.TEXTURE_MAX_LEVEL,i)}_initSampler(t){const e=this._gl,s=this._gl.createSampler();return this._glSamplers[t._resourceId]=s,Xh(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",s,!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:s,height:i}=this.getPixels(t),n=X.get().createCanvas();n.width=s,n.height=i;const o=n.getContext("2d");if(o){const a=o.createImageData(s,i);a.data.set(e),o.putImageData(a,0,0)}return n}getPixels(t){const e=t.source.resolution,s=t.frame,i=Math.max(Math.round(s.width*e),1),n=Math.max(Math.round(s.height*e),1),o=new Uint8Array(IG*i*n),a=this._renderer,l=a.renderTarget.getRenderTarget(t),u=a.renderTarget.getGpuRenderTarget(l),h=a.gl;return a.renderTarget.adaptor.bindFramebuffer(u.resolveTargetFramebuffer),h.readPixels(Math.round(s.x*e),Math.round(s.y*e),i,n,h.RGBA,h.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:i,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(B.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}};Hh.extension={type:[T.WebGLSystem],name:"texture"},Hh.uploadExtensions=Object.create(null);let zh=Hh;L.handleByMap(T.TextureUploaderWebGL,zh.uploadExtensions);class Wh{contextChange(t){const e=new wt({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new D,type:"mat3x3"},uRound:{value:0,type:"f32"}}),s=t.limits.maxBatchableTextures,i=kr({name:"graphics",bits:[Ki,Zi(s),Rn,Nr]});this.shader=new ne({glProgram:i,resources:{localUniforms:e,batchSamplers:Qi(s)}})}execute(t,e){const s=e.context,i=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(s);i.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(i),n.geometry.bind(a.geometry,i.glProgram);const u=l.instructions;for(let h=0;h",value:new D}}}})}execute(t,e){const s=t.renderer;let i=e._shader;if(i){if(!i.glProgram)return}else{i=this._shader;const n=e.texture,o=n.source;i.resources.uTexture=o,i.resources.uSampler=o.style,i.resources.textureUniforms.uniforms.uTextureMatrix=n.textureMatrix.mapCoord}i.groups[100]=s.globalUniforms.bindGroup,i.groups[101]=t.localUniformsBindGroup,s.encoder.draw({geometry:e._geometry,shader:i,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Vh.extension={type:[T.WebGLPipesAdaptor],name:"mesh"};const FG=[...ro,Gh,jy,Fy,Ah,bh,zh,Ih,Th,kh,Uh,Eh,f0,Ph,wh],BG=[..._h],DG=[zu,Vh,Wh],O0=[],G0=[],I0=[],F0=[];L.handleByNamedList(T.WebGLSystem,O0),L.handleByNamedList(T.WebGLPipes,G0),L.handleByNamedList(T.WebGLPipesAdaptor,I0),L.handleByNamedList(T.WebGLLoader,F0),L.add(...FG,...BG,...DG);class B0 extends Gr{constructor(){const t={name:"webgl",type:Mt.WEBGL,systems:O0,renderPipes:G0,renderPipeAdaptors:I0,loaders:F0};super(t)}}var $G={__proto__:null,WebGLRenderer:B0};let UG=class{constructor(t,e){this.autoGarbageCollect=!0,this._gpuData=null,this.gpuBindGroup=t,this._gcLastUsed=e}unload(){this.gpuBindGroup=null}};class Yh{constructor(t){this._hash=Object.create(null),this._renderer=t,t.gc.addResourceHash(this,"_hash","resource"),t.gc.addCollection(this,"_hash","hash")}contextChange(t){this._gpu=t,this._hash=Object.create(null)}getBindGroup(t,e,s){const i=`${t._key}:${e._layoutKey<<4|s}`,n=this._hash[i];return n?(n._gcLastUsed=this._renderer.gc.now,n.gpuBindGroup):this._createBindGroup(i,t,e,s)}_createBindGroup(t,e,s,i){var n,o;const a=this._gpu.device,l=s.layout[i],u=[],h=this._renderer;for(const p in l){const f=(n=e.resources[p])!=null?n:e.resources[l[p]];if(!f||f.destroyed)throw new Error(`[BindGroup] the resource bound as '${p}' was destroyed while a shader still uses it. Remove it from the shader before destroying it.`);let m;if(f._resourceType==="uniformGroup"){const g=f;h.ubo.updateUniformGroup(g);const _=g.buffer;m={buffer:h.buffer.getGPUBuffer(_),offset:0,size:_.descriptor.size}}else if(f._resourceType==="buffer"){const g=f;m={buffer:h.buffer.getGPUBuffer(g),offset:0,size:g.descriptor.size}}else if(f._resourceType==="bufferResource"){const g=f;m={buffer:h.buffer.getGPUBuffer(g.buffer),offset:g.offset,size:(o=g.size)!=null?o:g.buffer.descriptor.size}}else if(f._resourceType==="textureSampler"){const g=f;m=h.texture.getGpuSampler(g)}else if(f._resourceType==="textureSource"){const g=f;m=h.texture.getTextureView(g)}else if(f._resourceType==="textureView"){const g=f;m=h.texture.getTextureView(g.source,g.viewDescriptor)}u.push({binding:l[p],resource:m})}const c=h.shader.getProgramData(s).bindGroups[i],d=a.createBindGroup({layout:c,entries:u});return this._hash[t]=new UG(d,h.gc.now),d}destroy(){this._hash=null,this._renderer=null}}Yh.extension={type:[T.WebGPUSystem],name:"bindGroup"};class D0{constructor(t){this.gpuBuffer=t}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class Kh{constructor(t){this._renderer=t,this._managedBuffers=new kt({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(t){this._gpu=t,this.destroyAll()}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),s=t.data;return t._updateID&&s&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,t._updateOffset,s.buffer,s.byteOffset+t._updateOffset,(t._updateSize||s.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.data&&(Wi(t.data.buffer,e.getMappedRange(),t.data.byteOffset,t.data.byteLength),e.unmap()),t._gpuData[this._renderer.uid]=new D0(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}}Kh.extension={type:[T.WebGPUSystem],name:"buffer"};class $0{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 s=e+t*4;if(s=Math.ceil(s/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,s>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=s,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let s=0;sthis._setGpu(e)),this._initPromise)}_setGpu(t){this.gpu=t,this.extensions={transientAttachment:typeof GPUTextureUsage.TRANSIENT_ATTACHMENT=="number"},this._options.gpu||t.device.lost.then(()=>this._restoreDevice()).catch(e=>Bt("WebGPU device was lost and could not be restored",e)),this._renderer.runners.contextChange.emit(this.gpu)}async _restoreDevice(){if(!this._renderer)return;const t=await this._createDeviceAndAdaptor(this._options);if(!this._renderer){t.device.destroy();return}this._setGpu(t)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await X.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter});if(!e)throw new Error("WebGPU not supported. No GPU adapter was returned by navigator.gpu.requestAdapter().");const s=["texture-compression-bc","texture-compression-astc","texture-compression-etc2","indirect-first-instance"].filter(n=>e.features.has(n)),i=await e.requestDevice({requiredFeatures:s,requiredLimits:{maxSampledTexturesPerShaderStage:e.limits.maxSampledTexturesPerShaderStage,maxSamplersPerShaderStage:e.limits.maxSamplersPerShaderStage}});return{adapter:e,device:i}}destroy(){var t,e;(t=this._options)!=null&&t.gpu||(e=this.gpu)==null||e.device.destroy(),this.gpu=null,this.extensions=null,this._renderer=null}}po.extension={type:[T.WebGPUSystem],name:"device"},po.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class U0{constructor(t,e,s,i){this.gpuBundle=t,this.stateKey=e,this.device=s,this.label=i}}class Zh{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t;for(let e=0;e<16;e++)this._boundBindGroup[e]={bindGroup:null,program:null,key:null}}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this._passEncoder=this.commandEncoder.beginRenderPass(t.descriptor),this.renderPassEncoder=this._passEncoder}endRenderPass(){this._passEncoder&&this._passEncoder.end(),this.renderPassEncoder=null,this._passEncoder=null}beginBundle(t){if(this._passEncoder!==this.renderPassEncoder)throw new Error("Cannot begin a new render bundle while one is already being recorded.");this._clearCache();const e=this._renderer.pipeline,s=e.getBundleDescriptor();s.label=t,this._bundleStateKey=e.bundleStateKey,this._bundleLabel=t,this.renderPassEncoder=this._gpu.device.createRenderBundleEncoder(s)}endBundle(){const t=this.renderPassEncoder;if(!t||!("finish"in t))throw new Error("endBundle called without an active render bundle.");const e=t.finish({label:this._bundleLabel});return this.renderPassEncoder=this._passEncoder,this._clearCache(),new U0(e,this._bundleStateKey,this._gpu.device,this._bundleLabel)}isBundleValid(t){return(t==null?void 0:t.stateKey)===this._renderer.pipeline.bundleStateKey&&t.device===this._gpu.device}executeBundle(t){const e=[];if(Array.isArray(t))for(let s=0;s{this.supportsOverrideConstants=!s})}destroy(){}}Qh.extension={type:[T.WebGPUSystem],name:"limits"};class Jh{constructor(t){this._renderer=t,t.renderTarget.onRenderTargetChange.add(this)}contextChange(){this._activeGpuRenderTarget=null}onRenderTargetChange(t){const e=this._renderer.renderTarget.getGpuRenderTarget(t);this._activeRenderTarget=t,this._activeGpuRenderTarget=e,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){var s;const i=(s=this._activeGpuRenderTarget)!=null?s:this._activeGpuRenderTarget=this._renderer.renderTarget.getGpuRenderTarget(this._activeRenderTarget);i.stencilMode=t,i.stencilReference=e;const n=this._renderer;n.pipeline.setStencilMode(t),n.encoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._activeGpuRenderTarget=null}}Jh.extension={type:[T.WebGPUSystem],name:"stencil"};const si={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2":{align:8,size:8},"vec2":{align:8,size:8},"vec2":{align:8,size:8},"vec2":{align:4,size:4},"vec3":{align:16,size:12},"vec3":{align:16,size:12},"vec3":{align:16,size:12},"vec3":{align:8,size:6},"vec4":{align:16,size:16},"vec4":{align:16,size:16},"vec4":{align:16,size:16},"vec4":{align:8,size:8},"mat2x2":{align:8,size:16},"mat2x2":{align:4,size:8},"mat3x2":{align:8,size:24},"mat3x2":{align:4,size:12},"mat4x2":{align:8,size:32},"mat4x2":{align:4,size:16},"mat2x3":{align:16,size:32},"mat2x3":{align:8,size:16},"mat3x3":{align:16,size:48},"mat3x3":{align:8,size:24},"mat4x3":{align:16,size:64},"mat4x3":{align:8,size:32},"mat2x4":{align:16,size:32},"mat2x4":{align:8,size:16},"mat3x4":{align:16,size:48},"mat3x4":{align:8,size:24},"mat4x4":{align:16,size:64},"mat4x4":{align:8,size:32}};function k0(r){const t=r.map(s=>({data:s,offset:0,size:0}));let e=0;for(let s=0;s1&&(n=Math.max(n,o)*i.data.size),e=Math.ceil(e/o)*o,i.size=n,i.offset=e,e+=n}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function L0(r,t){const{size:e,align:s}=si[r.data.type],i=(s-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++]; } ${i!==0?`arrayOffset += ${i};`:""} } `}function N0(r){return Mh(r,Vy,L0)}class tc extends Ch{constructor(){super({createUboElements:k0,generateUboSync:N0})}}tc.extension={type:[T.WebGPUSystem],name:"ubo"};const Ye=128;class ec{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._batchBuffer=new $0({minUniformOffsetAlignment:Ye});const e=256/Ye;for(let s=0;st in r?kG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,HG=(r,t)=>{for(var e in t||(t={}))jG.call(t,e)&&X0(r,e,t[e]);if(j0)for(var e of j0(t))XG.call(t,e)&&X0(r,e,t[e]);return r},zG=(r,t)=>LG(r,NG(t));const H0={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4},WG=new as({}),VG={"depth24plus-stencil8":{depth:!0,stencil:!0,index:1},depth24plus:{depth:!0,stencil:!1,index:2},depth32float:{depth:!0,stencil:!1,index:3},"depth32float-stencil8":{depth:!0,stencil:!0,index:4},depth16unorm:{depth:!0,stencil:!1,index:5},stencil8:{depth:!1,stencil:!0,index:6}},z0={depth:!1,stencil:!1,index:0};function rc(r,t){for(const[e,s]of Object.entries(t)){const i=new RegExp(`override\\s+${e}\\s*:\\s*(\\w+)\\s*(?:=[^;]*)?;`);r=r.replace(i,(n,o)=>{let a;return o==="u32"?a=`${Math.trunc(s)}u`:o==="i32"?a=`${Math.trunc(s)}`:a=Number.isInteger(s)?`${s}.0`:`${s}`,`const ${e}: ${o} = ${a};`})}return r}function W0(r,t,e,s,i,n){return r*35184372088832+t*536870912+n*16384+(e<<8)+(s<<3)+i}const V0=Object.create(null);let YG=0;function Y0(r){let t=V0[r];return t===void 0&&(t=V0[r]=YG++),t}function KG(r,t,e,s,i,n,o,a){return a<<20|n<<16|i<<13|e<<9|r<<6|o<<5|s<<1|t}function qG(r,t,e,s,i,n,o){return o<<11|n<<10|i<<9|s<<8|e<<5|t<<1|r}class sc{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=new Map,this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._colorTargetCount=1,this._colorFormat="bgra8unorm",this._colorFormatId=Y0("bgra8unorm"),this._depthStencilFormat="depth24plus-stencil8",this._depthStencilFormatData=z0,this._depthReadOnly=!1,this._stencilReadOnly=!1,this._invertFrontFace=!1,this._renderer=t}contextChange(t){this._gpu=t,this._moduleCache=Object.create(null),this._pipeStateCaches=Object.create(null),this.setStencilMode(bt.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){var e,s,i,n,o,a,l;const u=(e=t.colorAttachments[0])==null?void 0:e.texture;this._multisampleCount=u!=null&&u.source.antialias?4:1,this._colorTargetCount=t.colorAttachments.length,this._colorFormat=(s=u==null?void 0:u.format)!=null?s:"bgra8unorm",this._colorFormatId=Y0(this._colorFormat),this._depthStencilFormat=(i=t.depthStencilAttachment)==null?void 0:i.texture.format,this._depthStencilFormatData=VG[this._depthStencilFormat]||z0,this._depthReadOnly=(o=(n=t.depthStencilAttachment)==null?void 0:n.depthReadOnly)!=null?o:!1,this._stencilReadOnly=(l=(a=t.depthStencilAttachment)==null?void 0:a.stencilReadOnly)!=null?l:this._depthReadOnly,this._invertFrontFace=this._renderer.renderTarget.isFrontFaceInverted(t,t.flipY),this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=ke[t],this._updatePipeHash())}get bundleStateKey(){const t=this._depthStencilFormatData;return qG(this._multisampleCount===1?0:1,this._colorTargetCount,t.index,t.depth&&this._depthReadOnly?1:0,t.stencil&&this._stencilReadOnly?1:0,this._invertFrontFace?1:0,this._colorFormatId)}getBundleDescriptor(){const t=[];for(let i=0;i0;let d=e.vertex.source,p=e.fragment.source,f;c&&(this._renderer.limits.supportsOverrideConstants?f=n.data:(d=rc(d,n.data),p=rc(p,n.data)));const m={vertex:{module:this._getModule(d),entryPoint:e.vertex.entryPoint,constants:f,buffers:a},fragment:{module:this._getModule(p),entryPoint:e.fragment.entryPoint,targets:l,constants:f},primitive:{topology:i,cullMode:s.culling?"back":"none",frontFace:s.clockwiseFrontFace!==this._invertFrontFace?"cw":"ccw"},layout:h,multisample:{count:this._multisampleCount},label:e.name?`PIXI Pipeline (${e.name})`:"PIXI Pipeline"};if(this._depthStencilFormatData.depth||this._depthStencilFormatData.stencil){const g=this._depthStencilFormatData;m.depthStencil=zG(HG({},this._stencilState),{format:this._depthStencilFormat,depthWriteEnabled:g.depth?s.depthMask&&!this._depthReadOnly:!1,depthCompare:g.depth&&s.depthTest?"less":"always"})}return o.createRenderPipeline(m)}_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 s=0;const i=Object.keys(t.attributes).sort();for(let o=0;o{var o;const a={arrayStride:0,stepMode:"vertex",attributes:[]},l=a.attributes;for(const u in e.attributeData){const h=t.attributes[u];((o=h.divisor)!=null?o:1)!==1&&Bt(`Attribute ${u} has an invalid divisor value of '${h.divisor}'. WebGPU only supports a divisor value of 1`),h.buffer===n&&(a.arrayStride=h.stride,a.stepMode=h.instance?"instance":"vertex",l.push({shaderLocation:e.attributeData[u].location,offset:h.offset,format:h.format}))}l.length&&i.push(a)}),this._bufferLayoutsCache[s]=i,i}_updatePipeHash(){var t,e;const s=KG(this._stencilMode,this._multisampleCount===1?0:1,this._colorMask,this._colorTargetCount,this._depthStencilFormatData.index,this._colorFormatId,this._depthReadOnly?1:0,this._invertFrontFace?1:0);this._pipeCache=(e=(t=this._pipeStateCaches)[s])!=null?e:t[s]=new Map}destroy(){this._bufferLayoutsCache=null,this._pipeCache=null,this._gpu=null,this._renderer=null,this._bindingNamesCache=null,this._pipeStateCaches=null,this._moduleCache=null}}sc.extension={type:[T.WebGPUSystem],name:"pipeline"};class K0{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1,this.stencilMode=bt.DISABLED,this.stencilReference=0,this.maskStackIndex=0}}var ZG=Object.defineProperty,q0=Object.getOwnPropertySymbols,QG=Object.prototype.hasOwnProperty,JG=Object.prototype.propertyIsEnumerable,Z0=(r,t,e)=>t in r?ZG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,tI=(r,t)=>{for(var e in t||(t={}))QG.call(t,e)&&Z0(r,e,t[e]);if(q0)for(var e of q0(t))JG.call(t,e)&&Z0(r,e,t[e]);return r};const eI={bgra8unorm:!0,rgba8unorm:!0,rgba16float:!0};function rI(r){if(eI[r])return r;const t=navigator.gpu.getPreferredCanvasFormat();return Bt(`[WebGPU] CanvasSource format '${r}' is not a valid GPUCanvasContext format. Falling back to '${t}'. Allowed formats are: bgra8unorm, rgba8unorm, rgba16float.`),t}class Q0{constructor(){this._activePass=null}init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,s,i,n){const o=this._renderer;this.finishRenderPass();const a=this._getGpuColorTexture(t),l=o.texture.getGpuSource(e.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:s},{texture:l,origin:n},i),e}copyDepthTexture(t,e,s,i,n){const o=this._renderer;this.finishRenderPass();const a=t.depthStencilAttachment.texture,l=o.texture.getGpuSource(a),u=o.texture.getGpuSource(e.source),h=o.encoder.commandEncoder===null,c=h?o.gpu.device.createCommandEncoder():o.encoder.commandEncoder;c.copyTextureToTexture({texture:l,origin:s},{texture:u,origin:n},{width:i.width,height:i.height}),h&&o.gpu.device.queue.submit([c.finish()])}startRenderPass(t,e=!0,s,i,n=0,o=0){var a,l;const u=this._renderTargetSystem.getGpuRenderTarget(t);if(o!==0&&(a=u.msaaTextures)!=null&&a.length)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported with MSAA render targets.");if(n>0&&(l=u.msaaTextures)!=null&&l.length)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");let h=e;typeof h=="boolean"&&(h=h?Pt.ALL:Pt.NONE),(t.stencil||t.depth)&&!t.depthStencilAttachment&&t.ensureDepthStencilTexture();const c=!!t.depthStencilAttachment,d=this._activePass,p=d!==null&&d.renderTarget===t&&d.mipLevel===n&&d.layer===o&&d.depthStencil===c&&this._renderer.encoder.renderPassEncoder!==null&&h===Pt.NONE;if(this._renderer.pipeline.setRenderTarget(t),p){this._renderer.encoder.setViewport(i);return}const f=this.getDescriptor(t,e,s,n,o);u.descriptor=f,this._renderer.encoder.beginRenderPass(u),this._renderer.encoder.setViewport(i),this._activePass={renderTarget:t,mipLevel:n,layer:o,depthStencil:c}}finishRenderPass(){this._renderer.encoder.endRenderPass(),this._activePass=null}_getGpuColorTexture(t){if(t.colorAttachments.length===0)throw new Error("[GpuRenderTargetAdaptor] cannot get gpu color texture from a depth-only render target");const e=t.colorAttachments[0].texture;return e instanceof re&&e._gpuContext?e._gpuContext.getCurrentTexture():this._renderer.texture.getGpuSource(e)}getDescriptor(t,e,s,i=0,n=0){var o,a,l,u,h,c,d,p,f;typeof e=="boolean"&&(e=e?Pt.ALL:Pt.NONE);const m=this._renderTargetSystem,g=m.getGpuRenderTarget(t),_=t.colorAttachments.map((v,b)=>{var S,y;const w=v.texture,E=w instanceof re?w._gpuContext:null;let A,P;if(E){if(n!==0)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported for canvas targets.");A=E.getCurrentTexture().createView(v.viewDescriptor)}else A=this._renderer.texture.getTextureRenderTargetView(v.texture,i,n,v.viewDescriptor);let C=!1;g.msaaTextures[b]&&(P=A,A=this._renderer.texture.getTextureView(g.msaaTextures[b]),C=g.msaaTextures[b].transient);let O=v.loadOp;e!==void 0&&(O=e&Pt.COLOR?"clear":"load"),s!=null||(s=m.defaultClearColor);const F=(S=v.storeOp)!=null?S:"store",R={view:A,resolveTarget:P,storeOp:C?"discard":F,loadOp:O};O==="clear"&&(s!=null||(s=(y=v.clearValue)!=null?y:m.defaultClearColor),R.clearValue=s);for(const G in v)G!=="texture"&&G!=="viewDescriptor"&&G!=="clearValue"&&G!=="loadOp"&&G!=="storeOp"&&(R[G]=v[G]);return R});let x;if(t.depthStencilAttachment){g.msaa&&(t.depthStencilAttachment.texture.sampleCount=4),t.depthStencilAttachment.texture.transient=!!((o=g.msaaTextures[0])!=null&&o.transient);const v=t.depthStencilAttachment,b=v.texture.format.includes("stencil"),S=v.texture.format.includes("depth"),y=v.texture.transient?"discard":"store";x={view:this._renderer.texture.getTextureRenderTargetView(v.texture,i,n,v.viewDescriptor)};const w=(a=v.depthReadOnly)!=null?a:!1,E=(l=v.stencilReadOnly)!=null?l:w;b&&!E?(x.stencilLoadOp=e&Pt.STENCIL?"clear":(u=v.stencilLoadOp)!=null?u:"load",x.stencilStoreOp=(h=v.stencilStoreOp)!=null?h:y,x.stencilLoadOp==="clear"&&(x.stencilClearValue=(c=v.stencilClearValue)!=null?c:0)):b&&E&&(x.stencilReadOnly=!0),S&&!w?(x.depthLoadOp=e&Pt.DEPTH?"clear":(d=v.depthLoadOp)!=null?d:"load",x.depthStoreOp=(p=v.depthStoreOp)!=null?p:y,x.depthLoadOp==="clear"&&(x.depthClearValue=(f=v.depthClearValue)!=null?f:1)):S&&w&&(x.depthReadOnly=!0);for(const A in v)A!=="texture"&&A!=="viewDescriptor"&&A!=="stencilLoadOp"&&A!=="stencilStoreOp"&&A!=="stencilClearValue"&&A!=="stencilReadOnly"&&A!=="depthLoadOp"&&A!=="depthStoreOp"&&A!=="depthClearValue"&&A!=="depthReadOnly"&&(x[A]=v[A])}return{colorAttachments:_,depthStencilAttachment:x,label:t.label}}clear(t,e=!0,s,i,n=0,o=0){if(!e)return;const{gpu:a,encoder:l}=this._renderer,u=a.device;if(l.commandEncoder===null){const h=u.createCommandEncoder(),c=this.getDescriptor(t,e,s,n,o),d=h.beginRenderPass(c);d.setViewport(i.x,i.y,i.width,i.height,0,1),d.end();const p=h.finish();u.queue.submit([p])}else this.startRenderPass(t,e,s,i,n,o)}initGpuRenderTarget(t){var e;t.isRoot=!0;const s=new K0;return t.colorAttachments.forEach((i,n)=>{var o;const a=i.texture;if(a instanceof re){const l=(o=a._gpuContext)!=null?o:a._gpuContext=a.resource.getContext("webgpu"),u=a.transparent?"premultiplied":"opaque",h=rI(a.format);try{l.configure(tI({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:h,alphaMode:u},h==="rgba16float"?{toneMapping:{mode:"extended"}}:{}))}catch(c){console.error(c)}s.contexts[n]=l}if(s.msaa=a.source.antialias,a.antialias){const l=new ct({width:0,height:0,sampleCount:4,autoGenerateMipmaps:!1,transient:a.transient,arrayLayerCount:a.arrayLayerCount,format:a.format});s.msaaTextures[n]=l}}),s.msaa&&(s.msaaSamples=4,t.depthStencilAttachment&&(t.depthStencilAttachment.texture.sampleCount=4,t.depthStencilAttachment.texture.transient=!!((e=s.msaaTextures[0])!=null&&e.transient))),s}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.depthStencilAttachment&&e.msaa&&(t.depthStencilAttachment.texture.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorAttachments.forEach((s,i)=>{const n=s.texture,o=e.msaaTextures[i];o==null||o.resize(n.width,n.height,n._resolution)})}}class ic extends so{constructor(t){super(t),this.adaptor=new Q0,this.adaptor.init(t,this)}}ic.extension={type:[T.WebGPUSystem],name:"renderTarget"};class nc{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t,this._gpuProgramData=Object.create(null)}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,s=t.gpuLayout.map(n=>e.createBindGroupLayout({entries:n})),i={bindGroupLayouts:s};return this._gpuProgramData[t._layoutKey]={bindGroups:s,pipeline:e.createPipelineLayout(i)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}nc.extension={type:[T.WebGPUSystem],name:"shader"};const Ht={};Ht.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},Ht.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},Ht.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},Ht.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Ht.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Ht.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},Ht["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},Ht["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},Ht["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},Ht.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},Ht.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},Ht.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class oc{constructor(){this.defaultState=new Kt,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t,e,s){const i=t.blend?Ht[t.blendMode]||Ht.normal:void 0,n=[];for(let o=0;o>1,1),n=Math.max(n>>1,1)}}},e1=["right","left","top","bottom","front","back"];function r1(r){return{type:"cube",upload(t,e,s){const i=t.faces;for(let n=0;n pos : array, 3> = array, 3>( vec2(-1.0, -1.0), vec2(-1.0, 3.0), vec2(3.0, -1.0)); struct VertexOutput { @builtin(position) position : vec4, @location(0) texCoord : vec2, }; @vertex fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput { var output : VertexOutput; output.texCoord = pos[vertexIndex] * vec2(0.5, -0.5) + vec2(0.5); output.position = vec4(pos[vertexIndex], 0.0, 1.0); return output; } @group(0) @binding(0) var imgSampler : sampler; @group(0) @binding(1) var img : texture_2d; @fragment fn fragmentMain(@location(0) texCoord : vec2) -> @location(0) vec4 { 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 s=t;const i=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:i},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};s=this.device.createTexture(l)}const o=this.device.createCommandEncoder({}),a=e.getBindGroupLayout(0);for(let l=0;lt in r?iI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fo=(r,t)=>{for(var e in t||(t={}))aI.call(t,e)&&o1(r,e,t[e]);if(n1)for(var e of n1(t))lI.call(t,e)&&o1(r,e,t[e]);return r},uI=(r,t)=>nI(r,oI(t));class uc{constructor(t){this.textureView=null,this.textureViews=Object.create(null),this.gpuTexture=t}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.textureViews=null,this.gpuTexture=null}}function a1(r){return`${r.format||""}.${r.dimension||""}.${r.aspect||""}.${r.baseMipLevel||0}.${r.mipLevelCount||""}.${r.baseArrayLayer||0}.${r.arrayLayerCount||""}`}const hc=class wS{constructor(t){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=t,t.gc.addCollection(this,"_bindGroupHash","hash"),this._managedTextures=new kt({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"gpuTextureSource"});const e=fo({image:lc,buffer:J0,video:s1,compressed:t1},wS.uploadExtensions);this._uploads=uI(fo({},e),{cube:r1(e)})}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gpu=t,this._managedTextures.removeAll(),this._gpuSamplers=Object.create(null),this._mipmapGenerator=null}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;t.sampleCount>1?(e=GPUTextureUsage.RENDER_ATTACHMENT,t.transient&&this._renderer.device.extensions.transientAttachment&&(e|=GPUTextureUsage.TRANSIENT_ATTACHMENT)):(e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST,t.uploadMethodId!=="compressed"&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC));const s=ac[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},i=Math.ceil(t.pixelWidth/s.blockWidth)*s.blockWidth,n=Math.ceil(t.pixelHeight/s.blockHeight)*s.blockHeight,o={label:t.label,size:{width:i,height:n,depthOrArrayLayers:t.arrayLayerCount},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 uc(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 i1(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],s=e==null?void 0:e.gpuTexture;s?(s.width!==t.pixelWidth||s.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 Ee({0:e,1:e.style,2:new wt({uTextureMatrix:{type:"mat3x3",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t,e){var s;const i=t.source;i._gcLastUsed=this._renderer.gc.now;let n=i._gpuData[this._renderer.uid];n||(this.initSource(i),n=i._gpuData[this._renderer.uid]);const o=e?a1(e):0;return(s=n.textureViews)[o]||(s[o]=n.gpuTexture.createView(fo({dimension:i.viewDimension},e))),n.textureViews[o]}getTextureRenderTargetView(t,e=0,s=0,i){var n;const o=t.source;o._gcLastUsed=this._renderer.gc.now;let a=o._gpuData[this._renderer.uid];a||(this.initSource(o),a=o._gpuData[this._renderer.uid]);let l=s*(o.mipLevelCount||1)+e+1;return i&&(l=`${l}.${a1(i)}`),(n=a.textureViews)[l]||(n[l]=a.gpuTexture.createView(fo({dimension:"2d",baseMipLevel:e,mipLevelCount:1,baseArrayLayer:s,arrayLayerCount:1},i))),a.textureViews[l]}generateCanvas(t){const e=this._renderer,s=e.gpu.device.createCommandEncoder(),i=X.get().createCanvas();i.width=t.source.pixelWidth,i.height=t.source.pixelHeight;const n=i.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:X.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),s.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:i.width,height:i.height}),e.gpu.device.queue.submit([s.finish()]),i}getPixels(t){const e=this.generateCanvas(t),s=se.getOptimalCanvasAndContext(e.width,e.height),i=s.context;i.drawImage(e,0,0);const{width:n,height:o}=e,a=i.getImageData(0,0,n,o),l=new Uint8ClampedArray(a.data.buffer);return se.returnCanvasAndContext(s),{pixels:l,width:n,height:o}}destroy(){this._managedTextures.destroy();for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),s=this._bindGroupHash[e];s==null||s.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}};hc.extension={type:[T.WebGPUSystem],name:"texture"},hc.uploadExtensions=Object.create(null);let cc=hc;L.handleByMap(T.TextureUploaderWebGPU,cc.uploadExtensions);class dc{constructor(){this._maxTextures=0}contextChange(t){const e=new wt({uTransformMatrix:{value:new D,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;const s=Ur({name:"graphics",bits:[Yi,qi(this._maxTextures),ov,Lr]});this.shader=new ne({gpuProgram:s,resources:{localUniforms:e}})}execute(t,e){const s=e.context,i=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(s),u=n.encoder;u.setGeometry(a.geometry,i.gpuProgram);const h=n.globalUniforms.bindGroup;u.setBindGroup(0,h,i.gpuProgram);const c=n.renderPipes.uniformBatch.getUniformBindGroup(i.resources.localUniforms,!0);u.setBindGroup(2,c,i.gpuProgram);const d=l.instructions;let p=null;for(let f=0;f",value:new D}}}})}execute(t,e){const s=t.renderer;let i=e._shader;if(!i)i=this._shader,i.groups[2]=s.texture.getTextureBindGroup(e.texture);else if(!i.gpuProgram)return;const n=i.gpuProgram;if(n.autoAssignGlobalUniforms&&(i.groups[0]=s.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const o=t.localUniforms;i.groups[1]=s.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}s.encoder.draw({geometry:e._geometry,shader:i,state:e.state})}destroy(){this._shader.destroy(),this._shader=null}}pc.extension={type:[T.WebGPUPipesAdaptor],name:"mesh"};const hI=[...ro,tc,Zh,po,Qh,Kh,cc,ic,nc,oc,sc,qh,Jh,Yh],cI=[..._h,ec],dI=[Wu,pc,dc],l1=[],u1=[],h1=[],c1=[];L.handleByNamedList(T.WebGPUSystem,l1),L.handleByNamedList(T.WebGPUPipes,u1),L.handleByNamedList(T.WebGPUPipesAdaptor,h1),L.handleByNamedList(T.WebGPULoader,c1),L.add(...hI,...cI,...dI);class d1 extends Gr{constructor(){const t={name:"webgpu",type:Mt.WEBGPU,systems:l1,renderPipes:u1,renderPipeAdaptors:h1,loaders:c1};super(t)}}var pI={__proto__:null,WebGPURenderer:d1};const fI={POINTS:"point-list",LINES:"line-list",LINE_STRIP:"line-strip",TRIANGLES:"triangle-list",TRIANGLE_STRIP:"triangle-strip"},mI=new Proxy(fI,{get(r,t){return r[t]}});var fc=(r=>(r.CLAMP="clamp-to-edge",r.REPEAT="repeat",r.MIRRORED_REPEAT="mirror-repeat",r))(fc||{});const gI=new Proxy(fc,{get(r,t){return r[t]}});var mc=(r=>(r.NEAREST="nearest",r.LINEAR="linear",r))(mc||{});const _I=new Proxy(mc,{get(r,t){return r[t]}});var xI=Object.defineProperty,vI=Object.defineProperties,bI=Object.getOwnPropertyDescriptors,mo=Object.getOwnPropertySymbols,p1=Object.prototype.hasOwnProperty,f1=Object.prototype.propertyIsEnumerable,m1=(r,t,e)=>t in r?xI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yI=(r,t)=>{for(var e in t||(t={}))p1.call(t,e)&&m1(r,e,t[e]);if(mo)for(var e of mo(t))f1.call(t,e)&&m1(r,e,t[e]);return r},TI=(r,t)=>vI(r,bI(t)),SI=(r,t)=>{var e={};for(var s in r)p1.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&mo)for(var s of mo(r))t.indexOf(s)<0&&f1.call(r,s)&&(e[s]=r[s]);return e};class ls extends ct{constructor(t){const e=t,{faces:s}=e,i=SI(e,["faces"]);ls._validateFaces(s);const n=s.right,o=n.resolution,a=n.format,l=n.alphaMode;super(TI(yI({},i),{resource:s,width:n.width,height:n.height,dimensions:"2d",viewDimension:"cube",arrayLayerCount:6,resolution:o,format:a,alphaMode:l})),this.uploadMethodId="cube",this.faces=s;for(const u of Object.keys(s)){const h=s[u];h.on("update",this._onFaceUpdate,this),h.on("resize",this._onFaceResize,this),h.on("unload",this._onFaceUpdate,this)}}destroy(){const t=this.faces;if(t)for(const e of Object.keys(t)){const s=t[e];s.off("update",this._onFaceUpdate,this),s.off("resize",this._onFaceResize,this),s.off("unload",this._onFaceUpdate,this)}super.destroy()}_onFaceUpdate(){this.emit("update",this)}_onFaceResize(t){ls._validateFaces(this.faces),this.resize(t.width,t.height,t.resolution)}static _validateFaces(t){if(!t.right||!t.left||!t.top||!t.bottom||!t.front||!t.back)throw new Error("[CubeTextureSource] Requires { left, right, top, bottom, front, back } faces.");const e=t.right,s=e.pixelWidth,i=e.pixelHeight,n=e.format,o=e.alphaMode,a=e.resolution;for(const l of Object.keys(t)){const u=t[l];if(u.pixelWidth!==s||u.pixelHeight!==i)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different size. All faces must match.`);if(u.format!==n)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different format. All faces must match.`);if(u.alphaMode!==o)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different alphaMode. All faces must match.`);if(u.resolution!==a)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different resolution. All faces must match.`)}}}var wI=Object.defineProperty,EI=Object.defineProperties,AI=Object.getOwnPropertyDescriptors,go=Object.getOwnPropertySymbols,g1=Object.prototype.hasOwnProperty,_1=Object.prototype.propertyIsEnumerable,x1=(r,t,e)=>t in r?wI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,v1=(r,t)=>{for(var e in t||(t={}))g1.call(t,e)&&x1(r,e,t[e]);if(go)for(var e of go(t))_1.call(t,e)&&x1(r,e,t[e]);return r},PI=(r,t)=>EI(r,AI(t)),CI=(r,t)=>{var e={};for(var s in r)g1.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&go)for(var s of go(r))t.indexOf(s)<0&&_1.call(r,s)&&(e[s]=r[s]);return e};const gc=["left","right","top","bottom","front","back"];function RI(r,t){const e=t?v1({},t):{};delete e.label;const s=Object.keys(e).sort(),i=s.length?`|${s.map(n=>`${n}=${String(e[n])}`).join("&")}`:"";return`cube:${gc.map(n=>r[n]).join(",")}${i}`}class Uo extends It{constructor(t){var e;super(),this.uid=ut("cubeTexture"),this.destroyed=!1;const{label:s,source:i}=t;this.label=s,this.source=i,this.source.label=(e=this.label)!=null?e:this.source.label}static from(t,e=!1){if(t instanceof ls)return new Uo({source:t});const s=t,{faces:i}=s,n=CI(s,["faces"]);let o=null;const a=gc.every(c=>typeof i[c]=="string");if(!e&&a&&(o=RI(i,n),rt.has(o)))return rt.get(o);const l=c=>c.isTexture?c:B.from(c),u={};for(const c of gc)u[c]=l(i[c]).source;const h=new Uo({source:new ls(PI(v1({},n),{faces:u})),label:n.label});return o&&(rt.set(o,h),h.once("destroy",()=>{rt.has(o)&&rt.remove(o)})),h}destroy(t=!1){this.destroyed||(this.destroyed=!0,t&&this.source.destroy(),this.emit("destroy",this),this.removeAllListeners())}}const _c=Object.create(null),xc=Object.create(null);function MI(r){var t;if(r.type===Mt.WEBGPU)return xc[t=r.uid]||(xc[t]=r.gpu.device.createTexture({label:"ExternalSource placeholder",size:{width:1,height:1},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST})),xc[r.uid];if(!_c[r.uid]){const e=r.gl,s=e.createTexture();e.bindTexture(e.TEXTURE_2D,s),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,null),_c[r.uid]=s}return _c[r.uid]}class OI extends ct{constructor({resource:t,renderer:e,label:s,width:i,height:n}){var o,a;t||(t=MI(e)),i||(i=(o=i!=null?i:t==null?void 0:t.width)!=null?o:1),n||(n=(a=n!=null?n:t==null?void 0:t.height)!=null?a:1),super({resource:t,width:i,height:n,label:s,autoGarbageCollect:!1}),this._renderer=e,this._initGpuData(t)}static test(t){return globalThis.GPUTexture&&t instanceof GPUTexture||globalThis.WebGLTexture&&t instanceof WebGLTexture}_validateTexture(t){const e=this._renderer,s=!!e.gpu,i=globalThis.GPUTexture&&t instanceof GPUTexture,n=globalThis.WebGLTexture&&t instanceof WebGLTexture;if(s&&n)throw new Error("Cannot use WebGLTexture with a WebGPU renderer");if(!s&&i)throw new Error("Cannot use GPUTexture with a WebGL renderer");if(!s){const o=e.gl;if(o&&!o.isTexture(t))throw new Error("WebGLTexture does not belong to this renderer's WebGL context")}}_initGpuData(t){const e=this._renderer;this._validateTexture(t),e.gpu?this._gpuData[e.uid]=new uc(t):this._gpuData[e.uid]=new Lh(t)}updateGPUTexture(t,e,s){const i=this._renderer,n=this._gpuData[i.uid];if(this.resource=t,i.gpu){this._validateTexture(t);const o=n;o.gpuTexture!==t&&(o.gpuTexture=t,o.textureView=null,o.textureViews=Object.create(null),this._resourceId=ut("resource"),this.emit("change",this));const a=e!=null?e:t.width,l=s!=null?s:t.height;this.resize(a,l)}else{this._validateTexture(t);const o=n;o.texture=t,e!==void 0&&s!==void 0&&this.resize(e,s)}this.emit("update",this)}destroy(){const t=this._renderer;delete this._gpuData[t.uid],super.destroy()}}class GI{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,s){const i=e.width,n=e.height;if(s){const o=t.width/2/i,a=t.height/2/n,l=t.x/i+o,u=t.y/n+a;s=H.add(s,H.NW),this.x0=l+o*H.uX(s),this.y0=u+a*H.uY(s),s=H.add(s,2),this.x1=l+o*H.uX(s),this.y1=u+a*H.uY(s),s=H.add(s,2),this.x2=l+o*H.uX(s),this.y2=u+a*H.uY(s),s=H.add(s,2),this.x3=l+o*H.uX(s),this.y3=u+a*H.uY(s)}else this.x0=t.x/i,this.y0=t.y/n,this.x1=(t.x+t.width)/i,this.y1=t.y/n,this.x2=(t.x+t.width)/i,this.y2=(t.y+t.height)/n,this.x3=t.x/i,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 II(r){const t=r.toString(),e=t.indexOf("{"),s=t.lastIndexOf("}");if(e===-1||s===-1)throw new Error("getFunctionBody: No body found in function definition");return t.slice(e+1,s).trim()}function FI(r,t){return r.getFastGlobalBounds(!0,t)}var BI=Object.defineProperty,_o=Object.getOwnPropertySymbols,b1=Object.prototype.hasOwnProperty,y1=Object.prototype.propertyIsEnumerable,T1=(r,t,e)=>t in r?BI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,DI=(r,t)=>{for(var e in t||(t={}))b1.call(t,e)&&T1(r,e,t[e]);if(_o)for(var e of _o(t))y1.call(t,e)&&T1(r,e,t[e]);return r},$I=(r,t)=>{var e={};for(var s in r)b1.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&_o)for(var s of _o(r))t.indexOf(s)<0&&y1.call(r,s)&&(e[s]=r[s]);return e};class UI extends Se{constructor(t){var e,s;typeof t=="function"&&(t={render:t});const i=t,{render:n}=i,o=$I(i,["render"]);super(DI({label:"RenderContainer"},o)),this.renderPipeId="customRender",this.batched=!1,n&&(this.render=n),this.containsPoint=(e=t.containsPoint)!=null?e:(()=>!1),this.addBounds=(s=t.addBounds)!=null?s:(()=>!1)}updateBounds(){this._bounds.clear(),this.addBounds(this._bounds)}render(t){}}function kI(r,t,e){const s=e.renderPipes?e:e.batch.renderer;return r.collectRenderables(t,s,null)}function LI(r,t){const e=t._scale,s=t._pivot,i=t._position,n=e._x,o=e._y,a=s._x,l=s._y;r.a=t._cx*n,r.b=t._sx*n,r.c=t._cy*o,r.d=t._sy*o,r.tx=i._x-(a*r.a+l*r.c),r.ty=i._y-(a*r.b+l*r.d)}function NI(r,t,e){const s=r.a,i=r.b,n=r.c,o=r.d,a=r.tx,l=r.ty,u=t.a,h=t.b,c=t.c,d=t.d;e.a=s*u+i*c,e.b=s*h+i*d,e.c=n*u+o*c,e.d=n*h+o*d,e.tx=a*u+l*c+t.tx,e.ty=a*h+l*d+t.ty}class S1{constructor(){this._gradients=[],this._nextId=0}addStyle(t){var e;if(!(t.fill instanceof Lt))return null;const s=`pixi-grad-${this._nextId++}`;return this._gradients.push({id:s,gradient:t.fill,textureSpace:(e=t.textureSpace)!=null?e:"local"}),`url(#${s})`}build(){var t,e,s,i,n,o,a,l,u,h,c,d,p,f,m,g,_;if(this._gradients.length===0)return"";const x=[""];for(const{id:v,gradient:b,textureSpace:S}of this._gradients){const y=S==="global"?"userSpaceOnUse":"objectBoundingBox",w=jI(b.colorStops);if(b.type==="radial"){const E=(e=(t=b.outerCenter)==null?void 0:t.x)!=null?e:.5,A=(i=(s=b.outerCenter)==null?void 0:s.y)!=null?i:.5,P=(n=b.outerRadius)!=null?n:.5,C=(a=(o=b.center)==null?void 0:o.x)!=null?a:E,O=(u=(l=b.center)==null?void 0:l.y)!=null?u:A;x.push(``,w,"")}else{const E=(c=(h=b.start)==null?void 0:h.x)!=null?c:0,A=(p=(d=b.start)==null?void 0:d.y)!=null?p:0,P=(m=(f=b.end)==null?void 0:f.x)!=null?m:1,C=(_=(g=b.end)==null?void 0:g.y)!=null?_:0;x.push(``,w,"")}}return x.push(""),x.join("")}}function jI(r){return r.map(t=>{const e=tt.shared.setValue(t.color).toHex();return``}).join("")}const Tr=Math.PI*2,XI=new Set(["regularPoly","roundPoly","roundShape","filletRect","chamferRect","arcTo"]);function Ke(r,t=2,e=!1){var s,i,n;if(r.instructions.some(l=>XI.has(l.action)))return VI(r,t,e);const o=[];let a=!1;for(let l=0;l0&&(s-=Tr):s<0&&(s+=Tr),Math.abs(s)>=Tr-1e-6}function W(r,t){return parseFloat(r.toFixed(t)).toString()}function $t(r,t,e,s){if(e&&!e.isIdentity()){const i=e.a*r+e.c*t+e.tx,n=e.b*r+e.d*t+e.ty;return`${W(i,s)} ${W(n,s)}`}return`${W(r,s)} ${W(t,s)}`}function zI(r,t,e,s,i,n,o,a,l=!1){let u=i-s;if(n?u>0&&(u-=Tr):u<0&&(u+=Tr),Math.abs(u)>=Tr-1e-6)return ii(r,t,e,e,null,a,l);if(l){const g=[];for(let _=0;_<=32;_++){const x=s+_/32*u,v=r+e*Math.cos(x),b=t+e*Math.sin(x),S=_===0?o?"L":"M":"L";g.push(`${S}${W(v,a)} ${W(b,a)}`)}return g.join("")}const h=r+e*Math.cos(s),c=t+e*Math.sin(s),d=r+e*Math.cos(i),p=t+e*Math.sin(i),f=Math.abs(u)>Math.PI?1:0,m=n?0:1;return`${o?"L":"M"}${W(h,a)} ${W(c,a)}A${W(e,a)} ${W(e,a)} 0 ${f} ${m} ${W(d,a)} ${W(p,a)}`}function ii(r,t,e,s,i,n,o=!1){const a=i&&!i.isIdentity()?i:null;if(!a&&!o)return`M${W(r-e,n)} ${W(t,n)}A${W(e,n)} ${W(s,n)} 0 1 1 ${W(r+e,n)} ${W(t,n)}A${W(e,n)} ${W(s,n)} 0 1 1 ${W(r-e,n)} ${W(t,n)}Z`;const l=64,u=[];for(let h=0;h`);break}case"stroke":{const m=f;let g=Ke(m.data.path,t);m.data.hole&&(g+=Ke(m.data.hole,t,!0));const _=P1(m.data.style,s);i.push(``);break}case"texture":break}o++}const a=e.bounds,l=parseFloat(a.minX.toFixed(t)),u=parseFloat(a.minY.toFixed(t)),h=parseFloat((a.maxX-a.minX).toFixed(t)),c=parseFloat((a.maxY-a.minY).toFixed(t)),d=s.build(),p=i.join("");return`${d}${p}`}function KI(r){r instanceof ge&&(r={path:r,textureMatrix:null,out:null});const t=[],e=[],s=[],i=r.path.shapePath,n=r.textureMatrix;i.shapePrimitives.forEach(({shape:a,transform:l})=>{const u=s.length,h=t.length/2,c=[],d=Xe[a.type];d.build(a,c),l&&tn(c,l),d.triangulate(c,t,2,h,s,u);const p=e.length/2;n?(l&&n.append(l.clone().invert()),gl(t,2,h,e,p,2,t.length/2-h,n)):_l(e,p,2,t.length/2-h)});const o=r.out;return o?(o.positions=new Float32Array(t),o.uvs=new Float32Array(e),o.indices=new Uint32Array(s),o):new Ve({positions:new Float32Array(t),uvs:new Float32Array(e),indices:new Uint32Array(s)})}var qI=Object.defineProperty,C1=Object.getOwnPropertySymbols,ZI=Object.prototype.hasOwnProperty,QI=Object.prototype.propertyIsEnumerable,R1=(r,t,e)=>t in r?qI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,M1=(r,t)=>{for(var e in t||(t={}))ZI.call(t,e)&&R1(r,e,t[e]);if(C1)for(var e of C1(t))QI.call(t,e)&&R1(r,e,t[e]);return r};const O1=class ES extends dt{constructor(t={}){t=M1(M1({},ES.defaultOptions),t),super(),this.renderLayerChildren=[],this.sortableChildren=t.sortableChildren,this.sortFunction=t.sortFunction}attach(...t){for(let e=0;er.zIndex-t.zIndex};let JI=O1;var tF=Object.defineProperty,G1=Object.getOwnPropertySymbols,eF=Object.prototype.hasOwnProperty,rF=Object.prototype.propertyIsEnumerable,I1=(r,t,e)=>t in r?tF(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,F1=(r,t)=>{for(var e in t||(t={}))eF.call(t,e)&&I1(r,e,t[e]);if(G1)for(var e of G1(t))rF.call(t,e)&&I1(r,e,t[e]);return r};const B1=class AS extends Ve{constructor(...t){var e;super({});let s=(e=t[0])!=null?e:{};typeof s=="number"&&(s={width:s,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(s)}build(t){var e,s,i,n;t=F1(F1({},AS.defaultOptions),t),this.verticesX=(e=this.verticesX)!=null?e:t.verticesX,this.verticesY=(s=this.verticesY)!=null?s:t.verticesY,this.width=(i=this.width)!=null?i:t.width,this.height=(n=this.height)!=null?n:t.height;const o=this.verticesX*this.verticesY,a=[],l=[],u=[],h=this.verticesX-1,c=this.verticesY-1,d=this.width/h,p=this.height/c;for(let m=0;mt in r?lF(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,bc=(r,t)=>{for(var e in t||(t={}))j1.call(t,e)&&H1(r,e,t[e]);if(bo)for(var e of bo(t))X1.call(t,e)&&H1(r,e,t[e]);return r},cF=(r,t)=>uF(r,hF(t)),dF=(r,t)=>{var e={};for(var s in r)j1.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&bo)for(var s of bo(r))t.indexOf(s)<0&&X1.call(r,s)&&(e[s]=r[s]);return e};const z1=class PS extends Qr{constructor(t){t=bc(bc({},PS.defaultOptions),t);const e=t,{texture:s,verticesX:i,verticesY:n}=e,o=dF(e,["texture","verticesX","verticesY"]),a=new N1(ce({width:s.width,height:s.height,verticesX:i,verticesY:n}));super(ce(cF(bc({},o),{geometry:a}))),this._texture=s,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:s}=this.texture;(t.width!==e||t.height!==s)&&(t.width=e,t.height=s,t.updateProjection())}set texture(t){this._texture!==t&&(super.texture=t,this.textureUpdated())}get texture(){return this._texture}setCorners(t,e,s,i,n,o,a,l){this.geometry.setCorners(t,e,s,i,n,o,a,l)}};z1.defaultOptions={texture:B.WHITE,verticesX:10,verticesY:10,x0:0,y0:0,x1:100,y1:0,x2:100,y2:100,x3:0,y3:100};let pF=z1;var fF=Object.defineProperty,mF=Object.defineProperties,gF=Object.getOwnPropertyDescriptors,yo=Object.getOwnPropertySymbols,W1=Object.prototype.hasOwnProperty,V1=Object.prototype.propertyIsEnumerable,Y1=(r,t,e)=>t in r?fF(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_F=(r,t)=>{for(var e in t||(t={}))W1.call(t,e)&&Y1(r,e,t[e]);if(yo)for(var e of yo(t))V1.call(t,e)&&Y1(r,e,t[e]);return r},xF=(r,t)=>mF(r,gF(t)),vF=(r,t)=>{var e={};for(var s in r)W1.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&yo)for(var s of yo(r))t.indexOf(s)<0&&V1.call(r,s)&&(e[s]=r[s]);return e};class bF extends Qr{constructor(t){const e=t,{texture:s,verticesX:i,verticesY:n}=e,o=vF(e,["texture","verticesX","verticesY"]),a=new xo(ce({width:s.width,height:s.height,verticesX:i,verticesY:n}));super(ce(xF(_F({},o),{geometry:a,texture:s}))),this.texture=s,this.autoResize=!0}textureUpdated(){const t=this.geometry,{width:e,height:s}=this.texture;this.autoResize&&(t.width!==e||t.height!==s)&&(t.width=e,t.height=s,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 yF=Object.defineProperty,K1=Object.getOwnPropertySymbols,TF=Object.prototype.hasOwnProperty,SF=Object.prototype.propertyIsEnumerable,q1=(r,t,e)=>t in r?yF(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Z1=(r,t)=>{for(var e in t||(t={}))TF.call(t,e)&&q1(r,e,t[e]);if(K1)for(var e of K1(t))SF.call(t,e)&&q1(r,e,t[e]);return r};const Q1=class CS extends Ve{constructor(t){const{width:e,points:s,textureScale:i}=Z1(Z1({},CS.defaultOptions),t);super({positions:new Float32Array(s.length*4),uvs:new Float32Array(s.length*4),indices:new Uint32Array((s.length-1)*6)}),this.points=s,this._width=e,this.textureScale=i,this._build()}get width(){return this._width}_build(){const t=this.points;if(!t)return;const e=this.getBuffer("aPosition"),s=this.getBuffer("aUV"),i=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),s.data=new Float32Array(t.length*4),i.data=new Uint16Array((t.length-1)*6));const n=s.data,o=i.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,h=t.length;for(let d=0;d0){const f=l.x-t[d].x,m=l.y-t[d].y,g=Math.sqrt(f*f+m*m);l=t[d],a+=g/u}else a=d/(h-1);n[p]=a,n[p+1]=0,n[p+2]=a,n[p+3]=1}let c=0;for(let d=0;d0?this.textureScale*this._width/2:this._width/2;for(let u=0;u1&&(d=1);const p=Math.sqrt(i*i+n*n);p<1e-6?(i=0,n=0):(i/=p,n/=p,i*=l,n*=l),o[c]=h.x+i,o[c+1]=h.y+n,o[c+2]=h.x-i,o[c+3]=h.y-n,e=h}this.buffers[0].update()}update(){this.textureScale>0?this._build():this.updateVertices()}};Q1.defaultOptions={width:200,points:[],textureScale:0};let J1=Q1;var wF=Object.defineProperty,EF=Object.defineProperties,AF=Object.getOwnPropertyDescriptors,To=Object.getOwnPropertySymbols,tT=Object.prototype.hasOwnProperty,eT=Object.prototype.propertyIsEnumerable,rT=(r,t,e)=>t in r?wF(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yc=(r,t)=>{for(var e in t||(t={}))tT.call(t,e)&&rT(r,e,t[e]);if(To)for(var e of To(t))eT.call(t,e)&&rT(r,e,t[e]);return r},PF=(r,t)=>EF(r,AF(t)),CF=(r,t)=>{var e={};for(var s in r)tT.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&To)for(var s of To(r))t.indexOf(s)<0&&eT.call(r,s)&&(e[s]=r[s]);return e};const sT=class RS extends Qr{constructor(t){const e=yc(yc({},RS.defaultOptions),t),{width:s,texture:i,points:n,textureScale:o}=e,a=CF(e,["width","texture","points","textureScale"]),l=new J1(ce({width:s!=null?s:i.height,points:n,textureScale:o}));o>0&&(i.source.style.addressMode="repeat"),super(ce(PF(yc({},a),{texture:i,geometry:l}))),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())}};sT.defaultOptions={textureScale:0};let RF=sT;var MF=Object.defineProperty,OF=Object.defineProperties,GF=Object.getOwnPropertyDescriptors,So=Object.getOwnPropertySymbols,iT=Object.prototype.hasOwnProperty,nT=Object.prototype.propertyIsEnumerable,oT=(r,t,e)=>t in r?MF(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,IF=(r,t)=>{for(var e in t||(t={}))iT.call(t,e)&&oT(r,e,t[e]);if(So)for(var e of So(t))nT.call(t,e)&&oT(r,e,t[e]);return r},FF=(r,t)=>OF(r,GF(t)),BF=(r,t)=>{var e={};for(var s in r)iT.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&So)for(var s of So(r))t.indexOf(s)<0&&nT.call(r,s)&&(e[s]=r[s]);return e};class DF extends Qr{constructor(t){const e=t,{texture:s,vertices:i,uvs:n,indices:o,topology:a}=e,l=BF(e,["texture","vertices","uvs","indices","topology"]),u=new Ve(ce({positions:i,uvs:n,indices:o,topology:a}));super(ce(FF(IF({},l),{texture:s,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 $F(r,t){const{width:e,height:s}=r.frame;return t.scale(1/e,1/s),t}class aT{execute(t,e){var s,i,n;const o=t.renderer,a=o.canvasContext.activeContext,l=e.particleChildren,u=e.texture;a.save(),o.canvasContext.setContextTransform(e.worldTransform,e.roundPixels),o.canvasContext.setBlendMode(e.groupBlendMode);const h=e.groupColorAlpha,c=(i=(s=o.filter)==null?void 0:s.alphaMultiplier)!=null?i:1,d=(h>>>24&255)/255*c;for(let p=0;p>>24&255)/255*d;if(_<=0)continue;const x=g&16777215,v=((x&255)<<16)+(x&65280)+(x>>16&255);let b=m.source.resource;v!==16777215&&(b=Z.getTintedCanvas({texture:m},v));const S=m.frame,y=m.source.resolution,w=S.x*y,E=S.y*y,A=S.width*y,P=S.height*y;a.globalAlpha=_;const C=-f.anchorX*S.width,O=-f.anchorY*S.height;f.rotation!==0||f.scaleX!==1||f.scaleY!==1?(a.save(),a.translate(f.x,f.y),a.rotate(f.rotation),a.scale(f.scaleX,f.scaleY),a.drawImage(b,w,E,A,P,C,O,S.width,S.height),a.restore()):a.drawImage(b,w,E,A,P,f.x+C,f.y+O,S.width,S.height)}a.restore()}}function Tc(r,t=null){const e=r*6;if(e>65535?t||(t=new Uint32Array(e)):t||(t=new Uint16Array(e)),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let s=0,i=0;sthis._size&&(e=!0,this._size=Math.max(t.length,this._size*1.5|0),this.staticAttributeBuffer=new pr(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new pr(this._size*this._dynamicStride*4*4),this.indexBuffer=Tc(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const s=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,s.float32View,s.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){const i=this.staticAttributeBuffer;this._staticUpload(t,i.float32View,i.uint32View),this._staticBuffer.setDataWithSize(i.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}function UF(r){const t=[];for(const e in r){const s=r[e];t.push(e,s.code,s.dynamic?"d":"s")}return t.join("_")}var cT=`varying vec2 vUV; varying vec4 vColor; uniform sampler2D uTexture; void main(void){ vec4 color = texture2D(uTexture, vUV) * vColor; gl_FragColor = color; }`,dT=`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; } `,Sc=` struct ParticleUniforms { uTranslationMatrix:mat3x3, uColor:vec4, uRound:f32, uResolution:vec2, }; fn roundPixels(position: vec2, targetSize: vec2) -> vec2 { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } @group(0) @binding(0) var uniforms: ParticleUniforms; @group(1) @binding(0) var uTexture: texture_2d; @group(1) @binding(1) var uSampler : sampler; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2, @location(1) color : vec4, }; @vertex fn mainVertex( @location(0) aVertex: vec2, @location(1) aPosition: vec2, @location(2) aUV: vec2, @location(3) aColor: vec4, @location(4) aRotation: f32, ) -> VSOutput { let v = vec2( aVertex.x * cos(aRotation) - aVertex.y * sin(aRotation), aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation) ) + aPosition; var position = vec4((uniforms.uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0); if(uniforms.uRound == 1.0) { position = vec4(roundPixels(position.xy, uniforms.uResolution), position.zw); } let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor; return VSOutput( position, aUV, vColor, ); } @fragment fn mainFragment( @location(0) uv: vec2, @location(1) color: vec4, @builtin(position) position: vec4, ) -> @location(0) vec4 { var sample = textureSample(uTexture, uSampler, uv) * color; return sample; }`;class pT extends ne{constructor(){const t=Yt.from({vertex:dT,fragment:cT}),e=zt.from({fragment:{source:Sc,entryPoint:"mainFragment"},vertex:{source:Sc,entryPoint:"mainVertex"}});super({glProgram:t,gpuProgram:e,resources:{uTexture:B.WHITE.source,uSampler:new ae({}),uniforms:{uTranslationMatrix:{value:new D,type:"mat3x3"},uColor:{value:new tt(16777215),type:"vec4"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2"}}}})}}class ni{constructor(t,e){this.state=Kt.for2d(),this.localUniforms=new wt({uTranslationMatrix:{value:new D,type:"mat3x3"},uColor:{value:new Float32Array(4),type:"vec4"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new pT,this.state=Kt.for2d(),this._managedContainers=new kt({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 hT({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 s=this.renderer,i=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const n=this.state;i.update(e,t._childrenDirty),t._childrenDirty=!1,n.blendMode=Dr(t.groupBlendMode,t.texture._source);const o=this.localUniforms.uniforms,a=o.uTranslationMatrix;t.worldTransform.copyTo(a);const l=s.globalUniforms.globalUniformData;a.tx-=l.offset.x,a.ty-=l.offset.y,a.prepend(l.projectionMatrix),o.uResolution=l.resolution,o.uRound=s._roundPixels|t._roundPixels;const u=t.groupColorAlpha,h=l.worldColor,c=(u>>>24)*(h>>>24)/255|0,d=be(u&16777215,h&16777215);Zr((c<<24|d)>>>0,o.uColor,0),this.adaptor.execute(this,t)}destroy(){this._managedContainers.destroy(),this.renderer=null,this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}ni.extension={type:[T.CanvasPipes],name:"particle"};class wc extends ni{constructor(t){super(t,new aT)}}wc.extension={type:[T.CanvasPipes],name:"particle"};class fT{execute(t,e){const s=t.state,i=t.renderer,n=e.shader||t.defaultShader;n.resources.uTexture=e.texture._source,n.resources.uniforms=t.localUniforms;const o=i.gl,a=t.getBuffers(e);i.shader.bind(n),i.state.set(s),i.geometry.bind(a.geometry,n.glProgram);const l=a.geometry.indexBuffer.data.BYTES_PER_ELEMENT===2?o.UNSIGNED_SHORT:o.UNSIGNED_INT;o.drawElements(o.TRIANGLES,e.particleChildren.length*6,l,0)}}class Ec extends ni{constructor(t){super(t,new fT)}}Ec.extension={type:[T.WebGLPipes],name:"particle"};class mT{execute(t,e){const s=t.renderer,i=e.shader||t.defaultShader;i.groups[0]=s.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),i.groups[1]=s.texture.getTextureBindGroup(e.texture);const n=t.state,o=t.getBuffers(e);s.encoder.draw({geometry:o.geometry,shader:e.shader||t.defaultShader,state:n,size:e.particleChildren.length*6})}}class Ac extends ni{constructor(t){super(t,new mT)}}Ac.extension={type:[T.WebGPUPipes],name:"particle"};var kF=Object.defineProperty,gT=Object.getOwnPropertySymbols,LF=Object.prototype.hasOwnProperty,NF=Object.prototype.propertyIsEnumerable,_T=(r,t,e)=>t in r?kF(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xT=(r,t)=>{for(var e in t||(t={}))LF.call(t,e)&&_T(r,e,t[e]);if(gT)for(var e of gT(t))NF.call(t,e)&&_T(r,e,t[e]);return r};const vT=class Hc{constructor(t){if(t instanceof B)this.texture=t,Ei(this,Hc.defaultOptions,{});else{const e=xT(xT({},Hc.defaultOptions),t);Ei(this,e,{})}}get alpha(){return this._alpha}set alpha(t){this._alpha=Math.min(Math.max(t,0),1),this._updateColor()}get tint(){return ye(this._tint)}set tint(t){this._tint=tt.shared.setValue(t!=null?t:16777215).toBgrNumber(),this._updateColor()}_updateColor(){this.color=this._tint+((this._alpha*255|0)<<24)}};vT.defaultOptions={anchorX:0,anchorY:0,x:0,y:0,scaleX:1,scaleY:1,rotation:0,tint:16777215,alpha:1};let jF=vT;const Pc={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}};L.add(Ec),L.add(Ac),L.add(wc);var XF=Object.defineProperty,HF=Object.defineProperties,zF=Object.getOwnPropertyDescriptors,wo=Object.getOwnPropertySymbols,bT=Object.prototype.hasOwnProperty,yT=Object.prototype.propertyIsEnumerable,TT=(r,t,e)=>t in r?XF(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,is=(r,t)=>{for(var e in t||(t={}))bT.call(t,e)&&TT(r,e,t[e]);if(wo)for(var e of wo(t))yT.call(t,e)&&TT(r,e,t[e]);return r},ST=(r,t)=>HF(r,zF(t)),WF=(r,t)=>{var e={};for(var s in r)bT.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&wo)for(var s of wo(r))t.indexOf(s)<0&&yT.call(r,s)&&(e[s]=r[s]);return e};const VF=new Ct(0,0,0,0),wT=class zc extends Se{constructor(t={}){t=ST(is(is({},zc.defaultOptions),t),{dynamicProperties:is(is({},zc.defaultOptions.dynamicProperties),t==null?void 0:t.dynamicProperties)});const e=t,{dynamicProperties:s,shader:i,roundPixels:n,texture:o,particles:a}=e,l=WF(e,["dynamicProperties","shader","roundPixels","texture","particles"]);super(is({label:"ParticleContainer"},l)),this.renderPipeId="particle",this.batched=!1,this._childrenDirty=!1,this.texture=o||null,this.shader=i,this._properties={};for(const u in Pc){const h=Pc[u],c=s[u];this._properties[u]=ST(is({},h),{dynamic:c})}this.allowChildren=!0,this.roundPixels=n!=null?n:!1,this.particleChildren=a!=null?a:[]}addParticle(...t){for(let e=0;e-1&&(this.particleChildren.splice(i,1),e=!0)}return e&&this.onViewUpdate(),t[0]}update(){this._childrenDirty=!0}onViewUpdate(){this._childrenDirty=!0,super.onViewUpdate()}get bounds(){return VF}updateBounds(){}destroy(t=!1){var e,s,i;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=(s=this.texture)!=null?s:(e=this.particleChildren[0])==null?void 0:e.texture;o&&o.destroy(n)}this.texture=null,(i=this.shader)==null||i.destroy()}removeParticles(t,e){t!=null||(t=0),e!=null||(e=this.particleChildren.length);const s=this.particleChildren.splice(t,e-t);return this.onViewUpdate(),s}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")}};wT.defaultOptions={dynamicProperties:{vertex:!1,position:!0,rotation:!1,uvs:!1,color:!1},roundPixels:!1};let YF=wT;const Cc=[[0,0],[0,0],[0,0]],Rc=[[0,0],[0,0],[0,0]],Mc=[[0,0],[0,0],[0,0]],Oc=[[0,0],[0,0],[0,0]];function Eo(r,t,e,s,i,n,o){r[0][0]=t,r[0][1]=e,r[1][0]=s,r[1][1]=i,r[2][0]=n,r[2][1]=o}class Gc{constructor(t){this._renderer=t}validateRenderable(t){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){var e,s,i,n,o,a;const l=this._renderer,u=l.canvasContext,h=u.activeContext;h.save();const c=t.groupTransform,d=l._roundPixels|t._roundPixels;u.setContextTransform(c,d===1),u.setBlendMode(t.groupBlendMode);const p=(s=(e=l.globalUniforms.globalUniformData)==null?void 0:e.worldColor)!=null?s:4294967295,f=t.groupColorAlpha,m=(p>>>24&255)/255,g=(f>>>24&255)/255,_=(n=(i=l.filter)==null?void 0:i.alphaMultiplier)!=null?n:1,x=m*g*_;if(x<=0){h.restore();return}h.globalAlpha=x;const v=p&16777215,b=f&16777215,S=ye(be(b,v)),y=t.texture,w=Z.getCanvasSource(y);if(!w){h.restore();return}const E=u.smoothProperty,A=y.source.style.scaleMode!=="nearest";h[E]!==A&&(h[E]=A);const P=S!==16777215||y.rotate!==0,C=P?Z.getTintedCanvas({texture:y},S):w,{leftWidth:O,topHeight:F,rightWidth:R,bottomHeight:G,width:M,height:I}=t,U=O+R,j=F+G,Q=Math.min(U>M?M/U:1,j>I?I/j:1,1),K=O*Q,N=R*Q,k=F*Q,$=G*Q,z=Math.max(0,M-K-N),et=Math.max(0,I-k-$),mt=t.anchor,J=(a=(o=y.source._resolution)!=null?o:y.source.resolution)!=null?a:1;let ot=y.frame.x*J,nt=y.frame.y*J;const ht=-mt.x*M,Tt=-mt.y*I,Et=O*J,_t=F*J,q=R*J,Wt=G*J;let Gt=y.frame.width*J,Me=y.frame.height*J;P&&(ot=0,nt=0,Gt=C.width,Me=C.height);const Le=Gt-Et-q,Ze=Me-_t-Wt,us=Le>0?ot+Et:Math.max(ot,Math.min(ot+Et,ot+Gt-1)),Qe=Le>0?Le:1,Je=Ze>0?nt+_t:Math.max(nt,Math.min(nt+_t,nt+Me-1)),Oe=Ze>0?Ze:1;Eo(Cc,ot,Et,us,Qe,ot+Gt-q,q),Eo(Rc,nt,_t,Je,Oe,nt+Me-Wt,Wt),Eo(Mc,ht,K,ht+K,z,ht+M-N,N),Eo(Oc,Tt,k,Tt+k,et,Tt+I-$,$);for(let te=0;te<3;te++){const ci=Mc[te][1];if(ci<=0)continue;const hs=Cc[te][0],di=Cc[te][1],pi=Mc[te][0];for(let Ge=0;Ge<3;Ge++){const cs=Oc[Ge][1];cs<=0||h.drawImage(C,hs,Rc[Ge][0],di,Rc[Ge][1],pi,Oc[Ge][0],ci,cs)}}h.restore()}destroy(){this._renderer=null}}Gc.extension={type:[T.CanvasPipes],name:"nineSliceSprite"};var KF=Object.defineProperty,ET=Object.getOwnPropertySymbols,qF=Object.prototype.hasOwnProperty,ZF=Object.prototype.propertyIsEnumerable,AT=(r,t,e)=>t in r?KF(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,PT=(r,t)=>{for(var e in t||(t={}))qF.call(t,e)&&AT(r,e,t[e]);if(ET)for(var e of ET(t))ZF.call(t,e)&&AT(r,e,t[e]);return r};const CT=class Mo extends xo{constructor(t={}){var e,s;t=PT(PT({},Mo.defaultOptions),t),super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this._trimX=0,this._trimY=0,this._trimWidth=(e=t.originalWidth)!=null?e:Mo.defaultOptions.originalWidth,this._trimHeight=(s=t.originalHeight)!=null?s:Mo.defaultOptions.originalHeight,this.update(t)}update(t){var e,s,i,n,o,a,l,u,h,c,d,p,f,m,g,_,x,v;this.width=(e=t.width)!=null?e:this.width,this.height=(s=t.height)!=null?s:this.height,this._originalWidth=(i=t.originalWidth)!=null?i: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=(h=t.anchor)==null?void 0:h.x,this._anchorY=(c=t.anchor)==null?void 0:c.y,t.trim!==void 0?(this._trimX=(p=(d=t.trim)==null?void 0:d.x)!=null?p:0,this._trimY=(m=(f=t.trim)==null?void 0:f.y)!=null?m:0,this._trimWidth=(_=(g=t.trim)==null?void 0:g.width)!=null?_:this._originalWidth,this._trimHeight=(v=(x=t.trim)==null?void 0:x.height)!=null?v:this._originalHeight):(this._trimWidth=this._originalWidth,this._trimHeight=this._originalHeight),this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:s,_leftWidth:i,_rightWidth:n,_topHeight:o,_bottomHeight:a,_anchorX:l,_anchorY:u}=this,h=i+n,c=e>h?1:e/h,d=o+a,p=s>d?1:s/d,f=Math.min(c,p),m=l*e,g=u*s;t[0]=t[8]=t[16]=t[24]=-m,t[2]=t[10]=t[18]=t[26]=i*f-m,t[4]=t[12]=t[20]=t[28]=e-n*f-m,t[6]=t[14]=t[22]=t[30]=e-m,t[1]=t[3]=t[5]=t[7]=-g,t[9]=t[11]=t[13]=t[15]=o*f-g,t[17]=t[19]=t[21]=t[23]=s-a*f-g,t[25]=t[27]=t[29]=t[31]=s-g,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs,e=this._originalWidth,s=this._originalHeight,i=this._trimX/e,n=this._trimY/s,o=(this._trimX+this._trimWidth)/e,a=(this._trimY+this._trimHeight)/s;t[0]=t[8]=t[16]=t[24]=i,t[1]=t[3]=t[5]=t[7]=n,t[6]=t[14]=t[22]=t[30]=o,t[25]=t[27]=t[29]=t[31]=a;const l=1/e,u=1/s;t[2]=t[10]=t[18]=t[26]=i+l*this._leftWidth,t[9]=t[11]=t[13]=t[15]=n+u*this._topHeight,t[4]=t[12]=t[20]=t[28]=o-l*this._rightWidth,t[17]=t[19]=t[21]=t[23]=a-u*this._bottomHeight,this.getBuffer("aUV").update()}};CT.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let qe=CT;class RT extends En{constructor(){super(),this.geometry=new qe}destroy(){this.geometry.destroy()}}class Ic{constructor(t){this._renderer=t,this._managedSprites=new kt({renderer:t,type:"renderable",name:"nineSliceSprite"})}addRenderable(t,e){const s=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,s),this._renderer.renderPipes.batch.addToBatch(s,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 RT,s=e;return s.renderable=t,s.transform=t.groupTransform,s.texture=t._texture,s.roundPixels=this._renderer._roundPixels|t._roundPixels,this._managedSprites.add(t),t.didViewUpdate||this._updateBatchableSprite(t,s),e}destroy(){this._managedSprites.destroy(),this._renderer=null}}Ic.extension={type:[T.WebGLPipes,T.WebGPUPipes],name:"nineSliceSprite"},L.add(Gc),L.add(Ic);var QF=Object.defineProperty,Ao=Object.getOwnPropertySymbols,MT=Object.prototype.hasOwnProperty,OT=Object.prototype.propertyIsEnumerable,GT=(r,t,e)=>t in r?QF(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,JF=(r,t)=>{for(var e in t||(t={}))MT.call(t,e)&>(r,e,t[e]);if(Ao)for(var e of Ao(t))OT.call(t,e)&>(r,e,t[e]);return r},tB=(r,t)=>{var e={};for(var s in r)MT.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Ao)for(var s of Ao(r))t.indexOf(s)<0&&OT.call(r,s)&&(e[s]=r[s]);return e};const IT=class MS extends Se{constructor(t){var e,s,i,n,o,a,l,u,h,c;t instanceof B&&(t={texture:t});const d=t,{width:p,height:f,anchor:m,leftWidth:g,rightWidth:_,topHeight:x,bottomHeight:v,texture:b,roundPixels:S}=d,y=tB(d,["width","height","anchor","leftWidth","rightWidth","topHeight","bottomHeight","texture","roundPixels"]);super(JF({label:"NineSliceSprite"},y)),this.renderPipeId="nineSliceSprite",this.batched=!0,this._leftWidth=(s=g!=null?g:(e=b==null?void 0:b.defaultBorders)==null?void 0:e.left)!=null?s:qe.defaultOptions.leftWidth,this._topHeight=(n=x!=null?x:(i=b==null?void 0:b.defaultBorders)==null?void 0:i.top)!=null?n:qe.defaultOptions.topHeight,this._rightWidth=(a=_!=null?_:(o=b==null?void 0:b.defaultBorders)==null?void 0:o.right)!=null?a:qe.defaultOptions.rightWidth,this._bottomHeight=(u=v!=null?v:(l=b==null?void 0:b.defaultBorders)==null?void 0:l.bottom)!=null?u:qe.defaultOptions.bottomHeight,this._width=(h=p!=null?p:b.width)!=null?h:qe.defaultOptions.width,this._height=(c=f!=null?f:b.height)!=null?c:qe.defaultOptions.height,this.allowChildren=!1,this.texture=b!=null?b:MS.defaultOptions.texture,this.roundPixels=S!=null?S:!1,this._anchor=new gt({_onUpdate:()=>{this.onViewUpdate()}}),m?this.anchor=m: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 s;typeof t=="object"&&(e=(s=t.height)!=null?s: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=B.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}get trim(){var t;return(t=this._texture.trim)!=null?t:null}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,s=this._width,i=this._height;t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*i,t.maxY=t.minY+i}};IT.defaultOptions={texture:B.EMPTY};let FT=IT;class eB extends FT{constructor(...t){let e=t[0];e instanceof B&&(e={texture:e,leftWidth:t[1],topHeight:t[2],rightWidth:t[3],bottomHeight:t[4]}),super(e)}}class BT extends Cu{constructor(t,e){var s;super();const{textures:i,data:n}=t;Object.keys(n.pages).forEach(o=>{const a=n.pages[parseInt(o,10)],l=i[a.id];this.pages.push({texture:l})}),Object.keys(n.chars).forEach(o=>{var a;const l=n.chars[o],{frame:u,source:h,rotate:c}=i[l.page],d=H.transformRectCoords(l,u,c,new it),p=new B({frame:d,orig:new it(0,0,l.width,l.height),source:h,rotate:c});this.chars[o]={id:o.codePointAt(0),xOffset:l.xOffset,yOffset:l.yOffset,xAdvance:l.xAdvance,kerning:(a=l.kerning)!=null?a:{},texture:p}}),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=(s=n.distanceField)!=null?s:{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t0?(y=s.shift(),y.text=v,y.style=i,y.label=`char-${v}`,y.x=f.charPositions[x]*l-f.charPositions[_]*l):y=new Du({text:v,style:i,label:`char-${v}`,x:f.charPositions[x]*l-f.charPositions[_]*l}),b||(u.push(y),g.addChild(y)),(b||S)&&g.children.length>0&&(g.x=f.charPositions[_]*l,h.push(g),m.addChild(g),g=new dt({label:"word"}),_=x+1)}p+=d}return{chars:u,lines:c,words:h}}var $T=Object.getOwnPropertySymbols,sB=Object.prototype.hasOwnProperty,iB=Object.prototype.propertyIsEnumerable,nB=(r,t)=>{var e={};for(var s in r)sB.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&$T)for(var s of $T(r))t.indexOf(s)<0&&iB.call(r,s)&&(e[s]=r[s]);return e};class Fc extends dt{constructor(t){const e=t,{text:s,style:i,autoSplit:n,lineAnchor:o,wordAnchor:a,charAnchor:l}=e,u=nB(e,["text","style","autoSplit","lineAnchor","wordAnchor","charAnchor"]);super(u),this._dirty=!1,this._canReuseChars=!1,this.chars=[],this.words=[],this.lines=[],this._originalText=s,this._autoSplit=n,this._lineAnchor=o,this._wordAnchor=a,this._charAnchor=l,this.style=i}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,s){let i;typeof t=="number"?i={x:t,y:t}:i={x:t.x,y:t.y},e.forEach(n=>{const o=n.getLocalBounds(),a=o.minX+o.width*i.x,l=o.minY+o.height*i.y;n.origin.set(a,l)}),this[s]=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 Xt(t),this.styleChanged()}styleChanged(){this.words.forEach(t=>t.destroy()),this.words.length=0,this.lines.forEach(t=>t.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 oB=Object.defineProperty,aB=Object.defineProperties,lB=Object.getOwnPropertyDescriptors,UT=Object.getOwnPropertySymbols,uB=Object.prototype.hasOwnProperty,hB=Object.prototype.propertyIsEnumerable,kT=(r,t,e)=>t in r?oB(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,oi=(r,t)=>{for(var e in t||(t={}))uB.call(t,e)&&kT(r,e,t[e]);if(UT)for(var e of UT(t))hB.call(t,e)&&kT(r,e,t[e]);return r},cB=(r,t)=>aB(r,lB(t));const LT=class Oo extends Fc{constructor(t){var e,s,i;const n=oi(oi({},Oo.defaultOptions),t);(e=n.style)!=null||(n.style={}),(i=(s=n.style).fill)!=null||(s.fill=16777215),super(n)}static from(t,e){const s=cB(oi(oi({},Oo.defaultOptions),e),{text:t.text,style:new Xt(t.style)});t.style.tagStyles&&(t.style._tagStyles=void 0);const i=new Oo(oi({},s)),n=t.anchor;return(n.x!==0||n.y!==0)&&i.pivot.set(i.width*n.x,i.height*n.y),i}splitFn(){return DT({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};LT.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let dB=LT;function NT(r,t,e){switch(r){case"center":return(e-t)/2;case"right":return e-t;default:return 0}}function Bc(r){return r==="\r"||r===` `||r===`\r `}const pB=/^\s*$/;function fB(r,t){const e=[];let s=t.lines[0],i="",n=[],o=0;return r.forEach(a=>{const l=pB.test(a),u=Bc(a),h=i.length===0&&l;l&&!u&&h&&(!s||!s.startsWith(a))||(u||(i+=a),n.push(a),i.length>=s.length&&(e.push({line:i,chars:n}),n=[],i="",o++,s=t.lines[o]))}),e}function jT(r){var t,e;const{text:s,style:i,chars:n}=r,o=i,a=vt.measureText(s,o);if(a.runsByLine&&a.runsByLine.length>0)return mB(a,o,n,s);const l=vt.graphemeSegmenter(s),u=fB(l,a),h=o.align,c=a.lineWidths.reduce((F,R)=>Math.max(F,R),0),d=(t=o._fill)==null?void 0:t.fill,p=(e=o._stroke)==null?void 0:e.fill,f=d instanceof Lt,m=p instanceof Lt,g=f||m,_=f&&d.textureSpace==="local"||m&&p.textureSpace==="local",x=a.width,v=a.height,b=o.clone();b.align="left";let S=0,y=0;if(b.trim){const{frame:F,canvasAndContext:R}=me.getCanvasAndContext({text:s,style:o,resolution:1});me.returnCanvasAndContext(R),S=-F.x,y=-F.y,b.trim=!1}const w=[],E=[],A=[];let P=0,C=0;const O=_?{width:x,height:v}:null;return u.forEach((F,R)=>{const G=new dt({label:`line-${R}`});G.y=P+y,E.push(G);const M=a.lineWidths[R];let I=NT(h,M,c),U=new dt({label:"word"});U.x=I+S;const j=vt._context;j.font=b._fontString,vt.experimentalLetterSpacingSupported&&(j.letterSpacing="0px",j.textLetterSpacing="0px");let Q=F.line,K=j.measureText(Q).width;if(F.chars.forEach(N=>{if(Bc(N))return;Q=Q.slice(N.length);const k=Q.length>0?j.measureText(Q).width:0,$=K-k;if(K=k,$!==0)if(N===" ")U.children.length>0&&(A.push(U),G.addChild(U)),I+=$+o.letterSpacing,U=new dt({label:"word"}),U.x=I+S;else{let z=b;g&&(z=b.clone(),z._gradientOffset={x:-I,y:-P},O&&(z._gradientBounds=O));let et;C0&&(A.push(U),G.addChild(U)),h==="justify"&&o.wordWrap&&R0){const $=(c-M)/k;for(let z=1;zMath.max(f,m),0);let a=0,l=0;if(t.trim){const{frame:f,canvasAndContext:m}=me.getCanvasAndContext({text:s,style:t,resolution:1});me.returnCanvasAndContext(m),a=-f.x,l=-f.y}const u=[],h=[],c=[];let d=0,p=0;return i.forEach((f,m)=>{var g,_,x,v;const b=new dt({label:`line-${m}`});b.y=d+l,h.push(b);const S=r.lineWidths[m];let y=NT(n,S,o),w=new dt({label:"word"});w.x=y+a;for(const A of f){const P=A.style,C=(g=P._fill)==null?void 0:g.fill,O=(_=P._stroke)==null?void 0:_.fill,F=C instanceof Lt,R=O instanceof Lt,G=F||R,M=F&&C.textureSpace==="local"||R&&O.textureSpace==="local",I=vt.graphemeSegmenter(A.text),U=P.clone();U.align="left",U.wordWrap=!1,U.trim&&(U.trim=!1),U.tagStyles=void 0,U._lineHeight=0;const j=vt._context;j.font=U._fontString,vt.experimentalLetterSpacingSupported&&(j.letterSpacing="0px",j.textLetterSpacing="0px");let Q=A.text,K=j.measureText(Q).width;const N=y,k=K,$=vt.measureFont(U._fontString),z=P.lineHeight||$.fontSize,et=M?{width:k,height:z}:null;for(const mt of I){Q=Q.slice(mt.length);const J=Q.length>0?j.measureText(Q).width:0,ot=K-J;if(K=J,!Bc(mt)&&ot!==0)if(mt===" ")w.children.length>0&&(c.push(w),b.addChild(w)),y+=ot+P.letterSpacing,w=new dt({label:"word"}),w.x=y+a;else{let nt=U;G&&(nt=U.clone(),M?(nt._gradientOffset={x:-(y-N),y:0},nt._gradientBounds=et):nt._gradientOffset={x:-(y-N),y:0});let ht;p0&&(c.push(w),b.addChild(w)),n==="justify"&&t.wordWrap&&m0){const C=(o-S)/P;for(let O=1;Ot in r?gB(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ai=(r,t)=>{for(var e in t||(t={}))vB.call(t,e)&&HT(r,e,t[e]);if(XT)for(var e of XT(t))bB.call(t,e)&&HT(r,e,t[e]);return r},yB=(r,t)=>_B(r,xB(t));const zT=class Go extends Fc{constructor(t){const e=ai(ai({},Go.defaultOptions),t);super(e)}static from(t,e){const s=yB(ai(ai({},Go.defaultOptions),e),{text:t.text,style:new Xt(t.style)}),i=new Go(ai({},s)),n=t.anchor;return(n.x!==0||n.y!==0)&&i.pivot.set(i.width*n.x,i.height*n.y),i}splitFn(){return jT({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};zT.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let TB=zT;const WT=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function SB(r){const t=[];let e=0;for(let s=0;st in r?CB(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qT=(r,t)=>{for(var e in t||(t={}))OB.call(t,e)&&KT(r,e,t[e]);if(YT)for(var e of YT(t))GB.call(t,e)&&KT(r,e,t[e]);return r},IB=(r,t)=>RB(r,MB(t));const FB=["#000080","#228B22","#8B0000","#4169E1","#008080","#800000","#9400D3","#FF8C00","#556B2F","#8B008B"];let BB=0;function ZT(r,t=0,e={color:"#000000"}){r.renderGroup&&(e.color=FB[BB++]);let s="";for(let o=0;o